From 6319110ce33faa76ee6cf9832e78faa224510fed Mon Sep 17 00:00:00 2001 From: hansonr Date: Fri, 24 Jul 2015 10:33:04 +0100 Subject: [PATCH] JAL-1807 still testing --- bin/MCview/Atom.js | 110 +- bin/MCview/Bond.js | 68 +- bin/MCview/PDBChain.js | 572 +- bin/MCview/PDBfile.js | 640 +- bin/MCview/Residue.js | 42 +- bin/awt2swing/Button.js | 8 +- bin/awt2swing/Canvas.js | 8 +- bin/awt2swing/Checkbox.js | 24 +- bin/awt2swing/CheckboxMenuItem.js | 32 +- bin/awt2swing/Choice.js | 16 +- bin/awt2swing/Frame.js | 42 +- bin/awt2swing/Label.js | 16 +- bin/awt2swing/Menu.js | 28 +- bin/awt2swing/MenuBar.js | 8 +- bin/awt2swing/MenuItem.js | 8 +- bin/awt2swing/Panel.js | 18 +- bin/awt2swing/PopupMenu.js | 8 +- bin/awt2swing/ScrollPane.js | 8 +- bin/awt2swing/Scrollbar.js | 8 +- bin/awt2swing/TextArea.js | 8 +- bin/awt2swing/TextField.js | 46 +- bin/com/stevesoft/pat/AmpersandRule.js | 32 +- bin/com/stevesoft/pat/Any.js | 60 +- bin/com/stevesoft/pat/BackG.js | 68 +- bin/com/stevesoft/pat/BackMatch.js | 72 +- bin/com/stevesoft/pat/BackRefRule.js | 50 +- bin/com/stevesoft/pat/Backup.js | 68 +- bin/com/stevesoft/pat/BasicStringBufferLike.js | 4 +- bin/com/stevesoft/pat/Bits.js | 5916 ++++++------- bin/com/stevesoft/pat/Boundary.js | 104 +- bin/com/stevesoft/pat/Bracket.js | 120 +- bin/com/stevesoft/pat/CaseMgr.js | 188 +- bin/com/stevesoft/pat/ChangeRule.js | 70 +- bin/com/stevesoft/pat/CodeRule.js | 48 +- bin/com/stevesoft/pat/Ctrl.js | 8 +- bin/com/stevesoft/pat/Custom.js | 82 +- bin/com/stevesoft/pat/CustomEndpoint.js | 54 +- bin/com/stevesoft/pat/DirFileRegex.js | 8 +- bin/com/stevesoft/pat/DotMulti.js | 258 +- bin/com/stevesoft/pat/End.js | 76 +- bin/com/stevesoft/pat/FastBracket.js | 312 +- bin/com/stevesoft/pat/FastMulti.js | 216 +- bin/com/stevesoft/pat/FileRegex.js | 8 +- bin/com/stevesoft/pat/Group.js | 96 +- bin/com/stevesoft/pat/LeftRule.js | 32 +- bin/com/stevesoft/pat/MessageManager.js | 24 +- bin/com/stevesoft/pat/Multi.js | 124 +- bin/com/stevesoft/pat/MultiMin.js | 18 +- bin/com/stevesoft/pat/Multi_stage2.js | 190 +- bin/com/stevesoft/pat/NoPattern.js | 32 +- bin/com/stevesoft/pat/NonDirFileRegex.js | 8 +- bin/com/stevesoft/pat/NotImplementedError.js | 8 +- bin/com/stevesoft/pat/NullPattern.js | 40 +- bin/com/stevesoft/pat/NullRule.js | 30 +- bin/com/stevesoft/pat/Or.js | 184 +- bin/com/stevesoft/pat/OrMark.js | 108 +- bin/com/stevesoft/pat/PartialBuffer.js | 100 +- bin/com/stevesoft/pat/Pattern.js | 306 +- bin/com/stevesoft/pat/PatternSub.js | 14 +- bin/com/stevesoft/pat/PopRule.js | 24 +- bin/com/stevesoft/pat/Prop.js | 80 +- bin/com/stevesoft/pat/Pthings.js | 26 +- bin/com/stevesoft/pat/PushRule.js | 70 +- bin/com/stevesoft/pat/RBuffer.js | 64 +- bin/com/stevesoft/pat/Range.js | 130 +- bin/com/stevesoft/pat/RegOpt.js | 508 +- bin/com/stevesoft/pat/RegRes.js | 310 +- bin/com/stevesoft/pat/RegSyntax.js | 16 +- bin/com/stevesoft/pat/RegSyntaxError.js | 32 +- bin/com/stevesoft/pat/Regex.js | 2052 ++--- bin/com/stevesoft/pat/RegexReader.js | 328 +- bin/com/stevesoft/pat/RegexTokenizer.js | 208 +- bin/com/stevesoft/pat/RegexWriter.js | 268 +- bin/com/stevesoft/pat/ReplaceRule.js | 406 +- bin/com/stevesoft/pat/Replacer.js | 460 +- bin/com/stevesoft/pat/RightRule.js | 32 +- bin/com/stevesoft/pat/Rthings.js | 70 +- bin/com/stevesoft/pat/RuleHolder.js | 64 +- bin/com/stevesoft/pat/Skip.js | 216 +- bin/com/stevesoft/pat/Skip2.js | 62 +- bin/com/stevesoft/pat/SkipBMH.js | 308 +- bin/com/stevesoft/pat/Skipped.js | 68 +- bin/com/stevesoft/pat/SpecialRule.js | 22 +- bin/com/stevesoft/pat/Start.js | 70 +- bin/com/stevesoft/pat/StrPos.js | 218 +- bin/com/stevesoft/pat/StringBufferLike.js | 124 +- bin/com/stevesoft/pat/StringLike.js | 4 +- bin/com/stevesoft/pat/StringRule.js | 48 +- bin/com/stevesoft/pat/SubMark.js | 42 +- bin/com/stevesoft/pat/TransPat.js | 70 +- bin/com/stevesoft/pat/Transformer.js | 260 +- bin/com/stevesoft/pat/UniValidator.js | 24 +- bin/com/stevesoft/pat/Util.js | 4 +- bin/com/stevesoft/pat/Validator.js | 48 +- bin/com/stevesoft/pat/WantMoreTextReplaceRule.js | 30 +- bin/com/stevesoft/pat/lookAhead.js | 124 +- bin/com/stevesoft/pat/oneChar.js | 110 +- bin/com/stevesoft/pat/package.js | 68 +- bin/com/stevesoft/pat/parsePerl.js | 534 +- bin/com/stevesoft/pat/patInf.js | 18 +- bin/com/stevesoft/pat/patInt.js | 188 +- bin/com/stevesoft/pat/wrap/CharArrayBufferWrap.js | 76 +- bin/com/stevesoft/pat/wrap/CharArrayWrap.js | 102 +- bin/com/stevesoft/pat/wrap/RandomAccessFileWrap.js | 4 +- bin/com/stevesoft/pat/wrap/StringBufferWrap.js | 68 +- bin/com/stevesoft/pat/wrap/StringWrap.js | 78 +- bin/com/stevesoft/pat/wrap/WriterWrap.js | 82 +- bin/fr/orsay/lri/varna/models/rna/RNA.js | 20 +- bin/jalview/analysis/AAFrequency.js | 616 +- bin/jalview/analysis/AlignSeq.js | 1172 +-- bin/jalview/analysis/AlignmentAnnotationUtils.js | 146 +- bin/jalview/analysis/AlignmentSorter.js | 766 +- bin/jalview/analysis/AlignmentUtils.js | 1064 +-- bin/jalview/analysis/AnnotationSorter.js | 342 +- bin/jalview/analysis/CodingUtils.js | 128 +- bin/jalview/analysis/CodonComparator.js | 42 +- bin/jalview/analysis/Conservation.js | 740 +- bin/jalview/analysis/Dna.js | 654 +- bin/jalview/analysis/Finder.js | 364 +- bin/jalview/analysis/Grouping.js | 176 +- bin/jalview/analysis/NJTree.js | 1154 +-- bin/jalview/analysis/PCA.js | 326 +- bin/jalview/analysis/ParseProperties.js | 150 +- bin/jalview/analysis/Rna.js | 212 +- bin/jalview/analysis/SecStrConsensus.js | 278 +- bin/jalview/analysis/SeqsetUtils.js | 248 +- bin/jalview/analysis/SequenceIdMatcher.js | 334 +- bin/jalview/analysis/StructureFrequency.js | 520 +- bin/jalview/analysis/WUSSParseException.js | 40 +- bin/jalview/analysis/package.js | 10 +- .../analysis/scoremodels/FeatureScoreModel.js | 172 +- bin/jalview/analysis/scoremodels/PIDScoreModel.js | 64 +- .../analysis/scoremodels/PairwiseSeqScoreModel.js | 78 +- bin/jalview/analysis/scoremodels/SWScoreModel.js | 90 +- bin/jalview/api/AlignCalcManagerI.js | 4 +- bin/jalview/api/AlignCalcWorkerI.js | 4 +- bin/jalview/api/AlignExportSettingI.js | 4 +- bin/jalview/api/AlignViewControllerGuiI.js | 4 +- bin/jalview/api/AlignViewControllerI.js | 4 +- bin/jalview/api/AlignViewportI.js | 8 +- bin/jalview/api/AlignmentViewPanel.js | 8 +- bin/jalview/api/ComplexAlignFile.js | 4 +- bin/jalview/api/FeatureRenderer.js | 4 +- bin/jalview/api/FeatureSettingsControllerI.js | 4 +- bin/jalview/api/FeatureSettingsModelI.js | 4 +- bin/jalview/api/FeaturesDisplayedI.js | 4 +- bin/jalview/api/OOMHandlerI.js | 4 +- bin/jalview/api/RotatableCanvasI.js | 4 +- bin/jalview/api/SequenceRenderer.js | 4 +- bin/jalview/api/SequenceStructureBinding.js | 4 +- bin/jalview/api/SplitContainerI.js | 4 +- .../api/StructureSelectionManagerProvider.js | 4 +- bin/jalview/api/ViewStyleI.js | 4 +- bin/jalview/api/analysis/ScoreModelI.js | 4 +- bin/jalview/api/analysis/ViewBasedAnalysisI.js | 4 +- .../api/structures/JalviewStructureDisplayI.js | 4 +- bin/jalview/appletgui/APopupMenu.js | 1594 ++-- bin/jalview/appletgui/AlignFrame.js | 4780 +++++------ bin/jalview/appletgui/AlignViewport.js | 458 +- bin/jalview/appletgui/AlignmentPanel.js | 1220 +-- bin/jalview/appletgui/AnnotationColourChooser.js | 696 +- bin/jalview/appletgui/AnnotationColumnChooser.js | 1244 +-- bin/jalview/appletgui/AnnotationLabels.js | 932 +-- bin/jalview/appletgui/AnnotationPanel.js | 728 +- bin/jalview/appletgui/AnnotationRowFilter.js | 262 +- bin/jalview/appletgui/AppletJmol.js | 96 +- bin/jalview/appletgui/AppletJmolBinding.js | 4 +- bin/jalview/appletgui/CutAndPasteTransfer.js | 528 +- bin/jalview/appletgui/EditNameDialog.js | 88 +- bin/jalview/appletgui/EmbmenuFrame.js | 220 +- bin/jalview/appletgui/ExtJmol.js | 34 +- bin/jalview/appletgui/FeatureColourChooser.js | 584 +- bin/jalview/appletgui/FeatureRenderer.js | 544 +- bin/jalview/appletgui/FeatureSettings.js | 888 +- bin/jalview/appletgui/Finder.js | 368 +- bin/jalview/appletgui/FontChooser.js | 518 +- bin/jalview/appletgui/IdCanvas.js | 382 +- bin/jalview/appletgui/IdPanel.js | 570 +- bin/jalview/appletgui/IdwidthAdjuster.js | 132 +- bin/jalview/appletgui/JVDialog.js | 80 +- bin/jalview/appletgui/OverviewPanel.js | 524 +- bin/jalview/appletgui/PCAPanel.js | 506 +- bin/jalview/appletgui/PaintRefresher.js | 252 +- bin/jalview/appletgui/PairwiseAlignPanel.js | 200 +- bin/jalview/appletgui/RedundancyPanel.js | 330 +- bin/jalview/appletgui/RotatableCanvas.js | 742 +- bin/jalview/appletgui/ScalePanel.js | 496 +- bin/jalview/appletgui/SeqCanvas.js | 822 +- bin/jalview/appletgui/SeqPanel.js | 1924 ++--- bin/jalview/appletgui/SequenceRenderer.js | 392 +- bin/jalview/appletgui/SliderPanel.js | 540 +- bin/jalview/appletgui/SplitFrame.js | 216 +- bin/jalview/appletgui/TitledPanel.js | 86 +- bin/jalview/appletgui/Tooltip.js | 134 +- bin/jalview/appletgui/TreeCanvas.js | 750 +- bin/jalview/appletgui/TreePanel.js | 522 +- bin/jalview/appletgui/UserDefinedColours.js | 962 +-- bin/jalview/bin/Cache.js | 58 +- bin/jalview/bin/JalviewLite.js | 3234 +++---- bin/jalview/commands/ChangeCaseCommand.js | 148 +- bin/jalview/commands/CommandI.js | 4 +- bin/jalview/commands/EditCommand.js | 1322 +-- bin/jalview/commands/OrderCommand.js | 76 +- bin/jalview/commands/RemoveGapColCommand.js | 90 +- bin/jalview/commands/RemoveGapsCommand.js | 112 +- bin/jalview/commands/SlideSequencesCommand.js | 96 +- bin/jalview/commands/TrimRegionCommand.js | 182 +- bin/jalview/controller/AlignViewController.js | 438 +- .../controller/FeatureSettingsController.js | 14 +- .../controller/FeatureSettingsControllerGuiI.js | 4 +- bin/jalview/datamodel/ASequence.js | 8 +- bin/jalview/datamodel/ASequenceI.js | 4 +- bin/jalview/datamodel/AlignedCodon.js | 84 +- bin/jalview/datamodel/AlignedCodonFrame.js | 396 +- bin/jalview/datamodel/Alignment.js | 1630 ++-- bin/jalview/datamodel/AlignmentAnnotation.js | 1246 +-- bin/jalview/datamodel/AlignmentI.js | 8 +- bin/jalview/datamodel/AlignmentOrder.js | 236 +- bin/jalview/datamodel/AlignmentView.js | 1250 +-- bin/jalview/datamodel/AnnotatedCollectionI.js | 8 +- bin/jalview/datamodel/Annotation.js | 144 +- bin/jalview/datamodel/BinaryNode.js | 224 +- bin/jalview/datamodel/BinarySequence.js | 198 +- bin/jalview/datamodel/CigarArray.js | 376 +- bin/jalview/datamodel/CigarBase.js | 620 +- bin/jalview/datamodel/CigarCigar.js | 44 +- bin/jalview/datamodel/CigarSimple.js | 8 +- bin/jalview/datamodel/ColumnSelection.js | 1364 +-- bin/jalview/datamodel/DBRefEntry.js | 186 +- bin/jalview/datamodel/DBRefSource.js | 58 +- bin/jalview/datamodel/FeatureProperties.js | 40 +- bin/jalview/datamodel/GraphLine.js | 72 +- bin/jalview/datamodel/HiddenSequences.js | 324 +- bin/jalview/datamodel/IncompleteCodonException.js | 8 +- bin/jalview/datamodel/Mapping.js | 608 +- bin/jalview/datamodel/NodeTransformI.js | 4 +- bin/jalview/datamodel/PDBEntry.js | 176 +- bin/jalview/datamodel/Provenance.js | 50 +- bin/jalview/datamodel/ProvenanceEntry.js | 62 +- bin/jalview/datamodel/RnaViewerModel.js | 42 +- bin/jalview/datamodel/SearchResults.js | 274 +- .../datamodel/SecondaryStructureAnnotation.js | 46 +- bin/jalview/datamodel/SeqCigar.js | 518 +- bin/jalview/datamodel/Sequence.js | 1316 +-- bin/jalview/datamodel/SequenceCollectionI.js | 4 +- bin/jalview/datamodel/SequenceDummy.js | 40 +- bin/jalview/datamodel/SequenceFeature.js | 340 +- bin/jalview/datamodel/SequenceGroup.js | 1202 +-- bin/jalview/datamodel/SequenceI.js | 8 +- bin/jalview/datamodel/SequenceNode.js | 128 +- bin/jalview/datamodel/SequencePoint.js | 24 +- bin/jalview/datamodel/StructureViewerModel.js | 312 +- bin/jalview/datamodel/UniprotEntry.js | 116 +- bin/jalview/datamodel/UniprotFile.js | 26 +- bin/jalview/datamodel/UniprotProteinName.js | 26 +- bin/jalview/datamodel/UniprotSequence.js | 42 +- bin/jalview/ext/jmol/JmolCommands.js | 138 +- bin/jalview/ext/varna/JalviewVarnaBinding.js | 8 +- bin/jalview/ext/varna/RnaModel.js | 34 +- bin/jalview/ext/varna/VarnaCommands.js | 132 +- bin/jalview/io/AlignFile.js | 316 +- bin/jalview/io/AlignmentProperties.js | 156 +- bin/jalview/io/AnnotationFile.js | 2006 ++--- bin/jalview/io/AppletFormatAdapter.js | 778 +- bin/jalview/io/FastaFile.js | 188 +- bin/jalview/io/FeaturesFile.js | 1544 ++-- bin/jalview/io/FileParse.js | 500 +- bin/jalview/io/IdentifyFile.js | 314 +- bin/jalview/io/JPredFile.js | 370 +- bin/jalview/io/JnetAnnotationMaker.js | 180 +- bin/jalview/io/MSFfile.js | 380 +- bin/jalview/io/ModellerDescription.js | 472 +- bin/jalview/io/NewickFile.js | 816 +- bin/jalview/io/PIRFile.js | 202 +- bin/jalview/io/PfamFile.js | 152 +- bin/jalview/io/PhylipFile.js | 206 +- bin/jalview/io/PileUpfile.js | 164 +- bin/jalview/io/SequenceAnnotationReport.js | 362 +- bin/jalview/io/TCoffeeScoreFile.js | 548 +- bin/jalview/javascript/JSFunctionExec.js | 332 +- bin/jalview/javascript/JalviewLiteJsApi.js | 4 +- bin/jalview/javascript/JsCallBack.js | 4 +- bin/jalview/javascript/JsSelectionSender.js | 140 +- bin/jalview/javascript/MouseOverListener.js | 92 +- .../javascript/MouseOverStructureListener.js | 286 +- bin/jalview/jsdev/Constants.js | 26 +- bin/jalview/jsdev/GenericFileAdapter.js | 170 +- bin/jalview/jsdev/JSRegex.js | 110 +- bin/jalview/jsdev/JavaScriptRegExp.js | 4 +- bin/jalview/jsdev/RegExp.js | 30 +- bin/jalview/jsdev/api/RegExpInterface.js | 4 +- bin/jalview/jsdev/api/VarnaRNA.js | 4 +- bin/jalview/math/AlignmentDimension.js | 54 +- bin/jalview/math/Matrix.js | 846 +- bin/jalview/math/RotatableMatrix.js | 228 +- bin/jalview/renderer/AnnotationRenderer.js | 1610 ++-- bin/jalview/renderer/AwtRenderPanelI.js | 8 +- .../renderer/seqfeatures/FeatureRenderer.js | 374 +- bin/jalview/schemes/AnnotationColourGradient.js | 400 +- bin/jalview/schemes/Blosum62ColourScheme.js | 74 +- bin/jalview/schemes/BuriedColourScheme.js | 24 +- bin/jalview/schemes/ClustalxColourScheme.js | 474 +- bin/jalview/schemes/ColourSchemeI.js | 4 +- bin/jalview/schemes/ColourSchemeProperty.js | 584 +- bin/jalview/schemes/Consensus.js | 90 +- bin/jalview/schemes/CovariationColourScheme.js | 82 +- bin/jalview/schemes/FollowerColourScheme.js | 52 +- bin/jalview/schemes/GraduatedColor.js | 320 +- bin/jalview/schemes/HelixColourScheme.js | 24 +- bin/jalview/schemes/HydrophobicColourScheme.js | 24 +- bin/jalview/schemes/NucleotideColourScheme.js | 62 +- bin/jalview/schemes/PIDColourScheme.js | 78 +- .../schemes/PurinePyrimidineColourScheme.js | 62 +- bin/jalview/schemes/RNAHelicesColour.js | 136 +- bin/jalview/schemes/RNAHelicesColourChooser.js | 126 +- bin/jalview/schemes/RNAInteractionColourScheme.js | 54 +- bin/jalview/schemes/ResidueColourScheme.js | 292 +- bin/jalview/schemes/ResidueProperties.js | 2180 ++--- bin/jalview/schemes/ScoreColourScheme.js | 86 +- bin/jalview/schemes/ScoreMatrix.js | 172 +- bin/jalview/schemes/StrandColourScheme.js | 24 +- bin/jalview/schemes/TCoffeeColourScheme.js | 90 +- bin/jalview/schemes/TaylorColourScheme.js | 16 +- bin/jalview/schemes/TurnColourScheme.js | 24 +- bin/jalview/schemes/UserColourScheme.js | 330 +- bin/jalview/schemes/ZappoColourScheme.js | 16 +- bin/jalview/schemes/package.js | 10 +- .../structure/AlignmentViewPanelListener.js | 4 +- bin/jalview/structure/AtomSpec.js | 70 +- bin/jalview/structure/CommandListener.js | 4 +- .../structure/SecondaryStructureListener.js | 4 +- bin/jalview/structure/SelectionListener.js | 4 +- bin/jalview/structure/SelectionSource.js | 4 +- bin/jalview/structure/SequenceListener.js | 4 +- bin/jalview/structure/StructureListener.js | 4 +- bin/jalview/structure/StructureMapping.js | 138 +- .../structure/StructureMappingcommandSet.js | 26 +- bin/jalview/structure/StructureSelectionManager.js | 1022 +-- bin/jalview/structure/VamsasListener.js | 4 +- bin/jalview/structure/VamsasSource.js | 4 +- .../structures/models/AAStructureBindingModel.js | 612 +- .../models/SequenceStructureBindingModel.js | 48 +- bin/jalview/util/ColorUtils.js | 60 +- bin/jalview/util/Comparison.js | 262 +- bin/jalview/util/DBRefUtils.js | 368 +- bin/jalview/util/Format.js | 778 +- bin/jalview/util/GroupUrlLink.js | 726 +- bin/jalview/util/MapList.js | 818 +- bin/jalview/util/MappingUtils.js | 490 +- bin/jalview/util/MessageManager.js | 146 +- bin/jalview/util/ParseHtmlBodyAndLinks.js | 156 +- bin/jalview/util/Platform.js | 60 +- bin/jalview/util/QuickSort.js | 462 +- bin/jalview/util/ReverseListIterator.js | 46 +- bin/jalview/util/ShiftList.js | 134 +- bin/jalview/util/StringUtils.js | 216 +- bin/jalview/util/TableSorter.js | 774 +- bin/jalview/util/UrlLink.js | 296 +- bin/jalview/viewmodel/AlignmentViewport.js | 2508 +++--- bin/jalview/viewmodel/PCAModel.js | 268 +- .../annotationfilter/AnnotationFilterParameter.js | 166 +- .../viewmodel/seqfeatures/FeatureRendererModel.js | 962 +-- .../seqfeatures/FeatureRendererSettings.js | 86 +- .../viewmodel/seqfeatures/FeatureSettingsModel.js | 8 +- .../viewmodel/seqfeatures/FeaturesDisplayed.js | 136 +- bin/jalview/viewmodel/styles/ViewStyle.js | 914 +- bin/jalview/workers/AlignCalcManager.js | 384 +- bin/jalview/workers/AlignCalcWorker.js | 108 +- bin/jalview/workers/ComplementConsensusThread.js | 92 +- bin/jalview/workers/ConsensusThread.js | 298 +- bin/jalview/workers/ConservationThread.js | 216 +- bin/jalview/workers/StrucConsensusThread.js | 190 +- bin/javajs/J2SIgnoreImport.js | 2 +- bin/javajs/J2SRequireImport.js | 2 +- bin/javajs/api/BytePoster.js | 4 +- bin/javajs/api/EigenInterface.js | 4 +- bin/javajs/api/EventManager.js | 4 +- bin/javajs/api/FontManager.js | 4 +- bin/javajs/api/GenericBinaryDocument.js | 4 +- bin/javajs/api/GenericCifDataParser.js | 8 +- bin/javajs/api/GenericColor.js | 4 +- bin/javajs/api/GenericFileInterface.js | 4 +- bin/javajs/api/GenericImageDialog.js | 4 +- bin/javajs/api/GenericImageEncoder.js | 4 +- bin/javajs/api/GenericLineReader.js | 4 +- bin/javajs/api/GenericMenuInterface.js | 4 +- bin/javajs/api/GenericMouseInterface.js | 4 +- bin/javajs/api/GenericPlatform.js | 22 +- bin/javajs/api/GenericZipInputStream.js | 8 +- bin/javajs/api/GenericZipTools.js | 4 +- bin/javajs/api/HTMLElement.js | 4 +- bin/javajs/api/HTMLWindowEvent.js | 4 +- bin/javajs/api/Interface.js | 32 +- bin/javajs/api/JSInterface.js | 4 +- bin/javajs/api/JSONEncodable.js | 4 +- bin/javajs/api/JmolObjectInterface.js | 4 +- bin/javajs/api/PlatformViewer.js | 4 +- bin/javajs/api/SC.js | 4 +- bin/javajs/api/SwingController.js | 4 +- bin/javajs/api/ZInputStream.js | 4 +- bin/javajs/awt/BorderLayout.js | 20 +- bin/javajs/awt/Color.js | 86 +- bin/javajs/awt/Component.js | 240 +- bin/javajs/awt/Container.js | 130 +- bin/javajs/awt/Dimension.js | 32 +- bin/javajs/awt/Font.js | 210 +- bin/javajs/awt/LayoutManager.js | 4 +- bin/javajs/awt/event/ActionEvent.js | 22 +- bin/javajs/awt/event/ActionListener.js | 4 +- bin/javajs/awt/event/Event.js | 98 +- bin/javajs/awt/event/ItemEvent.js | 8 +- bin/javajs/awt/event/WindowEvent.js | 8 +- bin/javajs/awt/event/WindowListener.js | 4 +- bin/javajs/export/PDFCreator.js | 600 +- bin/javajs/export/PDFObject.js | 230 +- bin/javajs/img/BMPDecoder.js | 288 +- bin/javajs/img/CRCEncoder.js | 148 +- bin/javajs/img/GifEncoder.js | 1254 +-- bin/javajs/img/ImageEncoder.js | 82 +- bin/javajs/img/Jpg64Encoder.js | 46 +- bin/javajs/img/JpgEncoder.js | 1506 ++-- bin/javajs/img/PdfEncoder.js | 116 +- bin/javajs/img/PngEncoder.js | 346 +- bin/javajs/img/PpmEncoder.js | 46 +- bin/javajs/img/package.js | 14 +- bin/javajs/swing/AbstractButton.js | 164 +- bin/javajs/swing/AbstractTableModel.js | 8 +- bin/javajs/swing/ButtonGroup.js | 30 +- bin/javajs/swing/Cell.js | 42 +- bin/javajs/swing/ColumnSelectionModel.js | 4 +- bin/javajs/swing/Document.js | 4 +- bin/javajs/swing/FlowLayout.js | 8 +- bin/javajs/swing/Grid.js | 92 +- bin/javajs/swing/GridBagConstraints.js | 82 +- bin/javajs/swing/GridBagLayout.js | 8 +- bin/javajs/swing/Insets.js | 30 +- bin/javajs/swing/JButton.js | 28 +- bin/javajs/swing/JCheckBox.js | 26 +- bin/javajs/swing/JCheckBoxMenuItem.js | 16 +- bin/javajs/swing/JComboBox.js | 72 +- bin/javajs/swing/JComponent.js | 50 +- bin/javajs/swing/JComponentImp.js | 16 +- bin/javajs/swing/JContentPane.js | 34 +- bin/javajs/swing/JDialog.js | 164 +- bin/javajs/swing/JEditorPane.js | 30 +- bin/javajs/swing/JLabel.js | 34 +- bin/javajs/swing/JMenu.js | 48 +- bin/javajs/swing/JMenuItem.js | 72 +- bin/javajs/swing/JPanel.js | 78 +- bin/javajs/swing/JPopupMenu.js | 74 +- bin/javajs/swing/JRadioButtonMenuItem.js | 22 +- bin/javajs/swing/JScrollPane.js | 44 +- bin/javajs/swing/JSplitPane.js | 134 +- bin/javajs/swing/JTable.js | 134 +- bin/javajs/swing/JTextField.js | 30 +- bin/javajs/swing/JTextPane.js | 48 +- bin/javajs/swing/ListSelectionModel.js | 4 +- bin/javajs/swing/SwingConstants.js | 12 +- bin/javajs/swing/TableCellRenderer.js | 4 +- bin/javajs/swing/TableColumn.js | 4 +- bin/javajs/util/A4.js | 178 +- bin/javajs/util/AU.js | 702 +- bin/javajs/util/AjaxURLConnection.js | 78 +- bin/javajs/util/AjaxURLStreamHandler.js | 68 +- bin/javajs/util/AjaxURLStreamHandlerFactory.js | 32 +- bin/javajs/util/ArrayDataReader.js | 62 +- bin/javajs/util/BArray.js | 54 +- bin/javajs/util/BC.js | 130 +- bin/javajs/util/BS.js | 714 +- bin/javajs/util/Base64.js | 108 +- bin/javajs/util/BinaryDocument.js | 436 +- bin/javajs/util/CU.js | 270 +- bin/javajs/util/CifDataParser.js | 606 +- bin/javajs/util/CompoundDocDirEntry.js | 116 +- bin/javajs/util/CompoundDocHeader.js | 132 +- bin/javajs/util/CompoundDocument.js | 572 +- bin/javajs/util/DF.js | 156 +- bin/javajs/util/DataReader.js | 68 +- bin/javajs/util/Eigen.js | 508 +- bin/javajs/util/Encoding.js | 20 +- bin/javajs/util/LimitedLineReader.js | 66 +- bin/javajs/util/ListDataReader.js | 62 +- bin/javajs/util/Lst.js | 28 +- bin/javajs/util/M3.js | 596 +- bin/javajs/util/M34.js | 672 +- bin/javajs/util/M4.js | 972 +-- bin/javajs/util/Matrix.js | 446 +- bin/javajs/util/Measure.js | 788 +- bin/javajs/util/OC.js | 472 +- bin/javajs/util/P3.js | 52 +- bin/javajs/util/P3i.js | 24 +- bin/javajs/util/P4.js | 48 +- bin/javajs/util/PT.js | 1890 ++--- bin/javajs/util/Quat.js | 854 +- bin/javajs/util/Rdr.js | 622 +- bin/javajs/util/SB.js | 302 +- bin/javajs/util/StringDataReader.js | 24 +- bin/javajs/util/T3.js | 282 +- bin/javajs/util/T3d.js | 174 +- bin/javajs/util/T3i.js | 96 +- bin/javajs/util/T4.js | 74 +- bin/javajs/util/V3.js | 62 +- bin/javajs/util/V3d.js | 54 +- bin/javajs/util/XmlUtil.js | 146 +- bin/javajs/util/ZipData.js | 90 +- bin/javajs/util/ZipTools.js | 616 +- bin/netscape/javascript/JSException.js | 8 +- bin/netscape/javascript/JSObject.js | 38 +- bin/org/exolab/castor/mapping/Mapping.js | 16 +- bin/org/exolab/castor/xml/Unmarshaller.js | 48 +- bin/org/jmol/viewer/Viewer.js | 4 +- bin/swingjs/JSThread.js | 98 +- bin/swingjs/api/DOMNode.js | 116 +- bin/swingjs/api/JSFunction.js | 4 +- unused/appletgui/APopupMenu.java | 2876 +++---- unused/appletgui/AlignFrame.java | 8496 +++++++++---------- unused/appletgui/AlignViewport.java | 944 +-- unused/appletgui/AlignmentPanel.java | 2332 +++--- unused/appletgui/AnnotationColourChooser.java | 1162 +-- unused/appletgui/AnnotationColumnChooser.java | 1856 ++-- unused/appletgui/AnnotationLabels.java | 1724 ++-- unused/appletgui/AnnotationPanel.java | 1402 ++-- unused/appletgui/AnnotationRowFilter.java | 392 +- unused/appletgui/CutAndPasteTransfer.java | 1018 +-- unused/appletgui/EditNameDialog.java | 168 +- unused/appletgui/EmbmenuFrame.java | 552 +- unused/appletgui/ExtJmol.java | 426 +- unused/appletgui/FeatureColourChooser.java | 932 +-- unused/appletgui/FeatureRenderer.java | 964 +-- unused/appletgui/FeatureSettings.java | 1594 ++-- unused/appletgui/Finder.java | 588 +- unused/appletgui/IdCanvas.java | 780 +- unused/appletgui/IdPanel.java | 996 +-- unused/appletgui/IdwidthAdjuster.java | 274 +- unused/appletgui/JVDialog.java | 174 +- unused/appletgui/OverviewPanel.java | 966 +-- unused/appletgui/PCAPanel.java | 752 +- unused/appletgui/PaintRefresher.java | 524 +- unused/appletgui/PairwiseAlignPanel.java | 358 +- unused/appletgui/RedundancyPanel.java | 584 +- unused/appletgui/RotatableCanvas.java | 1322 +-- unused/appletgui/ScalePanel.java | 946 +-- unused/appletgui/SeqCanvas.java | 1692 ++-- unused/appletgui/SeqPanel.java | 3954 ++++----- unused/appletgui/SequenceRenderer.java | 798 +- unused/appletgui/SliderPanel.java | 800 +- unused/appletgui/SplitFrame.java | 438 +- unused/appletgui/TitledPanel.java | 148 +- unused/appletgui/Tooltip.java | 492 +- unused/appletgui/TreeCanvas.java | 1484 ++-- unused/appletgui/TreePanel.java | 852 +- unused/appletgui/UserDefinedColours.java | 1510 ++-- unused/com/stevesoft/pat/AmpersandRule.java | 60 +- unused/com/stevesoft/pat/Any.java | 110 +- unused/com/stevesoft/pat/BackG.java | 94 +- unused/com/stevesoft/pat/BackMatch.java | 114 +- unused/com/stevesoft/pat/BackRefRule.java | 80 +- unused/com/stevesoft/pat/Backup.java | 108 +- .../com/stevesoft/pat/BasicStringBufferLike.java | 46 +- unused/com/stevesoft/pat/Bits.java | 6080 +++++++------- unused/com/stevesoft/pat/Boundary.java | 178 +- unused/com/stevesoft/pat/Bracket.java | 176 +- unused/com/stevesoft/pat/CaseMgr.java | 8818 ++++++++++---------- unused/com/stevesoft/pat/ChangeRule.java | 100 +- unused/com/stevesoft/pat/CodeRule.java | 66 +- unused/com/stevesoft/pat/Ctrl.java | 122 +- unused/com/stevesoft/pat/Custom.java | 128 +- unused/com/stevesoft/pat/CustomEndpoint.java | 88 +- unused/com/stevesoft/pat/DotMulti.java | 418 +- unused/com/stevesoft/pat/End.java | 142 +- unused/com/stevesoft/pat/FastBracket.java | 512 +- unused/com/stevesoft/pat/FastMulti.java | 338 +- unused/com/stevesoft/pat/Group.java | 154 +- unused/com/stevesoft/pat/LeftRule.java | 62 +- unused/com/stevesoft/pat/Multi.java | 180 +- unused/com/stevesoft/pat/MultiMin.java | 42 +- unused/com/stevesoft/pat/Multi_stage2.java | 314 +- unused/com/stevesoft/pat/NoPattern.java | 66 +- unused/com/stevesoft/pat/NotImplementedError.java | 32 +- unused/com/stevesoft/pat/NullPattern.java | 74 +- unused/com/stevesoft/pat/NullRule.java | 60 +- unused/com/stevesoft/pat/Or.java | 260 +- unused/com/stevesoft/pat/OrMark.java | 146 +- unused/com/stevesoft/pat/PartialBuffer.java | 218 +- unused/com/stevesoft/pat/Pattern.java | 592 +- unused/com/stevesoft/pat/PatternSub.java | 32 +- unused/com/stevesoft/pat/PopRule.java | 48 +- unused/com/stevesoft/pat/Prop.java | 150 +- unused/com/stevesoft/pat/Pthings.java | 94 +- unused/com/stevesoft/pat/PushRule.java | 100 +- unused/com/stevesoft/pat/RBuffer.java | 104 +- unused/com/stevesoft/pat/Range.java | 194 +- unused/com/stevesoft/pat/RegOpt.java | 896 +- unused/com/stevesoft/pat/RegRes.java | 598 +- unused/com/stevesoft/pat/RegSyntax.java | 60 +- unused/com/stevesoft/pat/RegSyntaxError.java | 80 +- unused/com/stevesoft/pat/Regex.java | 4162 ++++----- unused/com/stevesoft/pat/RegexReader.java | 618 +- unused/com/stevesoft/pat/RegexTokenizer.java | 342 +- unused/com/stevesoft/pat/RegexWriter.java | 476 +- unused/com/stevesoft/pat/ReplaceRule.java | 404 +- unused/com/stevesoft/pat/Replacer.java | 738 +- unused/com/stevesoft/pat/RightRule.java | 62 +- unused/com/stevesoft/pat/Rthings.java | 136 +- unused/com/stevesoft/pat/RuleHolder.java | 86 +- unused/com/stevesoft/pat/Skip.java | 392 +- unused/com/stevesoft/pat/Skip2.java | 114 +- unused/com/stevesoft/pat/SkipBMH.java | 558 +- unused/com/stevesoft/pat/Skipped.java | 112 +- unused/com/stevesoft/pat/SpecialRule.java | 38 +- unused/com/stevesoft/pat/Start.java | 112 +- unused/com/stevesoft/pat/StrPos.java | 384 +- unused/com/stevesoft/pat/StringBufferLike.java | 184 +- unused/com/stevesoft/pat/StringLike.java | 94 +- unused/com/stevesoft/pat/StringRule.java | 78 +- unused/com/stevesoft/pat/SubMark.java | 64 +- unused/com/stevesoft/pat/TransPat.java | 104 +- unused/com/stevesoft/pat/Transformer.java | 470 +- unused/com/stevesoft/pat/UniValidator.java | 48 +- unused/com/stevesoft/pat/Util.java | 26 +- unused/com/stevesoft/pat/Validator.java | 150 +- .../com/stevesoft/pat/WantMoreTextReplaceRule.java | 58 +- unused/com/stevesoft/pat/lookAhead.java | 198 +- unused/com/stevesoft/pat/oneChar.java | 152 +- unused/com/stevesoft/pat/parsePerl.java | 1142 +-- unused/com/stevesoft/pat/patInf.java | 32 +- unused/com/stevesoft/pat/patInt.java | 360 +- .../stevesoft/pat/wrap/CharArrayBufferWrap.java | 118 +- unused/com/stevesoft/pat/wrap/CharArrayWrap.java | 160 +- .../com/stevesoft/pat/wrap/StringBufferWrap.java | 106 +- unused/com/stevesoft/pat/wrap/StringWrap.java | 128 +- unused/com/stevesoft/pat/wrap/WriterWrap.java | 122 +- 632 files changed, 106861 insertions(+), 106861 deletions(-) diff --git a/bin/MCview/Atom.js b/bin/MCview/Atom.js index ff57b47..1f4c66f 100644 --- a/bin/MCview/Atom.js +++ b/bin/MCview/Atom.js @@ -1,55 +1,55 @@ -Clazz.declarePackage ("MCview"); -Clazz.load (["java.awt.Color"], "MCview.Atom", ["java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.z = 0; -this.number = 0; -this.name = null; -this.resName = null; -this.resNumber = 0; -this.insCode = ' '; -this.resNumIns = null; -this.type = 0; -this.color = null; -this.chain = null; -this.alignmentMapping = -1; -this.atomIndex = 0; -this.occupancy = 0; -this.tfactor = 0; -this.isSelected = false; -Clazz.instantialize (this, arguments); -}, MCview, "Atom"); -Clazz.prepareFields (c$, function () { -this.color = java.awt.Color.lightGray; -}); -Clazz.makeConstructor (c$, -function (str) { -this.atomIndex = Integer.parseInt (str.substring (6, 11).trim ()); -this.name = str.substring (12, 15).trim (); -this.resName = str.substring (17, 20); -this.chain = str.substring (21, 22); -this.resNumber = Integer.parseInt (str.substring (22, 26).trim ()); -this.resNumIns = str.substring (22, 27).trim (); -this.insCode = str.substring (26, 27).charAt (0); -this.x = ( new Float (str.substring (30, 38).trim ()).floatValue ()); -this.y = ( new Float (str.substring (38, 46).trim ()).floatValue ()); -this.z = ( new Float (str.substring (47, 55).trim ()).floatValue ()); -var tm = str.substring (54, 60).trim (); -if (tm.length > 0) { -this.occupancy = ( new Float (tm)).floatValue (); -} else { -this.occupancy = 1; -}tm = str.substring (60, 66).trim (); -if (tm.length > 0) { -this.tfactor = ( new Float (tm).floatValue ()); -} else { -this.tfactor = 1; -}}, "~S"); -Clazz.makeConstructor (c$, -function (x, y, z) { -this.x = x; -this.y = y; -this.z = z; -}, "~N,~N,~N"); -}); +Clazz.declarePackage ("MCview"); +Clazz.load (["java.awt.Color"], "MCview.Atom", ["java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.z = 0; +this.number = 0; +this.name = null; +this.resName = null; +this.resNumber = 0; +this.insCode = ' '; +this.resNumIns = null; +this.type = 0; +this.color = null; +this.chain = null; +this.alignmentMapping = -1; +this.atomIndex = 0; +this.occupancy = 0; +this.tfactor = 0; +this.isSelected = false; +Clazz.instantialize (this, arguments); +}, MCview, "Atom"); +Clazz.prepareFields (c$, function () { +this.color = java.awt.Color.lightGray; +}); +Clazz.makeConstructor (c$, +function (str) { +this.atomIndex = Integer.parseInt (str.substring (6, 11).trim ()); +this.name = str.substring (12, 15).trim (); +this.resName = str.substring (17, 20); +this.chain = str.substring (21, 22); +this.resNumber = Integer.parseInt (str.substring (22, 26).trim ()); +this.resNumIns = str.substring (22, 27).trim (); +this.insCode = str.substring (26, 27).charAt (0); +this.x = ( new Float (str.substring (30, 38).trim ()).floatValue ()); +this.y = ( new Float (str.substring (38, 46).trim ()).floatValue ()); +this.z = ( new Float (str.substring (47, 55).trim ()).floatValue ()); +var tm = str.substring (54, 60).trim (); +if (tm.length > 0) { +this.occupancy = ( new Float (tm)).floatValue (); +} else { +this.occupancy = 1; +}tm = str.substring (60, 66).trim (); +if (tm.length > 0) { +this.tfactor = ( new Float (tm).floatValue ()); +} else { +this.tfactor = 1; +}}, "~S"); +Clazz.makeConstructor (c$, +function (x, y, z) { +this.x = x; +this.y = y; +this.z = z; +}, "~N,~N,~N"); +}); diff --git a/bin/MCview/Bond.js b/bin/MCview/Bond.js index 9aaba45..539e323 100644 --- a/bin/MCview/Bond.js +++ b/bin/MCview/Bond.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("MCview"); -Clazz.load (["java.awt.Color"], "MCview.Bond", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.start = null; -this.end = null; -this.startCol = null; -this.endCol = null; -this.at1 = null; -this.at2 = null; -Clazz.instantialize (this, arguments); -}, MCview, "Bond"); -Clazz.prepareFields (c$, function () { -this.startCol = java.awt.Color.lightGray; -this.endCol = java.awt.Color.lightGray; -}); -Clazz.makeConstructor (c$, -function (at1, at2) { -this.start = Clazz.newFloatArray (-1, [at1.x, at1.y, at1.z]); -this.end = Clazz.newFloatArray (-1, [at2.x, at2.y, at2.z]); -this.startCol = at1.color; -this.endCol = at2.color; -this.at1 = at1; -this.at2 = at2; -}, "MCview.Atom,MCview.Atom"); -Clazz.defineMethod (c$, "translate", -function (x, y, z) { -this.start[0] = this.start[0] + x; -this.end[0] = this.end[0] + x; -this.start[1] = this.start[1] + y; -this.end[1] = this.end[1] + y; -this.start[2] = this.start[2] + z; -this.end[2] = this.end[2] + z; -}, "~N,~N,~N"); -}); +Clazz.declarePackage ("MCview"); +Clazz.load (["java.awt.Color"], "MCview.Bond", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.start = null; +this.end = null; +this.startCol = null; +this.endCol = null; +this.at1 = null; +this.at2 = null; +Clazz.instantialize (this, arguments); +}, MCview, "Bond"); +Clazz.prepareFields (c$, function () { +this.startCol = java.awt.Color.lightGray; +this.endCol = java.awt.Color.lightGray; +}); +Clazz.makeConstructor (c$, +function (at1, at2) { +this.start = Clazz.newFloatArray (-1, [at1.x, at1.y, at1.z]); +this.end = Clazz.newFloatArray (-1, [at2.x, at2.y, at2.z]); +this.startCol = at1.color; +this.endCol = at2.color; +this.at1 = at1; +this.at2 = at2; +}, "MCview.Atom,MCview.Atom"); +Clazz.defineMethod (c$, "translate", +function (x, y, z) { +this.start[0] = this.start[0] + x; +this.end[0] = this.end[0] + x; +this.start[1] = this.start[1] + y; +this.end[1] = this.end[1] + y; +this.start[2] = this.start[2] + z; +this.end[2] = this.end[2] + z; +}, "~N,~N,~N"); +}); diff --git a/bin/MCview/PDBChain.js b/bin/MCview/PDBChain.js index 727e98e..b58d3dd 100644 --- a/bin/MCview/PDBChain.js +++ b/bin/MCview/PDBChain.js @@ -1,286 +1,286 @@ -Clazz.declarePackage ("MCview"); -Clazz.load (["java.util.Vector"], "MCview.PDBChain", ["MCview.Bond", "$.Residue", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.Sequence", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "java.awt.Color", "java.lang.StringBuilder"], function () { -c$ = Clazz.decorateAsClass (function () { -this.id = null; -this.bonds = null; -this.atoms = null; -this.residues = null; -this.offset = 0; -this.sequence = null; -this.shadow = null; -this.isNa = false; -this.isVisible = true; -this.pdbstart = 0; -this.pdbend = 0; -this.seqstart = 0; -this.seqend = 0; -this.pdbid = ""; -this.newline = null; -this.shadowMap = null; -Clazz.instantialize (this, arguments); -}, MCview, "PDBChain"); -Clazz.prepareFields (c$, function () { -this.bonds = new java.util.Vector (); -this.atoms = new java.util.Vector (); -this.residues = new java.util.Vector (); -this.newline = System.getProperty ("line.separator"); -}); -Clazz.makeConstructor (c$, -function (pdbid, id) { -this.pdbid = pdbid.toLowerCase (); -this.id = id; -}, "~S,~S"); -Clazz.defineMethod (c$, "setNewlineString", -function (nl) { -this.newline = nl; -}, "~S"); -Clazz.defineMethod (c$, "getNewlineString", -function () { -return this.newline; -}); -Clazz.defineMethod (c$, "print", -function () { -var tmp = new StringBuilder (256); -for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { -tmp.append (b.at1.resName).append (" ").append (b.at1.resNumber).append (" ").append (this.offset).append (this.newline); -} -return tmp.toString (); -}); -Clazz.defineMethod (c$, "makeExactMapping", -function (as, s1) { -var pdbpos = as.getSeq2Start () - 2; -var alignpos = s1.getStart () + as.getSeq1Start () - 3; -for (var atom, $atom = this.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { -atom.alignmentMapping = -1; -} -for (var i = 0; i < as.astr1.length; i++) { -if (as.astr1.charAt (i) != '-') { -alignpos++; -}if (as.astr2.charAt (i) != '-') { -pdbpos++; -}if (as.astr1.charAt (i) == as.astr2.charAt (i)) { -var res = this.residues.elementAt (pdbpos); -for (var atom, $atom = res.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { -atom.alignmentMapping = alignpos; -} -}} -}, "jalview.analysis.AlignSeq,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "transferRESNUMFeatures", -function (seq, status) { -var sq = seq; -while (sq != null && sq.getDatasetSequence () != null) { -sq = sq.getDatasetSequence (); -if (sq === this.sequence) { -return null; -}} -if (status == null) { -status = "IEA:jalview"; -}var features = this.sequence.getSequenceFeatures (); -for (var i = 0; i < features.length; i++) { -if (features[i].getFeatureGroup ().equals (this.pdbid)) { -var tx = new jalview.datamodel.SequenceFeature (features[i]); -tx.setBegin (1 + this.residues.elementAt (tx.getBegin () - this.offset).atoms.elementAt (0).alignmentMapping); -tx.setEnd (1 + this.residues.elementAt (tx.getEnd () - this.offset).atoms.elementAt (0).alignmentMapping); -tx.setStatus (status + ((tx.getStatus () == null || tx.getStatus ().length == 0) ? "" : ":" + tx.getStatus ())); -if (tx.begin != 0 && tx.end != 0) { -sq.addSequenceFeature (tx); -}}} -return features; -}, "jalview.datamodel.SequenceI,~S"); -Clazz.defineMethod (c$, "makeCaBondList", -function () { -var na = false; -var numNa = 0; -for (var i = 0; i < (this.residues.size () - 1); i++) { -var tmpres = this.residues.elementAt (i); -var tmpres2 = this.residues.elementAt (i + 1); -var at1 = tmpres.findAtom ("CA"); -var at2 = tmpres2.findAtom ("CA"); -na = false; -if ((at1 == null) && (at2 == null)) { -na = true; -at1 = tmpres.findAtom ("P"); -at2 = tmpres2.findAtom ("P"); -}if ((at1 != null) && (at2 != null)) { -if (at1.chain.equals (at2.chain)) { -if (na) { -numNa++; -}this.makeBond (at1, at2); -}} else { -System.out.println ("not found " + i); -}} -if (this.residues.size () > 0 && (Clazz.doubleToInt (numNa / (this.residues.size () - 1)) > 0.99)) { -this.isNa = true; -}}); -Clazz.defineMethod (c$, "makeBond", -function (at1, at2) { -this.bonds.addElement ( new MCview.Bond (at1, at2)); -}, "MCview.Atom,MCview.Atom"); -Clazz.defineMethod (c$, "makeResidueList", -function (visibleChainAnnotation) { -var count = 0; -var symbol; -var deoxyn = false; -var nucleotide = false; -var seq = new StringBuilder (256); -var resFeatures = new java.util.Vector (); -var resAnnotation = new java.util.Vector (); -var i; -var iSize = this.atoms.size () - 1; -var resNumber = -1; -for (i = 0; i <= iSize; i++) { -var tmp = this.atoms.elementAt (i); -resNumber = tmp.resNumber; -var res = resNumber; -if (i == 0) { -this.offset = resNumber; -}var resAtoms = new java.util.Vector (); -while ((resNumber == res) && (i < this.atoms.size ())) { -resAtoms.add (this.atoms.elementAt (i)); -i++; -if (i < this.atoms.size ()) { -resNumber = this.atoms.elementAt (i).resNumber; -} else { -resNumber++; -}} -i--; -this.residues.addElement ( new MCview.Residue (resAtoms, resNumber - 1, count)); -var tmpres = this.residues.lastElement (); -var tmpat = tmpres.atoms.get (0); -var sf = new jalview.datamodel.SequenceFeature ("RESNUM", tmpat.resName + ":" + tmpat.resNumIns + " " + this.pdbid + this.id, "", this.offset + count, this.offset + count, this.pdbid); -resFeatures.addElement (sf); -resAnnotation.addElement ( new jalview.datamodel.Annotation (tmpat.tfactor)); -if ((symbol = jalview.schemes.ResidueProperties.getAA3Hash ().get (tmpat.resName)) == null) { -var nucname = tmpat.resName.trim (); -deoxyn = nucname.length == 2 && jalview.schemes.ResidueProperties.aaIndex[nucname.charCodeAt (0)] == jalview.schemes.ResidueProperties.aaIndex['D'.charCodeAt (0)]; -if (tmpat.name.equalsIgnoreCase ("CA") || jalview.schemes.ResidueProperties.nucleotideIndex[nucname.charCodeAt ((deoxyn ? 1 : 0))] == -1) { -seq.append ("X"); -} else { -nucleotide = true; -seq.append (nucname.charAt ((deoxyn ? 1 : 0))); -}} else { -if (nucleotide) { -System.err.println ("Warning: mixed nucleotide and amino acid chain.. its gonna do bad things to you!"); -}seq.append (jalview.schemes.ResidueProperties.aa[(symbol).intValue ()]); -}count++; -} -if (this.id.length < 1) { -this.id = " "; -}this.isNa = nucleotide; -this.sequence = new jalview.datamodel.Sequence (this.id, seq.toString (), this.offset, resNumber - 1); -for (i = 0, iSize = resFeatures.size (); i < iSize; i++) { -this.sequence.addSequenceFeature (resFeatures.elementAt (i)); -resFeatures.setElementAt (null, i); -} -if (visibleChainAnnotation) { -var annots = new Array (resAnnotation.size ()); -var max = 0; -for (i = 0, iSize = annots.length; i < iSize; i++) { -annots[i] = resAnnotation.elementAt (i); -if (annots[i].value > max) { -max = annots[i].value; -}resAnnotation.setElementAt (null, i); -} -var tfactorann = new jalview.datamodel.AlignmentAnnotation ("Temperature Factor", "Temperature Factor for " + this.pdbid + this.id, annots, 0, max, 2); -tfactorann.setSequenceRef (this.sequence); -this.sequence.addAlignmentAnnotation (tfactorann); -}}, "~B"); -Clazz.defineMethod (c$, "setChargeColours", -function () { -for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { -if (b.at1 != null && b.at2 != null) { -b.startCol = MCview.PDBChain.getChargeColour (b.at1.resName); -b.endCol = MCview.PDBChain.getChargeColour (b.at2.resName); -} else { -b.startCol = java.awt.Color.gray; -b.endCol = java.awt.Color.gray; -}} -}); -c$.getChargeColour = Clazz.defineMethod (c$, "getChargeColour", -function (resName) { -var result = java.awt.Color.lightGray; -if ("ASP".equals (resName) || "GLU".equals (resName)) { -result = java.awt.Color.red; -} else if ("LYS".equals (resName) || "ARG".equals (resName)) { -result = java.awt.Color.blue; -} else if ("CYS".equals (resName)) { -result = java.awt.Color.yellow; -}return result; -}, "~S"); -Clazz.defineMethod (c$, "setChainColours", -function (cs) { -var index; -for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { -try { -index = jalview.schemes.ResidueProperties.aa3Hash.get (b.at1.resName).intValue (); -b.startCol = cs.findColour (jalview.schemes.ResidueProperties.aa[index].charAt (0)); -index = jalview.schemes.ResidueProperties.aa3Hash.get (b.at2.resName).intValue (); -b.endCol = cs.findColour (jalview.schemes.ResidueProperties.aa[index].charAt (0)); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -b.startCol = java.awt.Color.gray; -b.endCol = java.awt.Color.gray; -} else { -throw e; -} -} -} -}, "jalview.schemes.ColourSchemeI"); -Clazz.defineMethod (c$, "setChainColours", -function (col) { -for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { -b.startCol = col; -b.endCol = col; -} -}, "java.awt.Color"); -Clazz.defineMethod (c$, "transferResidueAnnotation", -function (mapping, sqmpping) { -var sq = mapping.getSequence (); -var dsq = sq; -if (sq != null) { -while (dsq.getDatasetSequence () != null) { -dsq = dsq.getDatasetSequence (); -} -if (this.shadow != null && this.shadow.getAnnotation () != null) { -for (var ana, $ana = 0, $$ana = this.shadow.getAnnotation (); $ana < $$ana.length && ((ana = $$ana[$ana]) || true); $ana++) { -var transfer = sq.getAlignmentAnnotations (ana.getCalcId (), ana.label); -if (transfer == null || transfer.size () == 0) { -ana = new jalview.datamodel.AlignmentAnnotation (ana); -ana.liftOver (this.sequence, this.shadowMap); -ana.liftOver (dsq, sqmpping); -dsq.addAlignmentAnnotation (ana); -} else { -continue; -}} -} else { -if (this.sequence != null && this.sequence.getAnnotation () != null) { -for (var ana, $ana = 0, $$ana = this.sequence.getAnnotation (); $ana < $$ana.length && ((ana = $$ana[$ana]) || true); $ana++) { -var transfer = sq.getAlignmentAnnotations (ana.getCalcId (), ana.label); -if (transfer == null || transfer.size () == 0) { -ana = new jalview.datamodel.AlignmentAnnotation (ana); -ana.liftOver (dsq, sqmpping); -} else { -continue; -}} -}}if (false) { -var min = -1; -var max = 0; -var an = new Array (sq.getEnd () - sq.getStart () + 1); -for (var i = sq.getStart (), j = sq.getEnd (), k = 0; i <= j; i++, k++) { -var prn = mapping.getPDBResNum (k + 1); -an[k] = new jalview.datamodel.Annotation (prn); -if (min == -1) { -min = k; -max = k; -} else { -if (min > k) { -min = k; -} else if (max < k) { -max = k; -}}} -sq.addAlignmentAnnotation ( new jalview.datamodel.AlignmentAnnotation ("PDB.RESNUM", "PDB Residue Numbering for " + this.pdbid + ":" + this.id, an, min, max, 2)); -}}}, "jalview.structure.StructureMapping,jalview.datamodel.Mapping"); -Clazz.defineStatics (c$, -"PDBFILEFEATURE", "PDBFile", -"IEASTATUS", "IEA:jalview"); -}); +Clazz.declarePackage ("MCview"); +Clazz.load (["java.util.Vector"], "MCview.PDBChain", ["MCview.Bond", "$.Residue", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.Sequence", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "java.awt.Color", "java.lang.StringBuilder"], function () { +c$ = Clazz.decorateAsClass (function () { +this.id = null; +this.bonds = null; +this.atoms = null; +this.residues = null; +this.offset = 0; +this.sequence = null; +this.shadow = null; +this.isNa = false; +this.isVisible = true; +this.pdbstart = 0; +this.pdbend = 0; +this.seqstart = 0; +this.seqend = 0; +this.pdbid = ""; +this.newline = null; +this.shadowMap = null; +Clazz.instantialize (this, arguments); +}, MCview, "PDBChain"); +Clazz.prepareFields (c$, function () { +this.bonds = new java.util.Vector (); +this.atoms = new java.util.Vector (); +this.residues = new java.util.Vector (); +this.newline = System.getProperty ("line.separator"); +}); +Clazz.makeConstructor (c$, +function (pdbid, id) { +this.pdbid = pdbid.toLowerCase (); +this.id = id; +}, "~S,~S"); +Clazz.defineMethod (c$, "setNewlineString", +function (nl) { +this.newline = nl; +}, "~S"); +Clazz.defineMethod (c$, "getNewlineString", +function () { +return this.newline; +}); +Clazz.defineMethod (c$, "print", +function () { +var tmp = new StringBuilder (256); +for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { +tmp.append (b.at1.resName).append (" ").append (b.at1.resNumber).append (" ").append (this.offset).append (this.newline); +} +return tmp.toString (); +}); +Clazz.defineMethod (c$, "makeExactMapping", +function (as, s1) { +var pdbpos = as.getSeq2Start () - 2; +var alignpos = s1.getStart () + as.getSeq1Start () - 3; +for (var atom, $atom = this.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { +atom.alignmentMapping = -1; +} +for (var i = 0; i < as.astr1.length; i++) { +if (as.astr1.charAt (i) != '-') { +alignpos++; +}if (as.astr2.charAt (i) != '-') { +pdbpos++; +}if (as.astr1.charAt (i) == as.astr2.charAt (i)) { +var res = this.residues.elementAt (pdbpos); +for (var atom, $atom = res.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { +atom.alignmentMapping = alignpos; +} +}} +}, "jalview.analysis.AlignSeq,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "transferRESNUMFeatures", +function (seq, status) { +var sq = seq; +while (sq != null && sq.getDatasetSequence () != null) { +sq = sq.getDatasetSequence (); +if (sq === this.sequence) { +return null; +}} +if (status == null) { +status = "IEA:jalview"; +}var features = this.sequence.getSequenceFeatures (); +for (var i = 0; i < features.length; i++) { +if (features[i].getFeatureGroup ().equals (this.pdbid)) { +var tx = new jalview.datamodel.SequenceFeature (features[i]); +tx.setBegin (1 + this.residues.elementAt (tx.getBegin () - this.offset).atoms.elementAt (0).alignmentMapping); +tx.setEnd (1 + this.residues.elementAt (tx.getEnd () - this.offset).atoms.elementAt (0).alignmentMapping); +tx.setStatus (status + ((tx.getStatus () == null || tx.getStatus ().length == 0) ? "" : ":" + tx.getStatus ())); +if (tx.begin != 0 && tx.end != 0) { +sq.addSequenceFeature (tx); +}}} +return features; +}, "jalview.datamodel.SequenceI,~S"); +Clazz.defineMethod (c$, "makeCaBondList", +function () { +var na = false; +var numNa = 0; +for (var i = 0; i < (this.residues.size () - 1); i++) { +var tmpres = this.residues.elementAt (i); +var tmpres2 = this.residues.elementAt (i + 1); +var at1 = tmpres.findAtom ("CA"); +var at2 = tmpres2.findAtom ("CA"); +na = false; +if ((at1 == null) && (at2 == null)) { +na = true; +at1 = tmpres.findAtom ("P"); +at2 = tmpres2.findAtom ("P"); +}if ((at1 != null) && (at2 != null)) { +if (at1.chain.equals (at2.chain)) { +if (na) { +numNa++; +}this.makeBond (at1, at2); +}} else { +System.out.println ("not found " + i); +}} +if (this.residues.size () > 0 && (Clazz.doubleToInt (numNa / (this.residues.size () - 1)) > 0.99)) { +this.isNa = true; +}}); +Clazz.defineMethod (c$, "makeBond", +function (at1, at2) { +this.bonds.addElement ( new MCview.Bond (at1, at2)); +}, "MCview.Atom,MCview.Atom"); +Clazz.defineMethod (c$, "makeResidueList", +function (visibleChainAnnotation) { +var count = 0; +var symbol; +var deoxyn = false; +var nucleotide = false; +var seq = new StringBuilder (256); +var resFeatures = new java.util.Vector (); +var resAnnotation = new java.util.Vector (); +var i; +var iSize = this.atoms.size () - 1; +var resNumber = -1; +for (i = 0; i <= iSize; i++) { +var tmp = this.atoms.elementAt (i); +resNumber = tmp.resNumber; +var res = resNumber; +if (i == 0) { +this.offset = resNumber; +}var resAtoms = new java.util.Vector (); +while ((resNumber == res) && (i < this.atoms.size ())) { +resAtoms.add (this.atoms.elementAt (i)); +i++; +if (i < this.atoms.size ()) { +resNumber = this.atoms.elementAt (i).resNumber; +} else { +resNumber++; +}} +i--; +this.residues.addElement ( new MCview.Residue (resAtoms, resNumber - 1, count)); +var tmpres = this.residues.lastElement (); +var tmpat = tmpres.atoms.get (0); +var sf = new jalview.datamodel.SequenceFeature ("RESNUM", tmpat.resName + ":" + tmpat.resNumIns + " " + this.pdbid + this.id, "", this.offset + count, this.offset + count, this.pdbid); +resFeatures.addElement (sf); +resAnnotation.addElement ( new jalview.datamodel.Annotation (tmpat.tfactor)); +if ((symbol = jalview.schemes.ResidueProperties.getAA3Hash ().get (tmpat.resName)) == null) { +var nucname = tmpat.resName.trim (); +deoxyn = nucname.length == 2 && jalview.schemes.ResidueProperties.aaIndex[nucname.charCodeAt (0)] == jalview.schemes.ResidueProperties.aaIndex['D'.charCodeAt (0)]; +if (tmpat.name.equalsIgnoreCase ("CA") || jalview.schemes.ResidueProperties.nucleotideIndex[nucname.charCodeAt ((deoxyn ? 1 : 0))] == -1) { +seq.append ("X"); +} else { +nucleotide = true; +seq.append (nucname.charAt ((deoxyn ? 1 : 0))); +}} else { +if (nucleotide) { +System.err.println ("Warning: mixed nucleotide and amino acid chain.. its gonna do bad things to you!"); +}seq.append (jalview.schemes.ResidueProperties.aa[(symbol).intValue ()]); +}count++; +} +if (this.id.length < 1) { +this.id = " "; +}this.isNa = nucleotide; +this.sequence = new jalview.datamodel.Sequence (this.id, seq.toString (), this.offset, resNumber - 1); +for (i = 0, iSize = resFeatures.size (); i < iSize; i++) { +this.sequence.addSequenceFeature (resFeatures.elementAt (i)); +resFeatures.setElementAt (null, i); +} +if (visibleChainAnnotation) { +var annots = new Array (resAnnotation.size ()); +var max = 0; +for (i = 0, iSize = annots.length; i < iSize; i++) { +annots[i] = resAnnotation.elementAt (i); +if (annots[i].value > max) { +max = annots[i].value; +}resAnnotation.setElementAt (null, i); +} +var tfactorann = new jalview.datamodel.AlignmentAnnotation ("Temperature Factor", "Temperature Factor for " + this.pdbid + this.id, annots, 0, max, 2); +tfactorann.setSequenceRef (this.sequence); +this.sequence.addAlignmentAnnotation (tfactorann); +}}, "~B"); +Clazz.defineMethod (c$, "setChargeColours", +function () { +for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { +if (b.at1 != null && b.at2 != null) { +b.startCol = MCview.PDBChain.getChargeColour (b.at1.resName); +b.endCol = MCview.PDBChain.getChargeColour (b.at2.resName); +} else { +b.startCol = java.awt.Color.gray; +b.endCol = java.awt.Color.gray; +}} +}); +c$.getChargeColour = Clazz.defineMethod (c$, "getChargeColour", +function (resName) { +var result = java.awt.Color.lightGray; +if ("ASP".equals (resName) || "GLU".equals (resName)) { +result = java.awt.Color.red; +} else if ("LYS".equals (resName) || "ARG".equals (resName)) { +result = java.awt.Color.blue; +} else if ("CYS".equals (resName)) { +result = java.awt.Color.yellow; +}return result; +}, "~S"); +Clazz.defineMethod (c$, "setChainColours", +function (cs) { +var index; +for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { +try { +index = jalview.schemes.ResidueProperties.aa3Hash.get (b.at1.resName).intValue (); +b.startCol = cs.findColour (jalview.schemes.ResidueProperties.aa[index].charAt (0)); +index = jalview.schemes.ResidueProperties.aa3Hash.get (b.at2.resName).intValue (); +b.endCol = cs.findColour (jalview.schemes.ResidueProperties.aa[index].charAt (0)); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +b.startCol = java.awt.Color.gray; +b.endCol = java.awt.Color.gray; +} else { +throw e; +} +} +} +}, "jalview.schemes.ColourSchemeI"); +Clazz.defineMethod (c$, "setChainColours", +function (col) { +for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) { +b.startCol = col; +b.endCol = col; +} +}, "java.awt.Color"); +Clazz.defineMethod (c$, "transferResidueAnnotation", +function (mapping, sqmpping) { +var sq = mapping.getSequence (); +var dsq = sq; +if (sq != null) { +while (dsq.getDatasetSequence () != null) { +dsq = dsq.getDatasetSequence (); +} +if (this.shadow != null && this.shadow.getAnnotation () != null) { +for (var ana, $ana = 0, $$ana = this.shadow.getAnnotation (); $ana < $$ana.length && ((ana = $$ana[$ana]) || true); $ana++) { +var transfer = sq.getAlignmentAnnotations (ana.getCalcId (), ana.label); +if (transfer == null || transfer.size () == 0) { +ana = new jalview.datamodel.AlignmentAnnotation (ana); +ana.liftOver (this.sequence, this.shadowMap); +ana.liftOver (dsq, sqmpping); +dsq.addAlignmentAnnotation (ana); +} else { +continue; +}} +} else { +if (this.sequence != null && this.sequence.getAnnotation () != null) { +for (var ana, $ana = 0, $$ana = this.sequence.getAnnotation (); $ana < $$ana.length && ((ana = $$ana[$ana]) || true); $ana++) { +var transfer = sq.getAlignmentAnnotations (ana.getCalcId (), ana.label); +if (transfer == null || transfer.size () == 0) { +ana = new jalview.datamodel.AlignmentAnnotation (ana); +ana.liftOver (dsq, sqmpping); +} else { +continue; +}} +}}if (false) { +var min = -1; +var max = 0; +var an = new Array (sq.getEnd () - sq.getStart () + 1); +for (var i = sq.getStart (), j = sq.getEnd (), k = 0; i <= j; i++, k++) { +var prn = mapping.getPDBResNum (k + 1); +an[k] = new jalview.datamodel.Annotation (prn); +if (min == -1) { +min = k; +max = k; +} else { +if (min > k) { +min = k; +} else if (max < k) { +max = k; +}}} +sq.addAlignmentAnnotation ( new jalview.datamodel.AlignmentAnnotation ("PDB.RESNUM", "PDB Residue Numbering for " + this.pdbid + ":" + this.id, an, min, max, 2)); +}}}, "jalview.structure.StructureMapping,jalview.datamodel.Mapping"); +Clazz.defineStatics (c$, +"PDBFILEFEATURE", "PDBFile", +"IEASTATUS", "IEA:jalview"); +}); diff --git a/bin/MCview/PDBfile.js b/bin/MCview/PDBfile.js index c6af5ca..dfc40cc 100644 --- a/bin/MCview/PDBfile.js +++ b/bin/MCview/PDBfile.js @@ -1,320 +1,320 @@ -Clazz.declarePackage ("MCview"); -Clazz.load (["jalview.io.AlignFile"], "MCview.PDBfile", ["MCview.Atom", "$.PDBChain", "jalview.analysis.AlignSeq", "jalview.datamodel.Alignment", "$.AlignmentI", "$.PDBEntry", "jalview.io.FileParse", "jalview.util.MessageManager", "java.awt.Color", "java.io.IOException", "java.util.ArrayList", "$.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.chains = null; -this.id = null; -this.visibleChainAnnotation = false; -this.$predictSecondaryStructure = true; -this.externalSecondaryStructure = false; -Clazz.instantialize (this, arguments); -}, MCview, "PDBfile", jalview.io.AlignFile); -Clazz.makeConstructor (c$, -function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr) { -Clazz.superConstructor (this, MCview.PDBfile); -this.visibleChainAnnotation = addAlignmentAnnotations; -this.$predictSecondaryStructure = predictSecondaryStructure; -this.externalSecondaryStructure = externalSecStr; -}, "~B,~B,~B"); -Clazz.makeConstructor (c$, -function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr, file, protocol) { -Clazz.superConstructor (this, MCview.PDBfile, [false, file, protocol]); -this.visibleChainAnnotation = addAlignmentAnnotations; -this.$predictSecondaryStructure = predictSecondaryStructure; -this.externalSecondaryStructure = externalSecStr; -this.doParse (); -}, "~B,~B,~B,~S,~S"); -Clazz.makeConstructor (c$, -function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr, source) { -Clazz.superConstructor (this, MCview.PDBfile, [false, source]); -this.visibleChainAnnotation = addAlignmentAnnotations; -this.$predictSecondaryStructure = predictSecondaryStructure; -this.externalSecondaryStructure = externalSecStr; -this.doParse (); -}, "~B,~B,~B,jalview.io.FileParse"); -Clazz.overrideMethod (c$, "print", -function () { -return null; -}); -Clazz.overrideMethod (c$, "parse", -function () { -this.id = this.safeName (this.getDataName ()); -this.chains = new java.util.Vector (); -var rna = new java.util.ArrayList (); -var prot = new java.util.ArrayList (); -var tmpchain; -var line = null; -var modelFlag = false; -var terFlag = false; -var lastID = ""; -var indexx = 0; -var atomnam = null; -try { -while ((line = this.nextLine ()) != null) { -if (line.indexOf ("HEADER") == 0) { -if (line.length > 62) { -var tid; -if (line.length > 67) { -tid = line.substring (62, 67).trim (); -} else { -tid = line.substring (62).trim (); -}if (tid.length > 0) { -this.id = tid; -}continue; -}}if (line.indexOf ("SEQRES") == 0) { -}if (line.indexOf ("MODEL") == 0) { -modelFlag = true; -}if (line.indexOf ("TER") == 0) { -terFlag = true; -}if (modelFlag && line.indexOf ("ENDMDL") == 0) { -break; -}if (line.indexOf ("ATOM") == 0 || (line.indexOf ("HETATM") == 0 && !terFlag)) { -terFlag = false; -atomnam = line.substring (12, 15).trim (); -if (!atomnam.equals ("CA") && !atomnam.equals ("P")) { -continue; -}var tmpatom = new MCview.Atom (line); -tmpchain = this.findChain (tmpatom.chain); -if (tmpchain != null) { -if (tmpatom.resNumIns.trim ().equals (lastID)) { -continue; -}tmpchain.atoms.addElement (tmpatom); -} else { -tmpchain = new MCview.PDBChain (this.id, tmpatom.chain); -this.chains.addElement (tmpchain); -tmpchain.atoms.addElement (tmpatom); -}lastID = tmpatom.resNumIns.trim (); -}this.index++; -} -this.makeResidueList (); -this.makeCaBondList (); -if (this.id == null) { -this.id = this.inFile.getName (); -}for (var chain, $chain = this.chains.iterator (); $chain.hasNext () && ((chain = $chain.next ()) || true);) { -var chainseq = this.postProcessChain (chain); -if (MCview.PDBfile.isRNA (chainseq)) { -rna.add (chainseq); -} else { -prot.add (chainseq); -}} -if (this.$predictSecondaryStructure) { -this.predictSecondaryStructure (rna, prot); -}} catch (e$$) { -if (Clazz.exceptionOf (e$$, OutOfMemoryError)) { -var er = e$$; -{ -System.out.println ("OUT OF MEMORY LOADING PDB FILE"); -throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.outofmemory_loading_pdb_file")); -} -} else if (Clazz.exceptionOf (e$$, NumberFormatException)) { -var ex = e$$; -{ -if (line != null) { -System.err.println ("Couldn't read number from line:"); -System.err.println (line); -}} -} else { -throw e$$; -} -} -this.markCalcIds (); -}); -Clazz.defineMethod (c$, "predictSecondaryStructure", -function (rnaSequences, proteinSequences) { -if (this.externalSecondaryStructure && rnaSequences.size () > 0) { -try { -this.processPdbFileWithAnnotate3d (rnaSequences); -} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -System.err.println ("Exceptions when dealing with RNA in pdb file"); -x.printStackTrace (); -} else { -throw x; -} -} -}if (proteinSequences.size () > 0) { -try { -this.processPdbFileWithJmol (proteinSequences); -} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -System.err.println ("Exceptions from Jmol when processing data in pdb file"); -x.printStackTrace (); -} else { -throw x; -} -} -}}, "java.util.List,java.util.List"); -Clazz.defineMethod (c$, "postProcessChain", -function (chain) { -var dataset = chain.sequence; -dataset.setName (this.id + "|" + dataset.getName ()); -var entry = new jalview.datamodel.PDBEntry (); -entry.setId (this.id); -entry.setType (jalview.datamodel.PDBEntry.Type.PDB); -entry.setProperty ( new java.util.Hashtable ()); -if (chain.id != null) { -entry.setChainCode (String.valueOf (chain.id)); -}if (this.inFile != null) { -entry.setFile (this.inFile.getAbsolutePath ()); -} else { -entry.setFile (this.getDataName ()); -}dataset.addPDBId (entry); -var chainseq = dataset.deriveSequence (); -this.seqs.addElement (chainseq); -var chainannot = chainseq.getAnnotation (); -if (chainannot != null && this.visibleChainAnnotation) { -for (var ai = 0; ai < chainannot.length; ai++) { -chainannot[ai].visible = this.visibleChainAnnotation; -this.annotations.addElement (chainannot[ai]); -} -}return chainseq; -}, "MCview.PDBChain"); -c$.isCalcIdHandled = Clazz.defineMethod (c$, "isCalcIdHandled", -function (calcId) { -return calcId != null && (MCview.PDBfile.CALC_ID_PREFIX.equals (calcId)); -}, "~S"); -c$.isCalcIdForFile = Clazz.defineMethod (c$, "isCalcIdForFile", -function (alan, pdbFile) { -return alan.getCalcId () != null && MCview.PDBfile.CALC_ID_PREFIX.equals (alan.getCalcId ()) && pdbFile.equals (alan.getProperty ("PDBID")); -}, "jalview.datamodel.AlignmentAnnotation,~S"); -c$.relocateCalcId = Clazz.defineMethod (c$, "relocateCalcId", -function (calcId, alreadyLoadedPDB) { -var s = MCview.PDBfile.CALC_ID_PREFIX.length; -var end = calcId.indexOf (MCview.PDBfile.CALC_ID_PREFIX, s); -var between = calcId.substring (s, end - 1); -return MCview.PDBfile.CALC_ID_PREFIX + alreadyLoadedPDB.get (between) + ":" + calcId.substring (end); -}, "~S,java.util.Hashtable"); -Clazz.defineMethod (c$, "markCalcIds", -($fz = function () { -for (var sq, $sq = this.seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -if (sq.getAnnotation () != null) { -for (var aa, $aa = 0, $$aa = sq.getAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { -var oldId = aa.getCalcId (); -if (oldId == null) { -oldId = ""; -}aa.setCalcId (MCview.PDBfile.CALC_ID_PREFIX); -aa.setProperty ("PDBID", this.id); -aa.setProperty ("oldCalcId", oldId); -} -}} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "processPdbFileWithJmol", -($fz = function (prot) { -try { -var cl = Class.forName ("jalview.ext.jmol.PDBFileWithJmol"); -if (cl != null) { -var constructor = cl.getConstructor ( Clazz.newArray (-1, [jalview.io.FileParse])); -var args = Clazz.newArray (-1, [ new jalview.io.FileParse (this.getDataName (), this.type)]); -var jmf = constructor.newInstance (args); -var al = new jalview.datamodel.Alignment (cl.getMethod ("getSeqsAsArray", Clazz.newArray (-1, [])).invoke (jmf, [])); -cl.getMethod ("addAnnotations", Clazz.newArray (-1, [jalview.datamodel.AlignmentI])).invoke (jmf, [al]); -for (var sq, $sq = al.getSequences ().iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -if (sq.getDatasetSequence () != null) { -sq.getDatasetSequence ().getPDBId ().clear (); -} else { -sq.getPDBId ().clear (); -}} -this.replaceAndUpdateChains (prot, al, "pep", false); -}} catch (q) { -if (Clazz.exceptionOf (q, ClassNotFoundException)) { -} else { -throw q; -} -} -}, $fz.isPrivate = true, $fz), "java.util.List"); -Clazz.defineMethod (c$, "replaceAndUpdateChains", -($fz = function (prot, al, pep, b) { -var replaced = jalview.analysis.AlignSeq.replaceMatchingSeqsWith (this.seqs, this.annotations, prot, al, pep, false); -for (var ch, $ch = this.chains.iterator (); $ch.hasNext () && ((ch = $ch.next ()) || true);) { -var p = 0; -for (var sq, $sq = replaced.get (0).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -p++; -if (sq === ch.sequence || sq.getDatasetSequence () === ch.sequence) { -p = -p; -break; -}} -if (p < 0) { -p = -p - 1; -ch.shadow = replaced.get (1).get (p); -ch.shadowMap = (replaced.get (2).get (p)).getMappingFromS1 (false); -}} -}, $fz.isPrivate = true, $fz), "java.util.List,jalview.datamodel.AlignmentI,~S,~B"); -Clazz.defineMethod (c$, "processPdbFileWithAnnotate3d", -($fz = function (rna) { -try { -var cl = Class.forName ("jalview.ws.jws1.Annotate3D"); -if (cl != null) { -var annotate3d = cl.getConstructor ( Clazz.newArray (-1, [])).newInstance ( Clazz.newArray (-1, [])); -var al = (cl.getMethod ("getRNAMLFor", Clazz.newArray (-1, [jalview.io.FileParse])).invoke (annotate3d, Clazz.newArray (-1, [ new jalview.io.FileParse (this.getDataName (), this.type)]))); -for (var sq, $sq = al.getSequences ().iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -if (sq.getDatasetSequence () != null) { -if (sq.getDatasetSequence ().getPDBId () != null) { -sq.getDatasetSequence ().getPDBId ().clear (); -}} else { -if (sq.getPDBId () != null) { -sq.getPDBId ().clear (); -}}} -this.replaceAndUpdateChains (rna, al, "dna", false); -}} catch (x) { -if (Clazz.exceptionOf (x, ClassNotFoundException)) { -} else { -throw x; -} -} -;}, $fz.isPrivate = true, $fz), "java.util.List"); -Clazz.defineMethod (c$, "safeName", -($fz = function (dataName) { -var p = 0; -while ((p = dataName.indexOf ("/")) > -1 && p < dataName.length) { -dataName = dataName.substring (p + 1); -} -return dataName; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "makeResidueList", -function () { -for (var i = 0; i < this.chains.size (); i++) { -this.chains.elementAt (i).makeResidueList (this.visibleChainAnnotation); -} -}); -Clazz.defineMethod (c$, "makeCaBondList", -function () { -for (var i = 0; i < this.chains.size (); i++) { -this.chains.elementAt (i).makeCaBondList (); -} -}); -Clazz.defineMethod (c$, "findChain", -function (id) { -for (var i = 0; i < this.chains.size (); i++) { -if (this.chains.elementAt (i).id.equals (id)) { -return this.chains.elementAt (i); -}} -return null; -}, "~S"); -Clazz.defineMethod (c$, "setChargeColours", -function () { -for (var i = 0; i < this.chains.size (); i++) { -this.chains.elementAt (i).setChargeColours (); -} -}); -Clazz.defineMethod (c$, "setColours", -function (cs) { -for (var i = 0; i < this.chains.size (); i++) { -this.chains.elementAt (i).setChainColours (cs); -} -}, "jalview.schemes.ColourSchemeI"); -Clazz.defineMethod (c$, "setChainColours", -function () { -for (var i = 0; i < this.chains.size (); i++) { -this.chains.elementAt (i).setChainColours (java.awt.Color.getHSBColor (1.0 / i, .4, 1.0)); -} -}); -c$.isRNA = Clazz.defineMethod (c$, "isRNA", -function (seq) { -for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) { -if ((c != 'A') && (c != 'C') && (c != 'G') && (c != 'U')) { -return false; -}} -return true; -}, "jalview.datamodel.SequenceI"); -Clazz.defineStatics (c$, -"CALC_ID_PREFIX", "JalviewPDB"); -}); +Clazz.declarePackage ("MCview"); +Clazz.load (["jalview.io.AlignFile"], "MCview.PDBfile", ["MCview.Atom", "$.PDBChain", "jalview.analysis.AlignSeq", "jalview.datamodel.Alignment", "$.AlignmentI", "$.PDBEntry", "jalview.io.FileParse", "jalview.util.MessageManager", "java.awt.Color", "java.io.IOException", "java.util.ArrayList", "$.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.chains = null; +this.id = null; +this.visibleChainAnnotation = false; +this.$predictSecondaryStructure = true; +this.externalSecondaryStructure = false; +Clazz.instantialize (this, arguments); +}, MCview, "PDBfile", jalview.io.AlignFile); +Clazz.makeConstructor (c$, +function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr) { +Clazz.superConstructor (this, MCview.PDBfile); +this.visibleChainAnnotation = addAlignmentAnnotations; +this.$predictSecondaryStructure = predictSecondaryStructure; +this.externalSecondaryStructure = externalSecStr; +}, "~B,~B,~B"); +Clazz.makeConstructor (c$, +function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr, file, protocol) { +Clazz.superConstructor (this, MCview.PDBfile, [false, file, protocol]); +this.visibleChainAnnotation = addAlignmentAnnotations; +this.$predictSecondaryStructure = predictSecondaryStructure; +this.externalSecondaryStructure = externalSecStr; +this.doParse (); +}, "~B,~B,~B,~S,~S"); +Clazz.makeConstructor (c$, +function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr, source) { +Clazz.superConstructor (this, MCview.PDBfile, [false, source]); +this.visibleChainAnnotation = addAlignmentAnnotations; +this.$predictSecondaryStructure = predictSecondaryStructure; +this.externalSecondaryStructure = externalSecStr; +this.doParse (); +}, "~B,~B,~B,jalview.io.FileParse"); +Clazz.overrideMethod (c$, "print", +function () { +return null; +}); +Clazz.overrideMethod (c$, "parse", +function () { +this.id = this.safeName (this.getDataName ()); +this.chains = new java.util.Vector (); +var rna = new java.util.ArrayList (); +var prot = new java.util.ArrayList (); +var tmpchain; +var line = null; +var modelFlag = false; +var terFlag = false; +var lastID = ""; +var indexx = 0; +var atomnam = null; +try { +while ((line = this.nextLine ()) != null) { +if (line.indexOf ("HEADER") == 0) { +if (line.length > 62) { +var tid; +if (line.length > 67) { +tid = line.substring (62, 67).trim (); +} else { +tid = line.substring (62).trim (); +}if (tid.length > 0) { +this.id = tid; +}continue; +}}if (line.indexOf ("SEQRES") == 0) { +}if (line.indexOf ("MODEL") == 0) { +modelFlag = true; +}if (line.indexOf ("TER") == 0) { +terFlag = true; +}if (modelFlag && line.indexOf ("ENDMDL") == 0) { +break; +}if (line.indexOf ("ATOM") == 0 || (line.indexOf ("HETATM") == 0 && !terFlag)) { +terFlag = false; +atomnam = line.substring (12, 15).trim (); +if (!atomnam.equals ("CA") && !atomnam.equals ("P")) { +continue; +}var tmpatom = new MCview.Atom (line); +tmpchain = this.findChain (tmpatom.chain); +if (tmpchain != null) { +if (tmpatom.resNumIns.trim ().equals (lastID)) { +continue; +}tmpchain.atoms.addElement (tmpatom); +} else { +tmpchain = new MCview.PDBChain (this.id, tmpatom.chain); +this.chains.addElement (tmpchain); +tmpchain.atoms.addElement (tmpatom); +}lastID = tmpatom.resNumIns.trim (); +}this.index++; +} +this.makeResidueList (); +this.makeCaBondList (); +if (this.id == null) { +this.id = this.inFile.getName (); +}for (var chain, $chain = this.chains.iterator (); $chain.hasNext () && ((chain = $chain.next ()) || true);) { +var chainseq = this.postProcessChain (chain); +if (MCview.PDBfile.isRNA (chainseq)) { +rna.add (chainseq); +} else { +prot.add (chainseq); +}} +if (this.$predictSecondaryStructure) { +this.predictSecondaryStructure (rna, prot); +}} catch (e$$) { +if (Clazz.exceptionOf (e$$, OutOfMemoryError)) { +var er = e$$; +{ +System.out.println ("OUT OF MEMORY LOADING PDB FILE"); +throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.outofmemory_loading_pdb_file")); +} +} else if (Clazz.exceptionOf (e$$, NumberFormatException)) { +var ex = e$$; +{ +if (line != null) { +System.err.println ("Couldn't read number from line:"); +System.err.println (line); +}} +} else { +throw e$$; +} +} +this.markCalcIds (); +}); +Clazz.defineMethod (c$, "predictSecondaryStructure", +function (rnaSequences, proteinSequences) { +if (this.externalSecondaryStructure && rnaSequences.size () > 0) { +try { +this.processPdbFileWithAnnotate3d (rnaSequences); +} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +System.err.println ("Exceptions when dealing with RNA in pdb file"); +x.printStackTrace (); +} else { +throw x; +} +} +}if (proteinSequences.size () > 0) { +try { +this.processPdbFileWithJmol (proteinSequences); +} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +System.err.println ("Exceptions from Jmol when processing data in pdb file"); +x.printStackTrace (); +} else { +throw x; +} +} +}}, "java.util.List,java.util.List"); +Clazz.defineMethod (c$, "postProcessChain", +function (chain) { +var dataset = chain.sequence; +dataset.setName (this.id + "|" + dataset.getName ()); +var entry = new jalview.datamodel.PDBEntry (); +entry.setId (this.id); +entry.setType (jalview.datamodel.PDBEntry.Type.PDB); +entry.setProperty ( new java.util.Hashtable ()); +if (chain.id != null) { +entry.setChainCode (String.valueOf (chain.id)); +}if (this.inFile != null) { +entry.setFile (this.inFile.getAbsolutePath ()); +} else { +entry.setFile (this.getDataName ()); +}dataset.addPDBId (entry); +var chainseq = dataset.deriveSequence (); +this.seqs.addElement (chainseq); +var chainannot = chainseq.getAnnotation (); +if (chainannot != null && this.visibleChainAnnotation) { +for (var ai = 0; ai < chainannot.length; ai++) { +chainannot[ai].visible = this.visibleChainAnnotation; +this.annotations.addElement (chainannot[ai]); +} +}return chainseq; +}, "MCview.PDBChain"); +c$.isCalcIdHandled = Clazz.defineMethod (c$, "isCalcIdHandled", +function (calcId) { +return calcId != null && (MCview.PDBfile.CALC_ID_PREFIX.equals (calcId)); +}, "~S"); +c$.isCalcIdForFile = Clazz.defineMethod (c$, "isCalcIdForFile", +function (alan, pdbFile) { +return alan.getCalcId () != null && MCview.PDBfile.CALC_ID_PREFIX.equals (alan.getCalcId ()) && pdbFile.equals (alan.getProperty ("PDBID")); +}, "jalview.datamodel.AlignmentAnnotation,~S"); +c$.relocateCalcId = Clazz.defineMethod (c$, "relocateCalcId", +function (calcId, alreadyLoadedPDB) { +var s = MCview.PDBfile.CALC_ID_PREFIX.length; +var end = calcId.indexOf (MCview.PDBfile.CALC_ID_PREFIX, s); +var between = calcId.substring (s, end - 1); +return MCview.PDBfile.CALC_ID_PREFIX + alreadyLoadedPDB.get (between) + ":" + calcId.substring (end); +}, "~S,java.util.Hashtable"); +Clazz.defineMethod (c$, "markCalcIds", +($fz = function () { +for (var sq, $sq = this.seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +if (sq.getAnnotation () != null) { +for (var aa, $aa = 0, $$aa = sq.getAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { +var oldId = aa.getCalcId (); +if (oldId == null) { +oldId = ""; +}aa.setCalcId (MCview.PDBfile.CALC_ID_PREFIX); +aa.setProperty ("PDBID", this.id); +aa.setProperty ("oldCalcId", oldId); +} +}} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "processPdbFileWithJmol", +($fz = function (prot) { +try { +var cl = Class.forName ("jalview.ext.jmol.PDBFileWithJmol"); +if (cl != null) { +var constructor = cl.getConstructor ( Clazz.newArray (-1, [jalview.io.FileParse])); +var args = Clazz.newArray (-1, [ new jalview.io.FileParse (this.getDataName (), this.type)]); +var jmf = constructor.newInstance (args); +var al = new jalview.datamodel.Alignment (cl.getMethod ("getSeqsAsArray", Clazz.newArray (-1, [])).invoke (jmf, [])); +cl.getMethod ("addAnnotations", Clazz.newArray (-1, [jalview.datamodel.AlignmentI])).invoke (jmf, [al]); +for (var sq, $sq = al.getSequences ().iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +if (sq.getDatasetSequence () != null) { +sq.getDatasetSequence ().getPDBId ().clear (); +} else { +sq.getPDBId ().clear (); +}} +this.replaceAndUpdateChains (prot, al, "pep", false); +}} catch (q) { +if (Clazz.exceptionOf (q, ClassNotFoundException)) { +} else { +throw q; +} +} +}, $fz.isPrivate = true, $fz), "java.util.List"); +Clazz.defineMethod (c$, "replaceAndUpdateChains", +($fz = function (prot, al, pep, b) { +var replaced = jalview.analysis.AlignSeq.replaceMatchingSeqsWith (this.seqs, this.annotations, prot, al, pep, false); +for (var ch, $ch = this.chains.iterator (); $ch.hasNext () && ((ch = $ch.next ()) || true);) { +var p = 0; +for (var sq, $sq = replaced.get (0).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +p++; +if (sq === ch.sequence || sq.getDatasetSequence () === ch.sequence) { +p = -p; +break; +}} +if (p < 0) { +p = -p - 1; +ch.shadow = replaced.get (1).get (p); +ch.shadowMap = (replaced.get (2).get (p)).getMappingFromS1 (false); +}} +}, $fz.isPrivate = true, $fz), "java.util.List,jalview.datamodel.AlignmentI,~S,~B"); +Clazz.defineMethod (c$, "processPdbFileWithAnnotate3d", +($fz = function (rna) { +try { +var cl = Class.forName ("jalview.ws.jws1.Annotate3D"); +if (cl != null) { +var annotate3d = cl.getConstructor ( Clazz.newArray (-1, [])).newInstance ( Clazz.newArray (-1, [])); +var al = (cl.getMethod ("getRNAMLFor", Clazz.newArray (-1, [jalview.io.FileParse])).invoke (annotate3d, Clazz.newArray (-1, [ new jalview.io.FileParse (this.getDataName (), this.type)]))); +for (var sq, $sq = al.getSequences ().iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +if (sq.getDatasetSequence () != null) { +if (sq.getDatasetSequence ().getPDBId () != null) { +sq.getDatasetSequence ().getPDBId ().clear (); +}} else { +if (sq.getPDBId () != null) { +sq.getPDBId ().clear (); +}}} +this.replaceAndUpdateChains (rna, al, "dna", false); +}} catch (x) { +if (Clazz.exceptionOf (x, ClassNotFoundException)) { +} else { +throw x; +} +} +;}, $fz.isPrivate = true, $fz), "java.util.List"); +Clazz.defineMethod (c$, "safeName", +($fz = function (dataName) { +var p = 0; +while ((p = dataName.indexOf ("/")) > -1 && p < dataName.length) { +dataName = dataName.substring (p + 1); +} +return dataName; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "makeResidueList", +function () { +for (var i = 0; i < this.chains.size (); i++) { +this.chains.elementAt (i).makeResidueList (this.visibleChainAnnotation); +} +}); +Clazz.defineMethod (c$, "makeCaBondList", +function () { +for (var i = 0; i < this.chains.size (); i++) { +this.chains.elementAt (i).makeCaBondList (); +} +}); +Clazz.defineMethod (c$, "findChain", +function (id) { +for (var i = 0; i < this.chains.size (); i++) { +if (this.chains.elementAt (i).id.equals (id)) { +return this.chains.elementAt (i); +}} +return null; +}, "~S"); +Clazz.defineMethod (c$, "setChargeColours", +function () { +for (var i = 0; i < this.chains.size (); i++) { +this.chains.elementAt (i).setChargeColours (); +} +}); +Clazz.defineMethod (c$, "setColours", +function (cs) { +for (var i = 0; i < this.chains.size (); i++) { +this.chains.elementAt (i).setChainColours (cs); +} +}, "jalview.schemes.ColourSchemeI"); +Clazz.defineMethod (c$, "setChainColours", +function () { +for (var i = 0; i < this.chains.size (); i++) { +this.chains.elementAt (i).setChainColours (java.awt.Color.getHSBColor (1.0 / i, .4, 1.0)); +} +}); +c$.isRNA = Clazz.defineMethod (c$, "isRNA", +function (seq) { +for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) { +if ((c != 'A') && (c != 'C') && (c != 'G') && (c != 'U')) { +return false; +}} +return true; +}, "jalview.datamodel.SequenceI"); +Clazz.defineStatics (c$, +"CALC_ID_PREFIX", "JalviewPDB"); +}); diff --git a/bin/MCview/Residue.js b/bin/MCview/Residue.js index 6cb43ed..93e2930 100644 --- a/bin/MCview/Residue.js +++ b/bin/MCview/Residue.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("MCview"); -c$ = Clazz.decorateAsClass (function () { -this.atoms = null; -this.number = 0; -this.count = 0; -Clazz.instantialize (this, arguments); -}, MCview, "Residue"); -Clazz.makeConstructor (c$, -function (resAtoms, number, count) { -this.atoms = resAtoms; -this.number = number; -this.count = count; -}, "java.util.Vector,~N,~N"); -Clazz.defineMethod (c$, "findAtom", -function (name) { -for (var atom, $atom = this.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { -if (atom.name.equals (name)) { -return atom; -}} -return null; -}, "~S"); +Clazz.declarePackage ("MCview"); +c$ = Clazz.decorateAsClass (function () { +this.atoms = null; +this.number = 0; +this.count = 0; +Clazz.instantialize (this, arguments); +}, MCview, "Residue"); +Clazz.makeConstructor (c$, +function (resAtoms, number, count) { +this.atoms = resAtoms; +this.number = number; +this.count = count; +}, "java.util.Vector,~N,~N"); +Clazz.defineMethod (c$, "findAtom", +function (name) { +for (var atom, $atom = this.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { +if (atom.name.equals (name)) { +return atom; +}} +return null; +}, "~S"); diff --git a/bin/awt2swing/Button.js b/bin/awt2swing/Button.js index 80ce87e..b25baa7 100644 --- a/bin/awt2swing/Button.js +++ b/bin/awt2swing/Button.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JButton"], "awt2swing.Button", null, function () { -c$ = Clazz.declareType (awt2swing, "Button", javax.swing.JButton); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JButton"], "awt2swing.Button", null, function () { +c$ = Clazz.declareType (awt2swing, "Button", javax.swing.JButton); +}); diff --git a/bin/awt2swing/Canvas.js b/bin/awt2swing/Canvas.js index cf449b4..df3f0b9 100644 --- a/bin/awt2swing/Canvas.js +++ b/bin/awt2swing/Canvas.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["awt2swing.Panel"], "awt2swing.Canvas", null, function () { -c$ = Clazz.declareType (awt2swing, "Canvas", awt2swing.Panel); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["awt2swing.Panel"], "awt2swing.Canvas", null, function () { +c$ = Clazz.declareType (awt2swing, "Canvas", awt2swing.Panel); +}); diff --git a/bin/awt2swing/Checkbox.js b/bin/awt2swing/Checkbox.js index cfc477c..cd50679 100644 --- a/bin/awt2swing/Checkbox.js +++ b/bin/awt2swing/Checkbox.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JCheckBox"], "awt2swing.Checkbox", null, function () { -c$ = Clazz.declareType (awt2swing, "Checkbox", javax.swing.JCheckBox); -Clazz.defineMethod (c$, "getState", -function () { -return this.isSelected (); -}); -Clazz.defineMethod (c$, "setState", -function (b) { -this.setSelected (b); -}, "~B"); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JCheckBox"], "awt2swing.Checkbox", null, function () { +c$ = Clazz.declareType (awt2swing, "Checkbox", javax.swing.JCheckBox); +Clazz.defineMethod (c$, "getState", +function () { +return this.isSelected (); +}); +Clazz.defineMethod (c$, "setState", +function (b) { +this.setSelected (b); +}, "~B"); +}); diff --git a/bin/awt2swing/CheckboxMenuItem.js b/bin/awt2swing/CheckboxMenuItem.js index 9364af7..782c150 100644 --- a/bin/awt2swing/CheckboxMenuItem.js +++ b/bin/awt2swing/CheckboxMenuItem.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JCheckBoxMenuItem"], "awt2swing.CheckboxMenuItem", null, function () { -c$ = Clazz.declareType (awt2swing, "CheckboxMenuItem", javax.swing.JCheckBoxMenuItem); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, awt2swing.CheckboxMenuItem, []); -}); -Clazz.overrideMethod (c$, "getState", -function () { -return this.isSelected (); -}); -Clazz.overrideMethod (c$, "setState", -function (tf) { -this.setSelected (tf); -}, "~B"); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JCheckBoxMenuItem"], "awt2swing.CheckboxMenuItem", null, function () { +c$ = Clazz.declareType (awt2swing, "CheckboxMenuItem", javax.swing.JCheckBoxMenuItem); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, awt2swing.CheckboxMenuItem, []); +}); +Clazz.overrideMethod (c$, "getState", +function () { +return this.isSelected (); +}); +Clazz.overrideMethod (c$, "setState", +function (tf) { +this.setSelected (tf); +}, "~B"); +}); diff --git a/bin/awt2swing/Choice.js b/bin/awt2swing/Choice.js index 0eb2843..a4208b1 100644 --- a/bin/awt2swing/Choice.js +++ b/bin/awt2swing/Choice.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JComboBox"], "awt2swing.Choice", null, function () { -c$ = Clazz.declareType (awt2swing, "Choice", javax.swing.JComboBox); -Clazz.defineMethod (c$, "select", -function (key) { -this.setSelectedItem (key); -}, "~O"); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JComboBox"], "awt2swing.Choice", null, function () { +c$ = Clazz.declareType (awt2swing, "Choice", javax.swing.JComboBox); +Clazz.defineMethod (c$, "select", +function (key) { +this.setSelectedItem (key); +}, "~O"); +}); diff --git a/bin/awt2swing/Frame.js b/bin/awt2swing/Frame.js index a4e228b..027d871 100644 --- a/bin/awt2swing/Frame.js +++ b/bin/awt2swing/Frame.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JFrame"], "awt2swing.Frame", null, function () { -c$ = Clazz.declareType (awt2swing, "Frame", javax.swing.JFrame); -Clazz.defineMethod (c$, "remove", -function (i) { -{ -this.removeInt(i); -}}, "~N"); -Clazz.defineMethod (c$, "setMenuBar", -function (m) { -this.setJMenuBar (m); -}, "awt2swing.MenuBar"); -Clazz.defineMethod (c$, "unsetMenuBar", -function () { -this.setJMenuBar (null); -}); -Clazz.defineMethod (c$, "getMenubar", -function () { -return this.getJMenuBar (); -}); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JFrame"], "awt2swing.Frame", null, function () { +c$ = Clazz.declareType (awt2swing, "Frame", javax.swing.JFrame); +Clazz.defineMethod (c$, "remove", +function (i) { +{ +this.removeInt(i); +}}, "~N"); +Clazz.defineMethod (c$, "setMenuBar", +function (m) { +this.setJMenuBar (m); +}, "awt2swing.MenuBar"); +Clazz.defineMethod (c$, "unsetMenuBar", +function () { +this.setJMenuBar (null); +}); +Clazz.defineMethod (c$, "getMenubar", +function () { +return this.getJMenuBar (); +}); +}); diff --git a/bin/awt2swing/Label.js b/bin/awt2swing/Label.js index 713f8b3..380eaf6 100644 --- a/bin/awt2swing/Label.js +++ b/bin/awt2swing/Label.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JLabel"], "awt2swing.Label", null, function () { -c$ = Clazz.declareType (awt2swing, "Label", javax.swing.JLabel); -Clazz.defineMethod (c$, "setAlignment", -function (alignment) { -this.setAlignmentX (alignment); -}, "~N"); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JLabel"], "awt2swing.Label", null, function () { +c$ = Clazz.declareType (awt2swing, "Label", javax.swing.JLabel); +Clazz.defineMethod (c$, "setAlignment", +function (alignment) { +this.setAlignmentX (alignment); +}, "~N"); +}); diff --git a/bin/awt2swing/Menu.js b/bin/awt2swing/Menu.js index 867b6ab..da1b846 100644 --- a/bin/awt2swing/Menu.js +++ b/bin/awt2swing/Menu.js @@ -1,14 +1,14 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JMenu"], "awt2swing.Menu", null, function () { -c$ = Clazz.declareType (awt2swing, "Menu", javax.swing.JMenu); -Clazz.makeConstructor (c$, -function (title) { -Clazz.superConstructor (this, awt2swing.Menu, [title]); -title = null; -}, "~S"); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, awt2swing.Menu); -var s = null; -}); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JMenu"], "awt2swing.Menu", null, function () { +c$ = Clazz.declareType (awt2swing, "Menu", javax.swing.JMenu); +Clazz.makeConstructor (c$, +function (title) { +Clazz.superConstructor (this, awt2swing.Menu, [title]); +title = null; +}, "~S"); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, awt2swing.Menu); +var s = null; +}); +}); diff --git a/bin/awt2swing/MenuBar.js b/bin/awt2swing/MenuBar.js index 3b43191..4865fdd 100644 --- a/bin/awt2swing/MenuBar.js +++ b/bin/awt2swing/MenuBar.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JMenuBar"], "awt2swing.MenuBar", null, function () { -c$ = Clazz.declareType (awt2swing, "MenuBar", javax.swing.JMenuBar); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JMenuBar"], "awt2swing.MenuBar", null, function () { +c$ = Clazz.declareType (awt2swing, "MenuBar", javax.swing.JMenuBar); +}); diff --git a/bin/awt2swing/MenuItem.js b/bin/awt2swing/MenuItem.js index f610760..d20f729 100644 --- a/bin/awt2swing/MenuItem.js +++ b/bin/awt2swing/MenuItem.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JMenuItem"], "awt2swing.MenuItem", null, function () { -c$ = Clazz.declareType (awt2swing, "MenuItem", javax.swing.JMenuItem); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JMenuItem"], "awt2swing.MenuItem", null, function () { +c$ = Clazz.declareType (awt2swing, "MenuItem", javax.swing.JMenuItem); +}); diff --git a/bin/awt2swing/Panel.js b/bin/awt2swing/Panel.js index b6061d0..5e33047 100644 --- a/bin/awt2swing/Panel.js +++ b/bin/awt2swing/Panel.js @@ -1,9 +1,9 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JPanel"], "awt2swing.Panel", null, function () { -c$ = Clazz.declareType (awt2swing, "Panel", javax.swing.JPanel); -Clazz.defineMethod (c$, "setName", -function (name) { -System.out.println (name); -Clazz.superCall (this, awt2swing.Panel, "setName", [name]); -}, "~S"); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JPanel"], "awt2swing.Panel", null, function () { +c$ = Clazz.declareType (awt2swing, "Panel", javax.swing.JPanel); +Clazz.defineMethod (c$, "setName", +function (name) { +System.out.println (name); +Clazz.superCall (this, awt2swing.Panel, "setName", [name]); +}, "~S"); +}); diff --git a/bin/awt2swing/PopupMenu.js b/bin/awt2swing/PopupMenu.js index 4af0e16..007642a 100644 --- a/bin/awt2swing/PopupMenu.js +++ b/bin/awt2swing/PopupMenu.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JPopupMenu"], "awt2swing.PopupMenu", null, function () { -c$ = Clazz.declareType (awt2swing, "PopupMenu", javax.swing.JPopupMenu); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JPopupMenu"], "awt2swing.PopupMenu", null, function () { +c$ = Clazz.declareType (awt2swing, "PopupMenu", javax.swing.JPopupMenu); +}); diff --git a/bin/awt2swing/ScrollPane.js b/bin/awt2swing/ScrollPane.js index 3ba78cf..2ea1cea 100644 --- a/bin/awt2swing/ScrollPane.js +++ b/bin/awt2swing/ScrollPane.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JScrollPane"], "awt2swing.ScrollPane", null, function () { -c$ = Clazz.declareType (awt2swing, "ScrollPane", javax.swing.JScrollPane); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JScrollPane"], "awt2swing.ScrollPane", null, function () { +c$ = Clazz.declareType (awt2swing, "ScrollPane", javax.swing.JScrollPane); +}); diff --git a/bin/awt2swing/Scrollbar.js b/bin/awt2swing/Scrollbar.js index 3859a96..b68bd0c 100644 --- a/bin/awt2swing/Scrollbar.js +++ b/bin/awt2swing/Scrollbar.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JScrollBar"], "awt2swing.Scrollbar", null, function () { -c$ = Clazz.declareType (awt2swing, "Scrollbar", javax.swing.JScrollBar); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JScrollBar"], "awt2swing.Scrollbar", null, function () { +c$ = Clazz.declareType (awt2swing, "Scrollbar", javax.swing.JScrollBar); +}); diff --git a/bin/awt2swing/TextArea.js b/bin/awt2swing/TextArea.js index 4358c37..3aec891 100644 --- a/bin/awt2swing/TextArea.js +++ b/bin/awt2swing/TextArea.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JTextArea"], "awt2swing.TextArea", null, function () { -c$ = Clazz.declareType (awt2swing, "TextArea", javax.swing.JTextArea); -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JTextArea"], "awt2swing.TextArea", null, function () { +c$ = Clazz.declareType (awt2swing, "TextArea", javax.swing.JTextArea); +}); diff --git a/bin/awt2swing/TextField.js b/bin/awt2swing/TextField.js index ef48b75..e8c1558 100644 --- a/bin/awt2swing/TextField.js +++ b/bin/awt2swing/TextField.js @@ -1,23 +1,23 @@ -Clazz.declarePackage ("awt2swing"); -Clazz.load (["javax.swing.JTextField"], "awt2swing.TextField", ["java.awt.event.TextEvent", "javax.swing.event.DocumentListener"], function () { -c$ = Clazz.declareType (awt2swing, "TextField", javax.swing.JTextField); -Clazz.defineMethod (c$, "addTextListener", -function (textListener) { -this.getDocument ().addDocumentListener (((Clazz.isClassDefined ("awt2swing.TextField$1") ? 0 : awt2swing.TextField.$TextField$1$ ()), Clazz.innerTypeInstance (awt2swing.TextField$1, this, Clazz.cloneFinals ("textListener", textListener)))); -}, "java.awt.event.TextListener"); -c$.$TextField$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (awt2swing, "TextField$1", null, javax.swing.event.DocumentListener); -Clazz.overrideMethod (c$, "insertUpdate", -function (e) { -}, "javax.swing.event.DocumentEvent"); -Clazz.overrideMethod (c$, "removeUpdate", -function (e) { -}, "javax.swing.event.DocumentEvent"); -Clazz.overrideMethod (c$, "changedUpdate", -function (e) { -this.f$.textListener.textValueChanged ( new java.awt.event.TextEvent (this, 0)); -}, "javax.swing.event.DocumentEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("awt2swing"); +Clazz.load (["javax.swing.JTextField"], "awt2swing.TextField", ["java.awt.event.TextEvent", "javax.swing.event.DocumentListener"], function () { +c$ = Clazz.declareType (awt2swing, "TextField", javax.swing.JTextField); +Clazz.defineMethod (c$, "addTextListener", +function (textListener) { +this.getDocument ().addDocumentListener (((Clazz.isClassDefined ("awt2swing.TextField$1") ? 0 : awt2swing.TextField.$TextField$1$ ()), Clazz.innerTypeInstance (awt2swing.TextField$1, this, Clazz.cloneFinals ("textListener", textListener)))); +}, "java.awt.event.TextListener"); +c$.$TextField$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (awt2swing, "TextField$1", null, javax.swing.event.DocumentListener); +Clazz.overrideMethod (c$, "insertUpdate", +function (e) { +}, "javax.swing.event.DocumentEvent"); +Clazz.overrideMethod (c$, "removeUpdate", +function (e) { +}, "javax.swing.event.DocumentEvent"); +Clazz.overrideMethod (c$, "changedUpdate", +function (e) { +this.f$.textListener.textValueChanged ( new java.awt.event.TextEvent (this, 0)); +}, "javax.swing.event.DocumentEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/com/stevesoft/pat/AmpersandRule.js b/bin/com/stevesoft/pat/AmpersandRule.js index 6d1f622..ac1ce77 100644 --- a/bin/com/stevesoft/pat/AmpersandRule.js +++ b/bin/com/stevesoft/pat/AmpersandRule.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.AmpersandRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "AmpersandRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.AmpersandRule, []); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -sb.append (res.stringMatched ()); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return "$&"; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.AmpersandRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "AmpersandRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.AmpersandRule, []); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +sb.append (res.stringMatched ()); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return "$&"; +}); +}); diff --git a/bin/com/stevesoft/pat/Any.js b/bin/com/stevesoft/pat/Any.js index 503de21..f129d92 100644 --- a/bin/com/stevesoft/pat/Any.js +++ b/bin/com/stevesoft/pat/Any.js @@ -1,30 +1,30 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Any", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "Any", com.stevesoft.pat.Pattern); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (pos < pt.src.length ()) { -if (pt.dotDoesntMatchCR) { -if (pt.src.charAt (pos) != '\n') { -return this.nextMatch (pos + 1, pt); -}} else { -return this.nextMatch (pos + 1, pt); -}}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -return "." + this.nextString (); -}); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.Any (); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Any", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "Any", com.stevesoft.pat.Pattern); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (pos < pt.src.length ()) { +if (pt.dotDoesntMatchCR) { +if (pt.src.charAt (pos) != '\n') { +return this.nextMatch (pos + 1, pt); +}} else { +return this.nextMatch (pos + 1, pt); +}}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +return "." + this.nextString (); +}); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.Any (); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/BackG.js b/bin/com/stevesoft/pat/BackG.js index a9d07b7..28d17cd 100644 --- a/bin/com/stevesoft/pat/BackG.js +++ b/bin/com/stevesoft/pat/BackG.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.BackG", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.c = '\0'; -this.altc = '\0'; -this.altc2 = '\0'; -this.mask = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "BackG", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.BackG, []); -}); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -return pos == pt.lastPos ? this.nextMatch (pos, pt) : -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -return "\\G" + this.nextString (); -}); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.BackG (); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.BackG", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.c = '\0'; +this.altc = '\0'; +this.altc2 = '\0'; +this.mask = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "BackG", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.BackG, []); +}); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +return pos == pt.lastPos ? this.nextMatch (pos, pt) : -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +return "\\G" + this.nextString (); +}); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.BackG (); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/BackMatch.js b/bin/com/stevesoft/pat/BackMatch.js index f3a2ea9..018cdda 100644 --- a/bin/com/stevesoft/pat/BackMatch.js +++ b/bin/com/stevesoft/pat/BackMatch.js @@ -1,36 +1,36 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.BackMatch", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.id = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "BackMatch", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (id) { -Clazz.superConstructor (this, com.stevesoft.pat.BackMatch, []); -this.id = id; -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return "\\" + (this.id) + this.nextString (); -}); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, p) { -var i1 = p.marks[this.id]; -var i2 = p.marks[this.id + p.nMarks]; -var imax = i2 - i1; -if (i1 < 0 || imax < 0 || pos + imax > p.src.length ()) { -return -1; -}var ns = p.src.length () - pos; -if (imax < ns) { -ns = imax; -}for (var i = 0; i < ns; i++) { -if (p.src.charAt (i + i1) != p.src.charAt (pos + i)) { -return -1; -}} -return this.nextMatch (pos + imax, p); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.BackMatch (this.id); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.BackMatch", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.id = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "BackMatch", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (id) { +Clazz.superConstructor (this, com.stevesoft.pat.BackMatch, []); +this.id = id; +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return "\\" + (this.id) + this.nextString (); +}); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, p) { +var i1 = p.marks[this.id]; +var i2 = p.marks[this.id + p.nMarks]; +var imax = i2 - i1; +if (i1 < 0 || imax < 0 || pos + imax > p.src.length ()) { +return -1; +}var ns = p.src.length () - pos; +if (imax < ns) { +ns = imax; +}for (var i = 0; i < ns; i++) { +if (p.src.charAt (i + i1) != p.src.charAt (pos + i)) { +return -1; +}} +return this.nextMatch (pos + imax, p); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.BackMatch (this.id); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/BackRefRule.js b/bin/com/stevesoft/pat/BackRefRule.js index f744c08..d6a1e2e 100644 --- a/bin/com/stevesoft/pat/BackRefRule.js +++ b/bin/com/stevesoft/pat/BackRefRule.js @@ -1,25 +1,25 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.BackRefRule", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.n = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "BackRefRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function (n) { -Clazz.superConstructor (this, com.stevesoft.pat.BackRefRule, []); -this.n = n; -}, "~N"); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -var x = res.stringMatchedI (this.n); -sb.append (x == null ? "" : x); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return "$" + this.n; -}); -Clazz.overrideMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.BackRefRule (this.n); -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.BackRefRule", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.n = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "BackRefRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function (n) { +Clazz.superConstructor (this, com.stevesoft.pat.BackRefRule, []); +this.n = n; +}, "~N"); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +var x = res.stringMatchedI (this.n); +sb.append (x == null ? "" : x); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return "$" + this.n; +}); +Clazz.overrideMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.BackRefRule (this.n); +}); +}); diff --git a/bin/com/stevesoft/pat/Backup.js b/bin/com/stevesoft/pat/Backup.js index 3063b71..f155142 100644 --- a/bin/com/stevesoft/pat/Backup.js +++ b/bin/com/stevesoft/pat/Backup.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Backup", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.bk = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Backup", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (ii) { -Clazz.superConstructor (this, com.stevesoft.pat.Backup, []); -this.bk = ii; -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(?" + (this.bk < 0 ? ">" + (-this.bk) : "<" + this.bk) + ")" + this.nextString (); -}); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (pos < this.bk) { -return -1; -}return this.nextMatch (pos - this.bk, pt); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (-this.bk); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (-this.bk); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.Backup (this.bk); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Backup", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.bk = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Backup", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (ii) { +Clazz.superConstructor (this, com.stevesoft.pat.Backup, []); +this.bk = ii; +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(?" + (this.bk < 0 ? ">" + (-this.bk) : "<" + this.bk) + ")" + this.nextString (); +}); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (pos < this.bk) { +return -1; +}return this.nextMatch (pos - this.bk, pt); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (-this.bk); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (-this.bk); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.Backup (this.bk); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/BasicStringBufferLike.js b/bin/com/stevesoft/pat/BasicStringBufferLike.js index c492d08..f4df37f 100644 --- a/bin/com/stevesoft/pat/BasicStringBufferLike.js +++ b/bin/com/stevesoft/pat/BasicStringBufferLike.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.declareInterface (com.stevesoft.pat, "BasicStringBufferLike"); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.declareInterface (com.stevesoft.pat, "BasicStringBufferLike"); diff --git a/bin/com/stevesoft/pat/Bits.js b/bin/com/stevesoft/pat/Bits.js index 61bb0fd..ec8b74c 100644 --- a/bin/com/stevesoft/pat/Bits.js +++ b/bin/com/stevesoft/pat/Bits.js @@ -1,2958 +1,2958 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -c$ = Clazz.decorateAsClass (function () { -this.carray = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Bits"); -Clazz.makeConstructor (c$, -function (carray) { -this.carray = carray; -}, "~A"); -Clazz.defineMethod (c$, "get", -function (i) { -return ((this.carray[i >> 4]).charCodeAt (0) & (1 << (i & 15))) != 0; -}, "~N"); -Clazz.defineMethod (c$, "set", -function (i, b) { -if (b) { -this.carray[i >> 4] = String.fromCharCode ((this.carray[i >> 4]).charCodeAt (0) | ((String.fromCharCode (1)).charCodeAt (0) << (i & 15))); -} else { -this.carray[i >> 4] = String.fromCharCode ((this.carray[i >> 4]).charCodeAt (0) & (String.fromCharCode (~(1 << (i & 15)))).charCodeAt (0)); -}}, "~N,~B"); -c$.upper_f = Clazz.defineMethod (c$, "upper_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.upper = new com.stevesoft.pat.Bits (data); -data[4] = String.fromCharCode (0xfffe); -data[5] = String.fromCharCode (0x07ff); -data[12] = String.fromCharCode (0xffff); -data[13] = String.fromCharCode (0x7f7f); -data[16] = String.fromCharCode (0x5555); -data[17] = String.fromCharCode (0x5555); -data[18] = String.fromCharCode (0x5555); -data[19] = String.fromCharCode (0xaa55); -data[20] = String.fromCharCode (0x54aa); -data[21] = String.fromCharCode (0x5555); -data[22] = String.fromCharCode (0x5555); -data[23] = String.fromCharCode (0x2b55); -data[24] = String.fromCharCode (0xced6); -data[25] = String.fromCharCode (0xb1db); -data[26] = String.fromCharCode (0xd2d5); -data[27] = String.fromCharCode (0x11ae); -data[28] = String.fromCharCode (0xa490); -data[29] = String.fromCharCode (0x4aaa); -data[30] = String.fromCharCode (0x5555); -data[31] = String.fromCharCode (0x5412); -data[32] = String.fromCharCode (0x5555); -data[33] = 'U'; -data[56] = String.fromCharCode (0xd740); -data[57] = String.fromCharCode (0xfffe); -data[58] = String.fromCharCode (0x0ffb); -data[61] = String.fromCharCode (0x541c); -data[62] = String.fromCharCode (0x5555); -data[64] = String.fromCharCode (0xdffe); -data[65] = String.fromCharCode (0xffff); -data[66] = String.fromCharCode (0xffff); -data[70] = String.fromCharCode (0x5555); -data[71] = String.fromCharCode (0x5555); -data[72] = String.fromCharCode (0x0001); -data[73] = String.fromCharCode (0x5555); -data[74] = String.fromCharCode (0x5555); -data[75] = String.fromCharCode (0x5555); -data[76] = String.fromCharCode (0x088a); -data[77] = String.fromCharCode (0x5555); -data[78] = String.fromCharCode (0x4555); -data[79] = String.fromCharCode (0x0115); -data[83] = String.fromCharCode (0xfffe); -data[84] = String.fromCharCode (0xffff); -data[85] = String.fromCharCode (0x007f); -data[266] = String.fromCharCode (0xffff); -data[267] = String.fromCharCode (0xffff); -data[268] = String.fromCharCode (0x003f); -data[480] = String.fromCharCode (0x5555); -data[481] = String.fromCharCode (0x5555); -data[482] = String.fromCharCode (0x5555); -data[483] = String.fromCharCode (0x5555); -data[484] = String.fromCharCode (0x5555); -data[485] = String.fromCharCode (0x5555); -data[486] = String.fromCharCode (0x5555); -data[487] = String.fromCharCode (0x5555); -data[488] = String.fromCharCode (0x5555); -data[489] = String.fromCharCode (0x0015); -data[490] = String.fromCharCode (0x5555); -data[491] = String.fromCharCode (0x5555); -data[492] = String.fromCharCode (0x5555); -data[493] = String.fromCharCode (0x5555); -data[494] = String.fromCharCode (0x5555); -data[495] = String.fromCharCode (0x0155); -data[496] = String.fromCharCode (0xff00); -data[497] = String.fromCharCode (0x3f00); -data[498] = String.fromCharCode (0xff00); -data[499] = String.fromCharCode (0xff00); -data[500] = String.fromCharCode (0x3f00); -data[501] = String.fromCharCode (0xaa00); -data[502] = String.fromCharCode (0xff00); -data[504] = String.fromCharCode (0xff00); -data[505] = String.fromCharCode (0xff00); -data[506] = String.fromCharCode (0xff00); -data[507] = String.fromCharCode (0x5f00); -data[508] = String.fromCharCode (0x1f00); -data[509] = String.fromCharCode (0x0f00); -data[510] = String.fromCharCode (0x1f00); -data[511] = String.fromCharCode (0x1f00); -data[528] = String.fromCharCode (0x3884); -data[529] = String.fromCharCode (0x3f27); -data[530] = String.fromCharCode (0x3d50); -data[531] = String.fromCharCode (0x000b); -data[4082] = String.fromCharCode (0xfffe); -data[4083] = String.fromCharCode (0x07ff); -data[4100] = String.fromCharCode (0xfffe); -data[4101] = String.fromCharCode (0x07ff); -data[4108] = String.fromCharCode (0xffff); -data[4109] = String.fromCharCode (0x7f7f); -data[4112] = String.fromCharCode (0x5555); -data[4113] = String.fromCharCode (0x5555); -data[4114] = String.fromCharCode (0x5555); -data[4115] = String.fromCharCode (0xaa55); -data[4116] = String.fromCharCode (0x54aa); -data[4117] = String.fromCharCode (0x5555); -data[4118] = String.fromCharCode (0x5555); -data[4119] = String.fromCharCode (0x2b55); -data[4120] = String.fromCharCode (0xced6); -data[4121] = String.fromCharCode (0xb1db); -data[4122] = String.fromCharCode (0xd2d5); -data[4123] = String.fromCharCode (0x11ae); -data[4124] = String.fromCharCode (0xa490); -data[4125] = String.fromCharCode (0x4aaa); -data[4126] = String.fromCharCode (0x5555); -data[4127] = String.fromCharCode (0x5412); -data[4128] = String.fromCharCode (0x5555); -data[4129] = 'U'; -data[4152] = String.fromCharCode (0xd740); -data[4153] = String.fromCharCode (0xfffe); -data[4154] = String.fromCharCode (0x0ffb); -data[4157] = String.fromCharCode (0x541c); -data[4158] = 'U'; -}); -c$.lower_f = Clazz.defineMethod (c$, "lower_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.lower = new com.stevesoft.pat.Bits (data); -data[6] = String.fromCharCode (0xfffe); -data[7] = String.fromCharCode (0x07ff); -data[10] = String.fromCharCode (0x0400); -data[11] = String.fromCharCode (0x0420); -data[13] = String.fromCharCode (0x8000); -data[14] = String.fromCharCode (0xffff); -data[15] = String.fromCharCode (0xff7f); -data[16] = String.fromCharCode (0xaaaa); -data[17] = String.fromCharCode (0xaaaa); -data[18] = String.fromCharCode (0xaaaa); -data[19] = String.fromCharCode (0x55aa); -data[20] = String.fromCharCode (0xab55); -data[21] = String.fromCharCode (0xaaaa); -data[22] = String.fromCharCode (0xaaaa); -data[23] = String.fromCharCode (0xd4aa); -data[24] = String.fromCharCode (0x3129); -data[25] = String.fromCharCode (0x4e24); -data[26] = String.fromCharCode (0x292a); -data[27] = String.fromCharCode (0x2651); -data[28] = String.fromCharCode (0x5240); -data[29] = String.fromCharCode (0xb555); -data[30] = String.fromCharCode (0xaaaa); -data[31] = String.fromCharCode (0xa829); -data[32] = String.fromCharCode (0xaaaa); -data[33] = String.fromCharCode (0x00aa); -data[37] = String.fromCharCode (0xffff); -data[38] = String.fromCharCode (0xffff); -data[39] = String.fromCharCode (0xffff); -data[40] = String.fromCharCode (0xffff); -data[41] = String.fromCharCode (0xffff); -data[42] = String.fromCharCode (0x01ff); -data[57] = String.fromCharCode (0x0001); -data[58] = String.fromCharCode (0xf000); -data[59] = String.fromCharCode (0xffff); -data[60] = String.fromCharCode (0x7fff); -data[61] = 'c'; -data[62] = String.fromCharCode (0xaaa8); -data[63] = String.fromCharCode (0x0007); -data[67] = String.fromCharCode (0xffff); -data[68] = String.fromCharCode (0xffff); -data[69] = String.fromCharCode (0xdffe); -data[70] = String.fromCharCode (0xaaaa); -data[71] = String.fromCharCode (0xaaaa); -data[72] = String.fromCharCode (0x0002); -data[73] = String.fromCharCode (0xaaaa); -data[74] = String.fromCharCode (0xaaaa); -data[75] = String.fromCharCode (0xaaaa); -data[76] = String.fromCharCode (0x1114); -data[77] = String.fromCharCode (0xaaaa); -data[78] = String.fromCharCode (0x8aaa); -data[79] = String.fromCharCode (0x022a); -data[86] = String.fromCharCode (0xfffe); -data[87] = String.fromCharCode (0xffff); -data[88] = String.fromCharCode (0x00ff); -data[269] = String.fromCharCode (0xffff); -data[270] = String.fromCharCode (0xffff); -data[271] = String.fromCharCode (0x007f); -data[480] = String.fromCharCode (0xaaaa); -data[481] = String.fromCharCode (0xaaaa); -data[482] = String.fromCharCode (0xaaaa); -data[483] = String.fromCharCode (0xaaaa); -data[484] = String.fromCharCode (0xaaaa); -data[485] = String.fromCharCode (0xaaaa); -data[486] = String.fromCharCode (0xaaaa); -data[487] = String.fromCharCode (0xaaaa); -data[488] = String.fromCharCode (0xaaaa); -data[489] = String.fromCharCode (0x0fea); -data[490] = String.fromCharCode (0xaaaa); -data[491] = String.fromCharCode (0xaaaa); -data[492] = String.fromCharCode (0xaaaa); -data[493] = String.fromCharCode (0xaaaa); -data[494] = String.fromCharCode (0xaaaa); -data[495] = String.fromCharCode (0x02aa); -data[496] = String.fromCharCode (0x00ff); -data[497] = String.fromCharCode (0x003f); -data[498] = String.fromCharCode (0x00ff); -data[499] = String.fromCharCode (0x00ff); -data[500] = String.fromCharCode (0x003f); -data[501] = String.fromCharCode (0x00ff); -data[502] = String.fromCharCode (0x00ff); -data[503] = String.fromCharCode (0x3fff); -data[504] = String.fromCharCode (0x00ff); -data[505] = String.fromCharCode (0x00ff); -data[506] = String.fromCharCode (0x00ff); -data[507] = String.fromCharCode (0x00df); -data[508] = String.fromCharCode (0x00dc); -data[509] = String.fromCharCode (0x00cf); -data[510] = String.fromCharCode (0x00ff); -data[511] = String.fromCharCode (0x00dc); -data[519] = String.fromCharCode (0x8000); -data[528] = String.fromCharCode (0xc400); -data[529] = String.fromCharCode (0x0008); -data[530] = String.fromCharCode (0xc000); -data[531] = String.fromCharCode (0x0010); -data[4016] = String.fromCharCode (0x007f); -data[4017] = String.fromCharCode (0x00f8); -data[4084] = String.fromCharCode (0xfffe); -data[4085] = String.fromCharCode (0x07ff); -data[4102] = String.fromCharCode (0xfffe); -data[4103] = String.fromCharCode (0x07ff); -data[4106] = String.fromCharCode (0x0400); -data[4107] = String.fromCharCode (0x0420); -data[4109] = String.fromCharCode (0x8000); -data[4110] = String.fromCharCode (0xffff); -data[4111] = String.fromCharCode (0xff7f); -data[4112] = String.fromCharCode (0xaaaa); -data[4113] = String.fromCharCode (0xaaaa); -data[4114] = String.fromCharCode (0xaaaa); -data[4115] = String.fromCharCode (0x55aa); -data[4116] = String.fromCharCode (0xab55); -data[4117] = String.fromCharCode (0xaaaa); -data[4118] = String.fromCharCode (0xaaaa); -data[4119] = String.fromCharCode (0xd4aa); -data[4120] = String.fromCharCode (0x3129); -data[4121] = String.fromCharCode (0x4e24); -data[4122] = String.fromCharCode (0x292a); -data[4123] = String.fromCharCode (0x2651); -data[4124] = String.fromCharCode (0x5240); -data[4125] = String.fromCharCode (0xb555); -data[4126] = String.fromCharCode (0xaaaa); -data[4127] = String.fromCharCode (0xa829); -data[4128] = String.fromCharCode (0xaaaa); -data[4129] = String.fromCharCode (0x00aa); -data[4133] = String.fromCharCode (0xffff); -data[4134] = String.fromCharCode (0xffff); -data[4135] = String.fromCharCode (0xffff); -data[4136] = String.fromCharCode (0xffff); -data[4137] = String.fromCharCode (0xffff); -data[4138] = String.fromCharCode (0x01ff); -data[4153] = String.fromCharCode (0x0001); -data[4154] = String.fromCharCode (0xf000); -data[4155] = String.fromCharCode (0xffff); -data[4156] = String.fromCharCode (0x7fff); -data[4157] = 'c'; -data[4158] = String.fromCharCode (0x00a8); -}); -c$.title_f = Clazz.defineMethod (c$, "title_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.title = new com.stevesoft.pat.Bits (data); -data[6] = String.fromCharCode (0xfffe); -data[7] = String.fromCharCode (0x07ff); -data[10] = String.fromCharCode (0x0400); -data[11] = String.fromCharCode (0x0420); -data[13] = String.fromCharCode (0x8000); -data[14] = String.fromCharCode (0xffff); -data[15] = String.fromCharCode (0xff7f); -data[16] = String.fromCharCode (0xaaaa); -data[17] = String.fromCharCode (0xaaaa); -data[18] = String.fromCharCode (0xaaaa); -data[19] = String.fromCharCode (0x55aa); -data[20] = String.fromCharCode (0xab55); -data[21] = String.fromCharCode (0xaaaa); -data[22] = String.fromCharCode (0xaaaa); -data[23] = String.fromCharCode (0xd4aa); -data[24] = String.fromCharCode (0x3129); -data[25] = String.fromCharCode (0x4e24); -data[26] = String.fromCharCode (0x292a); -data[27] = String.fromCharCode (0x2651); -data[28] = String.fromCharCode (0x5240); -data[29] = String.fromCharCode (0xb555); -data[30] = String.fromCharCode (0xaaaa); -data[31] = String.fromCharCode (0xa829); -data[32] = String.fromCharCode (0xaaaa); -data[33] = String.fromCharCode (0x00aa); -data[37] = String.fromCharCode (0xffff); -data[38] = String.fromCharCode (0xffff); -data[39] = String.fromCharCode (0xffff); -data[40] = String.fromCharCode (0xffff); -data[41] = String.fromCharCode (0xffff); -data[42] = String.fromCharCode (0x01ff); -data[57] = String.fromCharCode (0x0001); -data[58] = String.fromCharCode (0xf000); -data[59] = String.fromCharCode (0xffff); -data[60] = String.fromCharCode (0x7fff); -data[61] = 'c'; -data[62] = String.fromCharCode (0xaaa8); -data[63] = String.fromCharCode (0x0007); -data[67] = String.fromCharCode (0xffff); -data[68] = String.fromCharCode (0xffff); -data[69] = String.fromCharCode (0xdffe); -data[70] = String.fromCharCode (0xaaaa); -data[71] = String.fromCharCode (0xaaaa); -data[72] = String.fromCharCode (0x0002); -data[73] = String.fromCharCode (0xaaaa); -data[74] = String.fromCharCode (0xaaaa); -data[75] = String.fromCharCode (0xaaaa); -data[76] = String.fromCharCode (0x1114); -data[77] = String.fromCharCode (0xaaaa); -data[78] = String.fromCharCode (0x8aaa); -data[79] = String.fromCharCode (0x022a); -data[86] = String.fromCharCode (0xfffe); -data[87] = String.fromCharCode (0xffff); -data[88] = String.fromCharCode (0x00ff); -data[269] = String.fromCharCode (0xffff); -data[270] = String.fromCharCode (0xffff); -data[271] = String.fromCharCode (0x007f); -data[480] = String.fromCharCode (0xaaaa); -data[481] = String.fromCharCode (0xaaaa); -data[482] = String.fromCharCode (0xaaaa); -data[483] = String.fromCharCode (0xaaaa); -data[484] = String.fromCharCode (0xaaaa); -data[485] = String.fromCharCode (0xaaaa); -data[486] = String.fromCharCode (0xaaaa); -data[487] = String.fromCharCode (0xaaaa); -data[488] = String.fromCharCode (0xaaaa); -data[489] = String.fromCharCode (0x0fea); -data[490] = String.fromCharCode (0xaaaa); -data[491] = String.fromCharCode (0xaaaa); -data[492] = String.fromCharCode (0xaaaa); -data[493] = String.fromCharCode (0xaaaa); -data[494] = String.fromCharCode (0xaaaa); -data[495] = String.fromCharCode (0x02aa); -data[496] = String.fromCharCode (0x00ff); -data[497] = String.fromCharCode (0x003f); -data[498] = String.fromCharCode (0x00ff); -data[499] = String.fromCharCode (0x00ff); -data[500] = String.fromCharCode (0x003f); -data[501] = String.fromCharCode (0x00ff); -data[502] = String.fromCharCode (0x00ff); -data[503] = String.fromCharCode (0x3fff); -data[504] = String.fromCharCode (0x00ff); -data[505] = String.fromCharCode (0x00ff); -data[506] = String.fromCharCode (0x00ff); -data[507] = String.fromCharCode (0x00df); -data[508] = String.fromCharCode (0x00dc); -data[509] = String.fromCharCode (0x00cf); -data[510] = String.fromCharCode (0x00ff); -data[511] = String.fromCharCode (0x00dc); -data[519] = String.fromCharCode (0x8000); -data[528] = String.fromCharCode (0xc400); -data[529] = String.fromCharCode (0x0008); -data[530] = String.fromCharCode (0xc000); -data[531] = String.fromCharCode (0x0010); -data[4016] = String.fromCharCode (0x007f); -data[4017] = String.fromCharCode (0x00f8); -data[4084] = String.fromCharCode (0xfffe); -data[4085] = String.fromCharCode (0x07ff); -data[4102] = String.fromCharCode (0xfffe); -data[4103] = String.fromCharCode (0x07ff); -data[4106] = String.fromCharCode (0x0400); -data[4107] = String.fromCharCode (0x0420); -data[4109] = String.fromCharCode (0x8000); -data[4110] = String.fromCharCode (0xffff); -data[4111] = String.fromCharCode (0xff7f); -data[4112] = String.fromCharCode (0xaaaa); -data[4113] = String.fromCharCode (0xaaaa); -data[4114] = String.fromCharCode (0xaaaa); -data[4115] = String.fromCharCode (0x55aa); -data[4116] = String.fromCharCode (0xab55); -data[4117] = String.fromCharCode (0xaaaa); -data[4118] = String.fromCharCode (0xaaaa); -data[4119] = String.fromCharCode (0xd4aa); -data[4120] = String.fromCharCode (0x3129); -data[4121] = String.fromCharCode (0x4e24); -data[4122] = String.fromCharCode (0x292a); -data[4123] = String.fromCharCode (0x2651); -data[4124] = String.fromCharCode (0x5240); -data[4125] = String.fromCharCode (0xb555); -data[4126] = String.fromCharCode (0xaaaa); -data[4127] = String.fromCharCode (0xa829); -data[4128] = String.fromCharCode (0xaaaa); -data[4129] = String.fromCharCode (0x00aa); -data[4133] = String.fromCharCode (0xffff); -data[4134] = String.fromCharCode (0xffff); -data[4135] = String.fromCharCode (0xffff); -data[4136] = String.fromCharCode (0xffff); -data[4137] = String.fromCharCode (0xffff); -data[4138] = String.fromCharCode (0x01ff); -data[4153] = String.fromCharCode (0x0001); -data[4154] = String.fromCharCode (0xf000); -data[4155] = String.fromCharCode (0xffff); -data[4156] = String.fromCharCode (0x7fff); -data[4157] = 'c'; -data[4158] = String.fromCharCode (0x00a8); -}); -c$.currency_f = Clazz.defineMethod (c$, "currency_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.currency = new com.stevesoft.pat.Bits (data); -data[2] = String.fromCharCode (0x0010); -data[10] = String.fromCharCode (0x003c); -data[159] = String.fromCharCode (0x000c); -data[227] = String.fromCharCode (0x8000); -data[522] = String.fromCharCode (0x1fff); -data[4070] = String.fromCharCode (0x0200); -data[4080] = String.fromCharCode (0x0010); -data[4094] = 'c'; -data[4098] = String.fromCharCode (0x0010); -data[4106] = String.fromCharCode (0x003c); -}); -c$.decimal_digit_f = Clazz.defineMethod (c$, "decimal_digit_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.decimal_digit = new com.stevesoft.pat.Bits (data); -data[3] = String.fromCharCode (0x03ff); -data[102] = String.fromCharCode (0x03ff); -data[111] = String.fromCharCode (0x03ff); -data[150] = String.fromCharCode (0xffc0); -data[158] = String.fromCharCode (0xffc0); -data[166] = String.fromCharCode (0xffc0); -data[174] = String.fromCharCode (0xffc0); -data[182] = String.fromCharCode (0xffc0); -data[190] = String.fromCharCode (0xff80); -data[198] = String.fromCharCode (0xffc0); -data[206] = String.fromCharCode (0xffc0); -data[214] = String.fromCharCode (0xffc0); -data[229] = String.fromCharCode (0x03ff); -data[237] = String.fromCharCode (0x03ff); -data[242] = String.fromCharCode (0x03ff); -data[4081] = String.fromCharCode (0x03ff); -data[4099] = String.fromCharCode (0x03ff); -}); -c$.math_f = Clazz.defineMethod (c$, "math_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.math = new com.stevesoft.pat.Bits (data); -data[2] = String.fromCharCode (0x0800); -data[3] = String.fromCharCode (0x7000); -data[7] = String.fromCharCode (0x5000); -data[10] = String.fromCharCode (0x1000); -data[11] = String.fromCharCode (0x0002); -data[13] = String.fromCharCode (0x0080); -data[15] = String.fromCharCode (0x0080); -data[516] = String.fromCharCode (0x0010); -data[519] = String.fromCharCode (0x1c00); -data[520] = String.fromCharCode (0x1c00); -data[537] = String.fromCharCode (0x001f); -data[541] = String.fromCharCode (0x0014); -data[544] = String.fromCharCode (0xffff); -data[545] = String.fromCharCode (0xffff); -data[546] = String.fromCharCode (0xffff); -data[547] = String.fromCharCode (0xffff); -data[548] = String.fromCharCode (0xffff); -data[549] = String.fromCharCode (0xffff); -data[550] = String.fromCharCode (0xffff); -data[551] = String.fromCharCode (0xffff); -data[552] = String.fromCharCode (0xffff); -data[553] = String.fromCharCode (0xffff); -data[554] = String.fromCharCode (0xffff); -data[555] = String.fromCharCode (0xffff); -data[556] = String.fromCharCode (0xffff); -data[557] = String.fromCharCode (0xffff); -data[558] = String.fromCharCode (0xffff); -data[559] = String.fromCharCode (0x0003); -data[560] = String.fromCharCode (0x0f00); -data[562] = String.fromCharCode (0x0003); -data[4018] = String.fromCharCode (0x0200); -data[4070] = 't'; -data[4080] = String.fromCharCode (0x0800); -data[4081] = String.fromCharCode (0x7000); -data[4085] = String.fromCharCode (0x5000); -data[4094] = String.fromCharCode (0x1f04); -data[4098] = String.fromCharCode (0x0800); -data[4099] = String.fromCharCode (0x7000); -data[4103] = String.fromCharCode (0x5000); -data[4106] = String.fromCharCode (0x1000); -data[4107] = String.fromCharCode (0x0002); -data[4109] = String.fromCharCode (0x0080); -data[4111] = String.fromCharCode (0x0080); -}); -c$.letter_f = Clazz.defineMethod (c$, "letter_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.letter = new com.stevesoft.pat.Bits (data); -data[4] = String.fromCharCode (0xfffe); -data[5] = String.fromCharCode (0x07ff); -data[6] = String.fromCharCode (0xfffe); -data[7] = String.fromCharCode (0x07ff); -data[10] = String.fromCharCode (0x0400); -data[11] = String.fromCharCode (0x0420); -data[12] = String.fromCharCode (0xffff); -data[13] = String.fromCharCode (0xff7f); -data[14] = String.fromCharCode (0xffff); -data[15] = String.fromCharCode (0xff7f); -data[16] = String.fromCharCode (0xffff); -data[17] = String.fromCharCode (0xffff); -data[18] = String.fromCharCode (0xffff); -data[19] = String.fromCharCode (0xffff); -data[20] = String.fromCharCode (0xffff); -data[21] = String.fromCharCode (0xffff); -data[22] = String.fromCharCode (0xffff); -data[23] = String.fromCharCode (0xffff); -data[24] = String.fromCharCode (0xffff); -data[25] = String.fromCharCode (0xffff); -data[26] = String.fromCharCode (0xffff); -data[27] = String.fromCharCode (0xffff); -data[28] = String.fromCharCode (0xffff); -data[29] = String.fromCharCode (0xffff); -data[30] = String.fromCharCode (0xffff); -data[31] = String.fromCharCode (0xfc3f); -data[32] = String.fromCharCode (0xffff); -data[33] = String.fromCharCode (0x00ff); -data[37] = String.fromCharCode (0xffff); -data[38] = String.fromCharCode (0xffff); -data[39] = String.fromCharCode (0xffff); -data[40] = String.fromCharCode (0xffff); -data[41] = String.fromCharCode (0xffff); -data[42] = String.fromCharCode (0x01ff); -data[43] = String.fromCharCode (0xf9ff); -data[44] = String.fromCharCode (0x0003); -data[45] = String.fromCharCode (0x0003); -data[46] = String.fromCharCode (0x001f); -data[55] = String.fromCharCode (0x0400); -data[56] = String.fromCharCode (0xd740); -data[57] = String.fromCharCode (0xffff); -data[58] = String.fromCharCode (0xfffb); -data[59] = String.fromCharCode (0xffff); -data[60] = String.fromCharCode (0x7fff); -data[61] = String.fromCharCode (0x547f); -data[62] = String.fromCharCode (0xfffd); -data[63] = String.fromCharCode (0x000f); -data[64] = String.fromCharCode (0xdffe); -data[65] = String.fromCharCode (0xffff); -data[66] = String.fromCharCode (0xffff); -data[67] = String.fromCharCode (0xffff); -data[68] = String.fromCharCode (0xffff); -data[69] = String.fromCharCode (0xdffe); -data[70] = String.fromCharCode (0xffff); -data[71] = String.fromCharCode (0xffff); -data[72] = String.fromCharCode (0x0003); -data[73] = String.fromCharCode (0xffff); -data[74] = String.fromCharCode (0xffff); -data[75] = String.fromCharCode (0xffff); -data[76] = String.fromCharCode (0x199f); -data[77] = String.fromCharCode (0xffff); -data[78] = String.fromCharCode (0xcfff); -data[79] = String.fromCharCode (0x033f); -data[83] = String.fromCharCode (0xfffe); -data[84] = String.fromCharCode (0xffff); -data[85] = String.fromCharCode (0x027f); -data[86] = String.fromCharCode (0xfffe); -data[87] = String.fromCharCode (0xffff); -data[88] = String.fromCharCode (0x00ff); -data[93] = String.fromCharCode (0xffff); -data[94] = String.fromCharCode (0x07ff); -data[95] = String.fromCharCode (0x0007); -data[98] = String.fromCharCode (0xfffe); -data[99] = String.fromCharCode (0x07ff); -data[100] = String.fromCharCode (0x07ff); -data[103] = String.fromCharCode (0xfffe); -data[104] = String.fromCharCode (0xffff); -data[105] = String.fromCharCode (0xffff); -data[106] = String.fromCharCode (0xffff); -data[107] = String.fromCharCode (0x7cff); -data[108] = String.fromCharCode (0x7fff); -data[109] = String.fromCharCode (0x002f); -data[110] = String.fromCharCode (0x0060); -data[144] = String.fromCharCode (0xffe0); -data[145] = String.fromCharCode (0xffff); -data[146] = String.fromCharCode (0xffff); -data[147] = String.fromCharCode (0x23ff); -data[149] = String.fromCharCode (0xff00); -data[150] = String.fromCharCode (0x0003); -data[152] = String.fromCharCode (0x9fe0); -data[153] = String.fromCharCode (0xfff9); -data[154] = String.fromCharCode (0xfdff); -data[155] = String.fromCharCode (0x03c5); -data[157] = String.fromCharCode (0xb000); -data[158] = String.fromCharCode (0x0003); -data[159] = String.fromCharCode (0x0003); -data[160] = String.fromCharCode (0x87e0); -data[161] = String.fromCharCode (0xfff9); -data[162] = String.fromCharCode (0xfdff); -data[163] = String.fromCharCode (0x036d); -data[165] = String.fromCharCode (0x5e00); -data[167] = String.fromCharCode (0x001c); -data[168] = String.fromCharCode (0xafe0); -data[169] = String.fromCharCode (0xfffb); -data[170] = String.fromCharCode (0xfdff); -data[171] = String.fromCharCode (0x23ed); -data[174] = String.fromCharCode (0x0001); -data[176] = String.fromCharCode (0x9fe0); -data[177] = String.fromCharCode (0xfff9); -data[178] = String.fromCharCode (0xfdff); -data[179] = String.fromCharCode (0x23cd); -data[181] = String.fromCharCode (0xb000); -data[182] = String.fromCharCode (0x0003); -data[184] = String.fromCharCode (0xc7e0); -data[185] = String.fromCharCode (0xd63d); -data[186] = String.fromCharCode (0xc718); -data[187] = String.fromCharCode (0x03bf); -data[192] = String.fromCharCode (0xdfe0); -data[193] = String.fromCharCode (0xfffd); -data[194] = String.fromCharCode (0xfdff); -data[195] = String.fromCharCode (0x03ef); -data[198] = String.fromCharCode (0x0003); -data[200] = String.fromCharCode (0xdfe0); -data[201] = String.fromCharCode (0xfffd); -data[202] = String.fromCharCode (0xfdff); -data[203] = String.fromCharCode (0x03ef); -data[205] = String.fromCharCode (0x4000); -data[206] = String.fromCharCode (0x0003); -data[208] = String.fromCharCode (0xdfe0); -data[209] = String.fromCharCode (0xfffd); -data[210] = String.fromCharCode (0xfdff); -data[211] = String.fromCharCode (0x03ff); -data[214] = String.fromCharCode (0x0003); -data[224] = String.fromCharCode (0xfffe); -data[225] = String.fromCharCode (0xffff); -data[226] = String.fromCharCode (0x7fff); -data[227] = String.fromCharCode (0x000d); -data[228] = String.fromCharCode (0x007f); -data[232] = String.fromCharCode (0x2596); -data[233] = String.fromCharCode (0xfef0); -data[234] = String.fromCharCode (0x6cae); -data[235] = String.fromCharCode (0x200d); -data[236] = String.fromCharCode (0x005f); -data[237] = String.fromCharCode (0x3000); -data[244] = String.fromCharCode (0xfeff); -data[245] = String.fromCharCode (0xffff); -data[246] = String.fromCharCode (0x03ff); -data[266] = String.fromCharCode (0xffff); -data[267] = String.fromCharCode (0xffff); -data[268] = String.fromCharCode (0x003f); -data[269] = String.fromCharCode (0xffff); -data[270] = String.fromCharCode (0xffff); -data[271] = String.fromCharCode (0x007f); -data[272] = String.fromCharCode (0xffff); -data[273] = String.fromCharCode (0xffff); -data[274] = String.fromCharCode (0xffff); -data[275] = String.fromCharCode (0xffff); -data[276] = String.fromCharCode (0xffff); -data[277] = String.fromCharCode (0x83ff); -data[278] = String.fromCharCode (0xffff); -data[279] = String.fromCharCode (0xffff); -data[280] = String.fromCharCode (0xffff); -data[281] = String.fromCharCode (0xffff); -data[282] = String.fromCharCode (0xff07); -data[283] = String.fromCharCode (0xffff); -data[284] = String.fromCharCode (0xffff); -data[285] = String.fromCharCode (0xffff); -data[286] = String.fromCharCode (0xffff); -data[287] = String.fromCharCode (0x03ff); -data[480] = String.fromCharCode (0xffff); -data[481] = String.fromCharCode (0xffff); -data[482] = String.fromCharCode (0xffff); -data[483] = String.fromCharCode (0xffff); -data[484] = String.fromCharCode (0xffff); -data[485] = String.fromCharCode (0xffff); -data[486] = String.fromCharCode (0xffff); -data[487] = String.fromCharCode (0xffff); -data[488] = String.fromCharCode (0xffff); -data[489] = String.fromCharCode (0x0fff); -data[490] = String.fromCharCode (0xffff); -data[491] = String.fromCharCode (0xffff); -data[492] = String.fromCharCode (0xffff); -data[493] = String.fromCharCode (0xffff); -data[494] = String.fromCharCode (0xffff); -data[495] = String.fromCharCode (0x03ff); -data[496] = String.fromCharCode (0xffff); -data[497] = String.fromCharCode (0x3f3f); -data[498] = String.fromCharCode (0xffff); -data[499] = String.fromCharCode (0xffff); -data[500] = String.fromCharCode (0x3f3f); -data[501] = String.fromCharCode (0xaaff); -data[502] = String.fromCharCode (0xffff); -data[503] = String.fromCharCode (0x3fff); -data[504] = String.fromCharCode (0xffff); -data[505] = String.fromCharCode (0xffff); -data[506] = String.fromCharCode (0xffff); -data[507] = String.fromCharCode (0x5fdf); -data[508] = String.fromCharCode (0x1fdc); -data[509] = String.fromCharCode (0x0fcf); -data[510] = String.fromCharCode (0x1fff); -data[511] = String.fromCharCode (0x1fdc); -data[519] = String.fromCharCode (0x8000); -data[528] = String.fromCharCode (0xfc84); -data[529] = String.fromCharCode (0x3f2f); -data[530] = String.fromCharCode (0xfd50); -data[531] = String.fromCharCode (0x01fb); -data[768] = String.fromCharCode (0x0020); -data[771] = String.fromCharCode (0x003e); -data[772] = String.fromCharCode (0xfffe); -data[773] = String.fromCharCode (0xffff); -data[774] = String.fromCharCode (0xffff); -data[775] = String.fromCharCode (0xffff); -data[776] = String.fromCharCode (0xffff); -data[777] = String.fromCharCode (0x781f); -data[778] = String.fromCharCode (0xfffe); -data[779] = String.fromCharCode (0xffff); -data[780] = String.fromCharCode (0xffff); -data[781] = String.fromCharCode (0xffff); -data[782] = String.fromCharCode (0xffff); -data[783] = String.fromCharCode (0x77ff); -data[784] = String.fromCharCode (0xffe0); -data[785] = String.fromCharCode (0xffff); -data[786] = String.fromCharCode (0x1fff); -data[787] = String.fromCharCode (0xfffe); -data[788] = String.fromCharCode (0xffff); -data[789] = String.fromCharCode (0xffff); -data[790] = String.fromCharCode (0xffff); -data[791] = String.fromCharCode (0xffff); -data[792] = String.fromCharCode (0x7fff); -data[1248] = String.fromCharCode (0xffff); -data[1249] = String.fromCharCode (0xffff); -data[1250] = String.fromCharCode (0xffff); -data[1251] = String.fromCharCode (0xffff); -data[1252] = String.fromCharCode (0xffff); -data[1253] = String.fromCharCode (0xffff); -data[1254] = String.fromCharCode (0xffff); -data[1255] = String.fromCharCode (0xffff); -data[1256] = String.fromCharCode (0xffff); -data[1257] = String.fromCharCode (0xffff); -data[1258] = String.fromCharCode (0xffff); -data[1259] = String.fromCharCode (0xffff); -data[1260] = String.fromCharCode (0xffff); -data[1261] = String.fromCharCode (0xffff); -data[1262] = String.fromCharCode (0xffff); -data[1263] = String.fromCharCode (0xffff); -data[1264] = String.fromCharCode (0xffff); -data[1265] = String.fromCharCode (0xffff); -data[1266] = String.fromCharCode (0xffff); -data[1267] = String.fromCharCode (0xffff); -data[1268] = String.fromCharCode (0xffff); -data[1269] = String.fromCharCode (0xffff); -data[1270] = String.fromCharCode (0xffff); -data[1271] = String.fromCharCode (0xffff); -data[1272] = String.fromCharCode (0xffff); -data[1273] = String.fromCharCode (0xffff); -data[1274] = String.fromCharCode (0xffff); -data[1275] = String.fromCharCode (0xffff); -data[1276] = String.fromCharCode (0xffff); -data[1277] = String.fromCharCode (0xffff); -data[1278] = String.fromCharCode (0xffff); -data[1279] = String.fromCharCode (0xffff); -data[1280] = String.fromCharCode (0xffff); -data[1281] = String.fromCharCode (0xffff); -data[1282] = String.fromCharCode (0xffff); -data[1283] = String.fromCharCode (0xffff); -data[1284] = String.fromCharCode (0xffff); -data[1285] = String.fromCharCode (0xffff); -data[1286] = String.fromCharCode (0xffff); -data[1287] = String.fromCharCode (0xffff); -data[1288] = String.fromCharCode (0xffff); -data[1289] = String.fromCharCode (0xffff); -data[1290] = String.fromCharCode (0xffff); -data[1291] = String.fromCharCode (0xffff); -data[1292] = String.fromCharCode (0xffff); -data[1293] = String.fromCharCode (0xffff); -data[1294] = String.fromCharCode (0xffff); -data[1295] = String.fromCharCode (0xffff); -data[1296] = String.fromCharCode (0xffff); -data[1297] = String.fromCharCode (0xffff); -data[1298] = String.fromCharCode (0xffff); -data[1299] = String.fromCharCode (0xffff); -data[1300] = String.fromCharCode (0xffff); -data[1301] = String.fromCharCode (0xffff); -data[1302] = String.fromCharCode (0xffff); -data[1303] = String.fromCharCode (0xffff); -data[1304] = String.fromCharCode (0xffff); -data[1305] = String.fromCharCode (0xffff); -data[1306] = String.fromCharCode (0xffff); -data[1307] = String.fromCharCode (0xffff); -data[1308] = String.fromCharCode (0xffff); -data[1309] = String.fromCharCode (0xffff); -data[1310] = String.fromCharCode (0xffff); -data[1311] = String.fromCharCode (0xffff); -data[1312] = String.fromCharCode (0xffff); -data[1313] = String.fromCharCode (0xffff); -data[1314] = String.fromCharCode (0xffff); -data[1315] = String.fromCharCode (0xffff); -data[1316] = String.fromCharCode (0xffff); -data[1317] = String.fromCharCode (0xffff); -data[1318] = String.fromCharCode (0xffff); -data[1319] = String.fromCharCode (0xffff); -data[1320] = String.fromCharCode (0xffff); -data[1321] = String.fromCharCode (0xffff); -data[1322] = String.fromCharCode (0xffff); -data[1323] = String.fromCharCode (0xffff); -data[1324] = String.fromCharCode (0xffff); -data[1325] = String.fromCharCode (0xffff); -data[1326] = String.fromCharCode (0xffff); -data[1327] = String.fromCharCode (0xffff); -data[1328] = String.fromCharCode (0xffff); -data[1329] = String.fromCharCode (0xffff); -data[1330] = String.fromCharCode (0xffff); -data[1331] = String.fromCharCode (0xffff); -data[1332] = String.fromCharCode (0xffff); -data[1333] = String.fromCharCode (0xffff); -data[1334] = String.fromCharCode (0xffff); -data[1335] = String.fromCharCode (0xffff); -data[1336] = String.fromCharCode (0xffff); -data[1337] = String.fromCharCode (0xffff); -data[1338] = String.fromCharCode (0xffff); -data[1339] = String.fromCharCode (0xffff); -data[1340] = String.fromCharCode (0xffff); -data[1341] = String.fromCharCode (0xffff); -data[1342] = String.fromCharCode (0xffff); -data[1343] = String.fromCharCode (0xffff); -data[1344] = String.fromCharCode (0xffff); -data[1345] = String.fromCharCode (0xffff); -data[1346] = String.fromCharCode (0xffff); -data[1347] = String.fromCharCode (0xffff); -data[1348] = String.fromCharCode (0xffff); -data[1349] = String.fromCharCode (0xffff); -data[1350] = String.fromCharCode (0xffff); -data[1351] = String.fromCharCode (0xffff); -data[1352] = String.fromCharCode (0xffff); -data[1353] = String.fromCharCode (0xffff); -data[1354] = String.fromCharCode (0xffff); -data[1355] = String.fromCharCode (0xffff); -data[1356] = String.fromCharCode (0xffff); -data[1357] = String.fromCharCode (0xffff); -data[1358] = String.fromCharCode (0xffff); -data[1359] = String.fromCharCode (0xffff); -data[1360] = String.fromCharCode (0xffff); -data[1361] = String.fromCharCode (0xffff); -data[1362] = String.fromCharCode (0xffff); -data[1363] = String.fromCharCode (0xffff); -data[1364] = String.fromCharCode (0xffff); -data[1365] = String.fromCharCode (0xffff); -data[1366] = String.fromCharCode (0xffff); -data[1367] = String.fromCharCode (0xffff); -data[1368] = String.fromCharCode (0xffff); -data[1369] = String.fromCharCode (0xffff); -data[1370] = String.fromCharCode (0xffff); -data[1371] = String.fromCharCode (0xffff); -data[1372] = String.fromCharCode (0xffff); -data[1373] = String.fromCharCode (0xffff); -data[1374] = String.fromCharCode (0xffff); -data[1375] = String.fromCharCode (0xffff); -data[1376] = String.fromCharCode (0xffff); -data[1377] = String.fromCharCode (0xffff); -data[1378] = String.fromCharCode (0xffff); -data[1379] = String.fromCharCode (0xffff); -data[1380] = String.fromCharCode (0xffff); -data[1381] = String.fromCharCode (0xffff); -data[1382] = String.fromCharCode (0xffff); -data[1383] = String.fromCharCode (0xffff); -data[1384] = String.fromCharCode (0xffff); -data[1385] = String.fromCharCode (0xffff); -data[1386] = String.fromCharCode (0xffff); -data[1387] = String.fromCharCode (0xffff); -data[1388] = String.fromCharCode (0xffff); -data[1389] = String.fromCharCode (0xffff); -data[1390] = String.fromCharCode (0xffff); -data[1391] = String.fromCharCode (0xffff); -data[1392] = String.fromCharCode (0xffff); -data[1393] = String.fromCharCode (0xffff); -data[1394] = String.fromCharCode (0xffff); -data[1395] = String.fromCharCode (0xffff); -data[1396] = String.fromCharCode (0xffff); -data[1397] = String.fromCharCode (0xffff); -data[1398] = String.fromCharCode (0xffff); -data[1399] = String.fromCharCode (0xffff); -data[1400] = String.fromCharCode (0xffff); -data[1401] = String.fromCharCode (0xffff); -data[1402] = String.fromCharCode (0xffff); -data[1403] = String.fromCharCode (0xffff); -data[1404] = String.fromCharCode (0xffff); -data[1405] = String.fromCharCode (0xffff); -data[1406] = String.fromCharCode (0xffff); -data[1407] = String.fromCharCode (0xffff); -data[1408] = String.fromCharCode (0xffff); -data[1409] = String.fromCharCode (0xffff); -data[1410] = String.fromCharCode (0xffff); -data[1411] = String.fromCharCode (0xffff); -data[1412] = String.fromCharCode (0xffff); -data[1413] = String.fromCharCode (0xffff); -data[1414] = String.fromCharCode (0xffff); -data[1415] = String.fromCharCode (0xffff); -data[1416] = String.fromCharCode (0xffff); -data[1417] = String.fromCharCode (0xffff); -data[1418] = String.fromCharCode (0xffff); -data[1419] = String.fromCharCode (0xffff); -data[1420] = String.fromCharCode (0xffff); -data[1421] = String.fromCharCode (0xffff); -data[1422] = String.fromCharCode (0xffff); -data[1423] = String.fromCharCode (0xffff); -data[1424] = String.fromCharCode (0xffff); -data[1425] = String.fromCharCode (0xffff); -data[1426] = String.fromCharCode (0xffff); -data[1427] = String.fromCharCode (0xffff); -data[1428] = String.fromCharCode (0xffff); -data[1429] = String.fromCharCode (0xffff); -data[1430] = String.fromCharCode (0xffff); -data[1431] = String.fromCharCode (0xffff); -data[1432] = String.fromCharCode (0xffff); -data[1433] = String.fromCharCode (0xffff); -data[1434] = String.fromCharCode (0xffff); -data[1435] = String.fromCharCode (0xffff); -data[1436] = String.fromCharCode (0xffff); -data[1437] = String.fromCharCode (0xffff); -data[1438] = String.fromCharCode (0xffff); -data[1439] = String.fromCharCode (0xffff); -data[1440] = String.fromCharCode (0xffff); -data[1441] = String.fromCharCode (0xffff); -data[1442] = String.fromCharCode (0xffff); -data[1443] = String.fromCharCode (0xffff); -data[1444] = String.fromCharCode (0xffff); -data[1445] = String.fromCharCode (0xffff); -data[1446] = String.fromCharCode (0xffff); -data[1447] = String.fromCharCode (0xffff); -data[1448] = String.fromCharCode (0xffff); -data[1449] = String.fromCharCode (0xffff); -data[1450] = String.fromCharCode (0xffff); -data[1451] = String.fromCharCode (0xffff); -data[1452] = String.fromCharCode (0xffff); -data[1453] = String.fromCharCode (0xffff); -data[1454] = String.fromCharCode (0xffff); -data[1455] = String.fromCharCode (0xffff); -data[1456] = String.fromCharCode (0xffff); -data[1457] = String.fromCharCode (0xffff); -data[1458] = String.fromCharCode (0xffff); -data[1459] = String.fromCharCode (0xffff); -data[1460] = String.fromCharCode (0xffff); -data[1461] = String.fromCharCode (0xffff); -data[1462] = String.fromCharCode (0xffff); -data[1463] = String.fromCharCode (0xffff); -data[1464] = String.fromCharCode (0xffff); -data[1465] = String.fromCharCode (0xffff); -data[1466] = String.fromCharCode (0xffff); -data[1467] = String.fromCharCode (0xffff); -data[1468] = String.fromCharCode (0xffff); -data[1469] = String.fromCharCode (0xffff); -data[1470] = String.fromCharCode (0xffff); -data[1471] = String.fromCharCode (0xffff); -data[1472] = String.fromCharCode (0xffff); -data[1473] = String.fromCharCode (0xffff); -data[1474] = String.fromCharCode (0xffff); -data[1475] = String.fromCharCode (0xffff); -data[1476] = String.fromCharCode (0xffff); -data[1477] = String.fromCharCode (0xffff); -data[1478] = String.fromCharCode (0xffff); -data[1479] = String.fromCharCode (0xffff); -data[1480] = String.fromCharCode (0xffff); -data[1481] = String.fromCharCode (0xffff); -data[1482] = String.fromCharCode (0xffff); -data[1483] = String.fromCharCode (0xffff); -data[1484] = String.fromCharCode (0xffff); -data[1485] = String.fromCharCode (0xffff); -data[1486] = String.fromCharCode (0xffff); -data[1487] = String.fromCharCode (0xffff); -data[1488] = String.fromCharCode (0xffff); -data[1489] = String.fromCharCode (0xffff); -data[1490] = String.fromCharCode (0xffff); -data[1491] = String.fromCharCode (0xffff); -data[1492] = String.fromCharCode (0xffff); -data[1493] = String.fromCharCode (0xffff); -data[1494] = String.fromCharCode (0xffff); -data[1495] = String.fromCharCode (0xffff); -data[1496] = String.fromCharCode (0xffff); -data[1497] = String.fromCharCode (0xffff); -data[1498] = String.fromCharCode (0xffff); -data[1499] = String.fromCharCode (0xffff); -data[1500] = String.fromCharCode (0xffff); -data[1501] = String.fromCharCode (0xffff); -data[1502] = String.fromCharCode (0xffff); -data[1503] = String.fromCharCode (0xffff); -data[1504] = String.fromCharCode (0xffff); -data[1505] = String.fromCharCode (0xffff); -data[1506] = String.fromCharCode (0xffff); -data[1507] = String.fromCharCode (0xffff); -data[1508] = String.fromCharCode (0xffff); -data[1509] = String.fromCharCode (0xffff); -data[1510] = String.fromCharCode (0xffff); -data[1511] = String.fromCharCode (0xffff); -data[1512] = String.fromCharCode (0xffff); -data[1513] = String.fromCharCode (0xffff); -data[1514] = String.fromCharCode (0xffff); -data[1515] = String.fromCharCode (0xffff); -data[1516] = String.fromCharCode (0xffff); -data[1517] = String.fromCharCode (0xffff); -data[1518] = String.fromCharCode (0xffff); -data[1519] = String.fromCharCode (0xffff); -data[1520] = String.fromCharCode (0xffff); -data[1521] = String.fromCharCode (0xffff); -data[1522] = String.fromCharCode (0xffff); -data[1523] = String.fromCharCode (0xffff); -data[1524] = String.fromCharCode (0xffff); -data[1525] = String.fromCharCode (0xffff); -data[1526] = String.fromCharCode (0xffff); -data[1527] = String.fromCharCode (0xffff); -data[1528] = String.fromCharCode (0xffff); -data[1529] = String.fromCharCode (0xffff); -data[1530] = String.fromCharCode (0xffff); -data[1531] = String.fromCharCode (0xffff); -data[1532] = String.fromCharCode (0xffff); -data[1533] = String.fromCharCode (0xffff); -data[1534] = String.fromCharCode (0xffff); -data[1535] = String.fromCharCode (0xffff); -data[1536] = String.fromCharCode (0xffff); -data[1537] = String.fromCharCode (0xffff); -data[1538] = String.fromCharCode (0xffff); -data[1539] = String.fromCharCode (0xffff); -data[1540] = String.fromCharCode (0xffff); -data[1541] = String.fromCharCode (0xffff); -data[1542] = String.fromCharCode (0xffff); -data[1543] = String.fromCharCode (0xffff); -data[1544] = String.fromCharCode (0xffff); -data[1545] = String.fromCharCode (0xffff); -data[1546] = String.fromCharCode (0xffff); -data[1547] = String.fromCharCode (0xffff); -data[1548] = String.fromCharCode (0xffff); -data[1549] = String.fromCharCode (0xffff); -data[1550] = String.fromCharCode (0xffff); -data[1551] = String.fromCharCode (0xffff); -data[1552] = String.fromCharCode (0xffff); -data[1553] = String.fromCharCode (0xffff); -data[1554] = String.fromCharCode (0xffff); -data[1555] = String.fromCharCode (0xffff); -data[1556] = String.fromCharCode (0xffff); -data[1557] = String.fromCharCode (0xffff); -data[1558] = String.fromCharCode (0xffff); -data[1559] = String.fromCharCode (0xffff); -data[1560] = String.fromCharCode (0xffff); -data[1561] = String.fromCharCode (0xffff); -data[1562] = String.fromCharCode (0xffff); -data[1563] = String.fromCharCode (0xffff); -data[1564] = String.fromCharCode (0xffff); -data[1565] = String.fromCharCode (0xffff); -data[1566] = String.fromCharCode (0xffff); -data[1567] = String.fromCharCode (0xffff); -data[1568] = String.fromCharCode (0xffff); -data[1569] = String.fromCharCode (0xffff); -data[1570] = String.fromCharCode (0xffff); -data[1571] = String.fromCharCode (0xffff); -data[1572] = String.fromCharCode (0xffff); -data[1573] = String.fromCharCode (0xffff); -data[1574] = String.fromCharCode (0xffff); -data[1575] = String.fromCharCode (0xffff); -data[1576] = String.fromCharCode (0xffff); -data[1577] = String.fromCharCode (0xffff); -data[1578] = String.fromCharCode (0xffff); -data[1579] = String.fromCharCode (0xffff); -data[1580] = String.fromCharCode (0xffff); -data[1581] = String.fromCharCode (0xffff); -data[1582] = String.fromCharCode (0xffff); -data[1583] = String.fromCharCode (0xffff); -data[1584] = String.fromCharCode (0xffff); -data[1585] = String.fromCharCode (0xffff); -data[1586] = String.fromCharCode (0xffff); -data[1587] = String.fromCharCode (0xffff); -data[1588] = String.fromCharCode (0xffff); -data[1589] = String.fromCharCode (0xffff); -data[1590] = String.fromCharCode (0xffff); -data[1591] = String.fromCharCode (0xffff); -data[1592] = String.fromCharCode (0xffff); -data[1593] = String.fromCharCode (0xffff); -data[1594] = String.fromCharCode (0xffff); -data[1595] = String.fromCharCode (0xffff); -data[1596] = String.fromCharCode (0xffff); -data[1597] = String.fromCharCode (0xffff); -data[1598] = String.fromCharCode (0xffff); -data[1599] = String.fromCharCode (0xffff); -data[1600] = String.fromCharCode (0xffff); -data[1601] = String.fromCharCode (0xffff); -data[1602] = String.fromCharCode (0xffff); -data[1603] = String.fromCharCode (0xffff); -data[1604] = String.fromCharCode (0xffff); -data[1605] = String.fromCharCode (0xffff); -data[1606] = String.fromCharCode (0xffff); -data[1607] = String.fromCharCode (0xffff); -data[1608] = String.fromCharCode (0xffff); -data[1609] = String.fromCharCode (0xffff); -data[1610] = String.fromCharCode (0xffff); -data[1611] = String.fromCharCode (0xffff); -data[1612] = String.fromCharCode (0xffff); -data[1613] = String.fromCharCode (0xffff); -data[1614] = String.fromCharCode (0xffff); -data[1615] = String.fromCharCode (0xffff); -data[1616] = String.fromCharCode (0xffff); -data[1617] = String.fromCharCode (0xffff); -data[1618] = String.fromCharCode (0xffff); -data[1619] = String.fromCharCode (0xffff); -data[1620] = String.fromCharCode (0xffff); -data[1621] = String.fromCharCode (0xffff); -data[1622] = String.fromCharCode (0xffff); -data[1623] = String.fromCharCode (0xffff); -data[1624] = String.fromCharCode (0xffff); -data[1625] = String.fromCharCode (0xffff); -data[1626] = String.fromCharCode (0xffff); -data[1627] = String.fromCharCode (0xffff); -data[1628] = String.fromCharCode (0xffff); -data[1629] = String.fromCharCode (0xffff); -data[1630] = String.fromCharCode (0xffff); -data[1631] = String.fromCharCode (0xffff); -data[1632] = String.fromCharCode (0xffff); -data[1633] = String.fromCharCode (0xffff); -data[1634] = String.fromCharCode (0xffff); -data[1635] = String.fromCharCode (0xffff); -data[1636] = String.fromCharCode (0xffff); -data[1637] = String.fromCharCode (0xffff); -data[1638] = String.fromCharCode (0xffff); -data[1639] = String.fromCharCode (0xffff); -data[1640] = String.fromCharCode (0xffff); -data[1641] = String.fromCharCode (0xffff); -data[1642] = String.fromCharCode (0xffff); -data[1643] = String.fromCharCode (0xffff); -data[1644] = String.fromCharCode (0xffff); -data[1645] = String.fromCharCode (0xffff); -data[1646] = String.fromCharCode (0xffff); -data[1647] = String.fromCharCode (0xffff); -data[1648] = String.fromCharCode (0xffff); -data[1649] = String.fromCharCode (0xffff); -data[1650] = String.fromCharCode (0xffff); -data[1651] = String.fromCharCode (0xffff); -data[1652] = String.fromCharCode (0xffff); -data[1653] = String.fromCharCode (0xffff); -data[1654] = String.fromCharCode (0xffff); -data[1655] = String.fromCharCode (0xffff); -data[1656] = String.fromCharCode (0xffff); -data[1657] = String.fromCharCode (0xffff); -data[1658] = String.fromCharCode (0xffff); -data[1659] = String.fromCharCode (0xffff); -data[1660] = String.fromCharCode (0xffff); -data[1661] = String.fromCharCode (0xffff); -data[1662] = String.fromCharCode (0xffff); -data[1663] = String.fromCharCode (0xffff); -data[1664] = String.fromCharCode (0xffff); -data[1665] = String.fromCharCode (0xffff); -data[1666] = String.fromCharCode (0xffff); -data[1667] = String.fromCharCode (0xffff); -data[1668] = String.fromCharCode (0xffff); -data[1669] = String.fromCharCode (0xffff); -data[1670] = String.fromCharCode (0xffff); -data[1671] = String.fromCharCode (0xffff); -data[1672] = String.fromCharCode (0xffff); -data[1673] = String.fromCharCode (0xffff); -data[1674] = String.fromCharCode (0xffff); -data[1675] = String.fromCharCode (0xffff); -data[1676] = String.fromCharCode (0xffff); -data[1677] = String.fromCharCode (0xffff); -data[1678] = String.fromCharCode (0xffff); -data[1679] = String.fromCharCode (0xffff); -data[1680] = String.fromCharCode (0xffff); -data[1681] = String.fromCharCode (0xffff); -data[1682] = String.fromCharCode (0xffff); -data[1683] = String.fromCharCode (0xffff); -data[1684] = String.fromCharCode (0xffff); -data[1685] = String.fromCharCode (0xffff); -data[1686] = String.fromCharCode (0xffff); -data[1687] = String.fromCharCode (0xffff); -data[1688] = String.fromCharCode (0xffff); -data[1689] = String.fromCharCode (0xffff); -data[1690] = String.fromCharCode (0xffff); -data[1691] = String.fromCharCode (0xffff); -data[1692] = String.fromCharCode (0xffff); -data[1693] = String.fromCharCode (0xffff); -data[1694] = String.fromCharCode (0xffff); -data[1695] = String.fromCharCode (0xffff); -data[1696] = String.fromCharCode (0xffff); -data[1697] = String.fromCharCode (0xffff); -data[1698] = String.fromCharCode (0xffff); -data[1699] = String.fromCharCode (0xffff); -data[1700] = String.fromCharCode (0xffff); -data[1701] = String.fromCharCode (0xffff); -data[1702] = String.fromCharCode (0xffff); -data[1703] = String.fromCharCode (0xffff); -data[1704] = String.fromCharCode (0xffff); -data[1705] = String.fromCharCode (0xffff); -data[1706] = String.fromCharCode (0xffff); -data[1707] = String.fromCharCode (0xffff); -data[1708] = String.fromCharCode (0xffff); -data[1709] = String.fromCharCode (0xffff); -data[1710] = String.fromCharCode (0xffff); -data[1711] = String.fromCharCode (0xffff); -data[1712] = String.fromCharCode (0xffff); -data[1713] = String.fromCharCode (0xffff); -data[1714] = String.fromCharCode (0xffff); -data[1715] = String.fromCharCode (0xffff); -data[1716] = String.fromCharCode (0xffff); -data[1717] = String.fromCharCode (0xffff); -data[1718] = String.fromCharCode (0xffff); -data[1719] = String.fromCharCode (0xffff); -data[1720] = String.fromCharCode (0xffff); -data[1721] = String.fromCharCode (0xffff); -data[1722] = String.fromCharCode (0xffff); -data[1723] = String.fromCharCode (0xffff); -data[1724] = String.fromCharCode (0xffff); -data[1725] = String.fromCharCode (0xffff); -data[1726] = String.fromCharCode (0xffff); -data[1727] = String.fromCharCode (0xffff); -data[1728] = String.fromCharCode (0xffff); -data[1729] = String.fromCharCode (0xffff); -data[1730] = String.fromCharCode (0xffff); -data[1731] = String.fromCharCode (0xffff); -data[1732] = String.fromCharCode (0xffff); -data[1733] = String.fromCharCode (0xffff); -data[1734] = String.fromCharCode (0xffff); -data[1735] = String.fromCharCode (0xffff); -data[1736] = String.fromCharCode (0xffff); -data[1737] = String.fromCharCode (0xffff); -data[1738] = String.fromCharCode (0xffff); -data[1739] = String.fromCharCode (0xffff); -data[1740] = String.fromCharCode (0xffff); -data[1741] = String.fromCharCode (0xffff); -data[1742] = String.fromCharCode (0xffff); -data[1743] = String.fromCharCode (0xffff); -data[1744] = String.fromCharCode (0xffff); -data[1745] = String.fromCharCode (0xffff); -data[1746] = String.fromCharCode (0xffff); -data[1747] = String.fromCharCode (0xffff); -data[1748] = String.fromCharCode (0xffff); -data[1749] = String.fromCharCode (0xffff); -data[1750] = String.fromCharCode (0xffff); -data[1751] = String.fromCharCode (0xffff); -data[1752] = String.fromCharCode (0xffff); -data[1753] = String.fromCharCode (0xffff); -data[1754] = String.fromCharCode (0xffff); -data[1755] = String.fromCharCode (0xffff); -data[1756] = String.fromCharCode (0xffff); -data[1757] = String.fromCharCode (0xffff); -data[1758] = String.fromCharCode (0xffff); -data[1759] = String.fromCharCode (0xffff); -data[1760] = String.fromCharCode (0xffff); -data[1761] = String.fromCharCode (0xffff); -data[1762] = String.fromCharCode (0xffff); -data[1763] = String.fromCharCode (0xffff); -data[1764] = String.fromCharCode (0xffff); -data[1765] = String.fromCharCode (0xffff); -data[1766] = String.fromCharCode (0xffff); -data[1767] = String.fromCharCode (0xffff); -data[1768] = String.fromCharCode (0xffff); -data[1769] = String.fromCharCode (0xffff); -data[1770] = String.fromCharCode (0xffff); -data[1771] = String.fromCharCode (0xffff); -data[1772] = String.fromCharCode (0xffff); -data[1773] = String.fromCharCode (0xffff); -data[1774] = String.fromCharCode (0xffff); -data[1775] = String.fromCharCode (0xffff); -data[1776] = String.fromCharCode (0xffff); -data[1777] = String.fromCharCode (0xffff); -data[1778] = String.fromCharCode (0xffff); -data[1779] = String.fromCharCode (0xffff); -data[1780] = String.fromCharCode (0xffff); -data[1781] = String.fromCharCode (0xffff); -data[1782] = String.fromCharCode (0xffff); -data[1783] = String.fromCharCode (0xffff); -data[1784] = String.fromCharCode (0xffff); -data[1785] = String.fromCharCode (0xffff); -data[1786] = String.fromCharCode (0xffff); -data[1787] = String.fromCharCode (0xffff); -data[1788] = String.fromCharCode (0xffff); -data[1789] = String.fromCharCode (0xffff); -data[1790] = String.fromCharCode (0xffff); -data[1791] = String.fromCharCode (0xffff); -data[1792] = String.fromCharCode (0xffff); -data[1793] = String.fromCharCode (0xffff); -data[1794] = String.fromCharCode (0xffff); -data[1795] = String.fromCharCode (0xffff); -data[1796] = String.fromCharCode (0xffff); -data[1797] = String.fromCharCode (0xffff); -data[1798] = String.fromCharCode (0xffff); -data[1799] = String.fromCharCode (0xffff); -data[1800] = String.fromCharCode (0xffff); -data[1801] = String.fromCharCode (0xffff); -data[1802] = String.fromCharCode (0xffff); -data[1803] = String.fromCharCode (0xffff); -data[1804] = String.fromCharCode (0xffff); -data[1805] = String.fromCharCode (0xffff); -data[1806] = String.fromCharCode (0xffff); -data[1807] = String.fromCharCode (0xffff); -data[1808] = String.fromCharCode (0xffff); -data[1809] = String.fromCharCode (0xffff); -data[1810] = String.fromCharCode (0xffff); -data[1811] = String.fromCharCode (0xffff); -data[1812] = String.fromCharCode (0xffff); -data[1813] = String.fromCharCode (0xffff); -data[1814] = String.fromCharCode (0xffff); -data[1815] = String.fromCharCode (0xffff); -data[1816] = String.fromCharCode (0xffff); -data[1817] = String.fromCharCode (0xffff); -data[1818] = String.fromCharCode (0xffff); -data[1819] = String.fromCharCode (0xffff); -data[1820] = String.fromCharCode (0xffff); -data[1821] = String.fromCharCode (0xffff); -data[1822] = String.fromCharCode (0xffff); -data[1823] = String.fromCharCode (0xffff); -data[1824] = String.fromCharCode (0xffff); -data[1825] = String.fromCharCode (0xffff); -data[1826] = String.fromCharCode (0xffff); -data[1827] = String.fromCharCode (0xffff); -data[1828] = String.fromCharCode (0xffff); -data[1829] = String.fromCharCode (0xffff); -data[1830] = String.fromCharCode (0xffff); -data[1831] = String.fromCharCode (0xffff); -data[1832] = String.fromCharCode (0xffff); -data[1833] = String.fromCharCode (0xffff); -data[1834] = String.fromCharCode (0xffff); -data[1835] = String.fromCharCode (0xffff); -data[1836] = String.fromCharCode (0xffff); -data[1837] = String.fromCharCode (0xffff); -data[1838] = String.fromCharCode (0xffff); -data[1839] = String.fromCharCode (0xffff); -data[1840] = String.fromCharCode (0xffff); -data[1841] = String.fromCharCode (0xffff); -data[1842] = String.fromCharCode (0xffff); -data[1843] = String.fromCharCode (0xffff); -data[1844] = String.fromCharCode (0xffff); -data[1845] = String.fromCharCode (0xffff); -data[1846] = String.fromCharCode (0xffff); -data[1847] = String.fromCharCode (0xffff); -data[1848] = String.fromCharCode (0xffff); -data[1849] = String.fromCharCode (0xffff); -data[1850] = String.fromCharCode (0xffff); -data[1851] = String.fromCharCode (0xffff); -data[1852] = String.fromCharCode (0xffff); -data[1853] = String.fromCharCode (0xffff); -data[1854] = String.fromCharCode (0xffff); -data[1855] = String.fromCharCode (0xffff); -data[1856] = String.fromCharCode (0xffff); -data[1857] = String.fromCharCode (0xffff); -data[1858] = String.fromCharCode (0xffff); -data[1859] = String.fromCharCode (0xffff); -data[1860] = String.fromCharCode (0xffff); -data[1861] = String.fromCharCode (0xffff); -data[1862] = String.fromCharCode (0xffff); -data[1863] = String.fromCharCode (0xffff); -data[1864] = String.fromCharCode (0xffff); -data[1865] = String.fromCharCode (0xffff); -data[1866] = String.fromCharCode (0xffff); -data[1867] = String.fromCharCode (0xffff); -data[1868] = String.fromCharCode (0xffff); -data[1869] = String.fromCharCode (0xffff); -data[1870] = String.fromCharCode (0xffff); -data[1871] = String.fromCharCode (0xffff); -data[1872] = String.fromCharCode (0xffff); -data[1873] = String.fromCharCode (0xffff); -data[1874] = String.fromCharCode (0xffff); -data[1875] = String.fromCharCode (0xffff); -data[1876] = String.fromCharCode (0xffff); -data[1877] = String.fromCharCode (0xffff); -data[1878] = String.fromCharCode (0xffff); -data[1879] = String.fromCharCode (0xffff); -data[1880] = String.fromCharCode (0xffff); -data[1881] = String.fromCharCode (0xffff); -data[1882] = String.fromCharCode (0xffff); -data[1883] = String.fromCharCode (0xffff); -data[1884] = String.fromCharCode (0xffff); -data[1885] = String.fromCharCode (0xffff); -data[1886] = String.fromCharCode (0xffff); -data[1887] = String.fromCharCode (0xffff); -data[1888] = String.fromCharCode (0xffff); -data[1889] = String.fromCharCode (0xffff); -data[1890] = String.fromCharCode (0xffff); -data[1891] = String.fromCharCode (0xffff); -data[1892] = String.fromCharCode (0xffff); -data[1893] = String.fromCharCode (0xffff); -data[1894] = String.fromCharCode (0xffff); -data[1895] = String.fromCharCode (0xffff); -data[1896] = String.fromCharCode (0xffff); -data[1897] = String.fromCharCode (0xffff); -data[1898] = String.fromCharCode (0xffff); -data[1899] = String.fromCharCode (0xffff); -data[1900] = String.fromCharCode (0xffff); -data[1901] = String.fromCharCode (0xffff); -data[1902] = String.fromCharCode (0xffff); -data[1903] = String.fromCharCode (0xffff); -data[1904] = String.fromCharCode (0xffff); -data[1905] = String.fromCharCode (0xffff); -data[1906] = String.fromCharCode (0xffff); -data[1907] = String.fromCharCode (0xffff); -data[1908] = String.fromCharCode (0xffff); -data[1909] = String.fromCharCode (0xffff); -data[1910] = String.fromCharCode (0xffff); -data[1911] = String.fromCharCode (0xffff); -data[1912] = String.fromCharCode (0xffff); -data[1913] = String.fromCharCode (0xffff); -data[1914] = String.fromCharCode (0xffff); -data[1915] = String.fromCharCode (0xffff); -data[1916] = String.fromCharCode (0xffff); -data[1917] = String.fromCharCode (0xffff); -data[1918] = String.fromCharCode (0xffff); -data[1919] = String.fromCharCode (0xffff); -data[1920] = String.fromCharCode (0xffff); -data[1921] = String.fromCharCode (0xffff); -data[1922] = String.fromCharCode (0xffff); -data[1923] = String.fromCharCode (0xffff); -data[1924] = String.fromCharCode (0xffff); -data[1925] = String.fromCharCode (0xffff); -data[1926] = String.fromCharCode (0xffff); -data[1927] = String.fromCharCode (0xffff); -data[1928] = String.fromCharCode (0xffff); -data[1929] = String.fromCharCode (0xffff); -data[1930] = String.fromCharCode (0xffff); -data[1931] = String.fromCharCode (0xffff); -data[1932] = String.fromCharCode (0xffff); -data[1933] = String.fromCharCode (0xffff); -data[1934] = String.fromCharCode (0xffff); -data[1935] = String.fromCharCode (0xffff); -data[1936] = String.fromCharCode (0xffff); -data[1937] = String.fromCharCode (0xffff); -data[1938] = String.fromCharCode (0xffff); -data[1939] = String.fromCharCode (0xffff); -data[1940] = String.fromCharCode (0xffff); -data[1941] = String.fromCharCode (0xffff); -data[1942] = String.fromCharCode (0xffff); -data[1943] = String.fromCharCode (0xffff); -data[1944] = String.fromCharCode (0xffff); -data[1945] = String.fromCharCode (0xffff); -data[1946] = String.fromCharCode (0xffff); -data[1947] = String.fromCharCode (0xffff); -data[1948] = String.fromCharCode (0xffff); -data[1949] = String.fromCharCode (0xffff); -data[1950] = String.fromCharCode (0xffff); -data[1951] = String.fromCharCode (0xffff); -data[1952] = String.fromCharCode (0xffff); -data[1953] = String.fromCharCode (0xffff); -data[1954] = String.fromCharCode (0xffff); -data[1955] = String.fromCharCode (0xffff); -data[1956] = String.fromCharCode (0xffff); -data[1957] = String.fromCharCode (0xffff); -data[1958] = String.fromCharCode (0xffff); -data[1959] = String.fromCharCode (0xffff); -data[1960] = String.fromCharCode (0xffff); -data[1961] = String.fromCharCode (0xffff); -data[1962] = String.fromCharCode (0xffff); -data[1963] = String.fromCharCode (0xffff); -data[1964] = String.fromCharCode (0xffff); -data[1965] = String.fromCharCode (0xffff); -data[1966] = String.fromCharCode (0xffff); -data[1967] = String.fromCharCode (0xffff); -data[1968] = String.fromCharCode (0xffff); -data[1969] = String.fromCharCode (0xffff); -data[1970] = String.fromCharCode (0xffff); -data[1971] = String.fromCharCode (0xffff); -data[1972] = String.fromCharCode (0xffff); -data[1973] = String.fromCharCode (0xffff); -data[1974] = String.fromCharCode (0xffff); -data[1975] = String.fromCharCode (0xffff); -data[1976] = String.fromCharCode (0xffff); -data[1977] = String.fromCharCode (0xffff); -data[1978] = String.fromCharCode (0xffff); -data[1979] = String.fromCharCode (0xffff); -data[1980] = String.fromCharCode (0xffff); -data[1981] = String.fromCharCode (0xffff); -data[1982] = String.fromCharCode (0xffff); -data[1983] = String.fromCharCode (0xffff); -data[1984] = String.fromCharCode (0xffff); -data[1985] = String.fromCharCode (0xffff); -data[1986] = String.fromCharCode (0xffff); -data[1987] = String.fromCharCode (0xffff); -data[1988] = String.fromCharCode (0xffff); -data[1989] = String.fromCharCode (0xffff); -data[1990] = String.fromCharCode (0xffff); -data[1991] = String.fromCharCode (0xffff); -data[1992] = String.fromCharCode (0xffff); -data[1993] = String.fromCharCode (0xffff); -data[1994] = String.fromCharCode (0xffff); -data[1995] = String.fromCharCode (0xffff); -data[1996] = String.fromCharCode (0xffff); -data[1997] = String.fromCharCode (0xffff); -data[1998] = String.fromCharCode (0xffff); -data[1999] = String.fromCharCode (0xffff); -data[2000] = String.fromCharCode (0xffff); -data[2001] = String.fromCharCode (0xffff); -data[2002] = String.fromCharCode (0xffff); -data[2003] = String.fromCharCode (0xffff); -data[2004] = String.fromCharCode (0xffff); -data[2005] = String.fromCharCode (0xffff); -data[2006] = String.fromCharCode (0xffff); -data[2007] = String.fromCharCode (0xffff); -data[2008] = String.fromCharCode (0xffff); -data[2009] = String.fromCharCode (0xffff); -data[2010] = String.fromCharCode (0xffff); -data[2011] = String.fromCharCode (0xffff); -data[2012] = String.fromCharCode (0xffff); -data[2013] = String.fromCharCode (0xffff); -data[2014] = String.fromCharCode (0xffff); -data[2015] = String.fromCharCode (0xffff); -data[2016] = String.fromCharCode (0xffff); -data[2017] = String.fromCharCode (0xffff); -data[2018] = String.fromCharCode (0xffff); -data[2019] = String.fromCharCode (0xffff); -data[2020] = String.fromCharCode (0xffff); -data[2021] = String.fromCharCode (0xffff); -data[2022] = String.fromCharCode (0xffff); -data[2023] = String.fromCharCode (0xffff); -data[2024] = String.fromCharCode (0xffff); -data[2025] = String.fromCharCode (0xffff); -data[2026] = String.fromCharCode (0xffff); -data[2027] = String.fromCharCode (0xffff); -data[2028] = String.fromCharCode (0xffff); -data[2029] = String.fromCharCode (0xffff); -data[2030] = String.fromCharCode (0xffff); -data[2031] = String.fromCharCode (0xffff); -data[2032] = String.fromCharCode (0xffff); -data[2033] = String.fromCharCode (0xffff); -data[2034] = String.fromCharCode (0xffff); -data[2035] = String.fromCharCode (0xffff); -data[2036] = String.fromCharCode (0xffff); -data[2037] = String.fromCharCode (0xffff); -data[2038] = String.fromCharCode (0xffff); -data[2039] = String.fromCharCode (0xffff); -data[2040] = String.fromCharCode (0xffff); -data[2041] = String.fromCharCode (0xffff); -data[2042] = String.fromCharCode (0xffff); -data[2043] = String.fromCharCode (0xffff); -data[2044] = String.fromCharCode (0xffff); -data[2045] = String.fromCharCode (0xffff); -data[2046] = String.fromCharCode (0xffff); -data[2047] = String.fromCharCode (0xffff); -data[2048] = String.fromCharCode (0xffff); -data[2049] = String.fromCharCode (0xffff); -data[2050] = String.fromCharCode (0xffff); -data[2051] = String.fromCharCode (0xffff); -data[2052] = String.fromCharCode (0xffff); -data[2053] = String.fromCharCode (0xffff); -data[2054] = String.fromCharCode (0xffff); -data[2055] = String.fromCharCode (0xffff); -data[2056] = String.fromCharCode (0xffff); -data[2057] = String.fromCharCode (0xffff); -data[2058] = String.fromCharCode (0xffff); -data[2059] = String.fromCharCode (0xffff); -data[2060] = String.fromCharCode (0xffff); -data[2061] = String.fromCharCode (0xffff); -data[2062] = String.fromCharCode (0xffff); -data[2063] = String.fromCharCode (0xffff); -data[2064] = String.fromCharCode (0xffff); -data[2065] = String.fromCharCode (0xffff); -data[2066] = String.fromCharCode (0xffff); -data[2067] = String.fromCharCode (0xffff); -data[2068] = String.fromCharCode (0xffff); -data[2069] = String.fromCharCode (0xffff); -data[2070] = String.fromCharCode (0xffff); -data[2071] = String.fromCharCode (0xffff); -data[2072] = String.fromCharCode (0xffff); -data[2073] = String.fromCharCode (0xffff); -data[2074] = String.fromCharCode (0xffff); -data[2075] = String.fromCharCode (0xffff); -data[2076] = String.fromCharCode (0xffff); -data[2077] = String.fromCharCode (0xffff); -data[2078] = String.fromCharCode (0xffff); -data[2079] = String.fromCharCode (0xffff); -data[2080] = String.fromCharCode (0xffff); -data[2081] = String.fromCharCode (0xffff); -data[2082] = String.fromCharCode (0xffff); -data[2083] = String.fromCharCode (0xffff); -data[2084] = String.fromCharCode (0xffff); -data[2085] = String.fromCharCode (0xffff); -data[2086] = String.fromCharCode (0xffff); -data[2087] = String.fromCharCode (0xffff); -data[2088] = String.fromCharCode (0xffff); -data[2089] = String.fromCharCode (0xffff); -data[2090] = String.fromCharCode (0xffff); -data[2091] = String.fromCharCode (0xffff); -data[2092] = String.fromCharCode (0xffff); -data[2093] = String.fromCharCode (0xffff); -data[2094] = String.fromCharCode (0xffff); -data[2095] = String.fromCharCode (0xffff); -data[2096] = String.fromCharCode (0xffff); -data[2097] = String.fromCharCode (0xffff); -data[2098] = String.fromCharCode (0xffff); -data[2099] = String.fromCharCode (0xffff); -data[2100] = String.fromCharCode (0xffff); -data[2101] = String.fromCharCode (0xffff); -data[2102] = String.fromCharCode (0xffff); -data[2103] = String.fromCharCode (0xffff); -data[2104] = String.fromCharCode (0xffff); -data[2105] = String.fromCharCode (0xffff); -data[2106] = String.fromCharCode (0xffff); -data[2107] = String.fromCharCode (0xffff); -data[2108] = String.fromCharCode (0xffff); -data[2109] = String.fromCharCode (0xffff); -data[2110] = String.fromCharCode (0xffff); -data[2111] = String.fromCharCode (0xffff); -data[2112] = String.fromCharCode (0xffff); -data[2113] = String.fromCharCode (0xffff); -data[2114] = String.fromCharCode (0xffff); -data[2115] = String.fromCharCode (0xffff); -data[2116] = String.fromCharCode (0xffff); -data[2117] = String.fromCharCode (0xffff); -data[2118] = String.fromCharCode (0xffff); -data[2119] = String.fromCharCode (0xffff); -data[2120] = String.fromCharCode (0xffff); -data[2121] = String.fromCharCode (0xffff); -data[2122] = String.fromCharCode (0xffff); -data[2123] = String.fromCharCode (0xffff); -data[2124] = String.fromCharCode (0xffff); -data[2125] = String.fromCharCode (0xffff); -data[2126] = String.fromCharCode (0xffff); -data[2127] = String.fromCharCode (0xffff); -data[2128] = String.fromCharCode (0xffff); -data[2129] = String.fromCharCode (0xffff); -data[2130] = String.fromCharCode (0xffff); -data[2131] = String.fromCharCode (0xffff); -data[2132] = String.fromCharCode (0xffff); -data[2133] = String.fromCharCode (0xffff); -data[2134] = String.fromCharCode (0xffff); -data[2135] = String.fromCharCode (0xffff); -data[2136] = String.fromCharCode (0xffff); -data[2137] = String.fromCharCode (0xffff); -data[2138] = String.fromCharCode (0xffff); -data[2139] = String.fromCharCode (0xffff); -data[2140] = String.fromCharCode (0xffff); -data[2141] = String.fromCharCode (0xffff); -data[2142] = String.fromCharCode (0xffff); -data[2143] = String.fromCharCode (0xffff); -data[2144] = String.fromCharCode (0xffff); -data[2145] = String.fromCharCode (0xffff); -data[2146] = String.fromCharCode (0xffff); -data[2147] = String.fromCharCode (0xffff); -data[2148] = String.fromCharCode (0xffff); -data[2149] = String.fromCharCode (0xffff); -data[2150] = String.fromCharCode (0xffff); -data[2151] = String.fromCharCode (0xffff); -data[2152] = String.fromCharCode (0xffff); -data[2153] = String.fromCharCode (0xffff); -data[2154] = String.fromCharCode (0xffff); -data[2155] = String.fromCharCode (0xffff); -data[2156] = String.fromCharCode (0xffff); -data[2157] = String.fromCharCode (0xffff); -data[2158] = String.fromCharCode (0xffff); -data[2159] = String.fromCharCode (0xffff); -data[2160] = String.fromCharCode (0xffff); -data[2161] = String.fromCharCode (0xffff); -data[2162] = String.fromCharCode (0xffff); -data[2163] = String.fromCharCode (0xffff); -data[2164] = String.fromCharCode (0xffff); -data[2165] = String.fromCharCode (0xffff); -data[2166] = String.fromCharCode (0xffff); -data[2167] = String.fromCharCode (0xffff); -data[2168] = String.fromCharCode (0xffff); -data[2169] = String.fromCharCode (0xffff); -data[2170] = String.fromCharCode (0xffff); -data[2171] = String.fromCharCode (0xffff); -data[2172] = String.fromCharCode (0xffff); -data[2173] = String.fromCharCode (0xffff); -data[2174] = String.fromCharCode (0xffff); -data[2175] = String.fromCharCode (0xffff); -data[2176] = String.fromCharCode (0xffff); -data[2177] = String.fromCharCode (0xffff); -data[2178] = String.fromCharCode (0xffff); -data[2179] = String.fromCharCode (0xffff); -data[2180] = String.fromCharCode (0xffff); -data[2181] = String.fromCharCode (0xffff); -data[2182] = String.fromCharCode (0xffff); -data[2183] = String.fromCharCode (0xffff); -data[2184] = String.fromCharCode (0xffff); -data[2185] = String.fromCharCode (0xffff); -data[2186] = String.fromCharCode (0xffff); -data[2187] = String.fromCharCode (0xffff); -data[2188] = String.fromCharCode (0xffff); -data[2189] = String.fromCharCode (0xffff); -data[2190] = String.fromCharCode (0xffff); -data[2191] = String.fromCharCode (0xffff); -data[2192] = String.fromCharCode (0xffff); -data[2193] = String.fromCharCode (0xffff); -data[2194] = String.fromCharCode (0xffff); -data[2195] = String.fromCharCode (0xffff); -data[2196] = String.fromCharCode (0xffff); -data[2197] = String.fromCharCode (0xffff); -data[2198] = String.fromCharCode (0xffff); -data[2199] = String.fromCharCode (0xffff); -data[2200] = String.fromCharCode (0xffff); -data[2201] = String.fromCharCode (0xffff); -data[2202] = String.fromCharCode (0xffff); -data[2203] = String.fromCharCode (0xffff); -data[2204] = String.fromCharCode (0xffff); -data[2205] = String.fromCharCode (0xffff); -data[2206] = String.fromCharCode (0xffff); -data[2207] = String.fromCharCode (0xffff); -data[2208] = String.fromCharCode (0xffff); -data[2209] = String.fromCharCode (0xffff); -data[2210] = String.fromCharCode (0xffff); -data[2211] = String.fromCharCode (0xffff); -data[2212] = String.fromCharCode (0xffff); -data[2213] = String.fromCharCode (0xffff); -data[2214] = String.fromCharCode (0xffff); -data[2215] = String.fromCharCode (0xffff); -data[2216] = String.fromCharCode (0xffff); -data[2217] = String.fromCharCode (0xffff); -data[2218] = String.fromCharCode (0xffff); -data[2219] = String.fromCharCode (0xffff); -data[2220] = String.fromCharCode (0xffff); -data[2221] = String.fromCharCode (0xffff); -data[2222] = String.fromCharCode (0xffff); -data[2223] = String.fromCharCode (0xffff); -data[2224] = String.fromCharCode (0xffff); -data[2225] = String.fromCharCode (0xffff); -data[2226] = String.fromCharCode (0xffff); -data[2227] = String.fromCharCode (0xffff); -data[2228] = String.fromCharCode (0xffff); -data[2229] = String.fromCharCode (0xffff); -data[2230] = String.fromCharCode (0xffff); -data[2231] = String.fromCharCode (0xffff); -data[2232] = String.fromCharCode (0xffff); -data[2233] = String.fromCharCode (0xffff); -data[2234] = String.fromCharCode (0xffff); -data[2235] = String.fromCharCode (0xffff); -data[2236] = String.fromCharCode (0xffff); -data[2237] = String.fromCharCode (0xffff); -data[2238] = String.fromCharCode (0xffff); -data[2239] = String.fromCharCode (0xffff); -data[2240] = String.fromCharCode (0xffff); -data[2241] = String.fromCharCode (0xffff); -data[2242] = String.fromCharCode (0xffff); -data[2243] = String.fromCharCode (0xffff); -data[2244] = String.fromCharCode (0xffff); -data[2245] = String.fromCharCode (0xffff); -data[2246] = String.fromCharCode (0xffff); -data[2247] = String.fromCharCode (0xffff); -data[2248] = String.fromCharCode (0xffff); -data[2249] = String.fromCharCode (0xffff); -data[2250] = String.fromCharCode (0xffff); -data[2251] = String.fromCharCode (0xffff); -data[2252] = String.fromCharCode (0xffff); -data[2253] = String.fromCharCode (0xffff); -data[2254] = String.fromCharCode (0xffff); -data[2255] = String.fromCharCode (0xffff); -data[2256] = String.fromCharCode (0xffff); -data[2257] = String.fromCharCode (0xffff); -data[2258] = String.fromCharCode (0xffff); -data[2259] = String.fromCharCode (0xffff); -data[2260] = String.fromCharCode (0xffff); -data[2261] = String.fromCharCode (0xffff); -data[2262] = String.fromCharCode (0xffff); -data[2263] = String.fromCharCode (0xffff); -data[2264] = String.fromCharCode (0xffff); -data[2265] = String.fromCharCode (0xffff); -data[2266] = String.fromCharCode (0xffff); -data[2267] = String.fromCharCode (0xffff); -data[2268] = String.fromCharCode (0xffff); -data[2269] = String.fromCharCode (0xffff); -data[2270] = String.fromCharCode (0xffff); -data[2271] = String.fromCharCode (0xffff); -data[2272] = String.fromCharCode (0xffff); -data[2273] = String.fromCharCode (0xffff); -data[2274] = String.fromCharCode (0xffff); -data[2275] = String.fromCharCode (0xffff); -data[2276] = String.fromCharCode (0xffff); -data[2277] = String.fromCharCode (0xffff); -data[2278] = String.fromCharCode (0xffff); -data[2279] = String.fromCharCode (0xffff); -data[2280] = String.fromCharCode (0xffff); -data[2281] = String.fromCharCode (0xffff); -data[2282] = String.fromCharCode (0xffff); -data[2283] = String.fromCharCode (0xffff); -data[2284] = String.fromCharCode (0xffff); -data[2285] = String.fromCharCode (0xffff); -data[2286] = String.fromCharCode (0xffff); -data[2287] = String.fromCharCode (0xffff); -data[2288] = String.fromCharCode (0xffff); -data[2289] = String.fromCharCode (0xffff); -data[2290] = String.fromCharCode (0xffff); -data[2291] = String.fromCharCode (0xffff); -data[2292] = String.fromCharCode (0xffff); -data[2293] = String.fromCharCode (0xffff); -data[2294] = String.fromCharCode (0xffff); -data[2295] = String.fromCharCode (0xffff); -data[2296] = String.fromCharCode (0xffff); -data[2297] = String.fromCharCode (0xffff); -data[2298] = String.fromCharCode (0xffff); -data[2299] = String.fromCharCode (0xffff); -data[2300] = String.fromCharCode (0xffff); -data[2301] = String.fromCharCode (0xffff); -data[2302] = String.fromCharCode (0xffff); -data[2303] = String.fromCharCode (0xffff); -data[2304] = String.fromCharCode (0xffff); -data[2305] = String.fromCharCode (0xffff); -data[2306] = String.fromCharCode (0xffff); -data[2307] = String.fromCharCode (0xffff); -data[2308] = String.fromCharCode (0xffff); -data[2309] = String.fromCharCode (0xffff); -data[2310] = String.fromCharCode (0xffff); -data[2311] = String.fromCharCode (0xffff); -data[2312] = String.fromCharCode (0xffff); -data[2313] = String.fromCharCode (0xffff); -data[2314] = String.fromCharCode (0xffff); -data[2315] = String.fromCharCode (0xffff); -data[2316] = String.fromCharCode (0xffff); -data[2317] = String.fromCharCode (0xffff); -data[2318] = String.fromCharCode (0xffff); -data[2319] = String.fromCharCode (0xffff); -data[2320] = String.fromCharCode (0xffff); -data[2321] = String.fromCharCode (0xffff); -data[2322] = String.fromCharCode (0xffff); -data[2323] = String.fromCharCode (0xffff); -data[2324] = String.fromCharCode (0xffff); -data[2325] = String.fromCharCode (0xffff); -data[2326] = String.fromCharCode (0xffff); -data[2327] = String.fromCharCode (0xffff); -data[2328] = String.fromCharCode (0xffff); -data[2329] = String.fromCharCode (0xffff); -data[2330] = String.fromCharCode (0xffff); -data[2331] = String.fromCharCode (0xffff); -data[2332] = String.fromCharCode (0xffff); -data[2333] = String.fromCharCode (0xffff); -data[2334] = String.fromCharCode (0xffff); -data[2335] = String.fromCharCode (0xffff); -data[2336] = String.fromCharCode (0xffff); -data[2337] = String.fromCharCode (0xffff); -data[2338] = String.fromCharCode (0xffff); -data[2339] = String.fromCharCode (0xffff); -data[2340] = String.fromCharCode (0xffff); -data[2341] = String.fromCharCode (0xffff); -data[2342] = String.fromCharCode (0xffff); -data[2343] = String.fromCharCode (0xffff); -data[2344] = String.fromCharCode (0xffff); -data[2345] = String.fromCharCode (0xffff); -data[2346] = String.fromCharCode (0xffff); -data[2347] = String.fromCharCode (0xffff); -data[2348] = String.fromCharCode (0xffff); -data[2349] = String.fromCharCode (0xffff); -data[2350] = String.fromCharCode (0xffff); -data[2351] = String.fromCharCode (0xffff); -data[2352] = String.fromCharCode (0xffff); -data[2353] = String.fromCharCode (0xffff); -data[2354] = String.fromCharCode (0xffff); -data[2355] = String.fromCharCode (0xffff); -data[2356] = String.fromCharCode (0xffff); -data[2357] = String.fromCharCode (0xffff); -data[2358] = String.fromCharCode (0xffff); -data[2359] = String.fromCharCode (0xffff); -data[2360] = String.fromCharCode (0xffff); -data[2361] = String.fromCharCode (0xffff); -data[2362] = String.fromCharCode (0xffff); -data[2363] = String.fromCharCode (0xffff); -data[2364] = String.fromCharCode (0xffff); -data[2365] = String.fromCharCode (0xffff); -data[2366] = String.fromCharCode (0xffff); -data[2367] = String.fromCharCode (0xffff); -data[2368] = String.fromCharCode (0xffff); -data[2369] = String.fromCharCode (0xffff); -data[2370] = String.fromCharCode (0xffff); -data[2371] = String.fromCharCode (0xffff); -data[2372] = String.fromCharCode (0xffff); -data[2373] = String.fromCharCode (0xffff); -data[2374] = String.fromCharCode (0xffff); -data[2375] = String.fromCharCode (0xffff); -data[2376] = String.fromCharCode (0xffff); -data[2377] = String.fromCharCode (0xffff); -data[2378] = String.fromCharCode (0xffff); -data[2379] = String.fromCharCode (0xffff); -data[2380] = String.fromCharCode (0xffff); -data[2381] = String.fromCharCode (0xffff); -data[2382] = String.fromCharCode (0xffff); -data[2383] = String.fromCharCode (0xffff); -data[2384] = String.fromCharCode (0xffff); -data[2385] = String.fromCharCode (0xffff); -data[2386] = String.fromCharCode (0xffff); -data[2387] = String.fromCharCode (0xffff); -data[2388] = String.fromCharCode (0xffff); -data[2389] = String.fromCharCode (0xffff); -data[2390] = String.fromCharCode (0xffff); -data[2391] = String.fromCharCode (0xffff); -data[2392] = String.fromCharCode (0xffff); -data[2393] = String.fromCharCode (0xffff); -data[2394] = String.fromCharCode (0xffff); -data[2395] = String.fromCharCode (0xffff); -data[2396] = String.fromCharCode (0xffff); -data[2397] = String.fromCharCode (0xffff); -data[2398] = String.fromCharCode (0xffff); -data[2399] = String.fromCharCode (0xffff); -data[2400] = String.fromCharCode (0xffff); -data[2401] = String.fromCharCode (0xffff); -data[2402] = String.fromCharCode (0xffff); -data[2403] = String.fromCharCode (0xffff); -data[2404] = String.fromCharCode (0xffff); -data[2405] = String.fromCharCode (0xffff); -data[2406] = String.fromCharCode (0xffff); -data[2407] = String.fromCharCode (0xffff); -data[2408] = String.fromCharCode (0xffff); -data[2409] = String.fromCharCode (0xffff); -data[2410] = String.fromCharCode (0xffff); -data[2411] = String.fromCharCode (0xffff); -data[2412] = String.fromCharCode (0xffff); -data[2413] = String.fromCharCode (0xffff); -data[2414] = String.fromCharCode (0xffff); -data[2415] = String.fromCharCode (0xffff); -data[2416] = String.fromCharCode (0xffff); -data[2417] = String.fromCharCode (0xffff); -data[2418] = String.fromCharCode (0xffff); -data[2419] = String.fromCharCode (0xffff); -data[2420] = String.fromCharCode (0xffff); -data[2421] = String.fromCharCode (0xffff); -data[2422] = String.fromCharCode (0xffff); -data[2423] = String.fromCharCode (0xffff); -data[2424] = String.fromCharCode (0xffff); -data[2425] = String.fromCharCode (0xffff); -data[2426] = String.fromCharCode (0xffff); -data[2427] = String.fromCharCode (0xffff); -data[2428] = String.fromCharCode (0xffff); -data[2429] = String.fromCharCode (0xffff); -data[2430] = String.fromCharCode (0xffff); -data[2431] = String.fromCharCode (0xffff); -data[2432] = String.fromCharCode (0xffff); -data[2433] = String.fromCharCode (0xffff); -data[2434] = String.fromCharCode (0xffff); -data[2435] = String.fromCharCode (0xffff); -data[2436] = String.fromCharCode (0xffff); -data[2437] = String.fromCharCode (0xffff); -data[2438] = String.fromCharCode (0xffff); -data[2439] = String.fromCharCode (0xffff); -data[2440] = String.fromCharCode (0xffff); -data[2441] = String.fromCharCode (0xffff); -data[2442] = String.fromCharCode (0xffff); -data[2443] = String.fromCharCode (0xffff); -data[2444] = String.fromCharCode (0xffff); -data[2445] = String.fromCharCode (0xffff); -data[2446] = String.fromCharCode (0xffff); -data[2447] = String.fromCharCode (0xffff); -data[2448] = String.fromCharCode (0xffff); -data[2449] = String.fromCharCode (0xffff); -data[2450] = String.fromCharCode (0xffff); -data[2451] = String.fromCharCode (0xffff); -data[2452] = String.fromCharCode (0xffff); -data[2453] = String.fromCharCode (0xffff); -data[2454] = String.fromCharCode (0xffff); -data[2455] = String.fromCharCode (0xffff); -data[2456] = String.fromCharCode (0xffff); -data[2457] = String.fromCharCode (0xffff); -data[2458] = String.fromCharCode (0xffff); -data[2459] = String.fromCharCode (0xffff); -data[2460] = String.fromCharCode (0xffff); -data[2461] = String.fromCharCode (0xffff); -data[2462] = String.fromCharCode (0xffff); -data[2463] = String.fromCharCode (0xffff); -data[2464] = String.fromCharCode (0xffff); -data[2465] = String.fromCharCode (0xffff); -data[2466] = String.fromCharCode (0xffff); -data[2467] = String.fromCharCode (0xffff); -data[2468] = String.fromCharCode (0xffff); -data[2469] = String.fromCharCode (0xffff); -data[2470] = String.fromCharCode (0xffff); -data[2471] = String.fromCharCode (0xffff); -data[2472] = String.fromCharCode (0xffff); -data[2473] = String.fromCharCode (0xffff); -data[2474] = String.fromCharCode (0xffff); -data[2475] = String.fromCharCode (0xffff); -data[2476] = String.fromCharCode (0xffff); -data[2477] = String.fromCharCode (0xffff); -data[2478] = String.fromCharCode (0xffff); -data[2479] = String.fromCharCode (0xffff); -data[2480] = String.fromCharCode (0xffff); -data[2481] = String.fromCharCode (0xffff); -data[2482] = String.fromCharCode (0xffff); -data[2483] = String.fromCharCode (0xffff); -data[2484] = String.fromCharCode (0xffff); -data[2485] = String.fromCharCode (0xffff); -data[2486] = String.fromCharCode (0xffff); -data[2487] = String.fromCharCode (0xffff); -data[2488] = String.fromCharCode (0xffff); -data[2489] = String.fromCharCode (0xffff); -data[2490] = String.fromCharCode (0xffff); -data[2491] = String.fromCharCode (0xffff); -data[2492] = String.fromCharCode (0xffff); -data[2493] = String.fromCharCode (0xffff); -data[2494] = String.fromCharCode (0xffff); -data[2495] = String.fromCharCode (0xffff); -data[2496] = String.fromCharCode (0xffff); -data[2497] = String.fromCharCode (0xffff); -data[2498] = String.fromCharCode (0xffff); -data[2499] = String.fromCharCode (0xffff); -data[2500] = String.fromCharCode (0xffff); -data[2501] = String.fromCharCode (0xffff); -data[2502] = String.fromCharCode (0xffff); -data[2503] = String.fromCharCode (0xffff); -data[2504] = String.fromCharCode (0xffff); -data[2505] = String.fromCharCode (0xffff); -data[2506] = String.fromCharCode (0xffff); -data[2507] = String.fromCharCode (0xffff); -data[2508] = String.fromCharCode (0xffff); -data[2509] = String.fromCharCode (0xffff); -data[2510] = String.fromCharCode (0xffff); -data[2511] = String.fromCharCode (0xffff); -data[2512] = String.fromCharCode (0xffff); -data[2513] = String.fromCharCode (0xffff); -data[2514] = String.fromCharCode (0xffff); -data[2515] = String.fromCharCode (0xffff); -data[2516] = String.fromCharCode (0xffff); -data[2517] = String.fromCharCode (0xffff); -data[2518] = String.fromCharCode (0xffff); -data[2519] = String.fromCharCode (0xffff); -data[2520] = String.fromCharCode (0xffff); -data[2521] = String.fromCharCode (0xffff); -data[2522] = String.fromCharCode (0xffff); -data[2523] = String.fromCharCode (0xffff); -data[2524] = String.fromCharCode (0xffff); -data[2525] = String.fromCharCode (0xffff); -data[2526] = String.fromCharCode (0xffff); -data[2527] = String.fromCharCode (0xffff); -data[2528] = String.fromCharCode (0xffff); -data[2529] = String.fromCharCode (0xffff); -data[2530] = String.fromCharCode (0xffff); -data[2531] = String.fromCharCode (0xffff); -data[2532] = String.fromCharCode (0xffff); -data[2533] = String.fromCharCode (0xffff); -data[2534] = String.fromCharCode (0xffff); -data[2535] = String.fromCharCode (0xffff); -data[2536] = String.fromCharCode (0xffff); -data[2537] = String.fromCharCode (0xffff); -data[2538] = String.fromCharCode (0xffff); -data[2539] = String.fromCharCode (0xffff); -data[2540] = String.fromCharCode (0xffff); -data[2541] = String.fromCharCode (0xffff); -data[2542] = String.fromCharCode (0xffff); -data[2543] = String.fromCharCode (0xffff); -data[2544] = String.fromCharCode (0xffff); -data[2545] = String.fromCharCode (0xffff); -data[2546] = String.fromCharCode (0xffff); -data[2547] = String.fromCharCode (0xffff); -data[2548] = String.fromCharCode (0xffff); -data[2549] = String.fromCharCode (0xffff); -data[2550] = String.fromCharCode (0xffff); -data[2551] = String.fromCharCode (0xffff); -data[2552] = String.fromCharCode (0xffff); -data[2553] = String.fromCharCode (0xffff); -data[2554] = String.fromCharCode (0x003f); -data[2752] = String.fromCharCode (0xffff); -data[2753] = String.fromCharCode (0xffff); -data[2754] = String.fromCharCode (0xffff); -data[2755] = String.fromCharCode (0xffff); -data[2756] = String.fromCharCode (0xffff); -data[2757] = String.fromCharCode (0xffff); -data[2758] = String.fromCharCode (0xffff); -data[2759] = String.fromCharCode (0xffff); -data[2760] = String.fromCharCode (0xffff); -data[2761] = String.fromCharCode (0xffff); -data[2762] = String.fromCharCode (0xffff); -data[2763] = String.fromCharCode (0xffff); -data[2764] = String.fromCharCode (0xffff); -data[2765] = String.fromCharCode (0xffff); -data[2766] = String.fromCharCode (0xffff); -data[2767] = String.fromCharCode (0xffff); -data[2768] = String.fromCharCode (0xffff); -data[2769] = String.fromCharCode (0xffff); -data[2770] = String.fromCharCode (0xffff); -data[2771] = String.fromCharCode (0xffff); -data[2772] = String.fromCharCode (0xffff); -data[2773] = String.fromCharCode (0xffff); -data[2774] = String.fromCharCode (0xffff); -data[2775] = String.fromCharCode (0xffff); -data[2776] = String.fromCharCode (0xffff); -data[2777] = String.fromCharCode (0xffff); -data[2778] = String.fromCharCode (0xffff); -data[2779] = String.fromCharCode (0xffff); -data[2780] = String.fromCharCode (0xffff); -data[2781] = String.fromCharCode (0xffff); -data[2782] = String.fromCharCode (0xffff); -data[2783] = String.fromCharCode (0xffff); -data[2784] = String.fromCharCode (0xffff); -data[2785] = String.fromCharCode (0xffff); -data[2786] = String.fromCharCode (0xffff); -data[2787] = String.fromCharCode (0xffff); -data[2788] = String.fromCharCode (0xffff); -data[2789] = String.fromCharCode (0xffff); -data[2790] = String.fromCharCode (0xffff); -data[2791] = String.fromCharCode (0xffff); -data[2792] = String.fromCharCode (0xffff); -data[2793] = String.fromCharCode (0xffff); -data[2794] = String.fromCharCode (0xffff); -data[2795] = String.fromCharCode (0xffff); -data[2796] = String.fromCharCode (0xffff); -data[2797] = String.fromCharCode (0xffff); -data[2798] = String.fromCharCode (0xffff); -data[2799] = String.fromCharCode (0xffff); -data[2800] = String.fromCharCode (0xffff); -data[2801] = String.fromCharCode (0xffff); -data[2802] = String.fromCharCode (0xffff); -data[2803] = String.fromCharCode (0xffff); -data[2804] = String.fromCharCode (0xffff); -data[2805] = String.fromCharCode (0xffff); -data[2806] = String.fromCharCode (0xffff); -data[2807] = String.fromCharCode (0xffff); -data[2808] = String.fromCharCode (0xffff); -data[2809] = String.fromCharCode (0xffff); -data[2810] = String.fromCharCode (0xffff); -data[2811] = String.fromCharCode (0xffff); -data[2812] = String.fromCharCode (0xffff); -data[2813] = String.fromCharCode (0xffff); -data[2814] = String.fromCharCode (0xffff); -data[2815] = String.fromCharCode (0xffff); -data[2816] = String.fromCharCode (0xffff); -data[2817] = String.fromCharCode (0xffff); -data[2818] = String.fromCharCode (0xffff); -data[2819] = String.fromCharCode (0xffff); -data[2820] = String.fromCharCode (0xffff); -data[2821] = String.fromCharCode (0xffff); -data[2822] = String.fromCharCode (0xffff); -data[2823] = String.fromCharCode (0xffff); -data[2824] = String.fromCharCode (0xffff); -data[2825] = String.fromCharCode (0xffff); -data[2826] = String.fromCharCode (0xffff); -data[2827] = String.fromCharCode (0xffff); -data[2828] = String.fromCharCode (0xffff); -data[2829] = String.fromCharCode (0xffff); -data[2830] = String.fromCharCode (0xffff); -data[2831] = String.fromCharCode (0xffff); -data[2832] = String.fromCharCode (0xffff); -data[2833] = String.fromCharCode (0xffff); -data[2834] = String.fromCharCode (0xffff); -data[2835] = String.fromCharCode (0xffff); -data[2836] = String.fromCharCode (0xffff); -data[2837] = String.fromCharCode (0xffff); -data[2838] = String.fromCharCode (0xffff); -data[2839] = String.fromCharCode (0xffff); -data[2840] = String.fromCharCode (0xffff); -data[2841] = String.fromCharCode (0xffff); -data[2842] = String.fromCharCode (0xffff); -data[2843] = String.fromCharCode (0xffff); -data[2844] = String.fromCharCode (0xffff); -data[2845] = String.fromCharCode (0xffff); -data[2846] = String.fromCharCode (0xffff); -data[2847] = String.fromCharCode (0xffff); -data[2848] = String.fromCharCode (0xffff); -data[2849] = String.fromCharCode (0xffff); -data[2850] = String.fromCharCode (0xffff); -data[2851] = String.fromCharCode (0xffff); -data[2852] = String.fromCharCode (0xffff); -data[2853] = String.fromCharCode (0xffff); -data[2854] = String.fromCharCode (0xffff); -data[2855] = String.fromCharCode (0xffff); -data[2856] = String.fromCharCode (0xffff); -data[2857] = String.fromCharCode (0xffff); -data[2858] = String.fromCharCode (0xffff); -data[2859] = String.fromCharCode (0xffff); -data[2860] = String.fromCharCode (0xffff); -data[2861] = String.fromCharCode (0xffff); -data[2862] = String.fromCharCode (0xffff); -data[2863] = String.fromCharCode (0xffff); -data[2864] = String.fromCharCode (0xffff); -data[2865] = String.fromCharCode (0xffff); -data[2866] = String.fromCharCode (0xffff); -data[2867] = String.fromCharCode (0xffff); -data[2868] = String.fromCharCode (0xffff); -data[2869] = String.fromCharCode (0xffff); -data[2870] = String.fromCharCode (0xffff); -data[2871] = String.fromCharCode (0xffff); -data[2872] = String.fromCharCode (0xffff); -data[2873] = String.fromCharCode (0xffff); -data[2874] = String.fromCharCode (0xffff); -data[2875] = String.fromCharCode (0xffff); -data[2876] = String.fromCharCode (0xffff); -data[2877] = String.fromCharCode (0xffff); -data[2878] = String.fromCharCode (0xffff); -data[2879] = String.fromCharCode (0xffff); -data[2880] = String.fromCharCode (0xffff); -data[2881] = String.fromCharCode (0xffff); -data[2882] = String.fromCharCode (0xffff); -data[2883] = String.fromCharCode (0xffff); -data[2884] = String.fromCharCode (0xffff); -data[2885] = String.fromCharCode (0xffff); -data[2886] = String.fromCharCode (0xffff); -data[2887] = String.fromCharCode (0xffff); -data[2888] = String.fromCharCode (0xffff); -data[2889] = String.fromCharCode (0xffff); -data[2890] = String.fromCharCode (0xffff); -data[2891] = String.fromCharCode (0xffff); -data[2892] = String.fromCharCode (0xffff); -data[2893] = String.fromCharCode (0xffff); -data[2894] = String.fromCharCode (0xffff); -data[2895] = String.fromCharCode (0xffff); -data[2896] = String.fromCharCode (0xffff); -data[2897] = String.fromCharCode (0xffff); -data[2898] = String.fromCharCode (0xffff); -data[2899] = String.fromCharCode (0xffff); -data[2900] = String.fromCharCode (0xffff); -data[2901] = String.fromCharCode (0xffff); -data[2902] = String.fromCharCode (0xffff); -data[2903] = String.fromCharCode (0xffff); -data[2904] = String.fromCharCode (0xffff); -data[2905] = String.fromCharCode (0xffff); -data[2906] = String.fromCharCode (0xffff); -data[2907] = String.fromCharCode (0xffff); -data[2908] = String.fromCharCode (0xffff); -data[2909] = String.fromCharCode (0xffff); -data[2910] = String.fromCharCode (0xffff); -data[2911] = String.fromCharCode (0xffff); -data[2912] = String.fromCharCode (0xffff); -data[2913] = String.fromCharCode (0xffff); -data[2914] = String.fromCharCode (0xffff); -data[2915] = String.fromCharCode (0xffff); -data[2916] = String.fromCharCode (0xffff); -data[2917] = String.fromCharCode (0xffff); -data[2918] = String.fromCharCode (0xffff); -data[2919] = String.fromCharCode (0xffff); -data[2920] = String.fromCharCode (0xffff); -data[2921] = String.fromCharCode (0xffff); -data[2922] = String.fromCharCode (0xffff); -data[2923] = String.fromCharCode (0xffff); -data[2924] = String.fromCharCode (0xffff); -data[2925] = String.fromCharCode (0xffff); -data[2926] = String.fromCharCode (0xffff); -data[2927] = String.fromCharCode (0xffff); -data[2928] = String.fromCharCode (0xffff); -data[2929] = String.fromCharCode (0xffff); -data[2930] = String.fromCharCode (0xffff); -data[2931] = String.fromCharCode (0xffff); -data[2932] = String.fromCharCode (0xffff); -data[2933] = String.fromCharCode (0xffff); -data[2934] = String.fromCharCode (0xffff); -data[2935] = String.fromCharCode (0xffff); -data[2936] = String.fromCharCode (0xffff); -data[2937] = String.fromCharCode (0xffff); -data[2938] = String.fromCharCode (0xffff); -data[2939] = String.fromCharCode (0xffff); -data[2940] = String.fromCharCode (0xffff); -data[2941] = String.fromCharCode (0xffff); -data[2942] = String.fromCharCode (0xffff); -data[2943] = String.fromCharCode (0xffff); -data[2944] = String.fromCharCode (0xffff); -data[2945] = String.fromCharCode (0xffff); -data[2946] = String.fromCharCode (0xffff); -data[2947] = String.fromCharCode (0xffff); -data[2948] = String.fromCharCode (0xffff); -data[2949] = String.fromCharCode (0xffff); -data[2950] = String.fromCharCode (0xffff); -data[2951] = String.fromCharCode (0xffff); -data[2952] = String.fromCharCode (0xffff); -data[2953] = String.fromCharCode (0xffff); -data[2954] = String.fromCharCode (0xffff); -data[2955] = String.fromCharCode (0xffff); -data[2956] = String.fromCharCode (0xffff); -data[2957] = String.fromCharCode (0xffff); -data[2958] = String.fromCharCode (0xffff); -data[2959] = String.fromCharCode (0xffff); -data[2960] = String.fromCharCode (0xffff); -data[2961] = String.fromCharCode (0xffff); -data[2962] = String.fromCharCode (0xffff); -data[2963] = String.fromCharCode (0xffff); -data[2964] = String.fromCharCode (0xffff); -data[2965] = String.fromCharCode (0xffff); -data[2966] = String.fromCharCode (0xffff); -data[2967] = String.fromCharCode (0xffff); -data[2968] = String.fromCharCode (0xffff); -data[2969] = String.fromCharCode (0xffff); -data[2970] = String.fromCharCode (0xffff); -data[2971] = String.fromCharCode (0xffff); -data[2972] = String.fromCharCode (0xffff); -data[2973] = String.fromCharCode (0xffff); -data[2974] = String.fromCharCode (0xffff); -data[2975] = String.fromCharCode (0xffff); -data[2976] = String.fromCharCode (0xffff); -data[2977] = String.fromCharCode (0xffff); -data[2978] = String.fromCharCode (0xffff); -data[2979] = String.fromCharCode (0xffff); -data[2980] = String.fromCharCode (0xffff); -data[2981] = String.fromCharCode (0xffff); -data[2982] = String.fromCharCode (0xffff); -data[2983] = String.fromCharCode (0xffff); -data[2984] = String.fromCharCode (0xffff); -data[2985] = String.fromCharCode (0xffff); -data[2986] = String.fromCharCode (0xffff); -data[2987] = String.fromCharCode (0xffff); -data[2988] = String.fromCharCode (0xffff); -data[2989] = String.fromCharCode (0xffff); -data[2990] = String.fromCharCode (0xffff); -data[2991] = String.fromCharCode (0xffff); -data[2992] = String.fromCharCode (0xffff); -data[2993] = String.fromCharCode (0xffff); -data[2994] = String.fromCharCode (0xffff); -data[2995] = String.fromCharCode (0xffff); -data[2996] = String.fromCharCode (0xffff); -data[2997] = String.fromCharCode (0xffff); -data[2998] = String.fromCharCode (0xffff); -data[2999] = String.fromCharCode (0xffff); -data[3000] = String.fromCharCode (0xffff); -data[3001] = String.fromCharCode (0xffff); -data[3002] = String.fromCharCode (0xffff); -data[3003] = String.fromCharCode (0xffff); -data[3004] = String.fromCharCode (0xffff); -data[3005] = String.fromCharCode (0xffff); -data[3006] = String.fromCharCode (0xffff); -data[3007] = String.fromCharCode (0xffff); -data[3008] = String.fromCharCode (0xffff); -data[3009] = String.fromCharCode (0xffff); -data[3010] = String.fromCharCode (0xffff); -data[3011] = String.fromCharCode (0xffff); -data[3012] = String.fromCharCode (0xffff); -data[3013] = String.fromCharCode (0xffff); -data[3014] = String.fromCharCode (0xffff); -data[3015] = String.fromCharCode (0xffff); -data[3016] = String.fromCharCode (0xffff); -data[3017] = String.fromCharCode (0xffff); -data[3018] = String.fromCharCode (0xffff); -data[3019] = String.fromCharCode (0xffff); -data[3020] = String.fromCharCode (0xffff); -data[3021] = String.fromCharCode (0xffff); -data[3022] = String.fromCharCode (0xffff); -data[3023] = String.fromCharCode (0xffff); -data[3024] = String.fromCharCode (0xffff); -data[3025] = String.fromCharCode (0xffff); -data[3026] = String.fromCharCode (0xffff); -data[3027] = String.fromCharCode (0xffff); -data[3028] = String.fromCharCode (0xffff); -data[3029] = String.fromCharCode (0xffff); -data[3030] = String.fromCharCode (0xffff); -data[3031] = String.fromCharCode (0xffff); -data[3032] = String.fromCharCode (0xffff); -data[3033] = String.fromCharCode (0xffff); -data[3034] = String.fromCharCode (0xffff); -data[3035] = String.fromCharCode (0xffff); -data[3036] = String.fromCharCode (0xffff); -data[3037] = String.fromCharCode (0xffff); -data[3038] = String.fromCharCode (0xffff); -data[3039] = String.fromCharCode (0xffff); -data[3040] = String.fromCharCode (0xffff); -data[3041] = String.fromCharCode (0xffff); -data[3042] = String.fromCharCode (0xffff); -data[3043] = String.fromCharCode (0xffff); -data[3044] = String.fromCharCode (0xffff); -data[3045] = String.fromCharCode (0xffff); -data[3046] = String.fromCharCode (0xffff); -data[3047] = String.fromCharCode (0xffff); -data[3048] = String.fromCharCode (0xffff); -data[3049] = String.fromCharCode (0xffff); -data[3050] = String.fromCharCode (0xffff); -data[3051] = String.fromCharCode (0xffff); -data[3052] = String.fromCharCode (0xffff); -data[3053] = String.fromCharCode (0xffff); -data[3054] = String.fromCharCode (0xffff); -data[3055] = String.fromCharCode (0xffff); -data[3056] = String.fromCharCode (0xffff); -data[3057] = String.fromCharCode (0xffff); -data[3058] = String.fromCharCode (0xffff); -data[3059] = String.fromCharCode (0xffff); -data[3060] = String.fromCharCode (0xffff); -data[3061] = String.fromCharCode (0xffff); -data[3062] = String.fromCharCode (0xffff); -data[3063] = String.fromCharCode (0xffff); -data[3064] = String.fromCharCode (0xffff); -data[3065] = String.fromCharCode (0xffff); -data[3066] = String.fromCharCode (0xffff); -data[3067] = String.fromCharCode (0xffff); -data[3068] = String.fromCharCode (0xffff); -data[3069] = String.fromCharCode (0xffff); -data[3070] = String.fromCharCode (0xffff); -data[3071] = String.fromCharCode (0xffff); -data[3072] = String.fromCharCode (0xffff); -data[3073] = String.fromCharCode (0xffff); -data[3074] = String.fromCharCode (0xffff); -data[3075] = String.fromCharCode (0xffff); -data[3076] = String.fromCharCode (0xffff); -data[3077] = String.fromCharCode (0xffff); -data[3078] = String.fromCharCode (0xffff); -data[3079] = String.fromCharCode (0xffff); -data[3080] = String.fromCharCode (0xffff); -data[3081] = String.fromCharCode (0xffff); -data[3082] = String.fromCharCode (0xffff); -data[3083] = String.fromCharCode (0xffff); -data[3084] = String.fromCharCode (0xffff); -data[3085] = String.fromCharCode (0xffff); -data[3086] = String.fromCharCode (0xffff); -data[3087] = String.fromCharCode (0xffff); -data[3088] = String.fromCharCode (0xffff); -data[3089] = String.fromCharCode (0xffff); -data[3090] = String.fromCharCode (0xffff); -data[3091] = String.fromCharCode (0xffff); -data[3092] = String.fromCharCode (0xffff); -data[3093] = String.fromCharCode (0xffff); -data[3094] = String.fromCharCode (0xffff); -data[3095] = String.fromCharCode (0xffff); -data[3096] = String.fromCharCode (0xffff); -data[3097] = String.fromCharCode (0xffff); -data[3098] = String.fromCharCode (0xffff); -data[3099] = String.fromCharCode (0xffff); -data[3100] = String.fromCharCode (0xffff); -data[3101] = String.fromCharCode (0xffff); -data[3102] = String.fromCharCode (0xffff); -data[3103] = String.fromCharCode (0xffff); -data[3104] = String.fromCharCode (0xffff); -data[3105] = String.fromCharCode (0xffff); -data[3106] = String.fromCharCode (0xffff); -data[3107] = String.fromCharCode (0xffff); -data[3108] = String.fromCharCode (0xffff); -data[3109] = String.fromCharCode (0xffff); -data[3110] = String.fromCharCode (0xffff); -data[3111] = String.fromCharCode (0xffff); -data[3112] = String.fromCharCode (0xffff); -data[3113] = String.fromCharCode (0xffff); -data[3114] = String.fromCharCode (0xffff); -data[3115] = String.fromCharCode (0xffff); -data[3116] = String.fromCharCode (0xffff); -data[3117] = String.fromCharCode (0xffff); -data[3118] = String.fromCharCode (0xffff); -data[3119] = String.fromCharCode (0xffff); -data[3120] = String.fromCharCode (0xffff); -data[3121] = String.fromCharCode (0xffff); -data[3122] = String.fromCharCode (0xffff); -data[3123] = String.fromCharCode (0xffff); -data[3124] = String.fromCharCode (0xffff); -data[3125] = String.fromCharCode (0xffff); -data[3126] = String.fromCharCode (0xffff); -data[3127] = String.fromCharCode (0xffff); -data[3128] = String.fromCharCode (0xffff); -data[3129] = String.fromCharCode (0xffff); -data[3130] = String.fromCharCode (0xffff); -data[3131] = String.fromCharCode (0xffff); -data[3132] = String.fromCharCode (0xffff); -data[3133] = String.fromCharCode (0xffff); -data[3134] = String.fromCharCode (0xffff); -data[3135] = String.fromCharCode (0xffff); -data[3136] = String.fromCharCode (0xffff); -data[3137] = String.fromCharCode (0xffff); -data[3138] = String.fromCharCode (0xffff); -data[3139] = String.fromCharCode (0xffff); -data[3140] = String.fromCharCode (0xffff); -data[3141] = String.fromCharCode (0xffff); -data[3142] = String.fromCharCode (0xffff); -data[3143] = String.fromCharCode (0xffff); -data[3144] = String.fromCharCode (0xffff); -data[3145] = String.fromCharCode (0xffff); -data[3146] = String.fromCharCode (0xffff); -data[3147] = String.fromCharCode (0xffff); -data[3148] = String.fromCharCode (0xffff); -data[3149] = String.fromCharCode (0xffff); -data[3150] = String.fromCharCode (0xffff); -data[3151] = String.fromCharCode (0xffff); -data[3152] = String.fromCharCode (0xffff); -data[3153] = String.fromCharCode (0xffff); -data[3154] = String.fromCharCode (0xffff); -data[3155] = String.fromCharCode (0xffff); -data[3156] = String.fromCharCode (0xffff); -data[3157] = String.fromCharCode (0xffff); -data[3158] = String.fromCharCode (0xffff); -data[3159] = String.fromCharCode (0xffff); -data[3160] = String.fromCharCode (0xffff); -data[3161] = String.fromCharCode (0xffff); -data[3162] = String.fromCharCode (0xffff); -data[3163] = String.fromCharCode (0xffff); -data[3164] = String.fromCharCode (0xffff); -data[3165] = String.fromCharCode (0xffff); -data[3166] = String.fromCharCode (0xffff); -data[3167] = String.fromCharCode (0xffff); -data[3168] = String.fromCharCode (0xffff); -data[3169] = String.fromCharCode (0xffff); -data[3170] = String.fromCharCode (0xffff); -data[3171] = String.fromCharCode (0xffff); -data[3172] = String.fromCharCode (0xffff); -data[3173] = String.fromCharCode (0xffff); -data[3174] = String.fromCharCode (0xffff); -data[3175] = String.fromCharCode (0xffff); -data[3176] = String.fromCharCode (0xffff); -data[3177] = String.fromCharCode (0xffff); -data[3178] = String.fromCharCode (0xffff); -data[3179] = String.fromCharCode (0xffff); -data[3180] = String.fromCharCode (0xffff); -data[3181] = String.fromCharCode (0xffff); -data[3182] = String.fromCharCode (0xffff); -data[3183] = String.fromCharCode (0xffff); -data[3184] = String.fromCharCode (0xffff); -data[3185] = String.fromCharCode (0xffff); -data[3186] = String.fromCharCode (0xffff); -data[3187] = String.fromCharCode (0xffff); -data[3188] = String.fromCharCode (0xffff); -data[3189] = String.fromCharCode (0xffff); -data[3190] = String.fromCharCode (0xffff); -data[3191] = String.fromCharCode (0xffff); -data[3192] = String.fromCharCode (0xffff); -data[3193] = String.fromCharCode (0xffff); -data[3194] = String.fromCharCode (0xffff); -data[3195] = String.fromCharCode (0xffff); -data[3196] = String.fromCharCode (0xffff); -data[3197] = String.fromCharCode (0xffff); -data[3198] = String.fromCharCode (0xffff); -data[3199] = String.fromCharCode (0xffff); -data[3200] = String.fromCharCode (0xffff); -data[3201] = String.fromCharCode (0xffff); -data[3202] = String.fromCharCode (0xffff); -data[3203] = String.fromCharCode (0xffff); -data[3204] = String.fromCharCode (0xffff); -data[3205] = String.fromCharCode (0xffff); -data[3206] = String.fromCharCode (0xffff); -data[3207] = String.fromCharCode (0xffff); -data[3208] = String.fromCharCode (0xffff); -data[3209] = String.fromCharCode (0xffff); -data[3210] = String.fromCharCode (0xffff); -data[3211] = String.fromCharCode (0xffff); -data[3212] = String.fromCharCode (0xffff); -data[3213] = String.fromCharCode (0xffff); -data[3214] = String.fromCharCode (0xffff); -data[3215] = String.fromCharCode (0xffff); -data[3216] = String.fromCharCode (0xffff); -data[3217] = String.fromCharCode (0xffff); -data[3218] = String.fromCharCode (0xffff); -data[3219] = String.fromCharCode (0xffff); -data[3220] = String.fromCharCode (0xffff); -data[3221] = String.fromCharCode (0xffff); -data[3222] = String.fromCharCode (0xffff); -data[3223] = String.fromCharCode (0xffff); -data[3224] = String.fromCharCode (0xffff); -data[3225] = String.fromCharCode (0xffff); -data[3226] = String.fromCharCode (0xffff); -data[3227] = String.fromCharCode (0xffff); -data[3228] = String.fromCharCode (0xffff); -data[3229] = String.fromCharCode (0xffff); -data[3230] = String.fromCharCode (0xffff); -data[3231] = String.fromCharCode (0xffff); -data[3232] = String.fromCharCode (0xffff); -data[3233] = String.fromCharCode (0xffff); -data[3234] = String.fromCharCode (0xffff); -data[3235] = String.fromCharCode (0xffff); -data[3236] = String.fromCharCode (0xffff); -data[3237] = String.fromCharCode (0xffff); -data[3238] = String.fromCharCode (0xffff); -data[3239] = String.fromCharCode (0xffff); -data[3240] = String.fromCharCode (0xffff); -data[3241] = String.fromCharCode (0xffff); -data[3242] = String.fromCharCode (0xffff); -data[3243] = String.fromCharCode (0xffff); -data[3244] = String.fromCharCode (0xffff); -data[3245] = String.fromCharCode (0xffff); -data[3246] = String.fromCharCode (0xffff); -data[3247] = String.fromCharCode (0xffff); -data[3248] = String.fromCharCode (0xffff); -data[3249] = String.fromCharCode (0xffff); -data[3250] = String.fromCharCode (0xffff); -data[3251] = String.fromCharCode (0xffff); -data[3252] = String.fromCharCode (0xffff); -data[3253] = String.fromCharCode (0xffff); -data[3254] = String.fromCharCode (0xffff); -data[3255] = String.fromCharCode (0xffff); -data[3256] = String.fromCharCode (0xffff); -data[3257] = String.fromCharCode (0xffff); -data[3258] = String.fromCharCode (0xffff); -data[3259] = String.fromCharCode (0xffff); -data[3260] = String.fromCharCode (0xffff); -data[3261] = String.fromCharCode (0xffff); -data[3262] = String.fromCharCode (0xffff); -data[3263] = String.fromCharCode (0xffff); -data[3264] = String.fromCharCode (0xffff); -data[3265] = String.fromCharCode (0xffff); -data[3266] = String.fromCharCode (0xffff); -data[3267] = String.fromCharCode (0xffff); -data[3268] = String.fromCharCode (0xffff); -data[3269] = String.fromCharCode (0xffff); -data[3270] = String.fromCharCode (0xffff); -data[3271] = String.fromCharCode (0xffff); -data[3272] = String.fromCharCode (0xffff); -data[3273] = String.fromCharCode (0xffff); -data[3274] = String.fromCharCode (0xffff); -data[3275] = String.fromCharCode (0xffff); -data[3276] = String.fromCharCode (0xffff); -data[3277] = String.fromCharCode (0xffff); -data[3278] = String.fromCharCode (0xffff); -data[3279] = String.fromCharCode (0xffff); -data[3280] = String.fromCharCode (0xffff); -data[3281] = String.fromCharCode (0xffff); -data[3282] = String.fromCharCode (0xffff); -data[3283] = String.fromCharCode (0xffff); -data[3284] = String.fromCharCode (0xffff); -data[3285] = String.fromCharCode (0xffff); -data[3286] = String.fromCharCode (0xffff); -data[3287] = String.fromCharCode (0xffff); -data[3288] = String.fromCharCode (0xffff); -data[3289] = String.fromCharCode (0xffff); -data[3290] = String.fromCharCode (0xffff); -data[3291] = String.fromCharCode (0xffff); -data[3292] = String.fromCharCode (0xffff); -data[3293] = String.fromCharCode (0xffff); -data[3294] = String.fromCharCode (0xffff); -data[3295] = String.fromCharCode (0xffff); -data[3296] = String.fromCharCode (0xffff); -data[3297] = String.fromCharCode (0xffff); -data[3298] = String.fromCharCode (0xffff); -data[3299] = String.fromCharCode (0xffff); -data[3300] = String.fromCharCode (0xffff); -data[3301] = String.fromCharCode (0xffff); -data[3302] = String.fromCharCode (0xffff); -data[3303] = String.fromCharCode (0xffff); -data[3304] = String.fromCharCode (0xffff); -data[3305] = String.fromCharCode (0xffff); -data[3306] = String.fromCharCode (0xffff); -data[3307] = String.fromCharCode (0xffff); -data[3308] = String.fromCharCode (0xffff); -data[3309] = String.fromCharCode (0xffff); -data[3310] = String.fromCharCode (0xffff); -data[3311] = String.fromCharCode (0xffff); -data[3312] = String.fromCharCode (0xffff); -data[3313] = String.fromCharCode (0xffff); -data[3314] = String.fromCharCode (0xffff); -data[3315] = String.fromCharCode (0xffff); -data[3316] = String.fromCharCode (0xffff); -data[3317] = String.fromCharCode (0xffff); -data[3318] = String.fromCharCode (0xffff); -data[3319] = String.fromCharCode (0xffff); -data[3320] = String.fromCharCode (0xffff); -data[3321] = String.fromCharCode (0xffff); -data[3322] = String.fromCharCode (0xffff); -data[3323] = String.fromCharCode (0xffff); -data[3324] = String.fromCharCode (0xffff); -data[3325] = String.fromCharCode (0xffff); -data[3326] = String.fromCharCode (0xffff); -data[3327] = String.fromCharCode (0xffff); -data[3328] = String.fromCharCode (0xffff); -data[3329] = String.fromCharCode (0xffff); -data[3330] = String.fromCharCode (0xffff); -data[3331] = String.fromCharCode (0xffff); -data[3332] = String.fromCharCode (0xffff); -data[3333] = String.fromCharCode (0xffff); -data[3334] = String.fromCharCode (0xffff); -data[3335] = String.fromCharCode (0xffff); -data[3336] = String.fromCharCode (0xffff); -data[3337] = String.fromCharCode (0xffff); -data[3338] = String.fromCharCode (0xffff); -data[3339] = String.fromCharCode (0xffff); -data[3340] = String.fromCharCode (0xffff); -data[3341] = String.fromCharCode (0xffff); -data[3342] = String.fromCharCode (0xffff); -data[3343] = String.fromCharCode (0xffff); -data[3344] = String.fromCharCode (0xffff); -data[3345] = String.fromCharCode (0xffff); -data[3346] = String.fromCharCode (0xffff); -data[3347] = String.fromCharCode (0xffff); -data[3348] = String.fromCharCode (0xffff); -data[3349] = String.fromCharCode (0xffff); -data[3350] = String.fromCharCode (0xffff); -data[3351] = String.fromCharCode (0xffff); -data[3352] = String.fromCharCode (0xffff); -data[3353] = String.fromCharCode (0xffff); -data[3354] = String.fromCharCode (0xffff); -data[3355] = String.fromCharCode (0xffff); -data[3356] = String.fromCharCode (0xffff); -data[3357] = String.fromCharCode (0xffff); -data[3358] = String.fromCharCode (0xffff); -data[3359] = String.fromCharCode (0xffff); -data[3360] = String.fromCharCode (0xffff); -data[3361] = String.fromCharCode (0xffff); -data[3362] = String.fromCharCode (0xffff); -data[3363] = String.fromCharCode (0xffff); -data[3364] = String.fromCharCode (0xffff); -data[3365] = String.fromCharCode (0xffff); -data[3366] = String.fromCharCode (0xffff); -data[3367] = String.fromCharCode (0xffff); -data[3368] = String.fromCharCode (0xffff); -data[3369] = String.fromCharCode (0xffff); -data[3370] = String.fromCharCode (0xffff); -data[3371] = String.fromCharCode (0xffff); -data[3372] = String.fromCharCode (0xffff); -data[3373] = String.fromCharCode (0xffff); -data[3374] = String.fromCharCode (0xffff); -data[3375] = String.fromCharCode (0xffff); -data[3376] = String.fromCharCode (0xffff); -data[3377] = String.fromCharCode (0xffff); -data[3378] = String.fromCharCode (0xffff); -data[3379] = String.fromCharCode (0xffff); -data[3380] = String.fromCharCode (0xffff); -data[3381] = String.fromCharCode (0xffff); -data[3382] = String.fromCharCode (0xffff); -data[3383] = String.fromCharCode (0xffff); -data[3384] = String.fromCharCode (0xffff); -data[3385] = String.fromCharCode (0xffff); -data[3386] = String.fromCharCode (0xffff); -data[3387] = String.fromCharCode (0xffff); -data[3388] = String.fromCharCode (0xffff); -data[3389] = String.fromCharCode (0xffff); -data[3390] = String.fromCharCode (0xffff); -data[3391] = String.fromCharCode (0xffff); -data[3392] = String.fromCharCode (0xffff); -data[3393] = String.fromCharCode (0xffff); -data[3394] = String.fromCharCode (0xffff); -data[3395] = String.fromCharCode (0xffff); -data[3396] = String.fromCharCode (0xffff); -data[3397] = String.fromCharCode (0xffff); -data[3398] = String.fromCharCode (0xffff); -data[3399] = String.fromCharCode (0xffff); -data[3400] = String.fromCharCode (0xffff); -data[3401] = String.fromCharCode (0xffff); -data[3402] = String.fromCharCode (0xffff); -data[3403] = String.fromCharCode (0xffff); -data[3404] = String.fromCharCode (0xffff); -data[3405] = String.fromCharCode (0xffff); -data[3406] = String.fromCharCode (0xffff); -data[3407] = String.fromCharCode (0xffff); -data[3408] = String.fromCharCode (0xffff); -data[3409] = String.fromCharCode (0xffff); -data[3410] = String.fromCharCode (0xffff); -data[3411] = String.fromCharCode (0xffff); -data[3412] = String.fromCharCode (0xffff); -data[3413] = String.fromCharCode (0xffff); -data[3414] = String.fromCharCode (0xffff); -data[3415] = String.fromCharCode (0xffff); -data[3416] = String.fromCharCode (0xffff); -data[3417] = String.fromCharCode (0xffff); -data[3418] = String.fromCharCode (0xffff); -data[3419] = String.fromCharCode (0xffff); -data[3420] = String.fromCharCode (0xffff); -data[3421] = String.fromCharCode (0xffff); -data[3422] = String.fromCharCode (0xffff); -data[3423] = String.fromCharCode (0xffff); -data[3424] = String.fromCharCode (0xffff); -data[3425] = String.fromCharCode (0xffff); -data[3426] = String.fromCharCode (0xffff); -data[3427] = String.fromCharCode (0xffff); -data[3428] = String.fromCharCode (0xffff); -data[3429] = String.fromCharCode (0xffff); -data[3430] = String.fromCharCode (0xffff); -data[3431] = String.fromCharCode (0xffff); -data[3432] = String.fromCharCode (0xffff); -data[3433] = String.fromCharCode (0xffff); -data[3434] = String.fromCharCode (0xffff); -data[3435] = String.fromCharCode (0xffff); -data[3436] = String.fromCharCode (0xffff); -data[3437] = String.fromCharCode (0xffff); -data[3438] = String.fromCharCode (0xffff); -data[3439] = String.fromCharCode (0xffff); -data[3440] = String.fromCharCode (0xffff); -data[3441] = String.fromCharCode (0xffff); -data[3442] = String.fromCharCode (0xffff); -data[3443] = String.fromCharCode (0xffff); -data[3444] = String.fromCharCode (0xffff); -data[3445] = String.fromCharCode (0xffff); -data[3446] = String.fromCharCode (0xffff); -data[3447] = String.fromCharCode (0xffff); -data[3448] = String.fromCharCode (0xffff); -data[3449] = String.fromCharCode (0xffff); -data[3450] = String.fromCharCode (0x000f); -data[3984] = String.fromCharCode (0xffff); -data[3985] = String.fromCharCode (0xffff); -data[3986] = String.fromCharCode (0xffff); -data[3987] = String.fromCharCode (0xffff); -data[3988] = String.fromCharCode (0xffff); -data[3989] = String.fromCharCode (0xffff); -data[3990] = String.fromCharCode (0xffff); -data[3991] = String.fromCharCode (0xffff); -data[3992] = String.fromCharCode (0xffff); -data[3993] = String.fromCharCode (0xffff); -data[3994] = String.fromCharCode (0xffff); -data[3995] = String.fromCharCode (0xffff); -data[3996] = String.fromCharCode (0xffff); -data[3997] = String.fromCharCode (0xffff); -data[3998] = String.fromCharCode (0xffff); -data[3999] = String.fromCharCode (0xffff); -data[4000] = String.fromCharCode (0xffff); -data[4001] = String.fromCharCode (0xffff); -data[4002] = String.fromCharCode (0x3fff); -data[4016] = String.fromCharCode (0x007f); -data[4017] = String.fromCharCode (0x80f8); -data[4018] = String.fromCharCode (0xfdff); -data[4019] = String.fromCharCode (0x5f7f); -data[4020] = String.fromCharCode (0xffdb); -data[4021] = String.fromCharCode (0xffff); -data[4022] = String.fromCharCode (0xffff); -data[4023] = String.fromCharCode (0xffff); -data[4024] = String.fromCharCode (0xffff); -data[4025] = String.fromCharCode (0xffff); -data[4026] = String.fromCharCode (0xffff); -data[4027] = String.fromCharCode (0x0003); -data[4029] = String.fromCharCode (0xfff8); -data[4030] = String.fromCharCode (0xffff); -data[4031] = String.fromCharCode (0xffff); -data[4032] = String.fromCharCode (0xffff); -data[4033] = String.fromCharCode (0xffff); -data[4034] = String.fromCharCode (0xffff); -data[4035] = String.fromCharCode (0xffff); -data[4036] = String.fromCharCode (0xffff); -data[4037] = String.fromCharCode (0xffff); -data[4038] = String.fromCharCode (0xffff); -data[4039] = String.fromCharCode (0xffff); -data[4040] = String.fromCharCode (0xffff); -data[4041] = String.fromCharCode (0xffff); -data[4042] = String.fromCharCode (0xffff); -data[4043] = String.fromCharCode (0xffff); -data[4044] = String.fromCharCode (0xffff); -data[4045] = String.fromCharCode (0xffff); -data[4046] = String.fromCharCode (0xffff); -data[4047] = String.fromCharCode (0xffff); -data[4048] = String.fromCharCode (0xffff); -data[4049] = String.fromCharCode (0xffff); -data[4050] = String.fromCharCode (0xffff); -data[4051] = String.fromCharCode (0x3fff); -data[4053] = String.fromCharCode (0xffff); -data[4054] = String.fromCharCode (0xffff); -data[4055] = String.fromCharCode (0xffff); -data[4056] = String.fromCharCode (0xffff); -data[4057] = String.fromCharCode (0xfffc); -data[4058] = String.fromCharCode (0xffff); -data[4059] = String.fromCharCode (0xffff); -data[4060] = String.fromCharCode (0x00ff); -data[4063] = String.fromCharCode (0x0fff); -data[4071] = String.fromCharCode (0xffd7); -data[4072] = String.fromCharCode (0xffff); -data[4073] = String.fromCharCode (0xffff); -data[4074] = String.fromCharCode (0xffff); -data[4075] = String.fromCharCode (0xffff); -data[4076] = String.fromCharCode (0xffff); -data[4077] = String.fromCharCode (0xffff); -data[4078] = String.fromCharCode (0xffff); -data[4079] = String.fromCharCode (0x1fff); -data[4082] = String.fromCharCode (0xfffe); -data[4083] = String.fromCharCode (0x07ff); -data[4084] = String.fromCharCode (0xfffe); -data[4085] = String.fromCharCode (0x07ff); -data[4086] = String.fromCharCode (0xffc0); -data[4087] = String.fromCharCode (0xffff); -data[4088] = String.fromCharCode (0xffff); -data[4089] = String.fromCharCode (0xffff); -data[4090] = String.fromCharCode (0xffff); -data[4091] = String.fromCharCode (0x7fff); -data[4092] = String.fromCharCode (0xfcfc); -data[4093] = String.fromCharCode (0x1cfc); -data[4100] = String.fromCharCode (0xfffe); -data[4101] = String.fromCharCode (0x07ff); -data[4102] = String.fromCharCode (0xfffe); -data[4103] = String.fromCharCode (0x07ff); -data[4106] = String.fromCharCode (0x0400); -data[4107] = String.fromCharCode (0x0420); -data[4108] = String.fromCharCode (0xffff); -data[4109] = String.fromCharCode (0xff7f); -data[4110] = String.fromCharCode (0xffff); -data[4111] = String.fromCharCode (0xff7f); -data[4112] = String.fromCharCode (0xffff); -data[4113] = String.fromCharCode (0xffff); -data[4114] = String.fromCharCode (0xffff); -data[4115] = String.fromCharCode (0xffff); -data[4116] = String.fromCharCode (0xffff); -data[4117] = String.fromCharCode (0xffff); -data[4118] = String.fromCharCode (0xffff); -data[4119] = String.fromCharCode (0xffff); -data[4120] = String.fromCharCode (0xffff); -data[4121] = String.fromCharCode (0xffff); -data[4122] = String.fromCharCode (0xffff); -data[4123] = String.fromCharCode (0xffff); -data[4124] = String.fromCharCode (0xffff); -data[4125] = String.fromCharCode (0xffff); -data[4126] = String.fromCharCode (0xffff); -data[4127] = String.fromCharCode (0xfc3f); -data[4128] = String.fromCharCode (0xffff); -data[4129] = String.fromCharCode (0x00ff); -data[4133] = String.fromCharCode (0xffff); -data[4134] = String.fromCharCode (0xffff); -data[4135] = String.fromCharCode (0xffff); -data[4136] = String.fromCharCode (0xffff); -data[4137] = String.fromCharCode (0xffff); -data[4138] = String.fromCharCode (0x01ff); -data[4139] = String.fromCharCode (0xf9ff); -data[4140] = String.fromCharCode (0x0003); -data[4141] = String.fromCharCode (0x0003); -data[4142] = String.fromCharCode (0x001f); -data[4151] = String.fromCharCode (0x0400); -data[4152] = String.fromCharCode (0xd740); -data[4153] = String.fromCharCode (0xffff); -data[4154] = String.fromCharCode (0xfffb); -data[4155] = String.fromCharCode (0xffff); -data[4156] = String.fromCharCode (0x7fff); -data[4157] = String.fromCharCode (0x547f); -data[4158] = String.fromCharCode (0x00fd); -}); -c$.white_f = Clazz.defineMethod (c$, "white_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.white = new com.stevesoft.pat.Bits (data); -data[0] = String.fromCharCode (0x3e00); -data[1] = String.fromCharCode (0xf000); -data[2] = String.fromCharCode (0x0001); -data[512] = String.fromCharCode (0x0fff); -data[514] = String.fromCharCode (0x0300); -data[768] = String.fromCharCode (0x0001); -data[4096] = String.fromCharCode (0x3e00); -data[4097] = String.fromCharCode (0xf000); -data[4098] = String.fromCharCode (0x0001); -}); -c$.punct_f = Clazz.defineMethod (c$, "punct_f", -function () { -var data = Clazz.newCharArray (4159, '\0'); -com.stevesoft.pat.Bits.punct = new com.stevesoft.pat.Bits (data); -data[2] = String.fromCharCode (0xf7ee); -data[3] = String.fromCharCode (0x8c00); -data[4] = String.fromCharCode (0x0001); -data[5] = String.fromCharCode (0xb800); -data[7] = String.fromCharCode (0x2800); -data[10] = String.fromCharCode (0x2802); -data[11] = String.fromCharCode (0x8880); -data[55] = String.fromCharCode (0x4030); -data[56] = String.fromCharCode (0x0080); -data[85] = String.fromCharCode (0xfc00); -data[88] = String.fromCharCode (0x0200); -data[91] = String.fromCharCode (0x4000); -data[92] = String.fromCharCode (0x0009); -data[95] = String.fromCharCode (0x0018); -data[96] = String.fromCharCode (0x1000); -data[97] = String.fromCharCode (0x8800); -data[102] = String.fromCharCode (0x3c00); -data[109] = String.fromCharCode (0x0010); -data[150] = '0'; -data[151] = String.fromCharCode (0x0001); -data[226] = String.fromCharCode (0x8000); -data[229] = String.fromCharCode (0x0c00); -data[234] = String.fromCharCode (0x8000); -data[240] = String.fromCharCode (0xfff0); -data[241] = String.fromCharCode (0x0007); -data[243] = String.fromCharCode (0x3c00); -data[248] = String.fromCharCode (0x0020); -data[271] = String.fromCharCode (0x0800); -data[513] = String.fromCharCode (0xffff); -data[514] = String.fromCharCode (0x00ff); -data[515] = String.fromCharCode (0xffff); -data[516] = 'o'; -data[519] = String.fromCharCode (0x6000); -data[520] = String.fromCharCode (0x6000); -data[562] = String.fromCharCode (0x0600); -data[768] = String.fromCharCode (0xff4e); -data[769] = String.fromCharCode (0xfff3); -data[771] = String.fromCharCode (0x0001); -data[783] = String.fromCharCode (0x0800); -data[4051] = String.fromCharCode (0xc000); -data[4067] = String.fromCharCode (0xffff); -data[4068] = String.fromCharCode (0xfe1f); -data[4069] = String.fromCharCode (0xfff7); -data[4070] = String.fromCharCode (0x0d0b); -data[4080] = String.fromCharCode (0xf7ee); -data[4081] = String.fromCharCode (0x8c00); -data[4082] = String.fromCharCode (0x0001); -data[4083] = String.fromCharCode (0xb800); -data[4085] = String.fromCharCode (0x2800); -data[4086] = String.fromCharCode (0x003e); -data[4098] = String.fromCharCode (0xf7ee); -data[4099] = String.fromCharCode (0x8c00); -data[4100] = String.fromCharCode (0x0001); -data[4101] = String.fromCharCode (0xb800); -data[4103] = String.fromCharCode (0x2800); -data[4106] = String.fromCharCode (0x2802); -data[4107] = String.fromCharCode (0x8880); -data[4151] = String.fromCharCode (0x4030); -data[4152] = String.fromCharCode (0x0080); -}); -Clazz.defineStatics (c$, -"upper", null, -"lower", null, -"title", null, -"currency", null, -"decimal_digit", null, -"math", null, -"letter", null, -"white", null, -"punct", null); +Clazz.declarePackage ("com.stevesoft.pat"); +c$ = Clazz.decorateAsClass (function () { +this.carray = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Bits"); +Clazz.makeConstructor (c$, +function (carray) { +this.carray = carray; +}, "~A"); +Clazz.defineMethod (c$, "get", +function (i) { +return ((this.carray[i >> 4]).charCodeAt (0) & (1 << (i & 15))) != 0; +}, "~N"); +Clazz.defineMethod (c$, "set", +function (i, b) { +if (b) { +this.carray[i >> 4] = String.fromCharCode ((this.carray[i >> 4]).charCodeAt (0) | ((String.fromCharCode (1)).charCodeAt (0) << (i & 15))); +} else { +this.carray[i >> 4] = String.fromCharCode ((this.carray[i >> 4]).charCodeAt (0) & (String.fromCharCode (~(1 << (i & 15)))).charCodeAt (0)); +}}, "~N,~B"); +c$.upper_f = Clazz.defineMethod (c$, "upper_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.upper = new com.stevesoft.pat.Bits (data); +data[4] = String.fromCharCode (0xfffe); +data[5] = String.fromCharCode (0x07ff); +data[12] = String.fromCharCode (0xffff); +data[13] = String.fromCharCode (0x7f7f); +data[16] = String.fromCharCode (0x5555); +data[17] = String.fromCharCode (0x5555); +data[18] = String.fromCharCode (0x5555); +data[19] = String.fromCharCode (0xaa55); +data[20] = String.fromCharCode (0x54aa); +data[21] = String.fromCharCode (0x5555); +data[22] = String.fromCharCode (0x5555); +data[23] = String.fromCharCode (0x2b55); +data[24] = String.fromCharCode (0xced6); +data[25] = String.fromCharCode (0xb1db); +data[26] = String.fromCharCode (0xd2d5); +data[27] = String.fromCharCode (0x11ae); +data[28] = String.fromCharCode (0xa490); +data[29] = String.fromCharCode (0x4aaa); +data[30] = String.fromCharCode (0x5555); +data[31] = String.fromCharCode (0x5412); +data[32] = String.fromCharCode (0x5555); +data[33] = 'U'; +data[56] = String.fromCharCode (0xd740); +data[57] = String.fromCharCode (0xfffe); +data[58] = String.fromCharCode (0x0ffb); +data[61] = String.fromCharCode (0x541c); +data[62] = String.fromCharCode (0x5555); +data[64] = String.fromCharCode (0xdffe); +data[65] = String.fromCharCode (0xffff); +data[66] = String.fromCharCode (0xffff); +data[70] = String.fromCharCode (0x5555); +data[71] = String.fromCharCode (0x5555); +data[72] = String.fromCharCode (0x0001); +data[73] = String.fromCharCode (0x5555); +data[74] = String.fromCharCode (0x5555); +data[75] = String.fromCharCode (0x5555); +data[76] = String.fromCharCode (0x088a); +data[77] = String.fromCharCode (0x5555); +data[78] = String.fromCharCode (0x4555); +data[79] = String.fromCharCode (0x0115); +data[83] = String.fromCharCode (0xfffe); +data[84] = String.fromCharCode (0xffff); +data[85] = String.fromCharCode (0x007f); +data[266] = String.fromCharCode (0xffff); +data[267] = String.fromCharCode (0xffff); +data[268] = String.fromCharCode (0x003f); +data[480] = String.fromCharCode (0x5555); +data[481] = String.fromCharCode (0x5555); +data[482] = String.fromCharCode (0x5555); +data[483] = String.fromCharCode (0x5555); +data[484] = String.fromCharCode (0x5555); +data[485] = String.fromCharCode (0x5555); +data[486] = String.fromCharCode (0x5555); +data[487] = String.fromCharCode (0x5555); +data[488] = String.fromCharCode (0x5555); +data[489] = String.fromCharCode (0x0015); +data[490] = String.fromCharCode (0x5555); +data[491] = String.fromCharCode (0x5555); +data[492] = String.fromCharCode (0x5555); +data[493] = String.fromCharCode (0x5555); +data[494] = String.fromCharCode (0x5555); +data[495] = String.fromCharCode (0x0155); +data[496] = String.fromCharCode (0xff00); +data[497] = String.fromCharCode (0x3f00); +data[498] = String.fromCharCode (0xff00); +data[499] = String.fromCharCode (0xff00); +data[500] = String.fromCharCode (0x3f00); +data[501] = String.fromCharCode (0xaa00); +data[502] = String.fromCharCode (0xff00); +data[504] = String.fromCharCode (0xff00); +data[505] = String.fromCharCode (0xff00); +data[506] = String.fromCharCode (0xff00); +data[507] = String.fromCharCode (0x5f00); +data[508] = String.fromCharCode (0x1f00); +data[509] = String.fromCharCode (0x0f00); +data[510] = String.fromCharCode (0x1f00); +data[511] = String.fromCharCode (0x1f00); +data[528] = String.fromCharCode (0x3884); +data[529] = String.fromCharCode (0x3f27); +data[530] = String.fromCharCode (0x3d50); +data[531] = String.fromCharCode (0x000b); +data[4082] = String.fromCharCode (0xfffe); +data[4083] = String.fromCharCode (0x07ff); +data[4100] = String.fromCharCode (0xfffe); +data[4101] = String.fromCharCode (0x07ff); +data[4108] = String.fromCharCode (0xffff); +data[4109] = String.fromCharCode (0x7f7f); +data[4112] = String.fromCharCode (0x5555); +data[4113] = String.fromCharCode (0x5555); +data[4114] = String.fromCharCode (0x5555); +data[4115] = String.fromCharCode (0xaa55); +data[4116] = String.fromCharCode (0x54aa); +data[4117] = String.fromCharCode (0x5555); +data[4118] = String.fromCharCode (0x5555); +data[4119] = String.fromCharCode (0x2b55); +data[4120] = String.fromCharCode (0xced6); +data[4121] = String.fromCharCode (0xb1db); +data[4122] = String.fromCharCode (0xd2d5); +data[4123] = String.fromCharCode (0x11ae); +data[4124] = String.fromCharCode (0xa490); +data[4125] = String.fromCharCode (0x4aaa); +data[4126] = String.fromCharCode (0x5555); +data[4127] = String.fromCharCode (0x5412); +data[4128] = String.fromCharCode (0x5555); +data[4129] = 'U'; +data[4152] = String.fromCharCode (0xd740); +data[4153] = String.fromCharCode (0xfffe); +data[4154] = String.fromCharCode (0x0ffb); +data[4157] = String.fromCharCode (0x541c); +data[4158] = 'U'; +}); +c$.lower_f = Clazz.defineMethod (c$, "lower_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.lower = new com.stevesoft.pat.Bits (data); +data[6] = String.fromCharCode (0xfffe); +data[7] = String.fromCharCode (0x07ff); +data[10] = String.fromCharCode (0x0400); +data[11] = String.fromCharCode (0x0420); +data[13] = String.fromCharCode (0x8000); +data[14] = String.fromCharCode (0xffff); +data[15] = String.fromCharCode (0xff7f); +data[16] = String.fromCharCode (0xaaaa); +data[17] = String.fromCharCode (0xaaaa); +data[18] = String.fromCharCode (0xaaaa); +data[19] = String.fromCharCode (0x55aa); +data[20] = String.fromCharCode (0xab55); +data[21] = String.fromCharCode (0xaaaa); +data[22] = String.fromCharCode (0xaaaa); +data[23] = String.fromCharCode (0xd4aa); +data[24] = String.fromCharCode (0x3129); +data[25] = String.fromCharCode (0x4e24); +data[26] = String.fromCharCode (0x292a); +data[27] = String.fromCharCode (0x2651); +data[28] = String.fromCharCode (0x5240); +data[29] = String.fromCharCode (0xb555); +data[30] = String.fromCharCode (0xaaaa); +data[31] = String.fromCharCode (0xa829); +data[32] = String.fromCharCode (0xaaaa); +data[33] = String.fromCharCode (0x00aa); +data[37] = String.fromCharCode (0xffff); +data[38] = String.fromCharCode (0xffff); +data[39] = String.fromCharCode (0xffff); +data[40] = String.fromCharCode (0xffff); +data[41] = String.fromCharCode (0xffff); +data[42] = String.fromCharCode (0x01ff); +data[57] = String.fromCharCode (0x0001); +data[58] = String.fromCharCode (0xf000); +data[59] = String.fromCharCode (0xffff); +data[60] = String.fromCharCode (0x7fff); +data[61] = 'c'; +data[62] = String.fromCharCode (0xaaa8); +data[63] = String.fromCharCode (0x0007); +data[67] = String.fromCharCode (0xffff); +data[68] = String.fromCharCode (0xffff); +data[69] = String.fromCharCode (0xdffe); +data[70] = String.fromCharCode (0xaaaa); +data[71] = String.fromCharCode (0xaaaa); +data[72] = String.fromCharCode (0x0002); +data[73] = String.fromCharCode (0xaaaa); +data[74] = String.fromCharCode (0xaaaa); +data[75] = String.fromCharCode (0xaaaa); +data[76] = String.fromCharCode (0x1114); +data[77] = String.fromCharCode (0xaaaa); +data[78] = String.fromCharCode (0x8aaa); +data[79] = String.fromCharCode (0x022a); +data[86] = String.fromCharCode (0xfffe); +data[87] = String.fromCharCode (0xffff); +data[88] = String.fromCharCode (0x00ff); +data[269] = String.fromCharCode (0xffff); +data[270] = String.fromCharCode (0xffff); +data[271] = String.fromCharCode (0x007f); +data[480] = String.fromCharCode (0xaaaa); +data[481] = String.fromCharCode (0xaaaa); +data[482] = String.fromCharCode (0xaaaa); +data[483] = String.fromCharCode (0xaaaa); +data[484] = String.fromCharCode (0xaaaa); +data[485] = String.fromCharCode (0xaaaa); +data[486] = String.fromCharCode (0xaaaa); +data[487] = String.fromCharCode (0xaaaa); +data[488] = String.fromCharCode (0xaaaa); +data[489] = String.fromCharCode (0x0fea); +data[490] = String.fromCharCode (0xaaaa); +data[491] = String.fromCharCode (0xaaaa); +data[492] = String.fromCharCode (0xaaaa); +data[493] = String.fromCharCode (0xaaaa); +data[494] = String.fromCharCode (0xaaaa); +data[495] = String.fromCharCode (0x02aa); +data[496] = String.fromCharCode (0x00ff); +data[497] = String.fromCharCode (0x003f); +data[498] = String.fromCharCode (0x00ff); +data[499] = String.fromCharCode (0x00ff); +data[500] = String.fromCharCode (0x003f); +data[501] = String.fromCharCode (0x00ff); +data[502] = String.fromCharCode (0x00ff); +data[503] = String.fromCharCode (0x3fff); +data[504] = String.fromCharCode (0x00ff); +data[505] = String.fromCharCode (0x00ff); +data[506] = String.fromCharCode (0x00ff); +data[507] = String.fromCharCode (0x00df); +data[508] = String.fromCharCode (0x00dc); +data[509] = String.fromCharCode (0x00cf); +data[510] = String.fromCharCode (0x00ff); +data[511] = String.fromCharCode (0x00dc); +data[519] = String.fromCharCode (0x8000); +data[528] = String.fromCharCode (0xc400); +data[529] = String.fromCharCode (0x0008); +data[530] = String.fromCharCode (0xc000); +data[531] = String.fromCharCode (0x0010); +data[4016] = String.fromCharCode (0x007f); +data[4017] = String.fromCharCode (0x00f8); +data[4084] = String.fromCharCode (0xfffe); +data[4085] = String.fromCharCode (0x07ff); +data[4102] = String.fromCharCode (0xfffe); +data[4103] = String.fromCharCode (0x07ff); +data[4106] = String.fromCharCode (0x0400); +data[4107] = String.fromCharCode (0x0420); +data[4109] = String.fromCharCode (0x8000); +data[4110] = String.fromCharCode (0xffff); +data[4111] = String.fromCharCode (0xff7f); +data[4112] = String.fromCharCode (0xaaaa); +data[4113] = String.fromCharCode (0xaaaa); +data[4114] = String.fromCharCode (0xaaaa); +data[4115] = String.fromCharCode (0x55aa); +data[4116] = String.fromCharCode (0xab55); +data[4117] = String.fromCharCode (0xaaaa); +data[4118] = String.fromCharCode (0xaaaa); +data[4119] = String.fromCharCode (0xd4aa); +data[4120] = String.fromCharCode (0x3129); +data[4121] = String.fromCharCode (0x4e24); +data[4122] = String.fromCharCode (0x292a); +data[4123] = String.fromCharCode (0x2651); +data[4124] = String.fromCharCode (0x5240); +data[4125] = String.fromCharCode (0xb555); +data[4126] = String.fromCharCode (0xaaaa); +data[4127] = String.fromCharCode (0xa829); +data[4128] = String.fromCharCode (0xaaaa); +data[4129] = String.fromCharCode (0x00aa); +data[4133] = String.fromCharCode (0xffff); +data[4134] = String.fromCharCode (0xffff); +data[4135] = String.fromCharCode (0xffff); +data[4136] = String.fromCharCode (0xffff); +data[4137] = String.fromCharCode (0xffff); +data[4138] = String.fromCharCode (0x01ff); +data[4153] = String.fromCharCode (0x0001); +data[4154] = String.fromCharCode (0xf000); +data[4155] = String.fromCharCode (0xffff); +data[4156] = String.fromCharCode (0x7fff); +data[4157] = 'c'; +data[4158] = String.fromCharCode (0x00a8); +}); +c$.title_f = Clazz.defineMethod (c$, "title_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.title = new com.stevesoft.pat.Bits (data); +data[6] = String.fromCharCode (0xfffe); +data[7] = String.fromCharCode (0x07ff); +data[10] = String.fromCharCode (0x0400); +data[11] = String.fromCharCode (0x0420); +data[13] = String.fromCharCode (0x8000); +data[14] = String.fromCharCode (0xffff); +data[15] = String.fromCharCode (0xff7f); +data[16] = String.fromCharCode (0xaaaa); +data[17] = String.fromCharCode (0xaaaa); +data[18] = String.fromCharCode (0xaaaa); +data[19] = String.fromCharCode (0x55aa); +data[20] = String.fromCharCode (0xab55); +data[21] = String.fromCharCode (0xaaaa); +data[22] = String.fromCharCode (0xaaaa); +data[23] = String.fromCharCode (0xd4aa); +data[24] = String.fromCharCode (0x3129); +data[25] = String.fromCharCode (0x4e24); +data[26] = String.fromCharCode (0x292a); +data[27] = String.fromCharCode (0x2651); +data[28] = String.fromCharCode (0x5240); +data[29] = String.fromCharCode (0xb555); +data[30] = String.fromCharCode (0xaaaa); +data[31] = String.fromCharCode (0xa829); +data[32] = String.fromCharCode (0xaaaa); +data[33] = String.fromCharCode (0x00aa); +data[37] = String.fromCharCode (0xffff); +data[38] = String.fromCharCode (0xffff); +data[39] = String.fromCharCode (0xffff); +data[40] = String.fromCharCode (0xffff); +data[41] = String.fromCharCode (0xffff); +data[42] = String.fromCharCode (0x01ff); +data[57] = String.fromCharCode (0x0001); +data[58] = String.fromCharCode (0xf000); +data[59] = String.fromCharCode (0xffff); +data[60] = String.fromCharCode (0x7fff); +data[61] = 'c'; +data[62] = String.fromCharCode (0xaaa8); +data[63] = String.fromCharCode (0x0007); +data[67] = String.fromCharCode (0xffff); +data[68] = String.fromCharCode (0xffff); +data[69] = String.fromCharCode (0xdffe); +data[70] = String.fromCharCode (0xaaaa); +data[71] = String.fromCharCode (0xaaaa); +data[72] = String.fromCharCode (0x0002); +data[73] = String.fromCharCode (0xaaaa); +data[74] = String.fromCharCode (0xaaaa); +data[75] = String.fromCharCode (0xaaaa); +data[76] = String.fromCharCode (0x1114); +data[77] = String.fromCharCode (0xaaaa); +data[78] = String.fromCharCode (0x8aaa); +data[79] = String.fromCharCode (0x022a); +data[86] = String.fromCharCode (0xfffe); +data[87] = String.fromCharCode (0xffff); +data[88] = String.fromCharCode (0x00ff); +data[269] = String.fromCharCode (0xffff); +data[270] = String.fromCharCode (0xffff); +data[271] = String.fromCharCode (0x007f); +data[480] = String.fromCharCode (0xaaaa); +data[481] = String.fromCharCode (0xaaaa); +data[482] = String.fromCharCode (0xaaaa); +data[483] = String.fromCharCode (0xaaaa); +data[484] = String.fromCharCode (0xaaaa); +data[485] = String.fromCharCode (0xaaaa); +data[486] = String.fromCharCode (0xaaaa); +data[487] = String.fromCharCode (0xaaaa); +data[488] = String.fromCharCode (0xaaaa); +data[489] = String.fromCharCode (0x0fea); +data[490] = String.fromCharCode (0xaaaa); +data[491] = String.fromCharCode (0xaaaa); +data[492] = String.fromCharCode (0xaaaa); +data[493] = String.fromCharCode (0xaaaa); +data[494] = String.fromCharCode (0xaaaa); +data[495] = String.fromCharCode (0x02aa); +data[496] = String.fromCharCode (0x00ff); +data[497] = String.fromCharCode (0x003f); +data[498] = String.fromCharCode (0x00ff); +data[499] = String.fromCharCode (0x00ff); +data[500] = String.fromCharCode (0x003f); +data[501] = String.fromCharCode (0x00ff); +data[502] = String.fromCharCode (0x00ff); +data[503] = String.fromCharCode (0x3fff); +data[504] = String.fromCharCode (0x00ff); +data[505] = String.fromCharCode (0x00ff); +data[506] = String.fromCharCode (0x00ff); +data[507] = String.fromCharCode (0x00df); +data[508] = String.fromCharCode (0x00dc); +data[509] = String.fromCharCode (0x00cf); +data[510] = String.fromCharCode (0x00ff); +data[511] = String.fromCharCode (0x00dc); +data[519] = String.fromCharCode (0x8000); +data[528] = String.fromCharCode (0xc400); +data[529] = String.fromCharCode (0x0008); +data[530] = String.fromCharCode (0xc000); +data[531] = String.fromCharCode (0x0010); +data[4016] = String.fromCharCode (0x007f); +data[4017] = String.fromCharCode (0x00f8); +data[4084] = String.fromCharCode (0xfffe); +data[4085] = String.fromCharCode (0x07ff); +data[4102] = String.fromCharCode (0xfffe); +data[4103] = String.fromCharCode (0x07ff); +data[4106] = String.fromCharCode (0x0400); +data[4107] = String.fromCharCode (0x0420); +data[4109] = String.fromCharCode (0x8000); +data[4110] = String.fromCharCode (0xffff); +data[4111] = String.fromCharCode (0xff7f); +data[4112] = String.fromCharCode (0xaaaa); +data[4113] = String.fromCharCode (0xaaaa); +data[4114] = String.fromCharCode (0xaaaa); +data[4115] = String.fromCharCode (0x55aa); +data[4116] = String.fromCharCode (0xab55); +data[4117] = String.fromCharCode (0xaaaa); +data[4118] = String.fromCharCode (0xaaaa); +data[4119] = String.fromCharCode (0xd4aa); +data[4120] = String.fromCharCode (0x3129); +data[4121] = String.fromCharCode (0x4e24); +data[4122] = String.fromCharCode (0x292a); +data[4123] = String.fromCharCode (0x2651); +data[4124] = String.fromCharCode (0x5240); +data[4125] = String.fromCharCode (0xb555); +data[4126] = String.fromCharCode (0xaaaa); +data[4127] = String.fromCharCode (0xa829); +data[4128] = String.fromCharCode (0xaaaa); +data[4129] = String.fromCharCode (0x00aa); +data[4133] = String.fromCharCode (0xffff); +data[4134] = String.fromCharCode (0xffff); +data[4135] = String.fromCharCode (0xffff); +data[4136] = String.fromCharCode (0xffff); +data[4137] = String.fromCharCode (0xffff); +data[4138] = String.fromCharCode (0x01ff); +data[4153] = String.fromCharCode (0x0001); +data[4154] = String.fromCharCode (0xf000); +data[4155] = String.fromCharCode (0xffff); +data[4156] = String.fromCharCode (0x7fff); +data[4157] = 'c'; +data[4158] = String.fromCharCode (0x00a8); +}); +c$.currency_f = Clazz.defineMethod (c$, "currency_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.currency = new com.stevesoft.pat.Bits (data); +data[2] = String.fromCharCode (0x0010); +data[10] = String.fromCharCode (0x003c); +data[159] = String.fromCharCode (0x000c); +data[227] = String.fromCharCode (0x8000); +data[522] = String.fromCharCode (0x1fff); +data[4070] = String.fromCharCode (0x0200); +data[4080] = String.fromCharCode (0x0010); +data[4094] = 'c'; +data[4098] = String.fromCharCode (0x0010); +data[4106] = String.fromCharCode (0x003c); +}); +c$.decimal_digit_f = Clazz.defineMethod (c$, "decimal_digit_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.decimal_digit = new com.stevesoft.pat.Bits (data); +data[3] = String.fromCharCode (0x03ff); +data[102] = String.fromCharCode (0x03ff); +data[111] = String.fromCharCode (0x03ff); +data[150] = String.fromCharCode (0xffc0); +data[158] = String.fromCharCode (0xffc0); +data[166] = String.fromCharCode (0xffc0); +data[174] = String.fromCharCode (0xffc0); +data[182] = String.fromCharCode (0xffc0); +data[190] = String.fromCharCode (0xff80); +data[198] = String.fromCharCode (0xffc0); +data[206] = String.fromCharCode (0xffc0); +data[214] = String.fromCharCode (0xffc0); +data[229] = String.fromCharCode (0x03ff); +data[237] = String.fromCharCode (0x03ff); +data[242] = String.fromCharCode (0x03ff); +data[4081] = String.fromCharCode (0x03ff); +data[4099] = String.fromCharCode (0x03ff); +}); +c$.math_f = Clazz.defineMethod (c$, "math_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.math = new com.stevesoft.pat.Bits (data); +data[2] = String.fromCharCode (0x0800); +data[3] = String.fromCharCode (0x7000); +data[7] = String.fromCharCode (0x5000); +data[10] = String.fromCharCode (0x1000); +data[11] = String.fromCharCode (0x0002); +data[13] = String.fromCharCode (0x0080); +data[15] = String.fromCharCode (0x0080); +data[516] = String.fromCharCode (0x0010); +data[519] = String.fromCharCode (0x1c00); +data[520] = String.fromCharCode (0x1c00); +data[537] = String.fromCharCode (0x001f); +data[541] = String.fromCharCode (0x0014); +data[544] = String.fromCharCode (0xffff); +data[545] = String.fromCharCode (0xffff); +data[546] = String.fromCharCode (0xffff); +data[547] = String.fromCharCode (0xffff); +data[548] = String.fromCharCode (0xffff); +data[549] = String.fromCharCode (0xffff); +data[550] = String.fromCharCode (0xffff); +data[551] = String.fromCharCode (0xffff); +data[552] = String.fromCharCode (0xffff); +data[553] = String.fromCharCode (0xffff); +data[554] = String.fromCharCode (0xffff); +data[555] = String.fromCharCode (0xffff); +data[556] = String.fromCharCode (0xffff); +data[557] = String.fromCharCode (0xffff); +data[558] = String.fromCharCode (0xffff); +data[559] = String.fromCharCode (0x0003); +data[560] = String.fromCharCode (0x0f00); +data[562] = String.fromCharCode (0x0003); +data[4018] = String.fromCharCode (0x0200); +data[4070] = 't'; +data[4080] = String.fromCharCode (0x0800); +data[4081] = String.fromCharCode (0x7000); +data[4085] = String.fromCharCode (0x5000); +data[4094] = String.fromCharCode (0x1f04); +data[4098] = String.fromCharCode (0x0800); +data[4099] = String.fromCharCode (0x7000); +data[4103] = String.fromCharCode (0x5000); +data[4106] = String.fromCharCode (0x1000); +data[4107] = String.fromCharCode (0x0002); +data[4109] = String.fromCharCode (0x0080); +data[4111] = String.fromCharCode (0x0080); +}); +c$.letter_f = Clazz.defineMethod (c$, "letter_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.letter = new com.stevesoft.pat.Bits (data); +data[4] = String.fromCharCode (0xfffe); +data[5] = String.fromCharCode (0x07ff); +data[6] = String.fromCharCode (0xfffe); +data[7] = String.fromCharCode (0x07ff); +data[10] = String.fromCharCode (0x0400); +data[11] = String.fromCharCode (0x0420); +data[12] = String.fromCharCode (0xffff); +data[13] = String.fromCharCode (0xff7f); +data[14] = String.fromCharCode (0xffff); +data[15] = String.fromCharCode (0xff7f); +data[16] = String.fromCharCode (0xffff); +data[17] = String.fromCharCode (0xffff); +data[18] = String.fromCharCode (0xffff); +data[19] = String.fromCharCode (0xffff); +data[20] = String.fromCharCode (0xffff); +data[21] = String.fromCharCode (0xffff); +data[22] = String.fromCharCode (0xffff); +data[23] = String.fromCharCode (0xffff); +data[24] = String.fromCharCode (0xffff); +data[25] = String.fromCharCode (0xffff); +data[26] = String.fromCharCode (0xffff); +data[27] = String.fromCharCode (0xffff); +data[28] = String.fromCharCode (0xffff); +data[29] = String.fromCharCode (0xffff); +data[30] = String.fromCharCode (0xffff); +data[31] = String.fromCharCode (0xfc3f); +data[32] = String.fromCharCode (0xffff); +data[33] = String.fromCharCode (0x00ff); +data[37] = String.fromCharCode (0xffff); +data[38] = String.fromCharCode (0xffff); +data[39] = String.fromCharCode (0xffff); +data[40] = String.fromCharCode (0xffff); +data[41] = String.fromCharCode (0xffff); +data[42] = String.fromCharCode (0x01ff); +data[43] = String.fromCharCode (0xf9ff); +data[44] = String.fromCharCode (0x0003); +data[45] = String.fromCharCode (0x0003); +data[46] = String.fromCharCode (0x001f); +data[55] = String.fromCharCode (0x0400); +data[56] = String.fromCharCode (0xd740); +data[57] = String.fromCharCode (0xffff); +data[58] = String.fromCharCode (0xfffb); +data[59] = String.fromCharCode (0xffff); +data[60] = String.fromCharCode (0x7fff); +data[61] = String.fromCharCode (0x547f); +data[62] = String.fromCharCode (0xfffd); +data[63] = String.fromCharCode (0x000f); +data[64] = String.fromCharCode (0xdffe); +data[65] = String.fromCharCode (0xffff); +data[66] = String.fromCharCode (0xffff); +data[67] = String.fromCharCode (0xffff); +data[68] = String.fromCharCode (0xffff); +data[69] = String.fromCharCode (0xdffe); +data[70] = String.fromCharCode (0xffff); +data[71] = String.fromCharCode (0xffff); +data[72] = String.fromCharCode (0x0003); +data[73] = String.fromCharCode (0xffff); +data[74] = String.fromCharCode (0xffff); +data[75] = String.fromCharCode (0xffff); +data[76] = String.fromCharCode (0x199f); +data[77] = String.fromCharCode (0xffff); +data[78] = String.fromCharCode (0xcfff); +data[79] = String.fromCharCode (0x033f); +data[83] = String.fromCharCode (0xfffe); +data[84] = String.fromCharCode (0xffff); +data[85] = String.fromCharCode (0x027f); +data[86] = String.fromCharCode (0xfffe); +data[87] = String.fromCharCode (0xffff); +data[88] = String.fromCharCode (0x00ff); +data[93] = String.fromCharCode (0xffff); +data[94] = String.fromCharCode (0x07ff); +data[95] = String.fromCharCode (0x0007); +data[98] = String.fromCharCode (0xfffe); +data[99] = String.fromCharCode (0x07ff); +data[100] = String.fromCharCode (0x07ff); +data[103] = String.fromCharCode (0xfffe); +data[104] = String.fromCharCode (0xffff); +data[105] = String.fromCharCode (0xffff); +data[106] = String.fromCharCode (0xffff); +data[107] = String.fromCharCode (0x7cff); +data[108] = String.fromCharCode (0x7fff); +data[109] = String.fromCharCode (0x002f); +data[110] = String.fromCharCode (0x0060); +data[144] = String.fromCharCode (0xffe0); +data[145] = String.fromCharCode (0xffff); +data[146] = String.fromCharCode (0xffff); +data[147] = String.fromCharCode (0x23ff); +data[149] = String.fromCharCode (0xff00); +data[150] = String.fromCharCode (0x0003); +data[152] = String.fromCharCode (0x9fe0); +data[153] = String.fromCharCode (0xfff9); +data[154] = String.fromCharCode (0xfdff); +data[155] = String.fromCharCode (0x03c5); +data[157] = String.fromCharCode (0xb000); +data[158] = String.fromCharCode (0x0003); +data[159] = String.fromCharCode (0x0003); +data[160] = String.fromCharCode (0x87e0); +data[161] = String.fromCharCode (0xfff9); +data[162] = String.fromCharCode (0xfdff); +data[163] = String.fromCharCode (0x036d); +data[165] = String.fromCharCode (0x5e00); +data[167] = String.fromCharCode (0x001c); +data[168] = String.fromCharCode (0xafe0); +data[169] = String.fromCharCode (0xfffb); +data[170] = String.fromCharCode (0xfdff); +data[171] = String.fromCharCode (0x23ed); +data[174] = String.fromCharCode (0x0001); +data[176] = String.fromCharCode (0x9fe0); +data[177] = String.fromCharCode (0xfff9); +data[178] = String.fromCharCode (0xfdff); +data[179] = String.fromCharCode (0x23cd); +data[181] = String.fromCharCode (0xb000); +data[182] = String.fromCharCode (0x0003); +data[184] = String.fromCharCode (0xc7e0); +data[185] = String.fromCharCode (0xd63d); +data[186] = String.fromCharCode (0xc718); +data[187] = String.fromCharCode (0x03bf); +data[192] = String.fromCharCode (0xdfe0); +data[193] = String.fromCharCode (0xfffd); +data[194] = String.fromCharCode (0xfdff); +data[195] = String.fromCharCode (0x03ef); +data[198] = String.fromCharCode (0x0003); +data[200] = String.fromCharCode (0xdfe0); +data[201] = String.fromCharCode (0xfffd); +data[202] = String.fromCharCode (0xfdff); +data[203] = String.fromCharCode (0x03ef); +data[205] = String.fromCharCode (0x4000); +data[206] = String.fromCharCode (0x0003); +data[208] = String.fromCharCode (0xdfe0); +data[209] = String.fromCharCode (0xfffd); +data[210] = String.fromCharCode (0xfdff); +data[211] = String.fromCharCode (0x03ff); +data[214] = String.fromCharCode (0x0003); +data[224] = String.fromCharCode (0xfffe); +data[225] = String.fromCharCode (0xffff); +data[226] = String.fromCharCode (0x7fff); +data[227] = String.fromCharCode (0x000d); +data[228] = String.fromCharCode (0x007f); +data[232] = String.fromCharCode (0x2596); +data[233] = String.fromCharCode (0xfef0); +data[234] = String.fromCharCode (0x6cae); +data[235] = String.fromCharCode (0x200d); +data[236] = String.fromCharCode (0x005f); +data[237] = String.fromCharCode (0x3000); +data[244] = String.fromCharCode (0xfeff); +data[245] = String.fromCharCode (0xffff); +data[246] = String.fromCharCode (0x03ff); +data[266] = String.fromCharCode (0xffff); +data[267] = String.fromCharCode (0xffff); +data[268] = String.fromCharCode (0x003f); +data[269] = String.fromCharCode (0xffff); +data[270] = String.fromCharCode (0xffff); +data[271] = String.fromCharCode (0x007f); +data[272] = String.fromCharCode (0xffff); +data[273] = String.fromCharCode (0xffff); +data[274] = String.fromCharCode (0xffff); +data[275] = String.fromCharCode (0xffff); +data[276] = String.fromCharCode (0xffff); +data[277] = String.fromCharCode (0x83ff); +data[278] = String.fromCharCode (0xffff); +data[279] = String.fromCharCode (0xffff); +data[280] = String.fromCharCode (0xffff); +data[281] = String.fromCharCode (0xffff); +data[282] = String.fromCharCode (0xff07); +data[283] = String.fromCharCode (0xffff); +data[284] = String.fromCharCode (0xffff); +data[285] = String.fromCharCode (0xffff); +data[286] = String.fromCharCode (0xffff); +data[287] = String.fromCharCode (0x03ff); +data[480] = String.fromCharCode (0xffff); +data[481] = String.fromCharCode (0xffff); +data[482] = String.fromCharCode (0xffff); +data[483] = String.fromCharCode (0xffff); +data[484] = String.fromCharCode (0xffff); +data[485] = String.fromCharCode (0xffff); +data[486] = String.fromCharCode (0xffff); +data[487] = String.fromCharCode (0xffff); +data[488] = String.fromCharCode (0xffff); +data[489] = String.fromCharCode (0x0fff); +data[490] = String.fromCharCode (0xffff); +data[491] = String.fromCharCode (0xffff); +data[492] = String.fromCharCode (0xffff); +data[493] = String.fromCharCode (0xffff); +data[494] = String.fromCharCode (0xffff); +data[495] = String.fromCharCode (0x03ff); +data[496] = String.fromCharCode (0xffff); +data[497] = String.fromCharCode (0x3f3f); +data[498] = String.fromCharCode (0xffff); +data[499] = String.fromCharCode (0xffff); +data[500] = String.fromCharCode (0x3f3f); +data[501] = String.fromCharCode (0xaaff); +data[502] = String.fromCharCode (0xffff); +data[503] = String.fromCharCode (0x3fff); +data[504] = String.fromCharCode (0xffff); +data[505] = String.fromCharCode (0xffff); +data[506] = String.fromCharCode (0xffff); +data[507] = String.fromCharCode (0x5fdf); +data[508] = String.fromCharCode (0x1fdc); +data[509] = String.fromCharCode (0x0fcf); +data[510] = String.fromCharCode (0x1fff); +data[511] = String.fromCharCode (0x1fdc); +data[519] = String.fromCharCode (0x8000); +data[528] = String.fromCharCode (0xfc84); +data[529] = String.fromCharCode (0x3f2f); +data[530] = String.fromCharCode (0xfd50); +data[531] = String.fromCharCode (0x01fb); +data[768] = String.fromCharCode (0x0020); +data[771] = String.fromCharCode (0x003e); +data[772] = String.fromCharCode (0xfffe); +data[773] = String.fromCharCode (0xffff); +data[774] = String.fromCharCode (0xffff); +data[775] = String.fromCharCode (0xffff); +data[776] = String.fromCharCode (0xffff); +data[777] = String.fromCharCode (0x781f); +data[778] = String.fromCharCode (0xfffe); +data[779] = String.fromCharCode (0xffff); +data[780] = String.fromCharCode (0xffff); +data[781] = String.fromCharCode (0xffff); +data[782] = String.fromCharCode (0xffff); +data[783] = String.fromCharCode (0x77ff); +data[784] = String.fromCharCode (0xffe0); +data[785] = String.fromCharCode (0xffff); +data[786] = String.fromCharCode (0x1fff); +data[787] = String.fromCharCode (0xfffe); +data[788] = String.fromCharCode (0xffff); +data[789] = String.fromCharCode (0xffff); +data[790] = String.fromCharCode (0xffff); +data[791] = String.fromCharCode (0xffff); +data[792] = String.fromCharCode (0x7fff); +data[1248] = String.fromCharCode (0xffff); +data[1249] = String.fromCharCode (0xffff); +data[1250] = String.fromCharCode (0xffff); +data[1251] = String.fromCharCode (0xffff); +data[1252] = String.fromCharCode (0xffff); +data[1253] = String.fromCharCode (0xffff); +data[1254] = String.fromCharCode (0xffff); +data[1255] = String.fromCharCode (0xffff); +data[1256] = String.fromCharCode (0xffff); +data[1257] = String.fromCharCode (0xffff); +data[1258] = String.fromCharCode (0xffff); +data[1259] = String.fromCharCode (0xffff); +data[1260] = String.fromCharCode (0xffff); +data[1261] = String.fromCharCode (0xffff); +data[1262] = String.fromCharCode (0xffff); +data[1263] = String.fromCharCode (0xffff); +data[1264] = String.fromCharCode (0xffff); +data[1265] = String.fromCharCode (0xffff); +data[1266] = String.fromCharCode (0xffff); +data[1267] = String.fromCharCode (0xffff); +data[1268] = String.fromCharCode (0xffff); +data[1269] = String.fromCharCode (0xffff); +data[1270] = String.fromCharCode (0xffff); +data[1271] = String.fromCharCode (0xffff); +data[1272] = String.fromCharCode (0xffff); +data[1273] = String.fromCharCode (0xffff); +data[1274] = String.fromCharCode (0xffff); +data[1275] = String.fromCharCode (0xffff); +data[1276] = String.fromCharCode (0xffff); +data[1277] = String.fromCharCode (0xffff); +data[1278] = String.fromCharCode (0xffff); +data[1279] = String.fromCharCode (0xffff); +data[1280] = String.fromCharCode (0xffff); +data[1281] = String.fromCharCode (0xffff); +data[1282] = String.fromCharCode (0xffff); +data[1283] = String.fromCharCode (0xffff); +data[1284] = String.fromCharCode (0xffff); +data[1285] = String.fromCharCode (0xffff); +data[1286] = String.fromCharCode (0xffff); +data[1287] = String.fromCharCode (0xffff); +data[1288] = String.fromCharCode (0xffff); +data[1289] = String.fromCharCode (0xffff); +data[1290] = String.fromCharCode (0xffff); +data[1291] = String.fromCharCode (0xffff); +data[1292] = String.fromCharCode (0xffff); +data[1293] = String.fromCharCode (0xffff); +data[1294] = String.fromCharCode (0xffff); +data[1295] = String.fromCharCode (0xffff); +data[1296] = String.fromCharCode (0xffff); +data[1297] = String.fromCharCode (0xffff); +data[1298] = String.fromCharCode (0xffff); +data[1299] = String.fromCharCode (0xffff); +data[1300] = String.fromCharCode (0xffff); +data[1301] = String.fromCharCode (0xffff); +data[1302] = String.fromCharCode (0xffff); +data[1303] = String.fromCharCode (0xffff); +data[1304] = String.fromCharCode (0xffff); +data[1305] = String.fromCharCode (0xffff); +data[1306] = String.fromCharCode (0xffff); +data[1307] = String.fromCharCode (0xffff); +data[1308] = String.fromCharCode (0xffff); +data[1309] = String.fromCharCode (0xffff); +data[1310] = String.fromCharCode (0xffff); +data[1311] = String.fromCharCode (0xffff); +data[1312] = String.fromCharCode (0xffff); +data[1313] = String.fromCharCode (0xffff); +data[1314] = String.fromCharCode (0xffff); +data[1315] = String.fromCharCode (0xffff); +data[1316] = String.fromCharCode (0xffff); +data[1317] = String.fromCharCode (0xffff); +data[1318] = String.fromCharCode (0xffff); +data[1319] = String.fromCharCode (0xffff); +data[1320] = String.fromCharCode (0xffff); +data[1321] = String.fromCharCode (0xffff); +data[1322] = String.fromCharCode (0xffff); +data[1323] = String.fromCharCode (0xffff); +data[1324] = String.fromCharCode (0xffff); +data[1325] = String.fromCharCode (0xffff); +data[1326] = String.fromCharCode (0xffff); +data[1327] = String.fromCharCode (0xffff); +data[1328] = String.fromCharCode (0xffff); +data[1329] = String.fromCharCode (0xffff); +data[1330] = String.fromCharCode (0xffff); +data[1331] = String.fromCharCode (0xffff); +data[1332] = String.fromCharCode (0xffff); +data[1333] = String.fromCharCode (0xffff); +data[1334] = String.fromCharCode (0xffff); +data[1335] = String.fromCharCode (0xffff); +data[1336] = String.fromCharCode (0xffff); +data[1337] = String.fromCharCode (0xffff); +data[1338] = String.fromCharCode (0xffff); +data[1339] = String.fromCharCode (0xffff); +data[1340] = String.fromCharCode (0xffff); +data[1341] = String.fromCharCode (0xffff); +data[1342] = String.fromCharCode (0xffff); +data[1343] = String.fromCharCode (0xffff); +data[1344] = String.fromCharCode (0xffff); +data[1345] = String.fromCharCode (0xffff); +data[1346] = String.fromCharCode (0xffff); +data[1347] = String.fromCharCode (0xffff); +data[1348] = String.fromCharCode (0xffff); +data[1349] = String.fromCharCode (0xffff); +data[1350] = String.fromCharCode (0xffff); +data[1351] = String.fromCharCode (0xffff); +data[1352] = String.fromCharCode (0xffff); +data[1353] = String.fromCharCode (0xffff); +data[1354] = String.fromCharCode (0xffff); +data[1355] = String.fromCharCode (0xffff); +data[1356] = String.fromCharCode (0xffff); +data[1357] = String.fromCharCode (0xffff); +data[1358] = String.fromCharCode (0xffff); +data[1359] = String.fromCharCode (0xffff); +data[1360] = String.fromCharCode (0xffff); +data[1361] = String.fromCharCode (0xffff); +data[1362] = String.fromCharCode (0xffff); +data[1363] = String.fromCharCode (0xffff); +data[1364] = String.fromCharCode (0xffff); +data[1365] = String.fromCharCode (0xffff); +data[1366] = String.fromCharCode (0xffff); +data[1367] = String.fromCharCode (0xffff); +data[1368] = String.fromCharCode (0xffff); +data[1369] = String.fromCharCode (0xffff); +data[1370] = String.fromCharCode (0xffff); +data[1371] = String.fromCharCode (0xffff); +data[1372] = String.fromCharCode (0xffff); +data[1373] = String.fromCharCode (0xffff); +data[1374] = String.fromCharCode (0xffff); +data[1375] = String.fromCharCode (0xffff); +data[1376] = String.fromCharCode (0xffff); +data[1377] = String.fromCharCode (0xffff); +data[1378] = String.fromCharCode (0xffff); +data[1379] = String.fromCharCode (0xffff); +data[1380] = String.fromCharCode (0xffff); +data[1381] = String.fromCharCode (0xffff); +data[1382] = String.fromCharCode (0xffff); +data[1383] = String.fromCharCode (0xffff); +data[1384] = String.fromCharCode (0xffff); +data[1385] = String.fromCharCode (0xffff); +data[1386] = String.fromCharCode (0xffff); +data[1387] = String.fromCharCode (0xffff); +data[1388] = String.fromCharCode (0xffff); +data[1389] = String.fromCharCode (0xffff); +data[1390] = String.fromCharCode (0xffff); +data[1391] = String.fromCharCode (0xffff); +data[1392] = String.fromCharCode (0xffff); +data[1393] = String.fromCharCode (0xffff); +data[1394] = String.fromCharCode (0xffff); +data[1395] = String.fromCharCode (0xffff); +data[1396] = String.fromCharCode (0xffff); +data[1397] = String.fromCharCode (0xffff); +data[1398] = String.fromCharCode (0xffff); +data[1399] = String.fromCharCode (0xffff); +data[1400] = String.fromCharCode (0xffff); +data[1401] = String.fromCharCode (0xffff); +data[1402] = String.fromCharCode (0xffff); +data[1403] = String.fromCharCode (0xffff); +data[1404] = String.fromCharCode (0xffff); +data[1405] = String.fromCharCode (0xffff); +data[1406] = String.fromCharCode (0xffff); +data[1407] = String.fromCharCode (0xffff); +data[1408] = String.fromCharCode (0xffff); +data[1409] = String.fromCharCode (0xffff); +data[1410] = String.fromCharCode (0xffff); +data[1411] = String.fromCharCode (0xffff); +data[1412] = String.fromCharCode (0xffff); +data[1413] = String.fromCharCode (0xffff); +data[1414] = String.fromCharCode (0xffff); +data[1415] = String.fromCharCode (0xffff); +data[1416] = String.fromCharCode (0xffff); +data[1417] = String.fromCharCode (0xffff); +data[1418] = String.fromCharCode (0xffff); +data[1419] = String.fromCharCode (0xffff); +data[1420] = String.fromCharCode (0xffff); +data[1421] = String.fromCharCode (0xffff); +data[1422] = String.fromCharCode (0xffff); +data[1423] = String.fromCharCode (0xffff); +data[1424] = String.fromCharCode (0xffff); +data[1425] = String.fromCharCode (0xffff); +data[1426] = String.fromCharCode (0xffff); +data[1427] = String.fromCharCode (0xffff); +data[1428] = String.fromCharCode (0xffff); +data[1429] = String.fromCharCode (0xffff); +data[1430] = String.fromCharCode (0xffff); +data[1431] = String.fromCharCode (0xffff); +data[1432] = String.fromCharCode (0xffff); +data[1433] = String.fromCharCode (0xffff); +data[1434] = String.fromCharCode (0xffff); +data[1435] = String.fromCharCode (0xffff); +data[1436] = String.fromCharCode (0xffff); +data[1437] = String.fromCharCode (0xffff); +data[1438] = String.fromCharCode (0xffff); +data[1439] = String.fromCharCode (0xffff); +data[1440] = String.fromCharCode (0xffff); +data[1441] = String.fromCharCode (0xffff); +data[1442] = String.fromCharCode (0xffff); +data[1443] = String.fromCharCode (0xffff); +data[1444] = String.fromCharCode (0xffff); +data[1445] = String.fromCharCode (0xffff); +data[1446] = String.fromCharCode (0xffff); +data[1447] = String.fromCharCode (0xffff); +data[1448] = String.fromCharCode (0xffff); +data[1449] = String.fromCharCode (0xffff); +data[1450] = String.fromCharCode (0xffff); +data[1451] = String.fromCharCode (0xffff); +data[1452] = String.fromCharCode (0xffff); +data[1453] = String.fromCharCode (0xffff); +data[1454] = String.fromCharCode (0xffff); +data[1455] = String.fromCharCode (0xffff); +data[1456] = String.fromCharCode (0xffff); +data[1457] = String.fromCharCode (0xffff); +data[1458] = String.fromCharCode (0xffff); +data[1459] = String.fromCharCode (0xffff); +data[1460] = String.fromCharCode (0xffff); +data[1461] = String.fromCharCode (0xffff); +data[1462] = String.fromCharCode (0xffff); +data[1463] = String.fromCharCode (0xffff); +data[1464] = String.fromCharCode (0xffff); +data[1465] = String.fromCharCode (0xffff); +data[1466] = String.fromCharCode (0xffff); +data[1467] = String.fromCharCode (0xffff); +data[1468] = String.fromCharCode (0xffff); +data[1469] = String.fromCharCode (0xffff); +data[1470] = String.fromCharCode (0xffff); +data[1471] = String.fromCharCode (0xffff); +data[1472] = String.fromCharCode (0xffff); +data[1473] = String.fromCharCode (0xffff); +data[1474] = String.fromCharCode (0xffff); +data[1475] = String.fromCharCode (0xffff); +data[1476] = String.fromCharCode (0xffff); +data[1477] = String.fromCharCode (0xffff); +data[1478] = String.fromCharCode (0xffff); +data[1479] = String.fromCharCode (0xffff); +data[1480] = String.fromCharCode (0xffff); +data[1481] = String.fromCharCode (0xffff); +data[1482] = String.fromCharCode (0xffff); +data[1483] = String.fromCharCode (0xffff); +data[1484] = String.fromCharCode (0xffff); +data[1485] = String.fromCharCode (0xffff); +data[1486] = String.fromCharCode (0xffff); +data[1487] = String.fromCharCode (0xffff); +data[1488] = String.fromCharCode (0xffff); +data[1489] = String.fromCharCode (0xffff); +data[1490] = String.fromCharCode (0xffff); +data[1491] = String.fromCharCode (0xffff); +data[1492] = String.fromCharCode (0xffff); +data[1493] = String.fromCharCode (0xffff); +data[1494] = String.fromCharCode (0xffff); +data[1495] = String.fromCharCode (0xffff); +data[1496] = String.fromCharCode (0xffff); +data[1497] = String.fromCharCode (0xffff); +data[1498] = String.fromCharCode (0xffff); +data[1499] = String.fromCharCode (0xffff); +data[1500] = String.fromCharCode (0xffff); +data[1501] = String.fromCharCode (0xffff); +data[1502] = String.fromCharCode (0xffff); +data[1503] = String.fromCharCode (0xffff); +data[1504] = String.fromCharCode (0xffff); +data[1505] = String.fromCharCode (0xffff); +data[1506] = String.fromCharCode (0xffff); +data[1507] = String.fromCharCode (0xffff); +data[1508] = String.fromCharCode (0xffff); +data[1509] = String.fromCharCode (0xffff); +data[1510] = String.fromCharCode (0xffff); +data[1511] = String.fromCharCode (0xffff); +data[1512] = String.fromCharCode (0xffff); +data[1513] = String.fromCharCode (0xffff); +data[1514] = String.fromCharCode (0xffff); +data[1515] = String.fromCharCode (0xffff); +data[1516] = String.fromCharCode (0xffff); +data[1517] = String.fromCharCode (0xffff); +data[1518] = String.fromCharCode (0xffff); +data[1519] = String.fromCharCode (0xffff); +data[1520] = String.fromCharCode (0xffff); +data[1521] = String.fromCharCode (0xffff); +data[1522] = String.fromCharCode (0xffff); +data[1523] = String.fromCharCode (0xffff); +data[1524] = String.fromCharCode (0xffff); +data[1525] = String.fromCharCode (0xffff); +data[1526] = String.fromCharCode (0xffff); +data[1527] = String.fromCharCode (0xffff); +data[1528] = String.fromCharCode (0xffff); +data[1529] = String.fromCharCode (0xffff); +data[1530] = String.fromCharCode (0xffff); +data[1531] = String.fromCharCode (0xffff); +data[1532] = String.fromCharCode (0xffff); +data[1533] = String.fromCharCode (0xffff); +data[1534] = String.fromCharCode (0xffff); +data[1535] = String.fromCharCode (0xffff); +data[1536] = String.fromCharCode (0xffff); +data[1537] = String.fromCharCode (0xffff); +data[1538] = String.fromCharCode (0xffff); +data[1539] = String.fromCharCode (0xffff); +data[1540] = String.fromCharCode (0xffff); +data[1541] = String.fromCharCode (0xffff); +data[1542] = String.fromCharCode (0xffff); +data[1543] = String.fromCharCode (0xffff); +data[1544] = String.fromCharCode (0xffff); +data[1545] = String.fromCharCode (0xffff); +data[1546] = String.fromCharCode (0xffff); +data[1547] = String.fromCharCode (0xffff); +data[1548] = String.fromCharCode (0xffff); +data[1549] = String.fromCharCode (0xffff); +data[1550] = String.fromCharCode (0xffff); +data[1551] = String.fromCharCode (0xffff); +data[1552] = String.fromCharCode (0xffff); +data[1553] = String.fromCharCode (0xffff); +data[1554] = String.fromCharCode (0xffff); +data[1555] = String.fromCharCode (0xffff); +data[1556] = String.fromCharCode (0xffff); +data[1557] = String.fromCharCode (0xffff); +data[1558] = String.fromCharCode (0xffff); +data[1559] = String.fromCharCode (0xffff); +data[1560] = String.fromCharCode (0xffff); +data[1561] = String.fromCharCode (0xffff); +data[1562] = String.fromCharCode (0xffff); +data[1563] = String.fromCharCode (0xffff); +data[1564] = String.fromCharCode (0xffff); +data[1565] = String.fromCharCode (0xffff); +data[1566] = String.fromCharCode (0xffff); +data[1567] = String.fromCharCode (0xffff); +data[1568] = String.fromCharCode (0xffff); +data[1569] = String.fromCharCode (0xffff); +data[1570] = String.fromCharCode (0xffff); +data[1571] = String.fromCharCode (0xffff); +data[1572] = String.fromCharCode (0xffff); +data[1573] = String.fromCharCode (0xffff); +data[1574] = String.fromCharCode (0xffff); +data[1575] = String.fromCharCode (0xffff); +data[1576] = String.fromCharCode (0xffff); +data[1577] = String.fromCharCode (0xffff); +data[1578] = String.fromCharCode (0xffff); +data[1579] = String.fromCharCode (0xffff); +data[1580] = String.fromCharCode (0xffff); +data[1581] = String.fromCharCode (0xffff); +data[1582] = String.fromCharCode (0xffff); +data[1583] = String.fromCharCode (0xffff); +data[1584] = String.fromCharCode (0xffff); +data[1585] = String.fromCharCode (0xffff); +data[1586] = String.fromCharCode (0xffff); +data[1587] = String.fromCharCode (0xffff); +data[1588] = String.fromCharCode (0xffff); +data[1589] = String.fromCharCode (0xffff); +data[1590] = String.fromCharCode (0xffff); +data[1591] = String.fromCharCode (0xffff); +data[1592] = String.fromCharCode (0xffff); +data[1593] = String.fromCharCode (0xffff); +data[1594] = String.fromCharCode (0xffff); +data[1595] = String.fromCharCode (0xffff); +data[1596] = String.fromCharCode (0xffff); +data[1597] = String.fromCharCode (0xffff); +data[1598] = String.fromCharCode (0xffff); +data[1599] = String.fromCharCode (0xffff); +data[1600] = String.fromCharCode (0xffff); +data[1601] = String.fromCharCode (0xffff); +data[1602] = String.fromCharCode (0xffff); +data[1603] = String.fromCharCode (0xffff); +data[1604] = String.fromCharCode (0xffff); +data[1605] = String.fromCharCode (0xffff); +data[1606] = String.fromCharCode (0xffff); +data[1607] = String.fromCharCode (0xffff); +data[1608] = String.fromCharCode (0xffff); +data[1609] = String.fromCharCode (0xffff); +data[1610] = String.fromCharCode (0xffff); +data[1611] = String.fromCharCode (0xffff); +data[1612] = String.fromCharCode (0xffff); +data[1613] = String.fromCharCode (0xffff); +data[1614] = String.fromCharCode (0xffff); +data[1615] = String.fromCharCode (0xffff); +data[1616] = String.fromCharCode (0xffff); +data[1617] = String.fromCharCode (0xffff); +data[1618] = String.fromCharCode (0xffff); +data[1619] = String.fromCharCode (0xffff); +data[1620] = String.fromCharCode (0xffff); +data[1621] = String.fromCharCode (0xffff); +data[1622] = String.fromCharCode (0xffff); +data[1623] = String.fromCharCode (0xffff); +data[1624] = String.fromCharCode (0xffff); +data[1625] = String.fromCharCode (0xffff); +data[1626] = String.fromCharCode (0xffff); +data[1627] = String.fromCharCode (0xffff); +data[1628] = String.fromCharCode (0xffff); +data[1629] = String.fromCharCode (0xffff); +data[1630] = String.fromCharCode (0xffff); +data[1631] = String.fromCharCode (0xffff); +data[1632] = String.fromCharCode (0xffff); +data[1633] = String.fromCharCode (0xffff); +data[1634] = String.fromCharCode (0xffff); +data[1635] = String.fromCharCode (0xffff); +data[1636] = String.fromCharCode (0xffff); +data[1637] = String.fromCharCode (0xffff); +data[1638] = String.fromCharCode (0xffff); +data[1639] = String.fromCharCode (0xffff); +data[1640] = String.fromCharCode (0xffff); +data[1641] = String.fromCharCode (0xffff); +data[1642] = String.fromCharCode (0xffff); +data[1643] = String.fromCharCode (0xffff); +data[1644] = String.fromCharCode (0xffff); +data[1645] = String.fromCharCode (0xffff); +data[1646] = String.fromCharCode (0xffff); +data[1647] = String.fromCharCode (0xffff); +data[1648] = String.fromCharCode (0xffff); +data[1649] = String.fromCharCode (0xffff); +data[1650] = String.fromCharCode (0xffff); +data[1651] = String.fromCharCode (0xffff); +data[1652] = String.fromCharCode (0xffff); +data[1653] = String.fromCharCode (0xffff); +data[1654] = String.fromCharCode (0xffff); +data[1655] = String.fromCharCode (0xffff); +data[1656] = String.fromCharCode (0xffff); +data[1657] = String.fromCharCode (0xffff); +data[1658] = String.fromCharCode (0xffff); +data[1659] = String.fromCharCode (0xffff); +data[1660] = String.fromCharCode (0xffff); +data[1661] = String.fromCharCode (0xffff); +data[1662] = String.fromCharCode (0xffff); +data[1663] = String.fromCharCode (0xffff); +data[1664] = String.fromCharCode (0xffff); +data[1665] = String.fromCharCode (0xffff); +data[1666] = String.fromCharCode (0xffff); +data[1667] = String.fromCharCode (0xffff); +data[1668] = String.fromCharCode (0xffff); +data[1669] = String.fromCharCode (0xffff); +data[1670] = String.fromCharCode (0xffff); +data[1671] = String.fromCharCode (0xffff); +data[1672] = String.fromCharCode (0xffff); +data[1673] = String.fromCharCode (0xffff); +data[1674] = String.fromCharCode (0xffff); +data[1675] = String.fromCharCode (0xffff); +data[1676] = String.fromCharCode (0xffff); +data[1677] = String.fromCharCode (0xffff); +data[1678] = String.fromCharCode (0xffff); +data[1679] = String.fromCharCode (0xffff); +data[1680] = String.fromCharCode (0xffff); +data[1681] = String.fromCharCode (0xffff); +data[1682] = String.fromCharCode (0xffff); +data[1683] = String.fromCharCode (0xffff); +data[1684] = String.fromCharCode (0xffff); +data[1685] = String.fromCharCode (0xffff); +data[1686] = String.fromCharCode (0xffff); +data[1687] = String.fromCharCode (0xffff); +data[1688] = String.fromCharCode (0xffff); +data[1689] = String.fromCharCode (0xffff); +data[1690] = String.fromCharCode (0xffff); +data[1691] = String.fromCharCode (0xffff); +data[1692] = String.fromCharCode (0xffff); +data[1693] = String.fromCharCode (0xffff); +data[1694] = String.fromCharCode (0xffff); +data[1695] = String.fromCharCode (0xffff); +data[1696] = String.fromCharCode (0xffff); +data[1697] = String.fromCharCode (0xffff); +data[1698] = String.fromCharCode (0xffff); +data[1699] = String.fromCharCode (0xffff); +data[1700] = String.fromCharCode (0xffff); +data[1701] = String.fromCharCode (0xffff); +data[1702] = String.fromCharCode (0xffff); +data[1703] = String.fromCharCode (0xffff); +data[1704] = String.fromCharCode (0xffff); +data[1705] = String.fromCharCode (0xffff); +data[1706] = String.fromCharCode (0xffff); +data[1707] = String.fromCharCode (0xffff); +data[1708] = String.fromCharCode (0xffff); +data[1709] = String.fromCharCode (0xffff); +data[1710] = String.fromCharCode (0xffff); +data[1711] = String.fromCharCode (0xffff); +data[1712] = String.fromCharCode (0xffff); +data[1713] = String.fromCharCode (0xffff); +data[1714] = String.fromCharCode (0xffff); +data[1715] = String.fromCharCode (0xffff); +data[1716] = String.fromCharCode (0xffff); +data[1717] = String.fromCharCode (0xffff); +data[1718] = String.fromCharCode (0xffff); +data[1719] = String.fromCharCode (0xffff); +data[1720] = String.fromCharCode (0xffff); +data[1721] = String.fromCharCode (0xffff); +data[1722] = String.fromCharCode (0xffff); +data[1723] = String.fromCharCode (0xffff); +data[1724] = String.fromCharCode (0xffff); +data[1725] = String.fromCharCode (0xffff); +data[1726] = String.fromCharCode (0xffff); +data[1727] = String.fromCharCode (0xffff); +data[1728] = String.fromCharCode (0xffff); +data[1729] = String.fromCharCode (0xffff); +data[1730] = String.fromCharCode (0xffff); +data[1731] = String.fromCharCode (0xffff); +data[1732] = String.fromCharCode (0xffff); +data[1733] = String.fromCharCode (0xffff); +data[1734] = String.fromCharCode (0xffff); +data[1735] = String.fromCharCode (0xffff); +data[1736] = String.fromCharCode (0xffff); +data[1737] = String.fromCharCode (0xffff); +data[1738] = String.fromCharCode (0xffff); +data[1739] = String.fromCharCode (0xffff); +data[1740] = String.fromCharCode (0xffff); +data[1741] = String.fromCharCode (0xffff); +data[1742] = String.fromCharCode (0xffff); +data[1743] = String.fromCharCode (0xffff); +data[1744] = String.fromCharCode (0xffff); +data[1745] = String.fromCharCode (0xffff); +data[1746] = String.fromCharCode (0xffff); +data[1747] = String.fromCharCode (0xffff); +data[1748] = String.fromCharCode (0xffff); +data[1749] = String.fromCharCode (0xffff); +data[1750] = String.fromCharCode (0xffff); +data[1751] = String.fromCharCode (0xffff); +data[1752] = String.fromCharCode (0xffff); +data[1753] = String.fromCharCode (0xffff); +data[1754] = String.fromCharCode (0xffff); +data[1755] = String.fromCharCode (0xffff); +data[1756] = String.fromCharCode (0xffff); +data[1757] = String.fromCharCode (0xffff); +data[1758] = String.fromCharCode (0xffff); +data[1759] = String.fromCharCode (0xffff); +data[1760] = String.fromCharCode (0xffff); +data[1761] = String.fromCharCode (0xffff); +data[1762] = String.fromCharCode (0xffff); +data[1763] = String.fromCharCode (0xffff); +data[1764] = String.fromCharCode (0xffff); +data[1765] = String.fromCharCode (0xffff); +data[1766] = String.fromCharCode (0xffff); +data[1767] = String.fromCharCode (0xffff); +data[1768] = String.fromCharCode (0xffff); +data[1769] = String.fromCharCode (0xffff); +data[1770] = String.fromCharCode (0xffff); +data[1771] = String.fromCharCode (0xffff); +data[1772] = String.fromCharCode (0xffff); +data[1773] = String.fromCharCode (0xffff); +data[1774] = String.fromCharCode (0xffff); +data[1775] = String.fromCharCode (0xffff); +data[1776] = String.fromCharCode (0xffff); +data[1777] = String.fromCharCode (0xffff); +data[1778] = String.fromCharCode (0xffff); +data[1779] = String.fromCharCode (0xffff); +data[1780] = String.fromCharCode (0xffff); +data[1781] = String.fromCharCode (0xffff); +data[1782] = String.fromCharCode (0xffff); +data[1783] = String.fromCharCode (0xffff); +data[1784] = String.fromCharCode (0xffff); +data[1785] = String.fromCharCode (0xffff); +data[1786] = String.fromCharCode (0xffff); +data[1787] = String.fromCharCode (0xffff); +data[1788] = String.fromCharCode (0xffff); +data[1789] = String.fromCharCode (0xffff); +data[1790] = String.fromCharCode (0xffff); +data[1791] = String.fromCharCode (0xffff); +data[1792] = String.fromCharCode (0xffff); +data[1793] = String.fromCharCode (0xffff); +data[1794] = String.fromCharCode (0xffff); +data[1795] = String.fromCharCode (0xffff); +data[1796] = String.fromCharCode (0xffff); +data[1797] = String.fromCharCode (0xffff); +data[1798] = String.fromCharCode (0xffff); +data[1799] = String.fromCharCode (0xffff); +data[1800] = String.fromCharCode (0xffff); +data[1801] = String.fromCharCode (0xffff); +data[1802] = String.fromCharCode (0xffff); +data[1803] = String.fromCharCode (0xffff); +data[1804] = String.fromCharCode (0xffff); +data[1805] = String.fromCharCode (0xffff); +data[1806] = String.fromCharCode (0xffff); +data[1807] = String.fromCharCode (0xffff); +data[1808] = String.fromCharCode (0xffff); +data[1809] = String.fromCharCode (0xffff); +data[1810] = String.fromCharCode (0xffff); +data[1811] = String.fromCharCode (0xffff); +data[1812] = String.fromCharCode (0xffff); +data[1813] = String.fromCharCode (0xffff); +data[1814] = String.fromCharCode (0xffff); +data[1815] = String.fromCharCode (0xffff); +data[1816] = String.fromCharCode (0xffff); +data[1817] = String.fromCharCode (0xffff); +data[1818] = String.fromCharCode (0xffff); +data[1819] = String.fromCharCode (0xffff); +data[1820] = String.fromCharCode (0xffff); +data[1821] = String.fromCharCode (0xffff); +data[1822] = String.fromCharCode (0xffff); +data[1823] = String.fromCharCode (0xffff); +data[1824] = String.fromCharCode (0xffff); +data[1825] = String.fromCharCode (0xffff); +data[1826] = String.fromCharCode (0xffff); +data[1827] = String.fromCharCode (0xffff); +data[1828] = String.fromCharCode (0xffff); +data[1829] = String.fromCharCode (0xffff); +data[1830] = String.fromCharCode (0xffff); +data[1831] = String.fromCharCode (0xffff); +data[1832] = String.fromCharCode (0xffff); +data[1833] = String.fromCharCode (0xffff); +data[1834] = String.fromCharCode (0xffff); +data[1835] = String.fromCharCode (0xffff); +data[1836] = String.fromCharCode (0xffff); +data[1837] = String.fromCharCode (0xffff); +data[1838] = String.fromCharCode (0xffff); +data[1839] = String.fromCharCode (0xffff); +data[1840] = String.fromCharCode (0xffff); +data[1841] = String.fromCharCode (0xffff); +data[1842] = String.fromCharCode (0xffff); +data[1843] = String.fromCharCode (0xffff); +data[1844] = String.fromCharCode (0xffff); +data[1845] = String.fromCharCode (0xffff); +data[1846] = String.fromCharCode (0xffff); +data[1847] = String.fromCharCode (0xffff); +data[1848] = String.fromCharCode (0xffff); +data[1849] = String.fromCharCode (0xffff); +data[1850] = String.fromCharCode (0xffff); +data[1851] = String.fromCharCode (0xffff); +data[1852] = String.fromCharCode (0xffff); +data[1853] = String.fromCharCode (0xffff); +data[1854] = String.fromCharCode (0xffff); +data[1855] = String.fromCharCode (0xffff); +data[1856] = String.fromCharCode (0xffff); +data[1857] = String.fromCharCode (0xffff); +data[1858] = String.fromCharCode (0xffff); +data[1859] = String.fromCharCode (0xffff); +data[1860] = String.fromCharCode (0xffff); +data[1861] = String.fromCharCode (0xffff); +data[1862] = String.fromCharCode (0xffff); +data[1863] = String.fromCharCode (0xffff); +data[1864] = String.fromCharCode (0xffff); +data[1865] = String.fromCharCode (0xffff); +data[1866] = String.fromCharCode (0xffff); +data[1867] = String.fromCharCode (0xffff); +data[1868] = String.fromCharCode (0xffff); +data[1869] = String.fromCharCode (0xffff); +data[1870] = String.fromCharCode (0xffff); +data[1871] = String.fromCharCode (0xffff); +data[1872] = String.fromCharCode (0xffff); +data[1873] = String.fromCharCode (0xffff); +data[1874] = String.fromCharCode (0xffff); +data[1875] = String.fromCharCode (0xffff); +data[1876] = String.fromCharCode (0xffff); +data[1877] = String.fromCharCode (0xffff); +data[1878] = String.fromCharCode (0xffff); +data[1879] = String.fromCharCode (0xffff); +data[1880] = String.fromCharCode (0xffff); +data[1881] = String.fromCharCode (0xffff); +data[1882] = String.fromCharCode (0xffff); +data[1883] = String.fromCharCode (0xffff); +data[1884] = String.fromCharCode (0xffff); +data[1885] = String.fromCharCode (0xffff); +data[1886] = String.fromCharCode (0xffff); +data[1887] = String.fromCharCode (0xffff); +data[1888] = String.fromCharCode (0xffff); +data[1889] = String.fromCharCode (0xffff); +data[1890] = String.fromCharCode (0xffff); +data[1891] = String.fromCharCode (0xffff); +data[1892] = String.fromCharCode (0xffff); +data[1893] = String.fromCharCode (0xffff); +data[1894] = String.fromCharCode (0xffff); +data[1895] = String.fromCharCode (0xffff); +data[1896] = String.fromCharCode (0xffff); +data[1897] = String.fromCharCode (0xffff); +data[1898] = String.fromCharCode (0xffff); +data[1899] = String.fromCharCode (0xffff); +data[1900] = String.fromCharCode (0xffff); +data[1901] = String.fromCharCode (0xffff); +data[1902] = String.fromCharCode (0xffff); +data[1903] = String.fromCharCode (0xffff); +data[1904] = String.fromCharCode (0xffff); +data[1905] = String.fromCharCode (0xffff); +data[1906] = String.fromCharCode (0xffff); +data[1907] = String.fromCharCode (0xffff); +data[1908] = String.fromCharCode (0xffff); +data[1909] = String.fromCharCode (0xffff); +data[1910] = String.fromCharCode (0xffff); +data[1911] = String.fromCharCode (0xffff); +data[1912] = String.fromCharCode (0xffff); +data[1913] = String.fromCharCode (0xffff); +data[1914] = String.fromCharCode (0xffff); +data[1915] = String.fromCharCode (0xffff); +data[1916] = String.fromCharCode (0xffff); +data[1917] = String.fromCharCode (0xffff); +data[1918] = String.fromCharCode (0xffff); +data[1919] = String.fromCharCode (0xffff); +data[1920] = String.fromCharCode (0xffff); +data[1921] = String.fromCharCode (0xffff); +data[1922] = String.fromCharCode (0xffff); +data[1923] = String.fromCharCode (0xffff); +data[1924] = String.fromCharCode (0xffff); +data[1925] = String.fromCharCode (0xffff); +data[1926] = String.fromCharCode (0xffff); +data[1927] = String.fromCharCode (0xffff); +data[1928] = String.fromCharCode (0xffff); +data[1929] = String.fromCharCode (0xffff); +data[1930] = String.fromCharCode (0xffff); +data[1931] = String.fromCharCode (0xffff); +data[1932] = String.fromCharCode (0xffff); +data[1933] = String.fromCharCode (0xffff); +data[1934] = String.fromCharCode (0xffff); +data[1935] = String.fromCharCode (0xffff); +data[1936] = String.fromCharCode (0xffff); +data[1937] = String.fromCharCode (0xffff); +data[1938] = String.fromCharCode (0xffff); +data[1939] = String.fromCharCode (0xffff); +data[1940] = String.fromCharCode (0xffff); +data[1941] = String.fromCharCode (0xffff); +data[1942] = String.fromCharCode (0xffff); +data[1943] = String.fromCharCode (0xffff); +data[1944] = String.fromCharCode (0xffff); +data[1945] = String.fromCharCode (0xffff); +data[1946] = String.fromCharCode (0xffff); +data[1947] = String.fromCharCode (0xffff); +data[1948] = String.fromCharCode (0xffff); +data[1949] = String.fromCharCode (0xffff); +data[1950] = String.fromCharCode (0xffff); +data[1951] = String.fromCharCode (0xffff); +data[1952] = String.fromCharCode (0xffff); +data[1953] = String.fromCharCode (0xffff); +data[1954] = String.fromCharCode (0xffff); +data[1955] = String.fromCharCode (0xffff); +data[1956] = String.fromCharCode (0xffff); +data[1957] = String.fromCharCode (0xffff); +data[1958] = String.fromCharCode (0xffff); +data[1959] = String.fromCharCode (0xffff); +data[1960] = String.fromCharCode (0xffff); +data[1961] = String.fromCharCode (0xffff); +data[1962] = String.fromCharCode (0xffff); +data[1963] = String.fromCharCode (0xffff); +data[1964] = String.fromCharCode (0xffff); +data[1965] = String.fromCharCode (0xffff); +data[1966] = String.fromCharCode (0xffff); +data[1967] = String.fromCharCode (0xffff); +data[1968] = String.fromCharCode (0xffff); +data[1969] = String.fromCharCode (0xffff); +data[1970] = String.fromCharCode (0xffff); +data[1971] = String.fromCharCode (0xffff); +data[1972] = String.fromCharCode (0xffff); +data[1973] = String.fromCharCode (0xffff); +data[1974] = String.fromCharCode (0xffff); +data[1975] = String.fromCharCode (0xffff); +data[1976] = String.fromCharCode (0xffff); +data[1977] = String.fromCharCode (0xffff); +data[1978] = String.fromCharCode (0xffff); +data[1979] = String.fromCharCode (0xffff); +data[1980] = String.fromCharCode (0xffff); +data[1981] = String.fromCharCode (0xffff); +data[1982] = String.fromCharCode (0xffff); +data[1983] = String.fromCharCode (0xffff); +data[1984] = String.fromCharCode (0xffff); +data[1985] = String.fromCharCode (0xffff); +data[1986] = String.fromCharCode (0xffff); +data[1987] = String.fromCharCode (0xffff); +data[1988] = String.fromCharCode (0xffff); +data[1989] = String.fromCharCode (0xffff); +data[1990] = String.fromCharCode (0xffff); +data[1991] = String.fromCharCode (0xffff); +data[1992] = String.fromCharCode (0xffff); +data[1993] = String.fromCharCode (0xffff); +data[1994] = String.fromCharCode (0xffff); +data[1995] = String.fromCharCode (0xffff); +data[1996] = String.fromCharCode (0xffff); +data[1997] = String.fromCharCode (0xffff); +data[1998] = String.fromCharCode (0xffff); +data[1999] = String.fromCharCode (0xffff); +data[2000] = String.fromCharCode (0xffff); +data[2001] = String.fromCharCode (0xffff); +data[2002] = String.fromCharCode (0xffff); +data[2003] = String.fromCharCode (0xffff); +data[2004] = String.fromCharCode (0xffff); +data[2005] = String.fromCharCode (0xffff); +data[2006] = String.fromCharCode (0xffff); +data[2007] = String.fromCharCode (0xffff); +data[2008] = String.fromCharCode (0xffff); +data[2009] = String.fromCharCode (0xffff); +data[2010] = String.fromCharCode (0xffff); +data[2011] = String.fromCharCode (0xffff); +data[2012] = String.fromCharCode (0xffff); +data[2013] = String.fromCharCode (0xffff); +data[2014] = String.fromCharCode (0xffff); +data[2015] = String.fromCharCode (0xffff); +data[2016] = String.fromCharCode (0xffff); +data[2017] = String.fromCharCode (0xffff); +data[2018] = String.fromCharCode (0xffff); +data[2019] = String.fromCharCode (0xffff); +data[2020] = String.fromCharCode (0xffff); +data[2021] = String.fromCharCode (0xffff); +data[2022] = String.fromCharCode (0xffff); +data[2023] = String.fromCharCode (0xffff); +data[2024] = String.fromCharCode (0xffff); +data[2025] = String.fromCharCode (0xffff); +data[2026] = String.fromCharCode (0xffff); +data[2027] = String.fromCharCode (0xffff); +data[2028] = String.fromCharCode (0xffff); +data[2029] = String.fromCharCode (0xffff); +data[2030] = String.fromCharCode (0xffff); +data[2031] = String.fromCharCode (0xffff); +data[2032] = String.fromCharCode (0xffff); +data[2033] = String.fromCharCode (0xffff); +data[2034] = String.fromCharCode (0xffff); +data[2035] = String.fromCharCode (0xffff); +data[2036] = String.fromCharCode (0xffff); +data[2037] = String.fromCharCode (0xffff); +data[2038] = String.fromCharCode (0xffff); +data[2039] = String.fromCharCode (0xffff); +data[2040] = String.fromCharCode (0xffff); +data[2041] = String.fromCharCode (0xffff); +data[2042] = String.fromCharCode (0xffff); +data[2043] = String.fromCharCode (0xffff); +data[2044] = String.fromCharCode (0xffff); +data[2045] = String.fromCharCode (0xffff); +data[2046] = String.fromCharCode (0xffff); +data[2047] = String.fromCharCode (0xffff); +data[2048] = String.fromCharCode (0xffff); +data[2049] = String.fromCharCode (0xffff); +data[2050] = String.fromCharCode (0xffff); +data[2051] = String.fromCharCode (0xffff); +data[2052] = String.fromCharCode (0xffff); +data[2053] = String.fromCharCode (0xffff); +data[2054] = String.fromCharCode (0xffff); +data[2055] = String.fromCharCode (0xffff); +data[2056] = String.fromCharCode (0xffff); +data[2057] = String.fromCharCode (0xffff); +data[2058] = String.fromCharCode (0xffff); +data[2059] = String.fromCharCode (0xffff); +data[2060] = String.fromCharCode (0xffff); +data[2061] = String.fromCharCode (0xffff); +data[2062] = String.fromCharCode (0xffff); +data[2063] = String.fromCharCode (0xffff); +data[2064] = String.fromCharCode (0xffff); +data[2065] = String.fromCharCode (0xffff); +data[2066] = String.fromCharCode (0xffff); +data[2067] = String.fromCharCode (0xffff); +data[2068] = String.fromCharCode (0xffff); +data[2069] = String.fromCharCode (0xffff); +data[2070] = String.fromCharCode (0xffff); +data[2071] = String.fromCharCode (0xffff); +data[2072] = String.fromCharCode (0xffff); +data[2073] = String.fromCharCode (0xffff); +data[2074] = String.fromCharCode (0xffff); +data[2075] = String.fromCharCode (0xffff); +data[2076] = String.fromCharCode (0xffff); +data[2077] = String.fromCharCode (0xffff); +data[2078] = String.fromCharCode (0xffff); +data[2079] = String.fromCharCode (0xffff); +data[2080] = String.fromCharCode (0xffff); +data[2081] = String.fromCharCode (0xffff); +data[2082] = String.fromCharCode (0xffff); +data[2083] = String.fromCharCode (0xffff); +data[2084] = String.fromCharCode (0xffff); +data[2085] = String.fromCharCode (0xffff); +data[2086] = String.fromCharCode (0xffff); +data[2087] = String.fromCharCode (0xffff); +data[2088] = String.fromCharCode (0xffff); +data[2089] = String.fromCharCode (0xffff); +data[2090] = String.fromCharCode (0xffff); +data[2091] = String.fromCharCode (0xffff); +data[2092] = String.fromCharCode (0xffff); +data[2093] = String.fromCharCode (0xffff); +data[2094] = String.fromCharCode (0xffff); +data[2095] = String.fromCharCode (0xffff); +data[2096] = String.fromCharCode (0xffff); +data[2097] = String.fromCharCode (0xffff); +data[2098] = String.fromCharCode (0xffff); +data[2099] = String.fromCharCode (0xffff); +data[2100] = String.fromCharCode (0xffff); +data[2101] = String.fromCharCode (0xffff); +data[2102] = String.fromCharCode (0xffff); +data[2103] = String.fromCharCode (0xffff); +data[2104] = String.fromCharCode (0xffff); +data[2105] = String.fromCharCode (0xffff); +data[2106] = String.fromCharCode (0xffff); +data[2107] = String.fromCharCode (0xffff); +data[2108] = String.fromCharCode (0xffff); +data[2109] = String.fromCharCode (0xffff); +data[2110] = String.fromCharCode (0xffff); +data[2111] = String.fromCharCode (0xffff); +data[2112] = String.fromCharCode (0xffff); +data[2113] = String.fromCharCode (0xffff); +data[2114] = String.fromCharCode (0xffff); +data[2115] = String.fromCharCode (0xffff); +data[2116] = String.fromCharCode (0xffff); +data[2117] = String.fromCharCode (0xffff); +data[2118] = String.fromCharCode (0xffff); +data[2119] = String.fromCharCode (0xffff); +data[2120] = String.fromCharCode (0xffff); +data[2121] = String.fromCharCode (0xffff); +data[2122] = String.fromCharCode (0xffff); +data[2123] = String.fromCharCode (0xffff); +data[2124] = String.fromCharCode (0xffff); +data[2125] = String.fromCharCode (0xffff); +data[2126] = String.fromCharCode (0xffff); +data[2127] = String.fromCharCode (0xffff); +data[2128] = String.fromCharCode (0xffff); +data[2129] = String.fromCharCode (0xffff); +data[2130] = String.fromCharCode (0xffff); +data[2131] = String.fromCharCode (0xffff); +data[2132] = String.fromCharCode (0xffff); +data[2133] = String.fromCharCode (0xffff); +data[2134] = String.fromCharCode (0xffff); +data[2135] = String.fromCharCode (0xffff); +data[2136] = String.fromCharCode (0xffff); +data[2137] = String.fromCharCode (0xffff); +data[2138] = String.fromCharCode (0xffff); +data[2139] = String.fromCharCode (0xffff); +data[2140] = String.fromCharCode (0xffff); +data[2141] = String.fromCharCode (0xffff); +data[2142] = String.fromCharCode (0xffff); +data[2143] = String.fromCharCode (0xffff); +data[2144] = String.fromCharCode (0xffff); +data[2145] = String.fromCharCode (0xffff); +data[2146] = String.fromCharCode (0xffff); +data[2147] = String.fromCharCode (0xffff); +data[2148] = String.fromCharCode (0xffff); +data[2149] = String.fromCharCode (0xffff); +data[2150] = String.fromCharCode (0xffff); +data[2151] = String.fromCharCode (0xffff); +data[2152] = String.fromCharCode (0xffff); +data[2153] = String.fromCharCode (0xffff); +data[2154] = String.fromCharCode (0xffff); +data[2155] = String.fromCharCode (0xffff); +data[2156] = String.fromCharCode (0xffff); +data[2157] = String.fromCharCode (0xffff); +data[2158] = String.fromCharCode (0xffff); +data[2159] = String.fromCharCode (0xffff); +data[2160] = String.fromCharCode (0xffff); +data[2161] = String.fromCharCode (0xffff); +data[2162] = String.fromCharCode (0xffff); +data[2163] = String.fromCharCode (0xffff); +data[2164] = String.fromCharCode (0xffff); +data[2165] = String.fromCharCode (0xffff); +data[2166] = String.fromCharCode (0xffff); +data[2167] = String.fromCharCode (0xffff); +data[2168] = String.fromCharCode (0xffff); +data[2169] = String.fromCharCode (0xffff); +data[2170] = String.fromCharCode (0xffff); +data[2171] = String.fromCharCode (0xffff); +data[2172] = String.fromCharCode (0xffff); +data[2173] = String.fromCharCode (0xffff); +data[2174] = String.fromCharCode (0xffff); +data[2175] = String.fromCharCode (0xffff); +data[2176] = String.fromCharCode (0xffff); +data[2177] = String.fromCharCode (0xffff); +data[2178] = String.fromCharCode (0xffff); +data[2179] = String.fromCharCode (0xffff); +data[2180] = String.fromCharCode (0xffff); +data[2181] = String.fromCharCode (0xffff); +data[2182] = String.fromCharCode (0xffff); +data[2183] = String.fromCharCode (0xffff); +data[2184] = String.fromCharCode (0xffff); +data[2185] = String.fromCharCode (0xffff); +data[2186] = String.fromCharCode (0xffff); +data[2187] = String.fromCharCode (0xffff); +data[2188] = String.fromCharCode (0xffff); +data[2189] = String.fromCharCode (0xffff); +data[2190] = String.fromCharCode (0xffff); +data[2191] = String.fromCharCode (0xffff); +data[2192] = String.fromCharCode (0xffff); +data[2193] = String.fromCharCode (0xffff); +data[2194] = String.fromCharCode (0xffff); +data[2195] = String.fromCharCode (0xffff); +data[2196] = String.fromCharCode (0xffff); +data[2197] = String.fromCharCode (0xffff); +data[2198] = String.fromCharCode (0xffff); +data[2199] = String.fromCharCode (0xffff); +data[2200] = String.fromCharCode (0xffff); +data[2201] = String.fromCharCode (0xffff); +data[2202] = String.fromCharCode (0xffff); +data[2203] = String.fromCharCode (0xffff); +data[2204] = String.fromCharCode (0xffff); +data[2205] = String.fromCharCode (0xffff); +data[2206] = String.fromCharCode (0xffff); +data[2207] = String.fromCharCode (0xffff); +data[2208] = String.fromCharCode (0xffff); +data[2209] = String.fromCharCode (0xffff); +data[2210] = String.fromCharCode (0xffff); +data[2211] = String.fromCharCode (0xffff); +data[2212] = String.fromCharCode (0xffff); +data[2213] = String.fromCharCode (0xffff); +data[2214] = String.fromCharCode (0xffff); +data[2215] = String.fromCharCode (0xffff); +data[2216] = String.fromCharCode (0xffff); +data[2217] = String.fromCharCode (0xffff); +data[2218] = String.fromCharCode (0xffff); +data[2219] = String.fromCharCode (0xffff); +data[2220] = String.fromCharCode (0xffff); +data[2221] = String.fromCharCode (0xffff); +data[2222] = String.fromCharCode (0xffff); +data[2223] = String.fromCharCode (0xffff); +data[2224] = String.fromCharCode (0xffff); +data[2225] = String.fromCharCode (0xffff); +data[2226] = String.fromCharCode (0xffff); +data[2227] = String.fromCharCode (0xffff); +data[2228] = String.fromCharCode (0xffff); +data[2229] = String.fromCharCode (0xffff); +data[2230] = String.fromCharCode (0xffff); +data[2231] = String.fromCharCode (0xffff); +data[2232] = String.fromCharCode (0xffff); +data[2233] = String.fromCharCode (0xffff); +data[2234] = String.fromCharCode (0xffff); +data[2235] = String.fromCharCode (0xffff); +data[2236] = String.fromCharCode (0xffff); +data[2237] = String.fromCharCode (0xffff); +data[2238] = String.fromCharCode (0xffff); +data[2239] = String.fromCharCode (0xffff); +data[2240] = String.fromCharCode (0xffff); +data[2241] = String.fromCharCode (0xffff); +data[2242] = String.fromCharCode (0xffff); +data[2243] = String.fromCharCode (0xffff); +data[2244] = String.fromCharCode (0xffff); +data[2245] = String.fromCharCode (0xffff); +data[2246] = String.fromCharCode (0xffff); +data[2247] = String.fromCharCode (0xffff); +data[2248] = String.fromCharCode (0xffff); +data[2249] = String.fromCharCode (0xffff); +data[2250] = String.fromCharCode (0xffff); +data[2251] = String.fromCharCode (0xffff); +data[2252] = String.fromCharCode (0xffff); +data[2253] = String.fromCharCode (0xffff); +data[2254] = String.fromCharCode (0xffff); +data[2255] = String.fromCharCode (0xffff); +data[2256] = String.fromCharCode (0xffff); +data[2257] = String.fromCharCode (0xffff); +data[2258] = String.fromCharCode (0xffff); +data[2259] = String.fromCharCode (0xffff); +data[2260] = String.fromCharCode (0xffff); +data[2261] = String.fromCharCode (0xffff); +data[2262] = String.fromCharCode (0xffff); +data[2263] = String.fromCharCode (0xffff); +data[2264] = String.fromCharCode (0xffff); +data[2265] = String.fromCharCode (0xffff); +data[2266] = String.fromCharCode (0xffff); +data[2267] = String.fromCharCode (0xffff); +data[2268] = String.fromCharCode (0xffff); +data[2269] = String.fromCharCode (0xffff); +data[2270] = String.fromCharCode (0xffff); +data[2271] = String.fromCharCode (0xffff); +data[2272] = String.fromCharCode (0xffff); +data[2273] = String.fromCharCode (0xffff); +data[2274] = String.fromCharCode (0xffff); +data[2275] = String.fromCharCode (0xffff); +data[2276] = String.fromCharCode (0xffff); +data[2277] = String.fromCharCode (0xffff); +data[2278] = String.fromCharCode (0xffff); +data[2279] = String.fromCharCode (0xffff); +data[2280] = String.fromCharCode (0xffff); +data[2281] = String.fromCharCode (0xffff); +data[2282] = String.fromCharCode (0xffff); +data[2283] = String.fromCharCode (0xffff); +data[2284] = String.fromCharCode (0xffff); +data[2285] = String.fromCharCode (0xffff); +data[2286] = String.fromCharCode (0xffff); +data[2287] = String.fromCharCode (0xffff); +data[2288] = String.fromCharCode (0xffff); +data[2289] = String.fromCharCode (0xffff); +data[2290] = String.fromCharCode (0xffff); +data[2291] = String.fromCharCode (0xffff); +data[2292] = String.fromCharCode (0xffff); +data[2293] = String.fromCharCode (0xffff); +data[2294] = String.fromCharCode (0xffff); +data[2295] = String.fromCharCode (0xffff); +data[2296] = String.fromCharCode (0xffff); +data[2297] = String.fromCharCode (0xffff); +data[2298] = String.fromCharCode (0xffff); +data[2299] = String.fromCharCode (0xffff); +data[2300] = String.fromCharCode (0xffff); +data[2301] = String.fromCharCode (0xffff); +data[2302] = String.fromCharCode (0xffff); +data[2303] = String.fromCharCode (0xffff); +data[2304] = String.fromCharCode (0xffff); +data[2305] = String.fromCharCode (0xffff); +data[2306] = String.fromCharCode (0xffff); +data[2307] = String.fromCharCode (0xffff); +data[2308] = String.fromCharCode (0xffff); +data[2309] = String.fromCharCode (0xffff); +data[2310] = String.fromCharCode (0xffff); +data[2311] = String.fromCharCode (0xffff); +data[2312] = String.fromCharCode (0xffff); +data[2313] = String.fromCharCode (0xffff); +data[2314] = String.fromCharCode (0xffff); +data[2315] = String.fromCharCode (0xffff); +data[2316] = String.fromCharCode (0xffff); +data[2317] = String.fromCharCode (0xffff); +data[2318] = String.fromCharCode (0xffff); +data[2319] = String.fromCharCode (0xffff); +data[2320] = String.fromCharCode (0xffff); +data[2321] = String.fromCharCode (0xffff); +data[2322] = String.fromCharCode (0xffff); +data[2323] = String.fromCharCode (0xffff); +data[2324] = String.fromCharCode (0xffff); +data[2325] = String.fromCharCode (0xffff); +data[2326] = String.fromCharCode (0xffff); +data[2327] = String.fromCharCode (0xffff); +data[2328] = String.fromCharCode (0xffff); +data[2329] = String.fromCharCode (0xffff); +data[2330] = String.fromCharCode (0xffff); +data[2331] = String.fromCharCode (0xffff); +data[2332] = String.fromCharCode (0xffff); +data[2333] = String.fromCharCode (0xffff); +data[2334] = String.fromCharCode (0xffff); +data[2335] = String.fromCharCode (0xffff); +data[2336] = String.fromCharCode (0xffff); +data[2337] = String.fromCharCode (0xffff); +data[2338] = String.fromCharCode (0xffff); +data[2339] = String.fromCharCode (0xffff); +data[2340] = String.fromCharCode (0xffff); +data[2341] = String.fromCharCode (0xffff); +data[2342] = String.fromCharCode (0xffff); +data[2343] = String.fromCharCode (0xffff); +data[2344] = String.fromCharCode (0xffff); +data[2345] = String.fromCharCode (0xffff); +data[2346] = String.fromCharCode (0xffff); +data[2347] = String.fromCharCode (0xffff); +data[2348] = String.fromCharCode (0xffff); +data[2349] = String.fromCharCode (0xffff); +data[2350] = String.fromCharCode (0xffff); +data[2351] = String.fromCharCode (0xffff); +data[2352] = String.fromCharCode (0xffff); +data[2353] = String.fromCharCode (0xffff); +data[2354] = String.fromCharCode (0xffff); +data[2355] = String.fromCharCode (0xffff); +data[2356] = String.fromCharCode (0xffff); +data[2357] = String.fromCharCode (0xffff); +data[2358] = String.fromCharCode (0xffff); +data[2359] = String.fromCharCode (0xffff); +data[2360] = String.fromCharCode (0xffff); +data[2361] = String.fromCharCode (0xffff); +data[2362] = String.fromCharCode (0xffff); +data[2363] = String.fromCharCode (0xffff); +data[2364] = String.fromCharCode (0xffff); +data[2365] = String.fromCharCode (0xffff); +data[2366] = String.fromCharCode (0xffff); +data[2367] = String.fromCharCode (0xffff); +data[2368] = String.fromCharCode (0xffff); +data[2369] = String.fromCharCode (0xffff); +data[2370] = String.fromCharCode (0xffff); +data[2371] = String.fromCharCode (0xffff); +data[2372] = String.fromCharCode (0xffff); +data[2373] = String.fromCharCode (0xffff); +data[2374] = String.fromCharCode (0xffff); +data[2375] = String.fromCharCode (0xffff); +data[2376] = String.fromCharCode (0xffff); +data[2377] = String.fromCharCode (0xffff); +data[2378] = String.fromCharCode (0xffff); +data[2379] = String.fromCharCode (0xffff); +data[2380] = String.fromCharCode (0xffff); +data[2381] = String.fromCharCode (0xffff); +data[2382] = String.fromCharCode (0xffff); +data[2383] = String.fromCharCode (0xffff); +data[2384] = String.fromCharCode (0xffff); +data[2385] = String.fromCharCode (0xffff); +data[2386] = String.fromCharCode (0xffff); +data[2387] = String.fromCharCode (0xffff); +data[2388] = String.fromCharCode (0xffff); +data[2389] = String.fromCharCode (0xffff); +data[2390] = String.fromCharCode (0xffff); +data[2391] = String.fromCharCode (0xffff); +data[2392] = String.fromCharCode (0xffff); +data[2393] = String.fromCharCode (0xffff); +data[2394] = String.fromCharCode (0xffff); +data[2395] = String.fromCharCode (0xffff); +data[2396] = String.fromCharCode (0xffff); +data[2397] = String.fromCharCode (0xffff); +data[2398] = String.fromCharCode (0xffff); +data[2399] = String.fromCharCode (0xffff); +data[2400] = String.fromCharCode (0xffff); +data[2401] = String.fromCharCode (0xffff); +data[2402] = String.fromCharCode (0xffff); +data[2403] = String.fromCharCode (0xffff); +data[2404] = String.fromCharCode (0xffff); +data[2405] = String.fromCharCode (0xffff); +data[2406] = String.fromCharCode (0xffff); +data[2407] = String.fromCharCode (0xffff); +data[2408] = String.fromCharCode (0xffff); +data[2409] = String.fromCharCode (0xffff); +data[2410] = String.fromCharCode (0xffff); +data[2411] = String.fromCharCode (0xffff); +data[2412] = String.fromCharCode (0xffff); +data[2413] = String.fromCharCode (0xffff); +data[2414] = String.fromCharCode (0xffff); +data[2415] = String.fromCharCode (0xffff); +data[2416] = String.fromCharCode (0xffff); +data[2417] = String.fromCharCode (0xffff); +data[2418] = String.fromCharCode (0xffff); +data[2419] = String.fromCharCode (0xffff); +data[2420] = String.fromCharCode (0xffff); +data[2421] = String.fromCharCode (0xffff); +data[2422] = String.fromCharCode (0xffff); +data[2423] = String.fromCharCode (0xffff); +data[2424] = String.fromCharCode (0xffff); +data[2425] = String.fromCharCode (0xffff); +data[2426] = String.fromCharCode (0xffff); +data[2427] = String.fromCharCode (0xffff); +data[2428] = String.fromCharCode (0xffff); +data[2429] = String.fromCharCode (0xffff); +data[2430] = String.fromCharCode (0xffff); +data[2431] = String.fromCharCode (0xffff); +data[2432] = String.fromCharCode (0xffff); +data[2433] = String.fromCharCode (0xffff); +data[2434] = String.fromCharCode (0xffff); +data[2435] = String.fromCharCode (0xffff); +data[2436] = String.fromCharCode (0xffff); +data[2437] = String.fromCharCode (0xffff); +data[2438] = String.fromCharCode (0xffff); +data[2439] = String.fromCharCode (0xffff); +data[2440] = String.fromCharCode (0xffff); +data[2441] = String.fromCharCode (0xffff); +data[2442] = String.fromCharCode (0xffff); +data[2443] = String.fromCharCode (0xffff); +data[2444] = String.fromCharCode (0xffff); +data[2445] = String.fromCharCode (0xffff); +data[2446] = String.fromCharCode (0xffff); +data[2447] = String.fromCharCode (0xffff); +data[2448] = String.fromCharCode (0xffff); +data[2449] = String.fromCharCode (0xffff); +data[2450] = String.fromCharCode (0xffff); +data[2451] = String.fromCharCode (0xffff); +data[2452] = String.fromCharCode (0xffff); +data[2453] = String.fromCharCode (0xffff); +data[2454] = String.fromCharCode (0xffff); +data[2455] = String.fromCharCode (0xffff); +data[2456] = String.fromCharCode (0xffff); +data[2457] = String.fromCharCode (0xffff); +data[2458] = String.fromCharCode (0xffff); +data[2459] = String.fromCharCode (0xffff); +data[2460] = String.fromCharCode (0xffff); +data[2461] = String.fromCharCode (0xffff); +data[2462] = String.fromCharCode (0xffff); +data[2463] = String.fromCharCode (0xffff); +data[2464] = String.fromCharCode (0xffff); +data[2465] = String.fromCharCode (0xffff); +data[2466] = String.fromCharCode (0xffff); +data[2467] = String.fromCharCode (0xffff); +data[2468] = String.fromCharCode (0xffff); +data[2469] = String.fromCharCode (0xffff); +data[2470] = String.fromCharCode (0xffff); +data[2471] = String.fromCharCode (0xffff); +data[2472] = String.fromCharCode (0xffff); +data[2473] = String.fromCharCode (0xffff); +data[2474] = String.fromCharCode (0xffff); +data[2475] = String.fromCharCode (0xffff); +data[2476] = String.fromCharCode (0xffff); +data[2477] = String.fromCharCode (0xffff); +data[2478] = String.fromCharCode (0xffff); +data[2479] = String.fromCharCode (0xffff); +data[2480] = String.fromCharCode (0xffff); +data[2481] = String.fromCharCode (0xffff); +data[2482] = String.fromCharCode (0xffff); +data[2483] = String.fromCharCode (0xffff); +data[2484] = String.fromCharCode (0xffff); +data[2485] = String.fromCharCode (0xffff); +data[2486] = String.fromCharCode (0xffff); +data[2487] = String.fromCharCode (0xffff); +data[2488] = String.fromCharCode (0xffff); +data[2489] = String.fromCharCode (0xffff); +data[2490] = String.fromCharCode (0xffff); +data[2491] = String.fromCharCode (0xffff); +data[2492] = String.fromCharCode (0xffff); +data[2493] = String.fromCharCode (0xffff); +data[2494] = String.fromCharCode (0xffff); +data[2495] = String.fromCharCode (0xffff); +data[2496] = String.fromCharCode (0xffff); +data[2497] = String.fromCharCode (0xffff); +data[2498] = String.fromCharCode (0xffff); +data[2499] = String.fromCharCode (0xffff); +data[2500] = String.fromCharCode (0xffff); +data[2501] = String.fromCharCode (0xffff); +data[2502] = String.fromCharCode (0xffff); +data[2503] = String.fromCharCode (0xffff); +data[2504] = String.fromCharCode (0xffff); +data[2505] = String.fromCharCode (0xffff); +data[2506] = String.fromCharCode (0xffff); +data[2507] = String.fromCharCode (0xffff); +data[2508] = String.fromCharCode (0xffff); +data[2509] = String.fromCharCode (0xffff); +data[2510] = String.fromCharCode (0xffff); +data[2511] = String.fromCharCode (0xffff); +data[2512] = String.fromCharCode (0xffff); +data[2513] = String.fromCharCode (0xffff); +data[2514] = String.fromCharCode (0xffff); +data[2515] = String.fromCharCode (0xffff); +data[2516] = String.fromCharCode (0xffff); +data[2517] = String.fromCharCode (0xffff); +data[2518] = String.fromCharCode (0xffff); +data[2519] = String.fromCharCode (0xffff); +data[2520] = String.fromCharCode (0xffff); +data[2521] = String.fromCharCode (0xffff); +data[2522] = String.fromCharCode (0xffff); +data[2523] = String.fromCharCode (0xffff); +data[2524] = String.fromCharCode (0xffff); +data[2525] = String.fromCharCode (0xffff); +data[2526] = String.fromCharCode (0xffff); +data[2527] = String.fromCharCode (0xffff); +data[2528] = String.fromCharCode (0xffff); +data[2529] = String.fromCharCode (0xffff); +data[2530] = String.fromCharCode (0xffff); +data[2531] = String.fromCharCode (0xffff); +data[2532] = String.fromCharCode (0xffff); +data[2533] = String.fromCharCode (0xffff); +data[2534] = String.fromCharCode (0xffff); +data[2535] = String.fromCharCode (0xffff); +data[2536] = String.fromCharCode (0xffff); +data[2537] = String.fromCharCode (0xffff); +data[2538] = String.fromCharCode (0xffff); +data[2539] = String.fromCharCode (0xffff); +data[2540] = String.fromCharCode (0xffff); +data[2541] = String.fromCharCode (0xffff); +data[2542] = String.fromCharCode (0xffff); +data[2543] = String.fromCharCode (0xffff); +data[2544] = String.fromCharCode (0xffff); +data[2545] = String.fromCharCode (0xffff); +data[2546] = String.fromCharCode (0xffff); +data[2547] = String.fromCharCode (0xffff); +data[2548] = String.fromCharCode (0xffff); +data[2549] = String.fromCharCode (0xffff); +data[2550] = String.fromCharCode (0xffff); +data[2551] = String.fromCharCode (0xffff); +data[2552] = String.fromCharCode (0xffff); +data[2553] = String.fromCharCode (0xffff); +data[2554] = String.fromCharCode (0x003f); +data[2752] = String.fromCharCode (0xffff); +data[2753] = String.fromCharCode (0xffff); +data[2754] = String.fromCharCode (0xffff); +data[2755] = String.fromCharCode (0xffff); +data[2756] = String.fromCharCode (0xffff); +data[2757] = String.fromCharCode (0xffff); +data[2758] = String.fromCharCode (0xffff); +data[2759] = String.fromCharCode (0xffff); +data[2760] = String.fromCharCode (0xffff); +data[2761] = String.fromCharCode (0xffff); +data[2762] = String.fromCharCode (0xffff); +data[2763] = String.fromCharCode (0xffff); +data[2764] = String.fromCharCode (0xffff); +data[2765] = String.fromCharCode (0xffff); +data[2766] = String.fromCharCode (0xffff); +data[2767] = String.fromCharCode (0xffff); +data[2768] = String.fromCharCode (0xffff); +data[2769] = String.fromCharCode (0xffff); +data[2770] = String.fromCharCode (0xffff); +data[2771] = String.fromCharCode (0xffff); +data[2772] = String.fromCharCode (0xffff); +data[2773] = String.fromCharCode (0xffff); +data[2774] = String.fromCharCode (0xffff); +data[2775] = String.fromCharCode (0xffff); +data[2776] = String.fromCharCode (0xffff); +data[2777] = String.fromCharCode (0xffff); +data[2778] = String.fromCharCode (0xffff); +data[2779] = String.fromCharCode (0xffff); +data[2780] = String.fromCharCode (0xffff); +data[2781] = String.fromCharCode (0xffff); +data[2782] = String.fromCharCode (0xffff); +data[2783] = String.fromCharCode (0xffff); +data[2784] = String.fromCharCode (0xffff); +data[2785] = String.fromCharCode (0xffff); +data[2786] = String.fromCharCode (0xffff); +data[2787] = String.fromCharCode (0xffff); +data[2788] = String.fromCharCode (0xffff); +data[2789] = String.fromCharCode (0xffff); +data[2790] = String.fromCharCode (0xffff); +data[2791] = String.fromCharCode (0xffff); +data[2792] = String.fromCharCode (0xffff); +data[2793] = String.fromCharCode (0xffff); +data[2794] = String.fromCharCode (0xffff); +data[2795] = String.fromCharCode (0xffff); +data[2796] = String.fromCharCode (0xffff); +data[2797] = String.fromCharCode (0xffff); +data[2798] = String.fromCharCode (0xffff); +data[2799] = String.fromCharCode (0xffff); +data[2800] = String.fromCharCode (0xffff); +data[2801] = String.fromCharCode (0xffff); +data[2802] = String.fromCharCode (0xffff); +data[2803] = String.fromCharCode (0xffff); +data[2804] = String.fromCharCode (0xffff); +data[2805] = String.fromCharCode (0xffff); +data[2806] = String.fromCharCode (0xffff); +data[2807] = String.fromCharCode (0xffff); +data[2808] = String.fromCharCode (0xffff); +data[2809] = String.fromCharCode (0xffff); +data[2810] = String.fromCharCode (0xffff); +data[2811] = String.fromCharCode (0xffff); +data[2812] = String.fromCharCode (0xffff); +data[2813] = String.fromCharCode (0xffff); +data[2814] = String.fromCharCode (0xffff); +data[2815] = String.fromCharCode (0xffff); +data[2816] = String.fromCharCode (0xffff); +data[2817] = String.fromCharCode (0xffff); +data[2818] = String.fromCharCode (0xffff); +data[2819] = String.fromCharCode (0xffff); +data[2820] = String.fromCharCode (0xffff); +data[2821] = String.fromCharCode (0xffff); +data[2822] = String.fromCharCode (0xffff); +data[2823] = String.fromCharCode (0xffff); +data[2824] = String.fromCharCode (0xffff); +data[2825] = String.fromCharCode (0xffff); +data[2826] = String.fromCharCode (0xffff); +data[2827] = String.fromCharCode (0xffff); +data[2828] = String.fromCharCode (0xffff); +data[2829] = String.fromCharCode (0xffff); +data[2830] = String.fromCharCode (0xffff); +data[2831] = String.fromCharCode (0xffff); +data[2832] = String.fromCharCode (0xffff); +data[2833] = String.fromCharCode (0xffff); +data[2834] = String.fromCharCode (0xffff); +data[2835] = String.fromCharCode (0xffff); +data[2836] = String.fromCharCode (0xffff); +data[2837] = String.fromCharCode (0xffff); +data[2838] = String.fromCharCode (0xffff); +data[2839] = String.fromCharCode (0xffff); +data[2840] = String.fromCharCode (0xffff); +data[2841] = String.fromCharCode (0xffff); +data[2842] = String.fromCharCode (0xffff); +data[2843] = String.fromCharCode (0xffff); +data[2844] = String.fromCharCode (0xffff); +data[2845] = String.fromCharCode (0xffff); +data[2846] = String.fromCharCode (0xffff); +data[2847] = String.fromCharCode (0xffff); +data[2848] = String.fromCharCode (0xffff); +data[2849] = String.fromCharCode (0xffff); +data[2850] = String.fromCharCode (0xffff); +data[2851] = String.fromCharCode (0xffff); +data[2852] = String.fromCharCode (0xffff); +data[2853] = String.fromCharCode (0xffff); +data[2854] = String.fromCharCode (0xffff); +data[2855] = String.fromCharCode (0xffff); +data[2856] = String.fromCharCode (0xffff); +data[2857] = String.fromCharCode (0xffff); +data[2858] = String.fromCharCode (0xffff); +data[2859] = String.fromCharCode (0xffff); +data[2860] = String.fromCharCode (0xffff); +data[2861] = String.fromCharCode (0xffff); +data[2862] = String.fromCharCode (0xffff); +data[2863] = String.fromCharCode (0xffff); +data[2864] = String.fromCharCode (0xffff); +data[2865] = String.fromCharCode (0xffff); +data[2866] = String.fromCharCode (0xffff); +data[2867] = String.fromCharCode (0xffff); +data[2868] = String.fromCharCode (0xffff); +data[2869] = String.fromCharCode (0xffff); +data[2870] = String.fromCharCode (0xffff); +data[2871] = String.fromCharCode (0xffff); +data[2872] = String.fromCharCode (0xffff); +data[2873] = String.fromCharCode (0xffff); +data[2874] = String.fromCharCode (0xffff); +data[2875] = String.fromCharCode (0xffff); +data[2876] = String.fromCharCode (0xffff); +data[2877] = String.fromCharCode (0xffff); +data[2878] = String.fromCharCode (0xffff); +data[2879] = String.fromCharCode (0xffff); +data[2880] = String.fromCharCode (0xffff); +data[2881] = String.fromCharCode (0xffff); +data[2882] = String.fromCharCode (0xffff); +data[2883] = String.fromCharCode (0xffff); +data[2884] = String.fromCharCode (0xffff); +data[2885] = String.fromCharCode (0xffff); +data[2886] = String.fromCharCode (0xffff); +data[2887] = String.fromCharCode (0xffff); +data[2888] = String.fromCharCode (0xffff); +data[2889] = String.fromCharCode (0xffff); +data[2890] = String.fromCharCode (0xffff); +data[2891] = String.fromCharCode (0xffff); +data[2892] = String.fromCharCode (0xffff); +data[2893] = String.fromCharCode (0xffff); +data[2894] = String.fromCharCode (0xffff); +data[2895] = String.fromCharCode (0xffff); +data[2896] = String.fromCharCode (0xffff); +data[2897] = String.fromCharCode (0xffff); +data[2898] = String.fromCharCode (0xffff); +data[2899] = String.fromCharCode (0xffff); +data[2900] = String.fromCharCode (0xffff); +data[2901] = String.fromCharCode (0xffff); +data[2902] = String.fromCharCode (0xffff); +data[2903] = String.fromCharCode (0xffff); +data[2904] = String.fromCharCode (0xffff); +data[2905] = String.fromCharCode (0xffff); +data[2906] = String.fromCharCode (0xffff); +data[2907] = String.fromCharCode (0xffff); +data[2908] = String.fromCharCode (0xffff); +data[2909] = String.fromCharCode (0xffff); +data[2910] = String.fromCharCode (0xffff); +data[2911] = String.fromCharCode (0xffff); +data[2912] = String.fromCharCode (0xffff); +data[2913] = String.fromCharCode (0xffff); +data[2914] = String.fromCharCode (0xffff); +data[2915] = String.fromCharCode (0xffff); +data[2916] = String.fromCharCode (0xffff); +data[2917] = String.fromCharCode (0xffff); +data[2918] = String.fromCharCode (0xffff); +data[2919] = String.fromCharCode (0xffff); +data[2920] = String.fromCharCode (0xffff); +data[2921] = String.fromCharCode (0xffff); +data[2922] = String.fromCharCode (0xffff); +data[2923] = String.fromCharCode (0xffff); +data[2924] = String.fromCharCode (0xffff); +data[2925] = String.fromCharCode (0xffff); +data[2926] = String.fromCharCode (0xffff); +data[2927] = String.fromCharCode (0xffff); +data[2928] = String.fromCharCode (0xffff); +data[2929] = String.fromCharCode (0xffff); +data[2930] = String.fromCharCode (0xffff); +data[2931] = String.fromCharCode (0xffff); +data[2932] = String.fromCharCode (0xffff); +data[2933] = String.fromCharCode (0xffff); +data[2934] = String.fromCharCode (0xffff); +data[2935] = String.fromCharCode (0xffff); +data[2936] = String.fromCharCode (0xffff); +data[2937] = String.fromCharCode (0xffff); +data[2938] = String.fromCharCode (0xffff); +data[2939] = String.fromCharCode (0xffff); +data[2940] = String.fromCharCode (0xffff); +data[2941] = String.fromCharCode (0xffff); +data[2942] = String.fromCharCode (0xffff); +data[2943] = String.fromCharCode (0xffff); +data[2944] = String.fromCharCode (0xffff); +data[2945] = String.fromCharCode (0xffff); +data[2946] = String.fromCharCode (0xffff); +data[2947] = String.fromCharCode (0xffff); +data[2948] = String.fromCharCode (0xffff); +data[2949] = String.fromCharCode (0xffff); +data[2950] = String.fromCharCode (0xffff); +data[2951] = String.fromCharCode (0xffff); +data[2952] = String.fromCharCode (0xffff); +data[2953] = String.fromCharCode (0xffff); +data[2954] = String.fromCharCode (0xffff); +data[2955] = String.fromCharCode (0xffff); +data[2956] = String.fromCharCode (0xffff); +data[2957] = String.fromCharCode (0xffff); +data[2958] = String.fromCharCode (0xffff); +data[2959] = String.fromCharCode (0xffff); +data[2960] = String.fromCharCode (0xffff); +data[2961] = String.fromCharCode (0xffff); +data[2962] = String.fromCharCode (0xffff); +data[2963] = String.fromCharCode (0xffff); +data[2964] = String.fromCharCode (0xffff); +data[2965] = String.fromCharCode (0xffff); +data[2966] = String.fromCharCode (0xffff); +data[2967] = String.fromCharCode (0xffff); +data[2968] = String.fromCharCode (0xffff); +data[2969] = String.fromCharCode (0xffff); +data[2970] = String.fromCharCode (0xffff); +data[2971] = String.fromCharCode (0xffff); +data[2972] = String.fromCharCode (0xffff); +data[2973] = String.fromCharCode (0xffff); +data[2974] = String.fromCharCode (0xffff); +data[2975] = String.fromCharCode (0xffff); +data[2976] = String.fromCharCode (0xffff); +data[2977] = String.fromCharCode (0xffff); +data[2978] = String.fromCharCode (0xffff); +data[2979] = String.fromCharCode (0xffff); +data[2980] = String.fromCharCode (0xffff); +data[2981] = String.fromCharCode (0xffff); +data[2982] = String.fromCharCode (0xffff); +data[2983] = String.fromCharCode (0xffff); +data[2984] = String.fromCharCode (0xffff); +data[2985] = String.fromCharCode (0xffff); +data[2986] = String.fromCharCode (0xffff); +data[2987] = String.fromCharCode (0xffff); +data[2988] = String.fromCharCode (0xffff); +data[2989] = String.fromCharCode (0xffff); +data[2990] = String.fromCharCode (0xffff); +data[2991] = String.fromCharCode (0xffff); +data[2992] = String.fromCharCode (0xffff); +data[2993] = String.fromCharCode (0xffff); +data[2994] = String.fromCharCode (0xffff); +data[2995] = String.fromCharCode (0xffff); +data[2996] = String.fromCharCode (0xffff); +data[2997] = String.fromCharCode (0xffff); +data[2998] = String.fromCharCode (0xffff); +data[2999] = String.fromCharCode (0xffff); +data[3000] = String.fromCharCode (0xffff); +data[3001] = String.fromCharCode (0xffff); +data[3002] = String.fromCharCode (0xffff); +data[3003] = String.fromCharCode (0xffff); +data[3004] = String.fromCharCode (0xffff); +data[3005] = String.fromCharCode (0xffff); +data[3006] = String.fromCharCode (0xffff); +data[3007] = String.fromCharCode (0xffff); +data[3008] = String.fromCharCode (0xffff); +data[3009] = String.fromCharCode (0xffff); +data[3010] = String.fromCharCode (0xffff); +data[3011] = String.fromCharCode (0xffff); +data[3012] = String.fromCharCode (0xffff); +data[3013] = String.fromCharCode (0xffff); +data[3014] = String.fromCharCode (0xffff); +data[3015] = String.fromCharCode (0xffff); +data[3016] = String.fromCharCode (0xffff); +data[3017] = String.fromCharCode (0xffff); +data[3018] = String.fromCharCode (0xffff); +data[3019] = String.fromCharCode (0xffff); +data[3020] = String.fromCharCode (0xffff); +data[3021] = String.fromCharCode (0xffff); +data[3022] = String.fromCharCode (0xffff); +data[3023] = String.fromCharCode (0xffff); +data[3024] = String.fromCharCode (0xffff); +data[3025] = String.fromCharCode (0xffff); +data[3026] = String.fromCharCode (0xffff); +data[3027] = String.fromCharCode (0xffff); +data[3028] = String.fromCharCode (0xffff); +data[3029] = String.fromCharCode (0xffff); +data[3030] = String.fromCharCode (0xffff); +data[3031] = String.fromCharCode (0xffff); +data[3032] = String.fromCharCode (0xffff); +data[3033] = String.fromCharCode (0xffff); +data[3034] = String.fromCharCode (0xffff); +data[3035] = String.fromCharCode (0xffff); +data[3036] = String.fromCharCode (0xffff); +data[3037] = String.fromCharCode (0xffff); +data[3038] = String.fromCharCode (0xffff); +data[3039] = String.fromCharCode (0xffff); +data[3040] = String.fromCharCode (0xffff); +data[3041] = String.fromCharCode (0xffff); +data[3042] = String.fromCharCode (0xffff); +data[3043] = String.fromCharCode (0xffff); +data[3044] = String.fromCharCode (0xffff); +data[3045] = String.fromCharCode (0xffff); +data[3046] = String.fromCharCode (0xffff); +data[3047] = String.fromCharCode (0xffff); +data[3048] = String.fromCharCode (0xffff); +data[3049] = String.fromCharCode (0xffff); +data[3050] = String.fromCharCode (0xffff); +data[3051] = String.fromCharCode (0xffff); +data[3052] = String.fromCharCode (0xffff); +data[3053] = String.fromCharCode (0xffff); +data[3054] = String.fromCharCode (0xffff); +data[3055] = String.fromCharCode (0xffff); +data[3056] = String.fromCharCode (0xffff); +data[3057] = String.fromCharCode (0xffff); +data[3058] = String.fromCharCode (0xffff); +data[3059] = String.fromCharCode (0xffff); +data[3060] = String.fromCharCode (0xffff); +data[3061] = String.fromCharCode (0xffff); +data[3062] = String.fromCharCode (0xffff); +data[3063] = String.fromCharCode (0xffff); +data[3064] = String.fromCharCode (0xffff); +data[3065] = String.fromCharCode (0xffff); +data[3066] = String.fromCharCode (0xffff); +data[3067] = String.fromCharCode (0xffff); +data[3068] = String.fromCharCode (0xffff); +data[3069] = String.fromCharCode (0xffff); +data[3070] = String.fromCharCode (0xffff); +data[3071] = String.fromCharCode (0xffff); +data[3072] = String.fromCharCode (0xffff); +data[3073] = String.fromCharCode (0xffff); +data[3074] = String.fromCharCode (0xffff); +data[3075] = String.fromCharCode (0xffff); +data[3076] = String.fromCharCode (0xffff); +data[3077] = String.fromCharCode (0xffff); +data[3078] = String.fromCharCode (0xffff); +data[3079] = String.fromCharCode (0xffff); +data[3080] = String.fromCharCode (0xffff); +data[3081] = String.fromCharCode (0xffff); +data[3082] = String.fromCharCode (0xffff); +data[3083] = String.fromCharCode (0xffff); +data[3084] = String.fromCharCode (0xffff); +data[3085] = String.fromCharCode (0xffff); +data[3086] = String.fromCharCode (0xffff); +data[3087] = String.fromCharCode (0xffff); +data[3088] = String.fromCharCode (0xffff); +data[3089] = String.fromCharCode (0xffff); +data[3090] = String.fromCharCode (0xffff); +data[3091] = String.fromCharCode (0xffff); +data[3092] = String.fromCharCode (0xffff); +data[3093] = String.fromCharCode (0xffff); +data[3094] = String.fromCharCode (0xffff); +data[3095] = String.fromCharCode (0xffff); +data[3096] = String.fromCharCode (0xffff); +data[3097] = String.fromCharCode (0xffff); +data[3098] = String.fromCharCode (0xffff); +data[3099] = String.fromCharCode (0xffff); +data[3100] = String.fromCharCode (0xffff); +data[3101] = String.fromCharCode (0xffff); +data[3102] = String.fromCharCode (0xffff); +data[3103] = String.fromCharCode (0xffff); +data[3104] = String.fromCharCode (0xffff); +data[3105] = String.fromCharCode (0xffff); +data[3106] = String.fromCharCode (0xffff); +data[3107] = String.fromCharCode (0xffff); +data[3108] = String.fromCharCode (0xffff); +data[3109] = String.fromCharCode (0xffff); +data[3110] = String.fromCharCode (0xffff); +data[3111] = String.fromCharCode (0xffff); +data[3112] = String.fromCharCode (0xffff); +data[3113] = String.fromCharCode (0xffff); +data[3114] = String.fromCharCode (0xffff); +data[3115] = String.fromCharCode (0xffff); +data[3116] = String.fromCharCode (0xffff); +data[3117] = String.fromCharCode (0xffff); +data[3118] = String.fromCharCode (0xffff); +data[3119] = String.fromCharCode (0xffff); +data[3120] = String.fromCharCode (0xffff); +data[3121] = String.fromCharCode (0xffff); +data[3122] = String.fromCharCode (0xffff); +data[3123] = String.fromCharCode (0xffff); +data[3124] = String.fromCharCode (0xffff); +data[3125] = String.fromCharCode (0xffff); +data[3126] = String.fromCharCode (0xffff); +data[3127] = String.fromCharCode (0xffff); +data[3128] = String.fromCharCode (0xffff); +data[3129] = String.fromCharCode (0xffff); +data[3130] = String.fromCharCode (0xffff); +data[3131] = String.fromCharCode (0xffff); +data[3132] = String.fromCharCode (0xffff); +data[3133] = String.fromCharCode (0xffff); +data[3134] = String.fromCharCode (0xffff); +data[3135] = String.fromCharCode (0xffff); +data[3136] = String.fromCharCode (0xffff); +data[3137] = String.fromCharCode (0xffff); +data[3138] = String.fromCharCode (0xffff); +data[3139] = String.fromCharCode (0xffff); +data[3140] = String.fromCharCode (0xffff); +data[3141] = String.fromCharCode (0xffff); +data[3142] = String.fromCharCode (0xffff); +data[3143] = String.fromCharCode (0xffff); +data[3144] = String.fromCharCode (0xffff); +data[3145] = String.fromCharCode (0xffff); +data[3146] = String.fromCharCode (0xffff); +data[3147] = String.fromCharCode (0xffff); +data[3148] = String.fromCharCode (0xffff); +data[3149] = String.fromCharCode (0xffff); +data[3150] = String.fromCharCode (0xffff); +data[3151] = String.fromCharCode (0xffff); +data[3152] = String.fromCharCode (0xffff); +data[3153] = String.fromCharCode (0xffff); +data[3154] = String.fromCharCode (0xffff); +data[3155] = String.fromCharCode (0xffff); +data[3156] = String.fromCharCode (0xffff); +data[3157] = String.fromCharCode (0xffff); +data[3158] = String.fromCharCode (0xffff); +data[3159] = String.fromCharCode (0xffff); +data[3160] = String.fromCharCode (0xffff); +data[3161] = String.fromCharCode (0xffff); +data[3162] = String.fromCharCode (0xffff); +data[3163] = String.fromCharCode (0xffff); +data[3164] = String.fromCharCode (0xffff); +data[3165] = String.fromCharCode (0xffff); +data[3166] = String.fromCharCode (0xffff); +data[3167] = String.fromCharCode (0xffff); +data[3168] = String.fromCharCode (0xffff); +data[3169] = String.fromCharCode (0xffff); +data[3170] = String.fromCharCode (0xffff); +data[3171] = String.fromCharCode (0xffff); +data[3172] = String.fromCharCode (0xffff); +data[3173] = String.fromCharCode (0xffff); +data[3174] = String.fromCharCode (0xffff); +data[3175] = String.fromCharCode (0xffff); +data[3176] = String.fromCharCode (0xffff); +data[3177] = String.fromCharCode (0xffff); +data[3178] = String.fromCharCode (0xffff); +data[3179] = String.fromCharCode (0xffff); +data[3180] = String.fromCharCode (0xffff); +data[3181] = String.fromCharCode (0xffff); +data[3182] = String.fromCharCode (0xffff); +data[3183] = String.fromCharCode (0xffff); +data[3184] = String.fromCharCode (0xffff); +data[3185] = String.fromCharCode (0xffff); +data[3186] = String.fromCharCode (0xffff); +data[3187] = String.fromCharCode (0xffff); +data[3188] = String.fromCharCode (0xffff); +data[3189] = String.fromCharCode (0xffff); +data[3190] = String.fromCharCode (0xffff); +data[3191] = String.fromCharCode (0xffff); +data[3192] = String.fromCharCode (0xffff); +data[3193] = String.fromCharCode (0xffff); +data[3194] = String.fromCharCode (0xffff); +data[3195] = String.fromCharCode (0xffff); +data[3196] = String.fromCharCode (0xffff); +data[3197] = String.fromCharCode (0xffff); +data[3198] = String.fromCharCode (0xffff); +data[3199] = String.fromCharCode (0xffff); +data[3200] = String.fromCharCode (0xffff); +data[3201] = String.fromCharCode (0xffff); +data[3202] = String.fromCharCode (0xffff); +data[3203] = String.fromCharCode (0xffff); +data[3204] = String.fromCharCode (0xffff); +data[3205] = String.fromCharCode (0xffff); +data[3206] = String.fromCharCode (0xffff); +data[3207] = String.fromCharCode (0xffff); +data[3208] = String.fromCharCode (0xffff); +data[3209] = String.fromCharCode (0xffff); +data[3210] = String.fromCharCode (0xffff); +data[3211] = String.fromCharCode (0xffff); +data[3212] = String.fromCharCode (0xffff); +data[3213] = String.fromCharCode (0xffff); +data[3214] = String.fromCharCode (0xffff); +data[3215] = String.fromCharCode (0xffff); +data[3216] = String.fromCharCode (0xffff); +data[3217] = String.fromCharCode (0xffff); +data[3218] = String.fromCharCode (0xffff); +data[3219] = String.fromCharCode (0xffff); +data[3220] = String.fromCharCode (0xffff); +data[3221] = String.fromCharCode (0xffff); +data[3222] = String.fromCharCode (0xffff); +data[3223] = String.fromCharCode (0xffff); +data[3224] = String.fromCharCode (0xffff); +data[3225] = String.fromCharCode (0xffff); +data[3226] = String.fromCharCode (0xffff); +data[3227] = String.fromCharCode (0xffff); +data[3228] = String.fromCharCode (0xffff); +data[3229] = String.fromCharCode (0xffff); +data[3230] = String.fromCharCode (0xffff); +data[3231] = String.fromCharCode (0xffff); +data[3232] = String.fromCharCode (0xffff); +data[3233] = String.fromCharCode (0xffff); +data[3234] = String.fromCharCode (0xffff); +data[3235] = String.fromCharCode (0xffff); +data[3236] = String.fromCharCode (0xffff); +data[3237] = String.fromCharCode (0xffff); +data[3238] = String.fromCharCode (0xffff); +data[3239] = String.fromCharCode (0xffff); +data[3240] = String.fromCharCode (0xffff); +data[3241] = String.fromCharCode (0xffff); +data[3242] = String.fromCharCode (0xffff); +data[3243] = String.fromCharCode (0xffff); +data[3244] = String.fromCharCode (0xffff); +data[3245] = String.fromCharCode (0xffff); +data[3246] = String.fromCharCode (0xffff); +data[3247] = String.fromCharCode (0xffff); +data[3248] = String.fromCharCode (0xffff); +data[3249] = String.fromCharCode (0xffff); +data[3250] = String.fromCharCode (0xffff); +data[3251] = String.fromCharCode (0xffff); +data[3252] = String.fromCharCode (0xffff); +data[3253] = String.fromCharCode (0xffff); +data[3254] = String.fromCharCode (0xffff); +data[3255] = String.fromCharCode (0xffff); +data[3256] = String.fromCharCode (0xffff); +data[3257] = String.fromCharCode (0xffff); +data[3258] = String.fromCharCode (0xffff); +data[3259] = String.fromCharCode (0xffff); +data[3260] = String.fromCharCode (0xffff); +data[3261] = String.fromCharCode (0xffff); +data[3262] = String.fromCharCode (0xffff); +data[3263] = String.fromCharCode (0xffff); +data[3264] = String.fromCharCode (0xffff); +data[3265] = String.fromCharCode (0xffff); +data[3266] = String.fromCharCode (0xffff); +data[3267] = String.fromCharCode (0xffff); +data[3268] = String.fromCharCode (0xffff); +data[3269] = String.fromCharCode (0xffff); +data[3270] = String.fromCharCode (0xffff); +data[3271] = String.fromCharCode (0xffff); +data[3272] = String.fromCharCode (0xffff); +data[3273] = String.fromCharCode (0xffff); +data[3274] = String.fromCharCode (0xffff); +data[3275] = String.fromCharCode (0xffff); +data[3276] = String.fromCharCode (0xffff); +data[3277] = String.fromCharCode (0xffff); +data[3278] = String.fromCharCode (0xffff); +data[3279] = String.fromCharCode (0xffff); +data[3280] = String.fromCharCode (0xffff); +data[3281] = String.fromCharCode (0xffff); +data[3282] = String.fromCharCode (0xffff); +data[3283] = String.fromCharCode (0xffff); +data[3284] = String.fromCharCode (0xffff); +data[3285] = String.fromCharCode (0xffff); +data[3286] = String.fromCharCode (0xffff); +data[3287] = String.fromCharCode (0xffff); +data[3288] = String.fromCharCode (0xffff); +data[3289] = String.fromCharCode (0xffff); +data[3290] = String.fromCharCode (0xffff); +data[3291] = String.fromCharCode (0xffff); +data[3292] = String.fromCharCode (0xffff); +data[3293] = String.fromCharCode (0xffff); +data[3294] = String.fromCharCode (0xffff); +data[3295] = String.fromCharCode (0xffff); +data[3296] = String.fromCharCode (0xffff); +data[3297] = String.fromCharCode (0xffff); +data[3298] = String.fromCharCode (0xffff); +data[3299] = String.fromCharCode (0xffff); +data[3300] = String.fromCharCode (0xffff); +data[3301] = String.fromCharCode (0xffff); +data[3302] = String.fromCharCode (0xffff); +data[3303] = String.fromCharCode (0xffff); +data[3304] = String.fromCharCode (0xffff); +data[3305] = String.fromCharCode (0xffff); +data[3306] = String.fromCharCode (0xffff); +data[3307] = String.fromCharCode (0xffff); +data[3308] = String.fromCharCode (0xffff); +data[3309] = String.fromCharCode (0xffff); +data[3310] = String.fromCharCode (0xffff); +data[3311] = String.fromCharCode (0xffff); +data[3312] = String.fromCharCode (0xffff); +data[3313] = String.fromCharCode (0xffff); +data[3314] = String.fromCharCode (0xffff); +data[3315] = String.fromCharCode (0xffff); +data[3316] = String.fromCharCode (0xffff); +data[3317] = String.fromCharCode (0xffff); +data[3318] = String.fromCharCode (0xffff); +data[3319] = String.fromCharCode (0xffff); +data[3320] = String.fromCharCode (0xffff); +data[3321] = String.fromCharCode (0xffff); +data[3322] = String.fromCharCode (0xffff); +data[3323] = String.fromCharCode (0xffff); +data[3324] = String.fromCharCode (0xffff); +data[3325] = String.fromCharCode (0xffff); +data[3326] = String.fromCharCode (0xffff); +data[3327] = String.fromCharCode (0xffff); +data[3328] = String.fromCharCode (0xffff); +data[3329] = String.fromCharCode (0xffff); +data[3330] = String.fromCharCode (0xffff); +data[3331] = String.fromCharCode (0xffff); +data[3332] = String.fromCharCode (0xffff); +data[3333] = String.fromCharCode (0xffff); +data[3334] = String.fromCharCode (0xffff); +data[3335] = String.fromCharCode (0xffff); +data[3336] = String.fromCharCode (0xffff); +data[3337] = String.fromCharCode (0xffff); +data[3338] = String.fromCharCode (0xffff); +data[3339] = String.fromCharCode (0xffff); +data[3340] = String.fromCharCode (0xffff); +data[3341] = String.fromCharCode (0xffff); +data[3342] = String.fromCharCode (0xffff); +data[3343] = String.fromCharCode (0xffff); +data[3344] = String.fromCharCode (0xffff); +data[3345] = String.fromCharCode (0xffff); +data[3346] = String.fromCharCode (0xffff); +data[3347] = String.fromCharCode (0xffff); +data[3348] = String.fromCharCode (0xffff); +data[3349] = String.fromCharCode (0xffff); +data[3350] = String.fromCharCode (0xffff); +data[3351] = String.fromCharCode (0xffff); +data[3352] = String.fromCharCode (0xffff); +data[3353] = String.fromCharCode (0xffff); +data[3354] = String.fromCharCode (0xffff); +data[3355] = String.fromCharCode (0xffff); +data[3356] = String.fromCharCode (0xffff); +data[3357] = String.fromCharCode (0xffff); +data[3358] = String.fromCharCode (0xffff); +data[3359] = String.fromCharCode (0xffff); +data[3360] = String.fromCharCode (0xffff); +data[3361] = String.fromCharCode (0xffff); +data[3362] = String.fromCharCode (0xffff); +data[3363] = String.fromCharCode (0xffff); +data[3364] = String.fromCharCode (0xffff); +data[3365] = String.fromCharCode (0xffff); +data[3366] = String.fromCharCode (0xffff); +data[3367] = String.fromCharCode (0xffff); +data[3368] = String.fromCharCode (0xffff); +data[3369] = String.fromCharCode (0xffff); +data[3370] = String.fromCharCode (0xffff); +data[3371] = String.fromCharCode (0xffff); +data[3372] = String.fromCharCode (0xffff); +data[3373] = String.fromCharCode (0xffff); +data[3374] = String.fromCharCode (0xffff); +data[3375] = String.fromCharCode (0xffff); +data[3376] = String.fromCharCode (0xffff); +data[3377] = String.fromCharCode (0xffff); +data[3378] = String.fromCharCode (0xffff); +data[3379] = String.fromCharCode (0xffff); +data[3380] = String.fromCharCode (0xffff); +data[3381] = String.fromCharCode (0xffff); +data[3382] = String.fromCharCode (0xffff); +data[3383] = String.fromCharCode (0xffff); +data[3384] = String.fromCharCode (0xffff); +data[3385] = String.fromCharCode (0xffff); +data[3386] = String.fromCharCode (0xffff); +data[3387] = String.fromCharCode (0xffff); +data[3388] = String.fromCharCode (0xffff); +data[3389] = String.fromCharCode (0xffff); +data[3390] = String.fromCharCode (0xffff); +data[3391] = String.fromCharCode (0xffff); +data[3392] = String.fromCharCode (0xffff); +data[3393] = String.fromCharCode (0xffff); +data[3394] = String.fromCharCode (0xffff); +data[3395] = String.fromCharCode (0xffff); +data[3396] = String.fromCharCode (0xffff); +data[3397] = String.fromCharCode (0xffff); +data[3398] = String.fromCharCode (0xffff); +data[3399] = String.fromCharCode (0xffff); +data[3400] = String.fromCharCode (0xffff); +data[3401] = String.fromCharCode (0xffff); +data[3402] = String.fromCharCode (0xffff); +data[3403] = String.fromCharCode (0xffff); +data[3404] = String.fromCharCode (0xffff); +data[3405] = String.fromCharCode (0xffff); +data[3406] = String.fromCharCode (0xffff); +data[3407] = String.fromCharCode (0xffff); +data[3408] = String.fromCharCode (0xffff); +data[3409] = String.fromCharCode (0xffff); +data[3410] = String.fromCharCode (0xffff); +data[3411] = String.fromCharCode (0xffff); +data[3412] = String.fromCharCode (0xffff); +data[3413] = String.fromCharCode (0xffff); +data[3414] = String.fromCharCode (0xffff); +data[3415] = String.fromCharCode (0xffff); +data[3416] = String.fromCharCode (0xffff); +data[3417] = String.fromCharCode (0xffff); +data[3418] = String.fromCharCode (0xffff); +data[3419] = String.fromCharCode (0xffff); +data[3420] = String.fromCharCode (0xffff); +data[3421] = String.fromCharCode (0xffff); +data[3422] = String.fromCharCode (0xffff); +data[3423] = String.fromCharCode (0xffff); +data[3424] = String.fromCharCode (0xffff); +data[3425] = String.fromCharCode (0xffff); +data[3426] = String.fromCharCode (0xffff); +data[3427] = String.fromCharCode (0xffff); +data[3428] = String.fromCharCode (0xffff); +data[3429] = String.fromCharCode (0xffff); +data[3430] = String.fromCharCode (0xffff); +data[3431] = String.fromCharCode (0xffff); +data[3432] = String.fromCharCode (0xffff); +data[3433] = String.fromCharCode (0xffff); +data[3434] = String.fromCharCode (0xffff); +data[3435] = String.fromCharCode (0xffff); +data[3436] = String.fromCharCode (0xffff); +data[3437] = String.fromCharCode (0xffff); +data[3438] = String.fromCharCode (0xffff); +data[3439] = String.fromCharCode (0xffff); +data[3440] = String.fromCharCode (0xffff); +data[3441] = String.fromCharCode (0xffff); +data[3442] = String.fromCharCode (0xffff); +data[3443] = String.fromCharCode (0xffff); +data[3444] = String.fromCharCode (0xffff); +data[3445] = String.fromCharCode (0xffff); +data[3446] = String.fromCharCode (0xffff); +data[3447] = String.fromCharCode (0xffff); +data[3448] = String.fromCharCode (0xffff); +data[3449] = String.fromCharCode (0xffff); +data[3450] = String.fromCharCode (0x000f); +data[3984] = String.fromCharCode (0xffff); +data[3985] = String.fromCharCode (0xffff); +data[3986] = String.fromCharCode (0xffff); +data[3987] = String.fromCharCode (0xffff); +data[3988] = String.fromCharCode (0xffff); +data[3989] = String.fromCharCode (0xffff); +data[3990] = String.fromCharCode (0xffff); +data[3991] = String.fromCharCode (0xffff); +data[3992] = String.fromCharCode (0xffff); +data[3993] = String.fromCharCode (0xffff); +data[3994] = String.fromCharCode (0xffff); +data[3995] = String.fromCharCode (0xffff); +data[3996] = String.fromCharCode (0xffff); +data[3997] = String.fromCharCode (0xffff); +data[3998] = String.fromCharCode (0xffff); +data[3999] = String.fromCharCode (0xffff); +data[4000] = String.fromCharCode (0xffff); +data[4001] = String.fromCharCode (0xffff); +data[4002] = String.fromCharCode (0x3fff); +data[4016] = String.fromCharCode (0x007f); +data[4017] = String.fromCharCode (0x80f8); +data[4018] = String.fromCharCode (0xfdff); +data[4019] = String.fromCharCode (0x5f7f); +data[4020] = String.fromCharCode (0xffdb); +data[4021] = String.fromCharCode (0xffff); +data[4022] = String.fromCharCode (0xffff); +data[4023] = String.fromCharCode (0xffff); +data[4024] = String.fromCharCode (0xffff); +data[4025] = String.fromCharCode (0xffff); +data[4026] = String.fromCharCode (0xffff); +data[4027] = String.fromCharCode (0x0003); +data[4029] = String.fromCharCode (0xfff8); +data[4030] = String.fromCharCode (0xffff); +data[4031] = String.fromCharCode (0xffff); +data[4032] = String.fromCharCode (0xffff); +data[4033] = String.fromCharCode (0xffff); +data[4034] = String.fromCharCode (0xffff); +data[4035] = String.fromCharCode (0xffff); +data[4036] = String.fromCharCode (0xffff); +data[4037] = String.fromCharCode (0xffff); +data[4038] = String.fromCharCode (0xffff); +data[4039] = String.fromCharCode (0xffff); +data[4040] = String.fromCharCode (0xffff); +data[4041] = String.fromCharCode (0xffff); +data[4042] = String.fromCharCode (0xffff); +data[4043] = String.fromCharCode (0xffff); +data[4044] = String.fromCharCode (0xffff); +data[4045] = String.fromCharCode (0xffff); +data[4046] = String.fromCharCode (0xffff); +data[4047] = String.fromCharCode (0xffff); +data[4048] = String.fromCharCode (0xffff); +data[4049] = String.fromCharCode (0xffff); +data[4050] = String.fromCharCode (0xffff); +data[4051] = String.fromCharCode (0x3fff); +data[4053] = String.fromCharCode (0xffff); +data[4054] = String.fromCharCode (0xffff); +data[4055] = String.fromCharCode (0xffff); +data[4056] = String.fromCharCode (0xffff); +data[4057] = String.fromCharCode (0xfffc); +data[4058] = String.fromCharCode (0xffff); +data[4059] = String.fromCharCode (0xffff); +data[4060] = String.fromCharCode (0x00ff); +data[4063] = String.fromCharCode (0x0fff); +data[4071] = String.fromCharCode (0xffd7); +data[4072] = String.fromCharCode (0xffff); +data[4073] = String.fromCharCode (0xffff); +data[4074] = String.fromCharCode (0xffff); +data[4075] = String.fromCharCode (0xffff); +data[4076] = String.fromCharCode (0xffff); +data[4077] = String.fromCharCode (0xffff); +data[4078] = String.fromCharCode (0xffff); +data[4079] = String.fromCharCode (0x1fff); +data[4082] = String.fromCharCode (0xfffe); +data[4083] = String.fromCharCode (0x07ff); +data[4084] = String.fromCharCode (0xfffe); +data[4085] = String.fromCharCode (0x07ff); +data[4086] = String.fromCharCode (0xffc0); +data[4087] = String.fromCharCode (0xffff); +data[4088] = String.fromCharCode (0xffff); +data[4089] = String.fromCharCode (0xffff); +data[4090] = String.fromCharCode (0xffff); +data[4091] = String.fromCharCode (0x7fff); +data[4092] = String.fromCharCode (0xfcfc); +data[4093] = String.fromCharCode (0x1cfc); +data[4100] = String.fromCharCode (0xfffe); +data[4101] = String.fromCharCode (0x07ff); +data[4102] = String.fromCharCode (0xfffe); +data[4103] = String.fromCharCode (0x07ff); +data[4106] = String.fromCharCode (0x0400); +data[4107] = String.fromCharCode (0x0420); +data[4108] = String.fromCharCode (0xffff); +data[4109] = String.fromCharCode (0xff7f); +data[4110] = String.fromCharCode (0xffff); +data[4111] = String.fromCharCode (0xff7f); +data[4112] = String.fromCharCode (0xffff); +data[4113] = String.fromCharCode (0xffff); +data[4114] = String.fromCharCode (0xffff); +data[4115] = String.fromCharCode (0xffff); +data[4116] = String.fromCharCode (0xffff); +data[4117] = String.fromCharCode (0xffff); +data[4118] = String.fromCharCode (0xffff); +data[4119] = String.fromCharCode (0xffff); +data[4120] = String.fromCharCode (0xffff); +data[4121] = String.fromCharCode (0xffff); +data[4122] = String.fromCharCode (0xffff); +data[4123] = String.fromCharCode (0xffff); +data[4124] = String.fromCharCode (0xffff); +data[4125] = String.fromCharCode (0xffff); +data[4126] = String.fromCharCode (0xffff); +data[4127] = String.fromCharCode (0xfc3f); +data[4128] = String.fromCharCode (0xffff); +data[4129] = String.fromCharCode (0x00ff); +data[4133] = String.fromCharCode (0xffff); +data[4134] = String.fromCharCode (0xffff); +data[4135] = String.fromCharCode (0xffff); +data[4136] = String.fromCharCode (0xffff); +data[4137] = String.fromCharCode (0xffff); +data[4138] = String.fromCharCode (0x01ff); +data[4139] = String.fromCharCode (0xf9ff); +data[4140] = String.fromCharCode (0x0003); +data[4141] = String.fromCharCode (0x0003); +data[4142] = String.fromCharCode (0x001f); +data[4151] = String.fromCharCode (0x0400); +data[4152] = String.fromCharCode (0xd740); +data[4153] = String.fromCharCode (0xffff); +data[4154] = String.fromCharCode (0xfffb); +data[4155] = String.fromCharCode (0xffff); +data[4156] = String.fromCharCode (0x7fff); +data[4157] = String.fromCharCode (0x547f); +data[4158] = String.fromCharCode (0x00fd); +}); +c$.white_f = Clazz.defineMethod (c$, "white_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.white = new com.stevesoft.pat.Bits (data); +data[0] = String.fromCharCode (0x3e00); +data[1] = String.fromCharCode (0xf000); +data[2] = String.fromCharCode (0x0001); +data[512] = String.fromCharCode (0x0fff); +data[514] = String.fromCharCode (0x0300); +data[768] = String.fromCharCode (0x0001); +data[4096] = String.fromCharCode (0x3e00); +data[4097] = String.fromCharCode (0xf000); +data[4098] = String.fromCharCode (0x0001); +}); +c$.punct_f = Clazz.defineMethod (c$, "punct_f", +function () { +var data = Clazz.newCharArray (4159, '\0'); +com.stevesoft.pat.Bits.punct = new com.stevesoft.pat.Bits (data); +data[2] = String.fromCharCode (0xf7ee); +data[3] = String.fromCharCode (0x8c00); +data[4] = String.fromCharCode (0x0001); +data[5] = String.fromCharCode (0xb800); +data[7] = String.fromCharCode (0x2800); +data[10] = String.fromCharCode (0x2802); +data[11] = String.fromCharCode (0x8880); +data[55] = String.fromCharCode (0x4030); +data[56] = String.fromCharCode (0x0080); +data[85] = String.fromCharCode (0xfc00); +data[88] = String.fromCharCode (0x0200); +data[91] = String.fromCharCode (0x4000); +data[92] = String.fromCharCode (0x0009); +data[95] = String.fromCharCode (0x0018); +data[96] = String.fromCharCode (0x1000); +data[97] = String.fromCharCode (0x8800); +data[102] = String.fromCharCode (0x3c00); +data[109] = String.fromCharCode (0x0010); +data[150] = '0'; +data[151] = String.fromCharCode (0x0001); +data[226] = String.fromCharCode (0x8000); +data[229] = String.fromCharCode (0x0c00); +data[234] = String.fromCharCode (0x8000); +data[240] = String.fromCharCode (0xfff0); +data[241] = String.fromCharCode (0x0007); +data[243] = String.fromCharCode (0x3c00); +data[248] = String.fromCharCode (0x0020); +data[271] = String.fromCharCode (0x0800); +data[513] = String.fromCharCode (0xffff); +data[514] = String.fromCharCode (0x00ff); +data[515] = String.fromCharCode (0xffff); +data[516] = 'o'; +data[519] = String.fromCharCode (0x6000); +data[520] = String.fromCharCode (0x6000); +data[562] = String.fromCharCode (0x0600); +data[768] = String.fromCharCode (0xff4e); +data[769] = String.fromCharCode (0xfff3); +data[771] = String.fromCharCode (0x0001); +data[783] = String.fromCharCode (0x0800); +data[4051] = String.fromCharCode (0xc000); +data[4067] = String.fromCharCode (0xffff); +data[4068] = String.fromCharCode (0xfe1f); +data[4069] = String.fromCharCode (0xfff7); +data[4070] = String.fromCharCode (0x0d0b); +data[4080] = String.fromCharCode (0xf7ee); +data[4081] = String.fromCharCode (0x8c00); +data[4082] = String.fromCharCode (0x0001); +data[4083] = String.fromCharCode (0xb800); +data[4085] = String.fromCharCode (0x2800); +data[4086] = String.fromCharCode (0x003e); +data[4098] = String.fromCharCode (0xf7ee); +data[4099] = String.fromCharCode (0x8c00); +data[4100] = String.fromCharCode (0x0001); +data[4101] = String.fromCharCode (0xb800); +data[4103] = String.fromCharCode (0x2800); +data[4106] = String.fromCharCode (0x2802); +data[4107] = String.fromCharCode (0x8880); +data[4151] = String.fromCharCode (0x4030); +data[4152] = String.fromCharCode (0x0080); +}); +Clazz.defineStatics (c$, +"upper", null, +"lower", null, +"title", null, +"currency", null, +"decimal_digit", null, +"math", null, +"letter", null, +"white", null, +"punct", null); diff --git a/bin/com/stevesoft/pat/Boundary.js b/bin/com/stevesoft/pat/Boundary.js index 9eaff99..58bb19c 100644 --- a/bin/com/stevesoft/pat/Boundary.js +++ b/bin/com/stevesoft/pat/Boundary.js @@ -1,52 +1,52 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Boundary", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "Boundary", com.stevesoft.pat.Pattern); -Clazz.overrideMethod (c$, "toString", -function () { -return "\\b" + this.nextString (); -}); -Clazz.defineMethod (c$, "isAChar", -function (c) { -if (c >= 'a' && c <= 'z') { -return true; -}if (c >= 'A' && c <= 'Z') { -return true; -}if (c >= '0' && c <= '9') { -return true; -}if (c == '_') { -return true; -}return false; -}, "~S"); -Clazz.defineMethod (c$, "matchLeft", -function (pos, pt) { -if (pos <= 0) { -return true; -}if (this.isAChar (pt.src.charAt (pos)) && this.isAChar (pt.src.charAt (pos - 1))) { -return false; -}return true; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "matchRight", -function (pos, pt) { -if (pos < 0) { -return false; -}if (pos + 1 >= pt.src.length ()) { -return true; -}if (this.isAChar (pt.src.charAt (pos)) && this.isAChar (pt.src.charAt (pos + 1))) { -return false; -}return true; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (this.matchRight (pos - 1, pt) || this.matchLeft (pos, pt)) { -return this.nextMatch (pos, pt); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.Boundary (); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Boundary", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "Boundary", com.stevesoft.pat.Pattern); +Clazz.overrideMethod (c$, "toString", +function () { +return "\\b" + this.nextString (); +}); +Clazz.defineMethod (c$, "isAChar", +function (c) { +if (c >= 'a' && c <= 'z') { +return true; +}if (c >= 'A' && c <= 'Z') { +return true; +}if (c >= '0' && c <= '9') { +return true; +}if (c == '_') { +return true; +}return false; +}, "~S"); +Clazz.defineMethod (c$, "matchLeft", +function (pos, pt) { +if (pos <= 0) { +return true; +}if (this.isAChar (pt.src.charAt (pos)) && this.isAChar (pt.src.charAt (pos - 1))) { +return false; +}return true; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "matchRight", +function (pos, pt) { +if (pos < 0) { +return false; +}if (pos + 1 >= pt.src.length ()) { +return true; +}if (this.isAChar (pt.src.charAt (pos)) && this.isAChar (pt.src.charAt (pos + 1))) { +return false; +}return true; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (this.matchRight (pos - 1, pt) || this.matchLeft (pos, pt)) { +return this.nextMatch (pos, pt); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.Boundary (); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/Bracket.js b/bin/com/stevesoft/pat/Bracket.js index 064ec34..26a2303 100644 --- a/bin/com/stevesoft/pat/Bracket.js +++ b/bin/com/stevesoft/pat/Bracket.js @@ -1,60 +1,60 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Or"], "com.stevesoft.pat.Bracket", ["com.stevesoft.pat.patInt", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.neg = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Bracket", com.stevesoft.pat.Or); -Clazz.makeConstructor (c$, -function (n) { -Clazz.superConstructor (this, com.stevesoft.pat.Bracket, []); -this.neg = n; -}, "~B"); -Clazz.overrideMethod (c$, "leftForm", -function () { -if (this.neg) { -return "[^"; -} else { -return "["; -}}); -Clazz.overrideMethod (c$, "rightForm", -function () { -return "]"; -}); -Clazz.overrideMethod (c$, "sepForm", -function () { -return ""; -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -if (pos >= pt.src.length ()) { -return -1; -}var r = Clazz.superCall (this, com.stevesoft.pat.Bracket, "matchInternal", [pos, pt]); -if ((this.neg && r < 0) || (!this.neg && r >= 0)) { -return this.nextMatch (pos + 1, pt); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "addOr", -function (p) { -this.pv = null; -this.v.addElement (p); -p.setParent (null); -return this; -}, "com.stevesoft.pat.Pattern"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -var b = new com.stevesoft.pat.Bracket (this.neg); -b.v = new java.util.Vector (); -for (var i = 0; i < this.v.size (); i++) { -b.v.addElement ((this.v.elementAt (i)).clone1 (h)); -} -return b; -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Or"], "com.stevesoft.pat.Bracket", ["com.stevesoft.pat.patInt", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.neg = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Bracket", com.stevesoft.pat.Or); +Clazz.makeConstructor (c$, +function (n) { +Clazz.superConstructor (this, com.stevesoft.pat.Bracket, []); +this.neg = n; +}, "~B"); +Clazz.overrideMethod (c$, "leftForm", +function () { +if (this.neg) { +return "[^"; +} else { +return "["; +}}); +Clazz.overrideMethod (c$, "rightForm", +function () { +return "]"; +}); +Clazz.overrideMethod (c$, "sepForm", +function () { +return ""; +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +if (pos >= pt.src.length ()) { +return -1; +}var r = Clazz.superCall (this, com.stevesoft.pat.Bracket, "matchInternal", [pos, pt]); +if ((this.neg && r < 0) || (!this.neg && r >= 0)) { +return this.nextMatch (pos + 1, pt); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "addOr", +function (p) { +this.pv = null; +this.v.addElement (p); +p.setParent (null); +return this; +}, "com.stevesoft.pat.Pattern"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +var b = new com.stevesoft.pat.Bracket (this.neg); +b.v = new java.util.Vector (); +for (var i = 0; i < this.v.size (); i++) { +b.v.addElement ((this.v.elementAt (i)).clone1 (h)); +} +return b; +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/CaseMgr.js b/bin/com/stevesoft/pat/CaseMgr.js index 30fe2ec..e35645b 100644 --- a/bin/com/stevesoft/pat/CaseMgr.js +++ b/bin/com/stevesoft/pat/CaseMgr.js @@ -1,94 +1,94 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.CaseMgr", ["java.lang.Character"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "CaseMgr"); -c$.toUpperCaseC = Clazz.defineMethod (c$, "toUpperCaseC", -function (c) { -return Character.toUpperCase (c); -}, "~S"); -c$.toLowerCaseC = Clazz.defineMethod (c$, "toLowerCaseC", -function (c) { -return Character.toLowerCase (c); -}, "~S"); -c$.toUpperCase = Clazz.defineMethod (c$, "toUpperCase", -function (s) { -return s.toUpperCase (); -}, "~S"); -c$.toLowerCase = Clazz.defineMethod (c$, "toLowerCase", -function (s) { -return s.toLowerCase (); -}, "~S"); -c$.toTitleCaseC = Clazz.defineMethod (c$, "toTitleCaseC", -function (c) { -return Character.toUpperCase (c); -}, "~S"); -c$.regionMatchesLike = Clazz.defineMethod (c$, "regionMatchesLike", -function (s1, ign, i1, s2, i2, i3) { -var itot = i2 + i3; -if (itot > s2.length () || i1 + i3 > s1.length ()) { -return false; -}if (!ign) { -for (var i = i2; i < itot; i++) { -if (s2.charAt (i) != s1.charAt (i1++)) { -return false; -}} -} else { -for (var i = i2; i < itot; i++) { -if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { -return false; -}} -}return true; -}, "com.stevesoft.pat.StringLike,~B,~N,com.stevesoft.pat.StringLike,~N,~N"); -c$.regionMatches = Clazz.defineMethod (c$, "regionMatches", -function (s1, ign, i1, s2, i2, i3) { -var itot = i2 + i3; -if (itot > s2.length () || i1 + i3 > s1.length) { -return false; -}if (!ign) { -for (var i = i2; i < itot; i++) { -if (s2.charAt (i) != s1.charAt (i1++)) { -return false; -}} -} else { -for (var i = i2; i < itot; i++) { -if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { -return false; -}} -}return true; -}, "~S,~B,~N,com.stevesoft.pat.StringLike,~N,~N"); -c$.regionMatchesLike2 = Clazz.defineMethod (c$, "regionMatchesLike2", -function (s1, ign, i1, s2, i2, i3) { -var itot = i2 + i3; -if (itot > s2.length || i1 + i3 > s1.length ()) { -return false; -}if (!ign) { -for (var i = i2; i < itot; i++) { -if (s2.charAt (i) != s1.charAt (i1++)) { -return false; -}} -} else { -for (var i = i2; i < itot; i++) { -if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { -return false; -}} -}return true; -}, "com.stevesoft.pat.StringLike,~B,~N,~S,~N,~N"); -c$.regionMatches2 = Clazz.defineMethod (c$, "regionMatches2", -function (s1, ign, i1, s2, i2, i3) { -var itot = i2 + i3; -if (itot > s2.length || i1 + i3 > s1.length) { -return false; -}if (!ign) { -for (var i = i2; i < itot; i++) { -if (s2.charAt (i) != s1.charAt (i1++)) { -return false; -}} -} else { -for (var i = i2; i < itot; i++) { -if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { -return false; -}} -}return true; -}, "~S,~B,~N,~S,~N,~N"); -Clazz.defineStatics (c$, -"java_1_0", false); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.CaseMgr", ["java.lang.Character"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "CaseMgr"); +c$.toUpperCaseC = Clazz.defineMethod (c$, "toUpperCaseC", +function (c) { +return Character.toUpperCase (c); +}, "~S"); +c$.toLowerCaseC = Clazz.defineMethod (c$, "toLowerCaseC", +function (c) { +return Character.toLowerCase (c); +}, "~S"); +c$.toUpperCase = Clazz.defineMethod (c$, "toUpperCase", +function (s) { +return s.toUpperCase (); +}, "~S"); +c$.toLowerCase = Clazz.defineMethod (c$, "toLowerCase", +function (s) { +return s.toLowerCase (); +}, "~S"); +c$.toTitleCaseC = Clazz.defineMethod (c$, "toTitleCaseC", +function (c) { +return Character.toUpperCase (c); +}, "~S"); +c$.regionMatchesLike = Clazz.defineMethod (c$, "regionMatchesLike", +function (s1, ign, i1, s2, i2, i3) { +var itot = i2 + i3; +if (itot > s2.length () || i1 + i3 > s1.length ()) { +return false; +}if (!ign) { +for (var i = i2; i < itot; i++) { +if (s2.charAt (i) != s1.charAt (i1++)) { +return false; +}} +} else { +for (var i = i2; i < itot; i++) { +if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { +return false; +}} +}return true; +}, "com.stevesoft.pat.StringLike,~B,~N,com.stevesoft.pat.StringLike,~N,~N"); +c$.regionMatches = Clazz.defineMethod (c$, "regionMatches", +function (s1, ign, i1, s2, i2, i3) { +var itot = i2 + i3; +if (itot > s2.length () || i1 + i3 > s1.length) { +return false; +}if (!ign) { +for (var i = i2; i < itot; i++) { +if (s2.charAt (i) != s1.charAt (i1++)) { +return false; +}} +} else { +for (var i = i2; i < itot; i++) { +if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { +return false; +}} +}return true; +}, "~S,~B,~N,com.stevesoft.pat.StringLike,~N,~N"); +c$.regionMatchesLike2 = Clazz.defineMethod (c$, "regionMatchesLike2", +function (s1, ign, i1, s2, i2, i3) { +var itot = i2 + i3; +if (itot > s2.length || i1 + i3 > s1.length ()) { +return false; +}if (!ign) { +for (var i = i2; i < itot; i++) { +if (s2.charAt (i) != s1.charAt (i1++)) { +return false; +}} +} else { +for (var i = i2; i < itot; i++) { +if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { +return false; +}} +}return true; +}, "com.stevesoft.pat.StringLike,~B,~N,~S,~N,~N"); +c$.regionMatches2 = Clazz.defineMethod (c$, "regionMatches2", +function (s1, ign, i1, s2, i2, i3) { +var itot = i2 + i3; +if (itot > s2.length || i1 + i3 > s1.length) { +return false; +}if (!ign) { +for (var i = i2; i < itot; i++) { +if (s2.charAt (i) != s1.charAt (i1++)) { +return false; +}} +} else { +for (var i = i2; i < itot; i++) { +if (com.stevesoft.pat.CaseMgr.toLowerCaseC (s2.charAt (i)) != com.stevesoft.pat.CaseMgr.toLowerCaseC (s1.charAt (i1++))) { +return false; +}} +}return true; +}, "~S,~B,~N,~S,~N,~N"); +Clazz.defineStatics (c$, +"java_1_0", false); +}); diff --git a/bin/com/stevesoft/pat/ChangeRule.js b/bin/com/stevesoft/pat/ChangeRule.js index 3edb0ff..1a6f683 100644 --- a/bin/com/stevesoft/pat/ChangeRule.js +++ b/bin/com/stevesoft/pat/ChangeRule.js @@ -1,35 +1,35 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.ChangeRule", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.NewRule = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "ChangeRule", com.stevesoft.pat.SpecialRule); -Clazz.makeConstructor (c$, -function (c) { -Clazz.superConstructor (this, com.stevesoft.pat.ChangeRule, []); -this.NewRule = c.NewRule; -}, "com.stevesoft.pat.ChangeRule"); -Clazz.makeConstructor (c$, -function (nm, rr) { -Clazz.superConstructor (this, com.stevesoft.pat.ChangeRule, []); -this.name = nm; -this.NewRule = rr; -}, "~S,com.stevesoft.pat.Regex"); -Clazz.makeConstructor (c$, -function (nm, tr) { -Clazz.superConstructor (this, com.stevesoft.pat.ChangeRule, []); -this.name = nm; -this.NewRule = tr.rp; -}, "~S,com.stevesoft.pat.Transformer"); -Clazz.overrideMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.ChangeRule (this); -}); -Clazz.overrideMethod (c$, "toString1", -function () { -return "${=" + this.name + "}"; -}); -Clazz.overrideMethod (c$, "apply", -function (sb, rr) { -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.ChangeRule", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.NewRule = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "ChangeRule", com.stevesoft.pat.SpecialRule); +Clazz.makeConstructor (c$, +function (c) { +Clazz.superConstructor (this, com.stevesoft.pat.ChangeRule, []); +this.NewRule = c.NewRule; +}, "com.stevesoft.pat.ChangeRule"); +Clazz.makeConstructor (c$, +function (nm, rr) { +Clazz.superConstructor (this, com.stevesoft.pat.ChangeRule, []); +this.name = nm; +this.NewRule = rr; +}, "~S,com.stevesoft.pat.Regex"); +Clazz.makeConstructor (c$, +function (nm, tr) { +Clazz.superConstructor (this, com.stevesoft.pat.ChangeRule, []); +this.name = nm; +this.NewRule = tr.rp; +}, "~S,com.stevesoft.pat.Transformer"); +Clazz.overrideMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.ChangeRule (this); +}); +Clazz.overrideMethod (c$, "toString1", +function () { +return "${=" + this.name + "}"; +}); +Clazz.overrideMethod (c$, "apply", +function (sb, rr) { +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +}); diff --git a/bin/com/stevesoft/pat/CodeRule.js b/bin/com/stevesoft/pat/CodeRule.js index 92c00f3..85a0917 100644 --- a/bin/com/stevesoft/pat/CodeRule.js +++ b/bin/com/stevesoft/pat/CodeRule.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.CodeRule", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.c = 'E'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "CodeRule", com.stevesoft.pat.SpecialRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.CodeRule, []); -}); -Clazz.makeConstructor (c$, -function (c) { -Clazz.superConstructor (this, com.stevesoft.pat.CodeRule, []); -this.c = c; -}, "~S"); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -sb.setMode (this.c); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return "\\" + this.c; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.CodeRule", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.c = 'E'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "CodeRule", com.stevesoft.pat.SpecialRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.CodeRule, []); +}); +Clazz.makeConstructor (c$, +function (c) { +Clazz.superConstructor (this, com.stevesoft.pat.CodeRule, []); +this.c = c; +}, "~S"); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +sb.setMode (this.c); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return "\\" + this.c; +}); +}); diff --git a/bin/com/stevesoft/pat/Ctrl.js b/bin/com/stevesoft/pat/Ctrl.js index 43250ce..9a42c67 100644 --- a/bin/com/stevesoft/pat/Ctrl.js +++ b/bin/com/stevesoft/pat/Ctrl.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -c$ = Clazz.declareType (com.stevesoft.pat, "Ctrl"); -Clazz.defineStatics (c$, -"cmap", Clazz.newCharArray (-1, [String.fromCharCode (64), 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', String.fromCharCode (91), String.fromCharCode (92), String.fromCharCode (93), String.fromCharCode (94), String.fromCharCode (95), String.fromCharCode (96), 'a', 'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', String.fromCharCode (123), String.fromCharCode (124), String.fromCharCode (125), String.fromCharCode (126), String.fromCharCode (127), String.fromCharCode (0), String.fromCharCode (1), String.fromCharCode (2), String.fromCharCode (3), String.fromCharCode (4), String.fromCharCode (5), String.fromCharCode (6), String.fromCharCode (7), String.fromCharCode (8), String.fromCharCode (9), String.fromCharCode (10), String.fromCharCode (11), String.fromCharCode (12), String.fromCharCode (13), String.fromCharCode (14), String.fromCharCode (15), String.fromCharCode (16), String.fromCharCode (17), String.fromCharCode (18), String.fromCharCode (19), String.fromCharCode (20), String.fromCharCode (21), String.fromCharCode (22), String.fromCharCode (23), String.fromCharCode (24), String.fromCharCode (25), String.fromCharCode (26), String.fromCharCode (27), String.fromCharCode (27), String.fromCharCode (29), String.fromCharCode (30), String.fromCharCode (31), String.fromCharCode (32), String.fromCharCode (1), String.fromCharCode (2), String.fromCharCode (3), String.fromCharCode (4), String.fromCharCode (5), String.fromCharCode (6), String.fromCharCode (7), String.fromCharCode (8), String.fromCharCode (9), String.fromCharCode (10), String.fromCharCode (11), String.fromCharCode (12), String.fromCharCode (13), String.fromCharCode (14), String.fromCharCode (15), String.fromCharCode (16), String.fromCharCode (17), String.fromCharCode (18), String.fromCharCode (19), String.fromCharCode (20), String.fromCharCode (21), String.fromCharCode (22), String.fromCharCode (23), String.fromCharCode (24), String.fromCharCode (25), String.fromCharCode (26), String.fromCharCode (59), String.fromCharCode (60), String.fromCharCode (61), String.fromCharCode (62), String.fromCharCode (63), String.fromCharCode (192), String.fromCharCode (193), String.fromCharCode (194), String.fromCharCode (195), String.fromCharCode (196), String.fromCharCode (197), String.fromCharCode (198), String.fromCharCode (199), String.fromCharCode (200), String.fromCharCode (201), String.fromCharCode (202), String.fromCharCode (203), String.fromCharCode (204), String.fromCharCode (205), String.fromCharCode (206), String.fromCharCode (207), String.fromCharCode (208), String.fromCharCode (209), String.fromCharCode (210), String.fromCharCode (211), String.fromCharCode (212), String.fromCharCode (213), String.fromCharCode (214), String.fromCharCode (215), String.fromCharCode (216), String.fromCharCode (217), String.fromCharCode (218), String.fromCharCode (219), String.fromCharCode (220), String.fromCharCode (221), String.fromCharCode (222), String.fromCharCode (223), String.fromCharCode (224), String.fromCharCode (225), String.fromCharCode (226), String.fromCharCode (227), String.fromCharCode (228), String.fromCharCode (229), String.fromCharCode (230), String.fromCharCode (231), String.fromCharCode (232), String.fromCharCode (233), String.fromCharCode (234), String.fromCharCode (235), String.fromCharCode (236), String.fromCharCode (237), String.fromCharCode (238), String.fromCharCode (239), String.fromCharCode (240), String.fromCharCode (241), String.fromCharCode (242), String.fromCharCode (243), String.fromCharCode (244), String.fromCharCode (245), String.fromCharCode (246), String.fromCharCode (247), String.fromCharCode (248), String.fromCharCode (249), String.fromCharCode (250), String.fromCharCode (251), String.fromCharCode (252), String.fromCharCode (253), String.fromCharCode (254), String.fromCharCode (255), String.fromCharCode (128), String.fromCharCode (129), String.fromCharCode (130), String.fromCharCode (131), String.fromCharCode (132), String.fromCharCode (133), String.fromCharCode (134), String.fromCharCode (135), String.fromCharCode (136), String.fromCharCode (137), String.fromCharCode (138), String.fromCharCode (139), String.fromCharCode (140), String.fromCharCode (141), String.fromCharCode (142), String.fromCharCode (143), String.fromCharCode (144), String.fromCharCode (145), String.fromCharCode (146), String.fromCharCode (147), String.fromCharCode (148), String.fromCharCode (149), String.fromCharCode (150), String.fromCharCode (151), String.fromCharCode (152), String.fromCharCode (153), String.fromCharCode (154), String.fromCharCode (155), String.fromCharCode (156), String.fromCharCode (157), String.fromCharCode (158), String.fromCharCode (159), String.fromCharCode (160), String.fromCharCode (161), String.fromCharCode (162), String.fromCharCode (163), String.fromCharCode (164), String.fromCharCode (165), String.fromCharCode (166), String.fromCharCode (167), String.fromCharCode (168), String.fromCharCode (169), String.fromCharCode (170), String.fromCharCode (171), String.fromCharCode (172), String.fromCharCode (173), String.fromCharCode (174), String.fromCharCode (175), String.fromCharCode (176), String.fromCharCode (177), String.fromCharCode (178), String.fromCharCode (179), String.fromCharCode (180), String.fromCharCode (181), String.fromCharCode (182), String.fromCharCode (183), String.fromCharCode (184), String.fromCharCode (185), String.fromCharCode (186), String.fromCharCode (187), String.fromCharCode (188), String.fromCharCode (189), String.fromCharCode (190), String.fromCharCode (191)])); +Clazz.declarePackage ("com.stevesoft.pat"); +c$ = Clazz.declareType (com.stevesoft.pat, "Ctrl"); +Clazz.defineStatics (c$, +"cmap", Clazz.newCharArray (-1, [String.fromCharCode (64), 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', String.fromCharCode (91), String.fromCharCode (92), String.fromCharCode (93), String.fromCharCode (94), String.fromCharCode (95), String.fromCharCode (96), 'a', 'a', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', String.fromCharCode (123), String.fromCharCode (124), String.fromCharCode (125), String.fromCharCode (126), String.fromCharCode (127), String.fromCharCode (0), String.fromCharCode (1), String.fromCharCode (2), String.fromCharCode (3), String.fromCharCode (4), String.fromCharCode (5), String.fromCharCode (6), String.fromCharCode (7), String.fromCharCode (8), String.fromCharCode (9), String.fromCharCode (10), String.fromCharCode (11), String.fromCharCode (12), String.fromCharCode (13), String.fromCharCode (14), String.fromCharCode (15), String.fromCharCode (16), String.fromCharCode (17), String.fromCharCode (18), String.fromCharCode (19), String.fromCharCode (20), String.fromCharCode (21), String.fromCharCode (22), String.fromCharCode (23), String.fromCharCode (24), String.fromCharCode (25), String.fromCharCode (26), String.fromCharCode (27), String.fromCharCode (27), String.fromCharCode (29), String.fromCharCode (30), String.fromCharCode (31), String.fromCharCode (32), String.fromCharCode (1), String.fromCharCode (2), String.fromCharCode (3), String.fromCharCode (4), String.fromCharCode (5), String.fromCharCode (6), String.fromCharCode (7), String.fromCharCode (8), String.fromCharCode (9), String.fromCharCode (10), String.fromCharCode (11), String.fromCharCode (12), String.fromCharCode (13), String.fromCharCode (14), String.fromCharCode (15), String.fromCharCode (16), String.fromCharCode (17), String.fromCharCode (18), String.fromCharCode (19), String.fromCharCode (20), String.fromCharCode (21), String.fromCharCode (22), String.fromCharCode (23), String.fromCharCode (24), String.fromCharCode (25), String.fromCharCode (26), String.fromCharCode (59), String.fromCharCode (60), String.fromCharCode (61), String.fromCharCode (62), String.fromCharCode (63), String.fromCharCode (192), String.fromCharCode (193), String.fromCharCode (194), String.fromCharCode (195), String.fromCharCode (196), String.fromCharCode (197), String.fromCharCode (198), String.fromCharCode (199), String.fromCharCode (200), String.fromCharCode (201), String.fromCharCode (202), String.fromCharCode (203), String.fromCharCode (204), String.fromCharCode (205), String.fromCharCode (206), String.fromCharCode (207), String.fromCharCode (208), String.fromCharCode (209), String.fromCharCode (210), String.fromCharCode (211), String.fromCharCode (212), String.fromCharCode (213), String.fromCharCode (214), String.fromCharCode (215), String.fromCharCode (216), String.fromCharCode (217), String.fromCharCode (218), String.fromCharCode (219), String.fromCharCode (220), String.fromCharCode (221), String.fromCharCode (222), String.fromCharCode (223), String.fromCharCode (224), String.fromCharCode (225), String.fromCharCode (226), String.fromCharCode (227), String.fromCharCode (228), String.fromCharCode (229), String.fromCharCode (230), String.fromCharCode (231), String.fromCharCode (232), String.fromCharCode (233), String.fromCharCode (234), String.fromCharCode (235), String.fromCharCode (236), String.fromCharCode (237), String.fromCharCode (238), String.fromCharCode (239), String.fromCharCode (240), String.fromCharCode (241), String.fromCharCode (242), String.fromCharCode (243), String.fromCharCode (244), String.fromCharCode (245), String.fromCharCode (246), String.fromCharCode (247), String.fromCharCode (248), String.fromCharCode (249), String.fromCharCode (250), String.fromCharCode (251), String.fromCharCode (252), String.fromCharCode (253), String.fromCharCode (254), String.fromCharCode (255), String.fromCharCode (128), String.fromCharCode (129), String.fromCharCode (130), String.fromCharCode (131), String.fromCharCode (132), String.fromCharCode (133), String.fromCharCode (134), String.fromCharCode (135), String.fromCharCode (136), String.fromCharCode (137), String.fromCharCode (138), String.fromCharCode (139), String.fromCharCode (140), String.fromCharCode (141), String.fromCharCode (142), String.fromCharCode (143), String.fromCharCode (144), String.fromCharCode (145), String.fromCharCode (146), String.fromCharCode (147), String.fromCharCode (148), String.fromCharCode (149), String.fromCharCode (150), String.fromCharCode (151), String.fromCharCode (152), String.fromCharCode (153), String.fromCharCode (154), String.fromCharCode (155), String.fromCharCode (156), String.fromCharCode (157), String.fromCharCode (158), String.fromCharCode (159), String.fromCharCode (160), String.fromCharCode (161), String.fromCharCode (162), String.fromCharCode (163), String.fromCharCode (164), String.fromCharCode (165), String.fromCharCode (166), String.fromCharCode (167), String.fromCharCode (168), String.fromCharCode (169), String.fromCharCode (170), String.fromCharCode (171), String.fromCharCode (172), String.fromCharCode (173), String.fromCharCode (174), String.fromCharCode (175), String.fromCharCode (176), String.fromCharCode (177), String.fromCharCode (178), String.fromCharCode (179), String.fromCharCode (180), String.fromCharCode (181), String.fromCharCode (182), String.fromCharCode (183), String.fromCharCode (184), String.fromCharCode (185), String.fromCharCode (186), String.fromCharCode (187), String.fromCharCode (188), String.fromCharCode (189), String.fromCharCode (190), String.fromCharCode (191)])); diff --git a/bin/com/stevesoft/pat/Custom.js b/bin/com/stevesoft/pat/Custom.js index 44fa656..4e0fa72 100644 --- a/bin/com/stevesoft/pat/Custom.js +++ b/bin/com/stevesoft/pat/Custom.js @@ -1,41 +1,41 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.Custom", ["com.stevesoft.pat.Regex"], function () { -c$ = Clazz.decorateAsClass (function () { -this.select = null; -this.v = null; -this.start = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Custom", com.stevesoft.pat.PatternSub); -Clazz.makeConstructor (c$, -function (s) { -Clazz.superConstructor (this, com.stevesoft.pat.Custom, []); -this.select = s; -this.v = com.stevesoft.pat.Regex.validators.get (s); -}, "~S"); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -this.start = pos; -return this.sub.matchInternal (pos, pt); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -var a = this.v.argsave == null ? "" : ":" + this.v.argsave; -return "(??" + this.select + a + ")" + this.nextString (); -}); -Clazz.overrideMethod (c$, "minChars", -function () { -return this.v.minChars (); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return this.v.maxChars (); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -var c = new com.stevesoft.pat.Custom (this.select); -h.put (c, c); -h.put (this, c); -c.sub = this.sub.clone (h); -return c; -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.Custom", ["com.stevesoft.pat.Regex"], function () { +c$ = Clazz.decorateAsClass (function () { +this.select = null; +this.v = null; +this.start = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Custom", com.stevesoft.pat.PatternSub); +Clazz.makeConstructor (c$, +function (s) { +Clazz.superConstructor (this, com.stevesoft.pat.Custom, []); +this.select = s; +this.v = com.stevesoft.pat.Regex.validators.get (s); +}, "~S"); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +this.start = pos; +return this.sub.matchInternal (pos, pt); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +var a = this.v.argsave == null ? "" : ":" + this.v.argsave; +return "(??" + this.select + a + ")" + this.nextString (); +}); +Clazz.overrideMethod (c$, "minChars", +function () { +return this.v.minChars (); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return this.v.maxChars (); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +var c = new com.stevesoft.pat.Custom (this.select); +h.put (c, c); +h.put (this, c); +c.sub = this.sub.clone (h); +return c; +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/CustomEndpoint.js b/bin/com/stevesoft/pat/CustomEndpoint.js index 800608f..f5cb0ed 100644 --- a/bin/com/stevesoft/pat/CustomEndpoint.js +++ b/bin/com/stevesoft/pat/CustomEndpoint.js @@ -1,27 +1,27 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.CustomEndpoint", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.c = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "CustomEndpoint", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (cm) { -Clazz.superConstructor (this, com.stevesoft.pat.CustomEndpoint, []); -this.c = cm; -}, "com.stevesoft.pat.Custom"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -var npos = this.c.v.validate (pt.src, this.c.start, pos); -if (npos >= 0) { -return this.nextMatch (npos, pt); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -return ""; -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.CustomEndpoint (this.c.clone (h)); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.CustomEndpoint", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.c = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "CustomEndpoint", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (cm) { +Clazz.superConstructor (this, com.stevesoft.pat.CustomEndpoint, []); +this.c = cm; +}, "com.stevesoft.pat.Custom"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +var npos = this.c.v.validate (pt.src, this.c.start, pos); +if (npos >= 0) { +return this.nextMatch (npos, pt); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +return ""; +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.CustomEndpoint (this.c.clone (h)); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/DirFileRegex.js b/bin/com/stevesoft/pat/DirFileRegex.js index b078e11..0a2470f 100644 --- a/bin/com/stevesoft/pat/DirFileRegex.js +++ b/bin/com/stevesoft/pat/DirFileRegex.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.FileRegex"], "com.stevesoft.pat.DirFileRegex", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "DirFileRegex", com.stevesoft.pat.FileRegex); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.FileRegex"], "com.stevesoft.pat.DirFileRegex", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "DirFileRegex", com.stevesoft.pat.FileRegex); +}); diff --git a/bin/com/stevesoft/pat/DotMulti.js b/bin/com/stevesoft/pat/DotMulti.js index 172397b..3584af1 100644 --- a/bin/com/stevesoft/pat/DotMulti.js +++ b/bin/com/stevesoft/pat/DotMulti.js @@ -1,129 +1,129 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.DotMulti", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.fewestMatches = null; -this.mostMatches = null; -this.matchFewest = false; -this.src = null; -this.srclength = 0; -this.dotDoesntMatchCR = true; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "DotMulti", com.stevesoft.pat.PatternSub); -Clazz.overrideMethod (c$, "minChars", -function () { -return this.fewestMatches; -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return this.mostMatches; -}); -Clazz.makeConstructor (c$, -function (a, b) { -Clazz.superConstructor (this, com.stevesoft.pat.DotMulti, []); -this.fewestMatches = a; -this.mostMatches = b; -}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt"); -Clazz.overrideMethod (c$, "toString", -function () { -return ".{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= dot multi)" + this.nextString (); -}); -Clazz.defineMethod (c$, "submatchInternal", -function (pos, pt) { -if (pos < this.srclength) { -if (this.dotDoesntMatchCR) { -if (this.src.charAt (pos) != '\n') { -return 1 + pos; -}} else { -return 1 + pos; -}}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -var m = -1; -var i = pos; -this.src = pt.src; -this.srclength = this.src.length (); -this.dotDoesntMatchCR = pt.dotDoesntMatchCR; -if (this.matchFewest) { -var nMatches = 0; -while (this.fewestMatches.intValue () > nMatches) { -i = this.submatchInternal (i, pt); -if (i < 0) { -return -1; -}nMatches++; -} -if (i < 0) { -return -1; -}var ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}if (!this.mostMatches.finite ()) { -while (i >= 0) { -i = this.submatchInternal (i, pt); -if (i < 0) { -return -1; -}ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}} -} else { -while (i > 0) { -i = this.submatchInternal (i, pt); -if (i < 0) { -return -1; -}nMatches++; -if (nMatches > this.mostMatches.intValue ()) { -return -1; -}ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}} -}return -1; -}var nMatches = 0; -while (this.fewestMatches.intValue () > nMatches) { -i = this.submatchInternal (i, pt); -if (i >= 0) { -nMatches++; -} else { -return -1; -}} -m = i; -if (this.mostMatches.finite ()) { -while (nMatches < this.mostMatches.intValue ()) { -i = this.submatchInternal (i, pt); -if (i >= 0) { -m = i; -nMatches++; -} else { -break; -}} -} else { -while (true) { -i = this.submatchInternal (i, pt); -if (i >= 0) { -m = i; -nMatches++; -} else { -break; -}} -}while (m >= pos) { -var r = this.nextMatch (m, pt); -if (r >= 0) { -return r; -}m -= 1; -nMatches--; -if (nMatches < this.fewestMatches.intValue ()) { -return -1; -}} -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -var dm = new com.stevesoft.pat.DotMulti (this.fewestMatches, this.mostMatches); -dm.matchFewest = this.matchFewest; -return dm; -}, "java.util.Hashtable"); -Clazz.defineStatics (c$, -"step", 1, -"idcount", 1); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.DotMulti", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.fewestMatches = null; +this.mostMatches = null; +this.matchFewest = false; +this.src = null; +this.srclength = 0; +this.dotDoesntMatchCR = true; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "DotMulti", com.stevesoft.pat.PatternSub); +Clazz.overrideMethod (c$, "minChars", +function () { +return this.fewestMatches; +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return this.mostMatches; +}); +Clazz.makeConstructor (c$, +function (a, b) { +Clazz.superConstructor (this, com.stevesoft.pat.DotMulti, []); +this.fewestMatches = a; +this.mostMatches = b; +}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt"); +Clazz.overrideMethod (c$, "toString", +function () { +return ".{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= dot multi)" + this.nextString (); +}); +Clazz.defineMethod (c$, "submatchInternal", +function (pos, pt) { +if (pos < this.srclength) { +if (this.dotDoesntMatchCR) { +if (this.src.charAt (pos) != '\n') { +return 1 + pos; +}} else { +return 1 + pos; +}}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +var m = -1; +var i = pos; +this.src = pt.src; +this.srclength = this.src.length (); +this.dotDoesntMatchCR = pt.dotDoesntMatchCR; +if (this.matchFewest) { +var nMatches = 0; +while (this.fewestMatches.intValue () > nMatches) { +i = this.submatchInternal (i, pt); +if (i < 0) { +return -1; +}nMatches++; +} +if (i < 0) { +return -1; +}var ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}if (!this.mostMatches.finite ()) { +while (i >= 0) { +i = this.submatchInternal (i, pt); +if (i < 0) { +return -1; +}ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}} +} else { +while (i > 0) { +i = this.submatchInternal (i, pt); +if (i < 0) { +return -1; +}nMatches++; +if (nMatches > this.mostMatches.intValue ()) { +return -1; +}ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}} +}return -1; +}var nMatches = 0; +while (this.fewestMatches.intValue () > nMatches) { +i = this.submatchInternal (i, pt); +if (i >= 0) { +nMatches++; +} else { +return -1; +}} +m = i; +if (this.mostMatches.finite ()) { +while (nMatches < this.mostMatches.intValue ()) { +i = this.submatchInternal (i, pt); +if (i >= 0) { +m = i; +nMatches++; +} else { +break; +}} +} else { +while (true) { +i = this.submatchInternal (i, pt); +if (i >= 0) { +m = i; +nMatches++; +} else { +break; +}} +}while (m >= pos) { +var r = this.nextMatch (m, pt); +if (r >= 0) { +return r; +}m -= 1; +nMatches--; +if (nMatches < this.fewestMatches.intValue ()) { +return -1; +}} +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +var dm = new com.stevesoft.pat.DotMulti (this.fewestMatches, this.mostMatches); +dm.matchFewest = this.matchFewest; +return dm; +}, "java.util.Hashtable"); +Clazz.defineStatics (c$, +"step", 1, +"idcount", 1); +}); diff --git a/bin/com/stevesoft/pat/End.js b/bin/com/stevesoft/pat/End.js index 3df399f..b332682 100644 --- a/bin/com/stevesoft/pat/End.js +++ b/bin/com/stevesoft/pat/End.js @@ -1,38 +1,38 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.End", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.retIsEnd = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "End", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (b) { -Clazz.superConstructor (this, com.stevesoft.pat.End, []); -this.retIsEnd = b; -}, "~B"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (this.retIsEnd && pt.mFlag && pos < pt.src.length ()) { -if (pt.src.charAt (pos) == '\n') { -return this.nextMatch (pos, pt); -}}if (pt.src.length () == pos) { -return this.nextMatch (pos, pt); -} else if (pos < pt.src.length ()) { -pt.src.charAt (pos); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -if (this.retIsEnd) { -return "$"; -} else { -return "\\Z"; -}}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.End (this.retIsEnd); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.End", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.retIsEnd = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "End", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (b) { +Clazz.superConstructor (this, com.stevesoft.pat.End, []); +this.retIsEnd = b; +}, "~B"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (this.retIsEnd && pt.mFlag && pos < pt.src.length ()) { +if (pt.src.charAt (pos) == '\n') { +return this.nextMatch (pos, pt); +}}if (pt.src.length () == pos) { +return this.nextMatch (pos, pt); +} else if (pos < pt.src.length ()) { +pt.src.charAt (pos); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +if (this.retIsEnd) { +return "$"; +} else { +return "\\Z"; +}}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.End (this.retIsEnd); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/FastBracket.js b/bin/com/stevesoft/pat/FastBracket.js index d26c009..0e7d38a 100644 --- a/bin/com/stevesoft/pat/FastBracket.js +++ b/bin/com/stevesoft/pat/FastBracket.js @@ -1,156 +1,156 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.$min = 0; -this.$max = 0; -this.bs = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket); -c$.process = Clazz.defineMethod (c$, "process", -function (b, ignc) { -var v = b.v; -b.pv = null; -try { -var nv = v; -if (ignc) { -nv = new java.util.Vector (); -for (var i = 0; i < v.size (); i++) { -var p = v.elementAt (i); -nv.addElement (p); -if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { -var oc = p; -nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc)); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { -var ra = p; -nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi)); -}} -}v = nv; -for (var i = 0; i < v.size () - 1; i++) { -for (var j = 0; j < v.size () - 1; j++) { -var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j)); -var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1)); -if (c2 < c1) { -var o = v.elementAt (j); -v.setElementAt (v.elementAt (j + 1), j); -v.setElementAt (o, j + 1); -}} -} -nv = new java.util.Vector (); -var p = v.elementAt (0); -nv.addElement (p); -for (var i = 1; i < v.size (); i++) { -if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) { -var p2 = v.elementAt (i); -var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2)); -var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2)); -nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1); -} else { -p = v.elementAt (i); -nv.addElement (p); -}} -b.v = v = nv; -} catch (e) { -if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) { -e.printStackTrace (); -} else { -throw e; -} -} -var negv = com.stevesoft.pat.FastBracket.neg (v); -if (v.size () == 1) { -return b; -}if (negv.size () == 1) { -b.v = negv; -b.neg = !b.neg; -return b; -}var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg); -if (fb == null) { -fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg); -}if (fb != null) { -fb.parent = b.parent; -fb.next = b.next; -return fb; -}return b; -}, "com.stevesoft.pat.Bracket,~B"); -c$.newbrack = Clazz.defineMethod (c$, "newbrack", -function (v, neg) { -var fb = new com.stevesoft.pat.FastBracket (neg); -fb.v = v; -if (v.size () == 0) { -return null; -}fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); -fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0); -if (fb.$max - fb.$min <= 256) { -fb.bs = new java.util.BitSet (fb.$max - fb.$min + 1); -for (var i = 0; i < v.size (); i++) { -var o = v.elementAt (i); -var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min; -var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min; -for (var j = min0; j <= max0; j++) { -fb.bs.set (j); -} -} -return fb; -}return null; -}, "java.util.Vector,~B"); -c$.neg = Clazz.defineMethod (c$, "neg", -function (v) { -try { -var nv = new java.util.Vector (); -if (v.size () == 0) { -nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535))); -return nv; -}var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); -if (p0 != 0) { -nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1))); -}for (var i = 0; i < v.size () - 1; i++) { -var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1; -var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1; -nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi))); -} -var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0); -if (pN != 65535) { -nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535))); -}return nv; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Vector"); -c$.mkelem = Clazz.defineMethod (c$, "mkelem", -function (lo, hi) { -return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi)); -}, "~S,~S"); -c$.min = Clazz.defineMethod (c$, "min", -function (a, b) { -return a < b ? a : b; -}, "~S,~S"); -c$.max = Clazz.defineMethod (c$, "max", -function (a, b) { -return a > b ? a : b; -}, "~S,~S"); -c$.getl = Clazz.defineMethod (c$, "getl", -function (o) { -var p = o; -if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { -return (p).lo; -}return (p).c; -}, "~O"); -c$.geth = Clazz.defineMethod (c$, "geth", -function (o) { -var p = o; -if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { -return (p).hi; -}return (p).c; -}, "~O"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (pos >= pt.src.length () || this.Masked (pos, pt)) { -return -1; -}var c = pt.src.charAt (pos); -return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1; -}, "~N,com.stevesoft.pat.Pthings"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.$min = 0; +this.$max = 0; +this.bs = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket); +c$.process = Clazz.defineMethod (c$, "process", +function (b, ignc) { +var v = b.v; +b.pv = null; +try { +var nv = v; +if (ignc) { +nv = new java.util.Vector (); +for (var i = 0; i < v.size (); i++) { +var p = v.elementAt (i); +nv.addElement (p); +if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { +var oc = p; +nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc)); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { +var ra = p; +nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi)); +}} +}v = nv; +for (var i = 0; i < v.size () - 1; i++) { +for (var j = 0; j < v.size () - 1; j++) { +var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j)); +var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1)); +if (c2 < c1) { +var o = v.elementAt (j); +v.setElementAt (v.elementAt (j + 1), j); +v.setElementAt (o, j + 1); +}} +} +nv = new java.util.Vector (); +var p = v.elementAt (0); +nv.addElement (p); +for (var i = 1; i < v.size (); i++) { +if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) { +var p2 = v.elementAt (i); +var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2)); +var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2)); +nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1); +} else { +p = v.elementAt (i); +nv.addElement (p); +}} +b.v = v = nv; +} catch (e) { +if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) { +e.printStackTrace (); +} else { +throw e; +} +} +var negv = com.stevesoft.pat.FastBracket.neg (v); +if (v.size () == 1) { +return b; +}if (negv.size () == 1) { +b.v = negv; +b.neg = !b.neg; +return b; +}var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg); +if (fb == null) { +fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg); +}if (fb != null) { +fb.parent = b.parent; +fb.next = b.next; +return fb; +}return b; +}, "com.stevesoft.pat.Bracket,~B"); +c$.newbrack = Clazz.defineMethod (c$, "newbrack", +function (v, neg) { +var fb = new com.stevesoft.pat.FastBracket (neg); +fb.v = v; +if (v.size () == 0) { +return null; +}fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); +fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0); +if (fb.$max - fb.$min <= 256) { +fb.bs = new java.util.BitSet (fb.$max - fb.$min + 1); +for (var i = 0; i < v.size (); i++) { +var o = v.elementAt (i); +var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min; +var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min; +for (var j = min0; j <= max0; j++) { +fb.bs.set (j); +} +} +return fb; +}return null; +}, "java.util.Vector,~B"); +c$.neg = Clazz.defineMethod (c$, "neg", +function (v) { +try { +var nv = new java.util.Vector (); +if (v.size () == 0) { +nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535))); +return nv; +}var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0); +if (p0 != 0) { +nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1))); +}for (var i = 0; i < v.size () - 1; i++) { +var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1; +var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1; +nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi))); +} +var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0); +if (pN != 65535) { +nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535))); +}return nv; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Vector"); +c$.mkelem = Clazz.defineMethod (c$, "mkelem", +function (lo, hi) { +return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi)); +}, "~S,~S"); +c$.min = Clazz.defineMethod (c$, "min", +function (a, b) { +return a < b ? a : b; +}, "~S,~S"); +c$.max = Clazz.defineMethod (c$, "max", +function (a, b) { +return a > b ? a : b; +}, "~S,~S"); +c$.getl = Clazz.defineMethod (c$, "getl", +function (o) { +var p = o; +if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { +return (p).lo; +}return (p).c; +}, "~O"); +c$.geth = Clazz.defineMethod (c$, "geth", +function (o) { +var p = o; +if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) { +return (p).hi; +}return (p).c; +}, "~O"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (pos >= pt.src.length () || this.Masked (pos, pt)) { +return -1; +}var c = pt.src.charAt (pos); +return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1; +}, "~N,com.stevesoft.pat.Pthings"); +}); diff --git a/bin/com/stevesoft/pat/FastMulti.js b/bin/com/stevesoft/pat/FastMulti.js index 16ffec1..898aa9e 100644 --- a/bin/com/stevesoft/pat/FastMulti.js +++ b/bin/com/stevesoft/pat/FastMulti.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.FastMulti", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fewestMatches = null; -this.mostMatches = null; -this.matchFewest = false; -this.step = -1; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "FastMulti", com.stevesoft.pat.PatternSub); -Clazz.overrideMethod (c$, "minChars", -function () { -return this.sub.countMinChars ().mul (this.fewestMatches); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return this.sub.countMaxChars ().mul (this.mostMatches); -}); -Clazz.makeConstructor (c$, -function (a, b, p) { -Clazz.superConstructor (this, com.stevesoft.pat.FastMulti, []); -if (p == null) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Null length pattern followed by *, +, or other Multi."); -}this.fewestMatches = a; -this.mostMatches = b; -this.sub = p; -this.step = p.countMinChars ().intValue (); -this.sub.setParent (null); -}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "toString", -function () { -return this.sub.toString () + "{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= fast multi)" + this.nextString (); -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -var m = -1; -var i = pos; -var endstr = pt.src.length () - this.step; -var matches = new com.stevesoft.pat.patInt (0); -if (this.matchFewest) { -if (this.fewestMatches.lessEq (matches)) { -var ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}}while (i >= 0 && i <= endstr) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -matches.inc (); -if (this.fewestMatches.lessEq (matches)) { -var ii = this.nextMatch (i, pt); -if (ii >= 0) { -return ii; -}}if (matches.equals (this.mostMatches)) { -return -1; -}}} -return -1; -}var nMatches = 0; -while (this.fewestMatches.intValue () > nMatches) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -nMatches++; -} else { -return -1; -}} -m = i; -if (this.mostMatches.finite ()) { -while (nMatches < this.mostMatches.intValue ()) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -m = i; -nMatches++; -} else { -break; -}} -} else { -while (true) { -i = this.sub.matchInternal (i, pt); -if (i >= 0) { -m = i; -nMatches++; -} else { -break; -}} -}while (m >= pos) { -var r = this.nextMatch (m, pt); -if (r >= 0) { -return r; -}m -= this.step; -nMatches--; -if (nMatches < this.fewestMatches.intValue ()) { -return -1; -}} -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -try { -var fm = new com.stevesoft.pat.FastMulti (this.fewestMatches, this.mostMatches, this.sub.clone (h)); -fm.matchFewest = this.matchFewest; -return fm; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.FastMulti", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fewestMatches = null; +this.mostMatches = null; +this.matchFewest = false; +this.step = -1; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "FastMulti", com.stevesoft.pat.PatternSub); +Clazz.overrideMethod (c$, "minChars", +function () { +return this.sub.countMinChars ().mul (this.fewestMatches); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return this.sub.countMaxChars ().mul (this.mostMatches); +}); +Clazz.makeConstructor (c$, +function (a, b, p) { +Clazz.superConstructor (this, com.stevesoft.pat.FastMulti, []); +if (p == null) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Null length pattern followed by *, +, or other Multi."); +}this.fewestMatches = a; +this.mostMatches = b; +this.sub = p; +this.step = p.countMinChars ().intValue (); +this.sub.setParent (null); +}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "toString", +function () { +return this.sub.toString () + "{" + this.fewestMatches + "," + this.mostMatches + "}" + (this.matchFewest ? "?" : "") + "(?# <= fast multi)" + this.nextString (); +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +var m = -1; +var i = pos; +var endstr = pt.src.length () - this.step; +var matches = new com.stevesoft.pat.patInt (0); +if (this.matchFewest) { +if (this.fewestMatches.lessEq (matches)) { +var ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}}while (i >= 0 && i <= endstr) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +matches.inc (); +if (this.fewestMatches.lessEq (matches)) { +var ii = this.nextMatch (i, pt); +if (ii >= 0) { +return ii; +}}if (matches.equals (this.mostMatches)) { +return -1; +}}} +return -1; +}var nMatches = 0; +while (this.fewestMatches.intValue () > nMatches) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +nMatches++; +} else { +return -1; +}} +m = i; +if (this.mostMatches.finite ()) { +while (nMatches < this.mostMatches.intValue ()) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +m = i; +nMatches++; +} else { +break; +}} +} else { +while (true) { +i = this.sub.matchInternal (i, pt); +if (i >= 0) { +m = i; +nMatches++; +} else { +break; +}} +}while (m >= pos) { +var r = this.nextMatch (m, pt); +if (r >= 0) { +return r; +}m -= this.step; +nMatches--; +if (nMatches < this.fewestMatches.intValue ()) { +return -1; +}} +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +try { +var fm = new com.stevesoft.pat.FastMulti (this.fewestMatches, this.mostMatches, this.sub.clone (h)); +fm.matchFewest = this.matchFewest; +return fm; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/FileRegex.js b/bin/com/stevesoft/pat/FileRegex.js index 8327c7c..ca23839 100644 --- a/bin/com/stevesoft/pat/FileRegex.js +++ b/bin/com/stevesoft/pat/FileRegex.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Regex"], "com.stevesoft.pat.FileRegex", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "FileRegex", com.stevesoft.pat.Regex); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Regex"], "com.stevesoft.pat.FileRegex", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "FileRegex", com.stevesoft.pat.Regex); +}); diff --git a/bin/com/stevesoft/pat/Group.js b/bin/com/stevesoft/pat/Group.js index 89fdd10..a9ebd1b 100644 --- a/bin/com/stevesoft/pat/Group.js +++ b/bin/com/stevesoft/pat/Group.js @@ -1,48 +1,48 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Group", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.op = '\0'; -this.cl = '\0'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Group", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (opi, cli) { -Clazz.superConstructor (this, com.stevesoft.pat.Group, []); -this.op = opi; -this.cl = cli; -}, "~S,~S"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -var i; -var count = 1; -if (pos < pt.src.length ()) { -if (!this.Masked (pos, pt) && pt.src.charAt (pos) != this.op) { -return -1; -}}for (i = pos + 1; i < pt.src.length (); i++) { -var c = pt.src.charAt (i); -var b = !this.Masked (i, pt); -if (b && c == '\\') { -i++; -} else { -if (b && c == this.cl) { -count--; -}if (count == 0) { -return this.nextMatch (i + 1, pt); -}if (b && c == this.op) { -count++; -}}} -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(?@" + this.op + this.cl + ")" + this.nextString (); -}); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (2); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.Group (this.op, this.cl); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Group", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.op = '\0'; +this.cl = '\0'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Group", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (opi, cli) { +Clazz.superConstructor (this, com.stevesoft.pat.Group, []); +this.op = opi; +this.cl = cli; +}, "~S,~S"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +var i; +var count = 1; +if (pos < pt.src.length ()) { +if (!this.Masked (pos, pt) && pt.src.charAt (pos) != this.op) { +return -1; +}}for (i = pos + 1; i < pt.src.length (); i++) { +var c = pt.src.charAt (i); +var b = !this.Masked (i, pt); +if (b && c == '\\') { +i++; +} else { +if (b && c == this.cl) { +count--; +}if (count == 0) { +return this.nextMatch (i + 1, pt); +}if (b && c == this.op) { +count++; +}}} +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(?@" + this.op + this.cl + ")" + this.nextString (); +}); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (2); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.Group (this.op, this.cl); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/LeftRule.js b/bin/com/stevesoft/pat/LeftRule.js index df5c04a..f70f50c 100644 --- a/bin/com/stevesoft/pat/LeftRule.js +++ b/bin/com/stevesoft/pat/LeftRule.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.LeftRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "LeftRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.LeftRule, []); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -sb.append (res.left ()); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return "$`"; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.LeftRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "LeftRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.LeftRule, []); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +sb.append (res.left ()); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return "$`"; +}); +}); diff --git a/bin/com/stevesoft/pat/MessageManager.js b/bin/com/stevesoft/pat/MessageManager.js index 23502c3..801e5de 100644 --- a/bin/com/stevesoft/pat/MessageManager.js +++ b/bin/com/stevesoft/pat/MessageManager.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -c$ = Clazz.declareType (com.stevesoft.pat, "MessageManager"); -c$.getString = Clazz.defineMethod (c$, "getString", -function (string) { -return string; -}, "~S"); -c$.formatMessage = Clazz.defineMethod (c$, "formatMessage", -function (s, fields) { -for (var i = 0; i < fields.length; i++) s += " " + fields[i]; - -return s; -}, "~S,~A"); +Clazz.declarePackage ("com.stevesoft.pat"); +c$ = Clazz.declareType (com.stevesoft.pat, "MessageManager"); +c$.getString = Clazz.defineMethod (c$, "getString", +function (string) { +return string; +}, "~S"); +c$.formatMessage = Clazz.defineMethod (c$, "formatMessage", +function (s, fields) { +for (var i = 0; i < fields.length; i++) s += " " + fields[i]; + +return s; +}, "~S,~A"); diff --git a/bin/com/stevesoft/pat/Multi.js b/bin/com/stevesoft/pat/Multi.js index e759c95..e98b4ff 100644 --- a/bin/com/stevesoft/pat/Multi.js +++ b/bin/com/stevesoft/pat/Multi.js @@ -1,62 +1,62 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.Multi", ["com.stevesoft.pat.Multi_stage2"], function () { -c$ = Clazz.decorateAsClass (function () { -this.a = null; -this.b = null; -this.p = null; -this.st2 = null; -this.matchFewest = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Multi", com.stevesoft.pat.PatternSub); -Clazz.overrideMethod (c$, "minChars", -function () { -return this.a.mul (this.p.countMinChars ()); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return this.b.mul (this.p.countMaxChars ()); -}); -Clazz.makeConstructor (c$, -function (a, b, p) { -Clazz.superConstructor (this, com.stevesoft.pat.Multi, []); -this.a = a; -this.b = b; -this.p = p; -this.st2 = new com.stevesoft.pat.Multi_stage2 (a, b, p); -this.st2.parent = this; -this.sub = this.st2.sub; -}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); -Clazz.overrideMethod (c$, "toString", -function () { -this.st2.matchFewest = this.matchFewest; -return this.st2.toString (); -}); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -try { -this.st2 = new com.stevesoft.pat.Multi_stage2 (this.a, this.b, this.p); -} catch (r__) { -if (Clazz.exceptionOf (r__, com.stevesoft.pat.RegSyntax)) { -} else { -throw r__; -} -} -this.st2.matchFewest = this.matchFewest; -this.st2.parent = this; -return this.st2.matchInternal (pos, pt); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -try { -var m = new com.stevesoft.pat.Multi (this.a, this.b, (this.p).clone (h)); -m.matchFewest = this.matchFewest; -return m; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.Multi", ["com.stevesoft.pat.Multi_stage2"], function () { +c$ = Clazz.decorateAsClass (function () { +this.a = null; +this.b = null; +this.p = null; +this.st2 = null; +this.matchFewest = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Multi", com.stevesoft.pat.PatternSub); +Clazz.overrideMethod (c$, "minChars", +function () { +return this.a.mul (this.p.countMinChars ()); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return this.b.mul (this.p.countMaxChars ()); +}); +Clazz.makeConstructor (c$, +function (a, b, p) { +Clazz.superConstructor (this, com.stevesoft.pat.Multi, []); +this.a = a; +this.b = b; +this.p = p; +this.st2 = new com.stevesoft.pat.Multi_stage2 (a, b, p); +this.st2.parent = this; +this.sub = this.st2.sub; +}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); +Clazz.overrideMethod (c$, "toString", +function () { +this.st2.matchFewest = this.matchFewest; +return this.st2.toString (); +}); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +try { +this.st2 = new com.stevesoft.pat.Multi_stage2 (this.a, this.b, this.p); +} catch (r__) { +if (Clazz.exceptionOf (r__, com.stevesoft.pat.RegSyntax)) { +} else { +throw r__; +} +} +this.st2.matchFewest = this.matchFewest; +this.st2.parent = this; +return this.st2.matchInternal (pos, pt); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +try { +var m = new com.stevesoft.pat.Multi (this.a, this.b, (this.p).clone (h)); +m.matchFewest = this.matchFewest; +return m; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/MultiMin.js b/bin/com/stevesoft/pat/MultiMin.js index e749758..f536031 100644 --- a/bin/com/stevesoft/pat/MultiMin.js +++ b/bin/com/stevesoft/pat/MultiMin.js @@ -1,9 +1,9 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Multi"], "com.stevesoft.pat.MultiMin", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "MultiMin", com.stevesoft.pat.Multi); -Clazz.makeConstructor (c$, -function (i1, i2, p) { -Clazz.superConstructor (this, com.stevesoft.pat.MultiMin, [i1, i2, p]); -this.matchFewest = true; -}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Multi"], "com.stevesoft.pat.MultiMin", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "MultiMin", com.stevesoft.pat.Multi); +Clazz.makeConstructor (c$, +function (i1, i2, p) { +Clazz.superConstructor (this, com.stevesoft.pat.MultiMin, [i1, i2, p]); +this.matchFewest = true; +}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); +}); diff --git a/bin/com/stevesoft/pat/Multi_stage2.js b/bin/com/stevesoft/pat/Multi_stage2.js index 6d4f8fc..1d291ab 100644 --- a/bin/com/stevesoft/pat/Multi_stage2.js +++ b/bin/com/stevesoft/pat/Multi_stage2.js @@ -1,95 +1,95 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.Multi_stage2", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.nextRet = null; -this.count = null; -this.matchMin = null; -this.matchMax = null; -this.matchFewest = false; -this.pos_old = -1; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Multi_stage2", com.stevesoft.pat.PatternSub); -Clazz.defineMethod (c$, "toString", -function () { -var ret = ""; -ret += this.sub.toString (); -ret += "{" + this.matchMin + "," + this.matchMax + "}"; -if (this.matchFewest) { -ret += "?"; -}ret += this.parent.nextString (); -return ret; -}); -Clazz.makeConstructor (c$, -function (a, b, p) { -Clazz.superConstructor (this, com.stevesoft.pat.Multi_stage2, []); -if (p == null) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Multiple match of Null pattern requested."); -}this.sub = p; -this.nextRet = this; -this.sub.setParent (this); -this.matchMin = a; -this.matchMax = b; -this.count = new com.stevesoft.pat.patInt (0); -if (!a.lessEq (b)) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Bad Multi Args: " + a + ">" + b); -}var i = new com.stevesoft.pat.patInt (-1); -if (a.lessEq (i)) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Bad Multi Args: " + a + "< 0"); -}}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "getNext", -function () { -return this.nextRet; -}); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -this.sub.setParent (this); -var canUse = -1; -if (this.pos_old >= 0 && pos == this.pos_old) { -return -1; -}this.pos_old = pos; -if (this.matchMin.lessEq (this.count)) { -canUse = pos; -}if (!this.count.lessEq (this.matchMax) || pos > pt.src.length ()) { -return -1; -}if ((this.matchFewest || this.count.equals (this.matchMax)) && canUse >= 0) { -var n = Clazz.superCall (this, com.stevesoft.pat.Multi_stage2, "getNext", []); -if (n == null) { -return canUse; -}var ret = this.testMatch (n, pos, pt); -if (ret >= 0) { -return ret; -} else { -canUse = -1; -}}this.count.inc (); -try { -if (this.count.lessEq (this.matchMax)) { -var r = this.testMatch (this.sub, pos, pt); -if (r >= 0) { -return r; -}}} finally { -this.count.dec (); -} -if (!this.matchFewest && canUse >= 0) { -var n = Clazz.superCall (this, com.stevesoft.pat.Multi_stage2, "getNext", []); -if (n == null) { -return canUse; -}var ret = this.testMatch (n, pos, pt); -return ret; -} else { -return canUse; -}}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -try { -var m = new com.stevesoft.pat.Multi_stage2 (this.matchMin, this.matchMax, this.sub.clone (h)); -m.matchFewest = this.matchFewest; -return m; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.PatternSub"], "com.stevesoft.pat.Multi_stage2", ["com.stevesoft.pat.RegSyntaxError", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.nextRet = null; +this.count = null; +this.matchMin = null; +this.matchMax = null; +this.matchFewest = false; +this.pos_old = -1; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Multi_stage2", com.stevesoft.pat.PatternSub); +Clazz.defineMethod (c$, "toString", +function () { +var ret = ""; +ret += this.sub.toString (); +ret += "{" + this.matchMin + "," + this.matchMax + "}"; +if (this.matchFewest) { +ret += "?"; +}ret += this.parent.nextString (); +return ret; +}); +Clazz.makeConstructor (c$, +function (a, b, p) { +Clazz.superConstructor (this, com.stevesoft.pat.Multi_stage2, []); +if (p == null) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Multiple match of Null pattern requested."); +}this.sub = p; +this.nextRet = this; +this.sub.setParent (this); +this.matchMin = a; +this.matchMax = b; +this.count = new com.stevesoft.pat.patInt (0); +if (!a.lessEq (b)) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Bad Multi Args: " + a + ">" + b); +}var i = new com.stevesoft.pat.patInt (-1); +if (a.lessEq (i)) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Bad Multi Args: " + a + "< 0"); +}}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "getNext", +function () { +return this.nextRet; +}); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +this.sub.setParent (this); +var canUse = -1; +if (this.pos_old >= 0 && pos == this.pos_old) { +return -1; +}this.pos_old = pos; +if (this.matchMin.lessEq (this.count)) { +canUse = pos; +}if (!this.count.lessEq (this.matchMax) || pos > pt.src.length ()) { +return -1; +}if ((this.matchFewest || this.count.equals (this.matchMax)) && canUse >= 0) { +var n = Clazz.superCall (this, com.stevesoft.pat.Multi_stage2, "getNext", []); +if (n == null) { +return canUse; +}var ret = this.testMatch (n, pos, pt); +if (ret >= 0) { +return ret; +} else { +canUse = -1; +}}this.count.inc (); +try { +if (this.count.lessEq (this.matchMax)) { +var r = this.testMatch (this.sub, pos, pt); +if (r >= 0) { +return r; +}}} finally { +this.count.dec (); +} +if (!this.matchFewest && canUse >= 0) { +var n = Clazz.superCall (this, com.stevesoft.pat.Multi_stage2, "getNext", []); +if (n == null) { +return canUse; +}var ret = this.testMatch (n, pos, pt); +return ret; +} else { +return canUse; +}}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +try { +var m = new com.stevesoft.pat.Multi_stage2 (this.matchMin, this.matchMax, this.sub.clone (h)); +m.matchFewest = this.matchFewest; +return m; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/NoPattern.js b/bin/com/stevesoft/pat/NoPattern.js index 394e032..ec7438b 100644 --- a/bin/com/stevesoft/pat/NoPattern.js +++ b/bin/com/stevesoft/pat/NoPattern.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.NoPattern", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "NoPattern", com.stevesoft.pat.Pattern); -Clazz.overrideMethod (c$, "toString", -function () { -return "(?e=#)[^#d#D]"; -}); -Clazz.overrideMethod (c$, "matchInternal", -function (i, p) { -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.NoPattern (); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.NoPattern", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "NoPattern", com.stevesoft.pat.Pattern); +Clazz.overrideMethod (c$, "toString", +function () { +return "(?e=#)[^#d#D]"; +}); +Clazz.overrideMethod (c$, "matchInternal", +function (i, p) { +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.NoPattern (); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/NonDirFileRegex.js b/bin/com/stevesoft/pat/NonDirFileRegex.js index eb3a57d..59811e9 100644 --- a/bin/com/stevesoft/pat/NonDirFileRegex.js +++ b/bin/com/stevesoft/pat/NonDirFileRegex.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.FileRegex"], "com.stevesoft.pat.NonDirFileRegex", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "NonDirFileRegex", com.stevesoft.pat.FileRegex); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.FileRegex"], "com.stevesoft.pat.NonDirFileRegex", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "NonDirFileRegex", com.stevesoft.pat.FileRegex); +}); diff --git a/bin/com/stevesoft/pat/NotImplementedError.js b/bin/com/stevesoft/pat/NotImplementedError.js index 4c44ef5..45dd68f 100644 --- a/bin/com/stevesoft/pat/NotImplementedError.js +++ b/bin/com/stevesoft/pat/NotImplementedError.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.lang.Error"], "com.stevesoft.pat.NotImplementedError", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "NotImplementedError", Error); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.lang.Error"], "com.stevesoft.pat.NotImplementedError", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "NotImplementedError", Error); +}); diff --git a/bin/com/stevesoft/pat/NullPattern.js b/bin/com/stevesoft/pat/NullPattern.js index a8eda32..2198789 100644 --- a/bin/com/stevesoft/pat/NullPattern.js +++ b/bin/com/stevesoft/pat/NullPattern.js @@ -1,20 +1,20 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.NullPattern", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "NullPattern", com.stevesoft.pat.Pattern); -Clazz.overrideMethod (c$, "toString", -function () { -return this.nextString (); -}); -Clazz.overrideMethod (c$, "matchInternal", -function (p, pt) { -return this.nextMatch (p, pt); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.NullPattern (); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.NullPattern", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "NullPattern", com.stevesoft.pat.Pattern); +Clazz.overrideMethod (c$, "toString", +function () { +return this.nextString (); +}); +Clazz.overrideMethod (c$, "matchInternal", +function (p, pt) { +return this.nextMatch (p, pt); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.NullPattern (); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/NullRule.js b/bin/com/stevesoft/pat/NullRule.js index f781239..f6a1485 100644 --- a/bin/com/stevesoft/pat/NullRule.js +++ b/bin/com/stevesoft/pat/NullRule.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.NullRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "NullRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.NullRule, []); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return ""; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.NullRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "NullRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.NullRule, []); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return ""; +}); +}); diff --git a/bin/com/stevesoft/pat/Or.js b/bin/com/stevesoft/pat/Or.js index 9255825..1ca2671 100644 --- a/bin/com/stevesoft/pat/Or.js +++ b/bin/com/stevesoft/pat/Or.js @@ -1,92 +1,92 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Or", ["com.stevesoft.pat.patInt", "java.lang.StringBuffer", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.v = null; -this.pv = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Or", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.Or, []); -this.v = new java.util.Vector (); -}); -Clazz.defineMethod (c$, "leftForm", -function () { -return "(?:"; -}); -Clazz.defineMethod (c$, "rightForm", -function () { -return ")"; -}); -Clazz.defineMethod (c$, "sepForm", -function () { -return "|"; -}); -Clazz.defineMethod (c$, "addOr", -function (p) { -this.pv = null; -this.v.addElement (p); -p.setParent (this); -return this; -}, "com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "toString", -function () { -var i; -var sb = new StringBuffer (); -sb.append (this.leftForm ()); -if (this.v.size () > 0) { -sb.append ((this.v.elementAt (0)).toString ()); -}for (i = 1; i < this.v.size (); i++) { -sb.append (this.sepForm ()); -sb.append ((this.v.elementAt (i)).toString ()); -} -sb.append (this.rightForm ()); -sb.append (this.nextString ()); -return sb.toString (); -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -if (this.pv == null) { -this.pv = new Array (this.v.size ()); -this.v.copyInto (this.pv); -}for (var i = 0; i < this.v.size (); i++) { -var p = this.pv[i]; -var r = p.matchInternal (pos, pt); -if (r >= 0) { -return r; -}} -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "minChars", -function () { -if (this.v.size () == 0) { -return new com.stevesoft.pat.patInt (0); -}var m = (this.v.elementAt (0)).countMinChars (); -for (var i = 1; i < this.v.size (); i++) { -var p = this.v.elementAt (i); -m.mineq (p.countMinChars ()); -} -return m; -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -if (this.v.size () == 0) { -return new com.stevesoft.pat.patInt (0); -}var m = (this.v.elementAt (0)).countMaxChars (); -for (var i = 1; i < this.v.size (); i++) { -var p = this.v.elementAt (i); -m.maxeq (p.countMaxChars ()); -} -return m; -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -var o = new com.stevesoft.pat.Or (); -h.put (this, o); -h.put (o, o); -for (var i = 0; i < this.v.size (); i++) { -o.v.addElement ((this.v.elementAt (i)).clone (h)); -} -return o; -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Or", ["com.stevesoft.pat.patInt", "java.lang.StringBuffer", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.v = null; +this.pv = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Or", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.Or, []); +this.v = new java.util.Vector (); +}); +Clazz.defineMethod (c$, "leftForm", +function () { +return "(?:"; +}); +Clazz.defineMethod (c$, "rightForm", +function () { +return ")"; +}); +Clazz.defineMethod (c$, "sepForm", +function () { +return "|"; +}); +Clazz.defineMethod (c$, "addOr", +function (p) { +this.pv = null; +this.v.addElement (p); +p.setParent (this); +return this; +}, "com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "toString", +function () { +var i; +var sb = new StringBuffer (); +sb.append (this.leftForm ()); +if (this.v.size () > 0) { +sb.append ((this.v.elementAt (0)).toString ()); +}for (i = 1; i < this.v.size (); i++) { +sb.append (this.sepForm ()); +sb.append ((this.v.elementAt (i)).toString ()); +} +sb.append (this.rightForm ()); +sb.append (this.nextString ()); +return sb.toString (); +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +if (this.pv == null) { +this.pv = new Array (this.v.size ()); +this.v.copyInto (this.pv); +}for (var i = 0; i < this.v.size (); i++) { +var p = this.pv[i]; +var r = p.matchInternal (pos, pt); +if (r >= 0) { +return r; +}} +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "minChars", +function () { +if (this.v.size () == 0) { +return new com.stevesoft.pat.patInt (0); +}var m = (this.v.elementAt (0)).countMinChars (); +for (var i = 1; i < this.v.size (); i++) { +var p = this.v.elementAt (i); +m.mineq (p.countMinChars ()); +} +return m; +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +if (this.v.size () == 0) { +return new com.stevesoft.pat.patInt (0); +}var m = (this.v.elementAt (0)).countMaxChars (); +for (var i = 1; i < this.v.size (); i++) { +var p = this.v.elementAt (i); +m.maxeq (p.countMaxChars ()); +} +return m; +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +var o = new com.stevesoft.pat.Or (); +h.put (this, o); +h.put (o, o); +for (var i = 0; i < this.v.size (); i++) { +o.v.addElement ((this.v.elementAt (i)).clone (h)); +} +return o; +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/OrMark.js b/bin/com/stevesoft/pat/OrMark.js index 7590a74..bf47fca 100644 --- a/bin/com/stevesoft/pat/OrMark.js +++ b/bin/com/stevesoft/pat/OrMark.js @@ -1,54 +1,54 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Or", "$.SubMark"], "com.stevesoft.pat.OrMark", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.sm = null; -this.id = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "OrMark", com.stevesoft.pat.Or); -Clazz.prepareFields (c$, function () { -this.sm = new com.stevesoft.pat.SubMark (); -}); -Clazz.makeConstructor (c$, -function (i) { -Clazz.superConstructor (this, com.stevesoft.pat.OrMark, []); -this.sm.om = this; -this.id = i; -}, "~N"); -Clazz.overrideMethod (c$, "leftForm", -function () { -return "("; -}); -Clazz.defineMethod (c$, "getNext", -function () { -return this.sm; -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -this.sm.next = Clazz.superCall (this, com.stevesoft.pat.OrMark, "getNext", []); -if (pt.marks == null) { -var n2 = 2 * pt.nMarks + 2; -pt.marks = Clazz.newIntArray (n2, 0); -for (var i = 0; i < n2; i++) { -pt.marks[i] = -1; -} -}pt.marks[this.id] = pos; -var ret = Clazz.superCall (this, com.stevesoft.pat.OrMark, "matchInternal", [pos, pt]); -if (ret < 0) { -pt.marks[this.id] = -1; -} else if (pt.marks[this.id] > pt.marks[this.id + pt.nMarks]) { -var swap = pt.marks[this.id]; -pt.marks[this.id] = pt.marks[this.id + pt.nMarks] + 1; -pt.marks[this.id + pt.nMarks] = swap + 1; -}return ret; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -var om = new com.stevesoft.pat.OrMark (this.id); -h.put (om, om); -h.put (this, om); -for (var i = 0; i < this.v.size (); i++) { -om.v.addElement ((this.v.elementAt (i)).clone (h)); -} -return om; -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Or", "$.SubMark"], "com.stevesoft.pat.OrMark", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.sm = null; +this.id = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "OrMark", com.stevesoft.pat.Or); +Clazz.prepareFields (c$, function () { +this.sm = new com.stevesoft.pat.SubMark (); +}); +Clazz.makeConstructor (c$, +function (i) { +Clazz.superConstructor (this, com.stevesoft.pat.OrMark, []); +this.sm.om = this; +this.id = i; +}, "~N"); +Clazz.overrideMethod (c$, "leftForm", +function () { +return "("; +}); +Clazz.defineMethod (c$, "getNext", +function () { +return this.sm; +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +this.sm.next = Clazz.superCall (this, com.stevesoft.pat.OrMark, "getNext", []); +if (pt.marks == null) { +var n2 = 2 * pt.nMarks + 2; +pt.marks = Clazz.newIntArray (n2, 0); +for (var i = 0; i < n2; i++) { +pt.marks[i] = -1; +} +}pt.marks[this.id] = pos; +var ret = Clazz.superCall (this, com.stevesoft.pat.OrMark, "matchInternal", [pos, pt]); +if (ret < 0) { +pt.marks[this.id] = -1; +} else if (pt.marks[this.id] > pt.marks[this.id + pt.nMarks]) { +var swap = pt.marks[this.id]; +pt.marks[this.id] = pt.marks[this.id + pt.nMarks] + 1; +pt.marks[this.id + pt.nMarks] = swap + 1; +}return ret; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +var om = new com.stevesoft.pat.OrMark (this.id); +h.put (om, om); +h.put (this, om); +for (var i = 0; i < this.v.size (); i++) { +om.v.addElement ((this.v.elementAt (i)).clone (h)); +} +return om; +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/PartialBuffer.js b/bin/com/stevesoft/pat/PartialBuffer.js index 02fc0e3..8490ff2 100644 --- a/bin/com/stevesoft/pat/PartialBuffer.js +++ b/bin/com/stevesoft/pat/PartialBuffer.js @@ -1,50 +1,50 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.PartialBuffer", ["java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.off = 0; -this.allowOverRun = true; -this.overRun = false; -this.sb = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "PartialBuffer", null, com.stevesoft.pat.StringLike); -Clazz.makeConstructor (c$, -function (sb) { -this.sb = sb; -}, "StringBuffer"); -Clazz.overrideMethod (c$, "charAt", -function (n) { -n += this.off; -if (n == this.sb.length ()) { -this.overRun = true; -return String.fromCharCode (0); -}return this.sb.charAt (n); -}, "~N"); -Clazz.overrideMethod (c$, "length", -function () { -return this.allowOverRun ? this.sb.length () + 1 : this.sb.length (); -}); -Clazz.overrideMethod (c$, "indexOf", -function (c) { -for (var i = 0; i < this.sb.length (); i++) { -if (this.sb.charAt (i) == c) { -return i; -}} -return -1; -}, "~S"); -Clazz.overrideMethod (c$, "unwrap", -function () { -return this.sb; -}); -Clazz.overrideMethod (c$, "substring", -function (i1, i2) { -var sb = new StringBuffer (i2 - i1); -for (var i = i1; i < i2; i++) { -sb.append (this.charAt (i)); -} -return sb.toString (); -}, "~N,~N"); -Clazz.overrideMethod (c$, "newStringBufferLike", -function () { -return null; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.PartialBuffer", ["java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.off = 0; +this.allowOverRun = true; +this.overRun = false; +this.sb = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "PartialBuffer", null, com.stevesoft.pat.StringLike); +Clazz.makeConstructor (c$, +function (sb) { +this.sb = sb; +}, "StringBuffer"); +Clazz.overrideMethod (c$, "charAt", +function (n) { +n += this.off; +if (n == this.sb.length ()) { +this.overRun = true; +return String.fromCharCode (0); +}return this.sb.charAt (n); +}, "~N"); +Clazz.overrideMethod (c$, "length", +function () { +return this.allowOverRun ? this.sb.length () + 1 : this.sb.length (); +}); +Clazz.overrideMethod (c$, "indexOf", +function (c) { +for (var i = 0; i < this.sb.length (); i++) { +if (this.sb.charAt (i) == c) { +return i; +}} +return -1; +}, "~S"); +Clazz.overrideMethod (c$, "unwrap", +function () { +return this.sb; +}); +Clazz.overrideMethod (c$, "substring", +function (i1, i2) { +var sb = new StringBuffer (i2 - i1); +for (var i = i1; i < i2; i++) { +sb.append (this.charAt (i)); +} +return sb.toString (); +}, "~N,~N"); +Clazz.overrideMethod (c$, "newStringBufferLike", +function () { +return null; +}); +}); diff --git a/bin/com/stevesoft/pat/Pattern.js b/bin/com/stevesoft/pat/Pattern.js index a3dddd4..a4dc10b 100644 --- a/bin/com/stevesoft/pat/Pattern.js +++ b/bin/com/stevesoft/pat/Pattern.js @@ -1,153 +1,153 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.Pattern", ["com.stevesoft.pat.MessageManager", "$.patInf", "$.patInt", "java.lang.Error", "$.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.next = null; -this.parent = null; -this.mfrom = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Pattern"); -Clazz.defineMethod (c$, "getNext", -function () { -return this.next != null ? this.next : (this.parent == null ? null : this.parent.getNext ()); -}); -Clazz.defineMethod (c$, "setParent", -function (p) { -if (this.next != null) { -this.next.setParent (p); -} else { -this.parent = p; -}}, "com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "nextMatch", -function (i, pt) { -var p = this.getNext (); -return p == null ? i : p.matchInternal (i, pt); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "nextString", -function () { -if (this.next == null) { -return ""; -}return this.next.toString (); -}); -c$.inString = Clazz.defineMethod (c$, "inString", -function (c, s) { -var i; -for (i = 0; i < s.length; i++) { -if (s.charAt (i) == c) { -return true; -}} -return false; -}, "~S,~S"); -c$.protect = Clazz.defineMethod (c$, "protect", -function (s, PROTECT_THESE, esc) { -var i; -var sb = new StringBuffer (); -var p = PROTECT_THESE + esc; -for (i = 0; i < s.length; i++) { -var c = s.charAt (i); -if (com.stevesoft.pat.Pattern.inString (c, p)) { -sb.append (esc); -}sb.append (c); -} -return sb.toString (); -}, "~S,~S,~S"); -Clazz.defineMethod (c$, "match", -function (s, pt) { -return this.matchAt (s, 0, pt); -}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "matchAt", -function (s, i, pt) { -pt.src = s; -var r = this.matchInternal (i, pt); -if (r < 0) { -return -1; -}this.mfrom = r < i ? r + 1 : i; -return r < i ? i - r - 1 : r - i; -}, "com.stevesoft.pat.StringLike,~N,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "Masked", -function (i, pt) { -return pt.cbits == null ? false : pt.cbits.get (i); -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "add", -function (p) { -if (this.next == null) { -if (p == null) { -return this; -}this.next = p; -p.parent = this.parent; -this.parent = null; -} else { -this.next.add (p); -}return this; -}, "com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.defineMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInf (); -}); -Clazz.defineMethod (c$, "countMinChars", -function () { -var p = this; -var sum = new com.stevesoft.pat.patInt (0); -while (p != null) { -sum.pluseq (p.minChars ()); -p = p.next; -} -return sum; -}); -Clazz.defineMethod (c$, "countMaxChars", -function () { -var p = this; -var sum = new com.stevesoft.pat.patInt (0); -while (p != null) { -sum.pluseq (p.maxChars ()); -p = p.next; -} -return sum; -}); -Clazz.defineMethod (c$, "testMatch", -function (p, pos, pt) { -var tab = null; -if (pt.marks != null) { -try { -tab = Clazz.newIntArray (pt.marks.length, 0); -for (var i = 0; i < tab.length; i++) { -tab[i] = pt.marks[i]; -} -} catch (t) { -} -}var ret = p.matchInternal (pos, pt); -if (ret < 0) { -pt.marks = tab; -}return ret; -}, "com.stevesoft.pat.Pattern,~N,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "clone1", -function (h) { -throw new Error (com.stevesoft.pat.MessageManager.formatMessage ("error.no_such_method_as_clone1_for", Clazz.newArray (-1, [this.getClass ().getName ()]))); -}, "java.util.Hashtable"); -Clazz.defineMethod (c$, "clone", -function (h) { -var p = h.get (this); -if (p != null) { -return p; -}p = this.clone1 (h); -if (p == null) { -throw new Error (com.stevesoft.pat.MessageManager.getString ("error.null_from_clone1")); -}h.put (this, p); -h.put (p, p); -if (this.next != null) { -p.next = this.next.clone (h); -}if (this.parent != null) { -p.parent = this.parent.clone (h); -}return p; -}, "java.util.Hashtable"); -Clazz.overrideMethod (c$, "equals", -function (o) { -return o === this; -}, "~O"); -Clazz.defineStatics (c$, -"ESC", '\\', -"PROTECT_THESE", "[]{}(),$,-\"^."); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.Pattern", ["com.stevesoft.pat.MessageManager", "$.patInf", "$.patInt", "java.lang.Error", "$.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.next = null; +this.parent = null; +this.mfrom = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Pattern"); +Clazz.defineMethod (c$, "getNext", +function () { +return this.next != null ? this.next : (this.parent == null ? null : this.parent.getNext ()); +}); +Clazz.defineMethod (c$, "setParent", +function (p) { +if (this.next != null) { +this.next.setParent (p); +} else { +this.parent = p; +}}, "com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "nextMatch", +function (i, pt) { +var p = this.getNext (); +return p == null ? i : p.matchInternal (i, pt); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "nextString", +function () { +if (this.next == null) { +return ""; +}return this.next.toString (); +}); +c$.inString = Clazz.defineMethod (c$, "inString", +function (c, s) { +var i; +for (i = 0; i < s.length; i++) { +if (s.charAt (i) == c) { +return true; +}} +return false; +}, "~S,~S"); +c$.protect = Clazz.defineMethod (c$, "protect", +function (s, PROTECT_THESE, esc) { +var i; +var sb = new StringBuffer (); +var p = PROTECT_THESE + esc; +for (i = 0; i < s.length; i++) { +var c = s.charAt (i); +if (com.stevesoft.pat.Pattern.inString (c, p)) { +sb.append (esc); +}sb.append (c); +} +return sb.toString (); +}, "~S,~S,~S"); +Clazz.defineMethod (c$, "match", +function (s, pt) { +return this.matchAt (s, 0, pt); +}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "matchAt", +function (s, i, pt) { +pt.src = s; +var r = this.matchInternal (i, pt); +if (r < 0) { +return -1; +}this.mfrom = r < i ? r + 1 : i; +return r < i ? i - r - 1 : r - i; +}, "com.stevesoft.pat.StringLike,~N,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "Masked", +function (i, pt) { +return pt.cbits == null ? false : pt.cbits.get (i); +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "add", +function (p) { +if (this.next == null) { +if (p == null) { +return this; +}this.next = p; +p.parent = this.parent; +this.parent = null; +} else { +this.next.add (p); +}return this; +}, "com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.defineMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInf (); +}); +Clazz.defineMethod (c$, "countMinChars", +function () { +var p = this; +var sum = new com.stevesoft.pat.patInt (0); +while (p != null) { +sum.pluseq (p.minChars ()); +p = p.next; +} +return sum; +}); +Clazz.defineMethod (c$, "countMaxChars", +function () { +var p = this; +var sum = new com.stevesoft.pat.patInt (0); +while (p != null) { +sum.pluseq (p.maxChars ()); +p = p.next; +} +return sum; +}); +Clazz.defineMethod (c$, "testMatch", +function (p, pos, pt) { +var tab = null; +if (pt.marks != null) { +try { +tab = Clazz.newIntArray (pt.marks.length, 0); +for (var i = 0; i < tab.length; i++) { +tab[i] = pt.marks[i]; +} +} catch (t) { +} +}var ret = p.matchInternal (pos, pt); +if (ret < 0) { +pt.marks = tab; +}return ret; +}, "com.stevesoft.pat.Pattern,~N,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "clone1", +function (h) { +throw new Error (com.stevesoft.pat.MessageManager.formatMessage ("error.no_such_method_as_clone1_for", Clazz.newArray (-1, [this.getClass ().getName ()]))); +}, "java.util.Hashtable"); +Clazz.defineMethod (c$, "clone", +function (h) { +var p = h.get (this); +if (p != null) { +return p; +}p = this.clone1 (h); +if (p == null) { +throw new Error (com.stevesoft.pat.MessageManager.getString ("error.null_from_clone1")); +}h.put (this, p); +h.put (p, p); +if (this.next != null) { +p.next = this.next.clone (h); +}if (this.parent != null) { +p.parent = this.parent.clone (h); +}return p; +}, "java.util.Hashtable"); +Clazz.overrideMethod (c$, "equals", +function (o) { +return o === this; +}, "~O"); +Clazz.defineStatics (c$, +"ESC", '\\', +"PROTECT_THESE", "[]{}(),$,-\"^."); +}); diff --git a/bin/com/stevesoft/pat/PatternSub.js b/bin/com/stevesoft/pat/PatternSub.js index 835661a..2199b2b 100644 --- a/bin/com/stevesoft/pat/PatternSub.js +++ b/bin/com/stevesoft/pat/PatternSub.js @@ -1,7 +1,7 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.PatternSub", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.sub = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "PatternSub", com.stevesoft.pat.Pattern); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.PatternSub", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.sub = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "PatternSub", com.stevesoft.pat.Pattern); +}); diff --git a/bin/com/stevesoft/pat/PopRule.js b/bin/com/stevesoft/pat/PopRule.js index 92af006..d983d19 100644 --- a/bin/com/stevesoft/pat/PopRule.js +++ b/bin/com/stevesoft/pat/PopRule.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.PopRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "PopRule", com.stevesoft.pat.SpecialRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.PopRule, []); -}); -Clazz.overrideMethod (c$, "toString1", -function () { -return "${POP}"; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.PopRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "PopRule", com.stevesoft.pat.SpecialRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.PopRule, []); +}); +Clazz.overrideMethod (c$, "toString1", +function () { +return "${POP}"; +}); +}); diff --git a/bin/com/stevesoft/pat/Prop.js b/bin/com/stevesoft/pat/Prop.js index 5dbb6db..7f99d0e 100644 --- a/bin/com/stevesoft/pat/Prop.js +++ b/bin/com/stevesoft/pat/Prop.js @@ -1,40 +1,40 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.Prop", ["com.stevesoft.pat.Bits"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "Prop"); -c$.isDecimalDigit = Clazz.defineMethod (c$, "isDecimalDigit", -function (c) { -if (com.stevesoft.pat.Bits.decimal_digit == null) { -com.stevesoft.pat.Bits.decimal_digit_f (); -}return com.stevesoft.pat.Bits.decimal_digit.get (c.charCodeAt (0)); -}, "~S"); -c$.isAlphabetic = Clazz.defineMethod (c$, "isAlphabetic", -function (c) { -if (com.stevesoft.pat.Bits.letter == null) { -com.stevesoft.pat.Bits.letter_f (); -}return com.stevesoft.pat.Bits.letter.get (c.charCodeAt (0)); -}, "~S"); -c$.isMath = Clazz.defineMethod (c$, "isMath", -function (c) { -if (com.stevesoft.pat.Bits.math == null) { -com.stevesoft.pat.Bits.math_f (); -}return com.stevesoft.pat.Bits.math.get (c.charCodeAt (0)); -}, "~S"); -c$.isCurrency = Clazz.defineMethod (c$, "isCurrency", -function (c) { -if (com.stevesoft.pat.Bits.currency == null) { -com.stevesoft.pat.Bits.currency_f (); -}return com.stevesoft.pat.Bits.currency.get (c.charCodeAt (0)); -}, "~S"); -c$.isWhite = Clazz.defineMethod (c$, "isWhite", -function (c) { -if (com.stevesoft.pat.Bits.white == null) { -com.stevesoft.pat.Bits.white_f (); -}return com.stevesoft.pat.Bits.white.get (c.charCodeAt (0)); -}, "~S"); -c$.isPunct = Clazz.defineMethod (c$, "isPunct", -function (c) { -if (com.stevesoft.pat.Bits.punct == null) { -com.stevesoft.pat.Bits.punct_f (); -}return com.stevesoft.pat.Bits.punct.get (c.charCodeAt (0)); -}, "~S"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.Prop", ["com.stevesoft.pat.Bits"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "Prop"); +c$.isDecimalDigit = Clazz.defineMethod (c$, "isDecimalDigit", +function (c) { +if (com.stevesoft.pat.Bits.decimal_digit == null) { +com.stevesoft.pat.Bits.decimal_digit_f (); +}return com.stevesoft.pat.Bits.decimal_digit.get (c.charCodeAt (0)); +}, "~S"); +c$.isAlphabetic = Clazz.defineMethod (c$, "isAlphabetic", +function (c) { +if (com.stevesoft.pat.Bits.letter == null) { +com.stevesoft.pat.Bits.letter_f (); +}return com.stevesoft.pat.Bits.letter.get (c.charCodeAt (0)); +}, "~S"); +c$.isMath = Clazz.defineMethod (c$, "isMath", +function (c) { +if (com.stevesoft.pat.Bits.math == null) { +com.stevesoft.pat.Bits.math_f (); +}return com.stevesoft.pat.Bits.math.get (c.charCodeAt (0)); +}, "~S"); +c$.isCurrency = Clazz.defineMethod (c$, "isCurrency", +function (c) { +if (com.stevesoft.pat.Bits.currency == null) { +com.stevesoft.pat.Bits.currency_f (); +}return com.stevesoft.pat.Bits.currency.get (c.charCodeAt (0)); +}, "~S"); +c$.isWhite = Clazz.defineMethod (c$, "isWhite", +function (c) { +if (com.stevesoft.pat.Bits.white == null) { +com.stevesoft.pat.Bits.white_f (); +}return com.stevesoft.pat.Bits.white.get (c.charCodeAt (0)); +}, "~S"); +c$.isPunct = Clazz.defineMethod (c$, "isPunct", +function (c) { +if (com.stevesoft.pat.Bits.punct == null) { +com.stevesoft.pat.Bits.punct_f (); +}return com.stevesoft.pat.Bits.punct.get (c.charCodeAt (0)); +}, "~S"); +}); diff --git a/bin/com/stevesoft/pat/Pthings.js b/bin/com/stevesoft/pat/Pthings.js index 8969d4f..179ec6b 100644 --- a/bin/com/stevesoft/pat/Pthings.js +++ b/bin/com/stevesoft/pat/Pthings.js @@ -1,13 +1,13 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -c$ = Clazz.decorateAsClass (function () { -this.src = null; -this.ignoreCase = false; -this.mFlag = false; -this.cbits = null; -this.marks = null; -this.nMarks = 0; -this.dotDoesntMatchCR = false; -this.no_check = false; -this.lastPos = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Pthings"); +Clazz.declarePackage ("com.stevesoft.pat"); +c$ = Clazz.decorateAsClass (function () { +this.src = null; +this.ignoreCase = false; +this.mFlag = false; +this.cbits = null; +this.marks = null; +this.nMarks = 0; +this.dotDoesntMatchCR = false; +this.no_check = false; +this.lastPos = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Pthings"); diff --git a/bin/com/stevesoft/pat/PushRule.js b/bin/com/stevesoft/pat/PushRule.js index fd7d64e..bac59ef 100644 --- a/bin/com/stevesoft/pat/PushRule.js +++ b/bin/com/stevesoft/pat/PushRule.js @@ -1,35 +1,35 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.PushRule", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.NewRule = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "PushRule", com.stevesoft.pat.SpecialRule); -Clazz.makeConstructor (c$, -function (p) { -Clazz.superConstructor (this, com.stevesoft.pat.PushRule, []); -this.NewRule = p.NewRule; -}, "com.stevesoft.pat.PushRule"); -Clazz.makeConstructor (c$, -function (nm, rr) { -Clazz.superConstructor (this, com.stevesoft.pat.PushRule, []); -this.name = nm; -this.NewRule = rr; -}, "~S,com.stevesoft.pat.Regex"); -Clazz.makeConstructor (c$, -function (nm, tr) { -Clazz.superConstructor (this, com.stevesoft.pat.PushRule, []); -this.name = nm; -this.NewRule = tr.rp; -}, "~S,com.stevesoft.pat.Transformer"); -Clazz.overrideMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.PushRule (this); -}); -Clazz.defineMethod (c$, "String1", -function () { -return "${+" + this.name + "}"; -}); -Clazz.overrideMethod (c$, "apply", -function (sbl, rr) { -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.PushRule", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.NewRule = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "PushRule", com.stevesoft.pat.SpecialRule); +Clazz.makeConstructor (c$, +function (p) { +Clazz.superConstructor (this, com.stevesoft.pat.PushRule, []); +this.NewRule = p.NewRule; +}, "com.stevesoft.pat.PushRule"); +Clazz.makeConstructor (c$, +function (nm, rr) { +Clazz.superConstructor (this, com.stevesoft.pat.PushRule, []); +this.name = nm; +this.NewRule = rr; +}, "~S,com.stevesoft.pat.Regex"); +Clazz.makeConstructor (c$, +function (nm, tr) { +Clazz.superConstructor (this, com.stevesoft.pat.PushRule, []); +this.name = nm; +this.NewRule = tr.rp; +}, "~S,com.stevesoft.pat.Transformer"); +Clazz.overrideMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.PushRule (this); +}); +Clazz.defineMethod (c$, "String1", +function () { +return "${+" + this.name + "}"; +}); +Clazz.overrideMethod (c$, "apply", +function (sbl, rr) { +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +}); diff --git a/bin/com/stevesoft/pat/RBuffer.js b/bin/com/stevesoft/pat/RBuffer.js index 27970cf..529f8a2 100644 --- a/bin/com/stevesoft/pat/RBuffer.js +++ b/bin/com/stevesoft/pat/RBuffer.js @@ -1,32 +1,32 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.RBuffer", ["java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.done = false; -this.sb = null; -this.pos = 0; -this.epos = 0; -this.next = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RBuffer"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (sb) { -this.sb = sb; -}, "StringBuffer"); -Clazz.overrideMethod (c$, "toString", -function () { -return "sb=" + this.sb.toString ().$replace ('\n', ' ') + " pos=" + this.pos + " epos=" + this.epos + " sb.length()=" + this.sb.length () + "\n" + this.sp (this.pos + 3) + "^" + this.sp (this.epos - this.pos - 1) + "^"; -}); -Clazz.defineMethod (c$, "sp", -function (n) { -if (n <= 0) { -return ""; -}var sb = new StringBuffer (n); -for (var i = 0; i < n; i++) { -sb.append (' '); -} -return sb.toString (); -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.RBuffer", ["java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.done = false; +this.sb = null; +this.pos = 0; +this.epos = 0; +this.next = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RBuffer"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (sb) { +this.sb = sb; +}, "StringBuffer"); +Clazz.overrideMethod (c$, "toString", +function () { +return "sb=" + this.sb.toString ().$replace ('\n', ' ') + " pos=" + this.pos + " epos=" + this.epos + " sb.length()=" + this.sb.length () + "\n" + this.sp (this.pos + 3) + "^" + this.sp (this.epos - this.pos - 1) + "^"; +}); +Clazz.defineMethod (c$, "sp", +function (n) { +if (n <= 0) { +return ""; +}var sb = new StringBuffer (n); +for (var i = 0; i < n; i++) { +sb.append (' '); +} +return sb.toString (); +}, "~N"); +}); diff --git a/bin/com/stevesoft/pat/Range.js b/bin/com/stevesoft/pat/Range.js index 8294a31..cb007c4 100644 --- a/bin/com/stevesoft/pat/Range.js +++ b/bin/com/stevesoft/pat/Range.js @@ -1,65 +1,65 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern", "$.RegSyntax"], ["com.stevesoft.pat.BadRangeArgs", "$.Range"], ["com.stevesoft.pat.RegSyntaxError", "$.oneChar", "$.patInt"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "BadRangeArgs", com.stevesoft.pat.RegSyntax); -c$ = Clazz.decorateAsClass (function () { -this.lo = '\0'; -this.hi = '\0'; -this.altlo = '\0'; -this.althi = '\0'; -this.printBrackets = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Range", com.stevesoft.pat.Pattern); -Clazz.overrideMethod (c$, "toString", -function () { -var s = com.stevesoft.pat.Pattern.protect ("" + this.lo, "[]{}(),$,-\"^.", '\\') + "-" + com.stevesoft.pat.Pattern.protect ("" + this.hi, "[]{}(),$,-\"^.", '\\'); -if (!this.printBrackets) { -return s; -}return "[" + s + "]"; -}); -Clazz.makeConstructor (c$, -function (loi, hii) { -Clazz.superConstructor (this, com.stevesoft.pat.Range, []); -this.lo = loi; -this.hi = hii; -var o = null; -if (this.lo >= this.hi) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Badly formed []'s : " + this.lo + " >= " + this.hi); -}o = new com.stevesoft.pat.oneChar (this.lo); -this.altlo = o.altc; -o = new com.stevesoft.pat.oneChar (this.hi); -this.althi = o.altc; -}, "~S,~S"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (pos >= pt.src.length ()) { -return -1; -}if (this.Masked (pos, pt)) { -return -1; -}var c = pt.src.charAt (pos); -if (this.lo <= c && c <= this.hi || (pt.ignoreCase && (this.altlo <= c && c <= this.althi))) { -return this.nextMatch (pos + 1, pt); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -try { -var r = new com.stevesoft.pat.Range (this.lo, this.hi); -r.printBrackets = this.printBrackets; -return r; -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -return null; -} else { -throw rs; -} -} -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern", "$.RegSyntax"], ["com.stevesoft.pat.BadRangeArgs", "$.Range"], ["com.stevesoft.pat.RegSyntaxError", "$.oneChar", "$.patInt"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "BadRangeArgs", com.stevesoft.pat.RegSyntax); +c$ = Clazz.decorateAsClass (function () { +this.lo = '\0'; +this.hi = '\0'; +this.altlo = '\0'; +this.althi = '\0'; +this.printBrackets = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Range", com.stevesoft.pat.Pattern); +Clazz.overrideMethod (c$, "toString", +function () { +var s = com.stevesoft.pat.Pattern.protect ("" + this.lo, "[]{}(),$,-\"^.", '\\') + "-" + com.stevesoft.pat.Pattern.protect ("" + this.hi, "[]{}(),$,-\"^.", '\\'); +if (!this.printBrackets) { +return s; +}return "[" + s + "]"; +}); +Clazz.makeConstructor (c$, +function (loi, hii) { +Clazz.superConstructor (this, com.stevesoft.pat.Range, []); +this.lo = loi; +this.hi = hii; +var o = null; +if (this.lo >= this.hi) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Badly formed []'s : " + this.lo + " >= " + this.hi); +}o = new com.stevesoft.pat.oneChar (this.lo); +this.altlo = o.altc; +o = new com.stevesoft.pat.oneChar (this.hi); +this.althi = o.altc; +}, "~S,~S"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (pos >= pt.src.length ()) { +return -1; +}if (this.Masked (pos, pt)) { +return -1; +}var c = pt.src.charAt (pos); +if (this.lo <= c && c <= this.hi || (pt.ignoreCase && (this.altlo <= c && c <= this.althi))) { +return this.nextMatch (pos + 1, pt); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +try { +var r = new com.stevesoft.pat.Range (this.lo, this.hi); +r.printBrackets = this.printBrackets; +return r; +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +return null; +} else { +throw rs; +} +} +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/RegOpt.js b/bin/com/stevesoft/pat/RegOpt.js index 54e0ed8..ed70432 100644 --- a/bin/com/stevesoft/pat/RegOpt.js +++ b/bin/com/stevesoft/pat/RegOpt.js @@ -1,254 +1,254 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern", "$.oneChar", "java.util.Hashtable", "$.Vector"], ["com.stevesoft.pat.Branch", "$.RegOpt", "$.FastChar"], ["com.stevesoft.pat.Any", "$.Bracket", "$.Custom", "$.FastBracket", "$.FastMulti", "$.Multi", "$.NullPattern", "$.Or", "$.Range", "$.UniValidator", "$.patInt", "java.lang.Character", "$.StringBuffer"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "FastChar", com.stevesoft.pat.oneChar); -Clazz.overrideMethod (c$, "matchInternal", -function (p, pt) { -return (p < pt.src.length () && pt.src.charAt (p) == this.c) ? this.nextMatch (p + 1, pt) : -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.FastChar (this.c); -}, "java.util.Hashtable"); -c$ = Clazz.decorateAsClass (function () { -this.h = null; -this.keys = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Branch", com.stevesoft.pat.Pattern); -Clazz.prepareFields (c$, function () { -this.h = new java.util.Hashtable (); -this.keys = new java.util.Vector (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.Branch, []); -}); -Clazz.overrideMethod (c$, "clone1", -function (x) { -var b = new com.stevesoft.pat.Branch (); -b.keys = this.keys.clone (); -x.put (this, b); -x.put (b, b); -for (var i = 0; i < this.keys.size (); i++) { -var p = this.h.get (this.keys.elementAt (i)); -b.h.put (this.keys.elementAt (i), p.clone (x)); -} -return b; -}, "java.util.Hashtable"); -Clazz.defineMethod (c$, "reduce", -function (ignoreCase, dontMinQ) { -if (this.h.size () == 1) { -var e = this.h.keys (); -var c = e.nextElement (); -var oc; -if (ignoreCase || dontMinQ) { -oc = new com.stevesoft.pat.oneChar (c.charValue ()); -} else { -oc = new com.stevesoft.pat.FastChar (c.charValue ()); -}oc.next = this.h.get (c); -oc.add (this.next); -return oc; -} else if (this.h.size () == 0) { -return null; -}return this; -}, "~B,~B"); -Clazz.defineMethod (c$, "maxChars", -function () { -var e = this.h.keys (); -var count = new com.stevesoft.pat.patInt (0); -while (e.hasMoreElements ()) { -var key = e.nextElement (); -var pa = this.h.get (key); -var pi = pa.maxChars (); -pi.inc (); -count.maxeq (pi); -} -return count; -}); -Clazz.defineMethod (c$, "minChars", -function () { -var e = this.h.keys (); -var count = new com.stevesoft.pat.patInt (0); -while (e.hasMoreElements ()) { -var key = e.nextElement (); -var pa = this.h.get (key); -var pi = pa.minChars (); -pi.inc (); -count.mineq (pi); -} -return count; -}); -Clazz.defineMethod (c$, "addc", -function (o, ignoreCase, dontMinQ) { -var n = o.next; -if (n == null) { -n = new com.stevesoft.pat.NullPattern (); -} else { -n = com.stevesoft.pat.RegOpt.opt (n, ignoreCase, dontMinQ); -}n.setParent (this); -this.set ( new Character (o.c), n, ignoreCase, dontMinQ); -if (ignoreCase) { -if (o.c != o.altc) { -this.set ( new Character (o.altc), n, ignoreCase, dontMinQ); -}if (o.c != o.altc2 && o.altc != o.altc2) { -this.set ( new Character (o.altc2), n, ignoreCase, dontMinQ); -}}}, "com.stevesoft.pat.oneChar,~B,~B"); -Clazz.defineMethod (c$, "set", -function (c, n, igc, dontMinQ) { -var p = this.h.get (c); -this.next = null; -if (p == null) { -if (Clazz.instanceOf (n, com.stevesoft.pat.Or)) { -var np = new com.stevesoft.pat.NullPattern (); -np.add (n); -this.h.put (c, np); -} else { -this.h.put (c, n); -}this.keys.addElement (c); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or)) { -(p).addOr (n); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (n, com.stevesoft.pat.oneChar) && (p).c != (n).c) { -var b = new com.stevesoft.pat.Branch (); -b.addc (p, igc, dontMinQ); -b.addc (n, igc, dontMinQ); -this.h.put (c, b); -b.setParent (this); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Branch) && Clazz.instanceOf (n, com.stevesoft.pat.oneChar)) { -(p).addc (n, igc, dontMinQ); -n.setParent (p); -} else { -var o = new com.stevesoft.pat.Or (); -o.setParent (this); -if (Clazz.instanceOf (p, com.stevesoft.pat.NullPattern) && p.parent == null && p.next != null) { -o.addOr (p.next); -} else { -o.addOr (p); -}o.addOr (n); -var optpat = com.stevesoft.pat.RegOpt.opt (o, igc, dontMinQ); -this.h.put (c, optpat); -optpat.setParent (this); -}}, "Character,com.stevesoft.pat.Pattern,~B,~B"); -Clazz.overrideMethod (c$, "toString", -function () { -var sb = new StringBuffer (); -sb.append ("(?:(?#branch)"); -for (var i = 0; i < this.keys.size (); i++) { -var c = this.keys.elementAt (i); -sb.append (c); -sb.append (this.h.get (c)); -if (i + 1 < this.keys.size ()) { -sb.append ("|"); -}} -sb.append (")"); -sb.append (this.nextString ()); -return sb.toString (); -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -if (pos >= pt.src.length ()) { -return -1; -}var n = this.h.get ( new Character (pt.src.charAt (pos))); -if (n == null) { -return -1; -}if (pt.cbits != null && pt.cbits.get (pos)) { -return -1; -}return n.matchInternal (pos + 1, pt); -}, "~N,com.stevesoft.pat.Pthings"); -c$ = Clazz.declareType (com.stevesoft.pat, "RegOpt"); -c$.opt = Clazz.defineMethod (c$, "opt", -function (p, ignoreCase, dontMinQ) { -if (p == null) { -return p; -}if (Clazz.instanceOf (p, com.stevesoft.pat.Bracket)) { -var b = p; -p = com.stevesoft.pat.FastBracket.process (b, ignoreCase); -p.next = b.next; -p.parent = b.parent; -} else if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && !ignoreCase && !dontMinQ) { -var o = p; -p = new com.stevesoft.pat.FastChar (o.c); -p.next = o.next; -p.parent = o.parent; -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or) && (p).leftForm ().equals ("(?:") && (p).v.size () == 1) { -var o = p; -p = o.v.elementAt (0); -p.setParent (null); -p = com.stevesoft.pat.RegOpt.opt (p, ignoreCase, dontMinQ); -p.add (o.next); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or)) { -var o = p; -o.pv = null; -var v = o.v; -o.v = new java.util.Vector (); -var b = new com.stevesoft.pat.Branch (); -b.parent = o.parent; -for (var i = 0; i < v.size (); i++) { -var pp = v.elementAt (i); -if (Clazz.instanceOf (pp, com.stevesoft.pat.oneChar) && (b.h.size () >= 1 || (i + 1 < v.size () && Clazz.instanceOf (v.elementAt (i + 1), com.stevesoft.pat.oneChar)))) { -b.addc (pp, ignoreCase, dontMinQ); -} else { -if (b.keys.size () > 0) { -var p2 = b.reduce (ignoreCase, dontMinQ); -if (p2 != null) { -o.addOr (p2); -b = new com.stevesoft.pat.Branch (); -b.parent = o.parent; -}}o.addOr (com.stevesoft.pat.RegOpt.opt (pp, ignoreCase, dontMinQ)); -}} -if (b.keys.size () > 0) { -var p2 = b.reduce (ignoreCase, dontMinQ); -if (p2 != null) { -o.addOr (p2); -}}if (o.v.size () == 1 && o.leftForm ().equals ("(?:")) { -p = o.v.elementAt (0); -p.setParent (null); -p = com.stevesoft.pat.RegOpt.opt (p, ignoreCase, dontMinQ); -p.add (o.next); -}} else if (Clazz.instanceOf (p, com.stevesoft.pat.FastMulti)) { -var ps = p; -ps.sub = com.stevesoft.pat.RegOpt.opt (ps.sub, ignoreCase, dontMinQ); -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Multi) && com.stevesoft.pat.RegOpt.safe4fm ((p).sub)) { -var m = p; -var fm = null; -try { -fm = new com.stevesoft.pat.FastMulti (m.a, m.b, com.stevesoft.pat.RegOpt.opt (m.sub, ignoreCase, dontMinQ)); -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -} else { -throw rs; -} -} -fm.parent = m.parent; -fm.matchFewest = m.matchFewest; -fm.next = m.next; -p = fm; -}if (p.next != null) { -p.next = com.stevesoft.pat.RegOpt.opt (p.next, ignoreCase, dontMinQ); -}return p; -}, "com.stevesoft.pat.Pattern,~B,~B"); -c$.safe4fm = Clazz.defineMethod (c$, "safe4fm", -function (x) { -while (x != null) { -if (Clazz.instanceOf (x, com.stevesoft.pat.Bracket)) { -;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Range)) { -;} else if (Clazz.instanceOf (x, com.stevesoft.pat.oneChar)) { -;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Any)) { -;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Custom) && Clazz.instanceOf ((x).v, com.stevesoft.pat.UniValidator)) { -;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Or)) { -var o = x; -if (!o.leftForm ().equals ("(?:")) { -return false; -}var lo = o.countMinChars (); -var hi = o.countMaxChars (); -if (!lo.equals (hi)) { -return false; -}for (var i = 0; i < o.v.size (); i++) { -if (!com.stevesoft.pat.RegOpt.safe4fm (o.v.elementAt (i))) { -return false; -}} -} else { -return false; -}x = x.next; -} -return true; -}, "com.stevesoft.pat.Pattern"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern", "$.oneChar", "java.util.Hashtable", "$.Vector"], ["com.stevesoft.pat.Branch", "$.RegOpt", "$.FastChar"], ["com.stevesoft.pat.Any", "$.Bracket", "$.Custom", "$.FastBracket", "$.FastMulti", "$.Multi", "$.NullPattern", "$.Or", "$.Range", "$.UniValidator", "$.patInt", "java.lang.Character", "$.StringBuffer"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "FastChar", com.stevesoft.pat.oneChar); +Clazz.overrideMethod (c$, "matchInternal", +function (p, pt) { +return (p < pt.src.length () && pt.src.charAt (p) == this.c) ? this.nextMatch (p + 1, pt) : -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.FastChar (this.c); +}, "java.util.Hashtable"); +c$ = Clazz.decorateAsClass (function () { +this.h = null; +this.keys = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Branch", com.stevesoft.pat.Pattern); +Clazz.prepareFields (c$, function () { +this.h = new java.util.Hashtable (); +this.keys = new java.util.Vector (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.Branch, []); +}); +Clazz.overrideMethod (c$, "clone1", +function (x) { +var b = new com.stevesoft.pat.Branch (); +b.keys = this.keys.clone (); +x.put (this, b); +x.put (b, b); +for (var i = 0; i < this.keys.size (); i++) { +var p = this.h.get (this.keys.elementAt (i)); +b.h.put (this.keys.elementAt (i), p.clone (x)); +} +return b; +}, "java.util.Hashtable"); +Clazz.defineMethod (c$, "reduce", +function (ignoreCase, dontMinQ) { +if (this.h.size () == 1) { +var e = this.h.keys (); +var c = e.nextElement (); +var oc; +if (ignoreCase || dontMinQ) { +oc = new com.stevesoft.pat.oneChar (c.charValue ()); +} else { +oc = new com.stevesoft.pat.FastChar (c.charValue ()); +}oc.next = this.h.get (c); +oc.add (this.next); +return oc; +} else if (this.h.size () == 0) { +return null; +}return this; +}, "~B,~B"); +Clazz.defineMethod (c$, "maxChars", +function () { +var e = this.h.keys (); +var count = new com.stevesoft.pat.patInt (0); +while (e.hasMoreElements ()) { +var key = e.nextElement (); +var pa = this.h.get (key); +var pi = pa.maxChars (); +pi.inc (); +count.maxeq (pi); +} +return count; +}); +Clazz.defineMethod (c$, "minChars", +function () { +var e = this.h.keys (); +var count = new com.stevesoft.pat.patInt (0); +while (e.hasMoreElements ()) { +var key = e.nextElement (); +var pa = this.h.get (key); +var pi = pa.minChars (); +pi.inc (); +count.mineq (pi); +} +return count; +}); +Clazz.defineMethod (c$, "addc", +function (o, ignoreCase, dontMinQ) { +var n = o.next; +if (n == null) { +n = new com.stevesoft.pat.NullPattern (); +} else { +n = com.stevesoft.pat.RegOpt.opt (n, ignoreCase, dontMinQ); +}n.setParent (this); +this.set ( new Character (o.c), n, ignoreCase, dontMinQ); +if (ignoreCase) { +if (o.c != o.altc) { +this.set ( new Character (o.altc), n, ignoreCase, dontMinQ); +}if (o.c != o.altc2 && o.altc != o.altc2) { +this.set ( new Character (o.altc2), n, ignoreCase, dontMinQ); +}}}, "com.stevesoft.pat.oneChar,~B,~B"); +Clazz.defineMethod (c$, "set", +function (c, n, igc, dontMinQ) { +var p = this.h.get (c); +this.next = null; +if (p == null) { +if (Clazz.instanceOf (n, com.stevesoft.pat.Or)) { +var np = new com.stevesoft.pat.NullPattern (); +np.add (n); +this.h.put (c, np); +} else { +this.h.put (c, n); +}this.keys.addElement (c); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or)) { +(p).addOr (n); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (n, com.stevesoft.pat.oneChar) && (p).c != (n).c) { +var b = new com.stevesoft.pat.Branch (); +b.addc (p, igc, dontMinQ); +b.addc (n, igc, dontMinQ); +this.h.put (c, b); +b.setParent (this); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Branch) && Clazz.instanceOf (n, com.stevesoft.pat.oneChar)) { +(p).addc (n, igc, dontMinQ); +n.setParent (p); +} else { +var o = new com.stevesoft.pat.Or (); +o.setParent (this); +if (Clazz.instanceOf (p, com.stevesoft.pat.NullPattern) && p.parent == null && p.next != null) { +o.addOr (p.next); +} else { +o.addOr (p); +}o.addOr (n); +var optpat = com.stevesoft.pat.RegOpt.opt (o, igc, dontMinQ); +this.h.put (c, optpat); +optpat.setParent (this); +}}, "Character,com.stevesoft.pat.Pattern,~B,~B"); +Clazz.overrideMethod (c$, "toString", +function () { +var sb = new StringBuffer (); +sb.append ("(?:(?#branch)"); +for (var i = 0; i < this.keys.size (); i++) { +var c = this.keys.elementAt (i); +sb.append (c); +sb.append (this.h.get (c)); +if (i + 1 < this.keys.size ()) { +sb.append ("|"); +}} +sb.append (")"); +sb.append (this.nextString ()); +return sb.toString (); +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +if (pos >= pt.src.length ()) { +return -1; +}var n = this.h.get ( new Character (pt.src.charAt (pos))); +if (n == null) { +return -1; +}if (pt.cbits != null && pt.cbits.get (pos)) { +return -1; +}return n.matchInternal (pos + 1, pt); +}, "~N,com.stevesoft.pat.Pthings"); +c$ = Clazz.declareType (com.stevesoft.pat, "RegOpt"); +c$.opt = Clazz.defineMethod (c$, "opt", +function (p, ignoreCase, dontMinQ) { +if (p == null) { +return p; +}if (Clazz.instanceOf (p, com.stevesoft.pat.Bracket)) { +var b = p; +p = com.stevesoft.pat.FastBracket.process (b, ignoreCase); +p.next = b.next; +p.parent = b.parent; +} else if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && !ignoreCase && !dontMinQ) { +var o = p; +p = new com.stevesoft.pat.FastChar (o.c); +p.next = o.next; +p.parent = o.parent; +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or) && (p).leftForm ().equals ("(?:") && (p).v.size () == 1) { +var o = p; +p = o.v.elementAt (0); +p.setParent (null); +p = com.stevesoft.pat.RegOpt.opt (p, ignoreCase, dontMinQ); +p.add (o.next); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or)) { +var o = p; +o.pv = null; +var v = o.v; +o.v = new java.util.Vector (); +var b = new com.stevesoft.pat.Branch (); +b.parent = o.parent; +for (var i = 0; i < v.size (); i++) { +var pp = v.elementAt (i); +if (Clazz.instanceOf (pp, com.stevesoft.pat.oneChar) && (b.h.size () >= 1 || (i + 1 < v.size () && Clazz.instanceOf (v.elementAt (i + 1), com.stevesoft.pat.oneChar)))) { +b.addc (pp, ignoreCase, dontMinQ); +} else { +if (b.keys.size () > 0) { +var p2 = b.reduce (ignoreCase, dontMinQ); +if (p2 != null) { +o.addOr (p2); +b = new com.stevesoft.pat.Branch (); +b.parent = o.parent; +}}o.addOr (com.stevesoft.pat.RegOpt.opt (pp, ignoreCase, dontMinQ)); +}} +if (b.keys.size () > 0) { +var p2 = b.reduce (ignoreCase, dontMinQ); +if (p2 != null) { +o.addOr (p2); +}}if (o.v.size () == 1 && o.leftForm ().equals ("(?:")) { +p = o.v.elementAt (0); +p.setParent (null); +p = com.stevesoft.pat.RegOpt.opt (p, ignoreCase, dontMinQ); +p.add (o.next); +}} else if (Clazz.instanceOf (p, com.stevesoft.pat.FastMulti)) { +var ps = p; +ps.sub = com.stevesoft.pat.RegOpt.opt (ps.sub, ignoreCase, dontMinQ); +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Multi) && com.stevesoft.pat.RegOpt.safe4fm ((p).sub)) { +var m = p; +var fm = null; +try { +fm = new com.stevesoft.pat.FastMulti (m.a, m.b, com.stevesoft.pat.RegOpt.opt (m.sub, ignoreCase, dontMinQ)); +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +} else { +throw rs; +} +} +fm.parent = m.parent; +fm.matchFewest = m.matchFewest; +fm.next = m.next; +p = fm; +}if (p.next != null) { +p.next = com.stevesoft.pat.RegOpt.opt (p.next, ignoreCase, dontMinQ); +}return p; +}, "com.stevesoft.pat.Pattern,~B,~B"); +c$.safe4fm = Clazz.defineMethod (c$, "safe4fm", +function (x) { +while (x != null) { +if (Clazz.instanceOf (x, com.stevesoft.pat.Bracket)) { +;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Range)) { +;} else if (Clazz.instanceOf (x, com.stevesoft.pat.oneChar)) { +;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Any)) { +;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Custom) && Clazz.instanceOf ((x).v, com.stevesoft.pat.UniValidator)) { +;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Or)) { +var o = x; +if (!o.leftForm ().equals ("(?:")) { +return false; +}var lo = o.countMinChars (); +var hi = o.countMaxChars (); +if (!lo.equals (hi)) { +return false; +}for (var i = 0; i < o.v.size (); i++) { +if (!com.stevesoft.pat.RegOpt.safe4fm (o.v.elementAt (i))) { +return false; +}} +} else { +return false; +}x = x.next; +} +return true; +}, "com.stevesoft.pat.Pattern"); +}); diff --git a/bin/com/stevesoft/pat/RegRes.js b/bin/com/stevesoft/pat/RegRes.js index 9a31c29..ec4def1 100644 --- a/bin/com/stevesoft/pat/RegRes.js +++ b/bin/com/stevesoft/pat/RegRes.js @@ -1,155 +1,155 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.RegRes", ["java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.marks = null; -this.didMatch_ = false; -this.src = null; -this.charsMatched_ = 0; -this.matchFrom_ = 0; -this.numSubs_ = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegRes"); -Clazz.defineMethod (c$, "getString", -function () { -return this.src.toString (); -}); -Clazz.defineMethod (c$, "getStringLike", -function () { -return this.src; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var sb = new StringBuffer (); -sb.append ("match=" + this.matchedFrom () + ":" + this.charsMatched ()); -if (!this.didMatch ()) { -return sb.toString (); -}for (var i = 0; i < this.numSubs (); i++) { -var n = i + 1; -sb.append (" sub(" + n + ")=" + this.matchedFromI (n) + ":" + this.charsMatchedI (n)); -} -return sb.toString (); -}); -Clazz.defineMethod (c$, "copyOutOf", -function (r) { -if (r.marks == null) { -this.marks = null; -} else { -try { -this.marks = Clazz.newIntArray (r.marks.length, 0); -for (var i = 0; i < this.marks.length; i++) { -this.marks[i] = r.marks[i]; -} -} catch (t) { -} -}this.didMatch_ = r.didMatch_; -this.src = r.src; -this.charsMatched_ = r.charsMatched_; -this.matchFrom_ = r.matchFrom_; -this.numSubs_ = r.numSubs_; -}, "com.stevesoft.pat.RegRes"); -Clazz.defineMethod (c$, "equals", -function (r) { -if (this.charsMatched_ != r.charsMatched_ || this.matchFrom_ != r.matchFrom_ || this.didMatch_ != r.didMatch_ || this.numSubs_ != r.numSubs_ || !this.src.unwrap ().equals (r.src.unwrap ())) { -return false; -}if (this.marks == null && r.marks != null) { -return false; -}if (this.marks != null && r.marks == null) { -return false; -}for (var i = 1; i <= this.numSubs_; i++) { -if (this.matchedFromI (i) != r.matchedFromI (i)) { -return false; -} else if (this.charsMatchedI (i) != r.charsMatchedI (i)) { -return false; -}} -return true; -}, "com.stevesoft.pat.RegRes"); -Clazz.defineMethod (c$, "stringMatched", -function () { -var mf = this.matchedFrom (); -var cm = this.charsMatched (); -return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf, mf + cm); -}); -Clazz.defineMethod (c$, "matchedFromI", -function (i) { -if (this.marks == null || i > this.numSubs_) { -return -1; -}return this.marks[i]; -}, "~N"); -Clazz.defineMethod (c$, "charsMatchedI", -function (i) { -if (this.marks == null || i > this.numSubs_ || !this.didMatch_) { -return -1; -}var mf = this.matchedFromI (i); -return mf < 0 ? -1 : this.marks[i + this.numSubs_] - this.matchedFromI (i); -}, "~N"); -Clazz.defineMethod (c$, "matchedToI", -function (i) { -if (this.marks == null || i > this.numSubs_ || !this.didMatch_) { -return -1; -}return this.marks[i + this.numSubs_]; -}, "~N"); -Clazz.defineMethod (c$, "stringMatchedI", -function (i) { -var mf = this.matchedFromI (i); -var cm = this.charsMatchedI (i); -return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf, mf + cm); -}, "~N"); -Clazz.defineMethod (c$, "left", -function () { -var mf = this.matchedFrom (); -return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf); -}); -Clazz.defineMethod (c$, "leftI", -function (i) { -var mf = this.matchedFromI (i); -return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf); -}, "~N"); -Clazz.defineMethod (c$, "right", -function () { -var mf = this.matchedFrom (); -var cm = this.charsMatched (); -return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf + cm, this.src.length ()); -}); -Clazz.defineMethod (c$, "rightI", -function (i) { -var mf = this.matchedFromI (i); -var cm = this.charsMatchedI (i); -return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf + cm, this.src.length ()); -}, "~N"); -Clazz.defineMethod (c$, "matchedFrom", -function () { -return !this.didMatch_ ? -1 : this.matchFrom_; -}); -Clazz.defineMethod (c$, "charsMatched", -function () { -return !this.didMatch_ || this.matchFrom_ < 0 ? -1 : this.charsMatched_; -}); -Clazz.defineMethod (c$, "matchedTo", -function () { -return !this.didMatch_ ? -1 : this.matchFrom_ + this.charsMatched_; -}); -Clazz.defineMethod (c$, "numSubs", -function () { -return this.numSubs_; -}); -Clazz.defineMethod (c$, "didMatch", -function () { -return this.didMatch_; -}); -Clazz.defineMethod (c$, "matchFrom", -function () { -return this.matchedFrom (); -}); -Clazz.defineMethod (c$, "substring", -function () { -return this.stringMatched (); -}); -Clazz.defineMethod (c$, "matchFromI", -function (i) { -return this.matchedFromI (i); -}, "~N"); -Clazz.defineMethod (c$, "substringI", -function (i) { -return this.stringMatchedI (i); -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.RegRes", ["java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.marks = null; +this.didMatch_ = false; +this.src = null; +this.charsMatched_ = 0; +this.matchFrom_ = 0; +this.numSubs_ = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegRes"); +Clazz.defineMethod (c$, "getString", +function () { +return this.src.toString (); +}); +Clazz.defineMethod (c$, "getStringLike", +function () { +return this.src; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var sb = new StringBuffer (); +sb.append ("match=" + this.matchedFrom () + ":" + this.charsMatched ()); +if (!this.didMatch ()) { +return sb.toString (); +}for (var i = 0; i < this.numSubs (); i++) { +var n = i + 1; +sb.append (" sub(" + n + ")=" + this.matchedFromI (n) + ":" + this.charsMatchedI (n)); +} +return sb.toString (); +}); +Clazz.defineMethod (c$, "copyOutOf", +function (r) { +if (r.marks == null) { +this.marks = null; +} else { +try { +this.marks = Clazz.newIntArray (r.marks.length, 0); +for (var i = 0; i < this.marks.length; i++) { +this.marks[i] = r.marks[i]; +} +} catch (t) { +} +}this.didMatch_ = r.didMatch_; +this.src = r.src; +this.charsMatched_ = r.charsMatched_; +this.matchFrom_ = r.matchFrom_; +this.numSubs_ = r.numSubs_; +}, "com.stevesoft.pat.RegRes"); +Clazz.defineMethod (c$, "equals", +function (r) { +if (this.charsMatched_ != r.charsMatched_ || this.matchFrom_ != r.matchFrom_ || this.didMatch_ != r.didMatch_ || this.numSubs_ != r.numSubs_ || !this.src.unwrap ().equals (r.src.unwrap ())) { +return false; +}if (this.marks == null && r.marks != null) { +return false; +}if (this.marks != null && r.marks == null) { +return false; +}for (var i = 1; i <= this.numSubs_; i++) { +if (this.matchedFromI (i) != r.matchedFromI (i)) { +return false; +} else if (this.charsMatchedI (i) != r.charsMatchedI (i)) { +return false; +}} +return true; +}, "com.stevesoft.pat.RegRes"); +Clazz.defineMethod (c$, "stringMatched", +function () { +var mf = this.matchedFrom (); +var cm = this.charsMatched (); +return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf, mf + cm); +}); +Clazz.defineMethod (c$, "matchedFromI", +function (i) { +if (this.marks == null || i > this.numSubs_) { +return -1; +}return this.marks[i]; +}, "~N"); +Clazz.defineMethod (c$, "charsMatchedI", +function (i) { +if (this.marks == null || i > this.numSubs_ || !this.didMatch_) { +return -1; +}var mf = this.matchedFromI (i); +return mf < 0 ? -1 : this.marks[i + this.numSubs_] - this.matchedFromI (i); +}, "~N"); +Clazz.defineMethod (c$, "matchedToI", +function (i) { +if (this.marks == null || i > this.numSubs_ || !this.didMatch_) { +return -1; +}return this.marks[i + this.numSubs_]; +}, "~N"); +Clazz.defineMethod (c$, "stringMatchedI", +function (i) { +var mf = this.matchedFromI (i); +var cm = this.charsMatchedI (i); +return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf, mf + cm); +}, "~N"); +Clazz.defineMethod (c$, "left", +function () { +var mf = this.matchedFrom (); +return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf); +}); +Clazz.defineMethod (c$, "leftI", +function (i) { +var mf = this.matchedFromI (i); +return !this.didMatch_ || (mf < 0) ? null : this.src.substring (0, mf); +}, "~N"); +Clazz.defineMethod (c$, "right", +function () { +var mf = this.matchedFrom (); +var cm = this.charsMatched (); +return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf + cm, this.src.length ()); +}); +Clazz.defineMethod (c$, "rightI", +function (i) { +var mf = this.matchedFromI (i); +var cm = this.charsMatchedI (i); +return !this.didMatch_ || mf < 0 || cm < 0 ? null : this.src.substring (mf + cm, this.src.length ()); +}, "~N"); +Clazz.defineMethod (c$, "matchedFrom", +function () { +return !this.didMatch_ ? -1 : this.matchFrom_; +}); +Clazz.defineMethod (c$, "charsMatched", +function () { +return !this.didMatch_ || this.matchFrom_ < 0 ? -1 : this.charsMatched_; +}); +Clazz.defineMethod (c$, "matchedTo", +function () { +return !this.didMatch_ ? -1 : this.matchFrom_ + this.charsMatched_; +}); +Clazz.defineMethod (c$, "numSubs", +function () { +return this.numSubs_; +}); +Clazz.defineMethod (c$, "didMatch", +function () { +return this.didMatch_; +}); +Clazz.defineMethod (c$, "matchFrom", +function () { +return this.matchedFrom (); +}); +Clazz.defineMethod (c$, "substring", +function () { +return this.stringMatched (); +}); +Clazz.defineMethod (c$, "matchFromI", +function (i) { +return this.matchedFromI (i); +}, "~N"); +Clazz.defineMethod (c$, "substringI", +function (i) { +return this.stringMatchedI (i); +}, "~N"); +}); diff --git a/bin/com/stevesoft/pat/RegSyntax.js b/bin/com/stevesoft/pat/RegSyntax.js index 8a6e621..9275c48 100644 --- a/bin/com/stevesoft/pat/RegSyntax.js +++ b/bin/com/stevesoft/pat/RegSyntax.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.lang.Exception"], "com.stevesoft.pat.RegSyntax", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "RegSyntax", Exception); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.RegSyntax, []); -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.lang.Exception"], "com.stevesoft.pat.RegSyntax", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "RegSyntax", Exception); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.RegSyntax, []); +}); +}); diff --git a/bin/com/stevesoft/pat/RegSyntaxError.js b/bin/com/stevesoft/pat/RegSyntaxError.js index 3a127a5..5a81c21 100644 --- a/bin/com/stevesoft/pat/RegSyntaxError.js +++ b/bin/com/stevesoft/pat/RegSyntaxError.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.lang.Error"], "com.stevesoft.pat.RegSyntaxError", ["com.stevesoft.pat.RegSyntax"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "RegSyntaxError", Error); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.RegSyntaxError, []); -}); -c$.endItAll = Clazz.defineMethod (c$, "endItAll", -function (s) { -if (com.stevesoft.pat.RegSyntaxError.RegSyntaxErrorEnabled) { -throw new com.stevesoft.pat.RegSyntaxError (s); -}throw new com.stevesoft.pat.RegSyntax (s); -}, "~S"); -Clazz.defineStatics (c$, -"RegSyntaxErrorEnabled", false); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.lang.Error"], "com.stevesoft.pat.RegSyntaxError", ["com.stevesoft.pat.RegSyntax"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "RegSyntaxError", Error); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.RegSyntaxError, []); +}); +c$.endItAll = Clazz.defineMethod (c$, "endItAll", +function (s) { +if (com.stevesoft.pat.RegSyntaxError.RegSyntaxErrorEnabled) { +throw new com.stevesoft.pat.RegSyntaxError (s); +}throw new com.stevesoft.pat.RegSyntax (s); +}, "~S"); +Clazz.defineStatics (c$, +"RegSyntaxErrorEnabled", false); +}); diff --git a/bin/com/stevesoft/pat/Regex.js b/bin/com/stevesoft/pat/Regex.js index 893eaa7..d05b95e 100644 --- a/bin/com/stevesoft/pat/Regex.js +++ b/bin/com/stevesoft/pat/Regex.js @@ -1,1026 +1,1026 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.RegRes", "$.UniValidator", "jalview.jsdev.api.RegExpInterface", "com.stevesoft.pat.NoPattern", "$.Pthings", "$.patInt", "java.util.Hashtable"], ["com.stevesoft.pat.UnicodeW", "$.UnicodeCurrency", "$.UnicodeAlpha", "$.UnicodeUpper", "$.NUnicodeCurrency", "$.NUnicodeW", "$.NUnicodeAlpha", "$.UnicodeMath", "$.UnicodeWhite", "$.UnicodeDigit", "$.NUnicodeMath", "$.Regex", "$.NUnicodeDigit", "$.NUnicodeWhite", "$.NUnicodePunct", "$.UnicodePunct", "$.UnicodeLower"], ["com.stevesoft.pat.Any", "$.BackG", "$.BackMatch", "$.Backup", "$.Boundary", "$.Bracket", "$.CaseMgr", "$.Ctrl", "$.Custom", "$.CustomEndpoint", "$.DotMulti", "$.End", "$.FastMulti", "$.Group", "$.MessageManager", "$.Multi", "$.NullPattern", "$.Or", "$.OrMark", "$.Prop", "$.Range", "$.RegOpt", "$.RegSyntax", "$.RegSyntaxError", "$.ReplaceRule", "$.Replacer", "$.Rthings", "$.Skip", "$.Skipped", "$.Start", "$.StrPos", "$.lookAhead", "$.oneChar", "$.parsePerl", "$.patInf", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException", "$.StringBuffer", "java.util.BitSet"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodePunct", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeWhite", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodePunct", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && !com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeWhite", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && !com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeW", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -if (from >= s.length ()) { -return -1; -}var c = s.charAt (from); -return (com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeW", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -if (from >= s.length ()) { -return -1; -}var c = s.charAt (from); -return !(com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeDigit", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeDigit", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && !com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeMath", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeMath", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && !com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeCurrency", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeCurrency", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && !com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeAlpha", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeAlpha", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && !com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeUpper", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && this.isUpper (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "isUpper", -function (c) { -return c == com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c != com.stevesoft.pat.CaseMgr.toLowerCaseC (c); -}, "~S"); -c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeLower", com.stevesoft.pat.UniValidator); -Clazz.overrideMethod (c$, "validate", -function (s, from, to) { -return from < s.length () && this.isLower (s.charAt (from)) ? to : -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "isLower", -function (c) { -return c != com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c == com.stevesoft.pat.CaseMgr.toLowerCaseC (c); -}, "~S"); -c$ = Clazz.decorateAsClass (function () { -this.thePattern = null; -this.minMatch = null; -this.rep = null; -this.dontMatchInQuotes = false; -this.ignoreCase = false; -this.repr = null; -this.esc = '\\'; -this.pt = null; -this.gFlags = null; -this.gFlagto = 0; -this.gFlag = false; -this.sFlag = false; -this.mFlag = false; -this.p = null; -this.or = null; -this.skipper = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Regex", com.stevesoft.pat.RegRes, [jalview.jsdev.api.RegExpInterface, Cloneable]); -Clazz.prepareFields (c$, function () { -this.thePattern = com.stevesoft.pat.Regex.none; -this.minMatch = new com.stevesoft.pat.patInt (0); -this.pt = new com.stevesoft.pat.Pthings (); -}); -Clazz.makeConstructor (c$, -function (s, strRp) { -Clazz.superConstructor (this, com.stevesoft.pat.Regex, []); -try { -if (s != null) this.compile (s); -if (strRp.length > 0) this.rep = com.stevesoft.pat.ReplaceRule.perlCode (strRp); -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -} else { -throw rs; -} -} -}, "~S,~S"); -Clazz.overrideMethod (c$, "clone", -function () { -return new com.stevesoft.pat.Regex (null, "").cloneFrom (this); -}); -Clazz.defineMethod (c$, "cloneFrom", -function (r) { -this.copyOutOf (r); -this.dontMatchInQuotes = r.dontMatchInQuotes; -this.esc = r.esc; -this.ignoreCase = r.ignoreCase; -this.gFlag = r.gFlag; -if (r.rep == null) { -this.rep = null; -} else { -this.rep = r.rep.clone (); -}this.thePattern = r.thePattern.clone ( new java.util.Hashtable ()); -this.minMatch = r.minMatch; -this.skipper = r.skipper; -return this; -}, "com.stevesoft.pat.Regex"); -Clazz.defineMethod (c$, "setDontMatchInQuotes", -function (b) { -this.dontMatchInQuotes = b; -}, "~B"); -Clazz.defineMethod (c$, "getDontMatchInQuotes", -function () { -return this.dontMatchInQuotes; -}); -Clazz.overrideMethod (c$, "setIgnoreCase", -function (b) { -this.ignoreCase = b; -}, "~B"); -Clazz.defineMethod (c$, "getIgnoreCase", -function () { -return this.ignoreCase; -}); -c$.setDefaultMFlag = Clazz.defineMethod (c$, "setDefaultMFlag", -function (mFlag) { -com.stevesoft.pat.Regex.defaultMFlag = mFlag; -}, "~B"); -c$.getDefaultMFlag = Clazz.defineMethod (c$, "getDefaultMFlag", -function () { -return com.stevesoft.pat.Regex.defaultMFlag; -}); -Clazz.defineMethod (c$, "setReplaceRuleStr", -function (rp) { -this.rep = com.stevesoft.pat.ReplaceRule.perlCode (rp); -this.repr = null; -}, "~S"); -Clazz.defineMethod (c$, "setReplaceRule", -function (rp) { -this.rep = rp; -}, "com.stevesoft.pat.ReplaceRule"); -c$.isDefined = Clazz.defineMethod (c$, "isDefined", -function (nm) { -return com.stevesoft.pat.Regex.validators.get (nm) != null; -}, "~S"); -c$.undefine = Clazz.defineMethod (c$, "undefine", -function (nm) { -com.stevesoft.pat.Regex.validators.remove (nm); -}, "~S"); -c$.defineV = Clazz.defineMethod (c$, "defineV", -function (nm, pat, v) { -v.pattern = pat; -com.stevesoft.pat.Regex.validators.put (nm, v); -}, "~S,~S,com.stevesoft.pat.Validator"); -c$.define = Clazz.defineMethod (c$, "define", -function (nm, pat) { -com.stevesoft.pat.Regex.validators.put (nm, pat); -}, "~S,~S"); -Clazz.defineMethod (c$, "getReplaceRule", -function () { -return this.rep; -}); -Clazz.defineMethod (c$, "_getReplacer", -function () { -return this.repr == null ? this.repr = new com.stevesoft.pat.Replacer () : this.repr; -}); -Clazz.defineMethod (c$, "getReplacer", -function () { -if (this.repr == null) { -this.repr = new com.stevesoft.pat.Replacer (); -}this.repr.rh.me = this; -this.repr.rh.prev = null; -return this.repr; -}); -Clazz.defineMethod (c$, "replaceFirst", -function (s) { -return this._getReplacer ().replaceFirstRegion (s, this, 0, s.length).toString (); -}, "~S"); -Clazz.defineMethod (c$, "replaceFirstFrom", -function (s, pos) { -return this._getReplacer ().replaceFirstRegion (s, this, pos, s.length).toString (); -}, "~S,~N"); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, start, end) { -return this._getReplacer ().replaceFirstRegion (s, this, start, end).toString (); -}, "~S,~N,~N"); -Clazz.overrideMethod (c$, "replaceAll", -function (s) { -return this._getReplacer ().replaceAllRegion (s, this, 0, s.length).toString (); -}, "~S"); -Clazz.defineMethod (c$, "replaceAllLike", -function (s) { -return this._getReplacer ().replaceAllRegion (s, this, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "replaceAllFrom", -function (s, pos) { -return this._getReplacer ().replaceAllRegion (s, this, pos, s.length).toString (); -}, "~S,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, start, end) { -return this._getReplacer ().replaceAllRegion (s, this, start, end).toString (); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "compile", -function (prepat) { -var postpat = com.stevesoft.pat.parsePerl.codify (prepat, true); -var pat = postpat == null ? prepat : postpat; -this.minMatch = null; -this.ignoreCase = false; -this.dontMatchInQuotes = false; -var mk = new com.stevesoft.pat.Rthings (this); -var offset = mk.val; -var newpat = pat; -this.thePattern = com.stevesoft.pat.Regex.none; -this.p = null; -this.or = null; -this.minMatch = new com.stevesoft.pat.patInt (0); -var sp = new com.stevesoft.pat.StrPos (pat, 0); -if (sp.incMatch ("(?e=")) { -var newEsc = sp.c; -sp.inc (); -if (sp.match (')')) { -newpat = com.stevesoft.pat.Regex.reEscape (pat.substring (6), newEsc, '\\'); -}} else if (this.esc != '\\') { -newpat = com.stevesoft.pat.Regex.reEscape (pat, this.esc, '\\'); -}this.thePattern = this._compile (newpat, mk); -this.numSubs_ = mk.val - offset; -mk.set (this); -}, "~S"); -Clazz.defineMethod (c$, "equals", -function (o) { -if (Clazz.instanceOf (o, com.stevesoft.pat.Regex)) { -if (this.toString ().equals (o.toString ())) { -return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]); -} else { -return false; -}} else { -return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]); -}}, "~O"); -Clazz.defineMethod (c$, "prep", -function (s) { -this.pt.lastPos = this.matchedTo (); -if (this.pt.lastPos < 0) { -this.pt.lastPos = 0; -}if ((s == null ? null : s.unwrap ()) !== (this.src == null ? null : s.unwrap ())) { -this.pt.lastPos = 0; -}this.src = s; -this.pt.dotDoesntMatchCR = com.stevesoft.pat.Regex.dotDoesntMatchCR && (!this.sFlag); -this.pt.mFlag = ( new Boolean (this.mFlag | com.stevesoft.pat.Regex.defaultMFlag).valueOf ()); -this.pt.ignoreCase = this.ignoreCase; -this.pt.no_check = false; -if (this.pt.marks != null) { -for (var i = 0; i < this.pt.marks.length; i++) { -this.pt.marks[i] = -1; -} -}this.pt.marks = null; -this.pt.nMarks = this.numSubs_; -this.pt.src = s; -if (this.dontMatchInQuotes) { -com.stevesoft.pat.Regex.setCbits (s, this.pt); -} else { -this.pt.cbits = null; -}return this.pt; -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "matchAt", -function (s, start_pos) { -return this._search (s, start_pos, start_pos); -}, "~S,~N"); -Clazz.defineMethod (c$, "matchAtLike", -function (s, start_pos) { -return this._searchLike (s, start_pos, start_pos); -}, "com.stevesoft.pat.StringLike,~N"); -Clazz.overrideMethod (c$, "search", -function (s) { -if (s == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_search")); -}return this._search (s, 0, s.length); -}, "~S"); -Clazz.defineMethod (c$, "searchLike", -function (sl) { -if (sl == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search")); -}return this._searchLike (sl, 0, sl.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "reverseSearch", -function (s) { -if (s == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_reverse_search")); -}return this._reverseSearch (s, 0, s.length); -}, "~S"); -Clazz.defineMethod (c$, "reverseSearchLike", -function (sl) { -if (sl == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_reverse_search")); -}return this._reverseSearchLike (sl, 0, sl.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.overrideMethod (c$, "searchFrom", -function (s, start) { -if (s == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from")); -}return this._search (s, start, s.length); -}, "~S,~N"); -Clazz.defineMethod (c$, "searchFromLike", -function (s, start) { -if (s == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from")); -}return this._searchLike (s, start, s.length ()); -}, "com.stevesoft.pat.StringLike,~N"); -Clazz.defineMethod (c$, "searchRegion", -function (s, start, end) { -if (s == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_region")); -}return this._search (s, start, end); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "setGFlag", -function (b) { -this.gFlag = b; -}, "~B"); -Clazz.defineMethod (c$, "getGFlag", -function () { -return this.gFlag; -}); -Clazz.defineMethod (c$, "getSFlag", -function () { -return this.sFlag; -}); -Clazz.defineMethod (c$, "getMFlag", -function () { -return this.mFlag; -}); -Clazz.defineMethod (c$, "_search", -function (s, start, end) { -return this._searchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "_searchLike", -function (s, start, end) { -if (this.gFlag && this.gFlagto > 0 && this.gFlags != null && s.unwrap () === this.gFlags.unwrap ()) { -start = this.gFlagto; -}this.gFlags = null; -var pt = this.prep (s); -var up = (this.minMatch == null ? end : end - this.minMatch.i); -if (up < start && end >= start) { -up = start; -}if (this.skipper == null) { -for (var i = start; i <= up; i++) { -this.charsMatched_ = this.thePattern.matchAt (s, i, pt); -if (this.charsMatched_ >= 0) { -this.matchFrom_ = this.thePattern.mfrom; -this.marks = pt.marks; -this.gFlagto = this.matchFrom_ + this.charsMatched_; -this.gFlags = s; -return this.didMatch_ = true; -}} -} else { -pt.no_check = true; -for (var i = start; i <= up; i++) { -i = this.skipper.find (this.src, i, up); -if (i < 0) { -this.charsMatched_ = this.matchFrom_ = -1; -return this.didMatch_ = false; -}this.charsMatched_ = this.thePattern.matchAt (s, i, pt); -if (this.charsMatched_ >= 0) { -this.matchFrom_ = this.thePattern.mfrom; -this.marks = pt.marks; -this.gFlagto = this.matchFrom_ + this.charsMatched_; -this.gFlags = s; -return this.didMatch_ = true; -}} -}return this.didMatch_ = false; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "_reverseSearch", -function (s, start, end) { -return this._reverseSearchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "_reverseSearchLike", -function (s, start, end) { -if (this.gFlag && this.gFlagto > 0 && s.unwrap () === this.gFlags.unwrap ()) { -end = this.gFlagto; -}this.gFlags = null; -var pt = this.prep (s); -for (var i = end; i >= start; i--) { -this.charsMatched_ = this.thePattern.matchAt (s, i, pt); -if (this.charsMatched_ >= 0) { -this.matchFrom_ = this.thePattern.mfrom; -this.marks = pt.marks; -this.gFlagto = this.matchFrom_ - 1; -this.gFlags = s; -return this.didMatch_ = true; -}} -return this.didMatch_ = false; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$.setCbits = Clazz.defineMethod (c$, "setCbits", -function (s, pt) { -if (s === com.stevesoft.pat.Regex.lasts) { -pt.cbits = com.stevesoft.pat.Regex.lastbs; -return; -}var bs = new java.util.BitSet (s.length ()); -var qc = ' '; -var setBit = false; -for (var i = 0; i < s.length (); i++) { -if (setBit) { -bs.set (i); -}var c = s.charAt (i); -if (!setBit && c == '"') { -qc = c; -setBit = true; -bs.set (i); -} else if (!setBit && c == '\'') { -qc = c; -setBit = true; -bs.set (i); -} else if (setBit && c == qc) { -setBit = false; -} else if (setBit && c == '\\' && i + 1 < s.length ()) { -i++; -if (setBit) { -bs.set (i); -}}} -pt.cbits = com.stevesoft.pat.Regex.lastbs = bs; -com.stevesoft.pat.Regex.lasts = s; -}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "add", -function (p2) { -if (this.p == null) { -this.p = p2; -} else { -this.p.add (p2); -p2 = this.p; -}}, "com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "compileSP", -function (sp, mk) { -if (sp.match ('[')) { -sp.inc (); -this.add (this.matchBracket (sp)); -} else if (sp.match ('|')) { -if (this.or == null) { -this.or = new com.stevesoft.pat.Or (); -}if (this.p == null) { -this.p = new com.stevesoft.pat.NullPattern (); -}this.or.addOr (this.p); -this.p = null; -} else if (sp.incMatch ("(?<")) { -var i = sp.getPatInt (); -if (i == null) { -com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?<"); -}this.add ( new com.stevesoft.pat.Backup (i.intValue ())); -if (!sp.match (')')) { -com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<"); -}} else if (sp.incMatch ("(?>")) { -var i = sp.getPatInt (); -if (i == null) { -com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?>"); -}this.add ( new com.stevesoft.pat.Backup (-i.intValue ())); -if (!sp.match (')')) { -com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<"); -}} else if (sp.incMatch ("(?@")) { -var op = sp.c; -sp.inc (); -var cl = sp.c; -sp.inc (); -if (!sp.match (')')) { -com.stevesoft.pat.RegSyntaxError.endItAll ("(?@ does not have closing paren"); -}this.add ( new com.stevesoft.pat.Group (op, cl)); -} else if (sp.incMatch ("(?#")) { -while (!sp.match (')')) { -sp.inc (); -} -} else if (sp.dontMatch && sp.c == 'w') { -var b = new com.stevesoft.pat.Bracket (false); -b.addOr ( new com.stevesoft.pat.Range ('a', 'z')); -b.addOr ( new com.stevesoft.pat.Range ('A', 'Z')); -b.addOr ( new com.stevesoft.pat.Range ('0', '9')); -b.addOr ( new com.stevesoft.pat.oneChar ('_')); -this.add (b); -} else if (sp.dontMatch && sp.c == 'G') { -this.add ( new com.stevesoft.pat.BackG ()); -} else if (sp.dontMatch && sp.c == 's') { -var b = new com.stevesoft.pat.Bracket (false); -b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32))); -b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10))); -b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13))); -this.add (b); -} else if (sp.dontMatch && sp.c == 'd') { -var digit = new com.stevesoft.pat.Range ('0', '9'); -digit.printBrackets = true; -this.add (digit); -} else if (sp.dontMatch && sp.c == 'W') { -var b = new com.stevesoft.pat.Bracket (true); -b.addOr ( new com.stevesoft.pat.Range ('a', 'z')); -b.addOr ( new com.stevesoft.pat.Range ('A', 'Z')); -b.addOr ( new com.stevesoft.pat.Range ('0', '9')); -b.addOr ( new com.stevesoft.pat.oneChar ('_')); -this.add (b); -} else if (sp.dontMatch && sp.c == 'S') { -var b = new com.stevesoft.pat.Bracket (true); -b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32))); -b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10))); -b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13))); -this.add (b); -} else if (sp.dontMatch && sp.c == 'D') { -var b = new com.stevesoft.pat.Bracket (true); -b.addOr ( new com.stevesoft.pat.Range ('0', '9')); -this.add (b); -} else if (sp.dontMatch && sp.c == 'B') { -var r = new com.stevesoft.pat.Regex (null, ""); -r._compile ("(?!\\b)", mk); -this.add (r.thePattern); -} else if (this.isOctalString (sp)) { -var d = sp.c.charCodeAt (0) - 48; -sp.inc (); -d = 8 * d + sp.c.charCodeAt (0) - 48; -var sp2 = new com.stevesoft.pat.StrPos (sp); -sp2.inc (); -if (this.isOctalDigit (sp2, false)) { -sp.inc (); -d = 8 * d + sp.c.charCodeAt (0) - 48; -}this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); -} else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') { -var iv = sp.c.charCodeAt (0) - 48; -var s2 = new com.stevesoft.pat.StrPos (sp); -s2.inc (); -if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') { -iv = 10 * iv + (s2.c.charCodeAt (0) - 48); -sp.inc (); -}this.add ( new com.stevesoft.pat.BackMatch (iv)); -} else if (sp.dontMatch && sp.c == 'b') { -this.add ( new com.stevesoft.pat.Boundary ()); -} else if (sp.match ('\b')) { -this.add ( new com.stevesoft.pat.Boundary ()); -} else if (sp.match ('$')) { -this.add ( new com.stevesoft.pat.End (true)); -} else if (sp.dontMatch && sp.c == 'Z') { -this.add ( new com.stevesoft.pat.End (false)); -} else if (sp.match ('.')) { -this.add ( new com.stevesoft.pat.Any ()); -} else if (sp.incMatch ("(??")) { -var sb = new StringBuffer (); -var sb2 = new StringBuffer (); -while (!sp.match (')') && !sp.match (':')) { -sb.append (sp.c); -sp.inc (); -} -if (sp.incMatch (":")) { -while (!sp.match (')')) { -sb2.append (sp.c); -sp.inc (); -} -}var sbs = sb.toString (); -if (Clazz.instanceOf (com.stevesoft.pat.Regex.validators.get (sbs), String)) { -var pat = com.stevesoft.pat.Regex.validators.get (sbs); -var r = new com.stevesoft.pat.Regex (null, ""); -var rth = new com.stevesoft.pat.Rthings (this); -rth.noBackRefs = true; -r._compile (pat, rth); -this.add (r.thePattern); -} else { -var cm = new com.stevesoft.pat.Custom (sb.toString ()); -if (cm.v != null) { -var v2 = cm.v.arg (sb2.toString ()); -if (v2 != null) { -v2.argsave = sb2.toString (); -var p = cm.v.pattern; -cm.v = v2; -v2.pattern = p; -}var r = new com.stevesoft.pat.Regex (null, ""); -var rth = new com.stevesoft.pat.Rthings (this); -rth.noBackRefs = true; -r._compile (cm.v.pattern, rth); -cm.sub = r.thePattern; -cm.sub.add ( new com.stevesoft.pat.CustomEndpoint (cm)); -cm.sub.setParent (cm); -this.add (cm); -}}} else if (sp.match ('(')) { -mk.parenLevel++; -var r = new com.stevesoft.pat.Regex (null, ""); -sp.inc (); -if (sp.incMatch ("?:")) { -r.or = new com.stevesoft.pat.Or (); -} else if (sp.incMatch ("?=")) { -r.or = new com.stevesoft.pat.lookAhead (false); -} else if (sp.incMatch ("?!")) { -r.or = new com.stevesoft.pat.lookAhead (true); -} else if (sp.match ('?')) { -sp.inc (); -do { -if (sp.c == 'i') { -mk.ignoreCase = true; -}if (sp.c == 'Q') { -mk.dontMatchInQuotes = true; -}if (sp.c == 'o') { -mk.optimizeMe = true; -}if (sp.c == 'g') { -mk.gFlag = true; -}if (sp.c == 's') { -mk.sFlag = true; -}if (sp.c == 'm') { -mk.mFlag = true; -}sp.inc (); -} while (!sp.match (')') && !sp.$eos); -r = null; -mk.parenLevel--; -if (sp.$eos) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed ()"); -}} else { -r.or = mk.noBackRefs ? new com.stevesoft.pat.Or () : new com.stevesoft.pat.OrMark (mk.val++); -}if (r != null) { -this.add (r._compileSP (sp, mk)); -}} else if (sp.match ('^')) { -this.add ( new com.stevesoft.pat.Start (true)); -} else if (sp.dontMatch && sp.c == 'A') { -this.add ( new com.stevesoft.pat.Start (false)); -} else if (sp.match ('*')) { -this.addMulti ( new com.stevesoft.pat.patInt (0), new com.stevesoft.pat.patInf ()); -} else if (sp.match ('+')) { -this.addMulti ( new com.stevesoft.pat.patInt (1), new com.stevesoft.pat.patInf ()); -} else if (sp.match ('?')) { -this.addMulti ( new com.stevesoft.pat.patInt (0), new com.stevesoft.pat.patInt (1)); -} else if (sp.match ('{')) { -var bad = false; -var sp2 = new com.stevesoft.pat.StrPos (sp); -sp.inc (); -var i1 = sp.getPatInt (); -var i2 = null; -if (sp.match ('}')) { -i2 = i1; -} else { -if (!sp.match (',')) { -bad = true; -}sp.inc (); -if (sp.match ('}')) { -i2 = new com.stevesoft.pat.patInf (); -} else { -i2 = sp.getPatInt (); -}}if (i1 == null || i2 == null) { -bad = true; -}if (bad) { -sp.dup (sp2); -this.add ( new com.stevesoft.pat.oneChar (sp.c)); -} else { -this.addMulti (i1, i2); -}} else if (sp.escMatch ('x') && this.next2Hex (sp)) { -sp.inc (); -var d = this.getHexDigit (sp); -sp.inc (); -d = 16 * d + this.getHexDigit (sp); -this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); -} else if (sp.escMatch ('c')) { -sp.inc (); -if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) { -this.add ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)])); -} else { -this.add ( new com.stevesoft.pat.oneChar (sp.c)); -}} else if (sp.escMatch ('f')) { -this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (12))); -} else if (sp.escMatch ('a')) { -this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (7))); -} else if (sp.escMatch ('t')) { -this.add ( new com.stevesoft.pat.oneChar ('\t')); -} else if (sp.escMatch ('n')) { -this.add ( new com.stevesoft.pat.oneChar ('\n')); -} else if (sp.escMatch ('r')) { -this.add ( new com.stevesoft.pat.oneChar ('\r')); -} else if (sp.escMatch ('b')) { -this.add ( new com.stevesoft.pat.oneChar ('\b')); -} else if (sp.escMatch ('e')) { -this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (27))); -} else { -this.add ( new com.stevesoft.pat.oneChar (sp.c)); -if (sp.match (')')) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched right paren in pattern"); -}}}, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings"); -Clazz.defineMethod (c$, "_compile", -($fz = function (pat, mk) { -this.minMatch = null; -this.sFlag = this.mFlag = this.ignoreCase = this.gFlag = false; -var sp = new com.stevesoft.pat.StrPos (pat, 0); -this.thePattern = this._compileSP (sp, mk); -this.pt.marks = null; -return this.thePattern; -}, $fz.isPrivate = true, $fz), "~S,com.stevesoft.pat.Rthings"); -Clazz.defineMethod (c$, "_compileSP", -function (sp, mk) { -while (!(sp.$eos || (this.or != null && sp.match (')')))) { -this.compileSP (sp, mk); -sp.inc (); -} -if (sp.match (')')) { -mk.parenLevel--; -} else if (sp.$eos && mk.parenLevel != 0) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed Parenthesis! lvl=" + mk.parenLevel); -}if (this.or != null) { -if (this.p == null) { -this.p = new com.stevesoft.pat.NullPattern (); -}this.or.addOr (this.p); -return this.or; -}return this.p == null ? new com.stevesoft.pat.NullPattern () : this.p; -}, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings"); -Clazz.defineMethod (c$, "addMulti", -function (i1, i2) { -var last; -var last2; -for (last = this.p; last != null && last.next != null; last = last.next) { -;} -if (last == null || last === this.p) { -last2 = null; -} else { -for (last2 = this.p; last2.next !== last; last2 = last2.next) { -;} -}if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) && i1.intValue () == 0 && i2.intValue () == 1) { -(last).matchFewest = true; -} else if (Clazz.instanceOf (last, com.stevesoft.pat.FastMulti) && i1.intValue () == 0 && i2.intValue () == 1) { -(last).matchFewest = true; -} else if (Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) && i1.intValue () == 0 && i2.intValue () == 1) { -(last).matchFewest = true; -} else if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) || Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) || Clazz.instanceOf (last, com.stevesoft.pat.FastMulti)) { -throw new com.stevesoft.pat.RegSyntax ("Syntax error."); -} else if (last2 == null) { -this.p = com.stevesoft.pat.Regex.mkMulti (i1, i2, this.p); -} else { -last2.next = com.stevesoft.pat.Regex.mkMulti (i1, i2, last); -}}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt"); -c$.mkMulti = Clazz.defineMethod (c$, "mkMulti", -function (lo, hi, p) { -if (Clazz.instanceOf (p, com.stevesoft.pat.Any) && p.next == null) { -return new com.stevesoft.pat.DotMulti (lo, hi); -}return com.stevesoft.pat.RegOpt.safe4fm (p) ? new com.stevesoft.pat.FastMulti (lo, hi, p) : new com.stevesoft.pat.Multi (lo, hi, p); -}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); -Clazz.defineMethod (c$, "matchBracket", -function (sp) { -var ret; -if (sp.match ('^')) { -ret = new com.stevesoft.pat.Bracket (true); -sp.inc (); -} else { -ret = new com.stevesoft.pat.Bracket (false); -}if (sp.match (']')) { -com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched []"); -}while (!sp.$eos && !sp.match (']')) { -var s1 = new com.stevesoft.pat.StrPos (sp); -s1.inc (); -var s1_ = new com.stevesoft.pat.StrPos (s1); -s1_.inc (); -if (s1.match ('-') && !s1_.match (']')) { -var s2 = new com.stevesoft.pat.StrPos (s1); -s2.inc (); -if (!s2.$eos) { -ret.addOr ( new com.stevesoft.pat.Range (sp.c, s2.c)); -}sp.inc (); -sp.inc (); -} else if (sp.escMatch ('Q')) { -sp.inc (); -while (!sp.escMatch ('E')) { -ret.addOr ( new com.stevesoft.pat.oneChar (sp.c)); -sp.inc (); -} -} else if (sp.escMatch ('d')) { -ret.addOr ( new com.stevesoft.pat.Range ('0', '9')); -} else if (sp.escMatch ('s')) { -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10))); -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13))); -} else if (sp.escMatch ('w')) { -ret.addOr ( new com.stevesoft.pat.Range ('a', 'z')); -ret.addOr ( new com.stevesoft.pat.Range ('A', 'Z')); -ret.addOr ( new com.stevesoft.pat.Range ('0', '9')); -ret.addOr ( new com.stevesoft.pat.oneChar ('_')); -} else if (sp.escMatch ('D')) { -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (47))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (58), String.fromCharCode (65535))); -} else if (sp.escMatch ('S')) { -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (7))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (11), String.fromCharCode (12))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (14), String.fromCharCode (31))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (33), String.fromCharCode (65535))); -} else if (sp.escMatch ('W')) { -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (64))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (91), String.fromCharCode (94))); -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (96))); -ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (123), String.fromCharCode (65535))); -} else if (sp.escMatch ('x') && this.next2Hex (sp)) { -sp.inc (); -var d = this.getHexDigit (sp); -sp.inc (); -d = 16 * d + this.getHexDigit (sp); -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); -} else if (sp.escMatch ('a')) { -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (7))); -} else if (sp.escMatch ('f')) { -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (12))); -} else if (sp.escMatch ('e')) { -ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (27))); -} else if (sp.escMatch ('n')) { -ret.addOr ( new com.stevesoft.pat.oneChar ('\n')); -} else if (sp.escMatch ('t')) { -ret.addOr ( new com.stevesoft.pat.oneChar ('\t')); -} else if (sp.escMatch ('r')) { -ret.addOr ( new com.stevesoft.pat.oneChar ('\r')); -} else if (sp.escMatch ('c')) { -sp.inc (); -if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) { -ret.addOr ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)])); -} else { -ret.addOr ( new com.stevesoft.pat.oneChar (sp.c)); -}} else if (this.isOctalString (sp)) { -var d = sp.c.charCodeAt (0) - 48; -sp.inc (); -d = 8 * d + sp.c.charCodeAt (0) - 48; -var sp2 = new com.stevesoft.pat.StrPos (sp); -sp2.inc (); -if (this.isOctalDigit (sp2, false)) { -sp.inc (); -d = 8 * d + sp.c.charCodeAt (0) - 48; -}ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); -} else { -ret.addOr ( new com.stevesoft.pat.oneChar (sp.c)); -}sp.inc (); -} -return ret; -}, "com.stevesoft.pat.StrPos"); -Clazz.overrideMethod (c$, "toString", -function () { -{ -var sb = new StringBuffer (); -if (this.esc != '\\') { -sb.append ("(?e="); -sb.append (this.esc); -sb.append (")"); -}if (this.gFlag || this.mFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR || this.sFlag || this.ignoreCase || this.dontMatchInQuotes || this.optimized ()) { -sb.append ("(?"); -if (this.ignoreCase) { -sb.append ("i"); -}if (this.mFlag) { -sb.append ("m"); -}if (this.sFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR) { -sb.append ("s"); -}if (this.dontMatchInQuotes) { -sb.append ("Q"); -}if (this.optimized ()) { -sb.append ("o"); -}if (this.gFlag) { -sb.append ("g"); -}sb.append (")"); -}var patstr = this.thePattern.toString (); -if (this.esc != '\\') { -patstr = com.stevesoft.pat.Regex.reEscape (patstr, '\\', this.esc); -}sb.append (patstr); -return sb.toString (); -}}); -c$.reEscape = Clazz.defineMethod (c$, "reEscape", -function (s, oldEsc, newEsc) { -if (oldEsc == newEsc) { -return s; -}var i; -var sb = new StringBuffer (); -for (i = 0; i < s.length; i++) { -if (s.charAt (i) == oldEsc && i + 1 < s.length) { -if (s.charAt (i + 1) == oldEsc) { -sb.append (oldEsc); -} else { -sb.append (newEsc); -sb.append (s.charAt (i + 1)); -}i++; -} else if (s.charAt (i) == newEsc) { -sb.append (newEsc); -sb.append (newEsc); -} else { -sb.append (s.charAt (i)); -}} -return sb.toString (); -}, "~S,~S,~S"); -Clazz.defineMethod (c$, "accept", -function (dir, s) { -return this.search (s); -}, "java.io.File,~S"); -c$.version = Clazz.defineMethod (c$, "version", -function () { -return "lgpl release 1.5.3"; -}); -Clazz.defineMethod (c$, "optimize", -function () { -if (this.optimized () || this.thePattern == null) { -return; -}this.minMatch = new com.stevesoft.pat.patInt (0); -this.thePattern = com.stevesoft.pat.RegOpt.opt (this.thePattern, this.ignoreCase, this.dontMatchInQuotes); -this.skipper = com.stevesoft.pat.Skip.findSkipRegex (this); -return; -}); -Clazz.defineMethod (c$, "optimized", -function () { -return this.minMatch != null; -}); -c$.perlCode = Clazz.defineMethod (c$, "perlCode", -function (s) { -return com.stevesoft.pat.parsePerl.parse (s); -}, "~S"); -Clazz.defineMethod (c$, "isLiteral", -function () { -var x = this.thePattern; -while (x != null) { -if (Clazz.instanceOf (x, com.stevesoft.pat.oneChar)) { -;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Skipped)) { -;} else { -return false; -}x = x.next; -} -return true; -}); -Clazz.defineMethod (c$, "countMinChars", -function () { -return this.thePattern.countMinChars (); -}); -Clazz.defineMethod (c$, "countMaxChars", -function () { -return this.thePattern.countMaxChars (); -}); -Clazz.defineMethod (c$, "isHexDigit", -function (sp) { -var r = !sp.$eos && !sp.dontMatch && ((sp.c >= '0' && sp.c <= '9') || (sp.c >= 'a' && sp.c <= 'f') || (sp.c >= 'A' && sp.c <= 'F')); -return r; -}, "com.stevesoft.pat.StrPos"); -Clazz.defineMethod (c$, "isOctalDigit", -function (sp, first) { -var r = !sp.$eos && !( new Boolean (first ^ sp.dontMatch).valueOf ()) && sp.c >= '0' && sp.c <= '7'; -return r; -}, "com.stevesoft.pat.StrPos,~B"); -Clazz.defineMethod (c$, "getHexDigit", -function (sp) { -if (sp.c >= '0' && sp.c <= '9') { -return sp.c.charCodeAt (0) - 48; -}if (sp.c >= 'a' && sp.c <= 'f') { -return sp.c.charCodeAt (0) - 97 + 10; -}return sp.c.charCodeAt (0) - 65 + 10; -}, "com.stevesoft.pat.StrPos"); -Clazz.defineMethod (c$, "next2Hex", -function (sp) { -var sp2 = new com.stevesoft.pat.StrPos (sp); -sp2.inc (); -if (!this.isHexDigit (sp2)) { -return false; -}sp2.inc (); -if (!this.isHexDigit (sp2)) { -return false; -}return true; -}, "com.stevesoft.pat.StrPos"); -Clazz.defineMethod (c$, "isOctalString", -function (sp) { -if (!this.isOctalDigit (sp, true)) { -return false; -}var sp2 = new com.stevesoft.pat.StrPos (sp); -sp2.inc (); -if (!this.isOctalDigit (sp2, false)) { -return false; -}return true; -}, "com.stevesoft.pat.StrPos"); -Clazz.defineStatics (c$, -"BackRefOffset", 1); -c$.none = c$.prototype.none = new com.stevesoft.pat.NoPattern (); -c$.validators = c$.prototype.validators = new java.util.Hashtable (); -{ -com.stevesoft.pat.Regex.defineV ("p", "(?>1)", new com.stevesoft.pat.UnicodePunct ()); -com.stevesoft.pat.Regex.defineV ("P", "(?>1)", new com.stevesoft.pat.NUnicodePunct ()); -com.stevesoft.pat.Regex.defineV ("s", "(?>1)", new com.stevesoft.pat.UnicodeWhite ()); -com.stevesoft.pat.Regex.defineV ("S", "(?>1)", new com.stevesoft.pat.NUnicodeWhite ()); -com.stevesoft.pat.Regex.defineV ("w", "(?>1)", new com.stevesoft.pat.UnicodeW ()); -com.stevesoft.pat.Regex.defineV ("W", "(?>1)", new com.stevesoft.pat.NUnicodeW ()); -com.stevesoft.pat.Regex.defineV ("d", "(?>1)", new com.stevesoft.pat.UnicodeDigit ()); -com.stevesoft.pat.Regex.defineV ("D", "(?>1)", new com.stevesoft.pat.NUnicodeDigit ()); -com.stevesoft.pat.Regex.defineV ("m", "(?>1)", new com.stevesoft.pat.UnicodeMath ()); -com.stevesoft.pat.Regex.defineV ("M", "(?>1)", new com.stevesoft.pat.NUnicodeMath ()); -com.stevesoft.pat.Regex.defineV ("c", "(?>1)", new com.stevesoft.pat.UnicodeCurrency ()); -com.stevesoft.pat.Regex.defineV ("C", "(?>1)", new com.stevesoft.pat.NUnicodeCurrency ()); -com.stevesoft.pat.Regex.defineV ("a", "(?>1)", new com.stevesoft.pat.UnicodeAlpha ()); -com.stevesoft.pat.Regex.defineV ("A", "(?>1)", new com.stevesoft.pat.NUnicodeAlpha ()); -com.stevesoft.pat.Regex.defineV ("uc", "(?>1)", new com.stevesoft.pat.UnicodeUpper ()); -com.stevesoft.pat.Regex.defineV ("lc", "(?>1)", new com.stevesoft.pat.UnicodeLower ()); -}Clazz.defineStatics (c$, -"defaultMFlag", false, -"dotDoesntMatchCR", true, -"lasts", null, -"lastbs", null, -"back_slash", '\\'); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.RegRes", "$.UniValidator", "jalview.jsdev.api.RegExpInterface", "com.stevesoft.pat.NoPattern", "$.Pthings", "$.patInt", "java.util.Hashtable"], ["com.stevesoft.pat.UnicodeW", "$.UnicodeCurrency", "$.UnicodeAlpha", "$.UnicodeUpper", "$.NUnicodeCurrency", "$.NUnicodeW", "$.NUnicodeAlpha", "$.UnicodeMath", "$.UnicodeWhite", "$.UnicodeDigit", "$.NUnicodeMath", "$.Regex", "$.NUnicodeDigit", "$.NUnicodeWhite", "$.NUnicodePunct", "$.UnicodePunct", "$.UnicodeLower"], ["com.stevesoft.pat.Any", "$.BackG", "$.BackMatch", "$.Backup", "$.Boundary", "$.Bracket", "$.CaseMgr", "$.Ctrl", "$.Custom", "$.CustomEndpoint", "$.DotMulti", "$.End", "$.FastMulti", "$.Group", "$.MessageManager", "$.Multi", "$.NullPattern", "$.Or", "$.OrMark", "$.Prop", "$.Range", "$.RegOpt", "$.RegSyntax", "$.RegSyntaxError", "$.ReplaceRule", "$.Replacer", "$.Rthings", "$.Skip", "$.Skipped", "$.Start", "$.StrPos", "$.lookAhead", "$.oneChar", "$.parsePerl", "$.patInf", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException", "$.StringBuffer", "java.util.BitSet"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodePunct", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeWhite", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodePunct", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && !com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeWhite", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && !com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeW", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +if (from >= s.length ()) { +return -1; +}var c = s.charAt (from); +return (com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeW", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +if (from >= s.length ()) { +return -1; +}var c = s.charAt (from); +return !(com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeDigit", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeDigit", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && !com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeMath", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeMath", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && !com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeCurrency", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeCurrency", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && !com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeAlpha", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeAlpha", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && !com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeUpper", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && this.isUpper (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "isUpper", +function (c) { +return c == com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c != com.stevesoft.pat.CaseMgr.toLowerCaseC (c); +}, "~S"); +c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeLower", com.stevesoft.pat.UniValidator); +Clazz.overrideMethod (c$, "validate", +function (s, from, to) { +return from < s.length () && this.isLower (s.charAt (from)) ? to : -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "isLower", +function (c) { +return c != com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c == com.stevesoft.pat.CaseMgr.toLowerCaseC (c); +}, "~S"); +c$ = Clazz.decorateAsClass (function () { +this.thePattern = null; +this.minMatch = null; +this.rep = null; +this.dontMatchInQuotes = false; +this.ignoreCase = false; +this.repr = null; +this.esc = '\\'; +this.pt = null; +this.gFlags = null; +this.gFlagto = 0; +this.gFlag = false; +this.sFlag = false; +this.mFlag = false; +this.p = null; +this.or = null; +this.skipper = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Regex", com.stevesoft.pat.RegRes, [jalview.jsdev.api.RegExpInterface, Cloneable]); +Clazz.prepareFields (c$, function () { +this.thePattern = com.stevesoft.pat.Regex.none; +this.minMatch = new com.stevesoft.pat.patInt (0); +this.pt = new com.stevesoft.pat.Pthings (); +}); +Clazz.makeConstructor (c$, +function (s, strRp) { +Clazz.superConstructor (this, com.stevesoft.pat.Regex, []); +try { +if (s != null) this.compile (s); +if (strRp.length > 0) this.rep = com.stevesoft.pat.ReplaceRule.perlCode (strRp); +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +} else { +throw rs; +} +} +}, "~S,~S"); +Clazz.overrideMethod (c$, "clone", +function () { +return new com.stevesoft.pat.Regex (null, "").cloneFrom (this); +}); +Clazz.defineMethod (c$, "cloneFrom", +function (r) { +this.copyOutOf (r); +this.dontMatchInQuotes = r.dontMatchInQuotes; +this.esc = r.esc; +this.ignoreCase = r.ignoreCase; +this.gFlag = r.gFlag; +if (r.rep == null) { +this.rep = null; +} else { +this.rep = r.rep.clone (); +}this.thePattern = r.thePattern.clone ( new java.util.Hashtable ()); +this.minMatch = r.minMatch; +this.skipper = r.skipper; +return this; +}, "com.stevesoft.pat.Regex"); +Clazz.defineMethod (c$, "setDontMatchInQuotes", +function (b) { +this.dontMatchInQuotes = b; +}, "~B"); +Clazz.defineMethod (c$, "getDontMatchInQuotes", +function () { +return this.dontMatchInQuotes; +}); +Clazz.overrideMethod (c$, "setIgnoreCase", +function (b) { +this.ignoreCase = b; +}, "~B"); +Clazz.defineMethod (c$, "getIgnoreCase", +function () { +return this.ignoreCase; +}); +c$.setDefaultMFlag = Clazz.defineMethod (c$, "setDefaultMFlag", +function (mFlag) { +com.stevesoft.pat.Regex.defaultMFlag = mFlag; +}, "~B"); +c$.getDefaultMFlag = Clazz.defineMethod (c$, "getDefaultMFlag", +function () { +return com.stevesoft.pat.Regex.defaultMFlag; +}); +Clazz.defineMethod (c$, "setReplaceRuleStr", +function (rp) { +this.rep = com.stevesoft.pat.ReplaceRule.perlCode (rp); +this.repr = null; +}, "~S"); +Clazz.defineMethod (c$, "setReplaceRule", +function (rp) { +this.rep = rp; +}, "com.stevesoft.pat.ReplaceRule"); +c$.isDefined = Clazz.defineMethod (c$, "isDefined", +function (nm) { +return com.stevesoft.pat.Regex.validators.get (nm) != null; +}, "~S"); +c$.undefine = Clazz.defineMethod (c$, "undefine", +function (nm) { +com.stevesoft.pat.Regex.validators.remove (nm); +}, "~S"); +c$.defineV = Clazz.defineMethod (c$, "defineV", +function (nm, pat, v) { +v.pattern = pat; +com.stevesoft.pat.Regex.validators.put (nm, v); +}, "~S,~S,com.stevesoft.pat.Validator"); +c$.define = Clazz.defineMethod (c$, "define", +function (nm, pat) { +com.stevesoft.pat.Regex.validators.put (nm, pat); +}, "~S,~S"); +Clazz.defineMethod (c$, "getReplaceRule", +function () { +return this.rep; +}); +Clazz.defineMethod (c$, "_getReplacer", +function () { +return this.repr == null ? this.repr = new com.stevesoft.pat.Replacer () : this.repr; +}); +Clazz.defineMethod (c$, "getReplacer", +function () { +if (this.repr == null) { +this.repr = new com.stevesoft.pat.Replacer (); +}this.repr.rh.me = this; +this.repr.rh.prev = null; +return this.repr; +}); +Clazz.defineMethod (c$, "replaceFirst", +function (s) { +return this._getReplacer ().replaceFirstRegion (s, this, 0, s.length).toString (); +}, "~S"); +Clazz.defineMethod (c$, "replaceFirstFrom", +function (s, pos) { +return this._getReplacer ().replaceFirstRegion (s, this, pos, s.length).toString (); +}, "~S,~N"); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, start, end) { +return this._getReplacer ().replaceFirstRegion (s, this, start, end).toString (); +}, "~S,~N,~N"); +Clazz.overrideMethod (c$, "replaceAll", +function (s) { +return this._getReplacer ().replaceAllRegion (s, this, 0, s.length).toString (); +}, "~S"); +Clazz.defineMethod (c$, "replaceAllLike", +function (s) { +return this._getReplacer ().replaceAllRegion (s, this, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "replaceAllFrom", +function (s, pos) { +return this._getReplacer ().replaceAllRegion (s, this, pos, s.length).toString (); +}, "~S,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, start, end) { +return this._getReplacer ().replaceAllRegion (s, this, start, end).toString (); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "compile", +function (prepat) { +var postpat = com.stevesoft.pat.parsePerl.codify (prepat, true); +var pat = postpat == null ? prepat : postpat; +this.minMatch = null; +this.ignoreCase = false; +this.dontMatchInQuotes = false; +var mk = new com.stevesoft.pat.Rthings (this); +var offset = mk.val; +var newpat = pat; +this.thePattern = com.stevesoft.pat.Regex.none; +this.p = null; +this.or = null; +this.minMatch = new com.stevesoft.pat.patInt (0); +var sp = new com.stevesoft.pat.StrPos (pat, 0); +if (sp.incMatch ("(?e=")) { +var newEsc = sp.c; +sp.inc (); +if (sp.match (')')) { +newpat = com.stevesoft.pat.Regex.reEscape (pat.substring (6), newEsc, '\\'); +}} else if (this.esc != '\\') { +newpat = com.stevesoft.pat.Regex.reEscape (pat, this.esc, '\\'); +}this.thePattern = this._compile (newpat, mk); +this.numSubs_ = mk.val - offset; +mk.set (this); +}, "~S"); +Clazz.defineMethod (c$, "equals", +function (o) { +if (Clazz.instanceOf (o, com.stevesoft.pat.Regex)) { +if (this.toString ().equals (o.toString ())) { +return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]); +} else { +return false; +}} else { +return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]); +}}, "~O"); +Clazz.defineMethod (c$, "prep", +function (s) { +this.pt.lastPos = this.matchedTo (); +if (this.pt.lastPos < 0) { +this.pt.lastPos = 0; +}if ((s == null ? null : s.unwrap ()) !== (this.src == null ? null : s.unwrap ())) { +this.pt.lastPos = 0; +}this.src = s; +this.pt.dotDoesntMatchCR = com.stevesoft.pat.Regex.dotDoesntMatchCR && (!this.sFlag); +this.pt.mFlag = ( new Boolean (this.mFlag | com.stevesoft.pat.Regex.defaultMFlag).valueOf ()); +this.pt.ignoreCase = this.ignoreCase; +this.pt.no_check = false; +if (this.pt.marks != null) { +for (var i = 0; i < this.pt.marks.length; i++) { +this.pt.marks[i] = -1; +} +}this.pt.marks = null; +this.pt.nMarks = this.numSubs_; +this.pt.src = s; +if (this.dontMatchInQuotes) { +com.stevesoft.pat.Regex.setCbits (s, this.pt); +} else { +this.pt.cbits = null; +}return this.pt; +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "matchAt", +function (s, start_pos) { +return this._search (s, start_pos, start_pos); +}, "~S,~N"); +Clazz.defineMethod (c$, "matchAtLike", +function (s, start_pos) { +return this._searchLike (s, start_pos, start_pos); +}, "com.stevesoft.pat.StringLike,~N"); +Clazz.overrideMethod (c$, "search", +function (s) { +if (s == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_search")); +}return this._search (s, 0, s.length); +}, "~S"); +Clazz.defineMethod (c$, "searchLike", +function (sl) { +if (sl == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search")); +}return this._searchLike (sl, 0, sl.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "reverseSearch", +function (s) { +if (s == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_reverse_search")); +}return this._reverseSearch (s, 0, s.length); +}, "~S"); +Clazz.defineMethod (c$, "reverseSearchLike", +function (sl) { +if (sl == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_reverse_search")); +}return this._reverseSearchLike (sl, 0, sl.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.overrideMethod (c$, "searchFrom", +function (s, start) { +if (s == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from")); +}return this._search (s, start, s.length); +}, "~S,~N"); +Clazz.defineMethod (c$, "searchFromLike", +function (s, start) { +if (s == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from")); +}return this._searchLike (s, start, s.length ()); +}, "com.stevesoft.pat.StringLike,~N"); +Clazz.defineMethod (c$, "searchRegion", +function (s, start, end) { +if (s == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_region")); +}return this._search (s, start, end); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "setGFlag", +function (b) { +this.gFlag = b; +}, "~B"); +Clazz.defineMethod (c$, "getGFlag", +function () { +return this.gFlag; +}); +Clazz.defineMethod (c$, "getSFlag", +function () { +return this.sFlag; +}); +Clazz.defineMethod (c$, "getMFlag", +function () { +return this.mFlag; +}); +Clazz.defineMethod (c$, "_search", +function (s, start, end) { +return this._searchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "_searchLike", +function (s, start, end) { +if (this.gFlag && this.gFlagto > 0 && this.gFlags != null && s.unwrap () === this.gFlags.unwrap ()) { +start = this.gFlagto; +}this.gFlags = null; +var pt = this.prep (s); +var up = (this.minMatch == null ? end : end - this.minMatch.i); +if (up < start && end >= start) { +up = start; +}if (this.skipper == null) { +for (var i = start; i <= up; i++) { +this.charsMatched_ = this.thePattern.matchAt (s, i, pt); +if (this.charsMatched_ >= 0) { +this.matchFrom_ = this.thePattern.mfrom; +this.marks = pt.marks; +this.gFlagto = this.matchFrom_ + this.charsMatched_; +this.gFlags = s; +return this.didMatch_ = true; +}} +} else { +pt.no_check = true; +for (var i = start; i <= up; i++) { +i = this.skipper.find (this.src, i, up); +if (i < 0) { +this.charsMatched_ = this.matchFrom_ = -1; +return this.didMatch_ = false; +}this.charsMatched_ = this.thePattern.matchAt (s, i, pt); +if (this.charsMatched_ >= 0) { +this.matchFrom_ = this.thePattern.mfrom; +this.marks = pt.marks; +this.gFlagto = this.matchFrom_ + this.charsMatched_; +this.gFlags = s; +return this.didMatch_ = true; +}} +}return this.didMatch_ = false; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "_reverseSearch", +function (s, start, end) { +return this._reverseSearchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "_reverseSearchLike", +function (s, start, end) { +if (this.gFlag && this.gFlagto > 0 && s.unwrap () === this.gFlags.unwrap ()) { +end = this.gFlagto; +}this.gFlags = null; +var pt = this.prep (s); +for (var i = end; i >= start; i--) { +this.charsMatched_ = this.thePattern.matchAt (s, i, pt); +if (this.charsMatched_ >= 0) { +this.matchFrom_ = this.thePattern.mfrom; +this.marks = pt.marks; +this.gFlagto = this.matchFrom_ - 1; +this.gFlags = s; +return this.didMatch_ = true; +}} +return this.didMatch_ = false; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$.setCbits = Clazz.defineMethod (c$, "setCbits", +function (s, pt) { +if (s === com.stevesoft.pat.Regex.lasts) { +pt.cbits = com.stevesoft.pat.Regex.lastbs; +return; +}var bs = new java.util.BitSet (s.length ()); +var qc = ' '; +var setBit = false; +for (var i = 0; i < s.length (); i++) { +if (setBit) { +bs.set (i); +}var c = s.charAt (i); +if (!setBit && c == '"') { +qc = c; +setBit = true; +bs.set (i); +} else if (!setBit && c == '\'') { +qc = c; +setBit = true; +bs.set (i); +} else if (setBit && c == qc) { +setBit = false; +} else if (setBit && c == '\\' && i + 1 < s.length ()) { +i++; +if (setBit) { +bs.set (i); +}}} +pt.cbits = com.stevesoft.pat.Regex.lastbs = bs; +com.stevesoft.pat.Regex.lasts = s; +}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "add", +function (p2) { +if (this.p == null) { +this.p = p2; +} else { +this.p.add (p2); +p2 = this.p; +}}, "com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "compileSP", +function (sp, mk) { +if (sp.match ('[')) { +sp.inc (); +this.add (this.matchBracket (sp)); +} else if (sp.match ('|')) { +if (this.or == null) { +this.or = new com.stevesoft.pat.Or (); +}if (this.p == null) { +this.p = new com.stevesoft.pat.NullPattern (); +}this.or.addOr (this.p); +this.p = null; +} else if (sp.incMatch ("(?<")) { +var i = sp.getPatInt (); +if (i == null) { +com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?<"); +}this.add ( new com.stevesoft.pat.Backup (i.intValue ())); +if (!sp.match (')')) { +com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<"); +}} else if (sp.incMatch ("(?>")) { +var i = sp.getPatInt (); +if (i == null) { +com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?>"); +}this.add ( new com.stevesoft.pat.Backup (-i.intValue ())); +if (!sp.match (')')) { +com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<"); +}} else if (sp.incMatch ("(?@")) { +var op = sp.c; +sp.inc (); +var cl = sp.c; +sp.inc (); +if (!sp.match (')')) { +com.stevesoft.pat.RegSyntaxError.endItAll ("(?@ does not have closing paren"); +}this.add ( new com.stevesoft.pat.Group (op, cl)); +} else if (sp.incMatch ("(?#")) { +while (!sp.match (')')) { +sp.inc (); +} +} else if (sp.dontMatch && sp.c == 'w') { +var b = new com.stevesoft.pat.Bracket (false); +b.addOr ( new com.stevesoft.pat.Range ('a', 'z')); +b.addOr ( new com.stevesoft.pat.Range ('A', 'Z')); +b.addOr ( new com.stevesoft.pat.Range ('0', '9')); +b.addOr ( new com.stevesoft.pat.oneChar ('_')); +this.add (b); +} else if (sp.dontMatch && sp.c == 'G') { +this.add ( new com.stevesoft.pat.BackG ()); +} else if (sp.dontMatch && sp.c == 's') { +var b = new com.stevesoft.pat.Bracket (false); +b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32))); +b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10))); +b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13))); +this.add (b); +} else if (sp.dontMatch && sp.c == 'd') { +var digit = new com.stevesoft.pat.Range ('0', '9'); +digit.printBrackets = true; +this.add (digit); +} else if (sp.dontMatch && sp.c == 'W') { +var b = new com.stevesoft.pat.Bracket (true); +b.addOr ( new com.stevesoft.pat.Range ('a', 'z')); +b.addOr ( new com.stevesoft.pat.Range ('A', 'Z')); +b.addOr ( new com.stevesoft.pat.Range ('0', '9')); +b.addOr ( new com.stevesoft.pat.oneChar ('_')); +this.add (b); +} else if (sp.dontMatch && sp.c == 'S') { +var b = new com.stevesoft.pat.Bracket (true); +b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32))); +b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10))); +b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13))); +this.add (b); +} else if (sp.dontMatch && sp.c == 'D') { +var b = new com.stevesoft.pat.Bracket (true); +b.addOr ( new com.stevesoft.pat.Range ('0', '9')); +this.add (b); +} else if (sp.dontMatch && sp.c == 'B') { +var r = new com.stevesoft.pat.Regex (null, ""); +r._compile ("(?!\\b)", mk); +this.add (r.thePattern); +} else if (this.isOctalString (sp)) { +var d = sp.c.charCodeAt (0) - 48; +sp.inc (); +d = 8 * d + sp.c.charCodeAt (0) - 48; +var sp2 = new com.stevesoft.pat.StrPos (sp); +sp2.inc (); +if (this.isOctalDigit (sp2, false)) { +sp.inc (); +d = 8 * d + sp.c.charCodeAt (0) - 48; +}this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); +} else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') { +var iv = sp.c.charCodeAt (0) - 48; +var s2 = new com.stevesoft.pat.StrPos (sp); +s2.inc (); +if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') { +iv = 10 * iv + (s2.c.charCodeAt (0) - 48); +sp.inc (); +}this.add ( new com.stevesoft.pat.BackMatch (iv)); +} else if (sp.dontMatch && sp.c == 'b') { +this.add ( new com.stevesoft.pat.Boundary ()); +} else if (sp.match ('\b')) { +this.add ( new com.stevesoft.pat.Boundary ()); +} else if (sp.match ('$')) { +this.add ( new com.stevesoft.pat.End (true)); +} else if (sp.dontMatch && sp.c == 'Z') { +this.add ( new com.stevesoft.pat.End (false)); +} else if (sp.match ('.')) { +this.add ( new com.stevesoft.pat.Any ()); +} else if (sp.incMatch ("(??")) { +var sb = new StringBuffer (); +var sb2 = new StringBuffer (); +while (!sp.match (')') && !sp.match (':')) { +sb.append (sp.c); +sp.inc (); +} +if (sp.incMatch (":")) { +while (!sp.match (')')) { +sb2.append (sp.c); +sp.inc (); +} +}var sbs = sb.toString (); +if (Clazz.instanceOf (com.stevesoft.pat.Regex.validators.get (sbs), String)) { +var pat = com.stevesoft.pat.Regex.validators.get (sbs); +var r = new com.stevesoft.pat.Regex (null, ""); +var rth = new com.stevesoft.pat.Rthings (this); +rth.noBackRefs = true; +r._compile (pat, rth); +this.add (r.thePattern); +} else { +var cm = new com.stevesoft.pat.Custom (sb.toString ()); +if (cm.v != null) { +var v2 = cm.v.arg (sb2.toString ()); +if (v2 != null) { +v2.argsave = sb2.toString (); +var p = cm.v.pattern; +cm.v = v2; +v2.pattern = p; +}var r = new com.stevesoft.pat.Regex (null, ""); +var rth = new com.stevesoft.pat.Rthings (this); +rth.noBackRefs = true; +r._compile (cm.v.pattern, rth); +cm.sub = r.thePattern; +cm.sub.add ( new com.stevesoft.pat.CustomEndpoint (cm)); +cm.sub.setParent (cm); +this.add (cm); +}}} else if (sp.match ('(')) { +mk.parenLevel++; +var r = new com.stevesoft.pat.Regex (null, ""); +sp.inc (); +if (sp.incMatch ("?:")) { +r.or = new com.stevesoft.pat.Or (); +} else if (sp.incMatch ("?=")) { +r.or = new com.stevesoft.pat.lookAhead (false); +} else if (sp.incMatch ("?!")) { +r.or = new com.stevesoft.pat.lookAhead (true); +} else if (sp.match ('?')) { +sp.inc (); +do { +if (sp.c == 'i') { +mk.ignoreCase = true; +}if (sp.c == 'Q') { +mk.dontMatchInQuotes = true; +}if (sp.c == 'o') { +mk.optimizeMe = true; +}if (sp.c == 'g') { +mk.gFlag = true; +}if (sp.c == 's') { +mk.sFlag = true; +}if (sp.c == 'm') { +mk.mFlag = true; +}sp.inc (); +} while (!sp.match (')') && !sp.$eos); +r = null; +mk.parenLevel--; +if (sp.$eos) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed ()"); +}} else { +r.or = mk.noBackRefs ? new com.stevesoft.pat.Or () : new com.stevesoft.pat.OrMark (mk.val++); +}if (r != null) { +this.add (r._compileSP (sp, mk)); +}} else if (sp.match ('^')) { +this.add ( new com.stevesoft.pat.Start (true)); +} else if (sp.dontMatch && sp.c == 'A') { +this.add ( new com.stevesoft.pat.Start (false)); +} else if (sp.match ('*')) { +this.addMulti ( new com.stevesoft.pat.patInt (0), new com.stevesoft.pat.patInf ()); +} else if (sp.match ('+')) { +this.addMulti ( new com.stevesoft.pat.patInt (1), new com.stevesoft.pat.patInf ()); +} else if (sp.match ('?')) { +this.addMulti ( new com.stevesoft.pat.patInt (0), new com.stevesoft.pat.patInt (1)); +} else if (sp.match ('{')) { +var bad = false; +var sp2 = new com.stevesoft.pat.StrPos (sp); +sp.inc (); +var i1 = sp.getPatInt (); +var i2 = null; +if (sp.match ('}')) { +i2 = i1; +} else { +if (!sp.match (',')) { +bad = true; +}sp.inc (); +if (sp.match ('}')) { +i2 = new com.stevesoft.pat.patInf (); +} else { +i2 = sp.getPatInt (); +}}if (i1 == null || i2 == null) { +bad = true; +}if (bad) { +sp.dup (sp2); +this.add ( new com.stevesoft.pat.oneChar (sp.c)); +} else { +this.addMulti (i1, i2); +}} else if (sp.escMatch ('x') && this.next2Hex (sp)) { +sp.inc (); +var d = this.getHexDigit (sp); +sp.inc (); +d = 16 * d + this.getHexDigit (sp); +this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); +} else if (sp.escMatch ('c')) { +sp.inc (); +if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) { +this.add ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)])); +} else { +this.add ( new com.stevesoft.pat.oneChar (sp.c)); +}} else if (sp.escMatch ('f')) { +this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (12))); +} else if (sp.escMatch ('a')) { +this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (7))); +} else if (sp.escMatch ('t')) { +this.add ( new com.stevesoft.pat.oneChar ('\t')); +} else if (sp.escMatch ('n')) { +this.add ( new com.stevesoft.pat.oneChar ('\n')); +} else if (sp.escMatch ('r')) { +this.add ( new com.stevesoft.pat.oneChar ('\r')); +} else if (sp.escMatch ('b')) { +this.add ( new com.stevesoft.pat.oneChar ('\b')); +} else if (sp.escMatch ('e')) { +this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (27))); +} else { +this.add ( new com.stevesoft.pat.oneChar (sp.c)); +if (sp.match (')')) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched right paren in pattern"); +}}}, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings"); +Clazz.defineMethod (c$, "_compile", +($fz = function (pat, mk) { +this.minMatch = null; +this.sFlag = this.mFlag = this.ignoreCase = this.gFlag = false; +var sp = new com.stevesoft.pat.StrPos (pat, 0); +this.thePattern = this._compileSP (sp, mk); +this.pt.marks = null; +return this.thePattern; +}, $fz.isPrivate = true, $fz), "~S,com.stevesoft.pat.Rthings"); +Clazz.defineMethod (c$, "_compileSP", +function (sp, mk) { +while (!(sp.$eos || (this.or != null && sp.match (')')))) { +this.compileSP (sp, mk); +sp.inc (); +} +if (sp.match (')')) { +mk.parenLevel--; +} else if (sp.$eos && mk.parenLevel != 0) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed Parenthesis! lvl=" + mk.parenLevel); +}if (this.or != null) { +if (this.p == null) { +this.p = new com.stevesoft.pat.NullPattern (); +}this.or.addOr (this.p); +return this.or; +}return this.p == null ? new com.stevesoft.pat.NullPattern () : this.p; +}, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings"); +Clazz.defineMethod (c$, "addMulti", +function (i1, i2) { +var last; +var last2; +for (last = this.p; last != null && last.next != null; last = last.next) { +;} +if (last == null || last === this.p) { +last2 = null; +} else { +for (last2 = this.p; last2.next !== last; last2 = last2.next) { +;} +}if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) && i1.intValue () == 0 && i2.intValue () == 1) { +(last).matchFewest = true; +} else if (Clazz.instanceOf (last, com.stevesoft.pat.FastMulti) && i1.intValue () == 0 && i2.intValue () == 1) { +(last).matchFewest = true; +} else if (Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) && i1.intValue () == 0 && i2.intValue () == 1) { +(last).matchFewest = true; +} else if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) || Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) || Clazz.instanceOf (last, com.stevesoft.pat.FastMulti)) { +throw new com.stevesoft.pat.RegSyntax ("Syntax error."); +} else if (last2 == null) { +this.p = com.stevesoft.pat.Regex.mkMulti (i1, i2, this.p); +} else { +last2.next = com.stevesoft.pat.Regex.mkMulti (i1, i2, last); +}}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt"); +c$.mkMulti = Clazz.defineMethod (c$, "mkMulti", +function (lo, hi, p) { +if (Clazz.instanceOf (p, com.stevesoft.pat.Any) && p.next == null) { +return new com.stevesoft.pat.DotMulti (lo, hi); +}return com.stevesoft.pat.RegOpt.safe4fm (p) ? new com.stevesoft.pat.FastMulti (lo, hi, p) : new com.stevesoft.pat.Multi (lo, hi, p); +}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern"); +Clazz.defineMethod (c$, "matchBracket", +function (sp) { +var ret; +if (sp.match ('^')) { +ret = new com.stevesoft.pat.Bracket (true); +sp.inc (); +} else { +ret = new com.stevesoft.pat.Bracket (false); +}if (sp.match (']')) { +com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched []"); +}while (!sp.$eos && !sp.match (']')) { +var s1 = new com.stevesoft.pat.StrPos (sp); +s1.inc (); +var s1_ = new com.stevesoft.pat.StrPos (s1); +s1_.inc (); +if (s1.match ('-') && !s1_.match (']')) { +var s2 = new com.stevesoft.pat.StrPos (s1); +s2.inc (); +if (!s2.$eos) { +ret.addOr ( new com.stevesoft.pat.Range (sp.c, s2.c)); +}sp.inc (); +sp.inc (); +} else if (sp.escMatch ('Q')) { +sp.inc (); +while (!sp.escMatch ('E')) { +ret.addOr ( new com.stevesoft.pat.oneChar (sp.c)); +sp.inc (); +} +} else if (sp.escMatch ('d')) { +ret.addOr ( new com.stevesoft.pat.Range ('0', '9')); +} else if (sp.escMatch ('s')) { +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10))); +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13))); +} else if (sp.escMatch ('w')) { +ret.addOr ( new com.stevesoft.pat.Range ('a', 'z')); +ret.addOr ( new com.stevesoft.pat.Range ('A', 'Z')); +ret.addOr ( new com.stevesoft.pat.Range ('0', '9')); +ret.addOr ( new com.stevesoft.pat.oneChar ('_')); +} else if (sp.escMatch ('D')) { +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (47))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (58), String.fromCharCode (65535))); +} else if (sp.escMatch ('S')) { +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (7))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (11), String.fromCharCode (12))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (14), String.fromCharCode (31))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (33), String.fromCharCode (65535))); +} else if (sp.escMatch ('W')) { +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (64))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (91), String.fromCharCode (94))); +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (96))); +ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (123), String.fromCharCode (65535))); +} else if (sp.escMatch ('x') && this.next2Hex (sp)) { +sp.inc (); +var d = this.getHexDigit (sp); +sp.inc (); +d = 16 * d + this.getHexDigit (sp); +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); +} else if (sp.escMatch ('a')) { +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (7))); +} else if (sp.escMatch ('f')) { +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (12))); +} else if (sp.escMatch ('e')) { +ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (27))); +} else if (sp.escMatch ('n')) { +ret.addOr ( new com.stevesoft.pat.oneChar ('\n')); +} else if (sp.escMatch ('t')) { +ret.addOr ( new com.stevesoft.pat.oneChar ('\t')); +} else if (sp.escMatch ('r')) { +ret.addOr ( new com.stevesoft.pat.oneChar ('\r')); +} else if (sp.escMatch ('c')) { +sp.inc (); +if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) { +ret.addOr ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)])); +} else { +ret.addOr ( new com.stevesoft.pat.oneChar (sp.c)); +}} else if (this.isOctalString (sp)) { +var d = sp.c.charCodeAt (0) - 48; +sp.inc (); +d = 8 * d + sp.c.charCodeAt (0) - 48; +var sp2 = new com.stevesoft.pat.StrPos (sp); +sp2.inc (); +if (this.isOctalDigit (sp2, false)) { +sp.inc (); +d = 8 * d + sp.c.charCodeAt (0) - 48; +}ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d))); +} else { +ret.addOr ( new com.stevesoft.pat.oneChar (sp.c)); +}sp.inc (); +} +return ret; +}, "com.stevesoft.pat.StrPos"); +Clazz.overrideMethod (c$, "toString", +function () { +{ +var sb = new StringBuffer (); +if (this.esc != '\\') { +sb.append ("(?e="); +sb.append (this.esc); +sb.append (")"); +}if (this.gFlag || this.mFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR || this.sFlag || this.ignoreCase || this.dontMatchInQuotes || this.optimized ()) { +sb.append ("(?"); +if (this.ignoreCase) { +sb.append ("i"); +}if (this.mFlag) { +sb.append ("m"); +}if (this.sFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR) { +sb.append ("s"); +}if (this.dontMatchInQuotes) { +sb.append ("Q"); +}if (this.optimized ()) { +sb.append ("o"); +}if (this.gFlag) { +sb.append ("g"); +}sb.append (")"); +}var patstr = this.thePattern.toString (); +if (this.esc != '\\') { +patstr = com.stevesoft.pat.Regex.reEscape (patstr, '\\', this.esc); +}sb.append (patstr); +return sb.toString (); +}}); +c$.reEscape = Clazz.defineMethod (c$, "reEscape", +function (s, oldEsc, newEsc) { +if (oldEsc == newEsc) { +return s; +}var i; +var sb = new StringBuffer (); +for (i = 0; i < s.length; i++) { +if (s.charAt (i) == oldEsc && i + 1 < s.length) { +if (s.charAt (i + 1) == oldEsc) { +sb.append (oldEsc); +} else { +sb.append (newEsc); +sb.append (s.charAt (i + 1)); +}i++; +} else if (s.charAt (i) == newEsc) { +sb.append (newEsc); +sb.append (newEsc); +} else { +sb.append (s.charAt (i)); +}} +return sb.toString (); +}, "~S,~S,~S"); +Clazz.defineMethod (c$, "accept", +function (dir, s) { +return this.search (s); +}, "java.io.File,~S"); +c$.version = Clazz.defineMethod (c$, "version", +function () { +return "lgpl release 1.5.3"; +}); +Clazz.defineMethod (c$, "optimize", +function () { +if (this.optimized () || this.thePattern == null) { +return; +}this.minMatch = new com.stevesoft.pat.patInt (0); +this.thePattern = com.stevesoft.pat.RegOpt.opt (this.thePattern, this.ignoreCase, this.dontMatchInQuotes); +this.skipper = com.stevesoft.pat.Skip.findSkipRegex (this); +return; +}); +Clazz.defineMethod (c$, "optimized", +function () { +return this.minMatch != null; +}); +c$.perlCode = Clazz.defineMethod (c$, "perlCode", +function (s) { +return com.stevesoft.pat.parsePerl.parse (s); +}, "~S"); +Clazz.defineMethod (c$, "isLiteral", +function () { +var x = this.thePattern; +while (x != null) { +if (Clazz.instanceOf (x, com.stevesoft.pat.oneChar)) { +;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Skipped)) { +;} else { +return false; +}x = x.next; +} +return true; +}); +Clazz.defineMethod (c$, "countMinChars", +function () { +return this.thePattern.countMinChars (); +}); +Clazz.defineMethod (c$, "countMaxChars", +function () { +return this.thePattern.countMaxChars (); +}); +Clazz.defineMethod (c$, "isHexDigit", +function (sp) { +var r = !sp.$eos && !sp.dontMatch && ((sp.c >= '0' && sp.c <= '9') || (sp.c >= 'a' && sp.c <= 'f') || (sp.c >= 'A' && sp.c <= 'F')); +return r; +}, "com.stevesoft.pat.StrPos"); +Clazz.defineMethod (c$, "isOctalDigit", +function (sp, first) { +var r = !sp.$eos && !( new Boolean (first ^ sp.dontMatch).valueOf ()) && sp.c >= '0' && sp.c <= '7'; +return r; +}, "com.stevesoft.pat.StrPos,~B"); +Clazz.defineMethod (c$, "getHexDigit", +function (sp) { +if (sp.c >= '0' && sp.c <= '9') { +return sp.c.charCodeAt (0) - 48; +}if (sp.c >= 'a' && sp.c <= 'f') { +return sp.c.charCodeAt (0) - 97 + 10; +}return sp.c.charCodeAt (0) - 65 + 10; +}, "com.stevesoft.pat.StrPos"); +Clazz.defineMethod (c$, "next2Hex", +function (sp) { +var sp2 = new com.stevesoft.pat.StrPos (sp); +sp2.inc (); +if (!this.isHexDigit (sp2)) { +return false; +}sp2.inc (); +if (!this.isHexDigit (sp2)) { +return false; +}return true; +}, "com.stevesoft.pat.StrPos"); +Clazz.defineMethod (c$, "isOctalString", +function (sp) { +if (!this.isOctalDigit (sp, true)) { +return false; +}var sp2 = new com.stevesoft.pat.StrPos (sp); +sp2.inc (); +if (!this.isOctalDigit (sp2, false)) { +return false; +}return true; +}, "com.stevesoft.pat.StrPos"); +Clazz.defineStatics (c$, +"BackRefOffset", 1); +c$.none = c$.prototype.none = new com.stevesoft.pat.NoPattern (); +c$.validators = c$.prototype.validators = new java.util.Hashtable (); +{ +com.stevesoft.pat.Regex.defineV ("p", "(?>1)", new com.stevesoft.pat.UnicodePunct ()); +com.stevesoft.pat.Regex.defineV ("P", "(?>1)", new com.stevesoft.pat.NUnicodePunct ()); +com.stevesoft.pat.Regex.defineV ("s", "(?>1)", new com.stevesoft.pat.UnicodeWhite ()); +com.stevesoft.pat.Regex.defineV ("S", "(?>1)", new com.stevesoft.pat.NUnicodeWhite ()); +com.stevesoft.pat.Regex.defineV ("w", "(?>1)", new com.stevesoft.pat.UnicodeW ()); +com.stevesoft.pat.Regex.defineV ("W", "(?>1)", new com.stevesoft.pat.NUnicodeW ()); +com.stevesoft.pat.Regex.defineV ("d", "(?>1)", new com.stevesoft.pat.UnicodeDigit ()); +com.stevesoft.pat.Regex.defineV ("D", "(?>1)", new com.stevesoft.pat.NUnicodeDigit ()); +com.stevesoft.pat.Regex.defineV ("m", "(?>1)", new com.stevesoft.pat.UnicodeMath ()); +com.stevesoft.pat.Regex.defineV ("M", "(?>1)", new com.stevesoft.pat.NUnicodeMath ()); +com.stevesoft.pat.Regex.defineV ("c", "(?>1)", new com.stevesoft.pat.UnicodeCurrency ()); +com.stevesoft.pat.Regex.defineV ("C", "(?>1)", new com.stevesoft.pat.NUnicodeCurrency ()); +com.stevesoft.pat.Regex.defineV ("a", "(?>1)", new com.stevesoft.pat.UnicodeAlpha ()); +com.stevesoft.pat.Regex.defineV ("A", "(?>1)", new com.stevesoft.pat.NUnicodeAlpha ()); +com.stevesoft.pat.Regex.defineV ("uc", "(?>1)", new com.stevesoft.pat.UnicodeUpper ()); +com.stevesoft.pat.Regex.defineV ("lc", "(?>1)", new com.stevesoft.pat.UnicodeLower ()); +}Clazz.defineStatics (c$, +"defaultMFlag", false, +"dotDoesntMatchCR", true, +"lasts", null, +"lastbs", null, +"back_slash", '\\'); +}); diff --git a/bin/com/stevesoft/pat/RegexReader.js b/bin/com/stevesoft/pat/RegexReader.js index d767d80..301d8e7 100644 --- a/bin/com/stevesoft/pat/RegexReader.js +++ b/bin/com/stevesoft/pat/RegexReader.js @@ -1,164 +1,164 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.io.Reader", "com.stevesoft.pat.PartialBuffer", "$.RBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexReader", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.StringBufferWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.rb = null; -this.wrap = null; -this.moreToRead = true; -this.r = null; -this.rp = null; -this.nmax = 2048; -this.max_lines = 2; -this.EOLchar = '\n'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegexReader", java.io.Reader); -Clazz.prepareFields (c$, function () { -this.rb = new com.stevesoft.pat.RBuffer ( new StringBuffer ()); -this.wrap = new com.stevesoft.pat.PartialBuffer (this.rb.sb); -}); -Clazz.makeConstructor (c$, -function (rex, r) { -Clazz.superConstructor (this, com.stevesoft.pat.RegexReader, []); -this.r = r; -this.rp = rex.getReplacer (); -}, "com.stevesoft.pat.Regex,java.io.Reader"); -Clazz.makeConstructor (c$, -function (tex, r) { -Clazz.superConstructor (this, com.stevesoft.pat.RegexReader, []); -this.r = r; -this.rp = tex.getReplacer (); -}, "com.stevesoft.pat.Transformer,java.io.Reader"); -Clazz.defineMethod (c$, "reset", -function () { -this.r.reset (); -this.rb = new com.stevesoft.pat.RBuffer ( new StringBuffer ()); -this.wrap = new com.stevesoft.pat.PartialBuffer (this.rb.sb); -this.moreToRead = true; -}); -Clazz.defineMethod (c$, "readData", -function () { -var c; -var n = 0; -while ((c = this.r.read ()) != -1) { -this.rb.sb.append (String.fromCharCode (c)); -if (n++ > this.nmax) { -break; -}} -if (c == -1 && n == 0) { -this.moreToRead = false; -this.wrap.allowOverRun = false; -}}); -Clazz.defineMethod (c$, "getMoreData", -function () { -while (this.rb.pos >= this.rb.epos) { -this.wrap.overRun = false; -if (this.rb.next != null) { -this.rb = this.rb.next; -} else if (this.rb.done) { -break; -} else if (this.rb.epos >= this.rb.sb.length () && this.rb.epos > this.nmax) { -this.rb.pos = 1; -this.rb.epos = 1; -this.rb.sb.setLength (1); -this.readData (); -} else if (this.rb.epos >= this.rb.sb.length () && this.moreToRead) { -this.readData (); -} else if (this.rp.getRegex ().matchAtLike (this.wrap, this.rb.epos)) { -if (this.wrap.overRun) { -this.readData (); -} else { -var sbw = new com.stevesoft.pat.wrap.StringBufferWrap (); -var sbl = new com.stevesoft.pat.StringBufferLike (sbw); -var rex = this.rp.getRegex (); -var npos = rex.matchedTo (); -this.rp.setBuffer (sbl); -this.rp.setSource (this.wrap); -this.rp.setPos (npos); -this.rp.apply (rex, rex.getReplaceRule ()); -var opos = this.rb.epos; -var rb2 = new com.stevesoft.pat.RBuffer (sbw.unwrap ()); -rb2.epos = rb2.sb.length (); -var rb3 = new com.stevesoft.pat.RBuffer (this.rb.sb); -this.rb.next = rb2; -rb2.next = rb3; -if (npos == opos) { -rb3.epos = npos + 1; -if (rb3.epos > rb3.sb.length ()) { -if (this.rb.pos >= this.rb.epos) { -this.rb = this.rb.next; -}rb3.pos = rb3.epos = 0; -rb3.done = true; -}rb3.pos = npos; -} else { -rb3.pos = rb3.epos = npos; -}}} else { -if (this.wrap.overRun) { -this.readData (); -} else if (this.rb.epos < this.rb.sb.length ()) { -this.rb.epos++; -} else { -break; -}}} -}); -Clazz.defineMethod (c$, "read", -function () { -if (this.rb.pos >= this.rb.epos) { -this.getMoreData (); -if (this.rb.pos >= this.rb.epos) { -return -1; -}}return this.rb.sb.charAt (this.rb.pos++); -}); -Clazz.defineMethod (c$, "read", -function (buf, off, len) { -var c = -1; -var end = off + len; -for (var i = off; i < end; i++) { -c = this.read (); -if (c < 0) { -if (i == off) { -return -1; -}return i - off; -}buf[i] = String.fromCharCode (c); -} -return len; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "close", -function () { -this.r.close (); -}); -Clazz.overrideMethod (c$, "markSupported", -function () { -return false; -}); -Clazz.defineMethod (c$, "getBufferSize", -function () { -return this.nmax; -}); -Clazz.defineMethod (c$, "setBufferSize", -function (n) { -this.nmax = n; -}, "~N"); -Clazz.defineMethod (c$, "getMaxLines", -function () { -return this.max_lines; -}); -Clazz.defineMethod (c$, "setMaxLines", -function (ml) { -this.max_lines = ml; -}, "~N"); -Clazz.defineMethod (c$, "getEOLchar", -function () { -return this.EOLchar; -}); -Clazz.defineMethod (c$, "setEOLchar", -function (c) { -this.EOLchar = c; -}, "~S"); -Clazz.overrideMethod (c$, "skip", -function (d) { -var n = 0; -while (n < d && this.read () != -1) { -n++; -} -return n; -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.io.Reader", "com.stevesoft.pat.PartialBuffer", "$.RBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexReader", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.StringBufferWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.rb = null; +this.wrap = null; +this.moreToRead = true; +this.r = null; +this.rp = null; +this.nmax = 2048; +this.max_lines = 2; +this.EOLchar = '\n'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegexReader", java.io.Reader); +Clazz.prepareFields (c$, function () { +this.rb = new com.stevesoft.pat.RBuffer ( new StringBuffer ()); +this.wrap = new com.stevesoft.pat.PartialBuffer (this.rb.sb); +}); +Clazz.makeConstructor (c$, +function (rex, r) { +Clazz.superConstructor (this, com.stevesoft.pat.RegexReader, []); +this.r = r; +this.rp = rex.getReplacer (); +}, "com.stevesoft.pat.Regex,java.io.Reader"); +Clazz.makeConstructor (c$, +function (tex, r) { +Clazz.superConstructor (this, com.stevesoft.pat.RegexReader, []); +this.r = r; +this.rp = tex.getReplacer (); +}, "com.stevesoft.pat.Transformer,java.io.Reader"); +Clazz.defineMethod (c$, "reset", +function () { +this.r.reset (); +this.rb = new com.stevesoft.pat.RBuffer ( new StringBuffer ()); +this.wrap = new com.stevesoft.pat.PartialBuffer (this.rb.sb); +this.moreToRead = true; +}); +Clazz.defineMethod (c$, "readData", +function () { +var c; +var n = 0; +while ((c = this.r.read ()) != -1) { +this.rb.sb.append (String.fromCharCode (c)); +if (n++ > this.nmax) { +break; +}} +if (c == -1 && n == 0) { +this.moreToRead = false; +this.wrap.allowOverRun = false; +}}); +Clazz.defineMethod (c$, "getMoreData", +function () { +while (this.rb.pos >= this.rb.epos) { +this.wrap.overRun = false; +if (this.rb.next != null) { +this.rb = this.rb.next; +} else if (this.rb.done) { +break; +} else if (this.rb.epos >= this.rb.sb.length () && this.rb.epos > this.nmax) { +this.rb.pos = 1; +this.rb.epos = 1; +this.rb.sb.setLength (1); +this.readData (); +} else if (this.rb.epos >= this.rb.sb.length () && this.moreToRead) { +this.readData (); +} else if (this.rp.getRegex ().matchAtLike (this.wrap, this.rb.epos)) { +if (this.wrap.overRun) { +this.readData (); +} else { +var sbw = new com.stevesoft.pat.wrap.StringBufferWrap (); +var sbl = new com.stevesoft.pat.StringBufferLike (sbw); +var rex = this.rp.getRegex (); +var npos = rex.matchedTo (); +this.rp.setBuffer (sbl); +this.rp.setSource (this.wrap); +this.rp.setPos (npos); +this.rp.apply (rex, rex.getReplaceRule ()); +var opos = this.rb.epos; +var rb2 = new com.stevesoft.pat.RBuffer (sbw.unwrap ()); +rb2.epos = rb2.sb.length (); +var rb3 = new com.stevesoft.pat.RBuffer (this.rb.sb); +this.rb.next = rb2; +rb2.next = rb3; +if (npos == opos) { +rb3.epos = npos + 1; +if (rb3.epos > rb3.sb.length ()) { +if (this.rb.pos >= this.rb.epos) { +this.rb = this.rb.next; +}rb3.pos = rb3.epos = 0; +rb3.done = true; +}rb3.pos = npos; +} else { +rb3.pos = rb3.epos = npos; +}}} else { +if (this.wrap.overRun) { +this.readData (); +} else if (this.rb.epos < this.rb.sb.length ()) { +this.rb.epos++; +} else { +break; +}}} +}); +Clazz.defineMethod (c$, "read", +function () { +if (this.rb.pos >= this.rb.epos) { +this.getMoreData (); +if (this.rb.pos >= this.rb.epos) { +return -1; +}}return this.rb.sb.charAt (this.rb.pos++); +}); +Clazz.defineMethod (c$, "read", +function (buf, off, len) { +var c = -1; +var end = off + len; +for (var i = off; i < end; i++) { +c = this.read (); +if (c < 0) { +if (i == off) { +return -1; +}return i - off; +}buf[i] = String.fromCharCode (c); +} +return len; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "close", +function () { +this.r.close (); +}); +Clazz.overrideMethod (c$, "markSupported", +function () { +return false; +}); +Clazz.defineMethod (c$, "getBufferSize", +function () { +return this.nmax; +}); +Clazz.defineMethod (c$, "setBufferSize", +function (n) { +this.nmax = n; +}, "~N"); +Clazz.defineMethod (c$, "getMaxLines", +function () { +return this.max_lines; +}); +Clazz.defineMethod (c$, "setMaxLines", +function (ml) { +this.max_lines = ml; +}, "~N"); +Clazz.defineMethod (c$, "getEOLchar", +function () { +return this.EOLchar; +}); +Clazz.defineMethod (c$, "setEOLchar", +function (c) { +this.EOLchar = c; +}, "~S"); +Clazz.overrideMethod (c$, "skip", +function (d) { +var n = 0; +while (n < d && this.read () != -1) { +n++; +} +return n; +}, "~N"); +}); diff --git a/bin/com/stevesoft/pat/RegexTokenizer.js b/bin/com/stevesoft/pat/RegexTokenizer.js index c5774f3..08cc754 100644 --- a/bin/com/stevesoft/pat/RegexTokenizer.js +++ b/bin/com/stevesoft/pat/RegexTokenizer.js @@ -1,104 +1,104 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.util.Enumeration", "$.Vector"], "com.stevesoft.pat.RegexTokenizer", ["com.stevesoft.pat.Regex"], function () { -c$ = Clazz.decorateAsClass (function () { -this.toParse = null; -this.r = null; -this.count = 0; -this.v = null; -this.vi = null; -this.pos = 0; -this.offset = 1; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegexTokenizer", null, java.util.Enumeration); -Clazz.prepareFields (c$, function () { -this.v = new java.util.Vector (); -this.vi = new java.util.Vector (); -}); -Clazz.defineMethod (c$, "getMore", -function () { -var s = this.r.right (); -if (this.r.searchFrom (this.toParse, this.pos)) { -this.v.addElement (this.r.left ().substring (this.pos)); -this.vi.addElement ( new Integer (this.r.matchFrom () + this.r.charsMatched ())); -for (var i = 0; i < this.r.numSubs (); i++) { -if (this.r.substring () != null) { -this.v.addElement (this.r.substringI (i + this.offset)); -this.vi.addElement ( new Integer (this.r.matchFromI (i + this.offset) + this.r.charsMatchedI (i + this.offset))); -}} -this.pos = this.r.matchFrom () + this.r.charsMatched (); -} else if (s != null) { -this.v.addElement (s); -}}); -Clazz.makeConstructor (c$, -function (txt, ptrn) { -this.toParse = txt; -this.r = new com.stevesoft.pat.Regex (ptrn, ""); -this.offset = com.stevesoft.pat.Regex.BackRefOffset; -this.getMore (); -}, "~S,~S"); -Clazz.makeConstructor (c$, -function (txt, r) { -this.toParse = txt; -this.r = r; -this.offset = com.stevesoft.pat.Regex.BackRefOffset; -this.getMore (); -}, "~S,com.stevesoft.pat.Regex"); -Clazz.overrideMethod (c$, "nextElement", -function () { -if (this.count >= this.v.size ()) { -this.getMore (); -}return this.v.elementAt (this.count++); -}); -Clazz.defineMethod (c$, "nextToken", -function () { -return this.nextElement (); -}); -Clazz.defineMethod (c$, "nextToken", -function (newpat) { -try { -this.r.compile (newpat); -} catch (r_) { -if (Clazz.exceptionOf (r_, com.stevesoft.pat.RegSyntax)) { -} else { -throw r_; -} -} -return this.nextToken (this.r); -}, "~S"); -Clazz.defineMethod (c$, "nextToken", -function (nr) { -this.r = nr; -if (this.vi.size () > this.count) { -this.pos = (this.vi.elementAt (this.count)).intValue (); -this.v.setSize (this.count); -this.vi.setSize (this.count); -}this.getMore (); -return this.nextToken (); -}, "com.stevesoft.pat.Regex"); -Clazz.overrideMethod (c$, "hasMoreElements", -function () { -if (this.count >= this.v.size ()) { -this.getMore (); -}return this.count < this.v.size (); -}); -Clazz.defineMethod (c$, "hasMoreTokens", -function () { -return this.hasMoreElements (); -}); -Clazz.defineMethod (c$, "countTokens", -function () { -var _count = this.count; -while (this.hasMoreTokens ()) { -this.nextToken (); -} -this.count = _count; -return this.v.size () - this.count; -}); -Clazz.defineMethod (c$, "allTokens", -function () { -this.countTokens (); -var ret = new Array (this.v.size ()); -this.v.copyInto (ret); -return ret; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.util.Enumeration", "$.Vector"], "com.stevesoft.pat.RegexTokenizer", ["com.stevesoft.pat.Regex"], function () { +c$ = Clazz.decorateAsClass (function () { +this.toParse = null; +this.r = null; +this.count = 0; +this.v = null; +this.vi = null; +this.pos = 0; +this.offset = 1; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegexTokenizer", null, java.util.Enumeration); +Clazz.prepareFields (c$, function () { +this.v = new java.util.Vector (); +this.vi = new java.util.Vector (); +}); +Clazz.defineMethod (c$, "getMore", +function () { +var s = this.r.right (); +if (this.r.searchFrom (this.toParse, this.pos)) { +this.v.addElement (this.r.left ().substring (this.pos)); +this.vi.addElement ( new Integer (this.r.matchFrom () + this.r.charsMatched ())); +for (var i = 0; i < this.r.numSubs (); i++) { +if (this.r.substring () != null) { +this.v.addElement (this.r.substringI (i + this.offset)); +this.vi.addElement ( new Integer (this.r.matchFromI (i + this.offset) + this.r.charsMatchedI (i + this.offset))); +}} +this.pos = this.r.matchFrom () + this.r.charsMatched (); +} else if (s != null) { +this.v.addElement (s); +}}); +Clazz.makeConstructor (c$, +function (txt, ptrn) { +this.toParse = txt; +this.r = new com.stevesoft.pat.Regex (ptrn, ""); +this.offset = com.stevesoft.pat.Regex.BackRefOffset; +this.getMore (); +}, "~S,~S"); +Clazz.makeConstructor (c$, +function (txt, r) { +this.toParse = txt; +this.r = r; +this.offset = com.stevesoft.pat.Regex.BackRefOffset; +this.getMore (); +}, "~S,com.stevesoft.pat.Regex"); +Clazz.overrideMethod (c$, "nextElement", +function () { +if (this.count >= this.v.size ()) { +this.getMore (); +}return this.v.elementAt (this.count++); +}); +Clazz.defineMethod (c$, "nextToken", +function () { +return this.nextElement (); +}); +Clazz.defineMethod (c$, "nextToken", +function (newpat) { +try { +this.r.compile (newpat); +} catch (r_) { +if (Clazz.exceptionOf (r_, com.stevesoft.pat.RegSyntax)) { +} else { +throw r_; +} +} +return this.nextToken (this.r); +}, "~S"); +Clazz.defineMethod (c$, "nextToken", +function (nr) { +this.r = nr; +if (this.vi.size () > this.count) { +this.pos = (this.vi.elementAt (this.count)).intValue (); +this.v.setSize (this.count); +this.vi.setSize (this.count); +}this.getMore (); +return this.nextToken (); +}, "com.stevesoft.pat.Regex"); +Clazz.overrideMethod (c$, "hasMoreElements", +function () { +if (this.count >= this.v.size ()) { +this.getMore (); +}return this.count < this.v.size (); +}); +Clazz.defineMethod (c$, "hasMoreTokens", +function () { +return this.hasMoreElements (); +}); +Clazz.defineMethod (c$, "countTokens", +function () { +var _count = this.count; +while (this.hasMoreTokens ()) { +this.nextToken (); +} +this.count = _count; +return this.v.size () - this.count; +}); +Clazz.defineMethod (c$, "allTokens", +function () { +this.countTokens (); +var ret = new Array (this.v.size ()); +this.v.copyInto (ret); +return ret; +}); +}); diff --git a/bin/com/stevesoft/pat/RegexWriter.js b/bin/com/stevesoft/pat/RegexWriter.js index f1be88e..817515b 100644 --- a/bin/com/stevesoft/pat/RegexWriter.js +++ b/bin/com/stevesoft/pat/RegexWriter.js @@ -1,134 +1,134 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.io.Writer", "com.stevesoft.pat.PartialBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexWriter", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.WriterWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.repr = null; -this.w = null; -this.ww = null; -this.sb = null; -this.wrap = null; -this.pos = 0; -this.epos = 0; -this.interval = 128; -this.bufferSize = 2048; -this.EOLchar = '\n'; -this.max_lines = 2; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegexWriter", java.io.Writer); -Clazz.prepareFields (c$, function () { -this.sb = new StringBuffer (); -this.wrap = new com.stevesoft.pat.PartialBuffer (this.sb); -}); -Clazz.makeConstructor (c$, -function (t, w) { -Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); -this.w = w; -this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); -this.repr = t.getReplacer (); -this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); -this.repr.setSource (this.wrap); -}, "com.stevesoft.pat.Transformer,java.io.Writer"); -Clazz.makeConstructor (c$, -function (r, w) { -Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); -this.w = w; -this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); -this.repr = r.getReplacer (); -this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); -this.repr.setSource (this.wrap); -}, "com.stevesoft.pat.Regex,java.io.Writer"); -Clazz.defineMethod (c$, "getEOLchar", -function () { -return this.EOLchar; -}); -Clazz.defineMethod (c$, "setEOLchar", -function (c) { -this.EOLchar = c; -}, "~S"); -Clazz.defineMethod (c$, "getMaxLines", -function () { -return this.max_lines; -}); -Clazz.defineMethod (c$, "setMaxLines", -function (ml) { -this.max_lines = ml; -}, "~N"); -Clazz.defineMethod (c$, "write", -function () { -var rex = this.repr.getRegex (); -var eposOld = this.epos; -if (rex.matchAtLike (this.wrap, this.epos) && !this.wrap.overRun) { -while (this.pos < this.epos) { -this.w.write (this.sb.charCodeAt (this.pos++)); -} -var to = rex.matchedTo (); -this.repr.setPos (to); -this.repr.apply (rex, rex.getReplaceRule ()); -this.epos = this.pos = to; -if (this.epos == eposOld && this.epos < this.sb.length ()) { -this.epos++; -}} else if (!this.wrap.overRun && this.epos < this.sb.length ()) { -this.epos++; -}while (this.pos < this.epos) { -this.w.write (this.sb.charCodeAt (this.pos++)); -} -if (this.epos == this.sb.length ()) { -this.sb.setLength (1); -this.pos = this.epos = 1; -} else if (this.pos > this.bufferSize) { -for (var i = this.bufferSize; i < this.sb.length (); i++) { -this.sb.setCharAt (i - this.bufferSize, this.sb.charAt (i)); -} -this.pos -= this.bufferSize; -this.epos -= this.bufferSize; -this.sb.setLength (this.sb.length () - this.bufferSize); -}}); -Clazz.defineMethod (c$, "write", -function (ca, b, n) { -var m = b + n; -for (var i = b; i < m; i++) { -this.sb.append (ca[i]); -if (this.sb.length () % this.interval == this.interval - 1) { -this.wrap.overRun = false; -while (this.epos + this.interval < this.sb.length () && !this.wrap.overRun) { -this.write (); -} -}} -}, "~A,~N,~N"); -Clazz.overrideMethod (c$, "flush", -function () { -}); -Clazz.defineMethod (c$, "close", -function () { -this.wrap.allowOverRun = false; -this.wrap.overRun = false; -while (this.epos < this.sb.length ()) { -this.write (); -} -this.write (); -this.w.close (); -}); -Clazz.defineMethod (c$, "length", -function () { -return this.sb.length (); -}); -Clazz.defineMethod (c$, "charAt", -function (i) { -return this.sb.charAt (i); -}, "~N"); -Clazz.defineMethod (c$, "setInterval", -function (i) { -this.interval = i; -}, "~N"); -Clazz.defineMethod (c$, "getInterval", -function () { -return this.interval; -}); -Clazz.defineMethod (c$, "getBufferSize", -function () { -return this.bufferSize; -}); -Clazz.defineMethod (c$, "setBufferSize", -function (i) { -this.bufferSize = i; -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.io.Writer", "com.stevesoft.pat.PartialBuffer", "java.lang.StringBuffer"], "com.stevesoft.pat.RegexWriter", ["com.stevesoft.pat.StringBufferLike", "com.stevesoft.pat.wrap.WriterWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.repr = null; +this.w = null; +this.ww = null; +this.sb = null; +this.wrap = null; +this.pos = 0; +this.epos = 0; +this.interval = 128; +this.bufferSize = 2048; +this.EOLchar = '\n'; +this.max_lines = 2; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegexWriter", java.io.Writer); +Clazz.prepareFields (c$, function () { +this.sb = new StringBuffer (); +this.wrap = new com.stevesoft.pat.PartialBuffer (this.sb); +}); +Clazz.makeConstructor (c$, +function (t, w) { +Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); +this.w = w; +this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); +this.repr = t.getReplacer (); +this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); +this.repr.setSource (this.wrap); +}, "com.stevesoft.pat.Transformer,java.io.Writer"); +Clazz.makeConstructor (c$, +function (r, w) { +Clazz.superConstructor (this, com.stevesoft.pat.RegexWriter, []); +this.w = w; +this.ww = new com.stevesoft.pat.wrap.WriterWrap (w); +this.repr = r.getReplacer (); +this.repr.setBuffer ( new com.stevesoft.pat.StringBufferLike (this.ww)); +this.repr.setSource (this.wrap); +}, "com.stevesoft.pat.Regex,java.io.Writer"); +Clazz.defineMethod (c$, "getEOLchar", +function () { +return this.EOLchar; +}); +Clazz.defineMethod (c$, "setEOLchar", +function (c) { +this.EOLchar = c; +}, "~S"); +Clazz.defineMethod (c$, "getMaxLines", +function () { +return this.max_lines; +}); +Clazz.defineMethod (c$, "setMaxLines", +function (ml) { +this.max_lines = ml; +}, "~N"); +Clazz.defineMethod (c$, "write", +function () { +var rex = this.repr.getRegex (); +var eposOld = this.epos; +if (rex.matchAtLike (this.wrap, this.epos) && !this.wrap.overRun) { +while (this.pos < this.epos) { +this.w.write (this.sb.charCodeAt (this.pos++)); +} +var to = rex.matchedTo (); +this.repr.setPos (to); +this.repr.apply (rex, rex.getReplaceRule ()); +this.epos = this.pos = to; +if (this.epos == eposOld && this.epos < this.sb.length ()) { +this.epos++; +}} else if (!this.wrap.overRun && this.epos < this.sb.length ()) { +this.epos++; +}while (this.pos < this.epos) { +this.w.write (this.sb.charCodeAt (this.pos++)); +} +if (this.epos == this.sb.length ()) { +this.sb.setLength (1); +this.pos = this.epos = 1; +} else if (this.pos > this.bufferSize) { +for (var i = this.bufferSize; i < this.sb.length (); i++) { +this.sb.setCharAt (i - this.bufferSize, this.sb.charAt (i)); +} +this.pos -= this.bufferSize; +this.epos -= this.bufferSize; +this.sb.setLength (this.sb.length () - this.bufferSize); +}}); +Clazz.defineMethod (c$, "write", +function (ca, b, n) { +var m = b + n; +for (var i = b; i < m; i++) { +this.sb.append (ca[i]); +if (this.sb.length () % this.interval == this.interval - 1) { +this.wrap.overRun = false; +while (this.epos + this.interval < this.sb.length () && !this.wrap.overRun) { +this.write (); +} +}} +}, "~A,~N,~N"); +Clazz.overrideMethod (c$, "flush", +function () { +}); +Clazz.defineMethod (c$, "close", +function () { +this.wrap.allowOverRun = false; +this.wrap.overRun = false; +while (this.epos < this.sb.length ()) { +this.write (); +} +this.write (); +this.w.close (); +}); +Clazz.defineMethod (c$, "length", +function () { +return this.sb.length (); +}); +Clazz.defineMethod (c$, "charAt", +function (i) { +return this.sb.charAt (i); +}, "~N"); +Clazz.defineMethod (c$, "setInterval", +function (i) { +this.interval = i; +}, "~N"); +Clazz.defineMethod (c$, "getInterval", +function () { +return this.interval; +}); +Clazz.defineMethod (c$, "getBufferSize", +function () { +return this.bufferSize; +}); +Clazz.defineMethod (c$, "setBufferSize", +function (i) { +this.bufferSize = i; +}, "~N"); +}); diff --git a/bin/com/stevesoft/pat/ReplaceRule.js b/bin/com/stevesoft/pat/ReplaceRule.js index 7485c5f..795545b 100644 --- a/bin/com/stevesoft/pat/ReplaceRule.js +++ b/bin/com/stevesoft/pat/ReplaceRule.js @@ -1,203 +1,203 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["java.util.Hashtable"], "com.stevesoft.pat.ReplaceRule", ["com.stevesoft.pat.Ctrl", "$.Regex", "$.Transformer", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.next = null; -this.name = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "ReplaceRule"); -Clazz.prepareFields (c$, function () { -this.name = this.getClass ().getName (); -}); -Clazz.defineMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.RuleHolder (this); -}); -Clazz.overrideMethod (c$, "clone", -function () { -var x = this.clone1 (); -var xsav = x; -var y = this; -while (y.next != null) { -x.next = y.next.clone1 (); -x.name = y.name; -x = x.next; -y = y.next; -} -return xsav; -}); -c$.add = Clazz.defineMethod (c$, "add", -function (head, adding) { -if (head == null) { -return head = adding; -}head.addRule (adding); -return head; -}, "com.stevesoft.pat.ReplaceRule,com.stevesoft.pat.ReplaceRule"); -Clazz.defineMethod (c$, "add", -function (adding) { -return com.stevesoft.pat.ReplaceRule.add (this, adding); -}, "com.stevesoft.pat.ReplaceRule"); -Clazz.defineMethod (c$, "addRule", -function (r) { -if (this.next == null) { -this.next = r; -} else { -this.next.addRule (r); -}}, "com.stevesoft.pat.ReplaceRule"); -c$.getv = Clazz.defineMethod (c$, "getv", -($fz = function () { -if (com.stevesoft.pat.ReplaceRule.getvar != null) { -return com.stevesoft.pat.ReplaceRule.getvar.clone (); -}com.stevesoft.pat.ReplaceRule.getvar = new com.stevesoft.pat.Regex ("(?:\\\\(\\d+)|\\$(?:(\\d+)|(\\w+)|([&\'`])|\\{(?:(\\d+)|([^\n}\\\\]+))})|\\\\([nrbtaef])|\\\\c([\u0000-\uffff])|\\\\x([A-Fa-f0-9]{2})|\\\\([\u0000-\uffff]))", ""); -com.stevesoft.pat.ReplaceRule.getvar.optimize (); -return com.stevesoft.pat.ReplaceRule.getvar; -}, $fz.isPrivate = true, $fz)); -c$.perlCode = Clazz.defineMethod (c$, "perlCode", -function (s) { -try { -var mf = 0; -var mt = 0; -var gv = com.stevesoft.pat.ReplaceRule.getv (); -var head = null; -var tmp = null; -while (gv.searchFrom (s, mt)) { -var off = com.stevesoft.pat.Regex.BackRefOffset - 1; -mf = gv.matchedFrom (); -if (mf > mt) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule (s.substring (mt, mf))); -}var $var = null; -if (($var = gv.stringMatchedI (1 + off)) != null || ($var = gv.stringMatchedI (2 + off)) != null || ($var = gv.stringMatchedI (5 + off)) != null) { -var d = 0; -for (var i = 0; i < $var.length; i++) { -d = 8 * d + ($var.charCodeAt (i) - 48); -} -if ($var.length == 1) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.BackRefRule (d)); -} else { -head = new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d)); -}} else if (($var = gv.stringMatchedI (10 + off)) != null) { -if ("QELlUu".indexOf ($var) >= 0) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.CodeRule ($var.charAt (0))); -} else { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ($var)); -}} else if (($var = gv.stringMatchedI (3 + off)) != null || ($var = gv.stringMatchedI (4 + off)) != null || ($var = gv.stringMatchedI (6 + off)) != null) { -var arg = ""; -var pc; -if ((pc = $var.indexOf (':')) > 0) { -arg = $var.substring (pc + 1); -$var = $var.substring (0, pc); -}if ($var.equals ("&") || $var.equals ("MATCH")) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.AmpersandRule ()); -} else if ($var.equals ("`") || $var.equals ("PREMATCH")) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.LeftRule ()); -} else if ($var.equals ("'") || $var.equals ("POSTMATCH")) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.RightRule ()); -} else if ($var.equals ("WANT_MORE_TEXT")) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.WantMoreTextReplaceRule ()); -} else if ($var.equals ("POP")) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.PopRule ()); -} else if ($var.startsWith ("+") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) { -if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.PushRule ($var.substring (1), tmp)); -} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.PushRule ($var.substring (1), tmp)); -} else { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("${" + $var + "}")); -}} else if ($var.startsWith ("=") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) { -if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp)); -} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp)); -} else { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("${" + $var + "}")); -}} else if ((tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var)) != null) { -if (Clazz.instanceOf (tmp, com.stevesoft.pat.ReplaceRule)) { -var alt = (tmp).arg (arg); -if (alt == null) { -alt = (tmp); -}head = com.stevesoft.pat.ReplaceRule.add (head, (alt.clone ())); -}} else { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("${" + $var + "}")); -}} else if (($var = gv.stringMatchedI (7 + off)) != null) { -var c = $var.charAt (0); -if (c == 'n') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\n")); -} else if (c == 't') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\t")); -} else if (c == 'r') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\r")); -} else if (c == 'b') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\r")); -} else if (c == 'a') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\u0007")); -} else if (c == 'e') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\u001b")); -} else if (c == 'f') { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\f")); -}} else if (($var = gv.stringMatchedI (8 + off)) != null) { -var c = $var.charAt (0); -if (c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) { -c = com.stevesoft.pat.Ctrl.cmap[c.charCodeAt (0)]; -}head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("" + c)); -} else if (($var = gv.stringMatchedI (9 + off)) != null) { -var d = 16 * com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (0)) + com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (1)); -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d))); -}mt = gv.matchedTo (); -} -if (mt <= s.length) { -head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule (s.substring (mt))); -}return head; -} finally { -} -}, "~S"); -c$.isDefined = Clazz.defineMethod (c$, "isDefined", -function (s) { -return com.stevesoft.pat.ReplaceRule.defs.get (s) != null; -}, "~S"); -c$.define = Clazz.defineMethod (c$, "define", -function (s, r) { -com.stevesoft.pat.ReplaceRule.defs.put (s, r); -}, "~S,com.stevesoft.pat.Regex"); -c$.define = Clazz.defineMethod (c$, "define", -function (s, r) { -com.stevesoft.pat.ReplaceRule.defs.put (s, r); -r.name = s; -}, "~S,com.stevesoft.pat.ReplaceRule"); -c$.define = Clazz.defineMethod (c$, "define", -function (s, t) { -com.stevesoft.pat.ReplaceRule.defs.put (s, t); -}, "~S,com.stevesoft.pat.Transformer"); -c$.undefine = Clazz.defineMethod (c$, "undefine", -function (s) { -com.stevesoft.pat.ReplaceRule.defs.remove (s); -}, "~S"); -Clazz.defineMethod (c$, "toString1", -function () { -return "${" + this.name + "}"; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var sb = new StringBuffer (); -sb.append (this.toString1 ()); -var rr = this.next; -while (rr != null) { -sb.append (rr.toString1 ()); -rr = rr.next; -} -return sb.toString (); -}); -Clazz.defineMethod (c$, "arg", -function (s) { -return null; -}, "~S"); -c$.getHexDigit = Clazz.defineMethod (c$, "getHexDigit", -function (c) { -if (c >= '0' && c <= '9') { -return c.charCodeAt (0) - 48; -}if (c >= 'a' && c <= 'f') { -return c.charCodeAt (0) - 97 + 10; -}return c.charCodeAt (0) - 65 + 10; -}, "~S"); -Clazz.defineStatics (c$, -"getvar", null); -c$.defs = c$.prototype.defs = new java.util.Hashtable (); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["java.util.Hashtable"], "com.stevesoft.pat.ReplaceRule", ["com.stevesoft.pat.Ctrl", "$.Regex", "$.Transformer", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.next = null; +this.name = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "ReplaceRule"); +Clazz.prepareFields (c$, function () { +this.name = this.getClass ().getName (); +}); +Clazz.defineMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.RuleHolder (this); +}); +Clazz.overrideMethod (c$, "clone", +function () { +var x = this.clone1 (); +var xsav = x; +var y = this; +while (y.next != null) { +x.next = y.next.clone1 (); +x.name = y.name; +x = x.next; +y = y.next; +} +return xsav; +}); +c$.add = Clazz.defineMethod (c$, "add", +function (head, adding) { +if (head == null) { +return head = adding; +}head.addRule (adding); +return head; +}, "com.stevesoft.pat.ReplaceRule,com.stevesoft.pat.ReplaceRule"); +Clazz.defineMethod (c$, "add", +function (adding) { +return com.stevesoft.pat.ReplaceRule.add (this, adding); +}, "com.stevesoft.pat.ReplaceRule"); +Clazz.defineMethod (c$, "addRule", +function (r) { +if (this.next == null) { +this.next = r; +} else { +this.next.addRule (r); +}}, "com.stevesoft.pat.ReplaceRule"); +c$.getv = Clazz.defineMethod (c$, "getv", +($fz = function () { +if (com.stevesoft.pat.ReplaceRule.getvar != null) { +return com.stevesoft.pat.ReplaceRule.getvar.clone (); +}com.stevesoft.pat.ReplaceRule.getvar = new com.stevesoft.pat.Regex ("(?:\\\\(\\d+)|\\$(?:(\\d+)|(\\w+)|([&\'`])|\\{(?:(\\d+)|([^\n}\\\\]+))})|\\\\([nrbtaef])|\\\\c([\u0000-\uffff])|\\\\x([A-Fa-f0-9]{2})|\\\\([\u0000-\uffff]))", ""); +com.stevesoft.pat.ReplaceRule.getvar.optimize (); +return com.stevesoft.pat.ReplaceRule.getvar; +}, $fz.isPrivate = true, $fz)); +c$.perlCode = Clazz.defineMethod (c$, "perlCode", +function (s) { +try { +var mf = 0; +var mt = 0; +var gv = com.stevesoft.pat.ReplaceRule.getv (); +var head = null; +var tmp = null; +while (gv.searchFrom (s, mt)) { +var off = com.stevesoft.pat.Regex.BackRefOffset - 1; +mf = gv.matchedFrom (); +if (mf > mt) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule (s.substring (mt, mf))); +}var $var = null; +if (($var = gv.stringMatchedI (1 + off)) != null || ($var = gv.stringMatchedI (2 + off)) != null || ($var = gv.stringMatchedI (5 + off)) != null) { +var d = 0; +for (var i = 0; i < $var.length; i++) { +d = 8 * d + ($var.charCodeAt (i) - 48); +} +if ($var.length == 1) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.BackRefRule (d)); +} else { +head = new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d)); +}} else if (($var = gv.stringMatchedI (10 + off)) != null) { +if ("QELlUu".indexOf ($var) >= 0) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.CodeRule ($var.charAt (0))); +} else { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ($var)); +}} else if (($var = gv.stringMatchedI (3 + off)) != null || ($var = gv.stringMatchedI (4 + off)) != null || ($var = gv.stringMatchedI (6 + off)) != null) { +var arg = ""; +var pc; +if ((pc = $var.indexOf (':')) > 0) { +arg = $var.substring (pc + 1); +$var = $var.substring (0, pc); +}if ($var.equals ("&") || $var.equals ("MATCH")) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.AmpersandRule ()); +} else if ($var.equals ("`") || $var.equals ("PREMATCH")) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.LeftRule ()); +} else if ($var.equals ("'") || $var.equals ("POSTMATCH")) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.RightRule ()); +} else if ($var.equals ("WANT_MORE_TEXT")) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.WantMoreTextReplaceRule ()); +} else if ($var.equals ("POP")) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.PopRule ()); +} else if ($var.startsWith ("+") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) { +if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.PushRule ($var.substring (1), tmp)); +} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.PushRule ($var.substring (1), tmp)); +} else { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("${" + $var + "}")); +}} else if ($var.startsWith ("=") && (tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var.substring (1))) != null) { +if (Clazz.instanceOf (tmp, com.stevesoft.pat.Regex)) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp)); +} else if (Clazz.instanceOf (tmp, com.stevesoft.pat.Transformer)) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.ChangeRule ($var.substring (1), tmp)); +} else { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("${" + $var + "}")); +}} else if ((tmp = com.stevesoft.pat.ReplaceRule.defs.get ($var)) != null) { +if (Clazz.instanceOf (tmp, com.stevesoft.pat.ReplaceRule)) { +var alt = (tmp).arg (arg); +if (alt == null) { +alt = (tmp); +}head = com.stevesoft.pat.ReplaceRule.add (head, (alt.clone ())); +}} else { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("${" + $var + "}")); +}} else if (($var = gv.stringMatchedI (7 + off)) != null) { +var c = $var.charAt (0); +if (c == 'n') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\n")); +} else if (c == 't') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\t")); +} else if (c == 'r') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\r")); +} else if (c == 'b') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\r")); +} else if (c == 'a') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\u0007")); +} else if (c == 'e') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\u001b")); +} else if (c == 'f') { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("\f")); +}} else if (($var = gv.stringMatchedI (8 + off)) != null) { +var c = $var.charAt (0); +if (c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) { +c = com.stevesoft.pat.Ctrl.cmap[c.charCodeAt (0)]; +}head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("" + c)); +} else if (($var = gv.stringMatchedI (9 + off)) != null) { +var d = 16 * com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (0)) + com.stevesoft.pat.ReplaceRule.getHexDigit ($var.charAt (1)); +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule ("" + String.fromCharCode (d))); +}mt = gv.matchedTo (); +} +if (mt <= s.length) { +head = com.stevesoft.pat.ReplaceRule.add (head, new com.stevesoft.pat.StringRule (s.substring (mt))); +}return head; +} finally { +} +}, "~S"); +c$.isDefined = Clazz.defineMethod (c$, "isDefined", +function (s) { +return com.stevesoft.pat.ReplaceRule.defs.get (s) != null; +}, "~S"); +c$.define = Clazz.defineMethod (c$, "define", +function (s, r) { +com.stevesoft.pat.ReplaceRule.defs.put (s, r); +}, "~S,com.stevesoft.pat.Regex"); +c$.define = Clazz.defineMethod (c$, "define", +function (s, r) { +com.stevesoft.pat.ReplaceRule.defs.put (s, r); +r.name = s; +}, "~S,com.stevesoft.pat.ReplaceRule"); +c$.define = Clazz.defineMethod (c$, "define", +function (s, t) { +com.stevesoft.pat.ReplaceRule.defs.put (s, t); +}, "~S,com.stevesoft.pat.Transformer"); +c$.undefine = Clazz.defineMethod (c$, "undefine", +function (s) { +com.stevesoft.pat.ReplaceRule.defs.remove (s); +}, "~S"); +Clazz.defineMethod (c$, "toString1", +function () { +return "${" + this.name + "}"; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var sb = new StringBuffer (); +sb.append (this.toString1 ()); +var rr = this.next; +while (rr != null) { +sb.append (rr.toString1 ()); +rr = rr.next; +} +return sb.toString (); +}); +Clazz.defineMethod (c$, "arg", +function (s) { +return null; +}, "~S"); +c$.getHexDigit = Clazz.defineMethod (c$, "getHexDigit", +function (c) { +if (c >= '0' && c <= '9') { +return c.charCodeAt (0) - 48; +}if (c >= 'a' && c <= 'f') { +return c.charCodeAt (0) - 97 + 10; +}return c.charCodeAt (0) - 65 + 10; +}, "~S"); +Clazz.defineStatics (c$, +"getvar", null); +c$.defs = c$.prototype.defs = new java.util.Hashtable (); +}); diff --git a/bin/com/stevesoft/pat/Replacer.js b/bin/com/stevesoft/pat/Replacer.js index 996de92..847b11c 100644 --- a/bin/com/stevesoft/pat/Replacer.js +++ b/bin/com/stevesoft/pat/Replacer.js @@ -1,230 +1,230 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, ["com.stevesoft.pat.RegHolder", "$.Replacer", "$.CodeVal"], ["com.stevesoft.pat.AmpersandRule", "$.ChangeRule", "$.MessageManager", "$.PopRule", "$.PushRule", "$.RuleHolder", "$.SpecialRule", "$.StringBufferLike", "$.WantMoreTextReplaceRule", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException"], function () { -c$ = Clazz.decorateAsClass (function () { -this.me = null; -this.prev = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RegHolder"); -c$ = Clazz.decorateAsClass (function () { -this.pos = 0; -this.code = '\0'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "CodeVal"); -Clazz.makeConstructor (c$, -function (p, c) { -this.pos = p; -this.code = c; -}, "~N,~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(" + this.pos + "," + this.code + ")"; -}); -c$ = Clazz.decorateAsClass (function () { -this.first = false; -this.rh = null; -this.sb = null; -this.src = null; -this.pos = 0; -this.want_more_text = false; -this.want_more_text_enable = false; -this.$lastMatchedTo = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Replacer"); -Clazz.prepareFields (c$, function () { -this.rh = new com.stevesoft.pat.RegHolder (); -}); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, r, start, end) { -return this.replaceFirstRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); -}, "~S,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, r, start, end) { -this.first = true; -this.rh.me = r; -this.rh.prev = null; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceFirst", -function (s) { -return this.replaceFirstRegion (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "replaceFirstFrom", -function (s, start) { -return this.replaceFirstRegion (s, start, s.length ()); -}, "com.stevesoft.pat.StringLike,~N"); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, start, end) { -this.first = true; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, r, start, end) { -return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); -}, "~S,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, r, start, end) { -this.first = false; -this.rh.me = r; -this.rh.prev = null; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); -Clazz.defineMethod (c$, "replaceAll", -function (s) { -return this.replaceAllRegion (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "replaceAllFrom", -function (s, start) { -return this.replaceAllRegion (s, start, s.length ()); -}, "com.stevesoft.pat.StringLike,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, start, end) { -this.first = false; -return this.dorep (s, start, end); -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "replaceAll", -function (s) { -return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), 0, s.length).toString (); -}, "~S"); -Clazz.defineMethod (c$, "replaceAllFrom", -function (s, start) { -return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), start, s.length).toString (); -}, "~S,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, start, end) { -this.first = false; -return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString (); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "isSpecial", -function (x) { -while (x != null) { -if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule) || (Clazz.instanceOf (x, com.stevesoft.pat.RuleHolder) && Clazz.instanceOf ((x).held, com.stevesoft.pat.SpecialRule))) { -return true; -}x = x.next; -} -return false; -}, "com.stevesoft.pat.ReplaceRule"); -Clazz.defineMethod (c$, "apply1", -function (rr) { -rr.charsMatched_++; -this.apply (rr, null); -rr.charsMatched_--; -}, "com.stevesoft.pat.RegRes"); -Clazz.defineMethod (c$, "dorep", -function (s, start, end) { -var ret = s; -this.want_more_text = false; -this.$lastMatchedTo = 0; -if (this.rh.me == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.replace_null_regex_pointer")); -}if (this.rh.me._searchLike (s, start, end)) { -var rmn = this.rh.me.matchedTo (); -if (this.rh.me.charsMatched () == 0 && !this.isSpecial (this.rh.me.getReplaceRule ())) { -this.apply1 (this.rh.me); -rmn++; -}this.apply (this.rh.me); -if (!this.first) { -for (var i = rmn; !this.want_more_text && this.rh.me._searchLike (s, i, end); i = rmn) { -rmn = this.rh.me.matchedTo (); -if (this.rh.me.charsMatched () == 0) { -if (!this.isSpecial (this.rh.me.getReplaceRule ())) { -this.apply1 (this.rh.me); -}rmn++; -}this.apply (this.rh.me); -} -}ret = this.finish (); -ret = ret == null ? s : ret; -}return ret; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "apply", -function (r, rp) { -if (rp == null || (rp.next == null && Clazz.instanceOf (rp, com.stevesoft.pat.AmpersandRule))) { -return; -}if (r.didMatch ()) { -if (this.src == null) { -this.src = r.getStringLike (); -}if (this.sb == null) { -this.sb = new com.stevesoft.pat.StringBufferLike (this.src.newStringBufferLike ()); -}var rmf = r.matchedFrom (); -for (var ii = this.pos; ii < rmf; ii++) { -this.sb.appendC (this.src.charAt (ii)); -} -for (var x = rp; x != null; x = x.next) { -x.apply (this.sb, r); -if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule)) { -if (Clazz.instanceOf (x, com.stevesoft.pat.WantMoreTextReplaceRule) && this.want_more_text_enable) { -this.want_more_text = true; -} else if (Clazz.instanceOf (x, com.stevesoft.pat.PushRule)) { -var rh2 = new com.stevesoft.pat.RegHolder (); -rh2.me = (x).NewRule; -rh2.prev = this.rh; -this.rh = rh2; -} else if (Clazz.instanceOf (x, com.stevesoft.pat.PopRule)) { -if (this.rh.prev != null) { -this.rh = this.rh.prev; -}} else if (Clazz.instanceOf (x, com.stevesoft.pat.ChangeRule)) { -this.rh.me = (x).NewRule; -}}} -if (!this.want_more_text) { -this.pos = r.matchedTo (); -}}}, "com.stevesoft.pat.RegRes,com.stevesoft.pat.ReplaceRule"); -Clazz.defineMethod (c$, "WantMoreText", -function () { -return this.want_more_text; -}); -Clazz.defineMethod (c$, "apply", -function (r) { -this.apply (r, r.getReplaceRule ()); -}, "com.stevesoft.pat.Regex"); -Clazz.defineMethod (c$, "finish", -function () { -if (this.src == null) { -return null; -}var s_end = this.src.length (); -for (var ii = this.pos; ii < s_end; ii++) { -this.sb.appendC (this.src.charAt (ii)); -} -this.src = null; -this.$lastMatchedTo = this.pos; -this.pos = 0; -var retstr = this.sb.toStringLike (); -this.sb = null; -return retstr; -}); -Clazz.overrideMethod (c$, "clone", -function () { -var r = new com.stevesoft.pat.Replacer (); -r.first = this.first; -r.src = this.src; -r.sb = this.sb; -r.pos = this.pos; -r.$lastMatchedTo = this.$lastMatchedTo; -r.want_more_text = this.want_more_text; -r.want_more_text_enable = this.want_more_text_enable; -r.rh.me = this.rh.me; -r.rh.prev = this.rh.prev; -return r; -}); -Clazz.defineMethod (c$, "lastMatchedTo", -function () { -return this.$lastMatchedTo; -}); -Clazz.defineMethod (c$, "getRegex", -function () { -return this.rh.me; -}); -Clazz.defineMethod (c$, "setSource", -function (sl) { -this.src = sl; -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "setBuffer", -function (sbl) { -this.sb = sbl; -}, "com.stevesoft.pat.StringBufferLike"); -Clazz.defineMethod (c$, "setPos", -function (pos) { -this.pos = pos; -}, "~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, ["com.stevesoft.pat.RegHolder", "$.Replacer", "$.CodeVal"], ["com.stevesoft.pat.AmpersandRule", "$.ChangeRule", "$.MessageManager", "$.PopRule", "$.PushRule", "$.RuleHolder", "$.SpecialRule", "$.StringBufferLike", "$.WantMoreTextReplaceRule", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException"], function () { +c$ = Clazz.decorateAsClass (function () { +this.me = null; +this.prev = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RegHolder"); +c$ = Clazz.decorateAsClass (function () { +this.pos = 0; +this.code = '\0'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "CodeVal"); +Clazz.makeConstructor (c$, +function (p, c) { +this.pos = p; +this.code = c; +}, "~N,~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(" + this.pos + "," + this.code + ")"; +}); +c$ = Clazz.decorateAsClass (function () { +this.first = false; +this.rh = null; +this.sb = null; +this.src = null; +this.pos = 0; +this.want_more_text = false; +this.want_more_text_enable = false; +this.$lastMatchedTo = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Replacer"); +Clazz.prepareFields (c$, function () { +this.rh = new com.stevesoft.pat.RegHolder (); +}); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, r, start, end) { +return this.replaceFirstRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); +}, "~S,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, r, start, end) { +this.first = true; +this.rh.me = r; +this.rh.prev = null; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceFirst", +function (s) { +return this.replaceFirstRegion (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "replaceFirstFrom", +function (s, start) { +return this.replaceFirstRegion (s, start, s.length ()); +}, "com.stevesoft.pat.StringLike,~N"); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, start, end) { +this.first = true; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, r, start, end) { +return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), r, start, end); +}, "~S,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, r, start, end) { +this.first = false; +this.rh.me = r; +this.rh.prev = null; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Regex,~N,~N"); +Clazz.defineMethod (c$, "replaceAll", +function (s) { +return this.replaceAllRegion (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "replaceAllFrom", +function (s, start) { +return this.replaceAllRegion (s, start, s.length ()); +}, "com.stevesoft.pat.StringLike,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, start, end) { +this.first = false; +return this.dorep (s, start, end); +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "replaceAll", +function (s) { +return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), 0, s.length).toString (); +}, "~S"); +Clazz.defineMethod (c$, "replaceAllFrom", +function (s, start) { +return this.replaceAllRegion ( new com.stevesoft.pat.wrap.StringWrap (s), start, s.length).toString (); +}, "~S,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, start, end) { +this.first = false; +return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString (); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "isSpecial", +function (x) { +while (x != null) { +if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule) || (Clazz.instanceOf (x, com.stevesoft.pat.RuleHolder) && Clazz.instanceOf ((x).held, com.stevesoft.pat.SpecialRule))) { +return true; +}x = x.next; +} +return false; +}, "com.stevesoft.pat.ReplaceRule"); +Clazz.defineMethod (c$, "apply1", +function (rr) { +rr.charsMatched_++; +this.apply (rr, null); +rr.charsMatched_--; +}, "com.stevesoft.pat.RegRes"); +Clazz.defineMethod (c$, "dorep", +function (s, start, end) { +var ret = s; +this.want_more_text = false; +this.$lastMatchedTo = 0; +if (this.rh.me == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.replace_null_regex_pointer")); +}if (this.rh.me._searchLike (s, start, end)) { +var rmn = this.rh.me.matchedTo (); +if (this.rh.me.charsMatched () == 0 && !this.isSpecial (this.rh.me.getReplaceRule ())) { +this.apply1 (this.rh.me); +rmn++; +}this.apply (this.rh.me); +if (!this.first) { +for (var i = rmn; !this.want_more_text && this.rh.me._searchLike (s, i, end); i = rmn) { +rmn = this.rh.me.matchedTo (); +if (this.rh.me.charsMatched () == 0) { +if (!this.isSpecial (this.rh.me.getReplaceRule ())) { +this.apply1 (this.rh.me); +}rmn++; +}this.apply (this.rh.me); +} +}ret = this.finish (); +ret = ret == null ? s : ret; +}return ret; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "apply", +function (r, rp) { +if (rp == null || (rp.next == null && Clazz.instanceOf (rp, com.stevesoft.pat.AmpersandRule))) { +return; +}if (r.didMatch ()) { +if (this.src == null) { +this.src = r.getStringLike (); +}if (this.sb == null) { +this.sb = new com.stevesoft.pat.StringBufferLike (this.src.newStringBufferLike ()); +}var rmf = r.matchedFrom (); +for (var ii = this.pos; ii < rmf; ii++) { +this.sb.appendC (this.src.charAt (ii)); +} +for (var x = rp; x != null; x = x.next) { +x.apply (this.sb, r); +if (Clazz.instanceOf (x, com.stevesoft.pat.SpecialRule)) { +if (Clazz.instanceOf (x, com.stevesoft.pat.WantMoreTextReplaceRule) && this.want_more_text_enable) { +this.want_more_text = true; +} else if (Clazz.instanceOf (x, com.stevesoft.pat.PushRule)) { +var rh2 = new com.stevesoft.pat.RegHolder (); +rh2.me = (x).NewRule; +rh2.prev = this.rh; +this.rh = rh2; +} else if (Clazz.instanceOf (x, com.stevesoft.pat.PopRule)) { +if (this.rh.prev != null) { +this.rh = this.rh.prev; +}} else if (Clazz.instanceOf (x, com.stevesoft.pat.ChangeRule)) { +this.rh.me = (x).NewRule; +}}} +if (!this.want_more_text) { +this.pos = r.matchedTo (); +}}}, "com.stevesoft.pat.RegRes,com.stevesoft.pat.ReplaceRule"); +Clazz.defineMethod (c$, "WantMoreText", +function () { +return this.want_more_text; +}); +Clazz.defineMethod (c$, "apply", +function (r) { +this.apply (r, r.getReplaceRule ()); +}, "com.stevesoft.pat.Regex"); +Clazz.defineMethod (c$, "finish", +function () { +if (this.src == null) { +return null; +}var s_end = this.src.length (); +for (var ii = this.pos; ii < s_end; ii++) { +this.sb.appendC (this.src.charAt (ii)); +} +this.src = null; +this.$lastMatchedTo = this.pos; +this.pos = 0; +var retstr = this.sb.toStringLike (); +this.sb = null; +return retstr; +}); +Clazz.overrideMethod (c$, "clone", +function () { +var r = new com.stevesoft.pat.Replacer (); +r.first = this.first; +r.src = this.src; +r.sb = this.sb; +r.pos = this.pos; +r.$lastMatchedTo = this.$lastMatchedTo; +r.want_more_text = this.want_more_text; +r.want_more_text_enable = this.want_more_text_enable; +r.rh.me = this.rh.me; +r.rh.prev = this.rh.prev; +return r; +}); +Clazz.defineMethod (c$, "lastMatchedTo", +function () { +return this.$lastMatchedTo; +}); +Clazz.defineMethod (c$, "getRegex", +function () { +return this.rh.me; +}); +Clazz.defineMethod (c$, "setSource", +function (sl) { +this.src = sl; +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "setBuffer", +function (sbl) { +this.sb = sbl; +}, "com.stevesoft.pat.StringBufferLike"); +Clazz.defineMethod (c$, "setPos", +function (pos) { +this.pos = pos; +}, "~N"); +}); diff --git a/bin/com/stevesoft/pat/RightRule.js b/bin/com/stevesoft/pat/RightRule.js index ab453dd..60fa08d 100644 --- a/bin/com/stevesoft/pat/RightRule.js +++ b/bin/com/stevesoft/pat/RightRule.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.RightRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "RightRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.RightRule, []); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -sb.append (res.right ()); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return "$'"; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.RightRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "RightRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.RightRule, []); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +sb.append (res.right ()); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return "$'"; +}); +}); diff --git a/bin/com/stevesoft/pat/Rthings.js b/bin/com/stevesoft/pat/Rthings.js index 66f9c83..c9c902e 100644 --- a/bin/com/stevesoft/pat/Rthings.js +++ b/bin/com/stevesoft/pat/Rthings.js @@ -1,35 +1,35 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Regex"], "com.stevesoft.pat.Rthings", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.val = 0; -this.ignoreCase = false; -this.dontMatchInQuotes = false; -this.optimizeMe = false; -this.noBackRefs = false; -this.parenLevel = 0; -this.gFlag = false; -this.mFlag = false; -this.sFlag = false; -this.p = null; -this.o = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Rthings"); -Clazz.prepareFields (c$, function () { -this.val = com.stevesoft.pat.Regex.BackRefOffset; -}); -Clazz.makeConstructor (c$, -function (r) { -this.ignoreCase = r.ignoreCase; -this.dontMatchInQuotes = r.dontMatchInQuotes; -}, "com.stevesoft.pat.Regex"); -Clazz.defineMethod (c$, "set", -function (r) { -r.gFlag = this.gFlag; -r.mFlag = this.mFlag; -r.sFlag = this.sFlag; -r.ignoreCase = this.ignoreCase; -r.dontMatchInQuotes = this.dontMatchInQuotes; -if (this.optimizeMe) { -r.optimize (); -}}, "com.stevesoft.pat.Regex"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Regex"], "com.stevesoft.pat.Rthings", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.val = 0; +this.ignoreCase = false; +this.dontMatchInQuotes = false; +this.optimizeMe = false; +this.noBackRefs = false; +this.parenLevel = 0; +this.gFlag = false; +this.mFlag = false; +this.sFlag = false; +this.p = null; +this.o = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Rthings"); +Clazz.prepareFields (c$, function () { +this.val = com.stevesoft.pat.Regex.BackRefOffset; +}); +Clazz.makeConstructor (c$, +function (r) { +this.ignoreCase = r.ignoreCase; +this.dontMatchInQuotes = r.dontMatchInQuotes; +}, "com.stevesoft.pat.Regex"); +Clazz.defineMethod (c$, "set", +function (r) { +r.gFlag = this.gFlag; +r.mFlag = this.mFlag; +r.sFlag = this.sFlag; +r.ignoreCase = this.ignoreCase; +r.dontMatchInQuotes = this.dontMatchInQuotes; +if (this.optimizeMe) { +r.optimize (); +}}, "com.stevesoft.pat.Regex"); +}); diff --git a/bin/com/stevesoft/pat/RuleHolder.js b/bin/com/stevesoft/pat/RuleHolder.js index 6924899..a628201 100644 --- a/bin/com/stevesoft/pat/RuleHolder.js +++ b/bin/com/stevesoft/pat/RuleHolder.js @@ -1,32 +1,32 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.RuleHolder", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.held = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "RuleHolder", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.RuleHolder, []); -}); -Clazz.makeConstructor (c$, -function (h) { -Clazz.superConstructor (this, com.stevesoft.pat.RuleHolder, []); -this.held = h; -}, "com.stevesoft.pat.ReplaceRule"); -Clazz.overrideMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.RuleHolder (this.held); -}); -Clazz.defineMethod (c$, "toString1", -function () { -return this.held.toString1 (); -}); -Clazz.defineMethod (c$, "apply", -function (sb, rr) { -this.held.apply (sb, rr); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.defineMethod (c$, "arg", -function (s) { -return new com.stevesoft.pat.RuleHolder (this.held.arg (s)); -}, "~S"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.RuleHolder", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.held = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "RuleHolder", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.RuleHolder, []); +}); +Clazz.makeConstructor (c$, +function (h) { +Clazz.superConstructor (this, com.stevesoft.pat.RuleHolder, []); +this.held = h; +}, "com.stevesoft.pat.ReplaceRule"); +Clazz.overrideMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.RuleHolder (this.held); +}); +Clazz.defineMethod (c$, "toString1", +function () { +return this.held.toString1 (); +}); +Clazz.defineMethod (c$, "apply", +function (sb, rr) { +this.held.apply (sb, rr); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.defineMethod (c$, "arg", +function (s) { +return new com.stevesoft.pat.RuleHolder (this.held.arg (s)); +}, "~S"); +}); diff --git a/bin/com/stevesoft/pat/Skip.js b/bin/com/stevesoft/pat/Skip.js index 6dd2756..bdf02e4 100644 --- a/bin/com/stevesoft/pat/Skip.js +++ b/bin/com/stevesoft/pat/Skip.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.Skip", ["com.stevesoft.pat.CaseMgr", "$.Or", "$.Skipped", "$.oneChar", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.src = null; -this.c = 0; -this.mask = 0; -this.$offset = 0; -this.ign = false; -this.m1 = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Skip"); -c$.mkmask = Clazz.defineMethod (c$, "mkmask", -function (c) { -var x = String.fromCharCode (c); -return ~((com.stevesoft.pat.CaseMgr.toUpperCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toLowerCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toTitleCaseC (x)).charCodeAt (0)); -}, "~N"); -c$.string = Clazz.defineMethod (c$, "string", -function (r) { -return r.skipper == null ? null : r.skipper.src; -}, "com.stevesoft.pat.Regex"); -c$.offset = Clazz.defineMethod (c$, "offset", -function (r) { -return r.skipper == null ? -1 : r.skipper.$offset; -}, "com.stevesoft.pat.Regex"); -Clazz.makeConstructor (c$, -function (s, ign, o) { -this.src = s; -this.c = s.charCodeAt (0); -if (ign) { -this.mask = com.stevesoft.pat.Skip.mkmask (this.c); -} else { -this.mask = 0; -}this.$offset = o; -this.ign = ign; -this.m1 = (s.length == 1); -}, "~S,~B,~N"); -Clazz.defineMethod (c$, "find", -function (s) { -return this.find (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -c$.min = Clazz.defineMethod (c$, "min", -function (a, b) { -return a < b ? a : b; -}, "~N,~N"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -if (start > end) { -return -1; -}start += this.$offset; -var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.$offset); -if (this.mask != this.c) { -for (var i = start; i <= vend; i++) { -if (0 == (s.charCodeAt (i) & this.mask)) { -if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { -return i - this.$offset; -}}} -} else { -for (var i = start; i <= vend; i++) { -if (this.c == s.charCodeAt (i)) { -if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { -return i - this.$offset; -}}} -}return -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -c$.findSkipRegex = Clazz.defineMethod (c$, "findSkipRegex", -function (r) { -return com.stevesoft.pat.Skip.findSkip (r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); -}, "com.stevesoft.pat.Regex"); -c$.findSkip = Clazz.defineMethod (c$, "findSkip", -function (p, ignoreCase, trnc) { -var sb = new StringBuffer (); -var subsk = null; -var offset = 0; -var skipc = -1; -var skipoff = 0; -for (; p != null; p = p.next) { -if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { -skipc = ((p).c).charCodeAt (0); -skipoff = offset; -}if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { -var psav = p; -sb.append ((p).c); -while (Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { -sb.append ((p.next).c); -p = p.next; -} -var st = sb.toString (); -var sk = null; -if (st.length > 2) { -sk = new com.stevesoft.pat.SkipBMH (st, ignoreCase, offset); -} else { -sk = new com.stevesoft.pat.Skip2 (st, ignoreCase, offset); -}if (trnc && st.length > 2) { -psav.next = new com.stevesoft.pat.Skipped (st.substring (1)); -psav.next.next = p.next; -psav.next.parent = p.parent; -}return sk; -} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or) && (p).v.size () == 1 && !(p).leftForm ().equals ("(?!") && null != (subsk = com.stevesoft.pat.Skip.findSkip ((p).v.elementAt (0), ignoreCase, trnc))) { -subsk.$offset += offset; -return subsk; -} else if (p.minChars ().equals (p.maxChars ())) { -offset += p.minChars ().intValue (); -} else { -return skipc < 0 ? null : new com.stevesoft.pat.Skip ("" + String.fromCharCode (skipc), ignoreCase, skipoff); -}} -return null; -}, "com.stevesoft.pat.Pattern,~B,~B"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.Skip", ["com.stevesoft.pat.CaseMgr", "$.Or", "$.Skipped", "$.oneChar", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.src = null; +this.c = 0; +this.mask = 0; +this.$offset = 0; +this.ign = false; +this.m1 = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Skip"); +c$.mkmask = Clazz.defineMethod (c$, "mkmask", +function (c) { +var x = String.fromCharCode (c); +return ~((com.stevesoft.pat.CaseMgr.toUpperCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toLowerCaseC (x)).charCodeAt (0) | (com.stevesoft.pat.CaseMgr.toTitleCaseC (x)).charCodeAt (0)); +}, "~N"); +c$.string = Clazz.defineMethod (c$, "string", +function (r) { +return r.skipper == null ? null : r.skipper.src; +}, "com.stevesoft.pat.Regex"); +c$.offset = Clazz.defineMethod (c$, "offset", +function (r) { +return r.skipper == null ? -1 : r.skipper.$offset; +}, "com.stevesoft.pat.Regex"); +Clazz.makeConstructor (c$, +function (s, ign, o) { +this.src = s; +this.c = s.charCodeAt (0); +if (ign) { +this.mask = com.stevesoft.pat.Skip.mkmask (this.c); +} else { +this.mask = 0; +}this.$offset = o; +this.ign = ign; +this.m1 = (s.length == 1); +}, "~S,~B,~N"); +Clazz.defineMethod (c$, "find", +function (s) { +return this.find (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +c$.min = Clazz.defineMethod (c$, "min", +function (a, b) { +return a < b ? a : b; +}, "~N,~N"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +if (start > end) { +return -1; +}start += this.$offset; +var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.$offset); +if (this.mask != this.c) { +for (var i = start; i <= vend; i++) { +if (0 == (s.charCodeAt (i) & this.mask)) { +if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { +return i - this.$offset; +}}} +} else { +for (var i = start; i <= vend; i++) { +if (this.c == s.charCodeAt (i)) { +if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { +return i - this.$offset; +}}} +}return -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +c$.findSkipRegex = Clazz.defineMethod (c$, "findSkipRegex", +function (r) { +return com.stevesoft.pat.Skip.findSkip (r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); +}, "com.stevesoft.pat.Regex"); +c$.findSkip = Clazz.defineMethod (c$, "findSkip", +function (p, ignoreCase, trnc) { +var sb = new StringBuffer (); +var subsk = null; +var offset = 0; +var skipc = -1; +var skipoff = 0; +for (; p != null; p = p.next) { +if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) { +skipc = ((p).c).charCodeAt (0); +skipoff = offset; +}if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar) && Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { +var psav = p; +sb.append ((p).c); +while (Clazz.instanceOf (p.next, com.stevesoft.pat.oneChar)) { +sb.append ((p.next).c); +p = p.next; +} +var st = sb.toString (); +var sk = null; +if (st.length > 2) { +sk = new com.stevesoft.pat.SkipBMH (st, ignoreCase, offset); +} else { +sk = new com.stevesoft.pat.Skip2 (st, ignoreCase, offset); +}if (trnc && st.length > 2) { +psav.next = new com.stevesoft.pat.Skipped (st.substring (1)); +psav.next.next = p.next; +psav.next.parent = p.parent; +}return sk; +} else if (Clazz.instanceOf (p, com.stevesoft.pat.Or) && (p).v.size () == 1 && !(p).leftForm ().equals ("(?!") && null != (subsk = com.stevesoft.pat.Skip.findSkip ((p).v.elementAt (0), ignoreCase, trnc))) { +subsk.$offset += offset; +return subsk; +} else if (p.minChars ().equals (p.maxChars ())) { +offset += p.minChars ().intValue (); +} else { +return skipc < 0 ? null : new com.stevesoft.pat.Skip ("" + String.fromCharCode (skipc), ignoreCase, skipoff); +}} +return null; +}, "com.stevesoft.pat.Pattern,~B,~B"); +}); diff --git a/bin/com/stevesoft/pat/Skip2.js b/bin/com/stevesoft/pat/Skip2.js index e69b45e..c06b56e 100644 --- a/bin/com/stevesoft/pat/Skip2.js +++ b/bin/com/stevesoft/pat/Skip2.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.Skip2", ["com.stevesoft.pat.CaseMgr"], function () { -c$ = Clazz.decorateAsClass (function () { -this.c1 = 0; -this.mask1 = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Skip2", com.stevesoft.pat.Skip); -Clazz.makeConstructor (c$, -function (s, ign, offset) { -Clazz.superConstructor (this, com.stevesoft.pat.Skip2, [s, ign, offset]); -this.c1 = s.charCodeAt (1); -this.m1 = 2 == s.length; -if (ign) { -this.mask1 = com.stevesoft.pat.Skip.mkmask (this.c1); -} else { -this.mask1 = 0; -}}, "~S,~B,~N"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -if (start > end) { -return -1; -}start += this.$offset; -var vend = com.stevesoft.pat.Skip.min (s.length () - 2, end + this.$offset); -for (var i = start; i <= vend; i++) { -if (0 == (s.charCodeAt (i) & this.mask) && 0 == (s.charCodeAt (i + 1) & this.mask1)) { -if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { -return i - this.$offset; -}}} -return -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.Skip2", ["com.stevesoft.pat.CaseMgr"], function () { +c$ = Clazz.decorateAsClass (function () { +this.c1 = 0; +this.mask1 = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Skip2", com.stevesoft.pat.Skip); +Clazz.makeConstructor (c$, +function (s, ign, offset) { +Clazz.superConstructor (this, com.stevesoft.pat.Skip2, [s, ign, offset]); +this.c1 = s.charCodeAt (1); +this.m1 = 2 == s.length; +if (ign) { +this.mask1 = com.stevesoft.pat.Skip.mkmask (this.c1); +} else { +this.mask1 = 0; +}}, "~S,~B,~N"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +if (start > end) { +return -1; +}start += this.$offset; +var vend = com.stevesoft.pat.Skip.min (s.length () - 2, end + this.$offset); +for (var i = start; i <= vend; i++) { +if (0 == (s.charCodeAt (i) & this.mask) && 0 == (s.charCodeAt (i + 1) & this.mask1)) { +if (this.m1 || com.stevesoft.pat.CaseMgr.regionMatchesLike2 (s, this.ign, i, this.src, 0, this.src.length)) { +return i - this.$offset; +}}} +return -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +}); diff --git a/bin/com/stevesoft/pat/SkipBMH.js b/bin/com/stevesoft/pat/SkipBMH.js index ac81e43..9ea4116 100644 --- a/bin/com/stevesoft/pat/SkipBMH.js +++ b/bin/com/stevesoft/pat/SkipBMH.js @@ -1,154 +1,154 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.SkipBMH", ["com.stevesoft.pat.CaseMgr", "com.stevesoft.pat.wrap.StringWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.MAX_CHAR = 64; -this.skip = null; -this.sm1 = 0; -this.jump_ahead = 0; -this.uc = '\0'; -this.lc = '\0'; -this.tc = '\0'; -this.x = '\0'; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "SkipBMH", com.stevesoft.pat.Skip); -Clazz.prepareFields (c$, function () { -this.skip = Clazz.newCharArray (64, '\0'); -}); -Clazz.defineMethod (c$, "exact", -function (c) { -return (this.ign && this.anyc (c)) || c == this.x; -}, "~S"); -Clazz.defineMethod (c$, "anyc", -function (c) { -return c == this.uc || c == this.lc || c == this.tc; -}, "~S"); -Clazz.makeConstructor (c$, -function (pt, ign) { -this.construct (pt, ign, 0); -}, "~S,~B"); -Clazz.makeConstructor (c$, -function (pt) { -this.construct (pt, false, 0); -}, "~S"); -Clazz.makeConstructor (c$, -function (pt, ign, offset) { -Clazz.superConstructor (this, com.stevesoft.pat.SkipBMH, [pt, ign, offset]); -for (var k = 0; k < 64; k++) { -this.skip[k] = String.fromCharCode (this.src.length); -} -this.sm1 = this.src.length - 1; -this.x = this.src.charAt (this.sm1); -this.uc = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.x); -this.lc = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.x); -this.tc = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.x); -for (var k = 0; k < this.src.length - 1; k++) { -var x_ = this.src.charAt (k); -if (ign) { -var uc_ = com.stevesoft.pat.CaseMgr.toUpperCaseC (x_); -var lc_ = com.stevesoft.pat.CaseMgr.toLowerCaseC (x_); -var tc_ = com.stevesoft.pat.CaseMgr.toTitleCaseC (x_); -this.skip[uc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -this.skip[lc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -this.skip[tc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -} else { -this.skip[x_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); -}} -this.jump_ahead = this.src.length - 1; -for (var k = 0; k < this.src.length - 1; k++) { -var y = this.src.charAt (this.sm1 - k - 1); -if (this.exact (y)) { -this.jump_ahead = k; -break; -}} -}, "~S,~B,~N"); -Clazz.defineMethod (c$, "searchRegion", -function (s, start, end) { -return this.find (s, start, end); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "searchFrom", -function (s, start) { -return this.find (s, start, s.length); -}, "~S,~N"); -Clazz.defineMethod (c$, "search", -function (s) { -return this.find (s, 0, s.length); -}, "~S"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -start += this.$offset + this.sm1; -var vend = com.stevesoft.pat.Skip.min (s.length - 1, end + this.sm1 + this.$offset); -var k; -var vend1 = vend - this.jump_ahead; -if (this.ign) { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -} else { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -}return -1; -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "find", -function (s, start, end) { -if (Clazz.instanceOf (s, com.stevesoft.pat.wrap.StringWrap)) { -return this.find (s.toString (), start, end); -}start += this.$offset + this.sm1; -var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.sm1 + this.$offset); -var k; -var vend1 = vend - this.jump_ahead; -if (this.ign) { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.anyc (s.charAt (k))) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -} else { -for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -}} -for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { -if (this.x == s.charAt (k)) { -if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { -return k - this.sm1 - this.$offset; -}k += this.jump_ahead; -if (k > vend) { -return -1; -}}} -}return -1; -}, "com.stevesoft.pat.StringLike,~N,~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Skip"], "com.stevesoft.pat.SkipBMH", ["com.stevesoft.pat.CaseMgr", "com.stevesoft.pat.wrap.StringWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.MAX_CHAR = 64; +this.skip = null; +this.sm1 = 0; +this.jump_ahead = 0; +this.uc = '\0'; +this.lc = '\0'; +this.tc = '\0'; +this.x = '\0'; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "SkipBMH", com.stevesoft.pat.Skip); +Clazz.prepareFields (c$, function () { +this.skip = Clazz.newCharArray (64, '\0'); +}); +Clazz.defineMethod (c$, "exact", +function (c) { +return (this.ign && this.anyc (c)) || c == this.x; +}, "~S"); +Clazz.defineMethod (c$, "anyc", +function (c) { +return c == this.uc || c == this.lc || c == this.tc; +}, "~S"); +Clazz.makeConstructor (c$, +function (pt, ign) { +this.construct (pt, ign, 0); +}, "~S,~B"); +Clazz.makeConstructor (c$, +function (pt) { +this.construct (pt, false, 0); +}, "~S"); +Clazz.makeConstructor (c$, +function (pt, ign, offset) { +Clazz.superConstructor (this, com.stevesoft.pat.SkipBMH, [pt, ign, offset]); +for (var k = 0; k < 64; k++) { +this.skip[k] = String.fromCharCode (this.src.length); +} +this.sm1 = this.src.length - 1; +this.x = this.src.charAt (this.sm1); +this.uc = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.x); +this.lc = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.x); +this.tc = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.x); +for (var k = 0; k < this.src.length - 1; k++) { +var x_ = this.src.charAt (k); +if (ign) { +var uc_ = com.stevesoft.pat.CaseMgr.toUpperCaseC (x_); +var lc_ = com.stevesoft.pat.CaseMgr.toLowerCaseC (x_); +var tc_ = com.stevesoft.pat.CaseMgr.toTitleCaseC (x_); +this.skip[uc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +this.skip[lc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +this.skip[tc_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +} else { +this.skip[x_.charCodeAt (0) & (63)] = String.fromCharCode (this.src.length - k - 1); +}} +this.jump_ahead = this.src.length - 1; +for (var k = 0; k < this.src.length - 1; k++) { +var y = this.src.charAt (this.sm1 - k - 1); +if (this.exact (y)) { +this.jump_ahead = k; +break; +}} +}, "~S,~B,~N"); +Clazz.defineMethod (c$, "searchRegion", +function (s, start, end) { +return this.find (s, start, end); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "searchFrom", +function (s, start) { +return this.find (s, start, s.length); +}, "~S,~N"); +Clazz.defineMethod (c$, "search", +function (s) { +return this.find (s, 0, s.length); +}, "~S"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +start += this.$offset + this.sm1; +var vend = com.stevesoft.pat.Skip.min (s.length - 1, end + this.sm1 + this.$offset); +var k; +var vend1 = vend - this.jump_ahead; +if (this.ign) { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +} else { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches2 (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +}return -1; +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "find", +function (s, start, end) { +if (Clazz.instanceOf (s, com.stevesoft.pat.wrap.StringWrap)) { +return this.find (s.toString (), start, end); +}start += this.$offset + this.sm1; +var vend = com.stevesoft.pat.Skip.min (s.length () - 1, end + this.sm1 + this.$offset); +var k; +var vend1 = vend - this.jump_ahead; +if (this.ign) { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.anyc (s.charAt (k))) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, this.ign, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +} else { +for (k = start; k <= vend1; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +}} +for (; k <= vend; k += (this.skip[s.charCodeAt (k) & (63)]).charCodeAt (0)) { +if (this.x == s.charAt (k)) { +if (com.stevesoft.pat.CaseMgr.regionMatches (this.src, false, 0, s, k - this.sm1, this.sm1)) { +return k - this.sm1 - this.$offset; +}k += this.jump_ahead; +if (k > vend) { +return -1; +}}} +}return -1; +}, "com.stevesoft.pat.StringLike,~N,~N"); +}); diff --git a/bin/com/stevesoft/pat/Skipped.js b/bin/com/stevesoft/pat/Skipped.js index 8f6f1d3..07c5ca9 100644 --- a/bin/com/stevesoft/pat/Skipped.js +++ b/bin/com/stevesoft/pat/Skipped.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Skipped", ["com.stevesoft.pat.CaseMgr", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.s = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Skipped", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (s) { -Clazz.superConstructor (this, com.stevesoft.pat.Skipped, []); -this.s = s; -}, "~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.s + this.nextString (); -}); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (pt.no_check || com.stevesoft.pat.CaseMgr.regionMatches (this.s, pt.ignoreCase, 0, pt.src, pos, this.s.length)) { -return this.nextMatch (pos + this.s.length, pt); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (this.s.length); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (this.s.length); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.Skipped (this.s); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Skipped", ["com.stevesoft.pat.CaseMgr", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.s = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Skipped", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (s) { +Clazz.superConstructor (this, com.stevesoft.pat.Skipped, []); +this.s = s; +}, "~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.s + this.nextString (); +}); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (pt.no_check || com.stevesoft.pat.CaseMgr.regionMatches (this.s, pt.ignoreCase, 0, pt.src, pos, this.s.length)) { +return this.nextMatch (pos + this.s.length, pt); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (this.s.length); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (this.s.length); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.Skipped (this.s); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/SpecialRule.js b/bin/com/stevesoft/pat/SpecialRule.js index aed49a6..13dfbe5 100644 --- a/bin/com/stevesoft/pat/SpecialRule.js +++ b/bin/com/stevesoft/pat/SpecialRule.js @@ -1,11 +1,11 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.SpecialRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "SpecialRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.SpecialRule, []); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, rr) { -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.SpecialRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "SpecialRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.SpecialRule, []); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, rr) { +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +}); diff --git a/bin/com/stevesoft/pat/Start.js b/bin/com/stevesoft/pat/Start.js index 1ef02d7..56168b1 100644 --- a/bin/com/stevesoft/pat/Start.js +++ b/bin/com/stevesoft/pat/Start.js @@ -1,35 +1,35 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Start", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.retIsStart = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Start", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (b) { -Clazz.superConstructor (this, com.stevesoft.pat.Start, []); -this.retIsStart = b; -}, "~B"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -if (this.retIsStart && pt.mFlag && pos > 0 && pt.src.charAt (pos - 1) == '\n') { -return this.nextMatch (pos, pt); -}if (pos == 0) { -return this.nextMatch (pos, pt); -}return -1; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -if (this.retIsStart) { -return "^" + this.nextString (); -} else { -return "\\A" + this.nextString (); -}}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.Start (this.retIsStart); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.Start", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.retIsStart = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Start", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (b) { +Clazz.superConstructor (this, com.stevesoft.pat.Start, []); +this.retIsStart = b; +}, "~B"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +if (this.retIsStart && pt.mFlag && pos > 0 && pt.src.charAt (pos - 1) == '\n') { +return this.nextMatch (pos, pt); +}if (pos == 0) { +return this.nextMatch (pos, pt); +}return -1; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +if (this.retIsStart) { +return "^" + this.nextString (); +} else { +return "\\A" + this.nextString (); +}}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.Start (this.retIsStart); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/StrPos.js b/bin/com/stevesoft/pat/StrPos.js index 366f46b..fb1baf4 100644 --- a/bin/com/stevesoft/pat/StrPos.js +++ b/bin/com/stevesoft/pat/StrPos.js @@ -1,109 +1,109 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.StrPos", ["com.stevesoft.pat.patInf", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.s = null; -this.$pos = 0; -this.esc = '\\'; -this.c = '\0'; -this.dontMatch = false; -this.$eos = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "StrPos"); -Clazz.defineMethod (c$, "pos", -function () { -return this.$pos; -}); -Clazz.defineMethod (c$, "thisChar", -function () { -return this.c; -}); -Clazz.defineMethod (c$, "eos", -function () { -return this.$eos; -}); -Clazz.makeConstructor (c$, -function (sp) { -this.dup (sp); -}, "com.stevesoft.pat.StrPos"); -Clazz.defineMethod (c$, "dup", -function (sp) { -this.s = sp.s; -this.$pos = sp.$pos; -this.c = sp.c; -this.dontMatch = sp.dontMatch; -this.$eos = sp.$eos; -}, "com.stevesoft.pat.StrPos"); -Clazz.makeConstructor (c$, -function (s, pos) { -this.s = s; -this.$pos = pos - 1; -this.inc (); -}, "~S,~N"); -Clazz.defineMethod (c$, "inc", -function () { -this.$pos++; -if (this.$pos >= this.s.length) { -this.$eos = true; -return this; -}this.$eos = false; -this.c = this.s.charAt (this.$pos); -if (this.c == this.esc && this.$pos + 1 < this.s.length) { -this.$pos++; -this.c = this.s.charAt (this.$pos); -if (this.c != this.esc) { -this.dontMatch = true; -} else { -this.dontMatch = false; -}} else { -this.dontMatch = false; -}return this; -}); -Clazz.defineMethod (c$, "match", -function (ch) { -if (this.dontMatch || this.$eos) { -return false; -}return this.c == ch; -}, "~S"); -Clazz.defineMethod (c$, "escMatch", -function (ch) { -if (!this.dontMatch || this.$eos) { -return false; -}return this.c == ch; -}, "~S"); -Clazz.defineMethod (c$, "escaped", -function () { -return this.dontMatch; -}); -Clazz.defineMethod (c$, "incMatch", -function (st) { -var sp = new com.stevesoft.pat.StrPos (this); -var i; -for (i = 0; i < st.length; i++) { -if (!sp.match (st.charAt (i))) { -return false; -}sp.inc (); -} -this.dup (sp); -return true; -}, "~S"); -Clazz.defineMethod (c$, "getPatInt", -function () { -if (this.incMatch ("inf")) { -return new com.stevesoft.pat.patInf (); -}var i; -var cnt = 0; -var sp = new com.stevesoft.pat.StrPos (this); -for (i = 0; !sp.$eos && sp.c >= '0' && sp.c <= '9'; i++) { -cnt = 10 * cnt + sp.c.charCodeAt (0) - 48; -sp.inc (); -} -if (i == 0) { -return null; -}this.dup (sp); -return new com.stevesoft.pat.patInt (cnt); -}); -Clazz.defineMethod (c$, "getString", -function () { -return this.s; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.StrPos", ["com.stevesoft.pat.patInf", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.s = null; +this.$pos = 0; +this.esc = '\\'; +this.c = '\0'; +this.dontMatch = false; +this.$eos = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "StrPos"); +Clazz.defineMethod (c$, "pos", +function () { +return this.$pos; +}); +Clazz.defineMethod (c$, "thisChar", +function () { +return this.c; +}); +Clazz.defineMethod (c$, "eos", +function () { +return this.$eos; +}); +Clazz.makeConstructor (c$, +function (sp) { +this.dup (sp); +}, "com.stevesoft.pat.StrPos"); +Clazz.defineMethod (c$, "dup", +function (sp) { +this.s = sp.s; +this.$pos = sp.$pos; +this.c = sp.c; +this.dontMatch = sp.dontMatch; +this.$eos = sp.$eos; +}, "com.stevesoft.pat.StrPos"); +Clazz.makeConstructor (c$, +function (s, pos) { +this.s = s; +this.$pos = pos - 1; +this.inc (); +}, "~S,~N"); +Clazz.defineMethod (c$, "inc", +function () { +this.$pos++; +if (this.$pos >= this.s.length) { +this.$eos = true; +return this; +}this.$eos = false; +this.c = this.s.charAt (this.$pos); +if (this.c == this.esc && this.$pos + 1 < this.s.length) { +this.$pos++; +this.c = this.s.charAt (this.$pos); +if (this.c != this.esc) { +this.dontMatch = true; +} else { +this.dontMatch = false; +}} else { +this.dontMatch = false; +}return this; +}); +Clazz.defineMethod (c$, "match", +function (ch) { +if (this.dontMatch || this.$eos) { +return false; +}return this.c == ch; +}, "~S"); +Clazz.defineMethod (c$, "escMatch", +function (ch) { +if (!this.dontMatch || this.$eos) { +return false; +}return this.c == ch; +}, "~S"); +Clazz.defineMethod (c$, "escaped", +function () { +return this.dontMatch; +}); +Clazz.defineMethod (c$, "incMatch", +function (st) { +var sp = new com.stevesoft.pat.StrPos (this); +var i; +for (i = 0; i < st.length; i++) { +if (!sp.match (st.charAt (i))) { +return false; +}sp.inc (); +} +this.dup (sp); +return true; +}, "~S"); +Clazz.defineMethod (c$, "getPatInt", +function () { +if (this.incMatch ("inf")) { +return new com.stevesoft.pat.patInf (); +}var i; +var cnt = 0; +var sp = new com.stevesoft.pat.StrPos (this); +for (i = 0; !sp.$eos && sp.c >= '0' && sp.c <= '9'; i++) { +cnt = 10 * cnt + sp.c.charCodeAt (0) - 48; +sp.inc (); +} +if (i == 0) { +return null; +}this.dup (sp); +return new com.stevesoft.pat.patInt (cnt); +}); +Clazz.defineMethod (c$, "getString", +function () { +return this.s; +}); +}); diff --git a/bin/com/stevesoft/pat/StringBufferLike.js b/bin/com/stevesoft/pat/StringBufferLike.js index fd5b6c3..2455329 100644 --- a/bin/com/stevesoft/pat/StringBufferLike.js +++ b/bin/com/stevesoft/pat/StringBufferLike.js @@ -1,62 +1,62 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.BasicStringBufferLike"], "com.stevesoft.pat.StringBufferLike", ["com.stevesoft.pat.CaseMgr"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sbl = null; -this.mode = 'E'; -this.altMode = ' '; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "StringBufferLike", null, com.stevesoft.pat.BasicStringBufferLike); -Clazz.makeConstructor (c$, -function (sbl) { -this.sbl = sbl; -}, "com.stevesoft.pat.BasicStringBufferLike"); -Clazz.defineMethod (c$, "toStringLike", -function () { -return this.sbl.toStringLike (); -}); -Clazz.defineMethod (c$, "toString", -function () { -return this.sbl.toString (); -}); -Clazz.defineMethod (c$, "appendC", -function (c) { -switch (this.mode) { -case 'u': -this.mode = this.altMode; -this.altMode = ' '; -case 'U': -this.sbl.appendC (com.stevesoft.pat.CaseMgr.toUpperCaseC (c)); -break; -case 'l': -this.mode = this.altMode; -this.altMode = ' '; -case 'L': -this.sbl.appendC (com.stevesoft.pat.CaseMgr.toLowerCaseC (c)); -break; -case 'Q': -if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) { -;} else { -this.sbl.appendC ('\\'); -}default: -this.sbl.appendC (c); -break; -} -}, "~S"); -Clazz.overrideMethod (c$, "append", -function (s) { -for (var i = 0; i < s.length; i++) { -this.appendC (s.charAt (i)); -} -}, "~S"); -Clazz.defineMethod (c$, "setMode", -function (c) { -if (c == 'u' || c == 'l') { -if (this.altMode == ' ') { -this.altMode = this.mode; -}}this.mode = c; -}, "~S"); -Clazz.defineMethod (c$, "unwrap", -function () { -return this.sbl.unwrap (); -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.BasicStringBufferLike"], "com.stevesoft.pat.StringBufferLike", ["com.stevesoft.pat.CaseMgr"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sbl = null; +this.mode = 'E'; +this.altMode = ' '; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "StringBufferLike", null, com.stevesoft.pat.BasicStringBufferLike); +Clazz.makeConstructor (c$, +function (sbl) { +this.sbl = sbl; +}, "com.stevesoft.pat.BasicStringBufferLike"); +Clazz.defineMethod (c$, "toStringLike", +function () { +return this.sbl.toStringLike (); +}); +Clazz.defineMethod (c$, "toString", +function () { +return this.sbl.toString (); +}); +Clazz.defineMethod (c$, "appendC", +function (c) { +switch (this.mode) { +case 'u': +this.mode = this.altMode; +this.altMode = ' '; +case 'U': +this.sbl.appendC (com.stevesoft.pat.CaseMgr.toUpperCaseC (c)); +break; +case 'l': +this.mode = this.altMode; +this.altMode = ' '; +case 'L': +this.sbl.appendC (com.stevesoft.pat.CaseMgr.toLowerCaseC (c)); +break; +case 'Q': +if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) { +;} else { +this.sbl.appendC ('\\'); +}default: +this.sbl.appendC (c); +break; +} +}, "~S"); +Clazz.overrideMethod (c$, "append", +function (s) { +for (var i = 0; i < s.length; i++) { +this.appendC (s.charAt (i)); +} +}, "~S"); +Clazz.defineMethod (c$, "setMode", +function (c) { +if (c == 'u' || c == 'l') { +if (this.altMode == ' ') { +this.altMode = this.mode; +}}this.mode = c; +}, "~S"); +Clazz.defineMethod (c$, "unwrap", +function () { +return this.sbl.unwrap (); +}); +}); diff --git a/bin/com/stevesoft/pat/StringLike.js b/bin/com/stevesoft/pat/StringLike.js index 12b2dc9..c677532 100644 --- a/bin/com/stevesoft/pat/StringLike.js +++ b/bin/com/stevesoft/pat/StringLike.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.declareInterface (com.stevesoft.pat, "StringLike"); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.declareInterface (com.stevesoft.pat, "StringLike"); diff --git a/bin/com/stevesoft/pat/StringRule.js b/bin/com/stevesoft/pat/StringRule.js index 1c04a68..aea8a98 100644 --- a/bin/com/stevesoft/pat/StringRule.js +++ b/bin/com/stevesoft/pat/StringRule.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.StringRule", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.s = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "StringRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function (s) { -Clazz.superConstructor (this, com.stevesoft.pat.StringRule, []); -this.s = s; -}, "~S"); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -sb.append (this.s); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return this.s; -}); -Clazz.overrideMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.StringRule (this.s); -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule"], "com.stevesoft.pat.StringRule", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.s = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "StringRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function (s) { +Clazz.superConstructor (this, com.stevesoft.pat.StringRule, []); +this.s = s; +}, "~S"); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +sb.append (this.s); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return this.s; +}); +Clazz.overrideMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.StringRule (this.s); +}); +}); diff --git a/bin/com/stevesoft/pat/SubMark.js b/bin/com/stevesoft/pat/SubMark.js index 9e1b5b8..0ea6b3a 100644 --- a/bin/com/stevesoft/pat/SubMark.js +++ b/bin/com/stevesoft/pat/SubMark.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.SubMark", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.end_pos = 0; -this.start_pos = 0; -this.om = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "SubMark", com.stevesoft.pat.Pattern); -Clazz.overrideMethod (c$, "toString", -function () { -return ""; -}); -Clazz.overrideMethod (c$, "matchInternal", -function (i, pt) { -pt.marks[this.om.id + pt.nMarks] = i; -var ret = this.nextMatch (i, pt); -if (ret < 0) { -pt.marks[this.om.id + pt.nMarks] = -1; -}return ret; -}, "~N,com.stevesoft.pat.Pthings"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.SubMark", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.end_pos = 0; +this.start_pos = 0; +this.om = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "SubMark", com.stevesoft.pat.Pattern); +Clazz.overrideMethod (c$, "toString", +function () { +return ""; +}); +Clazz.overrideMethod (c$, "matchInternal", +function (i, pt) { +pt.marks[this.om.id + pt.nMarks] = i; +var ret = this.nextMatch (i, pt); +if (ret < 0) { +pt.marks[this.om.id + pt.nMarks] = -1; +}return ret; +}, "~N,com.stevesoft.pat.Pthings"); +}); diff --git a/bin/com/stevesoft/pat/TransPat.js b/bin/com/stevesoft/pat/TransPat.js index 65f32a1..ec296f1 100644 --- a/bin/com/stevesoft/pat/TransPat.js +++ b/bin/com/stevesoft/pat/TransPat.js @@ -1,35 +1,35 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.TransPat", ["com.stevesoft.pat.Regex"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ra = null; -this.ra_len = 0; -this.pn = -1; -this.lastMatchedTo = -1; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "TransPat", com.stevesoft.pat.Pattern); -Clazz.prepareFields (c$, function () { -this.ra = new Array (10); -}); -Clazz.overrideMethod (c$, "toString", -function () { -return "(?#TransPat)"; -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.TransPat, []); -}); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -for (var i = 0; i < this.ra_len; i++) { -pt.ignoreCase = this.ra[i].ignoreCase; -pt.mFlag = this.ra[i].mFlag; -pt.dotDoesntMatchCR = com.stevesoft.pat.Regex.dotDoesntMatchCR; -var r = this.ra[i].thePattern.matchInternal (pos, pt); -if (r >= 0) { -this.pn = i; -return r; -}} -this.pn = -1; -return -1; -}, "~N,com.stevesoft.pat.Pthings"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.TransPat", ["com.stevesoft.pat.Regex"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ra = null; +this.ra_len = 0; +this.pn = -1; +this.lastMatchedTo = -1; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "TransPat", com.stevesoft.pat.Pattern); +Clazz.prepareFields (c$, function () { +this.ra = new Array (10); +}); +Clazz.overrideMethod (c$, "toString", +function () { +return "(?#TransPat)"; +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.TransPat, []); +}); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +for (var i = 0; i < this.ra_len; i++) { +pt.ignoreCase = this.ra[i].ignoreCase; +pt.mFlag = this.ra[i].mFlag; +pt.dotDoesntMatchCR = com.stevesoft.pat.Regex.dotDoesntMatchCR; +var r = this.ra[i].thePattern.matchInternal (pos, pt); +if (r >= 0) { +this.pn = i; +return r; +}} +this.pn = -1; +return -1; +}, "~N,com.stevesoft.pat.Pthings"); +}); diff --git a/bin/com/stevesoft/pat/Transformer.js b/bin/com/stevesoft/pat/Transformer.js index 25ef39f..3d169f9 100644 --- a/bin/com/stevesoft/pat/Transformer.js +++ b/bin/com/stevesoft/pat/Transformer.js @@ -1,130 +1,130 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.ReplaceRule", "$.Replacer"], ["com.stevesoft.pat.Transformer", "$.TransRepRule"], ["com.stevesoft.pat.MessageManager", "$.Regex", "$.TransPat", "com.stevesoft.pat.wrap.StringWrap", "java.lang.ArrayIndexOutOfBoundsException", "$.NullPointerException"], function () { -c$ = Clazz.decorateAsClass (function () { -this.t = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "TransRepRule", com.stevesoft.pat.ReplaceRule); -Clazz.makeConstructor (c$, -function (t) { -Clazz.superConstructor (this, com.stevesoft.pat.TransRepRule, []); -this.t = t; -}, "com.stevesoft.pat.Transformer"); -Clazz.overrideMethod (c$, "toString1", -function () { -return ""; -}); -Clazz.overrideMethod (c$, "clone1", -function () { -return new com.stevesoft.pat.TransRepRule (this.t); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, rr) { -this.next = this.t.tp.ra[this.t.tp.pn].getReplaceRule (); -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -c$ = Clazz.decorateAsClass (function () { -this.tp = null; -this.rp = null; -this.auto_optimize = false; -this.repr = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Transformer"); -Clazz.prepareFields (c$, function () { -this.repr = new com.stevesoft.pat.Replacer (); -}); -Clazz.defineMethod (c$, "getReplacer", -function () { -return this.rp.getReplacer (); -}); -Clazz.makeConstructor (c$, -function (auto) { -this.rp = new com.stevesoft.pat.Regex (null, ""); -this.auto_optimize = auto; -this.tp = new com.stevesoft.pat.TransPat (); -this.rp.setReplaceRule ( new com.stevesoft.pat.TransRepRule (this)); -this.rp.thePattern = this.tp; -}, "~B"); -Clazz.defineMethod (c$, "add", -function (r) { -if (this.auto_optimize) { -r.optimize (); -}this.tp.ra[this.tp.ra_len++] = r; -if (this.tp.ra.length == this.tp.ra_len) { -var ra2 = new Array (this.tp.ra_len + 10); -for (var i = 0; i < this.tp.ra_len; i++) { -ra2[i] = this.tp.ra[i]; -} -this.tp.ra = ra2; -}this.rp.numSubs_ = r.numSubs_ > this.rp.numSubs_ ? r.numSubs_ : this.rp.numSubs_; -}, "com.stevesoft.pat.Regex"); -Clazz.defineMethod (c$, "patterns", -function () { -return this.tp.ra_len; -}); -Clazz.defineMethod (c$, "getRegexAt", -function (i) { -if (i >= this.tp.ra_len) { -throw new ArrayIndexOutOfBoundsException ("i=" + i + ">=" + this.patterns ()); -}if (i < 0) { -throw new ArrayIndexOutOfBoundsException ("i=" + i + "< 0"); -}return this.tp.ra[i]; -}, "~N"); -Clazz.defineMethod (c$, "setRegexAt", -function (rx, i) { -if (i >= this.tp.ra_len) { -throw new ArrayIndexOutOfBoundsException ("i=" + i + ">=" + this.patterns ()); -}if (i < 0) { -throw new ArrayIndexOutOfBoundsException ("i=" + i + "< 0"); -}this.tp.ra[i] = rx; -}, "com.stevesoft.pat.Regex,~N"); -Clazz.defineMethod (c$, "add", -function (rs) { -var r = com.stevesoft.pat.Regex.perlCode (rs); -if (r == null) { -throw new NullPointerException (com.stevesoft.pat.MessageManager.formatMessage ("exception.bad_pattern_to_regex_perl_code", Clazz.newArray (-1, [rs]))); -}this.add (r); -}, "~S"); -Clazz.defineMethod (c$, "add", -function (array) { -for (var i = 0; i < array.length; i++) { -this.add (array[i]); -} -}, "~A"); -Clazz.defineMethod (c$, "replaceAll", -function (s) { -return this.dorep (s, 0, s.length); -}, "~S"); -Clazz.defineMethod (c$, "replaceAll", -function (s) { -return this.dorep (s, 0, s.length ()); -}, "com.stevesoft.pat.StringLike"); -Clazz.defineMethod (c$, "replaceAllFrom", -function (s, start) { -return this.dorep (s, start, s.length); -}, "~S,~N"); -Clazz.defineMethod (c$, "replaceAllRegion", -function (s, start, end) { -return this.dorep (s, start, end); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "dorep", -function (s, start, end) { -var tfmd = this.repr.replaceAllRegion (s, this.rp, start, end); -this.tp.lastMatchedTo = this.repr.$lastMatchedTo; -return tfmd; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "dorep", -function (s, start, end) { -return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString (); -}, "~S,~N,~N"); -Clazz.defineMethod (c$, "replaceFirst", -function (s) { -return this.dorep (s, 0, s.length); -}, "~S"); -Clazz.defineMethod (c$, "replaceFirstFrom", -function (s, start) { -return this.dorep (s, start, s.length); -}, "~S,~N"); -Clazz.defineMethod (c$, "replaceFirstRegion", -function (s, start, end) { -return this.dorep (s, start, end); -}, "~S,~N,~N"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.ReplaceRule", "$.Replacer"], ["com.stevesoft.pat.Transformer", "$.TransRepRule"], ["com.stevesoft.pat.MessageManager", "$.Regex", "$.TransPat", "com.stevesoft.pat.wrap.StringWrap", "java.lang.ArrayIndexOutOfBoundsException", "$.NullPointerException"], function () { +c$ = Clazz.decorateAsClass (function () { +this.t = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "TransRepRule", com.stevesoft.pat.ReplaceRule); +Clazz.makeConstructor (c$, +function (t) { +Clazz.superConstructor (this, com.stevesoft.pat.TransRepRule, []); +this.t = t; +}, "com.stevesoft.pat.Transformer"); +Clazz.overrideMethod (c$, "toString1", +function () { +return ""; +}); +Clazz.overrideMethod (c$, "clone1", +function () { +return new com.stevesoft.pat.TransRepRule (this.t); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, rr) { +this.next = this.t.tp.ra[this.t.tp.pn].getReplaceRule (); +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +c$ = Clazz.decorateAsClass (function () { +this.tp = null; +this.rp = null; +this.auto_optimize = false; +this.repr = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Transformer"); +Clazz.prepareFields (c$, function () { +this.repr = new com.stevesoft.pat.Replacer (); +}); +Clazz.defineMethod (c$, "getReplacer", +function () { +return this.rp.getReplacer (); +}); +Clazz.makeConstructor (c$, +function (auto) { +this.rp = new com.stevesoft.pat.Regex (null, ""); +this.auto_optimize = auto; +this.tp = new com.stevesoft.pat.TransPat (); +this.rp.setReplaceRule ( new com.stevesoft.pat.TransRepRule (this)); +this.rp.thePattern = this.tp; +}, "~B"); +Clazz.defineMethod (c$, "add", +function (r) { +if (this.auto_optimize) { +r.optimize (); +}this.tp.ra[this.tp.ra_len++] = r; +if (this.tp.ra.length == this.tp.ra_len) { +var ra2 = new Array (this.tp.ra_len + 10); +for (var i = 0; i < this.tp.ra_len; i++) { +ra2[i] = this.tp.ra[i]; +} +this.tp.ra = ra2; +}this.rp.numSubs_ = r.numSubs_ > this.rp.numSubs_ ? r.numSubs_ : this.rp.numSubs_; +}, "com.stevesoft.pat.Regex"); +Clazz.defineMethod (c$, "patterns", +function () { +return this.tp.ra_len; +}); +Clazz.defineMethod (c$, "getRegexAt", +function (i) { +if (i >= this.tp.ra_len) { +throw new ArrayIndexOutOfBoundsException ("i=" + i + ">=" + this.patterns ()); +}if (i < 0) { +throw new ArrayIndexOutOfBoundsException ("i=" + i + "< 0"); +}return this.tp.ra[i]; +}, "~N"); +Clazz.defineMethod (c$, "setRegexAt", +function (rx, i) { +if (i >= this.tp.ra_len) { +throw new ArrayIndexOutOfBoundsException ("i=" + i + ">=" + this.patterns ()); +}if (i < 0) { +throw new ArrayIndexOutOfBoundsException ("i=" + i + "< 0"); +}this.tp.ra[i] = rx; +}, "com.stevesoft.pat.Regex,~N"); +Clazz.defineMethod (c$, "add", +function (rs) { +var r = com.stevesoft.pat.Regex.perlCode (rs); +if (r == null) { +throw new NullPointerException (com.stevesoft.pat.MessageManager.formatMessage ("exception.bad_pattern_to_regex_perl_code", Clazz.newArray (-1, [rs]))); +}this.add (r); +}, "~S"); +Clazz.defineMethod (c$, "add", +function (array) { +for (var i = 0; i < array.length; i++) { +this.add (array[i]); +} +}, "~A"); +Clazz.defineMethod (c$, "replaceAll", +function (s) { +return this.dorep (s, 0, s.length); +}, "~S"); +Clazz.defineMethod (c$, "replaceAll", +function (s) { +return this.dorep (s, 0, s.length ()); +}, "com.stevesoft.pat.StringLike"); +Clazz.defineMethod (c$, "replaceAllFrom", +function (s, start) { +return this.dorep (s, start, s.length); +}, "~S,~N"); +Clazz.defineMethod (c$, "replaceAllRegion", +function (s, start, end) { +return this.dorep (s, start, end); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "dorep", +function (s, start, end) { +var tfmd = this.repr.replaceAllRegion (s, this.rp, start, end); +this.tp.lastMatchedTo = this.repr.$lastMatchedTo; +return tfmd; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "dorep", +function (s, start, end) { +return this.dorep ( new com.stevesoft.pat.wrap.StringWrap (s), start, end).toString (); +}, "~S,~N,~N"); +Clazz.defineMethod (c$, "replaceFirst", +function (s) { +return this.dorep (s, 0, s.length); +}, "~S"); +Clazz.defineMethod (c$, "replaceFirstFrom", +function (s, start) { +return this.dorep (s, start, s.length); +}, "~S,~N"); +Clazz.defineMethod (c$, "replaceFirstRegion", +function (s, start, end) { +return this.dorep (s, start, end); +}, "~S,~N,~N"); +}); diff --git a/bin/com/stevesoft/pat/UniValidator.js b/bin/com/stevesoft/pat/UniValidator.js index 18aa516..e1731a4 100644 --- a/bin/com/stevesoft/pat/UniValidator.js +++ b/bin/com/stevesoft/pat/UniValidator.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Validator"], "com.stevesoft.pat.UniValidator", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "UniValidator", com.stevesoft.pat.Validator); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Validator"], "com.stevesoft.pat.UniValidator", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "UniValidator", com.stevesoft.pat.Validator); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +}); diff --git a/bin/com/stevesoft/pat/Util.js b/bin/com/stevesoft/pat/Util.js index 3058320..6573d7b 100644 --- a/bin/com/stevesoft/pat/Util.js +++ b/bin/com/stevesoft/pat/Util.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -c$ = Clazz.declareType (com.stevesoft.pat, "Util"); +Clazz.declarePackage ("com.stevesoft.pat"); +c$ = Clazz.declareType (com.stevesoft.pat, "Util"); diff --git a/bin/com/stevesoft/pat/Validator.js b/bin/com/stevesoft/pat/Validator.js index e364969..c929431 100644 --- a/bin/com/stevesoft/pat/Validator.js +++ b/bin/com/stevesoft/pat/Validator.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.Validator", ["com.stevesoft.pat.patInf", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.argsave = null; -this.pattern = "."; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "Validator"); -Clazz.defineMethod (c$, "validate", -function (src, start, end) { -return end; -}, "com.stevesoft.pat.StringLike,~N,~N"); -Clazz.defineMethod (c$, "arg", -function (s) { -return null; -}, "~S"); -Clazz.defineMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.defineMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInf (); -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.Validator", ["com.stevesoft.pat.patInf", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.argsave = null; +this.pattern = "."; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "Validator"); +Clazz.defineMethod (c$, "validate", +function (src, start, end) { +return end; +}, "com.stevesoft.pat.StringLike,~N,~N"); +Clazz.defineMethod (c$, "arg", +function (s) { +return null; +}, "~S"); +Clazz.defineMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.defineMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInf (); +}); +}); diff --git a/bin/com/stevesoft/pat/WantMoreTextReplaceRule.js b/bin/com/stevesoft/pat/WantMoreTextReplaceRule.js index b572563..e305e86 100644 --- a/bin/com/stevesoft/pat/WantMoreTextReplaceRule.js +++ b/bin/com/stevesoft/pat/WantMoreTextReplaceRule.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.WantMoreTextReplaceRule", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "WantMoreTextReplaceRule", com.stevesoft.pat.SpecialRule); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.WantMoreTextReplaceRule, []); -}); -Clazz.overrideMethod (c$, "apply", -function (sb, res) { -}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); -Clazz.overrideMethod (c$, "toString1", -function () { -return "${WANT_MORE_TEXT}"; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.SpecialRule"], "com.stevesoft.pat.WantMoreTextReplaceRule", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "WantMoreTextReplaceRule", com.stevesoft.pat.SpecialRule); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.WantMoreTextReplaceRule, []); +}); +Clazz.overrideMethod (c$, "apply", +function (sb, res) { +}, "com.stevesoft.pat.StringBufferLike,com.stevesoft.pat.RegRes"); +Clazz.overrideMethod (c$, "toString1", +function () { +return "${WANT_MORE_TEXT}"; +}); +}); diff --git a/bin/com/stevesoft/pat/lookAhead.js b/bin/com/stevesoft/pat/lookAhead.js index 6b9fe88..05e888d 100644 --- a/bin/com/stevesoft/pat/lookAhead.js +++ b/bin/com/stevesoft/pat/lookAhead.js @@ -1,62 +1,62 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Or"], "com.stevesoft.pat.lookAhead", ["com.stevesoft.pat.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.reverse = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "lookAhead", com.stevesoft.pat.Or); -Clazz.makeConstructor (c$, -function (b) { -Clazz.superConstructor (this, com.stevesoft.pat.lookAhead, []); -this.reverse = b; -}, "~B"); -Clazz.defineMethod (c$, "getNext", -function () { -return null; -}); -Clazz.overrideMethod (c$, "nextMatch", -function (pos, pt) { -var p = Clazz.superCall (this, com.stevesoft.pat.lookAhead, "getNext", []); -if (p != null) { -return p.matchInternal (pos, pt); -} else { -return pos; -}}, "~N,com.stevesoft.pat.Pthings"); -Clazz.defineMethod (c$, "matchInternal", -function (pos, pt) { -if (Clazz.superCall (this, com.stevesoft.pat.lookAhead, "matchInternal", [pos, pt]) >= 0) { -if (this.reverse) { -return -1; -} else { -return this.nextMatch (pos, pt); -}} else { -if (this.reverse) { -return this.nextMatch (pos, pt); -} else { -return -1; -}}}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "leftForm", -function () { -if (this.reverse) { -return "(?!"; -} else { -return "(?="; -}}); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (0); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -var la = new com.stevesoft.pat.lookAhead (this.reverse); -h.put (this, la); -h.put (la, la); -for (var i = 0; i < this.v.size (); i++) { -la.v.addElement ((this.v.elementAt (i)).clone (h)); -} -return la; -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Or"], "com.stevesoft.pat.lookAhead", ["com.stevesoft.pat.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.reverse = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "lookAhead", com.stevesoft.pat.Or); +Clazz.makeConstructor (c$, +function (b) { +Clazz.superConstructor (this, com.stevesoft.pat.lookAhead, []); +this.reverse = b; +}, "~B"); +Clazz.defineMethod (c$, "getNext", +function () { +return null; +}); +Clazz.overrideMethod (c$, "nextMatch", +function (pos, pt) { +var p = Clazz.superCall (this, com.stevesoft.pat.lookAhead, "getNext", []); +if (p != null) { +return p.matchInternal (pos, pt); +} else { +return pos; +}}, "~N,com.stevesoft.pat.Pthings"); +Clazz.defineMethod (c$, "matchInternal", +function (pos, pt) { +if (Clazz.superCall (this, com.stevesoft.pat.lookAhead, "matchInternal", [pos, pt]) >= 0) { +if (this.reverse) { +return -1; +} else { +return this.nextMatch (pos, pt); +}} else { +if (this.reverse) { +return this.nextMatch (pos, pt); +} else { +return -1; +}}}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "leftForm", +function () { +if (this.reverse) { +return "(?!"; +} else { +return "(?="; +}}); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (0); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +var la = new com.stevesoft.pat.lookAhead (this.reverse); +h.put (this, la); +h.put (la, la); +for (var i = 0; i < this.v.size (); i++) { +la.v.addElement ((this.v.elementAt (i)).clone (h)); +} +return la; +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/oneChar.js b/bin/com/stevesoft/pat/oneChar.js index 1fbc400..3dac704 100644 --- a/bin/com/stevesoft/pat/oneChar.js +++ b/bin/com/stevesoft/pat/oneChar.js @@ -1,55 +1,55 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.oneChar", ["com.stevesoft.pat.CaseMgr", "$.patInt"], function () { -c$ = Clazz.decorateAsClass (function () { -this.c = '\0'; -this.altc = '\0'; -this.altc2 = '\0'; -this.mask = 0; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "oneChar", com.stevesoft.pat.Pattern); -Clazz.makeConstructor (c$, -function (ci) { -Clazz.superConstructor (this, com.stevesoft.pat.oneChar, []); -this.c = ci; -var cu; -var cl; -var ct; -cu = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.c); -cl = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.c); -ct = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.c); -if (this.c == cu) { -this.altc = cl; -this.altc2 = ct; -} else if (this.c == cl) { -this.altc = cu; -this.altc2 = ct; -} else { -this.altc = cl; -this.altc2 = cu; -}this.mask = this.c.charCodeAt (0) & this.altc.charCodeAt (0) & this.altc2.charCodeAt (0); -}, "~S"); -Clazz.overrideMethod (c$, "matchInternal", -function (pos, pt) { -var p; -var ret = -1; -if (pos < pt.src.length () && !this.Masked (pos, pt) && ((p = pt.src.charAt (pos)) == this.c || (pt.ignoreCase && (p == this.altc || p == this.altc2)))) { -ret = this.nextMatch (pos + 1, pt); -}return ret; -}, "~N,com.stevesoft.pat.Pthings"); -Clazz.overrideMethod (c$, "toString", -function () { -return com.stevesoft.pat.Pattern.protect ("" + this.c, "[]{}(),$,-\"^.", '\\') + this.nextString (); -}); -Clazz.overrideMethod (c$, "minChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "maxChars", -function () { -return new com.stevesoft.pat.patInt (1); -}); -Clazz.overrideMethod (c$, "clone1", -function (h) { -return new com.stevesoft.pat.oneChar (this.c); -}, "java.util.Hashtable"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.Pattern"], "com.stevesoft.pat.oneChar", ["com.stevesoft.pat.CaseMgr", "$.patInt"], function () { +c$ = Clazz.decorateAsClass (function () { +this.c = '\0'; +this.altc = '\0'; +this.altc2 = '\0'; +this.mask = 0; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "oneChar", com.stevesoft.pat.Pattern); +Clazz.makeConstructor (c$, +function (ci) { +Clazz.superConstructor (this, com.stevesoft.pat.oneChar, []); +this.c = ci; +var cu; +var cl; +var ct; +cu = com.stevesoft.pat.CaseMgr.toUpperCaseC (this.c); +cl = com.stevesoft.pat.CaseMgr.toLowerCaseC (this.c); +ct = com.stevesoft.pat.CaseMgr.toTitleCaseC (this.c); +if (this.c == cu) { +this.altc = cl; +this.altc2 = ct; +} else if (this.c == cl) { +this.altc = cu; +this.altc2 = ct; +} else { +this.altc = cl; +this.altc2 = cu; +}this.mask = this.c.charCodeAt (0) & this.altc.charCodeAt (0) & this.altc2.charCodeAt (0); +}, "~S"); +Clazz.overrideMethod (c$, "matchInternal", +function (pos, pt) { +var p; +var ret = -1; +if (pos < pt.src.length () && !this.Masked (pos, pt) && ((p = pt.src.charAt (pos)) == this.c || (pt.ignoreCase && (p == this.altc || p == this.altc2)))) { +ret = this.nextMatch (pos + 1, pt); +}return ret; +}, "~N,com.stevesoft.pat.Pthings"); +Clazz.overrideMethod (c$, "toString", +function () { +return com.stevesoft.pat.Pattern.protect ("" + this.c, "[]{}(),$,-\"^.", '\\') + this.nextString (); +}); +Clazz.overrideMethod (c$, "minChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "maxChars", +function () { +return new com.stevesoft.pat.patInt (1); +}); +Clazz.overrideMethod (c$, "clone1", +function (h) { +return new com.stevesoft.pat.oneChar (this.c); +}, "java.util.Hashtable"); +}); diff --git a/bin/com/stevesoft/pat/package.js b/bin/com/stevesoft/pat/package.js index 1c96a94..dd478ec 100644 --- a/bin/com/stevesoft/pat/package.js +++ b/bin/com/stevesoft/pat/package.js @@ -1,34 +1,34 @@ -var path = ClazzLoader.getClasspathFor ("com.stevesoft.pat.package"); -path = path.substring (0, path.lastIndexOf ("package.js")); -ClazzLoader.jarClasspath (path + "Range.js", [ -"com.stevesoft.pat.BadRangeArgs", -"$.Range"]); -ClazzLoader.jarClasspath (path + "RegOpt.js", [ -"com.stevesoft.pat.Branch", -"$.RegOpt", -"$.FastChar"]); -ClazzLoader.jarClasspath (path + "Regex.js", [ -"com.stevesoft.pat.UnicodeW", -"$.UnicodeCurrency", -"$.UnicodeAlpha", -"$.UnicodeUpper", -"$.NUnicodeCurrency", -"$.NUnicodeW", -"$.NUnicodeAlpha", -"$.UnicodeMath", -"$.UnicodeWhite", -"$.UnicodeDigit", -"$.NUnicodeMath", -"$.Regex", -"$.NUnicodeDigit", -"$.NUnicodeWhite", -"$.NUnicodePunct", -"$.UnicodePunct", -"$.UnicodeLower"]); -ClazzLoader.jarClasspath (path + "Replacer.js", [ -"com.stevesoft.pat.RegHolder", -"$.Replacer", -"$.CodeVal"]); -ClazzLoader.jarClasspath (path + "Transformer.js", [ -"com.stevesoft.pat.Transformer", -"$.TransRepRule"]); +var path = ClazzLoader.getClasspathFor ("com.stevesoft.pat.package"); +path = path.substring (0, path.lastIndexOf ("package.js")); +ClazzLoader.jarClasspath (path + "Range.js", [ +"com.stevesoft.pat.BadRangeArgs", +"$.Range"]); +ClazzLoader.jarClasspath (path + "RegOpt.js", [ +"com.stevesoft.pat.Branch", +"$.RegOpt", +"$.FastChar"]); +ClazzLoader.jarClasspath (path + "Regex.js", [ +"com.stevesoft.pat.UnicodeW", +"$.UnicodeCurrency", +"$.UnicodeAlpha", +"$.UnicodeUpper", +"$.NUnicodeCurrency", +"$.NUnicodeW", +"$.NUnicodeAlpha", +"$.UnicodeMath", +"$.UnicodeWhite", +"$.UnicodeDigit", +"$.NUnicodeMath", +"$.Regex", +"$.NUnicodeDigit", +"$.NUnicodeWhite", +"$.NUnicodePunct", +"$.UnicodePunct", +"$.UnicodeLower"]); +ClazzLoader.jarClasspath (path + "Replacer.js", [ +"com.stevesoft.pat.RegHolder", +"$.Replacer", +"$.CodeVal"]); +ClazzLoader.jarClasspath (path + "Transformer.js", [ +"com.stevesoft.pat.Transformer", +"$.TransRepRule"]); diff --git a/bin/com/stevesoft/pat/parsePerl.js b/bin/com/stevesoft/pat/parsePerl.js index d34fbd4..005236e 100644 --- a/bin/com/stevesoft/pat/parsePerl.js +++ b/bin/com/stevesoft/pat/parsePerl.js @@ -1,267 +1,267 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (null, "com.stevesoft.pat.parsePerl", ["com.stevesoft.pat.CaseMgr", "$.Prop", "$.RegSyntaxError", "$.Regex", "$.ReplaceRule", "$.StringRule", "java.lang.StringBuffer"], function () { -c$ = Clazz.declareType (com.stevesoft.pat, "parsePerl"); -c$.close = Clazz.defineMethod (c$, "close", -function (c) { -if (c == '<') { -return '>'; -}if (c == '[') { -return ']'; -}if (c == '(') { -return ')'; -}if (c == '{') { -return '}'; -}return c; -}, "~S"); -c$.codify = Clazz.defineMethod (c$, "codify", -function (s, keepbs) { -return com.stevesoft.pat.parsePerl.codifyRange (s, 0, s.length, keepbs); -}, "~S,~B"); -c$.codifyRange = Clazz.defineMethod (c$, "codifyRange", -function (s, i0, iN, keepbs) { -var sb = new StringBuffer (); -var ucmode = false; -var lcmode = false; -var litmode = false; -var uc1 = false; -var lc1 = false; -var modified = false; -for (var i = i0; i < iN; i++) { -var c = s.charAt (i); -var mf = true; -var app = true; -if (c == '\\') { -app = false; -i++; -if (i < s.length) { -var c2 = s.charAt (i); -switch (c2) { -case 'Q': -litmode = true; -break; -case 'U': -ucmode = true; -break; -case 'L': -lcmode = true; -break; -case 'u': -uc1 = true; -break; -case 'l': -lc1 = true; -break; -case 'E': -uc1 = lc1 = ucmode = lcmode = litmode = false; -break; -default: -if (keepbs) { -sb.append ('\\'); -}c = c2; -if (keepbs) { -mf = false; -}app = true; -break; -} -modified = new Boolean (modified | mf).valueOf (); -}}if (app) { -if (lc1) { -c = com.stevesoft.pat.parsePerl.lc (c); -lc1 = false; -} else if (uc1) { -c = com.stevesoft.pat.parsePerl.uc (c); -uc1 = false; -} else if (ucmode) { -c = com.stevesoft.pat.parsePerl.uc (c); -} else if (lcmode) { -c = com.stevesoft.pat.parsePerl.lc (c); -}if (litmode && com.stevesoft.pat.parsePerl.needbs (c)) { -sb.append ('\\'); -}sb.append (c); -}} -return modified ? sb.toString () : s; -}, "~S,~N,~N,~B"); -c$.uc = Clazz.defineMethod (c$, "uc", -function (c) { -return com.stevesoft.pat.CaseMgr.toUpperCaseC (c); -}, "~S"); -c$.lc = Clazz.defineMethod (c$, "lc", -function (c) { -return com.stevesoft.pat.CaseMgr.toLowerCaseC (c); -}, "~S"); -c$.needbs = Clazz.defineMethod (c$, "needbs", -function (c) { -if (c >= 'a' && c <= 'z') { -return false; -}if (c >= 'A' && c <= 'Z') { -return false; -}if (c >= '0' && c <= '9') { -return false; -}if (c == '_') { -return false; -}return true; -}, "~S"); -c$.parse = Clazz.defineMethod (c$, "parse", -function (s) { -var igncase = false; -var optim = false; -var gFlag = false; -var sFlag = false; -var mFlag = false; -var xFlag = false; -var s1 = new StringBuffer (); -var s2 = new StringBuffer (); -var i = 0; -var count = 0; -var mode; -var delim = '/'; -var cdelim = '/'; -if (s.length >= 3 && s.charAt (0) == 's') { -mode = 's'; -delim = s.charAt (1); -cdelim = com.stevesoft.pat.parsePerl.close (delim); -i = 2; -} else if (s.length >= 2 && s.charAt (0) == 'm') { -mode = 'm'; -delim = s.charAt (1); -cdelim = com.stevesoft.pat.parsePerl.close (delim); -i = 2; -} else if (s.length >= 1 && s.charAt (0) == '/') { -mode = 'm'; -i = 1; -} else { -try { -com.stevesoft.pat.RegSyntaxError.endItAll ("Regex.perlCode should be of the form s/// or m// or //"); -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -} else { -throw rs; -} -} -return null; -}for (; i < s.length; i++) { -if (s.charAt (i) == '\\') { -s1.append ('\\'); -i++; -} else if (s.charAt (i) == cdelim && count == 0) { -i++; -break; -} else if (s.charAt (i) == delim && cdelim != delim) { -count++; -} else if (s.charAt (i) == cdelim && cdelim != delim) { -count--; -}s1.append (s.charAt (i)); -} -if (mode == 's' && cdelim != delim) { -while (i < s.length && com.stevesoft.pat.Prop.isWhite (s.charAt (i))) { -i++; -} -if (i >= s.length) { -try { -com.stevesoft.pat.RegSyntaxError.endItAll ("" + mode + delim + " needs " + cdelim); -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -} else { -throw rs; -} -} -return null; -}cdelim = com.stevesoft.pat.parsePerl.close (delim = s.charAt (i)); -i++; -}count = 0; -if (mode == 's') { -for (; i < s.length; i++) { -if (s.charAt (i) == '\\') { -s2.append ('\\'); -i++; -} else if (s.charAt (i) == cdelim && count == 0) { -i++; -break; -} else if (s.charAt (i) == delim && cdelim != delim) { -count++; -} else if (s.charAt (i) == cdelim && cdelim != delim) { -count--; -}s2.append (s.charAt (i)); -} -}for (; i < s.length; i++) { -var c = s.charAt (i); -switch (c) { -case 'x': -xFlag = true; -break; -case 'i': -igncase = true; -break; -case 'o': -optim = true; -break; -case 's': -sFlag = true; -break; -case 'm': -mFlag = true; -break; -case 'g': -gFlag = true; -break; -default: -try { -com.stevesoft.pat.RegSyntaxError.endItAll ("Illegal flag to pattern: " + c); -} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -} else { -throw rs; -} -} -return null; -} -} -var r = new com.stevesoft.pat.Regex (null, ""); -try { -var pat = s1.toString (); -var reprul = s2.toString (); -if (xFlag) { -pat = com.stevesoft.pat.parsePerl.strip (pat); -reprul = com.stevesoft.pat.parsePerl.strip (reprul); -}r.compile (pat); -r.ignoreCase = new Boolean (r.ignoreCase | igncase).valueOf (); -r.gFlag = new Boolean (r.gFlag | gFlag).valueOf (); -r.sFlag = new Boolean (r.sFlag | sFlag).valueOf (); -r.mFlag = new Boolean (r.mFlag | mFlag).valueOf (); -if (optim) { -r.optimize (); -}if (delim == '\'') { -r.setReplaceRule ( new com.stevesoft.pat.StringRule (reprul)); -} else { -r.setReplaceRule (com.stevesoft.pat.ReplaceRule.perlCode (reprul)); -}} catch (rs) { -if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { -r = null; -} else { -throw rs; -} -} -return r; -}, "~S"); -c$.strip = Clazz.defineMethod (c$, "strip", -function (s) { -var sb = new StringBuffer (); -for (var i = 0; i < s.length; i++) { -var c = s.charAt (i); -if (com.stevesoft.pat.Prop.isWhite (c)) { -;} else if (c == '#') { -i++; -while (i < s.length) { -if (s.charAt (i) == '\n') { -break; -}i++; -} -} else if (c == '\\') { -sb.append (c); -sb.append (s.charAt (++i)); -} else { -sb.append (c); -}} -return sb.toString (); -}, "~S"); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (null, "com.stevesoft.pat.parsePerl", ["com.stevesoft.pat.CaseMgr", "$.Prop", "$.RegSyntaxError", "$.Regex", "$.ReplaceRule", "$.StringRule", "java.lang.StringBuffer"], function () { +c$ = Clazz.declareType (com.stevesoft.pat, "parsePerl"); +c$.close = Clazz.defineMethod (c$, "close", +function (c) { +if (c == '<') { +return '>'; +}if (c == '[') { +return ']'; +}if (c == '(') { +return ')'; +}if (c == '{') { +return '}'; +}return c; +}, "~S"); +c$.codify = Clazz.defineMethod (c$, "codify", +function (s, keepbs) { +return com.stevesoft.pat.parsePerl.codifyRange (s, 0, s.length, keepbs); +}, "~S,~B"); +c$.codifyRange = Clazz.defineMethod (c$, "codifyRange", +function (s, i0, iN, keepbs) { +var sb = new StringBuffer (); +var ucmode = false; +var lcmode = false; +var litmode = false; +var uc1 = false; +var lc1 = false; +var modified = false; +for (var i = i0; i < iN; i++) { +var c = s.charAt (i); +var mf = true; +var app = true; +if (c == '\\') { +app = false; +i++; +if (i < s.length) { +var c2 = s.charAt (i); +switch (c2) { +case 'Q': +litmode = true; +break; +case 'U': +ucmode = true; +break; +case 'L': +lcmode = true; +break; +case 'u': +uc1 = true; +break; +case 'l': +lc1 = true; +break; +case 'E': +uc1 = lc1 = ucmode = lcmode = litmode = false; +break; +default: +if (keepbs) { +sb.append ('\\'); +}c = c2; +if (keepbs) { +mf = false; +}app = true; +break; +} +modified = new Boolean (modified | mf).valueOf (); +}}if (app) { +if (lc1) { +c = com.stevesoft.pat.parsePerl.lc (c); +lc1 = false; +} else if (uc1) { +c = com.stevesoft.pat.parsePerl.uc (c); +uc1 = false; +} else if (ucmode) { +c = com.stevesoft.pat.parsePerl.uc (c); +} else if (lcmode) { +c = com.stevesoft.pat.parsePerl.lc (c); +}if (litmode && com.stevesoft.pat.parsePerl.needbs (c)) { +sb.append ('\\'); +}sb.append (c); +}} +return modified ? sb.toString () : s; +}, "~S,~N,~N,~B"); +c$.uc = Clazz.defineMethod (c$, "uc", +function (c) { +return com.stevesoft.pat.CaseMgr.toUpperCaseC (c); +}, "~S"); +c$.lc = Clazz.defineMethod (c$, "lc", +function (c) { +return com.stevesoft.pat.CaseMgr.toLowerCaseC (c); +}, "~S"); +c$.needbs = Clazz.defineMethod (c$, "needbs", +function (c) { +if (c >= 'a' && c <= 'z') { +return false; +}if (c >= 'A' && c <= 'Z') { +return false; +}if (c >= '0' && c <= '9') { +return false; +}if (c == '_') { +return false; +}return true; +}, "~S"); +c$.parse = Clazz.defineMethod (c$, "parse", +function (s) { +var igncase = false; +var optim = false; +var gFlag = false; +var sFlag = false; +var mFlag = false; +var xFlag = false; +var s1 = new StringBuffer (); +var s2 = new StringBuffer (); +var i = 0; +var count = 0; +var mode; +var delim = '/'; +var cdelim = '/'; +if (s.length >= 3 && s.charAt (0) == 's') { +mode = 's'; +delim = s.charAt (1); +cdelim = com.stevesoft.pat.parsePerl.close (delim); +i = 2; +} else if (s.length >= 2 && s.charAt (0) == 'm') { +mode = 'm'; +delim = s.charAt (1); +cdelim = com.stevesoft.pat.parsePerl.close (delim); +i = 2; +} else if (s.length >= 1 && s.charAt (0) == '/') { +mode = 'm'; +i = 1; +} else { +try { +com.stevesoft.pat.RegSyntaxError.endItAll ("Regex.perlCode should be of the form s/// or m// or //"); +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +} else { +throw rs; +} +} +return null; +}for (; i < s.length; i++) { +if (s.charAt (i) == '\\') { +s1.append ('\\'); +i++; +} else if (s.charAt (i) == cdelim && count == 0) { +i++; +break; +} else if (s.charAt (i) == delim && cdelim != delim) { +count++; +} else if (s.charAt (i) == cdelim && cdelim != delim) { +count--; +}s1.append (s.charAt (i)); +} +if (mode == 's' && cdelim != delim) { +while (i < s.length && com.stevesoft.pat.Prop.isWhite (s.charAt (i))) { +i++; +} +if (i >= s.length) { +try { +com.stevesoft.pat.RegSyntaxError.endItAll ("" + mode + delim + " needs " + cdelim); +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +} else { +throw rs; +} +} +return null; +}cdelim = com.stevesoft.pat.parsePerl.close (delim = s.charAt (i)); +i++; +}count = 0; +if (mode == 's') { +for (; i < s.length; i++) { +if (s.charAt (i) == '\\') { +s2.append ('\\'); +i++; +} else if (s.charAt (i) == cdelim && count == 0) { +i++; +break; +} else if (s.charAt (i) == delim && cdelim != delim) { +count++; +} else if (s.charAt (i) == cdelim && cdelim != delim) { +count--; +}s2.append (s.charAt (i)); +} +}for (; i < s.length; i++) { +var c = s.charAt (i); +switch (c) { +case 'x': +xFlag = true; +break; +case 'i': +igncase = true; +break; +case 'o': +optim = true; +break; +case 's': +sFlag = true; +break; +case 'm': +mFlag = true; +break; +case 'g': +gFlag = true; +break; +default: +try { +com.stevesoft.pat.RegSyntaxError.endItAll ("Illegal flag to pattern: " + c); +} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +} else { +throw rs; +} +} +return null; +} +} +var r = new com.stevesoft.pat.Regex (null, ""); +try { +var pat = s1.toString (); +var reprul = s2.toString (); +if (xFlag) { +pat = com.stevesoft.pat.parsePerl.strip (pat); +reprul = com.stevesoft.pat.parsePerl.strip (reprul); +}r.compile (pat); +r.ignoreCase = new Boolean (r.ignoreCase | igncase).valueOf (); +r.gFlag = new Boolean (r.gFlag | gFlag).valueOf (); +r.sFlag = new Boolean (r.sFlag | sFlag).valueOf (); +r.mFlag = new Boolean (r.mFlag | mFlag).valueOf (); +if (optim) { +r.optimize (); +}if (delim == '\'') { +r.setReplaceRule ( new com.stevesoft.pat.StringRule (reprul)); +} else { +r.setReplaceRule (com.stevesoft.pat.ReplaceRule.perlCode (reprul)); +}} catch (rs) { +if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) { +r = null; +} else { +throw rs; +} +} +return r; +}, "~S"); +c$.strip = Clazz.defineMethod (c$, "strip", +function (s) { +var sb = new StringBuffer (); +for (var i = 0; i < s.length; i++) { +var c = s.charAt (i); +if (com.stevesoft.pat.Prop.isWhite (c)) { +;} else if (c == '#') { +i++; +while (i < s.length) { +if (s.charAt (i) == '\n') { +break; +}i++; +} +} else if (c == '\\') { +sb.append (c); +sb.append (s.charAt (++i)); +} else { +sb.append (c); +}} +return sb.toString (); +}, "~S"); +}); diff --git a/bin/com/stevesoft/pat/patInf.js b/bin/com/stevesoft/pat/patInf.js index 1e11499..daf7087 100644 --- a/bin/com/stevesoft/pat/patInf.js +++ b/bin/com/stevesoft/pat/patInf.js @@ -1,9 +1,9 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -Clazz.load (["com.stevesoft.pat.patInt"], "com.stevesoft.pat.patInf", null, function () { -c$ = Clazz.declareType (com.stevesoft.pat, "patInf", com.stevesoft.pat.patInt); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, com.stevesoft.pat.patInf, []); -this.inf = true; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat"); +Clazz.load (["com.stevesoft.pat.patInt"], "com.stevesoft.pat.patInf", null, function () { +c$ = Clazz.declareType (com.stevesoft.pat, "patInf", com.stevesoft.pat.patInt); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, com.stevesoft.pat.patInf, []); +this.inf = true; +}); +}); diff --git a/bin/com/stevesoft/pat/patInt.js b/bin/com/stevesoft/pat/patInt.js index b7226f7..2d65e56 100644 --- a/bin/com/stevesoft/pat/patInt.js +++ b/bin/com/stevesoft/pat/patInt.js @@ -1,94 +1,94 @@ -Clazz.declarePackage ("com.stevesoft.pat"); -c$ = Clazz.decorateAsClass (function () { -this.i = 0; -this.inf = false; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat, "patInt"); -Clazz.makeConstructor (c$, -function () { -this.i = 0; -this.inf = false; -}); -Clazz.makeConstructor (c$, -function (init) { -this.i = init; -this.inf = false; -}, "~N"); -Clazz.makeConstructor (c$, -function (p) { -this.i = p.i; -this.inf = p.inf; -}, "com.stevesoft.pat.patInt"); -Clazz.defineMethod (c$, "setInf", -function (b) { -this.inf = b; -if (b) { -this.i = 2147483647; -}}, "~B"); -Clazz.defineMethod (c$, "inc", -function () { -if (!this.inf) { -this.i++; -}}); -Clazz.defineMethod (c$, "dec", -function () { -if (!this.inf) { -this.i--; -}}); -Clazz.defineMethod (c$, "lessEq", -function (j) { -return !this.inf && (j.inf || this.i <= j.i); -}, "com.stevesoft.pat.patInt"); -Clazz.defineMethod (c$, "equals", -function (j) { -return !j.inf && !this.inf && this.i == j.i; -}, "com.stevesoft.pat.patInt"); -Clazz.overrideMethod (c$, "toString", -function () { -if (this.inf) { -return ""; -} else { -return "" + this.i; -}}); -Clazz.defineMethod (c$, "pluseq", -function (p) { -if (this.inf || p.inf) { -this.setInf (true); -} else { -this.i += p.i; -}return this; -}, "com.stevesoft.pat.patInt"); -Clazz.defineMethod (c$, "mul", -function (p) { -if (this.inf || p.inf) { -return new com.stevesoft.pat.patInf (); -}return new com.stevesoft.pat.patInt (this.i * p.i); -}, "com.stevesoft.pat.patInt"); -Clazz.defineMethod (c$, "mineq", -function (p) { -if (p.inf) { -return this; -}if (this.inf) { -this.i = p.i; -} else if (p.i < this.i) { -this.i = p.i; -}this.setInf (false); -return this; -}, "com.stevesoft.pat.patInt"); -Clazz.defineMethod (c$, "maxeq", -function (p) { -if (this.inf || p.inf) { -this.setInf (true); -return this; -}if (p.i > this.i) { -this.i = p.i; -}return this; -}, "com.stevesoft.pat.patInt"); -Clazz.defineMethod (c$, "finite", -function () { -return !this.inf; -}); -Clazz.defineMethod (c$, "intValue", -function () { -return this.inf ? 2147483647 : this.i; -}); +Clazz.declarePackage ("com.stevesoft.pat"); +c$ = Clazz.decorateAsClass (function () { +this.i = 0; +this.inf = false; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat, "patInt"); +Clazz.makeConstructor (c$, +function () { +this.i = 0; +this.inf = false; +}); +Clazz.makeConstructor (c$, +function (init) { +this.i = init; +this.inf = false; +}, "~N"); +Clazz.makeConstructor (c$, +function (p) { +this.i = p.i; +this.inf = p.inf; +}, "com.stevesoft.pat.patInt"); +Clazz.defineMethod (c$, "setInf", +function (b) { +this.inf = b; +if (b) { +this.i = 2147483647; +}}, "~B"); +Clazz.defineMethod (c$, "inc", +function () { +if (!this.inf) { +this.i++; +}}); +Clazz.defineMethod (c$, "dec", +function () { +if (!this.inf) { +this.i--; +}}); +Clazz.defineMethod (c$, "lessEq", +function (j) { +return !this.inf && (j.inf || this.i <= j.i); +}, "com.stevesoft.pat.patInt"); +Clazz.defineMethod (c$, "equals", +function (j) { +return !j.inf && !this.inf && this.i == j.i; +}, "com.stevesoft.pat.patInt"); +Clazz.overrideMethod (c$, "toString", +function () { +if (this.inf) { +return ""; +} else { +return "" + this.i; +}}); +Clazz.defineMethod (c$, "pluseq", +function (p) { +if (this.inf || p.inf) { +this.setInf (true); +} else { +this.i += p.i; +}return this; +}, "com.stevesoft.pat.patInt"); +Clazz.defineMethod (c$, "mul", +function (p) { +if (this.inf || p.inf) { +return new com.stevesoft.pat.patInf (); +}return new com.stevesoft.pat.patInt (this.i * p.i); +}, "com.stevesoft.pat.patInt"); +Clazz.defineMethod (c$, "mineq", +function (p) { +if (p.inf) { +return this; +}if (this.inf) { +this.i = p.i; +} else if (p.i < this.i) { +this.i = p.i; +}this.setInf (false); +return this; +}, "com.stevesoft.pat.patInt"); +Clazz.defineMethod (c$, "maxeq", +function (p) { +if (this.inf || p.inf) { +this.setInf (true); +return this; +}if (p.i > this.i) { +this.i = p.i; +}return this; +}, "com.stevesoft.pat.patInt"); +Clazz.defineMethod (c$, "finite", +function () { +return !this.inf; +}); +Clazz.defineMethod (c$, "intValue", +function () { +return this.inf ? 2147483647 : this.i; +}); diff --git a/bin/com/stevesoft/pat/wrap/CharArrayBufferWrap.js b/bin/com/stevesoft/pat/wrap/CharArrayBufferWrap.js index ce61261..cfade25 100644 --- a/bin/com/stevesoft/pat/wrap/CharArrayBufferWrap.js +++ b/bin/com/stevesoft/pat/wrap/CharArrayBufferWrap.js @@ -1,38 +1,38 @@ -Clazz.declarePackage ("com.stevesoft.pat.wrap"); -Clazz.load (["com.stevesoft.pat.BasicStringBufferLike", "java.lang.StringBuffer"], "com.stevesoft.pat.wrap.CharArrayBufferWrap", ["com.stevesoft.pat.wrap.CharArrayWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sb = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat.wrap, "CharArrayBufferWrap", null, com.stevesoft.pat.BasicStringBufferLike); -Clazz.prepareFields (c$, function () { -this.sb = new StringBuffer (); -}); -Clazz.overrideMethod (c$, "appendC", -function (c) { -this.sb.append (c); -}, "~S"); -Clazz.overrideMethod (c$, "append", -function (s) { -this.sb.append (s); -}, "~S"); -Clazz.overrideMethod (c$, "toStringLike", -function () { -var ca = Clazz.newCharArray (this.sb.length (), '\0'); -for (var i = 0; i < ca.length; i++) { -ca[i] = this.sb.charAt (i); -} -return new com.stevesoft.pat.wrap.CharArrayWrap (ca); -}); -Clazz.defineMethod (c$, "length", -function () { -return this.sb.length (); -}); -Clazz.overrideMethod (c$, "toString", -function () { -return this.sb.toString (); -}); -Clazz.overrideMethod (c$, "unwrap", -function () { -return this.sb; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat.wrap"); +Clazz.load (["com.stevesoft.pat.BasicStringBufferLike", "java.lang.StringBuffer"], "com.stevesoft.pat.wrap.CharArrayBufferWrap", ["com.stevesoft.pat.wrap.CharArrayWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sb = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat.wrap, "CharArrayBufferWrap", null, com.stevesoft.pat.BasicStringBufferLike); +Clazz.prepareFields (c$, function () { +this.sb = new StringBuffer (); +}); +Clazz.overrideMethod (c$, "appendC", +function (c) { +this.sb.append (c); +}, "~S"); +Clazz.overrideMethod (c$, "append", +function (s) { +this.sb.append (s); +}, "~S"); +Clazz.overrideMethod (c$, "toStringLike", +function () { +var ca = Clazz.newCharArray (this.sb.length (), '\0'); +for (var i = 0; i < ca.length; i++) { +ca[i] = this.sb.charAt (i); +} +return new com.stevesoft.pat.wrap.CharArrayWrap (ca); +}); +Clazz.defineMethod (c$, "length", +function () { +return this.sb.length (); +}); +Clazz.overrideMethod (c$, "toString", +function () { +return this.sb.toString (); +}); +Clazz.overrideMethod (c$, "unwrap", +function () { +return this.sb; +}); +}); diff --git a/bin/com/stevesoft/pat/wrap/CharArrayWrap.js b/bin/com/stevesoft/pat/wrap/CharArrayWrap.js index 679bede..374d1dd 100644 --- a/bin/com/stevesoft/pat/wrap/CharArrayWrap.js +++ b/bin/com/stevesoft/pat/wrap/CharArrayWrap.js @@ -1,51 +1,51 @@ -Clazz.declarePackage ("com.stevesoft.pat.wrap"); -Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.wrap.CharArrayWrap", ["com.stevesoft.pat.wrap.CharArrayBufferWrap", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ca = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat.wrap, "CharArrayWrap", null, com.stevesoft.pat.StringLike); -Clazz.defineMethod (c$, "getCharArray", -function () { -return this.ca; -}); -Clazz.makeConstructor (c$, -function (ca) { -this.ca = ca; -}, "~A"); -Clazz.overrideMethod (c$, "toString", -function () { -return String.instantialize (this.ca); -}); -Clazz.overrideMethod (c$, "charAt", -function (i) { -return this.ca[i]; -}, "~N"); -Clazz.overrideMethod (c$, "length", -function () { -return this.ca.length; -}); -Clazz.overrideMethod (c$, "substring", -function (i1, i2) { -var sb = new StringBuffer (); -for (var i = i1; i < i2; i++) { -sb.append (this.ca[i]); -} -return sb.toString (); -}, "~N,~N"); -Clazz.overrideMethod (c$, "unwrap", -function () { -return this.ca; -}); -Clazz.overrideMethod (c$, "newStringBufferLike", -function () { -return new com.stevesoft.pat.wrap.CharArrayBufferWrap (); -}); -Clazz.overrideMethod (c$, "indexOf", -function (c) { -for (var i = 0; i < this.ca.length; i++) { -if (this.ca[i] == c) { -return i; -}} -return -1; -}, "~S"); -}); +Clazz.declarePackage ("com.stevesoft.pat.wrap"); +Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.wrap.CharArrayWrap", ["com.stevesoft.pat.wrap.CharArrayBufferWrap", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ca = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat.wrap, "CharArrayWrap", null, com.stevesoft.pat.StringLike); +Clazz.defineMethod (c$, "getCharArray", +function () { +return this.ca; +}); +Clazz.makeConstructor (c$, +function (ca) { +this.ca = ca; +}, "~A"); +Clazz.overrideMethod (c$, "toString", +function () { +return String.instantialize (this.ca); +}); +Clazz.overrideMethod (c$, "charAt", +function (i) { +return this.ca[i]; +}, "~N"); +Clazz.overrideMethod (c$, "length", +function () { +return this.ca.length; +}); +Clazz.overrideMethod (c$, "substring", +function (i1, i2) { +var sb = new StringBuffer (); +for (var i = i1; i < i2; i++) { +sb.append (this.ca[i]); +} +return sb.toString (); +}, "~N,~N"); +Clazz.overrideMethod (c$, "unwrap", +function () { +return this.ca; +}); +Clazz.overrideMethod (c$, "newStringBufferLike", +function () { +return new com.stevesoft.pat.wrap.CharArrayBufferWrap (); +}); +Clazz.overrideMethod (c$, "indexOf", +function (c) { +for (var i = 0; i < this.ca.length; i++) { +if (this.ca[i] == c) { +return i; +}} +return -1; +}, "~S"); +}); diff --git a/bin/com/stevesoft/pat/wrap/RandomAccessFileWrap.js b/bin/com/stevesoft/pat/wrap/RandomAccessFileWrap.js index 3b115fe..a2b42c5 100644 --- a/bin/com/stevesoft/pat/wrap/RandomAccessFileWrap.js +++ b/bin/com/stevesoft/pat/wrap/RandomAccessFileWrap.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("com.stevesoft.pat.wrap"); -c$ = Clazz.declareType (com.stevesoft.pat.wrap, "RandomAccessFileWrap"); +Clazz.declarePackage ("com.stevesoft.pat.wrap"); +c$ = Clazz.declareType (com.stevesoft.pat.wrap, "RandomAccessFileWrap"); diff --git a/bin/com/stevesoft/pat/wrap/StringBufferWrap.js b/bin/com/stevesoft/pat/wrap/StringBufferWrap.js index ea57230..811c548 100644 --- a/bin/com/stevesoft/pat/wrap/StringBufferWrap.js +++ b/bin/com/stevesoft/pat/wrap/StringBufferWrap.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("com.stevesoft.pat.wrap"); -Clazz.load (["com.stevesoft.pat.BasicStringBufferLike", "java.lang.StringBuffer"], "com.stevesoft.pat.wrap.StringBufferWrap", ["com.stevesoft.pat.wrap.StringWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sb = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat.wrap, "StringBufferWrap", null, com.stevesoft.pat.BasicStringBufferLike); -Clazz.prepareFields (c$, function () { -this.sb = new StringBuffer (); -}); -Clazz.overrideMethod (c$, "appendC", -function (c) { -this.sb.append (c); -}, "~S"); -Clazz.overrideMethod (c$, "append", -function (s) { -this.sb.append (s); -}, "~S"); -Clazz.defineMethod (c$, "length", -function () { -return this.sb.length (); -}); -Clazz.overrideMethod (c$, "toString", -function () { -return this.sb.toString (); -}); -Clazz.overrideMethod (c$, "toStringLike", -function () { -return new com.stevesoft.pat.wrap.StringWrap (this.sb.toString ()); -}); -Clazz.overrideMethod (c$, "unwrap", -function () { -return this.sb; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat.wrap"); +Clazz.load (["com.stevesoft.pat.BasicStringBufferLike", "java.lang.StringBuffer"], "com.stevesoft.pat.wrap.StringBufferWrap", ["com.stevesoft.pat.wrap.StringWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sb = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat.wrap, "StringBufferWrap", null, com.stevesoft.pat.BasicStringBufferLike); +Clazz.prepareFields (c$, function () { +this.sb = new StringBuffer (); +}); +Clazz.overrideMethod (c$, "appendC", +function (c) { +this.sb.append (c); +}, "~S"); +Clazz.overrideMethod (c$, "append", +function (s) { +this.sb.append (s); +}, "~S"); +Clazz.defineMethod (c$, "length", +function () { +return this.sb.length (); +}); +Clazz.overrideMethod (c$, "toString", +function () { +return this.sb.toString (); +}); +Clazz.overrideMethod (c$, "toStringLike", +function () { +return new com.stevesoft.pat.wrap.StringWrap (this.sb.toString ()); +}); +Clazz.overrideMethod (c$, "unwrap", +function () { +return this.sb; +}); +}); diff --git a/bin/com/stevesoft/pat/wrap/StringWrap.js b/bin/com/stevesoft/pat/wrap/StringWrap.js index a468b0d..d8e9dfe 100644 --- a/bin/com/stevesoft/pat/wrap/StringWrap.js +++ b/bin/com/stevesoft/pat/wrap/StringWrap.js @@ -1,39 +1,39 @@ -Clazz.declarePackage ("com.stevesoft.pat.wrap"); -Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.wrap.StringWrap", ["com.stevesoft.pat.wrap.StringBufferWrap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.s = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat.wrap, "StringWrap", null, com.stevesoft.pat.StringLike); -Clazz.makeConstructor (c$, -function (s) { -this.s = s; -}, "~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.s; -}); -Clazz.overrideMethod (c$, "charAt", -function (i) { -return this.s.charAt (i); -}, "~N"); -Clazz.overrideMethod (c$, "length", -function () { -return this.s.length; -}); -Clazz.overrideMethod (c$, "substring", -function (i1, i2) { -return this.s.substring (i1, i2); -}, "~N,~N"); -Clazz.overrideMethod (c$, "unwrap", -function () { -return this.s; -}); -Clazz.overrideMethod (c$, "newStringBufferLike", -function () { -return new com.stevesoft.pat.wrap.StringBufferWrap (); -}); -Clazz.overrideMethod (c$, "indexOf", -function (c) { -return this.s.indexOf (c); -}, "~S"); -}); +Clazz.declarePackage ("com.stevesoft.pat.wrap"); +Clazz.load (["com.stevesoft.pat.StringLike"], "com.stevesoft.pat.wrap.StringWrap", ["com.stevesoft.pat.wrap.StringBufferWrap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.s = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat.wrap, "StringWrap", null, com.stevesoft.pat.StringLike); +Clazz.makeConstructor (c$, +function (s) { +this.s = s; +}, "~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.s; +}); +Clazz.overrideMethod (c$, "charAt", +function (i) { +return this.s.charAt (i); +}, "~N"); +Clazz.overrideMethod (c$, "length", +function () { +return this.s.length; +}); +Clazz.overrideMethod (c$, "substring", +function (i1, i2) { +return this.s.substring (i1, i2); +}, "~N,~N"); +Clazz.overrideMethod (c$, "unwrap", +function () { +return this.s; +}); +Clazz.overrideMethod (c$, "newStringBufferLike", +function () { +return new com.stevesoft.pat.wrap.StringBufferWrap (); +}); +Clazz.overrideMethod (c$, "indexOf", +function (c) { +return this.s.indexOf (c); +}, "~S"); +}); diff --git a/bin/com/stevesoft/pat/wrap/WriterWrap.js b/bin/com/stevesoft/pat/wrap/WriterWrap.js index 9eff73c..4c80649 100644 --- a/bin/com/stevesoft/pat/wrap/WriterWrap.js +++ b/bin/com/stevesoft/pat/wrap/WriterWrap.js @@ -1,41 +1,41 @@ -Clazz.declarePackage ("com.stevesoft.pat.wrap"); -Clazz.load (["com.stevesoft.pat.BasicStringBufferLike"], "com.stevesoft.pat.wrap.WriterWrap", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.w = null; -Clazz.instantialize (this, arguments); -}, com.stevesoft.pat.wrap, "WriterWrap", null, com.stevesoft.pat.BasicStringBufferLike); -Clazz.makeConstructor (c$, -function (w) { -this.w = w; -}, "java.io.Writer"); -Clazz.overrideMethod (c$, "appendC", -function (c) { -try { -this.w.write ((c).charCodeAt (0)); -} catch (ioe) { -if (Clazz.exceptionOf (ioe, java.io.IOException)) { -} else { -throw ioe; -} -} -}, "~S"); -Clazz.overrideMethod (c$, "append", -function (s) { -try { -this.w.write (s); -} catch (ioe) { -if (Clazz.exceptionOf (ioe, java.io.IOException)) { -} else { -throw ioe; -} -} -}, "~S"); -Clazz.overrideMethod (c$, "toStringLike", -function () { -return null; -}); -Clazz.overrideMethod (c$, "unwrap", -function () { -return this.w; -}); -}); +Clazz.declarePackage ("com.stevesoft.pat.wrap"); +Clazz.load (["com.stevesoft.pat.BasicStringBufferLike"], "com.stevesoft.pat.wrap.WriterWrap", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.w = null; +Clazz.instantialize (this, arguments); +}, com.stevesoft.pat.wrap, "WriterWrap", null, com.stevesoft.pat.BasicStringBufferLike); +Clazz.makeConstructor (c$, +function (w) { +this.w = w; +}, "java.io.Writer"); +Clazz.overrideMethod (c$, "appendC", +function (c) { +try { +this.w.write ((c).charCodeAt (0)); +} catch (ioe) { +if (Clazz.exceptionOf (ioe, java.io.IOException)) { +} else { +throw ioe; +} +} +}, "~S"); +Clazz.overrideMethod (c$, "append", +function (s) { +try { +this.w.write (s); +} catch (ioe) { +if (Clazz.exceptionOf (ioe, java.io.IOException)) { +} else { +throw ioe; +} +} +}, "~S"); +Clazz.overrideMethod (c$, "toStringLike", +function () { +return null; +}); +Clazz.overrideMethod (c$, "unwrap", +function () { +return this.w; +}); +}); diff --git a/bin/fr/orsay/lri/varna/models/rna/RNA.js b/bin/fr/orsay/lri/varna/models/rna/RNA.js index c762cf3..18df75b 100644 --- a/bin/fr/orsay/lri/varna/models/rna/RNA.js +++ b/bin/fr/orsay/lri/varna/models/rna/RNA.js @@ -1,10 +1,10 @@ -Clazz.declarePackage ("fr.orsay.lri.varna.models.rna"); -c$ = Clazz.declareType (fr.orsay.lri.varna.models.rna, "RNA"); -Clazz.defineMethod (c$, "getSize", -function () { -return 0; -}); -Clazz.defineMethod (c$, "getStructDBN", -function (b) { -return null; -}, "~B"); +Clazz.declarePackage ("fr.orsay.lri.varna.models.rna"); +c$ = Clazz.declareType (fr.orsay.lri.varna.models.rna, "RNA"); +Clazz.defineMethod (c$, "getSize", +function () { +return 0; +}); +Clazz.defineMethod (c$, "getStructDBN", +function (b) { +return null; +}, "~B"); diff --git a/bin/jalview/analysis/AAFrequency.js b/bin/jalview/analysis/AAFrequency.js index a7a69d1..8e3d4c5 100644 --- a/bin/jalview/analysis/AAFrequency.js +++ b/bin/jalview/analysis/AAFrequency.js @@ -1,308 +1,308 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.AAFrequency", ["jalview.analysis.CodingUtils", "jalview.datamodel.Annotation", "jalview.util.Format", "$.MappingUtils", "$.QuickSort", "java.lang.Float", "$.StringBuilder", "java.util.Arrays", "$.Hashtable"], function () { -c$ = Clazz.declareType (jalview.analysis, "AAFrequency"); -c$.calculate = Clazz.defineMethod (c$, "calculate", -function (list, start, end) { -return jalview.analysis.AAFrequency.calculate (list, start, end, false); -}, "java.util.List,~N,~N"); -c$.calculate = Clazz.defineMethod (c$, "calculate", -function (sequences, start, end, profile) { -var seqs = new Array (sequences.size ()); -var width = 0; -{ -for (var i = 0; i < sequences.size (); i++) { -seqs[i] = sequences.get (i); -if (seqs[i].getLength () > width) { -width = seqs[i].getLength (); -}} -var reply = new Array (width); -if (end >= width) { -end = width; -}jalview.analysis.AAFrequency.calculate (seqs, start, end, reply, profile); -return reply; -}}, "java.util.List,~N,~N,~B"); -c$.calculate = Clazz.defineMethod (c$, "calculate", -function (sequences, start, end, result, profile) { -var residueHash; -var maxCount; -var nongap; -var i; -var j; -var v; -var jSize = sequences.length; -var maxResidue; -var c = '-'; -var percentage; -var values = Clazz.newIntArray (255, 0); -var seq; -for (i = start; i < end; i++) { -residueHash = new java.util.Hashtable (); -maxCount = 0; -maxResidue = ""; -nongap = 0; -values = Clazz.newIntArray (255, 0); -for (j = 0; j < jSize; j++) { -if (sequences[j] == null) { -System.err.println ("WARNING: Consensus skipping null sequence - possible race condition."); -continue; -}seq = sequences[j].getSequence (); -if (seq.length > i) { -c = seq[i]; -if (c == '.' || c == ' ') { -c = '-'; -}if (c == '-') { -values['-'.charCodeAt (0)]++; -continue; -} else if ('a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) + -32); -}nongap++; -values[c.charCodeAt (0)]++; -} else { -values['-'.charCodeAt (0)]++; -}} -if (jSize == 1) { -maxResidue = String.valueOf (c); -maxCount = 1; -} else { -for (v = 65; v <= 90; v++) { -if (values[v] < 1 || values[v] < maxCount) { -continue; -}if (values[v] > maxCount) { -maxResidue = jalview.analysis.AAFrequency.CHARS[v - 65]; -} else if (values[v] == maxCount) { -maxResidue += jalview.analysis.AAFrequency.CHARS[v - 65]; -}maxCount = values[v]; -} -}if (maxResidue.length == 0) { -maxResidue = "-"; -}if (profile) { -residueHash.put ("P", Clazz.newArray (-1, [values, Clazz.newIntArray (-1, [jSize, nongap])])); -}residueHash.put ("C", new Integer (maxCount)); -residueHash.put ("R", maxResidue); -percentage = (maxCount * 100) / jSize; -residueHash.put ("G", new Float (percentage)); -if (nongap > 0) { -percentage = (maxCount * 100) / nongap; -}residueHash.put ("N", new Float (percentage)); -result[i] = residueHash; -} -}, "~A,~N,~N,~A,~B"); -c$.completeConsensus = Clazz.defineMethod (c$, "completeConsensus", -function (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, nseq) { -jalview.analysis.AAFrequency.completeConsensus (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, null, nseq); -}, "jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~B,~B,~N"); -c$.completeConsensus = Clazz.defineMethod (c$, "completeConsensus", -function (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, alphabet, nseq) { -if (consensus == null || consensus.annotations == null || consensus.annotations.length < width) { -return; -}var fmt = jalview.analysis.AAFrequency.getPercentageFormat (nseq); -for (var i = iStart; i < width; i++) { -var hci; -if (i >= hconsensus.length || ((hci = hconsensus[i]) == null)) { -consensus.annotations[i] = null; -continue; -}var fv = hci.get (ignoreGapsInConsensusCalculation ? "N" : "G"); -if (fv == null) { -consensus.annotations[i] = null; -continue; -}var value = fv.floatValue (); -var maxRes = hci.get ("R").toString (); -var mouseOver = new StringBuilder (64); -if (maxRes.length > 1) { -mouseOver.append ("[").append (maxRes).append ("] "); -maxRes = "+"; -} else { -mouseOver.append (hci.get ("R") + " "); -}var profile = hci.get ("P"); -if (profile != null && includeAllConsSymbols) { -var sequenceCount = profile[1][0]; -var nonGappedCount = profile[1][1]; -var normalisedBy = ignoreGapsInConsensusCalculation ? nonGappedCount : sequenceCount; -mouseOver.setLength (0); -if (alphabet != null) { -for (var c = 0; c < alphabet.length; c++) { -var tval = profile[0][alphabet[c].charCodeAt (0)] * 100 / normalisedBy; -mouseOver.append (((c == 0) ? "" : "; ")).append (alphabet[c]).append (" ").append (((fmt != null) ? fmt.formDouble (tval) : (Clazz.floatToInt (tval)))).append ("%"); -} -} else { -var ca = Clazz.newCharArray (profile[0].length, '\0'); -var vl = Clazz.newFloatArray (profile[0].length, 0); -for (var c = 0; c < ca.length; c++) { -ca[c] = String.fromCharCode (c); -vl[c] = profile[0][c]; -} -jalview.util.QuickSort.sortFloatChar (vl, ca); -for (var p = 0, c = ca.length - 1; profile[0][ca[c].charCodeAt (0)] > 0; c--) { -var residue = ca[c]; -if (residue != '-') { -var tval = profile[0][residue.charCodeAt (0)] * 100 / normalisedBy; -mouseOver.append ((((p == 0) ? "" : "; "))).append (residue).append (" ").append (((fmt != null) ? fmt.formDouble (tval) : (Clazz.floatToInt (tval)))).append ("%"); -p++; -}} -}} else { -mouseOver.append ((((fmt != null) ? fmt.formDouble (value) : (Clazz.floatToInt (value))))).append ("%"); -}consensus.annotations[i] = new jalview.datamodel.Annotation (maxRes, mouseOver.toString (), ' ', value); -} -}, "jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~B,~B,~A,~N"); -c$.getPercentageFormat = Clazz.defineMethod (c$, "getPercentageFormat", -function (nseq) { -var scale = 0; -while (nseq >= 10) { -scale++; -nseq /= 10; -} -return scale <= 1 ? null : new jalview.util.Format ("%3." + (scale - 1) + "f"); -}, "~N"); -c$.extractProfile = Clazz.defineMethod (c$, "extractProfile", -function (hconsensus, ignoreGaps) { -var rtnval = Clazz.newIntArray (64, 0); -var profile = hconsensus.get ("P"); -if (profile == null) { -return null; -}var ca = Clazz.newCharArray (profile[0].length, '\0'); -var vl = Clazz.newFloatArray (profile[0].length, 0); -for (var c = 0; c < ca.length; c++) { -ca[c] = String.fromCharCode (c); -vl[c] = profile[0][c]; -} -jalview.util.QuickSort.sortFloatChar (vl, ca); -var nextArrayPos = 2; -var totalPercentage = 0; -var distinctValuesCount = 0; -var divisor = profile[1][ignoreGaps ? 1 : 0]; -for (var c = ca.length - 1; profile[0][ca[c].charCodeAt (0)] > 0; c--) { -if (ca[c] != '-') { -rtnval[nextArrayPos++] = (ca[c]).charCodeAt (0); -var percentage = Clazz.floatToInt (profile[0][ca[c].charCodeAt (0)] * 100 / divisor); -rtnval[nextArrayPos++] = percentage; -totalPercentage += percentage; -distinctValuesCount++; -}} -rtnval[0] = distinctValuesCount; -rtnval[1] = totalPercentage; -var result = Clazz.newIntArray (rtnval.length + 1, 0); -result[0] = 0; -System.arraycopy (rtnval, 0, result, 1, rtnval.length); -return result; -}, "java.util.Hashtable,~B"); -c$.extractCdnaProfile = Clazz.defineMethod (c$, "extractCdnaProfile", -function (hashtable, ignoreGaps) { -var codonCounts = hashtable.get ("P"); -var sortedCounts = Clazz.newIntArray (codonCounts.length - 2, 0); -System.arraycopy (codonCounts, 2, sortedCounts, 0, codonCounts.length - 2); -var result = Clazz.newIntArray (3 + 2 * sortedCounts.length, 0); -result[0] = 2; -var codons = Clazz.newCharArray (sortedCounts.length, '\0'); -for (var i = 0; i < codons.length; i++) { -codons[i] = String.fromCharCode (i); -} -jalview.util.QuickSort.sortIntChar (sortedCounts, codons); -var totalPercentage = 0; -var distinctValuesCount = 0; -var j = 3; -var divisor = ignoreGaps ? codonCounts[1] : codonCounts[0]; -for (var i = codons.length - 1; i >= 0; i--) { -var codonCount = sortedCounts[i]; -if (codonCount == 0) { -break; -}distinctValuesCount++; -result[j++] = (codons[i]).charCodeAt (0); -var percentage = Clazz.doubleToInt (codonCount * 100 / divisor); -result[j++] = percentage; -totalPercentage += percentage; -} -result[2] = totalPercentage; -result[1] = distinctValuesCount; -return java.util.Arrays.copyOfRange (result, 0, j); -}, "java.util.Hashtable,~B"); -c$.calculateCdna = Clazz.defineMethod (c$, "calculateCdna", -function (alignment, mappings, hconsensus, col0, col1) { -var gapCharacter = alignment.getGapCharacter (); -for (var col = col0; col < col1; col++) { -var columnHash = new java.util.Hashtable (); -var codonCounts = Clazz.newIntArray (66, 0); -codonCounts[0] = alignment.getSequences ().size (); -var ungappedCount = 0; -for (var seq, $seq = alignment.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -if (seq.getCharAt (col) == gapCharacter) { -continue; -}var codon = jalview.util.MappingUtils.findCodonFor (seq, col, mappings); -var codonEncoded = jalview.analysis.CodingUtils.encodeCodon (codon); -if (codonEncoded >= 0) { -codonCounts[codonEncoded + 2]++; -ungappedCount++; -}} -codonCounts[1] = ungappedCount; -columnHash.put ("P", codonCounts); -hconsensus[col] = columnHash; -} -}, "jalview.datamodel.AlignmentI,java.util.Set,~A,~N,~N"); -c$.completeCdnaConsensus = Clazz.defineMethod (c$, "completeCdnaConsensus", -function (consensusAnnotation, consensusData, showProfileLogo, nseqs) { -if (consensusAnnotation == null || consensusAnnotation.annotations == null || consensusAnnotation.annotations.length < consensusData.length) { -return; -}consensusAnnotation.scaleColLabel = true; -for (var col = 0; col < consensusData.length; col++) { -var hci = consensusData[col]; -if (hci == null) { -continue; -}var codonCounts = hci.get ("P"); -var totalCount = 0; -var codons = Clazz.newCharArray (codonCounts.length - 2, '\0'); -for (var j = 2; j < codonCounts.length; j++) { -var codonCount = codonCounts[j]; -codons[j - 2] = String.fromCharCode (j - 2); -totalCount += codonCount; -} -var sortedCodonCounts = Clazz.newIntArray (codonCounts.length - 2, 0); -System.arraycopy (codonCounts, 2, sortedCodonCounts, 0, codonCounts.length - 2); -jalview.util.QuickSort.sortIntChar (sortedCodonCounts, codons); -var modalCodonEncoded = (codons[codons.length - 1]).charCodeAt (0); -var modalCodonCount = sortedCodonCounts[codons.length - 1]; -var modalCodon = String.valueOf (jalview.analysis.CodingUtils.decodeCodon (modalCodonEncoded)); -if (sortedCodonCounts.length > 1 && sortedCodonCounts[codons.length - 2] == modalCodonEncoded) { -modalCodon = "+"; -}var pid = sortedCodonCounts[sortedCodonCounts.length - 1] * 100 / totalCount; -var mouseOver = new StringBuilder (32); -var samePercent = new StringBuilder (); -var percent = null; -var lastPercent = null; -var fmt = jalview.analysis.AAFrequency.getPercentageFormat (nseqs); -for (var j = codons.length - 1; j >= 0; j--) { -var codonCount = sortedCodonCounts[j]; -if (codonCount == 0) { -if (samePercent.length () > 0) { -mouseOver.append (samePercent).append (": ").append (percent).append ("% "); -}break; -}var codonEncoded = (codons[j]).charCodeAt (0); -var pct = Clazz.doubleToInt (codonCount * 100 / totalCount); -var codon = String.valueOf (jalview.analysis.CodingUtils.decodeCodon (codonEncoded)); -percent = fmt == null ? Integer.toString (pct) : fmt.formLong (pct); -if (showProfileLogo || codonCount == modalCodonCount) { -if (percent.equals (lastPercent) && j > 0) { -samePercent.append (samePercent.length () == 0 ? "" : ", "); -samePercent.append (codon); -} else { -if (samePercent.length () > 0) { -mouseOver.append (samePercent).append (": ").append (lastPercent).append ("% "); -}samePercent.setLength (0); -samePercent.append (codon); -}lastPercent = percent; -}} -consensusAnnotation.annotations[col] = new jalview.datamodel.Annotation (modalCodon, mouseOver.toString (), ' ', pid); -} -}, "jalview.datamodel.AlignmentAnnotation,~A,~B,~N"); -Clazz.defineStatics (c$, -"TO_UPPER_CASE", -32, -"MAXCOUNT", "C", -"MAXRESIDUE", "R", -"PID_GAPS", "G", -"PID_NOGAPS", "N", -"PROFILE", "P", -"ENCODED_CHARS", "E"); -c$.CHARS = c$.prototype.CHARS = new Array (26); -{ -for (var c = 'A'; c <= 'Z'; c = String.fromCharCode (c.charCodeAt (0) + 1)) { -jalview.analysis.AAFrequency.CHARS[c.charCodeAt (0) - 65] = String.valueOf (c); -} -}}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.AAFrequency", ["jalview.analysis.CodingUtils", "jalview.datamodel.Annotation", "jalview.util.Format", "$.MappingUtils", "$.QuickSort", "java.lang.Float", "$.StringBuilder", "java.util.Arrays", "$.Hashtable"], function () { +c$ = Clazz.declareType (jalview.analysis, "AAFrequency"); +c$.calculate = Clazz.defineMethod (c$, "calculate", +function (list, start, end) { +return jalview.analysis.AAFrequency.calculate (list, start, end, false); +}, "java.util.List,~N,~N"); +c$.calculate = Clazz.defineMethod (c$, "calculate", +function (sequences, start, end, profile) { +var seqs = new Array (sequences.size ()); +var width = 0; +{ +for (var i = 0; i < sequences.size (); i++) { +seqs[i] = sequences.get (i); +if (seqs[i].getLength () > width) { +width = seqs[i].getLength (); +}} +var reply = new Array (width); +if (end >= width) { +end = width; +}jalview.analysis.AAFrequency.calculate (seqs, start, end, reply, profile); +return reply; +}}, "java.util.List,~N,~N,~B"); +c$.calculate = Clazz.defineMethod (c$, "calculate", +function (sequences, start, end, result, profile) { +var residueHash; +var maxCount; +var nongap; +var i; +var j; +var v; +var jSize = sequences.length; +var maxResidue; +var c = '-'; +var percentage; +var values = Clazz.newIntArray (255, 0); +var seq; +for (i = start; i < end; i++) { +residueHash = new java.util.Hashtable (); +maxCount = 0; +maxResidue = ""; +nongap = 0; +values = Clazz.newIntArray (255, 0); +for (j = 0; j < jSize; j++) { +if (sequences[j] == null) { +System.err.println ("WARNING: Consensus skipping null sequence - possible race condition."); +continue; +}seq = sequences[j].getSequence (); +if (seq.length > i) { +c = seq[i]; +if (c == '.' || c == ' ') { +c = '-'; +}if (c == '-') { +values['-'.charCodeAt (0)]++; +continue; +} else if ('a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) + -32); +}nongap++; +values[c.charCodeAt (0)]++; +} else { +values['-'.charCodeAt (0)]++; +}} +if (jSize == 1) { +maxResidue = String.valueOf (c); +maxCount = 1; +} else { +for (v = 65; v <= 90; v++) { +if (values[v] < 1 || values[v] < maxCount) { +continue; +}if (values[v] > maxCount) { +maxResidue = jalview.analysis.AAFrequency.CHARS[v - 65]; +} else if (values[v] == maxCount) { +maxResidue += jalview.analysis.AAFrequency.CHARS[v - 65]; +}maxCount = values[v]; +} +}if (maxResidue.length == 0) { +maxResidue = "-"; +}if (profile) { +residueHash.put ("P", Clazz.newArray (-1, [values, Clazz.newIntArray (-1, [jSize, nongap])])); +}residueHash.put ("C", new Integer (maxCount)); +residueHash.put ("R", maxResidue); +percentage = (maxCount * 100) / jSize; +residueHash.put ("G", new Float (percentage)); +if (nongap > 0) { +percentage = (maxCount * 100) / nongap; +}residueHash.put ("N", new Float (percentage)); +result[i] = residueHash; +} +}, "~A,~N,~N,~A,~B"); +c$.completeConsensus = Clazz.defineMethod (c$, "completeConsensus", +function (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, nseq) { +jalview.analysis.AAFrequency.completeConsensus (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, null, nseq); +}, "jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~B,~B,~N"); +c$.completeConsensus = Clazz.defineMethod (c$, "completeConsensus", +function (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, alphabet, nseq) { +if (consensus == null || consensus.annotations == null || consensus.annotations.length < width) { +return; +}var fmt = jalview.analysis.AAFrequency.getPercentageFormat (nseq); +for (var i = iStart; i < width; i++) { +var hci; +if (i >= hconsensus.length || ((hci = hconsensus[i]) == null)) { +consensus.annotations[i] = null; +continue; +}var fv = hci.get (ignoreGapsInConsensusCalculation ? "N" : "G"); +if (fv == null) { +consensus.annotations[i] = null; +continue; +}var value = fv.floatValue (); +var maxRes = hci.get ("R").toString (); +var mouseOver = new StringBuilder (64); +if (maxRes.length > 1) { +mouseOver.append ("[").append (maxRes).append ("] "); +maxRes = "+"; +} else { +mouseOver.append (hci.get ("R") + " "); +}var profile = hci.get ("P"); +if (profile != null && includeAllConsSymbols) { +var sequenceCount = profile[1][0]; +var nonGappedCount = profile[1][1]; +var normalisedBy = ignoreGapsInConsensusCalculation ? nonGappedCount : sequenceCount; +mouseOver.setLength (0); +if (alphabet != null) { +for (var c = 0; c < alphabet.length; c++) { +var tval = profile[0][alphabet[c].charCodeAt (0)] * 100 / normalisedBy; +mouseOver.append (((c == 0) ? "" : "; ")).append (alphabet[c]).append (" ").append (((fmt != null) ? fmt.formDouble (tval) : (Clazz.floatToInt (tval)))).append ("%"); +} +} else { +var ca = Clazz.newCharArray (profile[0].length, '\0'); +var vl = Clazz.newFloatArray (profile[0].length, 0); +for (var c = 0; c < ca.length; c++) { +ca[c] = String.fromCharCode (c); +vl[c] = profile[0][c]; +} +jalview.util.QuickSort.sortFloatChar (vl, ca); +for (var p = 0, c = ca.length - 1; profile[0][ca[c].charCodeAt (0)] > 0; c--) { +var residue = ca[c]; +if (residue != '-') { +var tval = profile[0][residue.charCodeAt (0)] * 100 / normalisedBy; +mouseOver.append ((((p == 0) ? "" : "; "))).append (residue).append (" ").append (((fmt != null) ? fmt.formDouble (tval) : (Clazz.floatToInt (tval)))).append ("%"); +p++; +}} +}} else { +mouseOver.append ((((fmt != null) ? fmt.formDouble (value) : (Clazz.floatToInt (value))))).append ("%"); +}consensus.annotations[i] = new jalview.datamodel.Annotation (maxRes, mouseOver.toString (), ' ', value); +} +}, "jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~B,~B,~A,~N"); +c$.getPercentageFormat = Clazz.defineMethod (c$, "getPercentageFormat", +function (nseq) { +var scale = 0; +while (nseq >= 10) { +scale++; +nseq /= 10; +} +return scale <= 1 ? null : new jalview.util.Format ("%3." + (scale - 1) + "f"); +}, "~N"); +c$.extractProfile = Clazz.defineMethod (c$, "extractProfile", +function (hconsensus, ignoreGaps) { +var rtnval = Clazz.newIntArray (64, 0); +var profile = hconsensus.get ("P"); +if (profile == null) { +return null; +}var ca = Clazz.newCharArray (profile[0].length, '\0'); +var vl = Clazz.newFloatArray (profile[0].length, 0); +for (var c = 0; c < ca.length; c++) { +ca[c] = String.fromCharCode (c); +vl[c] = profile[0][c]; +} +jalview.util.QuickSort.sortFloatChar (vl, ca); +var nextArrayPos = 2; +var totalPercentage = 0; +var distinctValuesCount = 0; +var divisor = profile[1][ignoreGaps ? 1 : 0]; +for (var c = ca.length - 1; profile[0][ca[c].charCodeAt (0)] > 0; c--) { +if (ca[c] != '-') { +rtnval[nextArrayPos++] = (ca[c]).charCodeAt (0); +var percentage = Clazz.floatToInt (profile[0][ca[c].charCodeAt (0)] * 100 / divisor); +rtnval[nextArrayPos++] = percentage; +totalPercentage += percentage; +distinctValuesCount++; +}} +rtnval[0] = distinctValuesCount; +rtnval[1] = totalPercentage; +var result = Clazz.newIntArray (rtnval.length + 1, 0); +result[0] = 0; +System.arraycopy (rtnval, 0, result, 1, rtnval.length); +return result; +}, "java.util.Hashtable,~B"); +c$.extractCdnaProfile = Clazz.defineMethod (c$, "extractCdnaProfile", +function (hashtable, ignoreGaps) { +var codonCounts = hashtable.get ("P"); +var sortedCounts = Clazz.newIntArray (codonCounts.length - 2, 0); +System.arraycopy (codonCounts, 2, sortedCounts, 0, codonCounts.length - 2); +var result = Clazz.newIntArray (3 + 2 * sortedCounts.length, 0); +result[0] = 2; +var codons = Clazz.newCharArray (sortedCounts.length, '\0'); +for (var i = 0; i < codons.length; i++) { +codons[i] = String.fromCharCode (i); +} +jalview.util.QuickSort.sortIntChar (sortedCounts, codons); +var totalPercentage = 0; +var distinctValuesCount = 0; +var j = 3; +var divisor = ignoreGaps ? codonCounts[1] : codonCounts[0]; +for (var i = codons.length - 1; i >= 0; i--) { +var codonCount = sortedCounts[i]; +if (codonCount == 0) { +break; +}distinctValuesCount++; +result[j++] = (codons[i]).charCodeAt (0); +var percentage = Clazz.doubleToInt (codonCount * 100 / divisor); +result[j++] = percentage; +totalPercentage += percentage; +} +result[2] = totalPercentage; +result[1] = distinctValuesCount; +return java.util.Arrays.copyOfRange (result, 0, j); +}, "java.util.Hashtable,~B"); +c$.calculateCdna = Clazz.defineMethod (c$, "calculateCdna", +function (alignment, mappings, hconsensus, col0, col1) { +var gapCharacter = alignment.getGapCharacter (); +for (var col = col0; col < col1; col++) { +var columnHash = new java.util.Hashtable (); +var codonCounts = Clazz.newIntArray (66, 0); +codonCounts[0] = alignment.getSequences ().size (); +var ungappedCount = 0; +for (var seq, $seq = alignment.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +if (seq.getCharAt (col) == gapCharacter) { +continue; +}var codon = jalview.util.MappingUtils.findCodonFor (seq, col, mappings); +var codonEncoded = jalview.analysis.CodingUtils.encodeCodon (codon); +if (codonEncoded >= 0) { +codonCounts[codonEncoded + 2]++; +ungappedCount++; +}} +codonCounts[1] = ungappedCount; +columnHash.put ("P", codonCounts); +hconsensus[col] = columnHash; +} +}, "jalview.datamodel.AlignmentI,java.util.Set,~A,~N,~N"); +c$.completeCdnaConsensus = Clazz.defineMethod (c$, "completeCdnaConsensus", +function (consensusAnnotation, consensusData, showProfileLogo, nseqs) { +if (consensusAnnotation == null || consensusAnnotation.annotations == null || consensusAnnotation.annotations.length < consensusData.length) { +return; +}consensusAnnotation.scaleColLabel = true; +for (var col = 0; col < consensusData.length; col++) { +var hci = consensusData[col]; +if (hci == null) { +continue; +}var codonCounts = hci.get ("P"); +var totalCount = 0; +var codons = Clazz.newCharArray (codonCounts.length - 2, '\0'); +for (var j = 2; j < codonCounts.length; j++) { +var codonCount = codonCounts[j]; +codons[j - 2] = String.fromCharCode (j - 2); +totalCount += codonCount; +} +var sortedCodonCounts = Clazz.newIntArray (codonCounts.length - 2, 0); +System.arraycopy (codonCounts, 2, sortedCodonCounts, 0, codonCounts.length - 2); +jalview.util.QuickSort.sortIntChar (sortedCodonCounts, codons); +var modalCodonEncoded = (codons[codons.length - 1]).charCodeAt (0); +var modalCodonCount = sortedCodonCounts[codons.length - 1]; +var modalCodon = String.valueOf (jalview.analysis.CodingUtils.decodeCodon (modalCodonEncoded)); +if (sortedCodonCounts.length > 1 && sortedCodonCounts[codons.length - 2] == modalCodonEncoded) { +modalCodon = "+"; +}var pid = sortedCodonCounts[sortedCodonCounts.length - 1] * 100 / totalCount; +var mouseOver = new StringBuilder (32); +var samePercent = new StringBuilder (); +var percent = null; +var lastPercent = null; +var fmt = jalview.analysis.AAFrequency.getPercentageFormat (nseqs); +for (var j = codons.length - 1; j >= 0; j--) { +var codonCount = sortedCodonCounts[j]; +if (codonCount == 0) { +if (samePercent.length () > 0) { +mouseOver.append (samePercent).append (": ").append (percent).append ("% "); +}break; +}var codonEncoded = (codons[j]).charCodeAt (0); +var pct = Clazz.doubleToInt (codonCount * 100 / totalCount); +var codon = String.valueOf (jalview.analysis.CodingUtils.decodeCodon (codonEncoded)); +percent = fmt == null ? Integer.toString (pct) : fmt.formLong (pct); +if (showProfileLogo || codonCount == modalCodonCount) { +if (percent.equals (lastPercent) && j > 0) { +samePercent.append (samePercent.length () == 0 ? "" : ", "); +samePercent.append (codon); +} else { +if (samePercent.length () > 0) { +mouseOver.append (samePercent).append (": ").append (lastPercent).append ("% "); +}samePercent.setLength (0); +samePercent.append (codon); +}lastPercent = percent; +}} +consensusAnnotation.annotations[col] = new jalview.datamodel.Annotation (modalCodon, mouseOver.toString (), ' ', pid); +} +}, "jalview.datamodel.AlignmentAnnotation,~A,~B,~N"); +Clazz.defineStatics (c$, +"TO_UPPER_CASE", -32, +"MAXCOUNT", "C", +"MAXRESIDUE", "R", +"PID_GAPS", "G", +"PID_NOGAPS", "N", +"PROFILE", "P", +"ENCODED_CHARS", "E"); +c$.CHARS = c$.prototype.CHARS = new Array (26); +{ +for (var c = 'A'; c <= 'Z'; c = String.fromCharCode (c.charCodeAt (0) + 1)) { +jalview.analysis.AAFrequency.CHARS[c.charCodeAt (0) - 65] = String.valueOf (c); +} +}}); diff --git a/bin/jalview/analysis/AlignSeq.js b/bin/jalview/analysis/AlignSeq.js index 31dcb24..2c3ff10 100644 --- a/bin/jalview/analysis/AlignSeq.js +++ b/bin/jalview/analysis/AlignSeq.js @@ -1,586 +1,586 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["jalview.schemes.ResidueProperties", "java.lang.StringBuffer"], "jalview.analysis.AlignSeq", ["jalview.datamodel.Mapping", "$.Sequence", "jalview.util.Comparison", "$.Format", "$.MapList", "$.MessageManager", "java.awt.Color", "java.lang.Error", "$.StringBuilder", "java.util.ArrayList", "$.Arrays", "$.StringTokenizer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.score = null; -this.E = null; -this.F = null; -this.traceback = null; -this.seq1 = null; -this.seq2 = null; -this.s1 = null; -this.s2 = null; -this.s1str = null; -this.s2str = null; -this.maxi = 0; -this.maxj = 0; -this.aseq1 = null; -this.aseq2 = null; -this.astr1 = ""; -this.astr2 = ""; -this.seq1start = 0; -this.seq1end = 0; -this.seq2start = 0; -this.seq2end = 0; -this.count = 0; -this.maxscore = 0; -this.pid = 0; -this.prev = 0; -this.gapOpen = 120; -this.gapExtend = 20; -this.lookup = null; -this.intToStr = null; -this.defInt = 23; -this.output = null; -this.type = null; -this.charToInt = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "AlignSeq"); -Clazz.prepareFields (c$, function () { -this.lookup = jalview.schemes.ResidueProperties.getBLOSUM62 (); -this.intToStr = jalview.analysis.AlignSeq.pep; -this.output = new StringBuffer (); -}); -Clazz.makeConstructor (c$, -function (s1, s2, type) { -this.SeqInit (s1, s1.getSequenceAsString (), s2, s2.getSequenceAsString (), type); -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S"); -Clazz.makeConstructor (c$, -function (s1, string1, s2, string2, type) { -this.SeqInit (s1, string1.toUpperCase (), s2, string2.toUpperCase (), type); -}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.SequenceI,~S,~S"); -Clazz.defineMethod (c$, "getMaxScore", -function () { -return this.maxscore; -}); -Clazz.defineMethod (c$, "getSeq2Start", -function () { -return this.seq2start; -}); -Clazz.defineMethod (c$, "getSeq2End", -function () { -return this.seq2end; -}); -Clazz.defineMethod (c$, "getSeq1Start", -function () { -return this.seq1start; -}); -Clazz.defineMethod (c$, "getSeq1End", -function () { -return this.seq1end; -}); -Clazz.defineMethod (c$, "getOutput", -function () { -return this.output.toString (); -}); -Clazz.defineMethod (c$, "getAStr1", -function () { -return this.astr1; -}); -Clazz.defineMethod (c$, "getAStr2", -function () { -return this.astr2; -}); -Clazz.defineMethod (c$, "getASeq1", -function () { -return this.aseq1; -}); -Clazz.defineMethod (c$, "getASeq2", -function () { -return this.aseq2; -}); -Clazz.defineMethod (c$, "getS1", -function () { -return this.s1; -}); -Clazz.defineMethod (c$, "getS2", -function () { -return this.s2; -}); -Clazz.defineMethod (c$, "getAlignedSeq1", -function () { -var alSeq1 = new jalview.datamodel.Sequence (this.s1.getName (), this.getAStr1 ()); -alSeq1.setStart (this.s1.getStart () + this.getSeq1Start () - 1); -alSeq1.setEnd (this.s1.getStart () + this.getSeq1End () - 1); -alSeq1.setDatasetSequence (this.s1.getDatasetSequence () == null ? this.s1 : this.s1.getDatasetSequence ()); -return alSeq1; -}); -Clazz.defineMethod (c$, "getAlignedSeq2", -function () { -var alSeq2 = new jalview.datamodel.Sequence (this.s2.getName (), this.getAStr2 ()); -alSeq2.setStart (this.s2.getStart () + this.getSeq2Start () - 1); -alSeq2.setEnd (this.s2.getStart () + this.getSeq2End () - 1); -alSeq2.setDatasetSequence (this.s2.getDatasetSequence () == null ? this.s2 : this.s2.getDatasetSequence ()); -return alSeq2; -}); -Clazz.defineMethod (c$, "SeqInit", -function (s1, string1, s2, string2, type) { -this.s1 = s1; -this.s2 = s2; -this.setDefaultParams (type); -this.SeqInit (string1, string2); -}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.SequenceI,~S,~S"); -Clazz.defineMethod (c$, "SeqInit", -function (s1, string1, s2, string2, scoreMatrix) { -this.s1 = s1; -this.s2 = s2; -this.setType (scoreMatrix.isDNA () ? "dna" : "pep"); -this.lookup = scoreMatrix.getMatrix (); -}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.SequenceI,~S,jalview.schemes.ScoreMatrix"); -Clazz.defineMethod (c$, "SeqInit", -($fz = function (string1, string2) { -this.s1str = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, string1); -this.s2str = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, string2); -if (this.s1str.length == 0 || this.s2str.length == 0) { -this.output.append ("ALL GAPS: " + (this.s1str.length == 0 ? this.s1.getName () : " ") + (this.s2str.length == 0 ? this.s2.getName () : "")); -return; -}this.seq1 = Clazz.newIntArray (this.s1str.length, 0); -this.seq2 = Clazz.newIntArray (this.s2str.length, 0); -this.score = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); -this.E = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); -this.F = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); -this.traceback = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); -this.seq1 = this.stringToInt (this.s1str, this.type); -this.seq2 = this.stringToInt (this.s2str, this.type); -}, $fz.isPrivate = true, $fz), "~S,~S"); -Clazz.defineMethod (c$, "setDefaultParams", -($fz = function (type) { -this.setType (type); -if (type.equals ("pep")) { -this.lookup = jalview.schemes.ResidueProperties.getDefaultPeptideMatrix (); -} else if (type.equals ("dna")) { -this.lookup = jalview.schemes.ResidueProperties.getDefaultDnaMatrix (); -}}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "setType", -($fz = function (type2) { -this.type = type2; -if (this.type.equals ("pep")) { -this.intToStr = jalview.analysis.AlignSeq.pep; -this.charToInt = jalview.schemes.ResidueProperties.aaIndex; -this.defInt = 23; -} else if (this.type.equals ("dna")) { -this.intToStr = jalview.analysis.AlignSeq.dna; -this.charToInt = jalview.schemes.ResidueProperties.nucleotideIndex; -this.defInt = 10; -} else { -this.output.append ("Wrong type = dna or pep only"); -throw new Error (jalview.util.MessageManager.formatMessage ("error.unknown_type_dna_or_pep", Clazz.newArray (-1, [type2]))); -}}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "traceAlignment", -function () { -var max = -9999; -for (var i = 0; i < this.seq1.length; i++) { -if (this.score[i][this.seq2.length - 1] > max) { -max = this.score[i][this.seq2.length - 1]; -this.maxi = i; -this.maxj = this.seq2.length - 1; -}} -for (var j = 0; j < this.seq2.length; j++) { -if (this.score[this.seq1.length - 1][j] > max) { -max = this.score[this.seq1.length - 1][j]; -this.maxi = this.seq1.length - 1; -this.maxj = j; -}} -var i = this.maxi; -var j = this.maxj; -var trace; -this.maxscore = Clazz.doubleToInt (this.score[i][j] / 10); -this.seq1end = this.maxi + 1; -this.seq2end = this.maxj + 1; -this.aseq1 = Clazz.newIntArray (this.seq1.length + this.seq2.length, 0); -this.aseq2 = Clazz.newIntArray (this.seq1.length + this.seq2.length, 0); -this.count = (this.seq1.length + this.seq2.length) - 1; -while ((i > 0) && (j > 0)) { -if ((this.aseq1[this.count] != this.defInt) && (i >= 0)) { -this.aseq1[this.count] = this.seq1[i]; -this.astr1 = this.s1str.charAt (i) + this.astr1; -}if ((this.aseq2[this.count] != this.defInt) && (j > 0)) { -this.aseq2[this.count] = this.seq2[j]; -this.astr2 = this.s2str.charAt (j) + this.astr2; -}trace = this.findTrace (i, j); -if (trace == 0) { -i--; -j--; -} else if (trace == 1) { -j--; -this.aseq1[this.count] = this.defInt; -this.astr1 = "-" + this.astr1.substring (1); -} else if (trace == -1) { -i--; -this.aseq2[this.count] = this.defInt; -this.astr2 = "-" + this.astr2.substring (1); -}this.count--; -} -this.seq1start = i + 1; -this.seq2start = j + 1; -if (this.aseq1[this.count] != this.defInt) { -this.aseq1[this.count] = this.seq1[i]; -this.astr1 = this.s1str.charAt (i) + this.astr1; -}if (this.aseq2[this.count] != this.defInt) { -this.aseq2[this.count] = this.seq2[j]; -this.astr2 = this.s2str.charAt (j) + this.astr2; -}}); -Clazz.defineMethod (c$, "printAlignment", -function (os) { -var s1id = this.s1.getName (); -var s2id = this.s2.getName (); -var maxid = this.s1.getName ().length; -if (this.s2.getName ().length > maxid) { -maxid = this.s2.getName ().length; -}if (maxid > 30) { -maxid = 30; -if (this.s1.getName ().length > maxid) { -s1id = this.s1.getName ().substring (0, 30); -}if (this.s2.getName ().length > maxid) { -s2id = this.s2.getName ().substring (0, 30); -}}var len = 72 - maxid - 1; -var nochunks = (Clazz.doubleToInt ((this.aseq1.length - this.count) / len)) + 1; -this.pid = 0; -this.output.append ("Score = ").append ("" + this.score[this.maxi][this.maxj]).append (jalview.analysis.AlignSeq.NEWLINE); -this.output.append ("Length of alignment = ").append (String.valueOf (this.aseq1.length - this.count)).append (jalview.analysis.AlignSeq.NEWLINE); -this.output.append ("Sequence "); -this.output.append ( new jalview.util.Format ("%" + maxid + "s").form (this.s1.getName ())); -this.output.append (" : ").append (String.valueOf (this.s1.getStart ())).append (" - ").append (String.valueOf (this.s1.getEnd ())); -this.output.append (" (Sequence length = ").append (String.valueOf (this.s1str.length)).append (")").append (jalview.analysis.AlignSeq.NEWLINE); -this.output.append ("Sequence "); -this.output.append ( new jalview.util.Format ("%" + maxid + "s").form (this.s2.getName ())); -this.output.append (" : ").append (String.valueOf (this.s2.getStart ())).append (" - ").append (String.valueOf (this.s2.getEnd ())); -this.output.append (" (Sequence length = ").append (String.valueOf (this.s2str.length)).append (")").append (jalview.analysis.AlignSeq.NEWLINE).append (jalview.analysis.AlignSeq.NEWLINE); -for (var j = 0; j < nochunks; j++) { -this.output.append ( new jalview.util.Format ("%" + (maxid) + "s").form (s1id)).append (" "); -for (var i = 0; i < len; i++) { -if ((i + (j * len)) < this.astr1.length) { -this.output.append (this.astr1.charAt (i + (j * len))); -}} -this.output.append (jalview.analysis.AlignSeq.NEWLINE); -this.output.append ( new jalview.util.Format ("%" + (maxid) + "s").form (" ")).append (" "); -for (var i = 0; i < len; i++) { -if ((i + (j * len)) < this.astr1.length) { -if (this.astr1.charAt (i + (j * len)) == this.astr2.charAt (i + (j * len)) && !jalview.util.Comparison.isGap (this.astr1.charAt (i + (j * len)))) { -this.pid++; -this.output.append ("|"); -} else if (this.type.equals ("pep")) { -if (jalview.schemes.ResidueProperties.getPAM250 (this.astr1.charAt (i + (j * len)), this.astr2.charAt (i + (j * len))) > 0) { -this.output.append ("."); -} else { -this.output.append (" "); -}} else { -this.output.append (" "); -}}} -this.output = this.output.append (jalview.analysis.AlignSeq.NEWLINE); -this.output = this.output.append ( new jalview.util.Format ("%" + (maxid) + "s").form (s2id)).append (" "); -for (var i = 0; i < len; i++) { -if ((i + (j * len)) < this.astr2.length) { -this.output.append (this.astr2.charAt (i + (j * len))); -}} -this.output.append (jalview.analysis.AlignSeq.NEWLINE).append (jalview.analysis.AlignSeq.NEWLINE); -} -this.pid = this.pid / (this.aseq1.length - this.count) * 100; -this.output = this.output.append ( new jalview.util.Format ("Percentage ID = %2.2f\n\n").formDouble (this.pid)); -try { -os.print (this.output.toString ()); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -}, "java.io.PrintStream"); -Clazz.defineMethod (c$, "printScoreMatrix", -function (mat) { -var n = this.seq1.length; -var m = this.seq2.length; -for (var i = 0; i < n; i++) { -if (i == 0) { -jalview.util.Format.print (System.out, "%8s", this.s2str.substring (0, 1)); -for (var jj = 1; jj < m; jj++) { -jalview.util.Format.print (System.out, "%5s", this.s2str.substring (jj, jj + 1)); -} -System.out.println (); -}for (var j = 0; j < m; j++) { -if (j == 0) { -jalview.util.Format.print (System.out, "%3s", this.s1str.substring (i, i + 1)); -}jalview.util.Format.printLong (System.out, "%3d ", Clazz.doubleToInt (mat[i][j] / 10)); -} -System.out.println (); -} -}, "~A"); -Clazz.defineMethod (c$, "findTrace", -function (i, j) { -var t = 0; -var max = this.score[i - 1][j - 1] + (this.lookup[this.seq1[i]][this.seq2[j]] * 10); -if (this.F[i][j] > max) { -max = this.F[i][j]; -t = -1; -} else if (this.F[i][j] == max) { -if (this.prev == -1) { -max = this.F[i][j]; -t = -1; -}}if (this.E[i][j] >= max) { -max = this.E[i][j]; -t = 1; -} else if (this.E[i][j] == max) { -if (this.prev == 1) { -max = this.E[i][j]; -t = 1; -}}this.prev = t; -return t; -}, "~N,~N"); -Clazz.defineMethod (c$, "calcScoreMatrix", -function () { -var n = this.seq1.length; -var m = this.seq2.length; -this.score[0][0] = this.lookup[this.seq1[0]][this.seq2[0]] * 10; -this.E[0][0] = -this.gapExtend; -this.F[0][0] = 0; -for (var j = 1; j < m; j++) { -this.E[0][j] = this.max (this.score[0][j - 1] - this.gapOpen, this.E[0][j - 1] - this.gapExtend); -this.F[0][j] = -this.gapExtend; -this.score[0][j] = this.max (this.lookup[this.seq1[0]][this.seq2[j]] * 10, -this.gapOpen, -this.gapExtend); -this.traceback[0][j] = 1; -} -for (var i = 1; i < n; i++) { -this.E[i][0] = -this.gapOpen; -this.F[i][0] = this.max (this.score[i - 1][0] - this.gapOpen, this.F[i - 1][0] - this.gapExtend); -this.score[i][0] = this.max (this.lookup[this.seq1[i]][this.seq2[0]] * 10, this.E[i][0], this.F[i][0]); -this.traceback[i][0] = -1; -} -for (var i = 1; i < n; i++) { -for (var j = 1; j < m; j++) { -this.E[i][j] = this.max (this.score[i][j - 1] - this.gapOpen, this.E[i][j - 1] - this.gapExtend); -this.F[i][j] = this.max (this.score[i - 1][j] - this.gapOpen, this.F[i - 1][j] - this.gapExtend); -this.score[i][j] = this.max (this.score[i - 1][j - 1] + (this.lookup[this.seq1[i]][this.seq2[j]] * 10), this.E[i][j], this.F[i][j]); -this.traceback[i][j] = this.findTrace (i, j); -} -} -}); -c$.extractGaps = Clazz.defineMethod (c$, "extractGaps", -function (gapChars, seq) { -if (gapChars == null || seq == null) { -return null; -}var str = new java.util.StringTokenizer (seq, gapChars); -var newString = new StringBuilder (seq.length); -while (str.hasMoreTokens ()) { -newString.append (str.nextToken ()); -} -return newString.toString (); -}, "~S,~S"); -Clazz.defineMethod (c$, "max", -function (i1, i2, i3) { -var max = i1; -if (i2 > i1) { -max = i2; -}if (i3 > max) { -max = i3; -}return max; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "max", -function (i1, i2) { -var max = i1; -if (i2 > i1) { -max = i2; -}return max; -}, "~N,~N"); -Clazz.defineMethod (c$, "stringToInt", -function (s, type) { -var seq1 = Clazz.newIntArray (s.length, 0); -for (var i = 0; i < s.length; i++) { -var c = s.charAt (i); -if ('a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - (32)); -}try { -seq1[i] = this.charToInt[c.charCodeAt (0)]; -if (seq1[i] < 0 || seq1[i] > this.defInt) { -seq1[i] = this.defInt; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -seq1[i] = this.defInt; -} else { -throw e; -} -} -} -return seq1; -}, "~S,~S"); -c$.displayMatrix = Clazz.defineMethod (c$, "displayMatrix", -function (g, mat, n, m, psize) { -var max = -1000; -var min = 1000; -for (var i = 0; i < n; i++) { -for (var j = 0; j < m; j++) { -if (mat[i][j] >= max) { -max = mat[i][j]; -}if (mat[i][j] <= min) { -min = mat[i][j]; -}} -} -System.out.println (max + " " + min); -for (var i = 0; i < n; i++) { -for (var j = 0; j < m; j++) { -var x = psize * i; -var y = psize * j; -var score = (mat[i][j] - min) / (max - min); -g.setColor ( new java.awt.Color (score, 0, 0)); -g.fillRect (x, y, psize, psize); -} -} -}, "java.awt.Graphics,~A,~N,~N,~N"); -c$.doGlobalNWAlignment = Clazz.defineMethod (c$, "doGlobalNWAlignment", -function (s1, s2, type) { -var as = new jalview.analysis.AlignSeq (s1, s2, type); -as.calcScoreMatrix (); -as.traceAlignment (); -return as; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S"); -Clazz.defineMethod (c$, "getMappingFromS1", -function (allowmismatch) { -var as1 = new java.util.ArrayList (); -var as2 = new java.util.ArrayList (); -var pdbpos = this.s2.getStart () + this.getSeq2Start () - 2; -var alignpos = this.s1.getStart () + this.getSeq1Start () - 2; -var lp2 = pdbpos - 3; -var lp1 = alignpos - 3; -var lastmatch = false; -for (var i = 0; i < this.astr1.length; i++) { -var c1 = this.astr1.charAt (i); -var c2 = this.astr2.charAt (i); -if (c1 != '-') { -alignpos++; -}if (c2 != '-') { -pdbpos++; -}if (allowmismatch || c1 == c2) { -if (lp1 + 1 != alignpos || lp2 + 1 != pdbpos) { -as1.add (Integer.$valueOf (alignpos)); -as2.add (Integer.$valueOf (pdbpos)); -}lastmatch = true; -lp1 = alignpos; -lp2 = pdbpos; -} else { -if (lastmatch) { -as1.add (Integer.$valueOf (lp1)); -as2.add (Integer.$valueOf (lp2)); -}lastmatch = false; -}} -var mapseq1 = Clazz.newIntArray (as1.size () + (lastmatch ? 1 : 0), 0); -var mapseq2 = Clazz.newIntArray (as2.size () + (lastmatch ? 1 : 0), 0); -var i = 0; -for (var ip, $ip = as1.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { -mapseq1[i++] = (ip).intValue (); -} -;i = 0; -for (var ip, $ip = as2.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { -mapseq2[i++] = (ip).intValue (); -} -;if (lastmatch) { -mapseq1[mapseq1.length - 1] = alignpos; -mapseq2[mapseq2.length - 1] = pdbpos; -}var map = new jalview.util.MapList (mapseq1, mapseq2, 1, 1); -var mapping = new jalview.datamodel.Mapping (map); -mapping.setTo (this.s2); -return mapping; -}, "~B"); -c$.replaceMatchingSeqsWith = Clazz.defineMethod (c$, "replaceMatchingSeqsWith", -function (seqs, annotations, ochains, al, dnaOrProtein, removeOldAnnots) { -var orig = new java.util.ArrayList (); -var repl = new java.util.ArrayList (); -var aligs = new java.util.ArrayList (); -if (al != null && al.getHeight () > 0) { -var matches = new java.util.ArrayList (); -var aligns = new java.util.ArrayList (); -for (var sq, $sq = ochains.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -var bestm = null; -var bestaseq = null; -var bestscore = 0; -for (var msq, $msq = al.getSequences ().iterator (); $msq.hasNext () && ((msq = $msq.next ()) || true);) { -var aseq = jalview.analysis.AlignSeq.doGlobalNWAlignment (msq, sq, dnaOrProtein); -if (bestm == null || aseq.getMaxScore () > bestscore) { -bestscore = aseq.getMaxScore (); -bestaseq = aseq; -bestm = msq; -}} -System.out.println ("Best Score for " + (matches.size () + 1) + " :" + bestscore); -matches.add (bestm); -aligns.add (bestaseq); -al.deleteSequence (bestm); -} -for (var p = 0, pSize = seqs.size (); p < pSize; p++) { -var sq; -var sp = seqs.get (p); -var q; -if ((q = ochains.indexOf (sp)) > -1) { -seqs.set (p, sq = matches.get (q)); -orig.add (sp); -repl.add (sq); -sq.setName (sp.getName ()); -sq.setDescription (sp.getDescription ()); -var sp2sq; -sq.transferAnnotation (sp, sp2sq = aligns.get (q).getMappingFromS1 (false)); -aligs.add (aligns.get (q)); -var inspos = -1; -for (var ap = 0; ap < annotations.size (); ) { -if (annotations.get (ap).sequenceRef === sp) { -if (inspos == -1) { -inspos = ap; -}if (removeOldAnnots) { -annotations.remove (ap); -} else { -var alan = annotations.remove (ap); -alan.liftOver (sq, sp2sq); -alan.setSequenceRef (sq); -sq.addAlignmentAnnotation (alan); -}} else { -ap++; -}} -if (sq.getAnnotation () != null && sq.getAnnotation ().length > 0) { -annotations.addAll (inspos == -1 ? annotations.size () : inspos, java.util.Arrays.asList (sq.getAnnotation ())); -}}} -}return java.util.Arrays.asList ([orig, repl, aligs]); -}, "java.util.List,java.util.List,java.util.List,jalview.datamodel.AlignmentI,~S,~B"); -c$.computeRedundancyMatrix = Clazz.defineMethod (c$, "computeRedundancyMatrix", -function (originalSequences, omitHidden, start, end, ungapped) { -var height = originalSequences.length; -var redundancy = Clazz.newFloatArray (height, 0); -var lngth = Clazz.newIntArray (height, 0); -for (var i = 0; i < height; i++) { -redundancy[i] = 0; -lngth[i] = -1; -} -var pid; -var seqi; -var seqj; -for (var i = 0; i < height; i++) { -for (var j = 0; j < i; j++) { -if (i == j) { -continue; -}if (omitHidden == null) { -seqi = originalSequences[i].getSequenceAsString (start, end); -seqj = originalSequences[j].getSequenceAsString (start, end); -} else { -seqi = omitHidden[i]; -seqj = omitHidden[j]; -}if (lngth[i] == -1) { -var ug = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, seqi); -lngth[i] = ug.length; -if (ungapped) { -seqi = ug; -}}if (lngth[j] == -1) { -var ug = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, seqj); -lngth[j] = ug.length; -if (ungapped) { -seqj = ug; -}}pid = jalview.util.Comparison.PID (seqi, seqj); -if (lngth[j] < lngth[i]) { -redundancy[j] = Math.max (pid, redundancy[j]); -} else { -redundancy[i] = Math.max (pid, redundancy[i]); -}} -} -return redundancy; -}, "~A,~A,~N,~N,~B"); -Clazz.defineStatics (c$, -"PEP", "pep", -"DNA", "dna"); -c$.NEWLINE = c$.prototype.NEWLINE = System.lineSeparator (); -Clazz.defineStatics (c$, -"dna", Clazz.newArray (-1, ["A", "C", "G", "T", "-"]), -"pep", Clazz.newArray (-1, ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-"])); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["jalview.schemes.ResidueProperties", "java.lang.StringBuffer"], "jalview.analysis.AlignSeq", ["jalview.datamodel.Mapping", "$.Sequence", "jalview.util.Comparison", "$.Format", "$.MapList", "$.MessageManager", "java.awt.Color", "java.lang.Error", "$.StringBuilder", "java.util.ArrayList", "$.Arrays", "$.StringTokenizer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.score = null; +this.E = null; +this.F = null; +this.traceback = null; +this.seq1 = null; +this.seq2 = null; +this.s1 = null; +this.s2 = null; +this.s1str = null; +this.s2str = null; +this.maxi = 0; +this.maxj = 0; +this.aseq1 = null; +this.aseq2 = null; +this.astr1 = ""; +this.astr2 = ""; +this.seq1start = 0; +this.seq1end = 0; +this.seq2start = 0; +this.seq2end = 0; +this.count = 0; +this.maxscore = 0; +this.pid = 0; +this.prev = 0; +this.gapOpen = 120; +this.gapExtend = 20; +this.lookup = null; +this.intToStr = null; +this.defInt = 23; +this.output = null; +this.type = null; +this.charToInt = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "AlignSeq"); +Clazz.prepareFields (c$, function () { +this.lookup = jalview.schemes.ResidueProperties.getBLOSUM62 (); +this.intToStr = jalview.analysis.AlignSeq.pep; +this.output = new StringBuffer (); +}); +Clazz.makeConstructor (c$, +function (s1, s2, type) { +this.SeqInit (s1, s1.getSequenceAsString (), s2, s2.getSequenceAsString (), type); +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S"); +Clazz.makeConstructor (c$, +function (s1, string1, s2, string2, type) { +this.SeqInit (s1, string1.toUpperCase (), s2, string2.toUpperCase (), type); +}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.SequenceI,~S,~S"); +Clazz.defineMethod (c$, "getMaxScore", +function () { +return this.maxscore; +}); +Clazz.defineMethod (c$, "getSeq2Start", +function () { +return this.seq2start; +}); +Clazz.defineMethod (c$, "getSeq2End", +function () { +return this.seq2end; +}); +Clazz.defineMethod (c$, "getSeq1Start", +function () { +return this.seq1start; +}); +Clazz.defineMethod (c$, "getSeq1End", +function () { +return this.seq1end; +}); +Clazz.defineMethod (c$, "getOutput", +function () { +return this.output.toString (); +}); +Clazz.defineMethod (c$, "getAStr1", +function () { +return this.astr1; +}); +Clazz.defineMethod (c$, "getAStr2", +function () { +return this.astr2; +}); +Clazz.defineMethod (c$, "getASeq1", +function () { +return this.aseq1; +}); +Clazz.defineMethod (c$, "getASeq2", +function () { +return this.aseq2; +}); +Clazz.defineMethod (c$, "getS1", +function () { +return this.s1; +}); +Clazz.defineMethod (c$, "getS2", +function () { +return this.s2; +}); +Clazz.defineMethod (c$, "getAlignedSeq1", +function () { +var alSeq1 = new jalview.datamodel.Sequence (this.s1.getName (), this.getAStr1 ()); +alSeq1.setStart (this.s1.getStart () + this.getSeq1Start () - 1); +alSeq1.setEnd (this.s1.getStart () + this.getSeq1End () - 1); +alSeq1.setDatasetSequence (this.s1.getDatasetSequence () == null ? this.s1 : this.s1.getDatasetSequence ()); +return alSeq1; +}); +Clazz.defineMethod (c$, "getAlignedSeq2", +function () { +var alSeq2 = new jalview.datamodel.Sequence (this.s2.getName (), this.getAStr2 ()); +alSeq2.setStart (this.s2.getStart () + this.getSeq2Start () - 1); +alSeq2.setEnd (this.s2.getStart () + this.getSeq2End () - 1); +alSeq2.setDatasetSequence (this.s2.getDatasetSequence () == null ? this.s2 : this.s2.getDatasetSequence ()); +return alSeq2; +}); +Clazz.defineMethod (c$, "SeqInit", +function (s1, string1, s2, string2, type) { +this.s1 = s1; +this.s2 = s2; +this.setDefaultParams (type); +this.SeqInit (string1, string2); +}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.SequenceI,~S,~S"); +Clazz.defineMethod (c$, "SeqInit", +function (s1, string1, s2, string2, scoreMatrix) { +this.s1 = s1; +this.s2 = s2; +this.setType (scoreMatrix.isDNA () ? "dna" : "pep"); +this.lookup = scoreMatrix.getMatrix (); +}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.SequenceI,~S,jalview.schemes.ScoreMatrix"); +Clazz.defineMethod (c$, "SeqInit", +($fz = function (string1, string2) { +this.s1str = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, string1); +this.s2str = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, string2); +if (this.s1str.length == 0 || this.s2str.length == 0) { +this.output.append ("ALL GAPS: " + (this.s1str.length == 0 ? this.s1.getName () : " ") + (this.s2str.length == 0 ? this.s2.getName () : "")); +return; +}this.seq1 = Clazz.newIntArray (this.s1str.length, 0); +this.seq2 = Clazz.newIntArray (this.s2str.length, 0); +this.score = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); +this.E = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); +this.F = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); +this.traceback = Clazz.newIntArray (this.s1str.length, this.s2str.length, 0); +this.seq1 = this.stringToInt (this.s1str, this.type); +this.seq2 = this.stringToInt (this.s2str, this.type); +}, $fz.isPrivate = true, $fz), "~S,~S"); +Clazz.defineMethod (c$, "setDefaultParams", +($fz = function (type) { +this.setType (type); +if (type.equals ("pep")) { +this.lookup = jalview.schemes.ResidueProperties.getDefaultPeptideMatrix (); +} else if (type.equals ("dna")) { +this.lookup = jalview.schemes.ResidueProperties.getDefaultDnaMatrix (); +}}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "setType", +($fz = function (type2) { +this.type = type2; +if (this.type.equals ("pep")) { +this.intToStr = jalview.analysis.AlignSeq.pep; +this.charToInt = jalview.schemes.ResidueProperties.aaIndex; +this.defInt = 23; +} else if (this.type.equals ("dna")) { +this.intToStr = jalview.analysis.AlignSeq.dna; +this.charToInt = jalview.schemes.ResidueProperties.nucleotideIndex; +this.defInt = 10; +} else { +this.output.append ("Wrong type = dna or pep only"); +throw new Error (jalview.util.MessageManager.formatMessage ("error.unknown_type_dna_or_pep", Clazz.newArray (-1, [type2]))); +}}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "traceAlignment", +function () { +var max = -9999; +for (var i = 0; i < this.seq1.length; i++) { +if (this.score[i][this.seq2.length - 1] > max) { +max = this.score[i][this.seq2.length - 1]; +this.maxi = i; +this.maxj = this.seq2.length - 1; +}} +for (var j = 0; j < this.seq2.length; j++) { +if (this.score[this.seq1.length - 1][j] > max) { +max = this.score[this.seq1.length - 1][j]; +this.maxi = this.seq1.length - 1; +this.maxj = j; +}} +var i = this.maxi; +var j = this.maxj; +var trace; +this.maxscore = Clazz.doubleToInt (this.score[i][j] / 10); +this.seq1end = this.maxi + 1; +this.seq2end = this.maxj + 1; +this.aseq1 = Clazz.newIntArray (this.seq1.length + this.seq2.length, 0); +this.aseq2 = Clazz.newIntArray (this.seq1.length + this.seq2.length, 0); +this.count = (this.seq1.length + this.seq2.length) - 1; +while ((i > 0) && (j > 0)) { +if ((this.aseq1[this.count] != this.defInt) && (i >= 0)) { +this.aseq1[this.count] = this.seq1[i]; +this.astr1 = this.s1str.charAt (i) + this.astr1; +}if ((this.aseq2[this.count] != this.defInt) && (j > 0)) { +this.aseq2[this.count] = this.seq2[j]; +this.astr2 = this.s2str.charAt (j) + this.astr2; +}trace = this.findTrace (i, j); +if (trace == 0) { +i--; +j--; +} else if (trace == 1) { +j--; +this.aseq1[this.count] = this.defInt; +this.astr1 = "-" + this.astr1.substring (1); +} else if (trace == -1) { +i--; +this.aseq2[this.count] = this.defInt; +this.astr2 = "-" + this.astr2.substring (1); +}this.count--; +} +this.seq1start = i + 1; +this.seq2start = j + 1; +if (this.aseq1[this.count] != this.defInt) { +this.aseq1[this.count] = this.seq1[i]; +this.astr1 = this.s1str.charAt (i) + this.astr1; +}if (this.aseq2[this.count] != this.defInt) { +this.aseq2[this.count] = this.seq2[j]; +this.astr2 = this.s2str.charAt (j) + this.astr2; +}}); +Clazz.defineMethod (c$, "printAlignment", +function (os) { +var s1id = this.s1.getName (); +var s2id = this.s2.getName (); +var maxid = this.s1.getName ().length; +if (this.s2.getName ().length > maxid) { +maxid = this.s2.getName ().length; +}if (maxid > 30) { +maxid = 30; +if (this.s1.getName ().length > maxid) { +s1id = this.s1.getName ().substring (0, 30); +}if (this.s2.getName ().length > maxid) { +s2id = this.s2.getName ().substring (0, 30); +}}var len = 72 - maxid - 1; +var nochunks = (Clazz.doubleToInt ((this.aseq1.length - this.count) / len)) + 1; +this.pid = 0; +this.output.append ("Score = ").append ("" + this.score[this.maxi][this.maxj]).append (jalview.analysis.AlignSeq.NEWLINE); +this.output.append ("Length of alignment = ").append (String.valueOf (this.aseq1.length - this.count)).append (jalview.analysis.AlignSeq.NEWLINE); +this.output.append ("Sequence "); +this.output.append ( new jalview.util.Format ("%" + maxid + "s").form (this.s1.getName ())); +this.output.append (" : ").append (String.valueOf (this.s1.getStart ())).append (" - ").append (String.valueOf (this.s1.getEnd ())); +this.output.append (" (Sequence length = ").append (String.valueOf (this.s1str.length)).append (")").append (jalview.analysis.AlignSeq.NEWLINE); +this.output.append ("Sequence "); +this.output.append ( new jalview.util.Format ("%" + maxid + "s").form (this.s2.getName ())); +this.output.append (" : ").append (String.valueOf (this.s2.getStart ())).append (" - ").append (String.valueOf (this.s2.getEnd ())); +this.output.append (" (Sequence length = ").append (String.valueOf (this.s2str.length)).append (")").append (jalview.analysis.AlignSeq.NEWLINE).append (jalview.analysis.AlignSeq.NEWLINE); +for (var j = 0; j < nochunks; j++) { +this.output.append ( new jalview.util.Format ("%" + (maxid) + "s").form (s1id)).append (" "); +for (var i = 0; i < len; i++) { +if ((i + (j * len)) < this.astr1.length) { +this.output.append (this.astr1.charAt (i + (j * len))); +}} +this.output.append (jalview.analysis.AlignSeq.NEWLINE); +this.output.append ( new jalview.util.Format ("%" + (maxid) + "s").form (" ")).append (" "); +for (var i = 0; i < len; i++) { +if ((i + (j * len)) < this.astr1.length) { +if (this.astr1.charAt (i + (j * len)) == this.astr2.charAt (i + (j * len)) && !jalview.util.Comparison.isGap (this.astr1.charAt (i + (j * len)))) { +this.pid++; +this.output.append ("|"); +} else if (this.type.equals ("pep")) { +if (jalview.schemes.ResidueProperties.getPAM250 (this.astr1.charAt (i + (j * len)), this.astr2.charAt (i + (j * len))) > 0) { +this.output.append ("."); +} else { +this.output.append (" "); +}} else { +this.output.append (" "); +}}} +this.output = this.output.append (jalview.analysis.AlignSeq.NEWLINE); +this.output = this.output.append ( new jalview.util.Format ("%" + (maxid) + "s").form (s2id)).append (" "); +for (var i = 0; i < len; i++) { +if ((i + (j * len)) < this.astr2.length) { +this.output.append (this.astr2.charAt (i + (j * len))); +}} +this.output.append (jalview.analysis.AlignSeq.NEWLINE).append (jalview.analysis.AlignSeq.NEWLINE); +} +this.pid = this.pid / (this.aseq1.length - this.count) * 100; +this.output = this.output.append ( new jalview.util.Format ("Percentage ID = %2.2f\n\n").formDouble (this.pid)); +try { +os.print (this.output.toString ()); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +}, "java.io.PrintStream"); +Clazz.defineMethod (c$, "printScoreMatrix", +function (mat) { +var n = this.seq1.length; +var m = this.seq2.length; +for (var i = 0; i < n; i++) { +if (i == 0) { +jalview.util.Format.print (System.out, "%8s", this.s2str.substring (0, 1)); +for (var jj = 1; jj < m; jj++) { +jalview.util.Format.print (System.out, "%5s", this.s2str.substring (jj, jj + 1)); +} +System.out.println (); +}for (var j = 0; j < m; j++) { +if (j == 0) { +jalview.util.Format.print (System.out, "%3s", this.s1str.substring (i, i + 1)); +}jalview.util.Format.printLong (System.out, "%3d ", Clazz.doubleToInt (mat[i][j] / 10)); +} +System.out.println (); +} +}, "~A"); +Clazz.defineMethod (c$, "findTrace", +function (i, j) { +var t = 0; +var max = this.score[i - 1][j - 1] + (this.lookup[this.seq1[i]][this.seq2[j]] * 10); +if (this.F[i][j] > max) { +max = this.F[i][j]; +t = -1; +} else if (this.F[i][j] == max) { +if (this.prev == -1) { +max = this.F[i][j]; +t = -1; +}}if (this.E[i][j] >= max) { +max = this.E[i][j]; +t = 1; +} else if (this.E[i][j] == max) { +if (this.prev == 1) { +max = this.E[i][j]; +t = 1; +}}this.prev = t; +return t; +}, "~N,~N"); +Clazz.defineMethod (c$, "calcScoreMatrix", +function () { +var n = this.seq1.length; +var m = this.seq2.length; +this.score[0][0] = this.lookup[this.seq1[0]][this.seq2[0]] * 10; +this.E[0][0] = -this.gapExtend; +this.F[0][0] = 0; +for (var j = 1; j < m; j++) { +this.E[0][j] = this.max (this.score[0][j - 1] - this.gapOpen, this.E[0][j - 1] - this.gapExtend); +this.F[0][j] = -this.gapExtend; +this.score[0][j] = this.max (this.lookup[this.seq1[0]][this.seq2[j]] * 10, -this.gapOpen, -this.gapExtend); +this.traceback[0][j] = 1; +} +for (var i = 1; i < n; i++) { +this.E[i][0] = -this.gapOpen; +this.F[i][0] = this.max (this.score[i - 1][0] - this.gapOpen, this.F[i - 1][0] - this.gapExtend); +this.score[i][0] = this.max (this.lookup[this.seq1[i]][this.seq2[0]] * 10, this.E[i][0], this.F[i][0]); +this.traceback[i][0] = -1; +} +for (var i = 1; i < n; i++) { +for (var j = 1; j < m; j++) { +this.E[i][j] = this.max (this.score[i][j - 1] - this.gapOpen, this.E[i][j - 1] - this.gapExtend); +this.F[i][j] = this.max (this.score[i - 1][j] - this.gapOpen, this.F[i - 1][j] - this.gapExtend); +this.score[i][j] = this.max (this.score[i - 1][j - 1] + (this.lookup[this.seq1[i]][this.seq2[j]] * 10), this.E[i][j], this.F[i][j]); +this.traceback[i][j] = this.findTrace (i, j); +} +} +}); +c$.extractGaps = Clazz.defineMethod (c$, "extractGaps", +function (gapChars, seq) { +if (gapChars == null || seq == null) { +return null; +}var str = new java.util.StringTokenizer (seq, gapChars); +var newString = new StringBuilder (seq.length); +while (str.hasMoreTokens ()) { +newString.append (str.nextToken ()); +} +return newString.toString (); +}, "~S,~S"); +Clazz.defineMethod (c$, "max", +function (i1, i2, i3) { +var max = i1; +if (i2 > i1) { +max = i2; +}if (i3 > max) { +max = i3; +}return max; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "max", +function (i1, i2) { +var max = i1; +if (i2 > i1) { +max = i2; +}return max; +}, "~N,~N"); +Clazz.defineMethod (c$, "stringToInt", +function (s, type) { +var seq1 = Clazz.newIntArray (s.length, 0); +for (var i = 0; i < s.length; i++) { +var c = s.charAt (i); +if ('a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - (32)); +}try { +seq1[i] = this.charToInt[c.charCodeAt (0)]; +if (seq1[i] < 0 || seq1[i] > this.defInt) { +seq1[i] = this.defInt; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +seq1[i] = this.defInt; +} else { +throw e; +} +} +} +return seq1; +}, "~S,~S"); +c$.displayMatrix = Clazz.defineMethod (c$, "displayMatrix", +function (g, mat, n, m, psize) { +var max = -1000; +var min = 1000; +for (var i = 0; i < n; i++) { +for (var j = 0; j < m; j++) { +if (mat[i][j] >= max) { +max = mat[i][j]; +}if (mat[i][j] <= min) { +min = mat[i][j]; +}} +} +System.out.println (max + " " + min); +for (var i = 0; i < n; i++) { +for (var j = 0; j < m; j++) { +var x = psize * i; +var y = psize * j; +var score = (mat[i][j] - min) / (max - min); +g.setColor ( new java.awt.Color (score, 0, 0)); +g.fillRect (x, y, psize, psize); +} +} +}, "java.awt.Graphics,~A,~N,~N,~N"); +c$.doGlobalNWAlignment = Clazz.defineMethod (c$, "doGlobalNWAlignment", +function (s1, s2, type) { +var as = new jalview.analysis.AlignSeq (s1, s2, type); +as.calcScoreMatrix (); +as.traceAlignment (); +return as; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S"); +Clazz.defineMethod (c$, "getMappingFromS1", +function (allowmismatch) { +var as1 = new java.util.ArrayList (); +var as2 = new java.util.ArrayList (); +var pdbpos = this.s2.getStart () + this.getSeq2Start () - 2; +var alignpos = this.s1.getStart () + this.getSeq1Start () - 2; +var lp2 = pdbpos - 3; +var lp1 = alignpos - 3; +var lastmatch = false; +for (var i = 0; i < this.astr1.length; i++) { +var c1 = this.astr1.charAt (i); +var c2 = this.astr2.charAt (i); +if (c1 != '-') { +alignpos++; +}if (c2 != '-') { +pdbpos++; +}if (allowmismatch || c1 == c2) { +if (lp1 + 1 != alignpos || lp2 + 1 != pdbpos) { +as1.add (Integer.$valueOf (alignpos)); +as2.add (Integer.$valueOf (pdbpos)); +}lastmatch = true; +lp1 = alignpos; +lp2 = pdbpos; +} else { +if (lastmatch) { +as1.add (Integer.$valueOf (lp1)); +as2.add (Integer.$valueOf (lp2)); +}lastmatch = false; +}} +var mapseq1 = Clazz.newIntArray (as1.size () + (lastmatch ? 1 : 0), 0); +var mapseq2 = Clazz.newIntArray (as2.size () + (lastmatch ? 1 : 0), 0); +var i = 0; +for (var ip, $ip = as1.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { +mapseq1[i++] = (ip).intValue (); +} +;i = 0; +for (var ip, $ip = as2.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { +mapseq2[i++] = (ip).intValue (); +} +;if (lastmatch) { +mapseq1[mapseq1.length - 1] = alignpos; +mapseq2[mapseq2.length - 1] = pdbpos; +}var map = new jalview.util.MapList (mapseq1, mapseq2, 1, 1); +var mapping = new jalview.datamodel.Mapping (map); +mapping.setTo (this.s2); +return mapping; +}, "~B"); +c$.replaceMatchingSeqsWith = Clazz.defineMethod (c$, "replaceMatchingSeqsWith", +function (seqs, annotations, ochains, al, dnaOrProtein, removeOldAnnots) { +var orig = new java.util.ArrayList (); +var repl = new java.util.ArrayList (); +var aligs = new java.util.ArrayList (); +if (al != null && al.getHeight () > 0) { +var matches = new java.util.ArrayList (); +var aligns = new java.util.ArrayList (); +for (var sq, $sq = ochains.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +var bestm = null; +var bestaseq = null; +var bestscore = 0; +for (var msq, $msq = al.getSequences ().iterator (); $msq.hasNext () && ((msq = $msq.next ()) || true);) { +var aseq = jalview.analysis.AlignSeq.doGlobalNWAlignment (msq, sq, dnaOrProtein); +if (bestm == null || aseq.getMaxScore () > bestscore) { +bestscore = aseq.getMaxScore (); +bestaseq = aseq; +bestm = msq; +}} +System.out.println ("Best Score for " + (matches.size () + 1) + " :" + bestscore); +matches.add (bestm); +aligns.add (bestaseq); +al.deleteSequence (bestm); +} +for (var p = 0, pSize = seqs.size (); p < pSize; p++) { +var sq; +var sp = seqs.get (p); +var q; +if ((q = ochains.indexOf (sp)) > -1) { +seqs.set (p, sq = matches.get (q)); +orig.add (sp); +repl.add (sq); +sq.setName (sp.getName ()); +sq.setDescription (sp.getDescription ()); +var sp2sq; +sq.transferAnnotation (sp, sp2sq = aligns.get (q).getMappingFromS1 (false)); +aligs.add (aligns.get (q)); +var inspos = -1; +for (var ap = 0; ap < annotations.size (); ) { +if (annotations.get (ap).sequenceRef === sp) { +if (inspos == -1) { +inspos = ap; +}if (removeOldAnnots) { +annotations.remove (ap); +} else { +var alan = annotations.remove (ap); +alan.liftOver (sq, sp2sq); +alan.setSequenceRef (sq); +sq.addAlignmentAnnotation (alan); +}} else { +ap++; +}} +if (sq.getAnnotation () != null && sq.getAnnotation ().length > 0) { +annotations.addAll (inspos == -1 ? annotations.size () : inspos, java.util.Arrays.asList (sq.getAnnotation ())); +}}} +}return java.util.Arrays.asList ([orig, repl, aligs]); +}, "java.util.List,java.util.List,java.util.List,jalview.datamodel.AlignmentI,~S,~B"); +c$.computeRedundancyMatrix = Clazz.defineMethod (c$, "computeRedundancyMatrix", +function (originalSequences, omitHidden, start, end, ungapped) { +var height = originalSequences.length; +var redundancy = Clazz.newFloatArray (height, 0); +var lngth = Clazz.newIntArray (height, 0); +for (var i = 0; i < height; i++) { +redundancy[i] = 0; +lngth[i] = -1; +} +var pid; +var seqi; +var seqj; +for (var i = 0; i < height; i++) { +for (var j = 0; j < i; j++) { +if (i == j) { +continue; +}if (omitHidden == null) { +seqi = originalSequences[i].getSequenceAsString (start, end); +seqj = originalSequences[j].getSequenceAsString (start, end); +} else { +seqi = omitHidden[i]; +seqj = omitHidden[j]; +}if (lngth[i] == -1) { +var ug = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, seqi); +lngth[i] = ug.length; +if (ungapped) { +seqi = ug; +}}if (lngth[j] == -1) { +var ug = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, seqj); +lngth[j] = ug.length; +if (ungapped) { +seqj = ug; +}}pid = jalview.util.Comparison.PID (seqi, seqj); +if (lngth[j] < lngth[i]) { +redundancy[j] = Math.max (pid, redundancy[j]); +} else { +redundancy[i] = Math.max (pid, redundancy[i]); +}} +} +return redundancy; +}, "~A,~A,~N,~N,~B"); +Clazz.defineStatics (c$, +"PEP", "pep", +"DNA", "dna"); +c$.NEWLINE = c$.prototype.NEWLINE = System.lineSeparator (); +Clazz.defineStatics (c$, +"dna", Clazz.newArray (-1, ["A", "C", "G", "T", "-"]), +"pep", Clazz.newArray (-1, ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-"])); +}); diff --git a/bin/jalview/analysis/AlignmentAnnotationUtils.js b/bin/jalview/analysis/AlignmentAnnotationUtils.js index 9522f6e..f742aa9 100644 --- a/bin/jalview/analysis/AlignmentAnnotationUtils.js +++ b/bin/jalview/analysis/AlignmentAnnotationUtils.js @@ -1,73 +1,73 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.AlignmentAnnotationUtils", ["java.util.ArrayList", "$.Arrays", "$.BitSet", "$.Collections", "$.HashMap"], function () { -c$ = Clazz.declareType (jalview.analysis, "AlignmentAnnotationUtils"); -c$.getShownHiddenTypes = Clazz.defineMethod (c$, "getShownHiddenTypes", -function (shownTypes, hiddenTypes, annotations, forSequences) { -var visibleGraphGroups = jalview.analysis.AlignmentAnnotationUtils.getVisibleLineGraphGroups (annotations); -var groupLabels = new java.util.HashMap (); -var addedToShown = new java.util.ArrayList (); -var addedToHidden = new java.util.ArrayList (); -for (var aa, $aa = annotations.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { -if (aa.annotations == null) { -continue; -}if (forSequences != null && (aa.sequenceRef != null && forSequences.contains (aa.sequenceRef))) { -var calcId = aa.getCalcId (); -var labelAsList = new java.util.ArrayList (); -var displayLabel = aa.label; -labelAsList.add (displayLabel); -if (aa.graph == 2 && aa.graphGroup > -1) { -if (!groupLabels.containsKey (calcId)) { -groupLabels.put (calcId, new java.util.HashMap ()); -}var groupLabelsForCalcId = groupLabels.get (calcId); -if (groupLabelsForCalcId.containsKey (new Integer (aa.graphGroup))) { -if (!groupLabelsForCalcId.get (new Integer (aa.graphGroup)).contains (displayLabel)) { -groupLabelsForCalcId.get (new Integer (aa.graphGroup)).add (displayLabel); -}} else { -groupLabelsForCalcId.put (new Integer (aa.graphGroup), labelAsList); -}} else { -var rememberAs = calcId + "!" + displayLabel; -if (aa.visible && !addedToShown.contains (rememberAs)) { -if (!shownTypes.containsKey (calcId)) { -shownTypes.put (calcId, new java.util.ArrayList ()); -}shownTypes.get (calcId).add (labelAsList); -addedToShown.add (rememberAs); -} else { -if (!aa.visible && !addedToHidden.contains (rememberAs)) { -if (!hiddenTypes.containsKey (calcId)) { -hiddenTypes.put (calcId, new java.util.ArrayList ()); -}hiddenTypes.get (calcId).add (labelAsList); -addedToHidden.add (rememberAs); -}}}}} -for (var calcId, $calcId = groupLabels.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) { -for (var group, $group = groupLabels.get (calcId).keySet ().iterator (); $group.hasNext () && ((group = $group.next ()) || true);) { -var groupLabel = groupLabels.get (calcId).get (new Integer (group)); -java.util.Collections.sort (groupLabel); -if (visibleGraphGroups.get (group)) { -if (!shownTypes.containsKey (calcId)) { -shownTypes.put (calcId, new java.util.ArrayList ()); -}if (!shownTypes.get (calcId).contains (groupLabel)) { -shownTypes.get (calcId).add (groupLabel); -}} else { -if (!hiddenTypes.containsKey (calcId)) { -hiddenTypes.put (calcId, new java.util.ArrayList ()); -}if (!hiddenTypes.get (calcId).contains (groupLabel)) { -hiddenTypes.get (calcId).add (groupLabel); -}}} -} -}, "java.util.Map,java.util.Map,java.util.List,java.util.List"); -c$.getVisibleLineGraphGroups = Clazz.defineMethod (c$, "getVisibleLineGraphGroups", -function (annotations) { -var result = new java.util.BitSet (); -for (var ann, $ann = annotations.iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) { -if (ann.graph == 2 && ann.visible) { -var gg = ann.graphGroup; -if (gg > -1) { -result.set (gg); -}}} -return result; -}, "java.util.List"); -c$.asList = Clazz.defineMethod (c$, "asList", -function (anns) { -return (anns == null ? java.util.Collections.emptyList () : java.util.Arrays.asList (anns)); -}, "~A"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.AlignmentAnnotationUtils", ["java.util.ArrayList", "$.Arrays", "$.BitSet", "$.Collections", "$.HashMap"], function () { +c$ = Clazz.declareType (jalview.analysis, "AlignmentAnnotationUtils"); +c$.getShownHiddenTypes = Clazz.defineMethod (c$, "getShownHiddenTypes", +function (shownTypes, hiddenTypes, annotations, forSequences) { +var visibleGraphGroups = jalview.analysis.AlignmentAnnotationUtils.getVisibleLineGraphGroups (annotations); +var groupLabels = new java.util.HashMap (); +var addedToShown = new java.util.ArrayList (); +var addedToHidden = new java.util.ArrayList (); +for (var aa, $aa = annotations.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { +if (aa.annotations == null) { +continue; +}if (forSequences != null && (aa.sequenceRef != null && forSequences.contains (aa.sequenceRef))) { +var calcId = aa.getCalcId (); +var labelAsList = new java.util.ArrayList (); +var displayLabel = aa.label; +labelAsList.add (displayLabel); +if (aa.graph == 2 && aa.graphGroup > -1) { +if (!groupLabels.containsKey (calcId)) { +groupLabels.put (calcId, new java.util.HashMap ()); +}var groupLabelsForCalcId = groupLabels.get (calcId); +if (groupLabelsForCalcId.containsKey (new Integer (aa.graphGroup))) { +if (!groupLabelsForCalcId.get (new Integer (aa.graphGroup)).contains (displayLabel)) { +groupLabelsForCalcId.get (new Integer (aa.graphGroup)).add (displayLabel); +}} else { +groupLabelsForCalcId.put (new Integer (aa.graphGroup), labelAsList); +}} else { +var rememberAs = calcId + "!" + displayLabel; +if (aa.visible && !addedToShown.contains (rememberAs)) { +if (!shownTypes.containsKey (calcId)) { +shownTypes.put (calcId, new java.util.ArrayList ()); +}shownTypes.get (calcId).add (labelAsList); +addedToShown.add (rememberAs); +} else { +if (!aa.visible && !addedToHidden.contains (rememberAs)) { +if (!hiddenTypes.containsKey (calcId)) { +hiddenTypes.put (calcId, new java.util.ArrayList ()); +}hiddenTypes.get (calcId).add (labelAsList); +addedToHidden.add (rememberAs); +}}}}} +for (var calcId, $calcId = groupLabels.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) { +for (var group, $group = groupLabels.get (calcId).keySet ().iterator (); $group.hasNext () && ((group = $group.next ()) || true);) { +var groupLabel = groupLabels.get (calcId).get (new Integer (group)); +java.util.Collections.sort (groupLabel); +if (visibleGraphGroups.get (group)) { +if (!shownTypes.containsKey (calcId)) { +shownTypes.put (calcId, new java.util.ArrayList ()); +}if (!shownTypes.get (calcId).contains (groupLabel)) { +shownTypes.get (calcId).add (groupLabel); +}} else { +if (!hiddenTypes.containsKey (calcId)) { +hiddenTypes.put (calcId, new java.util.ArrayList ()); +}if (!hiddenTypes.get (calcId).contains (groupLabel)) { +hiddenTypes.get (calcId).add (groupLabel); +}}} +} +}, "java.util.Map,java.util.Map,java.util.List,java.util.List"); +c$.getVisibleLineGraphGroups = Clazz.defineMethod (c$, "getVisibleLineGraphGroups", +function (annotations) { +var result = new java.util.BitSet (); +for (var ann, $ann = annotations.iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) { +if (ann.graph == 2 && ann.visible) { +var gg = ann.graphGroup; +if (gg > -1) { +result.set (gg); +}}} +return result; +}, "java.util.List"); +c$.asList = Clazz.defineMethod (c$, "asList", +function (anns) { +return (anns == null ? java.util.Collections.emptyList () : java.util.Arrays.asList (anns)); +}, "~A"); +}); diff --git a/bin/jalview/analysis/AlignmentSorter.js b/bin/jalview/analysis/AlignmentSorter.js index bcf66d4..4c0604a 100644 --- a/bin/jalview/analysis/AlignmentSorter.js +++ b/bin/jalview/analysis/AlignmentSorter.js @@ -1,383 +1,383 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.AlignmentSorter", ["jalview.datamodel.SequenceI", "jalview.util.Comparison", "$.MessageManager", "$.QuickSort", "java.lang.Error", "$.Float", "$.StringBuffer", "java.util.ArrayList"], function () { -c$ = Clazz.declareType (jalview.analysis, "AlignmentSorter"); -c$.sortByPID = Clazz.defineMethod (c$, "sortByPID", -function (align, s, tosort) { -jalview.analysis.AlignmentSorter.sortByPID (align, s, tosort, 0, -1); -}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI,~A"); -c$.sortByPID = Clazz.defineMethod (c$, "sortByPID", -function (align, s, tosort, start, end) { -var nSeq = align.getHeight (); -var scores = Clazz.newFloatArray (nSeq, 0); -var seqs = new Array (nSeq); -for (var i = 0; i < nSeq; i++) { -scores[i] = jalview.util.Comparison.PID (align.getSequenceAt (i).getSequenceAsString (), s.getSequenceAsString ()); -seqs[i] = align.getSequenceAt (i); -} -jalview.util.QuickSort.sortFloatObject (scores, seqs); -jalview.analysis.AlignmentSorter.setReverseOrder (align, seqs); -}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI,~A,~N,~N"); -c$.setReverseOrder = Clazz.defineMethod (c$, "setReverseOrder", -($fz = function (align, seqs) { -var nSeq = seqs.length; -var len = 0; -if ((nSeq % 2) == 0) { -len = Clazz.doubleToInt (nSeq / 2); -} else { -len = Clazz.doubleToInt ((nSeq + 1) / 2); -}var asq; -{ -for (var i = 0; i < len; i++) { -asq.set (i, seqs[nSeq - i - 1]); -asq.set (nSeq - i - 1, seqs[i]); -} -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,~A"); -c$.setOrder = Clazz.defineMethod (c$, "setOrder", -($fz = function (align, tmp) { -jalview.analysis.AlignmentSorter.setOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (tmp, align.getSequences ())); -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List"); -c$.setOrder = Clazz.defineMethod (c$, "setOrder", -function (align, seqs) { -var algn; -{ -var tmp = new java.util.ArrayList (); -for (var i = 0; i < seqs.length; i++) { -if (algn.contains (seqs[i])) { -tmp.add (seqs[i]); -}} -algn.clear (); -for (var i = 0; i < tmp.size (); i++) { -algn.add (tmp.get (i)); -} -}}, "jalview.datamodel.AlignmentI,~A"); -c$.sortByID = Clazz.defineMethod (c$, "sortByID", -function (align) { -var nSeq = align.getHeight (); -var ids = new Array (nSeq); -var seqs = new Array (nSeq); -for (var i = 0; i < nSeq; i++) { -ids[i] = align.getSequenceAt (i).getName (); -seqs[i] = align.getSequenceAt (i); -} -jalview.util.QuickSort.sort (ids, seqs); -if (jalview.analysis.AlignmentSorter.sortIdAscending) { -jalview.analysis.AlignmentSorter.setReverseOrder (align, seqs); -} else { -jalview.analysis.AlignmentSorter.setOrder (align, seqs); -}jalview.analysis.AlignmentSorter.sortIdAscending = !jalview.analysis.AlignmentSorter.sortIdAscending; -}, "jalview.datamodel.AlignmentI"); -c$.sortByLength = Clazz.defineMethod (c$, "sortByLength", -function (align) { -var nSeq = align.getHeight (); -var length = Clazz.newFloatArray (nSeq, 0); -var seqs = new Array (nSeq); -for (var i = 0; i < nSeq; i++) { -seqs[i] = align.getSequenceAt (i); -length[i] = (seqs[i].getEnd () - seqs[i].getStart ()); -} -jalview.util.QuickSort.sortFloatObject (length, seqs); -if (jalview.analysis.AlignmentSorter.sortLengthAscending) { -jalview.analysis.AlignmentSorter.setReverseOrder (align, seqs); -} else { -jalview.analysis.AlignmentSorter.setOrder (align, seqs); -}jalview.analysis.AlignmentSorter.sortLengthAscending = !jalview.analysis.AlignmentSorter.sortLengthAscending; -}, "jalview.datamodel.AlignmentI"); -c$.sortByGroup = Clazz.defineMethod (c$, "sortByGroup", -function (align) { -var groups = new java.util.ArrayList (); -if (groups.hashCode () != jalview.analysis.AlignmentSorter.lastGroupHash) { -jalview.analysis.AlignmentSorter.sortGroupAscending = true; -jalview.analysis.AlignmentSorter.lastGroupHash = groups.hashCode (); -} else { -jalview.analysis.AlignmentSorter.sortGroupAscending = !jalview.analysis.AlignmentSorter.sortGroupAscending; -}for (var sg, $sg = align.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -for (var j = 0; j < groups.size (); j++) { -var sg2 = groups.get (j); -if (sg.getSize () > sg2.getSize ()) { -groups.add (j, sg); -break; -}} -if (!groups.contains (sg)) { -groups.add (sg); -}} -var seqs = new java.util.ArrayList (); -for (var i = 0; i < groups.size (); i++) { -var sg = groups.get (i); -var orderedseqs = sg.getSequencesInOrder (align); -for (var j = 0; j < orderedseqs.length; j++) { -seqs.add (orderedseqs[j]); -} -} -if (jalview.analysis.AlignmentSorter.sortGroupAscending) { -jalview.analysis.AlignmentSorter.setOrder (align, seqs); -} else { -jalview.analysis.AlignmentSorter.setReverseOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (seqs, align.getSequences ())); -}}, "jalview.datamodel.AlignmentI"); -c$.vectorSubsetToArray = Clazz.defineMethod (c$, "vectorSubsetToArray", -($fz = function (tmp, mask) { -var seqs = new java.util.ArrayList (); -var i; -var idx; -var tmask = Clazz.newBooleanArray (mask.size (), false); -for (i = 0; i < mask.size (); i++) { -tmask[i] = true; -} -for (i = 0; i < tmp.size (); i++) { -var sq = tmp.get (i); -idx = mask.indexOf (sq); -if (idx > -1 && tmask[idx]) { -tmask[idx] = false; -seqs.add (sq); -}} -for (i = 0; i < tmask.length; i++) { -if (tmask[i]) { -seqs.add (mask.get (i)); -}} -return seqs.toArray ( new Array (seqs.size ())); -}, $fz.isPrivate = true, $fz), "java.util.List,java.util.List"); -c$.sortBy = Clazz.defineMethod (c$, "sortBy", -function (align, order) { -var tmp = order.getOrder (); -if (jalview.analysis.AlignmentSorter.lastOrder === order) { -jalview.analysis.AlignmentSorter.sortOrderAscending = !jalview.analysis.AlignmentSorter.sortOrderAscending; -} else { -jalview.analysis.AlignmentSorter.sortOrderAscending = true; -}if (jalview.analysis.AlignmentSorter.sortOrderAscending) { -jalview.analysis.AlignmentSorter.setOrder (align, tmp); -} else { -jalview.analysis.AlignmentSorter.setReverseOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (tmp, align.getSequences ())); -}}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentOrder"); -c$.getOrderByTree = Clazz.defineMethod (c$, "getOrderByTree", -($fz = function (align, tree) { -var nSeq = align.getHeight (); -var tmp = new java.util.ArrayList (); -tmp = jalview.analysis.AlignmentSorter._sortByTree (tree.getTopNode (), tmp, align.getSequences ()); -if (tmp.size () != nSeq) { -if (tmp.size () != nSeq) { -jalview.analysis.AlignmentSorter.addStrays (align, tmp); -}if (tmp.size () != nSeq) { -System.err.println ("WARNING: tmp.size()=" + tmp.size () + " != nseq=" + nSeq + " in getOrderByTree - tree contains sequences not in alignment"); -}}return tmp; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,jalview.analysis.NJTree"); -c$.sortByTree = Clazz.defineMethod (c$, "sortByTree", -function (align, tree) { -var tmp = jalview.analysis.AlignmentSorter.getOrderByTree (align, tree); -if (jalview.analysis.AlignmentSorter.lastTree !== tree) { -jalview.analysis.AlignmentSorter.sortTreeAscending = true; -jalview.analysis.AlignmentSorter.lastTree = tree; -} else { -jalview.analysis.AlignmentSorter.sortTreeAscending = !jalview.analysis.AlignmentSorter.sortTreeAscending; -}if (jalview.analysis.AlignmentSorter.sortTreeAscending) { -jalview.analysis.AlignmentSorter.setOrder (align, tmp); -} else { -jalview.analysis.AlignmentSorter.setReverseOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (tmp, align.getSequences ())); -}}, "jalview.datamodel.AlignmentI,jalview.analysis.NJTree"); -c$.addStrays = Clazz.defineMethod (c$, "addStrays", -($fz = function (align, tmp) { -var nSeq = align.getHeight (); -for (var i = 0; i < nSeq; i++) { -if (!tmp.contains (align.getSequenceAt (i))) { -tmp.add (align.getSequenceAt (i)); -}} -if (nSeq != tmp.size ()) { -System.err.println ("ERROR: Size still not right even after addStrays"); -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List"); -c$._sortByTree = Clazz.defineMethod (c$, "_sortByTree", -($fz = function (node, tmp, seqset) { -if (node == null) { -return tmp; -}var left = node.left (); -var right = node.right (); -if ((left == null) && (right == null)) { -if (!node.isPlaceholder () && (node.element () != null)) { -if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { -if (!tmp.contains (node.element ())) { -tmp.add (node.element ()); -}}}return tmp; -} else { -jalview.analysis.AlignmentSorter._sortByTree (left, tmp, seqset); -jalview.analysis.AlignmentSorter._sortByTree (right, tmp, seqset); -}return tmp; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode,java.util.List,java.util.List"); -c$.recoverOrder = Clazz.defineMethod (c$, "recoverOrder", -function (alignment) { -var ids = Clazz.newFloatArray (alignment.length, 0); -for (var i = 0; i < alignment.length; i++) { -ids[i] = ( new Float (alignment[i].getName ().substring (8))).floatValue (); -} -jalview.util.QuickSort.sortFloatObject (ids, alignment); -}, "~A"); -c$.sortByAnnotationScore = Clazz.defineMethod (c$, "sortByAnnotationScore", -function (scoreLabel, alignment) { -var seqs = alignment.getSequencesArray (); -var hasScore = Clazz.newBooleanArray (seqs.length, false); -var hasScores = 0; -var scores = Clazz.newDoubleArray (seqs.length, 0); -var min = 0; -var max = 0; -for (var i = 0; i < seqs.length; i++) { -var scoreAnn = seqs[i].getAnnotation (scoreLabel); -if (scoreAnn != null) { -hasScores++; -hasScore[i] = true; -scores[i] = scoreAnn[0].getScore (); -if (hasScores == 1) { -max = min = scores[i]; -} else { -if (max < scores[i]) { -max = scores[i]; -}if (min > scores[i]) { -min = scores[i]; -}}} else { -hasScore[i] = false; -}} -if (hasScores == 0) { -return; -}if (hasScores < seqs.length) { -for (var i = 0; i < seqs.length; i++) { -if (!hasScore[i]) { -scores[i] = (max + i + 1.0); -}} -}jalview.util.QuickSort.sortDouble (scores, seqs); -if (jalview.analysis.AlignmentSorter.lastSortByScore !== scoreLabel) { -jalview.analysis.AlignmentSorter.lastSortByScore = scoreLabel; -jalview.analysis.AlignmentSorter.setOrder (alignment, seqs); -} else { -jalview.analysis.AlignmentSorter.setReverseOrder (alignment, seqs); -}}, "~S,jalview.datamodel.AlignmentI"); -c$.sortByFeature = Clazz.defineMethod (c$, "sortByFeature", -function (featureLabel, groupLabel, start, stop, alignment, method) { -jalview.analysis.AlignmentSorter.sortByFeature (featureLabel == null ? null : Clazz.newArray (-1, [featureLabel]), groupLabel == null ? null : Clazz.newArray (-1, [groupLabel]), start, stop, alignment, method); -}, "~S,~S,~N,~N,jalview.datamodel.AlignmentI,~S"); -c$.containsIgnoreCase = Clazz.defineMethod (c$, "containsIgnoreCase", -($fz = function (lab, labs) { -if (labs == null) { -return true; -}if (lab == null) { -return false; -}for (var q = 0; q < labs.length; q++) { -if (labs[q] != null && lab.equalsIgnoreCase (labs[q])) { -return true; -}} -return false; -}, $fz.isPrivate = true, $fz), "~S,~A"); -c$.sortByFeature = Clazz.defineMethod (c$, "sortByFeature", -function (featureLabels, groupLabels, start, stop, alignment, method) { -if (method !== jalview.analysis.AlignmentSorter.FEATURE_SCORE && method !== jalview.analysis.AlignmentSorter.FEATURE_LABEL && method !== jalview.analysis.AlignmentSorter.FEATURE_DENSITY) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_sortbyfeature")); -}var ignoreScore = method !== jalview.analysis.AlignmentSorter.FEATURE_SCORE; -var scoreLabel = new StringBuffer (); -scoreLabel.append (start + stop + method); -for (var i = 0; featureLabels != null && i < featureLabels.length; i++) { -scoreLabel.append (featureLabels[i] == null ? "null" : featureLabels[i]); -} -for (var i = 0; groupLabels != null && i < groupLabels.length; i++) { -scoreLabel.append (groupLabels[i] == null ? "null" : groupLabels[i]); -} -var seqs = alignment.getSequencesArray (); -var hasScore = Clazz.newBooleanArray (seqs.length, false); -var hasScores = 0; -var scores = Clazz.newDoubleArray (seqs.length, 0); -var seqScores = Clazz.newIntArray (seqs.length, 0); -var feats = new Array (seqs.length); -var min = 0; -var max = 0; -for (var i = 0; i < seqs.length; i++) { -var sf = seqs[i].getSequenceFeatures (); -if (sf == null) { -sf = new Array (0); -} else { -var tmp = new Array (sf.length); -for (var s = 0; s < tmp.length; s++) { -tmp[s] = sf[s]; -} -sf = tmp; -}var sstart = (start == -1) ? start : seqs[i].findPosition (start); -var sstop = (stop == -1) ? stop : seqs[i].findPosition (stop); -seqScores[i] = 0; -scores[i] = 0.0; -var n = sf.length; -for (var f = 0; f < sf.length; f++) { -if ((sf[f].end < sstart || sf[f].begin > sstop) || (featureLabels != null && !jalview.analysis.AlignmentSorter.containsIgnoreCase (sf[f].type, featureLabels)) || (groupLabels != null && (sf[f].getFeatureGroup () != null && !jalview.analysis.AlignmentSorter.containsIgnoreCase (sf[f].getFeatureGroup (), groupLabels)))) { -sf[f] = null; -n--; -} else { -if (!ignoreScore && !Float.isNaN (sf[f].getScore ())) { -if (seqScores[i] == 0) { -hasScores++; -}seqScores[i]++; -hasScore[i] = true; -scores[i] += sf[f].getScore (); -}}} -var fs; -feats[i] = fs = new Array (n); -if (n > 0) { -n = 0; -for (var f = 0; f < sf.length; f++) { -if (sf[f] != null) { -(feats[i])[n++] = sf[f]; -}} -if (method === jalview.analysis.AlignmentSorter.FEATURE_LABEL) { -var labs = new Array (fs.length); -for (var l = 0; l < labs.length; l++) { -labs[l] = (fs[l].getDescription () != null ? fs[l].getDescription () : fs[l].getType ()); -} -jalview.util.QuickSort.sort (labs, (feats[i])); -}}if (hasScore[i]) { -scores[i] /= seqScores[i]; -if (hasScores == 1) { -max = min = scores[i]; -} else { -if (max < scores[i]) { -max = scores[i]; -}if (min > scores[i]) { -min = scores[i]; -}}}} -if (method === jalview.analysis.AlignmentSorter.FEATURE_SCORE) { -if (hasScores == 0) { -return; -}if (hasScores < seqs.length) { -for (var i = 0; i < seqs.length; i++) { -if (!hasScore[i]) { -scores[i] = (max + 1 + i); -} else { -var nf = (feats[i] == null) ? 0 : (feats[i]).length; -}} -}jalview.util.QuickSort.sortDouble (scores, seqs); -} else if (method === jalview.analysis.AlignmentSorter.FEATURE_DENSITY) { -var fr = 0.9 / (1.0 * seqs.length); -for (var i = 0; i < seqs.length; i++) { -var nf; -scores[i] = (0.05 + fr * i) + (nf = ((feats[i] == null) ? 0.0 : 1.0 * (feats[i]).length)); -} -jalview.util.QuickSort.sortDouble (scores, seqs); -} else { -if (method === jalview.analysis.AlignmentSorter.FEATURE_LABEL) { -throw new Error (jalview.util.MessageManager.getString ("error.not_yet_implemented")); -}}if (jalview.analysis.AlignmentSorter.lastSortByFeatureScore == null || !scoreLabel.toString ().equals (jalview.analysis.AlignmentSorter.lastSortByFeatureScore)) { -jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending = true; -} else { -jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending = !jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending; -}if (jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending) { -jalview.analysis.AlignmentSorter.setOrder (alignment, seqs); -} else { -jalview.analysis.AlignmentSorter.setReverseOrder (alignment, seqs); -}jalview.analysis.AlignmentSorter.lastSortByFeatureScore = scoreLabel.toString (); -}, "~A,~A,~N,~N,jalview.datamodel.AlignmentI,~S"); -Clazz.defineStatics (c$, -"sortIdAscending", true, -"lastGroupHash", 0, -"sortGroupAscending", true, -"lastOrder", null, -"sortOrderAscending", true, -"lastTree", null, -"sortTreeAscending", true, -"lastSortByScore", null, -"sortByScoreAscending", true, -"lastSortByFeatureScore", null, -"sortByFeatureScoreAscending", true, -"sortLengthAscending", false, -"FEATURE_SCORE", "average_score", -"FEATURE_LABEL", "text", -"FEATURE_DENSITY", "density"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.AlignmentSorter", ["jalview.datamodel.SequenceI", "jalview.util.Comparison", "$.MessageManager", "$.QuickSort", "java.lang.Error", "$.Float", "$.StringBuffer", "java.util.ArrayList"], function () { +c$ = Clazz.declareType (jalview.analysis, "AlignmentSorter"); +c$.sortByPID = Clazz.defineMethod (c$, "sortByPID", +function (align, s, tosort) { +jalview.analysis.AlignmentSorter.sortByPID (align, s, tosort, 0, -1); +}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI,~A"); +c$.sortByPID = Clazz.defineMethod (c$, "sortByPID", +function (align, s, tosort, start, end) { +var nSeq = align.getHeight (); +var scores = Clazz.newFloatArray (nSeq, 0); +var seqs = new Array (nSeq); +for (var i = 0; i < nSeq; i++) { +scores[i] = jalview.util.Comparison.PID (align.getSequenceAt (i).getSequenceAsString (), s.getSequenceAsString ()); +seqs[i] = align.getSequenceAt (i); +} +jalview.util.QuickSort.sortFloatObject (scores, seqs); +jalview.analysis.AlignmentSorter.setReverseOrder (align, seqs); +}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI,~A,~N,~N"); +c$.setReverseOrder = Clazz.defineMethod (c$, "setReverseOrder", +($fz = function (align, seqs) { +var nSeq = seqs.length; +var len = 0; +if ((nSeq % 2) == 0) { +len = Clazz.doubleToInt (nSeq / 2); +} else { +len = Clazz.doubleToInt ((nSeq + 1) / 2); +}var asq; +{ +for (var i = 0; i < len; i++) { +asq.set (i, seqs[nSeq - i - 1]); +asq.set (nSeq - i - 1, seqs[i]); +} +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,~A"); +c$.setOrder = Clazz.defineMethod (c$, "setOrder", +($fz = function (align, tmp) { +jalview.analysis.AlignmentSorter.setOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (tmp, align.getSequences ())); +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List"); +c$.setOrder = Clazz.defineMethod (c$, "setOrder", +function (align, seqs) { +var algn; +{ +var tmp = new java.util.ArrayList (); +for (var i = 0; i < seqs.length; i++) { +if (algn.contains (seqs[i])) { +tmp.add (seqs[i]); +}} +algn.clear (); +for (var i = 0; i < tmp.size (); i++) { +algn.add (tmp.get (i)); +} +}}, "jalview.datamodel.AlignmentI,~A"); +c$.sortByID = Clazz.defineMethod (c$, "sortByID", +function (align) { +var nSeq = align.getHeight (); +var ids = new Array (nSeq); +var seqs = new Array (nSeq); +for (var i = 0; i < nSeq; i++) { +ids[i] = align.getSequenceAt (i).getName (); +seqs[i] = align.getSequenceAt (i); +} +jalview.util.QuickSort.sort (ids, seqs); +if (jalview.analysis.AlignmentSorter.sortIdAscending) { +jalview.analysis.AlignmentSorter.setReverseOrder (align, seqs); +} else { +jalview.analysis.AlignmentSorter.setOrder (align, seqs); +}jalview.analysis.AlignmentSorter.sortIdAscending = !jalview.analysis.AlignmentSorter.sortIdAscending; +}, "jalview.datamodel.AlignmentI"); +c$.sortByLength = Clazz.defineMethod (c$, "sortByLength", +function (align) { +var nSeq = align.getHeight (); +var length = Clazz.newFloatArray (nSeq, 0); +var seqs = new Array (nSeq); +for (var i = 0; i < nSeq; i++) { +seqs[i] = align.getSequenceAt (i); +length[i] = (seqs[i].getEnd () - seqs[i].getStart ()); +} +jalview.util.QuickSort.sortFloatObject (length, seqs); +if (jalview.analysis.AlignmentSorter.sortLengthAscending) { +jalview.analysis.AlignmentSorter.setReverseOrder (align, seqs); +} else { +jalview.analysis.AlignmentSorter.setOrder (align, seqs); +}jalview.analysis.AlignmentSorter.sortLengthAscending = !jalview.analysis.AlignmentSorter.sortLengthAscending; +}, "jalview.datamodel.AlignmentI"); +c$.sortByGroup = Clazz.defineMethod (c$, "sortByGroup", +function (align) { +var groups = new java.util.ArrayList (); +if (groups.hashCode () != jalview.analysis.AlignmentSorter.lastGroupHash) { +jalview.analysis.AlignmentSorter.sortGroupAscending = true; +jalview.analysis.AlignmentSorter.lastGroupHash = groups.hashCode (); +} else { +jalview.analysis.AlignmentSorter.sortGroupAscending = !jalview.analysis.AlignmentSorter.sortGroupAscending; +}for (var sg, $sg = align.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +for (var j = 0; j < groups.size (); j++) { +var sg2 = groups.get (j); +if (sg.getSize () > sg2.getSize ()) { +groups.add (j, sg); +break; +}} +if (!groups.contains (sg)) { +groups.add (sg); +}} +var seqs = new java.util.ArrayList (); +for (var i = 0; i < groups.size (); i++) { +var sg = groups.get (i); +var orderedseqs = sg.getSequencesInOrder (align); +for (var j = 0; j < orderedseqs.length; j++) { +seqs.add (orderedseqs[j]); +} +} +if (jalview.analysis.AlignmentSorter.sortGroupAscending) { +jalview.analysis.AlignmentSorter.setOrder (align, seqs); +} else { +jalview.analysis.AlignmentSorter.setReverseOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (seqs, align.getSequences ())); +}}, "jalview.datamodel.AlignmentI"); +c$.vectorSubsetToArray = Clazz.defineMethod (c$, "vectorSubsetToArray", +($fz = function (tmp, mask) { +var seqs = new java.util.ArrayList (); +var i; +var idx; +var tmask = Clazz.newBooleanArray (mask.size (), false); +for (i = 0; i < mask.size (); i++) { +tmask[i] = true; +} +for (i = 0; i < tmp.size (); i++) { +var sq = tmp.get (i); +idx = mask.indexOf (sq); +if (idx > -1 && tmask[idx]) { +tmask[idx] = false; +seqs.add (sq); +}} +for (i = 0; i < tmask.length; i++) { +if (tmask[i]) { +seqs.add (mask.get (i)); +}} +return seqs.toArray ( new Array (seqs.size ())); +}, $fz.isPrivate = true, $fz), "java.util.List,java.util.List"); +c$.sortBy = Clazz.defineMethod (c$, "sortBy", +function (align, order) { +var tmp = order.getOrder (); +if (jalview.analysis.AlignmentSorter.lastOrder === order) { +jalview.analysis.AlignmentSorter.sortOrderAscending = !jalview.analysis.AlignmentSorter.sortOrderAscending; +} else { +jalview.analysis.AlignmentSorter.sortOrderAscending = true; +}if (jalview.analysis.AlignmentSorter.sortOrderAscending) { +jalview.analysis.AlignmentSorter.setOrder (align, tmp); +} else { +jalview.analysis.AlignmentSorter.setReverseOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (tmp, align.getSequences ())); +}}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentOrder"); +c$.getOrderByTree = Clazz.defineMethod (c$, "getOrderByTree", +($fz = function (align, tree) { +var nSeq = align.getHeight (); +var tmp = new java.util.ArrayList (); +tmp = jalview.analysis.AlignmentSorter._sortByTree (tree.getTopNode (), tmp, align.getSequences ()); +if (tmp.size () != nSeq) { +if (tmp.size () != nSeq) { +jalview.analysis.AlignmentSorter.addStrays (align, tmp); +}if (tmp.size () != nSeq) { +System.err.println ("WARNING: tmp.size()=" + tmp.size () + " != nseq=" + nSeq + " in getOrderByTree - tree contains sequences not in alignment"); +}}return tmp; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,jalview.analysis.NJTree"); +c$.sortByTree = Clazz.defineMethod (c$, "sortByTree", +function (align, tree) { +var tmp = jalview.analysis.AlignmentSorter.getOrderByTree (align, tree); +if (jalview.analysis.AlignmentSorter.lastTree !== tree) { +jalview.analysis.AlignmentSorter.sortTreeAscending = true; +jalview.analysis.AlignmentSorter.lastTree = tree; +} else { +jalview.analysis.AlignmentSorter.sortTreeAscending = !jalview.analysis.AlignmentSorter.sortTreeAscending; +}if (jalview.analysis.AlignmentSorter.sortTreeAscending) { +jalview.analysis.AlignmentSorter.setOrder (align, tmp); +} else { +jalview.analysis.AlignmentSorter.setReverseOrder (align, jalview.analysis.AlignmentSorter.vectorSubsetToArray (tmp, align.getSequences ())); +}}, "jalview.datamodel.AlignmentI,jalview.analysis.NJTree"); +c$.addStrays = Clazz.defineMethod (c$, "addStrays", +($fz = function (align, tmp) { +var nSeq = align.getHeight (); +for (var i = 0; i < nSeq; i++) { +if (!tmp.contains (align.getSequenceAt (i))) { +tmp.add (align.getSequenceAt (i)); +}} +if (nSeq != tmp.size ()) { +System.err.println ("ERROR: Size still not right even after addStrays"); +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List"); +c$._sortByTree = Clazz.defineMethod (c$, "_sortByTree", +($fz = function (node, tmp, seqset) { +if (node == null) { +return tmp; +}var left = node.left (); +var right = node.right (); +if ((left == null) && (right == null)) { +if (!node.isPlaceholder () && (node.element () != null)) { +if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { +if (!tmp.contains (node.element ())) { +tmp.add (node.element ()); +}}}return tmp; +} else { +jalview.analysis.AlignmentSorter._sortByTree (left, tmp, seqset); +jalview.analysis.AlignmentSorter._sortByTree (right, tmp, seqset); +}return tmp; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode,java.util.List,java.util.List"); +c$.recoverOrder = Clazz.defineMethod (c$, "recoverOrder", +function (alignment) { +var ids = Clazz.newFloatArray (alignment.length, 0); +for (var i = 0; i < alignment.length; i++) { +ids[i] = ( new Float (alignment[i].getName ().substring (8))).floatValue (); +} +jalview.util.QuickSort.sortFloatObject (ids, alignment); +}, "~A"); +c$.sortByAnnotationScore = Clazz.defineMethod (c$, "sortByAnnotationScore", +function (scoreLabel, alignment) { +var seqs = alignment.getSequencesArray (); +var hasScore = Clazz.newBooleanArray (seqs.length, false); +var hasScores = 0; +var scores = Clazz.newDoubleArray (seqs.length, 0); +var min = 0; +var max = 0; +for (var i = 0; i < seqs.length; i++) { +var scoreAnn = seqs[i].getAnnotation (scoreLabel); +if (scoreAnn != null) { +hasScores++; +hasScore[i] = true; +scores[i] = scoreAnn[0].getScore (); +if (hasScores == 1) { +max = min = scores[i]; +} else { +if (max < scores[i]) { +max = scores[i]; +}if (min > scores[i]) { +min = scores[i]; +}}} else { +hasScore[i] = false; +}} +if (hasScores == 0) { +return; +}if (hasScores < seqs.length) { +for (var i = 0; i < seqs.length; i++) { +if (!hasScore[i]) { +scores[i] = (max + i + 1.0); +}} +}jalview.util.QuickSort.sortDouble (scores, seqs); +if (jalview.analysis.AlignmentSorter.lastSortByScore !== scoreLabel) { +jalview.analysis.AlignmentSorter.lastSortByScore = scoreLabel; +jalview.analysis.AlignmentSorter.setOrder (alignment, seqs); +} else { +jalview.analysis.AlignmentSorter.setReverseOrder (alignment, seqs); +}}, "~S,jalview.datamodel.AlignmentI"); +c$.sortByFeature = Clazz.defineMethod (c$, "sortByFeature", +function (featureLabel, groupLabel, start, stop, alignment, method) { +jalview.analysis.AlignmentSorter.sortByFeature (featureLabel == null ? null : Clazz.newArray (-1, [featureLabel]), groupLabel == null ? null : Clazz.newArray (-1, [groupLabel]), start, stop, alignment, method); +}, "~S,~S,~N,~N,jalview.datamodel.AlignmentI,~S"); +c$.containsIgnoreCase = Clazz.defineMethod (c$, "containsIgnoreCase", +($fz = function (lab, labs) { +if (labs == null) { +return true; +}if (lab == null) { +return false; +}for (var q = 0; q < labs.length; q++) { +if (labs[q] != null && lab.equalsIgnoreCase (labs[q])) { +return true; +}} +return false; +}, $fz.isPrivate = true, $fz), "~S,~A"); +c$.sortByFeature = Clazz.defineMethod (c$, "sortByFeature", +function (featureLabels, groupLabels, start, stop, alignment, method) { +if (method !== jalview.analysis.AlignmentSorter.FEATURE_SCORE && method !== jalview.analysis.AlignmentSorter.FEATURE_LABEL && method !== jalview.analysis.AlignmentSorter.FEATURE_DENSITY) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_sortbyfeature")); +}var ignoreScore = method !== jalview.analysis.AlignmentSorter.FEATURE_SCORE; +var scoreLabel = new StringBuffer (); +scoreLabel.append (start + stop + method); +for (var i = 0; featureLabels != null && i < featureLabels.length; i++) { +scoreLabel.append (featureLabels[i] == null ? "null" : featureLabels[i]); +} +for (var i = 0; groupLabels != null && i < groupLabels.length; i++) { +scoreLabel.append (groupLabels[i] == null ? "null" : groupLabels[i]); +} +var seqs = alignment.getSequencesArray (); +var hasScore = Clazz.newBooleanArray (seqs.length, false); +var hasScores = 0; +var scores = Clazz.newDoubleArray (seqs.length, 0); +var seqScores = Clazz.newIntArray (seqs.length, 0); +var feats = new Array (seqs.length); +var min = 0; +var max = 0; +for (var i = 0; i < seqs.length; i++) { +var sf = seqs[i].getSequenceFeatures (); +if (sf == null) { +sf = new Array (0); +} else { +var tmp = new Array (sf.length); +for (var s = 0; s < tmp.length; s++) { +tmp[s] = sf[s]; +} +sf = tmp; +}var sstart = (start == -1) ? start : seqs[i].findPosition (start); +var sstop = (stop == -1) ? stop : seqs[i].findPosition (stop); +seqScores[i] = 0; +scores[i] = 0.0; +var n = sf.length; +for (var f = 0; f < sf.length; f++) { +if ((sf[f].end < sstart || sf[f].begin > sstop) || (featureLabels != null && !jalview.analysis.AlignmentSorter.containsIgnoreCase (sf[f].type, featureLabels)) || (groupLabels != null && (sf[f].getFeatureGroup () != null && !jalview.analysis.AlignmentSorter.containsIgnoreCase (sf[f].getFeatureGroup (), groupLabels)))) { +sf[f] = null; +n--; +} else { +if (!ignoreScore && !Float.isNaN (sf[f].getScore ())) { +if (seqScores[i] == 0) { +hasScores++; +}seqScores[i]++; +hasScore[i] = true; +scores[i] += sf[f].getScore (); +}}} +var fs; +feats[i] = fs = new Array (n); +if (n > 0) { +n = 0; +for (var f = 0; f < sf.length; f++) { +if (sf[f] != null) { +(feats[i])[n++] = sf[f]; +}} +if (method === jalview.analysis.AlignmentSorter.FEATURE_LABEL) { +var labs = new Array (fs.length); +for (var l = 0; l < labs.length; l++) { +labs[l] = (fs[l].getDescription () != null ? fs[l].getDescription () : fs[l].getType ()); +} +jalview.util.QuickSort.sort (labs, (feats[i])); +}}if (hasScore[i]) { +scores[i] /= seqScores[i]; +if (hasScores == 1) { +max = min = scores[i]; +} else { +if (max < scores[i]) { +max = scores[i]; +}if (min > scores[i]) { +min = scores[i]; +}}}} +if (method === jalview.analysis.AlignmentSorter.FEATURE_SCORE) { +if (hasScores == 0) { +return; +}if (hasScores < seqs.length) { +for (var i = 0; i < seqs.length; i++) { +if (!hasScore[i]) { +scores[i] = (max + 1 + i); +} else { +var nf = (feats[i] == null) ? 0 : (feats[i]).length; +}} +}jalview.util.QuickSort.sortDouble (scores, seqs); +} else if (method === jalview.analysis.AlignmentSorter.FEATURE_DENSITY) { +var fr = 0.9 / (1.0 * seqs.length); +for (var i = 0; i < seqs.length; i++) { +var nf; +scores[i] = (0.05 + fr * i) + (nf = ((feats[i] == null) ? 0.0 : 1.0 * (feats[i]).length)); +} +jalview.util.QuickSort.sortDouble (scores, seqs); +} else { +if (method === jalview.analysis.AlignmentSorter.FEATURE_LABEL) { +throw new Error (jalview.util.MessageManager.getString ("error.not_yet_implemented")); +}}if (jalview.analysis.AlignmentSorter.lastSortByFeatureScore == null || !scoreLabel.toString ().equals (jalview.analysis.AlignmentSorter.lastSortByFeatureScore)) { +jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending = true; +} else { +jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending = !jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending; +}if (jalview.analysis.AlignmentSorter.sortByFeatureScoreAscending) { +jalview.analysis.AlignmentSorter.setOrder (alignment, seqs); +} else { +jalview.analysis.AlignmentSorter.setReverseOrder (alignment, seqs); +}jalview.analysis.AlignmentSorter.lastSortByFeatureScore = scoreLabel.toString (); +}, "~A,~A,~N,~N,jalview.datamodel.AlignmentI,~S"); +Clazz.defineStatics (c$, +"sortIdAscending", true, +"lastGroupHash", 0, +"sortGroupAscending", true, +"lastOrder", null, +"sortOrderAscending", true, +"lastTree", null, +"sortTreeAscending", true, +"lastSortByScore", null, +"sortByScoreAscending", true, +"lastSortByFeatureScore", null, +"sortByFeatureScoreAscending", true, +"sortLengthAscending", false, +"FEATURE_SCORE", "average_score", +"FEATURE_LABEL", "text", +"FEATURE_DENSITY", "density"); +}); diff --git a/bin/jalview/analysis/AlignmentUtils.js b/bin/jalview/analysis/AlignmentUtils.js index 2990b03..6af5e7a 100644 --- a/bin/jalview/analysis/AlignmentUtils.js +++ b/bin/jalview/analysis/AlignmentUtils.js @@ -1,532 +1,532 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.AlignmentUtils", ["jalview.analysis.CodonComparator", "jalview.datamodel.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.DBRefEntry", "$.DBRefSource", "$.FeatureProperties", "$.SearchResults", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.DBRefUtils", "$.MapList", "$.MappingUtils", "java.lang.StringBuilder", "java.util.ArrayList", "$.Arrays", "$.HashMap", "$.HashSet", "$.LinkedHashMap", "$.LinkedHashSet", "$.TreeMap"], function () { -c$ = Clazz.declareType (jalview.analysis, "AlignmentUtils"); -c$.expandContext = Clazz.defineMethod (c$, "expandContext", -function (core, flankSize) { -var sq = new java.util.ArrayList (); -var maxoffset = 0; -for (var s, $s = core.getSequences ().iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { -var newSeq = s.deriveSequence (); -var newSeqStart = newSeq.getStart () - 1; -if (newSeqStart > maxoffset && newSeq.getDatasetSequence ().getStart () < s.getStart ()) { -maxoffset = newSeqStart; -}sq.add (newSeq); -} -if (flankSize > -1) { -maxoffset = Math.min (maxoffset, flankSize); -}for (var s, $s = sq.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { -var ds = s; -while (ds.getDatasetSequence () != null) { -ds = ds.getDatasetSequence (); -} -var s_end = s.findPosition (s.getStart () + s.getLength ()); -var ustream_ds = s.getStart () - ds.getStart (); -var dstream_ds = ds.getEnd () - s_end; -var offset = maxoffset - ustream_ds; -if (flankSize >= 0) { -if (flankSize < ustream_ds) { -offset = maxoffset - flankSize; -ustream_ds = flankSize; -}if (flankSize <= dstream_ds) { -dstream_ds = flankSize - 1; -}}var upstream = String.instantialize (ds.getSequence (s.getStart () - 1 - ustream_ds, s.getStart () - 1)).toLowerCase ().toCharArray (); -var downstream = String.instantialize (ds.getSequence (s_end - 1, s_end + dstream_ds)).toLowerCase ().toCharArray (); -var coreseq = s.getSequence (); -var nseq = Clazz.newCharArray (offset + upstream.length + downstream.length + coreseq.length, '\0'); -var c = core.getGapCharacter (); -var p = 0; -for (; p < offset; p++) { -nseq[p] = c; -} -System.arraycopy (upstream, 0, nseq, p, upstream.length); -System.arraycopy (coreseq, 0, nseq, p + upstream.length, coreseq.length); -System.arraycopy (downstream, 0, nseq, p + coreseq.length + upstream.length, downstream.length); -s.setSequence ( String.instantialize (nseq)); -s.setStart (s.getStart () - ustream_ds); -s.setEnd (s_end + downstream.length); -} -var newAl = new jalview.datamodel.Alignment (sq.toArray ( new Array (0))); -for (var s, $s = sq.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { -if (s.getAnnotation () != null) { -for (var aa, $aa = 0, $$aa = s.getAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { -aa.adjustForAlignment (); -newAl.addAnnotation (aa); -} -}} -newAl.setDataset (core.getDataset ()); -return newAl; -}, "jalview.datamodel.AlignmentI,~N"); -c$.getSequenceIndex = Clazz.defineMethod (c$, "getSequenceIndex", -function (al, seq) { -var result = -1; -var pos = 0; -for (var alSeq, $alSeq = al.getSequences ().iterator (); $alSeq.hasNext () && ((alSeq = $alSeq.next ()) || true);) { -if (alSeq === seq) { -result = pos; -break; -}pos++; -} -return result; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI"); -c$.getSequencesByName = Clazz.defineMethod (c$, "getSequencesByName", -function (al) { -var theMap = new java.util.LinkedHashMap (); -for (var seq, $seq = al.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -var name = seq.getName (); -if (name != null) { -var seqs = theMap.get (name); -if (seqs == null) { -seqs = new java.util.ArrayList (); -theMap.put (name, seqs); -}seqs.add (seq); -}} -return theMap; -}, "jalview.datamodel.AlignmentI"); -c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna", -function (proteinAlignment, cdnaAlignment) { -if (proteinAlignment == null || cdnaAlignment == null) { -return false; -}var mappedDna = new java.util.HashSet (); -var mappedProtein = new java.util.HashSet (); -var mappingPerformed = jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, true); -mappingPerformed = new Boolean (mappingPerformed | jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, false)).valueOf (); -return mappingPerformed; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); -c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna", -function (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, xrefsOnly) { -var mappingPerformed = false; -var thisSeqs = proteinAlignment.getSequences (); -for (var aaSeq, $aaSeq = thisSeqs.iterator (); $aaSeq.hasNext () && ((aaSeq = $aaSeq.next ()) || true);) { -var proteinMapped = false; -var acf = new jalview.datamodel.AlignedCodonFrame (); -for (var cdnaSeq, $cdnaSeq = cdnaAlignment.getSequences ().iterator (); $cdnaSeq.hasNext () && ((cdnaSeq = $cdnaSeq.next ()) || true);) { -if (xrefsOnly && !jalview.analysis.AlignmentUtils.haveCrossRef (aaSeq, cdnaSeq)) { -continue; -}if (!xrefsOnly && (mappedProtein.contains (aaSeq) || mappedDna.contains (cdnaSeq))) { -continue; -}if (!jalview.analysis.AlignmentUtils.mappingExists (proteinAlignment.getCodonFrames (), aaSeq.getDatasetSequence (), cdnaSeq.getDatasetSequence ())) { -var map = jalview.analysis.AlignmentUtils.mapProteinToCdna (aaSeq, cdnaSeq); -if (map != null) { -acf.addMap (cdnaSeq, aaSeq, map); -mappingPerformed = true; -proteinMapped = true; -mappedDna.add (cdnaSeq); -mappedProtein.add (aaSeq); -}}} -if (proteinMapped) { -proteinAlignment.addCodonFrame (acf); -}} -return mappingPerformed; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI,java.util.Set,java.util.Set,~B"); -c$.mappingExists = Clazz.defineMethod (c$, "mappingExists", -function (set, aaSeq, cdnaSeq) { -if (set != null) { -for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -if (cdnaSeq === acf.getDnaForAaSeq (aaSeq)) { -return true; -}} -}return false; -}, "java.util.Set,jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna", -function (proteinSeq, cdnaSeq) { -var proteinDataset = proteinSeq.getDatasetSequence (); -var aaSeqChars = proteinDataset != null ? proteinDataset.getSequence () : proteinSeq.getSequence (); -var cdnaDataset = cdnaSeq.getDatasetSequence (); -var cdnaSeqChars = cdnaDataset != null ? cdnaDataset.getSequence () : cdnaSeq.getSequence (); -if (aaSeqChars == null || cdnaSeqChars == null) { -return null; -}var mappedLength = 3 * aaSeqChars.length; -var cdnaLength = cdnaSeqChars.length; -var cdnaStart = 1; -var cdnaEnd = cdnaLength; -var proteinStart = 1; -var proteinEnd = aaSeqChars.length; -if (cdnaLength != mappedLength && cdnaLength > 2) { -var lastCodon = String.valueOf (cdnaSeqChars, cdnaLength - 3, 3).toUpperCase (); -for (var stop, $stop = jalview.schemes.ResidueProperties.STOP.iterator (); $stop.hasNext () && ((stop = $stop.next ()) || true);) { -if (lastCodon.equals (stop)) { -cdnaEnd -= 3; -cdnaLength -= 3; -break; -}} -}if (cdnaLength != mappedLength && cdnaLength > 2 && String.valueOf (cdnaSeqChars, 0, 3).toUpperCase ().equals (jalview.schemes.ResidueProperties.START)) { -cdnaStart += 3; -cdnaLength -= 3; -}if (cdnaLength != mappedLength) { -return null; -}if (!jalview.analysis.AlignmentUtils.translatesAs (cdnaSeqChars, cdnaStart - 1, aaSeqChars)) { -return null; -}var map = new jalview.util.MapList ( Clazz.newIntArray (-1, [cdnaStart, cdnaEnd]), Clazz.newIntArray (-1, [1, proteinEnd]), 3, 1); -return map; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -c$.translatesAs = Clazz.defineMethod (c$, "translatesAs", -function (cdnaSeqChars, cdnaStart, aaSeqChars) { -var aaResidue = 0; -for (var i = cdnaStart; i < cdnaSeqChars.length - 2 && aaResidue < aaSeqChars.length; i += 3, aaResidue++) { -var codon = String.valueOf (cdnaSeqChars, i, 3); -var translated = jalview.schemes.ResidueProperties.codonTranslate (codon); -var aaRes = aaSeqChars[aaResidue]; -if ((translated == null || "STOP".equals (translated)) && aaRes == 'X') { -continue; -}if (translated == null || !(aaRes == translated.charAt (0))) { -return false; -}} -return (aaResidue == aaSeqChars.length); -}, "~A,~N,~A"); -c$.alignSequenceAs = Clazz.defineMethod (c$, "alignSequenceAs", -function (seq, al, gap, preserveMappedGaps, preserveUnmappedGaps) { -var mappings = al.getCodonFrame (seq); -if (mappings == null || mappings.isEmpty ()) { -return false; -}var alignFrom = null; -var mapping = null; -for (var mp, $mp = mappings.iterator (); $mp.hasNext () && ((mp = $mp.next ()) || true);) { -alignFrom = mp.findAlignedSequence (seq.getDatasetSequence (), al); -if (alignFrom != null) { -mapping = mp; -break; -}} -if (alignFrom == null) { -return false; -}jalview.analysis.AlignmentUtils.alignSequenceAs (seq, alignFrom, mapping, gap, al.getGapCharacter (), preserveMappedGaps, preserveUnmappedGaps); -return true; -}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,~S,~B,~B"); -c$.alignSequenceAs = Clazz.defineMethod (c$, "alignSequenceAs", -function (alignTo, alignFrom, mapping, myGap, sourceGap, preserveMappedGaps, preserveUnmappedGaps) { -var thisSeq = alignTo.getSequence (); -var thatAligned = alignFrom.getSequence (); -var thisAligned = new StringBuilder (2 * thisSeq.length); -var thisSeqPos = 0; -var sourceDsPos = 0; -var basesWritten = 0; -var myGapChar = myGap.charAt (0); -var ratio = myGap.length; -var sourceGapMappedLength = 0; -var inExon = false; -for (var sourceChar, $sourceChar = 0, $$sourceChar = thatAligned; $sourceChar < $$sourceChar.length && ((sourceChar = $$sourceChar[$sourceChar]) || true); $sourceChar++) { -if (sourceChar == sourceGap) { -sourceGapMappedLength += ratio; -continue; -}sourceDsPos++; -var mappedPos = mapping.getMappedRegion (alignTo, alignFrom, sourceDsPos); -if (mappedPos == null) { -System.err.println ("Can't align: no codon mapping to residue " + sourceDsPos + "(" + sourceChar + ")"); -return; -}var mappedCodonStart = mappedPos[0]; -var mappedCodonEnd = mappedPos[mappedPos.length - 1]; -var trailingCopiedGap = new StringBuilder (); -var intronLength = 0; -while (basesWritten < mappedCodonEnd && thisSeqPos < thisSeq.length) { -var c = thisSeq[thisSeqPos++]; -if (c != myGapChar) { -basesWritten++; -if (basesWritten < mappedCodonStart) { -if (preserveUnmappedGaps && trailingCopiedGap.length () > 0) { -thisAligned.append (trailingCopiedGap.toString ()); -intronLength += trailingCopiedGap.length (); -trailingCopiedGap = new StringBuilder (); -}intronLength++; -inExon = false; -} else { -var startOfCodon = basesWritten == mappedCodonStart; -var gapsToAdd = jalview.analysis.AlignmentUtils.calculateGapsToInsert (preserveMappedGaps, preserveUnmappedGaps, sourceGapMappedLength, inExon, trailingCopiedGap.length (), intronLength, startOfCodon); -for (var i = 0; i < gapsToAdd; i++) { -thisAligned.append (myGapChar); -} -sourceGapMappedLength = 0; -inExon = true; -}thisAligned.append (c); -trailingCopiedGap = new StringBuilder (); -} else { -if (inExon && preserveMappedGaps) { -trailingCopiedGap.append (myGapChar); -} else if (!inExon && preserveUnmappedGaps) { -trailingCopiedGap.append (myGapChar); -}}} -} -while (thisSeqPos < thisSeq.length) { -var c = thisSeq[thisSeqPos++]; -if (c != myGapChar || preserveUnmappedGaps) { -thisAligned.append (c); -}} -alignTo.setSequence ( String.instantialize (thisAligned)); -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.datamodel.AlignedCodonFrame,~S,~S,~B,~B"); -c$.calculateGapsToInsert = Clazz.defineMethod (c$, "calculateGapsToInsert", -function (preserveMappedGaps, preserveUnmappedGaps, sourceGapMappedLength, inExon, trailingGapLength, intronLength, startOfCodon) { -var gapsToAdd = 0; -if (startOfCodon) { -if (inExon && !preserveMappedGaps) { -trailingGapLength = 0; -}if (!inExon && !(preserveMappedGaps && preserveUnmappedGaps)) { -trailingGapLength = 0; -}if (inExon) { -gapsToAdd = Math.max (sourceGapMappedLength, trailingGapLength); -} else { -if (intronLength + trailingGapLength <= sourceGapMappedLength) { -gapsToAdd = sourceGapMappedLength - intronLength; -} else { -gapsToAdd = Math.min (intronLength + trailingGapLength - sourceGapMappedLength, trailingGapLength); -}}} else { -if (!preserveMappedGaps) { -trailingGapLength = 0; -}gapsToAdd = Math.max (sourceGapMappedLength, trailingGapLength); -}return gapsToAdd; -}, "~B,~B,~N,~B,~N,~N,~B"); -c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation", -function (sequences, gapCharacter, mappings) { -var alignedSeqs = new java.util.ArrayList (); -for (var seq, $seq = sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -var mapped = jalview.analysis.AlignmentUtils.getAlignedTranslation (seq, gapCharacter, mappings); -alignedSeqs.addAll (mapped); -} -return alignedSeqs; -}, "java.util.List,~S,java.util.Set"); -c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation", -function (seq, gapCharacter, mappings) { -var result = new java.util.ArrayList (); -for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { -if (mapping.involvesSequence (seq)) { -var mapped = jalview.analysis.AlignmentUtils.getAlignedTranslation (seq, gapCharacter, mapping); -if (mapped != null) { -result.add (mapped); -}}} -return result; -}, "jalview.datamodel.SequenceI,~S,java.util.Set"); -c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation", -function (seq, gapCharacter, mapping) { -var gap = String.valueOf (gapCharacter); -var toDna = false; -var fromRatio = 1; -var mapTo = mapping.getDnaForAaSeq (seq); -if (mapTo != null) { -toDna = true; -gap = String.valueOf ( Clazz.newCharArray (-1, [gapCharacter, gapCharacter, gapCharacter])); -} else { -mapTo = mapping.getAaForDnaSeq (seq); -fromRatio = 3; -}var newseq = new StringBuilder (seq.getLength () * (toDna ? 3 : 1)); -var residueNo = 0; -var phrase = Clazz.newIntArray (fromRatio, 0); -var phraseOffset = 0; -var gapWidth = 0; -var first = true; -var alignedSeq = new jalview.datamodel.Sequence ("", ""); -for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) { -if (c == gapCharacter) { -gapWidth++; -if (gapWidth >= fromRatio) { -newseq.append (gap); -gapWidth = 0; -}} else { -phrase[phraseOffset++] = residueNo + 1; -if (phraseOffset == fromRatio) { -var sr = new jalview.datamodel.SearchResults (); -for (var pos, $pos = 0, $$pos = phrase; $pos < $$pos.length && ((pos = $$pos[$pos]) || true); $pos++) { -mapping.markMappedRegion (seq, pos, sr); -} -newseq.append (sr.toString ()); -if (first) { -first = false; -var mappedTo = sr.getResultSequence (0); -alignedSeq.setName (mappedTo.getName ()); -alignedSeq.setDescription (mappedTo.getDescription ()); -alignedSeq.setDatasetSequence (mappedTo); -}phraseOffset = 0; -}residueNo++; -}} -alignedSeq.setSequence (newseq.toString ()); -return alignedSeq; -}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame"); -c$.alignProteinAsDna = Clazz.defineMethod (c$, "alignProteinAsDna", -function (protein, dna) { -var mappings = protein.getCodonFrames (); -var alignedCodons = new java.util.TreeMap ( new jalview.analysis.CodonComparator ()); -for (var dnaSeq, $dnaSeq = dna.getSequences ().iterator (); $dnaSeq.hasNext () && ((dnaSeq = $dnaSeq.next ()) || true);) { -for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { -var seqMap = mapping.getMappingForSequence (dnaSeq); -var prot = mapping.findAlignedSequence (dnaSeq.getDatasetSequence (), protein); -if (prot != null) { -jalview.analysis.AlignmentUtils.addCodonPositions (dnaSeq, prot, protein.getGapCharacter (), seqMap, alignedCodons); -}} -} -return jalview.analysis.AlignmentUtils.alignProteinAs (protein, alignedCodons); -}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); -c$.alignProteinAs = Clazz.defineMethod (c$, "alignProteinAs", -function (protein, alignedCodons) { -var alignedWidth = alignedCodons.size (); -var gaps = Clazz.newCharArray (alignedWidth, '\0'); -java.util.Arrays.fill (gaps, protein.getGapCharacter ()); -var allGaps = String.valueOf (gaps); -for (var seq, $seq = protein.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -seq.setSequence (allGaps); -} -var column = 0; -for (var codon, $codon = alignedCodons.keySet ().iterator (); $codon.hasNext () && ((codon = $codon.next ()) || true);) { -var columnResidues = alignedCodons.get (codon); -for (var entry, $entry = columnResidues.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) { -entry.getKey ().getSequence ()[column] = entry.getValue ().charAt (0); -} -column++; -} -return 0; -}, "jalview.datamodel.AlignmentI,java.util.Map"); -c$.addCodonPositions = Clazz.defineMethod (c$, "addCodonPositions", -function (dna, protein, gapChar, seqMap, alignedCodons) { -var codons = seqMap.getCodonIterator (dna, gapChar); -while (codons.hasNext ()) { -var codon = codons.next (); -var seqProduct = alignedCodons.get (codon); -if (seqProduct == null) { -seqProduct = new java.util.HashMap (); -alignedCodons.put (codon, seqProduct); -}seqProduct.put (protein, codon.product); -} -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S,jalview.datamodel.Mapping,java.util.Map"); -c$.isMappable = Clazz.defineMethod (c$, "isMappable", -function (al1, al2) { -if (al1.isNucleotide () == al2.isNucleotide ()) { -return false; -}var dna = al1.isNucleotide () ? al1 : al2; -var protein = dna === al1 ? al2 : al1; -var mappings = protein.getCodonFrames (); -for (var dnaSeq, $dnaSeq = dna.getSequences ().iterator (); $dnaSeq.hasNext () && ((dnaSeq = $dnaSeq.next ()) || true);) { -for (var proteinSeq, $proteinSeq = protein.getSequences ().iterator (); $proteinSeq.hasNext () && ((proteinSeq = $proteinSeq.next ()) || true);) { -if (jalview.analysis.AlignmentUtils.isMappable (dnaSeq, proteinSeq, mappings)) { -return true; -}} -} -return false; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); -c$.isMappable = Clazz.defineMethod (c$, "isMappable", -function (dnaSeq, proteinSeq, mappings) { -var dnaDs = dnaSeq.getDatasetSequence () == null ? dnaSeq : dnaSeq.getDatasetSequence (); -var proteinDs = proteinSeq.getDatasetSequence () == null ? proteinSeq : proteinSeq.getDatasetSequence (); -for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { -if (proteinDs === mapping.getAaForDnaSeq (dnaDs)) { -return true; -}} -return jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinDs, dnaDs) != null; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,java.util.Set"); -c$.findAddableReferenceAnnotations = Clazz.defineMethod (c$, "findAddableReferenceAnnotations", -function (sequenceScope, labelForCalcId, candidates, al) { -if (sequenceScope == null) { -return; -}for (var seq, $seq = sequenceScope.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -var dataset = seq.getDatasetSequence (); -if (dataset == null) { -continue; -}var datasetAnnotations = dataset.getAnnotation (); -if (datasetAnnotations == null) { -continue; -}var result = new java.util.ArrayList (); -for (var dsann, $dsann = 0, $$dsann = datasetAnnotations; $dsann < $$dsann.length && ((dsann = $$dsann[$dsann]) || true); $dsann++) { -var matchedAlignmentAnnotations = al.findAnnotations (seq, dsann.getCalcId (), dsann.label); -if (!matchedAlignmentAnnotations.iterator ().hasNext ()) { -result.add (dsann); -if (labelForCalcId != null) { -labelForCalcId.put (dsann.getCalcId (), dsann.label); -}}} -if (!result.isEmpty ()) { -candidates.put (seq, result); -}} -}, "java.util.List,java.util.Map,java.util.Map,jalview.datamodel.AlignmentI"); -c$.addReferenceAnnotations = Clazz.defineMethod (c$, "addReferenceAnnotations", -function (annotations, alignment, selectionGroup) { -for (var seq, $seq = annotations.keySet ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -for (var ann, $ann = annotations.get (seq).iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) { -var copyAnn = new jalview.datamodel.AlignmentAnnotation (ann); -var startRes = 0; -var endRes = ann.annotations.length; -if (selectionGroup != null) { -startRes = selectionGroup.getStartRes (); -endRes = selectionGroup.getEndRes (); -}copyAnn.restrict (startRes, endRes); -if (!seq.hasAnnotation (ann)) { -seq.addAlignmentAnnotation (copyAnn); -}copyAnn.adjustForAlignment (); -alignment.addAnnotation (copyAnn); -copyAnn.visible = true; -} -} -}, "java.util.Map,jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); -c$.showOrHideSequenceAnnotations = Clazz.defineMethod (c$, "showOrHideSequenceAnnotations", -function (al, types, forSequences, anyType, doShow) { -for (var aa, $aa = 0, $$aa = al.getAlignmentAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { -if (anyType || types.contains (aa.label)) { -if ((aa.sequenceRef != null) && (forSequences == null || forSequences.contains (aa.sequenceRef))) { -aa.visible = doShow; -}}} -}, "jalview.datamodel.AlignmentI,java.util.Collection,java.util.List,~B,~B"); -c$.haveCrossRef = Clazz.defineMethod (c$, "haveCrossRef", -function (seq1, seq2) { -return jalview.analysis.AlignmentUtils.hasCrossRef (seq1, seq2) || jalview.analysis.AlignmentUtils.hasCrossRef (seq2, seq1); -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -c$.hasCrossRef = Clazz.defineMethod (c$, "hasCrossRef", -function (seq1, seq2) { -if (seq1 == null || seq2 == null) { -return false; -}var name = seq2.getName (); -var xrefs = seq1.getDBRef (); -if (xrefs != null) { -for (var xref, $xref = 0, $$xref = xrefs; $xref < $$xref.length && ((xref = $$xref[$xref]) || true); $xref++) { -var xrefName = xref.getSource () + "|" + xref.getAccessionId (); -if (xrefName.equalsIgnoreCase (name)) { -return true; -}} -}return false; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -c$.makeExonAlignment = Clazz.defineMethod (c$, "makeExonAlignment", -function (dna, mappings) { -var newMappings = new java.util.LinkedHashSet (); -var exonSequences = new java.util.ArrayList (); -for (var dnaSeq, $dnaSeq = 0, $$dnaSeq = dna; $dnaSeq < $$dnaSeq.length && ((dnaSeq = $$dnaSeq[$dnaSeq]) || true); $dnaSeq++) { -var ds = dnaSeq.getDatasetSequence (); -var seqMappings = jalview.util.MappingUtils.findMappingsForSequence (ds, mappings); -for (var acf, $acf = seqMappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -var newMapping = new jalview.datamodel.AlignedCodonFrame (); -var mappedExons = jalview.analysis.AlignmentUtils.makeExonSequences (ds, acf, newMapping); -if (!mappedExons.isEmpty ()) { -exonSequences.addAll (mappedExons); -newMappings.add (newMapping); -}} -} -var al = new jalview.datamodel.Alignment (exonSequences.toArray ( new Array (exonSequences.size ()))); -al.setDataset (null); -mappings.clear (); -mappings.addAll (newMappings); -return al; -}, "~A,java.util.Set"); -c$.makeExonSequences = Clazz.defineMethod (c$, "makeExonSequences", -function (dnaSeq, mapping, newMapping) { -var exonSequences = new java.util.ArrayList (); -var seqMappings = mapping.getMappingsForSequence (dnaSeq); -var dna = dnaSeq.getSequence (); -for (var seqMapping, $seqMapping = seqMappings.iterator (); $seqMapping.hasNext () && ((seqMapping = $seqMapping.next ()) || true);) { -var newSequence = new StringBuilder (dnaSeq.getLength ()); -var dnaExonRanges = seqMapping.getMap ().getFromRanges (); -for (var range, $range = dnaExonRanges.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { -for (var pos = range[0]; pos <= range[1]; pos++) { -newSequence.append (dna[pos - 1]); -} -} -var exon = new jalview.datamodel.Sequence (dnaSeq.getName (), newSequence.toString ()); -var cdsAccId = jalview.datamodel.FeatureProperties.getCodingFeature (jalview.datamodel.DBRefSource.EMBL); -var cdsRefs = jalview.util.DBRefUtils.selectRefs (seqMapping.getTo ().getDBRef (), jalview.datamodel.DBRefSource.CODINGDBS); -if (cdsRefs != null) { -for (var cdsRef, $cdsRef = 0, $$cdsRef = cdsRefs; $cdsRef < $$cdsRef.length && ((cdsRef = $$cdsRef[$cdsRef]) || true); $cdsRef++) { -exon.addDBRef ( new jalview.datamodel.DBRefEntry (cdsRef)); -cdsAccId = cdsRef.getAccessionId (); -} -}exon.setName (exon.getName () + "|" + cdsAccId); -exon.createDatasetSequence (); -var exonRange = new java.util.ArrayList (); -exonRange.add ( Clazz.newIntArray (-1, [1, newSequence.length ()])); -var map = new jalview.util.MapList (exonRange, seqMapping.getMap ().getToRanges (), 3, 1); -newMapping.addMap (exon.getDatasetSequence (), seqMapping.getTo (), map); -var cdsToDnaMap = new jalview.util.MapList (dnaExonRanges, exonRange, 1, 1); -newMapping.addMap (dnaSeq, exon.getDatasetSequence (), cdsToDnaMap); -exonSequences.add (exon); -} -return exonSequences; -}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignedCodonFrame,jalview.datamodel.AlignedCodonFrame"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.AlignmentUtils", ["jalview.analysis.CodonComparator", "jalview.datamodel.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.DBRefEntry", "$.DBRefSource", "$.FeatureProperties", "$.SearchResults", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.DBRefUtils", "$.MapList", "$.MappingUtils", "java.lang.StringBuilder", "java.util.ArrayList", "$.Arrays", "$.HashMap", "$.HashSet", "$.LinkedHashMap", "$.LinkedHashSet", "$.TreeMap"], function () { +c$ = Clazz.declareType (jalview.analysis, "AlignmentUtils"); +c$.expandContext = Clazz.defineMethod (c$, "expandContext", +function (core, flankSize) { +var sq = new java.util.ArrayList (); +var maxoffset = 0; +for (var s, $s = core.getSequences ().iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { +var newSeq = s.deriveSequence (); +var newSeqStart = newSeq.getStart () - 1; +if (newSeqStart > maxoffset && newSeq.getDatasetSequence ().getStart () < s.getStart ()) { +maxoffset = newSeqStart; +}sq.add (newSeq); +} +if (flankSize > -1) { +maxoffset = Math.min (maxoffset, flankSize); +}for (var s, $s = sq.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { +var ds = s; +while (ds.getDatasetSequence () != null) { +ds = ds.getDatasetSequence (); +} +var s_end = s.findPosition (s.getStart () + s.getLength ()); +var ustream_ds = s.getStart () - ds.getStart (); +var dstream_ds = ds.getEnd () - s_end; +var offset = maxoffset - ustream_ds; +if (flankSize >= 0) { +if (flankSize < ustream_ds) { +offset = maxoffset - flankSize; +ustream_ds = flankSize; +}if (flankSize <= dstream_ds) { +dstream_ds = flankSize - 1; +}}var upstream = String.instantialize (ds.getSequence (s.getStart () - 1 - ustream_ds, s.getStart () - 1)).toLowerCase ().toCharArray (); +var downstream = String.instantialize (ds.getSequence (s_end - 1, s_end + dstream_ds)).toLowerCase ().toCharArray (); +var coreseq = s.getSequence (); +var nseq = Clazz.newCharArray (offset + upstream.length + downstream.length + coreseq.length, '\0'); +var c = core.getGapCharacter (); +var p = 0; +for (; p < offset; p++) { +nseq[p] = c; +} +System.arraycopy (upstream, 0, nseq, p, upstream.length); +System.arraycopy (coreseq, 0, nseq, p + upstream.length, coreseq.length); +System.arraycopy (downstream, 0, nseq, p + coreseq.length + upstream.length, downstream.length); +s.setSequence ( String.instantialize (nseq)); +s.setStart (s.getStart () - ustream_ds); +s.setEnd (s_end + downstream.length); +} +var newAl = new jalview.datamodel.Alignment (sq.toArray ( new Array (0))); +for (var s, $s = sq.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { +if (s.getAnnotation () != null) { +for (var aa, $aa = 0, $$aa = s.getAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { +aa.adjustForAlignment (); +newAl.addAnnotation (aa); +} +}} +newAl.setDataset (core.getDataset ()); +return newAl; +}, "jalview.datamodel.AlignmentI,~N"); +c$.getSequenceIndex = Clazz.defineMethod (c$, "getSequenceIndex", +function (al, seq) { +var result = -1; +var pos = 0; +for (var alSeq, $alSeq = al.getSequences ().iterator (); $alSeq.hasNext () && ((alSeq = $alSeq.next ()) || true);) { +if (alSeq === seq) { +result = pos; +break; +}pos++; +} +return result; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI"); +c$.getSequencesByName = Clazz.defineMethod (c$, "getSequencesByName", +function (al) { +var theMap = new java.util.LinkedHashMap (); +for (var seq, $seq = al.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +var name = seq.getName (); +if (name != null) { +var seqs = theMap.get (name); +if (seqs == null) { +seqs = new java.util.ArrayList (); +theMap.put (name, seqs); +}seqs.add (seq); +}} +return theMap; +}, "jalview.datamodel.AlignmentI"); +c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna", +function (proteinAlignment, cdnaAlignment) { +if (proteinAlignment == null || cdnaAlignment == null) { +return false; +}var mappedDna = new java.util.HashSet (); +var mappedProtein = new java.util.HashSet (); +var mappingPerformed = jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, true); +mappingPerformed = new Boolean (mappingPerformed | jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, false)).valueOf (); +return mappingPerformed; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); +c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna", +function (proteinAlignment, cdnaAlignment, mappedDna, mappedProtein, xrefsOnly) { +var mappingPerformed = false; +var thisSeqs = proteinAlignment.getSequences (); +for (var aaSeq, $aaSeq = thisSeqs.iterator (); $aaSeq.hasNext () && ((aaSeq = $aaSeq.next ()) || true);) { +var proteinMapped = false; +var acf = new jalview.datamodel.AlignedCodonFrame (); +for (var cdnaSeq, $cdnaSeq = cdnaAlignment.getSequences ().iterator (); $cdnaSeq.hasNext () && ((cdnaSeq = $cdnaSeq.next ()) || true);) { +if (xrefsOnly && !jalview.analysis.AlignmentUtils.haveCrossRef (aaSeq, cdnaSeq)) { +continue; +}if (!xrefsOnly && (mappedProtein.contains (aaSeq) || mappedDna.contains (cdnaSeq))) { +continue; +}if (!jalview.analysis.AlignmentUtils.mappingExists (proteinAlignment.getCodonFrames (), aaSeq.getDatasetSequence (), cdnaSeq.getDatasetSequence ())) { +var map = jalview.analysis.AlignmentUtils.mapProteinToCdna (aaSeq, cdnaSeq); +if (map != null) { +acf.addMap (cdnaSeq, aaSeq, map); +mappingPerformed = true; +proteinMapped = true; +mappedDna.add (cdnaSeq); +mappedProtein.add (aaSeq); +}}} +if (proteinMapped) { +proteinAlignment.addCodonFrame (acf); +}} +return mappingPerformed; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI,java.util.Set,java.util.Set,~B"); +c$.mappingExists = Clazz.defineMethod (c$, "mappingExists", +function (set, aaSeq, cdnaSeq) { +if (set != null) { +for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +if (cdnaSeq === acf.getDnaForAaSeq (aaSeq)) { +return true; +}} +}return false; +}, "java.util.Set,jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +c$.mapProteinToCdna = Clazz.defineMethod (c$, "mapProteinToCdna", +function (proteinSeq, cdnaSeq) { +var proteinDataset = proteinSeq.getDatasetSequence (); +var aaSeqChars = proteinDataset != null ? proteinDataset.getSequence () : proteinSeq.getSequence (); +var cdnaDataset = cdnaSeq.getDatasetSequence (); +var cdnaSeqChars = cdnaDataset != null ? cdnaDataset.getSequence () : cdnaSeq.getSequence (); +if (aaSeqChars == null || cdnaSeqChars == null) { +return null; +}var mappedLength = 3 * aaSeqChars.length; +var cdnaLength = cdnaSeqChars.length; +var cdnaStart = 1; +var cdnaEnd = cdnaLength; +var proteinStart = 1; +var proteinEnd = aaSeqChars.length; +if (cdnaLength != mappedLength && cdnaLength > 2) { +var lastCodon = String.valueOf (cdnaSeqChars, cdnaLength - 3, 3).toUpperCase (); +for (var stop, $stop = jalview.schemes.ResidueProperties.STOP.iterator (); $stop.hasNext () && ((stop = $stop.next ()) || true);) { +if (lastCodon.equals (stop)) { +cdnaEnd -= 3; +cdnaLength -= 3; +break; +}} +}if (cdnaLength != mappedLength && cdnaLength > 2 && String.valueOf (cdnaSeqChars, 0, 3).toUpperCase ().equals (jalview.schemes.ResidueProperties.START)) { +cdnaStart += 3; +cdnaLength -= 3; +}if (cdnaLength != mappedLength) { +return null; +}if (!jalview.analysis.AlignmentUtils.translatesAs (cdnaSeqChars, cdnaStart - 1, aaSeqChars)) { +return null; +}var map = new jalview.util.MapList ( Clazz.newIntArray (-1, [cdnaStart, cdnaEnd]), Clazz.newIntArray (-1, [1, proteinEnd]), 3, 1); +return map; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +c$.translatesAs = Clazz.defineMethod (c$, "translatesAs", +function (cdnaSeqChars, cdnaStart, aaSeqChars) { +var aaResidue = 0; +for (var i = cdnaStart; i < cdnaSeqChars.length - 2 && aaResidue < aaSeqChars.length; i += 3, aaResidue++) { +var codon = String.valueOf (cdnaSeqChars, i, 3); +var translated = jalview.schemes.ResidueProperties.codonTranslate (codon); +var aaRes = aaSeqChars[aaResidue]; +if ((translated == null || "STOP".equals (translated)) && aaRes == 'X') { +continue; +}if (translated == null || !(aaRes == translated.charAt (0))) { +return false; +}} +return (aaResidue == aaSeqChars.length); +}, "~A,~N,~A"); +c$.alignSequenceAs = Clazz.defineMethod (c$, "alignSequenceAs", +function (seq, al, gap, preserveMappedGaps, preserveUnmappedGaps) { +var mappings = al.getCodonFrame (seq); +if (mappings == null || mappings.isEmpty ()) { +return false; +}var alignFrom = null; +var mapping = null; +for (var mp, $mp = mappings.iterator (); $mp.hasNext () && ((mp = $mp.next ()) || true);) { +alignFrom = mp.findAlignedSequence (seq.getDatasetSequence (), al); +if (alignFrom != null) { +mapping = mp; +break; +}} +if (alignFrom == null) { +return false; +}jalview.analysis.AlignmentUtils.alignSequenceAs (seq, alignFrom, mapping, gap, al.getGapCharacter (), preserveMappedGaps, preserveUnmappedGaps); +return true; +}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,~S,~B,~B"); +c$.alignSequenceAs = Clazz.defineMethod (c$, "alignSequenceAs", +function (alignTo, alignFrom, mapping, myGap, sourceGap, preserveMappedGaps, preserveUnmappedGaps) { +var thisSeq = alignTo.getSequence (); +var thatAligned = alignFrom.getSequence (); +var thisAligned = new StringBuilder (2 * thisSeq.length); +var thisSeqPos = 0; +var sourceDsPos = 0; +var basesWritten = 0; +var myGapChar = myGap.charAt (0); +var ratio = myGap.length; +var sourceGapMappedLength = 0; +var inExon = false; +for (var sourceChar, $sourceChar = 0, $$sourceChar = thatAligned; $sourceChar < $$sourceChar.length && ((sourceChar = $$sourceChar[$sourceChar]) || true); $sourceChar++) { +if (sourceChar == sourceGap) { +sourceGapMappedLength += ratio; +continue; +}sourceDsPos++; +var mappedPos = mapping.getMappedRegion (alignTo, alignFrom, sourceDsPos); +if (mappedPos == null) { +System.err.println ("Can't align: no codon mapping to residue " + sourceDsPos + "(" + sourceChar + ")"); +return; +}var mappedCodonStart = mappedPos[0]; +var mappedCodonEnd = mappedPos[mappedPos.length - 1]; +var trailingCopiedGap = new StringBuilder (); +var intronLength = 0; +while (basesWritten < mappedCodonEnd && thisSeqPos < thisSeq.length) { +var c = thisSeq[thisSeqPos++]; +if (c != myGapChar) { +basesWritten++; +if (basesWritten < mappedCodonStart) { +if (preserveUnmappedGaps && trailingCopiedGap.length () > 0) { +thisAligned.append (trailingCopiedGap.toString ()); +intronLength += trailingCopiedGap.length (); +trailingCopiedGap = new StringBuilder (); +}intronLength++; +inExon = false; +} else { +var startOfCodon = basesWritten == mappedCodonStart; +var gapsToAdd = jalview.analysis.AlignmentUtils.calculateGapsToInsert (preserveMappedGaps, preserveUnmappedGaps, sourceGapMappedLength, inExon, trailingCopiedGap.length (), intronLength, startOfCodon); +for (var i = 0; i < gapsToAdd; i++) { +thisAligned.append (myGapChar); +} +sourceGapMappedLength = 0; +inExon = true; +}thisAligned.append (c); +trailingCopiedGap = new StringBuilder (); +} else { +if (inExon && preserveMappedGaps) { +trailingCopiedGap.append (myGapChar); +} else if (!inExon && preserveUnmappedGaps) { +trailingCopiedGap.append (myGapChar); +}}} +} +while (thisSeqPos < thisSeq.length) { +var c = thisSeq[thisSeqPos++]; +if (c != myGapChar || preserveUnmappedGaps) { +thisAligned.append (c); +}} +alignTo.setSequence ( String.instantialize (thisAligned)); +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.datamodel.AlignedCodonFrame,~S,~S,~B,~B"); +c$.calculateGapsToInsert = Clazz.defineMethod (c$, "calculateGapsToInsert", +function (preserveMappedGaps, preserveUnmappedGaps, sourceGapMappedLength, inExon, trailingGapLength, intronLength, startOfCodon) { +var gapsToAdd = 0; +if (startOfCodon) { +if (inExon && !preserveMappedGaps) { +trailingGapLength = 0; +}if (!inExon && !(preserveMappedGaps && preserveUnmappedGaps)) { +trailingGapLength = 0; +}if (inExon) { +gapsToAdd = Math.max (sourceGapMappedLength, trailingGapLength); +} else { +if (intronLength + trailingGapLength <= sourceGapMappedLength) { +gapsToAdd = sourceGapMappedLength - intronLength; +} else { +gapsToAdd = Math.min (intronLength + trailingGapLength - sourceGapMappedLength, trailingGapLength); +}}} else { +if (!preserveMappedGaps) { +trailingGapLength = 0; +}gapsToAdd = Math.max (sourceGapMappedLength, trailingGapLength); +}return gapsToAdd; +}, "~B,~B,~N,~B,~N,~N,~B"); +c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation", +function (sequences, gapCharacter, mappings) { +var alignedSeqs = new java.util.ArrayList (); +for (var seq, $seq = sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +var mapped = jalview.analysis.AlignmentUtils.getAlignedTranslation (seq, gapCharacter, mappings); +alignedSeqs.addAll (mapped); +} +return alignedSeqs; +}, "java.util.List,~S,java.util.Set"); +c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation", +function (seq, gapCharacter, mappings) { +var result = new java.util.ArrayList (); +for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { +if (mapping.involvesSequence (seq)) { +var mapped = jalview.analysis.AlignmentUtils.getAlignedTranslation (seq, gapCharacter, mapping); +if (mapped != null) { +result.add (mapped); +}}} +return result; +}, "jalview.datamodel.SequenceI,~S,java.util.Set"); +c$.getAlignedTranslation = Clazz.defineMethod (c$, "getAlignedTranslation", +function (seq, gapCharacter, mapping) { +var gap = String.valueOf (gapCharacter); +var toDna = false; +var fromRatio = 1; +var mapTo = mapping.getDnaForAaSeq (seq); +if (mapTo != null) { +toDna = true; +gap = String.valueOf ( Clazz.newCharArray (-1, [gapCharacter, gapCharacter, gapCharacter])); +} else { +mapTo = mapping.getAaForDnaSeq (seq); +fromRatio = 3; +}var newseq = new StringBuilder (seq.getLength () * (toDna ? 3 : 1)); +var residueNo = 0; +var phrase = Clazz.newIntArray (fromRatio, 0); +var phraseOffset = 0; +var gapWidth = 0; +var first = true; +var alignedSeq = new jalview.datamodel.Sequence ("", ""); +for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) { +if (c == gapCharacter) { +gapWidth++; +if (gapWidth >= fromRatio) { +newseq.append (gap); +gapWidth = 0; +}} else { +phrase[phraseOffset++] = residueNo + 1; +if (phraseOffset == fromRatio) { +var sr = new jalview.datamodel.SearchResults (); +for (var pos, $pos = 0, $$pos = phrase; $pos < $$pos.length && ((pos = $$pos[$pos]) || true); $pos++) { +mapping.markMappedRegion (seq, pos, sr); +} +newseq.append (sr.toString ()); +if (first) { +first = false; +var mappedTo = sr.getResultSequence (0); +alignedSeq.setName (mappedTo.getName ()); +alignedSeq.setDescription (mappedTo.getDescription ()); +alignedSeq.setDatasetSequence (mappedTo); +}phraseOffset = 0; +}residueNo++; +}} +alignedSeq.setSequence (newseq.toString ()); +return alignedSeq; +}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame"); +c$.alignProteinAsDna = Clazz.defineMethod (c$, "alignProteinAsDna", +function (protein, dna) { +var mappings = protein.getCodonFrames (); +var alignedCodons = new java.util.TreeMap ( new jalview.analysis.CodonComparator ()); +for (var dnaSeq, $dnaSeq = dna.getSequences ().iterator (); $dnaSeq.hasNext () && ((dnaSeq = $dnaSeq.next ()) || true);) { +for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { +var seqMap = mapping.getMappingForSequence (dnaSeq); +var prot = mapping.findAlignedSequence (dnaSeq.getDatasetSequence (), protein); +if (prot != null) { +jalview.analysis.AlignmentUtils.addCodonPositions (dnaSeq, prot, protein.getGapCharacter (), seqMap, alignedCodons); +}} +} +return jalview.analysis.AlignmentUtils.alignProteinAs (protein, alignedCodons); +}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); +c$.alignProteinAs = Clazz.defineMethod (c$, "alignProteinAs", +function (protein, alignedCodons) { +var alignedWidth = alignedCodons.size (); +var gaps = Clazz.newCharArray (alignedWidth, '\0'); +java.util.Arrays.fill (gaps, protein.getGapCharacter ()); +var allGaps = String.valueOf (gaps); +for (var seq, $seq = protein.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +seq.setSequence (allGaps); +} +var column = 0; +for (var codon, $codon = alignedCodons.keySet ().iterator (); $codon.hasNext () && ((codon = $codon.next ()) || true);) { +var columnResidues = alignedCodons.get (codon); +for (var entry, $entry = columnResidues.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) { +entry.getKey ().getSequence ()[column] = entry.getValue ().charAt (0); +} +column++; +} +return 0; +}, "jalview.datamodel.AlignmentI,java.util.Map"); +c$.addCodonPositions = Clazz.defineMethod (c$, "addCodonPositions", +function (dna, protein, gapChar, seqMap, alignedCodons) { +var codons = seqMap.getCodonIterator (dna, gapChar); +while (codons.hasNext ()) { +var codon = codons.next (); +var seqProduct = alignedCodons.get (codon); +if (seqProduct == null) { +seqProduct = new java.util.HashMap (); +alignedCodons.put (codon, seqProduct); +}seqProduct.put (protein, codon.product); +} +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~S,jalview.datamodel.Mapping,java.util.Map"); +c$.isMappable = Clazz.defineMethod (c$, "isMappable", +function (al1, al2) { +if (al1.isNucleotide () == al2.isNucleotide ()) { +return false; +}var dna = al1.isNucleotide () ? al1 : al2; +var protein = dna === al1 ? al2 : al1; +var mappings = protein.getCodonFrames (); +for (var dnaSeq, $dnaSeq = dna.getSequences ().iterator (); $dnaSeq.hasNext () && ((dnaSeq = $dnaSeq.next ()) || true);) { +for (var proteinSeq, $proteinSeq = protein.getSequences ().iterator (); $proteinSeq.hasNext () && ((proteinSeq = $proteinSeq.next ()) || true);) { +if (jalview.analysis.AlignmentUtils.isMappable (dnaSeq, proteinSeq, mappings)) { +return true; +}} +} +return false; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); +c$.isMappable = Clazz.defineMethod (c$, "isMappable", +function (dnaSeq, proteinSeq, mappings) { +var dnaDs = dnaSeq.getDatasetSequence () == null ? dnaSeq : dnaSeq.getDatasetSequence (); +var proteinDs = proteinSeq.getDatasetSequence () == null ? proteinSeq : proteinSeq.getDatasetSequence (); +for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { +if (proteinDs === mapping.getAaForDnaSeq (dnaDs)) { +return true; +}} +return jalview.analysis.AlignmentUtils.mapProteinToCdna (proteinDs, dnaDs) != null; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,java.util.Set"); +c$.findAddableReferenceAnnotations = Clazz.defineMethod (c$, "findAddableReferenceAnnotations", +function (sequenceScope, labelForCalcId, candidates, al) { +if (sequenceScope == null) { +return; +}for (var seq, $seq = sequenceScope.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +var dataset = seq.getDatasetSequence (); +if (dataset == null) { +continue; +}var datasetAnnotations = dataset.getAnnotation (); +if (datasetAnnotations == null) { +continue; +}var result = new java.util.ArrayList (); +for (var dsann, $dsann = 0, $$dsann = datasetAnnotations; $dsann < $$dsann.length && ((dsann = $$dsann[$dsann]) || true); $dsann++) { +var matchedAlignmentAnnotations = al.findAnnotations (seq, dsann.getCalcId (), dsann.label); +if (!matchedAlignmentAnnotations.iterator ().hasNext ()) { +result.add (dsann); +if (labelForCalcId != null) { +labelForCalcId.put (dsann.getCalcId (), dsann.label); +}}} +if (!result.isEmpty ()) { +candidates.put (seq, result); +}} +}, "java.util.List,java.util.Map,java.util.Map,jalview.datamodel.AlignmentI"); +c$.addReferenceAnnotations = Clazz.defineMethod (c$, "addReferenceAnnotations", +function (annotations, alignment, selectionGroup) { +for (var seq, $seq = annotations.keySet ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +for (var ann, $ann = annotations.get (seq).iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) { +var copyAnn = new jalview.datamodel.AlignmentAnnotation (ann); +var startRes = 0; +var endRes = ann.annotations.length; +if (selectionGroup != null) { +startRes = selectionGroup.getStartRes (); +endRes = selectionGroup.getEndRes (); +}copyAnn.restrict (startRes, endRes); +if (!seq.hasAnnotation (ann)) { +seq.addAlignmentAnnotation (copyAnn); +}copyAnn.adjustForAlignment (); +alignment.addAnnotation (copyAnn); +copyAnn.visible = true; +} +} +}, "java.util.Map,jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); +c$.showOrHideSequenceAnnotations = Clazz.defineMethod (c$, "showOrHideSequenceAnnotations", +function (al, types, forSequences, anyType, doShow) { +for (var aa, $aa = 0, $$aa = al.getAlignmentAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { +if (anyType || types.contains (aa.label)) { +if ((aa.sequenceRef != null) && (forSequences == null || forSequences.contains (aa.sequenceRef))) { +aa.visible = doShow; +}}} +}, "jalview.datamodel.AlignmentI,java.util.Collection,java.util.List,~B,~B"); +c$.haveCrossRef = Clazz.defineMethod (c$, "haveCrossRef", +function (seq1, seq2) { +return jalview.analysis.AlignmentUtils.hasCrossRef (seq1, seq2) || jalview.analysis.AlignmentUtils.hasCrossRef (seq2, seq1); +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +c$.hasCrossRef = Clazz.defineMethod (c$, "hasCrossRef", +function (seq1, seq2) { +if (seq1 == null || seq2 == null) { +return false; +}var name = seq2.getName (); +var xrefs = seq1.getDBRef (); +if (xrefs != null) { +for (var xref, $xref = 0, $$xref = xrefs; $xref < $$xref.length && ((xref = $$xref[$xref]) || true); $xref++) { +var xrefName = xref.getSource () + "|" + xref.getAccessionId (); +if (xrefName.equalsIgnoreCase (name)) { +return true; +}} +}return false; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +c$.makeExonAlignment = Clazz.defineMethod (c$, "makeExonAlignment", +function (dna, mappings) { +var newMappings = new java.util.LinkedHashSet (); +var exonSequences = new java.util.ArrayList (); +for (var dnaSeq, $dnaSeq = 0, $$dnaSeq = dna; $dnaSeq < $$dnaSeq.length && ((dnaSeq = $$dnaSeq[$dnaSeq]) || true); $dnaSeq++) { +var ds = dnaSeq.getDatasetSequence (); +var seqMappings = jalview.util.MappingUtils.findMappingsForSequence (ds, mappings); +for (var acf, $acf = seqMappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +var newMapping = new jalview.datamodel.AlignedCodonFrame (); +var mappedExons = jalview.analysis.AlignmentUtils.makeExonSequences (ds, acf, newMapping); +if (!mappedExons.isEmpty ()) { +exonSequences.addAll (mappedExons); +newMappings.add (newMapping); +}} +} +var al = new jalview.datamodel.Alignment (exonSequences.toArray ( new Array (exonSequences.size ()))); +al.setDataset (null); +mappings.clear (); +mappings.addAll (newMappings); +return al; +}, "~A,java.util.Set"); +c$.makeExonSequences = Clazz.defineMethod (c$, "makeExonSequences", +function (dnaSeq, mapping, newMapping) { +var exonSequences = new java.util.ArrayList (); +var seqMappings = mapping.getMappingsForSequence (dnaSeq); +var dna = dnaSeq.getSequence (); +for (var seqMapping, $seqMapping = seqMappings.iterator (); $seqMapping.hasNext () && ((seqMapping = $seqMapping.next ()) || true);) { +var newSequence = new StringBuilder (dnaSeq.getLength ()); +var dnaExonRanges = seqMapping.getMap ().getFromRanges (); +for (var range, $range = dnaExonRanges.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { +for (var pos = range[0]; pos <= range[1]; pos++) { +newSequence.append (dna[pos - 1]); +} +} +var exon = new jalview.datamodel.Sequence (dnaSeq.getName (), newSequence.toString ()); +var cdsAccId = jalview.datamodel.FeatureProperties.getCodingFeature (jalview.datamodel.DBRefSource.EMBL); +var cdsRefs = jalview.util.DBRefUtils.selectRefs (seqMapping.getTo ().getDBRef (), jalview.datamodel.DBRefSource.CODINGDBS); +if (cdsRefs != null) { +for (var cdsRef, $cdsRef = 0, $$cdsRef = cdsRefs; $cdsRef < $$cdsRef.length && ((cdsRef = $$cdsRef[$cdsRef]) || true); $cdsRef++) { +exon.addDBRef ( new jalview.datamodel.DBRefEntry (cdsRef)); +cdsAccId = cdsRef.getAccessionId (); +} +}exon.setName (exon.getName () + "|" + cdsAccId); +exon.createDatasetSequence (); +var exonRange = new java.util.ArrayList (); +exonRange.add ( Clazz.newIntArray (-1, [1, newSequence.length ()])); +var map = new jalview.util.MapList (exonRange, seqMapping.getMap ().getToRanges (), 3, 1); +newMapping.addMap (exon.getDatasetSequence (), seqMapping.getTo (), map); +var cdsToDnaMap = new jalview.util.MapList (dnaExonRanges, exonRange, 1, 1); +newMapping.addMap (dnaSeq, exon.getDatasetSequence (), cdsToDnaMap); +exonSequences.add (exon); +} +return exonSequences; +}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignedCodonFrame,jalview.datamodel.AlignedCodonFrame"); +}); diff --git a/bin/jalview/analysis/AnnotationSorter.js b/bin/jalview/analysis/AnnotationSorter.js index b7d78cd..2757955 100644 --- a/bin/jalview/analysis/AnnotationSorter.js +++ b/bin/jalview/analysis/AnnotationSorter.js @@ -1,171 +1,171 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["java.lang.Enum", "java.util.HashMap"], "jalview.analysis.AnnotationSorter", ["jalview.analysis.AlignmentUtils", "java.lang.UnsupportedOperationException", "java.util.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.alignment = null; -this.showAutocalcAbove = false; -this.sequenceIndices = null; -this.bySequenceAndLabel = null; -this.byLabelAndSequence = null; -this.noSort = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "AnnotationSorter"); -Clazz.prepareFields (c$, function () { -this.sequenceIndices = new java.util.HashMap (); -this.bySequenceAndLabel = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$1") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$1$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$1, this, null)); -this.byLabelAndSequence = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$2") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$2$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$2, this, null)); -this.noSort = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$3") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$3$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$3, this, null)); -}); -Clazz.makeConstructor (c$, -function (alignmentI, showAutocalculatedAbove) { -this.alignment = alignmentI; -this.showAutocalcAbove = showAutocalculatedAbove; -}, "jalview.datamodel.AlignmentI,~B"); -Clazz.defineMethod (c$, "sort", -function (alignmentAnnotations, order) { -if (alignmentAnnotations == null) { -return; -}this.saveSequenceIndices (alignmentAnnotations); -var comparator = this.getComparator (order); -if (alignmentAnnotations != null) { -{ -java.util.Arrays.sort (alignmentAnnotations, comparator); -}}}, "~A,jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); -Clazz.defineMethod (c$, "saveSequenceIndices", -($fz = function (alignmentAnnotations) { -this.sequenceIndices.clear (); -for (var ann, $ann = 0, $$ann = alignmentAnnotations; $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { -var seq = ann.sequenceRef; -if (seq != null) { -var index = jalview.analysis.AlignmentUtils.getSequenceIndex (this.alignment, seq); -this.sequenceIndices.put (seq, new Integer (index)); -}} -}, $fz.isPrivate = true, $fz), "~A"); -Clazz.defineMethod (c$, "getComparator", -($fz = function (order) { -if (order == null) { -return this.noSort; -}switch (order) { -case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE: -return this.noSort; -case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL: -return this.bySequenceAndLabel; -case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE: -return this.byLabelAndSequence; -default: -throw new UnsupportedOperationException (order.toString ()); -} -}, $fz.isPrivate = true, $fz), "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); -Clazz.defineMethod (c$, "compareLabels", -($fz = function (o1, o2) { -if (o1 == null || o2 == null) { -return 0; -}var label1 = o1.label; -var label2 = o2.label; -if (label1 == null && label2 == null) { -return 0; -}if (label1 == null) { -return -1; -}if (label2 == null) { -return 1; -}return label1.toUpperCase ().compareTo (label2.toUpperCase ()); -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "compareSequences", -($fz = function (o1, o2) { -var seq1 = o1.sequenceRef; -var seq2 = o2.sequenceRef; -if (seq1 == null && seq2 == null) { -return 0; -}if (seq1 == null) { -return this.showAutocalcAbove ? -1 : 1; -}if (seq2 == null) { -return this.showAutocalcAbove ? 1 : -1; -}var index1 = (this.sequenceIndices.get (seq1)).intValue (); -var index2 = (this.sequenceIndices.get (seq2)).intValue (); -if (index1 == index2) { -return 0; -}if (index1 == -1) { -return -1; -}if (index2 == -1) { -return 1; -}return Integer.compare (index1, index2); -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$.$AnnotationSorter$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$1", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (o1, o2) { -if (o1 == null && o2 == null) { -return 0; -}if (o1 == null) { -return -1; -}if (o2 == null) { -return 1; -}if (o1.sequenceRef == null && o2.sequenceRef == null) { -return 0; -}var sequenceOrder = this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2); -return sequenceOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2) : sequenceOrder; -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationSorter$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$2", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (o1, o2) { -if (o1 == null && o2 == null) { -return 0; -}if (o1 == null) { -return -1; -}if (o2 == null) { -return 1; -}if (o1.sequenceRef == null && o2.sequenceRef == null) { -return 0; -}if (o1.sequenceRef == null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; -}if (o2.sequenceRef == null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; -}var labelOrder = this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2); -return labelOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2) : labelOrder; -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationSorter$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$3", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (o1, o2) { -if (o1 != null && o2 != null) { -if (o1.sequenceRef == null && o2.sequenceRef != null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; -}if (o1.sequenceRef != null && o2.sequenceRef == null) { -return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; -}}return 0; -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); -c$ = Clazz.p0p (); -}; -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.description = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis.AnnotationSorter, "SequenceAnnotationOrder", Enum); -Clazz.makeConstructor (c$, -($fz = function (a) { -this.description = a; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.description; -}); -c$.forDescription = Clazz.defineMethod (c$, "forDescription", -function (a) { -for (var order, $order = 0, $$order = jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.values (); $order < $$order.length && ((order = $$order[$order]) || true); $order++) { -if (order.toString ().equals (a)) { -return order; -}} -return null; -}, "~S"); -Clazz.defineEnumConstant (c$, "SEQUENCE_AND_LABEL", 0, ["Sequence"]); -Clazz.defineEnumConstant (c$, "LABEL_AND_SEQUENCE", 1, ["Label"]); -Clazz.defineEnumConstant (c$, "NONE", 2, ["No sort"]); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["java.lang.Enum", "java.util.HashMap"], "jalview.analysis.AnnotationSorter", ["jalview.analysis.AlignmentUtils", "java.lang.UnsupportedOperationException", "java.util.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.alignment = null; +this.showAutocalcAbove = false; +this.sequenceIndices = null; +this.bySequenceAndLabel = null; +this.byLabelAndSequence = null; +this.noSort = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "AnnotationSorter"); +Clazz.prepareFields (c$, function () { +this.sequenceIndices = new java.util.HashMap (); +this.bySequenceAndLabel = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$1") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$1$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$1, this, null)); +this.byLabelAndSequence = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$2") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$2$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$2, this, null)); +this.noSort = ((Clazz.isClassDefined ("jalview.analysis.AnnotationSorter$3") ? 0 : jalview.analysis.AnnotationSorter.$AnnotationSorter$3$ ()), Clazz.innerTypeInstance (jalview.analysis.AnnotationSorter$3, this, null)); +}); +Clazz.makeConstructor (c$, +function (alignmentI, showAutocalculatedAbove) { +this.alignment = alignmentI; +this.showAutocalcAbove = showAutocalculatedAbove; +}, "jalview.datamodel.AlignmentI,~B"); +Clazz.defineMethod (c$, "sort", +function (alignmentAnnotations, order) { +if (alignmentAnnotations == null) { +return; +}this.saveSequenceIndices (alignmentAnnotations); +var comparator = this.getComparator (order); +if (alignmentAnnotations != null) { +{ +java.util.Arrays.sort (alignmentAnnotations, comparator); +}}}, "~A,jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); +Clazz.defineMethod (c$, "saveSequenceIndices", +($fz = function (alignmentAnnotations) { +this.sequenceIndices.clear (); +for (var ann, $ann = 0, $$ann = alignmentAnnotations; $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { +var seq = ann.sequenceRef; +if (seq != null) { +var index = jalview.analysis.AlignmentUtils.getSequenceIndex (this.alignment, seq); +this.sequenceIndices.put (seq, new Integer (index)); +}} +}, $fz.isPrivate = true, $fz), "~A"); +Clazz.defineMethod (c$, "getComparator", +($fz = function (order) { +if (order == null) { +return this.noSort; +}switch (order) { +case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE: +return this.noSort; +case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL: +return this.bySequenceAndLabel; +case jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE: +return this.byLabelAndSequence; +default: +throw new UnsupportedOperationException (order.toString ()); +} +}, $fz.isPrivate = true, $fz), "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); +Clazz.defineMethod (c$, "compareLabels", +($fz = function (o1, o2) { +if (o1 == null || o2 == null) { +return 0; +}var label1 = o1.label; +var label2 = o2.label; +if (label1 == null && label2 == null) { +return 0; +}if (label1 == null) { +return -1; +}if (label2 == null) { +return 1; +}return label1.toUpperCase ().compareTo (label2.toUpperCase ()); +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "compareSequences", +($fz = function (o1, o2) { +var seq1 = o1.sequenceRef; +var seq2 = o2.sequenceRef; +if (seq1 == null && seq2 == null) { +return 0; +}if (seq1 == null) { +return this.showAutocalcAbove ? -1 : 1; +}if (seq2 == null) { +return this.showAutocalcAbove ? 1 : -1; +}var index1 = (this.sequenceIndices.get (seq1)).intValue (); +var index2 = (this.sequenceIndices.get (seq2)).intValue (); +if (index1 == index2) { +return 0; +}if (index1 == -1) { +return -1; +}if (index2 == -1) { +return 1; +}return Integer.compare (index1, index2); +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$.$AnnotationSorter$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$1", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (o1, o2) { +if (o1 == null && o2 == null) { +return 0; +}if (o1 == null) { +return -1; +}if (o2 == null) { +return 1; +}if (o1.sequenceRef == null && o2.sequenceRef == null) { +return 0; +}var sequenceOrder = this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2); +return sequenceOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2) : sequenceOrder; +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationSorter$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$2", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (o1, o2) { +if (o1 == null && o2 == null) { +return 0; +}if (o1 == null) { +return -1; +}if (o2 == null) { +return 1; +}if (o1.sequenceRef == null && o2.sequenceRef == null) { +return 0; +}if (o1.sequenceRef == null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; +}if (o2.sequenceRef == null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; +}var labelOrder = this.b$["jalview.analysis.AnnotationSorter"].compareLabels (o1, o2); +return labelOrder == 0 ? this.b$["jalview.analysis.AnnotationSorter"].compareSequences (o1, o2) : labelOrder; +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationSorter$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.analysis, "AnnotationSorter$3", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (o1, o2) { +if (o1 != null && o2 != null) { +if (o1.sequenceRef == null && o2.sequenceRef != null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? -1 : 1; +}if (o1.sequenceRef != null && o2.sequenceRef == null) { +return this.b$["jalview.analysis.AnnotationSorter"].showAutocalcAbove ? 1 : -1; +}}return 0; +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation"); +c$ = Clazz.p0p (); +}; +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.description = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis.AnnotationSorter, "SequenceAnnotationOrder", Enum); +Clazz.makeConstructor (c$, +($fz = function (a) { +this.description = a; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.description; +}); +c$.forDescription = Clazz.defineMethod (c$, "forDescription", +function (a) { +for (var order, $order = 0, $$order = jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.values (); $order < $$order.length && ((order = $$order[$order]) || true); $order++) { +if (order.toString ().equals (a)) { +return order; +}} +return null; +}, "~S"); +Clazz.defineEnumConstant (c$, "SEQUENCE_AND_LABEL", 0, ["Sequence"]); +Clazz.defineEnumConstant (c$, "LABEL_AND_SEQUENCE", 1, ["Label"]); +Clazz.defineEnumConstant (c$, "NONE", 2, ["No sort"]); +c$ = Clazz.p0p (); +}); diff --git a/bin/jalview/analysis/CodingUtils.js b/bin/jalview/analysis/CodingUtils.js index 69abb90..08fa0ce 100644 --- a/bin/jalview/analysis/CodingUtils.js +++ b/bin/jalview/analysis/CodingUtils.js @@ -1,64 +1,64 @@ -Clazz.declarePackage ("jalview.analysis"); -c$ = Clazz.declareType (jalview.analysis, "CodingUtils"); -c$.encodeCodon = Clazz.defineMethod (c$, "encodeCodon", -function (codon) { -if (codon == null) { -return -1; -}return jalview.analysis.CodingUtils.encodeCodon (codon[2]) + (jalview.analysis.CodingUtils.encodeCodon (codon[1]) << 2) + (jalview.analysis.CodingUtils.encodeCodon (codon[0]) << (4)); -}, "~A"); -c$.encodeCodon = Clazz.defineMethod (c$, "encodeCodon", -function (c) { -var result = -2147483648; -switch (c) { -case 'A': -case 'a': -result = 0; -break; -case 'C': -case 'c': -result = 1; -break; -case 'G': -case 'g': -result = 2; -break; -case 'T': -case 't': -case 'U': -case 'u': -result = 3; -break; -} -return result; -}, "~S"); -c$.decodeCodon = Clazz.defineMethod (c$, "decodeCodon", -function (encoded) { -var result = Clazz.newCharArray (3, '\0'); -result[2] = jalview.analysis.CodingUtils.decodeNucleotide (encoded & 3); -encoded = encoded >>> 2; -result[1] = jalview.analysis.CodingUtils.decodeNucleotide (encoded & 3); -encoded = encoded >>> 2; -result[0] = jalview.analysis.CodingUtils.decodeNucleotide (encoded & 3); -return result; -}, "~N"); -c$.decodeNucleotide = Clazz.defineMethod (c$, "decodeNucleotide", -function (i) { -var result = '0'; -switch (i) { -case 0: -result = 'A'; -break; -case 1: -result = 'C'; -break; -case 2: -result = 'G'; -break; -case 3: -result = 'T'; -break; -} -return result; -}, "~N"); -Clazz.defineStatics (c$, -"CODON_ENCODING_BITSHIFT", 2); +Clazz.declarePackage ("jalview.analysis"); +c$ = Clazz.declareType (jalview.analysis, "CodingUtils"); +c$.encodeCodon = Clazz.defineMethod (c$, "encodeCodon", +function (codon) { +if (codon == null) { +return -1; +}return jalview.analysis.CodingUtils.encodeCodon (codon[2]) + (jalview.analysis.CodingUtils.encodeCodon (codon[1]) << 2) + (jalview.analysis.CodingUtils.encodeCodon (codon[0]) << (4)); +}, "~A"); +c$.encodeCodon = Clazz.defineMethod (c$, "encodeCodon", +function (c) { +var result = -2147483648; +switch (c) { +case 'A': +case 'a': +result = 0; +break; +case 'C': +case 'c': +result = 1; +break; +case 'G': +case 'g': +result = 2; +break; +case 'T': +case 't': +case 'U': +case 'u': +result = 3; +break; +} +return result; +}, "~S"); +c$.decodeCodon = Clazz.defineMethod (c$, "decodeCodon", +function (encoded) { +var result = Clazz.newCharArray (3, '\0'); +result[2] = jalview.analysis.CodingUtils.decodeNucleotide (encoded & 3); +encoded = encoded >>> 2; +result[1] = jalview.analysis.CodingUtils.decodeNucleotide (encoded & 3); +encoded = encoded >>> 2; +result[0] = jalview.analysis.CodingUtils.decodeNucleotide (encoded & 3); +return result; +}, "~N"); +c$.decodeNucleotide = Clazz.defineMethod (c$, "decodeNucleotide", +function (i) { +var result = '0'; +switch (i) { +case 0: +result = 'A'; +break; +case 1: +result = 'C'; +break; +case 2: +result = 'G'; +break; +case 3: +result = 'T'; +break; +} +return result; +}, "~N"); +Clazz.defineStatics (c$, +"CODON_ENCODING_BITSHIFT", 2); diff --git a/bin/jalview/analysis/CodonComparator.js b/bin/jalview/analysis/CodonComparator.js index afa4c8d..7c07b92 100644 --- a/bin/jalview/analysis/CodonComparator.js +++ b/bin/jalview/analysis/CodonComparator.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("jalview.analysis"); -c$ = Clazz.declareType (jalview.analysis, "CodonComparator", null, java.util.Comparator); -Clazz.overrideMethod (c$, "compare", -function (ac1, ac2) { -if (ac1 == null || ac2 == null || ac1.equals (ac2)) { -return 0; -}if (ac1.pos1 < ac2.pos1 && ac1.pos3 <= ac2.pos3) { -return -1; -}if (ac2.pos1 < ac1.pos1 && ac2.pos3 <= ac1.pos3) { -return 1; -}if (ac1.pos3 > ac2.pos3 && ac1.pos1 >= ac2.pos1) { -return 1; -}if (ac2.pos3 > ac1.pos3 && ac2.pos1 >= ac1.pos1) { -return -1; -}if (ac1.pos1 == ac2.pos1 && ac1.pos3 == ac2.pos3) { -return Integer.compare (ac1.pos2, ac2.pos2); -}var compareMiddles = Integer.compare (ac1.pos2, ac2.pos2); -if (compareMiddles != 0) { -return compareMiddles; -}return Integer.compare (ac1.pos1, ac2.pos1); -}, "jalview.datamodel.AlignedCodon,jalview.datamodel.AlignedCodon"); +Clazz.declarePackage ("jalview.analysis"); +c$ = Clazz.declareType (jalview.analysis, "CodonComparator", null, java.util.Comparator); +Clazz.overrideMethod (c$, "compare", +function (ac1, ac2) { +if (ac1 == null || ac2 == null || ac1.equals (ac2)) { +return 0; +}if (ac1.pos1 < ac2.pos1 && ac1.pos3 <= ac2.pos3) { +return -1; +}if (ac2.pos1 < ac1.pos1 && ac2.pos3 <= ac1.pos3) { +return 1; +}if (ac1.pos3 > ac2.pos3 && ac1.pos1 >= ac2.pos1) { +return 1; +}if (ac2.pos3 > ac1.pos3 && ac2.pos1 >= ac1.pos1) { +return -1; +}if (ac1.pos1 == ac2.pos1 && ac1.pos3 == ac2.pos3) { +return Integer.compare (ac1.pos2, ac2.pos2); +}var compareMiddles = Integer.compare (ac1.pos2, ac2.pos2); +if (compareMiddles != 0) { +return compareMiddles; +}return Integer.compare (ac1.pos1, ac2.pos1); +}, "jalview.datamodel.AlignedCodon,jalview.datamodel.AlignedCodon"); diff --git a/bin/jalview/analysis/Conservation.js b/bin/jalview/analysis/Conservation.js index aa95a73..fbcd478 100644 --- a/bin/jalview/analysis/Conservation.js +++ b/bin/jalview/analysis/Conservation.js @@ -1,370 +1,370 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.Conservation", ["jalview.datamodel.Annotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color", "java.lang.Character", "$.Double", "$.StringBuffer", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sequences = null; -this.start = 0; -this.end = 0; -this.seqNums = null; -this.maxLength = 0; -this.seqNumsChanged = false; -this.total = null; -this.canonicaliseAa = true; -this.quality = null; -this.qualityRange = null; -this.consString = ""; -this.consSequence = null; -this.propHash = null; -this.threshold = 0; -this.name = ""; -this.cons2 = null; -this.consSymbs = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "Conservation"); -Clazz.prepareFields (c$, function () { -this.qualityRange = new Array (2); -}); -Clazz.makeConstructor (c$, -function (name, propHash, threshold, sequences, start, end) { -this.name = name; -this.propHash = propHash; -this.threshold = threshold; -this.start = start; -this.end = end; -this.maxLength = end - start + 1; -var s; -var sSize = sequences.size (); -var sarray = new Array (sSize); -this.sequences = sarray; -try { -for (s = 0; s < sSize; s++) { -sarray[s] = sequences.get (s); -if (sarray[s].getLength () > this.maxLength) { -this.maxLength = sarray[s].getLength (); -}} -} catch (ex) { -if (Clazz.exceptionOf (ex, ArrayIndexOutOfBoundsException)) { -this.sequences = new Array (0); -this.maxLength = 0; -} else { -throw ex; -} -} -}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N"); -Clazz.defineMethod (c$, "calcSeqNum", -($fz = function (i) { -var sq = null; -var sqnum = null; -var sSize = this.sequences.length; -if ((i > -1) && (i < sSize)) { -sq = this.sequences[i].getSequenceAsString (); -if (this.seqNums.size () <= i) { -this.seqNums.addElement ( Clazz.newIntArray (sq.length + 1, 0)); -}if (sq.hashCode () != (this.seqNums.elementAt (i))[0]) { -var j; -var len; -this.seqNumsChanged = true; -len = sq.length; -if (this.maxLength < len) { -this.maxLength = len; -}sqnum = Clazz.newIntArray (len + 1, 0); -sqnum[0] = sq.hashCode (); -for (j = 1; j <= len; j++) { -sqnum[j] = jalview.schemes.ResidueProperties.aaIndex[sq.charCodeAt (j - 1)]; -} -this.seqNums.setElementAt (sqnum, i); -} else { -System.out.println ("SEQUENCE HAS BEEN DELETED!!!"); -}} else { -System.err.println ("ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); -}}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "calculate", -function () { -var resultHash; -var ht; -var thresh; -var j; -var jSize = this.sequences.length; -var values; -var type; -var res = null; -var c; -var enumeration2; -this.total = new Array (this.maxLength); -for (var i = this.start; i <= this.end; i++) { -values = Clazz.newIntArray (255, 0); -for (j = 0; j < jSize; j++) { -if (this.sequences[j].getLength () > i) { -c = this.sequences[j].getCharAt (i); -if (this.canonicaliseAa) { -c = String.fromCharCode (jalview.schemes.ResidueProperties.aaIndex[this.sequences[j].getCharAt (i).charCodeAt (0)]); -if (c.charCodeAt (0) > 20) { -c = '-'; -} else { -c = jalview.schemes.ResidueProperties.aa[c.charCodeAt (0)].charAt (0); -}} else { -if (c == '.' || c == ' ') { -c = '-'; -}if (!this.canonicaliseAa && 'a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - (32)); -}}values[c.charCodeAt (0)]++; -} else { -values['-'.charCodeAt (0)]++; -}} -thresh = Clazz.doubleToInt ((this.threshold * (jSize)) / 100); -resultHash = new java.util.Hashtable (); -for (var v = '-'; v < 'Z'; v = String.fromCharCode (v.charCodeAt (0) + 1)) { -if (values[v.charCodeAt (0)] > thresh) { -res = String.valueOf (v); -enumeration2 = this.propHash.keys (); -while (enumeration2.hasMoreElements ()) { -type = enumeration2.nextElement (); -ht = this.propHash.get (type); -if (!resultHash.containsKey (type)) { -if (ht.containsKey (res)) { -resultHash.put (type, ht.get (res)); -} else { -resultHash.put (type, ht.get ("-")); -}} else if ((resultHash.get (type)).equals (ht.get (res)) == false) { -resultHash.put (type, new Integer (-1)); -}} -}} -if (this.total.length > 0) { -this.total[i - this.start] = resultHash; -}} -}); -Clazz.defineMethod (c$, "countConsNGaps", -function (j) { -var count = 0; -var cons = 0; -var nres = 0; -var r = Clazz.newIntArray (2, 0); -var f = '$'; -var i; -var iSize = this.sequences.length; -var c; -for (i = 0; i < iSize; i++) { -if (j >= this.sequences[i].getLength ()) { -count++; -continue; -}c = this.sequences[i].getCharAt (j); -if (jalview.util.Comparison.isGap ((c))) { -count++; -} else { -nres++; -if (nres == 1) { -f = c; -cons++; -} else if (f == c) { -cons++; -}}} -r[0] = (nres == cons) ? 1 : 0; -r[1] = count; -return r; -}, "~N"); -Clazz.defineMethod (c$, "verdict", -function (consflag, percentageGaps) { -var consString = new StringBuffer (); -var type; -var result; -var gapcons; -var totGaps; -var count; -var pgaps; -var resultHash; -var enumeration; -for (var i = 0; i < this.start; i++) { -consString.append ('-'); -} -this.consSymbs = new Array (this.end - this.start + 1); -for (var i = this.start; i <= this.end; i++) { -gapcons = this.countConsNGaps (i); -totGaps = gapcons[1]; -pgaps = (totGaps * 100) / this.sequences.length; -this.consSymbs[i - this.start] = String.instantialize (); -if (percentageGaps > pgaps) { -resultHash = this.total[i - this.start]; -count = 0; -enumeration = resultHash.keys (); -while (enumeration.hasMoreElements ()) { -type = enumeration.nextElement (); -result = resultHash.get (type); -if (consflag) { -if (result.intValue () == 1) { -this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; -count++; -}} else { -if (result.intValue () != -1) { -{ -if (result.intValue () == 0) { -this.consSymbs[i - this.start] = this.consSymbs[i - this.start] + " !" + type; -} else { -this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; -}}count++; -}}} -if (count < 10) { -consString.append ("" + count); -} else { -consString.append ((gapcons[0] == 1) ? "*" : "+"); -}} else { -consString.append ('-'); -}} -this.consSequence = new jalview.datamodel.Sequence (this.name, consString.toString (), this.start, this.end); -}, "~B,~N"); -Clazz.defineMethod (c$, "getConsSequence", -function () { -return this.consSequence; -}); -Clazz.defineMethod (c$, "findQuality", -function () { -this.findQuality (0, this.maxLength - 1); -}); -Clazz.defineMethod (c$, "percentIdentity2", -($fz = function () { -this.seqNums = new java.util.Vector (); -var i = 0; -var iSize = this.sequences.length; -for (i = 0; i < iSize; i++) { -this.calcSeqNum (i); -} -if ((this.cons2 == null) || this.seqNumsChanged) { -this.cons2 = Clazz.newIntArray (this.maxLength, 24, 0); -for (var j = 0; j < 24; j++) { -for (i = 0; i < this.maxLength; i++) { -this.cons2[i][j] = 0; -} -} -var sqnum; -var j = 0; -while (j < this.sequences.length) { -sqnum = this.seqNums.elementAt (j); -for (i = 1; i < sqnum.length; i++) { -this.cons2[i - 1][sqnum[i]]++; -} -for (i = sqnum.length - 1; i < this.maxLength; i++) { -this.cons2[i][23]++; -} -j++; -} -}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "findQuality", -function (start, end) { -this.quality = new java.util.Vector (); -var max = -10000; -var BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62 (); -this.percentIdentity2 (); -var size = this.seqNums.size (); -var lengths = Clazz.newIntArray (size, 0); -var tot; -var bigtot; -var sr; -var tmp; -var x; -var xx; -var l; -var j; -var i; -var ii; -var i2; -var k; -var seqNum; -for (l = 0; l < size; l++) { -lengths[l] = (this.seqNums.elementAt (l)).length - 1; -} -for (j = start; j <= end; j++) { -bigtot = 0; -x = Clazz.newDoubleArray (24, 0); -for (ii = 0; ii < 24; ii++) { -x[ii] = 0; -for (i2 = 0; i2 < 24; i2++) { -x[ii] += ((this.cons2[j][i2] * BLOSUM62[ii][i2]) + 4); -} -x[ii] /= size; -} -for (k = 0; k < size; k++) { -tot = 0; -xx = Clazz.newDoubleArray (24, 0); -seqNum = (j < lengths[k]) ? (this.seqNums.elementAt (k))[j + 1] : 23; -for (i = 0; i < 23; i++) { -sr = 0; -sr = BLOSUM62[i][seqNum] + 4; -xx[i] = x[i] - sr; -tot += (xx[i] * xx[i]); -} -bigtot += Math.sqrt (tot); -} -if (max < bigtot) { -max = bigtot; -}this.quality.addElement ( new Double (bigtot)); -} -var newmax = -10000; -for (j = start; j <= end; j++) { -tmp = (this.quality.elementAt (j)).doubleValue (); -tmp = ((max - tmp) * (size - this.cons2[j][23])) / size; -this.quality.setElementAt ( new Double (tmp), j); -if (tmp > newmax) { -newmax = tmp; -}} -this.qualityRange[0] = new Double (0); -this.qualityRange[1] = new Double (newmax); -}, "~N,~N"); -Clazz.defineMethod (c$, "completeAnnotations", -function (conservation, quality2, istart, alWidth) { -var sequence = this.getConsSequence ().getSequence (); -var minR; -var minG; -var minB; -var maxR; -var maxG; -var maxB; -minR = 0.3; -minG = 0.0; -minB = 0; -maxR = 1.0 - minR; -maxG = 0.9 - minG; -maxB = 0 - minB; -var min = 0; -var max = 11; -var qmin = 0; -var qmax = 0; -var c; -if (conservation.annotations != null && conservation.annotations.length < alWidth) { -conservation.annotations = new Array (alWidth); -}if (quality2 != null) { -quality2.graphMax = this.qualityRange[1].floatValue (); -if (quality2.annotations != null && quality2.annotations.length < alWidth) { -quality2.annotations = new Array (alWidth); -}qmin = this.qualityRange[0].floatValue (); -qmax = this.qualityRange[1].floatValue (); -}for (var i = 0; i < alWidth; i++) { -var value = 0; -c = sequence[i]; -if (Character.isDigit (c)) { -value = c.charCodeAt (0) - 48; -} else if (c == '*') { -value = 11; -} else if (c == '+') { -value = 10; -}var vprop = value - min; -vprop /= max; -conservation.annotations[i] = new jalview.datamodel.Annotation (String.valueOf (c), this.consSymbs[i - this.start], ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); -if (quality2 != null) { -value = (this.quality.elementAt (i)).floatValue (); -vprop = value - qmin; -vprop /= qmax; -quality2.annotations[i] = new jalview.datamodel.Annotation (" ", String.valueOf (value), ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); -}} -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation,~N,~N"); -c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", -function (name, consHash, threshold, seqs, start, end, posOrNeg, consPercGaps, calcQuality) { -var cons = new jalview.analysis.Conservation (name, consHash, threshold, seqs, start, end); -return jalview.analysis.Conservation.calculateConservation (cons, posOrNeg, consPercGaps, calcQuality); -}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N,~B,~N,~B"); -c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", -function (cons, b, consPercGaps, calcQuality) { -cons.calculate (); -cons.verdict (b, consPercGaps); -if (calcQuality) { -cons.findQuality (); -}return cons; -}, "jalview.analysis.Conservation,~B,~N,~B"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.Conservation", ["jalview.datamodel.Annotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color", "java.lang.Character", "$.Double", "$.StringBuffer", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sequences = null; +this.start = 0; +this.end = 0; +this.seqNums = null; +this.maxLength = 0; +this.seqNumsChanged = false; +this.total = null; +this.canonicaliseAa = true; +this.quality = null; +this.qualityRange = null; +this.consString = ""; +this.consSequence = null; +this.propHash = null; +this.threshold = 0; +this.name = ""; +this.cons2 = null; +this.consSymbs = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "Conservation"); +Clazz.prepareFields (c$, function () { +this.qualityRange = new Array (2); +}); +Clazz.makeConstructor (c$, +function (name, propHash, threshold, sequences, start, end) { +this.name = name; +this.propHash = propHash; +this.threshold = threshold; +this.start = start; +this.end = end; +this.maxLength = end - start + 1; +var s; +var sSize = sequences.size (); +var sarray = new Array (sSize); +this.sequences = sarray; +try { +for (s = 0; s < sSize; s++) { +sarray[s] = sequences.get (s); +if (sarray[s].getLength () > this.maxLength) { +this.maxLength = sarray[s].getLength (); +}} +} catch (ex) { +if (Clazz.exceptionOf (ex, ArrayIndexOutOfBoundsException)) { +this.sequences = new Array (0); +this.maxLength = 0; +} else { +throw ex; +} +} +}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N"); +Clazz.defineMethod (c$, "calcSeqNum", +($fz = function (i) { +var sq = null; +var sqnum = null; +var sSize = this.sequences.length; +if ((i > -1) && (i < sSize)) { +sq = this.sequences[i].getSequenceAsString (); +if (this.seqNums.size () <= i) { +this.seqNums.addElement ( Clazz.newIntArray (sq.length + 1, 0)); +}if (sq.hashCode () != (this.seqNums.elementAt (i))[0]) { +var j; +var len; +this.seqNumsChanged = true; +len = sq.length; +if (this.maxLength < len) { +this.maxLength = len; +}sqnum = Clazz.newIntArray (len + 1, 0); +sqnum[0] = sq.hashCode (); +for (j = 1; j <= len; j++) { +sqnum[j] = jalview.schemes.ResidueProperties.aaIndex[sq.charCodeAt (j - 1)]; +} +this.seqNums.setElementAt (sqnum, i); +} else { +System.out.println ("SEQUENCE HAS BEEN DELETED!!!"); +}} else { +System.err.println ("ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); +}}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "calculate", +function () { +var resultHash; +var ht; +var thresh; +var j; +var jSize = this.sequences.length; +var values; +var type; +var res = null; +var c; +var enumeration2; +this.total = new Array (this.maxLength); +for (var i = this.start; i <= this.end; i++) { +values = Clazz.newIntArray (255, 0); +for (j = 0; j < jSize; j++) { +if (this.sequences[j].getLength () > i) { +c = this.sequences[j].getCharAt (i); +if (this.canonicaliseAa) { +c = String.fromCharCode (jalview.schemes.ResidueProperties.aaIndex[this.sequences[j].getCharAt (i).charCodeAt (0)]); +if (c.charCodeAt (0) > 20) { +c = '-'; +} else { +c = jalview.schemes.ResidueProperties.aa[c.charCodeAt (0)].charAt (0); +}} else { +if (c == '.' || c == ' ') { +c = '-'; +}if (!this.canonicaliseAa && 'a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - (32)); +}}values[c.charCodeAt (0)]++; +} else { +values['-'.charCodeAt (0)]++; +}} +thresh = Clazz.doubleToInt ((this.threshold * (jSize)) / 100); +resultHash = new java.util.Hashtable (); +for (var v = '-'; v < 'Z'; v = String.fromCharCode (v.charCodeAt (0) + 1)) { +if (values[v.charCodeAt (0)] > thresh) { +res = String.valueOf (v); +enumeration2 = this.propHash.keys (); +while (enumeration2.hasMoreElements ()) { +type = enumeration2.nextElement (); +ht = this.propHash.get (type); +if (!resultHash.containsKey (type)) { +if (ht.containsKey (res)) { +resultHash.put (type, ht.get (res)); +} else { +resultHash.put (type, ht.get ("-")); +}} else if ((resultHash.get (type)).equals (ht.get (res)) == false) { +resultHash.put (type, new Integer (-1)); +}} +}} +if (this.total.length > 0) { +this.total[i - this.start] = resultHash; +}} +}); +Clazz.defineMethod (c$, "countConsNGaps", +function (j) { +var count = 0; +var cons = 0; +var nres = 0; +var r = Clazz.newIntArray (2, 0); +var f = '$'; +var i; +var iSize = this.sequences.length; +var c; +for (i = 0; i < iSize; i++) { +if (j >= this.sequences[i].getLength ()) { +count++; +continue; +}c = this.sequences[i].getCharAt (j); +if (jalview.util.Comparison.isGap ((c))) { +count++; +} else { +nres++; +if (nres == 1) { +f = c; +cons++; +} else if (f == c) { +cons++; +}}} +r[0] = (nres == cons) ? 1 : 0; +r[1] = count; +return r; +}, "~N"); +Clazz.defineMethod (c$, "verdict", +function (consflag, percentageGaps) { +var consString = new StringBuffer (); +var type; +var result; +var gapcons; +var totGaps; +var count; +var pgaps; +var resultHash; +var enumeration; +for (var i = 0; i < this.start; i++) { +consString.append ('-'); +} +this.consSymbs = new Array (this.end - this.start + 1); +for (var i = this.start; i <= this.end; i++) { +gapcons = this.countConsNGaps (i); +totGaps = gapcons[1]; +pgaps = (totGaps * 100) / this.sequences.length; +this.consSymbs[i - this.start] = String.instantialize (); +if (percentageGaps > pgaps) { +resultHash = this.total[i - this.start]; +count = 0; +enumeration = resultHash.keys (); +while (enumeration.hasMoreElements ()) { +type = enumeration.nextElement (); +result = resultHash.get (type); +if (consflag) { +if (result.intValue () == 1) { +this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; +count++; +}} else { +if (result.intValue () != -1) { +{ +if (result.intValue () == 0) { +this.consSymbs[i - this.start] = this.consSymbs[i - this.start] + " !" + type; +} else { +this.consSymbs[i - this.start] = type + " " + this.consSymbs[i - this.start]; +}}count++; +}}} +if (count < 10) { +consString.append ("" + count); +} else { +consString.append ((gapcons[0] == 1) ? "*" : "+"); +}} else { +consString.append ('-'); +}} +this.consSequence = new jalview.datamodel.Sequence (this.name, consString.toString (), this.start, this.end); +}, "~B,~N"); +Clazz.defineMethod (c$, "getConsSequence", +function () { +return this.consSequence; +}); +Clazz.defineMethod (c$, "findQuality", +function () { +this.findQuality (0, this.maxLength - 1); +}); +Clazz.defineMethod (c$, "percentIdentity2", +($fz = function () { +this.seqNums = new java.util.Vector (); +var i = 0; +var iSize = this.sequences.length; +for (i = 0; i < iSize; i++) { +this.calcSeqNum (i); +} +if ((this.cons2 == null) || this.seqNumsChanged) { +this.cons2 = Clazz.newIntArray (this.maxLength, 24, 0); +for (var j = 0; j < 24; j++) { +for (i = 0; i < this.maxLength; i++) { +this.cons2[i][j] = 0; +} +} +var sqnum; +var j = 0; +while (j < this.sequences.length) { +sqnum = this.seqNums.elementAt (j); +for (i = 1; i < sqnum.length; i++) { +this.cons2[i - 1][sqnum[i]]++; +} +for (i = sqnum.length - 1; i < this.maxLength; i++) { +this.cons2[i][23]++; +} +j++; +} +}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "findQuality", +function (start, end) { +this.quality = new java.util.Vector (); +var max = -10000; +var BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62 (); +this.percentIdentity2 (); +var size = this.seqNums.size (); +var lengths = Clazz.newIntArray (size, 0); +var tot; +var bigtot; +var sr; +var tmp; +var x; +var xx; +var l; +var j; +var i; +var ii; +var i2; +var k; +var seqNum; +for (l = 0; l < size; l++) { +lengths[l] = (this.seqNums.elementAt (l)).length - 1; +} +for (j = start; j <= end; j++) { +bigtot = 0; +x = Clazz.newDoubleArray (24, 0); +for (ii = 0; ii < 24; ii++) { +x[ii] = 0; +for (i2 = 0; i2 < 24; i2++) { +x[ii] += ((this.cons2[j][i2] * BLOSUM62[ii][i2]) + 4); +} +x[ii] /= size; +} +for (k = 0; k < size; k++) { +tot = 0; +xx = Clazz.newDoubleArray (24, 0); +seqNum = (j < lengths[k]) ? (this.seqNums.elementAt (k))[j + 1] : 23; +for (i = 0; i < 23; i++) { +sr = 0; +sr = BLOSUM62[i][seqNum] + 4; +xx[i] = x[i] - sr; +tot += (xx[i] * xx[i]); +} +bigtot += Math.sqrt (tot); +} +if (max < bigtot) { +max = bigtot; +}this.quality.addElement ( new Double (bigtot)); +} +var newmax = -10000; +for (j = start; j <= end; j++) { +tmp = (this.quality.elementAt (j)).doubleValue (); +tmp = ((max - tmp) * (size - this.cons2[j][23])) / size; +this.quality.setElementAt ( new Double (tmp), j); +if (tmp > newmax) { +newmax = tmp; +}} +this.qualityRange[0] = new Double (0); +this.qualityRange[1] = new Double (newmax); +}, "~N,~N"); +Clazz.defineMethod (c$, "completeAnnotations", +function (conservation, quality2, istart, alWidth) { +var sequence = this.getConsSequence ().getSequence (); +var minR; +var minG; +var minB; +var maxR; +var maxG; +var maxB; +minR = 0.3; +minG = 0.0; +minB = 0; +maxR = 1.0 - minR; +maxG = 0.9 - minG; +maxB = 0 - minB; +var min = 0; +var max = 11; +var qmin = 0; +var qmax = 0; +var c; +if (conservation.annotations != null && conservation.annotations.length < alWidth) { +conservation.annotations = new Array (alWidth); +}if (quality2 != null) { +quality2.graphMax = this.qualityRange[1].floatValue (); +if (quality2.annotations != null && quality2.annotations.length < alWidth) { +quality2.annotations = new Array (alWidth); +}qmin = this.qualityRange[0].floatValue (); +qmax = this.qualityRange[1].floatValue (); +}for (var i = 0; i < alWidth; i++) { +var value = 0; +c = sequence[i]; +if (Character.isDigit (c)) { +value = c.charCodeAt (0) - 48; +} else if (c == '*') { +value = 11; +} else if (c == '+') { +value = 10; +}var vprop = value - min; +vprop /= max; +conservation.annotations[i] = new jalview.datamodel.Annotation (String.valueOf (c), this.consSymbs[i - this.start], ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); +if (quality2 != null) { +value = (this.quality.elementAt (i)).floatValue (); +vprop = value - qmin; +vprop /= qmax; +quality2.annotations[i] = new jalview.datamodel.Annotation (" ", String.valueOf (value), ' ', value, new java.awt.Color (minR + (maxR * vprop), minG + (maxG * vprop), minB + (maxB * vprop))); +}} +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.AlignmentAnnotation,~N,~N"); +c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", +function (name, consHash, threshold, seqs, start, end, posOrNeg, consPercGaps, calcQuality) { +var cons = new jalview.analysis.Conservation (name, consHash, threshold, seqs, start, end); +return jalview.analysis.Conservation.calculateConservation (cons, posOrNeg, consPercGaps, calcQuality); +}, "~S,java.util.Hashtable,~N,java.util.List,~N,~N,~B,~N,~B"); +c$.calculateConservation = Clazz.defineMethod (c$, "calculateConservation", +function (cons, b, consPercGaps, calcQuality) { +cons.calculate (); +cons.verdict (b, consPercGaps); +if (calcQuality) { +cons.findQuality (); +}return cons; +}, "jalview.analysis.Conservation,~B,~N,~B"); +}); diff --git a/bin/jalview/analysis/Dna.js b/bin/jalview/analysis/Dna.js index 57c052f..68086a9 100644 --- a/bin/jalview/analysis/Dna.js +++ b/bin/jalview/analysis/Dna.js @@ -1,327 +1,327 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["jalview.analysis.CodonComparator"], "jalview.analysis.Dna", ["jalview.datamodel.AlignedCodon", "$.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.Annotation", "$.DBRefSource", "$.FeatureProperties", "$.GraphLine", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.DBRefUtils", "$.MapList", "$.ShiftList", "java.lang.IllegalStateException", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.selection = null; -this.seqstring = null; -this.contigs = null; -this.gapChar = '\0'; -this.annotations = null; -this.dnaWidth = 0; -this.dataset = null; -this.aaWidth = 0; -this.alignedCodons = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "Dna"); -Clazz.makeConstructor (c$, -function (viewport, visibleContigs) { -this.selection = java.util.Arrays.asList (viewport.getSequenceSelection ()); -this.seqstring = viewport.getViewAsString (true); -this.contigs = visibleContigs; -this.gapChar = viewport.getGapCharacter (); -this.annotations = viewport.getAlignment ().getAlignmentAnnotation (); -this.dnaWidth = viewport.getAlignment ().getWidth (); -this.dataset = viewport.getAlignment ().getDataset (); -}, "jalview.api.AlignViewportI,~A"); -c$.compareCodonPos = Clazz.defineMethod (c$, "compareCodonPos", -function (ac1, ac2) { -return jalview.analysis.Dna.comparator.compare (ac1, ac2); -}, "jalview.datamodel.AlignedCodon,jalview.datamodel.AlignedCodon"); -Clazz.defineMethod (c$, "translateCdna", -function () { -var acf = new jalview.datamodel.AlignedCodonFrame (); -this.alignedCodons = new Array (this.dnaWidth); -var s; -var sSize = this.selection.size (); -var pepseqs = new java.util.ArrayList (); -for (s = 0; s < sSize; s++) { -var newseq = this.translateCodingRegion (this.selection.get (s), this.seqstring[s], acf, pepseqs); -if (newseq != null) { -pepseqs.add (newseq); -var ds = newseq; -if (this.dataset != null) { -while (ds.getDatasetSequence () != null) { -ds = ds.getDatasetSequence (); -} -this.dataset.addSequence (ds); -}}} -var newseqs = pepseqs.toArray ( new Array (pepseqs.size ())); -var al = new jalview.datamodel.Alignment (newseqs); -al.padGaps (); -al.setDataset (this.dataset); -this.translateAlignedAnnotations (al, acf); -al.addCodonFrame (acf); -return al; -}); -c$.canTranslate = Clazz.defineMethod (c$, "canTranslate", -function (selection, viscontigs) { -for (var gd = 0; gd < selection.length; gd++) { -var dna = selection[gd]; -var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); -if (dnarefs != null) { -var mappedrefs = new java.util.ArrayList (); -var refs = dna.getDBRef (); -for (var d = 0; d < refs.length; d++) { -if (refs[d].getMap () != null && refs[d].getMap ().getMap () != null && refs[d].getMap ().getMap ().getFromRatio () == 3 && refs[d].getMap ().getMap ().getToRatio () == 1) { -mappedrefs.add (refs[d]); -}} -dnarefs = mappedrefs.toArray ( new Array (mappedrefs.size ())); -for (var d = 0; d < dnarefs.length; d++) { -var mp = dnarefs[d].getMap (); -if (mp != null) { -for (var vc = 0; vc < viscontigs.length; vc += 2) { -var mpr = mp.locateMappedRange (viscontigs[vc], viscontigs[vc + 1]); -if (mpr != null) { -return true; -}} -}} -}} -return false; -}, "~A,~A"); -Clazz.defineMethod (c$, "translateAlignedAnnotations", -function (al, acf) { -if (this.annotations != null) { -for (var annotation, $annotation = 0, $$annotation = this.annotations; $annotation < $$annotation.length && ((annotation = $$annotation[$annotation]) || true); $annotation++) { -if (annotation.autoCalculated || !annotation.visible || annotation.isRNA ()) { -continue; -}var aSize = this.aaWidth; -var anots = (annotation.annotations == null) ? null : new Array (aSize); -if (anots != null) { -for (var a = 0; a < aSize; a++) { -if (a < this.alignedCodons.length && this.alignedCodons[a] != null && this.alignedCodons[a].pos1 == (this.alignedCodons[a].pos3 - 2)) { -anots[a] = jalview.analysis.Dna.getCodonAnnotation (this.alignedCodons[a], annotation.annotations); -}} -}var aa = new jalview.datamodel.AlignmentAnnotation (annotation.label, annotation.description, anots); -aa.graph = annotation.graph; -aa.graphGroup = annotation.graphGroup; -aa.graphHeight = annotation.graphHeight; -if (annotation.getThreshold () != null) { -aa.setThreshold ( new jalview.datamodel.GraphLine (annotation.getThreshold ())); -}if (annotation.$hasScore) { -aa.setScore (annotation.getScore ()); -}var seqRef = annotation.sequenceRef; -if (seqRef != null) { -var aaSeq = acf.getAaForDnaSeq (seqRef); -if (aaSeq != null) { -aa.setSequenceRef (aaSeq); -aa.createSequenceMapping (aaSeq, aaSeq.getStart (), true); -aa.adjustForAlignment (); -aaSeq.addAlignmentAnnotation (aa); -}}al.addAnnotation (aa); -} -}}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignedCodonFrame"); -c$.getCodonAnnotation = Clazz.defineMethod (c$, "getCodonAnnotation", -($fz = function (is, annotations) { -var contrib = 0; -var annot = null; -for (var p = 1; p <= 3; p++) { -var dnaCol = is.getBaseColumn (p); -if (annotations[dnaCol] != null) { -if (annot == null) { -annot = new jalview.datamodel.Annotation (annotations[dnaCol]); -contrib = 1; -} else { -var cpy = new jalview.datamodel.Annotation (annotations[dnaCol]); -if (annot.colour == null) { -annot.colour = cpy.colour; -}if (annot.description == null || annot.description.length == 0) { -annot.description = cpy.description; -}if (annot.displayCharacter == null) { -annot.displayCharacter = cpy.displayCharacter; -}if (annot.secondaryStructure.charCodeAt (0) == 0) { -annot.secondaryStructure = cpy.secondaryStructure; -}annot.value += cpy.value; -contrib++; -}}} -if (contrib > 1) { -annot.value /= contrib; -}return annot; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignedCodon,~A"); -Clazz.defineMethod (c$, "translateCodingRegion", -function (selection, seqstring, acf, proteinSeqs) { -var skip = new java.util.ArrayList (); -var skipint = null; -var vismapping = new jalview.util.ShiftList (); -var vc; -var scontigs = Clazz.newIntArray (this.contigs.length, 0); -var npos = 0; -for (vc = 0; vc < this.contigs.length; vc += 2) { -if (vc == 0) { -vismapping.addShift (npos, this.contigs[vc]); -} else { -vismapping.addShift (npos, this.contigs[vc] - this.contigs[vc - 1] + 1); -}scontigs[vc] = this.contigs[vc]; -scontigs[vc + 1] = this.contigs[vc + 1]; -} -var protein = new StringBuilder (Clazz.doubleToInt (seqstring.length / 2)); -var seq = seqstring.$replace ('U', 'T').$replace ('u', 'T'); -var codon = Clazz.newCharArray (3, '\0'); -var cdp = Clazz.newIntArray (3, 0); -var rf = 0; -var lastnpos = 0; -var nend; -var aspos = 0; -var resSize = 0; -for (npos = 0, nend = seq.length; npos < nend; npos++) { -if (!jalview.util.Comparison.isGap (seq.charAt (npos))) { -cdp[rf] = npos; -codon[rf++] = seq.charAt (npos); -}if (rf == 3) { -var alignedCodon = new jalview.datamodel.AlignedCodon (cdp[0], cdp[1], cdp[2]); -var aa = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (codon)); -rf = 0; -var gapString = String.valueOf (this.gapChar); -if (aa == null) { -aa = gapString; -if (skipint == null) { -skipint = Clazz.newIntArray (-1, [alignedCodon.pos1, alignedCodon.pos3]); -}skipint[1] = alignedCodon.pos3; -} else { -if (skipint != null) { -skipint[0] = vismapping.shift (skipint[0]); -skipint[1] = vismapping.shift (skipint[1]); -for (vc = 0; vc < scontigs.length; ) { -if (scontigs[vc + 1] < skipint[0]) { -vc += 2; -continue; -}if (scontigs[vc] > skipint[1]) { -break; -}var t; -if (scontigs[vc] <= skipint[0]) { -if (skipint[0] == scontigs[vc]) { -if (scontigs[vc + 1] > skipint[1]) { -scontigs[vc] = skipint[1]; -vc += 2; -} else { -if (scontigs[vc + 1] == skipint[1]) { -t = Clazz.newIntArray (scontigs.length - 2, 0); -if (vc > 0) { -System.arraycopy (scontigs, 0, t, 0, vc - 1); -}if (vc + 2 < t.length) { -System.arraycopy (scontigs, vc + 2, t, vc, t.length - vc + 2); -}scontigs = t; -} else { -scontigs[vc + 1] = skipint[0] - 1; -vc += 2; -}}} else { -if (scontigs[vc + 1] < skipint[1]) { -scontigs[vc + 1] = skipint[0] - 1; -vc += 2; -} else { -t = Clazz.newIntArray (scontigs.length + 2, 0); -System.arraycopy (scontigs, 0, t, 0, vc + 1); -t[vc + 1] = skipint[0]; -t[vc + 2] = skipint[1]; -System.arraycopy (scontigs, vc + 1, t, vc + 3, scontigs.length - (vc + 1)); -scontigs = t; -vc += 4; -}}}} -skip.add (skipint); -skipint = null; -}if (aa.equals ("STOP")) { -aa = "X"; -}resSize++; -}var findpos = true; -while (findpos) { -var compareCodonPos = jalview.analysis.Dna.compareCodonPos (alignedCodon, this.alignedCodons[aspos]); -switch (compareCodonPos) { -case -1: -this.insertAAGap (aspos, proteinSeqs); -findpos = false; -break; -case 1: -aa = gapString + aa; -aspos++; -break; -case 0: -findpos = false; -} -} -protein.append (aa); -lastnpos = npos; -if (this.alignedCodons[aspos] == null) { -this.alignedCodons[aspos] = alignedCodon; -} else if (!this.alignedCodons[aspos].equals (alignedCodon)) { -throw new IllegalStateException ("Tried to coalign " + this.alignedCodons[aspos].toString () + " with " + alignedCodon.toString ()); -}if (aspos >= this.aaWidth) { -this.aaWidth = aspos; -}aspos++; -}} -if (resSize > 0) { -var newseq = new jalview.datamodel.Sequence (selection.getName (), protein.toString ()); -if (rf != 0) { -var errMsg = "trimming contigs for incomplete terminal codon."; -System.err.println ("trimming contigs for incomplete terminal codon."); -vc = scontigs.length - 1; -lastnpos = vismapping.shift (lastnpos); -while (vc >= 0 && scontigs[vc] > lastnpos) { -if (vc > 0 && scontigs[vc - 1] > lastnpos) { -vc -= 2; -} else { -scontigs[vc] = lastnpos; -}} -if (vc > 0 && (vc + 1) < scontigs.length) { -var t = Clazz.newIntArray (vc + 1, 0); -System.arraycopy (scontigs, 0, t, 0, vc + 1); -scontigs = t; -}if (vc <= 0) { -scontigs = null; -}}if (scontigs != null) { -npos = 0; -for (vc = 0; vc < scontigs.length; vc += 2) { -scontigs[vc] = selection.findPosition (scontigs[vc]); -scontigs[vc + 1] = selection.findPosition (scontigs[vc + 1]); -if (scontigs[vc + 1] == selection.getEnd ()) { -break; -}} -if ((vc + 2) < scontigs.length) { -var t = Clazz.newIntArray (vc + 2, 0); -System.arraycopy (scontigs, 0, t, 0, vc + 2); -scontigs = t; -}var map = new jalview.util.MapList (scontigs, Clazz.newIntArray (-1, [1, resSize]), 3, 1); -jalview.analysis.Dna.transferCodedFeatures (selection, newseq, map, null, null); -var rseq = newseq.deriveSequence (); -acf.addMap (selection, rseq, map); -return rseq; -}}return null; -}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame,java.util.List"); -Clazz.defineMethod (c$, "insertAAGap", -function (pos, proteinSeqs) { -this.aaWidth++; -for (var seq, $seq = proteinSeqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -seq.insertCharAt (pos, this.gapChar); -} -this.checkCodonFrameWidth (); -if (pos < this.aaWidth) { -this.aaWidth++; -System.arraycopy (this.alignedCodons, pos, this.alignedCodons, pos + 1, this.alignedCodons.length - pos - 1); -this.alignedCodons[pos] = null; -}}, "~N,java.util.List"); -Clazz.defineMethod (c$, "checkCodonFrameWidth", -function () { -if (this.alignedCodons[this.alignedCodons.length - 1] != null) { -var c = new Array (this.alignedCodons.length + 10); -System.arraycopy (this.alignedCodons, 0, c, 0, this.alignedCodons.length); -this.alignedCodons = c; -}}); -c$.transferCodedFeatures = Clazz.defineMethod (c$, "transferCodedFeatures", -($fz = function (dna, pep, map, featureTypes, featureGroups) { -var sfs = dna.getSequenceFeatures (); -var fgstate; -var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); -if (dnarefs != null) { -for (var d = 0; d < dnarefs.length; d++) { -var mp = dnarefs[d].getMap (); -if (mp != null) { -}} -}if (sfs != null) { -for (var sf, $sf = 0, $$sf = sfs; $sf < $$sf.length && ((sf = $$sf[$sf]) || true); $sf++) { -fgstate = (featureGroups == null) ? null : featureGroups.get (sf.featureGroup); -if ((featureTypes == null || featureTypes.containsKey (sf.getType ())) && (fgstate == null || fgstate.booleanValue ())) { -if (jalview.datamodel.FeatureProperties.isCodingFeature (null, sf.getType ())) { -{ -}}}} -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList,java.util.Map,java.util.Map"); -Clazz.defineStatics (c$, -"STOP_X", "X"); -c$.comparator = c$.prototype.comparator = new jalview.analysis.CodonComparator (); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["jalview.analysis.CodonComparator"], "jalview.analysis.Dna", ["jalview.datamodel.AlignedCodon", "$.AlignedCodonFrame", "$.Alignment", "$.AlignmentAnnotation", "$.Annotation", "$.DBRefSource", "$.FeatureProperties", "$.GraphLine", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.DBRefUtils", "$.MapList", "$.ShiftList", "java.lang.IllegalStateException", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.selection = null; +this.seqstring = null; +this.contigs = null; +this.gapChar = '\0'; +this.annotations = null; +this.dnaWidth = 0; +this.dataset = null; +this.aaWidth = 0; +this.alignedCodons = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "Dna"); +Clazz.makeConstructor (c$, +function (viewport, visibleContigs) { +this.selection = java.util.Arrays.asList (viewport.getSequenceSelection ()); +this.seqstring = viewport.getViewAsString (true); +this.contigs = visibleContigs; +this.gapChar = viewport.getGapCharacter (); +this.annotations = viewport.getAlignment ().getAlignmentAnnotation (); +this.dnaWidth = viewport.getAlignment ().getWidth (); +this.dataset = viewport.getAlignment ().getDataset (); +}, "jalview.api.AlignViewportI,~A"); +c$.compareCodonPos = Clazz.defineMethod (c$, "compareCodonPos", +function (ac1, ac2) { +return jalview.analysis.Dna.comparator.compare (ac1, ac2); +}, "jalview.datamodel.AlignedCodon,jalview.datamodel.AlignedCodon"); +Clazz.defineMethod (c$, "translateCdna", +function () { +var acf = new jalview.datamodel.AlignedCodonFrame (); +this.alignedCodons = new Array (this.dnaWidth); +var s; +var sSize = this.selection.size (); +var pepseqs = new java.util.ArrayList (); +for (s = 0; s < sSize; s++) { +var newseq = this.translateCodingRegion (this.selection.get (s), this.seqstring[s], acf, pepseqs); +if (newseq != null) { +pepseqs.add (newseq); +var ds = newseq; +if (this.dataset != null) { +while (ds.getDatasetSequence () != null) { +ds = ds.getDatasetSequence (); +} +this.dataset.addSequence (ds); +}}} +var newseqs = pepseqs.toArray ( new Array (pepseqs.size ())); +var al = new jalview.datamodel.Alignment (newseqs); +al.padGaps (); +al.setDataset (this.dataset); +this.translateAlignedAnnotations (al, acf); +al.addCodonFrame (acf); +return al; +}); +c$.canTranslate = Clazz.defineMethod (c$, "canTranslate", +function (selection, viscontigs) { +for (var gd = 0; gd < selection.length; gd++) { +var dna = selection[gd]; +var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); +if (dnarefs != null) { +var mappedrefs = new java.util.ArrayList (); +var refs = dna.getDBRef (); +for (var d = 0; d < refs.length; d++) { +if (refs[d].getMap () != null && refs[d].getMap ().getMap () != null && refs[d].getMap ().getMap ().getFromRatio () == 3 && refs[d].getMap ().getMap ().getToRatio () == 1) { +mappedrefs.add (refs[d]); +}} +dnarefs = mappedrefs.toArray ( new Array (mappedrefs.size ())); +for (var d = 0; d < dnarefs.length; d++) { +var mp = dnarefs[d].getMap (); +if (mp != null) { +for (var vc = 0; vc < viscontigs.length; vc += 2) { +var mpr = mp.locateMappedRange (viscontigs[vc], viscontigs[vc + 1]); +if (mpr != null) { +return true; +}} +}} +}} +return false; +}, "~A,~A"); +Clazz.defineMethod (c$, "translateAlignedAnnotations", +function (al, acf) { +if (this.annotations != null) { +for (var annotation, $annotation = 0, $$annotation = this.annotations; $annotation < $$annotation.length && ((annotation = $$annotation[$annotation]) || true); $annotation++) { +if (annotation.autoCalculated || !annotation.visible || annotation.isRNA ()) { +continue; +}var aSize = this.aaWidth; +var anots = (annotation.annotations == null) ? null : new Array (aSize); +if (anots != null) { +for (var a = 0; a < aSize; a++) { +if (a < this.alignedCodons.length && this.alignedCodons[a] != null && this.alignedCodons[a].pos1 == (this.alignedCodons[a].pos3 - 2)) { +anots[a] = jalview.analysis.Dna.getCodonAnnotation (this.alignedCodons[a], annotation.annotations); +}} +}var aa = new jalview.datamodel.AlignmentAnnotation (annotation.label, annotation.description, anots); +aa.graph = annotation.graph; +aa.graphGroup = annotation.graphGroup; +aa.graphHeight = annotation.graphHeight; +if (annotation.getThreshold () != null) { +aa.setThreshold ( new jalview.datamodel.GraphLine (annotation.getThreshold ())); +}if (annotation.$hasScore) { +aa.setScore (annotation.getScore ()); +}var seqRef = annotation.sequenceRef; +if (seqRef != null) { +var aaSeq = acf.getAaForDnaSeq (seqRef); +if (aaSeq != null) { +aa.setSequenceRef (aaSeq); +aa.createSequenceMapping (aaSeq, aaSeq.getStart (), true); +aa.adjustForAlignment (); +aaSeq.addAlignmentAnnotation (aa); +}}al.addAnnotation (aa); +} +}}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignedCodonFrame"); +c$.getCodonAnnotation = Clazz.defineMethod (c$, "getCodonAnnotation", +($fz = function (is, annotations) { +var contrib = 0; +var annot = null; +for (var p = 1; p <= 3; p++) { +var dnaCol = is.getBaseColumn (p); +if (annotations[dnaCol] != null) { +if (annot == null) { +annot = new jalview.datamodel.Annotation (annotations[dnaCol]); +contrib = 1; +} else { +var cpy = new jalview.datamodel.Annotation (annotations[dnaCol]); +if (annot.colour == null) { +annot.colour = cpy.colour; +}if (annot.description == null || annot.description.length == 0) { +annot.description = cpy.description; +}if (annot.displayCharacter == null) { +annot.displayCharacter = cpy.displayCharacter; +}if (annot.secondaryStructure.charCodeAt (0) == 0) { +annot.secondaryStructure = cpy.secondaryStructure; +}annot.value += cpy.value; +contrib++; +}}} +if (contrib > 1) { +annot.value /= contrib; +}return annot; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignedCodon,~A"); +Clazz.defineMethod (c$, "translateCodingRegion", +function (selection, seqstring, acf, proteinSeqs) { +var skip = new java.util.ArrayList (); +var skipint = null; +var vismapping = new jalview.util.ShiftList (); +var vc; +var scontigs = Clazz.newIntArray (this.contigs.length, 0); +var npos = 0; +for (vc = 0; vc < this.contigs.length; vc += 2) { +if (vc == 0) { +vismapping.addShift (npos, this.contigs[vc]); +} else { +vismapping.addShift (npos, this.contigs[vc] - this.contigs[vc - 1] + 1); +}scontigs[vc] = this.contigs[vc]; +scontigs[vc + 1] = this.contigs[vc + 1]; +} +var protein = new StringBuilder (Clazz.doubleToInt (seqstring.length / 2)); +var seq = seqstring.$replace ('U', 'T').$replace ('u', 'T'); +var codon = Clazz.newCharArray (3, '\0'); +var cdp = Clazz.newIntArray (3, 0); +var rf = 0; +var lastnpos = 0; +var nend; +var aspos = 0; +var resSize = 0; +for (npos = 0, nend = seq.length; npos < nend; npos++) { +if (!jalview.util.Comparison.isGap (seq.charAt (npos))) { +cdp[rf] = npos; +codon[rf++] = seq.charAt (npos); +}if (rf == 3) { +var alignedCodon = new jalview.datamodel.AlignedCodon (cdp[0], cdp[1], cdp[2]); +var aa = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (codon)); +rf = 0; +var gapString = String.valueOf (this.gapChar); +if (aa == null) { +aa = gapString; +if (skipint == null) { +skipint = Clazz.newIntArray (-1, [alignedCodon.pos1, alignedCodon.pos3]); +}skipint[1] = alignedCodon.pos3; +} else { +if (skipint != null) { +skipint[0] = vismapping.shift (skipint[0]); +skipint[1] = vismapping.shift (skipint[1]); +for (vc = 0; vc < scontigs.length; ) { +if (scontigs[vc + 1] < skipint[0]) { +vc += 2; +continue; +}if (scontigs[vc] > skipint[1]) { +break; +}var t; +if (scontigs[vc] <= skipint[0]) { +if (skipint[0] == scontigs[vc]) { +if (scontigs[vc + 1] > skipint[1]) { +scontigs[vc] = skipint[1]; +vc += 2; +} else { +if (scontigs[vc + 1] == skipint[1]) { +t = Clazz.newIntArray (scontigs.length - 2, 0); +if (vc > 0) { +System.arraycopy (scontigs, 0, t, 0, vc - 1); +}if (vc + 2 < t.length) { +System.arraycopy (scontigs, vc + 2, t, vc, t.length - vc + 2); +}scontigs = t; +} else { +scontigs[vc + 1] = skipint[0] - 1; +vc += 2; +}}} else { +if (scontigs[vc + 1] < skipint[1]) { +scontigs[vc + 1] = skipint[0] - 1; +vc += 2; +} else { +t = Clazz.newIntArray (scontigs.length + 2, 0); +System.arraycopy (scontigs, 0, t, 0, vc + 1); +t[vc + 1] = skipint[0]; +t[vc + 2] = skipint[1]; +System.arraycopy (scontigs, vc + 1, t, vc + 3, scontigs.length - (vc + 1)); +scontigs = t; +vc += 4; +}}}} +skip.add (skipint); +skipint = null; +}if (aa.equals ("STOP")) { +aa = "X"; +}resSize++; +}var findpos = true; +while (findpos) { +var compareCodonPos = jalview.analysis.Dna.compareCodonPos (alignedCodon, this.alignedCodons[aspos]); +switch (compareCodonPos) { +case -1: +this.insertAAGap (aspos, proteinSeqs); +findpos = false; +break; +case 1: +aa = gapString + aa; +aspos++; +break; +case 0: +findpos = false; +} +} +protein.append (aa); +lastnpos = npos; +if (this.alignedCodons[aspos] == null) { +this.alignedCodons[aspos] = alignedCodon; +} else if (!this.alignedCodons[aspos].equals (alignedCodon)) { +throw new IllegalStateException ("Tried to coalign " + this.alignedCodons[aspos].toString () + " with " + alignedCodon.toString ()); +}if (aspos >= this.aaWidth) { +this.aaWidth = aspos; +}aspos++; +}} +if (resSize > 0) { +var newseq = new jalview.datamodel.Sequence (selection.getName (), protein.toString ()); +if (rf != 0) { +var errMsg = "trimming contigs for incomplete terminal codon."; +System.err.println ("trimming contigs for incomplete terminal codon."); +vc = scontigs.length - 1; +lastnpos = vismapping.shift (lastnpos); +while (vc >= 0 && scontigs[vc] > lastnpos) { +if (vc > 0 && scontigs[vc - 1] > lastnpos) { +vc -= 2; +} else { +scontigs[vc] = lastnpos; +}} +if (vc > 0 && (vc + 1) < scontigs.length) { +var t = Clazz.newIntArray (vc + 1, 0); +System.arraycopy (scontigs, 0, t, 0, vc + 1); +scontigs = t; +}if (vc <= 0) { +scontigs = null; +}}if (scontigs != null) { +npos = 0; +for (vc = 0; vc < scontigs.length; vc += 2) { +scontigs[vc] = selection.findPosition (scontigs[vc]); +scontigs[vc + 1] = selection.findPosition (scontigs[vc + 1]); +if (scontigs[vc + 1] == selection.getEnd ()) { +break; +}} +if ((vc + 2) < scontigs.length) { +var t = Clazz.newIntArray (vc + 2, 0); +System.arraycopy (scontigs, 0, t, 0, vc + 2); +scontigs = t; +}var map = new jalview.util.MapList (scontigs, Clazz.newIntArray (-1, [1, resSize]), 3, 1); +jalview.analysis.Dna.transferCodedFeatures (selection, newseq, map, null, null); +var rseq = newseq.deriveSequence (); +acf.addMap (selection, rseq, map); +return rseq; +}}return null; +}, "jalview.datamodel.SequenceI,~S,jalview.datamodel.AlignedCodonFrame,java.util.List"); +Clazz.defineMethod (c$, "insertAAGap", +function (pos, proteinSeqs) { +this.aaWidth++; +for (var seq, $seq = proteinSeqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +seq.insertCharAt (pos, this.gapChar); +} +this.checkCodonFrameWidth (); +if (pos < this.aaWidth) { +this.aaWidth++; +System.arraycopy (this.alignedCodons, pos, this.alignedCodons, pos + 1, this.alignedCodons.length - pos - 1); +this.alignedCodons[pos] = null; +}}, "~N,java.util.List"); +Clazz.defineMethod (c$, "checkCodonFrameWidth", +function () { +if (this.alignedCodons[this.alignedCodons.length - 1] != null) { +var c = new Array (this.alignedCodons.length + 10); +System.arraycopy (this.alignedCodons, 0, c, 0, this.alignedCodons.length); +this.alignedCodons = c; +}}); +c$.transferCodedFeatures = Clazz.defineMethod (c$, "transferCodedFeatures", +($fz = function (dna, pep, map, featureTypes, featureGroups) { +var sfs = dna.getSequenceFeatures (); +var fgstate; +var dnarefs = jalview.util.DBRefUtils.selectRefs (dna.getDBRef (), jalview.datamodel.DBRefSource.DNACODINGDBS); +if (dnarefs != null) { +for (var d = 0; d < dnarefs.length; d++) { +var mp = dnarefs[d].getMap (); +if (mp != null) { +}} +}if (sfs != null) { +for (var sf, $sf = 0, $$sf = sfs; $sf < $$sf.length && ((sf = $$sf[$sf]) || true); $sf++) { +fgstate = (featureGroups == null) ? null : featureGroups.get (sf.featureGroup); +if ((featureTypes == null || featureTypes.containsKey (sf.getType ())) && (fgstate == null || fgstate.booleanValue ())) { +if (jalview.datamodel.FeatureProperties.isCodingFeature (null, sf.getType ())) { +{ +}}}} +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList,java.util.Map,java.util.Map"); +Clazz.defineStatics (c$, +"STOP_X", "X"); +c$.comparator = c$.prototype.comparator = new jalview.analysis.CodonComparator (); +}); diff --git a/bin/jalview/analysis/Finder.js b/bin/jalview/analysis/Finder.js index 5d20c2c..cf1d8f9 100644 --- a/bin/jalview/analysis/Finder.js +++ b/bin/jalview/analysis/Finder.js @@ -1,182 +1,182 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.Finder", ["jalview.datamodel.SearchResults", "jalview.jsdev.RegExp", "jalview.util.Comparison", "java.lang.StringBuffer", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.searchResults = null; -this.alignment = null; -this.selection = null; -this.idMatch = null; -this.caseSensitive = false; -this.includeDescription = false; -this.findAll = false; -this.regex = null; -this.seqIndex = 0; -this.resIndex = -1; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "Finder"); -Clazz.makeConstructor (c$, -function (alignment, selection) { -this.alignment = alignment; -this.selection = selection; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); -Clazz.makeConstructor (c$, -function (alignment, selectionGroup, seqIndex, resIndex) { -this.construct (alignment, selectionGroup); -this.seqIndex = seqIndex; -this.resIndex = resIndex; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup,~N,~N"); -Clazz.defineMethod (c$, "find", -function (searchString) { -var hasResults = false; -if (!this.caseSensitive) { -searchString = searchString.toUpperCase (); -}this.regex = jalview.jsdev.RegExp.newRegex ([searchString]); -this.regex.setIgnoreCase (!this.caseSensitive); -this.searchResults = new jalview.datamodel.SearchResults (); -this.idMatch = new java.util.Vector (); -var seq; -var item = null; -var found = false; -var end = this.alignment.getHeight (); -if (this.selection != null) { -if ((this.selection.getSize () < 1) || ((this.selection.getEndRes () - this.selection.getStartRes ()) < 2)) { -this.selection = null; -}}while (!found && (this.seqIndex < end)) { -seq = this.alignment.getSequenceAt (this.seqIndex); -if ((this.selection != null && this.selection.getSize () > 0) && !this.selection.getSequences (null).contains (seq)) { -this.seqIndex++; -this.resIndex = -1; -continue; -}if (this.resIndex < 0) { -this.resIndex = 0; -try { -var res = Integer.parseInt (searchString); -if (seq.getEnd () >= res) { -this.searchResults.addResult (seq, res, res); -hasResults = true; -if (!this.findAll) { -found = true; -break; -}}} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -if (this.regex.search (seq.getName ())) { -this.idMatch.addElement (seq); -hasResults = true; -if (!this.findAll) { -found = true; -break; -}}if (this.isIncludeDescription () && seq.getDescription () != null && this.regex.search (seq.getDescription ())) { -this.idMatch.addElement (seq); -hasResults = true; -if (!this.findAll) { -found = true; -break; -}}}item = seq.getSequenceAsString (); -if ((this.selection != null) && (this.selection.getEndRes () < this.alignment.getWidth () - 1)) { -item = item.substring (0, this.selection.getEndRes () + 1); -}var noGapsSB = new StringBuffer (); -var insertCount = 0; -var spaces = new java.util.Vector (); -for (var j = 0; j < item.length; j++) { -if (!jalview.util.Comparison.isGap (item.charAt (j))) { -noGapsSB.append (item.charAt (j)); -spaces.addElement ( new Integer (insertCount)); -} else { -insertCount++; -}} -var noGaps = noGapsSB.toString (); -for (var r = this.resIndex; r < noGaps.length; r++) { -if (this.regex.searchFrom (noGaps, r)) { -this.resIndex = this.regex.matchedFrom (); -if ((this.selection != null && this.selection.getSize () > 0) && ((this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ())) < this.selection.getStartRes ())) { -continue; -}var sres = seq.findPosition (this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ())); -var eres = seq.findPosition (this.regex.matchedTo () - 1 + Integer.parseInt (spaces.elementAt (this.regex.matchedTo () - 1).toString ())); -this.searchResults.addResult (seq, sres, eres); -hasResults = true; -if (!this.findAll) { -found = true; -this.resIndex++; -break; -}r = this.resIndex; -} else { -break; -}} -if (!found) { -this.seqIndex++; -this.resIndex = -1; -}} -return hasResults; -}, "~S"); -Clazz.defineMethod (c$, "getAlignment", -function () { -return this.alignment; -}); -Clazz.defineMethod (c$, "setAlignment", -function (alignment) { -this.alignment = alignment; -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "isCaseSensitive", -function () { -return this.caseSensitive; -}); -Clazz.defineMethod (c$, "setCaseSensitive", -function (caseSensitive) { -this.caseSensitive = caseSensitive; -}, "~B"); -Clazz.defineMethod (c$, "isFindAll", -function () { -return this.findAll; -}); -Clazz.defineMethod (c$, "setFindAll", -function (findAll) { -this.findAll = findAll; -}, "~B"); -Clazz.defineMethod (c$, "getSelection", -function () { -return this.selection; -}); -Clazz.defineMethod (c$, "setSelection", -function (selection) { -this.selection = selection; -}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "getIdMatch", -function () { -return this.idMatch; -}); -Clazz.defineMethod (c$, "getRegex", -function () { -return this.regex; -}); -Clazz.defineMethod (c$, "getSearchResults", -function () { -return this.searchResults; -}); -Clazz.defineMethod (c$, "getResIndex", -function () { -return this.resIndex; -}); -Clazz.defineMethod (c$, "setResIndex", -function (resIndex) { -this.resIndex = resIndex; -}, "~N"); -Clazz.defineMethod (c$, "getSeqIndex", -function () { -return this.seqIndex; -}); -Clazz.defineMethod (c$, "setSeqIndex", -function (seqIndex) { -this.seqIndex = seqIndex; -}, "~N"); -Clazz.defineMethod (c$, "isIncludeDescription", -function () { -return this.includeDescription; -}); -Clazz.defineMethod (c$, "setIncludeDescription", -function (includeDescription) { -this.includeDescription = includeDescription; -}, "~B"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.Finder", ["jalview.datamodel.SearchResults", "jalview.jsdev.RegExp", "jalview.util.Comparison", "java.lang.StringBuffer", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.searchResults = null; +this.alignment = null; +this.selection = null; +this.idMatch = null; +this.caseSensitive = false; +this.includeDescription = false; +this.findAll = false; +this.regex = null; +this.seqIndex = 0; +this.resIndex = -1; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "Finder"); +Clazz.makeConstructor (c$, +function (alignment, selection) { +this.alignment = alignment; +this.selection = selection; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); +Clazz.makeConstructor (c$, +function (alignment, selectionGroup, seqIndex, resIndex) { +this.construct (alignment, selectionGroup); +this.seqIndex = seqIndex; +this.resIndex = resIndex; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup,~N,~N"); +Clazz.defineMethod (c$, "find", +function (searchString) { +var hasResults = false; +if (!this.caseSensitive) { +searchString = searchString.toUpperCase (); +}this.regex = jalview.jsdev.RegExp.newRegex ([searchString]); +this.regex.setIgnoreCase (!this.caseSensitive); +this.searchResults = new jalview.datamodel.SearchResults (); +this.idMatch = new java.util.Vector (); +var seq; +var item = null; +var found = false; +var end = this.alignment.getHeight (); +if (this.selection != null) { +if ((this.selection.getSize () < 1) || ((this.selection.getEndRes () - this.selection.getStartRes ()) < 2)) { +this.selection = null; +}}while (!found && (this.seqIndex < end)) { +seq = this.alignment.getSequenceAt (this.seqIndex); +if ((this.selection != null && this.selection.getSize () > 0) && !this.selection.getSequences (null).contains (seq)) { +this.seqIndex++; +this.resIndex = -1; +continue; +}if (this.resIndex < 0) { +this.resIndex = 0; +try { +var res = Integer.parseInt (searchString); +if (seq.getEnd () >= res) { +this.searchResults.addResult (seq, res, res); +hasResults = true; +if (!this.findAll) { +found = true; +break; +}}} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +if (this.regex.search (seq.getName ())) { +this.idMatch.addElement (seq); +hasResults = true; +if (!this.findAll) { +found = true; +break; +}}if (this.isIncludeDescription () && seq.getDescription () != null && this.regex.search (seq.getDescription ())) { +this.idMatch.addElement (seq); +hasResults = true; +if (!this.findAll) { +found = true; +break; +}}}item = seq.getSequenceAsString (); +if ((this.selection != null) && (this.selection.getEndRes () < this.alignment.getWidth () - 1)) { +item = item.substring (0, this.selection.getEndRes () + 1); +}var noGapsSB = new StringBuffer (); +var insertCount = 0; +var spaces = new java.util.Vector (); +for (var j = 0; j < item.length; j++) { +if (!jalview.util.Comparison.isGap (item.charAt (j))) { +noGapsSB.append (item.charAt (j)); +spaces.addElement ( new Integer (insertCount)); +} else { +insertCount++; +}} +var noGaps = noGapsSB.toString (); +for (var r = this.resIndex; r < noGaps.length; r++) { +if (this.regex.searchFrom (noGaps, r)) { +this.resIndex = this.regex.matchedFrom (); +if ((this.selection != null && this.selection.getSize () > 0) && ((this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ())) < this.selection.getStartRes ())) { +continue; +}var sres = seq.findPosition (this.resIndex + Integer.parseInt (spaces.elementAt (this.resIndex).toString ())); +var eres = seq.findPosition (this.regex.matchedTo () - 1 + Integer.parseInt (spaces.elementAt (this.regex.matchedTo () - 1).toString ())); +this.searchResults.addResult (seq, sres, eres); +hasResults = true; +if (!this.findAll) { +found = true; +this.resIndex++; +break; +}r = this.resIndex; +} else { +break; +}} +if (!found) { +this.seqIndex++; +this.resIndex = -1; +}} +return hasResults; +}, "~S"); +Clazz.defineMethod (c$, "getAlignment", +function () { +return this.alignment; +}); +Clazz.defineMethod (c$, "setAlignment", +function (alignment) { +this.alignment = alignment; +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "isCaseSensitive", +function () { +return this.caseSensitive; +}); +Clazz.defineMethod (c$, "setCaseSensitive", +function (caseSensitive) { +this.caseSensitive = caseSensitive; +}, "~B"); +Clazz.defineMethod (c$, "isFindAll", +function () { +return this.findAll; +}); +Clazz.defineMethod (c$, "setFindAll", +function (findAll) { +this.findAll = findAll; +}, "~B"); +Clazz.defineMethod (c$, "getSelection", +function () { +return this.selection; +}); +Clazz.defineMethod (c$, "setSelection", +function (selection) { +this.selection = selection; +}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "getIdMatch", +function () { +return this.idMatch; +}); +Clazz.defineMethod (c$, "getRegex", +function () { +return this.regex; +}); +Clazz.defineMethod (c$, "getSearchResults", +function () { +return this.searchResults; +}); +Clazz.defineMethod (c$, "getResIndex", +function () { +return this.resIndex; +}); +Clazz.defineMethod (c$, "setResIndex", +function (resIndex) { +this.resIndex = resIndex; +}, "~N"); +Clazz.defineMethod (c$, "getSeqIndex", +function () { +return this.seqIndex; +}); +Clazz.defineMethod (c$, "setSeqIndex", +function (seqIndex) { +this.seqIndex = seqIndex; +}, "~N"); +Clazz.defineMethod (c$, "isIncludeDescription", +function () { +return this.includeDescription; +}); +Clazz.defineMethod (c$, "setIncludeDescription", +function (includeDescription) { +this.includeDescription = includeDescription; +}, "~B"); +}); diff --git a/bin/jalview/analysis/Grouping.js b/bin/jalview/analysis/Grouping.js index 49d4004..60e2571 100644 --- a/bin/jalview/analysis/Grouping.js +++ b/bin/jalview/analysis/Grouping.js @@ -1,88 +1,88 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.Grouping", ["jalview.datamodel.SequenceGroup", "java.lang.StringBuilder", "java.util.ArrayList", "$.HashMap"], function () { -c$ = Clazz.declareType (jalview.analysis, "Grouping"); -c$.makeGroupsFrom = Clazz.defineMethod (c$, "makeGroupsFrom", -function (sequences, selectedChars, list) { -var gps = new java.util.HashMap (); -var width = 0; -var i; -var pgroup = new java.util.HashMap (); -if (list != null) { -for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -for (var sq, $sq = sg.getSequences (null).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -pgroup.put (sq.toString (), sg); -} -} -}for (i = 0; i < sequences.length; i++) { -var schar = selectedChars[i]; -var pgp = pgroup.get ((sequences[i]).toString ()); -if (pgp != null) { -schar = pgp.getName () + ":" + schar; -}var svec = gps.get (schar); -if (svec == null) { -svec = new java.util.ArrayList (); -gps.put (schar, svec); -}if (width < sequences[i].getLength ()) { -width = sequences[i].getLength (); -}svec.add (sequences[i]); -} -var groups = new Array (gps.size ()); -i = 0; -for (var key, $key = gps.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { -var group = new jalview.datamodel.SequenceGroup (gps.get (key), "Subseq: " + key, null, true, true, false, 0, width - 1); -groups[i++] = group; -} -gps.clear (); -pgroup.clear (); -return groups; -}, "~A,~A,java.util.List"); -c$.makeGroupsFromCols = Clazz.defineMethod (c$, "makeGroupsFromCols", -function (sequences, cs, list) { -var gps = new java.util.HashMap (); -var pgroup = new java.util.HashMap (); -if (list != null) { -for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -for (var sq, $sq = sg.getSequences (null).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -pgroup.put (sq.toString (), sg); -} -} -}var spos = Clazz.newIntArray (cs.getSelected ().size (), 0); -var width = -1; -var i = 0; -for (var pos, $pos = cs.getSelected ().iterator (); $pos.hasNext () && ((pos = $pos.next ()) || true);) { -spos[i++] = pos.intValue (); -} -;for (i = 0; i < sequences.length; i++) { -var slen = sequences[i].getLength (); -if (width < slen) { -width = slen; -}var pgp = pgroup.get ((sequences[i]).toString ()); -var schar = new StringBuilder (); -if (pgp != null) { -schar.append (pgp.getName () + ":"); -}for (var p, $p = 0, $$p = spos; $p < $$p.length && ((p = $$p[$p]) || true); $p++) { -if (p >= slen) { -schar.append ("~"); -} else { -schar.append (sequences[i].getCharAt (p)); -}} -var svec = gps.get (schar.toString ()); -if (svec == null) { -svec = new java.util.ArrayList (); -gps.put (schar.toString (), svec); -}svec.add (sequences[i]); -} -var groups = new Array (gps.size ()); -i = 0; -for (var key, $key = gps.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { -var group = new jalview.datamodel.SequenceGroup (gps.get (key), "Subseq: " + key, null, true, true, false, 0, width - 1); -groups[i++] = group; -} -gps.clear (); -pgroup.clear (); -return groups; -}, "~A,jalview.datamodel.ColumnSelection,java.util.List"); -c$.divideByFeature = Clazz.defineMethod (c$, "divideByFeature", -function (featureLabels, groupLabels, start, stop, sequences, exgroups, method) { -}, "~A,~A,~N,~N,~A,java.util.Vector,~S"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.Grouping", ["jalview.datamodel.SequenceGroup", "java.lang.StringBuilder", "java.util.ArrayList", "$.HashMap"], function () { +c$ = Clazz.declareType (jalview.analysis, "Grouping"); +c$.makeGroupsFrom = Clazz.defineMethod (c$, "makeGroupsFrom", +function (sequences, selectedChars, list) { +var gps = new java.util.HashMap (); +var width = 0; +var i; +var pgroup = new java.util.HashMap (); +if (list != null) { +for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +for (var sq, $sq = sg.getSequences (null).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +pgroup.put (sq.toString (), sg); +} +} +}for (i = 0; i < sequences.length; i++) { +var schar = selectedChars[i]; +var pgp = pgroup.get ((sequences[i]).toString ()); +if (pgp != null) { +schar = pgp.getName () + ":" + schar; +}var svec = gps.get (schar); +if (svec == null) { +svec = new java.util.ArrayList (); +gps.put (schar, svec); +}if (width < sequences[i].getLength ()) { +width = sequences[i].getLength (); +}svec.add (sequences[i]); +} +var groups = new Array (gps.size ()); +i = 0; +for (var key, $key = gps.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { +var group = new jalview.datamodel.SequenceGroup (gps.get (key), "Subseq: " + key, null, true, true, false, 0, width - 1); +groups[i++] = group; +} +gps.clear (); +pgroup.clear (); +return groups; +}, "~A,~A,java.util.List"); +c$.makeGroupsFromCols = Clazz.defineMethod (c$, "makeGroupsFromCols", +function (sequences, cs, list) { +var gps = new java.util.HashMap (); +var pgroup = new java.util.HashMap (); +if (list != null) { +for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +for (var sq, $sq = sg.getSequences (null).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +pgroup.put (sq.toString (), sg); +} +} +}var spos = Clazz.newIntArray (cs.getSelected ().size (), 0); +var width = -1; +var i = 0; +for (var pos, $pos = cs.getSelected ().iterator (); $pos.hasNext () && ((pos = $pos.next ()) || true);) { +spos[i++] = pos.intValue (); +} +;for (i = 0; i < sequences.length; i++) { +var slen = sequences[i].getLength (); +if (width < slen) { +width = slen; +}var pgp = pgroup.get ((sequences[i]).toString ()); +var schar = new StringBuilder (); +if (pgp != null) { +schar.append (pgp.getName () + ":"); +}for (var p, $p = 0, $$p = spos; $p < $$p.length && ((p = $$p[$p]) || true); $p++) { +if (p >= slen) { +schar.append ("~"); +} else { +schar.append (sequences[i].getCharAt (p)); +}} +var svec = gps.get (schar.toString ()); +if (svec == null) { +svec = new java.util.ArrayList (); +gps.put (schar.toString (), svec); +}svec.add (sequences[i]); +} +var groups = new Array (gps.size ()); +i = 0; +for (var key, $key = gps.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { +var group = new jalview.datamodel.SequenceGroup (gps.get (key), "Subseq: " + key, null, true, true, false, 0, width - 1); +groups[i++] = group; +} +gps.clear (); +pgroup.clear (); +return groups; +}, "~A,jalview.datamodel.ColumnSelection,java.util.List"); +c$.divideByFeature = Clazz.defineMethod (c$, "divideByFeature", +function (featureLabels, groupLabels, start, stop, sequences, exgroups, method) { +}, "~A,~A,~N,~N,~A,java.util.Vector,~S"); +}); diff --git a/bin/jalview/analysis/NJTree.js b/bin/jalview/analysis/NJTree.js index 8f3a367..24a8fc5 100644 --- a/bin/jalview/analysis/NJTree.js +++ b/bin/jalview/analysis/NJTree.js @@ -1,577 +1,577 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["java.util.Vector"], ["jalview.analysis.Cluster", "$.NJTree"], ["jalview.analysis.SequenceIdMatcher", "jalview.datamodel.AlignmentView", "$.CigarArray", "$.NodeTransformI", "$.SeqCigar", "$.Sequence", "$.SequenceI", "$.SequenceNode", "jalview.io.NewickFile", "jalview.schemes.ResidueProperties", "jalview.util.Format", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.$cluster = null; -this.sequence = null; -this.seqData = null; -this.done = null; -this.noseqs = 0; -this.noClus = 0; -this.distance = null; -this.mini = 0; -this.minj = 0; -this.ri = 0; -this.rj = 0; -this.groups = null; -this.maxdist = null; -this.top = null; -this.maxDistValue = 0; -this.maxheight = 0; -this.ycount = 0; -this.node = null; -this.type = null; -this.pwtype = null; -this.found = null; -this.leaves = null; -this.hasDistances = true; -this.hasBootstrap = false; -this.hasRootDistance = true; -this._lycount = 0; -this._lylimit = 0; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "NJTree"); -Clazz.prepareFields (c$, function () { -this.groups = new java.util.Vector (); -}); -Clazz.makeConstructor (c$, -function (seqs, odata, treefile) { -this.construct (seqs, treefile); -if (odata != null) { -this.seqData = odata; -}}, "~A,jalview.datamodel.AlignmentView,jalview.io.NewickFile"); -Clazz.makeConstructor (c$, -function (seqs, treefile) { -this.sequence = seqs; -this.top = treefile.getTree (); -this.hasDistances = treefile.HasDistances (); -this.hasBootstrap = treefile.HasBootstrap (); -this.hasRootDistance = treefile.HasRootDistance (); -this.maxheight = this.findHeight (this.top); -var algnIds = new jalview.analysis.SequenceIdMatcher (seqs); -var leaves = new java.util.Vector (); -this.findLeaves (this.top, leaves); -var i = 0; -var namesleft = seqs.length; -var j; -var nam; -var realnam; -var one2many = new java.util.Vector (); -var countOne2Many = 0; -while (i < leaves.size ()) { -j = leaves.elementAt (i++); -realnam = j.getName (); -nam = null; -if (namesleft > -1) { -nam = algnIds.findIdMatch (realnam); -}if (nam != null) { -j.setElement (nam); -if (one2many.contains (nam)) { -countOne2Many++; -} else { -one2many.addElement (nam); -namesleft--; -}} else { -j.setElement ( new jalview.datamodel.Sequence (realnam, "THISISAPLACEHLDER")); -j.setPlaceholder (true); -}} -}, "~A,jalview.io.NewickFile"); -Clazz.makeConstructor (c$, -function (sequence, seqData, type, pwtype, sm, start, end) { -this.sequence = sequence; -this.node = new java.util.Vector (); -this.type = type; -this.pwtype = pwtype; -if (seqData != null) { -this.seqData = seqData; -} else { -var seqs = new Array (sequence.length); -for (var i = 0; i < sequence.length; i++) { -seqs[i] = new jalview.datamodel.SeqCigar (sequence[i], start, end); -} -var sdata = new jalview.datamodel.CigarArray (seqs); -sdata.addOperation ('M', end - start + 1); -this.seqData = new jalview.datamodel.AlignmentView (sdata, start); -}if (!(type.equals ("NJ"))) { -type = "AV"; -}if (sm == null && !(pwtype.equals ("PID"))) { -if (jalview.schemes.ResidueProperties.getScoreMatrix (pwtype) == null) { -pwtype = "BLOSUM62"; -}}var i = 0; -this.done = Clazz.newIntArray (sequence.length, 0); -while ((i < sequence.length) && (sequence[i] != null)) { -this.done[i] = 0; -i++; -} -this.noseqs = i++; -this.distance = this.findDistances (sm); -this.makeLeaves (); -this.noClus = this.$cluster.size (); -this.cluster (); -}, "~A,jalview.datamodel.AlignmentView,~S,~S,jalview.api.analysis.ScoreModelI,~N,~N"); -Clazz.overrideMethod (c$, "toString", -function () { -var fout = new jalview.io.NewickFile (this.getTopNode ()); -return fout.print (this.isHasBootstrap (), this.isHasDistances (), this.isHasRootDistance ()); -}); -Clazz.defineMethod (c$, "UpdatePlaceHolders", -function (list) { -var leaves = new java.util.Vector (); -this.findLeaves (this.top, leaves); -var sz = leaves.size (); -var seqmatcher = null; -var i = 0; -while (i < sz) { -var leaf = leaves.elementAt (i++); -if (list.contains (leaf.element ())) { -leaf.setPlaceholder (false); -} else { -if (seqmatcher == null) { -var seqs = new Array (list.size ()); -for (var j = 0; j < seqs.length; j++) { -seqs[j] = list.get (j); -} -seqmatcher = new jalview.analysis.SequenceIdMatcher (seqs); -}var nam = seqmatcher.findIdMatch (leaf.getName ()); -if (nam != null) { -if (!leaf.isPlaceholder ()) { -}leaf.setPlaceholder (false); -leaf.setElement (nam); -} else { -if (!leaf.isPlaceholder ()) { -leaf.setElement ( new jalview.datamodel.Sequence (leaf.getName (), "THISISAPLACEHLDER")); -}leaf.setPlaceholder (true); -}}} -}, "java.util.List"); -Clazz.defineMethod (c$, "renameAssociatedNodes", -function () { -this.applyToNodes (((Clazz.isClassDefined ("jalview.analysis.NJTree$1") ? 0 : jalview.analysis.NJTree.$NJTree$1$ ()), Clazz.innerTypeInstance (jalview.analysis.NJTree$1, this, null))); -}); -Clazz.defineMethod (c$, "cluster", -function () { -while (this.noClus > 2) { -if (this.type.equals ("NJ")) { -this.findMinNJDistance (); -} else { -this.findMinDistance (); -}var c = this.joinClusters (this.mini, this.minj); -this.done[this.minj] = 1; -this.$cluster.setElementAt (null, this.minj); -this.$cluster.setElementAt (c, this.mini); -this.noClus--; -} -var onefound = false; -var one = -1; -var two = -1; -for (var i = 0; i < this.noseqs; i++) { -if (this.done[i] != 1) { -if (onefound == false) { -two = i; -onefound = true; -} else { -one = i; -}}} -this.joinClusters (one, two); -this.top = (this.node.elementAt (one)); -this.reCount (this.top); -this.findHeight (this.top); -this.findMaxDist (this.top); -}); -Clazz.defineMethod (c$, "joinClusters", -function (i, j) { -var dist = this.distance[i][j]; -var noi = (this.$cluster.elementAt (i)).value.length; -var noj = (this.$cluster.elementAt (j)).value.length; -var value = Clazz.newIntArray (noi + noj, 0); -for (var ii = 0; ii < noi; ii++) { -value[ii] = (this.$cluster.elementAt (i)).value[ii]; -} -for (var ii = noi; ii < (noi + noj); ii++) { -value[ii] = (this.$cluster.elementAt (j)).value[ii - noi]; -} -var c = new jalview.analysis.Cluster (value); -this.ri = this.findr (i, j); -this.rj = this.findr (j, i); -if (this.type.equals ("NJ")) { -this.findClusterNJDistance (i, j); -} else { -this.findClusterDistance (i, j); -}var sn = new jalview.datamodel.SequenceNode (); -sn.setLeft ((this.node.elementAt (i))); -sn.setRight ((this.node.elementAt (j))); -var tmpi = (this.node.elementAt (i)); -var tmpj = (this.node.elementAt (j)); -if (this.type.equals ("NJ")) { -this.findNewNJDistances (tmpi, tmpj, dist); -} else { -this.findNewDistances (tmpi, tmpj, dist); -}tmpi.setParent (sn); -tmpj.setParent (sn); -this.node.setElementAt (sn, i); -return c; -}, "~N,~N"); -Clazz.defineMethod (c$, "findNewNJDistances", -function (tmpi, tmpj, dist) { -tmpi.dist = ((dist + this.ri) - this.rj) / 2; -tmpj.dist = (dist - tmpi.dist); -if (tmpi.dist < 0) { -tmpi.dist = 0; -}if (tmpj.dist < 0) { -tmpj.dist = 0; -}}, "jalview.datamodel.SequenceNode,jalview.datamodel.SequenceNode,~N"); -Clazz.defineMethod (c$, "findNewDistances", -function (tmpi, tmpj, dist) { -var ih = 0; -var jh = 0; -var sni = tmpi; -var snj = tmpj; -while (sni != null) { -ih = ih + sni.dist; -sni = sni.left (); -} -while (snj != null) { -jh = jh + snj.dist; -snj = snj.left (); -} -tmpi.dist = ((dist / 2) - ih); -tmpj.dist = ((dist / 2) - jh); -}, "jalview.datamodel.SequenceNode,jalview.datamodel.SequenceNode,~N"); -Clazz.defineMethod (c$, "findClusterDistance", -function (i, j) { -var noi = (this.$cluster.elementAt (i)).value.length; -var noj = (this.$cluster.elementAt (j)).value.length; -var newdist = Clazz.newFloatArray (this.noseqs, 0); -for (var l = 0; l < this.noseqs; l++) { -if ((l != i) && (l != j)) { -newdist[l] = ((this.distance[i][l] * noi) + (this.distance[j][l] * noj)) / (noi + noj); -} else { -newdist[l] = 0; -}} -for (var ii = 0; ii < this.noseqs; ii++) { -this.distance[i][ii] = newdist[ii]; -this.distance[ii][i] = newdist[ii]; -} -}, "~N,~N"); -Clazz.defineMethod (c$, "findClusterNJDistance", -function (i, j) { -var newdist = Clazz.newFloatArray (this.noseqs, 0); -for (var l = 0; l < this.noseqs; l++) { -if ((l != i) && (l != j)) { -newdist[l] = ((this.distance[i][l] + this.distance[j][l]) - this.distance[i][j]) / 2; -} else { -newdist[l] = 0; -}} -for (var ii = 0; ii < this.noseqs; ii++) { -this.distance[i][ii] = newdist[ii]; -this.distance[ii][i] = newdist[ii]; -} -}, "~N,~N"); -Clazz.defineMethod (c$, "findr", -function (i, j) { -var tmp = 1; -for (var k = 0; k < this.noseqs; k++) { -if ((k != i) && (k != j) && (this.done[k] != 1)) { -tmp = tmp + this.distance[i][k]; -}} -if (this.noClus > 2) { -tmp = tmp / (this.noClus - 2); -}return tmp; -}, "~N,~N"); -Clazz.defineMethod (c$, "findMinNJDistance", -function () { -var min = 100000; -for (var i = 0; i < (this.noseqs - 1); i++) { -for (var j = i + 1; j < this.noseqs; j++) { -if ((this.done[i] != 1) && (this.done[j] != 1)) { -var tmp = this.distance[i][j] - (this.findr (i, j) + this.findr (j, i)); -if (tmp < min) { -this.mini = i; -this.minj = j; -min = tmp; -}}} -} -return min; -}); -Clazz.defineMethod (c$, "findMinDistance", -function () { -var min = 100000; -for (var i = 0; i < (this.noseqs - 1); i++) { -for (var j = i + 1; j < this.noseqs; j++) { -if ((this.done[i] != 1) && (this.done[j] != 1)) { -if (this.distance[i][j] < min) { -this.mini = i; -this.minj = j; -min = this.distance[i][j]; -}}} -} -return min; -}); -Clazz.defineMethod (c$, "findDistances", -function (_pwmatrix) { -var distance = Clazz.newFloatArray (this.noseqs, this.noseqs, 0); -if (_pwmatrix == null) { -_pwmatrix = jalview.schemes.ResidueProperties.getScoreModel (this.pwtype); -if (_pwmatrix == null) { -_pwmatrix = jalview.schemes.ResidueProperties.getScoreMatrix ("BLOSUM62"); -}}distance = _pwmatrix.findDistances (this.seqData); -return distance; -}, "jalview.api.analysis.ScoreModelI"); -Clazz.defineMethod (c$, "makeLeaves", -function () { -this.$cluster = new java.util.Vector (); -for (var i = 0; i < this.noseqs; i++) { -var sn = new jalview.datamodel.SequenceNode (); -sn.setElement (this.sequence[i]); -sn.setName (this.sequence[i].getName ()); -this.node.addElement (sn); -var value = Clazz.newIntArray (1, 0); -value[0] = i; -var c = new jalview.analysis.Cluster (value); -this.$cluster.addElement (c); -} -}); -Clazz.defineMethod (c$, "findLeaves", -function (node, leaves) { -if (node == null) { -return leaves; -}if ((node.left () == null) && (node.right () == null)) { -leaves.addElement (node); -return leaves; -} else { -this.findLeaves (node.left (), leaves); -this.findLeaves (node.right (), leaves); -}return leaves; -}, "jalview.datamodel.SequenceNode,java.util.Vector"); -Clazz.defineMethod (c$, "findLeaf", -function (node, count) { -this.found = this._findLeaf (node, count); -return this.found; -}, "jalview.datamodel.SequenceNode,~N"); -Clazz.defineMethod (c$, "_findLeaf", -function (node, count) { -if (node == null) { -return null; -}if (node.ycount == count) { -this.found = node.element (); -return this.found; -} else { -this._findLeaf (node.left (), count); -this._findLeaf (node.right (), count); -}return this.found; -}, "jalview.datamodel.SequenceNode,~N"); -Clazz.defineMethod (c$, "printNode", -function (node) { -if (node == null) { -return; -}if ((node.left () == null) && (node.right () == null)) { -System.out.println ("Leaf = " + (node.element ()).getName ()); -System.out.println ("Dist " + node.dist); -System.out.println ("Boot " + node.getBootstrap ()); -} else { -System.out.println ("Dist " + node.dist); -this.printNode (node.left ()); -this.printNode (node.right ()); -}}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "findMaxDist", -function (node) { -if (node == null) { -return; -}if ((node.left () == null) && (node.right () == null)) { -var dist = node.dist; -if (dist > this.maxDistValue) { -this.maxdist = node; -this.maxDistValue = dist; -}} else { -this.findMaxDist (node.left ()); -this.findMaxDist (node.right ()); -}}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "getGroups", -function () { -return this.groups; -}); -Clazz.defineMethod (c$, "getMaxHeight", -function () { -return this.maxheight; -}); -Clazz.defineMethod (c$, "groupNodes", -function (node, threshold) { -if (node == null) { -return; -}if ((node.height / this.maxheight) > threshold) { -this.groups.addElement (node); -} else { -this.groupNodes (node.left (), threshold); -this.groupNodes (node.right (), threshold); -}}, "jalview.datamodel.SequenceNode,~N"); -Clazz.defineMethod (c$, "findHeight", -function (node) { -if (node == null) { -return this.maxheight; -}if ((node.left () == null) && (node.right () == null)) { -node.height = (node.parent ()).height + node.dist; -if (node.height > this.maxheight) { -return node.height; -} else { -return this.maxheight; -}} else { -if (node.parent () != null) { -node.height = (node.parent ()).height + node.dist; -} else { -this.maxheight = 0; -node.height = 0.0; -}this.maxheight = this.findHeight ((node.left ())); -this.maxheight = this.findHeight ((node.right ())); -}return this.maxheight; -}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "reRoot", -function () { -if (this.maxdist != null) { -this.ycount = 0; -var tmpdist = this.maxdist.dist; -var sn = new jalview.datamodel.SequenceNode (); -sn.setParent (null); -var snr = this.maxdist.parent (); -this.changeDirection (snr, this.maxdist); -System.out.println ("Printing reversed tree"); -this.printN (snr); -snr.dist = tmpdist / 2; -this.maxdist.dist = tmpdist / 2; -snr.setParent (sn); -this.maxdist.setParent (sn); -sn.setRight (snr); -sn.setLeft (this.maxdist); -this.top = sn; -this.ycount = 0; -this.reCount (this.top); -this.findHeight (this.top); -}return this.top; -}); -Clazz.defineMethod (c$, "hasOriginalSequenceData", -function () { -return this.seqData != null; -}); -Clazz.defineMethod (c$, "printOriginalSequenceData", -function (gapChar) { -if (this.seqData == null) { -return null; -}var sb = new StringBuffer (); -var seqdatas = this.seqData.getSequenceStrings (gapChar); -for (var i = 0; i < seqdatas.length; i++) { -sb.append ( new jalview.util.Format ("%-15s").form (this.sequence[i].getName ())); -sb.append (" " + seqdatas[i] + "\n"); -} -return sb.toString (); -}, "~S"); -Clazz.defineMethod (c$, "printN", -function (node) { -if (node == null) { -return; -}if ((node.left () != null) && (node.right () != null)) { -this.printN (node.left ()); -this.printN (node.right ()); -} else { -System.out.println (" name = " + (node.element ()).getName ()); -}System.out.println (" dist = " + node.dist + " " + node.count + " " + node.height); -}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "reCount", -function (node) { -this.ycount = 0; -this._lycount = 0; -this._reCount (node); -}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "_reCount", -function (node) { -if (node == null) { -return; -}this._lycount++; -if ((node.left () != null) && (node.right () != null)) { -this._reCount (node.left ()); -this._reCount (node.right ()); -var l = node.left (); -var r = node.right (); -node.count = l.count + r.count; -node.ycount = (l.ycount + r.ycount) / 2; -} else { -node.count = 1; -node.ycount = this.ycount++; -}this._lycount--; -}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "swapNodes", -function (node) { -if (node == null) { -return; -}var tmp = node.left (); -node.setLeft (node.right ()); -node.setRight (tmp); -}, "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "changeDirection", -function (node, dir) { -if (node == null) { -return; -}if (node.parent () !== this.top) { -this.changeDirection (node.parent (), node); -var tmp = node.parent (); -if (dir === node.left ()) { -node.setParent (dir); -node.setLeft (tmp); -} else if (dir === node.right ()) { -node.setParent (dir); -node.setRight (tmp); -}} else { -if (dir === node.left ()) { -node.setParent (node.left ()); -if (this.top.left () === node) { -node.setRight (this.top.right ()); -} else { -node.setRight (this.top.left ()); -}} else { -node.setParent (node.right ()); -if (this.top.left () === node) { -node.setLeft (this.top.right ()); -} else { -node.setLeft (this.top.left ()); -}}}}, "jalview.datamodel.SequenceNode,jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "getMaxDist", -function () { -return this.maxdist; -}); -Clazz.defineMethod (c$, "getTopNode", -function () { -return this.top; -}); -Clazz.defineMethod (c$, "isHasDistances", -function () { -return this.hasDistances; -}); -Clazz.defineMethod (c$, "isHasBootstrap", -function () { -return this.hasBootstrap; -}); -Clazz.defineMethod (c$, "isHasRootDistance", -function () { -return this.hasRootDistance; -}); -Clazz.defineMethod (c$, "applyToNodes", -function (nodeTransformI) { -for (var nodes = this.node.elements (); nodes.hasMoreElements (); nodeTransformI.transform (nodes.nextElement ())) { -;} -}, "jalview.datamodel.NodeTransformI"); -c$.$NJTree$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.analysis, "NJTree$1", null, jalview.datamodel.NodeTransformI); -Clazz.defineMethod (c$, "transform", -function (node) { -var el = node.element (); -if (el != null && Clazz.instanceOf (el, jalview.datamodel.SequenceI)) { -node.setName ((el).getName ()); -}}, "jalview.datamodel.BinaryNode"); -c$ = Clazz.p0p (); -}; -c$ = Clazz.decorateAsClass (function () { -this.value = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "Cluster"); -Clazz.makeConstructor (c$, -function (value) { -this.value = value; -}, "~A"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["java.util.Vector"], ["jalview.analysis.Cluster", "$.NJTree"], ["jalview.analysis.SequenceIdMatcher", "jalview.datamodel.AlignmentView", "$.CigarArray", "$.NodeTransformI", "$.SeqCigar", "$.Sequence", "$.SequenceI", "$.SequenceNode", "jalview.io.NewickFile", "jalview.schemes.ResidueProperties", "jalview.util.Format", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.$cluster = null; +this.sequence = null; +this.seqData = null; +this.done = null; +this.noseqs = 0; +this.noClus = 0; +this.distance = null; +this.mini = 0; +this.minj = 0; +this.ri = 0; +this.rj = 0; +this.groups = null; +this.maxdist = null; +this.top = null; +this.maxDistValue = 0; +this.maxheight = 0; +this.ycount = 0; +this.node = null; +this.type = null; +this.pwtype = null; +this.found = null; +this.leaves = null; +this.hasDistances = true; +this.hasBootstrap = false; +this.hasRootDistance = true; +this._lycount = 0; +this._lylimit = 0; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "NJTree"); +Clazz.prepareFields (c$, function () { +this.groups = new java.util.Vector (); +}); +Clazz.makeConstructor (c$, +function (seqs, odata, treefile) { +this.construct (seqs, treefile); +if (odata != null) { +this.seqData = odata; +}}, "~A,jalview.datamodel.AlignmentView,jalview.io.NewickFile"); +Clazz.makeConstructor (c$, +function (seqs, treefile) { +this.sequence = seqs; +this.top = treefile.getTree (); +this.hasDistances = treefile.HasDistances (); +this.hasBootstrap = treefile.HasBootstrap (); +this.hasRootDistance = treefile.HasRootDistance (); +this.maxheight = this.findHeight (this.top); +var algnIds = new jalview.analysis.SequenceIdMatcher (seqs); +var leaves = new java.util.Vector (); +this.findLeaves (this.top, leaves); +var i = 0; +var namesleft = seqs.length; +var j; +var nam; +var realnam; +var one2many = new java.util.Vector (); +var countOne2Many = 0; +while (i < leaves.size ()) { +j = leaves.elementAt (i++); +realnam = j.getName (); +nam = null; +if (namesleft > -1) { +nam = algnIds.findIdMatch (realnam); +}if (nam != null) { +j.setElement (nam); +if (one2many.contains (nam)) { +countOne2Many++; +} else { +one2many.addElement (nam); +namesleft--; +}} else { +j.setElement ( new jalview.datamodel.Sequence (realnam, "THISISAPLACEHLDER")); +j.setPlaceholder (true); +}} +}, "~A,jalview.io.NewickFile"); +Clazz.makeConstructor (c$, +function (sequence, seqData, type, pwtype, sm, start, end) { +this.sequence = sequence; +this.node = new java.util.Vector (); +this.type = type; +this.pwtype = pwtype; +if (seqData != null) { +this.seqData = seqData; +} else { +var seqs = new Array (sequence.length); +for (var i = 0; i < sequence.length; i++) { +seqs[i] = new jalview.datamodel.SeqCigar (sequence[i], start, end); +} +var sdata = new jalview.datamodel.CigarArray (seqs); +sdata.addOperation ('M', end - start + 1); +this.seqData = new jalview.datamodel.AlignmentView (sdata, start); +}if (!(type.equals ("NJ"))) { +type = "AV"; +}if (sm == null && !(pwtype.equals ("PID"))) { +if (jalview.schemes.ResidueProperties.getScoreMatrix (pwtype) == null) { +pwtype = "BLOSUM62"; +}}var i = 0; +this.done = Clazz.newIntArray (sequence.length, 0); +while ((i < sequence.length) && (sequence[i] != null)) { +this.done[i] = 0; +i++; +} +this.noseqs = i++; +this.distance = this.findDistances (sm); +this.makeLeaves (); +this.noClus = this.$cluster.size (); +this.cluster (); +}, "~A,jalview.datamodel.AlignmentView,~S,~S,jalview.api.analysis.ScoreModelI,~N,~N"); +Clazz.overrideMethod (c$, "toString", +function () { +var fout = new jalview.io.NewickFile (this.getTopNode ()); +return fout.print (this.isHasBootstrap (), this.isHasDistances (), this.isHasRootDistance ()); +}); +Clazz.defineMethod (c$, "UpdatePlaceHolders", +function (list) { +var leaves = new java.util.Vector (); +this.findLeaves (this.top, leaves); +var sz = leaves.size (); +var seqmatcher = null; +var i = 0; +while (i < sz) { +var leaf = leaves.elementAt (i++); +if (list.contains (leaf.element ())) { +leaf.setPlaceholder (false); +} else { +if (seqmatcher == null) { +var seqs = new Array (list.size ()); +for (var j = 0; j < seqs.length; j++) { +seqs[j] = list.get (j); +} +seqmatcher = new jalview.analysis.SequenceIdMatcher (seqs); +}var nam = seqmatcher.findIdMatch (leaf.getName ()); +if (nam != null) { +if (!leaf.isPlaceholder ()) { +}leaf.setPlaceholder (false); +leaf.setElement (nam); +} else { +if (!leaf.isPlaceholder ()) { +leaf.setElement ( new jalview.datamodel.Sequence (leaf.getName (), "THISISAPLACEHLDER")); +}leaf.setPlaceholder (true); +}}} +}, "java.util.List"); +Clazz.defineMethod (c$, "renameAssociatedNodes", +function () { +this.applyToNodes (((Clazz.isClassDefined ("jalview.analysis.NJTree$1") ? 0 : jalview.analysis.NJTree.$NJTree$1$ ()), Clazz.innerTypeInstance (jalview.analysis.NJTree$1, this, null))); +}); +Clazz.defineMethod (c$, "cluster", +function () { +while (this.noClus > 2) { +if (this.type.equals ("NJ")) { +this.findMinNJDistance (); +} else { +this.findMinDistance (); +}var c = this.joinClusters (this.mini, this.minj); +this.done[this.minj] = 1; +this.$cluster.setElementAt (null, this.minj); +this.$cluster.setElementAt (c, this.mini); +this.noClus--; +} +var onefound = false; +var one = -1; +var two = -1; +for (var i = 0; i < this.noseqs; i++) { +if (this.done[i] != 1) { +if (onefound == false) { +two = i; +onefound = true; +} else { +one = i; +}}} +this.joinClusters (one, two); +this.top = (this.node.elementAt (one)); +this.reCount (this.top); +this.findHeight (this.top); +this.findMaxDist (this.top); +}); +Clazz.defineMethod (c$, "joinClusters", +function (i, j) { +var dist = this.distance[i][j]; +var noi = (this.$cluster.elementAt (i)).value.length; +var noj = (this.$cluster.elementAt (j)).value.length; +var value = Clazz.newIntArray (noi + noj, 0); +for (var ii = 0; ii < noi; ii++) { +value[ii] = (this.$cluster.elementAt (i)).value[ii]; +} +for (var ii = noi; ii < (noi + noj); ii++) { +value[ii] = (this.$cluster.elementAt (j)).value[ii - noi]; +} +var c = new jalview.analysis.Cluster (value); +this.ri = this.findr (i, j); +this.rj = this.findr (j, i); +if (this.type.equals ("NJ")) { +this.findClusterNJDistance (i, j); +} else { +this.findClusterDistance (i, j); +}var sn = new jalview.datamodel.SequenceNode (); +sn.setLeft ((this.node.elementAt (i))); +sn.setRight ((this.node.elementAt (j))); +var tmpi = (this.node.elementAt (i)); +var tmpj = (this.node.elementAt (j)); +if (this.type.equals ("NJ")) { +this.findNewNJDistances (tmpi, tmpj, dist); +} else { +this.findNewDistances (tmpi, tmpj, dist); +}tmpi.setParent (sn); +tmpj.setParent (sn); +this.node.setElementAt (sn, i); +return c; +}, "~N,~N"); +Clazz.defineMethod (c$, "findNewNJDistances", +function (tmpi, tmpj, dist) { +tmpi.dist = ((dist + this.ri) - this.rj) / 2; +tmpj.dist = (dist - tmpi.dist); +if (tmpi.dist < 0) { +tmpi.dist = 0; +}if (tmpj.dist < 0) { +tmpj.dist = 0; +}}, "jalview.datamodel.SequenceNode,jalview.datamodel.SequenceNode,~N"); +Clazz.defineMethod (c$, "findNewDistances", +function (tmpi, tmpj, dist) { +var ih = 0; +var jh = 0; +var sni = tmpi; +var snj = tmpj; +while (sni != null) { +ih = ih + sni.dist; +sni = sni.left (); +} +while (snj != null) { +jh = jh + snj.dist; +snj = snj.left (); +} +tmpi.dist = ((dist / 2) - ih); +tmpj.dist = ((dist / 2) - jh); +}, "jalview.datamodel.SequenceNode,jalview.datamodel.SequenceNode,~N"); +Clazz.defineMethod (c$, "findClusterDistance", +function (i, j) { +var noi = (this.$cluster.elementAt (i)).value.length; +var noj = (this.$cluster.elementAt (j)).value.length; +var newdist = Clazz.newFloatArray (this.noseqs, 0); +for (var l = 0; l < this.noseqs; l++) { +if ((l != i) && (l != j)) { +newdist[l] = ((this.distance[i][l] * noi) + (this.distance[j][l] * noj)) / (noi + noj); +} else { +newdist[l] = 0; +}} +for (var ii = 0; ii < this.noseqs; ii++) { +this.distance[i][ii] = newdist[ii]; +this.distance[ii][i] = newdist[ii]; +} +}, "~N,~N"); +Clazz.defineMethod (c$, "findClusterNJDistance", +function (i, j) { +var newdist = Clazz.newFloatArray (this.noseqs, 0); +for (var l = 0; l < this.noseqs; l++) { +if ((l != i) && (l != j)) { +newdist[l] = ((this.distance[i][l] + this.distance[j][l]) - this.distance[i][j]) / 2; +} else { +newdist[l] = 0; +}} +for (var ii = 0; ii < this.noseqs; ii++) { +this.distance[i][ii] = newdist[ii]; +this.distance[ii][i] = newdist[ii]; +} +}, "~N,~N"); +Clazz.defineMethod (c$, "findr", +function (i, j) { +var tmp = 1; +for (var k = 0; k < this.noseqs; k++) { +if ((k != i) && (k != j) && (this.done[k] != 1)) { +tmp = tmp + this.distance[i][k]; +}} +if (this.noClus > 2) { +tmp = tmp / (this.noClus - 2); +}return tmp; +}, "~N,~N"); +Clazz.defineMethod (c$, "findMinNJDistance", +function () { +var min = 100000; +for (var i = 0; i < (this.noseqs - 1); i++) { +for (var j = i + 1; j < this.noseqs; j++) { +if ((this.done[i] != 1) && (this.done[j] != 1)) { +var tmp = this.distance[i][j] - (this.findr (i, j) + this.findr (j, i)); +if (tmp < min) { +this.mini = i; +this.minj = j; +min = tmp; +}}} +} +return min; +}); +Clazz.defineMethod (c$, "findMinDistance", +function () { +var min = 100000; +for (var i = 0; i < (this.noseqs - 1); i++) { +for (var j = i + 1; j < this.noseqs; j++) { +if ((this.done[i] != 1) && (this.done[j] != 1)) { +if (this.distance[i][j] < min) { +this.mini = i; +this.minj = j; +min = this.distance[i][j]; +}}} +} +return min; +}); +Clazz.defineMethod (c$, "findDistances", +function (_pwmatrix) { +var distance = Clazz.newFloatArray (this.noseqs, this.noseqs, 0); +if (_pwmatrix == null) { +_pwmatrix = jalview.schemes.ResidueProperties.getScoreModel (this.pwtype); +if (_pwmatrix == null) { +_pwmatrix = jalview.schemes.ResidueProperties.getScoreMatrix ("BLOSUM62"); +}}distance = _pwmatrix.findDistances (this.seqData); +return distance; +}, "jalview.api.analysis.ScoreModelI"); +Clazz.defineMethod (c$, "makeLeaves", +function () { +this.$cluster = new java.util.Vector (); +for (var i = 0; i < this.noseqs; i++) { +var sn = new jalview.datamodel.SequenceNode (); +sn.setElement (this.sequence[i]); +sn.setName (this.sequence[i].getName ()); +this.node.addElement (sn); +var value = Clazz.newIntArray (1, 0); +value[0] = i; +var c = new jalview.analysis.Cluster (value); +this.$cluster.addElement (c); +} +}); +Clazz.defineMethod (c$, "findLeaves", +function (node, leaves) { +if (node == null) { +return leaves; +}if ((node.left () == null) && (node.right () == null)) { +leaves.addElement (node); +return leaves; +} else { +this.findLeaves (node.left (), leaves); +this.findLeaves (node.right (), leaves); +}return leaves; +}, "jalview.datamodel.SequenceNode,java.util.Vector"); +Clazz.defineMethod (c$, "findLeaf", +function (node, count) { +this.found = this._findLeaf (node, count); +return this.found; +}, "jalview.datamodel.SequenceNode,~N"); +Clazz.defineMethod (c$, "_findLeaf", +function (node, count) { +if (node == null) { +return null; +}if (node.ycount == count) { +this.found = node.element (); +return this.found; +} else { +this._findLeaf (node.left (), count); +this._findLeaf (node.right (), count); +}return this.found; +}, "jalview.datamodel.SequenceNode,~N"); +Clazz.defineMethod (c$, "printNode", +function (node) { +if (node == null) { +return; +}if ((node.left () == null) && (node.right () == null)) { +System.out.println ("Leaf = " + (node.element ()).getName ()); +System.out.println ("Dist " + node.dist); +System.out.println ("Boot " + node.getBootstrap ()); +} else { +System.out.println ("Dist " + node.dist); +this.printNode (node.left ()); +this.printNode (node.right ()); +}}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "findMaxDist", +function (node) { +if (node == null) { +return; +}if ((node.left () == null) && (node.right () == null)) { +var dist = node.dist; +if (dist > this.maxDistValue) { +this.maxdist = node; +this.maxDistValue = dist; +}} else { +this.findMaxDist (node.left ()); +this.findMaxDist (node.right ()); +}}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "getGroups", +function () { +return this.groups; +}); +Clazz.defineMethod (c$, "getMaxHeight", +function () { +return this.maxheight; +}); +Clazz.defineMethod (c$, "groupNodes", +function (node, threshold) { +if (node == null) { +return; +}if ((node.height / this.maxheight) > threshold) { +this.groups.addElement (node); +} else { +this.groupNodes (node.left (), threshold); +this.groupNodes (node.right (), threshold); +}}, "jalview.datamodel.SequenceNode,~N"); +Clazz.defineMethod (c$, "findHeight", +function (node) { +if (node == null) { +return this.maxheight; +}if ((node.left () == null) && (node.right () == null)) { +node.height = (node.parent ()).height + node.dist; +if (node.height > this.maxheight) { +return node.height; +} else { +return this.maxheight; +}} else { +if (node.parent () != null) { +node.height = (node.parent ()).height + node.dist; +} else { +this.maxheight = 0; +node.height = 0.0; +}this.maxheight = this.findHeight ((node.left ())); +this.maxheight = this.findHeight ((node.right ())); +}return this.maxheight; +}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "reRoot", +function () { +if (this.maxdist != null) { +this.ycount = 0; +var tmpdist = this.maxdist.dist; +var sn = new jalview.datamodel.SequenceNode (); +sn.setParent (null); +var snr = this.maxdist.parent (); +this.changeDirection (snr, this.maxdist); +System.out.println ("Printing reversed tree"); +this.printN (snr); +snr.dist = tmpdist / 2; +this.maxdist.dist = tmpdist / 2; +snr.setParent (sn); +this.maxdist.setParent (sn); +sn.setRight (snr); +sn.setLeft (this.maxdist); +this.top = sn; +this.ycount = 0; +this.reCount (this.top); +this.findHeight (this.top); +}return this.top; +}); +Clazz.defineMethod (c$, "hasOriginalSequenceData", +function () { +return this.seqData != null; +}); +Clazz.defineMethod (c$, "printOriginalSequenceData", +function (gapChar) { +if (this.seqData == null) { +return null; +}var sb = new StringBuffer (); +var seqdatas = this.seqData.getSequenceStrings (gapChar); +for (var i = 0; i < seqdatas.length; i++) { +sb.append ( new jalview.util.Format ("%-15s").form (this.sequence[i].getName ())); +sb.append (" " + seqdatas[i] + "\n"); +} +return sb.toString (); +}, "~S"); +Clazz.defineMethod (c$, "printN", +function (node) { +if (node == null) { +return; +}if ((node.left () != null) && (node.right () != null)) { +this.printN (node.left ()); +this.printN (node.right ()); +} else { +System.out.println (" name = " + (node.element ()).getName ()); +}System.out.println (" dist = " + node.dist + " " + node.count + " " + node.height); +}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "reCount", +function (node) { +this.ycount = 0; +this._lycount = 0; +this._reCount (node); +}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "_reCount", +function (node) { +if (node == null) { +return; +}this._lycount++; +if ((node.left () != null) && (node.right () != null)) { +this._reCount (node.left ()); +this._reCount (node.right ()); +var l = node.left (); +var r = node.right (); +node.count = l.count + r.count; +node.ycount = (l.ycount + r.ycount) / 2; +} else { +node.count = 1; +node.ycount = this.ycount++; +}this._lycount--; +}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "swapNodes", +function (node) { +if (node == null) { +return; +}var tmp = node.left (); +node.setLeft (node.right ()); +node.setRight (tmp); +}, "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "changeDirection", +function (node, dir) { +if (node == null) { +return; +}if (node.parent () !== this.top) { +this.changeDirection (node.parent (), node); +var tmp = node.parent (); +if (dir === node.left ()) { +node.setParent (dir); +node.setLeft (tmp); +} else if (dir === node.right ()) { +node.setParent (dir); +node.setRight (tmp); +}} else { +if (dir === node.left ()) { +node.setParent (node.left ()); +if (this.top.left () === node) { +node.setRight (this.top.right ()); +} else { +node.setRight (this.top.left ()); +}} else { +node.setParent (node.right ()); +if (this.top.left () === node) { +node.setLeft (this.top.right ()); +} else { +node.setLeft (this.top.left ()); +}}}}, "jalview.datamodel.SequenceNode,jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "getMaxDist", +function () { +return this.maxdist; +}); +Clazz.defineMethod (c$, "getTopNode", +function () { +return this.top; +}); +Clazz.defineMethod (c$, "isHasDistances", +function () { +return this.hasDistances; +}); +Clazz.defineMethod (c$, "isHasBootstrap", +function () { +return this.hasBootstrap; +}); +Clazz.defineMethod (c$, "isHasRootDistance", +function () { +return this.hasRootDistance; +}); +Clazz.defineMethod (c$, "applyToNodes", +function (nodeTransformI) { +for (var nodes = this.node.elements (); nodes.hasMoreElements (); nodeTransformI.transform (nodes.nextElement ())) { +;} +}, "jalview.datamodel.NodeTransformI"); +c$.$NJTree$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.analysis, "NJTree$1", null, jalview.datamodel.NodeTransformI); +Clazz.defineMethod (c$, "transform", +function (node) { +var el = node.element (); +if (el != null && Clazz.instanceOf (el, jalview.datamodel.SequenceI)) { +node.setName ((el).getName ()); +}}, "jalview.datamodel.BinaryNode"); +c$ = Clazz.p0p (); +}; +c$ = Clazz.decorateAsClass (function () { +this.value = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "Cluster"); +Clazz.makeConstructor (c$, +function (value) { +this.value = value; +}, "~A"); +}); diff --git a/bin/jalview/analysis/PCA.js b/bin/jalview/analysis/PCA.js index 5effde0..c9e885c 100644 --- a/bin/jalview/analysis/PCA.js +++ b/bin/jalview/analysis/PCA.js @@ -1,163 +1,163 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["java.lang.StringBuffer"], "jalview.analysis.PCA", ["jalview.datamodel.BinarySequence", "jalview.math.Matrix", "jalview.schemes.ResidueProperties"], function () { -c$ = Clazz.decorateAsClass (function () { -this.m = null; -this.symm = null; -this.m2 = null; -this.eigenvalue = null; -this.eigenvector = null; -this.details = null; -this.jvCalcMode = true; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "PCA", null, Runnable); -Clazz.prepareFields (c$, function () { -this.details = new StringBuffer (); -}); -Clazz.makeConstructor (c$, -function (s) { -this.construct (s, false); -}, "~A"); -Clazz.makeConstructor (c$, -function (s, nucleotides) { -this.construct (s, nucleotides, null); -}, "~A,~B"); -Clazz.makeConstructor (c$, -function (s, nucleotides, s_m) { -var bs = new Array (s.length); -var ii = 0; -while ((ii < s.length) && (s[ii] != null)) { -bs[ii] = new jalview.datamodel.BinarySequence (s[ii], nucleotides); -bs[ii].encode (); -ii++; -} -var bs2 = new Array (s.length); -ii = 0; -var smtrx = null; -var sm = s_m; -if (sm != null) { -smtrx = jalview.schemes.ResidueProperties.getScoreMatrix (sm); -}if (smtrx == null) { -smtrx = jalview.schemes.ResidueProperties.getScoreMatrix (sm = (nucleotides ? "DNA" : "BLOSUM62")); -}this.details.append ("PCA calculation using " + sm + " sequence similarity matrix\n========\n\n"); -while ((ii < s.length) && (s[ii] != null)) { -bs2[ii] = new jalview.datamodel.BinarySequence (s[ii], nucleotides); -if (smtrx != null) { -try { -bs2[ii].matrixEncode (smtrx); -} catch (x) { -if (Clazz.exceptionOf (x, jalview.datamodel.BinarySequence.InvalidSequenceTypeException)) { -this.details.append ("Unexpected mismatch of sequence type and score matrix. Calculation will not be valid!\n\n"); -} else { -throw x; -} -} -}ii++; -} -var count = 0; -while ((count < bs.length) && (bs[count] != null)) { -count++; -} -var seqmat = Clazz.newDoubleArray (count, bs[0].getDBinary ().length, 0); -var seqmat2 = Clazz.newDoubleArray (count, bs2[0].getDBinary ().length, 0); -var i = 0; -while (i < count) { -seqmat[i] = bs[i].getDBinary (); -seqmat2[i] = bs2[i].getDBinary (); -i++; -} -this.m = new jalview.math.Matrix (seqmat, count, bs[0].getDBinary ().length); -this.m2 = new jalview.math.Matrix (seqmat2, count, bs2[0].getDBinary ().length); -}, "~A,~B,~S"); -Clazz.defineMethod (c$, "getM", -function () { -return this.m; -}); -Clazz.defineMethod (c$, "getEigenvalue", -function (i) { -return this.eigenvector.d[i]; -}, "~N"); -Clazz.defineMethod (c$, "getComponents", -function (l, n, mm, factor) { -var out = Clazz.newFloatArray (this.m.rows, 3, 0); -for (var i = 0; i < this.m.rows; i++) { -out[i][0] = this.component (i, l) * factor; -out[i][1] = this.component (i, n) * factor; -out[i][2] = this.component (i, mm) * factor; -} -return out; -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "component", -function (n) { -var out = Clazz.newDoubleArray (this.m.rows, 0); -for (var i = 0; i < this.m.rows; i++) { -out[i] = this.component (i, n); -} -return out; -}, "~N"); -Clazz.defineMethod (c$, "component", -function (row, n) { -var out = 0.0; -for (var i = 0; i < this.symm.cols; i++) { -out += (this.symm.value[row][i] * this.eigenvector.value[i][n]); -} -return out / this.eigenvector.d[n]; -}, "~N,~N"); -Clazz.defineMethod (c$, "getDetails", -function () { -return this.details.toString (); -}); -Clazz.overrideMethod (c$, "run", -function () { -var ps = ((Clazz.isClassDefined ("jalview.analysis.PCA$1") ? 0 : jalview.analysis.PCA.$PCA$1$ ()), Clazz.innerTypeInstance (jalview.analysis.PCA$1, this, null, System.out)); -try { -this.details.append ("PCA Calculation Mode is " + (this.jvCalcMode ? "Jalview variant" : "Original SeqSpace") + "\n"); -var mt = this.m.transpose (); -this.details.append (" --- OrigT * Orig ---- \n"); -if (!this.jvCalcMode) { -this.eigenvector = mt.preMultiply (this.m); -} else { -this.eigenvector = mt.preMultiply (this.m2); -}this.eigenvector.print (ps); -this.symm = this.eigenvector.copy (); -this.eigenvector.tred (); -this.details.append (" ---Tridiag transform matrix ---\n"); -this.details.append (" --- D vector ---\n"); -this.eigenvector.printD (ps); -ps.println (); -this.details.append ("--- E vector ---\n"); -this.eigenvector.printE (ps); -ps.println (); -this.eigenvector.tqli (); -} catch (q) { -if (Clazz.exceptionOf (q, Exception)) { -q.printStackTrace (); -this.details.append ("\n*** Unexpected exception when performing PCA ***\n" + q.getLocalizedMessage ()); -this.details.append ("*** Matrices below may not be fully diagonalised. ***\n"); -} else { -throw q; -} -} -this.details.append (" --- New diagonalization matrix ---\n"); -this.eigenvector.print (ps); -this.details.append (" --- Eigenvalues ---\n"); -this.eigenvector.printD (ps); -ps.println (); -}); -Clazz.defineMethod (c$, "setJvCalcMode", -function (calcMode) { -this.jvCalcMode = calcMode; -}, "~B"); -c$.$PCA$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.analysis, "PCA$1", java.io.PrintStream); -Clazz.defineMethod (c$, "print", -function (x) { -this.b$["jalview.analysis.PCA"].details.append (x); -}, "~S"); -Clazz.defineMethod (c$, "println", -function () { -this.b$["jalview.analysis.PCA"].details.append ("\n"); -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["java.lang.StringBuffer"], "jalview.analysis.PCA", ["jalview.datamodel.BinarySequence", "jalview.math.Matrix", "jalview.schemes.ResidueProperties"], function () { +c$ = Clazz.decorateAsClass (function () { +this.m = null; +this.symm = null; +this.m2 = null; +this.eigenvalue = null; +this.eigenvector = null; +this.details = null; +this.jvCalcMode = true; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "PCA", null, Runnable); +Clazz.prepareFields (c$, function () { +this.details = new StringBuffer (); +}); +Clazz.makeConstructor (c$, +function (s) { +this.construct (s, false); +}, "~A"); +Clazz.makeConstructor (c$, +function (s, nucleotides) { +this.construct (s, nucleotides, null); +}, "~A,~B"); +Clazz.makeConstructor (c$, +function (s, nucleotides, s_m) { +var bs = new Array (s.length); +var ii = 0; +while ((ii < s.length) && (s[ii] != null)) { +bs[ii] = new jalview.datamodel.BinarySequence (s[ii], nucleotides); +bs[ii].encode (); +ii++; +} +var bs2 = new Array (s.length); +ii = 0; +var smtrx = null; +var sm = s_m; +if (sm != null) { +smtrx = jalview.schemes.ResidueProperties.getScoreMatrix (sm); +}if (smtrx == null) { +smtrx = jalview.schemes.ResidueProperties.getScoreMatrix (sm = (nucleotides ? "DNA" : "BLOSUM62")); +}this.details.append ("PCA calculation using " + sm + " sequence similarity matrix\n========\n\n"); +while ((ii < s.length) && (s[ii] != null)) { +bs2[ii] = new jalview.datamodel.BinarySequence (s[ii], nucleotides); +if (smtrx != null) { +try { +bs2[ii].matrixEncode (smtrx); +} catch (x) { +if (Clazz.exceptionOf (x, jalview.datamodel.BinarySequence.InvalidSequenceTypeException)) { +this.details.append ("Unexpected mismatch of sequence type and score matrix. Calculation will not be valid!\n\n"); +} else { +throw x; +} +} +}ii++; +} +var count = 0; +while ((count < bs.length) && (bs[count] != null)) { +count++; +} +var seqmat = Clazz.newDoubleArray (count, bs[0].getDBinary ().length, 0); +var seqmat2 = Clazz.newDoubleArray (count, bs2[0].getDBinary ().length, 0); +var i = 0; +while (i < count) { +seqmat[i] = bs[i].getDBinary (); +seqmat2[i] = bs2[i].getDBinary (); +i++; +} +this.m = new jalview.math.Matrix (seqmat, count, bs[0].getDBinary ().length); +this.m2 = new jalview.math.Matrix (seqmat2, count, bs2[0].getDBinary ().length); +}, "~A,~B,~S"); +Clazz.defineMethod (c$, "getM", +function () { +return this.m; +}); +Clazz.defineMethod (c$, "getEigenvalue", +function (i) { +return this.eigenvector.d[i]; +}, "~N"); +Clazz.defineMethod (c$, "getComponents", +function (l, n, mm, factor) { +var out = Clazz.newFloatArray (this.m.rows, 3, 0); +for (var i = 0; i < this.m.rows; i++) { +out[i][0] = this.component (i, l) * factor; +out[i][1] = this.component (i, n) * factor; +out[i][2] = this.component (i, mm) * factor; +} +return out; +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "component", +function (n) { +var out = Clazz.newDoubleArray (this.m.rows, 0); +for (var i = 0; i < this.m.rows; i++) { +out[i] = this.component (i, n); +} +return out; +}, "~N"); +Clazz.defineMethod (c$, "component", +function (row, n) { +var out = 0.0; +for (var i = 0; i < this.symm.cols; i++) { +out += (this.symm.value[row][i] * this.eigenvector.value[i][n]); +} +return out / this.eigenvector.d[n]; +}, "~N,~N"); +Clazz.defineMethod (c$, "getDetails", +function () { +return this.details.toString (); +}); +Clazz.overrideMethod (c$, "run", +function () { +var ps = ((Clazz.isClassDefined ("jalview.analysis.PCA$1") ? 0 : jalview.analysis.PCA.$PCA$1$ ()), Clazz.innerTypeInstance (jalview.analysis.PCA$1, this, null, System.out)); +try { +this.details.append ("PCA Calculation Mode is " + (this.jvCalcMode ? "Jalview variant" : "Original SeqSpace") + "\n"); +var mt = this.m.transpose (); +this.details.append (" --- OrigT * Orig ---- \n"); +if (!this.jvCalcMode) { +this.eigenvector = mt.preMultiply (this.m); +} else { +this.eigenvector = mt.preMultiply (this.m2); +}this.eigenvector.print (ps); +this.symm = this.eigenvector.copy (); +this.eigenvector.tred (); +this.details.append (" ---Tridiag transform matrix ---\n"); +this.details.append (" --- D vector ---\n"); +this.eigenvector.printD (ps); +ps.println (); +this.details.append ("--- E vector ---\n"); +this.eigenvector.printE (ps); +ps.println (); +this.eigenvector.tqli (); +} catch (q) { +if (Clazz.exceptionOf (q, Exception)) { +q.printStackTrace (); +this.details.append ("\n*** Unexpected exception when performing PCA ***\n" + q.getLocalizedMessage ()); +this.details.append ("*** Matrices below may not be fully diagonalised. ***\n"); +} else { +throw q; +} +} +this.details.append (" --- New diagonalization matrix ---\n"); +this.eigenvector.print (ps); +this.details.append (" --- Eigenvalues ---\n"); +this.eigenvector.printD (ps); +ps.println (); +}); +Clazz.defineMethod (c$, "setJvCalcMode", +function (calcMode) { +this.jvCalcMode = calcMode; +}, "~B"); +c$.$PCA$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.analysis, "PCA$1", java.io.PrintStream); +Clazz.defineMethod (c$, "print", +function (x) { +this.b$["jalview.analysis.PCA"].details.append (x); +}, "~S"); +Clazz.defineMethod (c$, "println", +function () { +this.b$["jalview.analysis.PCA"].details.append ("\n"); +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/analysis/ParseProperties.js b/bin/jalview/analysis/ParseProperties.js index c117d07..d18979d 100644 --- a/bin/jalview/analysis/ParseProperties.js +++ b/bin/jalview/analysis/ParseProperties.js @@ -1,75 +1,75 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.ParseProperties", ["jalview.datamodel.AlignmentAnnotation", "jalview.jsdev.RegExp", "java.lang.Double"], function () { -c$ = Clazz.decorateAsClass (function () { -this.al = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "ParseProperties"); -Clazz.makeConstructor (c$, -function (al) { -this.al = al; -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "getScoresFromDescription", -function (ScoreName, ScoreDescriptions, regex, repeat) { -return this.getScoresFromDescription ( Clazz.newArray (-1, [ScoreName]), Clazz.newArray (-1, [ScoreDescriptions]), regex, repeat); -}, "~S,~S,~S,~B"); -Clazz.defineMethod (c$, "getScoresFromDescription", -function (ScoreNames, ScoreDescriptions, regex, repeat) { -return this.getScoresFromDescription (this.al.getSequencesArray (), ScoreNames, ScoreDescriptions, regex, repeat); -}, "~A,~A,~S,~B"); -Clazz.defineMethod (c$, "getScoresFromDescription", -function (seqs, ScoreNames, ScoreDescriptions, regex, repeat) { -var count = 0; -var pattern = jalview.jsdev.RegExp.newRegex ([regex]); -if (pattern.numSubs () > ScoreNames.length) { -var onamelen = ScoreNames.length; -var tnames = new Array (pattern.numSubs () + 1); -System.arraycopy (ScoreNames, 0, tnames, 0, ScoreNames.length); -var base = tnames[ScoreNames.length - 1]; -ScoreNames = tnames; -var descrbase = ScoreDescriptions[onamelen - 1]; -if (descrbase == null) { -descrbase = "Score parsed from (" + regex + ")"; -}tnames = new Array (pattern.numSubs () + 1); -System.arraycopy (ScoreDescriptions, 0, tnames, 0, ScoreDescriptions.length); -ScoreDescriptions = tnames; -for (var i = onamelen; i < ScoreNames.length; i++) { -ScoreNames[i] = base + "_" + i; -ScoreDescriptions[i] = descrbase + " (column " + i + ")"; -} -}for (var i = 0; i < seqs.length; i++) { -var descr = seqs[i].getDescription (); -if (descr == null) { -continue; -}var pos = 0; -var added = false; -var reps = 0; -while ((repeat || pos == 0) && pattern.searchFrom (descr, pos)) { -pos = pattern.matchedTo (); -for (var cols = 0; cols < pattern.numSubs (); cols++) { -var sstring = pattern.stringMatchedI (cols + 1); -var score = NaN; -try { -score = new Double (sstring).doubleValue (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -continue; -} else { -throw e; -} -} -var an = new jalview.datamodel.AlignmentAnnotation (ScoreNames[cols] + ((reps > 0) ? "_" + reps : ""), ScoreDescriptions[cols], null); -an.setScore (score); -System.out.println (seqs[i].getName () + " score: '" + ScoreNames[cols] + "' = " + score); -an.setSequenceRef (seqs[i]); -seqs[i].addAlignmentAnnotation (an); -this.al.addAnnotation (an); -added = true; -} -reps++; -} -if (added) { -count++; -}} -return count; -}, "~A,~A,~A,~S,~B"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.ParseProperties", ["jalview.datamodel.AlignmentAnnotation", "jalview.jsdev.RegExp", "java.lang.Double"], function () { +c$ = Clazz.decorateAsClass (function () { +this.al = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "ParseProperties"); +Clazz.makeConstructor (c$, +function (al) { +this.al = al; +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "getScoresFromDescription", +function (ScoreName, ScoreDescriptions, regex, repeat) { +return this.getScoresFromDescription ( Clazz.newArray (-1, [ScoreName]), Clazz.newArray (-1, [ScoreDescriptions]), regex, repeat); +}, "~S,~S,~S,~B"); +Clazz.defineMethod (c$, "getScoresFromDescription", +function (ScoreNames, ScoreDescriptions, regex, repeat) { +return this.getScoresFromDescription (this.al.getSequencesArray (), ScoreNames, ScoreDescriptions, regex, repeat); +}, "~A,~A,~S,~B"); +Clazz.defineMethod (c$, "getScoresFromDescription", +function (seqs, ScoreNames, ScoreDescriptions, regex, repeat) { +var count = 0; +var pattern = jalview.jsdev.RegExp.newRegex ([regex]); +if (pattern.numSubs () > ScoreNames.length) { +var onamelen = ScoreNames.length; +var tnames = new Array (pattern.numSubs () + 1); +System.arraycopy (ScoreNames, 0, tnames, 0, ScoreNames.length); +var base = tnames[ScoreNames.length - 1]; +ScoreNames = tnames; +var descrbase = ScoreDescriptions[onamelen - 1]; +if (descrbase == null) { +descrbase = "Score parsed from (" + regex + ")"; +}tnames = new Array (pattern.numSubs () + 1); +System.arraycopy (ScoreDescriptions, 0, tnames, 0, ScoreDescriptions.length); +ScoreDescriptions = tnames; +for (var i = onamelen; i < ScoreNames.length; i++) { +ScoreNames[i] = base + "_" + i; +ScoreDescriptions[i] = descrbase + " (column " + i + ")"; +} +}for (var i = 0; i < seqs.length; i++) { +var descr = seqs[i].getDescription (); +if (descr == null) { +continue; +}var pos = 0; +var added = false; +var reps = 0; +while ((repeat || pos == 0) && pattern.searchFrom (descr, pos)) { +pos = pattern.matchedTo (); +for (var cols = 0; cols < pattern.numSubs (); cols++) { +var sstring = pattern.stringMatchedI (cols + 1); +var score = NaN; +try { +score = new Double (sstring).doubleValue (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +continue; +} else { +throw e; +} +} +var an = new jalview.datamodel.AlignmentAnnotation (ScoreNames[cols] + ((reps > 0) ? "_" + reps : ""), ScoreDescriptions[cols], null); +an.setScore (score); +System.out.println (seqs[i].getName () + " score: '" + ScoreNames[cols] + "' = " + score); +an.setSequenceRef (seqs[i]); +seqs[i].addAlignmentAnnotation (an); +this.al.addAnnotation (an); +added = true; +} +reps++; +} +if (added) { +count++; +}} +return count; +}, "~A,~A,~A,~S,~B"); +}); diff --git a/bin/jalview/analysis/Rna.js b/bin/jalview/analysis/Rna.js index 4b23f2d..0ed5a63 100644 --- a/bin/jalview/analysis/Rna.js +++ b/bin/jalview/analysis/Rna.js @@ -1,106 +1,106 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["java.util.Arrays", "$.HashSet", "$.Hashtable"], "jalview.analysis.Rna", ["jalview.analysis.SecStrConsensus", "$.WUSSParseException", "jalview.datamodel.SequenceFeature", "jalview.util.MessageManager", "java.lang.StringBuffer", "java.util.ArrayList", "$.Stack", "$.Vector"], function () { -c$ = Clazz.declareType (jalview.analysis, "Rna"); -c$.isOpeningParenthesis = Clazz.defineMethod (c$, "isOpeningParenthesis", -($fz = function (c) { -return jalview.analysis.Rna.openingParsSet.contains (new Character (c).charCodeAt (0)); -}, $fz.isPrivate = true, $fz), "~S"); -c$.isClosingParenthesis = Clazz.defineMethod (c$, "isClosingParenthesis", -($fz = function (c) { -return jalview.analysis.Rna.closingParsSet.contains (new Character (c).charCodeAt (0)); -}, $fz.isPrivate = true, $fz), "~S"); -c$.matchingOpeningParenthesis = Clazz.defineMethod (c$, "matchingOpeningParenthesis", -($fz = function (closingParenthesis) { -if (!jalview.analysis.Rna.isClosingParenthesis (closingParenthesis)) { -throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.querying_matching_opening_parenthesis_for_non_closing_parenthesis", Clazz.newArray (-1, [ new StringBuffer (closingParenthesis.charCodeAt (0)).toString ()])), -1); -}return String.fromCharCode (jalview.analysis.Rna.closingToOpening.get (new Character (closingParenthesis).charCodeAt (0))); -}, $fz.isPrivate = true, $fz), "~S"); -c$.GetSimpleBPs = Clazz.defineMethod (c$, "GetSimpleBPs", -function (line) { -var stacks = new java.util.Hashtable (); -var pairs = new java.util.Vector (); -var i = 0; -while (i < line.length) { -var base = line.charAt (i); -if (jalview.analysis.Rna.isOpeningParenthesis (base)) { -if (!stacks.containsKey (new Character (base).charCodeAt (0))) { -stacks.put (new Character (base).charCodeAt (0), new java.util.Stack ()); -}stacks.get (new Character (base).charCodeAt (0)).push (new Integer (i)); -} else if (jalview.analysis.Rna.isClosingParenthesis (base)) { -var opening = jalview.analysis.Rna.matchingOpeningParenthesis (base); -if (!stacks.containsKey (new Character (opening).charCodeAt (0))) { -throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.mismatched_unseen_closing_char", Clazz.newArray (-1, [ new StringBuffer (base.charCodeAt (0)).toString ()])), i); -}var stack = stacks.get (new Character (opening).charCodeAt (0)); -if (stack.isEmpty ()) { -throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.mismatched_closing_char", Clazz.newArray (-1, [ new StringBuffer (base.charCodeAt (0)).toString ()])), i); -}var temp = (stack.pop ()).intValue (); -pairs.add ( new jalview.analysis.SecStrConsensus.SimpleBP (temp, i)); -}i++; -} -for (var opening, $opening = stacks.keySet ().iterator (); $opening.hasNext () && ((opening = $opening.next ()) || true);) { -var stack = stacks.get (new Character (opening).charCodeAt (0)); -if (!stack.empty ()) { -throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.mismatched_opening_char", Clazz.newArray (-1, [ new StringBuffer (opening.charCodeAt (0)).toString (), Integer.$valueOf ((stack.pop ()).intValue ()).toString ()])), i); -}} -return pairs; -}, "CharSequence"); -c$.GetBasePairs = Clazz.defineMethod (c$, "GetBasePairs", -function (line) { -var bps = jalview.analysis.Rna.GetSimpleBPs (line); -var outPairs = new Array (bps.size ()); -for (var p = 0; p < bps.size (); p++) { -var bp = bps.elementAt (p); -outPairs[p] = new jalview.datamodel.SequenceFeature ("RNA helix", "", "", bp.getBP5 (), bp.getBP3 (), ""); -} -return outPairs; -}, "CharSequence"); -c$.GetModeleBP = Clazz.defineMethod (c$, "GetModeleBP", -function (line) { -var bps = jalview.analysis.Rna.GetSimpleBPs (line); -return new java.util.ArrayList (bps); -}, "CharSequence"); -c$.HelixMap = Clazz.defineMethod (c$, "HelixMap", -function (pairs) { -var helix = 0; -var lastopen = 0; -var lastclose = 9999999; -var i = pairs.length; -var open; -var close; -var j; -var helices = new java.util.Hashtable (); -for (i = 0; i < pairs.length; i++) { -open = pairs[i].getBegin (); -close = pairs[i].getEnd (); -if (open > lastclose) { -helix++; -}j = pairs.length - 1; -while (j >= 0) { -var popen = pairs[j].getBegin (); -if ((popen < lastopen) && (popen > open)) { -if (helices.containsValue (new Integer (popen)) && (((helices.get (new Integer (popen)))).intValue () === helix)) { -continue; -} else { -helix++; -break; -}}j -= 1; -} -helices.put (new Integer (open), new Integer (helix)); -helices.put (new Integer (close), new Integer (helix)); -pairs[i].setFeatureGroup (Integer.toString (helix)); -lastopen = open; -lastclose = close; -} -}, "~A"); -c$.pairHash = c$.prototype.pairHash = new java.util.Hashtable (); -Clazz.defineStatics (c$, -"openingPars", Clazz.newArray (-1, [new Character ('('), new Character ('['), new Character ('{'), new Character ('<'), new Character ('A'), new Character ('B'), new Character ('C'), new Character ('D'), new Character ('E'), new Character ('F'), new Character ('G'), new Character ('H'), new Character ('I'), new Character ('J'), new Character ('K'), new Character ('L'), new Character ('M'), new Character ('N'), new Character ('O'), new Character ('P'), new Character ('Q'), new Character ('R'), new Character ('S'), new Character ('T'), new Character ('U'), new Character ('V'), new Character ('W'), new Character ('X'), new Character ('Y'), new Character ('Z')]), -"closingPars", Clazz.newArray (-1, [new Character (')'), new Character (']'), new Character ('}'), new Character ('>'), new Character ('a'), new Character ('b'), new Character ('c'), new Character ('d'), new Character ('e'), new Character ('f'), new Character ('g'), new Character ('h'), new Character ('i'), new Character ('j'), new Character ('k'), new Character ('l'), new Character ('m'), new Character ('n'), new Character ('o'), new Character ('p'), new Character ('q'), new Character ('r'), new Character ('s'), new Character ('t'), new Character ('u'), new Character ('v'), new Character ('w'), new Character ('x'), new Character ('y'), new Character ('z')])); -c$.openingParsSet = c$.prototype.openingParsSet = new java.util.HashSet (java.util.Arrays.asList (jalview.analysis.Rna.openingPars)); -c$.closingParsSet = c$.prototype.closingParsSet = new java.util.HashSet (java.util.Arrays.asList (jalview.analysis.Rna.closingPars)); -c$.closingToOpening = c$.prototype.closingToOpening = new java.util.Hashtable (); -{ -for (var i = 0; i < jalview.analysis.Rna.openingPars.length; i++) { -jalview.analysis.Rna.closingToOpening.put (jalview.analysis.Rna.closingPars[i], jalview.analysis.Rna.openingPars[i]); -} -}}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["java.util.Arrays", "$.HashSet", "$.Hashtable"], "jalview.analysis.Rna", ["jalview.analysis.SecStrConsensus", "$.WUSSParseException", "jalview.datamodel.SequenceFeature", "jalview.util.MessageManager", "java.lang.StringBuffer", "java.util.ArrayList", "$.Stack", "$.Vector"], function () { +c$ = Clazz.declareType (jalview.analysis, "Rna"); +c$.isOpeningParenthesis = Clazz.defineMethod (c$, "isOpeningParenthesis", +($fz = function (c) { +return jalview.analysis.Rna.openingParsSet.contains (new Character (c).charCodeAt (0)); +}, $fz.isPrivate = true, $fz), "~S"); +c$.isClosingParenthesis = Clazz.defineMethod (c$, "isClosingParenthesis", +($fz = function (c) { +return jalview.analysis.Rna.closingParsSet.contains (new Character (c).charCodeAt (0)); +}, $fz.isPrivate = true, $fz), "~S"); +c$.matchingOpeningParenthesis = Clazz.defineMethod (c$, "matchingOpeningParenthesis", +($fz = function (closingParenthesis) { +if (!jalview.analysis.Rna.isClosingParenthesis (closingParenthesis)) { +throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.querying_matching_opening_parenthesis_for_non_closing_parenthesis", Clazz.newArray (-1, [ new StringBuffer (closingParenthesis.charCodeAt (0)).toString ()])), -1); +}return String.fromCharCode (jalview.analysis.Rna.closingToOpening.get (new Character (closingParenthesis).charCodeAt (0))); +}, $fz.isPrivate = true, $fz), "~S"); +c$.GetSimpleBPs = Clazz.defineMethod (c$, "GetSimpleBPs", +function (line) { +var stacks = new java.util.Hashtable (); +var pairs = new java.util.Vector (); +var i = 0; +while (i < line.length) { +var base = line.charAt (i); +if (jalview.analysis.Rna.isOpeningParenthesis (base)) { +if (!stacks.containsKey (new Character (base).charCodeAt (0))) { +stacks.put (new Character (base).charCodeAt (0), new java.util.Stack ()); +}stacks.get (new Character (base).charCodeAt (0)).push (new Integer (i)); +} else if (jalview.analysis.Rna.isClosingParenthesis (base)) { +var opening = jalview.analysis.Rna.matchingOpeningParenthesis (base); +if (!stacks.containsKey (new Character (opening).charCodeAt (0))) { +throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.mismatched_unseen_closing_char", Clazz.newArray (-1, [ new StringBuffer (base.charCodeAt (0)).toString ()])), i); +}var stack = stacks.get (new Character (opening).charCodeAt (0)); +if (stack.isEmpty ()) { +throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.mismatched_closing_char", Clazz.newArray (-1, [ new StringBuffer (base.charCodeAt (0)).toString ()])), i); +}var temp = (stack.pop ()).intValue (); +pairs.add ( new jalview.analysis.SecStrConsensus.SimpleBP (temp, i)); +}i++; +} +for (var opening, $opening = stacks.keySet ().iterator (); $opening.hasNext () && ((opening = $opening.next ()) || true);) { +var stack = stacks.get (new Character (opening).charCodeAt (0)); +if (!stack.empty ()) { +throw new jalview.analysis.WUSSParseException (jalview.util.MessageManager.formatMessage ("exception.mismatched_opening_char", Clazz.newArray (-1, [ new StringBuffer (opening.charCodeAt (0)).toString (), Integer.$valueOf ((stack.pop ()).intValue ()).toString ()])), i); +}} +return pairs; +}, "CharSequence"); +c$.GetBasePairs = Clazz.defineMethod (c$, "GetBasePairs", +function (line) { +var bps = jalview.analysis.Rna.GetSimpleBPs (line); +var outPairs = new Array (bps.size ()); +for (var p = 0; p < bps.size (); p++) { +var bp = bps.elementAt (p); +outPairs[p] = new jalview.datamodel.SequenceFeature ("RNA helix", "", "", bp.getBP5 (), bp.getBP3 (), ""); +} +return outPairs; +}, "CharSequence"); +c$.GetModeleBP = Clazz.defineMethod (c$, "GetModeleBP", +function (line) { +var bps = jalview.analysis.Rna.GetSimpleBPs (line); +return new java.util.ArrayList (bps); +}, "CharSequence"); +c$.HelixMap = Clazz.defineMethod (c$, "HelixMap", +function (pairs) { +var helix = 0; +var lastopen = 0; +var lastclose = 9999999; +var i = pairs.length; +var open; +var close; +var j; +var helices = new java.util.Hashtable (); +for (i = 0; i < pairs.length; i++) { +open = pairs[i].getBegin (); +close = pairs[i].getEnd (); +if (open > lastclose) { +helix++; +}j = pairs.length - 1; +while (j >= 0) { +var popen = pairs[j].getBegin (); +if ((popen < lastopen) && (popen > open)) { +if (helices.containsValue (new Integer (popen)) && (((helices.get (new Integer (popen)))).intValue () === helix)) { +continue; +} else { +helix++; +break; +}}j -= 1; +} +helices.put (new Integer (open), new Integer (helix)); +helices.put (new Integer (close), new Integer (helix)); +pairs[i].setFeatureGroup (Integer.toString (helix)); +lastopen = open; +lastclose = close; +} +}, "~A"); +c$.pairHash = c$.prototype.pairHash = new java.util.Hashtable (); +Clazz.defineStatics (c$, +"openingPars", Clazz.newArray (-1, [new Character ('('), new Character ('['), new Character ('{'), new Character ('<'), new Character ('A'), new Character ('B'), new Character ('C'), new Character ('D'), new Character ('E'), new Character ('F'), new Character ('G'), new Character ('H'), new Character ('I'), new Character ('J'), new Character ('K'), new Character ('L'), new Character ('M'), new Character ('N'), new Character ('O'), new Character ('P'), new Character ('Q'), new Character ('R'), new Character ('S'), new Character ('T'), new Character ('U'), new Character ('V'), new Character ('W'), new Character ('X'), new Character ('Y'), new Character ('Z')]), +"closingPars", Clazz.newArray (-1, [new Character (')'), new Character (']'), new Character ('}'), new Character ('>'), new Character ('a'), new Character ('b'), new Character ('c'), new Character ('d'), new Character ('e'), new Character ('f'), new Character ('g'), new Character ('h'), new Character ('i'), new Character ('j'), new Character ('k'), new Character ('l'), new Character ('m'), new Character ('n'), new Character ('o'), new Character ('p'), new Character ('q'), new Character ('r'), new Character ('s'), new Character ('t'), new Character ('u'), new Character ('v'), new Character ('w'), new Character ('x'), new Character ('y'), new Character ('z')])); +c$.openingParsSet = c$.prototype.openingParsSet = new java.util.HashSet (java.util.Arrays.asList (jalview.analysis.Rna.openingPars)); +c$.closingParsSet = c$.prototype.closingParsSet = new java.util.HashSet (java.util.Arrays.asList (jalview.analysis.Rna.closingPars)); +c$.closingToOpening = c$.prototype.closingToOpening = new java.util.Hashtable (); +{ +for (var i = 0; i < jalview.analysis.Rna.openingPars.length; i++) { +jalview.analysis.Rna.closingToOpening.put (jalview.analysis.Rna.closingPars[i], jalview.analysis.Rna.openingPars[i]); +} +}}); diff --git a/bin/jalview/analysis/SecStrConsensus.js b/bin/jalview/analysis/SecStrConsensus.js index f96678e..44e1009 100644 --- a/bin/jalview/analysis/SecStrConsensus.js +++ b/bin/jalview/analysis/SecStrConsensus.js @@ -1,139 +1,139 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.SecStrConsensus", ["java.util.ArrayList", "$.Hashtable"], function () { -c$ = Clazz.declareType (jalview.analysis, "SecStrConsensus"); -c$.extractConsensus = Clazz.defineMethod (c$, "extractConsensus", -function (bps) { -var maxlength = 0; -for (var strs, $strs = bps.iterator (); $strs.hasNext () && ((strs = $strs.next ()) || true);) { -for (var bp, $bp = strs.iterator (); $bp.hasNext () && ((bp = $bp.next ()) || true);) { -maxlength = Math.max (1 + Math.max (bp.bp5, bp.bp3), maxlength); -} -} -var seq = new java.util.ArrayList (); -for (var i = 0; i < maxlength; i++) { -seq.add ( new java.util.Hashtable ()); -} -for (var strs, $strs = bps.iterator (); $strs.hasNext () && ((strs = $strs.next ()) || true);) { -for (var bp, $bp = strs.iterator (); $bp.hasNext () && ((bp = $bp.next ()) || true);) { -var i = bp.bp5; -var j = bp.bp3; -var h = seq.get (i); -if (!h.containsKey (new Integer (j))) { -h.put (new Integer (j), new Double (0.0)); -}h.put (new Integer (j), new Double ((h.get (new Integer (j))).doubleValue () + 1.)); -} -} -var mat = jalview.analysis.SecStrConsensus.fillMatrix (seq); -var res = jalview.analysis.SecStrConsensus.backtrack (mat, seq); -var finalres = Clazz.newIntArray (seq.size (), 0); -for (var i = 0; i < seq.size (); i++) { -finalres[i] = -1; -} -for (var bp, $bp = res.iterator (); $bp.hasNext () && ((bp = $bp.next ()) || true);) { -finalres[bp.bp5] = bp.bp3; -finalres[bp.bp3] = bp.bp5; -} -return finalres; -}, "java.util.ArrayList"); -c$.canBasePair = Clazz.defineMethod (c$, "canBasePair", -($fz = function (seq, i, k) { -return seq.get (i).containsKey (new Integer (k)); -}, $fz.isPrivate = true, $fz), "java.util.ArrayList,~N,~N"); -c$.basePairScore = Clazz.defineMethod (c$, "basePairScore", -($fz = function (seq, i, k) { -return seq.get (i).get (new Integer (k)); -}, $fz.isPrivate = true, $fz), "java.util.ArrayList,~N,~N"); -c$.fillMatrix = Clazz.defineMethod (c$, "fillMatrix", -($fz = function (seq) { -var n = seq.size (); -var tab = Clazz.newDoubleArray (n, n, 0); -for (var m = 1; m <= n; m++) { -for (var i = 0; i < n - m + 1; i++) { -var j = i + m - 1; -tab[i][j] = 0; -if (i < j) { -tab[i][j] = Math.max (tab[i][j], tab[i + 1][j]); -for (var k = i + 1; k <= j; k++) { -if (jalview.analysis.SecStrConsensus.canBasePair (seq, i, k)) { -var fact1 = 0; -if (k > i + 1) { -fact1 = tab[i + 1][k - 1]; -}var fact2 = 0; -if (k < j) { -fact2 = tab[k + 1][j]; -}tab[i][j] = Math.max (tab[i][j], jalview.analysis.SecStrConsensus.basePairScore (seq, i, k) + fact1 + fact2); -}} -}} -} -return tab; -}, $fz.isPrivate = true, $fz), "java.util.ArrayList"); -c$.backtrack = Clazz.defineMethod (c$, "backtrack", -($fz = function (tab, seq) { -return jalview.analysis.SecStrConsensus.backtrack (tab, seq, 0, seq.size () - 1); -}, $fz.isPrivate = true, $fz), "~A,java.util.ArrayList"); -c$.backtrack = Clazz.defineMethod (c$, "backtrack", -($fz = function (tab, seq, i, j) { -var result = new java.util.ArrayList (); -if (i < j) { -var indices = new java.util.ArrayList (); -indices.add (new Integer (-1)); -for (var k = i + 1; k <= j; k++) { -indices.add (new Integer (k)); -} -for (var k, $k = indices.iterator (); $k.hasNext () && ((k = $k.next ()) || true);) { -if (k == -1) { -if (tab[i][j] == tab[i + 1][j]) { -result = jalview.analysis.SecStrConsensus.backtrack (tab, seq, i + 1, j); -}} else { -if (jalview.analysis.SecStrConsensus.canBasePair (seq, i, k)) { -var fact1 = 0; -if (k > i + 1) { -fact1 = tab[i + 1][k - 1]; -}var fact2 = 0; -if (k < j) { -fact2 = tab[k + 1][j]; -}if (tab[i][j] == jalview.analysis.SecStrConsensus.basePairScore (seq, i, k) + fact1 + fact2) { -result = jalview.analysis.SecStrConsensus.backtrack (tab, seq, i + 1, k - 1); -result.addAll (jalview.analysis.SecStrConsensus.backtrack (tab, seq, k + 1, j)); -result.add ( new jalview.analysis.SecStrConsensus.SimpleBP (i, k)); -}}}} -} else if (i == j) { -} else { -}return result; -}, $fz.isPrivate = true, $fz), "~A,java.util.ArrayList,~N,~N"); -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.bp5 = 0; -this.bp3 = 0; -Clazz.instantialize (this, arguments); -}, jalview.analysis.SecStrConsensus, "SimpleBP"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (a, b) { -this.bp5 = a; -this.bp3 = b; -}, "~N,~N"); -Clazz.defineMethod (c$, "setBP5", -function (a) { -this.bp5 = a; -}, "~N"); -Clazz.defineMethod (c$, "setBP3", -function (a) { -this.bp3 = a; -}, "~N"); -Clazz.defineMethod (c$, "getBP5", -function () { -return this.bp5; -}); -Clazz.defineMethod (c$, "getBP3", -function () { -return this.bp3; -}); -Clazz.overrideMethod (c$, "toString", -function () { -return "(" + this.bp5 + "," + this.bp3 + ")"; -}); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.SecStrConsensus", ["java.util.ArrayList", "$.Hashtable"], function () { +c$ = Clazz.declareType (jalview.analysis, "SecStrConsensus"); +c$.extractConsensus = Clazz.defineMethod (c$, "extractConsensus", +function (bps) { +var maxlength = 0; +for (var strs, $strs = bps.iterator (); $strs.hasNext () && ((strs = $strs.next ()) || true);) { +for (var bp, $bp = strs.iterator (); $bp.hasNext () && ((bp = $bp.next ()) || true);) { +maxlength = Math.max (1 + Math.max (bp.bp5, bp.bp3), maxlength); +} +} +var seq = new java.util.ArrayList (); +for (var i = 0; i < maxlength; i++) { +seq.add ( new java.util.Hashtable ()); +} +for (var strs, $strs = bps.iterator (); $strs.hasNext () && ((strs = $strs.next ()) || true);) { +for (var bp, $bp = strs.iterator (); $bp.hasNext () && ((bp = $bp.next ()) || true);) { +var i = bp.bp5; +var j = bp.bp3; +var h = seq.get (i); +if (!h.containsKey (new Integer (j))) { +h.put (new Integer (j), new Double (0.0)); +}h.put (new Integer (j), new Double ((h.get (new Integer (j))).doubleValue () + 1.)); +} +} +var mat = jalview.analysis.SecStrConsensus.fillMatrix (seq); +var res = jalview.analysis.SecStrConsensus.backtrack (mat, seq); +var finalres = Clazz.newIntArray (seq.size (), 0); +for (var i = 0; i < seq.size (); i++) { +finalres[i] = -1; +} +for (var bp, $bp = res.iterator (); $bp.hasNext () && ((bp = $bp.next ()) || true);) { +finalres[bp.bp5] = bp.bp3; +finalres[bp.bp3] = bp.bp5; +} +return finalres; +}, "java.util.ArrayList"); +c$.canBasePair = Clazz.defineMethod (c$, "canBasePair", +($fz = function (seq, i, k) { +return seq.get (i).containsKey (new Integer (k)); +}, $fz.isPrivate = true, $fz), "java.util.ArrayList,~N,~N"); +c$.basePairScore = Clazz.defineMethod (c$, "basePairScore", +($fz = function (seq, i, k) { +return seq.get (i).get (new Integer (k)); +}, $fz.isPrivate = true, $fz), "java.util.ArrayList,~N,~N"); +c$.fillMatrix = Clazz.defineMethod (c$, "fillMatrix", +($fz = function (seq) { +var n = seq.size (); +var tab = Clazz.newDoubleArray (n, n, 0); +for (var m = 1; m <= n; m++) { +for (var i = 0; i < n - m + 1; i++) { +var j = i + m - 1; +tab[i][j] = 0; +if (i < j) { +tab[i][j] = Math.max (tab[i][j], tab[i + 1][j]); +for (var k = i + 1; k <= j; k++) { +if (jalview.analysis.SecStrConsensus.canBasePair (seq, i, k)) { +var fact1 = 0; +if (k > i + 1) { +fact1 = tab[i + 1][k - 1]; +}var fact2 = 0; +if (k < j) { +fact2 = tab[k + 1][j]; +}tab[i][j] = Math.max (tab[i][j], jalview.analysis.SecStrConsensus.basePairScore (seq, i, k) + fact1 + fact2); +}} +}} +} +return tab; +}, $fz.isPrivate = true, $fz), "java.util.ArrayList"); +c$.backtrack = Clazz.defineMethod (c$, "backtrack", +($fz = function (tab, seq) { +return jalview.analysis.SecStrConsensus.backtrack (tab, seq, 0, seq.size () - 1); +}, $fz.isPrivate = true, $fz), "~A,java.util.ArrayList"); +c$.backtrack = Clazz.defineMethod (c$, "backtrack", +($fz = function (tab, seq, i, j) { +var result = new java.util.ArrayList (); +if (i < j) { +var indices = new java.util.ArrayList (); +indices.add (new Integer (-1)); +for (var k = i + 1; k <= j; k++) { +indices.add (new Integer (k)); +} +for (var k, $k = indices.iterator (); $k.hasNext () && ((k = $k.next ()) || true);) { +if (k == -1) { +if (tab[i][j] == tab[i + 1][j]) { +result = jalview.analysis.SecStrConsensus.backtrack (tab, seq, i + 1, j); +}} else { +if (jalview.analysis.SecStrConsensus.canBasePair (seq, i, k)) { +var fact1 = 0; +if (k > i + 1) { +fact1 = tab[i + 1][k - 1]; +}var fact2 = 0; +if (k < j) { +fact2 = tab[k + 1][j]; +}if (tab[i][j] == jalview.analysis.SecStrConsensus.basePairScore (seq, i, k) + fact1 + fact2) { +result = jalview.analysis.SecStrConsensus.backtrack (tab, seq, i + 1, k - 1); +result.addAll (jalview.analysis.SecStrConsensus.backtrack (tab, seq, k + 1, j)); +result.add ( new jalview.analysis.SecStrConsensus.SimpleBP (i, k)); +}}}} +} else if (i == j) { +} else { +}return result; +}, $fz.isPrivate = true, $fz), "~A,java.util.ArrayList,~N,~N"); +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.bp5 = 0; +this.bp3 = 0; +Clazz.instantialize (this, arguments); +}, jalview.analysis.SecStrConsensus, "SimpleBP"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (a, b) { +this.bp5 = a; +this.bp3 = b; +}, "~N,~N"); +Clazz.defineMethod (c$, "setBP5", +function (a) { +this.bp5 = a; +}, "~N"); +Clazz.defineMethod (c$, "setBP3", +function (a) { +this.bp3 = a; +}, "~N"); +Clazz.defineMethod (c$, "getBP5", +function () { +return this.bp5; +}); +Clazz.defineMethod (c$, "getBP3", +function () { +return this.bp3; +}); +Clazz.overrideMethod (c$, "toString", +function () { +return "(" + this.bp5 + "," + this.bp3 + ")"; +}); +c$ = Clazz.p0p (); +}); diff --git a/bin/jalview/analysis/SeqsetUtils.js b/bin/jalview/analysis/SeqsetUtils.js index f8914e1..a93fedd 100644 --- a/bin/jalview/analysis/SeqsetUtils.js +++ b/bin/jalview/analysis/SeqsetUtils.js @@ -1,124 +1,124 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.SeqsetUtils", ["jalview.analysis.AlignSeq", "$.SequenceIdMatcher", "jalview.datamodel.Sequence", "jalview.util.Comparison", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.declareType (jalview.analysis, "SeqsetUtils"); -c$.SeqCharacterHash = Clazz.defineMethod (c$, "SeqCharacterHash", -function (seq) { -var sqinfo = new java.util.Hashtable (); -sqinfo.put ("Name", seq.getName ()); -sqinfo.put ("Start", new Integer (seq.getStart ())); -sqinfo.put ("End", new Integer (seq.getEnd ())); -if (seq.getDescription () != null) { -sqinfo.put ("Description", seq.getDescription ()); -}var sfeat = new java.util.Vector (); -var sfarray = seq.getSequenceFeatures (); -if (sfarray != null && sfarray.length > 0) { -for (var i = 0; i < sfarray.length; i++) { -sfeat.addElement (sfarray[i]); -} -}sqinfo.put ("SeqFeatures", sfeat); -sqinfo.put ("PdbId", (seq.getPDBId () != null) ? seq.getPDBId () : new java.util.Vector ()); -sqinfo.put ("datasetSequence", (seq.getDatasetSequence () != null) ? seq.getDatasetSequence () : new jalview.datamodel.Sequence ("THISISAPLACEHOLDER", "")); -return sqinfo; -}, "jalview.datamodel.SequenceI"); -c$.SeqCharacterUnhash = Clazz.defineMethod (c$, "SeqCharacterUnhash", -function (sq, sqinfo) { -var namePresent = true; -if (sqinfo == null) { -return false; -}var oldname = sqinfo.get ("Name"); -var start = sqinfo.get ("Start"); -var end = sqinfo.get ("End"); -var sfeatures = sqinfo.get ("SeqFeatures"); -var pdbid = sqinfo.get ("PdbId"); -var description = sqinfo.get ("Description"); -var seqds = sqinfo.get ("datasetSequence"); -if (oldname == null) { -namePresent = false; -} else { -sq.setName (oldname); -}if (pdbid != null && pdbid.size () > 0) { -sq.setPDBId (pdbid); -}if ((start != null) && (end != null)) { -sq.setStart (start.intValue ()); -sq.setEnd (end.intValue ()); -}if ((sfeatures != null) && (sfeatures.size () > 0)) { -var sfarray = new Array (sfeatures.size ()); -for (var is = 0, isize = sfeatures.size (); is < isize; is++) { -sfarray[is] = sfeatures.elementAt (is); -} -sq.setSequenceFeatures (sfarray); -}if (description != null) { -sq.setDescription (description); -}if ((seqds != null) && !(seqds.getName ().equals ("THISISAPLACEHOLDER") && seqds.getLength () == 0)) { -sq.setDatasetSequence (seqds); -}return namePresent; -}, "jalview.datamodel.SequenceI,java.util.Hashtable"); -c$.unique_name = Clazz.defineMethod (c$, "unique_name", -function (i) { -return String.instantialize ("Sequence" + i); -}, "~N"); -c$.uniquify = Clazz.defineMethod (c$, "uniquify", -function (sequences, write_names) { -var map = new java.util.Hashtable (); -for (var i = 0; i < sequences.length; i++) { -var safename = jalview.analysis.SeqsetUtils.unique_name (i); -map.put (safename, jalview.analysis.SeqsetUtils.SeqCharacterHash (sequences[i])); -if (write_names) { -sequences[i].setName (safename); -}} -return map; -}, "~A,~B"); -c$.deuniquify = Clazz.defineMethod (c$, "deuniquify", -function (map, sequences) { -return jalview.analysis.SeqsetUtils.deuniquify (map, sequences, true); -}, "java.util.Hashtable,~A"); -c$.deuniquify = Clazz.defineMethod (c$, "deuniquify", -function (map, sequences, quiet) { -var matcher = new jalview.analysis.SequenceIdMatcher (sequences); -var msq = null; -var keys = map.keys (); -var unmatched = new java.util.Vector (); -for (var i = 0, j = sequences.length; i < j; i++) { -unmatched.addElement (sequences[i]); -} -while (keys.hasMoreElements ()) { -var key = keys.nextElement (); -if (Clazz.instanceOf (key, String)) { -if ((msq = matcher.findIdMatch (key)) != null) { -var sqinfo = map.get (key); -unmatched.removeElement (msq); -jalview.analysis.SeqsetUtils.SeqCharacterUnhash (msq, sqinfo); -} else { -if (!quiet) { -System.err.println ("Can't find '" + (key) + "' in uniquified alignment"); -}}}} -if (unmatched.size () > 0 && !quiet) { -System.err.println ("Did not find matches for :"); -for (var i = unmatched.elements (); i.hasMoreElements (); System.out.println ((i.nextElement ()).getName ())) { -;} -return false; -}return true; -}, "java.util.Hashtable,~A,~B"); -c$.getNonEmptySequenceSet = Clazz.defineMethod (c$, "getNonEmptySequenceSet", -function (sequences) { -var ungapped = Clazz.newBooleanArray (sequences.length, false); -var msflen = 0; -for (var i = 0, j = sequences.length; i < j; i++) { -var tempseq = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, sequences[i].getSequenceAsString ()); -if (tempseq.length == 0) { -ungapped[i] = false; -} else { -ungapped[i] = true; -msflen++; -}} -if (msflen == 0) { -return null; -}var mset = new Array (msflen); -for (var i = 0, j = sequences.length, k = 0; i < j; i++) { -if (ungapped[i]) { -mset[k++] = sequences[i]; -}} -ungapped = null; -return mset; -}, "~A"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.SeqsetUtils", ["jalview.analysis.AlignSeq", "$.SequenceIdMatcher", "jalview.datamodel.Sequence", "jalview.util.Comparison", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.declareType (jalview.analysis, "SeqsetUtils"); +c$.SeqCharacterHash = Clazz.defineMethod (c$, "SeqCharacterHash", +function (seq) { +var sqinfo = new java.util.Hashtable (); +sqinfo.put ("Name", seq.getName ()); +sqinfo.put ("Start", new Integer (seq.getStart ())); +sqinfo.put ("End", new Integer (seq.getEnd ())); +if (seq.getDescription () != null) { +sqinfo.put ("Description", seq.getDescription ()); +}var sfeat = new java.util.Vector (); +var sfarray = seq.getSequenceFeatures (); +if (sfarray != null && sfarray.length > 0) { +for (var i = 0; i < sfarray.length; i++) { +sfeat.addElement (sfarray[i]); +} +}sqinfo.put ("SeqFeatures", sfeat); +sqinfo.put ("PdbId", (seq.getPDBId () != null) ? seq.getPDBId () : new java.util.Vector ()); +sqinfo.put ("datasetSequence", (seq.getDatasetSequence () != null) ? seq.getDatasetSequence () : new jalview.datamodel.Sequence ("THISISAPLACEHOLDER", "")); +return sqinfo; +}, "jalview.datamodel.SequenceI"); +c$.SeqCharacterUnhash = Clazz.defineMethod (c$, "SeqCharacterUnhash", +function (sq, sqinfo) { +var namePresent = true; +if (sqinfo == null) { +return false; +}var oldname = sqinfo.get ("Name"); +var start = sqinfo.get ("Start"); +var end = sqinfo.get ("End"); +var sfeatures = sqinfo.get ("SeqFeatures"); +var pdbid = sqinfo.get ("PdbId"); +var description = sqinfo.get ("Description"); +var seqds = sqinfo.get ("datasetSequence"); +if (oldname == null) { +namePresent = false; +} else { +sq.setName (oldname); +}if (pdbid != null && pdbid.size () > 0) { +sq.setPDBId (pdbid); +}if ((start != null) && (end != null)) { +sq.setStart (start.intValue ()); +sq.setEnd (end.intValue ()); +}if ((sfeatures != null) && (sfeatures.size () > 0)) { +var sfarray = new Array (sfeatures.size ()); +for (var is = 0, isize = sfeatures.size (); is < isize; is++) { +sfarray[is] = sfeatures.elementAt (is); +} +sq.setSequenceFeatures (sfarray); +}if (description != null) { +sq.setDescription (description); +}if ((seqds != null) && !(seqds.getName ().equals ("THISISAPLACEHOLDER") && seqds.getLength () == 0)) { +sq.setDatasetSequence (seqds); +}return namePresent; +}, "jalview.datamodel.SequenceI,java.util.Hashtable"); +c$.unique_name = Clazz.defineMethod (c$, "unique_name", +function (i) { +return String.instantialize ("Sequence" + i); +}, "~N"); +c$.uniquify = Clazz.defineMethod (c$, "uniquify", +function (sequences, write_names) { +var map = new java.util.Hashtable (); +for (var i = 0; i < sequences.length; i++) { +var safename = jalview.analysis.SeqsetUtils.unique_name (i); +map.put (safename, jalview.analysis.SeqsetUtils.SeqCharacterHash (sequences[i])); +if (write_names) { +sequences[i].setName (safename); +}} +return map; +}, "~A,~B"); +c$.deuniquify = Clazz.defineMethod (c$, "deuniquify", +function (map, sequences) { +return jalview.analysis.SeqsetUtils.deuniquify (map, sequences, true); +}, "java.util.Hashtable,~A"); +c$.deuniquify = Clazz.defineMethod (c$, "deuniquify", +function (map, sequences, quiet) { +var matcher = new jalview.analysis.SequenceIdMatcher (sequences); +var msq = null; +var keys = map.keys (); +var unmatched = new java.util.Vector (); +for (var i = 0, j = sequences.length; i < j; i++) { +unmatched.addElement (sequences[i]); +} +while (keys.hasMoreElements ()) { +var key = keys.nextElement (); +if (Clazz.instanceOf (key, String)) { +if ((msq = matcher.findIdMatch (key)) != null) { +var sqinfo = map.get (key); +unmatched.removeElement (msq); +jalview.analysis.SeqsetUtils.SeqCharacterUnhash (msq, sqinfo); +} else { +if (!quiet) { +System.err.println ("Can't find '" + (key) + "' in uniquified alignment"); +}}}} +if (unmatched.size () > 0 && !quiet) { +System.err.println ("Did not find matches for :"); +for (var i = unmatched.elements (); i.hasMoreElements (); System.out.println ((i.nextElement ()).getName ())) { +;} +return false; +}return true; +}, "java.util.Hashtable,~A,~B"); +c$.getNonEmptySequenceSet = Clazz.defineMethod (c$, "getNonEmptySequenceSet", +function (sequences) { +var ungapped = Clazz.newBooleanArray (sequences.length, false); +var msflen = 0; +for (var i = 0, j = sequences.length; i < j; i++) { +var tempseq = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, sequences[i].getSequenceAsString ()); +if (tempseq.length == 0) { +ungapped[i] = false; +} else { +ungapped[i] = true; +msflen++; +}} +if (msflen == 0) { +return null; +}var mset = new Array (msflen); +for (var i = 0, j = sequences.length, k = 0; i < j; i++) { +if (ungapped[i]) { +mset[k++] = sequences[i]; +}} +ungapped = null; +return mset; +}, "~A"); +}); diff --git a/bin/jalview/analysis/SequenceIdMatcher.js b/bin/jalview/analysis/SequenceIdMatcher.js index adb0a5a..6e94b5f 100644 --- a/bin/jalview/analysis/SequenceIdMatcher.js +++ b/bin/jalview/analysis/SequenceIdMatcher.js @@ -1,167 +1,167 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.SequenceIdMatcher", ["java.util.ArrayList", "$.Arrays", "$.HashMap", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.names = null; -if (!Clazz.isClassDefined ("jalview.analysis.SequenceIdMatcher.SeqIdName")) { -jalview.analysis.SequenceIdMatcher.$SequenceIdMatcher$SeqIdName$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.analysis, "SequenceIdMatcher"); -Clazz.makeConstructor (c$, -function (seqs) { -this.names = new java.util.HashMap (); -this.addAll (seqs); -}, "java.util.List"); -Clazz.defineMethod (c$, "addAll", -function (seqs) { -for (var seq, $seq = seqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getDisplayId (true)), seq); -var dbseq = seq; -while (dbseq.getDatasetSequence () != null) { -dbseq = dbseq.getDatasetSequence (); -} -if (dbseq.getDBRef () != null) { -var dbr = dbseq.getDBRef (); -var sid = null; -for (var r = 0; r < dbr.length; r++) { -sid = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, dbr[r].getAccessionId ()); -if (!this.names.containsKey (sid)) { -this.names.put (sid, seq); -}} -}} -}, "java.util.List"); -Clazz.makeConstructor (c$, -function (sequences) { -this.construct (java.util.Arrays.asList (sequences)); -}, "~A"); -Clazz.defineMethod (c$, "pickbestMatch", -($fz = function (candName, matches) { -var st = this.pickbestMatches (candName, matches); -return st == null || st.size () == 0 ? null : st.get (0); -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); -Clazz.defineMethod (c$, "pickbestMatches", -($fz = function (candName, matches) { -var best = new java.util.ArrayList (); -if (candName == null || matches == null || matches.size () == 0) { -return null; -}var match = matches.remove (0); -best.add (match); -this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, match.getName ()), match); -var matchlen = match.getName ().length; -var namlen = candName.id.length; -while (matches.size () > 0) { -var cand = matches.remove (0); -this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, cand.getName ()), cand); -var q; -var w; -var candlen = cand.getName ().length; -if ((q = Math.abs (matchlen - namlen)) > (w = Math.abs (candlen - namlen)) && candlen > matchlen) { -best.clear (); -match = cand; -matchlen = candlen; -best.add (match); -}if (q == w && candlen == matchlen) { -best.add (cand); -}} -if (best.size () == 0) { -return null; -};return best; -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); -Clazz.defineMethod (c$, "findIdMatch", -function (seq) { -var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getName ()); -return this.findIdMatch (nam); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "findIdMatch", -function (seqnam) { -var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); -return this.findIdMatch (nam); -}, "~S"); -Clazz.defineMethod (c$, "findAllIdMatches", -function (seqnam) { -var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); -var m = this.findAllIdMatches (nam); -if (m != null) { -return m.toArray ( new Array (m.size ())); -}return null; -}, "~S"); -Clazz.defineMethod (c$, "findIdMatch", -function (seqs) { -var namedseqs = null; -var i = 0; -var nam; -if (seqs.length > 0) { -namedseqs = new Array (seqs.length); -do { -nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqs[i].getName ()); -if (this.names.containsKey (nam)) { -namedseqs[i] = this.findIdMatch (nam); -} else { -namedseqs[i] = null; -}} while (++i < seqs.length); -}return namedseqs; -}, "~A"); -Clazz.defineMethod (c$, "findIdMatch", -($fz = function (nam) { -var matches = new java.util.Vector (); -while (this.names.containsKey (nam)) { -matches.addElement (this.names.remove (nam)); -} -return this.pickbestMatch (nam, matches); -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); -Clazz.defineMethod (c$, "findAllIdMatches", -($fz = function (nam) { -var matches = new java.util.ArrayList (); -while (this.names.containsKey (nam)) { -matches.add (this.names.remove (nam)); -} -var r = this.pickbestMatches (nam, matches); -return r; -}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); -c$.$SequenceIdMatcher$SeqIdName$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.id = null; -this.WORD_SEP = "~. |#\\/<>!\"\u00a4$%^*)}[@\',?_"; -Clazz.instantialize (this, arguments); -}, jalview.analysis.SequenceIdMatcher, "SeqIdName"); -Clazz.makeConstructor (c$, -function (a) { -if (a != null) { -this.id = String.instantialize (a); -} else { -this.id = ""; -}}, "~S"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return ((this.id.length >= 4) ? this.id.substring (0, 4).hashCode () : this.id.hashCode ()); -}); -Clazz.defineMethod (c$, "equals", -function (a) { -if (a == null) { -return false; -}if (Clazz.instanceOf (a, jalview.analysis.SequenceIdMatcher.SeqIdName)) { -return this.equals (a); -} else { -if (Clazz.instanceOf (a, String)) { -return this.equals (a); -}}return false; -}, "~O"); -Clazz.defineMethod (c$, "equals", -function (a) { -if (this.id.length > a.id.length) { -return this.id.startsWith (a.id) ? (this.WORD_SEP.indexOf (this.id.charAt (a.id.length)) > -1) : false; -} else { -return a.id.startsWith (this.id) ? (a.id.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.id.charAt (this.id.length)) > -1)) : false; -}}, "jalview.analysis.SequenceIdMatcher.SeqIdName"); -Clazz.defineMethod (c$, "equals", -function (a) { -if (this.id.length > a.length) { -return this.id.startsWith (a) ? (this.WORD_SEP.indexOf (this.id.charAt (a.length)) > -1) : false; -} else { -return a.startsWith (this.id) ? (a.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.charAt (this.id.length)) > -1)) : false; -}}, "~S"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.SequenceIdMatcher", ["java.util.ArrayList", "$.Arrays", "$.HashMap", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.names = null; +if (!Clazz.isClassDefined ("jalview.analysis.SequenceIdMatcher.SeqIdName")) { +jalview.analysis.SequenceIdMatcher.$SequenceIdMatcher$SeqIdName$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.analysis, "SequenceIdMatcher"); +Clazz.makeConstructor (c$, +function (seqs) { +this.names = new java.util.HashMap (); +this.addAll (seqs); +}, "java.util.List"); +Clazz.defineMethod (c$, "addAll", +function (seqs) { +for (var seq, $seq = seqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getDisplayId (true)), seq); +var dbseq = seq; +while (dbseq.getDatasetSequence () != null) { +dbseq = dbseq.getDatasetSequence (); +} +if (dbseq.getDBRef () != null) { +var dbr = dbseq.getDBRef (); +var sid = null; +for (var r = 0; r < dbr.length; r++) { +sid = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, dbr[r].getAccessionId ()); +if (!this.names.containsKey (sid)) { +this.names.put (sid, seq); +}} +}} +}, "java.util.List"); +Clazz.makeConstructor (c$, +function (sequences) { +this.construct (java.util.Arrays.asList (sequences)); +}, "~A"); +Clazz.defineMethod (c$, "pickbestMatch", +($fz = function (candName, matches) { +var st = this.pickbestMatches (candName, matches); +return st == null || st.size () == 0 ? null : st.get (0); +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); +Clazz.defineMethod (c$, "pickbestMatches", +($fz = function (candName, matches) { +var best = new java.util.ArrayList (); +if (candName == null || matches == null || matches.size () == 0) { +return null; +}var match = matches.remove (0); +best.add (match); +this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, match.getName ()), match); +var matchlen = match.getName ().length; +var namlen = candName.id.length; +while (matches.size () > 0) { +var cand = matches.remove (0); +this.names.put (Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, cand.getName ()), cand); +var q; +var w; +var candlen = cand.getName ().length; +if ((q = Math.abs (matchlen - namlen)) > (w = Math.abs (candlen - namlen)) && candlen > matchlen) { +best.clear (); +match = cand; +matchlen = candlen; +best.add (match); +}if (q == w && candlen == matchlen) { +best.add (cand); +}} +if (best.size () == 0) { +return null; +};return best; +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName,java.util.List"); +Clazz.defineMethod (c$, "findIdMatch", +function (seq) { +var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seq.getName ()); +return this.findIdMatch (nam); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "findIdMatch", +function (seqnam) { +var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); +return this.findIdMatch (nam); +}, "~S"); +Clazz.defineMethod (c$, "findAllIdMatches", +function (seqnam) { +var nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqnam); +var m = this.findAllIdMatches (nam); +if (m != null) { +return m.toArray ( new Array (m.size ())); +}return null; +}, "~S"); +Clazz.defineMethod (c$, "findIdMatch", +function (seqs) { +var namedseqs = null; +var i = 0; +var nam; +if (seqs.length > 0) { +namedseqs = new Array (seqs.length); +do { +nam = Clazz.innerTypeInstance (jalview.analysis.SequenceIdMatcher.SeqIdName, this, null, seqs[i].getName ()); +if (this.names.containsKey (nam)) { +namedseqs[i] = this.findIdMatch (nam); +} else { +namedseqs[i] = null; +}} while (++i < seqs.length); +}return namedseqs; +}, "~A"); +Clazz.defineMethod (c$, "findIdMatch", +($fz = function (nam) { +var matches = new java.util.Vector (); +while (this.names.containsKey (nam)) { +matches.addElement (this.names.remove (nam)); +} +return this.pickbestMatch (nam, matches); +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); +Clazz.defineMethod (c$, "findAllIdMatches", +($fz = function (nam) { +var matches = new java.util.ArrayList (); +while (this.names.containsKey (nam)) { +matches.add (this.names.remove (nam)); +} +var r = this.pickbestMatches (nam, matches); +return r; +}, $fz.isPrivate = true, $fz), "jalview.analysis.SequenceIdMatcher.SeqIdName"); +c$.$SequenceIdMatcher$SeqIdName$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.id = null; +this.WORD_SEP = "~. |#\\/<>!\"\u00a4$%^*)}[@\',?_"; +Clazz.instantialize (this, arguments); +}, jalview.analysis.SequenceIdMatcher, "SeqIdName"); +Clazz.makeConstructor (c$, +function (a) { +if (a != null) { +this.id = String.instantialize (a); +} else { +this.id = ""; +}}, "~S"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return ((this.id.length >= 4) ? this.id.substring (0, 4).hashCode () : this.id.hashCode ()); +}); +Clazz.defineMethod (c$, "equals", +function (a) { +if (a == null) { +return false; +}if (Clazz.instanceOf (a, jalview.analysis.SequenceIdMatcher.SeqIdName)) { +return this.equals (a); +} else { +if (Clazz.instanceOf (a, String)) { +return this.equals (a); +}}return false; +}, "~O"); +Clazz.defineMethod (c$, "equals", +function (a) { +if (this.id.length > a.id.length) { +return this.id.startsWith (a.id) ? (this.WORD_SEP.indexOf (this.id.charAt (a.id.length)) > -1) : false; +} else { +return a.id.startsWith (this.id) ? (a.id.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.id.charAt (this.id.length)) > -1)) : false; +}}, "jalview.analysis.SequenceIdMatcher.SeqIdName"); +Clazz.defineMethod (c$, "equals", +function (a) { +if (this.id.length > a.length) { +return this.id.startsWith (a) ? (this.WORD_SEP.indexOf (this.id.charAt (a.length)) > -1) : false; +} else { +return a.startsWith (this.id) ? (a.equals (this.id) ? true : (this.WORD_SEP.indexOf (a.charAt (this.id.length)) > -1)) : false; +}}, "~S"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/analysis/StructureFrequency.js b/bin/jalview/analysis/StructureFrequency.js index 83c8f02..6c90b65 100644 --- a/bin/jalview/analysis/StructureFrequency.js +++ b/bin/jalview/analysis/StructureFrequency.js @@ -1,260 +1,260 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (null, "jalview.analysis.StructureFrequency", ["jalview.datamodel.Annotation", "jalview.util.Format", "$.QuickSort", "java.lang.Float", "java.util.Hashtable", "javajs.util.AU"], function () { -c$ = Clazz.declareType (jalview.analysis, "StructureFrequency"); -c$.findPair = Clazz.defineMethod (c$, "findPair", -function (pairs, indice) { -for (var i = 0; i < pairs.length; i++) { -if (pairs[i].getBegin () == indice) { -return pairs[i].getEnd (); -}} -return -1; -}, "~A,~N"); -c$.calculate = Clazz.defineMethod (c$, "calculate", -function (sequences, start, end, result, profile, rnaStruc) { -var residueHash; -var maxResidue; -var struc = rnaStruc.getRNAStruc ().toCharArray (); -var rna = rnaStruc._rnasecstr; -var c; -var s; -var cEnd; -var count = 0; -var nonGap = 0; -var i; -var bpEnd = -1; -var j; -var jSize = sequences.length; -var values; -var pairs; -var percentage; -var wooble = true; -for (i = start; i < end; i++) { -residueHash = new java.util.Hashtable (); -maxResidue = "-"; -values = Clazz.newIntArray (255, 0); -pairs = Clazz.newIntArray (255, 255, 0); -bpEnd = -1; -if (i < struc.length) { -s = struc[i]; -} else { -s = '-'; -}if (s == '.' || s == ' ') { -s = '-'; -}if (s != '(' && s != '[') { -if (s == '-') { -values['-'.charCodeAt (0)]++; -}} else { -bpEnd = jalview.analysis.StructureFrequency.findPair (rna, i); -if (bpEnd > -1) { -for (j = 0; j < jSize; j++) { -if (sequences[j] == null) { -System.err.println ("WARNING: Consensus skipping null sequence - possible race condition."); -continue; -}c = sequences[j].getCharAt (i); -if (c == '.' || c == ' ') { -c = '-'; -}if (c == '-') { -values['-'.charCodeAt (0)]++; -continue; -}cEnd = sequences[j].getCharAt (bpEnd); -if (jalview.analysis.StructureFrequency.checkBpType (c, cEnd) == true) { -values['('.charCodeAt (0)]++; -maxResidue = "("; -wooble = true; -}if (jalview.analysis.StructureFrequency.checkBpType (c, cEnd) == false) { -wooble = false; -values['['.charCodeAt (0)]++; -maxResidue = "["; -}pairs[c.charCodeAt (0)][cEnd.charCodeAt (0)]++; -} -}}if (profile) { -residueHash.put ("P", Clazz.newArray (-1, [values, Clazz.newIntArray (-1, [jSize, (jSize - values['-'.charCodeAt (0)])])])); -residueHash.put ("B", pairs); -}if (wooble == true) { -count = values['('.charCodeAt (0)]; -}if (wooble == false) { -count = values['['.charCodeAt (0)]; -}residueHash.put ("C", new Integer (count)); -residueHash.put ("R", maxResidue); -percentage = (count * 100) / jSize; -residueHash.put ("G", new Float (percentage)); -if (result[i] == null) { -result[i] = residueHash; -}if (bpEnd > 0) { -values[')'.charCodeAt (0)] = values['('.charCodeAt (0)]; -values[']'.charCodeAt (0)] = values['['.charCodeAt (0)]; -values['('.charCodeAt (0)] = 0; -values['['.charCodeAt (0)] = 0; -residueHash = new java.util.Hashtable (); -if (wooble == true) { -maxResidue = ")"; -}if (wooble == false) { -maxResidue = "]"; -}if (profile) { -residueHash.put ("P", Clazz.newArray (-1, [values, Clazz.newIntArray (-1, [jSize, (jSize - values['-'.charCodeAt (0)])])])); -residueHash.put ("B", pairs); -}residueHash.put ("C", new Integer (count)); -residueHash.put ("R", maxResidue); -percentage = (count * 100) / jSize; -residueHash.put ("G", new Float (percentage)); -result[bpEnd] = residueHash; -}} -}, "~A,~N,~N,~A,~B,jalview.datamodel.AlignmentAnnotation"); -c$.checkBpType = Clazz.defineMethod (c$, "checkBpType", -function (up, down) { -if (up > 'Z') { -up = String.fromCharCode (up.charCodeAt (0) - 32); -}if (down > 'Z') { -down = String.fromCharCode (down.charCodeAt (0) - 32); -}switch (up) { -case 'A': -switch (down) { -case 'T': -return true; -case 'U': -return true; -} -break; -case 'C': -switch (down) { -case 'G': -return true; -} -break; -case 'T': -switch (down) { -case 'A': -return true; -case 'G': -return true; -} -break; -case 'G': -switch (down) { -case 'C': -return true; -case 'T': -return true; -case 'U': -return true; -} -break; -case 'U': -switch (down) { -case 'A': -return true; -case 'G': -return true; -} -break; -} -return false; -}, "~S,~S"); -c$.completeConsensus = Clazz.defineMethod (c$, "completeConsensus", -function (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, nseq) { -var tval; -var value; -if (consensus == null || consensus.annotations == null || consensus.annotations.length < width) { -return; -}var fmtstr = "%3.1f"; -var precision = 2; -while (nseq > 100) { -precision++; -nseq /= 10; -} -if (precision > 2) { -fmtstr = "%" + (2 + precision) + "." + precision + "f"; -}var fmt = new jalview.util.Format (fmtstr); -for (var i = iStart; i < width; i++) { -var hci; -if (i >= hconsensus.length || ((hci = hconsensus[i]) == null)) { -consensus.annotations[i] = null; -continue; -}value = 0; -var fv; -if (ignoreGapsInConsensusCalculation) { -fv = hci.get ("N"); -} else { -fv = hci.get ("G"); -}if (fv == null) { -consensus.annotations[i] = null; -continue; -}value = fv.floatValue (); -var maxRes = hci.get ("R").toString (); -var mouseOver = hci.get ("R") + " "; -if (maxRes.length > 1) { -mouseOver = "[" + maxRes + "] "; -maxRes = "+"; -}var profile = hci.get ("P"); -var pairs = hci.get ("B"); -if (pairs != null && includeAllConsSymbols) { -mouseOver = ""; -var ca = javajs.util.AU.newInt2 (625); -var vl = Clazz.newFloatArray (625, 0); -var x = 0; -for (var c = 65; c < 90; c++) { -for (var d = 65; d < 90; d++) { -ca[x] = Clazz.newIntArray (-1, [c, d]); -vl[x] = pairs[c][d]; -x++; -} -} -jalview.util.QuickSort.sortFloatObject (vl, ca); -var p = 0; -var divisor = profile[1][ignoreGapsInConsensusCalculation ? 1 : 0]; -for (var c = 624; c > 0; c--) { -if (vl[c] > 0) { -tval = (vl[c] * 100 / divisor); -mouseOver += ((p == 0) ? "" : "; ") + String.fromCharCode (ca[c][0]) + String.fromCharCode (ca[c][1]) + " " + fmt.formDouble (tval) + "%"; -p++; -}} -} else { -mouseOver += (fmt.formDouble (value) + "%"); -}consensus.annotations[i] = new jalview.datamodel.Annotation (maxRes, mouseOver, ' ', value); -} -}, "jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~B,~B,~N"); -c$.extractProfile = Clazz.defineMethod (c$, "extractProfile", -function (hconsensus, ignoreGapsInConsensusCalculation) { -var rtnval = Clazz.newIntArray (74, 0); -var profile = hconsensus.get ("P"); -var pairs = hconsensus.get ("B"); -if (profile == null) { -return null; -}var ca = javajs.util.AU.newInt2 (625); -var vl = Clazz.newFloatArray (625, 0); -var x = 0; -for (var c = 65; c < 90; c++) { -for (var d = 65; d < 90; d++) { -ca[x] = Clazz.newIntArray (-1, [c, d]); -vl[x] = pairs[c][d]; -x++; -} -} -jalview.util.QuickSort.sortFloatObject (vl, ca); -var valuesCount = 0; -rtnval[1] = 0; -var offset = 2; -var divisor = profile[1][ignoreGapsInConsensusCalculation ? 1 : 0]; -for (var c = 624; c > 0; c--) { -if (vl[c] > 0) { -rtnval[offset++] = ca[c][0]; -rtnval[offset++] = ca[c][1]; -rtnval[offset] = Clazz.floatToInt (vl[c] * 100 / divisor); -rtnval[1] += rtnval[offset++]; -valuesCount++; -}} -rtnval[0] = valuesCount; -var result = Clazz.newIntArray (rtnval.length + 1, 0); -result[0] = 1; -System.arraycopy (rtnval, 0, result, 1, rtnval.length); -return result; -}, "java.util.Hashtable,~B"); -Clazz.defineStatics (c$, -"STRUCTURE_PROFILE_LENGTH", 74, -"MAXCOUNT", "C", -"MAXRESIDUE", "R", -"PID_GAPS", "G", -"PID_NOGAPS", "N", -"PROFILE", "P", -"PAIRPROFILE", "B"); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (null, "jalview.analysis.StructureFrequency", ["jalview.datamodel.Annotation", "jalview.util.Format", "$.QuickSort", "java.lang.Float", "java.util.Hashtable", "javajs.util.AU"], function () { +c$ = Clazz.declareType (jalview.analysis, "StructureFrequency"); +c$.findPair = Clazz.defineMethod (c$, "findPair", +function (pairs, indice) { +for (var i = 0; i < pairs.length; i++) { +if (pairs[i].getBegin () == indice) { +return pairs[i].getEnd (); +}} +return -1; +}, "~A,~N"); +c$.calculate = Clazz.defineMethod (c$, "calculate", +function (sequences, start, end, result, profile, rnaStruc) { +var residueHash; +var maxResidue; +var struc = rnaStruc.getRNAStruc ().toCharArray (); +var rna = rnaStruc._rnasecstr; +var c; +var s; +var cEnd; +var count = 0; +var nonGap = 0; +var i; +var bpEnd = -1; +var j; +var jSize = sequences.length; +var values; +var pairs; +var percentage; +var wooble = true; +for (i = start; i < end; i++) { +residueHash = new java.util.Hashtable (); +maxResidue = "-"; +values = Clazz.newIntArray (255, 0); +pairs = Clazz.newIntArray (255, 255, 0); +bpEnd = -1; +if (i < struc.length) { +s = struc[i]; +} else { +s = '-'; +}if (s == '.' || s == ' ') { +s = '-'; +}if (s != '(' && s != '[') { +if (s == '-') { +values['-'.charCodeAt (0)]++; +}} else { +bpEnd = jalview.analysis.StructureFrequency.findPair (rna, i); +if (bpEnd > -1) { +for (j = 0; j < jSize; j++) { +if (sequences[j] == null) { +System.err.println ("WARNING: Consensus skipping null sequence - possible race condition."); +continue; +}c = sequences[j].getCharAt (i); +if (c == '.' || c == ' ') { +c = '-'; +}if (c == '-') { +values['-'.charCodeAt (0)]++; +continue; +}cEnd = sequences[j].getCharAt (bpEnd); +if (jalview.analysis.StructureFrequency.checkBpType (c, cEnd) == true) { +values['('.charCodeAt (0)]++; +maxResidue = "("; +wooble = true; +}if (jalview.analysis.StructureFrequency.checkBpType (c, cEnd) == false) { +wooble = false; +values['['.charCodeAt (0)]++; +maxResidue = "["; +}pairs[c.charCodeAt (0)][cEnd.charCodeAt (0)]++; +} +}}if (profile) { +residueHash.put ("P", Clazz.newArray (-1, [values, Clazz.newIntArray (-1, [jSize, (jSize - values['-'.charCodeAt (0)])])])); +residueHash.put ("B", pairs); +}if (wooble == true) { +count = values['('.charCodeAt (0)]; +}if (wooble == false) { +count = values['['.charCodeAt (0)]; +}residueHash.put ("C", new Integer (count)); +residueHash.put ("R", maxResidue); +percentage = (count * 100) / jSize; +residueHash.put ("G", new Float (percentage)); +if (result[i] == null) { +result[i] = residueHash; +}if (bpEnd > 0) { +values[')'.charCodeAt (0)] = values['('.charCodeAt (0)]; +values[']'.charCodeAt (0)] = values['['.charCodeAt (0)]; +values['('.charCodeAt (0)] = 0; +values['['.charCodeAt (0)] = 0; +residueHash = new java.util.Hashtable (); +if (wooble == true) { +maxResidue = ")"; +}if (wooble == false) { +maxResidue = "]"; +}if (profile) { +residueHash.put ("P", Clazz.newArray (-1, [values, Clazz.newIntArray (-1, [jSize, (jSize - values['-'.charCodeAt (0)])])])); +residueHash.put ("B", pairs); +}residueHash.put ("C", new Integer (count)); +residueHash.put ("R", maxResidue); +percentage = (count * 100) / jSize; +residueHash.put ("G", new Float (percentage)); +result[bpEnd] = residueHash; +}} +}, "~A,~N,~N,~A,~B,jalview.datamodel.AlignmentAnnotation"); +c$.checkBpType = Clazz.defineMethod (c$, "checkBpType", +function (up, down) { +if (up > 'Z') { +up = String.fromCharCode (up.charCodeAt (0) - 32); +}if (down > 'Z') { +down = String.fromCharCode (down.charCodeAt (0) - 32); +}switch (up) { +case 'A': +switch (down) { +case 'T': +return true; +case 'U': +return true; +} +break; +case 'C': +switch (down) { +case 'G': +return true; +} +break; +case 'T': +switch (down) { +case 'A': +return true; +case 'G': +return true; +} +break; +case 'G': +switch (down) { +case 'C': +return true; +case 'T': +return true; +case 'U': +return true; +} +break; +case 'U': +switch (down) { +case 'A': +return true; +case 'G': +return true; +} +break; +} +return false; +}, "~S,~S"); +c$.completeConsensus = Clazz.defineMethod (c$, "completeConsensus", +function (consensus, hconsensus, iStart, width, ignoreGapsInConsensusCalculation, includeAllConsSymbols, nseq) { +var tval; +var value; +if (consensus == null || consensus.annotations == null || consensus.annotations.length < width) { +return; +}var fmtstr = "%3.1f"; +var precision = 2; +while (nseq > 100) { +precision++; +nseq /= 10; +} +if (precision > 2) { +fmtstr = "%" + (2 + precision) + "." + precision + "f"; +}var fmt = new jalview.util.Format (fmtstr); +for (var i = iStart; i < width; i++) { +var hci; +if (i >= hconsensus.length || ((hci = hconsensus[i]) == null)) { +consensus.annotations[i] = null; +continue; +}value = 0; +var fv; +if (ignoreGapsInConsensusCalculation) { +fv = hci.get ("N"); +} else { +fv = hci.get ("G"); +}if (fv == null) { +consensus.annotations[i] = null; +continue; +}value = fv.floatValue (); +var maxRes = hci.get ("R").toString (); +var mouseOver = hci.get ("R") + " "; +if (maxRes.length > 1) { +mouseOver = "[" + maxRes + "] "; +maxRes = "+"; +}var profile = hci.get ("P"); +var pairs = hci.get ("B"); +if (pairs != null && includeAllConsSymbols) { +mouseOver = ""; +var ca = javajs.util.AU.newInt2 (625); +var vl = Clazz.newFloatArray (625, 0); +var x = 0; +for (var c = 65; c < 90; c++) { +for (var d = 65; d < 90; d++) { +ca[x] = Clazz.newIntArray (-1, [c, d]); +vl[x] = pairs[c][d]; +x++; +} +} +jalview.util.QuickSort.sortFloatObject (vl, ca); +var p = 0; +var divisor = profile[1][ignoreGapsInConsensusCalculation ? 1 : 0]; +for (var c = 624; c > 0; c--) { +if (vl[c] > 0) { +tval = (vl[c] * 100 / divisor); +mouseOver += ((p == 0) ? "" : "; ") + String.fromCharCode (ca[c][0]) + String.fromCharCode (ca[c][1]) + " " + fmt.formDouble (tval) + "%"; +p++; +}} +} else { +mouseOver += (fmt.formDouble (value) + "%"); +}consensus.annotations[i] = new jalview.datamodel.Annotation (maxRes, mouseOver, ' ', value); +} +}, "jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~B,~B,~N"); +c$.extractProfile = Clazz.defineMethod (c$, "extractProfile", +function (hconsensus, ignoreGapsInConsensusCalculation) { +var rtnval = Clazz.newIntArray (74, 0); +var profile = hconsensus.get ("P"); +var pairs = hconsensus.get ("B"); +if (profile == null) { +return null; +}var ca = javajs.util.AU.newInt2 (625); +var vl = Clazz.newFloatArray (625, 0); +var x = 0; +for (var c = 65; c < 90; c++) { +for (var d = 65; d < 90; d++) { +ca[x] = Clazz.newIntArray (-1, [c, d]); +vl[x] = pairs[c][d]; +x++; +} +} +jalview.util.QuickSort.sortFloatObject (vl, ca); +var valuesCount = 0; +rtnval[1] = 0; +var offset = 2; +var divisor = profile[1][ignoreGapsInConsensusCalculation ? 1 : 0]; +for (var c = 624; c > 0; c--) { +if (vl[c] > 0) { +rtnval[offset++] = ca[c][0]; +rtnval[offset++] = ca[c][1]; +rtnval[offset] = Clazz.floatToInt (vl[c] * 100 / divisor); +rtnval[1] += rtnval[offset++]; +valuesCount++; +}} +rtnval[0] = valuesCount; +var result = Clazz.newIntArray (rtnval.length + 1, 0); +result[0] = 1; +System.arraycopy (rtnval, 0, result, 1, rtnval.length); +return result; +}, "java.util.Hashtable,~B"); +Clazz.defineStatics (c$, +"STRUCTURE_PROFILE_LENGTH", 74, +"MAXCOUNT", "C", +"MAXRESIDUE", "R", +"PID_GAPS", "G", +"PID_NOGAPS", "N", +"PROFILE", "P", +"PAIRPROFILE", "B"); +}); diff --git a/bin/jalview/analysis/WUSSParseException.js b/bin/jalview/analysis/WUSSParseException.js index 32861ff..535f6ac 100644 --- a/bin/jalview/analysis/WUSSParseException.js +++ b/bin/jalview/analysis/WUSSParseException.js @@ -1,20 +1,20 @@ -Clazz.declarePackage ("jalview.analysis"); -Clazz.load (["java.lang.Exception"], "jalview.analysis.WUSSParseException", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.problemPos = 0; -Clazz.instantialize (this, arguments); -}, jalview.analysis, "WUSSParseException", Exception); -Clazz.makeConstructor (c$, -function (problemPos) { -this.construct ("Invalid WUSS Notation", problemPos); -}, "~N"); -Clazz.makeConstructor (c$, -function (message, problemPos) { -Clazz.superConstructor (this, jalview.analysis.WUSSParseException, [message + " at or near position " + problemPos]); -this.problemPos = problemPos; -}, "~S,~N"); -Clazz.defineMethod (c$, "getProblemPos", -function () { -return this.problemPos; -}); -}); +Clazz.declarePackage ("jalview.analysis"); +Clazz.load (["java.lang.Exception"], "jalview.analysis.WUSSParseException", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.problemPos = 0; +Clazz.instantialize (this, arguments); +}, jalview.analysis, "WUSSParseException", Exception); +Clazz.makeConstructor (c$, +function (problemPos) { +this.construct ("Invalid WUSS Notation", problemPos); +}, "~N"); +Clazz.makeConstructor (c$, +function (message, problemPos) { +Clazz.superConstructor (this, jalview.analysis.WUSSParseException, [message + " at or near position " + problemPos]); +this.problemPos = problemPos; +}, "~S,~N"); +Clazz.defineMethod (c$, "getProblemPos", +function () { +return this.problemPos; +}); +}); diff --git a/bin/jalview/analysis/package.js b/bin/jalview/analysis/package.js index a23ac21..45e0428 100644 --- a/bin/jalview/analysis/package.js +++ b/bin/jalview/analysis/package.js @@ -1,5 +1,5 @@ -var path = ClazzLoader.getClasspathFor ("jalview.analysis.package"); -path = path.substring (0, path.lastIndexOf ("package.js")); -ClazzLoader.jarClasspath (path + "NJTree.js", [ -"jalview.analysis.Cluster", -"$.NJTree"]); +var path = ClazzLoader.getClasspathFor ("jalview.analysis.package"); +path = path.substring (0, path.lastIndexOf ("package.js")); +ClazzLoader.jarClasspath (path + "NJTree.js", [ +"jalview.analysis.Cluster", +"$.NJTree"]); diff --git a/bin/jalview/analysis/scoremodels/FeatureScoreModel.js b/bin/jalview/analysis/scoremodels/FeatureScoreModel.js index 7e483bd..3e8e57d 100644 --- a/bin/jalview/analysis/scoremodels/FeatureScoreModel.js +++ b/bin/jalview/analysis/scoremodels/FeatureScoreModel.js @@ -1,86 +1,86 @@ -Clazz.declarePackage ("jalview.analysis.scoremodels"); -Clazz.load (["jalview.api.analysis.ScoreModelI", "$.ViewBasedAnalysisI"], "jalview.analysis.scoremodels.FeatureScoreModel", ["jalview.util.Comparison", "java.util.ArrayList", "$.Arrays", "$.Hashtable"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fr = null; -Clazz.instantialize (this, arguments); -}, jalview.analysis.scoremodels, "FeatureScoreModel", null, [jalview.api.analysis.ScoreModelI, jalview.api.analysis.ViewBasedAnalysisI]); -Clazz.overrideMethod (c$, "configureFromAlignmentView", -function (view) { -this.fr = view.cloneFeatureRenderer (); -return true; -}, "jalview.api.AlignmentViewPanel"); -Clazz.overrideMethod (c$, "findDistances", -function (seqData) { -var nofeats = 0; -var dft = java.util.Arrays.asList (this.fr.getDisplayedFeatureTypes ()); -if (dft != null) { -nofeats = dft.size (); -}var sequenceString = seqData.getVisibleAlignment (jalview.util.Comparison.GapChars.charAt (0)).getSequencesArray (); -var noseqs = sequenceString.length; -var cpwidth = seqData.getWidth (); -var distance = Clazz.newFloatArray (noseqs, noseqs, 0); -if (nofeats == 0) { -for (var d, $d = 0, $$d = distance; $d < $$d.length && ((d = $$d[$d]) || true); $d++) { -for (var i = 0; i < d.length; d[i++] = 0) { -;} -} -return distance; -}var max = 0; -for (var cpos = 0; cpos < cpwidth; cpos++) { -var sfap = new java.util.ArrayList (); -for (var i = 0; i < noseqs; i++) { -var types = new java.util.Hashtable (); -var sfs = this.fr.findFeaturesAtRes (sequenceString[i], sequenceString[i].findPosition (cpos)); -for (var sf, $sf = sfs.iterator (); $sf.hasNext () && ((sf = $sf.next ()) || true);) { -types.put (sf.getType (), sf); -} -sfap.add (types); -} -for (var i = 0; i < (noseqs - 1); i++) { -if (cpos == 0) { -distance[i][i] = 0; -}for (var j = i + 1; j < noseqs; j++) { -var sfcommon = 0; -var fi = sfap.get (i); -var fk; -var fj = sfap.get (j); -if (fi.size () > fj.size ()) { -fk = fj; -} else { -fk = fi; -fi = fj; -}for (var k, $k = fi.keySet ().iterator (); $k.hasNext () && ((k = $k.next ()) || true);) { -var sfj = fk.get (k); -if (sfj != null) { -sfcommon++; -}} -distance[i][j] += (fi.size () + fk.size () - 2 * sfcommon); -distance[j][i] += distance[i][j]; -} -} -} -for (var i = 0; i < noseqs; i++) { -for (var j = i + 1; j < noseqs; j++) { -distance[i][j] /= cpwidth; -distance[j][i] = distance[i][j]; -} -} -return distance; -}, "jalview.datamodel.AlignmentView"); -Clazz.overrideMethod (c$, "getName", -function () { -return "Sequence Feature Similarity"; -}); -Clazz.overrideMethod (c$, "isDNA", -function () { -return true; -}); -Clazz.overrideMethod (c$, "isProtein", -function () { -return true; -}); -Clazz.overrideMethod (c$, "toString", -function () { -return "Score between sequences based on hamming distance between binary vectors marking features displayed at each column"; -}); -}); +Clazz.declarePackage ("jalview.analysis.scoremodels"); +Clazz.load (["jalview.api.analysis.ScoreModelI", "$.ViewBasedAnalysisI"], "jalview.analysis.scoremodels.FeatureScoreModel", ["jalview.util.Comparison", "java.util.ArrayList", "$.Arrays", "$.Hashtable"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fr = null; +Clazz.instantialize (this, arguments); +}, jalview.analysis.scoremodels, "FeatureScoreModel", null, [jalview.api.analysis.ScoreModelI, jalview.api.analysis.ViewBasedAnalysisI]); +Clazz.overrideMethod (c$, "configureFromAlignmentView", +function (view) { +this.fr = view.cloneFeatureRenderer (); +return true; +}, "jalview.api.AlignmentViewPanel"); +Clazz.overrideMethod (c$, "findDistances", +function (seqData) { +var nofeats = 0; +var dft = java.util.Arrays.asList (this.fr.getDisplayedFeatureTypes ()); +if (dft != null) { +nofeats = dft.size (); +}var sequenceString = seqData.getVisibleAlignment (jalview.util.Comparison.GapChars.charAt (0)).getSequencesArray (); +var noseqs = sequenceString.length; +var cpwidth = seqData.getWidth (); +var distance = Clazz.newFloatArray (noseqs, noseqs, 0); +if (nofeats == 0) { +for (var d, $d = 0, $$d = distance; $d < $$d.length && ((d = $$d[$d]) || true); $d++) { +for (var i = 0; i < d.length; d[i++] = 0) { +;} +} +return distance; +}var max = 0; +for (var cpos = 0; cpos < cpwidth; cpos++) { +var sfap = new java.util.ArrayList (); +for (var i = 0; i < noseqs; i++) { +var types = new java.util.Hashtable (); +var sfs = this.fr.findFeaturesAtRes (sequenceString[i], sequenceString[i].findPosition (cpos)); +for (var sf, $sf = sfs.iterator (); $sf.hasNext () && ((sf = $sf.next ()) || true);) { +types.put (sf.getType (), sf); +} +sfap.add (types); +} +for (var i = 0; i < (noseqs - 1); i++) { +if (cpos == 0) { +distance[i][i] = 0; +}for (var j = i + 1; j < noseqs; j++) { +var sfcommon = 0; +var fi = sfap.get (i); +var fk; +var fj = sfap.get (j); +if (fi.size () > fj.size ()) { +fk = fj; +} else { +fk = fi; +fi = fj; +}for (var k, $k = fi.keySet ().iterator (); $k.hasNext () && ((k = $k.next ()) || true);) { +var sfj = fk.get (k); +if (sfj != null) { +sfcommon++; +}} +distance[i][j] += (fi.size () + fk.size () - 2 * sfcommon); +distance[j][i] += distance[i][j]; +} +} +} +for (var i = 0; i < noseqs; i++) { +for (var j = i + 1; j < noseqs; j++) { +distance[i][j] /= cpwidth; +distance[j][i] = distance[i][j]; +} +} +return distance; +}, "jalview.datamodel.AlignmentView"); +Clazz.overrideMethod (c$, "getName", +function () { +return "Sequence Feature Similarity"; +}); +Clazz.overrideMethod (c$, "isDNA", +function () { +return true; +}); +Clazz.overrideMethod (c$, "isProtein", +function () { +return true; +}); +Clazz.overrideMethod (c$, "toString", +function () { +return "Score between sequences based on hamming distance between binary vectors marking features displayed at each column"; +}); +}); diff --git a/bin/jalview/analysis/scoremodels/PIDScoreModel.js b/bin/jalview/analysis/scoremodels/PIDScoreModel.js index 09c86e5..0266c33 100644 --- a/bin/jalview/analysis/scoremodels/PIDScoreModel.js +++ b/bin/jalview/analysis/scoremodels/PIDScoreModel.js @@ -1,32 +1,32 @@ -Clazz.declarePackage ("jalview.analysis.scoremodels"); -Clazz.load (["jalview.api.analysis.ScoreModelI"], "jalview.analysis.scoremodels.PIDScoreModel", ["jalview.util.Comparison"], function () { -c$ = Clazz.declareType (jalview.analysis.scoremodels, "PIDScoreModel", null, jalview.api.analysis.ScoreModelI); -Clazz.overrideMethod (c$, "findDistances", -function (seqData) { -var sequenceString = seqData.getSequenceStrings (jalview.util.Comparison.GapChars.charAt (0)); -var noseqs = sequenceString.length; -var distance = Clazz.newFloatArray (noseqs, noseqs, 0); -for (var i = 0; i < (noseqs - 1); i++) { -for (var j = i; j < noseqs; j++) { -if (j == i) { -distance[i][i] = 0; -} else { -distance[i][j] = 100 - jalview.util.Comparison.PID (sequenceString[i], sequenceString[j]); -distance[j][i] = distance[i][j]; -}} -} -return distance; -}, "jalview.datamodel.AlignmentView"); -Clazz.overrideMethod (c$, "getName", -function () { -return "PID"; -}); -Clazz.overrideMethod (c$, "isDNA", -function () { -return true; -}); -Clazz.overrideMethod (c$, "isProtein", -function () { -return true; -}); -}); +Clazz.declarePackage ("jalview.analysis.scoremodels"); +Clazz.load (["jalview.api.analysis.ScoreModelI"], "jalview.analysis.scoremodels.PIDScoreModel", ["jalview.util.Comparison"], function () { +c$ = Clazz.declareType (jalview.analysis.scoremodels, "PIDScoreModel", null, jalview.api.analysis.ScoreModelI); +Clazz.overrideMethod (c$, "findDistances", +function (seqData) { +var sequenceString = seqData.getSequenceStrings (jalview.util.Comparison.GapChars.charAt (0)); +var noseqs = sequenceString.length; +var distance = Clazz.newFloatArray (noseqs, noseqs, 0); +for (var i = 0; i < (noseqs - 1); i++) { +for (var j = i; j < noseqs; j++) { +if (j == i) { +distance[i][i] = 0; +} else { +distance[i][j] = 100 - jalview.util.Comparison.PID (sequenceString[i], sequenceString[j]); +distance[j][i] = distance[i][j]; +}} +} +return distance; +}, "jalview.datamodel.AlignmentView"); +Clazz.overrideMethod (c$, "getName", +function () { +return "PID"; +}); +Clazz.overrideMethod (c$, "isDNA", +function () { +return true; +}); +Clazz.overrideMethod (c$, "isProtein", +function () { +return true; +}); +}); diff --git a/bin/jalview/analysis/scoremodels/PairwiseSeqScoreModel.js b/bin/jalview/analysis/scoremodels/PairwiseSeqScoreModel.js index 4c1456f..6cfe67a 100644 --- a/bin/jalview/analysis/scoremodels/PairwiseSeqScoreModel.js +++ b/bin/jalview/analysis/scoremodels/PairwiseSeqScoreModel.js @@ -1,39 +1,39 @@ -Clazz.declarePackage ("jalview.analysis.scoremodels"); -Clazz.load (["jalview.api.analysis.ScoreModelI"], "jalview.analysis.scoremodels.PairwiseSeqScoreModel", ["jalview.util.Comparison"], function () { -c$ = Clazz.declareType (jalview.analysis.scoremodels, "PairwiseSeqScoreModel", null, jalview.api.analysis.ScoreModelI); -Clazz.overrideMethod (c$, "findDistances", -function (seqData) { -var sequenceString = seqData.getSequenceStrings (jalview.util.Comparison.GapChars.charAt (0)); -var noseqs = sequenceString.length; -var distance = Clazz.newFloatArray (noseqs, noseqs, 0); -var maxscore = 0; -var end = sequenceString[0].length; -for (var i = 0; i < (noseqs - 1); i++) { -for (var j = i; j < noseqs; j++) { -var score = 0; -for (var k = 0; k < end; k++) { -try { -score += this.getPairwiseScore (sequenceString[i].charAt (k), sequenceString[j].charAt (k)); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("err creating " + this.getName () + " tree"); -ex.printStackTrace (); -} else { -throw ex; -} -} -} -distance[i][j] = score; -if (score > maxscore) { -maxscore = score; -}} -} -for (var i = 0; i < (noseqs - 1); i++) { -for (var j = i; j < noseqs; j++) { -distance[i][j] = maxscore - distance[i][j]; -distance[j][i] = distance[i][j]; -} -} -return distance; -}, "jalview.datamodel.AlignmentView"); -}); +Clazz.declarePackage ("jalview.analysis.scoremodels"); +Clazz.load (["jalview.api.analysis.ScoreModelI"], "jalview.analysis.scoremodels.PairwiseSeqScoreModel", ["jalview.util.Comparison"], function () { +c$ = Clazz.declareType (jalview.analysis.scoremodels, "PairwiseSeqScoreModel", null, jalview.api.analysis.ScoreModelI); +Clazz.overrideMethod (c$, "findDistances", +function (seqData) { +var sequenceString = seqData.getSequenceStrings (jalview.util.Comparison.GapChars.charAt (0)); +var noseqs = sequenceString.length; +var distance = Clazz.newFloatArray (noseqs, noseqs, 0); +var maxscore = 0; +var end = sequenceString[0].length; +for (var i = 0; i < (noseqs - 1); i++) { +for (var j = i; j < noseqs; j++) { +var score = 0; +for (var k = 0; k < end; k++) { +try { +score += this.getPairwiseScore (sequenceString[i].charAt (k), sequenceString[j].charAt (k)); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("err creating " + this.getName () + " tree"); +ex.printStackTrace (); +} else { +throw ex; +} +} +} +distance[i][j] = score; +if (score > maxscore) { +maxscore = score; +}} +} +for (var i = 0; i < (noseqs - 1); i++) { +for (var j = i; j < noseqs; j++) { +distance[i][j] = maxscore - distance[i][j]; +distance[j][i] = distance[i][j]; +} +} +return distance; +}, "jalview.datamodel.AlignmentView"); +}); diff --git a/bin/jalview/analysis/scoremodels/SWScoreModel.js b/bin/jalview/analysis/scoremodels/SWScoreModel.js index e2e0eef..06ef966 100644 --- a/bin/jalview/analysis/scoremodels/SWScoreModel.js +++ b/bin/jalview/analysis/scoremodels/SWScoreModel.js @@ -1,45 +1,45 @@ -Clazz.declarePackage ("jalview.analysis.scoremodels"); -Clazz.load (["jalview.api.analysis.ScoreModelI"], "jalview.analysis.scoremodels.SWScoreModel", ["jalview.analysis.AlignSeq", "jalview.util.Comparison"], function () { -c$ = Clazz.declareType (jalview.analysis.scoremodels, "SWScoreModel", null, jalview.api.analysis.ScoreModelI); -Clazz.overrideMethod (c$, "findDistances", -function (seqData) { -var sequenceString = seqData.getVisibleAlignment (jalview.util.Comparison.GapChars.charAt (0)).getSequencesArray (); -var noseqs = sequenceString.length; -var distance = Clazz.newFloatArray (noseqs, noseqs, 0); -var max = -1; -for (var i = 0; i < (noseqs - 1); i++) { -for (var j = i; j < noseqs; j++) { -var as = new jalview.analysis.AlignSeq (sequenceString[i], sequenceString[j], seqData.isNa () ? "dna" : "pep"); -as.calcScoreMatrix (); -as.traceAlignment (); -as.printAlignment (System.out); -distance[i][j] = as.maxscore; -if (max < distance[i][j]) { -max = distance[i][j]; -}} -} -for (var i = 0; i < (noseqs - 1); i++) { -for (var j = i; j < noseqs; j++) { -distance[i][j] = max - distance[i][j]; -distance[j][i] = distance[i][j]; -} -} -return distance; -}, "jalview.datamodel.AlignmentView"); -Clazz.overrideMethod (c$, "getName", -function () { -return "Smith Waterman Score"; -}); -Clazz.overrideMethod (c$, "isDNA", -function () { -return true; -}); -Clazz.overrideMethod (c$, "isProtein", -function () { -return true; -}); -Clazz.overrideMethod (c$, "toString", -function () { -return "Score between two sequences aligned with Smith Waterman with default Peptide/Nucleotide matrix"; -}); -}); +Clazz.declarePackage ("jalview.analysis.scoremodels"); +Clazz.load (["jalview.api.analysis.ScoreModelI"], "jalview.analysis.scoremodels.SWScoreModel", ["jalview.analysis.AlignSeq", "jalview.util.Comparison"], function () { +c$ = Clazz.declareType (jalview.analysis.scoremodels, "SWScoreModel", null, jalview.api.analysis.ScoreModelI); +Clazz.overrideMethod (c$, "findDistances", +function (seqData) { +var sequenceString = seqData.getVisibleAlignment (jalview.util.Comparison.GapChars.charAt (0)).getSequencesArray (); +var noseqs = sequenceString.length; +var distance = Clazz.newFloatArray (noseqs, noseqs, 0); +var max = -1; +for (var i = 0; i < (noseqs - 1); i++) { +for (var j = i; j < noseqs; j++) { +var as = new jalview.analysis.AlignSeq (sequenceString[i], sequenceString[j], seqData.isNa () ? "dna" : "pep"); +as.calcScoreMatrix (); +as.traceAlignment (); +as.printAlignment (System.out); +distance[i][j] = as.maxscore; +if (max < distance[i][j]) { +max = distance[i][j]; +}} +} +for (var i = 0; i < (noseqs - 1); i++) { +for (var j = i; j < noseqs; j++) { +distance[i][j] = max - distance[i][j]; +distance[j][i] = distance[i][j]; +} +} +return distance; +}, "jalview.datamodel.AlignmentView"); +Clazz.overrideMethod (c$, "getName", +function () { +return "Smith Waterman Score"; +}); +Clazz.overrideMethod (c$, "isDNA", +function () { +return true; +}); +Clazz.overrideMethod (c$, "isProtein", +function () { +return true; +}); +Clazz.overrideMethod (c$, "toString", +function () { +return "Score between two sequences aligned with Smith Waterman with default Peptide/Nucleotide matrix"; +}); +}); diff --git a/bin/jalview/api/AlignCalcManagerI.js b/bin/jalview/api/AlignCalcManagerI.js index 231cd97..47dd8f5 100644 --- a/bin/jalview/api/AlignCalcManagerI.js +++ b/bin/jalview/api/AlignCalcManagerI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "AlignCalcManagerI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "AlignCalcManagerI"); diff --git a/bin/jalview/api/AlignCalcWorkerI.js b/bin/jalview/api/AlignCalcWorkerI.js index 77fffcc..cf7fe41 100644 --- a/bin/jalview/api/AlignCalcWorkerI.js +++ b/bin/jalview/api/AlignCalcWorkerI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "AlignCalcWorkerI", Runnable); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "AlignCalcWorkerI", Runnable); diff --git a/bin/jalview/api/AlignExportSettingI.js b/bin/jalview/api/AlignExportSettingI.js index 512e454..d26a509 100644 --- a/bin/jalview/api/AlignExportSettingI.js +++ b/bin/jalview/api/AlignExportSettingI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "AlignExportSettingI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "AlignExportSettingI"); diff --git a/bin/jalview/api/AlignViewControllerGuiI.js b/bin/jalview/api/AlignViewControllerGuiI.js index 8dd9d75..b132c71 100644 --- a/bin/jalview/api/AlignViewControllerGuiI.js +++ b/bin/jalview/api/AlignViewControllerGuiI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "AlignViewControllerGuiI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "AlignViewControllerGuiI"); diff --git a/bin/jalview/api/AlignViewControllerI.js b/bin/jalview/api/AlignViewControllerI.js index 4dbfb00..9851769 100644 --- a/bin/jalview/api/AlignViewControllerI.js +++ b/bin/jalview/api/AlignViewControllerI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "AlignViewControllerI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "AlignViewControllerI"); diff --git a/bin/jalview/api/AlignViewportI.js b/bin/jalview/api/AlignViewportI.js index c65c3f7..b8de508 100644 --- a/bin/jalview/api/AlignViewportI.js +++ b/bin/jalview/api/AlignViewportI.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.load (["jalview.api.ViewStyleI"], "jalview.api.AlignViewportI", null, function () { -Clazz.declareInterface (jalview.api, "AlignViewportI", jalview.api.ViewStyleI); -}); +Clazz.declarePackage ("jalview.api"); +Clazz.load (["jalview.api.ViewStyleI"], "jalview.api.AlignViewportI", null, function () { +Clazz.declareInterface (jalview.api, "AlignViewportI", jalview.api.ViewStyleI); +}); diff --git a/bin/jalview/api/AlignmentViewPanel.js b/bin/jalview/api/AlignmentViewPanel.js index 5e0dc22..1a1598e 100644 --- a/bin/jalview/api/AlignmentViewPanel.js +++ b/bin/jalview/api/AlignmentViewPanel.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.load (["jalview.api.OOMHandlerI"], "jalview.api.AlignmentViewPanel", null, function () { -Clazz.declareInterface (jalview.api, "AlignmentViewPanel", jalview.api.OOMHandlerI); -}); +Clazz.declarePackage ("jalview.api"); +Clazz.load (["jalview.api.OOMHandlerI"], "jalview.api.AlignmentViewPanel", null, function () { +Clazz.declareInterface (jalview.api, "AlignmentViewPanel", jalview.api.OOMHandlerI); +}); diff --git a/bin/jalview/api/ComplexAlignFile.js b/bin/jalview/api/ComplexAlignFile.js index c15e9ab..7e6e24d 100644 --- a/bin/jalview/api/ComplexAlignFile.js +++ b/bin/jalview/api/ComplexAlignFile.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "ComplexAlignFile"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "ComplexAlignFile"); diff --git a/bin/jalview/api/FeatureRenderer.js b/bin/jalview/api/FeatureRenderer.js index e845bcd..cce7fb2 100644 --- a/bin/jalview/api/FeatureRenderer.js +++ b/bin/jalview/api/FeatureRenderer.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "FeatureRenderer"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "FeatureRenderer"); diff --git a/bin/jalview/api/FeatureSettingsControllerI.js b/bin/jalview/api/FeatureSettingsControllerI.js index 6785f01..d7e477c 100644 --- a/bin/jalview/api/FeatureSettingsControllerI.js +++ b/bin/jalview/api/FeatureSettingsControllerI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "FeatureSettingsControllerI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "FeatureSettingsControllerI"); diff --git a/bin/jalview/api/FeatureSettingsModelI.js b/bin/jalview/api/FeatureSettingsModelI.js index 0fded11..a01cd0e 100644 --- a/bin/jalview/api/FeatureSettingsModelI.js +++ b/bin/jalview/api/FeatureSettingsModelI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "FeatureSettingsModelI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "FeatureSettingsModelI"); diff --git a/bin/jalview/api/FeaturesDisplayedI.js b/bin/jalview/api/FeaturesDisplayedI.js index 331bf21..c796711 100644 --- a/bin/jalview/api/FeaturesDisplayedI.js +++ b/bin/jalview/api/FeaturesDisplayedI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "FeaturesDisplayedI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "FeaturesDisplayedI"); diff --git a/bin/jalview/api/OOMHandlerI.js b/bin/jalview/api/OOMHandlerI.js index 1f61be8..48ab467 100644 --- a/bin/jalview/api/OOMHandlerI.js +++ b/bin/jalview/api/OOMHandlerI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "OOMHandlerI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "OOMHandlerI"); diff --git a/bin/jalview/api/RotatableCanvasI.js b/bin/jalview/api/RotatableCanvasI.js index e582e4c..ccaa5b8 100644 --- a/bin/jalview/api/RotatableCanvasI.js +++ b/bin/jalview/api/RotatableCanvasI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "RotatableCanvasI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "RotatableCanvasI"); diff --git a/bin/jalview/api/SequenceRenderer.js b/bin/jalview/api/SequenceRenderer.js index 247757d..ce4be46 100644 --- a/bin/jalview/api/SequenceRenderer.js +++ b/bin/jalview/api/SequenceRenderer.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "SequenceRenderer"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "SequenceRenderer"); diff --git a/bin/jalview/api/SequenceStructureBinding.js b/bin/jalview/api/SequenceStructureBinding.js index 4eee259..f1a45f3 100644 --- a/bin/jalview/api/SequenceStructureBinding.js +++ b/bin/jalview/api/SequenceStructureBinding.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "SequenceStructureBinding"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "SequenceStructureBinding"); diff --git a/bin/jalview/api/SplitContainerI.js b/bin/jalview/api/SplitContainerI.js index eb0b347..03965d8 100644 --- a/bin/jalview/api/SplitContainerI.js +++ b/bin/jalview/api/SplitContainerI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "SplitContainerI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "SplitContainerI"); diff --git a/bin/jalview/api/StructureSelectionManagerProvider.js b/bin/jalview/api/StructureSelectionManagerProvider.js index e65f1a5..a051fb2 100644 --- a/bin/jalview/api/StructureSelectionManagerProvider.js +++ b/bin/jalview/api/StructureSelectionManagerProvider.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "StructureSelectionManagerProvider"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "StructureSelectionManagerProvider"); diff --git a/bin/jalview/api/ViewStyleI.js b/bin/jalview/api/ViewStyleI.js index ea7a773..9838149 100644 --- a/bin/jalview/api/ViewStyleI.js +++ b/bin/jalview/api/ViewStyleI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api"); -Clazz.declareInterface (jalview.api, "ViewStyleI"); +Clazz.declarePackage ("jalview.api"); +Clazz.declareInterface (jalview.api, "ViewStyleI"); diff --git a/bin/jalview/api/analysis/ScoreModelI.js b/bin/jalview/api/analysis/ScoreModelI.js index 4b5c4fb..56b0281 100644 --- a/bin/jalview/api/analysis/ScoreModelI.js +++ b/bin/jalview/api/analysis/ScoreModelI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api.analysis"); -Clazz.declareInterface (jalview.api.analysis, "ScoreModelI"); +Clazz.declarePackage ("jalview.api.analysis"); +Clazz.declareInterface (jalview.api.analysis, "ScoreModelI"); diff --git a/bin/jalview/api/analysis/ViewBasedAnalysisI.js b/bin/jalview/api/analysis/ViewBasedAnalysisI.js index cbb8c8d..bc5e92d 100644 --- a/bin/jalview/api/analysis/ViewBasedAnalysisI.js +++ b/bin/jalview/api/analysis/ViewBasedAnalysisI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api.analysis"); -Clazz.declareInterface (jalview.api.analysis, "ViewBasedAnalysisI"); +Clazz.declarePackage ("jalview.api.analysis"); +Clazz.declareInterface (jalview.api.analysis, "ViewBasedAnalysisI"); diff --git a/bin/jalview/api/structures/JalviewStructureDisplayI.js b/bin/jalview/api/structures/JalviewStructureDisplayI.js index 643feb8..2512221 100644 --- a/bin/jalview/api/structures/JalviewStructureDisplayI.js +++ b/bin/jalview/api/structures/JalviewStructureDisplayI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.api.structures"); -Clazz.declareInterface (jalview.api.structures, "JalviewStructureDisplayI"); +Clazz.declarePackage ("jalview.api.structures"); +Clazz.declareInterface (jalview.api.structures, "JalviewStructureDisplayI"); diff --git a/bin/jalview/appletgui/APopupMenu.js b/bin/jalview/appletgui/APopupMenu.js index 1e89852..eac223b 100644 --- a/bin/jalview/appletgui/APopupMenu.js +++ b/bin/jalview/appletgui/APopupMenu.js @@ -1,797 +1,797 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.PopupMenu", "java.awt.event.ActionListener", "$.ItemListener", "awt2swing.CheckboxMenuItem", "$.Menu", "$.MenuItem", "jalview.util.MessageManager"], "jalview.appletgui.APopupMenu", ["awt2swing.Frame", "jalview.analysis.AAFrequency", "$.AlignmentAnnotationUtils", "$.AlignmentUtils", "$.Conservation", "jalview.appletgui.AppletJmol", "$.CutAndPasteTransfer", "$.EditNameDialog", "$.SliderPanel", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.commands.ChangeCaseCommand", "$.EditCommand", "jalview.datamodel.SequenceFeature", "jalview.io.AppletFormatAdapter", "$.SequenceAnnotationReport", "jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.ResidueProperties", "$.StrandColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.ZappoColourScheme", "jalview.util.DBRefUtils", "$.UrlLink", "java.lang.StringBuffer", "$.StringBuilder", "java.util.Arrays", "$.Collections", "$.LinkedHashMap", "$.TreeMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.groupMenu = null; -this.editGroupName = null; -this.clustalColour = null; -this.zappoColour = null; -this.taylorColour = null; -this.hydrophobicityColour = null; -this.helixColour = null; -this.strandColour = null; -this.turnColour = null; -this.buriedColour = null; -this.abovePIDColour = null; -this.userDefinedColour = null; -this.PIDColour = null; -this.BLOSUM62Colour = null; -this.noColourmenuItem = null; -this.conservationMenuItem = null; -this.ap = null; -this.unGroupMenuItem = null; -this.createGroupMenuItem = null; -this.nucleotideMenuItem = null; -this.colourMenu = null; -this.showBoxes = null; -this.showText = null; -this.showColourText = null; -this.displayNonconserved = null; -this.seqShowAnnotationsMenu = null; -this.seqHideAnnotationsMenu = null; -this.seqAddReferenceAnnotations = null; -this.groupShowAnnotationsMenu = null; -this.groupHideAnnotationsMenu = null; -this.groupAddReferenceAnnotations = null; -this.editMenu = null; -this.copy = null; -this.cut = null; -this.toUpper = null; -this.toLower = null; -this.toggleCase = null; -this.outputmenu = null; -this.seqMenu = null; -this.pdb = null; -this.hideSeqs = null; -this.repGroup = null; -this.sequenceName = null; -this.sequenceFeature = null; -this.editSequence = null; -this.sequenceDetails = null; -this.selSeqDetails = null; -this.makeReferenceSeq = null; -this.seq = null; -this.revealAll = null; -this.revealSeq = null; -this.revealSeq_index = -1; -this.menu1 = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "APopupMenu", awt2swing.PopupMenu, [java.awt.event.ActionListener, java.awt.event.ItemListener]); -Clazz.prepareFields (c$, function () { -this.groupMenu = new awt2swing.Menu (); -this.editGroupName = new awt2swing.MenuItem (); -this.clustalColour = new awt2swing.MenuItem (); -this.zappoColour = new awt2swing.MenuItem (); -this.taylorColour = new awt2swing.MenuItem (); -this.hydrophobicityColour = new awt2swing.MenuItem (); -this.helixColour = new awt2swing.MenuItem (); -this.strandColour = new awt2swing.MenuItem (); -this.turnColour = new awt2swing.MenuItem (); -this.buriedColour = new awt2swing.MenuItem (); -this.abovePIDColour = new awt2swing.CheckboxMenuItem (); -this.userDefinedColour = new awt2swing.MenuItem (); -this.PIDColour = new awt2swing.MenuItem (); -this.BLOSUM62Colour = new awt2swing.MenuItem (); -this.noColourmenuItem = new awt2swing.MenuItem (); -this.conservationMenuItem = new awt2swing.CheckboxMenuItem (); -this.unGroupMenuItem = new awt2swing.MenuItem (); -this.createGroupMenuItem = new awt2swing.MenuItem (); -this.nucleotideMenuItem = new awt2swing.MenuItem (); -this.colourMenu = new awt2swing.Menu (); -this.showBoxes = new awt2swing.CheckboxMenuItem (); -this.showText = new awt2swing.CheckboxMenuItem (); -this.showColourText = new awt2swing.CheckboxMenuItem (); -this.displayNonconserved = new awt2swing.CheckboxMenuItem (); -this.seqShowAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.show_annotations")); -this.seqHideAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.hide_annotations")); -this.seqAddReferenceAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.add_reference_annotations")); -this.groupShowAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.show_annotations")); -this.groupHideAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.hide_annotations")); -this.groupAddReferenceAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.add_reference_annotations")); -this.editMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.edit")); -this.copy = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.copy")); -this.cut = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.cut")); -this.toUpper = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.to_upper_case")); -this.toLower = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.to_lower_case")); -this.toggleCase = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.toggle_case")); -this.outputmenu = new awt2swing.Menu (); -this.seqMenu = new awt2swing.Menu (); -this.pdb = new awt2swing.MenuItem (); -this.hideSeqs = new awt2swing.MenuItem (); -this.repGroup = new awt2swing.MenuItem (); -this.sequenceName = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.edit_name_description")); -this.sequenceFeature = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.create_sequence_feature")); -this.editSequence = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.edit_sequence")); -this.sequenceDetails = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sequence_details") + "..."); -this.selSeqDetails = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sequence_details") + "..."); -this.makeReferenceSeq = new awt2swing.MenuItem (); -this.revealAll = new awt2swing.MenuItem (); -this.revealSeq = new awt2swing.MenuItem (); -this.menu1 = new awt2swing.Menu (); -}); -Clazz.makeConstructor (c$, -function (apanel, seq, links) { -Clazz.superConstructor (this, jalview.appletgui.APopupMenu, []); -this.ap = apanel; -this.seq = seq; -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -for (var i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { -var item = new awt2swing.MenuItem (jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); -item.addActionListener (this); -this.outputmenu.add (item); -} -this.buildAnnotationSubmenus (); -var sg = this.ap.av.getSelectionGroup (); -if (sg != null && sg.getSize () > 0) { -this.editGroupName.setLabel (jalview.util.MessageManager.formatMessage ("label.name_param", Clazz.newArray (-1, [sg.getName ()]))); -this.showText.setState (sg.getDisplayText ()); -this.showColourText.setState (sg.getColourText ()); -this.showBoxes.setState (sg.getDisplayBoxes ()); -this.displayNonconserved.setState (sg.getShowNonconserved ()); -if (!this.ap.av.getAlignment ().getGroups ().contains (sg)) { -this.menu1.setLabel (jalview.util.MessageManager.getString ("action.edit_new_group")); -this.groupMenu.remove (this.unGroupMenuItem); -} else { -this.menu1.setLabel (jalview.util.MessageManager.getString ("action.edit_group")); -this.groupMenu.remove (this.createGroupMenuItem); -}} else { -this.remove (this.hideSeqs); -this.remove (this.groupMenu); -}if (links != null && links.size () > 0) { -var linkMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.link")); -for (var i = 0; i < links.size (); i++) { -var link = links.elementAt (i); -var urlLink = new jalview.util.UrlLink (link); -if (!urlLink.isValid ()) { -System.err.println (urlLink.getInvalidMessage ()); -continue; -}var target = urlLink.getTarget (); -var label = urlLink.getLabel (); -if (seq != null && urlLink.isDynamic ()) { -var dbr = jalview.util.DBRefUtils.selectRefs (seq.getDBRef (), Clazz.newArray (-1, [target])); -var id = seq.getName (); -var descr = seq.getDescription (); -if (descr != null && descr.length < 1) { -descr = null; -}if (dbr != null) { -for (var r = 0; r < dbr.length; r++) { -if (id != null && dbr[r].getAccessionId ().equals (id)) { -id = null; -}var urls = urlLink.makeUrls (dbr[r].getAccessionId (), true); -if (urls != null) { -for (var u = 0; u < urls.length; u += 2) { -this.addshowLink (linkMenu, label + "|" + urls[u], urls[u + 1]); -} -}} -}if (id != null) { -var urls = urlLink.makeUrls (id, true); -if (urls != null) { -for (var u = 0; u < urls.length; u += 2) { -this.addshowLink (linkMenu, label, urls[u + 1]); -} -}}if (descr != null && urlLink.getRegexReplace () != null) { -var urls = urlLink.makeUrls (descr, true); -if (urls != null) { -for (var u = 0; u < urls.length; u += 2) { -this.addshowLink (linkMenu, label, urls[u + 1]); -} -}}} else { -this.addshowLink (linkMenu, target, urlLink.getUrl_prefix ()); -}} -if (linkMenu.getItemCount () > 0) { -if (seq != null) { -this.seqMenu.add (linkMenu); -} else { -this.add (linkMenu); -}}}if (seq != null) { -this.seqMenu.setLabel (seq.getName ()); -if (seq === this.ap.av.getAlignment ().getSeqrep ()) { -this.makeReferenceSeq.setLabel (jalview.util.MessageManager.getString ("action.unmark_as_reference")); -} else { -this.makeReferenceSeq.setLabel (jalview.util.MessageManager.getString ("action.set_as_reference")); -}this.repGroup.setLabel (jalview.util.MessageManager.formatMessage ("label.represent_group_with", Clazz.newArray (-1, [seq.getName ()]))); -} else { -this.remove (this.seqMenu); -}if (!this.ap.av.hasHiddenRows ()) { -this.remove (this.revealAll); -this.remove (this.revealSeq); -} else { -var index = this.ap.av.getAlignment ().findIndex (seq); -if (this.ap.av.adjustForHiddenSeqs (index) - this.ap.av.adjustForHiddenSeqs (index - 1) > 1) { -this.revealSeq_index = index; -} else { -this.remove (this.revealSeq); -}}}, "jalview.appletgui.AlignmentPanel,jalview.datamodel.SequenceI,java.util.Vector"); -Clazz.defineMethod (c$, "buildAnnotationSubmenus", -($fz = function () { -var selectedSequence = (this.seq == null ? java.util.Collections.emptyList () : java.util.Arrays.asList ([this.seq])); -this.buildAnnotationTypesMenus (this.seqShowAnnotationsMenu, this.seqHideAnnotationsMenu, selectedSequence); -this.configureReferenceAnnotationsMenu (this.seqAddReferenceAnnotations, selectedSequence); -var selectedGroup = (this.ap.av.getSelectionGroup () == null ? java.util.Collections.emptyList () : this.ap.av.getSelectionGroup ().getSequences ()); -this.buildAnnotationTypesMenus (this.groupShowAnnotationsMenu, this.groupHideAnnotationsMenu, selectedGroup); -this.configureReferenceAnnotationsMenu (this.groupAddReferenceAnnotations, selectedGroup); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "configureReferenceAnnotationsMenu", -($fz = function (menuItem, forSequences) { -menuItem.setEnabled (false); -var tipEntries = new java.util.TreeMap (); -var candidates = new java.util.LinkedHashMap (); -var al = this.ap.av.getAlignment (); -jalview.analysis.AlignmentUtils.findAddableReferenceAnnotations (forSequences, tipEntries, candidates, al); -if (!candidates.isEmpty ()) { -var tooltip = new StringBuilder (64); -tooltip.append (jalview.util.MessageManager.getString ("label.add_annotations_for")); -menuItem.setEnabled (true); -menuItem.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$1") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$1, this, Clazz.cloneFinals ("candidates", candidates)))); -}}, $fz.isPrivate = true, $fz), "awt2swing.MenuItem,java.util.List"); -Clazz.defineMethod (c$, "addReferenceAnnotations_actionPerformed", -function (candidates) { -var selectionGroup = this.ap.av.getSelectionGroup (); -var alignment = this.ap.getAlignment (); -jalview.analysis.AlignmentUtils.addReferenceAnnotations (candidates, alignment, selectionGroup); -this.refresh (); -}, "java.util.Map"); -Clazz.defineMethod (c$, "addshowLink", -($fz = function (linkMenu, target, url) { -this.addshowLink (linkMenu, target, target, url); -}, $fz.isPrivate = true, $fz), "awt2swing.Menu,~S,~S"); -Clazz.defineMethod (c$, "addshowLink", -($fz = function (linkMenu, target, label, url) { -var item = new awt2swing.MenuItem (label); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$2") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$2, this, Clazz.cloneFinals ("url", url, "target", target)))); -linkMenu.add (item); -}, $fz.isPrivate = true, $fz), "awt2swing.Menu,~S,~S,~S"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -if (evt.getSource () === this.abovePIDColour) { -this.abovePIDColour_itemStateChanged (); -} else if (evt.getSource () === this.showColourText) { -this.showColourText_itemStateChanged (); -} else if (evt.getSource () === this.showText) { -this.showText_itemStateChanged (); -} else if (evt.getSource () === this.showBoxes) { -this.showBoxes_itemStateChanged (); -} else if (evt.getSource () === this.displayNonconserved) { -this.showNonconserved_itemStateChanged (); -}}, "java.awt.event.ItemEvent"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -var source = evt.getSource (); -if (source === this.clustalColour) { -this.clustalColour_actionPerformed (); -} else if (source === this.zappoColour) { -this.zappoColour_actionPerformed (); -} else if (source === this.taylorColour) { -this.taylorColour_actionPerformed (); -} else if (source === this.hydrophobicityColour) { -this.hydrophobicityColour_actionPerformed (); -} else if (source === this.helixColour) { -this.helixColour_actionPerformed (); -} else if (source === this.strandColour) { -this.strandColour_actionPerformed (); -} else if (source === this.turnColour) { -this.turnColour_actionPerformed (); -} else if (source === this.buriedColour) { -this.buriedColour_actionPerformed (); -} else if (source === this.nucleotideMenuItem) { -this.nucleotideMenuItem_actionPerformed (); -} else if (source === this.userDefinedColour) { -this.userDefinedColour_actionPerformed (); -} else if (source === this.PIDColour) { -this.PIDColour_actionPerformed (); -} else if (source === this.BLOSUM62Colour) { -this.BLOSUM62Colour_actionPerformed (); -} else if (source === this.noColourmenuItem) { -this.noColourmenuItem_actionPerformed (); -} else if (source === this.conservationMenuItem) { -this.conservationMenuItem_itemStateChanged (); -} else if (source === this.unGroupMenuItem) { -this.unGroupMenuItem_actionPerformed (); -} else if (source === this.createGroupMenuItem) { -this.createGroupMenuItem_actionPerformed (); -} else if (source === this.sequenceName) { -this.editName (); -} else if (source === this.makeReferenceSeq) { -this.makeReferenceSeq_actionPerformed (); -} else if (source === this.sequenceDetails) { -this.showSequenceDetails (); -} else if (source === this.selSeqDetails) { -this.showSequenceSelectionDetails (); -} else if (source === this.pdb) { -this.addPDB (); -} else if (source === this.hideSeqs) { -this.hideSequences (false); -} else if (source === this.repGroup) { -this.hideSequences (true); -} else if (source === this.revealSeq) { -this.ap.av.showSequence (this.revealSeq_index); -} else if (source === this.revealAll) { -this.ap.av.showAllHiddenSeqs (); -} else if (source === this.editGroupName) { -var dialog = new jalview.appletgui.EditNameDialog (this.getGroup ().getName (), this.getGroup ().getDescription (), " Group Name", "Group Description", this.ap.alignFrame, "Edit Group Name / Description", 500, 100, true); -if (dialog.accept) { -this.getGroup ().setName (dialog.getName ().$replace (' ', '_')); -this.getGroup ().setDescription (dialog.getDescription ()); -}} else if (source === this.copy) { -this.ap.alignFrame.copy_actionPerformed (); -} else if (source === this.cut) { -this.ap.alignFrame.cut_actionPerformed (); -} else if (source === this.editSequence) { -var sg = this.ap.av.getSelectionGroup (); -if (sg != null) { -if (this.seq == null) { -this.seq = sg.getSequenceAt (0); -}var dialog = new jalview.appletgui.EditNameDialog (this.seq.getSequenceAsString (sg.getStartRes (), sg.getEndRes () + 1), null, "Edit Sequence ", null, this.ap.alignFrame, "Edit Sequence", 500, 100, true); -if (dialog.accept) { -var editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.edit_sequences"), jalview.commands.EditCommand.Action.REPLACE, dialog.getName ().$replace (' ', this.ap.av.getGapCharacter ()), sg.getSequencesAsArray (this.ap.av.getHiddenRepSequences ()), sg.getStartRes (), sg.getEndRes () + 1, this.ap.av.getAlignment ()); -this.ap.alignFrame.addHistoryItem (editCommand); -this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); -}}} else if (source === this.toUpper || source === this.toLower || source === this.toggleCase) { -var sg = this.ap.av.getSelectionGroup (); -if (sg != null) { -var startEnd = this.ap.av.getVisibleRegionBoundaries (sg.getStartRes (), sg.getEndRes () + 1); -var description; -var caseChange; -if (source === this.toggleCase) { -description = "Toggle Case"; -caseChange = jalview.commands.ChangeCaseCommand.TOGGLE_CASE; -} else if (source === this.toUpper) { -description = "To Upper Case"; -caseChange = jalview.commands.ChangeCaseCommand.TO_UPPER; -} else { -description = "To Lower Case"; -caseChange = jalview.commands.ChangeCaseCommand.TO_LOWER; -}var caseCommand = new jalview.commands.ChangeCaseCommand (description, sg.getSequencesAsArray (this.ap.av.getHiddenRepSequences ()), startEnd, caseChange); -this.ap.alignFrame.addHistoryItem (caseCommand); -this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); -}} else if (source === this.sequenceFeature) { -var sg = this.ap.av.getSelectionGroup (); -if (sg == null) { -return; -}var rsize = 0; -var gSize = sg.getSize (); -var rseqs; -var seqs = new Array (gSize); -var tfeatures; -var features = new Array (gSize); -for (var i = 0; i < gSize; i++) { -var start = sg.getSequenceAt (i).findPosition (sg.getStartRes ()); -var end = sg.findEndRes (sg.getSequenceAt (i)); -if (start <= end) { -seqs[rsize] = sg.getSequenceAt (i); -features[rsize] = new jalview.datamodel.SequenceFeature (null, null, null, start, end, "Jalview"); -rsize++; -}} -rseqs = new Array (rsize); -tfeatures = new Array (rsize); -System.arraycopy (seqs, 0, rseqs, 0, rsize); -System.arraycopy (features, 0, tfeatures, 0, rsize); -features = tfeatures; -seqs = rseqs; -if (this.ap.seqPanel.seqCanvas.getFeatureRenderer ().amendFeatures (seqs, features, true, this.ap)) { -this.ap.alignFrame.sequenceFeatures.setState (true); -this.ap.av.setShowSequenceFeatures (true); -;this.ap.highlightSearchResults (null); -}} else { -this.outputText (evt); -}}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "outputText", -function (e) { -var cap = new jalview.appletgui.CutAndPasteTransfer (true, this.ap.alignFrame); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.selection_output_command", Clazz.newArray (-1, [e.getActionCommand ()])), 600, 500); -cap.setText ( new jalview.io.AppletFormatAdapter ().formatSequences (e.getActionCommand (), this.ap.av.getShowJVSuffix (), this.ap, true)); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "showSequenceSelectionDetails", -function () { -this.createSequenceDetailsReport (this.ap.av.getSequenceSelection ()); -}); -Clazz.defineMethod (c$, "showSequenceDetails", -function () { -this.createSequenceDetailsReport ( Clazz.newArray (-1, [this.seq])); -}); -Clazz.defineMethod (c$, "createSequenceDetailsReport", -function (sequences) { -var cap = new jalview.appletgui.CutAndPasteTransfer (false, this.ap.alignFrame); -var contents = new StringBuffer (); -for (var seq, $seq = 0, $$seq = sequences; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { -contents.append (jalview.util.MessageManager.formatMessage ("label.annotation_for_displayid", Clazz.newArray (-1, [seq.getDisplayId (true)]))); - new jalview.io.SequenceAnnotationReport (null).createSequenceAnnotationReport (contents, seq, true, true, false, (this.ap.seqPanel.seqCanvas.fr != null) ? this.ap.seqPanel.seqCanvas.fr.getMinMax () : null); -contents.append ("

"); -} -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, "Sequence Details for " + (sequences.length == 1 ? sequences[0].getDisplayId (true) : "Selection"), 600, 500); -cap.setText (jalview.util.MessageManager.formatMessage ("label.html_content", Clazz.newArray (-1, [contents.toString ()]))); -}, "~A"); -Clazz.defineMethod (c$, "editName", -function () { -var dialog = new jalview.appletgui.EditNameDialog (this.seq.getName (), this.seq.getDescription (), " Sequence Name", "Sequence Description", this.ap.alignFrame, "Edit Sequence Name / Description", 500, 100, true); -if (dialog.accept) { -this.seq.setName (dialog.getName ()); -this.seq.setDescription (dialog.getDescription ()); -this.ap.paintAlignment (false); -}}); -Clazz.defineMethod (c$, "addPDB", -function () { -if (this.seq.getPDBId () != null) { -var entry = this.seq.getPDBId ().firstElement (); -if (this.ap.av.applet.jmolAvailable) { - new jalview.appletgui.AppletJmol (entry, Clazz.newArray (-1, [this.seq]), null, this.ap, jalview.io.AppletFormatAdapter.URL); -}} else { -var cap = new jalview.appletgui.CutAndPasteTransfer (true, this.ap.alignFrame); -cap.setText (jalview.util.MessageManager.getString ("label.paste_pdb_file")); -cap.setPDBImport (this.seq); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.paste_pdb_file_for_sequence", Clazz.newArray (-1, [this.seq.getName ()])), 400, 300); -}}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.groupMenu.setLabel (jalview.util.MessageManager.getString ("label.selection")); -this.sequenceFeature.addActionListener (this); -this.editGroupName.addActionListener (this); -this.unGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_group")); -this.unGroupMenuItem.addActionListener (this); -this.createGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.create_group")); -this.createGroupMenuItem.addActionListener (this); -this.nucleotideMenuItem.setLabel (jalview.util.MessageManager.getString ("label.nucleotide")); -this.nucleotideMenuItem.addActionListener (this); -this.conservationMenuItem.addItemListener (this); -this.abovePIDColour.addItemListener (this); -this.colourMenu.setLabel (jalview.util.MessageManager.getString ("label.group_colour")); -this.showBoxes.setLabel (jalview.util.MessageManager.getString ("action.boxes")); -this.showBoxes.setState (true); -this.showBoxes.addItemListener (this); -this.sequenceName.addActionListener (this); -this.sequenceDetails.addActionListener (this); -this.selSeqDetails.addActionListener (this); -this.displayNonconserved.setLabel (jalview.util.MessageManager.getString ("label.show_non_conversed")); -this.displayNonconserved.setState (false); -this.displayNonconserved.addItemListener (this); -this.showText.setLabel (jalview.util.MessageManager.getString ("action.text")); -this.showText.addItemListener (this); -this.showColourText.setLabel (jalview.util.MessageManager.getString ("label.colour_text")); -this.showColourText.addItemListener (this); -this.outputmenu.setLabel (jalview.util.MessageManager.getString ("label.out_to_textbox")); -this.seqMenu.setLabel (jalview.util.MessageManager.getString ("label.sequence")); -this.pdb.setLabel (jalview.util.MessageManager.getString ("label.view_pdb_structure")); -this.hideSeqs.setLabel (jalview.util.MessageManager.getString ("action.hide_sequences")); -this.repGroup.setLabel (jalview.util.MessageManager.formatMessage ("label.represent_group_with", Clazz.newArray (-1, [""]))); -this.revealAll.setLabel (jalview.util.MessageManager.getString ("action.reveal_all")); -this.revealSeq.setLabel (jalview.util.MessageManager.getString ("action.reveal_sequences")); -this.menu1.setLabel (jalview.util.MessageManager.getString ("label.group") + ":"); -this.add (this.groupMenu); -this.add (this.seqMenu); -this.add (this.hideSeqs); -this.add (this.revealSeq); -this.add (this.revealAll); -this.groupMenu.add (this.groupShowAnnotationsMenu); -this.groupMenu.add (this.groupHideAnnotationsMenu); -this.groupMenu.add (this.groupAddReferenceAnnotations); -this.groupMenu.add (this.editMenu); -this.groupMenu.add (this.outputmenu); -this.groupMenu.add (this.sequenceFeature); -this.groupMenu.add (this.createGroupMenuItem); -this.groupMenu.add (this.unGroupMenuItem); -this.groupMenu.add (this.menu1); -this.colourMenu.add (this.noColourmenuItem); -this.colourMenu.add (this.clustalColour); -this.colourMenu.add (this.BLOSUM62Colour); -this.colourMenu.add (this.PIDColour); -this.colourMenu.add (this.zappoColour); -this.colourMenu.add (this.taylorColour); -this.colourMenu.add (this.hydrophobicityColour); -this.colourMenu.add (this.helixColour); -this.colourMenu.add (this.strandColour); -this.colourMenu.add (this.turnColour); -this.colourMenu.add (this.buriedColour); -this.colourMenu.add (this.nucleotideMenuItem); -this.colourMenu.add (this.userDefinedColour); -this.colourMenu.addSeparator (); -this.colourMenu.add (this.abovePIDColour); -this.colourMenu.add (this.conservationMenuItem); -this.noColourmenuItem.setLabel (jalview.util.MessageManager.getString ("label.none")); -this.noColourmenuItem.addActionListener (this); -this.clustalColour.setLabel (jalview.util.MessageManager.getString ("label.clustalx_colours")); -this.clustalColour.addActionListener (this); -this.zappoColour.setLabel (jalview.util.MessageManager.getString ("label.zappo")); -this.zappoColour.addActionListener (this); -this.taylorColour.setLabel (jalview.util.MessageManager.getString ("label.taylor")); -this.taylorColour.addActionListener (this); -this.hydrophobicityColour.setLabel (jalview.util.MessageManager.getString ("label.hydrophobicity")); -this.hydrophobicityColour.addActionListener (this); -this.helixColour.setLabel (jalview.util.MessageManager.getString ("label.helix_propensity")); -this.helixColour.addActionListener (this); -this.strandColour.setLabel (jalview.util.MessageManager.getString ("label.strand_propensity")); -this.strandColour.addActionListener (this); -this.turnColour.setLabel (jalview.util.MessageManager.getString ("label.turn_propensity")); -this.turnColour.addActionListener (this); -this.buriedColour.setLabel (jalview.util.MessageManager.getString ("label.buried_index")); -this.buriedColour.addActionListener (this); -this.abovePIDColour.setLabel (jalview.util.MessageManager.getString ("label.above_identity_percentage")); -this.userDefinedColour.setLabel (jalview.util.MessageManager.getString ("action.user_defined")); -this.userDefinedColour.addActionListener (this); -this.PIDColour.setLabel (jalview.util.MessageManager.getString ("action.percentage_identity")); -this.PIDColour.addActionListener (this); -this.BLOSUM62Colour.setLabel ("BLOSUM62"); -this.BLOSUM62Colour.addActionListener (this); -this.conservationMenuItem.setLabel (jalview.util.MessageManager.getString ("label.conservation")); -this.editMenu.add (this.copy); -this.copy.addActionListener (this); -this.editMenu.add (this.cut); -this.cut.addActionListener (this); -this.editMenu.add (this.editSequence); -this.editSequence.addActionListener (this); -this.editMenu.add (this.toUpper); -this.toUpper.addActionListener (this); -this.editMenu.add (this.toLower); -this.toLower.addActionListener (this); -this.editMenu.add (this.toggleCase); -this.seqMenu.add (this.seqShowAnnotationsMenu); -this.seqMenu.add (this.seqHideAnnotationsMenu); -this.seqMenu.add (this.seqAddReferenceAnnotations); -this.seqMenu.add (this.sequenceName); -this.seqMenu.add (this.makeReferenceSeq); -if (!this.ap.av.applet.useXtrnalSviewer) { -this.seqMenu.add (this.pdb); -}this.seqMenu.add (this.repGroup); -this.menu1.add (this.editGroupName); -this.menu1.add (this.colourMenu); -this.menu1.add (this.showBoxes); -this.menu1.add (this.showText); -this.menu1.add (this.showColourText); -this.menu1.add (this.displayNonconserved); -this.toggleCase.addActionListener (this); -this.pdb.addActionListener (this); -this.hideSeqs.addActionListener (this); -this.repGroup.addActionListener (this); -this.revealAll.addActionListener (this); -this.revealSeq.addActionListener (this); -this.makeReferenceSeq.addActionListener (this); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "refresh", -function () { -this.ap.paintAlignment (true); -}); -Clazz.defineMethod (c$, "clustalColour_actionPerformed", -function () { -var sg = this.getGroup (); -sg.cs = new jalview.schemes.ClustalxColourScheme (sg, this.ap.av.getHiddenRepSequences ()); -this.refresh (); -}); -Clazz.defineMethod (c$, "zappoColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.ZappoColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "taylorColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.TaylorColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "hydrophobicityColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.HydrophobicColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "helixColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.HelixColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "strandColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.StrandColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "turnColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.TurnColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "buriedColour_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.BuriedColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "nucleotideMenuItem_actionPerformed", -function () { -this.getGroup ().cs = new jalview.schemes.NucleotideColourScheme (); -this.refresh (); -}); -Clazz.defineMethod (c$, "abovePIDColour_itemStateChanged", -function () { -var sg = this.getGroup (); -if (sg.cs == null) { -return; -}if (this.abovePIDColour.getState ()) { -sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ())); -var threshold = jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, sg.cs, this.getGroup ().getName ()); -sg.cs.setThreshold (threshold, this.ap.av.isIgnoreGapsConsensus ()); -jalview.appletgui.SliderPanel.showPIDSlider (); -} else { -sg.cs.setThreshold (0, this.ap.av.isIgnoreGapsConsensus ()); -}this.refresh (); -}); -Clazz.defineMethod (c$, "userDefinedColour_actionPerformed", -function () { - new jalview.appletgui.UserDefinedColours (this.ap, this.getGroup ()); -}); -Clazz.defineMethod (c$, "PIDColour_actionPerformed", -function () { -var sg = this.getGroup (); -sg.cs = new jalview.schemes.PIDColourScheme (); -sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ())); -this.refresh (); -}); -Clazz.defineMethod (c$, "BLOSUM62Colour_actionPerformed", -function () { -var sg = this.getGroup (); -sg.cs = new jalview.schemes.Blosum62ColourScheme (); -sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ())); -this.refresh (); -}); -Clazz.defineMethod (c$, "noColourmenuItem_actionPerformed", -function () { -this.getGroup ().cs = null; -this.refresh (); -}); -Clazz.defineMethod (c$, "conservationMenuItem_itemStateChanged", -function () { -var sg = this.getGroup (); -if (sg.cs == null) { -return; -}if (this.conservationMenuItem.getState ()) { -sg.cs.setConservation (jalview.analysis.Conservation.calculateConservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth (), false, this.ap.av.getConsPercGaps (), false)); -jalview.appletgui.SliderPanel.setConservationSlider (this.ap, sg.cs, sg.getName ()); -jalview.appletgui.SliderPanel.showConservationSlider (); -} else { -sg.cs.setConservation (null); -}this.refresh (); -}); -Clazz.defineMethod (c$, "getGroup", -function () { -var sg = this.ap.av.getSelectionGroup (); -if (sg != null) { -this.ap.av.getAlignment ().addGroup (sg); -}return sg; -}); -Clazz.defineMethod (c$, "unGroupMenuItem_actionPerformed", -function () { -var sg = this.ap.av.getSelectionGroup (); -this.ap.av.getAlignment ().deleteGroup (sg); -this.ap.av.setSelectionGroup (null); -this.ap.paintAlignment (true); -}); -Clazz.defineMethod (c$, "createGroupMenuItem_actionPerformed", -function () { -this.getGroup (); -this.refresh (); -}); -Clazz.defineMethod (c$, "showColourText_itemStateChanged", -function () { -this.getGroup ().setColourText (this.showColourText.getState ()); -this.refresh (); -}); -Clazz.defineMethod (c$, "showText_itemStateChanged", -function () { -this.getGroup ().setDisplayText (this.showText.getState ()); -this.refresh (); -}); -Clazz.defineMethod (c$, "makeReferenceSeq_actionPerformed", -function () { -if (!this.ap.av.getAlignment ().hasSeqrep ()) { -this.ap.av.setDisplayReferenceSeq (true); -this.ap.av.setColourByReferenceSeq (true); -this.ap.av.getAlignment ().setSeqrep (this.seq); -} else { -if (this.ap.av.getAlignment ().getSeqrep () === this.seq) { -this.ap.av.getAlignment ().setSeqrep (null); -} else { -this.ap.av.getAlignment ().setSeqrep (this.seq); -}}this.refresh (); -}); -Clazz.defineMethod (c$, "showNonconserved_itemStateChanged", -function () { -this.getGroup ().setShowNonconserved (this.displayNonconserved.getState ()); -this.refresh (); -}); -Clazz.defineMethod (c$, "showBoxes_itemStateChanged", -function () { -this.getGroup ().setDisplayBoxes (this.showBoxes.getState ()); -this.refresh (); -}); -Clazz.defineMethod (c$, "hideSequences", -function (representGroup) { -var sg = this.ap.av.getSelectionGroup (); -if (sg == null || sg.getSize () < 1) { -this.ap.av.hideSequence ( Clazz.newArray (-1, [this.seq])); -return; -}this.ap.av.setSelectionGroup (null); -if (representGroup) { -this.ap.av.hideRepSequences (this.seq, sg); -return; -}var gsize = sg.getSize (); -var hseqs; -hseqs = new Array (gsize); -var index = 0; -for (var i = 0; i < gsize; i++) { -hseqs[index++] = sg.getSequenceAt (i); -} -this.ap.av.hideSequence (hseqs); -this.ap.av.sendSelection (); -}, "~B"); -Clazz.defineMethod (c$, "buildAnnotationTypesMenus", -function (showMenu, hideMenu, forSequences) { -showMenu.removeAll (); -hideMenu.removeAll (); -var all = java.util.Arrays.asList (["All"]); -this.addAnnotationTypeToShowHide (showMenu, forSequences, "", all, true, true); -this.addAnnotationTypeToShowHide (hideMenu, forSequences, "", all, true, false); -showMenu.addSeparator (); -hideMenu.addSeparator (); -var annotations = this.ap.getAlignment ().getAlignmentAnnotation (); -var shownTypes = new java.util.LinkedHashMap (); -var hiddenTypes = new java.util.LinkedHashMap (); -jalview.analysis.AlignmentAnnotationUtils.getShownHiddenTypes (shownTypes, hiddenTypes, jalview.analysis.AlignmentAnnotationUtils.asList (annotations), forSequences); -for (var calcId, $calcId = hiddenTypes.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) { -for (var type, $type = hiddenTypes.get (calcId).iterator (); $type.hasNext () && ((type = $type.next ()) || true);) { -this.addAnnotationTypeToShowHide (showMenu, forSequences, calcId, type, false, true); -} -} -showMenu.setEnabled (!hiddenTypes.isEmpty ()); -for (var calcId, $calcId = shownTypes.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) { -for (var type, $type = shownTypes.get (calcId).iterator (); $type.hasNext () && ((type = $type.next ()) || true);) { -this.addAnnotationTypeToShowHide (hideMenu, forSequences, calcId, type, false, false); -} -} -hideMenu.setEnabled (!shownTypes.isEmpty ()); -}, "awt2swing.Menu,awt2swing.Menu,java.util.List"); -Clazz.defineMethod (c$, "addAnnotationTypeToShowHide", -function (showOrHideMenu, forSequences, calcId, types, allTypes, actionIsShow) { -var label = types.toString (); -label = label.substring (1, label.length - 1); -var item = new awt2swing.MenuItem (label); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$3") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$3, this, Clazz.cloneFinals ("types", types, "forSequences", forSequences, "allTypes", allTypes, "actionIsShow", actionIsShow)))); -showOrHideMenu.add (item); -}, "awt2swing.Menu,java.util.List,~S,java.util.List,~B,~B"); -c$.$APopupMenu$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$1", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.APopupMenu"].addReferenceAnnotations_actionPerformed (this.f$.candidates); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$APopupMenu$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$2", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.APopupMenu"].ap.alignFrame.showURL (this.f$.url, this.f$.target); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$APopupMenu$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$3", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -jalview.analysis.AlignmentUtils.showOrHideSequenceAnnotations (this.b$["jalview.appletgui.APopupMenu"].ap.getAlignment (), this.f$.types, this.f$.forSequences, this.f$.allTypes, this.f$.actionIsShow); -this.b$["jalview.appletgui.APopupMenu"].refresh (); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"ALL_ANNOTATIONS", "All"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.PopupMenu", "java.awt.event.ActionListener", "$.ItemListener", "awt2swing.CheckboxMenuItem", "$.Menu", "$.MenuItem", "jalview.util.MessageManager"], "jalview.appletgui.APopupMenu", ["awt2swing.Frame", "jalview.analysis.AAFrequency", "$.AlignmentAnnotationUtils", "$.AlignmentUtils", "$.Conservation", "jalview.appletgui.AppletJmol", "$.CutAndPasteTransfer", "$.EditNameDialog", "$.SliderPanel", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.commands.ChangeCaseCommand", "$.EditCommand", "jalview.datamodel.SequenceFeature", "jalview.io.AppletFormatAdapter", "$.SequenceAnnotationReport", "jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.ResidueProperties", "$.StrandColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.ZappoColourScheme", "jalview.util.DBRefUtils", "$.UrlLink", "java.lang.StringBuffer", "$.StringBuilder", "java.util.Arrays", "$.Collections", "$.LinkedHashMap", "$.TreeMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.groupMenu = null; +this.editGroupName = null; +this.clustalColour = null; +this.zappoColour = null; +this.taylorColour = null; +this.hydrophobicityColour = null; +this.helixColour = null; +this.strandColour = null; +this.turnColour = null; +this.buriedColour = null; +this.abovePIDColour = null; +this.userDefinedColour = null; +this.PIDColour = null; +this.BLOSUM62Colour = null; +this.noColourmenuItem = null; +this.conservationMenuItem = null; +this.ap = null; +this.unGroupMenuItem = null; +this.createGroupMenuItem = null; +this.nucleotideMenuItem = null; +this.colourMenu = null; +this.showBoxes = null; +this.showText = null; +this.showColourText = null; +this.displayNonconserved = null; +this.seqShowAnnotationsMenu = null; +this.seqHideAnnotationsMenu = null; +this.seqAddReferenceAnnotations = null; +this.groupShowAnnotationsMenu = null; +this.groupHideAnnotationsMenu = null; +this.groupAddReferenceAnnotations = null; +this.editMenu = null; +this.copy = null; +this.cut = null; +this.toUpper = null; +this.toLower = null; +this.toggleCase = null; +this.outputmenu = null; +this.seqMenu = null; +this.pdb = null; +this.hideSeqs = null; +this.repGroup = null; +this.sequenceName = null; +this.sequenceFeature = null; +this.editSequence = null; +this.sequenceDetails = null; +this.selSeqDetails = null; +this.makeReferenceSeq = null; +this.seq = null; +this.revealAll = null; +this.revealSeq = null; +this.revealSeq_index = -1; +this.menu1 = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "APopupMenu", awt2swing.PopupMenu, [java.awt.event.ActionListener, java.awt.event.ItemListener]); +Clazz.prepareFields (c$, function () { +this.groupMenu = new awt2swing.Menu (); +this.editGroupName = new awt2swing.MenuItem (); +this.clustalColour = new awt2swing.MenuItem (); +this.zappoColour = new awt2swing.MenuItem (); +this.taylorColour = new awt2swing.MenuItem (); +this.hydrophobicityColour = new awt2swing.MenuItem (); +this.helixColour = new awt2swing.MenuItem (); +this.strandColour = new awt2swing.MenuItem (); +this.turnColour = new awt2swing.MenuItem (); +this.buriedColour = new awt2swing.MenuItem (); +this.abovePIDColour = new awt2swing.CheckboxMenuItem (); +this.userDefinedColour = new awt2swing.MenuItem (); +this.PIDColour = new awt2swing.MenuItem (); +this.BLOSUM62Colour = new awt2swing.MenuItem (); +this.noColourmenuItem = new awt2swing.MenuItem (); +this.conservationMenuItem = new awt2swing.CheckboxMenuItem (); +this.unGroupMenuItem = new awt2swing.MenuItem (); +this.createGroupMenuItem = new awt2swing.MenuItem (); +this.nucleotideMenuItem = new awt2swing.MenuItem (); +this.colourMenu = new awt2swing.Menu (); +this.showBoxes = new awt2swing.CheckboxMenuItem (); +this.showText = new awt2swing.CheckboxMenuItem (); +this.showColourText = new awt2swing.CheckboxMenuItem (); +this.displayNonconserved = new awt2swing.CheckboxMenuItem (); +this.seqShowAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.show_annotations")); +this.seqHideAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.hide_annotations")); +this.seqAddReferenceAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.add_reference_annotations")); +this.groupShowAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.show_annotations")); +this.groupHideAnnotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.hide_annotations")); +this.groupAddReferenceAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.add_reference_annotations")); +this.editMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.edit")); +this.copy = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.copy")); +this.cut = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.cut")); +this.toUpper = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.to_upper_case")); +this.toLower = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.to_lower_case")); +this.toggleCase = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.toggle_case")); +this.outputmenu = new awt2swing.Menu (); +this.seqMenu = new awt2swing.Menu (); +this.pdb = new awt2swing.MenuItem (); +this.hideSeqs = new awt2swing.MenuItem (); +this.repGroup = new awt2swing.MenuItem (); +this.sequenceName = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.edit_name_description")); +this.sequenceFeature = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.create_sequence_feature")); +this.editSequence = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.edit_sequence")); +this.sequenceDetails = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sequence_details") + "..."); +this.selSeqDetails = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sequence_details") + "..."); +this.makeReferenceSeq = new awt2swing.MenuItem (); +this.revealAll = new awt2swing.MenuItem (); +this.revealSeq = new awt2swing.MenuItem (); +this.menu1 = new awt2swing.Menu (); +}); +Clazz.makeConstructor (c$, +function (apanel, seq, links) { +Clazz.superConstructor (this, jalview.appletgui.APopupMenu, []); +this.ap = apanel; +this.seq = seq; +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +for (var i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { +var item = new awt2swing.MenuItem (jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); +item.addActionListener (this); +this.outputmenu.add (item); +} +this.buildAnnotationSubmenus (); +var sg = this.ap.av.getSelectionGroup (); +if (sg != null && sg.getSize () > 0) { +this.editGroupName.setLabel (jalview.util.MessageManager.formatMessage ("label.name_param", Clazz.newArray (-1, [sg.getName ()]))); +this.showText.setState (sg.getDisplayText ()); +this.showColourText.setState (sg.getColourText ()); +this.showBoxes.setState (sg.getDisplayBoxes ()); +this.displayNonconserved.setState (sg.getShowNonconserved ()); +if (!this.ap.av.getAlignment ().getGroups ().contains (sg)) { +this.menu1.setLabel (jalview.util.MessageManager.getString ("action.edit_new_group")); +this.groupMenu.remove (this.unGroupMenuItem); +} else { +this.menu1.setLabel (jalview.util.MessageManager.getString ("action.edit_group")); +this.groupMenu.remove (this.createGroupMenuItem); +}} else { +this.remove (this.hideSeqs); +this.remove (this.groupMenu); +}if (links != null && links.size () > 0) { +var linkMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.link")); +for (var i = 0; i < links.size (); i++) { +var link = links.elementAt (i); +var urlLink = new jalview.util.UrlLink (link); +if (!urlLink.isValid ()) { +System.err.println (urlLink.getInvalidMessage ()); +continue; +}var target = urlLink.getTarget (); +var label = urlLink.getLabel (); +if (seq != null && urlLink.isDynamic ()) { +var dbr = jalview.util.DBRefUtils.selectRefs (seq.getDBRef (), Clazz.newArray (-1, [target])); +var id = seq.getName (); +var descr = seq.getDescription (); +if (descr != null && descr.length < 1) { +descr = null; +}if (dbr != null) { +for (var r = 0; r < dbr.length; r++) { +if (id != null && dbr[r].getAccessionId ().equals (id)) { +id = null; +}var urls = urlLink.makeUrls (dbr[r].getAccessionId (), true); +if (urls != null) { +for (var u = 0; u < urls.length; u += 2) { +this.addshowLink (linkMenu, label + "|" + urls[u], urls[u + 1]); +} +}} +}if (id != null) { +var urls = urlLink.makeUrls (id, true); +if (urls != null) { +for (var u = 0; u < urls.length; u += 2) { +this.addshowLink (linkMenu, label, urls[u + 1]); +} +}}if (descr != null && urlLink.getRegexReplace () != null) { +var urls = urlLink.makeUrls (descr, true); +if (urls != null) { +for (var u = 0; u < urls.length; u += 2) { +this.addshowLink (linkMenu, label, urls[u + 1]); +} +}}} else { +this.addshowLink (linkMenu, target, urlLink.getUrl_prefix ()); +}} +if (linkMenu.getItemCount () > 0) { +if (seq != null) { +this.seqMenu.add (linkMenu); +} else { +this.add (linkMenu); +}}}if (seq != null) { +this.seqMenu.setLabel (seq.getName ()); +if (seq === this.ap.av.getAlignment ().getSeqrep ()) { +this.makeReferenceSeq.setLabel (jalview.util.MessageManager.getString ("action.unmark_as_reference")); +} else { +this.makeReferenceSeq.setLabel (jalview.util.MessageManager.getString ("action.set_as_reference")); +}this.repGroup.setLabel (jalview.util.MessageManager.formatMessage ("label.represent_group_with", Clazz.newArray (-1, [seq.getName ()]))); +} else { +this.remove (this.seqMenu); +}if (!this.ap.av.hasHiddenRows ()) { +this.remove (this.revealAll); +this.remove (this.revealSeq); +} else { +var index = this.ap.av.getAlignment ().findIndex (seq); +if (this.ap.av.adjustForHiddenSeqs (index) - this.ap.av.adjustForHiddenSeqs (index - 1) > 1) { +this.revealSeq_index = index; +} else { +this.remove (this.revealSeq); +}}}, "jalview.appletgui.AlignmentPanel,jalview.datamodel.SequenceI,java.util.Vector"); +Clazz.defineMethod (c$, "buildAnnotationSubmenus", +($fz = function () { +var selectedSequence = (this.seq == null ? java.util.Collections.emptyList () : java.util.Arrays.asList ([this.seq])); +this.buildAnnotationTypesMenus (this.seqShowAnnotationsMenu, this.seqHideAnnotationsMenu, selectedSequence); +this.configureReferenceAnnotationsMenu (this.seqAddReferenceAnnotations, selectedSequence); +var selectedGroup = (this.ap.av.getSelectionGroup () == null ? java.util.Collections.emptyList () : this.ap.av.getSelectionGroup ().getSequences ()); +this.buildAnnotationTypesMenus (this.groupShowAnnotationsMenu, this.groupHideAnnotationsMenu, selectedGroup); +this.configureReferenceAnnotationsMenu (this.groupAddReferenceAnnotations, selectedGroup); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "configureReferenceAnnotationsMenu", +($fz = function (menuItem, forSequences) { +menuItem.setEnabled (false); +var tipEntries = new java.util.TreeMap (); +var candidates = new java.util.LinkedHashMap (); +var al = this.ap.av.getAlignment (); +jalview.analysis.AlignmentUtils.findAddableReferenceAnnotations (forSequences, tipEntries, candidates, al); +if (!candidates.isEmpty ()) { +var tooltip = new StringBuilder (64); +tooltip.append (jalview.util.MessageManager.getString ("label.add_annotations_for")); +menuItem.setEnabled (true); +menuItem.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$1") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$1, this, Clazz.cloneFinals ("candidates", candidates)))); +}}, $fz.isPrivate = true, $fz), "awt2swing.MenuItem,java.util.List"); +Clazz.defineMethod (c$, "addReferenceAnnotations_actionPerformed", +function (candidates) { +var selectionGroup = this.ap.av.getSelectionGroup (); +var alignment = this.ap.getAlignment (); +jalview.analysis.AlignmentUtils.addReferenceAnnotations (candidates, alignment, selectionGroup); +this.refresh (); +}, "java.util.Map"); +Clazz.defineMethod (c$, "addshowLink", +($fz = function (linkMenu, target, url) { +this.addshowLink (linkMenu, target, target, url); +}, $fz.isPrivate = true, $fz), "awt2swing.Menu,~S,~S"); +Clazz.defineMethod (c$, "addshowLink", +($fz = function (linkMenu, target, label, url) { +var item = new awt2swing.MenuItem (label); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$2") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$2, this, Clazz.cloneFinals ("url", url, "target", target)))); +linkMenu.add (item); +}, $fz.isPrivate = true, $fz), "awt2swing.Menu,~S,~S,~S"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +if (evt.getSource () === this.abovePIDColour) { +this.abovePIDColour_itemStateChanged (); +} else if (evt.getSource () === this.showColourText) { +this.showColourText_itemStateChanged (); +} else if (evt.getSource () === this.showText) { +this.showText_itemStateChanged (); +} else if (evt.getSource () === this.showBoxes) { +this.showBoxes_itemStateChanged (); +} else if (evt.getSource () === this.displayNonconserved) { +this.showNonconserved_itemStateChanged (); +}}, "java.awt.event.ItemEvent"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +var source = evt.getSource (); +if (source === this.clustalColour) { +this.clustalColour_actionPerformed (); +} else if (source === this.zappoColour) { +this.zappoColour_actionPerformed (); +} else if (source === this.taylorColour) { +this.taylorColour_actionPerformed (); +} else if (source === this.hydrophobicityColour) { +this.hydrophobicityColour_actionPerformed (); +} else if (source === this.helixColour) { +this.helixColour_actionPerformed (); +} else if (source === this.strandColour) { +this.strandColour_actionPerformed (); +} else if (source === this.turnColour) { +this.turnColour_actionPerformed (); +} else if (source === this.buriedColour) { +this.buriedColour_actionPerformed (); +} else if (source === this.nucleotideMenuItem) { +this.nucleotideMenuItem_actionPerformed (); +} else if (source === this.userDefinedColour) { +this.userDefinedColour_actionPerformed (); +} else if (source === this.PIDColour) { +this.PIDColour_actionPerformed (); +} else if (source === this.BLOSUM62Colour) { +this.BLOSUM62Colour_actionPerformed (); +} else if (source === this.noColourmenuItem) { +this.noColourmenuItem_actionPerformed (); +} else if (source === this.conservationMenuItem) { +this.conservationMenuItem_itemStateChanged (); +} else if (source === this.unGroupMenuItem) { +this.unGroupMenuItem_actionPerformed (); +} else if (source === this.createGroupMenuItem) { +this.createGroupMenuItem_actionPerformed (); +} else if (source === this.sequenceName) { +this.editName (); +} else if (source === this.makeReferenceSeq) { +this.makeReferenceSeq_actionPerformed (); +} else if (source === this.sequenceDetails) { +this.showSequenceDetails (); +} else if (source === this.selSeqDetails) { +this.showSequenceSelectionDetails (); +} else if (source === this.pdb) { +this.addPDB (); +} else if (source === this.hideSeqs) { +this.hideSequences (false); +} else if (source === this.repGroup) { +this.hideSequences (true); +} else if (source === this.revealSeq) { +this.ap.av.showSequence (this.revealSeq_index); +} else if (source === this.revealAll) { +this.ap.av.showAllHiddenSeqs (); +} else if (source === this.editGroupName) { +var dialog = new jalview.appletgui.EditNameDialog (this.getGroup ().getName (), this.getGroup ().getDescription (), " Group Name", "Group Description", this.ap.alignFrame, "Edit Group Name / Description", 500, 100, true); +if (dialog.accept) { +this.getGroup ().setName (dialog.getName ().$replace (' ', '_')); +this.getGroup ().setDescription (dialog.getDescription ()); +}} else if (source === this.copy) { +this.ap.alignFrame.copy_actionPerformed (); +} else if (source === this.cut) { +this.ap.alignFrame.cut_actionPerformed (); +} else if (source === this.editSequence) { +var sg = this.ap.av.getSelectionGroup (); +if (sg != null) { +if (this.seq == null) { +this.seq = sg.getSequenceAt (0); +}var dialog = new jalview.appletgui.EditNameDialog (this.seq.getSequenceAsString (sg.getStartRes (), sg.getEndRes () + 1), null, "Edit Sequence ", null, this.ap.alignFrame, "Edit Sequence", 500, 100, true); +if (dialog.accept) { +var editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.edit_sequences"), jalview.commands.EditCommand.Action.REPLACE, dialog.getName ().$replace (' ', this.ap.av.getGapCharacter ()), sg.getSequencesAsArray (this.ap.av.getHiddenRepSequences ()), sg.getStartRes (), sg.getEndRes () + 1, this.ap.av.getAlignment ()); +this.ap.alignFrame.addHistoryItem (editCommand); +this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); +}}} else if (source === this.toUpper || source === this.toLower || source === this.toggleCase) { +var sg = this.ap.av.getSelectionGroup (); +if (sg != null) { +var startEnd = this.ap.av.getVisibleRegionBoundaries (sg.getStartRes (), sg.getEndRes () + 1); +var description; +var caseChange; +if (source === this.toggleCase) { +description = "Toggle Case"; +caseChange = jalview.commands.ChangeCaseCommand.TOGGLE_CASE; +} else if (source === this.toUpper) { +description = "To Upper Case"; +caseChange = jalview.commands.ChangeCaseCommand.TO_UPPER; +} else { +description = "To Lower Case"; +caseChange = jalview.commands.ChangeCaseCommand.TO_LOWER; +}var caseCommand = new jalview.commands.ChangeCaseCommand (description, sg.getSequencesAsArray (this.ap.av.getHiddenRepSequences ()), startEnd, caseChange); +this.ap.alignFrame.addHistoryItem (caseCommand); +this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); +}} else if (source === this.sequenceFeature) { +var sg = this.ap.av.getSelectionGroup (); +if (sg == null) { +return; +}var rsize = 0; +var gSize = sg.getSize (); +var rseqs; +var seqs = new Array (gSize); +var tfeatures; +var features = new Array (gSize); +for (var i = 0; i < gSize; i++) { +var start = sg.getSequenceAt (i).findPosition (sg.getStartRes ()); +var end = sg.findEndRes (sg.getSequenceAt (i)); +if (start <= end) { +seqs[rsize] = sg.getSequenceAt (i); +features[rsize] = new jalview.datamodel.SequenceFeature (null, null, null, start, end, "Jalview"); +rsize++; +}} +rseqs = new Array (rsize); +tfeatures = new Array (rsize); +System.arraycopy (seqs, 0, rseqs, 0, rsize); +System.arraycopy (features, 0, tfeatures, 0, rsize); +features = tfeatures; +seqs = rseqs; +if (this.ap.seqPanel.seqCanvas.getFeatureRenderer ().amendFeatures (seqs, features, true, this.ap)) { +this.ap.alignFrame.sequenceFeatures.setState (true); +this.ap.av.setShowSequenceFeatures (true); +;this.ap.highlightSearchResults (null); +}} else { +this.outputText (evt); +}}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "outputText", +function (e) { +var cap = new jalview.appletgui.CutAndPasteTransfer (true, this.ap.alignFrame); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.selection_output_command", Clazz.newArray (-1, [e.getActionCommand ()])), 600, 500); +cap.setText ( new jalview.io.AppletFormatAdapter ().formatSequences (e.getActionCommand (), this.ap.av.getShowJVSuffix (), this.ap, true)); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "showSequenceSelectionDetails", +function () { +this.createSequenceDetailsReport (this.ap.av.getSequenceSelection ()); +}); +Clazz.defineMethod (c$, "showSequenceDetails", +function () { +this.createSequenceDetailsReport ( Clazz.newArray (-1, [this.seq])); +}); +Clazz.defineMethod (c$, "createSequenceDetailsReport", +function (sequences) { +var cap = new jalview.appletgui.CutAndPasteTransfer (false, this.ap.alignFrame); +var contents = new StringBuffer (); +for (var seq, $seq = 0, $$seq = sequences; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { +contents.append (jalview.util.MessageManager.formatMessage ("label.annotation_for_displayid", Clazz.newArray (-1, [seq.getDisplayId (true)]))); + new jalview.io.SequenceAnnotationReport (null).createSequenceAnnotationReport (contents, seq, true, true, false, (this.ap.seqPanel.seqCanvas.fr != null) ? this.ap.seqPanel.seqCanvas.fr.getMinMax () : null); +contents.append ("

"); +} +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, "Sequence Details for " + (sequences.length == 1 ? sequences[0].getDisplayId (true) : "Selection"), 600, 500); +cap.setText (jalview.util.MessageManager.formatMessage ("label.html_content", Clazz.newArray (-1, [contents.toString ()]))); +}, "~A"); +Clazz.defineMethod (c$, "editName", +function () { +var dialog = new jalview.appletgui.EditNameDialog (this.seq.getName (), this.seq.getDescription (), " Sequence Name", "Sequence Description", this.ap.alignFrame, "Edit Sequence Name / Description", 500, 100, true); +if (dialog.accept) { +this.seq.setName (dialog.getName ()); +this.seq.setDescription (dialog.getDescription ()); +this.ap.paintAlignment (false); +}}); +Clazz.defineMethod (c$, "addPDB", +function () { +if (this.seq.getPDBId () != null) { +var entry = this.seq.getPDBId ().firstElement (); +if (this.ap.av.applet.jmolAvailable) { + new jalview.appletgui.AppletJmol (entry, Clazz.newArray (-1, [this.seq]), null, this.ap, jalview.io.AppletFormatAdapter.URL); +}} else { +var cap = new jalview.appletgui.CutAndPasteTransfer (true, this.ap.alignFrame); +cap.setText (jalview.util.MessageManager.getString ("label.paste_pdb_file")); +cap.setPDBImport (this.seq); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.paste_pdb_file_for_sequence", Clazz.newArray (-1, [this.seq.getName ()])), 400, 300); +}}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.groupMenu.setLabel (jalview.util.MessageManager.getString ("label.selection")); +this.sequenceFeature.addActionListener (this); +this.editGroupName.addActionListener (this); +this.unGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_group")); +this.unGroupMenuItem.addActionListener (this); +this.createGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.create_group")); +this.createGroupMenuItem.addActionListener (this); +this.nucleotideMenuItem.setLabel (jalview.util.MessageManager.getString ("label.nucleotide")); +this.nucleotideMenuItem.addActionListener (this); +this.conservationMenuItem.addItemListener (this); +this.abovePIDColour.addItemListener (this); +this.colourMenu.setLabel (jalview.util.MessageManager.getString ("label.group_colour")); +this.showBoxes.setLabel (jalview.util.MessageManager.getString ("action.boxes")); +this.showBoxes.setState (true); +this.showBoxes.addItemListener (this); +this.sequenceName.addActionListener (this); +this.sequenceDetails.addActionListener (this); +this.selSeqDetails.addActionListener (this); +this.displayNonconserved.setLabel (jalview.util.MessageManager.getString ("label.show_non_conversed")); +this.displayNonconserved.setState (false); +this.displayNonconserved.addItemListener (this); +this.showText.setLabel (jalview.util.MessageManager.getString ("action.text")); +this.showText.addItemListener (this); +this.showColourText.setLabel (jalview.util.MessageManager.getString ("label.colour_text")); +this.showColourText.addItemListener (this); +this.outputmenu.setLabel (jalview.util.MessageManager.getString ("label.out_to_textbox")); +this.seqMenu.setLabel (jalview.util.MessageManager.getString ("label.sequence")); +this.pdb.setLabel (jalview.util.MessageManager.getString ("label.view_pdb_structure")); +this.hideSeqs.setLabel (jalview.util.MessageManager.getString ("action.hide_sequences")); +this.repGroup.setLabel (jalview.util.MessageManager.formatMessage ("label.represent_group_with", Clazz.newArray (-1, [""]))); +this.revealAll.setLabel (jalview.util.MessageManager.getString ("action.reveal_all")); +this.revealSeq.setLabel (jalview.util.MessageManager.getString ("action.reveal_sequences")); +this.menu1.setLabel (jalview.util.MessageManager.getString ("label.group") + ":"); +this.add (this.groupMenu); +this.add (this.seqMenu); +this.add (this.hideSeqs); +this.add (this.revealSeq); +this.add (this.revealAll); +this.groupMenu.add (this.groupShowAnnotationsMenu); +this.groupMenu.add (this.groupHideAnnotationsMenu); +this.groupMenu.add (this.groupAddReferenceAnnotations); +this.groupMenu.add (this.editMenu); +this.groupMenu.add (this.outputmenu); +this.groupMenu.add (this.sequenceFeature); +this.groupMenu.add (this.createGroupMenuItem); +this.groupMenu.add (this.unGroupMenuItem); +this.groupMenu.add (this.menu1); +this.colourMenu.add (this.noColourmenuItem); +this.colourMenu.add (this.clustalColour); +this.colourMenu.add (this.BLOSUM62Colour); +this.colourMenu.add (this.PIDColour); +this.colourMenu.add (this.zappoColour); +this.colourMenu.add (this.taylorColour); +this.colourMenu.add (this.hydrophobicityColour); +this.colourMenu.add (this.helixColour); +this.colourMenu.add (this.strandColour); +this.colourMenu.add (this.turnColour); +this.colourMenu.add (this.buriedColour); +this.colourMenu.add (this.nucleotideMenuItem); +this.colourMenu.add (this.userDefinedColour); +this.colourMenu.addSeparator (); +this.colourMenu.add (this.abovePIDColour); +this.colourMenu.add (this.conservationMenuItem); +this.noColourmenuItem.setLabel (jalview.util.MessageManager.getString ("label.none")); +this.noColourmenuItem.addActionListener (this); +this.clustalColour.setLabel (jalview.util.MessageManager.getString ("label.clustalx_colours")); +this.clustalColour.addActionListener (this); +this.zappoColour.setLabel (jalview.util.MessageManager.getString ("label.zappo")); +this.zappoColour.addActionListener (this); +this.taylorColour.setLabel (jalview.util.MessageManager.getString ("label.taylor")); +this.taylorColour.addActionListener (this); +this.hydrophobicityColour.setLabel (jalview.util.MessageManager.getString ("label.hydrophobicity")); +this.hydrophobicityColour.addActionListener (this); +this.helixColour.setLabel (jalview.util.MessageManager.getString ("label.helix_propensity")); +this.helixColour.addActionListener (this); +this.strandColour.setLabel (jalview.util.MessageManager.getString ("label.strand_propensity")); +this.strandColour.addActionListener (this); +this.turnColour.setLabel (jalview.util.MessageManager.getString ("label.turn_propensity")); +this.turnColour.addActionListener (this); +this.buriedColour.setLabel (jalview.util.MessageManager.getString ("label.buried_index")); +this.buriedColour.addActionListener (this); +this.abovePIDColour.setLabel (jalview.util.MessageManager.getString ("label.above_identity_percentage")); +this.userDefinedColour.setLabel (jalview.util.MessageManager.getString ("action.user_defined")); +this.userDefinedColour.addActionListener (this); +this.PIDColour.setLabel (jalview.util.MessageManager.getString ("action.percentage_identity")); +this.PIDColour.addActionListener (this); +this.BLOSUM62Colour.setLabel ("BLOSUM62"); +this.BLOSUM62Colour.addActionListener (this); +this.conservationMenuItem.setLabel (jalview.util.MessageManager.getString ("label.conservation")); +this.editMenu.add (this.copy); +this.copy.addActionListener (this); +this.editMenu.add (this.cut); +this.cut.addActionListener (this); +this.editMenu.add (this.editSequence); +this.editSequence.addActionListener (this); +this.editMenu.add (this.toUpper); +this.toUpper.addActionListener (this); +this.editMenu.add (this.toLower); +this.toLower.addActionListener (this); +this.editMenu.add (this.toggleCase); +this.seqMenu.add (this.seqShowAnnotationsMenu); +this.seqMenu.add (this.seqHideAnnotationsMenu); +this.seqMenu.add (this.seqAddReferenceAnnotations); +this.seqMenu.add (this.sequenceName); +this.seqMenu.add (this.makeReferenceSeq); +if (!this.ap.av.applet.useXtrnalSviewer) { +this.seqMenu.add (this.pdb); +}this.seqMenu.add (this.repGroup); +this.menu1.add (this.editGroupName); +this.menu1.add (this.colourMenu); +this.menu1.add (this.showBoxes); +this.menu1.add (this.showText); +this.menu1.add (this.showColourText); +this.menu1.add (this.displayNonconserved); +this.toggleCase.addActionListener (this); +this.pdb.addActionListener (this); +this.hideSeqs.addActionListener (this); +this.repGroup.addActionListener (this); +this.revealAll.addActionListener (this); +this.revealSeq.addActionListener (this); +this.makeReferenceSeq.addActionListener (this); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "refresh", +function () { +this.ap.paintAlignment (true); +}); +Clazz.defineMethod (c$, "clustalColour_actionPerformed", +function () { +var sg = this.getGroup (); +sg.cs = new jalview.schemes.ClustalxColourScheme (sg, this.ap.av.getHiddenRepSequences ()); +this.refresh (); +}); +Clazz.defineMethod (c$, "zappoColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.ZappoColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "taylorColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.TaylorColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "hydrophobicityColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.HydrophobicColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "helixColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.HelixColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "strandColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.StrandColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "turnColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.TurnColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "buriedColour_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.BuriedColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "nucleotideMenuItem_actionPerformed", +function () { +this.getGroup ().cs = new jalview.schemes.NucleotideColourScheme (); +this.refresh (); +}); +Clazz.defineMethod (c$, "abovePIDColour_itemStateChanged", +function () { +var sg = this.getGroup (); +if (sg.cs == null) { +return; +}if (this.abovePIDColour.getState ()) { +sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ())); +var threshold = jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, sg.cs, this.getGroup ().getName ()); +sg.cs.setThreshold (threshold, this.ap.av.isIgnoreGapsConsensus ()); +jalview.appletgui.SliderPanel.showPIDSlider (); +} else { +sg.cs.setThreshold (0, this.ap.av.isIgnoreGapsConsensus ()); +}this.refresh (); +}); +Clazz.defineMethod (c$, "userDefinedColour_actionPerformed", +function () { + new jalview.appletgui.UserDefinedColours (this.ap, this.getGroup ()); +}); +Clazz.defineMethod (c$, "PIDColour_actionPerformed", +function () { +var sg = this.getGroup (); +sg.cs = new jalview.schemes.PIDColourScheme (); +sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ())); +this.refresh (); +}); +Clazz.defineMethod (c$, "BLOSUM62Colour_actionPerformed", +function () { +var sg = this.getGroup (); +sg.cs = new jalview.schemes.Blosum62ColourScheme (); +sg.cs.setConsensus (jalview.analysis.AAFrequency.calculate (sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth ())); +this.refresh (); +}); +Clazz.defineMethod (c$, "noColourmenuItem_actionPerformed", +function () { +this.getGroup ().cs = null; +this.refresh (); +}); +Clazz.defineMethod (c$, "conservationMenuItem_itemStateChanged", +function () { +var sg = this.getGroup (); +if (sg.cs == null) { +return; +}if (this.conservationMenuItem.getState ()) { +sg.cs.setConservation (jalview.analysis.Conservation.calculateConservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (this.ap.av.getHiddenRepSequences ()), 0, this.ap.av.getAlignment ().getWidth (), false, this.ap.av.getConsPercGaps (), false)); +jalview.appletgui.SliderPanel.setConservationSlider (this.ap, sg.cs, sg.getName ()); +jalview.appletgui.SliderPanel.showConservationSlider (); +} else { +sg.cs.setConservation (null); +}this.refresh (); +}); +Clazz.defineMethod (c$, "getGroup", +function () { +var sg = this.ap.av.getSelectionGroup (); +if (sg != null) { +this.ap.av.getAlignment ().addGroup (sg); +}return sg; +}); +Clazz.defineMethod (c$, "unGroupMenuItem_actionPerformed", +function () { +var sg = this.ap.av.getSelectionGroup (); +this.ap.av.getAlignment ().deleteGroup (sg); +this.ap.av.setSelectionGroup (null); +this.ap.paintAlignment (true); +}); +Clazz.defineMethod (c$, "createGroupMenuItem_actionPerformed", +function () { +this.getGroup (); +this.refresh (); +}); +Clazz.defineMethod (c$, "showColourText_itemStateChanged", +function () { +this.getGroup ().setColourText (this.showColourText.getState ()); +this.refresh (); +}); +Clazz.defineMethod (c$, "showText_itemStateChanged", +function () { +this.getGroup ().setDisplayText (this.showText.getState ()); +this.refresh (); +}); +Clazz.defineMethod (c$, "makeReferenceSeq_actionPerformed", +function () { +if (!this.ap.av.getAlignment ().hasSeqrep ()) { +this.ap.av.setDisplayReferenceSeq (true); +this.ap.av.setColourByReferenceSeq (true); +this.ap.av.getAlignment ().setSeqrep (this.seq); +} else { +if (this.ap.av.getAlignment ().getSeqrep () === this.seq) { +this.ap.av.getAlignment ().setSeqrep (null); +} else { +this.ap.av.getAlignment ().setSeqrep (this.seq); +}}this.refresh (); +}); +Clazz.defineMethod (c$, "showNonconserved_itemStateChanged", +function () { +this.getGroup ().setShowNonconserved (this.displayNonconserved.getState ()); +this.refresh (); +}); +Clazz.defineMethod (c$, "showBoxes_itemStateChanged", +function () { +this.getGroup ().setDisplayBoxes (this.showBoxes.getState ()); +this.refresh (); +}); +Clazz.defineMethod (c$, "hideSequences", +function (representGroup) { +var sg = this.ap.av.getSelectionGroup (); +if (sg == null || sg.getSize () < 1) { +this.ap.av.hideSequence ( Clazz.newArray (-1, [this.seq])); +return; +}this.ap.av.setSelectionGroup (null); +if (representGroup) { +this.ap.av.hideRepSequences (this.seq, sg); +return; +}var gsize = sg.getSize (); +var hseqs; +hseqs = new Array (gsize); +var index = 0; +for (var i = 0; i < gsize; i++) { +hseqs[index++] = sg.getSequenceAt (i); +} +this.ap.av.hideSequence (hseqs); +this.ap.av.sendSelection (); +}, "~B"); +Clazz.defineMethod (c$, "buildAnnotationTypesMenus", +function (showMenu, hideMenu, forSequences) { +showMenu.removeAll (); +hideMenu.removeAll (); +var all = java.util.Arrays.asList (["All"]); +this.addAnnotationTypeToShowHide (showMenu, forSequences, "", all, true, true); +this.addAnnotationTypeToShowHide (hideMenu, forSequences, "", all, true, false); +showMenu.addSeparator (); +hideMenu.addSeparator (); +var annotations = this.ap.getAlignment ().getAlignmentAnnotation (); +var shownTypes = new java.util.LinkedHashMap (); +var hiddenTypes = new java.util.LinkedHashMap (); +jalview.analysis.AlignmentAnnotationUtils.getShownHiddenTypes (shownTypes, hiddenTypes, jalview.analysis.AlignmentAnnotationUtils.asList (annotations), forSequences); +for (var calcId, $calcId = hiddenTypes.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) { +for (var type, $type = hiddenTypes.get (calcId).iterator (); $type.hasNext () && ((type = $type.next ()) || true);) { +this.addAnnotationTypeToShowHide (showMenu, forSequences, calcId, type, false, true); +} +} +showMenu.setEnabled (!hiddenTypes.isEmpty ()); +for (var calcId, $calcId = shownTypes.keySet ().iterator (); $calcId.hasNext () && ((calcId = $calcId.next ()) || true);) { +for (var type, $type = shownTypes.get (calcId).iterator (); $type.hasNext () && ((type = $type.next ()) || true);) { +this.addAnnotationTypeToShowHide (hideMenu, forSequences, calcId, type, false, false); +} +} +hideMenu.setEnabled (!shownTypes.isEmpty ()); +}, "awt2swing.Menu,awt2swing.Menu,java.util.List"); +Clazz.defineMethod (c$, "addAnnotationTypeToShowHide", +function (showOrHideMenu, forSequences, calcId, types, allTypes, actionIsShow) { +var label = types.toString (); +label = label.substring (1, label.length - 1); +var item = new awt2swing.MenuItem (label); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.APopupMenu$3") ? 0 : jalview.appletgui.APopupMenu.$APopupMenu$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.APopupMenu$3, this, Clazz.cloneFinals ("types", types, "forSequences", forSequences, "allTypes", allTypes, "actionIsShow", actionIsShow)))); +showOrHideMenu.add (item); +}, "awt2swing.Menu,java.util.List,~S,java.util.List,~B,~B"); +c$.$APopupMenu$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$1", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.APopupMenu"].addReferenceAnnotations_actionPerformed (this.f$.candidates); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$APopupMenu$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$2", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.APopupMenu"].ap.alignFrame.showURL (this.f$.url, this.f$.target); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$APopupMenu$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "APopupMenu$3", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +jalview.analysis.AlignmentUtils.showOrHideSequenceAnnotations (this.b$["jalview.appletgui.APopupMenu"].ap.getAlignment (), this.f$.types, this.f$.forSequences, this.f$.allTypes, this.f$.actionIsShow); +this.b$["jalview.appletgui.APopupMenu"].refresh (); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"ALL_ANNOTATIONS", "All"); +}); diff --git a/bin/jalview/appletgui/AlignFrame.js b/bin/jalview/appletgui/AlignFrame.js index f3c3d8e..7221f66 100644 --- a/bin/jalview/appletgui/AlignFrame.js +++ b/bin/jalview/appletgui/AlignFrame.js @@ -1,2390 +1,2390 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Canvas", "jalview.api.AlignViewControllerGuiI", "jalview.appletgui.EmbmenuFrame", "java.awt.event.ActionListener", "$.ItemListener", "$.KeyListener", "awt2swing.CheckboxMenuItem", "$.Label", "$.Menu", "$.MenuBar", "$.MenuItem", "jalview.util.MessageManager", "java.awt.BorderLayout"], "jalview.appletgui.AlignFrame", ["awt2swing.Frame", "jalview.analysis.AlignmentSorter", "$.AnnotationSorter", "jalview.appletgui.AlignViewport", "$.AlignmentPanel", "$.AnnotationColourChooser", "$.AnnotationColumnChooser", "$.AppletJmol", "$.CutAndPasteTransfer", "$.FeatureSettings", "$.Finder", "$.FontChooser", "$.OverviewPanel", "$.PCAPanel", "$.PaintRefresher", "$.PairwiseAlignPanel", "$.RedundancyPanel", "$.SliderPanel", "$.TreePanel", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.commands.EditCommand", "$.OrderCommand", "$.RemoveGapColCommand", "$.RemoveGapsCommand", "$.SlideSequencesCommand", "$.TrimRegionCommand", "jalview.controller.AlignViewController", "jalview.datamodel.Alignment", "$.PDBEntry", "$.Sequence", "$.SequenceGroup", "jalview.io.AlignmentProperties", "$.AnnotationFile", "$.AppletFormatAdapter", "$.FeaturesFile", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.PurinePyrimidineColourScheme", "$.RNAHelicesColourChooser", "$.RNAInteractionColourScheme", "$.StrandColourScheme", "$.TCoffeeColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.ZappoColourScheme", "jalview.structure.StructureSelectionManager", "jalview.util.Comparison", "$.MappingUtils", "java.awt.Color", "$.Font", "java.awt.event.FocusListener", "$.WindowAdapter", "java.lang.Character", "$.StringBuffer", "java.net.URL", "$.URLEncoder", "java.util.Arrays", "$.HashMap", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.avc = null; -this.alignPanel = null; -this.viewport = null; -this.frameWidth = 700; -this.frameHeight = 500; -this.jalviewServletURL = null; -this.showAutoCalculatedAbove = false; -this.annotationSortOrder = null; -this.alignFrameMenuBar = null; -this.fileMenu = null; -this.loadApplication = null; -this.$loadTree = null; -this.$loadAnnotations = null; -this.$outputFeatures = null; -this.$outputAnnotations = null; -this.closeMenuItem = null; -this.selectAllSequenceMenuItem = null; -this.deselectAllSequenceMenuItem = null; -this.invertSequenceMenuItem = null; -this.remove2LeftMenuItem = null; -this.remove2RightMenuItem = null; -this.removeGappedColumnMenuItem = null; -this.removeAllGapsMenuItem = null; -this.viewBoxesMenuItem = null; -this.viewTextMenuItem = null; -this.sortPairwiseMenuItem = null; -this.sortIDMenuItem = null; -this.sortLengthMenuItem = null; -this.sortGroupMenuItem = null; -this.removeRedundancyMenuItem = null; -this.pairwiseAlignmentMenuItem = null; -this.PCAMenuItem = null; -this.averageDistanceTreeMenuItem = null; -this.neighbourTreeMenuItem = null; -this.borderLayout1 = null; -this.statusBar = null; -this.clustalColour = null; -this.zappoColour = null; -this.taylorColour = null; -this.hydrophobicityColour = null; -this.helixColour = null; -this.strandColour = null; -this.turnColour = null; -this.buriedColour = null; -this.purinePyrimidineColour = null; -this.RNAInteractionColour = null; -this.RNAHelixColour = null; -this.userDefinedColour = null; -this.PIDColour = null; -this.BLOSUM62Colour = null; -this.tcoffeeColour = null; -this.njTreeBlosumMenuItem = null; -this.avDistanceTreeBlosumMenuItem = null; -this.annotationPanelMenuItem = null; -this.colourTextMenuItem = null; -this.displayNonconservedMenuItem = null; -this.alProperties = null; -this.overviewMenuItem = null; -this.undoMenuItem = null; -this.redoMenuItem = null; -this.conservationMenuItem = null; -this.noColourmenuItem = null; -this.wrapMenuItem = null; -this.renderGapsMenuItem = null; -this.findMenuItem = null; -this.abovePIDThreshold = null; -this.nucleotideColour = null; -this.deleteGroups = null; -this.grpsFromSelection = null; -this.createGroup = null; -this.unGroup = null; -this.$delete = null; -this.copy = null; -this.cut = null; -this.pasteMenu = null; -this.pasteNew = null; -this.pasteThis = null; -this.applyToAllGroups = null; -this.$font = null; -this.scaleAbove = null; -this.scaleLeft = null; -this.scaleRight = null; -this.modifyPID = null; -this.modifyConservation = null; -this.autoCalculate = null; -this.$sortByTree = null; -this.sortByTreeMenu = null; -this.inputText = null; -this.documentation = null; -this.about = null; -this.seqLimits = null; -this.centreColumnLabelFlag = null; -this.followMouseOverFlag = null; -this.showSequenceLogo = null; -this.applyAutoAnnotationSettings = null; -this.showConsensusHistogram = null; -this.showGroupConsensus = null; -this.showGroupConservation = null; -this.normSequenceLogo = null; -this.featureSettings = null; -this.sequenceFeatures = null; -this.annotationColour = null; -this.annotationColumnSelection = null; -this.invertColSel = null; -this.showColumns = null; -this.showSeqs = null; -this.hideColumns = null; -this.hideSequences = null; -this.hideAllButSelection = null; -this.hideAllSelection = null; -this.showAllHidden = null; -this.$newView = null; -this.showAlignmentAnnotations = null; -this.showSequenceAnnotations = null; -this.sortAnnBySequence = null; -this.sortAnnByLabel = null; -this.showAutoFirst = null; -this.showAutoLast = null; -this.splitFrame = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AlignFrame", jalview.appletgui.EmbmenuFrame, [java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, jalview.api.AlignViewControllerGuiI]); -Clazz.prepareFields (c$, function () { -this.alignFrameMenuBar = new awt2swing.MenuBar (); -this.fileMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.file")); -this.loadApplication = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.view_full_application")); -this.$loadTree = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.load_associated_tree")); -this.$loadAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.load_features_annotations")); -this.$outputFeatures = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.export_features").concat ("...")); -this.$outputAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.export_annotations").concat ("...")); -this.closeMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.close")); -this.selectAllSequenceMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.select_all")); -this.deselectAllSequenceMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.deselect_all")); -this.invertSequenceMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.invert_selection")); -this.remove2LeftMenuItem = new awt2swing.MenuItem (); -this.remove2RightMenuItem = new awt2swing.MenuItem (); -this.removeGappedColumnMenuItem = new awt2swing.MenuItem (); -this.removeAllGapsMenuItem = new awt2swing.MenuItem (); -this.viewBoxesMenuItem = new awt2swing.CheckboxMenuItem (); -this.viewTextMenuItem = new awt2swing.CheckboxMenuItem (); -this.sortPairwiseMenuItem = new awt2swing.MenuItem (); -this.sortIDMenuItem = new awt2swing.MenuItem (); -this.sortLengthMenuItem = new awt2swing.MenuItem (); -this.sortGroupMenuItem = new awt2swing.MenuItem (); -this.removeRedundancyMenuItem = new awt2swing.MenuItem (); -this.pairwiseAlignmentMenuItem = new awt2swing.MenuItem (); -this.PCAMenuItem = new awt2swing.MenuItem (); -this.averageDistanceTreeMenuItem = new awt2swing.MenuItem (); -this.neighbourTreeMenuItem = new awt2swing.MenuItem (); -this.borderLayout1 = new java.awt.BorderLayout (); -this.statusBar = new awt2swing.Label (); -this.clustalColour = new awt2swing.MenuItem (); -this.zappoColour = new awt2swing.MenuItem (); -this.taylorColour = new awt2swing.MenuItem (); -this.hydrophobicityColour = new awt2swing.MenuItem (); -this.helixColour = new awt2swing.MenuItem (); -this.strandColour = new awt2swing.MenuItem (); -this.turnColour = new awt2swing.MenuItem (); -this.buriedColour = new awt2swing.MenuItem (); -this.purinePyrimidineColour = new awt2swing.MenuItem (); -this.RNAInteractionColour = new awt2swing.MenuItem (); -this.RNAHelixColour = new awt2swing.MenuItem (); -this.userDefinedColour = new awt2swing.MenuItem (); -this.PIDColour = new awt2swing.MenuItem (); -this.BLOSUM62Colour = new awt2swing.MenuItem (); -this.tcoffeeColour = new awt2swing.MenuItem (); -this.njTreeBlosumMenuItem = new awt2swing.MenuItem (); -this.avDistanceTreeBlosumMenuItem = new awt2swing.MenuItem (); -this.annotationPanelMenuItem = new awt2swing.CheckboxMenuItem (); -this.colourTextMenuItem = new awt2swing.CheckboxMenuItem (); -this.displayNonconservedMenuItem = new awt2swing.CheckboxMenuItem (); -this.alProperties = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.alignment_props")); -this.overviewMenuItem = new awt2swing.MenuItem (); -this.undoMenuItem = new awt2swing.MenuItem (); -this.redoMenuItem = new awt2swing.MenuItem (); -this.conservationMenuItem = new awt2swing.CheckboxMenuItem (); -this.noColourmenuItem = new awt2swing.MenuItem (); -this.wrapMenuItem = new awt2swing.CheckboxMenuItem (); -this.renderGapsMenuItem = new awt2swing.CheckboxMenuItem (); -this.findMenuItem = new awt2swing.MenuItem (); -this.abovePIDThreshold = new awt2swing.CheckboxMenuItem (); -this.nucleotideColour = new awt2swing.MenuItem (); -this.deleteGroups = new awt2swing.MenuItem (); -this.grpsFromSelection = new awt2swing.MenuItem (); -this.createGroup = new awt2swing.MenuItem (); -this.unGroup = new awt2swing.MenuItem (); -this.$delete = new awt2swing.MenuItem (); -this.copy = new awt2swing.MenuItem (); -this.cut = new awt2swing.MenuItem (); -this.pasteMenu = new awt2swing.Menu (); -this.pasteNew = new awt2swing.MenuItem (); -this.pasteThis = new awt2swing.MenuItem (); -this.applyToAllGroups = new awt2swing.CheckboxMenuItem (); -this.$font = new awt2swing.MenuItem (); -this.scaleAbove = new awt2swing.CheckboxMenuItem (); -this.scaleLeft = new awt2swing.CheckboxMenuItem (); -this.scaleRight = new awt2swing.CheckboxMenuItem (); -this.modifyPID = new awt2swing.MenuItem (); -this.modifyConservation = new awt2swing.MenuItem (); -this.$sortByTree = new awt2swing.CheckboxMenuItem ("Sort Alignment With New Tree", true); -this.sortByTreeMenu = new awt2swing.Menu (); -this.inputText = new awt2swing.MenuItem (); -this.documentation = new awt2swing.MenuItem (); -this.about = new awt2swing.MenuItem (); -this.seqLimits = new awt2swing.CheckboxMenuItem (); -this.centreColumnLabelFlag = new awt2swing.CheckboxMenuItem (); -this.followMouseOverFlag = new awt2swing.CheckboxMenuItem (); -this.showSequenceLogo = new awt2swing.CheckboxMenuItem (); -this.applyAutoAnnotationSettings = new awt2swing.CheckboxMenuItem (); -this.showConsensusHistogram = new awt2swing.CheckboxMenuItem (); -this.showGroupConsensus = new awt2swing.CheckboxMenuItem (); -this.showGroupConservation = new awt2swing.CheckboxMenuItem (); -this.normSequenceLogo = new awt2swing.CheckboxMenuItem (); -this.featureSettings = new awt2swing.MenuItem (); -this.sequenceFeatures = new awt2swing.CheckboxMenuItem (); -this.annotationColour = new awt2swing.MenuItem (); -this.annotationColumnSelection = new awt2swing.MenuItem (); -this.invertColSel = new awt2swing.MenuItem (); -this.showColumns = new awt2swing.MenuItem (); -this.showSeqs = new awt2swing.MenuItem (); -this.hideColumns = new awt2swing.MenuItem (); -this.hideSequences = new awt2swing.MenuItem (); -this.hideAllButSelection = new awt2swing.MenuItem (); -this.hideAllSelection = new awt2swing.MenuItem (); -this.showAllHidden = new awt2swing.MenuItem (); -this.$newView = new awt2swing.MenuItem (); -}); -Clazz.makeConstructor (c$, -function (al, applet, title, embedded) { -this.construct (al, applet, title, embedded, true); -}, "jalview.datamodel.AlignmentI,jalview.bin.JalviewLite,~S,~B"); -Clazz.makeConstructor (c$, -function (al, applet, title, embedded, addToDisplay) { -this.construct (al, null, null, applet, title, embedded, addToDisplay); -}, "jalview.datamodel.AlignmentI,jalview.bin.JalviewLite,~S,~B,~B"); -Clazz.makeConstructor (c$, -function (al, hiddenSeqs, columnSelection, applet, title, embedded) { -this.construct (al, hiddenSeqs, columnSelection, applet, title, embedded, true); -}, "jalview.datamodel.AlignmentI,~A,jalview.datamodel.ColumnSelection,jalview.bin.JalviewLite,~S,~B"); -Clazz.makeConstructor (c$, -function (al, hiddenSeqs, columnSelection, applet, title, embedded, addToDisplay) { -Clazz.superConstructor (this, jalview.appletgui.AlignFrame, []); -if (applet != null) { -this.jalviewServletURL = applet.jalviewServletURL; -}try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -if (applet != null) { -var param; -try { -param = applet.windowWidth; -if (param != null) { -var width = Integer.parseInt (param); -this.frameWidth = width; -}param = applet.windowHeight; -if (param != null) { -var height = Integer.parseInt (param); -this.frameHeight = height; -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -}this.viewport = new jalview.appletgui.AlignViewport (al, applet); -if (hiddenSeqs != null && hiddenSeqs.length > 0) { -this.viewport.hideSequence (hiddenSeqs); -}if (columnSelection != null) { -this.viewport.setColumnSelection (columnSelection); -}this.alignPanel = new jalview.appletgui.AlignmentPanel (this, this.viewport); -this.avc = new jalview.controller.AlignViewController (this, this.viewport, this.alignPanel); -this.viewport.updateConservation (this.alignPanel); -this.viewport.updateConsensus (this.alignPanel); -this.displayNonconservedMenuItem.setState (this.viewport.getShowUnconserved ()); -this.followMouseOverFlag.setState (this.viewport.isFollowHighlight ()); -this.showGroupConsensus.setState (this.viewport.isShowGroupConsensus ()); -this.showGroupConservation.setState (this.viewport.isShowGroupConservation ()); -this.showConsensusHistogram.setState (this.viewport.isShowConsensusHistogram ()); -this.showSequenceLogo.setState (this.viewport.isShowSequenceLogo ()); -this.normSequenceLogo.setState (this.viewport.isNormaliseSequenceLogo ()); -this.applyToAllGroups.setState (this.viewport.getColourAppliesToAllGroups ()); -this.annotationPanelMenuItem.setState (this.viewport.isShowAnnotation ()); -this.showAlignmentAnnotations.setState (this.viewport.isShowAnnotation ()); -this.showSequenceAnnotations.setState (this.viewport.isShowAnnotation ()); -this.seqLimits.setState (this.viewport.getShowJVSuffix ()); -if (applet != null) { -var param = applet.sortBy; -if (param != null) { -if (param.equalsIgnoreCase ("Id")) { -this.sortIDMenuItem_actionPerformed (); -} else if (param.equalsIgnoreCase ("Pairwise Identity")) { -this.sortPairwiseMenuItem_actionPerformed (); -} else if (param.equalsIgnoreCase ("Length")) { -this.sortLengthMenuItem_actionPerformed (); -}}param = applet.wrap; -if (param != null) { -if (param.equalsIgnoreCase ("true")) { -this.wrapMenuItem.setState (true); -this.wrapMenuItem_actionPerformed (); -}}param = applet.centrecolumnlabels; -if (param != null) { -this.centreColumnLabelFlag.setState (true); -this.centreColumnLabelFlag_stateChanged (); -}}if (this.viewport.getAlignment ().isNucleotide ()) { -this.viewport.updateStrucConsensus (this.alignPanel); -if (this.viewport.getAlignment ().hasRNAStructure ()) { -this.RNAHelixColour.setEnabled (true); -} else { -this.RNAHelixColour.setEnabled (false); -}} else { -this.RNAHelixColour.setEnabled (false); -this.purinePyrimidineColour.setEnabled (false); -}this.addKeyListener (this); -this.alignPanel.seqPanel.seqCanvas.addKeyListener (this); -this.alignPanel.idPanel.idCanvas.addKeyListener (this); -this.alignPanel.scalePanel.addKeyListener (this); -this.alignPanel.annotationPanel.addKeyListener (this); -this.alignPanel.annotationPanelHolder.addKeyListener (this); -this.alignPanel.annotationSpaceFillerHolder.addKeyListener (this); -this.alignPanel.alabels.addKeyListener (this); -if (addToDisplay) { -this.addToDisplay (embedded); -}}, "jalview.datamodel.AlignmentI,~A,jalview.datamodel.ColumnSelection,jalview.bin.JalviewLite,~S,~B,~B"); -Clazz.defineMethod (c$, "addToDisplay", -function (embedded) { -this.createAlignFrameWindow (embedded); -this.validate (); -this.alignPanel.adjustAnnotationHeight (); -this.alignPanel.paintAlignment (true); -}, "~B"); -Clazz.defineMethod (c$, "getAlignViewport", -function () { -return this.viewport; -}); -Clazz.defineMethod (c$, "getSeqcanvas", -function () { -return this.alignPanel.seqPanel.seqCanvas; -}); -Clazz.defineMethod (c$, "parseFeaturesFile", -function (file, type) { -return this.parseFeaturesFile (file, type, true); -}, "~S,~S"); -Clazz.defineMethod (c$, "parseFeaturesFile", -function (file, type, autoenabledisplay) { -var featureLinks = new java.util.Hashtable (); -var featuresFile = false; -try { -featuresFile = new jalview.io.FeaturesFile (file, type).parse (this.viewport.getAlignment (), this.alignPanel.seqPanel.seqCanvas.getFeatureRenderer ().getFeatureColours (), featureLinks, true, this.viewport.applet.getDefaultParameter ("relaxedidmatch", false)); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -if (featuresFile) { -if (featureLinks.size () > 0) { -this.alignPanel.seqPanel.seqCanvas.getFeatureRenderer ().featureLinks = featureLinks; -}if (autoenabledisplay) { -this.viewport.setShowSequenceFeatures (true); -this.sequenceFeatures.setState (true); -}if (this.alignPanel.seqPanel.seqCanvas.fr != null) { -this.alignPanel.seqPanel.seqCanvas.fr.findAllFeatures (true); -}if (this.viewport.featureSettings != null) { -this.viewport.featureSettings.refreshTable (); -}this.alignPanel.paintAlignment (true); -this.setStatus (jalview.util.MessageManager.getString ("label.successfully_added_features_alignment")); -}return featuresFile; -}, "~S,~S,~B"); -Clazz.overrideMethod (c$, "keyPressed", -function (evt) { -if (this.viewport.cursorMode && ((evt.getKeyCode () >= 48 && evt.getKeyCode () <= 57) || (evt.getKeyCode () >= 96 && evt.getKeyCode () <= 105)) && Character.isDigit (evt.getKeyChar ())) { -this.alignPanel.seqPanel.numberPressed (evt.getKeyChar ()); -}switch (evt.getKeyCode ()) { -case 27: -this.deselectAllSequenceMenuItem_actionPerformed (); -this.alignPanel.alabels.cancelDrag (); -break; -case 88: -if (evt.isControlDown () || evt.isMetaDown ()) { -this.cut_actionPerformed (); -}break; -case 67: -if (this.viewport.cursorMode && !evt.isControlDown ()) { -this.alignPanel.seqPanel.setCursorColumn (); -}if (evt.isControlDown () || evt.isMetaDown ()) { -this.copy_actionPerformed (); -}break; -case 86: -if (evt.isControlDown ()) { -this.paste (evt.isShiftDown ()); -}break; -case 65: -if (evt.isControlDown () || evt.isMetaDown ()) { -this.selectAllSequenceMenuItem_actionPerformed (); -}break; -case 40: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.moveCursor (0, 1); -} else { -this.moveSelectedSequences (false); -}break; -case 38: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.moveCursor (0, -1); -} else { -this.moveSelectedSequences (true); -}break; -case 37: -if (evt.isAltDown () || !this.viewport.cursorMode) { -this.slideSequences (false, this.alignPanel.seqPanel.getKeyboardNo1 ()); -} else { -this.alignPanel.seqPanel.moveCursor (-1, 0); -}break; -case 39: -if (evt.isAltDown () || !this.viewport.cursorMode) { -this.slideSequences (true, this.alignPanel.seqPanel.getKeyboardNo1 ()); -} else { -this.alignPanel.seqPanel.moveCursor (1, 0); -}break; -case 32: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.insertGapAtCursor (evt.isControlDown () || evt.isShiftDown () || evt.isAltDown ()); -}break; -case 127: -case 8: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.deleteGapAtCursor (evt.isControlDown () || evt.isShiftDown () || evt.isAltDown ()); -} else { -this.cut_actionPerformed (); -this.alignPanel.seqPanel.seqCanvas.repaint (); -}break; -case 83: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.setCursorRow (); -}break; -case 80: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.setCursorPosition (); -}break; -case 10: -case 44: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.setCursorRowAndColumn (); -}break; -case 81: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.setSelectionAreaAtCursor (true); -}break; -case 77: -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.setSelectionAreaAtCursor (false); -}break; -case 113: -this.viewport.cursorMode = !this.viewport.cursorMode; -this.setStatus (jalview.util.MessageManager.formatMessage ("label.keyboard_editing_mode", Clazz.newArray (-1, [(this.viewport.cursorMode ? "on" : "off")]))); -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.seqCanvas.cursorX = this.viewport.startRes; -this.alignPanel.seqPanel.seqCanvas.cursorY = this.viewport.startSeq; -}break; -case 70: -if (evt.isControlDown ()) { -this.findMenuItem_actionPerformed (); -}break; -case 72: -{ -var toggleSeqs = !evt.isControlDown (); -var toggleCols = !evt.isShiftDown (); -this.toggleHiddenRegions (toggleSeqs, toggleCols); -break; -}case 33: -if (this.viewport.getWrapAlignment ()) { -this.alignPanel.scrollUp (true); -} else { -this.alignPanel.setScrollValues (this.viewport.startRes, this.viewport.startSeq - this.viewport.endSeq + this.viewport.startSeq); -}break; -case 34: -if (this.viewport.getWrapAlignment ()) { -this.alignPanel.scrollUp (false); -} else { -this.alignPanel.setScrollValues (this.viewport.startRes, this.viewport.startSeq + this.viewport.endSeq - this.viewport.startSeq); -}break; -case 90: -if (evt.isControlDown ()) { -this.undoMenuItem_actionPerformed (); -}break; -case 89: -if (evt.isControlDown ()) { -this.redoMenuItem_actionPerformed (); -}break; -case 76: -if (evt.isControlDown ()) { -this.trimAlignment (true); -}break; -case 82: -if (evt.isControlDown ()) { -this.trimAlignment (false); -}break; -case 69: -if (evt.isControlDown ()) { -if (evt.isShiftDown ()) { -this.removeAllGapsMenuItem_actionPerformed (); -} else { -this.removeGappedColumnMenuItem_actionPerformed (); -}}break; -case 73: -if (evt.isControlDown ()) { -if (evt.isAltDown ()) { -this.invertColSel_actionPerformed (); -} else { -this.invertSequenceMenuItem_actionPerformed (); -}}break; -case 71: -if (evt.isControlDown ()) { -if (evt.isShiftDown ()) { -this.unGroup_actionPerformed (); -} else { -this.createGroup_actionPerformed (); -}}break; -case 85: -if (evt.isControlDown ()) { -this.deleteGroups_actionPerformed (); -}break; -case 84: -if (evt.isControlDown ()) { -this.newView (null); -}break; -} -this.alignPanel.paintAlignment (true); -}, "java.awt.event.KeyEvent"); -Clazz.defineMethod (c$, "toggleHiddenRegions", -($fz = function (toggleSeqs, toggleCols) { -var hide = false; -var sg = this.viewport.getSelectionGroup (); -if (!toggleSeqs && !toggleCols) { -if ((this.viewport.getColumnSelection () != null && this.viewport.getColumnSelection ().getSelected () != null && this.viewport.getColumnSelection ().getSelected ().size () > 0) || (sg != null && sg.getSize () > 0 && sg.getStartRes () <= sg.getEndRes ())) { -if (sg != null) { -this.invertSequenceMenuItem_actionPerformed (); -sg = this.viewport.getSelectionGroup (); -toggleSeqs = true; -}this.viewport.expandColSelection (sg, true); -this.invertColSel_actionPerformed (); -toggleCols = true; -}}if (toggleSeqs) { -if (sg != null && sg.getSize () != this.viewport.getAlignment ().getHeight ()) { -hide = true; -this.viewport.hideAllSelectedSeqs (); -} else if (!(toggleCols && this.viewport.getColumnSelection ().getSelected ().size () > 0)) { -this.viewport.showAllHiddenSeqs (); -}}if (toggleCols) { -if (this.viewport.getColumnSelection ().getSelected ().size () > 0) { -this.viewport.hideSelectedColumns (); -if (!toggleSeqs) { -this.viewport.setSelectionGroup (sg); -}} else if (!hide) { -this.viewport.showAllHiddenColumns (); -}}}, $fz.isPrivate = true, $fz), "~B,~B"); -Clazz.overrideMethod (c$, "keyReleased", -function (evt) { -}, "java.awt.event.KeyEvent"); -Clazz.overrideMethod (c$, "keyTyped", -function (evt) { -}, "java.awt.event.KeyEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -var source = evt.getSource (); -if (source === this.displayNonconservedMenuItem) { -this.displayNonconservedMenuItem_actionPerformed (); -} else if (source === this.colourTextMenuItem) { -this.colourTextMenuItem_actionPerformed (); -} else if (source === this.wrapMenuItem) { -this.wrapMenuItem_actionPerformed (); -} else if (source === this.scaleAbove) { -this.viewport.setScaleAboveWrapped (this.scaleAbove.getState ()); -} else if (source === this.scaleLeft) { -this.viewport.setScaleLeftWrapped (this.scaleLeft.getState ()); -} else if (source === this.scaleRight) { -this.viewport.setScaleRightWrapped (this.scaleRight.getState ()); -} else if (source === this.seqLimits) { -this.seqLimits_itemStateChanged (); -} else if (source === this.viewBoxesMenuItem) { -this.viewport.setShowBoxes (this.viewBoxesMenuItem.getState ()); -} else if (source === this.viewTextMenuItem) { -this.viewport.setShowText (this.viewTextMenuItem.getState ()); -} else if (source === this.renderGapsMenuItem) { -this.viewport.setRenderGaps (this.renderGapsMenuItem.getState ()); -} else if (source === this.annotationPanelMenuItem) { -this.viewport.setShowAnnotation (this.annotationPanelMenuItem.getState ()); -this.alignPanel.setAnnotationVisible (this.annotationPanelMenuItem.getState ()); -} else if (source === this.sequenceFeatures) { -this.viewport.setShowSequenceFeatures (this.sequenceFeatures.getState ()); -this.alignPanel.seqPanel.seqCanvas.repaint (); -} else if (source === this.showAlignmentAnnotations) { -this.setAnnotationsVisibility (); -} else if (source === this.showSequenceAnnotations) { -this.setAnnotationsVisibility (); -} else if (source === this.sortAnnBySequence) { -var newState = this.sortAnnBySequence.getState (); -this.sortAnnByLabel.setState (false); -this.setAnnotationSortOrder (newState ? jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL : jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE); -this.setViewportAnnotationOrder (); -} else if (source === this.sortAnnByLabel) { -var newState = this.sortAnnByLabel.getState (); -this.sortAnnBySequence.setState (false); -this.setAnnotationSortOrder (newState ? jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE : jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE); -this.setViewportAnnotationOrder (); -} else if (source === this.showAutoFirst) { -this.showAutoLast.setState (!this.showAutoFirst.getState ()); -this.setShowAutoCalculatedAbove (this.showAutoFirst.getState ()); -this.setViewportAnnotationOrder (); -} else if (source === this.showAutoLast) { -this.showAutoFirst.setState (!this.showAutoLast.getState ()); -this.setShowAutoCalculatedAbove (this.showAutoFirst.getState ()); -this.setViewportAnnotationOrder (); -} else if (source === this.conservationMenuItem) { -this.conservationMenuItem_actionPerformed (); -} else if (source === this.abovePIDThreshold) { -this.abovePIDThreshold_actionPerformed (); -} else if (source === this.applyToAllGroups) { -this.viewport.setColourAppliesToAllGroups (this.applyToAllGroups.getState ()); -} else if (source === this.autoCalculate) { -this.viewport.autoCalculateConsensus = this.autoCalculate.getState (); -} else if (source === this.$sortByTree) { -this.viewport.sortByTree = this.$sortByTree.getState (); -} else if (source === this.centreColumnLabelFlag) { -this.centreColumnLabelFlag_stateChanged (); -} else if (source === this.followMouseOverFlag) { -this.mouseOverFlag_stateChanged (); -} else if (source === this.showGroupConsensus) { -this.showGroupConsensus_actionPerformed (); -} else if (source === this.showGroupConservation) { -this.showGroupConservation_actionPerformed (); -} else if (source === this.showSequenceLogo) { -this.showSequenceLogo_actionPerformed (); -} else if (source === this.normSequenceLogo) { -this.normSequenceLogo_actionPerformed (); -} else if (source === this.showConsensusHistogram) { -this.showConsensusHistogram_actionPerformed (); -} else if (source === this.applyAutoAnnotationSettings) { -this.applyAutoAnnotationSettings_actionPerformed (); -}this.alignPanel.paintAlignment (true); -}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "setAnnotationsVisibility", -($fz = function () { -var showForAlignment = this.showAlignmentAnnotations.getState (); -var showForSequences = this.showSequenceAnnotations.getState (); -for (var aa, $aa = 0, $$aa = this.alignPanel.getAlignment ().getAlignmentAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { -var visible = (aa.sequenceRef == null ? showForAlignment : showForSequences); -aa.visible = visible; -} -this.alignPanel.validateAnnotationDimensions (true); -this.validate (); -this.repaint (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "setAnnotationSortOrder", -($fz = function (order) { -this.annotationSortOrder = order; -}, $fz.isPrivate = true, $fz), "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); -Clazz.defineMethod (c$, "setViewportAnnotationOrder", -($fz = function () { -this.alignPanel.av.setSortAnnotationsBy (this.annotationSortOrder); -this.alignPanel.av.setShowAutocalculatedAbove (this.showAutoCalculatedAbove); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "setShowAutoCalculatedAbove", -($fz = function (showAbove) { -this.showAutoCalculatedAbove = showAbove; -}, $fz.isPrivate = true, $fz), "~B"); -Clazz.defineMethod (c$, "mouseOverFlag_stateChanged", -($fz = function () { -this.viewport.setFollowHighlight (this.followMouseOverFlag.getState ()); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "centreColumnLabelFlag_stateChanged", -($fz = function () { -this.viewport.centreColumnLabels = this.centreColumnLabelFlag.getState (); -this.alignPanel.annotationPanel.repaint (); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -var source = evt.getSource (); -if (source === this.inputText) { -this.inputText_actionPerformed (); -} else if (source === this.$loadTree) { -this.loadTree_actionPerformed (); -} else if (source === this.loadApplication) { -this.launchFullApplication (); -} else if (source === this.$loadAnnotations) { -this.loadAnnotations (); -} else if (source === this.$outputAnnotations) { -this.outputAnnotations (true); -} else if (source === this.$outputFeatures) { -this.outputFeatures (true, "Jalview"); -} else if (source === this.closeMenuItem) { -this.closeMenuItem_actionPerformed (); -} else if (source === this.copy) { -this.copy_actionPerformed (); -} else if (source === this.undoMenuItem) { -this.undoMenuItem_actionPerformed (); -} else if (source === this.redoMenuItem) { -this.redoMenuItem_actionPerformed (); -} else if (source === this.inputText) { -this.inputText_actionPerformed (); -} else if (source === this.closeMenuItem) { -this.closeMenuItem_actionPerformed (); -} else if (source === this.undoMenuItem) { -this.undoMenuItem_actionPerformed (); -} else if (source === this.redoMenuItem) { -this.redoMenuItem_actionPerformed (); -} else if (source === this.copy) { -this.copy_actionPerformed (); -} else if (source === this.pasteNew) { -this.pasteNew_actionPerformed (); -} else if (source === this.pasteThis) { -this.pasteThis_actionPerformed (); -} else if (source === this.cut) { -this.cut_actionPerformed (); -} else if (source === this.$delete) { -this.delete_actionPerformed (); -} else if (source === this.grpsFromSelection) { -this.makeGrpsFromSelection_actionPerformed (); -} else if (source === this.deleteGroups) { -this.deleteGroups_actionPerformed (); -} else if (source === this.selectAllSequenceMenuItem) { -this.selectAllSequenceMenuItem_actionPerformed (); -} else if (source === this.deselectAllSequenceMenuItem) { -this.deselectAllSequenceMenuItem_actionPerformed (); -} else if (source === this.invertSequenceMenuItem) { -this.invertSequenceMenuItem_actionPerformed (); -} else if (source === this.invertColSel) { -this.viewport.invertColumnSelection (); -this.alignPanel.paintAlignment (true); -} else if (source === this.remove2LeftMenuItem) { -this.trimAlignment (true); -} else if (source === this.remove2RightMenuItem) { -this.trimAlignment (false); -} else if (source === this.removeGappedColumnMenuItem) { -this.removeGappedColumnMenuItem_actionPerformed (); -} else if (source === this.removeAllGapsMenuItem) { -this.removeAllGapsMenuItem_actionPerformed (); -} else if (source === this.findMenuItem) { -this.findMenuItem_actionPerformed (); -} else if (source === this.$font) { - new jalview.appletgui.FontChooser (this.alignPanel); -} else if (source === this.$newView) { -this.newView (null); -} else if (source === this.showColumns) { -this.viewport.showAllHiddenColumns (); -this.alignPanel.paintAlignment (true); -} else if (source === this.showSeqs) { -this.viewport.showAllHiddenSeqs (); -this.alignPanel.paintAlignment (true); -} else if (source === this.hideColumns) { -this.viewport.hideSelectedColumns (); -this.alignPanel.paintAlignment (true); -} else if (source === this.hideSequences && this.viewport.getSelectionGroup () != null) { -this.viewport.hideAllSelectedSeqs (); -this.alignPanel.paintAlignment (true); -} else if (source === this.hideAllButSelection) { -this.toggleHiddenRegions (false, false); -this.alignPanel.paintAlignment (true); -} else if (source === this.hideAllSelection) { -var sg = this.viewport.getSelectionGroup (); -this.viewport.expandColSelection (sg, false); -this.viewport.hideAllSelectedSeqs (); -this.viewport.hideSelectedColumns (); -this.alignPanel.paintAlignment (true); -} else if (source === this.showAllHidden) { -this.viewport.showAllHiddenColumns (); -this.viewport.showAllHiddenSeqs (); -this.alignPanel.paintAlignment (true); -} else if (source === this.showGroupConsensus) { -this.showGroupConsensus_actionPerformed (); -} else if (source === this.showGroupConservation) { -this.showGroupConservation_actionPerformed (); -} else if (source === this.showSequenceLogo) { -this.showSequenceLogo_actionPerformed (); -} else if (source === this.normSequenceLogo) { -this.normSequenceLogo_actionPerformed (); -} else if (source === this.showConsensusHistogram) { -this.showConsensusHistogram_actionPerformed (); -} else if (source === this.applyAutoAnnotationSettings) { -this.applyAutoAnnotationSettings_actionPerformed (); -} else if (source === this.featureSettings) { - new jalview.appletgui.FeatureSettings (this.alignPanel); -} else if (source === this.alProperties) { -var contents = new jalview.io.AlignmentProperties (this.viewport.getAlignment ()).formatAsString (); -var cap = new jalview.appletgui.CutAndPasteTransfer (false, this); -cap.setText (contents.toString ()); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.alignment_properties", Clazz.newArray (-1, [this.getTitle ()])), 400, 250); -} else if (source === this.overviewMenuItem) { -this.overviewMenuItem_actionPerformed (); -} else if (source === this.noColourmenuItem) { -this.changeColour (null); -} else if (source === this.clustalColour) { -this.abovePIDThreshold.setState (false); -this.changeColour ( new jalview.schemes.ClustalxColourScheme (this.viewport.getAlignment (), null)); -} else if (source === this.zappoColour) { -this.changeColour ( new jalview.schemes.ZappoColourScheme ()); -} else if (source === this.taylorColour) { -this.changeColour ( new jalview.schemes.TaylorColourScheme ()); -} else if (source === this.hydrophobicityColour) { -this.changeColour ( new jalview.schemes.HydrophobicColourScheme ()); -} else if (source === this.helixColour) { -this.changeColour ( new jalview.schemes.HelixColourScheme ()); -} else if (source === this.strandColour) { -this.changeColour ( new jalview.schemes.StrandColourScheme ()); -} else if (source === this.turnColour) { -this.changeColour ( new jalview.schemes.TurnColourScheme ()); -} else if (source === this.buriedColour) { -this.changeColour ( new jalview.schemes.BuriedColourScheme ()); -} else if (source === this.nucleotideColour) { -this.changeColour ( new jalview.schemes.NucleotideColourScheme ()); -} else if (source === this.purinePyrimidineColour) { -this.changeColour ( new jalview.schemes.PurinePyrimidineColourScheme ()); -} else if (source === this.RNAInteractionColour) { -this.changeColour ( new jalview.schemes.RNAInteractionColourScheme ()); -} else if (source === this.RNAHelixColour) { - new jalview.schemes.RNAHelicesColourChooser (this.viewport, this.alignPanel); -} else if (source === this.modifyPID) { -this.modifyPID_actionPerformed (); -} else if (source === this.modifyConservation) { -this.modifyConservation_actionPerformed (); -} else if (source === this.userDefinedColour) { - new jalview.appletgui.UserDefinedColours (this.alignPanel, null); -} else if (source === this.PIDColour) { -this.changeColour ( new jalview.schemes.PIDColourScheme ()); -} else if (source === this.BLOSUM62Colour) { -this.changeColour ( new jalview.schemes.Blosum62ColourScheme ()); -} else if (source === this.tcoffeeColour) { -this.changeColour ( new jalview.schemes.TCoffeeColourScheme (this.alignPanel.getAlignment ())); -} else if (source === this.annotationColour) { - new jalview.appletgui.AnnotationColourChooser (this.viewport, this.alignPanel); -} else if (source === this.annotationColumnSelection) { - new jalview.appletgui.AnnotationColumnChooser (this.viewport, this.alignPanel); -} else if (source === this.sortPairwiseMenuItem) { -this.sortPairwiseMenuItem_actionPerformed (); -} else if (source === this.sortIDMenuItem) { -this.sortIDMenuItem_actionPerformed (); -} else if (source === this.sortLengthMenuItem) { -this.sortLengthMenuItem_actionPerformed (); -} else if (source === this.sortGroupMenuItem) { -this.sortGroupMenuItem_actionPerformed (); -} else if (source === this.removeRedundancyMenuItem) { -this.removeRedundancyMenuItem_actionPerformed (); -} else if (source === this.pairwiseAlignmentMenuItem) { -this.pairwiseAlignmentMenuItem_actionPerformed (); -} else if (source === this.PCAMenuItem) { -this.PCAMenuItem_actionPerformed (); -} else if (source === this.averageDistanceTreeMenuItem) { -this.averageDistanceTreeMenuItem_actionPerformed (); -} else if (source === this.neighbourTreeMenuItem) { -this.neighbourTreeMenuItem_actionPerformed (); -} else if (source === this.njTreeBlosumMenuItem) { -this.njTreeBlosumMenuItem_actionPerformed (); -} else if (source === this.avDistanceTreeBlosumMenuItem) { -this.avTreeBlosumMenuItem_actionPerformed (); -} else if (source === this.documentation) { -this.documentation_actionPerformed (); -} else if (source === this.about) { -this.about_actionPerformed (); -}}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "inputText_actionPerformed", -function () { -var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.input_cut_paste"), 500, 500); -}); -Clazz.defineMethod (c$, "outputText_actionPerformed", -function (e) { -var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.alignment_output_command", Clazz.newArray (-1, [e.getActionCommand ()])), 600, 500); -var fr = this.alignPanel.cloneFeatureRenderer (); -cap.setText ( new jalview.io.AppletFormatAdapter (this.alignPanel).formatSequences (e.getActionCommand (), this.viewport.getAlignment (), this.viewport.getShowJVSuffix ())); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "loadAnnotations", -function () { -var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); -cap.setText (jalview.util.MessageManager.getString ("label.paste_features_annotations_Tcoffee_here")); -cap.setAnnotationImport (); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("action.paste_annotations"), 400, 300); -}); -Clazz.defineMethod (c$, "outputAnnotations", -function (displayTextbox) { -var annotation = new jalview.io.AnnotationFile ().printAnnotationsForView (this.viewport); -if (displayTextbox) { -var cap = new jalview.appletgui.CutAndPasteTransfer (false, this); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.annotations"), 600, 500); -cap.setText (annotation); -}return annotation; -}, "~B"); -Clazz.defineMethod (c$, "getDisplayedFeatureCols", -($fz = function () { -if (this.alignPanel.getFeatureRenderer () != null && this.viewport.getFeaturesDisplayed () != null) { -return this.alignPanel.getFeatureRenderer ().getDisplayedFeatureCols (); -}return null; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "outputFeatures", -function (displayTextbox, format) { -var features; -if (format.equalsIgnoreCase ("Jalview")) { -features = new jalview.io.FeaturesFile ().printJalviewFormat (this.viewport.getAlignment ().getSequencesArray (), this.getDisplayedFeatureCols ()); -} else { -features = new jalview.io.FeaturesFile ().printGFFFormat (this.viewport.getAlignment ().getSequencesArray (), this.getDisplayedFeatureCols ()); -}if (displayTextbox) { -var frimport = false; -if (features == null || features.equals ("No Features Visible")) { -features = "# No features visible - paste some and import them here."; -frimport = true; -}var cap = new jalview.appletgui.CutAndPasteTransfer (frimport, this); -if (frimport) { -cap.setAnnotationImport (); -}var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.features"), 600, 500); -cap.setText (features); -} else { -if (features == null) { -features = ""; -}}return features; -}, "~B,~S"); -Clazz.defineMethod (c$, "launchFullApplication", -function () { -var url = new StringBuffer (this.jalviewServletURL); -var firstSep = url.lastIndexOf ("?") > url.lastIndexOf ("/") ? "&" : "?"; -url.append (firstSep); -var applet = this.viewport.applet; -var s = applet.startupFile; -url.append ("open=" + this.appendProtocol (s)); -if (this.viewport.applet.features != null) { -url.append ("&features="); -url.append (this.appendProtocol (applet.features)); -}if (applet.annotations != null) { -url.append ("&annotations="); -url.append (this.appendProtocol (applet.annotations)); -}if (applet.jnetFile != null) { -url.append ("&annotations="); -url.append (this.appendProtocol (applet.jnetFile)); -}if (applet.defaultColour != null) { -url.append ("&colour=" + this.removeWhiteSpace (applet.defaultColour)); -}if (applet.userDefinedColour != null) { -url.append ("&colour=" + this.removeWhiteSpace (applet.userDefinedColour)); -}if (applet.treeFile != null) { -url.append ("&tree=" + this.appendProtocol (applet.treeFile)); -}this.showURL (url.toString (), "FULL_APP"); -}); -Clazz.defineMethod (c$, "removeWhiteSpace", -function (colour) { -var sb = new StringBuffer (); -for (var i = 0; i < colour.length; i++) { -if (Character.isWhitespace (colour.charAt (i))) { -sb.append ("%20"); -} else { -sb.append (colour.charAt (i)); -}} -return sb.toString (); -}, "~S"); -Clazz.defineMethod (c$, "appendProtocol", -function (url) { -try { - new java.net.URL (url); -url = java.net.URLEncoder.encode (url); -} catch (ex) { -if (Clazz.exceptionOf (ex, java.net.MalformedURLException)) { -url = this.viewport.applet.getCodeBase () + url; -} else { -throw ex; -} -} -return url; -}, "~S"); -Clazz.defineMethod (c$, "closeMenuItem_actionPerformed", -function () { -jalview.appletgui.PaintRefresher.RemoveComponent (this.alignPanel); -if (this.alignPanel.seqPanel != null && this.alignPanel.seqPanel.seqCanvas != null) { -jalview.appletgui.PaintRefresher.RemoveComponent (this.alignPanel.seqPanel.seqCanvas); -}if (this.alignPanel.idPanel != null && this.alignPanel.idPanel.idCanvas != null) { -jalview.appletgui.PaintRefresher.RemoveComponent (this.alignPanel.idPanel.idCanvas); -}if (jalview.appletgui.PaintRefresher.components.size () == 0 && this.viewport.applet == null) { -System.exit (0); -} else { -}this.viewport = null; -this.alignPanel = null; -this.dispose (); -}); -Clazz.defineMethod (c$, "updateEditMenuBar", -function () { -if (this.viewport.getHistoryList ().size () > 0) { -this.undoMenuItem.setEnabled (true); -var command = this.viewport.getHistoryList ().peek (); -this.undoMenuItem.setLabel (jalview.util.MessageManager.formatMessage ("label.undo_command", Clazz.newArray (-1, [command.getDescription ()]))); -} else { -this.undoMenuItem.setEnabled (false); -this.undoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.undo")); -}if (this.viewport.getRedoList ().size () > 0) { -this.redoMenuItem.setEnabled (true); -var command = this.viewport.getRedoList ().peek (); -this.redoMenuItem.setLabel (jalview.util.MessageManager.formatMessage ("label.redo_command", Clazz.newArray (-1, [command.getDescription ()]))); -} else { -this.redoMenuItem.setEnabled (false); -this.redoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.redo")); -}}); -Clazz.overrideMethod (c$, "addHistoryItem", -function (command) { -if (command.getSize () > 0) { -this.viewport.addToHistoryList (command); -this.viewport.clearRedoList (); -this.updateEditMenuBar (); -this.viewport.updateHiddenColumns (); -}}, "jalview.commands.CommandI"); -Clazz.defineMethod (c$, "undoMenuItem_actionPerformed", -function () { -if (this.viewport.getHistoryList ().isEmpty ()) { -return; -}var command = this.viewport.getHistoryList ().pop (); -this.viewport.addToRedoList (command); -command.undoCommand (null); -var originalSource = this.getOriginatingSource (command); -if (originalSource !== this.viewport) { -System.err.println ("Warning: Viewport object mismatch whilst undoing"); -}originalSource.updateHiddenColumns (); -this.updateEditMenuBar (); -originalSource.firePropertyChange ("alignment", null, originalSource.getAlignment ().getSequences ()); -}); -Clazz.defineMethod (c$, "redoMenuItem_actionPerformed", -function () { -if (this.viewport.getRedoList ().isEmpty ()) { -return; -}var command = this.viewport.getRedoList ().pop (); -this.viewport.addToHistoryList (command); -command.doCommand (null); -var originalSource = this.getOriginatingSource (command); -if (originalSource !== this.viewport) { -System.err.println ("Warning: Viewport object mismatch whilst re-doing"); -}originalSource.updateHiddenColumns (); -this.updateEditMenuBar (); -originalSource.firePropertyChange ("alignment", null, originalSource.getAlignment ().getSequences ()); -}); -Clazz.defineMethod (c$, "getOriginatingSource", -function (command) { -var originalSource = null; -var al = null; -if (Clazz.instanceOf (command, jalview.commands.EditCommand)) { -var editCommand = command; -al = editCommand.getAlignment (); -var comps = jalview.appletgui.PaintRefresher.components.get (this.viewport.getSequenceSetId ()); -for (var i = 0; i < comps.size (); i++) { -if (Clazz.instanceOf (comps.elementAt (i), jalview.appletgui.AlignmentPanel)) { -if (al === (comps.elementAt (i)).av.getAlignment ()) { -originalSource = (comps.elementAt (i)).av; -break; -}}} -}if (originalSource == null) { -if (al != null) { -jalview.appletgui.PaintRefresher.validateSequences (al, this.viewport.getAlignment ()); -}originalSource = this.viewport; -}return originalSource; -}, "jalview.commands.CommandI"); -Clazz.defineMethod (c$, "moveSelectedSequences", -function (up) { -var sg = this.viewport.getSelectionGroup (); -if (sg == null) { -return; -}this.viewport.getAlignment ().moveSelectedSequencesByOne (sg, up ? null : this.viewport.getHiddenRepSequences (), up); -this.alignPanel.paintAlignment (true); -var complement = this.viewport.getCodingComplement (); -if (complement != null) { -var mappedSelection = jalview.util.MappingUtils.mapSequenceGroup (sg, this.viewport, complement); -complement.getAlignment ().moveSelectedSequencesByOne (mappedSelection, up ? null : complement.getHiddenRepSequences (), up); -}}, "~B"); -Clazz.defineMethod (c$, "slideSequences", -function (right, size) { -var sg = new java.util.Vector (); -if (this.viewport.cursorMode) { -sg.add (this.viewport.getAlignment ().getSequenceAt (this.alignPanel.seqPanel.seqCanvas.cursorY)); -} else if (this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () != this.viewport.getAlignment ().getHeight ()) { -sg = this.viewport.getSelectionGroup ().getSequences (this.viewport.getHiddenRepSequences ()); -}if (sg.size () < 1) { -return; -}var invertGroup = new java.util.Vector (); -for (var i = 0; i < this.viewport.getAlignment ().getHeight (); i++) { -if (!sg.contains (this.viewport.getAlignment ().getSequenceAt (i))) { -invertGroup.addElement (this.viewport.getAlignment ().getSequenceAt (i)); -}} -var seqs1 = sg.toArray ( new Array (sg.size ())); -var seqs2 = invertGroup.toArray ( new Array (invertGroup.size ())); -for (var i = 0; i < invertGroup.size (); i++) { -seqs2[i] = invertGroup.elementAt (i); -} -var ssc; -if (right) { -ssc = new jalview.commands.SlideSequencesCommand ("Slide Sequences", seqs2, seqs1, size, this.viewport.getGapCharacter ()); -} else { -ssc = new jalview.commands.SlideSequencesCommand ("Slide Sequences", seqs1, seqs2, size, this.viewport.getGapCharacter ()); -}var groupAdjustment = 0; -if (ssc.getGapsInsertedBegin () && right) { -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.moveCursor (size, 0); -} else { -groupAdjustment = size; -}} else if (!ssc.getGapsInsertedBegin () && !right) { -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.moveCursor (-size, 0); -} else { -groupAdjustment = -size; -}}if (groupAdjustment != 0) { -this.viewport.getSelectionGroup ().setStartRes (this.viewport.getSelectionGroup ().getStartRes () + groupAdjustment); -this.viewport.getSelectionGroup ().setEndRes (this.viewport.getSelectionGroup ().getEndRes () + groupAdjustment); -}var appendHistoryItem = false; -var historyList = this.viewport.getHistoryList (); -if (historyList != null && historyList.size () > 0 && Clazz.instanceOf (historyList.peek (), jalview.commands.SlideSequencesCommand)) { -appendHistoryItem = ssc.appendSlideCommand (historyList.peek ()); -}if (!appendHistoryItem) { -this.addHistoryItem (ssc); -}this.repaint (); -}, "~B,~N"); -Clazz.defineMethod (c$, "copy_actionPerformed", -function () { -if (this.viewport.getSelectionGroup () == null) { -return; -}var sg = this.viewport.getSelectionGroup (); -jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer (); -var orderedSeqs = new java.util.HashMap (); -for (var i = 0; i < sg.getSize (); i++) { -var seq = sg.getSequenceAt (i); -var index = this.viewport.getAlignment ().findIndex (seq); -orderedSeqs.put (new Integer (index), seq); -} -var index = 0; -var startRes; -var endRes; -var ch; -if (this.viewport.hasHiddenColumns () && this.viewport.getSelectionGroup () != null) { -jalview.appletgui.AlignFrame.copiedHiddenColumns = new java.util.Vector (); -var hiddenOffset = this.viewport.getSelectionGroup ().getStartRes (); -for (var region, $region = this.viewport.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { -jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement ( Clazz.newIntArray (-1, [region[0] - hiddenOffset, region[1] - hiddenOffset])); -} -} else { -jalview.appletgui.AlignFrame.copiedHiddenColumns = null; -}for (var i = 0; i < sg.getSize (); i++) { -var seq = null; -while (seq == null) { -if (orderedSeqs.containsKey (new Integer (index))) { -seq = orderedSeqs.get (new Integer (index)); -index++; -break; -} else { -index++; -}} -startRes = seq.findPosition (sg.getStartRes ()); -endRes = 0; -for (var j = 0; j < sg.getEndRes () + 1 && j < seq.getLength (); j++) { -ch = seq.getCharAt (j); -if (!jalview.util.Comparison.isGap ((ch))) { -endRes++; -}} -if (endRes > 0) { -endRes += seq.getStart () - 1; -}jalview.appletgui.AlignFrame.copiedSequences.append (seq.getName () + "\t" + startRes + "\t" + endRes + "\t" + seq.getSequenceAsString (sg.getStartRes (), sg.getEndRes () + 1) + "\n"); -} -}); -Clazz.defineMethod (c$, "pasteNew_actionPerformed", -function () { -this.paste (true); -}); -Clazz.defineMethod (c$, "pasteThis_actionPerformed", -function () { -this.paste (false); -}); -Clazz.defineMethod (c$, "paste", -function (newAlignment) { -try { -if (jalview.appletgui.AlignFrame.copiedSequences == null) { -return; -}var st = new java.util.StringTokenizer (jalview.appletgui.AlignFrame.copiedSequences.toString ()); -var seqs = new java.util.Vector (); -while (st.hasMoreElements ()) { -var name = st.nextToken (); -var start = Integer.parseInt (st.nextToken ()); -var end = Integer.parseInt (st.nextToken ()); -seqs.addElement ( new jalview.datamodel.Sequence (name, st.nextToken (), start, end)); -} -var newSeqs = new Array (seqs.size ()); -for (var i = 0; i < seqs.size (); i++) { -newSeqs[i] = seqs.elementAt (i); -} -if (newAlignment) { -var newtitle = jalview.util.MessageManager.getString ("label.copied_sequences"); -if (this.getTitle ().startsWith (jalview.util.MessageManager.getString ("label.copied_sequences"))) { -newtitle = this.getTitle (); -} else { -newtitle = newtitle.concat (jalview.util.MessageManager.formatMessage ("label.from_msname", Clazz.newArray (-1, [this.getTitle ()]))); -}var af = new jalview.appletgui.AlignFrame ( new jalview.datamodel.Alignment (newSeqs), this.viewport.applet, newtitle, false); -if (jalview.appletgui.AlignFrame.copiedHiddenColumns != null) { -for (var i = 0; i < jalview.appletgui.AlignFrame.copiedHiddenColumns.size (); i++) { -var region = jalview.appletgui.AlignFrame.copiedHiddenColumns.elementAt (i); -af.viewport.hideColumns (region[0], region[1]); -} -}jalview.bin.JalviewLite.addFrame (af, newtitle, this.frameWidth, this.frameHeight); -} else { -this.addSequences (newSeqs); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -}, "~B"); -Clazz.defineMethod (c$, "addSequences", -function (seqs) { -for (var i = 0; i < seqs.length; i++) { -this.viewport.getAlignment ().addSequence (seqs[i]); -} -this.addHistoryItem ( new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.add_sequences"), jalview.commands.EditCommand.Action.PASTE, seqs, 0, this.viewport.getAlignment ().getWidth (), this.viewport.getAlignment ())); -this.viewport.setEndSeq (this.viewport.getAlignment ().getHeight ()); -this.viewport.getAlignment ().getWidth (); -this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); -}, "~A"); -Clazz.defineMethod (c$, "cut_actionPerformed", -function () { -this.copy_actionPerformed (); -this.delete_actionPerformed (); -}); -Clazz.defineMethod (c$, "delete_actionPerformed", -function () { -var sg = this.viewport.getSelectionGroup (); -if (sg == null) { -return; -}var seqs = new java.util.Vector (); -var seq; -for (var i = 0; i < sg.getSize (); i++) { -seq = sg.getSequenceAt (i); -seqs.addElement (seq); -} -if (sg.getSize () == this.viewport.getAlignment ().getHeight ()) { -this.viewport.getColumnSelection ().removeElements (sg.getStartRes (), sg.getEndRes () + 1); -}var cut = new Array (seqs.size ()); -for (var i = 0; i < seqs.size (); i++) { -cut[i] = seqs.elementAt (i); -} -this.addHistoryItem ( new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.cut_sequences"), jalview.commands.EditCommand.Action.CUT, cut, sg.getStartRes (), sg.getEndRes () - sg.getStartRes () + 1, this.viewport.getAlignment ())); -this.viewport.setSelectionGroup (null); -this.viewport.getAlignment ().deleteGroup (sg); -this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); -if (this.viewport.getAlignment ().getHeight () < 1) { -this.setVisible (false); -}this.viewport.sendSelection (); -}); -Clazz.defineMethod (c$, "showGroupConsensus_actionPerformed", -function () { -this.viewport.setShowGroupConsensus (this.showGroupConsensus.getState ()); -this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); -}); -Clazz.defineMethod (c$, "showGroupConservation_actionPerformed", -function () { -this.viewport.setShowGroupConservation (this.showGroupConservation.getState ()); -this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); -}); -Clazz.defineMethod (c$, "showConsensusHistogram_actionPerformed", -function () { -this.viewport.setShowConsensusHistogram (this.showConsensusHistogram.getState ()); -this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); -}); -Clazz.defineMethod (c$, "showSequenceLogo_actionPerformed", -function () { -this.viewport.setShowSequenceLogo (this.showSequenceLogo.getState ()); -this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); -}); -Clazz.defineMethod (c$, "normSequenceLogo_actionPerformed", -function () { -this.showSequenceLogo.setState (true); -this.viewport.setShowSequenceLogo (true); -this.viewport.setNormaliseSequenceLogo (this.normSequenceLogo.getState ()); -this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); -}); -Clazz.defineMethod (c$, "applyAutoAnnotationSettings_actionPerformed", -function () { -this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); -}); -Clazz.defineMethod (c$, "makeGrpsFromSelection_actionPerformed", -function () { -if (this.avc.makeGroupsFromSelection ()) { -jalview.appletgui.PaintRefresher.Refresh (this, this.viewport.getSequenceSetId ()); -this.alignPanel.updateAnnotation (); -this.alignPanel.paintAlignment (true); -}}); -Clazz.defineMethod (c$, "createGroup_actionPerformed", -function () { -this.avc.createGroup (); -}); -Clazz.defineMethod (c$, "unGroup_actionPerformed", -function () { -if (this.avc.unGroup ()) { -this.alignPanel.alignmentChanged (); -}}); -Clazz.defineMethod (c$, "deleteGroups_actionPerformed", -function () { -if (this.avc.deleteGroups ()) { -this.alignPanel.alignmentChanged (); -}}); -Clazz.defineMethod (c$, "selectAllSequenceMenuItem_actionPerformed", -function () { -var sg = new jalview.datamodel.SequenceGroup (); -for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { -sg.addSequence (this.viewport.getAlignment ().getSequenceAt (i), false); -} -sg.setEndRes (this.viewport.getAlignment ().getWidth () - 1); -this.viewport.setSelectionGroup (sg); -this.alignPanel.paintAlignment (true); -jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); -this.viewport.sendSelection (); -}); -Clazz.defineMethod (c$, "deselectAllSequenceMenuItem_actionPerformed", -function () { -if (this.viewport.cursorMode) { -this.alignPanel.seqPanel.keyboardNo1 = null; -this.alignPanel.seqPanel.keyboardNo2 = null; -}this.viewport.setSelectionGroup (null); -this.viewport.getColumnSelection ().clear (); -this.viewport.setSelectionGroup (null); -this.alignPanel.idPanel.idCanvas.searchResults = null; -this.alignPanel.seqPanel.seqCanvas.highlightSearchResults (null); -this.alignPanel.paintAlignment (true); -jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); -this.viewport.sendSelection (); -}); -Clazz.defineMethod (c$, "invertSequenceMenuItem_actionPerformed", -function () { -var sg = this.viewport.getSelectionGroup (); -for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { -sg.addOrRemove (this.viewport.getAlignment ().getSequenceAt (i), false); -} -jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); -this.viewport.sendSelection (); -}); -Clazz.defineMethod (c$, "invertColSel_actionPerformed", -function () { -this.viewport.invertColumnSelection (); -this.alignPanel.paintAlignment (true); -jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); -this.viewport.sendSelection (); -}); -Clazz.defineMethod (c$, "trimAlignment", -function (trimLeft) { -var colSel = this.viewport.getColumnSelection (); -var column; -if (colSel.size () > 0) { -if (trimLeft) { -column = colSel.getMin (); -} else { -column = colSel.getMax (); -}var seqs; -if (this.viewport.getSelectionGroup () != null) { -seqs = this.viewport.getSelectionGroup ().getSequencesAsArray (this.viewport.getHiddenRepSequences ()); -} else { -seqs = this.viewport.getAlignment ().getSequencesArray (); -}var trimRegion; -if (trimLeft) { -trimRegion = new jalview.commands.TrimRegionCommand ("Remove Left", jalview.commands.TrimRegionCommand.TRIM_LEFT, seqs, column, this.viewport.getAlignment (), this.viewport.getColumnSelection (), this.viewport.getSelectionGroup ()); -this.viewport.setStartRes (0); -} else { -trimRegion = new jalview.commands.TrimRegionCommand ("Remove Right", jalview.commands.TrimRegionCommand.TRIM_RIGHT, seqs, column, this.viewport.getAlignment (), this.viewport.getColumnSelection (), this.viewport.getSelectionGroup ()); -}this.setStatus (jalview.util.MessageManager.formatMessage ("label.removed_columns", Clazz.newArray (-1, [Integer.$valueOf (trimRegion.getSize ()).toString ()]))); -this.addHistoryItem (trimRegion); -for (var sg, $sg = this.viewport.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if ((trimLeft && !sg.adjustForRemoveLeft (column)) || (!trimLeft && !sg.adjustForRemoveRight (column))) { -this.viewport.getAlignment ().deleteGroup (sg); -}} -this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); -}}, "~B"); -Clazz.defineMethod (c$, "removeGappedColumnMenuItem_actionPerformed", -function () { -var start = 0; -var end = this.viewport.getAlignment ().getWidth () - 1; -var seqs; -if (this.viewport.getSelectionGroup () != null) { -seqs = this.viewport.getSelectionGroup ().getSequencesAsArray (this.viewport.getHiddenRepSequences ()); -start = this.viewport.getSelectionGroup ().getStartRes (); -end = this.viewport.getSelectionGroup ().getEndRes (); -} else { -seqs = this.viewport.getAlignment ().getSequencesArray (); -}var removeGapCols = new jalview.commands.RemoveGapColCommand ("Remove Gapped Columns", seqs, start, end, this.viewport.getAlignment ()); -this.addHistoryItem (removeGapCols); -this.setStatus (jalview.util.MessageManager.formatMessage ("label.removed_empty_columns", Clazz.newArray (-1, [Integer.$valueOf (removeGapCols.getSize ()).toString ()]))); -var seq = this.viewport.getAlignment ().getSequenceAt (0); -var startRes = seq.findPosition (this.viewport.startRes); -this.viewport.setStartRes (seq.findIndex (startRes) - 1); -this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); -}); -Clazz.defineMethod (c$, "removeAllGapsMenuItem_actionPerformed", -function () { -var start = 0; -var end = this.viewport.getAlignment ().getWidth () - 1; -var seqs; -if (this.viewport.getSelectionGroup () != null) { -seqs = this.viewport.getSelectionGroup ().getSequencesAsArray (this.viewport.getHiddenRepSequences ()); -start = this.viewport.getSelectionGroup ().getStartRes (); -end = this.viewport.getSelectionGroup ().getEndRes (); -} else { -seqs = this.viewport.getAlignment ().getSequencesArray (); -}var seq = this.viewport.getAlignment ().getSequenceAt (0); -var startRes = seq.findPosition (this.viewport.startRes); -this.addHistoryItem ( new jalview.commands.RemoveGapsCommand ("Remove Gaps", seqs, start, end, this.viewport.getAlignment ())); -this.viewport.setStartRes (seq.findIndex (startRes) - 1); -this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); -}); -Clazz.defineMethod (c$, "findMenuItem_actionPerformed", -function () { - new jalview.appletgui.Finder (this.alignPanel); -}); -Clazz.defineMethod (c$, "newView", -function (viewtitle) { -var newal; -if (this.viewport.hasHiddenRows ()) { -newal = new jalview.datamodel.Alignment (this.viewport.getAlignment ().getHiddenSequences ().getFullAlignment ().getSequencesArray ()); -} else { -newal = new jalview.datamodel.Alignment (this.viewport.getAlignment ().getSequencesArray ()); -}if (this.viewport.getAlignment ().getAlignmentAnnotation () != null) { -for (var i = 0; i < this.viewport.getAlignment ().getAlignmentAnnotation ().length; i++) { -if (!this.viewport.getAlignment ().getAlignmentAnnotation ()[i].autoCalculated) { -newal.addAnnotation (this.viewport.getAlignment ().getAlignmentAnnotation ()[i]); -}} -}var newaf = new jalview.appletgui.AlignFrame (newal, this.viewport.applet, "", false); -newaf.viewport.setSequenceSetId (this.alignPanel.av.getSequenceSetId ()); -jalview.appletgui.PaintRefresher.Register (this.alignPanel, this.alignPanel.av.getSequenceSetId ()); -jalview.appletgui.PaintRefresher.Register (newaf.alignPanel, newaf.alignPanel.av.getSequenceSetId ()); -jalview.appletgui.PaintRefresher.Register (newaf.alignPanel.idPanel.idCanvas, newaf.alignPanel.av.getSequenceSetId ()); -jalview.appletgui.PaintRefresher.Register (newaf.alignPanel.seqPanel.seqCanvas, newaf.alignPanel.av.getSequenceSetId ()); -var comps = jalview.appletgui.PaintRefresher.components.get (this.viewport.getSequenceSetId ()); -var viewSize = -1; -for (var i = 0; i < comps.size (); i++) { -if (Clazz.instanceOf (comps.elementAt (i), jalview.appletgui.AlignmentPanel)) { -viewSize++; -}} -var title = String.instantialize (this.getTitle ()); -if (viewtitle != null) { -title = viewtitle + " ( " + title + ")"; -} else { -if (title.indexOf ("(View") > -1) { -title = title.substring (0, title.indexOf ("(View")); -}title += "(View " + viewSize + ")"; -}newaf.setTitle (title.toString ()); -newaf.viewport.setHistoryList (this.viewport.getHistoryList ()); -newaf.viewport.setRedoList (this.viewport.getRedoList ()); -return newaf; -}, "~S"); -Clazz.defineMethod (c$, "getFeatureGroups", -function () { -var fr = null; -if (this.alignPanel != null && (fr = this.alignPanel.getFeatureRenderer ()) != null) { -var gps = fr.getFeatureGroups (); -var _gps = gps.toArray ( new Array (gps.size ())); -return _gps; -}return null; -}); -Clazz.defineMethod (c$, "getFeatureGroupsOfState", -function (visible) { -var fr = null; -if (this.alignPanel != null && (fr = this.alignPanel.getFeatureRenderer ()) != null) { -var gps = fr.getGroups (visible); -var _gps = gps.toArray ( new Array (gps.size ())); -return _gps; -}return null; -}, "~B"); -Clazz.defineMethod (c$, "setFeatureGroupState", -function (groups, state) { -var fr = null; -this.sequenceFeatures.setState (true); -this.viewport.setShowSequenceFeatures (true); -if (this.alignPanel != null && (fr = this.alignPanel.getFeatureRenderer ()) != null) { -fr.setGroupVisibility (java.util.Arrays.asList (groups), state); -this.alignPanel.seqPanel.seqCanvas.repaint (); -if (this.alignPanel.overviewPanel != null) { -this.alignPanel.overviewPanel.updateOverviewImage (); -}}}, "~A,~B"); -Clazz.defineMethod (c$, "seqLimits_itemStateChanged", -function () { -this.viewport.setShowJVSuffix (this.seqLimits.getState ()); -this.alignPanel.fontChanged (); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "colourTextMenuItem_actionPerformed", -function () { -this.viewport.setColourText (this.colourTextMenuItem.getState ()); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "displayNonconservedMenuItem_actionPerformed", -function () { -this.viewport.setShowUnconserved (this.displayNonconservedMenuItem.getState ()); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "wrapMenuItem_actionPerformed", -function () { -this.viewport.setWrapAlignment (this.wrapMenuItem.getState ()); -this.alignPanel.setWrapAlignment (this.wrapMenuItem.getState ()); -this.scaleAbove.setEnabled (this.wrapMenuItem.getState ()); -this.scaleLeft.setEnabled (this.wrapMenuItem.getState ()); -this.scaleRight.setEnabled (this.wrapMenuItem.getState ()); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "overviewMenuItem_actionPerformed", -function () { -if (this.alignPanel.overviewPanel != null) { -return; -}var frame = new awt2swing.Frame (); -var overview = new jalview.appletgui.OverviewPanel (this.alignPanel); -frame.add (overview); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.overview_params", Clazz.newArray (-1, [this.getTitle ()])), overview.getPreferredSize ().width, overview.getPreferredSize ().height + 50); -frame.pack (); -var ap = this.alignPanel; -frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$1") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$1, this, Clazz.cloneFinals ("ap", ap)))); -this.alignPanel.setOverviewPanel (overview); -}); -Clazz.overrideMethod (c$, "changeColour", -function (cs) { -var threshold = 0; -if (cs != null) { -if (this.viewport.getAbovePIDThreshold ()) { -this.viewport.setThreshold (jalview.appletgui.SliderPanel.setPIDSliderSource (this.alignPanel, cs, "Background")); -}if (this.viewport.getConservationSelected ()) { -cs.setConservationApplied (true); -this.viewport.setIncrement (jalview.appletgui.SliderPanel.setConservationSlider (this.alignPanel, cs, "Background")); -} else { -cs.setConservationApplied (false); -}}this.viewport.setGlobalColourScheme (cs); -if (this.alignPanel.getOverviewPanel () != null) { -this.alignPanel.getOverviewPanel ().updateOverviewImage (); -}jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.viewport.applet).sequenceColoursChanged (this.alignPanel); -this.alignPanel.paintAlignment (true); -}, "jalview.schemes.ColourSchemeI"); -Clazz.defineMethod (c$, "modifyPID_actionPerformed", -function () { -if (this.viewport.getAbovePIDThreshold () && this.viewport.getGlobalColourScheme () != null) { -jalview.appletgui.SliderPanel.setPIDSliderSource (this.alignPanel, this.viewport.getGlobalColourScheme (), "Background"); -jalview.appletgui.SliderPanel.showPIDSlider (); -}}); -Clazz.defineMethod (c$, "modifyConservation_actionPerformed", -function () { -if (this.viewport.getConservationSelected () && this.viewport.getGlobalColourScheme () != null) { -jalview.appletgui.SliderPanel.setConservationSlider (this.alignPanel, this.viewport.getGlobalColourScheme (), "Background"); -jalview.appletgui.SliderPanel.showConservationSlider (); -}}); -Clazz.defineMethod (c$, "conservationMenuItem_actionPerformed", -function () { -this.viewport.setConservationSelected (this.conservationMenuItem.getState ()); -this.viewport.setAbovePIDThreshold (false); -this.abovePIDThreshold.setState (false); -this.changeColour (this.viewport.getGlobalColourScheme ()); -this.modifyConservation_actionPerformed (); -}); -Clazz.defineMethod (c$, "abovePIDThreshold_actionPerformed", -function () { -this.viewport.setAbovePIDThreshold (this.abovePIDThreshold.getState ()); -this.conservationMenuItem.setState (false); -this.viewport.setConservationSelected (false); -this.changeColour (this.viewport.getGlobalColourScheme ()); -this.modifyPID_actionPerformed (); -}); -Clazz.defineMethod (c$, "sortPairwiseMenuItem_actionPerformed", -function () { -var oldOrder = this.viewport.getAlignment ().getSequencesArray (); -jalview.analysis.AlignmentSorter.sortByPID (this.viewport.getAlignment (), this.viewport.getAlignment ().getSequenceAt (0), null); -this.addHistoryItem ( new jalview.commands.OrderCommand ("Pairwise Sort", oldOrder, this.viewport.getAlignment ())); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "sortIDMenuItem_actionPerformed", -function () { -var oldOrder = this.viewport.getAlignment ().getSequencesArray (); -jalview.analysis.AlignmentSorter.sortByID (this.viewport.getAlignment ()); -this.addHistoryItem ( new jalview.commands.OrderCommand ("ID Sort", oldOrder, this.viewport.getAlignment ())); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "sortLengthMenuItem_actionPerformed", -function () { -var oldOrder = this.viewport.getAlignment ().getSequencesArray (); -jalview.analysis.AlignmentSorter.sortByLength (this.viewport.getAlignment ()); -this.addHistoryItem ( new jalview.commands.OrderCommand ("Length Sort", oldOrder, this.viewport.getAlignment ())); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "sortGroupMenuItem_actionPerformed", -function () { -var oldOrder = this.viewport.getAlignment ().getSequencesArray (); -jalview.analysis.AlignmentSorter.sortByGroup (this.viewport.getAlignment ()); -this.addHistoryItem ( new jalview.commands.OrderCommand ("Group Sort", oldOrder, this.viewport.getAlignment ())); -this.alignPanel.paintAlignment (true); -}); -Clazz.defineMethod (c$, "removeRedundancyMenuItem_actionPerformed", -function () { - new jalview.appletgui.RedundancyPanel (this.alignPanel); -}); -Clazz.defineMethod (c$, "pairwiseAlignmentMenuItem_actionPerformed", -function () { -if (this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () > 1) { -var frame = new awt2swing.Frame (); -frame.add ( new jalview.appletgui.PairwiseAlignPanel (this.alignPanel)); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("action.pairwise_alignment"), 600, 500); -}}); -Clazz.defineMethod (c$, "PCAMenuItem_actionPerformed", -function () { -if (!this.viewport.getAlignment ().isAligned (false)) { -var current; -var Width = this.viewport.getAlignment ().getWidth (); -for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { -current = this.viewport.getAlignment ().getSequenceAt (i); -if (current.getLength () < Width) { -current.insertCharAt (Width - 1, this.viewport.getGapCharacter ()); -}} -this.alignPanel.paintAlignment (true); -}if ((this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () < 4 && this.viewport.getSelectionGroup ().getSize () > 0) || this.viewport.getAlignment ().getHeight () < 4) { -return; -}try { - new jalview.appletgui.PCAPanel (this.viewport); -} catch (ex) { -if (Clazz.exceptionOf (ex, OutOfMemoryError)) { -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "averageDistanceTreeMenuItem_actionPerformed", -function () { -this.NewTreePanel ("AV", "PID", "Average distance tree using PID"); -}); -Clazz.defineMethod (c$, "neighbourTreeMenuItem_actionPerformed", -function () { -this.NewTreePanel ("NJ", "PID", "Neighbour joining tree using PID"); -}); -Clazz.defineMethod (c$, "njTreeBlosumMenuItem_actionPerformed", -function () { -this.NewTreePanel ("NJ", "BL", "Neighbour joining tree using BLOSUM62"); -}); -Clazz.defineMethod (c$, "avTreeBlosumMenuItem_actionPerformed", -function () { -this.NewTreePanel ("AV", "BL", "Average distance tree using BLOSUM62"); -}); -Clazz.defineMethod (c$, "NewTreePanel", -function (type, pwType, title) { -if (!this.viewport.getAlignment ().isAligned (false)) { -var current; -var Width = this.viewport.getAlignment ().getWidth (); -for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { -current = this.viewport.getAlignment ().getSequenceAt (i); -if (current.getLength () < Width) { -current.insertCharAt (Width - 1, this.viewport.getGapCharacter ()); -}} -this.alignPanel.paintAlignment (true); -}if ((this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () > 1) || (this.viewport.getAlignment ().getHeight () > 1)) { -var tp = new jalview.appletgui.TreePanel (this.alignPanel, type, pwType); -this.addTreeMenuItem (tp, title); -jalview.bin.JalviewLite.addFrame (tp, title, 600, 500); -}}, "~S,~S,~S"); -Clazz.defineMethod (c$, "loadTree_actionPerformed", -function () { -var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); -cap.setText (jalview.util.MessageManager.getString ("label.paste_newick_tree_file")); -cap.setTreeImport (); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.paste_newick_file"), 400, 300); -}); -Clazz.defineMethod (c$, "loadTree", -function (tree, treeFile) { -var tp = new jalview.appletgui.TreePanel (this.alignPanel, treeFile, jalview.util.MessageManager.getString ("label.load_tree_from_file"), tree); -jalview.bin.JalviewLite.addFrame (tp, treeFile, 600, 500); -this.addTreeMenuItem (tp, treeFile); -}, "jalview.io.NewickFile,~S"); -Clazz.defineMethod (c$, "sortByTree", -function (treePanel, title) { -var oldOrder = this.viewport.getAlignment ().getSequencesArray (); -jalview.analysis.AlignmentSorter.sortByTree (this.viewport.getAlignment (), treePanel.getTree ()); -this.addHistoryItem ( new jalview.commands.OrderCommand (jalview.util.MessageManager.formatMessage ("label.order_by_params", Clazz.newArray (-1, [title])), oldOrder, this.viewport.getAlignment ())); -this.alignPanel.paintAlignment (true); -}, "jalview.appletgui.TreePanel,~S"); -Clazz.defineMethod (c$, "addTreeMenuItem", -function (treePanel, title) { -var item = new awt2swing.MenuItem (title); -this.sortByTreeMenu.add (item); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$2") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$2, this, Clazz.cloneFinals ("treePanel", treePanel, "title", title)))); -treePanel.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$3") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$3, this, Clazz.cloneFinals ("treePanel", treePanel, "title", title, "item", item)))); -}, "jalview.appletgui.TreePanel,~S"); -Clazz.defineMethod (c$, "sortBy", -function (alorder, undoname) { -var oldOrder = this.viewport.getAlignment ().getSequencesArray (); -if ((this.viewport.applet, jalview.bin.JalviewLite).debug) { -System.err.println ("Sorting " + alorder.getOrder ().size () + " in alignment '" + this.getTitle () + "'"); -}jalview.analysis.AlignmentSorter.sortBy (this.viewport.getAlignment (), alorder); -if (undoname != null) { -this.addHistoryItem ( new jalview.commands.OrderCommand (undoname, oldOrder, this.viewport.getAlignment ())); -}this.alignPanel.paintAlignment (true); -return true; -}, "jalview.datamodel.AlignmentOrder,~S"); -Clazz.defineMethod (c$, "documentation_actionPerformed", -function () { -this.alignPanel.av.applet.openJalviewHelpUrl (); -}); -Clazz.defineMethod (c$, "about_actionPerformed", -function () { -if (!Clazz.isClassDefined ("jalview.appletgui.AlignFrame$1AboutPanel")) { -jalview.appletgui.AlignFrame.$AlignFrame$1AboutPanel$ (); -} -var frame = new awt2swing.Frame (); -frame.add (Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$1AboutPanel, this, null, jalview.bin.JalviewLite.getVersion (), jalview.bin.JalviewLite.getBuildDate ())); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.jalview"), 580, 220); -}); -Clazz.defineMethod (c$, "showURL", -function (url, target) { -if (this.viewport.applet == null) { -System.out.println ("Not running as applet - no browser available."); -} else { -this.viewport.applet.showURL (url, target); -}}, "~S,~S"); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setMenuBar (this.alignFrameMenuBar); -this.inputText.setLabel (jalview.util.MessageManager.getString ("label.input_from_textbox")); -this.inputText.addActionListener (this); -var outputTextboxMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.out_to_textbox")); -for (var i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { -var item = new awt2swing.MenuItem (jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$4") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$4$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$4, this, null))); -outputTextboxMenu.add (item); -} -this.closeMenuItem.addActionListener (this); -this.loadApplication.addActionListener (this); -this.$loadTree.addActionListener (this); -this.$loadAnnotations.addActionListener (this); -this.$outputFeatures.addActionListener (this); -this.$outputAnnotations.addActionListener (this); -this.undoMenuItem.setEnabled (false); -this.undoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.undo")); -this.undoMenuItem.addActionListener (this); -this.redoMenuItem.setEnabled (false); -this.redoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.redo")); -this.redoMenuItem.addActionListener (this); -this.copy.setLabel (jalview.util.MessageManager.getString ("action.copy")); -this.copy.addActionListener (this); -this.cut.setLabel (jalview.util.MessageManager.getString ("action.cut")); -this.cut.addActionListener (this); -this.$delete.setLabel (jalview.util.MessageManager.getString ("action.delete")); -this.$delete.addActionListener (this); -this.pasteMenu.setLabel (jalview.util.MessageManager.getString ("action.paste")); -this.pasteNew.setLabel (jalview.util.MessageManager.getString ("label.to_new_alignment")); -this.pasteNew.addActionListener (this); -this.pasteThis.setLabel (jalview.util.MessageManager.getString ("label.to_this_alignment")); -this.pasteThis.addActionListener (this); -this.remove2LeftMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_left")); -this.remove2LeftMenuItem.addActionListener (this); -this.remove2RightMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_right")); -this.remove2RightMenuItem.addActionListener (this); -this.removeGappedColumnMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_empty_columns")); -this.removeGappedColumnMenuItem.addActionListener (this); -this.removeAllGapsMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_all_gaps")); -this.removeAllGapsMenuItem.addActionListener (this); -this.removeRedundancyMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_redundancy").concat ("...")); -this.removeRedundancyMenuItem.addActionListener (this); -this.findMenuItem.setLabel (jalview.util.MessageManager.getString ("action.find")); -this.findMenuItem.addActionListener (this); -this.selectAllSequenceMenuItem.addActionListener (this); -this.deselectAllSequenceMenuItem.addActionListener (this); -this.invertSequenceMenuItem.setLabel (jalview.util.MessageManager.getString ("action.invert_sequence_selection")); -this.invertSequenceMenuItem.addActionListener (this); -this.invertColSel.setLabel (jalview.util.MessageManager.getString ("action.invert_column_selection")); -this.invertColSel.addActionListener (this); -this.deleteGroups.setLabel (jalview.util.MessageManager.getString ("action.undefine_groups")); -this.deleteGroups.addActionListener (this); -this.grpsFromSelection.setLabel (jalview.util.MessageManager.getString ("action.make_groups_selection")); -this.grpsFromSelection.addActionListener (this); -this.createGroup.setLabel (jalview.util.MessageManager.getString ("action.create_group")); -this.unGroup.setLabel (jalview.util.MessageManager.getString ("action.remove_group")); -this.annotationColumnSelection.setLabel ("Select by Annotation"); -this.annotationColumnSelection.addActionListener (this); -this.$newView.setLabel (jalview.util.MessageManager.getString ("action.new_view")); -this.$newView.addActionListener (this); -var showMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.show")); -this.showColumns.setLabel (jalview.util.MessageManager.getString ("label.all_columns")); -this.showSeqs.setLabel (jalview.util.MessageManager.getString ("label.all_sequences")); -var hideMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.hide")); -this.hideColumns.setLabel (jalview.util.MessageManager.getString ("label.selected_columns")); -this.hideSequences.setLabel (jalview.util.MessageManager.getString ("label.selected_sequences")); -this.hideAllButSelection.setLabel (jalview.util.MessageManager.getString ("label.all_but_selected_region")); -this.hideAllSelection.setLabel (jalview.util.MessageManager.getString ("label.selected_region")); -this.showAllHidden.setLabel (jalview.util.MessageManager.getString ("label.all_sequences_columns")); -this.showColumns.addActionListener (this); -this.showSeqs.addActionListener (this); -this.hideColumns.addActionListener (this); -this.hideSequences.addActionListener (this); -this.hideAllButSelection.addActionListener (this); -this.hideAllSelection.addActionListener (this); -this.showAllHidden.addActionListener (this); -this.featureSettings.setLabel (jalview.util.MessageManager.getString ("label.feature_settings")); -this.featureSettings.addActionListener (this); -this.sequenceFeatures.setLabel (jalview.util.MessageManager.getString ("label.show_sequence_features")); -this.sequenceFeatures.addItemListener (this); -this.sequenceFeatures.setState (false); -this.followMouseOverFlag.setLabel (jalview.util.MessageManager.getString ("label.automatic_scrolling")); -this.followMouseOverFlag.addItemListener (this); -this.alProperties.addActionListener (this); -this.overviewMenuItem.setLabel (jalview.util.MessageManager.getString ("label.overview_window")); -this.overviewMenuItem.addActionListener (this); -this.annotationPanelMenuItem.setLabel (jalview.util.MessageManager.getString ("label.show_annotations")); -this.annotationPanelMenuItem.addItemListener (this); -this.showGroupConsensus.setLabel (jalview.util.MessageManager.getString ("label.group_consensus")); -this.showGroupConservation.setLabel (jalview.util.MessageManager.getString ("label.group_conservation")); -this.showConsensusHistogram.setLabel (jalview.util.MessageManager.getString ("label.show_consensus_histogram")); -this.showSequenceLogo.setLabel (jalview.util.MessageManager.getString ("label.show_consensus_logo")); -this.normSequenceLogo.setLabel (jalview.util.MessageManager.getString ("label.norm_consensus_logo")); -this.applyAutoAnnotationSettings.setLabel (jalview.util.MessageManager.getString ("label.apply_all_groups")); -this.applyAutoAnnotationSettings.setState (true); -var autoAnnMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.autocalculated_annotation")); -this.showGroupConsensus.addItemListener (this); -this.showGroupConservation.addItemListener (this); -this.showConsensusHistogram.addItemListener (this); -this.showSequenceLogo.addItemListener (this); -this.normSequenceLogo.addItemListener (this); -this.applyAutoAnnotationSettings.addItemListener (this); -this.showAlignmentAnnotations = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_all_al_annotations")); -this.showSequenceAnnotations = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_all_seq_annotations")); -this.sortAnnBySequence = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.sort_annotations_by_sequence")); -this.sortAnnByLabel = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.sort_annotations_by_label")); -this.showAutoFirst = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_first")); -this.showAutoLast = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_last")); -this.showAlignmentAnnotations.addItemListener (this); -this.showSequenceAnnotations.addItemListener (this); -this.sortAnnBySequence.addItemListener (this); -this.sortAnnByLabel.addItemListener (this); -this.showAutoFirst.addItemListener (this); -this.showAutoLast.addItemListener (this); -this.$font.setLabel (jalview.util.MessageManager.getString ("action.font")); -this.$font.addActionListener (this); -this.scaleAbove.setLabel (jalview.util.MessageManager.getString ("action.scale_above")); -this.scaleAbove.setState (true); -this.scaleAbove.setEnabled (false); -this.scaleAbove.addItemListener (this); -this.scaleLeft.setEnabled (false); -this.scaleLeft.setState (true); -this.scaleLeft.setLabel (jalview.util.MessageManager.getString ("action.scale_left")); -this.scaleLeft.addItemListener (this); -this.scaleRight.setEnabled (false); -this.scaleRight.setState (true); -this.scaleRight.setLabel (jalview.util.MessageManager.getString ("action.scale_right")); -this.scaleRight.addItemListener (this); -this.viewBoxesMenuItem.setLabel (jalview.util.MessageManager.getString ("action.boxes")); -this.viewBoxesMenuItem.setState (true); -this.viewBoxesMenuItem.addItemListener (this); -this.viewTextMenuItem.setLabel (jalview.util.MessageManager.getString ("action.text")); -this.viewTextMenuItem.setState (true); -this.viewTextMenuItem.addItemListener (this); -this.colourTextMenuItem.setLabel (jalview.util.MessageManager.getString ("label.colour_text")); -this.colourTextMenuItem.addItemListener (this); -this.displayNonconservedMenuItem.setLabel (jalview.util.MessageManager.getString ("label.show_non_conversed")); -this.displayNonconservedMenuItem.addItemListener (this); -this.wrapMenuItem.setLabel (jalview.util.MessageManager.getString ("action.wrap")); -this.wrapMenuItem.addItemListener (this); -this.renderGapsMenuItem.setLabel (jalview.util.MessageManager.getString ("action.show_gaps")); -this.renderGapsMenuItem.setState (true); -this.renderGapsMenuItem.addItemListener (this); -this.centreColumnLabelFlag.setLabel (jalview.util.MessageManager.getString ("label.centre_column_labels")); -this.centreColumnLabelFlag.addItemListener (this); -this.seqLimits.setState (true); -this.seqLimits.setLabel (jalview.util.MessageManager.getString ("label.show_sequence_limits")); -this.seqLimits.addItemListener (this); -this.applyToAllGroups.setLabel (jalview.util.MessageManager.getString ("label.apply_colour_to_all_groups")); -this.applyToAllGroups.setState (true); -this.applyToAllGroups.addItemListener (this); -this.clustalColour.setLabel (jalview.util.MessageManager.getString ("label.clustalx")); -this.clustalColour.addActionListener (this); -this.zappoColour.setLabel (jalview.util.MessageManager.getString ("label.zappo")); -this.zappoColour.addActionListener (this); -this.taylorColour.setLabel (jalview.util.MessageManager.getString ("label.taylor")); -this.taylorColour.addActionListener (this); -this.hydrophobicityColour.setLabel (jalview.util.MessageManager.getString ("label.hydrophobicity")); -this.hydrophobicityColour.addActionListener (this); -this.helixColour.setLabel (jalview.util.MessageManager.getString ("label.helix_propensity")); -this.helixColour.addActionListener (this); -this.strandColour.setLabel (jalview.util.MessageManager.getString ("label.strand_propensity")); -this.strandColour.addActionListener (this); -this.turnColour.setLabel (jalview.util.MessageManager.getString ("label.turn_propensity")); -this.turnColour.addActionListener (this); -this.buriedColour.setLabel (jalview.util.MessageManager.getString ("label.buried_index")); -this.buriedColour.addActionListener (this); -this.purinePyrimidineColour.setLabel (jalview.util.MessageManager.getString ("label.purine_pyrimidine")); -this.purinePyrimidineColour.addActionListener (this); -this.RNAInteractionColour.setLabel (jalview.util.MessageManager.getString ("label.rna_interaction")); -this.RNAInteractionColour.addActionListener (this); -this.RNAHelixColour.setLabel (jalview.util.MessageManager.getString ("action.by_rna_helixes")); -this.RNAHelixColour.addActionListener (this); -this.userDefinedColour.setLabel (jalview.util.MessageManager.getString ("action.user_defined")); -this.userDefinedColour.addActionListener (this); -this.PIDColour.setLabel (jalview.util.MessageManager.getString ("label.percentage_identity")); -this.PIDColour.addActionListener (this); -this.BLOSUM62Colour.setLabel (jalview.util.MessageManager.getString ("label.blosum62_score")); -this.BLOSUM62Colour.addActionListener (this); -this.tcoffeeColour.setLabel (jalview.util.MessageManager.getString ("label.tcoffee_scores")); -this.tcoffeeColour.setEnabled (false); -this.tcoffeeColour.addActionListener (this); -this.conservationMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_conservation")); -this.conservationMenuItem.addItemListener (this); -this.noColourmenuItem.setLabel (jalview.util.MessageManager.getString ("label.none")); -this.noColourmenuItem.addActionListener (this); -this.abovePIDThreshold.setLabel (jalview.util.MessageManager.getString ("label.above_identity_threshold")); -this.abovePIDThreshold.addItemListener (this); -this.nucleotideColour.setLabel (jalview.util.MessageManager.getString ("label.nucleotide")); -this.nucleotideColour.addActionListener (this); -this.modifyPID.setLabel (jalview.util.MessageManager.getString ("label.modify_identity_thereshold")); -this.modifyPID.addActionListener (this); -this.modifyConservation.setLabel (jalview.util.MessageManager.getString ("label.modify_conservation_thereshold")); -this.modifyConservation.addActionListener (this); -this.annotationColour.setLabel (jalview.util.MessageManager.getString ("action.by_annotation")); -this.annotationColour.addActionListener (this); -this.sortPairwiseMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_pairwise_id")); -this.sortPairwiseMenuItem.addActionListener (this); -this.sortIDMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_id")); -this.sortIDMenuItem.addActionListener (this); -this.sortLengthMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_length")); -this.sortLengthMenuItem.addActionListener (this); -this.sortGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_group")); -this.sortGroupMenuItem.addActionListener (this); -this.pairwiseAlignmentMenuItem.setLabel (jalview.util.MessageManager.getString ("action.pairwise_alignment")); -this.pairwiseAlignmentMenuItem.addActionListener (this); -this.PCAMenuItem.setLabel (jalview.util.MessageManager.getString ("label.principal_component_analysis")); -this.PCAMenuItem.addActionListener (this); -this.autoCalculate = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.autocalculate_consensus"), true); -this.averageDistanceTreeMenuItem.setLabel (jalview.util.MessageManager.getString ("label.average_distance_identity")); -this.averageDistanceTreeMenuItem.addActionListener (this); -this.neighbourTreeMenuItem.setLabel (jalview.util.MessageManager.getString ("label.neighbour_joining_identity")); -this.neighbourTreeMenuItem.addActionListener (this); -this.avDistanceTreeBlosumMenuItem.setLabel (jalview.util.MessageManager.getString ("label.average_distance_bloslum62")); -this.avDistanceTreeBlosumMenuItem.addActionListener (this); -this.njTreeBlosumMenuItem.setLabel (jalview.util.MessageManager.getString ("label.neighbour_blosum62")); -this.njTreeBlosumMenuItem.addActionListener (this); -this.sortByTreeMenu.setLabel (jalview.util.MessageManager.getString ("action.by_tree_order")); -var sortMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.sort")); -var calculateTreeMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.calculate_tree")); -this.autoCalculate.addItemListener (this); -this.$sortByTree.addItemListener (this); -var helpMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.help")); -this.documentation.setLabel (jalview.util.MessageManager.getString ("label.documentation")); -this.documentation.addActionListener (this); -this.about.setLabel (jalview.util.MessageManager.getString ("label.about")); -this.about.addActionListener (this); -this.alignFrameMenuBar.add (this.fileMenu); -var editMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.edit")); -this.alignFrameMenuBar.add (editMenu); -var selectMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.select")); -this.alignFrameMenuBar.add (selectMenu); -var viewMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.view")); -this.alignFrameMenuBar.add (viewMenu); -var annotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.annotations")); -this.alignFrameMenuBar.add (annotationsMenu); -var formatMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.format")); -this.alignFrameMenuBar.add (formatMenu); -var colourMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.colour")); -this.alignFrameMenuBar.add (colourMenu); -var calculateMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.calculate")); -this.alignFrameMenuBar.add (calculateMenu); -this.alignFrameMenuBar.add (helpMenu); -this.fileMenu.add (this.inputText); -this.fileMenu.add (this.$loadTree); -this.fileMenu.add (this.$loadAnnotations); -this.fileMenu.addSeparator (); -this.fileMenu.add (outputTextboxMenu); -this.fileMenu.add (this.$outputFeatures); -this.fileMenu.add (this.$outputAnnotations); -if (this.jalviewServletURL != null) { -this.fileMenu.add (this.loadApplication); -}this.fileMenu.addSeparator (); -this.fileMenu.add (this.closeMenuItem); -editMenu.add (this.undoMenuItem); -editMenu.add (this.redoMenuItem); -editMenu.add (this.cut); -editMenu.add (this.copy); -this.pasteMenu.add (this.pasteNew); -this.pasteMenu.add (this.pasteThis); -editMenu.add (this.pasteMenu); -editMenu.add (this.$delete); -editMenu.addSeparator (); -editMenu.add (this.remove2LeftMenuItem); -editMenu.add (this.remove2RightMenuItem); -editMenu.add (this.removeGappedColumnMenuItem); -editMenu.add (this.removeAllGapsMenuItem); -editMenu.add (this.removeRedundancyMenuItem); -selectMenu.add (this.findMenuItem); -selectMenu.addSeparator (); -selectMenu.add (this.selectAllSequenceMenuItem); -selectMenu.add (this.deselectAllSequenceMenuItem); -selectMenu.add (this.invertSequenceMenuItem); -selectMenu.add (this.invertColSel); -selectMenu.add (this.createGroup); -selectMenu.add (this.unGroup); -selectMenu.add (this.grpsFromSelection); -selectMenu.add (this.deleteGroups); -selectMenu.add (this.annotationColumnSelection); -viewMenu.add (this.$newView); -viewMenu.addSeparator (); -showMenu.add (this.showColumns); -showMenu.add (this.showSeqs); -showMenu.add (this.showAllHidden); -viewMenu.add (showMenu); -hideMenu.add (this.hideColumns); -hideMenu.add (this.hideSequences); -hideMenu.add (this.hideAllSelection); -hideMenu.add (this.hideAllButSelection); -viewMenu.add (hideMenu); -viewMenu.addSeparator (); -viewMenu.add (this.followMouseOverFlag); -viewMenu.addSeparator (); -viewMenu.add (this.sequenceFeatures); -viewMenu.add (this.featureSettings); -viewMenu.addSeparator (); -viewMenu.add (this.alProperties); -viewMenu.addSeparator (); -viewMenu.add (this.overviewMenuItem); -annotationsMenu.add (this.annotationPanelMenuItem); -annotationsMenu.addSeparator (); -annotationsMenu.add (this.showAlignmentAnnotations); -annotationsMenu.add (this.showSequenceAnnotations); -annotationsMenu.add (this.sortAnnBySequence); -annotationsMenu.add (this.sortAnnByLabel); -annotationsMenu.addSeparator (); -autoAnnMenu.add (this.showAutoFirst); -autoAnnMenu.add (this.showAutoLast); -autoAnnMenu.addSeparator (); -autoAnnMenu.add (this.applyAutoAnnotationSettings); -autoAnnMenu.add (this.showConsensusHistogram); -autoAnnMenu.add (this.showSequenceLogo); -autoAnnMenu.add (this.normSequenceLogo); -autoAnnMenu.addSeparator (); -autoAnnMenu.add (this.showGroupConservation); -autoAnnMenu.add (this.showGroupConsensus); -annotationsMenu.add (autoAnnMenu); -formatMenu.add (this.$font); -formatMenu.add (this.seqLimits); -formatMenu.add (this.wrapMenuItem); -formatMenu.add (this.scaleAbove); -formatMenu.add (this.scaleLeft); -formatMenu.add (this.scaleRight); -formatMenu.add (this.viewBoxesMenuItem); -formatMenu.add (this.viewTextMenuItem); -formatMenu.add (this.colourTextMenuItem); -formatMenu.add (this.displayNonconservedMenuItem); -formatMenu.add (this.renderGapsMenuItem); -formatMenu.add (this.centreColumnLabelFlag); -colourMenu.add (this.applyToAllGroups); -colourMenu.addSeparator (); -colourMenu.add (this.noColourmenuItem); -colourMenu.add (this.clustalColour); -colourMenu.add (this.BLOSUM62Colour); -colourMenu.add (this.PIDColour); -colourMenu.add (this.zappoColour); -colourMenu.add (this.taylorColour); -colourMenu.add (this.hydrophobicityColour); -colourMenu.add (this.helixColour); -colourMenu.add (this.strandColour); -colourMenu.add (this.turnColour); -colourMenu.add (this.buriedColour); -colourMenu.add (this.nucleotideColour); -colourMenu.add (this.purinePyrimidineColour); -colourMenu.add (this.tcoffeeColour); -colourMenu.add (this.userDefinedColour); -colourMenu.addSeparator (); -colourMenu.add (this.conservationMenuItem); -colourMenu.add (this.modifyConservation); -colourMenu.add (this.abovePIDThreshold); -colourMenu.add (this.modifyPID); -colourMenu.add (this.annotationColour); -colourMenu.add (this.RNAHelixColour); -sortMenu.add (this.sortIDMenuItem); -sortMenu.add (this.sortLengthMenuItem); -sortMenu.add (this.sortByTreeMenu); -sortMenu.add (this.sortGroupMenuItem); -sortMenu.add (this.sortPairwiseMenuItem); -calculateMenu.add (sortMenu); -calculateTreeMenu.add (this.averageDistanceTreeMenuItem); -calculateTreeMenu.add (this.neighbourTreeMenuItem); -calculateTreeMenu.add (this.avDistanceTreeBlosumMenuItem); -calculateTreeMenu.add (this.njTreeBlosumMenuItem); -calculateMenu.add (calculateTreeMenu); -calculateMenu.addSeparator (); -calculateMenu.add (this.pairwiseAlignmentMenuItem); -calculateMenu.add (this.PCAMenuItem); -calculateMenu.add (this.autoCalculate); -calculateMenu.add (this.$sortByTree); -helpMenu.add (this.documentation); -helpMenu.add (this.about); -this.statusBar.setBackground (java.awt.Color.white); -this.statusBar.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.setStatus (jalview.util.MessageManager.getString ("label.status_bar")); -this.add (this.statusBar, "South"); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "setStatus", -function (string) { -this.statusBar.setText (string); -}, "~S"); -Clazz.defineMethod (c$, "createAlignFrameWindow", -function (reallyEmbedded) { -if (reallyEmbedded) { -this.embedAlignFrameInApplet (this.viewport.applet); -} else { -if (this.embedMenuIfNeeded (this.alignPanel)) { -this.alignPanel.setSize (this.getSize ().width, this.getSize ().height - this.statusBar.getHeight ()); -}this.add (this.statusBar, "South"); -this.add (this.alignPanel, "Center"); -jalview.bin.JalviewLite.addFrame (this, this.getTitle (), this.frameWidth, this.frameHeight); -}}, "~B"); -Clazz.defineMethod (c$, "embedAlignFrameInApplet", -function (theApplet) { -this.fileMenu.remove (this.closeMenuItem); -this.fileMenu.remove (3); -this.embeddedMenu = this.makeEmbeddedPopupMenu (this.alignFrameMenuBar, false, false); -theApplet.setLayout ( new java.awt.BorderLayout ()); -theApplet.add (this.embeddedMenu, "North"); -theApplet.add (this.statusBar, "South"); -this.alignPanel.setSize (theApplet.getSize ().width, theApplet.getSize ().height - this.embeddedMenu.getHeight () - this.statusBar.getHeight ()); -theApplet.add (this.alignPanel, "Center"); -var me = this; -theApplet.addFocusListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$5") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$5$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$5, this, Clazz.cloneFinals ("theApplet", theApplet, "me", me)))); -theApplet.validate (); -}, "jalview.bin.JalviewLite"); -Clazz.defineMethod (c$, "addStructureViewInstance", -function (jmolviewer, sequenceIds) { -return null; -}, "~O,~A"); -Clazz.defineMethod (c$, "addPdbFile", -function (sequenceId, pdbEntryString, pdbFile) { -var toaddpdb = this.viewport.getAlignment ().findName (sequenceId); -var needtoadd = false; -if (toaddpdb != null) { -var pdbe = toaddpdb.getPDBId (); -var pdbentry = null; -if (pdbe != null && pdbe.size () > 0) { -for (var pe = 0, peSize = pdbe.size (); pe < peSize; pe++) { -pdbentry = pdbe.elementAt (pe); -if (!pdbentry.getId ().equals (pdbEntryString) && !pdbentry.getFile ().equals (pdbFile)) { -pdbentry = null; -} else { -continue; -}} -}if (pdbentry == null) { -pdbentry = new jalview.datamodel.PDBEntry (); -pdbentry.setId (pdbEntryString); -pdbentry.setFile (pdbFile); -needtoadd = true; -}var protocol = jalview.io.AppletFormatAdapter.resolveProtocol (pdbFile, "PDB"); -if (protocol == null) { -return false; -}if (needtoadd) { -if (pdbentry.getProperty () == null) { -pdbentry.setProperty ( new java.util.Hashtable ()); -}pdbentry.getProperty ().put ("protocol", protocol); -toaddpdb.addPDBId (pdbentry); -this.alignPanel.getStructureSelectionManager ().registerPDBEntry (pdbentry); -}}return true; -}, "~S,~S,~S"); -Clazz.defineMethod (c$, "cleanSeqChainArrays", -($fz = function (seqs, chains) { -if (seqs != null) { -var sequences = new java.util.Vector (); -for (var i = 0; i < seqs.length; i++) { -if (seqs[i] != null) { -sequences.addElement ( Clazz.newArray (-1, [seqs[i], (chains != null) ? chains[i] : null])); -}} -seqs = new Array (sequences.size ()); -chains = new Array (sequences.size ()); -for (var i = 0, isize = sequences.size (); i < isize; i++) { -var oj = sequences.elementAt (i); -seqs[i] = oj[0]; -chains[i] = oj[1]; -} -}return Clazz.newArray (-1, [seqs, chains]); -}, $fz.isPrivate = true, $fz), "~A,~A"); -Clazz.defineMethod (c$, "newStructureView", -function (applet, pdb, seqs, chains, protocol) { -var sqch = this.cleanSeqChainArrays (seqs, chains); -seqs = sqch[0]; -chains = sqch[1]; -if (seqs == null || seqs.length == 0) { -System.err.println ("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); -}if (protocol == null || protocol.trim ().length == 0 || protocol.equals ("null")) { -protocol = pdb.getProperty ().get ("protocol"); -if (protocol == null) { -System.err.println ("Couldn't work out protocol to open structure: " + pdb.getId ()); -return; -}}if (applet.useXtrnalSviewer) { -if (jalview.structure.StructureSelectionManager.getStructureSelectionManager (applet).setMapping (seqs, chains, pdb.getFile (), protocol) == null) { -System.err.println ("Failed to map " + pdb.getFile () + " (" + protocol + ") to any sequences"); -}return; -}if (applet.isAlignPdbStructures () && applet.jmolAvailable) { -var ajm = null; -var tajm; -var jmols = applet.getAppletWindow (jalview.appletgui.AppletJmol); -for (var i = 0, iSize = jmols.size (); i < iSize; i++) { -tajm = jmols.elementAt (i); -if (tajm.ap.alignFrame === this) { -ajm = tajm; -break; -}} -if (ajm != null) { -System.err.println ("Incremental adding and aligning structure to existing Jmol view not yet implemented."); -ajm = null; -}} new jalview.appletgui.AppletJmol (pdb, seqs, chains, this.alignPanel, protocol); -jalview.bin.JalviewLite.lastFrameX += 40; -jalview.bin.JalviewLite.lastFrameY += 40; -}, "jalview.bin.JalviewLite,jalview.datamodel.PDBEntry,~A,~A,~S"); -Clazz.defineMethod (c$, "alignedStructureView", -function (applet, pdb, seqs, chains, protocols) { -System.err.println ("Aligned Structure View: Not yet implemented."); -}, "jalview.bin.JalviewLite,~A,~A,~A,~A"); -Clazz.defineMethod (c$, "select", -function (sel, csel) { -this.alignPanel.seqPanel.selection (sel, csel, null); -}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection"); -Clazz.defineMethod (c$, "scrollTo", -function (row, column) { -this.alignPanel.seqPanel.scrollTo (row, column); -}, "~N,~N"); -Clazz.defineMethod (c$, "scrollToRow", -function (row) { -this.alignPanel.seqPanel.scrollToRow (row); -}, "~N"); -Clazz.defineMethod (c$, "scrollToColumn", -function (column) { -this.alignPanel.seqPanel.scrollToColumn (column); -}, "~N"); -Clazz.defineMethod (c$, "getSequenceSetId", -function () { -return this.viewport.getSequenceSetId (); -}); -Clazz.defineMethod (c$, "loadScoreFile", -function (inFile) { -var file = jalview.jsdev.GenericFileAdapter.getFile ("TCoffeeScoreFile", [inFile, jalview.io.AppletFormatAdapter.checkProtocol (inFile)]); -if (!file.isValid ()) { -System.err.println ("Problems parsing T-Coffee scores: " + file.getWarningMessage ()); -System.err.println ("Origin was:\n" + inFile); -return false; -}var aln; -if ((aln = this.viewport.getAlignment ()) != null && (aln.getHeight () != file.getHeight () || aln.getWidth () != file.getWidth ())) { -System.err.println ("The scores matrix does not match the alignment dimensions"); -}if (file.annotateAlignment (this.alignPanel.getAlignment (), false)) { -this.alignPanel.fontChanged (); -this.tcoffeeColour.setEnabled (true); -this.changeColour ( new jalview.schemes.TCoffeeColourScheme (this.alignPanel.getAlignment ())); -return true; -} else { -System.err.println ("Problems resolving T-Coffee scores:"); -if (file.getWarningMessage () != null) { -System.err.println (file.getWarningMessage ()); -}}return false; -}, "~S"); -Clazz.defineMethod (c$, "getSplitFrame", -function () { -return this.splitFrame; -}); -Clazz.defineMethod (c$, "setSplitFrame", -function (sf) { -this.splitFrame = sf; -}, "jalview.appletgui.SplitFrame"); -Clazz.overrideMethod (c$, "setShowSeqFeatures", -function (b) { -this.viewport.setShowSequenceFeatures (b); -}, "~B"); -Clazz.overrideMethod (c$, "setMenusForViewport", -function () { -}); -Clazz.overrideMethod (c$, "refreshFeatureUI", -function (enableIfNecessary) { -if (enableIfNecessary) { -this.sequenceFeatures.setState (true); -this.alignPanel.av.setShowSequenceFeatures (true); -}}, "~B"); -Clazz.overrideMethod (c$, "getFeatureSettingsUI", -function () { -return this.alignPanel.av.featureSettings; -}); -c$.$AlignFrame$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$1", java.awt.event.WindowAdapter); -Clazz.overrideMethod (c$, "windowClosing", -function (e) { -if (this.f$.ap != null) { -this.f$.ap.setOverviewPanel (null); -}}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -c$.$AlignFrame$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$2", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -this.b$["jalview.appletgui.AlignFrame"].sortByTree (this.f$.treePanel, this.f$.title); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$AlignFrame$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$3", java.awt.event.WindowAdapter); -Clazz.defineMethod (c$, "windowOpened", -function (e) { -if (this.b$["jalview.appletgui.AlignFrame"].viewport.sortByTree) { -this.b$["jalview.appletgui.AlignFrame"].sortByTree (this.f$.treePanel, this.f$.title); -}Clazz.superCall (this, jalview.appletgui.AlignFrame$3, "windowOpened", [e]); -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowClosing", -function (e) { -this.b$["jalview.appletgui.AlignFrame"].sortByTreeMenu.remove (this.f$.item); -}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -c$.$AlignFrame$1AboutPanel$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.version = null; -this.builddate = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AlignFrame$1AboutPanel", awt2swing.Canvas); -Clazz.makeConstructor (c$, -function (a, b) { -Clazz.superConstructor (this, jalview.appletgui.AlignFrame$1AboutPanel, []); -this.version = a; -this.builddate = b; -}, "~S,~S"); -Clazz.overrideMethod (c$, "paintComponent", -function (a) { -a.setColor (java.awt.Color.white); -a.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -a.setFont ( new java.awt.Font ("Helvetica", 0, 12)); -var b = a.getFontMetrics (); -var c = b.getHeight (); -var d = 5; -var e = 7; -a.setColor (java.awt.Color.black); -a.setFont ( new java.awt.Font ("Helvetica", 1, 14)); -a.drawString (jalview.util.MessageManager.formatMessage ("label.jalviewLite_release", Clazz.newArray (-1, [this.version])), e, d += c); -a.setFont ( new java.awt.Font ("Helvetica", 1, 12)); -a.drawString (jalview.util.MessageManager.formatMessage ("label.jaview_build_date", Clazz.newArray (-1, [this.builddate])), e, d += c); -a.setFont ( new java.awt.Font ("Helvetica", 0, 12)); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_authors_1"), e, d += c * 1.5); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_authors_2"), e + 50, d += c + 8); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_dev_managers"), e, d += c); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_distribution_lists"), e, d += c); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_please_cite"), e, d += c + 8); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_cite_1_authors"), e, d += c); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_cite_1_title"), e, d += c); -a.drawString (jalview.util.MessageManager.getString ("label.jalview_cite_1_ref"), e, d += c); -}, "java.awt.Graphics"); -c$ = Clazz.p0p (); -}; -c$.$AlignFrame$4$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$4", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.AlignFrame"].outputText_actionPerformed (e); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$AlignFrame$5$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$5", null, java.awt.event.FocusListener); -Clazz.overrideMethod (c$, "focusLost", -function (e) { -if (this.f$.theApplet.currentAlignFrame === this.f$.me) { -this.f$.theApplet.currentAlignFrame = null; -}}, "java.awt.event.FocusEvent"); -Clazz.overrideMethod (c$, "focusGained", -function (e) { -this.f$.theApplet.currentAlignFrame = this.f$.me; -}, "java.awt.event.FocusEvent"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"copiedSequences", null, -"copiedHiddenColumns", null); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Canvas", "jalview.api.AlignViewControllerGuiI", "jalview.appletgui.EmbmenuFrame", "java.awt.event.ActionListener", "$.ItemListener", "$.KeyListener", "awt2swing.CheckboxMenuItem", "$.Label", "$.Menu", "$.MenuBar", "$.MenuItem", "jalview.util.MessageManager", "java.awt.BorderLayout"], "jalview.appletgui.AlignFrame", ["awt2swing.Frame", "jalview.analysis.AlignmentSorter", "$.AnnotationSorter", "jalview.appletgui.AlignViewport", "$.AlignmentPanel", "$.AnnotationColourChooser", "$.AnnotationColumnChooser", "$.AppletJmol", "$.CutAndPasteTransfer", "$.FeatureSettings", "$.Finder", "$.FontChooser", "$.OverviewPanel", "$.PCAPanel", "$.PaintRefresher", "$.PairwiseAlignPanel", "$.RedundancyPanel", "$.SliderPanel", "$.TreePanel", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.commands.EditCommand", "$.OrderCommand", "$.RemoveGapColCommand", "$.RemoveGapsCommand", "$.SlideSequencesCommand", "$.TrimRegionCommand", "jalview.controller.AlignViewController", "jalview.datamodel.Alignment", "$.PDBEntry", "$.Sequence", "$.SequenceGroup", "jalview.io.AlignmentProperties", "$.AnnotationFile", "$.AppletFormatAdapter", "$.FeaturesFile", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.PurinePyrimidineColourScheme", "$.RNAHelicesColourChooser", "$.RNAInteractionColourScheme", "$.StrandColourScheme", "$.TCoffeeColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.ZappoColourScheme", "jalview.structure.StructureSelectionManager", "jalview.util.Comparison", "$.MappingUtils", "java.awt.Color", "$.Font", "java.awt.event.FocusListener", "$.WindowAdapter", "java.lang.Character", "$.StringBuffer", "java.net.URL", "$.URLEncoder", "java.util.Arrays", "$.HashMap", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.avc = null; +this.alignPanel = null; +this.viewport = null; +this.frameWidth = 700; +this.frameHeight = 500; +this.jalviewServletURL = null; +this.showAutoCalculatedAbove = false; +this.annotationSortOrder = null; +this.alignFrameMenuBar = null; +this.fileMenu = null; +this.loadApplication = null; +this.$loadTree = null; +this.$loadAnnotations = null; +this.$outputFeatures = null; +this.$outputAnnotations = null; +this.closeMenuItem = null; +this.selectAllSequenceMenuItem = null; +this.deselectAllSequenceMenuItem = null; +this.invertSequenceMenuItem = null; +this.remove2LeftMenuItem = null; +this.remove2RightMenuItem = null; +this.removeGappedColumnMenuItem = null; +this.removeAllGapsMenuItem = null; +this.viewBoxesMenuItem = null; +this.viewTextMenuItem = null; +this.sortPairwiseMenuItem = null; +this.sortIDMenuItem = null; +this.sortLengthMenuItem = null; +this.sortGroupMenuItem = null; +this.removeRedundancyMenuItem = null; +this.pairwiseAlignmentMenuItem = null; +this.PCAMenuItem = null; +this.averageDistanceTreeMenuItem = null; +this.neighbourTreeMenuItem = null; +this.borderLayout1 = null; +this.statusBar = null; +this.clustalColour = null; +this.zappoColour = null; +this.taylorColour = null; +this.hydrophobicityColour = null; +this.helixColour = null; +this.strandColour = null; +this.turnColour = null; +this.buriedColour = null; +this.purinePyrimidineColour = null; +this.RNAInteractionColour = null; +this.RNAHelixColour = null; +this.userDefinedColour = null; +this.PIDColour = null; +this.BLOSUM62Colour = null; +this.tcoffeeColour = null; +this.njTreeBlosumMenuItem = null; +this.avDistanceTreeBlosumMenuItem = null; +this.annotationPanelMenuItem = null; +this.colourTextMenuItem = null; +this.displayNonconservedMenuItem = null; +this.alProperties = null; +this.overviewMenuItem = null; +this.undoMenuItem = null; +this.redoMenuItem = null; +this.conservationMenuItem = null; +this.noColourmenuItem = null; +this.wrapMenuItem = null; +this.renderGapsMenuItem = null; +this.findMenuItem = null; +this.abovePIDThreshold = null; +this.nucleotideColour = null; +this.deleteGroups = null; +this.grpsFromSelection = null; +this.createGroup = null; +this.unGroup = null; +this.$delete = null; +this.copy = null; +this.cut = null; +this.pasteMenu = null; +this.pasteNew = null; +this.pasteThis = null; +this.applyToAllGroups = null; +this.$font = null; +this.scaleAbove = null; +this.scaleLeft = null; +this.scaleRight = null; +this.modifyPID = null; +this.modifyConservation = null; +this.autoCalculate = null; +this.$sortByTree = null; +this.sortByTreeMenu = null; +this.inputText = null; +this.documentation = null; +this.about = null; +this.seqLimits = null; +this.centreColumnLabelFlag = null; +this.followMouseOverFlag = null; +this.showSequenceLogo = null; +this.applyAutoAnnotationSettings = null; +this.showConsensusHistogram = null; +this.showGroupConsensus = null; +this.showGroupConservation = null; +this.normSequenceLogo = null; +this.featureSettings = null; +this.sequenceFeatures = null; +this.annotationColour = null; +this.annotationColumnSelection = null; +this.invertColSel = null; +this.showColumns = null; +this.showSeqs = null; +this.hideColumns = null; +this.hideSequences = null; +this.hideAllButSelection = null; +this.hideAllSelection = null; +this.showAllHidden = null; +this.$newView = null; +this.showAlignmentAnnotations = null; +this.showSequenceAnnotations = null; +this.sortAnnBySequence = null; +this.sortAnnByLabel = null; +this.showAutoFirst = null; +this.showAutoLast = null; +this.splitFrame = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AlignFrame", jalview.appletgui.EmbmenuFrame, [java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, jalview.api.AlignViewControllerGuiI]); +Clazz.prepareFields (c$, function () { +this.alignFrameMenuBar = new awt2swing.MenuBar (); +this.fileMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.file")); +this.loadApplication = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.view_full_application")); +this.$loadTree = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.load_associated_tree")); +this.$loadAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.load_features_annotations")); +this.$outputFeatures = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.export_features").concat ("...")); +this.$outputAnnotations = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.export_annotations").concat ("...")); +this.closeMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.close")); +this.selectAllSequenceMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.select_all")); +this.deselectAllSequenceMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.deselect_all")); +this.invertSequenceMenuItem = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.invert_selection")); +this.remove2LeftMenuItem = new awt2swing.MenuItem (); +this.remove2RightMenuItem = new awt2swing.MenuItem (); +this.removeGappedColumnMenuItem = new awt2swing.MenuItem (); +this.removeAllGapsMenuItem = new awt2swing.MenuItem (); +this.viewBoxesMenuItem = new awt2swing.CheckboxMenuItem (); +this.viewTextMenuItem = new awt2swing.CheckboxMenuItem (); +this.sortPairwiseMenuItem = new awt2swing.MenuItem (); +this.sortIDMenuItem = new awt2swing.MenuItem (); +this.sortLengthMenuItem = new awt2swing.MenuItem (); +this.sortGroupMenuItem = new awt2swing.MenuItem (); +this.removeRedundancyMenuItem = new awt2swing.MenuItem (); +this.pairwiseAlignmentMenuItem = new awt2swing.MenuItem (); +this.PCAMenuItem = new awt2swing.MenuItem (); +this.averageDistanceTreeMenuItem = new awt2swing.MenuItem (); +this.neighbourTreeMenuItem = new awt2swing.MenuItem (); +this.borderLayout1 = new java.awt.BorderLayout (); +this.statusBar = new awt2swing.Label (); +this.clustalColour = new awt2swing.MenuItem (); +this.zappoColour = new awt2swing.MenuItem (); +this.taylorColour = new awt2swing.MenuItem (); +this.hydrophobicityColour = new awt2swing.MenuItem (); +this.helixColour = new awt2swing.MenuItem (); +this.strandColour = new awt2swing.MenuItem (); +this.turnColour = new awt2swing.MenuItem (); +this.buriedColour = new awt2swing.MenuItem (); +this.purinePyrimidineColour = new awt2swing.MenuItem (); +this.RNAInteractionColour = new awt2swing.MenuItem (); +this.RNAHelixColour = new awt2swing.MenuItem (); +this.userDefinedColour = new awt2swing.MenuItem (); +this.PIDColour = new awt2swing.MenuItem (); +this.BLOSUM62Colour = new awt2swing.MenuItem (); +this.tcoffeeColour = new awt2swing.MenuItem (); +this.njTreeBlosumMenuItem = new awt2swing.MenuItem (); +this.avDistanceTreeBlosumMenuItem = new awt2swing.MenuItem (); +this.annotationPanelMenuItem = new awt2swing.CheckboxMenuItem (); +this.colourTextMenuItem = new awt2swing.CheckboxMenuItem (); +this.displayNonconservedMenuItem = new awt2swing.CheckboxMenuItem (); +this.alProperties = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.alignment_props")); +this.overviewMenuItem = new awt2swing.MenuItem (); +this.undoMenuItem = new awt2swing.MenuItem (); +this.redoMenuItem = new awt2swing.MenuItem (); +this.conservationMenuItem = new awt2swing.CheckboxMenuItem (); +this.noColourmenuItem = new awt2swing.MenuItem (); +this.wrapMenuItem = new awt2swing.CheckboxMenuItem (); +this.renderGapsMenuItem = new awt2swing.CheckboxMenuItem (); +this.findMenuItem = new awt2swing.MenuItem (); +this.abovePIDThreshold = new awt2swing.CheckboxMenuItem (); +this.nucleotideColour = new awt2swing.MenuItem (); +this.deleteGroups = new awt2swing.MenuItem (); +this.grpsFromSelection = new awt2swing.MenuItem (); +this.createGroup = new awt2swing.MenuItem (); +this.unGroup = new awt2swing.MenuItem (); +this.$delete = new awt2swing.MenuItem (); +this.copy = new awt2swing.MenuItem (); +this.cut = new awt2swing.MenuItem (); +this.pasteMenu = new awt2swing.Menu (); +this.pasteNew = new awt2swing.MenuItem (); +this.pasteThis = new awt2swing.MenuItem (); +this.applyToAllGroups = new awt2swing.CheckboxMenuItem (); +this.$font = new awt2swing.MenuItem (); +this.scaleAbove = new awt2swing.CheckboxMenuItem (); +this.scaleLeft = new awt2swing.CheckboxMenuItem (); +this.scaleRight = new awt2swing.CheckboxMenuItem (); +this.modifyPID = new awt2swing.MenuItem (); +this.modifyConservation = new awt2swing.MenuItem (); +this.$sortByTree = new awt2swing.CheckboxMenuItem ("Sort Alignment With New Tree", true); +this.sortByTreeMenu = new awt2swing.Menu (); +this.inputText = new awt2swing.MenuItem (); +this.documentation = new awt2swing.MenuItem (); +this.about = new awt2swing.MenuItem (); +this.seqLimits = new awt2swing.CheckboxMenuItem (); +this.centreColumnLabelFlag = new awt2swing.CheckboxMenuItem (); +this.followMouseOverFlag = new awt2swing.CheckboxMenuItem (); +this.showSequenceLogo = new awt2swing.CheckboxMenuItem (); +this.applyAutoAnnotationSettings = new awt2swing.CheckboxMenuItem (); +this.showConsensusHistogram = new awt2swing.CheckboxMenuItem (); +this.showGroupConsensus = new awt2swing.CheckboxMenuItem (); +this.showGroupConservation = new awt2swing.CheckboxMenuItem (); +this.normSequenceLogo = new awt2swing.CheckboxMenuItem (); +this.featureSettings = new awt2swing.MenuItem (); +this.sequenceFeatures = new awt2swing.CheckboxMenuItem (); +this.annotationColour = new awt2swing.MenuItem (); +this.annotationColumnSelection = new awt2swing.MenuItem (); +this.invertColSel = new awt2swing.MenuItem (); +this.showColumns = new awt2swing.MenuItem (); +this.showSeqs = new awt2swing.MenuItem (); +this.hideColumns = new awt2swing.MenuItem (); +this.hideSequences = new awt2swing.MenuItem (); +this.hideAllButSelection = new awt2swing.MenuItem (); +this.hideAllSelection = new awt2swing.MenuItem (); +this.showAllHidden = new awt2swing.MenuItem (); +this.$newView = new awt2swing.MenuItem (); +}); +Clazz.makeConstructor (c$, +function (al, applet, title, embedded) { +this.construct (al, applet, title, embedded, true); +}, "jalview.datamodel.AlignmentI,jalview.bin.JalviewLite,~S,~B"); +Clazz.makeConstructor (c$, +function (al, applet, title, embedded, addToDisplay) { +this.construct (al, null, null, applet, title, embedded, addToDisplay); +}, "jalview.datamodel.AlignmentI,jalview.bin.JalviewLite,~S,~B,~B"); +Clazz.makeConstructor (c$, +function (al, hiddenSeqs, columnSelection, applet, title, embedded) { +this.construct (al, hiddenSeqs, columnSelection, applet, title, embedded, true); +}, "jalview.datamodel.AlignmentI,~A,jalview.datamodel.ColumnSelection,jalview.bin.JalviewLite,~S,~B"); +Clazz.makeConstructor (c$, +function (al, hiddenSeqs, columnSelection, applet, title, embedded, addToDisplay) { +Clazz.superConstructor (this, jalview.appletgui.AlignFrame, []); +if (applet != null) { +this.jalviewServletURL = applet.jalviewServletURL; +}try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +if (applet != null) { +var param; +try { +param = applet.windowWidth; +if (param != null) { +var width = Integer.parseInt (param); +this.frameWidth = width; +}param = applet.windowHeight; +if (param != null) { +var height = Integer.parseInt (param); +this.frameHeight = height; +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +}this.viewport = new jalview.appletgui.AlignViewport (al, applet); +if (hiddenSeqs != null && hiddenSeqs.length > 0) { +this.viewport.hideSequence (hiddenSeqs); +}if (columnSelection != null) { +this.viewport.setColumnSelection (columnSelection); +}this.alignPanel = new jalview.appletgui.AlignmentPanel (this, this.viewport); +this.avc = new jalview.controller.AlignViewController (this, this.viewport, this.alignPanel); +this.viewport.updateConservation (this.alignPanel); +this.viewport.updateConsensus (this.alignPanel); +this.displayNonconservedMenuItem.setState (this.viewport.getShowUnconserved ()); +this.followMouseOverFlag.setState (this.viewport.isFollowHighlight ()); +this.showGroupConsensus.setState (this.viewport.isShowGroupConsensus ()); +this.showGroupConservation.setState (this.viewport.isShowGroupConservation ()); +this.showConsensusHistogram.setState (this.viewport.isShowConsensusHistogram ()); +this.showSequenceLogo.setState (this.viewport.isShowSequenceLogo ()); +this.normSequenceLogo.setState (this.viewport.isNormaliseSequenceLogo ()); +this.applyToAllGroups.setState (this.viewport.getColourAppliesToAllGroups ()); +this.annotationPanelMenuItem.setState (this.viewport.isShowAnnotation ()); +this.showAlignmentAnnotations.setState (this.viewport.isShowAnnotation ()); +this.showSequenceAnnotations.setState (this.viewport.isShowAnnotation ()); +this.seqLimits.setState (this.viewport.getShowJVSuffix ()); +if (applet != null) { +var param = applet.sortBy; +if (param != null) { +if (param.equalsIgnoreCase ("Id")) { +this.sortIDMenuItem_actionPerformed (); +} else if (param.equalsIgnoreCase ("Pairwise Identity")) { +this.sortPairwiseMenuItem_actionPerformed (); +} else if (param.equalsIgnoreCase ("Length")) { +this.sortLengthMenuItem_actionPerformed (); +}}param = applet.wrap; +if (param != null) { +if (param.equalsIgnoreCase ("true")) { +this.wrapMenuItem.setState (true); +this.wrapMenuItem_actionPerformed (); +}}param = applet.centrecolumnlabels; +if (param != null) { +this.centreColumnLabelFlag.setState (true); +this.centreColumnLabelFlag_stateChanged (); +}}if (this.viewport.getAlignment ().isNucleotide ()) { +this.viewport.updateStrucConsensus (this.alignPanel); +if (this.viewport.getAlignment ().hasRNAStructure ()) { +this.RNAHelixColour.setEnabled (true); +} else { +this.RNAHelixColour.setEnabled (false); +}} else { +this.RNAHelixColour.setEnabled (false); +this.purinePyrimidineColour.setEnabled (false); +}this.addKeyListener (this); +this.alignPanel.seqPanel.seqCanvas.addKeyListener (this); +this.alignPanel.idPanel.idCanvas.addKeyListener (this); +this.alignPanel.scalePanel.addKeyListener (this); +this.alignPanel.annotationPanel.addKeyListener (this); +this.alignPanel.annotationPanelHolder.addKeyListener (this); +this.alignPanel.annotationSpaceFillerHolder.addKeyListener (this); +this.alignPanel.alabels.addKeyListener (this); +if (addToDisplay) { +this.addToDisplay (embedded); +}}, "jalview.datamodel.AlignmentI,~A,jalview.datamodel.ColumnSelection,jalview.bin.JalviewLite,~S,~B,~B"); +Clazz.defineMethod (c$, "addToDisplay", +function (embedded) { +this.createAlignFrameWindow (embedded); +this.validate (); +this.alignPanel.adjustAnnotationHeight (); +this.alignPanel.paintAlignment (true); +}, "~B"); +Clazz.defineMethod (c$, "getAlignViewport", +function () { +return this.viewport; +}); +Clazz.defineMethod (c$, "getSeqcanvas", +function () { +return this.alignPanel.seqPanel.seqCanvas; +}); +Clazz.defineMethod (c$, "parseFeaturesFile", +function (file, type) { +return this.parseFeaturesFile (file, type, true); +}, "~S,~S"); +Clazz.defineMethod (c$, "parseFeaturesFile", +function (file, type, autoenabledisplay) { +var featureLinks = new java.util.Hashtable (); +var featuresFile = false; +try { +featuresFile = new jalview.io.FeaturesFile (file, type).parse (this.viewport.getAlignment (), this.alignPanel.seqPanel.seqCanvas.getFeatureRenderer ().getFeatureColours (), featureLinks, true, this.viewport.applet.getDefaultParameter ("relaxedidmatch", false)); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +if (featuresFile) { +if (featureLinks.size () > 0) { +this.alignPanel.seqPanel.seqCanvas.getFeatureRenderer ().featureLinks = featureLinks; +}if (autoenabledisplay) { +this.viewport.setShowSequenceFeatures (true); +this.sequenceFeatures.setState (true); +}if (this.alignPanel.seqPanel.seqCanvas.fr != null) { +this.alignPanel.seqPanel.seqCanvas.fr.findAllFeatures (true); +}if (this.viewport.featureSettings != null) { +this.viewport.featureSettings.refreshTable (); +}this.alignPanel.paintAlignment (true); +this.setStatus (jalview.util.MessageManager.getString ("label.successfully_added_features_alignment")); +}return featuresFile; +}, "~S,~S,~B"); +Clazz.overrideMethod (c$, "keyPressed", +function (evt) { +if (this.viewport.cursorMode && ((evt.getKeyCode () >= 48 && evt.getKeyCode () <= 57) || (evt.getKeyCode () >= 96 && evt.getKeyCode () <= 105)) && Character.isDigit (evt.getKeyChar ())) { +this.alignPanel.seqPanel.numberPressed (evt.getKeyChar ()); +}switch (evt.getKeyCode ()) { +case 27: +this.deselectAllSequenceMenuItem_actionPerformed (); +this.alignPanel.alabels.cancelDrag (); +break; +case 88: +if (evt.isControlDown () || evt.isMetaDown ()) { +this.cut_actionPerformed (); +}break; +case 67: +if (this.viewport.cursorMode && !evt.isControlDown ()) { +this.alignPanel.seqPanel.setCursorColumn (); +}if (evt.isControlDown () || evt.isMetaDown ()) { +this.copy_actionPerformed (); +}break; +case 86: +if (evt.isControlDown ()) { +this.paste (evt.isShiftDown ()); +}break; +case 65: +if (evt.isControlDown () || evt.isMetaDown ()) { +this.selectAllSequenceMenuItem_actionPerformed (); +}break; +case 40: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.moveCursor (0, 1); +} else { +this.moveSelectedSequences (false); +}break; +case 38: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.moveCursor (0, -1); +} else { +this.moveSelectedSequences (true); +}break; +case 37: +if (evt.isAltDown () || !this.viewport.cursorMode) { +this.slideSequences (false, this.alignPanel.seqPanel.getKeyboardNo1 ()); +} else { +this.alignPanel.seqPanel.moveCursor (-1, 0); +}break; +case 39: +if (evt.isAltDown () || !this.viewport.cursorMode) { +this.slideSequences (true, this.alignPanel.seqPanel.getKeyboardNo1 ()); +} else { +this.alignPanel.seqPanel.moveCursor (1, 0); +}break; +case 32: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.insertGapAtCursor (evt.isControlDown () || evt.isShiftDown () || evt.isAltDown ()); +}break; +case 127: +case 8: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.deleteGapAtCursor (evt.isControlDown () || evt.isShiftDown () || evt.isAltDown ()); +} else { +this.cut_actionPerformed (); +this.alignPanel.seqPanel.seqCanvas.repaint (); +}break; +case 83: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.setCursorRow (); +}break; +case 80: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.setCursorPosition (); +}break; +case 10: +case 44: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.setCursorRowAndColumn (); +}break; +case 81: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.setSelectionAreaAtCursor (true); +}break; +case 77: +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.setSelectionAreaAtCursor (false); +}break; +case 113: +this.viewport.cursorMode = !this.viewport.cursorMode; +this.setStatus (jalview.util.MessageManager.formatMessage ("label.keyboard_editing_mode", Clazz.newArray (-1, [(this.viewport.cursorMode ? "on" : "off")]))); +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.seqCanvas.cursorX = this.viewport.startRes; +this.alignPanel.seqPanel.seqCanvas.cursorY = this.viewport.startSeq; +}break; +case 70: +if (evt.isControlDown ()) { +this.findMenuItem_actionPerformed (); +}break; +case 72: +{ +var toggleSeqs = !evt.isControlDown (); +var toggleCols = !evt.isShiftDown (); +this.toggleHiddenRegions (toggleSeqs, toggleCols); +break; +}case 33: +if (this.viewport.getWrapAlignment ()) { +this.alignPanel.scrollUp (true); +} else { +this.alignPanel.setScrollValues (this.viewport.startRes, this.viewport.startSeq - this.viewport.endSeq + this.viewport.startSeq); +}break; +case 34: +if (this.viewport.getWrapAlignment ()) { +this.alignPanel.scrollUp (false); +} else { +this.alignPanel.setScrollValues (this.viewport.startRes, this.viewport.startSeq + this.viewport.endSeq - this.viewport.startSeq); +}break; +case 90: +if (evt.isControlDown ()) { +this.undoMenuItem_actionPerformed (); +}break; +case 89: +if (evt.isControlDown ()) { +this.redoMenuItem_actionPerformed (); +}break; +case 76: +if (evt.isControlDown ()) { +this.trimAlignment (true); +}break; +case 82: +if (evt.isControlDown ()) { +this.trimAlignment (false); +}break; +case 69: +if (evt.isControlDown ()) { +if (evt.isShiftDown ()) { +this.removeAllGapsMenuItem_actionPerformed (); +} else { +this.removeGappedColumnMenuItem_actionPerformed (); +}}break; +case 73: +if (evt.isControlDown ()) { +if (evt.isAltDown ()) { +this.invertColSel_actionPerformed (); +} else { +this.invertSequenceMenuItem_actionPerformed (); +}}break; +case 71: +if (evt.isControlDown ()) { +if (evt.isShiftDown ()) { +this.unGroup_actionPerformed (); +} else { +this.createGroup_actionPerformed (); +}}break; +case 85: +if (evt.isControlDown ()) { +this.deleteGroups_actionPerformed (); +}break; +case 84: +if (evt.isControlDown ()) { +this.newView (null); +}break; +} +this.alignPanel.paintAlignment (true); +}, "java.awt.event.KeyEvent"); +Clazz.defineMethod (c$, "toggleHiddenRegions", +($fz = function (toggleSeqs, toggleCols) { +var hide = false; +var sg = this.viewport.getSelectionGroup (); +if (!toggleSeqs && !toggleCols) { +if ((this.viewport.getColumnSelection () != null && this.viewport.getColumnSelection ().getSelected () != null && this.viewport.getColumnSelection ().getSelected ().size () > 0) || (sg != null && sg.getSize () > 0 && sg.getStartRes () <= sg.getEndRes ())) { +if (sg != null) { +this.invertSequenceMenuItem_actionPerformed (); +sg = this.viewport.getSelectionGroup (); +toggleSeqs = true; +}this.viewport.expandColSelection (sg, true); +this.invertColSel_actionPerformed (); +toggleCols = true; +}}if (toggleSeqs) { +if (sg != null && sg.getSize () != this.viewport.getAlignment ().getHeight ()) { +hide = true; +this.viewport.hideAllSelectedSeqs (); +} else if (!(toggleCols && this.viewport.getColumnSelection ().getSelected ().size () > 0)) { +this.viewport.showAllHiddenSeqs (); +}}if (toggleCols) { +if (this.viewport.getColumnSelection ().getSelected ().size () > 0) { +this.viewport.hideSelectedColumns (); +if (!toggleSeqs) { +this.viewport.setSelectionGroup (sg); +}} else if (!hide) { +this.viewport.showAllHiddenColumns (); +}}}, $fz.isPrivate = true, $fz), "~B,~B"); +Clazz.overrideMethod (c$, "keyReleased", +function (evt) { +}, "java.awt.event.KeyEvent"); +Clazz.overrideMethod (c$, "keyTyped", +function (evt) { +}, "java.awt.event.KeyEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +var source = evt.getSource (); +if (source === this.displayNonconservedMenuItem) { +this.displayNonconservedMenuItem_actionPerformed (); +} else if (source === this.colourTextMenuItem) { +this.colourTextMenuItem_actionPerformed (); +} else if (source === this.wrapMenuItem) { +this.wrapMenuItem_actionPerformed (); +} else if (source === this.scaleAbove) { +this.viewport.setScaleAboveWrapped (this.scaleAbove.getState ()); +} else if (source === this.scaleLeft) { +this.viewport.setScaleLeftWrapped (this.scaleLeft.getState ()); +} else if (source === this.scaleRight) { +this.viewport.setScaleRightWrapped (this.scaleRight.getState ()); +} else if (source === this.seqLimits) { +this.seqLimits_itemStateChanged (); +} else if (source === this.viewBoxesMenuItem) { +this.viewport.setShowBoxes (this.viewBoxesMenuItem.getState ()); +} else if (source === this.viewTextMenuItem) { +this.viewport.setShowText (this.viewTextMenuItem.getState ()); +} else if (source === this.renderGapsMenuItem) { +this.viewport.setRenderGaps (this.renderGapsMenuItem.getState ()); +} else if (source === this.annotationPanelMenuItem) { +this.viewport.setShowAnnotation (this.annotationPanelMenuItem.getState ()); +this.alignPanel.setAnnotationVisible (this.annotationPanelMenuItem.getState ()); +} else if (source === this.sequenceFeatures) { +this.viewport.setShowSequenceFeatures (this.sequenceFeatures.getState ()); +this.alignPanel.seqPanel.seqCanvas.repaint (); +} else if (source === this.showAlignmentAnnotations) { +this.setAnnotationsVisibility (); +} else if (source === this.showSequenceAnnotations) { +this.setAnnotationsVisibility (); +} else if (source === this.sortAnnBySequence) { +var newState = this.sortAnnBySequence.getState (); +this.sortAnnByLabel.setState (false); +this.setAnnotationSortOrder (newState ? jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.SEQUENCE_AND_LABEL : jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE); +this.setViewportAnnotationOrder (); +} else if (source === this.sortAnnByLabel) { +var newState = this.sortAnnByLabel.getState (); +this.sortAnnBySequence.setState (false); +this.setAnnotationSortOrder (newState ? jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.LABEL_AND_SEQUENCE : jalview.analysis.AnnotationSorter.SequenceAnnotationOrder.NONE); +this.setViewportAnnotationOrder (); +} else if (source === this.showAutoFirst) { +this.showAutoLast.setState (!this.showAutoFirst.getState ()); +this.setShowAutoCalculatedAbove (this.showAutoFirst.getState ()); +this.setViewportAnnotationOrder (); +} else if (source === this.showAutoLast) { +this.showAutoFirst.setState (!this.showAutoLast.getState ()); +this.setShowAutoCalculatedAbove (this.showAutoFirst.getState ()); +this.setViewportAnnotationOrder (); +} else if (source === this.conservationMenuItem) { +this.conservationMenuItem_actionPerformed (); +} else if (source === this.abovePIDThreshold) { +this.abovePIDThreshold_actionPerformed (); +} else if (source === this.applyToAllGroups) { +this.viewport.setColourAppliesToAllGroups (this.applyToAllGroups.getState ()); +} else if (source === this.autoCalculate) { +this.viewport.autoCalculateConsensus = this.autoCalculate.getState (); +} else if (source === this.$sortByTree) { +this.viewport.sortByTree = this.$sortByTree.getState (); +} else if (source === this.centreColumnLabelFlag) { +this.centreColumnLabelFlag_stateChanged (); +} else if (source === this.followMouseOverFlag) { +this.mouseOverFlag_stateChanged (); +} else if (source === this.showGroupConsensus) { +this.showGroupConsensus_actionPerformed (); +} else if (source === this.showGroupConservation) { +this.showGroupConservation_actionPerformed (); +} else if (source === this.showSequenceLogo) { +this.showSequenceLogo_actionPerformed (); +} else if (source === this.normSequenceLogo) { +this.normSequenceLogo_actionPerformed (); +} else if (source === this.showConsensusHistogram) { +this.showConsensusHistogram_actionPerformed (); +} else if (source === this.applyAutoAnnotationSettings) { +this.applyAutoAnnotationSettings_actionPerformed (); +}this.alignPanel.paintAlignment (true); +}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "setAnnotationsVisibility", +($fz = function () { +var showForAlignment = this.showAlignmentAnnotations.getState (); +var showForSequences = this.showSequenceAnnotations.getState (); +for (var aa, $aa = 0, $$aa = this.alignPanel.getAlignment ().getAlignmentAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { +var visible = (aa.sequenceRef == null ? showForAlignment : showForSequences); +aa.visible = visible; +} +this.alignPanel.validateAnnotationDimensions (true); +this.validate (); +this.repaint (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "setAnnotationSortOrder", +($fz = function (order) { +this.annotationSortOrder = order; +}, $fz.isPrivate = true, $fz), "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); +Clazz.defineMethod (c$, "setViewportAnnotationOrder", +($fz = function () { +this.alignPanel.av.setSortAnnotationsBy (this.annotationSortOrder); +this.alignPanel.av.setShowAutocalculatedAbove (this.showAutoCalculatedAbove); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "setShowAutoCalculatedAbove", +($fz = function (showAbove) { +this.showAutoCalculatedAbove = showAbove; +}, $fz.isPrivate = true, $fz), "~B"); +Clazz.defineMethod (c$, "mouseOverFlag_stateChanged", +($fz = function () { +this.viewport.setFollowHighlight (this.followMouseOverFlag.getState ()); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "centreColumnLabelFlag_stateChanged", +($fz = function () { +this.viewport.centreColumnLabels = this.centreColumnLabelFlag.getState (); +this.alignPanel.annotationPanel.repaint (); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +var source = evt.getSource (); +if (source === this.inputText) { +this.inputText_actionPerformed (); +} else if (source === this.$loadTree) { +this.loadTree_actionPerformed (); +} else if (source === this.loadApplication) { +this.launchFullApplication (); +} else if (source === this.$loadAnnotations) { +this.loadAnnotations (); +} else if (source === this.$outputAnnotations) { +this.outputAnnotations (true); +} else if (source === this.$outputFeatures) { +this.outputFeatures (true, "Jalview"); +} else if (source === this.closeMenuItem) { +this.closeMenuItem_actionPerformed (); +} else if (source === this.copy) { +this.copy_actionPerformed (); +} else if (source === this.undoMenuItem) { +this.undoMenuItem_actionPerformed (); +} else if (source === this.redoMenuItem) { +this.redoMenuItem_actionPerformed (); +} else if (source === this.inputText) { +this.inputText_actionPerformed (); +} else if (source === this.closeMenuItem) { +this.closeMenuItem_actionPerformed (); +} else if (source === this.undoMenuItem) { +this.undoMenuItem_actionPerformed (); +} else if (source === this.redoMenuItem) { +this.redoMenuItem_actionPerformed (); +} else if (source === this.copy) { +this.copy_actionPerformed (); +} else if (source === this.pasteNew) { +this.pasteNew_actionPerformed (); +} else if (source === this.pasteThis) { +this.pasteThis_actionPerformed (); +} else if (source === this.cut) { +this.cut_actionPerformed (); +} else if (source === this.$delete) { +this.delete_actionPerformed (); +} else if (source === this.grpsFromSelection) { +this.makeGrpsFromSelection_actionPerformed (); +} else if (source === this.deleteGroups) { +this.deleteGroups_actionPerformed (); +} else if (source === this.selectAllSequenceMenuItem) { +this.selectAllSequenceMenuItem_actionPerformed (); +} else if (source === this.deselectAllSequenceMenuItem) { +this.deselectAllSequenceMenuItem_actionPerformed (); +} else if (source === this.invertSequenceMenuItem) { +this.invertSequenceMenuItem_actionPerformed (); +} else if (source === this.invertColSel) { +this.viewport.invertColumnSelection (); +this.alignPanel.paintAlignment (true); +} else if (source === this.remove2LeftMenuItem) { +this.trimAlignment (true); +} else if (source === this.remove2RightMenuItem) { +this.trimAlignment (false); +} else if (source === this.removeGappedColumnMenuItem) { +this.removeGappedColumnMenuItem_actionPerformed (); +} else if (source === this.removeAllGapsMenuItem) { +this.removeAllGapsMenuItem_actionPerformed (); +} else if (source === this.findMenuItem) { +this.findMenuItem_actionPerformed (); +} else if (source === this.$font) { + new jalview.appletgui.FontChooser (this.alignPanel); +} else if (source === this.$newView) { +this.newView (null); +} else if (source === this.showColumns) { +this.viewport.showAllHiddenColumns (); +this.alignPanel.paintAlignment (true); +} else if (source === this.showSeqs) { +this.viewport.showAllHiddenSeqs (); +this.alignPanel.paintAlignment (true); +} else if (source === this.hideColumns) { +this.viewport.hideSelectedColumns (); +this.alignPanel.paintAlignment (true); +} else if (source === this.hideSequences && this.viewport.getSelectionGroup () != null) { +this.viewport.hideAllSelectedSeqs (); +this.alignPanel.paintAlignment (true); +} else if (source === this.hideAllButSelection) { +this.toggleHiddenRegions (false, false); +this.alignPanel.paintAlignment (true); +} else if (source === this.hideAllSelection) { +var sg = this.viewport.getSelectionGroup (); +this.viewport.expandColSelection (sg, false); +this.viewport.hideAllSelectedSeqs (); +this.viewport.hideSelectedColumns (); +this.alignPanel.paintAlignment (true); +} else if (source === this.showAllHidden) { +this.viewport.showAllHiddenColumns (); +this.viewport.showAllHiddenSeqs (); +this.alignPanel.paintAlignment (true); +} else if (source === this.showGroupConsensus) { +this.showGroupConsensus_actionPerformed (); +} else if (source === this.showGroupConservation) { +this.showGroupConservation_actionPerformed (); +} else if (source === this.showSequenceLogo) { +this.showSequenceLogo_actionPerformed (); +} else if (source === this.normSequenceLogo) { +this.normSequenceLogo_actionPerformed (); +} else if (source === this.showConsensusHistogram) { +this.showConsensusHistogram_actionPerformed (); +} else if (source === this.applyAutoAnnotationSettings) { +this.applyAutoAnnotationSettings_actionPerformed (); +} else if (source === this.featureSettings) { + new jalview.appletgui.FeatureSettings (this.alignPanel); +} else if (source === this.alProperties) { +var contents = new jalview.io.AlignmentProperties (this.viewport.getAlignment ()).formatAsString (); +var cap = new jalview.appletgui.CutAndPasteTransfer (false, this); +cap.setText (contents.toString ()); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.alignment_properties", Clazz.newArray (-1, [this.getTitle ()])), 400, 250); +} else if (source === this.overviewMenuItem) { +this.overviewMenuItem_actionPerformed (); +} else if (source === this.noColourmenuItem) { +this.changeColour (null); +} else if (source === this.clustalColour) { +this.abovePIDThreshold.setState (false); +this.changeColour ( new jalview.schemes.ClustalxColourScheme (this.viewport.getAlignment (), null)); +} else if (source === this.zappoColour) { +this.changeColour ( new jalview.schemes.ZappoColourScheme ()); +} else if (source === this.taylorColour) { +this.changeColour ( new jalview.schemes.TaylorColourScheme ()); +} else if (source === this.hydrophobicityColour) { +this.changeColour ( new jalview.schemes.HydrophobicColourScheme ()); +} else if (source === this.helixColour) { +this.changeColour ( new jalview.schemes.HelixColourScheme ()); +} else if (source === this.strandColour) { +this.changeColour ( new jalview.schemes.StrandColourScheme ()); +} else if (source === this.turnColour) { +this.changeColour ( new jalview.schemes.TurnColourScheme ()); +} else if (source === this.buriedColour) { +this.changeColour ( new jalview.schemes.BuriedColourScheme ()); +} else if (source === this.nucleotideColour) { +this.changeColour ( new jalview.schemes.NucleotideColourScheme ()); +} else if (source === this.purinePyrimidineColour) { +this.changeColour ( new jalview.schemes.PurinePyrimidineColourScheme ()); +} else if (source === this.RNAInteractionColour) { +this.changeColour ( new jalview.schemes.RNAInteractionColourScheme ()); +} else if (source === this.RNAHelixColour) { + new jalview.schemes.RNAHelicesColourChooser (this.viewport, this.alignPanel); +} else if (source === this.modifyPID) { +this.modifyPID_actionPerformed (); +} else if (source === this.modifyConservation) { +this.modifyConservation_actionPerformed (); +} else if (source === this.userDefinedColour) { + new jalview.appletgui.UserDefinedColours (this.alignPanel, null); +} else if (source === this.PIDColour) { +this.changeColour ( new jalview.schemes.PIDColourScheme ()); +} else if (source === this.BLOSUM62Colour) { +this.changeColour ( new jalview.schemes.Blosum62ColourScheme ()); +} else if (source === this.tcoffeeColour) { +this.changeColour ( new jalview.schemes.TCoffeeColourScheme (this.alignPanel.getAlignment ())); +} else if (source === this.annotationColour) { + new jalview.appletgui.AnnotationColourChooser (this.viewport, this.alignPanel); +} else if (source === this.annotationColumnSelection) { + new jalview.appletgui.AnnotationColumnChooser (this.viewport, this.alignPanel); +} else if (source === this.sortPairwiseMenuItem) { +this.sortPairwiseMenuItem_actionPerformed (); +} else if (source === this.sortIDMenuItem) { +this.sortIDMenuItem_actionPerformed (); +} else if (source === this.sortLengthMenuItem) { +this.sortLengthMenuItem_actionPerformed (); +} else if (source === this.sortGroupMenuItem) { +this.sortGroupMenuItem_actionPerformed (); +} else if (source === this.removeRedundancyMenuItem) { +this.removeRedundancyMenuItem_actionPerformed (); +} else if (source === this.pairwiseAlignmentMenuItem) { +this.pairwiseAlignmentMenuItem_actionPerformed (); +} else if (source === this.PCAMenuItem) { +this.PCAMenuItem_actionPerformed (); +} else if (source === this.averageDistanceTreeMenuItem) { +this.averageDistanceTreeMenuItem_actionPerformed (); +} else if (source === this.neighbourTreeMenuItem) { +this.neighbourTreeMenuItem_actionPerformed (); +} else if (source === this.njTreeBlosumMenuItem) { +this.njTreeBlosumMenuItem_actionPerformed (); +} else if (source === this.avDistanceTreeBlosumMenuItem) { +this.avTreeBlosumMenuItem_actionPerformed (); +} else if (source === this.documentation) { +this.documentation_actionPerformed (); +} else if (source === this.about) { +this.about_actionPerformed (); +}}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "inputText_actionPerformed", +function () { +var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.input_cut_paste"), 500, 500); +}); +Clazz.defineMethod (c$, "outputText_actionPerformed", +function (e) { +var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.alignment_output_command", Clazz.newArray (-1, [e.getActionCommand ()])), 600, 500); +var fr = this.alignPanel.cloneFeatureRenderer (); +cap.setText ( new jalview.io.AppletFormatAdapter (this.alignPanel).formatSequences (e.getActionCommand (), this.viewport.getAlignment (), this.viewport.getShowJVSuffix ())); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "loadAnnotations", +function () { +var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); +cap.setText (jalview.util.MessageManager.getString ("label.paste_features_annotations_Tcoffee_here")); +cap.setAnnotationImport (); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("action.paste_annotations"), 400, 300); +}); +Clazz.defineMethod (c$, "outputAnnotations", +function (displayTextbox) { +var annotation = new jalview.io.AnnotationFile ().printAnnotationsForView (this.viewport); +if (displayTextbox) { +var cap = new jalview.appletgui.CutAndPasteTransfer (false, this); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.annotations"), 600, 500); +cap.setText (annotation); +}return annotation; +}, "~B"); +Clazz.defineMethod (c$, "getDisplayedFeatureCols", +($fz = function () { +if (this.alignPanel.getFeatureRenderer () != null && this.viewport.getFeaturesDisplayed () != null) { +return this.alignPanel.getFeatureRenderer ().getDisplayedFeatureCols (); +}return null; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "outputFeatures", +function (displayTextbox, format) { +var features; +if (format.equalsIgnoreCase ("Jalview")) { +features = new jalview.io.FeaturesFile ().printJalviewFormat (this.viewport.getAlignment ().getSequencesArray (), this.getDisplayedFeatureCols ()); +} else { +features = new jalview.io.FeaturesFile ().printGFFFormat (this.viewport.getAlignment ().getSequencesArray (), this.getDisplayedFeatureCols ()); +}if (displayTextbox) { +var frimport = false; +if (features == null || features.equals ("No Features Visible")) { +features = "# No features visible - paste some and import them here."; +frimport = true; +}var cap = new jalview.appletgui.CutAndPasteTransfer (frimport, this); +if (frimport) { +cap.setAnnotationImport (); +}var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.features"), 600, 500); +cap.setText (features); +} else { +if (features == null) { +features = ""; +}}return features; +}, "~B,~S"); +Clazz.defineMethod (c$, "launchFullApplication", +function () { +var url = new StringBuffer (this.jalviewServletURL); +var firstSep = url.lastIndexOf ("?") > url.lastIndexOf ("/") ? "&" : "?"; +url.append (firstSep); +var applet = this.viewport.applet; +var s = applet.startupFile; +url.append ("open=" + this.appendProtocol (s)); +if (this.viewport.applet.features != null) { +url.append ("&features="); +url.append (this.appendProtocol (applet.features)); +}if (applet.annotations != null) { +url.append ("&annotations="); +url.append (this.appendProtocol (applet.annotations)); +}if (applet.jnetFile != null) { +url.append ("&annotations="); +url.append (this.appendProtocol (applet.jnetFile)); +}if (applet.defaultColour != null) { +url.append ("&colour=" + this.removeWhiteSpace (applet.defaultColour)); +}if (applet.userDefinedColour != null) { +url.append ("&colour=" + this.removeWhiteSpace (applet.userDefinedColour)); +}if (applet.treeFile != null) { +url.append ("&tree=" + this.appendProtocol (applet.treeFile)); +}this.showURL (url.toString (), "FULL_APP"); +}); +Clazz.defineMethod (c$, "removeWhiteSpace", +function (colour) { +var sb = new StringBuffer (); +for (var i = 0; i < colour.length; i++) { +if (Character.isWhitespace (colour.charAt (i))) { +sb.append ("%20"); +} else { +sb.append (colour.charAt (i)); +}} +return sb.toString (); +}, "~S"); +Clazz.defineMethod (c$, "appendProtocol", +function (url) { +try { + new java.net.URL (url); +url = java.net.URLEncoder.encode (url); +} catch (ex) { +if (Clazz.exceptionOf (ex, java.net.MalformedURLException)) { +url = this.viewport.applet.getCodeBase () + url; +} else { +throw ex; +} +} +return url; +}, "~S"); +Clazz.defineMethod (c$, "closeMenuItem_actionPerformed", +function () { +jalview.appletgui.PaintRefresher.RemoveComponent (this.alignPanel); +if (this.alignPanel.seqPanel != null && this.alignPanel.seqPanel.seqCanvas != null) { +jalview.appletgui.PaintRefresher.RemoveComponent (this.alignPanel.seqPanel.seqCanvas); +}if (this.alignPanel.idPanel != null && this.alignPanel.idPanel.idCanvas != null) { +jalview.appletgui.PaintRefresher.RemoveComponent (this.alignPanel.idPanel.idCanvas); +}if (jalview.appletgui.PaintRefresher.components.size () == 0 && this.viewport.applet == null) { +System.exit (0); +} else { +}this.viewport = null; +this.alignPanel = null; +this.dispose (); +}); +Clazz.defineMethod (c$, "updateEditMenuBar", +function () { +if (this.viewport.getHistoryList ().size () > 0) { +this.undoMenuItem.setEnabled (true); +var command = this.viewport.getHistoryList ().peek (); +this.undoMenuItem.setLabel (jalview.util.MessageManager.formatMessage ("label.undo_command", Clazz.newArray (-1, [command.getDescription ()]))); +} else { +this.undoMenuItem.setEnabled (false); +this.undoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.undo")); +}if (this.viewport.getRedoList ().size () > 0) { +this.redoMenuItem.setEnabled (true); +var command = this.viewport.getRedoList ().peek (); +this.redoMenuItem.setLabel (jalview.util.MessageManager.formatMessage ("label.redo_command", Clazz.newArray (-1, [command.getDescription ()]))); +} else { +this.redoMenuItem.setEnabled (false); +this.redoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.redo")); +}}); +Clazz.overrideMethod (c$, "addHistoryItem", +function (command) { +if (command.getSize () > 0) { +this.viewport.addToHistoryList (command); +this.viewport.clearRedoList (); +this.updateEditMenuBar (); +this.viewport.updateHiddenColumns (); +}}, "jalview.commands.CommandI"); +Clazz.defineMethod (c$, "undoMenuItem_actionPerformed", +function () { +if (this.viewport.getHistoryList ().isEmpty ()) { +return; +}var command = this.viewport.getHistoryList ().pop (); +this.viewport.addToRedoList (command); +command.undoCommand (null); +var originalSource = this.getOriginatingSource (command); +if (originalSource !== this.viewport) { +System.err.println ("Warning: Viewport object mismatch whilst undoing"); +}originalSource.updateHiddenColumns (); +this.updateEditMenuBar (); +originalSource.firePropertyChange ("alignment", null, originalSource.getAlignment ().getSequences ()); +}); +Clazz.defineMethod (c$, "redoMenuItem_actionPerformed", +function () { +if (this.viewport.getRedoList ().isEmpty ()) { +return; +}var command = this.viewport.getRedoList ().pop (); +this.viewport.addToHistoryList (command); +command.doCommand (null); +var originalSource = this.getOriginatingSource (command); +if (originalSource !== this.viewport) { +System.err.println ("Warning: Viewport object mismatch whilst re-doing"); +}originalSource.updateHiddenColumns (); +this.updateEditMenuBar (); +originalSource.firePropertyChange ("alignment", null, originalSource.getAlignment ().getSequences ()); +}); +Clazz.defineMethod (c$, "getOriginatingSource", +function (command) { +var originalSource = null; +var al = null; +if (Clazz.instanceOf (command, jalview.commands.EditCommand)) { +var editCommand = command; +al = editCommand.getAlignment (); +var comps = jalview.appletgui.PaintRefresher.components.get (this.viewport.getSequenceSetId ()); +for (var i = 0; i < comps.size (); i++) { +if (Clazz.instanceOf (comps.elementAt (i), jalview.appletgui.AlignmentPanel)) { +if (al === (comps.elementAt (i)).av.getAlignment ()) { +originalSource = (comps.elementAt (i)).av; +break; +}}} +}if (originalSource == null) { +if (al != null) { +jalview.appletgui.PaintRefresher.validateSequences (al, this.viewport.getAlignment ()); +}originalSource = this.viewport; +}return originalSource; +}, "jalview.commands.CommandI"); +Clazz.defineMethod (c$, "moveSelectedSequences", +function (up) { +var sg = this.viewport.getSelectionGroup (); +if (sg == null) { +return; +}this.viewport.getAlignment ().moveSelectedSequencesByOne (sg, up ? null : this.viewport.getHiddenRepSequences (), up); +this.alignPanel.paintAlignment (true); +var complement = this.viewport.getCodingComplement (); +if (complement != null) { +var mappedSelection = jalview.util.MappingUtils.mapSequenceGroup (sg, this.viewport, complement); +complement.getAlignment ().moveSelectedSequencesByOne (mappedSelection, up ? null : complement.getHiddenRepSequences (), up); +}}, "~B"); +Clazz.defineMethod (c$, "slideSequences", +function (right, size) { +var sg = new java.util.Vector (); +if (this.viewport.cursorMode) { +sg.add (this.viewport.getAlignment ().getSequenceAt (this.alignPanel.seqPanel.seqCanvas.cursorY)); +} else if (this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () != this.viewport.getAlignment ().getHeight ()) { +sg = this.viewport.getSelectionGroup ().getSequences (this.viewport.getHiddenRepSequences ()); +}if (sg.size () < 1) { +return; +}var invertGroup = new java.util.Vector (); +for (var i = 0; i < this.viewport.getAlignment ().getHeight (); i++) { +if (!sg.contains (this.viewport.getAlignment ().getSequenceAt (i))) { +invertGroup.addElement (this.viewport.getAlignment ().getSequenceAt (i)); +}} +var seqs1 = sg.toArray ( new Array (sg.size ())); +var seqs2 = invertGroup.toArray ( new Array (invertGroup.size ())); +for (var i = 0; i < invertGroup.size (); i++) { +seqs2[i] = invertGroup.elementAt (i); +} +var ssc; +if (right) { +ssc = new jalview.commands.SlideSequencesCommand ("Slide Sequences", seqs2, seqs1, size, this.viewport.getGapCharacter ()); +} else { +ssc = new jalview.commands.SlideSequencesCommand ("Slide Sequences", seqs1, seqs2, size, this.viewport.getGapCharacter ()); +}var groupAdjustment = 0; +if (ssc.getGapsInsertedBegin () && right) { +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.moveCursor (size, 0); +} else { +groupAdjustment = size; +}} else if (!ssc.getGapsInsertedBegin () && !right) { +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.moveCursor (-size, 0); +} else { +groupAdjustment = -size; +}}if (groupAdjustment != 0) { +this.viewport.getSelectionGroup ().setStartRes (this.viewport.getSelectionGroup ().getStartRes () + groupAdjustment); +this.viewport.getSelectionGroup ().setEndRes (this.viewport.getSelectionGroup ().getEndRes () + groupAdjustment); +}var appendHistoryItem = false; +var historyList = this.viewport.getHistoryList (); +if (historyList != null && historyList.size () > 0 && Clazz.instanceOf (historyList.peek (), jalview.commands.SlideSequencesCommand)) { +appendHistoryItem = ssc.appendSlideCommand (historyList.peek ()); +}if (!appendHistoryItem) { +this.addHistoryItem (ssc); +}this.repaint (); +}, "~B,~N"); +Clazz.defineMethod (c$, "copy_actionPerformed", +function () { +if (this.viewport.getSelectionGroup () == null) { +return; +}var sg = this.viewport.getSelectionGroup (); +jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer (); +var orderedSeqs = new java.util.HashMap (); +for (var i = 0; i < sg.getSize (); i++) { +var seq = sg.getSequenceAt (i); +var index = this.viewport.getAlignment ().findIndex (seq); +orderedSeqs.put (new Integer (index), seq); +} +var index = 0; +var startRes; +var endRes; +var ch; +if (this.viewport.hasHiddenColumns () && this.viewport.getSelectionGroup () != null) { +jalview.appletgui.AlignFrame.copiedHiddenColumns = new java.util.Vector (); +var hiddenOffset = this.viewport.getSelectionGroup ().getStartRes (); +for (var region, $region = this.viewport.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { +jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement ( Clazz.newIntArray (-1, [region[0] - hiddenOffset, region[1] - hiddenOffset])); +} +} else { +jalview.appletgui.AlignFrame.copiedHiddenColumns = null; +}for (var i = 0; i < sg.getSize (); i++) { +var seq = null; +while (seq == null) { +if (orderedSeqs.containsKey (new Integer (index))) { +seq = orderedSeqs.get (new Integer (index)); +index++; +break; +} else { +index++; +}} +startRes = seq.findPosition (sg.getStartRes ()); +endRes = 0; +for (var j = 0; j < sg.getEndRes () + 1 && j < seq.getLength (); j++) { +ch = seq.getCharAt (j); +if (!jalview.util.Comparison.isGap ((ch))) { +endRes++; +}} +if (endRes > 0) { +endRes += seq.getStart () - 1; +}jalview.appletgui.AlignFrame.copiedSequences.append (seq.getName () + "\t" + startRes + "\t" + endRes + "\t" + seq.getSequenceAsString (sg.getStartRes (), sg.getEndRes () + 1) + "\n"); +} +}); +Clazz.defineMethod (c$, "pasteNew_actionPerformed", +function () { +this.paste (true); +}); +Clazz.defineMethod (c$, "pasteThis_actionPerformed", +function () { +this.paste (false); +}); +Clazz.defineMethod (c$, "paste", +function (newAlignment) { +try { +if (jalview.appletgui.AlignFrame.copiedSequences == null) { +return; +}var st = new java.util.StringTokenizer (jalview.appletgui.AlignFrame.copiedSequences.toString ()); +var seqs = new java.util.Vector (); +while (st.hasMoreElements ()) { +var name = st.nextToken (); +var start = Integer.parseInt (st.nextToken ()); +var end = Integer.parseInt (st.nextToken ()); +seqs.addElement ( new jalview.datamodel.Sequence (name, st.nextToken (), start, end)); +} +var newSeqs = new Array (seqs.size ()); +for (var i = 0; i < seqs.size (); i++) { +newSeqs[i] = seqs.elementAt (i); +} +if (newAlignment) { +var newtitle = jalview.util.MessageManager.getString ("label.copied_sequences"); +if (this.getTitle ().startsWith (jalview.util.MessageManager.getString ("label.copied_sequences"))) { +newtitle = this.getTitle (); +} else { +newtitle = newtitle.concat (jalview.util.MessageManager.formatMessage ("label.from_msname", Clazz.newArray (-1, [this.getTitle ()]))); +}var af = new jalview.appletgui.AlignFrame ( new jalview.datamodel.Alignment (newSeqs), this.viewport.applet, newtitle, false); +if (jalview.appletgui.AlignFrame.copiedHiddenColumns != null) { +for (var i = 0; i < jalview.appletgui.AlignFrame.copiedHiddenColumns.size (); i++) { +var region = jalview.appletgui.AlignFrame.copiedHiddenColumns.elementAt (i); +af.viewport.hideColumns (region[0], region[1]); +} +}jalview.bin.JalviewLite.addFrame (af, newtitle, this.frameWidth, this.frameHeight); +} else { +this.addSequences (newSeqs); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +}, "~B"); +Clazz.defineMethod (c$, "addSequences", +function (seqs) { +for (var i = 0; i < seqs.length; i++) { +this.viewport.getAlignment ().addSequence (seqs[i]); +} +this.addHistoryItem ( new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.add_sequences"), jalview.commands.EditCommand.Action.PASTE, seqs, 0, this.viewport.getAlignment ().getWidth (), this.viewport.getAlignment ())); +this.viewport.setEndSeq (this.viewport.getAlignment ().getHeight ()); +this.viewport.getAlignment ().getWidth (); +this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); +}, "~A"); +Clazz.defineMethod (c$, "cut_actionPerformed", +function () { +this.copy_actionPerformed (); +this.delete_actionPerformed (); +}); +Clazz.defineMethod (c$, "delete_actionPerformed", +function () { +var sg = this.viewport.getSelectionGroup (); +if (sg == null) { +return; +}var seqs = new java.util.Vector (); +var seq; +for (var i = 0; i < sg.getSize (); i++) { +seq = sg.getSequenceAt (i); +seqs.addElement (seq); +} +if (sg.getSize () == this.viewport.getAlignment ().getHeight ()) { +this.viewport.getColumnSelection ().removeElements (sg.getStartRes (), sg.getEndRes () + 1); +}var cut = new Array (seqs.size ()); +for (var i = 0; i < seqs.size (); i++) { +cut[i] = seqs.elementAt (i); +} +this.addHistoryItem ( new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("label.cut_sequences"), jalview.commands.EditCommand.Action.CUT, cut, sg.getStartRes (), sg.getEndRes () - sg.getStartRes () + 1, this.viewport.getAlignment ())); +this.viewport.setSelectionGroup (null); +this.viewport.getAlignment ().deleteGroup (sg); +this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); +if (this.viewport.getAlignment ().getHeight () < 1) { +this.setVisible (false); +}this.viewport.sendSelection (); +}); +Clazz.defineMethod (c$, "showGroupConsensus_actionPerformed", +function () { +this.viewport.setShowGroupConsensus (this.showGroupConsensus.getState ()); +this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); +}); +Clazz.defineMethod (c$, "showGroupConservation_actionPerformed", +function () { +this.viewport.setShowGroupConservation (this.showGroupConservation.getState ()); +this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); +}); +Clazz.defineMethod (c$, "showConsensusHistogram_actionPerformed", +function () { +this.viewport.setShowConsensusHistogram (this.showConsensusHistogram.getState ()); +this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); +}); +Clazz.defineMethod (c$, "showSequenceLogo_actionPerformed", +function () { +this.viewport.setShowSequenceLogo (this.showSequenceLogo.getState ()); +this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); +}); +Clazz.defineMethod (c$, "normSequenceLogo_actionPerformed", +function () { +this.showSequenceLogo.setState (true); +this.viewport.setShowSequenceLogo (true); +this.viewport.setNormaliseSequenceLogo (this.normSequenceLogo.getState ()); +this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); +}); +Clazz.defineMethod (c$, "applyAutoAnnotationSettings_actionPerformed", +function () { +this.alignPanel.updateAnnotation (this.applyAutoAnnotationSettings.getState ()); +}); +Clazz.defineMethod (c$, "makeGrpsFromSelection_actionPerformed", +function () { +if (this.avc.makeGroupsFromSelection ()) { +jalview.appletgui.PaintRefresher.Refresh (this, this.viewport.getSequenceSetId ()); +this.alignPanel.updateAnnotation (); +this.alignPanel.paintAlignment (true); +}}); +Clazz.defineMethod (c$, "createGroup_actionPerformed", +function () { +this.avc.createGroup (); +}); +Clazz.defineMethod (c$, "unGroup_actionPerformed", +function () { +if (this.avc.unGroup ()) { +this.alignPanel.alignmentChanged (); +}}); +Clazz.defineMethod (c$, "deleteGroups_actionPerformed", +function () { +if (this.avc.deleteGroups ()) { +this.alignPanel.alignmentChanged (); +}}); +Clazz.defineMethod (c$, "selectAllSequenceMenuItem_actionPerformed", +function () { +var sg = new jalview.datamodel.SequenceGroup (); +for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { +sg.addSequence (this.viewport.getAlignment ().getSequenceAt (i), false); +} +sg.setEndRes (this.viewport.getAlignment ().getWidth () - 1); +this.viewport.setSelectionGroup (sg); +this.alignPanel.paintAlignment (true); +jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); +this.viewport.sendSelection (); +}); +Clazz.defineMethod (c$, "deselectAllSequenceMenuItem_actionPerformed", +function () { +if (this.viewport.cursorMode) { +this.alignPanel.seqPanel.keyboardNo1 = null; +this.alignPanel.seqPanel.keyboardNo2 = null; +}this.viewport.setSelectionGroup (null); +this.viewport.getColumnSelection ().clear (); +this.viewport.setSelectionGroup (null); +this.alignPanel.idPanel.idCanvas.searchResults = null; +this.alignPanel.seqPanel.seqCanvas.highlightSearchResults (null); +this.alignPanel.paintAlignment (true); +jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); +this.viewport.sendSelection (); +}); +Clazz.defineMethod (c$, "invertSequenceMenuItem_actionPerformed", +function () { +var sg = this.viewport.getSelectionGroup (); +for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { +sg.addOrRemove (this.viewport.getAlignment ().getSequenceAt (i), false); +} +jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); +this.viewport.sendSelection (); +}); +Clazz.defineMethod (c$, "invertColSel_actionPerformed", +function () { +this.viewport.invertColumnSelection (); +this.alignPanel.paintAlignment (true); +jalview.appletgui.PaintRefresher.Refresh (this.alignPanel, this.viewport.getSequenceSetId ()); +this.viewport.sendSelection (); +}); +Clazz.defineMethod (c$, "trimAlignment", +function (trimLeft) { +var colSel = this.viewport.getColumnSelection (); +var column; +if (colSel.size () > 0) { +if (trimLeft) { +column = colSel.getMin (); +} else { +column = colSel.getMax (); +}var seqs; +if (this.viewport.getSelectionGroup () != null) { +seqs = this.viewport.getSelectionGroup ().getSequencesAsArray (this.viewport.getHiddenRepSequences ()); +} else { +seqs = this.viewport.getAlignment ().getSequencesArray (); +}var trimRegion; +if (trimLeft) { +trimRegion = new jalview.commands.TrimRegionCommand ("Remove Left", jalview.commands.TrimRegionCommand.TRIM_LEFT, seqs, column, this.viewport.getAlignment (), this.viewport.getColumnSelection (), this.viewport.getSelectionGroup ()); +this.viewport.setStartRes (0); +} else { +trimRegion = new jalview.commands.TrimRegionCommand ("Remove Right", jalview.commands.TrimRegionCommand.TRIM_RIGHT, seqs, column, this.viewport.getAlignment (), this.viewport.getColumnSelection (), this.viewport.getSelectionGroup ()); +}this.setStatus (jalview.util.MessageManager.formatMessage ("label.removed_columns", Clazz.newArray (-1, [Integer.$valueOf (trimRegion.getSize ()).toString ()]))); +this.addHistoryItem (trimRegion); +for (var sg, $sg = this.viewport.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if ((trimLeft && !sg.adjustForRemoveLeft (column)) || (!trimLeft && !sg.adjustForRemoveRight (column))) { +this.viewport.getAlignment ().deleteGroup (sg); +}} +this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); +}}, "~B"); +Clazz.defineMethod (c$, "removeGappedColumnMenuItem_actionPerformed", +function () { +var start = 0; +var end = this.viewport.getAlignment ().getWidth () - 1; +var seqs; +if (this.viewport.getSelectionGroup () != null) { +seqs = this.viewport.getSelectionGroup ().getSequencesAsArray (this.viewport.getHiddenRepSequences ()); +start = this.viewport.getSelectionGroup ().getStartRes (); +end = this.viewport.getSelectionGroup ().getEndRes (); +} else { +seqs = this.viewport.getAlignment ().getSequencesArray (); +}var removeGapCols = new jalview.commands.RemoveGapColCommand ("Remove Gapped Columns", seqs, start, end, this.viewport.getAlignment ()); +this.addHistoryItem (removeGapCols); +this.setStatus (jalview.util.MessageManager.formatMessage ("label.removed_empty_columns", Clazz.newArray (-1, [Integer.$valueOf (removeGapCols.getSize ()).toString ()]))); +var seq = this.viewport.getAlignment ().getSequenceAt (0); +var startRes = seq.findPosition (this.viewport.startRes); +this.viewport.setStartRes (seq.findIndex (startRes) - 1); +this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); +}); +Clazz.defineMethod (c$, "removeAllGapsMenuItem_actionPerformed", +function () { +var start = 0; +var end = this.viewport.getAlignment ().getWidth () - 1; +var seqs; +if (this.viewport.getSelectionGroup () != null) { +seqs = this.viewport.getSelectionGroup ().getSequencesAsArray (this.viewport.getHiddenRepSequences ()); +start = this.viewport.getSelectionGroup ().getStartRes (); +end = this.viewport.getSelectionGroup ().getEndRes (); +} else { +seqs = this.viewport.getAlignment ().getSequencesArray (); +}var seq = this.viewport.getAlignment ().getSequenceAt (0); +var startRes = seq.findPosition (this.viewport.startRes); +this.addHistoryItem ( new jalview.commands.RemoveGapsCommand ("Remove Gaps", seqs, start, end, this.viewport.getAlignment ())); +this.viewport.setStartRes (seq.findIndex (startRes) - 1); +this.viewport.firePropertyChange ("alignment", null, this.viewport.getAlignment ().getSequences ()); +}); +Clazz.defineMethod (c$, "findMenuItem_actionPerformed", +function () { + new jalview.appletgui.Finder (this.alignPanel); +}); +Clazz.defineMethod (c$, "newView", +function (viewtitle) { +var newal; +if (this.viewport.hasHiddenRows ()) { +newal = new jalview.datamodel.Alignment (this.viewport.getAlignment ().getHiddenSequences ().getFullAlignment ().getSequencesArray ()); +} else { +newal = new jalview.datamodel.Alignment (this.viewport.getAlignment ().getSequencesArray ()); +}if (this.viewport.getAlignment ().getAlignmentAnnotation () != null) { +for (var i = 0; i < this.viewport.getAlignment ().getAlignmentAnnotation ().length; i++) { +if (!this.viewport.getAlignment ().getAlignmentAnnotation ()[i].autoCalculated) { +newal.addAnnotation (this.viewport.getAlignment ().getAlignmentAnnotation ()[i]); +}} +}var newaf = new jalview.appletgui.AlignFrame (newal, this.viewport.applet, "", false); +newaf.viewport.setSequenceSetId (this.alignPanel.av.getSequenceSetId ()); +jalview.appletgui.PaintRefresher.Register (this.alignPanel, this.alignPanel.av.getSequenceSetId ()); +jalview.appletgui.PaintRefresher.Register (newaf.alignPanel, newaf.alignPanel.av.getSequenceSetId ()); +jalview.appletgui.PaintRefresher.Register (newaf.alignPanel.idPanel.idCanvas, newaf.alignPanel.av.getSequenceSetId ()); +jalview.appletgui.PaintRefresher.Register (newaf.alignPanel.seqPanel.seqCanvas, newaf.alignPanel.av.getSequenceSetId ()); +var comps = jalview.appletgui.PaintRefresher.components.get (this.viewport.getSequenceSetId ()); +var viewSize = -1; +for (var i = 0; i < comps.size (); i++) { +if (Clazz.instanceOf (comps.elementAt (i), jalview.appletgui.AlignmentPanel)) { +viewSize++; +}} +var title = String.instantialize (this.getTitle ()); +if (viewtitle != null) { +title = viewtitle + " ( " + title + ")"; +} else { +if (title.indexOf ("(View") > -1) { +title = title.substring (0, title.indexOf ("(View")); +}title += "(View " + viewSize + ")"; +}newaf.setTitle (title.toString ()); +newaf.viewport.setHistoryList (this.viewport.getHistoryList ()); +newaf.viewport.setRedoList (this.viewport.getRedoList ()); +return newaf; +}, "~S"); +Clazz.defineMethod (c$, "getFeatureGroups", +function () { +var fr = null; +if (this.alignPanel != null && (fr = this.alignPanel.getFeatureRenderer ()) != null) { +var gps = fr.getFeatureGroups (); +var _gps = gps.toArray ( new Array (gps.size ())); +return _gps; +}return null; +}); +Clazz.defineMethod (c$, "getFeatureGroupsOfState", +function (visible) { +var fr = null; +if (this.alignPanel != null && (fr = this.alignPanel.getFeatureRenderer ()) != null) { +var gps = fr.getGroups (visible); +var _gps = gps.toArray ( new Array (gps.size ())); +return _gps; +}return null; +}, "~B"); +Clazz.defineMethod (c$, "setFeatureGroupState", +function (groups, state) { +var fr = null; +this.sequenceFeatures.setState (true); +this.viewport.setShowSequenceFeatures (true); +if (this.alignPanel != null && (fr = this.alignPanel.getFeatureRenderer ()) != null) { +fr.setGroupVisibility (java.util.Arrays.asList (groups), state); +this.alignPanel.seqPanel.seqCanvas.repaint (); +if (this.alignPanel.overviewPanel != null) { +this.alignPanel.overviewPanel.updateOverviewImage (); +}}}, "~A,~B"); +Clazz.defineMethod (c$, "seqLimits_itemStateChanged", +function () { +this.viewport.setShowJVSuffix (this.seqLimits.getState ()); +this.alignPanel.fontChanged (); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "colourTextMenuItem_actionPerformed", +function () { +this.viewport.setColourText (this.colourTextMenuItem.getState ()); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "displayNonconservedMenuItem_actionPerformed", +function () { +this.viewport.setShowUnconserved (this.displayNonconservedMenuItem.getState ()); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "wrapMenuItem_actionPerformed", +function () { +this.viewport.setWrapAlignment (this.wrapMenuItem.getState ()); +this.alignPanel.setWrapAlignment (this.wrapMenuItem.getState ()); +this.scaleAbove.setEnabled (this.wrapMenuItem.getState ()); +this.scaleLeft.setEnabled (this.wrapMenuItem.getState ()); +this.scaleRight.setEnabled (this.wrapMenuItem.getState ()); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "overviewMenuItem_actionPerformed", +function () { +if (this.alignPanel.overviewPanel != null) { +return; +}var frame = new awt2swing.Frame (); +var overview = new jalview.appletgui.OverviewPanel (this.alignPanel); +frame.add (overview); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.formatMessage ("label.overview_params", Clazz.newArray (-1, [this.getTitle ()])), overview.getPreferredSize ().width, overview.getPreferredSize ().height + 50); +frame.pack (); +var ap = this.alignPanel; +frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$1") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$1, this, Clazz.cloneFinals ("ap", ap)))); +this.alignPanel.setOverviewPanel (overview); +}); +Clazz.overrideMethod (c$, "changeColour", +function (cs) { +var threshold = 0; +if (cs != null) { +if (this.viewport.getAbovePIDThreshold ()) { +this.viewport.setThreshold (jalview.appletgui.SliderPanel.setPIDSliderSource (this.alignPanel, cs, "Background")); +}if (this.viewport.getConservationSelected ()) { +cs.setConservationApplied (true); +this.viewport.setIncrement (jalview.appletgui.SliderPanel.setConservationSlider (this.alignPanel, cs, "Background")); +} else { +cs.setConservationApplied (false); +}}this.viewport.setGlobalColourScheme (cs); +if (this.alignPanel.getOverviewPanel () != null) { +this.alignPanel.getOverviewPanel ().updateOverviewImage (); +}jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.viewport.applet).sequenceColoursChanged (this.alignPanel); +this.alignPanel.paintAlignment (true); +}, "jalview.schemes.ColourSchemeI"); +Clazz.defineMethod (c$, "modifyPID_actionPerformed", +function () { +if (this.viewport.getAbovePIDThreshold () && this.viewport.getGlobalColourScheme () != null) { +jalview.appletgui.SliderPanel.setPIDSliderSource (this.alignPanel, this.viewport.getGlobalColourScheme (), "Background"); +jalview.appletgui.SliderPanel.showPIDSlider (); +}}); +Clazz.defineMethod (c$, "modifyConservation_actionPerformed", +function () { +if (this.viewport.getConservationSelected () && this.viewport.getGlobalColourScheme () != null) { +jalview.appletgui.SliderPanel.setConservationSlider (this.alignPanel, this.viewport.getGlobalColourScheme (), "Background"); +jalview.appletgui.SliderPanel.showConservationSlider (); +}}); +Clazz.defineMethod (c$, "conservationMenuItem_actionPerformed", +function () { +this.viewport.setConservationSelected (this.conservationMenuItem.getState ()); +this.viewport.setAbovePIDThreshold (false); +this.abovePIDThreshold.setState (false); +this.changeColour (this.viewport.getGlobalColourScheme ()); +this.modifyConservation_actionPerformed (); +}); +Clazz.defineMethod (c$, "abovePIDThreshold_actionPerformed", +function () { +this.viewport.setAbovePIDThreshold (this.abovePIDThreshold.getState ()); +this.conservationMenuItem.setState (false); +this.viewport.setConservationSelected (false); +this.changeColour (this.viewport.getGlobalColourScheme ()); +this.modifyPID_actionPerformed (); +}); +Clazz.defineMethod (c$, "sortPairwiseMenuItem_actionPerformed", +function () { +var oldOrder = this.viewport.getAlignment ().getSequencesArray (); +jalview.analysis.AlignmentSorter.sortByPID (this.viewport.getAlignment (), this.viewport.getAlignment ().getSequenceAt (0), null); +this.addHistoryItem ( new jalview.commands.OrderCommand ("Pairwise Sort", oldOrder, this.viewport.getAlignment ())); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "sortIDMenuItem_actionPerformed", +function () { +var oldOrder = this.viewport.getAlignment ().getSequencesArray (); +jalview.analysis.AlignmentSorter.sortByID (this.viewport.getAlignment ()); +this.addHistoryItem ( new jalview.commands.OrderCommand ("ID Sort", oldOrder, this.viewport.getAlignment ())); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "sortLengthMenuItem_actionPerformed", +function () { +var oldOrder = this.viewport.getAlignment ().getSequencesArray (); +jalview.analysis.AlignmentSorter.sortByLength (this.viewport.getAlignment ()); +this.addHistoryItem ( new jalview.commands.OrderCommand ("Length Sort", oldOrder, this.viewport.getAlignment ())); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "sortGroupMenuItem_actionPerformed", +function () { +var oldOrder = this.viewport.getAlignment ().getSequencesArray (); +jalview.analysis.AlignmentSorter.sortByGroup (this.viewport.getAlignment ()); +this.addHistoryItem ( new jalview.commands.OrderCommand ("Group Sort", oldOrder, this.viewport.getAlignment ())); +this.alignPanel.paintAlignment (true); +}); +Clazz.defineMethod (c$, "removeRedundancyMenuItem_actionPerformed", +function () { + new jalview.appletgui.RedundancyPanel (this.alignPanel); +}); +Clazz.defineMethod (c$, "pairwiseAlignmentMenuItem_actionPerformed", +function () { +if (this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () > 1) { +var frame = new awt2swing.Frame (); +frame.add ( new jalview.appletgui.PairwiseAlignPanel (this.alignPanel)); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("action.pairwise_alignment"), 600, 500); +}}); +Clazz.defineMethod (c$, "PCAMenuItem_actionPerformed", +function () { +if (!this.viewport.getAlignment ().isAligned (false)) { +var current; +var Width = this.viewport.getAlignment ().getWidth (); +for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { +current = this.viewport.getAlignment ().getSequenceAt (i); +if (current.getLength () < Width) { +current.insertCharAt (Width - 1, this.viewport.getGapCharacter ()); +}} +this.alignPanel.paintAlignment (true); +}if ((this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () < 4 && this.viewport.getSelectionGroup ().getSize () > 0) || this.viewport.getAlignment ().getHeight () < 4) { +return; +}try { + new jalview.appletgui.PCAPanel (this.viewport); +} catch (ex) { +if (Clazz.exceptionOf (ex, OutOfMemoryError)) { +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "averageDistanceTreeMenuItem_actionPerformed", +function () { +this.NewTreePanel ("AV", "PID", "Average distance tree using PID"); +}); +Clazz.defineMethod (c$, "neighbourTreeMenuItem_actionPerformed", +function () { +this.NewTreePanel ("NJ", "PID", "Neighbour joining tree using PID"); +}); +Clazz.defineMethod (c$, "njTreeBlosumMenuItem_actionPerformed", +function () { +this.NewTreePanel ("NJ", "BL", "Neighbour joining tree using BLOSUM62"); +}); +Clazz.defineMethod (c$, "avTreeBlosumMenuItem_actionPerformed", +function () { +this.NewTreePanel ("AV", "BL", "Average distance tree using BLOSUM62"); +}); +Clazz.defineMethod (c$, "NewTreePanel", +function (type, pwType, title) { +if (!this.viewport.getAlignment ().isAligned (false)) { +var current; +var Width = this.viewport.getAlignment ().getWidth (); +for (var i = 0; i < this.viewport.getAlignment ().getSequences ().size (); i++) { +current = this.viewport.getAlignment ().getSequenceAt (i); +if (current.getLength () < Width) { +current.insertCharAt (Width - 1, this.viewport.getGapCharacter ()); +}} +this.alignPanel.paintAlignment (true); +}if ((this.viewport.getSelectionGroup () != null && this.viewport.getSelectionGroup ().getSize () > 1) || (this.viewport.getAlignment ().getHeight () > 1)) { +var tp = new jalview.appletgui.TreePanel (this.alignPanel, type, pwType); +this.addTreeMenuItem (tp, title); +jalview.bin.JalviewLite.addFrame (tp, title, 600, 500); +}}, "~S,~S,~S"); +Clazz.defineMethod (c$, "loadTree_actionPerformed", +function () { +var cap = new jalview.appletgui.CutAndPasteTransfer (true, this); +cap.setText (jalview.util.MessageManager.getString ("label.paste_newick_tree_file")); +cap.setTreeImport (); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.paste_newick_file"), 400, 300); +}); +Clazz.defineMethod (c$, "loadTree", +function (tree, treeFile) { +var tp = new jalview.appletgui.TreePanel (this.alignPanel, treeFile, jalview.util.MessageManager.getString ("label.load_tree_from_file"), tree); +jalview.bin.JalviewLite.addFrame (tp, treeFile, 600, 500); +this.addTreeMenuItem (tp, treeFile); +}, "jalview.io.NewickFile,~S"); +Clazz.defineMethod (c$, "sortByTree", +function (treePanel, title) { +var oldOrder = this.viewport.getAlignment ().getSequencesArray (); +jalview.analysis.AlignmentSorter.sortByTree (this.viewport.getAlignment (), treePanel.getTree ()); +this.addHistoryItem ( new jalview.commands.OrderCommand (jalview.util.MessageManager.formatMessage ("label.order_by_params", Clazz.newArray (-1, [title])), oldOrder, this.viewport.getAlignment ())); +this.alignPanel.paintAlignment (true); +}, "jalview.appletgui.TreePanel,~S"); +Clazz.defineMethod (c$, "addTreeMenuItem", +function (treePanel, title) { +var item = new awt2swing.MenuItem (title); +this.sortByTreeMenu.add (item); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$2") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$2, this, Clazz.cloneFinals ("treePanel", treePanel, "title", title)))); +treePanel.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$3") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$3, this, Clazz.cloneFinals ("treePanel", treePanel, "title", title, "item", item)))); +}, "jalview.appletgui.TreePanel,~S"); +Clazz.defineMethod (c$, "sortBy", +function (alorder, undoname) { +var oldOrder = this.viewport.getAlignment ().getSequencesArray (); +if ((this.viewport.applet, jalview.bin.JalviewLite).debug) { +System.err.println ("Sorting " + alorder.getOrder ().size () + " in alignment '" + this.getTitle () + "'"); +}jalview.analysis.AlignmentSorter.sortBy (this.viewport.getAlignment (), alorder); +if (undoname != null) { +this.addHistoryItem ( new jalview.commands.OrderCommand (undoname, oldOrder, this.viewport.getAlignment ())); +}this.alignPanel.paintAlignment (true); +return true; +}, "jalview.datamodel.AlignmentOrder,~S"); +Clazz.defineMethod (c$, "documentation_actionPerformed", +function () { +this.alignPanel.av.applet.openJalviewHelpUrl (); +}); +Clazz.defineMethod (c$, "about_actionPerformed", +function () { +if (!Clazz.isClassDefined ("jalview.appletgui.AlignFrame$1AboutPanel")) { +jalview.appletgui.AlignFrame.$AlignFrame$1AboutPanel$ (); +} +var frame = new awt2swing.Frame (); +frame.add (Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$1AboutPanel, this, null, jalview.bin.JalviewLite.getVersion (), jalview.bin.JalviewLite.getBuildDate ())); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.jalview"), 580, 220); +}); +Clazz.defineMethod (c$, "showURL", +function (url, target) { +if (this.viewport.applet == null) { +System.out.println ("Not running as applet - no browser available."); +} else { +this.viewport.applet.showURL (url, target); +}}, "~S,~S"); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setMenuBar (this.alignFrameMenuBar); +this.inputText.setLabel (jalview.util.MessageManager.getString ("label.input_from_textbox")); +this.inputText.addActionListener (this); +var outputTextboxMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.out_to_textbox")); +for (var i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { +var item = new awt2swing.MenuItem (jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$4") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$4$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$4, this, null))); +outputTextboxMenu.add (item); +} +this.closeMenuItem.addActionListener (this); +this.loadApplication.addActionListener (this); +this.$loadTree.addActionListener (this); +this.$loadAnnotations.addActionListener (this); +this.$outputFeatures.addActionListener (this); +this.$outputAnnotations.addActionListener (this); +this.undoMenuItem.setEnabled (false); +this.undoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.undo")); +this.undoMenuItem.addActionListener (this); +this.redoMenuItem.setEnabled (false); +this.redoMenuItem.setLabel (jalview.util.MessageManager.getString ("action.redo")); +this.redoMenuItem.addActionListener (this); +this.copy.setLabel (jalview.util.MessageManager.getString ("action.copy")); +this.copy.addActionListener (this); +this.cut.setLabel (jalview.util.MessageManager.getString ("action.cut")); +this.cut.addActionListener (this); +this.$delete.setLabel (jalview.util.MessageManager.getString ("action.delete")); +this.$delete.addActionListener (this); +this.pasteMenu.setLabel (jalview.util.MessageManager.getString ("action.paste")); +this.pasteNew.setLabel (jalview.util.MessageManager.getString ("label.to_new_alignment")); +this.pasteNew.addActionListener (this); +this.pasteThis.setLabel (jalview.util.MessageManager.getString ("label.to_this_alignment")); +this.pasteThis.addActionListener (this); +this.remove2LeftMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_left")); +this.remove2LeftMenuItem.addActionListener (this); +this.remove2RightMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_right")); +this.remove2RightMenuItem.addActionListener (this); +this.removeGappedColumnMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_empty_columns")); +this.removeGappedColumnMenuItem.addActionListener (this); +this.removeAllGapsMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_all_gaps")); +this.removeAllGapsMenuItem.addActionListener (this); +this.removeRedundancyMenuItem.setLabel (jalview.util.MessageManager.getString ("action.remove_redundancy").concat ("...")); +this.removeRedundancyMenuItem.addActionListener (this); +this.findMenuItem.setLabel (jalview.util.MessageManager.getString ("action.find")); +this.findMenuItem.addActionListener (this); +this.selectAllSequenceMenuItem.addActionListener (this); +this.deselectAllSequenceMenuItem.addActionListener (this); +this.invertSequenceMenuItem.setLabel (jalview.util.MessageManager.getString ("action.invert_sequence_selection")); +this.invertSequenceMenuItem.addActionListener (this); +this.invertColSel.setLabel (jalview.util.MessageManager.getString ("action.invert_column_selection")); +this.invertColSel.addActionListener (this); +this.deleteGroups.setLabel (jalview.util.MessageManager.getString ("action.undefine_groups")); +this.deleteGroups.addActionListener (this); +this.grpsFromSelection.setLabel (jalview.util.MessageManager.getString ("action.make_groups_selection")); +this.grpsFromSelection.addActionListener (this); +this.createGroup.setLabel (jalview.util.MessageManager.getString ("action.create_group")); +this.unGroup.setLabel (jalview.util.MessageManager.getString ("action.remove_group")); +this.annotationColumnSelection.setLabel ("Select by Annotation"); +this.annotationColumnSelection.addActionListener (this); +this.$newView.setLabel (jalview.util.MessageManager.getString ("action.new_view")); +this.$newView.addActionListener (this); +var showMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.show")); +this.showColumns.setLabel (jalview.util.MessageManager.getString ("label.all_columns")); +this.showSeqs.setLabel (jalview.util.MessageManager.getString ("label.all_sequences")); +var hideMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.hide")); +this.hideColumns.setLabel (jalview.util.MessageManager.getString ("label.selected_columns")); +this.hideSequences.setLabel (jalview.util.MessageManager.getString ("label.selected_sequences")); +this.hideAllButSelection.setLabel (jalview.util.MessageManager.getString ("label.all_but_selected_region")); +this.hideAllSelection.setLabel (jalview.util.MessageManager.getString ("label.selected_region")); +this.showAllHidden.setLabel (jalview.util.MessageManager.getString ("label.all_sequences_columns")); +this.showColumns.addActionListener (this); +this.showSeqs.addActionListener (this); +this.hideColumns.addActionListener (this); +this.hideSequences.addActionListener (this); +this.hideAllButSelection.addActionListener (this); +this.hideAllSelection.addActionListener (this); +this.showAllHidden.addActionListener (this); +this.featureSettings.setLabel (jalview.util.MessageManager.getString ("label.feature_settings")); +this.featureSettings.addActionListener (this); +this.sequenceFeatures.setLabel (jalview.util.MessageManager.getString ("label.show_sequence_features")); +this.sequenceFeatures.addItemListener (this); +this.sequenceFeatures.setState (false); +this.followMouseOverFlag.setLabel (jalview.util.MessageManager.getString ("label.automatic_scrolling")); +this.followMouseOverFlag.addItemListener (this); +this.alProperties.addActionListener (this); +this.overviewMenuItem.setLabel (jalview.util.MessageManager.getString ("label.overview_window")); +this.overviewMenuItem.addActionListener (this); +this.annotationPanelMenuItem.setLabel (jalview.util.MessageManager.getString ("label.show_annotations")); +this.annotationPanelMenuItem.addItemListener (this); +this.showGroupConsensus.setLabel (jalview.util.MessageManager.getString ("label.group_consensus")); +this.showGroupConservation.setLabel (jalview.util.MessageManager.getString ("label.group_conservation")); +this.showConsensusHistogram.setLabel (jalview.util.MessageManager.getString ("label.show_consensus_histogram")); +this.showSequenceLogo.setLabel (jalview.util.MessageManager.getString ("label.show_consensus_logo")); +this.normSequenceLogo.setLabel (jalview.util.MessageManager.getString ("label.norm_consensus_logo")); +this.applyAutoAnnotationSettings.setLabel (jalview.util.MessageManager.getString ("label.apply_all_groups")); +this.applyAutoAnnotationSettings.setState (true); +var autoAnnMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("label.autocalculated_annotation")); +this.showGroupConsensus.addItemListener (this); +this.showGroupConservation.addItemListener (this); +this.showConsensusHistogram.addItemListener (this); +this.showSequenceLogo.addItemListener (this); +this.normSequenceLogo.addItemListener (this); +this.applyAutoAnnotationSettings.addItemListener (this); +this.showAlignmentAnnotations = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_all_al_annotations")); +this.showSequenceAnnotations = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_all_seq_annotations")); +this.sortAnnBySequence = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.sort_annotations_by_sequence")); +this.sortAnnByLabel = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.sort_annotations_by_label")); +this.showAutoFirst = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_first")); +this.showAutoLast = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_last")); +this.showAlignmentAnnotations.addItemListener (this); +this.showSequenceAnnotations.addItemListener (this); +this.sortAnnBySequence.addItemListener (this); +this.sortAnnByLabel.addItemListener (this); +this.showAutoFirst.addItemListener (this); +this.showAutoLast.addItemListener (this); +this.$font.setLabel (jalview.util.MessageManager.getString ("action.font")); +this.$font.addActionListener (this); +this.scaleAbove.setLabel (jalview.util.MessageManager.getString ("action.scale_above")); +this.scaleAbove.setState (true); +this.scaleAbove.setEnabled (false); +this.scaleAbove.addItemListener (this); +this.scaleLeft.setEnabled (false); +this.scaleLeft.setState (true); +this.scaleLeft.setLabel (jalview.util.MessageManager.getString ("action.scale_left")); +this.scaleLeft.addItemListener (this); +this.scaleRight.setEnabled (false); +this.scaleRight.setState (true); +this.scaleRight.setLabel (jalview.util.MessageManager.getString ("action.scale_right")); +this.scaleRight.addItemListener (this); +this.viewBoxesMenuItem.setLabel (jalview.util.MessageManager.getString ("action.boxes")); +this.viewBoxesMenuItem.setState (true); +this.viewBoxesMenuItem.addItemListener (this); +this.viewTextMenuItem.setLabel (jalview.util.MessageManager.getString ("action.text")); +this.viewTextMenuItem.setState (true); +this.viewTextMenuItem.addItemListener (this); +this.colourTextMenuItem.setLabel (jalview.util.MessageManager.getString ("label.colour_text")); +this.colourTextMenuItem.addItemListener (this); +this.displayNonconservedMenuItem.setLabel (jalview.util.MessageManager.getString ("label.show_non_conversed")); +this.displayNonconservedMenuItem.addItemListener (this); +this.wrapMenuItem.setLabel (jalview.util.MessageManager.getString ("action.wrap")); +this.wrapMenuItem.addItemListener (this); +this.renderGapsMenuItem.setLabel (jalview.util.MessageManager.getString ("action.show_gaps")); +this.renderGapsMenuItem.setState (true); +this.renderGapsMenuItem.addItemListener (this); +this.centreColumnLabelFlag.setLabel (jalview.util.MessageManager.getString ("label.centre_column_labels")); +this.centreColumnLabelFlag.addItemListener (this); +this.seqLimits.setState (true); +this.seqLimits.setLabel (jalview.util.MessageManager.getString ("label.show_sequence_limits")); +this.seqLimits.addItemListener (this); +this.applyToAllGroups.setLabel (jalview.util.MessageManager.getString ("label.apply_colour_to_all_groups")); +this.applyToAllGroups.setState (true); +this.applyToAllGroups.addItemListener (this); +this.clustalColour.setLabel (jalview.util.MessageManager.getString ("label.clustalx")); +this.clustalColour.addActionListener (this); +this.zappoColour.setLabel (jalview.util.MessageManager.getString ("label.zappo")); +this.zappoColour.addActionListener (this); +this.taylorColour.setLabel (jalview.util.MessageManager.getString ("label.taylor")); +this.taylorColour.addActionListener (this); +this.hydrophobicityColour.setLabel (jalview.util.MessageManager.getString ("label.hydrophobicity")); +this.hydrophobicityColour.addActionListener (this); +this.helixColour.setLabel (jalview.util.MessageManager.getString ("label.helix_propensity")); +this.helixColour.addActionListener (this); +this.strandColour.setLabel (jalview.util.MessageManager.getString ("label.strand_propensity")); +this.strandColour.addActionListener (this); +this.turnColour.setLabel (jalview.util.MessageManager.getString ("label.turn_propensity")); +this.turnColour.addActionListener (this); +this.buriedColour.setLabel (jalview.util.MessageManager.getString ("label.buried_index")); +this.buriedColour.addActionListener (this); +this.purinePyrimidineColour.setLabel (jalview.util.MessageManager.getString ("label.purine_pyrimidine")); +this.purinePyrimidineColour.addActionListener (this); +this.RNAInteractionColour.setLabel (jalview.util.MessageManager.getString ("label.rna_interaction")); +this.RNAInteractionColour.addActionListener (this); +this.RNAHelixColour.setLabel (jalview.util.MessageManager.getString ("action.by_rna_helixes")); +this.RNAHelixColour.addActionListener (this); +this.userDefinedColour.setLabel (jalview.util.MessageManager.getString ("action.user_defined")); +this.userDefinedColour.addActionListener (this); +this.PIDColour.setLabel (jalview.util.MessageManager.getString ("label.percentage_identity")); +this.PIDColour.addActionListener (this); +this.BLOSUM62Colour.setLabel (jalview.util.MessageManager.getString ("label.blosum62_score")); +this.BLOSUM62Colour.addActionListener (this); +this.tcoffeeColour.setLabel (jalview.util.MessageManager.getString ("label.tcoffee_scores")); +this.tcoffeeColour.setEnabled (false); +this.tcoffeeColour.addActionListener (this); +this.conservationMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_conservation")); +this.conservationMenuItem.addItemListener (this); +this.noColourmenuItem.setLabel (jalview.util.MessageManager.getString ("label.none")); +this.noColourmenuItem.addActionListener (this); +this.abovePIDThreshold.setLabel (jalview.util.MessageManager.getString ("label.above_identity_threshold")); +this.abovePIDThreshold.addItemListener (this); +this.nucleotideColour.setLabel (jalview.util.MessageManager.getString ("label.nucleotide")); +this.nucleotideColour.addActionListener (this); +this.modifyPID.setLabel (jalview.util.MessageManager.getString ("label.modify_identity_thereshold")); +this.modifyPID.addActionListener (this); +this.modifyConservation.setLabel (jalview.util.MessageManager.getString ("label.modify_conservation_thereshold")); +this.modifyConservation.addActionListener (this); +this.annotationColour.setLabel (jalview.util.MessageManager.getString ("action.by_annotation")); +this.annotationColour.addActionListener (this); +this.sortPairwiseMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_pairwise_id")); +this.sortPairwiseMenuItem.addActionListener (this); +this.sortIDMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_id")); +this.sortIDMenuItem.addActionListener (this); +this.sortLengthMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_length")); +this.sortLengthMenuItem.addActionListener (this); +this.sortGroupMenuItem.setLabel (jalview.util.MessageManager.getString ("action.by_group")); +this.sortGroupMenuItem.addActionListener (this); +this.pairwiseAlignmentMenuItem.setLabel (jalview.util.MessageManager.getString ("action.pairwise_alignment")); +this.pairwiseAlignmentMenuItem.addActionListener (this); +this.PCAMenuItem.setLabel (jalview.util.MessageManager.getString ("label.principal_component_analysis")); +this.PCAMenuItem.addActionListener (this); +this.autoCalculate = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.autocalculate_consensus"), true); +this.averageDistanceTreeMenuItem.setLabel (jalview.util.MessageManager.getString ("label.average_distance_identity")); +this.averageDistanceTreeMenuItem.addActionListener (this); +this.neighbourTreeMenuItem.setLabel (jalview.util.MessageManager.getString ("label.neighbour_joining_identity")); +this.neighbourTreeMenuItem.addActionListener (this); +this.avDistanceTreeBlosumMenuItem.setLabel (jalview.util.MessageManager.getString ("label.average_distance_bloslum62")); +this.avDistanceTreeBlosumMenuItem.addActionListener (this); +this.njTreeBlosumMenuItem.setLabel (jalview.util.MessageManager.getString ("label.neighbour_blosum62")); +this.njTreeBlosumMenuItem.addActionListener (this); +this.sortByTreeMenu.setLabel (jalview.util.MessageManager.getString ("action.by_tree_order")); +var sortMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.sort")); +var calculateTreeMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.calculate_tree")); +this.autoCalculate.addItemListener (this); +this.$sortByTree.addItemListener (this); +var helpMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.help")); +this.documentation.setLabel (jalview.util.MessageManager.getString ("label.documentation")); +this.documentation.addActionListener (this); +this.about.setLabel (jalview.util.MessageManager.getString ("label.about")); +this.about.addActionListener (this); +this.alignFrameMenuBar.add (this.fileMenu); +var editMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.edit")); +this.alignFrameMenuBar.add (editMenu); +var selectMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.select")); +this.alignFrameMenuBar.add (selectMenu); +var viewMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.view")); +this.alignFrameMenuBar.add (viewMenu); +var annotationsMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.annotations")); +this.alignFrameMenuBar.add (annotationsMenu); +var formatMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.format")); +this.alignFrameMenuBar.add (formatMenu); +var colourMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.colour")); +this.alignFrameMenuBar.add (colourMenu); +var calculateMenu = new awt2swing.Menu (jalview.util.MessageManager.getString ("action.calculate")); +this.alignFrameMenuBar.add (calculateMenu); +this.alignFrameMenuBar.add (helpMenu); +this.fileMenu.add (this.inputText); +this.fileMenu.add (this.$loadTree); +this.fileMenu.add (this.$loadAnnotations); +this.fileMenu.addSeparator (); +this.fileMenu.add (outputTextboxMenu); +this.fileMenu.add (this.$outputFeatures); +this.fileMenu.add (this.$outputAnnotations); +if (this.jalviewServletURL != null) { +this.fileMenu.add (this.loadApplication); +}this.fileMenu.addSeparator (); +this.fileMenu.add (this.closeMenuItem); +editMenu.add (this.undoMenuItem); +editMenu.add (this.redoMenuItem); +editMenu.add (this.cut); +editMenu.add (this.copy); +this.pasteMenu.add (this.pasteNew); +this.pasteMenu.add (this.pasteThis); +editMenu.add (this.pasteMenu); +editMenu.add (this.$delete); +editMenu.addSeparator (); +editMenu.add (this.remove2LeftMenuItem); +editMenu.add (this.remove2RightMenuItem); +editMenu.add (this.removeGappedColumnMenuItem); +editMenu.add (this.removeAllGapsMenuItem); +editMenu.add (this.removeRedundancyMenuItem); +selectMenu.add (this.findMenuItem); +selectMenu.addSeparator (); +selectMenu.add (this.selectAllSequenceMenuItem); +selectMenu.add (this.deselectAllSequenceMenuItem); +selectMenu.add (this.invertSequenceMenuItem); +selectMenu.add (this.invertColSel); +selectMenu.add (this.createGroup); +selectMenu.add (this.unGroup); +selectMenu.add (this.grpsFromSelection); +selectMenu.add (this.deleteGroups); +selectMenu.add (this.annotationColumnSelection); +viewMenu.add (this.$newView); +viewMenu.addSeparator (); +showMenu.add (this.showColumns); +showMenu.add (this.showSeqs); +showMenu.add (this.showAllHidden); +viewMenu.add (showMenu); +hideMenu.add (this.hideColumns); +hideMenu.add (this.hideSequences); +hideMenu.add (this.hideAllSelection); +hideMenu.add (this.hideAllButSelection); +viewMenu.add (hideMenu); +viewMenu.addSeparator (); +viewMenu.add (this.followMouseOverFlag); +viewMenu.addSeparator (); +viewMenu.add (this.sequenceFeatures); +viewMenu.add (this.featureSettings); +viewMenu.addSeparator (); +viewMenu.add (this.alProperties); +viewMenu.addSeparator (); +viewMenu.add (this.overviewMenuItem); +annotationsMenu.add (this.annotationPanelMenuItem); +annotationsMenu.addSeparator (); +annotationsMenu.add (this.showAlignmentAnnotations); +annotationsMenu.add (this.showSequenceAnnotations); +annotationsMenu.add (this.sortAnnBySequence); +annotationsMenu.add (this.sortAnnByLabel); +annotationsMenu.addSeparator (); +autoAnnMenu.add (this.showAutoFirst); +autoAnnMenu.add (this.showAutoLast); +autoAnnMenu.addSeparator (); +autoAnnMenu.add (this.applyAutoAnnotationSettings); +autoAnnMenu.add (this.showConsensusHistogram); +autoAnnMenu.add (this.showSequenceLogo); +autoAnnMenu.add (this.normSequenceLogo); +autoAnnMenu.addSeparator (); +autoAnnMenu.add (this.showGroupConservation); +autoAnnMenu.add (this.showGroupConsensus); +annotationsMenu.add (autoAnnMenu); +formatMenu.add (this.$font); +formatMenu.add (this.seqLimits); +formatMenu.add (this.wrapMenuItem); +formatMenu.add (this.scaleAbove); +formatMenu.add (this.scaleLeft); +formatMenu.add (this.scaleRight); +formatMenu.add (this.viewBoxesMenuItem); +formatMenu.add (this.viewTextMenuItem); +formatMenu.add (this.colourTextMenuItem); +formatMenu.add (this.displayNonconservedMenuItem); +formatMenu.add (this.renderGapsMenuItem); +formatMenu.add (this.centreColumnLabelFlag); +colourMenu.add (this.applyToAllGroups); +colourMenu.addSeparator (); +colourMenu.add (this.noColourmenuItem); +colourMenu.add (this.clustalColour); +colourMenu.add (this.BLOSUM62Colour); +colourMenu.add (this.PIDColour); +colourMenu.add (this.zappoColour); +colourMenu.add (this.taylorColour); +colourMenu.add (this.hydrophobicityColour); +colourMenu.add (this.helixColour); +colourMenu.add (this.strandColour); +colourMenu.add (this.turnColour); +colourMenu.add (this.buriedColour); +colourMenu.add (this.nucleotideColour); +colourMenu.add (this.purinePyrimidineColour); +colourMenu.add (this.tcoffeeColour); +colourMenu.add (this.userDefinedColour); +colourMenu.addSeparator (); +colourMenu.add (this.conservationMenuItem); +colourMenu.add (this.modifyConservation); +colourMenu.add (this.abovePIDThreshold); +colourMenu.add (this.modifyPID); +colourMenu.add (this.annotationColour); +colourMenu.add (this.RNAHelixColour); +sortMenu.add (this.sortIDMenuItem); +sortMenu.add (this.sortLengthMenuItem); +sortMenu.add (this.sortByTreeMenu); +sortMenu.add (this.sortGroupMenuItem); +sortMenu.add (this.sortPairwiseMenuItem); +calculateMenu.add (sortMenu); +calculateTreeMenu.add (this.averageDistanceTreeMenuItem); +calculateTreeMenu.add (this.neighbourTreeMenuItem); +calculateTreeMenu.add (this.avDistanceTreeBlosumMenuItem); +calculateTreeMenu.add (this.njTreeBlosumMenuItem); +calculateMenu.add (calculateTreeMenu); +calculateMenu.addSeparator (); +calculateMenu.add (this.pairwiseAlignmentMenuItem); +calculateMenu.add (this.PCAMenuItem); +calculateMenu.add (this.autoCalculate); +calculateMenu.add (this.$sortByTree); +helpMenu.add (this.documentation); +helpMenu.add (this.about); +this.statusBar.setBackground (java.awt.Color.white); +this.statusBar.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.setStatus (jalview.util.MessageManager.getString ("label.status_bar")); +this.add (this.statusBar, "South"); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "setStatus", +function (string) { +this.statusBar.setText (string); +}, "~S"); +Clazz.defineMethod (c$, "createAlignFrameWindow", +function (reallyEmbedded) { +if (reallyEmbedded) { +this.embedAlignFrameInApplet (this.viewport.applet); +} else { +if (this.embedMenuIfNeeded (this.alignPanel)) { +this.alignPanel.setSize (this.getSize ().width, this.getSize ().height - this.statusBar.getHeight ()); +}this.add (this.statusBar, "South"); +this.add (this.alignPanel, "Center"); +jalview.bin.JalviewLite.addFrame (this, this.getTitle (), this.frameWidth, this.frameHeight); +}}, "~B"); +Clazz.defineMethod (c$, "embedAlignFrameInApplet", +function (theApplet) { +this.fileMenu.remove (this.closeMenuItem); +this.fileMenu.remove (3); +this.embeddedMenu = this.makeEmbeddedPopupMenu (this.alignFrameMenuBar, false, false); +theApplet.setLayout ( new java.awt.BorderLayout ()); +theApplet.add (this.embeddedMenu, "North"); +theApplet.add (this.statusBar, "South"); +this.alignPanel.setSize (theApplet.getSize ().width, theApplet.getSize ().height - this.embeddedMenu.getHeight () - this.statusBar.getHeight ()); +theApplet.add (this.alignPanel, "Center"); +var me = this; +theApplet.addFocusListener (((Clazz.isClassDefined ("jalview.appletgui.AlignFrame$5") ? 0 : jalview.appletgui.AlignFrame.$AlignFrame$5$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignFrame$5, this, Clazz.cloneFinals ("theApplet", theApplet, "me", me)))); +theApplet.validate (); +}, "jalview.bin.JalviewLite"); +Clazz.defineMethod (c$, "addStructureViewInstance", +function (jmolviewer, sequenceIds) { +return null; +}, "~O,~A"); +Clazz.defineMethod (c$, "addPdbFile", +function (sequenceId, pdbEntryString, pdbFile) { +var toaddpdb = this.viewport.getAlignment ().findName (sequenceId); +var needtoadd = false; +if (toaddpdb != null) { +var pdbe = toaddpdb.getPDBId (); +var pdbentry = null; +if (pdbe != null && pdbe.size () > 0) { +for (var pe = 0, peSize = pdbe.size (); pe < peSize; pe++) { +pdbentry = pdbe.elementAt (pe); +if (!pdbentry.getId ().equals (pdbEntryString) && !pdbentry.getFile ().equals (pdbFile)) { +pdbentry = null; +} else { +continue; +}} +}if (pdbentry == null) { +pdbentry = new jalview.datamodel.PDBEntry (); +pdbentry.setId (pdbEntryString); +pdbentry.setFile (pdbFile); +needtoadd = true; +}var protocol = jalview.io.AppletFormatAdapter.resolveProtocol (pdbFile, "PDB"); +if (protocol == null) { +return false; +}if (needtoadd) { +if (pdbentry.getProperty () == null) { +pdbentry.setProperty ( new java.util.Hashtable ()); +}pdbentry.getProperty ().put ("protocol", protocol); +toaddpdb.addPDBId (pdbentry); +this.alignPanel.getStructureSelectionManager ().registerPDBEntry (pdbentry); +}}return true; +}, "~S,~S,~S"); +Clazz.defineMethod (c$, "cleanSeqChainArrays", +($fz = function (seqs, chains) { +if (seqs != null) { +var sequences = new java.util.Vector (); +for (var i = 0; i < seqs.length; i++) { +if (seqs[i] != null) { +sequences.addElement ( Clazz.newArray (-1, [seqs[i], (chains != null) ? chains[i] : null])); +}} +seqs = new Array (sequences.size ()); +chains = new Array (sequences.size ()); +for (var i = 0, isize = sequences.size (); i < isize; i++) { +var oj = sequences.elementAt (i); +seqs[i] = oj[0]; +chains[i] = oj[1]; +} +}return Clazz.newArray (-1, [seqs, chains]); +}, $fz.isPrivate = true, $fz), "~A,~A"); +Clazz.defineMethod (c$, "newStructureView", +function (applet, pdb, seqs, chains, protocol) { +var sqch = this.cleanSeqChainArrays (seqs, chains); +seqs = sqch[0]; +chains = sqch[1]; +if (seqs == null || seqs.length == 0) { +System.err.println ("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); +}if (protocol == null || protocol.trim ().length == 0 || protocol.equals ("null")) { +protocol = pdb.getProperty ().get ("protocol"); +if (protocol == null) { +System.err.println ("Couldn't work out protocol to open structure: " + pdb.getId ()); +return; +}}if (applet.useXtrnalSviewer) { +if (jalview.structure.StructureSelectionManager.getStructureSelectionManager (applet).setMapping (seqs, chains, pdb.getFile (), protocol) == null) { +System.err.println ("Failed to map " + pdb.getFile () + " (" + protocol + ") to any sequences"); +}return; +}if (applet.isAlignPdbStructures () && applet.jmolAvailable) { +var ajm = null; +var tajm; +var jmols = applet.getAppletWindow (jalview.appletgui.AppletJmol); +for (var i = 0, iSize = jmols.size (); i < iSize; i++) { +tajm = jmols.elementAt (i); +if (tajm.ap.alignFrame === this) { +ajm = tajm; +break; +}} +if (ajm != null) { +System.err.println ("Incremental adding and aligning structure to existing Jmol view not yet implemented."); +ajm = null; +}} new jalview.appletgui.AppletJmol (pdb, seqs, chains, this.alignPanel, protocol); +jalview.bin.JalviewLite.lastFrameX += 40; +jalview.bin.JalviewLite.lastFrameY += 40; +}, "jalview.bin.JalviewLite,jalview.datamodel.PDBEntry,~A,~A,~S"); +Clazz.defineMethod (c$, "alignedStructureView", +function (applet, pdb, seqs, chains, protocols) { +System.err.println ("Aligned Structure View: Not yet implemented."); +}, "jalview.bin.JalviewLite,~A,~A,~A,~A"); +Clazz.defineMethod (c$, "select", +function (sel, csel) { +this.alignPanel.seqPanel.selection (sel, csel, null); +}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection"); +Clazz.defineMethod (c$, "scrollTo", +function (row, column) { +this.alignPanel.seqPanel.scrollTo (row, column); +}, "~N,~N"); +Clazz.defineMethod (c$, "scrollToRow", +function (row) { +this.alignPanel.seqPanel.scrollToRow (row); +}, "~N"); +Clazz.defineMethod (c$, "scrollToColumn", +function (column) { +this.alignPanel.seqPanel.scrollToColumn (column); +}, "~N"); +Clazz.defineMethod (c$, "getSequenceSetId", +function () { +return this.viewport.getSequenceSetId (); +}); +Clazz.defineMethod (c$, "loadScoreFile", +function (inFile) { +var file = jalview.jsdev.GenericFileAdapter.getFile ("TCoffeeScoreFile", [inFile, jalview.io.AppletFormatAdapter.checkProtocol (inFile)]); +if (!file.isValid ()) { +System.err.println ("Problems parsing T-Coffee scores: " + file.getWarningMessage ()); +System.err.println ("Origin was:\n" + inFile); +return false; +}var aln; +if ((aln = this.viewport.getAlignment ()) != null && (aln.getHeight () != file.getHeight () || aln.getWidth () != file.getWidth ())) { +System.err.println ("The scores matrix does not match the alignment dimensions"); +}if (file.annotateAlignment (this.alignPanel.getAlignment (), false)) { +this.alignPanel.fontChanged (); +this.tcoffeeColour.setEnabled (true); +this.changeColour ( new jalview.schemes.TCoffeeColourScheme (this.alignPanel.getAlignment ())); +return true; +} else { +System.err.println ("Problems resolving T-Coffee scores:"); +if (file.getWarningMessage () != null) { +System.err.println (file.getWarningMessage ()); +}}return false; +}, "~S"); +Clazz.defineMethod (c$, "getSplitFrame", +function () { +return this.splitFrame; +}); +Clazz.defineMethod (c$, "setSplitFrame", +function (sf) { +this.splitFrame = sf; +}, "jalview.appletgui.SplitFrame"); +Clazz.overrideMethod (c$, "setShowSeqFeatures", +function (b) { +this.viewport.setShowSequenceFeatures (b); +}, "~B"); +Clazz.overrideMethod (c$, "setMenusForViewport", +function () { +}); +Clazz.overrideMethod (c$, "refreshFeatureUI", +function (enableIfNecessary) { +if (enableIfNecessary) { +this.sequenceFeatures.setState (true); +this.alignPanel.av.setShowSequenceFeatures (true); +}}, "~B"); +Clazz.overrideMethod (c$, "getFeatureSettingsUI", +function () { +return this.alignPanel.av.featureSettings; +}); +c$.$AlignFrame$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$1", java.awt.event.WindowAdapter); +Clazz.overrideMethod (c$, "windowClosing", +function (e) { +if (this.f$.ap != null) { +this.f$.ap.setOverviewPanel (null); +}}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +c$.$AlignFrame$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$2", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +this.b$["jalview.appletgui.AlignFrame"].sortByTree (this.f$.treePanel, this.f$.title); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$AlignFrame$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$3", java.awt.event.WindowAdapter); +Clazz.defineMethod (c$, "windowOpened", +function (e) { +if (this.b$["jalview.appletgui.AlignFrame"].viewport.sortByTree) { +this.b$["jalview.appletgui.AlignFrame"].sortByTree (this.f$.treePanel, this.f$.title); +}Clazz.superCall (this, jalview.appletgui.AlignFrame$3, "windowOpened", [e]); +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowClosing", +function (e) { +this.b$["jalview.appletgui.AlignFrame"].sortByTreeMenu.remove (this.f$.item); +}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +c$.$AlignFrame$1AboutPanel$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.version = null; +this.builddate = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AlignFrame$1AboutPanel", awt2swing.Canvas); +Clazz.makeConstructor (c$, +function (a, b) { +Clazz.superConstructor (this, jalview.appletgui.AlignFrame$1AboutPanel, []); +this.version = a; +this.builddate = b; +}, "~S,~S"); +Clazz.overrideMethod (c$, "paintComponent", +function (a) { +a.setColor (java.awt.Color.white); +a.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +a.setFont ( new java.awt.Font ("Helvetica", 0, 12)); +var b = a.getFontMetrics (); +var c = b.getHeight (); +var d = 5; +var e = 7; +a.setColor (java.awt.Color.black); +a.setFont ( new java.awt.Font ("Helvetica", 1, 14)); +a.drawString (jalview.util.MessageManager.formatMessage ("label.jalviewLite_release", Clazz.newArray (-1, [this.version])), e, d += c); +a.setFont ( new java.awt.Font ("Helvetica", 1, 12)); +a.drawString (jalview.util.MessageManager.formatMessage ("label.jaview_build_date", Clazz.newArray (-1, [this.builddate])), e, d += c); +a.setFont ( new java.awt.Font ("Helvetica", 0, 12)); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_authors_1"), e, d += c * 1.5); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_authors_2"), e + 50, d += c + 8); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_dev_managers"), e, d += c); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_distribution_lists"), e, d += c); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_please_cite"), e, d += c + 8); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_cite_1_authors"), e, d += c); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_cite_1_title"), e, d += c); +a.drawString (jalview.util.MessageManager.getString ("label.jalview_cite_1_ref"), e, d += c); +}, "java.awt.Graphics"); +c$ = Clazz.p0p (); +}; +c$.$AlignFrame$4$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$4", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.AlignFrame"].outputText_actionPerformed (e); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$AlignFrame$5$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignFrame$5", null, java.awt.event.FocusListener); +Clazz.overrideMethod (c$, "focusLost", +function (e) { +if (this.f$.theApplet.currentAlignFrame === this.f$.me) { +this.f$.theApplet.currentAlignFrame = null; +}}, "java.awt.event.FocusEvent"); +Clazz.overrideMethod (c$, "focusGained", +function (e) { +this.f$.theApplet.currentAlignFrame = this.f$.me; +}, "java.awt.event.FocusEvent"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"copiedSequences", null, +"copiedHiddenColumns", null); +}); diff --git a/bin/jalview/appletgui/AlignViewport.js b/bin/jalview/appletgui/AlignViewport.js index 1d890fc..8ea8971 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"); +}); diff --git a/bin/jalview/appletgui/AlignmentPanel.js b/bin/jalview/appletgui/AlignmentPanel.js index 1d6069d..8989731 100644 --- a/bin/jalview/appletgui/AlignmentPanel.js +++ b/bin/jalview/appletgui/AlignmentPanel.js @@ -1,610 +1,610 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.api.AlignmentViewPanel", "java.awt.event.AdjustmentListener", "awt2swing.Scrollbar"], "jalview.appletgui.AlignmentPanel", ["awt2swing.Frame", "jalview.analysis.AnnotationSorter", "jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.FeatureRenderer", "$.IdPanel", "$.IdwidthAdjuster", "$.PaintRefresher", "$.ScalePanel", "$.SeqPanel", "jalview.bin.JalviewLite", "jalview.structure.StructureSelectionManager", "java.awt.BorderLayout", "$.Color", "$.Dimension", "java.awt.event.ComponentAdapter", "java.beans.PropertyChangeListener"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.overviewPanel = null; -this.seqPanel = null; -this.idPanel = null; -this.idwidthAdjuster = null; -this.alignFrame = null; -this.scalePanel = null; -this.annotationPanel = null; -this.alabels = null; -this.fastPaint = true; -this.hextent = 0; -this.vextent = 0; -this.sequenceHolderPanel = null; -this.vscroll = null; -this.hscroll = null; -this.seqPanelHolder = null; -this.scalePanelHolder = null; -this.idPanelHolder = null; -this.idSpaceFillerPanel1 = null; -this.annotationSpaceFillerHolder = null; -this.hscrollFillerPanel = null; -this.annotationPanelHolder = null; -this.apvscroll = null; -this.followingComplementScroll = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AlignmentPanel", awt2swing.Panel, [java.awt.event.AdjustmentListener, jalview.api.AlignmentViewPanel]); -Clazz.prepareFields (c$, function () { -this.sequenceHolderPanel = new awt2swing.Panel (); -this.vscroll = new awt2swing.Scrollbar (); -this.hscroll = new awt2swing.Scrollbar (); -this.seqPanelHolder = new awt2swing.Panel (); -this.scalePanelHolder = new awt2swing.Panel (); -this.idPanelHolder = new awt2swing.Panel (); -this.idSpaceFillerPanel1 = new awt2swing.Panel (); -this.annotationSpaceFillerHolder = new awt2swing.Panel (); -this.hscrollFillerPanel = new awt2swing.Panel (); -this.annotationPanelHolder = new awt2swing.Panel (); -this.apvscroll = new awt2swing.Scrollbar (); -}); -Clazz.overrideMethod (c$, "finalize", -function () { -this.alignFrame = null; -this.av = null; -this.seqPanel = null; -this.seqPanelHolder = null; -this.sequenceHolderPanel = null; -this.scalePanel = null; -this.scalePanelHolder = null; -this.annotationPanel = null; -this.annotationPanelHolder = null; -this.annotationSpaceFillerHolder = null; -}); -Clazz.makeConstructor (c$, -function (af, av) { -Clazz.superConstructor (this, jalview.appletgui.AlignmentPanel, []); -this.setName ("alignmentPanel"); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.alignFrame = af; -this.av = av; -this.seqPanel = new jalview.appletgui.SeqPanel (av, this); -this.idPanel = new jalview.appletgui.IdPanel (av, this); -this.scalePanel = new jalview.appletgui.ScalePanel (av, this); -this.idwidthAdjuster = new jalview.appletgui.IdwidthAdjuster (this); -this.annotationPanel = new jalview.appletgui.AnnotationPanel (this); -this.annotationPanelHolder.add (this.annotationPanel, "Center"); -this.sequenceHolderPanel.add (this.annotationPanelHolder, "South"); -this.alabels = new jalview.appletgui.AnnotationLabels (this); -this.setAnnotationVisible (av.isShowAnnotation ()); -this.idPanelHolder.add (this.idPanel, "Center"); -this.idSpaceFillerPanel1.add (this.idwidthAdjuster, "Center"); -this.annotationSpaceFillerHolder.add (this.alabels, "Center"); -this.scalePanelHolder.add (this.scalePanel, "Center"); -this.seqPanelHolder.add (this.seqPanel, "Center"); -this.fontChanged (); -this.setScrollValues (0, 0); -this.apvscroll.addAdjustmentListener (this); -this.hscroll.addAdjustmentListener (this); -this.vscroll.addAdjustmentListener (this); -this.addComponentListener (((Clazz.isClassDefined ("jalview.appletgui.AlignmentPanel$1") ? 0 : jalview.appletgui.AlignmentPanel.$AlignmentPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignmentPanel$1, this, Clazz.cloneFinals ("av", av)))); -var d = this.calculateIdWidth (); -this.idPanel.idCanvas.setSize (d); -this.hscrollFillerPanel.setSize (d.width, this.annotationPanel.getSize ().height); -this.idPanel.idCanvas.setSize (d.width, this.seqPanel.seqCanvas.getSize ().height); -this.annotationSpaceFillerHolder.setSize (d.width, this.annotationPanel.getSize ().height); -this.alabels.setSize (d.width, this.annotationPanel.getSize ().height); -var ap = this; -av.addPropertyChangeListener (((Clazz.isClassDefined ("jalview.appletgui.AlignmentPanel$2") ? 0 : jalview.appletgui.AlignmentPanel.$AlignmentPanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignmentPanel$2, this, Clazz.cloneFinals ("ap", ap, "av", av)))); -}, "jalview.appletgui.AlignFrame,jalview.appletgui.AlignViewport"); -Clazz.overrideMethod (c$, "getAlignViewport", -function () { -return this.av; -}); -Clazz.defineMethod (c$, "getSequenceRenderer", -function () { -return this.seqPanel.seqCanvas.sr; -}); -Clazz.overrideMethod (c$, "getFeatureRenderer", -function () { -return this.seqPanel.seqCanvas.fr; -}); -Clazz.overrideMethod (c$, "cloneFeatureRenderer", -function () { -var nfr = new jalview.appletgui.FeatureRenderer (this.av); -nfr.transferSettings (this.seqPanel.seqCanvas.fr); -return nfr; -}); -Clazz.defineMethod (c$, "alignmentChanged", -function () { -this.av.alignmentChanged (this); -if (this.overviewPanel != null) { -this.overviewPanel.updateOverviewImage (); -}this.alignFrame.updateEditMenuBar (); -this.repaint (); -}); -Clazz.defineMethod (c$, "fontChanged", -function () { -this.idPanel.idCanvas.image = null; -var fm = this.getFontMetrics (this.av.getFont ()); -this.scalePanel.setSize ( new java.awt.Dimension (10, this.av.getCharHeight () + fm.getDescent ())); -this.idwidthAdjuster.setSize ( new java.awt.Dimension (10, this.av.getCharHeight () + fm.getDescent ())); -this.av.updateSequenceIdColours (); -this.annotationPanel.image = null; -var ap = this.annotationPanel.adjustPanelHeight (false); -var d = this.calculateIdWidth (); -d.setSize (d.width + 4, this.seqPanel.seqCanvas.getSize ().height); -this.alabels.setSize (d.width + 4, ap); -this.idPanel.idCanvas.setSize (d); -this.hscrollFillerPanel.setSize (d); -this.validateAnnotationDimensions (false); -this.annotationPanel.repaint (); -this.validate (); -this.repaint (); -if (this.overviewPanel != null) { -this.overviewPanel.updateOverviewImage (); -}}); -Clazz.defineMethod (c$, "setIdWidth", -function (w, h) { -this.idPanel.idCanvas.setSize (w, h); -this.idPanelHolder.setSize (w, this.idPanelHolder.getSize ().height); -this.annotationSpaceFillerHolder.setSize (w, this.annotationSpaceFillerHolder.getSize ().height); -this.alabels.setSize (w, this.alabels.getSize ().height); -this.validate (); -}, "~N,~N"); -Clazz.defineMethod (c$, "calculateIdWidth", -function () { -if (this.av.nullFrame == null) { -this.av.nullFrame = new awt2swing.Frame (); -this.av.nullFrame.addNotify (); -this.av.nullFrame.setFont (this.av.font); -}var g = this.av.nullFrame.getGraphics (); -var fm = g.getFontMetrics (this.av.font); -var al = this.av.getAlignment (); -var i = 0; -var idWidth = 0; -var id; -while (i < al.getHeight () && al.getSequenceAt (i) != null) { -var s = al.getSequenceAt (i); -id = s.getDisplayId (this.av.getShowJVSuffix ()); -if (fm.stringWidth (id) > idWidth) { -idWidth = fm.stringWidth (id); -}i++; -} -i = 0; -if (al.getAlignmentAnnotation () != null) { -fm = g.getFontMetrics (this.av.nullFrame.getFont ()); -while (i < al.getAlignmentAnnotation ().length) { -var label = al.getAlignmentAnnotation ()[i].label; -if (fm.stringWidth (label) > idWidth) { -idWidth = fm.stringWidth (label); -}i++; -} -}return new java.awt.Dimension (idWidth, this.idPanel.idCanvas.getSize ().height); -}); -Clazz.defineMethod (c$, "highlightSearchResults", -function (results) { -this.scrollToPosition (results); -this.seqPanel.seqCanvas.highlightSearchResults (results); -}, "jalview.datamodel.SearchResults"); -Clazz.defineMethod (c$, "scrollToPosition", -function (results) { -return this.scrollToPosition (results, true); -}, "jalview.datamodel.SearchResults"); -Clazz.defineMethod (c$, "scrollToPosition", -function (results, redrawOverview) { -return this.scrollToPosition (results, redrawOverview, false); -}, "jalview.datamodel.SearchResults,~B"); -Clazz.defineMethod (c$, "scrollToPosition", -function (results, redrawOverview, centre) { -if (results != null && results.getSize () > 0) { -var alignment = this.av.getAlignment (); -var seqIndex = alignment.findIndex (results); -if (seqIndex == -1) { -return false; -}var seq = alignment.getSequenceAt (seqIndex); -var r = results.getResults (seq, 0, alignment.getWidth ()); -if (r == null) { -if (jalview.bin.JalviewLite.debug) { -System.out.println ("DEBUG: scroll didn't happen - results not within alignment : " + seq.getStart () + "," + seq.getEnd ()); -}return false; -}if (jalview.bin.JalviewLite.debug) { -}var start = r[0]; -var end = r[1]; -if (centre) { -var offset = Clazz.doubleToInt ((this.av.getEndRes () - this.av.getStartRes () + 1) / 2) - 1; -start = Math.max (start - offset, 0); -end = Math.min (end + offset, seq.getEnd () - 1); -}if (start < 0) { -return false; -}if (end == seq.getEnd ()) { -return false; -}return this.scrollTo (start, end, seqIndex, false, redrawOverview); -}return true; -}, "jalview.datamodel.SearchResults,~B,~B"); -Clazz.defineMethod (c$, "scrollTo", -function (ostart, end, seqIndex, scrollToNearest, redrawOverview) { -var startv; -var endv; -var starts; -var ends; -var width; -var start = -1; -if (this.av.hasHiddenColumns ()) { -start = this.av.getColumnSelection ().findColumnPosition (ostart); -end = this.av.getColumnSelection ().findColumnPosition (end); -if (start == end) { -if (!scrollToNearest && !this.av.getColumnSelection ().isVisible (ostart)) { -return false; -}}} else { -start = ostart; -}if (!this.av.getWrapAlignment ()) { -if ((startv = this.av.getStartRes ()) >= start) { -this.setScrollValues (start - 1, seqIndex); -} else if ((endv = this.av.getEndRes ()) <= end) { -this.setScrollValues (startv + 1 + end - endv, seqIndex); -} else if ((starts = this.av.getStartSeq ()) > seqIndex) { -this.setScrollValues (this.av.getStartRes (), seqIndex); -} else if ((ends = this.av.getEndSeq ()) <= seqIndex) { -this.setScrollValues (this.av.getStartRes (), starts + seqIndex - ends + 1); -}} else { -this.scrollToWrappedVisible (start); -}if (redrawOverview && this.overviewPanel != null) { -this.overviewPanel.setBoxPosition (); -}this.paintAlignment (redrawOverview); -return true; -}, "~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "scrollToWrappedVisible", -function (res) { -var cwidth = this.seqPanel.seqCanvas.getWrappedCanvasWidth (this.seqPanel.seqCanvas.getSize ().width); -if (res <= this.av.getStartRes () || res >= (this.av.getStartRes () + cwidth)) { -this.vscroll.setValue (Clazz.doubleToInt (res / cwidth)); -this.av.startRes = this.vscroll.getValue () * cwidth; -}}, "~N"); -Clazz.defineMethod (c$, "getOverviewPanel", -function () { -return this.overviewPanel; -}); -Clazz.defineMethod (c$, "setOverviewPanel", -function (op) { -this.overviewPanel = op; -}, "jalview.appletgui.OverviewPanel"); -Clazz.defineMethod (c$, "setAnnotationVisible", -function (b) { -if (!this.av.getWrapAlignment ()) { -this.annotationSpaceFillerHolder.setVisible (b); -this.annotationPanelHolder.setVisible (b); -} else { -this.annotationSpaceFillerHolder.setVisible (false); -this.annotationPanelHolder.setVisible (false); -}this.validate (); -this.repaint (); -}, "~B"); -Clazz.overrideMethod (c$, "adjustAnnotationHeight", -function () { -if (this.alignFrame.getSize ().height == 0) { -System.out.println ("adjustAnnotationHeight frame size zero NEEDS FIXING"); -}this.fontChanged (); -this.validateAnnotationDimensions (true); -this.apvscroll.addNotify (); -this.hscroll.addNotify (); -this.validate (); -this.paintAlignment (true); -}); -Clazz.defineMethod (c$, "validateAnnotationDimensions", -function (adjustPanelHeight) { -var rowHeight = this.av.getCharHeight (); -var alignmentHeight = rowHeight * this.av.getAlignment ().getHeight (); -var annotationHeight = this.av.calcPanelHeight (); -var mheight = annotationHeight; -var d = this.sequenceHolderPanel.getSize (); -var availableHeight = d.height - this.scalePanelHolder.getHeight (); -if (adjustPanelHeight) { -if (annotationHeight + alignmentHeight > availableHeight) { -annotationHeight = Math.min (annotationHeight, availableHeight - 2 * rowHeight); -}} else { -annotationHeight = this.annotationPanelHolder.getSize ().height; -}if (availableHeight - annotationHeight < 5) { -annotationHeight = availableHeight; -}this.annotationPanel.setSize ( new java.awt.Dimension (d.width, annotationHeight)); -this.annotationPanelHolder.setSize ( new java.awt.Dimension (d.width, annotationHeight)); -this.seqPanel.seqCanvas.setSize (d.width, this.seqPanel.seqCanvas.getSize ().height); -var e = this.idPanel.getSize (); -this.alabels.setSize ( new java.awt.Dimension (e.width, annotationHeight)); -this.annotationSpaceFillerHolder.setSize ( new java.awt.Dimension (e.width, annotationHeight)); -var s = this.apvscroll.getValue (); -if (s > mheight - annotationHeight) { -s = 0; -}this.apvscroll.setValues (s, annotationHeight, 0, mheight); -this.annotationPanel.setScrollOffset (this.apvscroll.getValue (), false); -this.alabels.setScrollOffset (this.apvscroll.getValue (), false); -}, "~B"); -Clazz.defineMethod (c$, "setWrapAlignment", -function (wrap) { -this.av.startSeq = 0; -this.av.startRes = 0; -this.scalePanelHolder.setVisible (!wrap); -this.hscroll.setVisible (!wrap); -this.idwidthAdjuster.setVisible (!wrap); -if (wrap) { -this.annotationPanelHolder.setVisible (false); -this.annotationSpaceFillerHolder.setVisible (false); -} else if (this.av.isShowAnnotation ()) { -this.annotationPanelHolder.setVisible (true); -this.annotationSpaceFillerHolder.setVisible (true); -}this.idSpaceFillerPanel1.setVisible (!wrap); -this.fontChanged (); -this.validate (); -this.sequenceHolderPanel.validate (); -this.repaint (); -}, "~B"); -Clazz.defineMethod (c$, "scrollUp", -function (up) { -if (up) { -if (this.vscroll.getValue () < 1) { -return false; -}this.setScrollValues (this.hscroll.getValue (), this.vscroll.getValue () - 1); -} else { -if (this.vextent + this.vscroll.getValue () >= this.av.getAlignment ().getHeight ()) { -return false; -}this.setScrollValues (this.hscroll.getValue (), this.vscroll.getValue () + 1); -}this.repaint (); -return true; -}, "~B"); -Clazz.defineMethod (c$, "scrollRight", -function (right) { -if (!right) { -if (this.hscroll.getValue () < 1) { -return false; -}this.setScrollValues (this.hscroll.getValue () - 1, this.vscroll.getValue ()); -} else { -if (this.hextent + this.hscroll.getValue () >= this.av.getAlignment ().getWidth ()) { -return false; -}this.setScrollValues (this.hscroll.getValue () + 1, this.vscroll.getValue ()); -}this.repaint (); -return true; -}, "~B"); -Clazz.defineMethod (c$, "setScrollValues", -function (x, y) { -var width = this.av.getAlignment ().getWidth (); -var height = this.av.getAlignment ().getHeight (); -if (this.av.hasHiddenColumns ()) { -width = this.av.getColumnSelection ().findColumnPosition (width); -}if (x < 0) { -x = 0; -};this.hextent = Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().width / this.av.getCharWidth ()); -this.vextent = Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().height / this.av.getCharHeight ()); -if (this.hextent > width) { -this.hextent = width; -}if (this.vextent > height) { -this.vextent = height; -}if ((this.hextent + x) > width) { -System.err.println ("hextent was " + this.hextent + " and x was " + x); -x = width - this.hextent; -}if ((this.vextent + y) > height) { -y = height - this.vextent; -}if (y < 0) { -y = 0; -}if (x < 0) { -System.err.println ("x was " + x); -x = 0; -}this.av.setStartSeq (y); -var endSeq = y + this.vextent; -if (endSeq > this.av.getAlignment ().getHeight ()) { -endSeq = this.av.getAlignment ().getHeight (); -}this.av.setEndSeq (endSeq); -this.av.setStartRes (x); -this.av.setEndRes ((x + (Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().width / this.av.getCharWidth ()))) - 1); -this.hscroll.setValues (x, this.hextent, 0, width); -this.vscroll.setValues (y, this.vextent, 0, height); -if (this.overviewPanel != null) { -this.overviewPanel.setBoxPosition (); -}this.sendViewPosition (); -}, "~N,~N"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -if (this.annotationPanel == null) return; -var oldX = this.av.getStartRes (); -var oldY = this.av.getStartSeq (); -if (evt == null || evt.getSource () === this.apvscroll) { -this.annotationPanel.setScrollOffset (this.apvscroll.getValue (), false); -this.alabels.setScrollOffset (this.apvscroll.getValue (), false); -}if (evt == null || evt.getSource () === this.hscroll) { -var x = this.hscroll.getValue (); -this.av.setStartRes (x); -this.av.setEndRes (x + Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().width / this.av.getCharWidth ()) - 1); -}if (evt == null || evt.getSource () === this.vscroll) { -var offy = this.vscroll.getValue (); -if (this.av.getWrapAlignment ()) { -var rowSize = this.seqPanel.seqCanvas.getWrappedCanvasWidth (this.seqPanel.seqCanvas.getSize ().width); -this.av.setStartRes (this.vscroll.getValue () * rowSize); -this.av.setEndRes ((this.vscroll.getValue () + 1) * rowSize); -} else { -this.av.setStartSeq (offy); -this.av.setEndSeq (offy + Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().height / this.av.getCharHeight ())); -}}if (this.overviewPanel != null) { -this.overviewPanel.setBoxPosition (); -}var scrollX = this.av.startRes - oldX; -var scrollY = this.av.startSeq - oldY; -if (this.av.getWrapAlignment () || !this.fastPaint || this.av.MAC) { -this.repaint (); -} else { -if (scrollX > this.av.endRes - this.av.startRes) { -scrollX = this.av.endRes - this.av.startRes; -} else if (scrollX < this.av.startRes - this.av.endRes) { -scrollX = this.av.startRes - this.av.endRes; -}this.idPanel.idCanvas.fastPaint (scrollY); -this.seqPanel.seqCanvas.fastPaint (scrollX, scrollY); -this.scalePanel.repaint (); -if (this.av.isShowAnnotation ()) { -this.annotationPanel.fastPaint (this.av.getStartRes () - oldX); -}}this.sendViewPosition (); -if (this.isFollowingComplementScroll ()) { -this.setFollowingComplementScroll (false); -} else { -var ap = this.getComplementPanel (); -this.av.scrollComplementaryAlignment (ap); -}}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "getComplementPanel", -($fz = function () { -var ap = null; -if (this.alignFrame != null) { -var sf = this.alignFrame.getSplitFrame (); -if (sf != null) { -var other = sf.getComplement (this.alignFrame); -if (other != null) { -ap = other.alignPanel; -}}}return ap; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "scrollToCentre", -function (sr, seqOffset) { -var mappedTo = sr.getResultSequence (0); -var seqs = this.av.getAlignment ().getSequences (); -var sequenceIndex = 0; -var matched = false; -for (var seq, $seq = seqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -if (mappedTo === seq.getDatasetSequence ()) { -matched = true; -break; -}sequenceIndex++; -} -if (!matched) { -return; -}sequenceIndex = Math.max (0, sequenceIndex - seqOffset); -sr.getResults ().get (0).setSequence (this.av.getAlignment ().getSequenceAt (sequenceIndex)); -this.setFollowingComplementScroll (true); -this.scrollToPosition (sr, true, true); -}, "jalview.datamodel.SearchResults,~N"); -Clazz.defineMethod (c$, "sendViewPosition", -($fz = function () { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet).sendViewPosition (this, this.av.startRes, this.av.endRes, this.av.startSeq, this.av.endSeq); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "paintAlignment", -function (updateOverview) { -var sorter = new jalview.analysis.AnnotationSorter (this.getAlignment (), this.av.isShowAutocalculatedAbove ()); -sorter.sort (this.getAlignment ().getAlignmentAnnotation (), this.av.getSortAnnotationsBy ()); -this.repaint (); -if (updateOverview) { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet).sequenceColoursChanged (this); -if (this.overviewPanel != null) { -this.overviewPanel.updateOverviewImage (); -}}}, "~B"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -System.out.println ("alignframe paintcomp"); -this.invalidate (); -var d = this.idPanel.idCanvas.getSize (); -var canvasHeight = this.seqPanel.seqCanvas.getSize ().height; -if (canvasHeight != d.height) { -this.idPanel.idCanvas.setSize (d.width, canvasHeight); -}if (this.av.getWrapAlignment ()) { -var maxwidth = this.av.getAlignment ().getWidth (); -if (this.av.hasHiddenColumns ()) { -maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; -}var canvasWidth = this.seqPanel.seqCanvas.getWrappedCanvasWidth (this.seqPanel.seqCanvas.getSize ().width); -if (canvasWidth > 0) { -var max = Clazz.doubleToInt (maxwidth / canvasWidth); -this.vscroll.setMaximum (1 + max); -this.vscroll.setUnitIncrement (1); -this.vscroll.setVisibleAmount (1); -}} else { -this.setScrollValues (this.av.getStartRes (), this.av.getStartSeq ()); -}}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout ( new java.awt.BorderLayout ()); -this.sequenceHolderPanel.setLayout ( new java.awt.BorderLayout ()); -this.seqPanelHolder.setLayout ( new java.awt.BorderLayout ()); -this.scalePanelHolder.setBackground (java.awt.Color.white); -this.scalePanelHolder.setLayout ( new java.awt.BorderLayout ()); -this.idPanelHolder.setLayout ( new java.awt.BorderLayout ()); -this.idSpaceFillerPanel1.setBackground (java.awt.Color.white); -this.idSpaceFillerPanel1.setLayout ( new java.awt.BorderLayout ()); -this.annotationSpaceFillerHolder.setBackground (java.awt.Color.white); -this.annotationSpaceFillerHolder.setLayout ( new java.awt.BorderLayout ()); -this.hscroll.setOrientation (0); -var hscrollHolder = new awt2swing.Panel (); -hscrollHolder.setLayout ( new java.awt.BorderLayout ()); -this.hscrollFillerPanel.setBackground (java.awt.Color.white); -this.apvscroll.setOrientation (1); -this.apvscroll.setVisible (true); -this.apvscroll.addAdjustmentListener (this); -this.annotationPanelHolder.setBackground (java.awt.Color.white); -this.annotationPanelHolder.setLayout ( new java.awt.BorderLayout ()); -this.annotationPanelHolder.add (this.apvscroll, "East"); -hscrollHolder.setBackground (java.awt.Color.white); -this.seqPanelHolder.setBackground (java.awt.Color.white); -this.idPanelHolder.setBackground (java.awt.Color.white); -this.sequenceHolderPanel.add (this.scalePanelHolder, "North"); -this.sequenceHolderPanel.add (this.seqPanelHolder, "Center"); -this.seqPanelHolder.add (this.vscroll, "East"); -this.add (this.idPanelHolder, "West"); -this.idPanelHolder.add (this.idSpaceFillerPanel1, "North"); -this.idPanelHolder.add (this.annotationSpaceFillerHolder, "South"); -this.add (hscrollHolder, "South"); -hscrollHolder.add (this.hscroll, "Center"); -hscrollHolder.add (this.hscrollFillerPanel, "West"); -this.add (this.sequenceHolderPanel, "Center"); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "updateAnnotation", -function () { -this.updateAnnotation (false); -}); -Clazz.defineMethod (c$, "updateAnnotation", -function (applyGlobalSettings) { -this.updateAnnotation (applyGlobalSettings, false); -}, "~B"); -Clazz.defineMethod (c$, "updateAnnotation", -function (applyGlobalSettings, preserveNewGroupSettings) { -this.av.updateGroupAnnotationSettings (applyGlobalSettings, preserveNewGroupSettings); -this.adjustAnnotationHeight (); -}, "~B,~B"); -Clazz.overrideMethod (c$, "getAlignment", -function () { -return this.av.getAlignment (); -}); -Clazz.overrideMethod (c$, "getViewName", -function () { -return this.getName (); -}); -Clazz.overrideMethod (c$, "getStructureSelectionManager", -function () { -return jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet); -}); -Clazz.overrideMethod (c$, "raiseOOMWarning", -function (string, error) { -System.err.println ("Out of memory whilst '" + string + "'"); -error.printStackTrace (); -}, "~S,OutOfMemoryError"); -Clazz.defineMethod (c$, "setFollowingComplementScroll", -function (b) { -this.followingComplementScroll = b; -}, "~B"); -Clazz.defineMethod (c$, "isFollowingComplementScroll", -function () { -return this.followingComplementScroll; -}); -c$.$AlignmentPanel$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignmentPanel$1", java.awt.event.ComponentAdapter); -Clazz.overrideMethod (c$, "componentResized", -function (evt) { -this.b$["jalview.appletgui.AlignmentPanel"].setScrollValues (this.f$.av.getStartRes (), this.f$.av.getStartSeq ()); -if (this.b$["jalview.appletgui.AlignmentPanel"].getSize ().height > 0 && this.b$["jalview.appletgui.AlignmentPanel"].annotationPanelHolder.getSize ().height > 0) { -this.b$["jalview.appletgui.AlignmentPanel"].validateAnnotationDimensions (false); -}this.b$["jalview.appletgui.AlignmentPanel"].repaint (); -}, "java.awt.event.ComponentEvent"); -c$ = Clazz.p0p (); -}; -c$.$AlignmentPanel$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignmentPanel$2", null, java.beans.PropertyChangeListener); -Clazz.overrideMethod (c$, "propertyChange", -function (evt) { -if (evt.getPropertyName ().equals ("alignment")) { -jalview.appletgui.PaintRefresher.Refresh (this.f$.ap, this.f$.av.getSequenceSetId (), true, true); -this.b$["jalview.appletgui.AlignmentPanel"].alignmentChanged (); -}}, "java.beans.PropertyChangeEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.api.AlignmentViewPanel", "java.awt.event.AdjustmentListener", "awt2swing.Scrollbar"], "jalview.appletgui.AlignmentPanel", ["awt2swing.Frame", "jalview.analysis.AnnotationSorter", "jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.FeatureRenderer", "$.IdPanel", "$.IdwidthAdjuster", "$.PaintRefresher", "$.ScalePanel", "$.SeqPanel", "jalview.bin.JalviewLite", "jalview.structure.StructureSelectionManager", "java.awt.BorderLayout", "$.Color", "$.Dimension", "java.awt.event.ComponentAdapter", "java.beans.PropertyChangeListener"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.overviewPanel = null; +this.seqPanel = null; +this.idPanel = null; +this.idwidthAdjuster = null; +this.alignFrame = null; +this.scalePanel = null; +this.annotationPanel = null; +this.alabels = null; +this.fastPaint = true; +this.hextent = 0; +this.vextent = 0; +this.sequenceHolderPanel = null; +this.vscroll = null; +this.hscroll = null; +this.seqPanelHolder = null; +this.scalePanelHolder = null; +this.idPanelHolder = null; +this.idSpaceFillerPanel1 = null; +this.annotationSpaceFillerHolder = null; +this.hscrollFillerPanel = null; +this.annotationPanelHolder = null; +this.apvscroll = null; +this.followingComplementScroll = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AlignmentPanel", awt2swing.Panel, [java.awt.event.AdjustmentListener, jalview.api.AlignmentViewPanel]); +Clazz.prepareFields (c$, function () { +this.sequenceHolderPanel = new awt2swing.Panel (); +this.vscroll = new awt2swing.Scrollbar (); +this.hscroll = new awt2swing.Scrollbar (); +this.seqPanelHolder = new awt2swing.Panel (); +this.scalePanelHolder = new awt2swing.Panel (); +this.idPanelHolder = new awt2swing.Panel (); +this.idSpaceFillerPanel1 = new awt2swing.Panel (); +this.annotationSpaceFillerHolder = new awt2swing.Panel (); +this.hscrollFillerPanel = new awt2swing.Panel (); +this.annotationPanelHolder = new awt2swing.Panel (); +this.apvscroll = new awt2swing.Scrollbar (); +}); +Clazz.overrideMethod (c$, "finalize", +function () { +this.alignFrame = null; +this.av = null; +this.seqPanel = null; +this.seqPanelHolder = null; +this.sequenceHolderPanel = null; +this.scalePanel = null; +this.scalePanelHolder = null; +this.annotationPanel = null; +this.annotationPanelHolder = null; +this.annotationSpaceFillerHolder = null; +}); +Clazz.makeConstructor (c$, +function (af, av) { +Clazz.superConstructor (this, jalview.appletgui.AlignmentPanel, []); +this.setName ("alignmentPanel"); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.alignFrame = af; +this.av = av; +this.seqPanel = new jalview.appletgui.SeqPanel (av, this); +this.idPanel = new jalview.appletgui.IdPanel (av, this); +this.scalePanel = new jalview.appletgui.ScalePanel (av, this); +this.idwidthAdjuster = new jalview.appletgui.IdwidthAdjuster (this); +this.annotationPanel = new jalview.appletgui.AnnotationPanel (this); +this.annotationPanelHolder.add (this.annotationPanel, "Center"); +this.sequenceHolderPanel.add (this.annotationPanelHolder, "South"); +this.alabels = new jalview.appletgui.AnnotationLabels (this); +this.setAnnotationVisible (av.isShowAnnotation ()); +this.idPanelHolder.add (this.idPanel, "Center"); +this.idSpaceFillerPanel1.add (this.idwidthAdjuster, "Center"); +this.annotationSpaceFillerHolder.add (this.alabels, "Center"); +this.scalePanelHolder.add (this.scalePanel, "Center"); +this.seqPanelHolder.add (this.seqPanel, "Center"); +this.fontChanged (); +this.setScrollValues (0, 0); +this.apvscroll.addAdjustmentListener (this); +this.hscroll.addAdjustmentListener (this); +this.vscroll.addAdjustmentListener (this); +this.addComponentListener (((Clazz.isClassDefined ("jalview.appletgui.AlignmentPanel$1") ? 0 : jalview.appletgui.AlignmentPanel.$AlignmentPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignmentPanel$1, this, Clazz.cloneFinals ("av", av)))); +var d = this.calculateIdWidth (); +this.idPanel.idCanvas.setSize (d); +this.hscrollFillerPanel.setSize (d.width, this.annotationPanel.getSize ().height); +this.idPanel.idCanvas.setSize (d.width, this.seqPanel.seqCanvas.getSize ().height); +this.annotationSpaceFillerHolder.setSize (d.width, this.annotationPanel.getSize ().height); +this.alabels.setSize (d.width, this.annotationPanel.getSize ().height); +var ap = this; +av.addPropertyChangeListener (((Clazz.isClassDefined ("jalview.appletgui.AlignmentPanel$2") ? 0 : jalview.appletgui.AlignmentPanel.$AlignmentPanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.AlignmentPanel$2, this, Clazz.cloneFinals ("ap", ap, "av", av)))); +}, "jalview.appletgui.AlignFrame,jalview.appletgui.AlignViewport"); +Clazz.overrideMethod (c$, "getAlignViewport", +function () { +return this.av; +}); +Clazz.defineMethod (c$, "getSequenceRenderer", +function () { +return this.seqPanel.seqCanvas.sr; +}); +Clazz.overrideMethod (c$, "getFeatureRenderer", +function () { +return this.seqPanel.seqCanvas.fr; +}); +Clazz.overrideMethod (c$, "cloneFeatureRenderer", +function () { +var nfr = new jalview.appletgui.FeatureRenderer (this.av); +nfr.transferSettings (this.seqPanel.seqCanvas.fr); +return nfr; +}); +Clazz.defineMethod (c$, "alignmentChanged", +function () { +this.av.alignmentChanged (this); +if (this.overviewPanel != null) { +this.overviewPanel.updateOverviewImage (); +}this.alignFrame.updateEditMenuBar (); +this.repaint (); +}); +Clazz.defineMethod (c$, "fontChanged", +function () { +this.idPanel.idCanvas.image = null; +var fm = this.getFontMetrics (this.av.getFont ()); +this.scalePanel.setSize ( new java.awt.Dimension (10, this.av.getCharHeight () + fm.getDescent ())); +this.idwidthAdjuster.setSize ( new java.awt.Dimension (10, this.av.getCharHeight () + fm.getDescent ())); +this.av.updateSequenceIdColours (); +this.annotationPanel.image = null; +var ap = this.annotationPanel.adjustPanelHeight (false); +var d = this.calculateIdWidth (); +d.setSize (d.width + 4, this.seqPanel.seqCanvas.getSize ().height); +this.alabels.setSize (d.width + 4, ap); +this.idPanel.idCanvas.setSize (d); +this.hscrollFillerPanel.setSize (d); +this.validateAnnotationDimensions (false); +this.annotationPanel.repaint (); +this.validate (); +this.repaint (); +if (this.overviewPanel != null) { +this.overviewPanel.updateOverviewImage (); +}}); +Clazz.defineMethod (c$, "setIdWidth", +function (w, h) { +this.idPanel.idCanvas.setSize (w, h); +this.idPanelHolder.setSize (w, this.idPanelHolder.getSize ().height); +this.annotationSpaceFillerHolder.setSize (w, this.annotationSpaceFillerHolder.getSize ().height); +this.alabels.setSize (w, this.alabels.getSize ().height); +this.validate (); +}, "~N,~N"); +Clazz.defineMethod (c$, "calculateIdWidth", +function () { +if (this.av.nullFrame == null) { +this.av.nullFrame = new awt2swing.Frame (); +this.av.nullFrame.addNotify (); +this.av.nullFrame.setFont (this.av.font); +}var g = this.av.nullFrame.getGraphics (); +var fm = g.getFontMetrics (this.av.font); +var al = this.av.getAlignment (); +var i = 0; +var idWidth = 0; +var id; +while (i < al.getHeight () && al.getSequenceAt (i) != null) { +var s = al.getSequenceAt (i); +id = s.getDisplayId (this.av.getShowJVSuffix ()); +if (fm.stringWidth (id) > idWidth) { +idWidth = fm.stringWidth (id); +}i++; +} +i = 0; +if (al.getAlignmentAnnotation () != null) { +fm = g.getFontMetrics (this.av.nullFrame.getFont ()); +while (i < al.getAlignmentAnnotation ().length) { +var label = al.getAlignmentAnnotation ()[i].label; +if (fm.stringWidth (label) > idWidth) { +idWidth = fm.stringWidth (label); +}i++; +} +}return new java.awt.Dimension (idWidth, this.idPanel.idCanvas.getSize ().height); +}); +Clazz.defineMethod (c$, "highlightSearchResults", +function (results) { +this.scrollToPosition (results); +this.seqPanel.seqCanvas.highlightSearchResults (results); +}, "jalview.datamodel.SearchResults"); +Clazz.defineMethod (c$, "scrollToPosition", +function (results) { +return this.scrollToPosition (results, true); +}, "jalview.datamodel.SearchResults"); +Clazz.defineMethod (c$, "scrollToPosition", +function (results, redrawOverview) { +return this.scrollToPosition (results, redrawOverview, false); +}, "jalview.datamodel.SearchResults,~B"); +Clazz.defineMethod (c$, "scrollToPosition", +function (results, redrawOverview, centre) { +if (results != null && results.getSize () > 0) { +var alignment = this.av.getAlignment (); +var seqIndex = alignment.findIndex (results); +if (seqIndex == -1) { +return false; +}var seq = alignment.getSequenceAt (seqIndex); +var r = results.getResults (seq, 0, alignment.getWidth ()); +if (r == null) { +if (jalview.bin.JalviewLite.debug) { +System.out.println ("DEBUG: scroll didn't happen - results not within alignment : " + seq.getStart () + "," + seq.getEnd ()); +}return false; +}if (jalview.bin.JalviewLite.debug) { +}var start = r[0]; +var end = r[1]; +if (centre) { +var offset = Clazz.doubleToInt ((this.av.getEndRes () - this.av.getStartRes () + 1) / 2) - 1; +start = Math.max (start - offset, 0); +end = Math.min (end + offset, seq.getEnd () - 1); +}if (start < 0) { +return false; +}if (end == seq.getEnd ()) { +return false; +}return this.scrollTo (start, end, seqIndex, false, redrawOverview); +}return true; +}, "jalview.datamodel.SearchResults,~B,~B"); +Clazz.defineMethod (c$, "scrollTo", +function (ostart, end, seqIndex, scrollToNearest, redrawOverview) { +var startv; +var endv; +var starts; +var ends; +var width; +var start = -1; +if (this.av.hasHiddenColumns ()) { +start = this.av.getColumnSelection ().findColumnPosition (ostart); +end = this.av.getColumnSelection ().findColumnPosition (end); +if (start == end) { +if (!scrollToNearest && !this.av.getColumnSelection ().isVisible (ostart)) { +return false; +}}} else { +start = ostart; +}if (!this.av.getWrapAlignment ()) { +if ((startv = this.av.getStartRes ()) >= start) { +this.setScrollValues (start - 1, seqIndex); +} else if ((endv = this.av.getEndRes ()) <= end) { +this.setScrollValues (startv + 1 + end - endv, seqIndex); +} else if ((starts = this.av.getStartSeq ()) > seqIndex) { +this.setScrollValues (this.av.getStartRes (), seqIndex); +} else if ((ends = this.av.getEndSeq ()) <= seqIndex) { +this.setScrollValues (this.av.getStartRes (), starts + seqIndex - ends + 1); +}} else { +this.scrollToWrappedVisible (start); +}if (redrawOverview && this.overviewPanel != null) { +this.overviewPanel.setBoxPosition (); +}this.paintAlignment (redrawOverview); +return true; +}, "~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "scrollToWrappedVisible", +function (res) { +var cwidth = this.seqPanel.seqCanvas.getWrappedCanvasWidth (this.seqPanel.seqCanvas.getSize ().width); +if (res <= this.av.getStartRes () || res >= (this.av.getStartRes () + cwidth)) { +this.vscroll.setValue (Clazz.doubleToInt (res / cwidth)); +this.av.startRes = this.vscroll.getValue () * cwidth; +}}, "~N"); +Clazz.defineMethod (c$, "getOverviewPanel", +function () { +return this.overviewPanel; +}); +Clazz.defineMethod (c$, "setOverviewPanel", +function (op) { +this.overviewPanel = op; +}, "jalview.appletgui.OverviewPanel"); +Clazz.defineMethod (c$, "setAnnotationVisible", +function (b) { +if (!this.av.getWrapAlignment ()) { +this.annotationSpaceFillerHolder.setVisible (b); +this.annotationPanelHolder.setVisible (b); +} else { +this.annotationSpaceFillerHolder.setVisible (false); +this.annotationPanelHolder.setVisible (false); +}this.validate (); +this.repaint (); +}, "~B"); +Clazz.overrideMethod (c$, "adjustAnnotationHeight", +function () { +if (this.alignFrame.getSize ().height == 0) { +System.out.println ("adjustAnnotationHeight frame size zero NEEDS FIXING"); +}this.fontChanged (); +this.validateAnnotationDimensions (true); +this.apvscroll.addNotify (); +this.hscroll.addNotify (); +this.validate (); +this.paintAlignment (true); +}); +Clazz.defineMethod (c$, "validateAnnotationDimensions", +function (adjustPanelHeight) { +var rowHeight = this.av.getCharHeight (); +var alignmentHeight = rowHeight * this.av.getAlignment ().getHeight (); +var annotationHeight = this.av.calcPanelHeight (); +var mheight = annotationHeight; +var d = this.sequenceHolderPanel.getSize (); +var availableHeight = d.height - this.scalePanelHolder.getHeight (); +if (adjustPanelHeight) { +if (annotationHeight + alignmentHeight > availableHeight) { +annotationHeight = Math.min (annotationHeight, availableHeight - 2 * rowHeight); +}} else { +annotationHeight = this.annotationPanelHolder.getSize ().height; +}if (availableHeight - annotationHeight < 5) { +annotationHeight = availableHeight; +}this.annotationPanel.setSize ( new java.awt.Dimension (d.width, annotationHeight)); +this.annotationPanelHolder.setSize ( new java.awt.Dimension (d.width, annotationHeight)); +this.seqPanel.seqCanvas.setSize (d.width, this.seqPanel.seqCanvas.getSize ().height); +var e = this.idPanel.getSize (); +this.alabels.setSize ( new java.awt.Dimension (e.width, annotationHeight)); +this.annotationSpaceFillerHolder.setSize ( new java.awt.Dimension (e.width, annotationHeight)); +var s = this.apvscroll.getValue (); +if (s > mheight - annotationHeight) { +s = 0; +}this.apvscroll.setValues (s, annotationHeight, 0, mheight); +this.annotationPanel.setScrollOffset (this.apvscroll.getValue (), false); +this.alabels.setScrollOffset (this.apvscroll.getValue (), false); +}, "~B"); +Clazz.defineMethod (c$, "setWrapAlignment", +function (wrap) { +this.av.startSeq = 0; +this.av.startRes = 0; +this.scalePanelHolder.setVisible (!wrap); +this.hscroll.setVisible (!wrap); +this.idwidthAdjuster.setVisible (!wrap); +if (wrap) { +this.annotationPanelHolder.setVisible (false); +this.annotationSpaceFillerHolder.setVisible (false); +} else if (this.av.isShowAnnotation ()) { +this.annotationPanelHolder.setVisible (true); +this.annotationSpaceFillerHolder.setVisible (true); +}this.idSpaceFillerPanel1.setVisible (!wrap); +this.fontChanged (); +this.validate (); +this.sequenceHolderPanel.validate (); +this.repaint (); +}, "~B"); +Clazz.defineMethod (c$, "scrollUp", +function (up) { +if (up) { +if (this.vscroll.getValue () < 1) { +return false; +}this.setScrollValues (this.hscroll.getValue (), this.vscroll.getValue () - 1); +} else { +if (this.vextent + this.vscroll.getValue () >= this.av.getAlignment ().getHeight ()) { +return false; +}this.setScrollValues (this.hscroll.getValue (), this.vscroll.getValue () + 1); +}this.repaint (); +return true; +}, "~B"); +Clazz.defineMethod (c$, "scrollRight", +function (right) { +if (!right) { +if (this.hscroll.getValue () < 1) { +return false; +}this.setScrollValues (this.hscroll.getValue () - 1, this.vscroll.getValue ()); +} else { +if (this.hextent + this.hscroll.getValue () >= this.av.getAlignment ().getWidth ()) { +return false; +}this.setScrollValues (this.hscroll.getValue () + 1, this.vscroll.getValue ()); +}this.repaint (); +return true; +}, "~B"); +Clazz.defineMethod (c$, "setScrollValues", +function (x, y) { +var width = this.av.getAlignment ().getWidth (); +var height = this.av.getAlignment ().getHeight (); +if (this.av.hasHiddenColumns ()) { +width = this.av.getColumnSelection ().findColumnPosition (width); +}if (x < 0) { +x = 0; +};this.hextent = Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().width / this.av.getCharWidth ()); +this.vextent = Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().height / this.av.getCharHeight ()); +if (this.hextent > width) { +this.hextent = width; +}if (this.vextent > height) { +this.vextent = height; +}if ((this.hextent + x) > width) { +System.err.println ("hextent was " + this.hextent + " and x was " + x); +x = width - this.hextent; +}if ((this.vextent + y) > height) { +y = height - this.vextent; +}if (y < 0) { +y = 0; +}if (x < 0) { +System.err.println ("x was " + x); +x = 0; +}this.av.setStartSeq (y); +var endSeq = y + this.vextent; +if (endSeq > this.av.getAlignment ().getHeight ()) { +endSeq = this.av.getAlignment ().getHeight (); +}this.av.setEndSeq (endSeq); +this.av.setStartRes (x); +this.av.setEndRes ((x + (Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().width / this.av.getCharWidth ()))) - 1); +this.hscroll.setValues (x, this.hextent, 0, width); +this.vscroll.setValues (y, this.vextent, 0, height); +if (this.overviewPanel != null) { +this.overviewPanel.setBoxPosition (); +}this.sendViewPosition (); +}, "~N,~N"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +if (this.annotationPanel == null) return; +var oldX = this.av.getStartRes (); +var oldY = this.av.getStartSeq (); +if (evt == null || evt.getSource () === this.apvscroll) { +this.annotationPanel.setScrollOffset (this.apvscroll.getValue (), false); +this.alabels.setScrollOffset (this.apvscroll.getValue (), false); +}if (evt == null || evt.getSource () === this.hscroll) { +var x = this.hscroll.getValue (); +this.av.setStartRes (x); +this.av.setEndRes (x + Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().width / this.av.getCharWidth ()) - 1); +}if (evt == null || evt.getSource () === this.vscroll) { +var offy = this.vscroll.getValue (); +if (this.av.getWrapAlignment ()) { +var rowSize = this.seqPanel.seqCanvas.getWrappedCanvasWidth (this.seqPanel.seqCanvas.getSize ().width); +this.av.setStartRes (this.vscroll.getValue () * rowSize); +this.av.setEndRes ((this.vscroll.getValue () + 1) * rowSize); +} else { +this.av.setStartSeq (offy); +this.av.setEndSeq (offy + Clazz.doubleToInt (this.seqPanel.seqCanvas.getSize ().height / this.av.getCharHeight ())); +}}if (this.overviewPanel != null) { +this.overviewPanel.setBoxPosition (); +}var scrollX = this.av.startRes - oldX; +var scrollY = this.av.startSeq - oldY; +if (this.av.getWrapAlignment () || !this.fastPaint || this.av.MAC) { +this.repaint (); +} else { +if (scrollX > this.av.endRes - this.av.startRes) { +scrollX = this.av.endRes - this.av.startRes; +} else if (scrollX < this.av.startRes - this.av.endRes) { +scrollX = this.av.startRes - this.av.endRes; +}this.idPanel.idCanvas.fastPaint (scrollY); +this.seqPanel.seqCanvas.fastPaint (scrollX, scrollY); +this.scalePanel.repaint (); +if (this.av.isShowAnnotation ()) { +this.annotationPanel.fastPaint (this.av.getStartRes () - oldX); +}}this.sendViewPosition (); +if (this.isFollowingComplementScroll ()) { +this.setFollowingComplementScroll (false); +} else { +var ap = this.getComplementPanel (); +this.av.scrollComplementaryAlignment (ap); +}}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "getComplementPanel", +($fz = function () { +var ap = null; +if (this.alignFrame != null) { +var sf = this.alignFrame.getSplitFrame (); +if (sf != null) { +var other = sf.getComplement (this.alignFrame); +if (other != null) { +ap = other.alignPanel; +}}}return ap; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "scrollToCentre", +function (sr, seqOffset) { +var mappedTo = sr.getResultSequence (0); +var seqs = this.av.getAlignment ().getSequences (); +var sequenceIndex = 0; +var matched = false; +for (var seq, $seq = seqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +if (mappedTo === seq.getDatasetSequence ()) { +matched = true; +break; +}sequenceIndex++; +} +if (!matched) { +return; +}sequenceIndex = Math.max (0, sequenceIndex - seqOffset); +sr.getResults ().get (0).setSequence (this.av.getAlignment ().getSequenceAt (sequenceIndex)); +this.setFollowingComplementScroll (true); +this.scrollToPosition (sr, true, true); +}, "jalview.datamodel.SearchResults,~N"); +Clazz.defineMethod (c$, "sendViewPosition", +($fz = function () { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet).sendViewPosition (this, this.av.startRes, this.av.endRes, this.av.startSeq, this.av.endSeq); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "paintAlignment", +function (updateOverview) { +var sorter = new jalview.analysis.AnnotationSorter (this.getAlignment (), this.av.isShowAutocalculatedAbove ()); +sorter.sort (this.getAlignment ().getAlignmentAnnotation (), this.av.getSortAnnotationsBy ()); +this.repaint (); +if (updateOverview) { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet).sequenceColoursChanged (this); +if (this.overviewPanel != null) { +this.overviewPanel.updateOverviewImage (); +}}}, "~B"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +System.out.println ("alignframe paintcomp"); +this.invalidate (); +var d = this.idPanel.idCanvas.getSize (); +var canvasHeight = this.seqPanel.seqCanvas.getSize ().height; +if (canvasHeight != d.height) { +this.idPanel.idCanvas.setSize (d.width, canvasHeight); +}if (this.av.getWrapAlignment ()) { +var maxwidth = this.av.getAlignment ().getWidth (); +if (this.av.hasHiddenColumns ()) { +maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; +}var canvasWidth = this.seqPanel.seqCanvas.getWrappedCanvasWidth (this.seqPanel.seqCanvas.getSize ().width); +if (canvasWidth > 0) { +var max = Clazz.doubleToInt (maxwidth / canvasWidth); +this.vscroll.setMaximum (1 + max); +this.vscroll.setUnitIncrement (1); +this.vscroll.setVisibleAmount (1); +}} else { +this.setScrollValues (this.av.getStartRes (), this.av.getStartSeq ()); +}}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout ( new java.awt.BorderLayout ()); +this.sequenceHolderPanel.setLayout ( new java.awt.BorderLayout ()); +this.seqPanelHolder.setLayout ( new java.awt.BorderLayout ()); +this.scalePanelHolder.setBackground (java.awt.Color.white); +this.scalePanelHolder.setLayout ( new java.awt.BorderLayout ()); +this.idPanelHolder.setLayout ( new java.awt.BorderLayout ()); +this.idSpaceFillerPanel1.setBackground (java.awt.Color.white); +this.idSpaceFillerPanel1.setLayout ( new java.awt.BorderLayout ()); +this.annotationSpaceFillerHolder.setBackground (java.awt.Color.white); +this.annotationSpaceFillerHolder.setLayout ( new java.awt.BorderLayout ()); +this.hscroll.setOrientation (0); +var hscrollHolder = new awt2swing.Panel (); +hscrollHolder.setLayout ( new java.awt.BorderLayout ()); +this.hscrollFillerPanel.setBackground (java.awt.Color.white); +this.apvscroll.setOrientation (1); +this.apvscroll.setVisible (true); +this.apvscroll.addAdjustmentListener (this); +this.annotationPanelHolder.setBackground (java.awt.Color.white); +this.annotationPanelHolder.setLayout ( new java.awt.BorderLayout ()); +this.annotationPanelHolder.add (this.apvscroll, "East"); +hscrollHolder.setBackground (java.awt.Color.white); +this.seqPanelHolder.setBackground (java.awt.Color.white); +this.idPanelHolder.setBackground (java.awt.Color.white); +this.sequenceHolderPanel.add (this.scalePanelHolder, "North"); +this.sequenceHolderPanel.add (this.seqPanelHolder, "Center"); +this.seqPanelHolder.add (this.vscroll, "East"); +this.add (this.idPanelHolder, "West"); +this.idPanelHolder.add (this.idSpaceFillerPanel1, "North"); +this.idPanelHolder.add (this.annotationSpaceFillerHolder, "South"); +this.add (hscrollHolder, "South"); +hscrollHolder.add (this.hscroll, "Center"); +hscrollHolder.add (this.hscrollFillerPanel, "West"); +this.add (this.sequenceHolderPanel, "Center"); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "updateAnnotation", +function () { +this.updateAnnotation (false); +}); +Clazz.defineMethod (c$, "updateAnnotation", +function (applyGlobalSettings) { +this.updateAnnotation (applyGlobalSettings, false); +}, "~B"); +Clazz.defineMethod (c$, "updateAnnotation", +function (applyGlobalSettings, preserveNewGroupSettings) { +this.av.updateGroupAnnotationSettings (applyGlobalSettings, preserveNewGroupSettings); +this.adjustAnnotationHeight (); +}, "~B,~B"); +Clazz.overrideMethod (c$, "getAlignment", +function () { +return this.av.getAlignment (); +}); +Clazz.overrideMethod (c$, "getViewName", +function () { +return this.getName (); +}); +Clazz.overrideMethod (c$, "getStructureSelectionManager", +function () { +return jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet); +}); +Clazz.overrideMethod (c$, "raiseOOMWarning", +function (string, error) { +System.err.println ("Out of memory whilst '" + string + "'"); +error.printStackTrace (); +}, "~S,OutOfMemoryError"); +Clazz.defineMethod (c$, "setFollowingComplementScroll", +function (b) { +this.followingComplementScroll = b; +}, "~B"); +Clazz.defineMethod (c$, "isFollowingComplementScroll", +function () { +return this.followingComplementScroll; +}); +c$.$AlignmentPanel$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignmentPanel$1", java.awt.event.ComponentAdapter); +Clazz.overrideMethod (c$, "componentResized", +function (evt) { +this.b$["jalview.appletgui.AlignmentPanel"].setScrollValues (this.f$.av.getStartRes (), this.f$.av.getStartSeq ()); +if (this.b$["jalview.appletgui.AlignmentPanel"].getSize ().height > 0 && this.b$["jalview.appletgui.AlignmentPanel"].annotationPanelHolder.getSize ().height > 0) { +this.b$["jalview.appletgui.AlignmentPanel"].validateAnnotationDimensions (false); +}this.b$["jalview.appletgui.AlignmentPanel"].repaint (); +}, "java.awt.event.ComponentEvent"); +c$ = Clazz.p0p (); +}; +c$.$AlignmentPanel$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AlignmentPanel$2", null, java.beans.PropertyChangeListener); +Clazz.overrideMethod (c$, "propertyChange", +function (evt) { +if (evt.getPropertyName ().equals ("alignment")) { +jalview.appletgui.PaintRefresher.Refresh (this.f$.ap, this.f$.av.getSequenceSetId (), true, true); +this.b$["jalview.appletgui.AlignmentPanel"].alignmentChanged (); +}}, "java.beans.PropertyChangeEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/AnnotationColourChooser.js b/bin/jalview/appletgui/AnnotationColourChooser.js index 668d9cd..fce2267 100644 --- a/bin/jalview/appletgui/AnnotationColourChooser.js +++ b/bin/jalview/appletgui/AnnotationColourChooser.js @@ -1,348 +1,348 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.AnnotationColourChooser", ["awt2swing.Frame", "jalview.appletgui.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.datamodel.GraphLine", "jalview.schemes.AnnotationColourGradient", "$.ColourSchemeI", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.Font", "java.lang.Error", "$.Float", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.frame = null; -this.av = null; -this.ap = null; -this.oldcs = null; -this.oldgroupColours = null; -this.currentAnnotation = null; -this.adjusting = false; -this.annotations = null; -this.minColour = null; -this.maxColour = null; -this.ok = null; -this.cancel = null; -this.defColours = null; -this.jPanel1 = null; -this.jPanel2 = null; -this.threshold = null; -this.flowLayout1 = null; -this.jPanel3 = null; -this.slider = null; -this.thresholdValue = null; -this.currentColours = null; -this.borderLayout1 = null; -this.thresholdIsMin = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); -Clazz.prepareFields (c$, function () { -this.annotations = new awt2swing.Choice (); -this.minColour = new awt2swing.Button (); -this.maxColour = new awt2swing.Button (); -this.ok = new awt2swing.Button (); -this.cancel = new awt2swing.Button (); -this.defColours = new awt2swing.Button (); -this.jPanel1 = new awt2swing.Panel (); -this.jPanel2 = new awt2swing.Panel (); -this.threshold = new awt2swing.Choice (); -this.flowLayout1 = new java.awt.FlowLayout (); -this.jPanel3 = new awt2swing.Panel (); -this.slider = new awt2swing.Scrollbar (0); -this.thresholdValue = new awt2swing.TextField (20); -this.currentColours = new awt2swing.Checkbox (); -this.borderLayout1 = new java.awt.BorderLayout (); -this.thresholdIsMin = new awt2swing.Checkbox (); -}); -Clazz.makeConstructor (c$, -function (av, ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -this.oldcs = av.getGlobalColourScheme (); -if (av.getAlignment ().getGroups () != null) { -this.oldgroupColours = new java.util.Hashtable (); -for (var sg, $sg = ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs != null) { -this.oldgroupColours.put (sg, sg.cs); -} else { -this.oldgroupColours.put (sg, "null"); -}} -}this.av = av; -this.ap = ap; -this.slider.addAdjustmentListener (this); -this.slider.addMouseListener (this); -if (av.getAlignment ().getAlignmentAnnotation () == null) { -return; -}this.setDefaultMinMax (); -this.adjusting = true; -if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { -var acg = this.oldcs; -this.currentColours.setState (acg.isPredefinedColours () || acg.getBaseColour () != null); -if (!acg.isPredefinedColours () && acg.getBaseColour () == null) { -this.minColour.setBackground (acg.getMinColour ()); -this.maxColour.setBackground (acg.getMaxColour ()); -}}var list = new java.util.Vector (); -var index = 1; -for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { -var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; -if (!list.contains (label)) { -list.addElement (label); -} else { -list.addElement (label + "_" + (index++)); -}} -for (var i = 0; i < list.size (); i++) { -this.annotations.addItem (list.elementAt (i).toString ()); -} -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); -if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { -var acg = this.oldcs; -this.annotations.select (acg.getAnnotation ()); -switch (acg.getAboveThreshold ()) { -case -1: -this.threshold.select (new Integer (0)); -break; -case 1: -this.threshold.select (new Integer (1)); -break; -case 0: -this.threshold.select (new Integer (1)); -break; -default: -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_dont_know_thereshold_annotationcolourgradient")); -} -this.thresholdIsMin.setState (acg.thresholdIsMinMax); -this.thresholdValue.setText ("" + acg.getAnnotationThreshold ()); -}this.adjusting = false; -this.changeColour (); -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.colour_by_annotation"), 560, 175); -this.validate (); -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "setDefaultMinMax", -($fz = function () { -this.minColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MIN", java.awt.Color.orange)); -this.maxColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MAX", java.awt.Color.red)); -}, $fz.isPrivate = true, $fz)); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.minColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.minColour.setLabel (jalview.util.MessageManager.getString ("label.min_colour")); -this.minColour.addActionListener (this); -this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.maxColour.setLabel (jalview.util.MessageManager.getString ("label.max_colour")); -this.maxColour.addActionListener (this); -this.thresholdIsMin.addItemListener (this); -this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); -this.ok.addActionListener (this); -this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); -this.cancel.addActionListener (this); -this.defColours.setLabel (jalview.util.MessageManager.getString ("action.set_defaults")); -this.defColours.addActionListener (this); -this.annotations.addItemListener (this); -this.thresholdValue.addActionListener (this); -this.slider.setBackground (java.awt.Color.white); -this.slider.setPreferredSize ( new java.awt.Dimension (193, 21)); -this.slider.setEnabled (false); -this.thresholdValue.setPreferredSize ( new java.awt.Dimension (79, 22)); -this.thresholdValue.setEnabled (false); -this.thresholdValue.setColumns (5); -this.currentColours.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.currentColours.setLabel (jalview.util.MessageManager.getString ("label.use_original_colours")); -this.currentColours.addItemListener (this); -this.thresholdIsMin.setBackground (java.awt.Color.white); -this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax")); -this.setLayout (this.borderLayout1); -this.jPanel1.setBackground (java.awt.Color.white); -this.jPanel2.setLayout ( new java.awt.FlowLayout ()); -this.jPanel2.setBackground (java.awt.Color.white); -this.threshold.addItemListener (this); -this.jPanel3.setLayout ( new java.awt.FlowLayout ()); -this.jPanel3.setBackground (java.awt.Color.white); -var jPanel4 = new awt2swing.Panel (); -jPanel4.setLayout ( new java.awt.BorderLayout ()); -jPanel4.setBackground (java.awt.Color.white); -this.jPanel1.add (this.ok); -this.jPanel1.add (this.cancel); -this.jPanel2.add (this.annotations); -this.jPanel2.add (this.currentColours); -this.jPanel2.add (this.minColour); -this.jPanel2.add (this.maxColour); -jPanel4.add (this.thresholdIsMin, "West"); -jPanel4.add (this.slider, "Center"); -jPanel4.add (this.thresholdValue, "East"); -var jPanel34 = new awt2swing.Panel (); -jPanel34.setLayout ( new java.awt.BorderLayout ()); -jPanel34.setBackground (java.awt.Color.white); -jPanel34.add (this.jPanel2, "North"); -jPanel34.add (this.threshold, "West"); -this.jPanel3.add (this.defColours); -jPanel34.add (this.jPanel3, "East"); -jPanel34.add (jPanel4, "South"); -this.add (jPanel34, "Center"); -this.add (this.jPanel1, "South"); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.thresholdValue) { -try { -var f = new Float (this.thresholdValue.getText ()).floatValue (); -this.slider.setValue (Clazz.floatToInt (f * 1000)); -this.adjustmentValueChanged (null); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -} else if (evt.getSource () === this.minColour) { -this.minColour_actionPerformed (null); -} else if (evt.getSource () === this.maxColour) { -this.maxColour_actionPerformed (null); -} else if (evt.getSource () === this.defColours) { -this.defColour_actionPerformed (); -} else if (evt.getSource () === this.ok) { -this.changeColour (); -this.frame.setVisible (false); -} else if (evt.getSource () === this.cancel) { -this.reset (); -this.ap.paintAlignment (true); -this.frame.setVisible (false); -} else { -this.changeColour (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -if (evt.getSource () === this.currentColours) { -if (this.currentColours.getState ()) { -this.reset (); -}this.maxColour.setEnabled (!this.currentColours.getState ()); -this.minColour.setEnabled (!this.currentColours.getState ()); -}this.changeColour (); -}, "java.awt.event.ItemEvent"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -if (!this.adjusting) { -this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); -if (this.currentColours.getState () && !(Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.AnnotationColourGradient))) { -this.changeColour (); -}this.currentAnnotation.threshold.value = this.slider.getValue () / 1000; -this.ap.paintAlignment (false); -}}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "minColour_actionPerformed", -function (newCol) { -if (newCol != null) { -this.minColour.setBackground (newCol); -this.minColour.repaint (); -this.changeColour (); -} else { - new jalview.appletgui.UserDefinedColours (this, "Min Colour", this.minColour.getBackground ()); -}}, "java.awt.Color"); -Clazz.defineMethod (c$, "maxColour_actionPerformed", -function (newCol) { -if (newCol != null) { -this.maxColour.setBackground (newCol); -this.maxColour.repaint (); -this.changeColour (); -} else { - new jalview.appletgui.UserDefinedColours (this, "Max Colour", this.maxColour.getBackground ()); -}}, "java.awt.Color"); -Clazz.defineMethod (c$, "defColour_actionPerformed", -function () { -this.setDefaultMinMax (); -this.minColour.repaint (); -this.maxColour.repaint (); -this.changeColour (); -}); -Clazz.defineMethod (c$, "changeColour", -function () { -if (this.adjusting) { -return; -}this.currentAnnotation = this.av.getAlignment ().getAlignmentAnnotation ()[this.annotations.getSelectedIndex ()]; -var aboveThreshold = -1; -if (this.threshold.getSelectedIndex () == 1) { -aboveThreshold = 1; -} else if (this.threshold.getSelectedIndex () == 2) { -aboveThreshold = 0; -}this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -this.thresholdIsMin.setEnabled (true); -if (aboveThreshold == -1) { -this.slider.setEnabled (false); -this.thresholdValue.setEnabled (false); -this.thresholdIsMin.setEnabled (false); -this.thresholdValue.setText (""); -} else if (aboveThreshold != -1 && this.currentAnnotation.threshold == null) { -this.currentAnnotation.setThreshold ( new jalview.datamodel.GraphLine ((this.currentAnnotation.graphMax - this.currentAnnotation.graphMin) / 2, "Threshold", java.awt.Color.black)); -}if (aboveThreshold != -1) { -this.adjusting = true; -this.slider.setMinimum (Clazz.floatToInt (this.currentAnnotation.graphMin * 1000)); -this.slider.setMaximum (Clazz.floatToInt (this.currentAnnotation.graphMax * 1000)); -this.slider.setValue (Clazz.floatToInt (this.currentAnnotation.threshold.value * 1000)); -this.thresholdValue.setText (this.currentAnnotation.threshold.value + ""); -this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -this.adjusting = false; -}var acg = null; -if (this.currentColours.getState ()) { -acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.av.getGlobalColourScheme (), aboveThreshold); -} else { -acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); -}if (this.currentAnnotation.graphMin == 0 && this.currentAnnotation.graphMax == 0) { -acg.setPredefinedColours (true); -}acg.thresholdIsMinMax = this.thresholdIsMin.getState (); -this.av.setGlobalColourScheme (acg); -if (this.av.getAlignment ().getGroups () != null) { -for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs == null) { -continue; -}if (this.currentColours.getState ()) { -sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, sg.cs, aboveThreshold); -} else { -sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); -}} -}this.ap.alignmentChanged (); -this.ap.paintAlignment (true); -}); -Clazz.defineMethod (c$, "reset", -function () { -this.av.setGlobalColourScheme (this.oldcs); -if (this.av.getAlignment ().getGroups () != null) { -for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -var cs = this.oldgroupColours.get (sg); -if (Clazz.instanceOf (cs, jalview.schemes.ColourSchemeI)) { -sg.cs = cs; -} else { -sg.cs = null; -}} -}this.ap.paintAlignment (true); -}); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.ap.paintAlignment (true); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.AnnotationColourChooser", ["awt2swing.Frame", "jalview.appletgui.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.datamodel.GraphLine", "jalview.schemes.AnnotationColourGradient", "$.ColourSchemeI", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.Font", "java.lang.Error", "$.Float", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.frame = null; +this.av = null; +this.ap = null; +this.oldcs = null; +this.oldgroupColours = null; +this.currentAnnotation = null; +this.adjusting = false; +this.annotations = null; +this.minColour = null; +this.maxColour = null; +this.ok = null; +this.cancel = null; +this.defColours = null; +this.jPanel1 = null; +this.jPanel2 = null; +this.threshold = null; +this.flowLayout1 = null; +this.jPanel3 = null; +this.slider = null; +this.thresholdValue = null; +this.currentColours = null; +this.borderLayout1 = null; +this.thresholdIsMin = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); +Clazz.prepareFields (c$, function () { +this.annotations = new awt2swing.Choice (); +this.minColour = new awt2swing.Button (); +this.maxColour = new awt2swing.Button (); +this.ok = new awt2swing.Button (); +this.cancel = new awt2swing.Button (); +this.defColours = new awt2swing.Button (); +this.jPanel1 = new awt2swing.Panel (); +this.jPanel2 = new awt2swing.Panel (); +this.threshold = new awt2swing.Choice (); +this.flowLayout1 = new java.awt.FlowLayout (); +this.jPanel3 = new awt2swing.Panel (); +this.slider = new awt2swing.Scrollbar (0); +this.thresholdValue = new awt2swing.TextField (20); +this.currentColours = new awt2swing.Checkbox (); +this.borderLayout1 = new java.awt.BorderLayout (); +this.thresholdIsMin = new awt2swing.Checkbox (); +}); +Clazz.makeConstructor (c$, +function (av, ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +this.oldcs = av.getGlobalColourScheme (); +if (av.getAlignment ().getGroups () != null) { +this.oldgroupColours = new java.util.Hashtable (); +for (var sg, $sg = ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs != null) { +this.oldgroupColours.put (sg, sg.cs); +} else { +this.oldgroupColours.put (sg, "null"); +}} +}this.av = av; +this.ap = ap; +this.slider.addAdjustmentListener (this); +this.slider.addMouseListener (this); +if (av.getAlignment ().getAlignmentAnnotation () == null) { +return; +}this.setDefaultMinMax (); +this.adjusting = true; +if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { +var acg = this.oldcs; +this.currentColours.setState (acg.isPredefinedColours () || acg.getBaseColour () != null); +if (!acg.isPredefinedColours () && acg.getBaseColour () == null) { +this.minColour.setBackground (acg.getMinColour ()); +this.maxColour.setBackground (acg.getMaxColour ()); +}}var list = new java.util.Vector (); +var index = 1; +for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { +var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; +if (!list.contains (label)) { +list.addElement (label); +} else { +list.addElement (label + "_" + (index++)); +}} +for (var i = 0; i < list.size (); i++) { +this.annotations.addItem (list.elementAt (i).toString ()); +} +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); +if (Clazz.instanceOf (this.oldcs, jalview.schemes.AnnotationColourGradient)) { +var acg = this.oldcs; +this.annotations.select (acg.getAnnotation ()); +switch (acg.getAboveThreshold ()) { +case -1: +this.threshold.select (new Integer (0)); +break; +case 1: +this.threshold.select (new Integer (1)); +break; +case 0: +this.threshold.select (new Integer (1)); +break; +default: +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_dont_know_thereshold_annotationcolourgradient")); +} +this.thresholdIsMin.setState (acg.thresholdIsMinMax); +this.thresholdValue.setText ("" + acg.getAnnotationThreshold ()); +}this.adjusting = false; +this.changeColour (); +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.colour_by_annotation"), 560, 175); +this.validate (); +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "setDefaultMinMax", +($fz = function () { +this.minColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MIN", java.awt.Color.orange)); +this.maxColour.setBackground (this.av.applet.getDefaultColourParameter ("ANNOTATIONCOLOUR_MAX", java.awt.Color.red)); +}, $fz.isPrivate = true, $fz)); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColourChooser, []); +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.minColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.minColour.setLabel (jalview.util.MessageManager.getString ("label.min_colour")); +this.minColour.addActionListener (this); +this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.maxColour.setLabel (jalview.util.MessageManager.getString ("label.max_colour")); +this.maxColour.addActionListener (this); +this.thresholdIsMin.addItemListener (this); +this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); +this.ok.addActionListener (this); +this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); +this.cancel.addActionListener (this); +this.defColours.setLabel (jalview.util.MessageManager.getString ("action.set_defaults")); +this.defColours.addActionListener (this); +this.annotations.addItemListener (this); +this.thresholdValue.addActionListener (this); +this.slider.setBackground (java.awt.Color.white); +this.slider.setPreferredSize ( new java.awt.Dimension (193, 21)); +this.slider.setEnabled (false); +this.thresholdValue.setPreferredSize ( new java.awt.Dimension (79, 22)); +this.thresholdValue.setEnabled (false); +this.thresholdValue.setColumns (5); +this.currentColours.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.currentColours.setLabel (jalview.util.MessageManager.getString ("label.use_original_colours")); +this.currentColours.addItemListener (this); +this.thresholdIsMin.setBackground (java.awt.Color.white); +this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax")); +this.setLayout (this.borderLayout1); +this.jPanel1.setBackground (java.awt.Color.white); +this.jPanel2.setLayout ( new java.awt.FlowLayout ()); +this.jPanel2.setBackground (java.awt.Color.white); +this.threshold.addItemListener (this); +this.jPanel3.setLayout ( new java.awt.FlowLayout ()); +this.jPanel3.setBackground (java.awt.Color.white); +var jPanel4 = new awt2swing.Panel (); +jPanel4.setLayout ( new java.awt.BorderLayout ()); +jPanel4.setBackground (java.awt.Color.white); +this.jPanel1.add (this.ok); +this.jPanel1.add (this.cancel); +this.jPanel2.add (this.annotations); +this.jPanel2.add (this.currentColours); +this.jPanel2.add (this.minColour); +this.jPanel2.add (this.maxColour); +jPanel4.add (this.thresholdIsMin, "West"); +jPanel4.add (this.slider, "Center"); +jPanel4.add (this.thresholdValue, "East"); +var jPanel34 = new awt2swing.Panel (); +jPanel34.setLayout ( new java.awt.BorderLayout ()); +jPanel34.setBackground (java.awt.Color.white); +jPanel34.add (this.jPanel2, "North"); +jPanel34.add (this.threshold, "West"); +this.jPanel3.add (this.defColours); +jPanel34.add (this.jPanel3, "East"); +jPanel34.add (jPanel4, "South"); +this.add (jPanel34, "Center"); +this.add (this.jPanel1, "South"); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.thresholdValue) { +try { +var f = new Float (this.thresholdValue.getText ()).floatValue (); +this.slider.setValue (Clazz.floatToInt (f * 1000)); +this.adjustmentValueChanged (null); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +} else if (evt.getSource () === this.minColour) { +this.minColour_actionPerformed (null); +} else if (evt.getSource () === this.maxColour) { +this.maxColour_actionPerformed (null); +} else if (evt.getSource () === this.defColours) { +this.defColour_actionPerformed (); +} else if (evt.getSource () === this.ok) { +this.changeColour (); +this.frame.setVisible (false); +} else if (evt.getSource () === this.cancel) { +this.reset (); +this.ap.paintAlignment (true); +this.frame.setVisible (false); +} else { +this.changeColour (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +if (evt.getSource () === this.currentColours) { +if (this.currentColours.getState ()) { +this.reset (); +}this.maxColour.setEnabled (!this.currentColours.getState ()); +this.minColour.setEnabled (!this.currentColours.getState ()); +}this.changeColour (); +}, "java.awt.event.ItemEvent"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +if (!this.adjusting) { +this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); +if (this.currentColours.getState () && !(Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.AnnotationColourGradient))) { +this.changeColour (); +}this.currentAnnotation.threshold.value = this.slider.getValue () / 1000; +this.ap.paintAlignment (false); +}}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "minColour_actionPerformed", +function (newCol) { +if (newCol != null) { +this.minColour.setBackground (newCol); +this.minColour.repaint (); +this.changeColour (); +} else { + new jalview.appletgui.UserDefinedColours (this, "Min Colour", this.minColour.getBackground ()); +}}, "java.awt.Color"); +Clazz.defineMethod (c$, "maxColour_actionPerformed", +function (newCol) { +if (newCol != null) { +this.maxColour.setBackground (newCol); +this.maxColour.repaint (); +this.changeColour (); +} else { + new jalview.appletgui.UserDefinedColours (this, "Max Colour", this.maxColour.getBackground ()); +}}, "java.awt.Color"); +Clazz.defineMethod (c$, "defColour_actionPerformed", +function () { +this.setDefaultMinMax (); +this.minColour.repaint (); +this.maxColour.repaint (); +this.changeColour (); +}); +Clazz.defineMethod (c$, "changeColour", +function () { +if (this.adjusting) { +return; +}this.currentAnnotation = this.av.getAlignment ().getAlignmentAnnotation ()[this.annotations.getSelectedIndex ()]; +var aboveThreshold = -1; +if (this.threshold.getSelectedIndex () == 1) { +aboveThreshold = 1; +} else if (this.threshold.getSelectedIndex () == 2) { +aboveThreshold = 0; +}this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +this.thresholdIsMin.setEnabled (true); +if (aboveThreshold == -1) { +this.slider.setEnabled (false); +this.thresholdValue.setEnabled (false); +this.thresholdIsMin.setEnabled (false); +this.thresholdValue.setText (""); +} else if (aboveThreshold != -1 && this.currentAnnotation.threshold == null) { +this.currentAnnotation.setThreshold ( new jalview.datamodel.GraphLine ((this.currentAnnotation.graphMax - this.currentAnnotation.graphMin) / 2, "Threshold", java.awt.Color.black)); +}if (aboveThreshold != -1) { +this.adjusting = true; +this.slider.setMinimum (Clazz.floatToInt (this.currentAnnotation.graphMin * 1000)); +this.slider.setMaximum (Clazz.floatToInt (this.currentAnnotation.graphMax * 1000)); +this.slider.setValue (Clazz.floatToInt (this.currentAnnotation.threshold.value * 1000)); +this.thresholdValue.setText (this.currentAnnotation.threshold.value + ""); +this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +this.adjusting = false; +}var acg = null; +if (this.currentColours.getState ()) { +acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.av.getGlobalColourScheme (), aboveThreshold); +} else { +acg = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); +}if (this.currentAnnotation.graphMin == 0 && this.currentAnnotation.graphMax == 0) { +acg.setPredefinedColours (true); +}acg.thresholdIsMinMax = this.thresholdIsMin.getState (); +this.av.setGlobalColourScheme (acg); +if (this.av.getAlignment ().getGroups () != null) { +for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs == null) { +continue; +}if (this.currentColours.getState ()) { +sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, sg.cs, aboveThreshold); +} else { +sg.cs = new jalview.schemes.AnnotationColourGradient (this.currentAnnotation, this.minColour.getBackground (), this.maxColour.getBackground (), aboveThreshold); +}} +}this.ap.alignmentChanged (); +this.ap.paintAlignment (true); +}); +Clazz.defineMethod (c$, "reset", +function () { +this.av.setGlobalColourScheme (this.oldcs); +if (this.av.getAlignment ().getGroups () != null) { +for (var sg, $sg = this.ap.av.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +var cs = this.oldgroupColours.get (sg); +if (Clazz.instanceOf (cs, jalview.schemes.ColourSchemeI)) { +sg.cs = cs; +} else { +sg.cs = null; +}} +}this.ap.paintAlignment (true); +}); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.ap.paintAlignment (true); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +}); diff --git a/bin/jalview/appletgui/AnnotationColumnChooser.js b/bin/jalview/appletgui/AnnotationColumnChooser.js index 340a161..f50bb0c 100644 --- a/bin/jalview/appletgui/AnnotationColumnChooser.js +++ b/bin/jalview/appletgui/AnnotationColumnChooser.js @@ -1,622 +1,622 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.appletgui.AnnotationRowFilter", "$.TitledPanel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Checkbox", "$.Choice", "$.TextField", "java.awt.BorderLayout", "$.CardLayout"], "jalview.appletgui.AnnotationColumnChooser", ["awt2swing.Frame", "jalview.bin.JalviewLite", "jalview.datamodel.ColumnSelection", "$.GraphLine", "jalview.util.MessageManager", "jalview.viewmodel.annotationfilter.AnnotationFilterParameter", "java.awt.Color", "$.Dimension", "java.awt.event.MouseAdapter", "$.TextListener", "java.lang.Float", "java.util.Vector", "javax.swing.JPanel"], function () { -c$ = Clazz.decorateAsClass (function () { -this.annotations = null; -this.actionPanel = null; -this.thresholdPanel = null; -this.switchableViewsPanel = null; -this.switchableViewsLayout = null; -this.noGraphFilterView = null; -this.graphFilterView = null; -this.annotationComboBoxPanel = null; -this.borderLayout1 = null; -this.gBorderLayout = null; -this.ngBorderLayout = null; -this.threshold = null; -this.gStructureFilterPanel = null; -this.ngStructureFilterPanel = null; -this.currentStructureFilterPanel = null; -this.currentSearchPanel = null; -this.gSearchPanel = null; -this.ngSearchPanel = null; -this.currentFurtherActionPanel = null; -this.gFurtherActionPanel = null; -this.ngFurtherActionPanel = null; -this.actionOption = 1; -this.oldColumnSelection = null; -if (!Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel")) { -jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$FurtherActionPanel$ (); -} -if (!Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel")) { -jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$StructureFilterPanel$ (); -} -if (!Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser.SearchPanel")) { -jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$SearchPanel$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationColumnChooser", jalview.appletgui.AnnotationRowFilter, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); -Clazz.prepareFields (c$, function () { -this.annotations = new awt2swing.Choice (); -this.actionPanel = new awt2swing.Panel (); -this.thresholdPanel = new jalview.appletgui.TitledPanel (); -this.switchableViewsPanel = new awt2swing.Panel ( new java.awt.CardLayout ()); -this.switchableViewsLayout = (this.switchableViewsPanel.getLayout ()); -this.noGraphFilterView = new awt2swing.Panel (); -this.graphFilterView = new awt2swing.Panel (); -this.annotationComboBoxPanel = new awt2swing.Panel (); -this.borderLayout1 = new java.awt.BorderLayout (); -this.gBorderLayout = new java.awt.BorderLayout (); -this.ngBorderLayout = new java.awt.BorderLayout (); -this.threshold = new awt2swing.Choice (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser, []); -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -Clazz.makeConstructor (c$, -function (av, ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser, [av, ap]); -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.select_by_annotation"), 520, 215); -this.slider.addAdjustmentListener (this); -this.slider.addMouseListener (this); -if (av.getAlignment ().getAlignmentAnnotation () == null) { -return; -}this.setOldColumnSelection (av.getColumnSelection ()); -this.adjusting = true; -var list = new java.util.Vector (); -var index = 1; -for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { -var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; -if (!list.contains (label)) { -list.addElement (label); -} else { -list.addElement (label + "_" + (index++)); -}} -for (var i = 0; i < list.size (); i++) { -this.annotations.addItem (list.elementAt (i).toString ()); -} -this.populateThresholdComboBox (this.threshold); -if (av.getAnnotationColumnSelectionState () != null) { -this.currentSearchPanel = av.getAnnotationColumnSelectionState ().getCurrentSearchPanel (); -this.currentStructureFilterPanel = av.getAnnotationColumnSelectionState ().getCurrentStructureFilterPanel (); -this.annotations.select (new Integer (av.getAnnotationColumnSelectionState ().getAnnotations ().getSelectedIndex ())); -this.threshold.select (new Integer (av.getAnnotationColumnSelectionState ().getThreshold ().getSelectedIndex ())); -this.actionOption = av.getAnnotationColumnSelectionState ().getActionOption (); -}try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -this.adjusting = false; -this.updateView (); -this.frame.invalidate (); -this.frame.pack (); -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); -this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); -this.thresholdValue.setEnabled (false); -this.thresholdValue.setColumns (7); -this.ok.addActionListener (this); -this.cancel.addActionListener (this); -this.annotations.addItemListener (this); -this.thresholdValue.addActionListener (this); -this.threshold.addItemListener (this); -this.slider.setBackground (java.awt.Color.white); -this.slider.setEnabled (false); -this.slider.setPreferredSize ( new java.awt.Dimension (100, 32)); -this.thresholdPanel.setBackground (java.awt.Color.white); -this.actionPanel.setBackground (java.awt.Color.white); -this.graphFilterView.setLayout (this.gBorderLayout); -this.graphFilterView.setBackground (java.awt.Color.white); -this.noGraphFilterView.setLayout (this.ngBorderLayout); -this.noGraphFilterView.setBackground (java.awt.Color.white); -this.annotationComboBoxPanel.setBackground (java.awt.Color.white); -this.gSearchPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.SearchPanel, this, null, this); -this.ngSearchPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.SearchPanel, this, null, this); -this.gFurtherActionPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel, this, null, this); -this.ngFurtherActionPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel, this, null, this); -this.gStructureFilterPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel, this, null, this); -this.ngStructureFilterPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel, this, null, this); -this.thresholdPanel.setTitle ("Threshold Filter"); -this.thresholdPanel.add (this.getThreshold ()); -this.thresholdPanel.add (this.slider); -this.thresholdPanel.add (this.thresholdValue); -this.actionPanel.add (this.ok); -this.actionPanel.add (this.cancel); -var staticPanel = new javax.swing.JPanel (); -staticPanel.setLayout ( new java.awt.BorderLayout ()); -staticPanel.setBackground (java.awt.Color.white); -staticPanel.add (this.gSearchPanel, "North"); -staticPanel.add (this.gStructureFilterPanel, "South"); -this.graphFilterView.add (staticPanel, "North"); -this.graphFilterView.add (this.thresholdPanel, "Center"); -this.graphFilterView.add (this.gFurtherActionPanel, "South"); -this.noGraphFilterView.add (this.ngSearchPanel, "First"); -this.noGraphFilterView.add (this.ngStructureFilterPanel, "Center"); -this.noGraphFilterView.add (this.ngFurtherActionPanel, "Center"); -this.annotationComboBoxPanel.add (this.getAnnotations ()); -this.switchableViewsPanel.add (this.noGraphFilterView, jalview.appletgui.AnnotationColumnChooser.NO_GRAPH_VIEW); -this.switchableViewsPanel.add (this.graphFilterView, jalview.appletgui.AnnotationColumnChooser.GRAPH_VIEW); -this.setLayout (this.borderLayout1); -this.add (this.annotationComboBoxPanel, "First"); -this.add (this.switchableViewsPanel, "Center"); -this.add (this.actionPanel, "South"); -this.selectedAnnotationChanged (); -this.validate (); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "reset", -function () { -if (this.getOldColumnSelection () != null) { -this.av.getColumnSelection ().clear (); -if (this.av.getAnnotationColumnSelectionState () != null) { -var oldSelection = this.av.getAnnotationColumnSelectionState ().getOldColumnSelection (); -if (oldSelection != null && oldSelection.getHiddenColumns () != null && !oldSelection.getHiddenColumns ().isEmpty ()) { -for (var itr = oldSelection.getHiddenColumns ().iterator (); itr.hasNext (); ) { -var positions = itr.next (); -this.av.hideColumns (positions[0], positions[1]); -} -}this.av.setColumnSelection (oldSelection); -}this.ap.paintAlignment (true); -}}); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -if (!this.adjusting) { -this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); -this.valueChanged (!this.sliderDragging); -}}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "addSliderMouseListeners", -function () { -this.slider.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser$1") ? 0 : jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser$1, this, null))); -}); -Clazz.overrideMethod (c$, "valueChanged", -function (updateAllAnnotation) { -if (this.slider.isEnabled ()) { -this.getCurrentAnnotation ().threshold.value = this.slider.getValue () / 1000; -this.updateView (); -this.ap.paintAlignment (false); -}}, "~B"); -Clazz.defineMethod (c$, "getThreshold", -function () { -return this.threshold; -}); -Clazz.defineMethod (c$, "setThreshold", -function (threshold) { -this.threshold = threshold; -}, "awt2swing.Choice"); -Clazz.defineMethod (c$, "getAnnotations", -function () { -return this.annotations; -}); -Clazz.defineMethod (c$, "setAnnotations", -function (annotations) { -this.annotations = annotations; -}, "awt2swing.Choice"); -Clazz.overrideMethod (c$, "updateView", -function () { -if (this.adjusting) { -return; -}var filterParams = new jalview.viewmodel.annotationfilter.AnnotationFilterParameter (); -this.setCurrentAnnotation (this.av.getAlignment ().getAlignmentAnnotation ()[this.getAnnotations ().getSelectedIndex ()]); -var selectedThresholdItem = this.getSelectedThresholdItem (this.getThreshold ().getSelectedIndex ()); -this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -if (selectedThresholdItem == -1) { -this.slider.setEnabled (false); -this.thresholdValue.setEnabled (false); -this.thresholdValue.setText (""); -} else if (selectedThresholdItem != -1) { -if (this.getCurrentAnnotation ().threshold == null) { -this.getCurrentAnnotation ().setThreshold ( new jalview.datamodel.GraphLine ((this.getCurrentAnnotation ().graphMax - this.getCurrentAnnotation ().graphMin) / 2, "Threshold", java.awt.Color.black)); -}this.adjusting = true; -var range = this.getCurrentAnnotation ().graphMax * 1000 - this.getCurrentAnnotation ().graphMin * 1000; -this.slider.setMinimum (Clazz.floatToInt (this.getCurrentAnnotation ().graphMin * 1000)); -this.slider.setMaximum (Clazz.floatToInt (this.getCurrentAnnotation ().graphMax * 1000)); -this.slider.setValue (Clazz.floatToInt (this.getCurrentAnnotation ().threshold.value * 1000)); -this.thresholdValue.setText (this.getCurrentAnnotation ().threshold.value + ""); -this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -this.adjusting = false; -filterParams.setThresholdType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); -if (this.getCurrentAnnotation ().graph != 0) { -filterParams.setThresholdValue (this.getCurrentAnnotation ().threshold.value); -if (selectedThresholdItem == 1) { -filterParams.setThresholdType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD); -} else if (selectedThresholdItem == 0) { -filterParams.setThresholdType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD); -}}}if (this.currentStructureFilterPanel != null) { -if (this.currentStructureFilterPanel.alphaHelix.getState ()) { -filterParams.setFilterAlphaHelix (true); -}if (this.currentStructureFilterPanel.betaStrand.getState ()) { -filterParams.setFilterBetaSheet (true); -}if (this.currentStructureFilterPanel.turn.getState ()) { -filterParams.setFilterTurn (true); -}}if (this.currentSearchPanel != null) { -if (!this.currentSearchPanel.searchBox.getText ().isEmpty ()) { -this.currentSearchPanel.description.setEnabled (true); -this.currentSearchPanel.displayName.setEnabled (true); -filterParams.setRegexString (this.currentSearchPanel.searchBox.getText ()); -if (this.currentSearchPanel.displayName.getState ()) { -filterParams.addRegexSearchField (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING); -}if (this.currentSearchPanel.description.getState ()) { -filterParams.addRegexSearchField (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION); -}} else { -this.currentSearchPanel.description.setEnabled (false); -this.currentSearchPanel.displayName.setEnabled (false); -}}this.av.getColumnSelection ().filterAnnotations (this.getCurrentAnnotation ().annotations, filterParams); -this.av.showAllHiddenColumns (); -if (this.getActionOption () == jalview.appletgui.AnnotationColumnChooser.ACTION_OPTION_HIDE) { -this.av.hideSelectedColumns (); -}filterParams = null; -this.av.setAnnotationColumnSelectionState (this); -this.ap.paintAlignment (true); -}); -Clazz.defineMethod (c$, "getOldColumnSelection", -function () { -return this.oldColumnSelection; -}); -Clazz.defineMethod (c$, "setOldColumnSelection", -function (currentColumnSelection) { -if (currentColumnSelection != null) { -this.oldColumnSelection = new jalview.datamodel.ColumnSelection (currentColumnSelection); -}}, "jalview.datamodel.ColumnSelection"); -Clazz.defineMethod (c$, "getCurrentFutherActionPanel", -function () { -return this.currentFurtherActionPanel; -}); -Clazz.defineMethod (c$, "setCurrentFutherActionPanel", -function (currentFutherActionPanel) { -this.currentFurtherActionPanel = currentFutherActionPanel; -}, "jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel"); -Clazz.defineMethod (c$, "getCurrentSearchPanel", -function () { -return this.currentSearchPanel; -}); -Clazz.defineMethod (c$, "setCurrentSearchPanel", -function (currentSearchPanel) { -this.currentSearchPanel = currentSearchPanel; -}, "jalview.appletgui.AnnotationColumnChooser.SearchPanel"); -Clazz.defineMethod (c$, "getActionOption", -function () { -return this.actionOption; -}); -Clazz.defineMethod (c$, "setActionOption", -function (actionOption) { -this.actionOption = actionOption; -}, "~N"); -Clazz.defineMethod (c$, "getCurrentStructureFilterPanel", -function () { -return this.currentStructureFilterPanel; -}); -Clazz.defineMethod (c$, "setCurrentStructureFilterPanel", -function (currentStructureFilterPanel) { -this.currentStructureFilterPanel = currentStructureFilterPanel; -}, "jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -if (e.getSource () === this.annotations) { -this.selectedAnnotationChanged (); -} else if (e.getSource () === this.threshold) { -this.threshold_actionPerformed (null); -}}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "selectedAnnotationChanged", -function () { -var currentView = jalview.appletgui.AnnotationColumnChooser.NO_GRAPH_VIEW; -if (this.av.getAlignment ().getAlignmentAnnotation ()[this.getAnnotations ().getSelectedIndex ()].graph != 0) { -currentView = jalview.appletgui.AnnotationColumnChooser.GRAPH_VIEW; -}this.gSearchPanel.syncState (); -this.gFurtherActionPanel.syncState (); -this.gStructureFilterPanel.syncState (); -this.ngSearchPanel.syncState (); -this.ngFurtherActionPanel.syncState (); -this.ngStructureFilterPanel.syncState (); -this.switchableViewsLayout.show (this.switchableViewsPanel, currentView); -this.updateView (); -}); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.thresholdValue) { -try { -var f = new Float (this.thresholdValue.getText ()).floatValue (); -this.slider.setValue (Clazz.floatToInt (f * 1000)); -this.adjustmentValueChanged (null); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -} else if (evt.getSource () === this.ok) { -this.ok_actionPerformed (null); -} else if (evt.getSource () === this.cancel) { -this.cancel_actionPerformed (null); -} else if (evt.getSource () === this.thresholdValue) { -this.thresholdValue_actionPerformed (null); -} else { -this.updateView (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (e) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (e) { -if (e.getSource () === this.slider) { -this.updateView (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (e) { -if (e.getSource () === this.slider) { -this.updateView (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (e) { -if (e.getSource () === this.slider) { -this.updateView (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (e) { -if (e.getSource () === this.slider) { -this.updateView (); -}}, "java.awt.event.MouseEvent"); -c$.$AnnotationColumnChooser$FurtherActionPanel$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.aColChooser = null; -this.furtherAction = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.AnnotationColumnChooser, "FurtherActionPanel", awt2swing.Panel, java.awt.event.ItemListener); -Clazz.prepareFields (c$, function () { -this.furtherAction = new awt2swing.Choice (); -}); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel, []); -this.aColChooser = a; -this.furtherAction.addItem ("Select"); -this.furtherAction.addItem ("Hide"); -this.furtherAction.addItemListener (this); -this.syncState (); -this.add (this.furtherAction); -}, "jalview.appletgui.AnnotationColumnChooser"); -Clazz.defineMethod (c$, "syncState", -function () { -if (this.aColChooser.getActionOption () == jalview.appletgui.AnnotationColumnChooser.ACTION_OPTION_HIDE) { -this.furtherAction.select ("Hide"); -} else { -this.furtherAction.select ("Select"); -}}); -Clazz.overrideMethod (c$, "itemStateChanged", -function (a) { -this.aColChooser.setCurrentFutherActionPanel (this); -if (this.furtherAction.getSelectedItem ().toString ().equalsIgnoreCase ("Select")) { -this.b$["jalview.appletgui.AnnotationColumnChooser"].setActionOption (1); -this.b$["jalview.appletgui.AnnotationColumnChooser"].updateView (); -} else { -this.b$["jalview.appletgui.AnnotationColumnChooser"].setActionOption (jalview.appletgui.AnnotationColumnChooser.ACTION_OPTION_HIDE); -this.b$["jalview.appletgui.AnnotationColumnChooser"].updateView (); -}}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationColumnChooser$StructureFilterPanel$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.aColChooser = null; -this.alphaHelix = null; -this.betaStrand = null; -this.turn = null; -this.all = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.AnnotationColumnChooser, "StructureFilterPanel", jalview.appletgui.TitledPanel, java.awt.event.ItemListener); -Clazz.prepareFields (c$, function () { -this.alphaHelix = new awt2swing.Checkbox (); -this.betaStrand = new awt2swing.Checkbox (); -this.turn = new awt2swing.Checkbox (); -this.all = new awt2swing.Checkbox (); -}); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel, []); -this.aColChooser = a; -this.alphaHelix.setLabel (jalview.util.MessageManager.getString ("label.alpha_helix")); -this.alphaHelix.setBackground (java.awt.Color.white); -this.alphaHelix.addItemListener (this); -this.betaStrand.setLabel (jalview.util.MessageManager.getString ("label.beta_strand")); -this.betaStrand.setBackground (java.awt.Color.white); -this.betaStrand.addItemListener (this); -this.turn.setLabel (jalview.util.MessageManager.getString ("label.turn")); -this.turn.setBackground (java.awt.Color.white); -this.turn.addItemListener (this); -this.all.setLabel (jalview.util.MessageManager.getString ("label.select_all")); -this.all.setBackground (java.awt.Color.white); -this.all.addItemListener (this); -this.setBackground (java.awt.Color.white); -this.setTitle ("Structure Filter"); -this.add (this.all); -this.add (this.alphaHelix); -this.add (this.betaStrand); -this.add (this.turn); -}, "jalview.appletgui.AnnotationColumnChooser"); -Clazz.defineMethod (c$, "alphaHelix_actionPerformed", -function () { -this.updateSelectAllState (); -this.aColChooser.setCurrentStructureFilterPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "betaStrand_actionPerformed", -function () { -this.updateSelectAllState (); -this.aColChooser.setCurrentStructureFilterPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "turn_actionPerformed", -function () { -this.updateSelectAllState (); -this.aColChooser.setCurrentStructureFilterPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "all_actionPerformed", -function () { -if (this.all.getState ()) { -this.alphaHelix.setState (true); -this.betaStrand.setState (true); -this.turn.setState (true); -} else { -this.alphaHelix.setState (false); -this.betaStrand.setState (false); -this.turn.setState (false); -}this.aColChooser.setCurrentStructureFilterPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "updateSelectAllState", -function () { -if (this.alphaHelix.getState () && this.betaStrand.getState () && this.turn.getState ()) { -this.all.setState (true); -} else { -this.all.setState (false); -}}); -Clazz.defineMethod (c$, "syncState", -function () { -var a = this.aColChooser.getCurrentStructureFilterPanel (); -if (a != null) { -this.alphaHelix.setState (a.alphaHelix.getState ()); -this.betaStrand.setState (a.betaStrand.getState ()); -this.turn.setState (a.turn.getState ()); -if (a.all.getState ()) { -this.all.setState (true); -this.alphaHelix.setState (true); -this.betaStrand.setState (true); -this.turn.setState (true); -}}}); -Clazz.overrideMethod (c$, "itemStateChanged", -function (a) { -if (a.getSource () === this.alphaHelix) { -this.alphaHelix_actionPerformed (); -} else if (a.getSource () === this.betaStrand) { -this.betaStrand_actionPerformed (); -} else if (a.getSource () === this.turn) { -this.turn_actionPerformed (); -} else if (a.getSource () === this.all) { -this.all_actionPerformed (); -}}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationColumnChooser$SearchPanel$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.aColChooser = null; -this.displayName = null; -this.description = null; -this.searchBox = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.AnnotationColumnChooser, "SearchPanel", jalview.appletgui.TitledPanel, java.awt.event.ItemListener); -Clazz.prepareFields (c$, function () { -this.displayName = new awt2swing.Checkbox (); -this.description = new awt2swing.Checkbox (); -this.searchBox = new awt2swing.TextField (10); -}); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser.SearchPanel, []); -this.aColChooser = a; -this.searchBox.addTextListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser$SearchPanel$1") ? 0 : jalview.appletgui.AnnotationColumnChooser.SearchPanel.$AnnotationColumnChooser$SearchPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser$SearchPanel$1, this, null))); -this.displayName.setLabel (jalview.util.MessageManager.getString ("label.display_name")); -this.displayName.setEnabled (false); -this.displayName.addItemListener (this); -this.description.setLabel (jalview.util.MessageManager.getString ("label.description")); -this.description.setEnabled (false); -this.description.addItemListener (this); -this.setTitle ("Search Filter"); -this.syncState (); -this.add (this.searchBox); -this.add (this.displayName); -this.add (this.description); -}, "jalview.appletgui.AnnotationColumnChooser"); -Clazz.defineMethod (c$, "displayNameCheckboxAction", -function () { -this.aColChooser.setCurrentSearchPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "discriptionCheckboxAction", -function () { -this.aColChooser.setCurrentSearchPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "searchStringAction", -function () { -this.aColChooser.setCurrentSearchPanel (this); -this.aColChooser.updateView (); -}); -Clazz.defineMethod (c$, "syncState", -function () { -var a = this.aColChooser.getCurrentSearchPanel (); -if (a != null) { -this.description.setEnabled (a.description.isEnabled ()); -this.description.setState (a.description.getState ()); -this.displayName.setEnabled (a.displayName.isEnabled ()); -this.displayName.setState (a.displayName.getState ()); -this.searchBox.setText (a.searchBox.getText ()); -}}); -Clazz.overrideMethod (c$, "itemStateChanged", -function (a) { -if (a.getSource () === this.displayName) { -this.displayNameCheckboxAction (); -} else if (a.getSource () === this.description) { -this.discriptionCheckboxAction (); -}}, "java.awt.event.ItemEvent"); -c$.$AnnotationColumnChooser$SearchPanel$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationColumnChooser$SearchPanel$1", null, java.awt.event.TextListener); -Clazz.overrideMethod (c$, "textValueChanged", -function (a) { -this.b$["jalview.appletgui.AnnotationColumnChooser.SearchPanel"].searchStringAction (); -}, "java.awt.event.TextEvent"); -c$ = Clazz.p0p (); -}; -c$ = Clazz.p0p (); -}; -c$.$AnnotationColumnChooser$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationColumnChooser$1", java.awt.event.MouseAdapter); -Clazz.defineMethod (c$, "mousePressed", -function (e) { -this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging = true; -Clazz.superCall (this, jalview.appletgui.AnnotationColumnChooser$1, "mousePressed", [e]); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mouseDragged", -function (e) { -this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging = true; -Clazz.superCall (this, jalview.appletgui.AnnotationColumnChooser$1, "mouseDragged", [e]); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -if (this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging) { -this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging = false; -this.b$["jalview.appletgui.AnnotationColumnChooser"].valueChanged (true); -}this.b$["jalview.appletgui.AnnotationColumnChooser"].ap.paintAlignment (true); -}, "java.awt.event.MouseEvent"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"ACTION_OPTION_SELECT", 1, -"ACTION_OPTION_HIDE", 2, -"NO_GRAPH_VIEW", "0", -"GRAPH_VIEW", "1"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.appletgui.AnnotationRowFilter", "$.TitledPanel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Checkbox", "$.Choice", "$.TextField", "java.awt.BorderLayout", "$.CardLayout"], "jalview.appletgui.AnnotationColumnChooser", ["awt2swing.Frame", "jalview.bin.JalviewLite", "jalview.datamodel.ColumnSelection", "$.GraphLine", "jalview.util.MessageManager", "jalview.viewmodel.annotationfilter.AnnotationFilterParameter", "java.awt.Color", "$.Dimension", "java.awt.event.MouseAdapter", "$.TextListener", "java.lang.Float", "java.util.Vector", "javax.swing.JPanel"], function () { +c$ = Clazz.decorateAsClass (function () { +this.annotations = null; +this.actionPanel = null; +this.thresholdPanel = null; +this.switchableViewsPanel = null; +this.switchableViewsLayout = null; +this.noGraphFilterView = null; +this.graphFilterView = null; +this.annotationComboBoxPanel = null; +this.borderLayout1 = null; +this.gBorderLayout = null; +this.ngBorderLayout = null; +this.threshold = null; +this.gStructureFilterPanel = null; +this.ngStructureFilterPanel = null; +this.currentStructureFilterPanel = null; +this.currentSearchPanel = null; +this.gSearchPanel = null; +this.ngSearchPanel = null; +this.currentFurtherActionPanel = null; +this.gFurtherActionPanel = null; +this.ngFurtherActionPanel = null; +this.actionOption = 1; +this.oldColumnSelection = null; +if (!Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel")) { +jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$FurtherActionPanel$ (); +} +if (!Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel")) { +jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$StructureFilterPanel$ (); +} +if (!Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser.SearchPanel")) { +jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$SearchPanel$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationColumnChooser", jalview.appletgui.AnnotationRowFilter, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); +Clazz.prepareFields (c$, function () { +this.annotations = new awt2swing.Choice (); +this.actionPanel = new awt2swing.Panel (); +this.thresholdPanel = new jalview.appletgui.TitledPanel (); +this.switchableViewsPanel = new awt2swing.Panel ( new java.awt.CardLayout ()); +this.switchableViewsLayout = (this.switchableViewsPanel.getLayout ()); +this.noGraphFilterView = new awt2swing.Panel (); +this.graphFilterView = new awt2swing.Panel (); +this.annotationComboBoxPanel = new awt2swing.Panel (); +this.borderLayout1 = new java.awt.BorderLayout (); +this.gBorderLayout = new java.awt.BorderLayout (); +this.ngBorderLayout = new java.awt.BorderLayout (); +this.threshold = new awt2swing.Choice (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser, []); +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +Clazz.makeConstructor (c$, +function (av, ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser, [av, ap]); +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.select_by_annotation"), 520, 215); +this.slider.addAdjustmentListener (this); +this.slider.addMouseListener (this); +if (av.getAlignment ().getAlignmentAnnotation () == null) { +return; +}this.setOldColumnSelection (av.getColumnSelection ()); +this.adjusting = true; +var list = new java.util.Vector (); +var index = 1; +for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { +var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; +if (!list.contains (label)) { +list.addElement (label); +} else { +list.addElement (label + "_" + (index++)); +}} +for (var i = 0; i < list.size (); i++) { +this.annotations.addItem (list.elementAt (i).toString ()); +} +this.populateThresholdComboBox (this.threshold); +if (av.getAnnotationColumnSelectionState () != null) { +this.currentSearchPanel = av.getAnnotationColumnSelectionState ().getCurrentSearchPanel (); +this.currentStructureFilterPanel = av.getAnnotationColumnSelectionState ().getCurrentStructureFilterPanel (); +this.annotations.select (new Integer (av.getAnnotationColumnSelectionState ().getAnnotations ().getSelectedIndex ())); +this.threshold.select (new Integer (av.getAnnotationColumnSelectionState ().getThreshold ().getSelectedIndex ())); +this.actionOption = av.getAnnotationColumnSelectionState ().getActionOption (); +}try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +this.adjusting = false; +this.updateView (); +this.frame.invalidate (); +this.frame.pack (); +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); +this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); +this.thresholdValue.setEnabled (false); +this.thresholdValue.setColumns (7); +this.ok.addActionListener (this); +this.cancel.addActionListener (this); +this.annotations.addItemListener (this); +this.thresholdValue.addActionListener (this); +this.threshold.addItemListener (this); +this.slider.setBackground (java.awt.Color.white); +this.slider.setEnabled (false); +this.slider.setPreferredSize ( new java.awt.Dimension (100, 32)); +this.thresholdPanel.setBackground (java.awt.Color.white); +this.actionPanel.setBackground (java.awt.Color.white); +this.graphFilterView.setLayout (this.gBorderLayout); +this.graphFilterView.setBackground (java.awt.Color.white); +this.noGraphFilterView.setLayout (this.ngBorderLayout); +this.noGraphFilterView.setBackground (java.awt.Color.white); +this.annotationComboBoxPanel.setBackground (java.awt.Color.white); +this.gSearchPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.SearchPanel, this, null, this); +this.ngSearchPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.SearchPanel, this, null, this); +this.gFurtherActionPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel, this, null, this); +this.ngFurtherActionPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel, this, null, this); +this.gStructureFilterPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel, this, null, this); +this.ngStructureFilterPanel = Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel, this, null, this); +this.thresholdPanel.setTitle ("Threshold Filter"); +this.thresholdPanel.add (this.getThreshold ()); +this.thresholdPanel.add (this.slider); +this.thresholdPanel.add (this.thresholdValue); +this.actionPanel.add (this.ok); +this.actionPanel.add (this.cancel); +var staticPanel = new javax.swing.JPanel (); +staticPanel.setLayout ( new java.awt.BorderLayout ()); +staticPanel.setBackground (java.awt.Color.white); +staticPanel.add (this.gSearchPanel, "North"); +staticPanel.add (this.gStructureFilterPanel, "South"); +this.graphFilterView.add (staticPanel, "North"); +this.graphFilterView.add (this.thresholdPanel, "Center"); +this.graphFilterView.add (this.gFurtherActionPanel, "South"); +this.noGraphFilterView.add (this.ngSearchPanel, "First"); +this.noGraphFilterView.add (this.ngStructureFilterPanel, "Center"); +this.noGraphFilterView.add (this.ngFurtherActionPanel, "Center"); +this.annotationComboBoxPanel.add (this.getAnnotations ()); +this.switchableViewsPanel.add (this.noGraphFilterView, jalview.appletgui.AnnotationColumnChooser.NO_GRAPH_VIEW); +this.switchableViewsPanel.add (this.graphFilterView, jalview.appletgui.AnnotationColumnChooser.GRAPH_VIEW); +this.setLayout (this.borderLayout1); +this.add (this.annotationComboBoxPanel, "First"); +this.add (this.switchableViewsPanel, "Center"); +this.add (this.actionPanel, "South"); +this.selectedAnnotationChanged (); +this.validate (); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "reset", +function () { +if (this.getOldColumnSelection () != null) { +this.av.getColumnSelection ().clear (); +if (this.av.getAnnotationColumnSelectionState () != null) { +var oldSelection = this.av.getAnnotationColumnSelectionState ().getOldColumnSelection (); +if (oldSelection != null && oldSelection.getHiddenColumns () != null && !oldSelection.getHiddenColumns ().isEmpty ()) { +for (var itr = oldSelection.getHiddenColumns ().iterator (); itr.hasNext (); ) { +var positions = itr.next (); +this.av.hideColumns (positions[0], positions[1]); +} +}this.av.setColumnSelection (oldSelection); +}this.ap.paintAlignment (true); +}}); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +if (!this.adjusting) { +this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); +this.valueChanged (!this.sliderDragging); +}}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "addSliderMouseListeners", +function () { +this.slider.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser$1") ? 0 : jalview.appletgui.AnnotationColumnChooser.$AnnotationColumnChooser$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser$1, this, null))); +}); +Clazz.overrideMethod (c$, "valueChanged", +function (updateAllAnnotation) { +if (this.slider.isEnabled ()) { +this.getCurrentAnnotation ().threshold.value = this.slider.getValue () / 1000; +this.updateView (); +this.ap.paintAlignment (false); +}}, "~B"); +Clazz.defineMethod (c$, "getThreshold", +function () { +return this.threshold; +}); +Clazz.defineMethod (c$, "setThreshold", +function (threshold) { +this.threshold = threshold; +}, "awt2swing.Choice"); +Clazz.defineMethod (c$, "getAnnotations", +function () { +return this.annotations; +}); +Clazz.defineMethod (c$, "setAnnotations", +function (annotations) { +this.annotations = annotations; +}, "awt2swing.Choice"); +Clazz.overrideMethod (c$, "updateView", +function () { +if (this.adjusting) { +return; +}var filterParams = new jalview.viewmodel.annotationfilter.AnnotationFilterParameter (); +this.setCurrentAnnotation (this.av.getAlignment ().getAlignmentAnnotation ()[this.getAnnotations ().getSelectedIndex ()]); +var selectedThresholdItem = this.getSelectedThresholdItem (this.getThreshold ().getSelectedIndex ()); +this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +if (selectedThresholdItem == -1) { +this.slider.setEnabled (false); +this.thresholdValue.setEnabled (false); +this.thresholdValue.setText (""); +} else if (selectedThresholdItem != -1) { +if (this.getCurrentAnnotation ().threshold == null) { +this.getCurrentAnnotation ().setThreshold ( new jalview.datamodel.GraphLine ((this.getCurrentAnnotation ().graphMax - this.getCurrentAnnotation ().graphMin) / 2, "Threshold", java.awt.Color.black)); +}this.adjusting = true; +var range = this.getCurrentAnnotation ().graphMax * 1000 - this.getCurrentAnnotation ().graphMin * 1000; +this.slider.setMinimum (Clazz.floatToInt (this.getCurrentAnnotation ().graphMin * 1000)); +this.slider.setMaximum (Clazz.floatToInt (this.getCurrentAnnotation ().graphMax * 1000)); +this.slider.setValue (Clazz.floatToInt (this.getCurrentAnnotation ().threshold.value * 1000)); +this.thresholdValue.setText (this.getCurrentAnnotation ().threshold.value + ""); +this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +this.adjusting = false; +filterParams.setThresholdType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); +if (this.getCurrentAnnotation ().graph != 0) { +filterParams.setThresholdValue (this.getCurrentAnnotation ().threshold.value); +if (selectedThresholdItem == 1) { +filterParams.setThresholdType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD); +} else if (selectedThresholdItem == 0) { +filterParams.setThresholdType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD); +}}}if (this.currentStructureFilterPanel != null) { +if (this.currentStructureFilterPanel.alphaHelix.getState ()) { +filterParams.setFilterAlphaHelix (true); +}if (this.currentStructureFilterPanel.betaStrand.getState ()) { +filterParams.setFilterBetaSheet (true); +}if (this.currentStructureFilterPanel.turn.getState ()) { +filterParams.setFilterTurn (true); +}}if (this.currentSearchPanel != null) { +if (!this.currentSearchPanel.searchBox.getText ().isEmpty ()) { +this.currentSearchPanel.description.setEnabled (true); +this.currentSearchPanel.displayName.setEnabled (true); +filterParams.setRegexString (this.currentSearchPanel.searchBox.getText ()); +if (this.currentSearchPanel.displayName.getState ()) { +filterParams.addRegexSearchField (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING); +}if (this.currentSearchPanel.description.getState ()) { +filterParams.addRegexSearchField (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION); +}} else { +this.currentSearchPanel.description.setEnabled (false); +this.currentSearchPanel.displayName.setEnabled (false); +}}this.av.getColumnSelection ().filterAnnotations (this.getCurrentAnnotation ().annotations, filterParams); +this.av.showAllHiddenColumns (); +if (this.getActionOption () == jalview.appletgui.AnnotationColumnChooser.ACTION_OPTION_HIDE) { +this.av.hideSelectedColumns (); +}filterParams = null; +this.av.setAnnotationColumnSelectionState (this); +this.ap.paintAlignment (true); +}); +Clazz.defineMethod (c$, "getOldColumnSelection", +function () { +return this.oldColumnSelection; +}); +Clazz.defineMethod (c$, "setOldColumnSelection", +function (currentColumnSelection) { +if (currentColumnSelection != null) { +this.oldColumnSelection = new jalview.datamodel.ColumnSelection (currentColumnSelection); +}}, "jalview.datamodel.ColumnSelection"); +Clazz.defineMethod (c$, "getCurrentFutherActionPanel", +function () { +return this.currentFurtherActionPanel; +}); +Clazz.defineMethod (c$, "setCurrentFutherActionPanel", +function (currentFutherActionPanel) { +this.currentFurtherActionPanel = currentFutherActionPanel; +}, "jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel"); +Clazz.defineMethod (c$, "getCurrentSearchPanel", +function () { +return this.currentSearchPanel; +}); +Clazz.defineMethod (c$, "setCurrentSearchPanel", +function (currentSearchPanel) { +this.currentSearchPanel = currentSearchPanel; +}, "jalview.appletgui.AnnotationColumnChooser.SearchPanel"); +Clazz.defineMethod (c$, "getActionOption", +function () { +return this.actionOption; +}); +Clazz.defineMethod (c$, "setActionOption", +function (actionOption) { +this.actionOption = actionOption; +}, "~N"); +Clazz.defineMethod (c$, "getCurrentStructureFilterPanel", +function () { +return this.currentStructureFilterPanel; +}); +Clazz.defineMethod (c$, "setCurrentStructureFilterPanel", +function (currentStructureFilterPanel) { +this.currentStructureFilterPanel = currentStructureFilterPanel; +}, "jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +if (e.getSource () === this.annotations) { +this.selectedAnnotationChanged (); +} else if (e.getSource () === this.threshold) { +this.threshold_actionPerformed (null); +}}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "selectedAnnotationChanged", +function () { +var currentView = jalview.appletgui.AnnotationColumnChooser.NO_GRAPH_VIEW; +if (this.av.getAlignment ().getAlignmentAnnotation ()[this.getAnnotations ().getSelectedIndex ()].graph != 0) { +currentView = jalview.appletgui.AnnotationColumnChooser.GRAPH_VIEW; +}this.gSearchPanel.syncState (); +this.gFurtherActionPanel.syncState (); +this.gStructureFilterPanel.syncState (); +this.ngSearchPanel.syncState (); +this.ngFurtherActionPanel.syncState (); +this.ngStructureFilterPanel.syncState (); +this.switchableViewsLayout.show (this.switchableViewsPanel, currentView); +this.updateView (); +}); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.thresholdValue) { +try { +var f = new Float (this.thresholdValue.getText ()).floatValue (); +this.slider.setValue (Clazz.floatToInt (f * 1000)); +this.adjustmentValueChanged (null); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +} else if (evt.getSource () === this.ok) { +this.ok_actionPerformed (null); +} else if (evt.getSource () === this.cancel) { +this.cancel_actionPerformed (null); +} else if (evt.getSource () === this.thresholdValue) { +this.thresholdValue_actionPerformed (null); +} else { +this.updateView (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (e) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (e) { +if (e.getSource () === this.slider) { +this.updateView (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (e) { +if (e.getSource () === this.slider) { +this.updateView (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (e) { +if (e.getSource () === this.slider) { +this.updateView (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (e) { +if (e.getSource () === this.slider) { +this.updateView (); +}}, "java.awt.event.MouseEvent"); +c$.$AnnotationColumnChooser$FurtherActionPanel$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.aColChooser = null; +this.furtherAction = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.AnnotationColumnChooser, "FurtherActionPanel", awt2swing.Panel, java.awt.event.ItemListener); +Clazz.prepareFields (c$, function () { +this.furtherAction = new awt2swing.Choice (); +}); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser.FurtherActionPanel, []); +this.aColChooser = a; +this.furtherAction.addItem ("Select"); +this.furtherAction.addItem ("Hide"); +this.furtherAction.addItemListener (this); +this.syncState (); +this.add (this.furtherAction); +}, "jalview.appletgui.AnnotationColumnChooser"); +Clazz.defineMethod (c$, "syncState", +function () { +if (this.aColChooser.getActionOption () == jalview.appletgui.AnnotationColumnChooser.ACTION_OPTION_HIDE) { +this.furtherAction.select ("Hide"); +} else { +this.furtherAction.select ("Select"); +}}); +Clazz.overrideMethod (c$, "itemStateChanged", +function (a) { +this.aColChooser.setCurrentFutherActionPanel (this); +if (this.furtherAction.getSelectedItem ().toString ().equalsIgnoreCase ("Select")) { +this.b$["jalview.appletgui.AnnotationColumnChooser"].setActionOption (1); +this.b$["jalview.appletgui.AnnotationColumnChooser"].updateView (); +} else { +this.b$["jalview.appletgui.AnnotationColumnChooser"].setActionOption (jalview.appletgui.AnnotationColumnChooser.ACTION_OPTION_HIDE); +this.b$["jalview.appletgui.AnnotationColumnChooser"].updateView (); +}}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationColumnChooser$StructureFilterPanel$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.aColChooser = null; +this.alphaHelix = null; +this.betaStrand = null; +this.turn = null; +this.all = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.AnnotationColumnChooser, "StructureFilterPanel", jalview.appletgui.TitledPanel, java.awt.event.ItemListener); +Clazz.prepareFields (c$, function () { +this.alphaHelix = new awt2swing.Checkbox (); +this.betaStrand = new awt2swing.Checkbox (); +this.turn = new awt2swing.Checkbox (); +this.all = new awt2swing.Checkbox (); +}); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser.StructureFilterPanel, []); +this.aColChooser = a; +this.alphaHelix.setLabel (jalview.util.MessageManager.getString ("label.alpha_helix")); +this.alphaHelix.setBackground (java.awt.Color.white); +this.alphaHelix.addItemListener (this); +this.betaStrand.setLabel (jalview.util.MessageManager.getString ("label.beta_strand")); +this.betaStrand.setBackground (java.awt.Color.white); +this.betaStrand.addItemListener (this); +this.turn.setLabel (jalview.util.MessageManager.getString ("label.turn")); +this.turn.setBackground (java.awt.Color.white); +this.turn.addItemListener (this); +this.all.setLabel (jalview.util.MessageManager.getString ("label.select_all")); +this.all.setBackground (java.awt.Color.white); +this.all.addItemListener (this); +this.setBackground (java.awt.Color.white); +this.setTitle ("Structure Filter"); +this.add (this.all); +this.add (this.alphaHelix); +this.add (this.betaStrand); +this.add (this.turn); +}, "jalview.appletgui.AnnotationColumnChooser"); +Clazz.defineMethod (c$, "alphaHelix_actionPerformed", +function () { +this.updateSelectAllState (); +this.aColChooser.setCurrentStructureFilterPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "betaStrand_actionPerformed", +function () { +this.updateSelectAllState (); +this.aColChooser.setCurrentStructureFilterPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "turn_actionPerformed", +function () { +this.updateSelectAllState (); +this.aColChooser.setCurrentStructureFilterPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "all_actionPerformed", +function () { +if (this.all.getState ()) { +this.alphaHelix.setState (true); +this.betaStrand.setState (true); +this.turn.setState (true); +} else { +this.alphaHelix.setState (false); +this.betaStrand.setState (false); +this.turn.setState (false); +}this.aColChooser.setCurrentStructureFilterPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "updateSelectAllState", +function () { +if (this.alphaHelix.getState () && this.betaStrand.getState () && this.turn.getState ()) { +this.all.setState (true); +} else { +this.all.setState (false); +}}); +Clazz.defineMethod (c$, "syncState", +function () { +var a = this.aColChooser.getCurrentStructureFilterPanel (); +if (a != null) { +this.alphaHelix.setState (a.alphaHelix.getState ()); +this.betaStrand.setState (a.betaStrand.getState ()); +this.turn.setState (a.turn.getState ()); +if (a.all.getState ()) { +this.all.setState (true); +this.alphaHelix.setState (true); +this.betaStrand.setState (true); +this.turn.setState (true); +}}}); +Clazz.overrideMethod (c$, "itemStateChanged", +function (a) { +if (a.getSource () === this.alphaHelix) { +this.alphaHelix_actionPerformed (); +} else if (a.getSource () === this.betaStrand) { +this.betaStrand_actionPerformed (); +} else if (a.getSource () === this.turn) { +this.turn_actionPerformed (); +} else if (a.getSource () === this.all) { +this.all_actionPerformed (); +}}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationColumnChooser$SearchPanel$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.aColChooser = null; +this.displayName = null; +this.description = null; +this.searchBox = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.AnnotationColumnChooser, "SearchPanel", jalview.appletgui.TitledPanel, java.awt.event.ItemListener); +Clazz.prepareFields (c$, function () { +this.displayName = new awt2swing.Checkbox (); +this.description = new awt2swing.Checkbox (); +this.searchBox = new awt2swing.TextField (10); +}); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationColumnChooser.SearchPanel, []); +this.aColChooser = a; +this.searchBox.addTextListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationColumnChooser$SearchPanel$1") ? 0 : jalview.appletgui.AnnotationColumnChooser.SearchPanel.$AnnotationColumnChooser$SearchPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationColumnChooser$SearchPanel$1, this, null))); +this.displayName.setLabel (jalview.util.MessageManager.getString ("label.display_name")); +this.displayName.setEnabled (false); +this.displayName.addItemListener (this); +this.description.setLabel (jalview.util.MessageManager.getString ("label.description")); +this.description.setEnabled (false); +this.description.addItemListener (this); +this.setTitle ("Search Filter"); +this.syncState (); +this.add (this.searchBox); +this.add (this.displayName); +this.add (this.description); +}, "jalview.appletgui.AnnotationColumnChooser"); +Clazz.defineMethod (c$, "displayNameCheckboxAction", +function () { +this.aColChooser.setCurrentSearchPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "discriptionCheckboxAction", +function () { +this.aColChooser.setCurrentSearchPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "searchStringAction", +function () { +this.aColChooser.setCurrentSearchPanel (this); +this.aColChooser.updateView (); +}); +Clazz.defineMethod (c$, "syncState", +function () { +var a = this.aColChooser.getCurrentSearchPanel (); +if (a != null) { +this.description.setEnabled (a.description.isEnabled ()); +this.description.setState (a.description.getState ()); +this.displayName.setEnabled (a.displayName.isEnabled ()); +this.displayName.setState (a.displayName.getState ()); +this.searchBox.setText (a.searchBox.getText ()); +}}); +Clazz.overrideMethod (c$, "itemStateChanged", +function (a) { +if (a.getSource () === this.displayName) { +this.displayNameCheckboxAction (); +} else if (a.getSource () === this.description) { +this.discriptionCheckboxAction (); +}}, "java.awt.event.ItemEvent"); +c$.$AnnotationColumnChooser$SearchPanel$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationColumnChooser$SearchPanel$1", null, java.awt.event.TextListener); +Clazz.overrideMethod (c$, "textValueChanged", +function (a) { +this.b$["jalview.appletgui.AnnotationColumnChooser.SearchPanel"].searchStringAction (); +}, "java.awt.event.TextEvent"); +c$ = Clazz.p0p (); +}; +c$ = Clazz.p0p (); +}; +c$.$AnnotationColumnChooser$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationColumnChooser$1", java.awt.event.MouseAdapter); +Clazz.defineMethod (c$, "mousePressed", +function (e) { +this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging = true; +Clazz.superCall (this, jalview.appletgui.AnnotationColumnChooser$1, "mousePressed", [e]); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mouseDragged", +function (e) { +this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging = true; +Clazz.superCall (this, jalview.appletgui.AnnotationColumnChooser$1, "mouseDragged", [e]); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +if (this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging) { +this.b$["jalview.appletgui.AnnotationColumnChooser"].sliderDragging = false; +this.b$["jalview.appletgui.AnnotationColumnChooser"].valueChanged (true); +}this.b$["jalview.appletgui.AnnotationColumnChooser"].ap.paintAlignment (true); +}, "java.awt.event.MouseEvent"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"ACTION_OPTION_SELECT", 1, +"ACTION_OPTION_HIDE", 2, +"NO_GRAPH_VIEW", "0", +"GRAPH_VIEW", "1"); +}); diff --git a/bin/jalview/appletgui/AnnotationLabels.js b/bin/jalview/appletgui/AnnotationLabels.js index 27cabd2..195bfa5 100644 --- a/bin/jalview/appletgui/AnnotationLabels.js +++ b/bin/jalview/appletgui/AnnotationLabels.js @@ -1,466 +1,466 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.AnnotationLabels", ["awt2swing.Checkbox", "$.CheckboxMenuItem", "$.Frame", "$.MenuItem", "$.PopupMenu", "jalview.analysis.AlignmentUtils", "jalview.appletgui.AlignFrame", "$.CutAndPasteTransfer", "$.EditNameDialog", "$.PaintRefresher", "$.Tooltip", "jalview.bin.JalviewLite", "jalview.datamodel.AlignmentAnnotation", "$.SequenceGroup", "jalview.util.MessageManager", "$.ParseHtmlBodyAndLinks", "java.awt.Color", "$.Dimension", "$.FlowLayout", "java.awt.event.ItemListener", "java.lang.StringBuffer", "java.util.Arrays", "$.Collections", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.image = null; -this.active = false; -this.ap = null; -this.av = null; -this.resizing = false; -this.oldY = 0; -this.mouseX = 0; -this.scrollOffset = 0; -this.selectedRow = -1; -this.tooltip = null; -this.hasHiddenRows = false; -this.resizePanel = false; -this.dragEvent = null; -this.dragCancelled = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationLabels", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationLabels, []); -this.ap = ap; -this.av = ap.av; -this.setLayout (null); -this.addMouseListener (this); -this.addMouseMotionListener (this); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationLabels, []); -this.av = av; -}, "jalview.appletgui.AlignViewport"); -Clazz.defineMethod (c$, "setScrollOffset", -function (y, repaint) { -this.scrollOffset = y; -if (repaint) { -this.repaint (); -}}, "~N,~B"); -Clazz.defineMethod (c$, "getSelectedRow", -function (y) { -var row = -2; -var aa = this.ap.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return row; -}var height = 0; -for (var i = 0; i < aa.length; i++) { -row = -1; -if (!aa[i].visible) { -continue; -}height += aa[i].height; -if (y < height) { -row = i; -break; -}} -return row; -}, "~N"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.ADDNEW)) { -var newAnnotation = new jalview.datamodel.AlignmentAnnotation ("", null, new Array (this.ap.av.getAlignment ().getWidth ())); -if (!this.editLabelDescription (newAnnotation)) { -return; -}this.ap.av.getAlignment ().addAnnotation (newAnnotation); -this.ap.av.getAlignment ().setAnnotationIndex (newAnnotation, 0); -} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.EDITNAME)) { -this.editLabelDescription (aa[this.selectedRow]); -} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.HIDE)) { -aa[this.selectedRow].visible = false; -} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.SHOWALL)) { -for (var i = 0; i < aa.length; i++) { -aa[i].visible = (aa[i].annotations == null) ? false : true; -} -} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.OUTPUT_TEXT)) { -var cap = new jalview.appletgui.CutAndPasteTransfer (false, this.ap.alignFrame); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, this.ap.alignFrame.getTitle () + " - " + aa[this.selectedRow].label, 500, 100); -cap.setText (aa[this.selectedRow].toString ()); -} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.COPYCONS_SEQ)) { -var cons = this.av.getConsensusSeq (); -if (cons != null) { -this.copy_annotseqtoclipboard (cons); -}}this.refresh (); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "refresh", -function () { -this.ap.annotationPanel.adjustPanelHeight (); -this.setSize (this.getSize ().width, this.ap.annotationPanel.getSize ().height); -this.ap.validate (); -this.ap.paintAlignment (true); -}); -Clazz.defineMethod (c$, "editLabelDescription", -function (annotation) { -var padGaps = new awt2swing.Checkbox ("Fill Empty Gaps With \"" + this.ap.av.getGapCharacter () + "\"", annotation.padGaps); -var dialog = new jalview.appletgui.EditNameDialog (annotation.label, annotation.description, " Annotation Label", "Annotation Description", this.ap.alignFrame, "Edit Annotation Name / Description", 500, 180, false); -var empty = new awt2swing.Panel ( new java.awt.FlowLayout ()); -empty.add (padGaps); -dialog.add (empty); -dialog.pack (); -dialog.setVisible (true); -if (dialog.accept) { -annotation.label = dialog.getName (); -annotation.description = dialog.getDescription (); -annotation.setPadGaps (padGaps.getState (), this.av.getGapCharacter ()); -this.repaint (); -return true; -} else { -return false; -}}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -this.resizePanel = evt.getY () < 10 && evt.getX () < 14; -var row = this.getSelectedRow (evt.getY () + this.scrollOffset); -if (row > -1) { -var phb = new jalview.util.ParseHtmlBodyAndLinks (this.av.getAlignment ().getAlignmentAnnotation ()[row].getDescription (true), true, "\n"); -if (this.tooltip == null) { -this.tooltip = new jalview.appletgui.Tooltip (phb.getNonHtmlContent (), this); -} else { -this.tooltip.setTip (phb.getNonHtmlContent ()); -}} else if (this.tooltip != null) { -this.tooltip.setTip (""); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "cancelDrag", -function () { -this.dragEvent = null; -this.dragCancelled = true; -}); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -if (this.dragCancelled) { -return; -};this.dragEvent = evt; -if (this.resizePanel) { -var d = this.ap.annotationPanelHolder.getSize (); -var e = this.ap.annotationSpaceFillerHolder.getSize (); -var f = this.ap.seqPanelHolder.getSize (); -var dif = evt.getY () - this.oldY; -dif /= this.ap.av.getCharHeight (); -dif *= this.ap.av.getCharHeight (); -if ((d.height - dif) > 20 && (f.height + dif) > 20) { -this.ap.annotationPanel.setSize (d.width, d.height - dif); -this.setSize ( new java.awt.Dimension (e.width, d.height - dif)); -this.ap.annotationSpaceFillerHolder.setSize ( new java.awt.Dimension (e.width, d.height - dif)); -this.ap.annotationPanelHolder.setSize ( new java.awt.Dimension (d.width, d.height - dif)); -this.ap.apvscroll.setValues (this.ap.apvscroll.getValue (), d.height - dif, 0, this.av.calcPanelHeight ()); -f.height += dif; -this.ap.seqPanelHolder.setPreferredSize (f); -this.ap.setScrollValues (this.av.getStartRes (), this.av.getStartSeq ()); -this.ap.validate (); -this.ap.addNotify (); -}} else { -var diff; -if ((diff = 6 - evt.getY ()) > 0) { -this.ap.apvscroll.setValue (this.ap.apvscroll.getValue () - diff); -this.ap.adjustmentValueChanged (null); -} else if ((0 < (diff = 6 - this.ap.annotationSpaceFillerHolder.getSize ().height + evt.getY ()))) { -this.ap.apvscroll.setValue (this.ap.apvscroll.getValue () + diff); -this.ap.adjustmentValueChanged (null); -}this.repaint (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -if (!this.resizePanel && !this.dragCancelled) { -var start = this.selectedRow; -var end = this.getSelectedRow (evt.getY () + this.scrollOffset); -if (start > -1 && start != end) { -var startAA = this.ap.av.getAlignment ().getAlignmentAnnotation ()[start]; -if (end == -1) { -end = this.ap.av.getAlignment ().getAlignmentAnnotation ().length - 1; -}var endAA = this.ap.av.getAlignment ().getAlignmentAnnotation ()[end]; -this.ap.av.getAlignment ().getAlignmentAnnotation ()[end] = startAA; -this.ap.av.getAlignment ().getAlignmentAnnotation ()[start] = endAA; -}}this.resizePanel = false; -this.dragEvent = null; -this.dragCancelled = false; -this.repaint (); -this.ap.annotationPanel.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -if (evt.getY () < 10 && evt.getX () < 14) { -this.resizePanel = true; -this.repaint (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -this.dragCancelled = false; -if (this.dragEvent == null) { -this.resizePanel = false; -} else { -if (!this.resizePanel) { -this.dragEvent = null; -}}this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -this.oldY = evt.getY (); -if (this.resizePanel) { -return; -}this.dragCancelled = false; -this.selectedRow = this.getSelectedRow (evt.getY () + this.scrollOffset); -var aa = this.ap.av.getAlignment ().getAlignmentAnnotation (); -if ((evt.getModifiers () & 4) == 4) { -var popup = new awt2swing.PopupMenu (jalview.util.MessageManager.getString ("label.annotations")); -var item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.ADDNEW); -item.addActionListener (this); -popup.add (item); -if (this.selectedRow < 0) { -if (this.hasHiddenRows) { -item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.SHOWALL); -item.addActionListener (this); -popup.add (item); -}this.add (popup); -popup.show (this, evt.getX (), evt.getY ()); -return; -}item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.EDITNAME); -item.addActionListener (this); -popup.add (item); -item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.HIDE); -item.addActionListener (this); -popup.add (item); -if (this.selectedRow < aa.length) { -if (aa[this.selectedRow].sequenceRef != null) { -var label = aa[this.selectedRow].label; -var hideType = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.hide_all") + " " + label); -hideType.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$1") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$1, this, Clazz.cloneFinals ("label", label)))); -popup.add (hideType); -}}if (this.hasHiddenRows) { -item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.SHOWALL); -item.addActionListener (this); -popup.add (item); -}this.add (popup); -item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.OUTPUT_TEXT); -item.addActionListener (this); -popup.add (item); -if (this.selectedRow < aa.length) { -if (aa[this.selectedRow].autoCalculated) { -if (aa[this.selectedRow].label.indexOf ("Consensus") > -1) { -popup.addSeparator (); -var cbmi = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.ignore_gaps_consensus"), (aa[this.selectedRow].groupRef != null) ? aa[this.selectedRow].groupRef.getIgnoreGapsConsensus () : this.ap.av.isIgnoreGapsConsensus ()); -var aaa = aa[this.selectedRow]; -cbmi.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$2") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$2, this, Clazz.cloneFinals ("aaa", aaa, "cbmi", cbmi)))); -popup.add (cbmi); -if (aaa.groupRef != null) { -var chist = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_group_histogram"), aa[this.selectedRow].groupRef.isShowConsensusHistogram ()); -chist.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$3") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$3, this, Clazz.cloneFinals ("aaa", aaa, "chist", chist)))); -popup.add (chist); -var cprofl = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_group_logo"), aa[this.selectedRow].groupRef.isShowSequenceLogo ()); -cprofl.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$4") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$4$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$4, this, Clazz.cloneFinals ("aaa", aaa, "cprofl", cprofl)))); -popup.add (cprofl); -var cprofn = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.normalise_group_logo"), aa[this.selectedRow].groupRef.isNormaliseSequenceLogo ()); -cprofn.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$5") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$5$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$5, this, Clazz.cloneFinals ("aaa", aaa, "cprofn", cprofn)))); -popup.add (cprofn); -} else { -var chist = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_histogram"), this.av.isShowConsensusHistogram ()); -chist.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$6") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$6$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$6, this, Clazz.cloneFinals ("chist", chist)))); -popup.add (chist); -var cprof = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_logo"), this.av.isShowSequenceLogo ()); -cprof.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$7") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$7$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$7, this, Clazz.cloneFinals ("cprof", cprof)))); -popup.add (cprof); -var cprofn = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.normalise_logo"), this.av.isNormaliseSequenceLogo ()); -cprofn.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$8") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$8$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$8, this, Clazz.cloneFinals ("cprofn", cprofn)))); -popup.add (cprofn); -}item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.COPYCONS_SEQ); -item.addActionListener (this); -popup.add (item); -}}}popup.show (this, evt.getX (), evt.getY ()); -} else { -if (this.selectedRow > -1 && this.selectedRow < aa.length) { -if (aa[this.selectedRow].groupRef != null) { -if (evt.getClickCount () >= 2) { -this.ap.seqPanel.ap.idPanel.highlightSearchResults (null); -this.ap.av.setSelectionGroup (aa[this.selectedRow].groupRef); -this.ap.av.sendSelection (); -this.ap.paintAlignment (false); -jalview.appletgui.PaintRefresher.Refresh (this.ap, this.ap.av.getSequenceSetId ()); -} else { -this.ap.seqPanel.ap.idPanel.highlightSearchResults (aa[this.selectedRow].groupRef.getSequences (null)); -}return; -} else if (aa[this.selectedRow].sequenceRef != null) { -if (evt.getClickCount () == 1) { -this.ap.seqPanel.ap.idPanel.highlightSearchResults (java.util.Arrays.asList ( Clazz.newArray (-1, [aa[this.selectedRow].sequenceRef]))); -} else if (evt.getClickCount () >= 2) { -this.ap.seqPanel.ap.idPanel.highlightSearchResults (null); -var sg = this.ap.av.getSelectionGroup (); -if (sg != null) { -if (!(evt.isControlDown () || evt.isShiftDown ())) { -sg = new jalview.datamodel.SequenceGroup (sg); -sg.clear (); -sg.addSequence (aa[this.selectedRow].sequenceRef, false); -} else { -if (evt.isControlDown ()) { -sg.addOrRemove (aa[this.selectedRow].sequenceRef, true); -} else { -sg.addSequence (aa[this.selectedRow].sequenceRef, true); -}}} else { -sg = new jalview.datamodel.SequenceGroup (); -sg.setStartRes (0); -sg.setEndRes (this.ap.av.getAlignment ().getWidth () - 1); -sg.addSequence (aa[this.selectedRow].sequenceRef, false); -}this.ap.av.setSelectionGroup (sg); -this.ap.paintAlignment (false); -jalview.appletgui.PaintRefresher.Refresh (this.ap, this.ap.av.getSequenceSetId ()); -this.ap.av.sendSelection (); -}}}}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "copy_annotseqtoclipboard", -function (sq) { -if (sq == null || sq.getLength () < 1) { -return; -}jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer (); -jalview.appletgui.AlignFrame.copiedSequences.append (sq.getName () + "\t" + sq.getStart () + "\t" + sq.getEnd () + "\t" + sq.getSequenceAsString () + "\n"); -if (this.av.hasHiddenColumns ()) { -jalview.appletgui.AlignFrame.copiedHiddenColumns = new java.util.Vector (); -for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { -jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement ( Clazz.newIntArray (-1, [region[0], region[1]])); -} -}}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.av.getWrapAlignment () || !this.av.isShowAnnotation ()) return; -var w = this.getSize ().width; -var h = this.getSize ().height; -if (this.image == null || w != this.image.getWidth (this) || h != this.image.getHeight (this)) { -this.image = this.createImage (w, this.ap.annotationPanel.getSize ().height); -}this.drawComponent (this.image.getGraphics (), w); -g.drawImage (this.image, 0, 0, this); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawComponent", -function (g, width) { -g.setFont (this.av.getFont ()); -var fm = g.getFontMetrics (this.av.getFont ()); -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -g.translate (0, -this.scrollOffset); -g.setColor (java.awt.Color.black); -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -var y = 0; -var fy = g.getFont ().getSize (); -var x = 0; -var offset; -if (aa != null) { -this.hasHiddenRows = false; -for (var i = 0; i < aa.length; i++) { -if (!aa[i].visible) { -this.hasHiddenRows = true; -continue; -}x = width - fm.stringWidth (aa[i].label) - 3; -y += aa[i].height; -offset = Clazz.doubleToInt (-(aa[i].height - fy) / 2); -g.drawString (aa[i].label, x, y + offset); -} -}g.translate (0, +this.scrollOffset); -if (this.resizePanel) { -g.setColor (java.awt.Color.red); -g.setPaintMode (); -g.drawLine (2, 8, 5, 2); -g.drawLine (5, 2, 8, 8); -} else if (!this.dragCancelled && this.dragEvent != null && aa != null) { -g.setColor (java.awt.Color.lightGray); -g.drawString (aa[this.selectedRow].label, this.dragEvent.getX (), this.dragEvent.getY ()); -}if (!this.av.getWrapAlignment () && ((aa == null) || (aa.length < 1))) { -g.setColor (java.awt.Color.black); -g.drawString (jalview.util.MessageManager.getString ("label.right_click"), 2, 8); -g.drawString (jalview.util.MessageManager.getString ("label.to_add_annotation"), 2, 18); -}}, "java.awt.Graphics,~N"); -c$.$AnnotationLabels$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$1", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -jalview.analysis.AlignmentUtils.showOrHideSequenceAnnotations (this.b$["jalview.appletgui.AnnotationLabels"].ap.av.getAlignment (), java.util.Collections.singleton (this.f$.label), null, false, false); -this.b$["jalview.appletgui.AnnotationLabels"].refresh (); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$2", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -if (this.f$.aaa.groupRef != null) { -this.f$.aaa.groupRef.setIgnoreGapsConsensus (this.f$.cbmi.getState ()); -} else { -this.b$["jalview.appletgui.AnnotationLabels"].ap.av.setIgnoreGapsConsensus (this.f$.cbmi.getState (), this.b$["jalview.appletgui.AnnotationLabels"].ap); -}this.b$["jalview.appletgui.AnnotationLabels"].ap.paintAlignment (true); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$3", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -this.f$.aaa.groupRef.setShowConsensusHistogram (this.f$.chist.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$4$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$4", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -this.f$.aaa.groupRef.setshowSequenceLogo (this.f$.cprofl.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$5$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$5", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -this.f$.aaa.groupRef.setshowSequenceLogo (true); -this.f$.aaa.groupRef.setNormaliseSequenceLogo (this.f$.cprofn.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$6$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$6", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -this.b$["jalview.appletgui.AnnotationLabels"].av.setShowConsensusHistogram (this.f$.chist.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.alignFrame.showConsensusHistogram.setState (this.f$.chist.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$7$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$7", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -this.b$["jalview.appletgui.AnnotationLabels"].av.setShowSequenceLogo (this.f$.cprof.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.alignFrame.showSequenceLogo.setState (this.f$.cprof.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$AnnotationLabels$8$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$8", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -this.b$["jalview.appletgui.AnnotationLabels"].av.setShowSequenceLogo (true); -this.b$["jalview.appletgui.AnnotationLabels"].ap.alignFrame.normSequenceLogo.setState (this.f$.cprofn.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].av.setNormaliseSequenceLogo (this.f$.cprofn.getState ()); -this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"ADDNEW", "Add New Row", -"EDITNAME", "Edit Label/Description", -"HIDE", "Hide This Row", -"SHOWALL", "Show All Hidden Rows", -"OUTPUT_TEXT", "Show Values In Textbox", -"COPYCONS_SEQ", "Copy Consensus Sequence"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.AnnotationLabels", ["awt2swing.Checkbox", "$.CheckboxMenuItem", "$.Frame", "$.MenuItem", "$.PopupMenu", "jalview.analysis.AlignmentUtils", "jalview.appletgui.AlignFrame", "$.CutAndPasteTransfer", "$.EditNameDialog", "$.PaintRefresher", "$.Tooltip", "jalview.bin.JalviewLite", "jalview.datamodel.AlignmentAnnotation", "$.SequenceGroup", "jalview.util.MessageManager", "$.ParseHtmlBodyAndLinks", "java.awt.Color", "$.Dimension", "$.FlowLayout", "java.awt.event.ItemListener", "java.lang.StringBuffer", "java.util.Arrays", "$.Collections", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.image = null; +this.active = false; +this.ap = null; +this.av = null; +this.resizing = false; +this.oldY = 0; +this.mouseX = 0; +this.scrollOffset = 0; +this.selectedRow = -1; +this.tooltip = null; +this.hasHiddenRows = false; +this.resizePanel = false; +this.dragEvent = null; +this.dragCancelled = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationLabels", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationLabels, []); +this.ap = ap; +this.av = ap.av; +this.setLayout (null); +this.addMouseListener (this); +this.addMouseMotionListener (this); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationLabels, []); +this.av = av; +}, "jalview.appletgui.AlignViewport"); +Clazz.defineMethod (c$, "setScrollOffset", +function (y, repaint) { +this.scrollOffset = y; +if (repaint) { +this.repaint (); +}}, "~N,~B"); +Clazz.defineMethod (c$, "getSelectedRow", +function (y) { +var row = -2; +var aa = this.ap.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return row; +}var height = 0; +for (var i = 0; i < aa.length; i++) { +row = -1; +if (!aa[i].visible) { +continue; +}height += aa[i].height; +if (y < height) { +row = i; +break; +}} +return row; +}, "~N"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.ADDNEW)) { +var newAnnotation = new jalview.datamodel.AlignmentAnnotation ("", null, new Array (this.ap.av.getAlignment ().getWidth ())); +if (!this.editLabelDescription (newAnnotation)) { +return; +}this.ap.av.getAlignment ().addAnnotation (newAnnotation); +this.ap.av.getAlignment ().setAnnotationIndex (newAnnotation, 0); +} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.EDITNAME)) { +this.editLabelDescription (aa[this.selectedRow]); +} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.HIDE)) { +aa[this.selectedRow].visible = false; +} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.SHOWALL)) { +for (var i = 0; i < aa.length; i++) { +aa[i].visible = (aa[i].annotations == null) ? false : true; +} +} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.OUTPUT_TEXT)) { +var cap = new jalview.appletgui.CutAndPasteTransfer (false, this.ap.alignFrame); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, this.ap.alignFrame.getTitle () + " - " + aa[this.selectedRow].label, 500, 100); +cap.setText (aa[this.selectedRow].toString ()); +} else if (evt.getActionCommand ().equals (jalview.appletgui.AnnotationLabels.COPYCONS_SEQ)) { +var cons = this.av.getConsensusSeq (); +if (cons != null) { +this.copy_annotseqtoclipboard (cons); +}}this.refresh (); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "refresh", +function () { +this.ap.annotationPanel.adjustPanelHeight (); +this.setSize (this.getSize ().width, this.ap.annotationPanel.getSize ().height); +this.ap.validate (); +this.ap.paintAlignment (true); +}); +Clazz.defineMethod (c$, "editLabelDescription", +function (annotation) { +var padGaps = new awt2swing.Checkbox ("Fill Empty Gaps With \"" + this.ap.av.getGapCharacter () + "\"", annotation.padGaps); +var dialog = new jalview.appletgui.EditNameDialog (annotation.label, annotation.description, " Annotation Label", "Annotation Description", this.ap.alignFrame, "Edit Annotation Name / Description", 500, 180, false); +var empty = new awt2swing.Panel ( new java.awt.FlowLayout ()); +empty.add (padGaps); +dialog.add (empty); +dialog.pack (); +dialog.setVisible (true); +if (dialog.accept) { +annotation.label = dialog.getName (); +annotation.description = dialog.getDescription (); +annotation.setPadGaps (padGaps.getState (), this.av.getGapCharacter ()); +this.repaint (); +return true; +} else { +return false; +}}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +this.resizePanel = evt.getY () < 10 && evt.getX () < 14; +var row = this.getSelectedRow (evt.getY () + this.scrollOffset); +if (row > -1) { +var phb = new jalview.util.ParseHtmlBodyAndLinks (this.av.getAlignment ().getAlignmentAnnotation ()[row].getDescription (true), true, "\n"); +if (this.tooltip == null) { +this.tooltip = new jalview.appletgui.Tooltip (phb.getNonHtmlContent (), this); +} else { +this.tooltip.setTip (phb.getNonHtmlContent ()); +}} else if (this.tooltip != null) { +this.tooltip.setTip (""); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "cancelDrag", +function () { +this.dragEvent = null; +this.dragCancelled = true; +}); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +if (this.dragCancelled) { +return; +};this.dragEvent = evt; +if (this.resizePanel) { +var d = this.ap.annotationPanelHolder.getSize (); +var e = this.ap.annotationSpaceFillerHolder.getSize (); +var f = this.ap.seqPanelHolder.getSize (); +var dif = evt.getY () - this.oldY; +dif /= this.ap.av.getCharHeight (); +dif *= this.ap.av.getCharHeight (); +if ((d.height - dif) > 20 && (f.height + dif) > 20) { +this.ap.annotationPanel.setSize (d.width, d.height - dif); +this.setSize ( new java.awt.Dimension (e.width, d.height - dif)); +this.ap.annotationSpaceFillerHolder.setSize ( new java.awt.Dimension (e.width, d.height - dif)); +this.ap.annotationPanelHolder.setSize ( new java.awt.Dimension (d.width, d.height - dif)); +this.ap.apvscroll.setValues (this.ap.apvscroll.getValue (), d.height - dif, 0, this.av.calcPanelHeight ()); +f.height += dif; +this.ap.seqPanelHolder.setPreferredSize (f); +this.ap.setScrollValues (this.av.getStartRes (), this.av.getStartSeq ()); +this.ap.validate (); +this.ap.addNotify (); +}} else { +var diff; +if ((diff = 6 - evt.getY ()) > 0) { +this.ap.apvscroll.setValue (this.ap.apvscroll.getValue () - diff); +this.ap.adjustmentValueChanged (null); +} else if ((0 < (diff = 6 - this.ap.annotationSpaceFillerHolder.getSize ().height + evt.getY ()))) { +this.ap.apvscroll.setValue (this.ap.apvscroll.getValue () + diff); +this.ap.adjustmentValueChanged (null); +}this.repaint (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +if (!this.resizePanel && !this.dragCancelled) { +var start = this.selectedRow; +var end = this.getSelectedRow (evt.getY () + this.scrollOffset); +if (start > -1 && start != end) { +var startAA = this.ap.av.getAlignment ().getAlignmentAnnotation ()[start]; +if (end == -1) { +end = this.ap.av.getAlignment ().getAlignmentAnnotation ().length - 1; +}var endAA = this.ap.av.getAlignment ().getAlignmentAnnotation ()[end]; +this.ap.av.getAlignment ().getAlignmentAnnotation ()[end] = startAA; +this.ap.av.getAlignment ().getAlignmentAnnotation ()[start] = endAA; +}}this.resizePanel = false; +this.dragEvent = null; +this.dragCancelled = false; +this.repaint (); +this.ap.annotationPanel.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +if (evt.getY () < 10 && evt.getX () < 14) { +this.resizePanel = true; +this.repaint (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +this.dragCancelled = false; +if (this.dragEvent == null) { +this.resizePanel = false; +} else { +if (!this.resizePanel) { +this.dragEvent = null; +}}this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +this.oldY = evt.getY (); +if (this.resizePanel) { +return; +}this.dragCancelled = false; +this.selectedRow = this.getSelectedRow (evt.getY () + this.scrollOffset); +var aa = this.ap.av.getAlignment ().getAlignmentAnnotation (); +if ((evt.getModifiers () & 4) == 4) { +var popup = new awt2swing.PopupMenu (jalview.util.MessageManager.getString ("label.annotations")); +var item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.ADDNEW); +item.addActionListener (this); +popup.add (item); +if (this.selectedRow < 0) { +if (this.hasHiddenRows) { +item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.SHOWALL); +item.addActionListener (this); +popup.add (item); +}this.add (popup); +popup.show (this, evt.getX (), evt.getY ()); +return; +}item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.EDITNAME); +item.addActionListener (this); +popup.add (item); +item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.HIDE); +item.addActionListener (this); +popup.add (item); +if (this.selectedRow < aa.length) { +if (aa[this.selectedRow].sequenceRef != null) { +var label = aa[this.selectedRow].label; +var hideType = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.hide_all") + " " + label); +hideType.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$1") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$1, this, Clazz.cloneFinals ("label", label)))); +popup.add (hideType); +}}if (this.hasHiddenRows) { +item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.SHOWALL); +item.addActionListener (this); +popup.add (item); +}this.add (popup); +item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.OUTPUT_TEXT); +item.addActionListener (this); +popup.add (item); +if (this.selectedRow < aa.length) { +if (aa[this.selectedRow].autoCalculated) { +if (aa[this.selectedRow].label.indexOf ("Consensus") > -1) { +popup.addSeparator (); +var cbmi = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.ignore_gaps_consensus"), (aa[this.selectedRow].groupRef != null) ? aa[this.selectedRow].groupRef.getIgnoreGapsConsensus () : this.ap.av.isIgnoreGapsConsensus ()); +var aaa = aa[this.selectedRow]; +cbmi.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$2") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$2, this, Clazz.cloneFinals ("aaa", aaa, "cbmi", cbmi)))); +popup.add (cbmi); +if (aaa.groupRef != null) { +var chist = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_group_histogram"), aa[this.selectedRow].groupRef.isShowConsensusHistogram ()); +chist.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$3") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$3, this, Clazz.cloneFinals ("aaa", aaa, "chist", chist)))); +popup.add (chist); +var cprofl = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_group_logo"), aa[this.selectedRow].groupRef.isShowSequenceLogo ()); +cprofl.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$4") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$4$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$4, this, Clazz.cloneFinals ("aaa", aaa, "cprofl", cprofl)))); +popup.add (cprofl); +var cprofn = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.normalise_group_logo"), aa[this.selectedRow].groupRef.isNormaliseSequenceLogo ()); +cprofn.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$5") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$5$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$5, this, Clazz.cloneFinals ("aaa", aaa, "cprofn", cprofn)))); +popup.add (cprofn); +} else { +var chist = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_histogram"), this.av.isShowConsensusHistogram ()); +chist.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$6") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$6$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$6, this, Clazz.cloneFinals ("chist", chist)))); +popup.add (chist); +var cprof = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.show_logo"), this.av.isShowSequenceLogo ()); +cprof.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$7") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$7$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$7, this, Clazz.cloneFinals ("cprof", cprof)))); +popup.add (cprof); +var cprofn = new awt2swing.CheckboxMenuItem (jalview.util.MessageManager.getString ("label.normalise_logo"), this.av.isNormaliseSequenceLogo ()); +cprofn.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.AnnotationLabels$8") ? 0 : jalview.appletgui.AnnotationLabels.$AnnotationLabels$8$ ()), Clazz.innerTypeInstance (jalview.appletgui.AnnotationLabels$8, this, Clazz.cloneFinals ("cprofn", cprofn)))); +popup.add (cprofn); +}item = new awt2swing.MenuItem (jalview.appletgui.AnnotationLabels.COPYCONS_SEQ); +item.addActionListener (this); +popup.add (item); +}}}popup.show (this, evt.getX (), evt.getY ()); +} else { +if (this.selectedRow > -1 && this.selectedRow < aa.length) { +if (aa[this.selectedRow].groupRef != null) { +if (evt.getClickCount () >= 2) { +this.ap.seqPanel.ap.idPanel.highlightSearchResults (null); +this.ap.av.setSelectionGroup (aa[this.selectedRow].groupRef); +this.ap.av.sendSelection (); +this.ap.paintAlignment (false); +jalview.appletgui.PaintRefresher.Refresh (this.ap, this.ap.av.getSequenceSetId ()); +} else { +this.ap.seqPanel.ap.idPanel.highlightSearchResults (aa[this.selectedRow].groupRef.getSequences (null)); +}return; +} else if (aa[this.selectedRow].sequenceRef != null) { +if (evt.getClickCount () == 1) { +this.ap.seqPanel.ap.idPanel.highlightSearchResults (java.util.Arrays.asList ( Clazz.newArray (-1, [aa[this.selectedRow].sequenceRef]))); +} else if (evt.getClickCount () >= 2) { +this.ap.seqPanel.ap.idPanel.highlightSearchResults (null); +var sg = this.ap.av.getSelectionGroup (); +if (sg != null) { +if (!(evt.isControlDown () || evt.isShiftDown ())) { +sg = new jalview.datamodel.SequenceGroup (sg); +sg.clear (); +sg.addSequence (aa[this.selectedRow].sequenceRef, false); +} else { +if (evt.isControlDown ()) { +sg.addOrRemove (aa[this.selectedRow].sequenceRef, true); +} else { +sg.addSequence (aa[this.selectedRow].sequenceRef, true); +}}} else { +sg = new jalview.datamodel.SequenceGroup (); +sg.setStartRes (0); +sg.setEndRes (this.ap.av.getAlignment ().getWidth () - 1); +sg.addSequence (aa[this.selectedRow].sequenceRef, false); +}this.ap.av.setSelectionGroup (sg); +this.ap.paintAlignment (false); +jalview.appletgui.PaintRefresher.Refresh (this.ap, this.ap.av.getSequenceSetId ()); +this.ap.av.sendSelection (); +}}}}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "copy_annotseqtoclipboard", +function (sq) { +if (sq == null || sq.getLength () < 1) { +return; +}jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer (); +jalview.appletgui.AlignFrame.copiedSequences.append (sq.getName () + "\t" + sq.getStart () + "\t" + sq.getEnd () + "\t" + sq.getSequenceAsString () + "\n"); +if (this.av.hasHiddenColumns ()) { +jalview.appletgui.AlignFrame.copiedHiddenColumns = new java.util.Vector (); +for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { +jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement ( Clazz.newIntArray (-1, [region[0], region[1]])); +} +}}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.av.getWrapAlignment () || !this.av.isShowAnnotation ()) return; +var w = this.getSize ().width; +var h = this.getSize ().height; +if (this.image == null || w != this.image.getWidth (this) || h != this.image.getHeight (this)) { +this.image = this.createImage (w, this.ap.annotationPanel.getSize ().height); +}this.drawComponent (this.image.getGraphics (), w); +g.drawImage (this.image, 0, 0, this); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawComponent", +function (g, width) { +g.setFont (this.av.getFont ()); +var fm = g.getFontMetrics (this.av.getFont ()); +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +g.translate (0, -this.scrollOffset); +g.setColor (java.awt.Color.black); +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +var y = 0; +var fy = g.getFont ().getSize (); +var x = 0; +var offset; +if (aa != null) { +this.hasHiddenRows = false; +for (var i = 0; i < aa.length; i++) { +if (!aa[i].visible) { +this.hasHiddenRows = true; +continue; +}x = width - fm.stringWidth (aa[i].label) - 3; +y += aa[i].height; +offset = Clazz.doubleToInt (-(aa[i].height - fy) / 2); +g.drawString (aa[i].label, x, y + offset); +} +}g.translate (0, +this.scrollOffset); +if (this.resizePanel) { +g.setColor (java.awt.Color.red); +g.setPaintMode (); +g.drawLine (2, 8, 5, 2); +g.drawLine (5, 2, 8, 8); +} else if (!this.dragCancelled && this.dragEvent != null && aa != null) { +g.setColor (java.awt.Color.lightGray); +g.drawString (aa[this.selectedRow].label, this.dragEvent.getX (), this.dragEvent.getY ()); +}if (!this.av.getWrapAlignment () && ((aa == null) || (aa.length < 1))) { +g.setColor (java.awt.Color.black); +g.drawString (jalview.util.MessageManager.getString ("label.right_click"), 2, 8); +g.drawString (jalview.util.MessageManager.getString ("label.to_add_annotation"), 2, 18); +}}, "java.awt.Graphics,~N"); +c$.$AnnotationLabels$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$1", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +jalview.analysis.AlignmentUtils.showOrHideSequenceAnnotations (this.b$["jalview.appletgui.AnnotationLabels"].ap.av.getAlignment (), java.util.Collections.singleton (this.f$.label), null, false, false); +this.b$["jalview.appletgui.AnnotationLabels"].refresh (); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$2", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +if (this.f$.aaa.groupRef != null) { +this.f$.aaa.groupRef.setIgnoreGapsConsensus (this.f$.cbmi.getState ()); +} else { +this.b$["jalview.appletgui.AnnotationLabels"].ap.av.setIgnoreGapsConsensus (this.f$.cbmi.getState (), this.b$["jalview.appletgui.AnnotationLabels"].ap); +}this.b$["jalview.appletgui.AnnotationLabels"].ap.paintAlignment (true); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$3", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +this.f$.aaa.groupRef.setShowConsensusHistogram (this.f$.chist.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$4$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$4", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +this.f$.aaa.groupRef.setshowSequenceLogo (this.f$.cprofl.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$5$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$5", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +this.f$.aaa.groupRef.setshowSequenceLogo (true); +this.f$.aaa.groupRef.setNormaliseSequenceLogo (this.f$.cprofn.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$6$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$6", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +this.b$["jalview.appletgui.AnnotationLabels"].av.setShowConsensusHistogram (this.f$.chist.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.alignFrame.showConsensusHistogram.setState (this.f$.chist.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$7$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$7", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +this.b$["jalview.appletgui.AnnotationLabels"].av.setShowSequenceLogo (this.f$.cprof.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.alignFrame.showSequenceLogo.setState (this.f$.cprof.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$AnnotationLabels$8$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "AnnotationLabels$8", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +this.b$["jalview.appletgui.AnnotationLabels"].av.setShowSequenceLogo (true); +this.b$["jalview.appletgui.AnnotationLabels"].ap.alignFrame.normSequenceLogo.setState (this.f$.cprofn.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].av.setNormaliseSequenceLogo (this.f$.cprofn.getState ()); +this.b$["jalview.appletgui.AnnotationLabels"].ap.repaint (); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"ADDNEW", "Add New Row", +"EDITNAME", "Edit Label/Description", +"HIDE", "Hide This Row", +"SHOWALL", "Show All Hidden Rows", +"OUTPUT_TEXT", "Show Values In Textbox", +"COPYCONS_SEQ", "Copy Consensus Sequence"); +}); diff --git a/bin/jalview/appletgui/AnnotationPanel.js b/bin/jalview/appletgui/AnnotationPanel.js index 6234bd3..33f7259 100644 --- a/bin/jalview/appletgui/AnnotationPanel.js +++ b/bin/jalview/appletgui/AnnotationPanel.js @@ -1,364 +1,364 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.renderer.AwtRenderPanelI", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "$.MouseMotionListener", "java.awt.Color"], "jalview.appletgui.AnnotationPanel", ["awt2swing.MenuItem", "$.PopupMenu", "jalview.appletgui.EditNameDialog", "$.UserDefinedColours", "jalview.datamodel.Annotation", "jalview.renderer.AnnotationRenderer", "jalview.util.MessageManager", "$.Platform", "java.awt.Dimension", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.ap = null; -this.activeRow = -1; -this.HELIX = "Helix"; -this.SHEET = "Sheet"; -this.STEM = "RNA Helix"; -this.LABEL = "Label"; -this.REMOVE = "Remove Annotation"; -this.COLOUR = "Colour"; -this.HELIX_COLOUR = null; -this.SHEET_COLOUR = null; -this.image = null; -this.gg = null; -this.fm = null; -this.imgWidth = 0; -this.$fastPaint = false; -this.graphStretch = -1; -this.graphStretchY = -1; -this.mouseDragging = false; -this.MAC = false; -this.renderer = null; -this.needValidating = false; -this.scrollOffset = 0; -this.$bounds = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationPanel", awt2swing.Panel, [jalview.renderer.AwtRenderPanelI, java.awt.event.AdjustmentListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); -Clazz.prepareFields (c$, function () { -this.HELIX_COLOUR = java.awt.Color.red.darker (); -this.SHEET_COLOUR = java.awt.Color.green.darker ().darker (); -this.$bounds = Clazz.newIntArray (2, 0); -}); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); -this.MAC = jalview.util.Platform.isAMac (); -this.ap = ap; -this.av = ap.av; -this.setLayout (null); -var height = this.adjustPanelHeight (); -ap.apvscroll.setValues (0, this.getSize ().height, 0, height); -this.addMouseMotionListener (this); -this.addMouseListener (this); -this.renderer = new jalview.renderer.AnnotationRenderer (); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); -this.av = av; -this.renderer = new jalview.renderer.AnnotationRenderer (); -}, "jalview.appletgui.AlignViewport"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -}, "java.awt.event.AdjustmentEvent"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}var anot = aa[this.activeRow].annotations; -if (anot.length < this.av.getColumnSelection ().getMax ()) { -var temp = new Array (this.av.getColumnSelection ().getMax () + 2); -System.arraycopy (anot, 0, temp, 0, anot.length); -anot = temp; -aa[this.activeRow].annotations = anot; -}var label = ""; -if (this.av.getColumnSelection () != null && this.av.getColumnSelection ().size () > 0 && anot[this.av.getColumnSelection ().getMin ()] != null) { -label = anot[this.av.getColumnSelection ().getMin ()].displayCharacter; -}if (evt.getActionCommand ().equals ("Remove Annotation")) { -for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -anot[this.av.getColumnSelection ().columnAt (i)] = null; -} -} else if (evt.getActionCommand ().equals ("Label")) { -label = this.enterLabel (label, "Enter Label"); -if (label == null) { -return; -}if ((label.length > 0) && !aa[this.activeRow].hasText) { -aa[this.activeRow].hasText = true; -}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -var index = this.av.getColumnSelection ().columnAt (i); -if (!this.av.getColumnSelection ().isVisible (index)) { -continue; -}if (anot[index] == null) { -anot[index] = new jalview.datamodel.Annotation (label, "", ' ', 0); -}anot[index].displayCharacter = label; -} -} else if (evt.getActionCommand ().equals ("Colour")) { -var udc = new jalview.appletgui.UserDefinedColours (this, java.awt.Color.black, this.ap.alignFrame); -var col = udc.getColor (); -for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -var index = this.av.getColumnSelection ().columnAt (i); -if (!this.av.getColumnSelection ().isVisible (index)) { -continue; -}if (anot[index] == null) { -anot[index] = new jalview.datamodel.Annotation ("", "", ' ', 0); -}anot[index].colour = col; -} -} else { -var type = String.fromCharCode (0); -var symbol = "\u03B1"; -if (evt.getActionCommand ().equals ("Helix")) { -type = 'H'; -} else if (evt.getActionCommand ().equals ("Sheet")) { -type = 'E'; -symbol = "\u03B2"; -} else if (evt.getActionCommand ().equals ("RNA Helix")) { -type = 'S'; -symbol = "\u03C3"; -}if (!aa[this.activeRow].hasIcons) { -aa[this.activeRow].hasIcons = true; -}label = this.enterLabel (symbol, "Enter Label"); -if (label == null) { -return; -}if ((label.length > 0) && !aa[this.activeRow].hasText) { -aa[this.activeRow].hasText = true; -if (evt.getActionCommand ().equals ("RNA Helix")) { -aa[this.activeRow].showAllColLabels = true; -}}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -var index = this.av.getColumnSelection ().columnAt (i); -if (!this.av.getColumnSelection ().isVisible (index)) { -continue; -}if (anot[index] == null) { -anot[index] = new jalview.datamodel.Annotation (label, "", type, 0); -}anot[index].secondaryStructure = type != 'S' ? type : label.length == 0 ? ' ' : label.charAt (0); -anot[index].displayCharacter = label; -} -}this.av.getAlignment ().validateAnnotation (aa[this.activeRow]); -this.ap.alignmentChanged (); -this.adjustPanelHeight (); -this.repaint (); -return; -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "enterLabel", -function (text, label) { -var dialog = new jalview.appletgui.EditNameDialog (text, null, label, null, this.ap.alignFrame, "Enter Label", 400, 200, true); -if (dialog.accept) { -return dialog.getName (); -} else { -return null; -}}, "~S,~S"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}var height = -this.scrollOffset; -this.activeRow = -1; -for (var i = 0; i < aa.length; i++) { -if (aa[i].visible) { -height += aa[i].height; -}if (evt.getY () < height) { -if (aa[i].editable) { -this.activeRow = i; -} else if (aa[i].graph > 0) { -this.graphStretch = i; -this.graphStretchY = evt.getY (); -}break; -}} -if ((evt.getModifiers () & 4) == 4 && this.activeRow != -1) { -if (this.av.getColumnSelection () == null) { -return; -}var pop = new awt2swing.PopupMenu (jalview.util.MessageManager.getString ("label.structure_type")); -var item; -if (this.av.getAlignment ().isNucleotide () == true) { -item = new awt2swing.MenuItem ("RNA Helix"); -item.addActionListener (this); -pop.add (item); -} else { -item = new awt2swing.MenuItem ("Helix"); -item.addActionListener (this); -pop.add (item); -item = new awt2swing.MenuItem ("Sheet"); -item.addActionListener (this); -pop.add (item); -}item = new awt2swing.MenuItem ("Label"); -item.addActionListener (this); -pop.add (item); -item = new awt2swing.MenuItem ("Colour"); -item.addActionListener (this); -pop.add (item); -item = new awt2swing.MenuItem ("Remove Annotation"); -item.addActionListener (this); -pop.add (item); -this.ap.alignFrame.add (pop); -pop.show (this, evt.getX (), evt.getY ()); -return; -}this.ap.scalePanel.mousePressed (evt); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.graphStretch = -1; -this.graphStretchY = -1; -this.mouseDragging = false; -if (this.needValidating) { -this.ap.validate (); -this.needValidating = false; -}this.ap.scalePanel.mouseReleased (evt); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -if (this.graphStretch > -1) { -this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight += this.graphStretchY - evt.getY (); -if (this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight < 0) { -this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight = 0; -}this.graphStretchY = evt.getY (); -this.av.calcPanelHeight (); -this.needValidating = true; -this.ap.paintAlignment (true); -} else { -this.ap.scalePanel.mouseDragged (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}var row = -1; -var height = -this.scrollOffset; -for (var i = 0; i < aa.length; i++) { -if (aa[i].visible) { -height += aa[i].height; -}if (evt.getY () < height) { -row = i; -break; -}} -var res = Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ()) + this.av.getStartRes (); -if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -}if (row > -1 && res < aa[row].annotations.length && aa[row].annotations[res] != null) { -var text = new StringBuffer ("Sequence position " + (res + 1)); -if (aa[row].annotations[res].description != null) { -text.append (" " + aa[row].annotations[res].description); -}this.ap.alignFrame.setStatus (text.toString ()); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -this.ap.scalePanel.mouseEntered (evt); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -this.ap.scalePanel.mouseExited (evt); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "adjustPanelHeight", -function () { -return this.adjustPanelHeight (true); -}); -Clazz.defineMethod (c$, "adjustPanelHeight", -function (repaint) { -var height = this.av.calcPanelHeight (); -this.setSize ( new java.awt.Dimension (this.getSize ().width, height)); -if (repaint) { -this.repaint (); -}return height; -}, "~B"); -Clazz.defineMethod (c$, "addEditableColumn", -function (i) { -if (this.activeRow == -1) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}for (var j = 0; j < aa.length; j++) { -if (aa[j].editable) { -this.activeRow = j; -break; -}} -}}, "~N"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.av.getWrapAlignment () || !this.av.isShowAnnotation ()) return; -var d = this.getSize (); -this.imgWidth = d.width; -if (this.imgWidth < 1 || d.height < 1) { -return; -}if (this.image == null || this.imgWidth != this.image.getWidth (this) || d.height != this.image.getHeight (this)) { -this.image = this.createImage (this.imgWidth, d.height); -this.gg = this.image.getGraphics (); -this.gg.setFont (this.av.getFont ()); -this.fm = this.gg.getFontMetrics (); -this.$fastPaint = false; -}if (this.$fastPaint) { -g.drawImage (this.image, 0, 0, this); -this.$fastPaint = false; -return; -}this.gg.setColor (java.awt.Color.white); -this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -this.drawComponent (this.gg, this.av.startRes, this.av.endRes + 1); -g.drawImage (this.image, 0, 0, this); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "fastPaint", -function (horizontal) { -if (horizontal == 0 || this.av.getAlignment ().getAlignmentAnnotation () == null || this.av.getAlignment ().getAlignmentAnnotation ().length < 1) { -this.repaint (); -return; -}this.gg.copyArea (0, 0, this.imgWidth, this.getSize ().height, -horizontal * this.av.getCharWidth (), 0); -var sr = this.av.startRes; -var er = this.av.endRes + 1; -var transX = 0; -if (horizontal > 0) { -transX = (er - sr - horizontal) * this.av.getCharWidth (); -sr = er - horizontal; -} else if (horizontal < 0) { -er = sr - horizontal; -}this.gg.translate (transX, 0); -this.drawComponent (this.gg, sr, er); -this.gg.translate (-transX, 0); -this.$fastPaint = true; -this.repaint (); -}, "~N"); -Clazz.defineMethod (c$, "drawComponent", -function (g, startRes, endRes) { -var ofont = this.av.getFont (); -g.setFont (ofont); -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, (endRes - startRes) * this.av.getCharWidth (), this.getSize ().height); -if (this.fm == null) { -this.fm = g.getFontMetrics (); -}if ((this.av.getAlignment ().getAlignmentAnnotation () == null) || (this.av.getAlignment ().getAlignmentAnnotation ().length < 1)) { -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -g.setColor (java.awt.Color.black); -if (this.av.validCharWidth) { -g.drawString (jalview.util.MessageManager.getString ("label.alignment_has_no_annotations"), 20, 15); -}return; -}g.translate (0, -this.scrollOffset); -this.renderer.drawComponent (this, this.av, g, this.activeRow, startRes, endRes); -g.translate (0, +this.scrollOffset); -}, "java.awt.Graphics,~N,~N"); -Clazz.defineMethod (c$, "setScrollOffset", -function (value, repaint) { -this.scrollOffset = value; -if (repaint) { -this.repaint (); -}}, "~N,~B"); -Clazz.defineMethod (c$, "getFontMetrics", -function () { -return this.fm; -}); -Clazz.overrideMethod (c$, "getFadedImage", -function () { -return this.image; -}); -Clazz.overrideMethod (c$, "getFadedImageWidth", -function () { -return this.imgWidth; -}); -Clazz.overrideMethod (c$, "getVisibleVRange", -function () { -if (this.ap != null && this.ap.alabels != null) { -var sOffset = -this.ap.alabels.scrollOffset; -var visHeight = sOffset + this.ap.annotationPanelHolder.getHeight (); -this.$bounds[0] = sOffset; -this.$bounds[1] = visHeight; -return this.$bounds; -} else { -return null; -}}); -Clazz.defineStatics (c$, -"GRAPH_HEIGHT", 40); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.renderer.AwtRenderPanelI", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "$.MouseMotionListener", "java.awt.Color"], "jalview.appletgui.AnnotationPanel", ["awt2swing.MenuItem", "$.PopupMenu", "jalview.appletgui.EditNameDialog", "$.UserDefinedColours", "jalview.datamodel.Annotation", "jalview.renderer.AnnotationRenderer", "jalview.util.MessageManager", "$.Platform", "java.awt.Dimension", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.ap = null; +this.activeRow = -1; +this.HELIX = "Helix"; +this.SHEET = "Sheet"; +this.STEM = "RNA Helix"; +this.LABEL = "Label"; +this.REMOVE = "Remove Annotation"; +this.COLOUR = "Colour"; +this.HELIX_COLOUR = null; +this.SHEET_COLOUR = null; +this.image = null; +this.gg = null; +this.fm = null; +this.imgWidth = 0; +this.$fastPaint = false; +this.graphStretch = -1; +this.graphStretchY = -1; +this.mouseDragging = false; +this.MAC = false; +this.renderer = null; +this.needValidating = false; +this.scrollOffset = 0; +this.$bounds = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationPanel", awt2swing.Panel, [jalview.renderer.AwtRenderPanelI, java.awt.event.AdjustmentListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); +Clazz.prepareFields (c$, function () { +this.HELIX_COLOUR = java.awt.Color.red.darker (); +this.SHEET_COLOUR = java.awt.Color.green.darker ().darker (); +this.$bounds = Clazz.newIntArray (2, 0); +}); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); +this.MAC = jalview.util.Platform.isAMac (); +this.ap = ap; +this.av = ap.av; +this.setLayout (null); +var height = this.adjustPanelHeight (); +ap.apvscroll.setValues (0, this.getSize ().height, 0, height); +this.addMouseMotionListener (this); +this.addMouseListener (this); +this.renderer = new jalview.renderer.AnnotationRenderer (); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); +this.av = av; +this.renderer = new jalview.renderer.AnnotationRenderer (); +}, "jalview.appletgui.AlignViewport"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +}, "java.awt.event.AdjustmentEvent"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}var anot = aa[this.activeRow].annotations; +if (anot.length < this.av.getColumnSelection ().getMax ()) { +var temp = new Array (this.av.getColumnSelection ().getMax () + 2); +System.arraycopy (anot, 0, temp, 0, anot.length); +anot = temp; +aa[this.activeRow].annotations = anot; +}var label = ""; +if (this.av.getColumnSelection () != null && this.av.getColumnSelection ().size () > 0 && anot[this.av.getColumnSelection ().getMin ()] != null) { +label = anot[this.av.getColumnSelection ().getMin ()].displayCharacter; +}if (evt.getActionCommand ().equals ("Remove Annotation")) { +for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +anot[this.av.getColumnSelection ().columnAt (i)] = null; +} +} else if (evt.getActionCommand ().equals ("Label")) { +label = this.enterLabel (label, "Enter Label"); +if (label == null) { +return; +}if ((label.length > 0) && !aa[this.activeRow].hasText) { +aa[this.activeRow].hasText = true; +}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +var index = this.av.getColumnSelection ().columnAt (i); +if (!this.av.getColumnSelection ().isVisible (index)) { +continue; +}if (anot[index] == null) { +anot[index] = new jalview.datamodel.Annotation (label, "", ' ', 0); +}anot[index].displayCharacter = label; +} +} else if (evt.getActionCommand ().equals ("Colour")) { +var udc = new jalview.appletgui.UserDefinedColours (this, java.awt.Color.black, this.ap.alignFrame); +var col = udc.getColor (); +for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +var index = this.av.getColumnSelection ().columnAt (i); +if (!this.av.getColumnSelection ().isVisible (index)) { +continue; +}if (anot[index] == null) { +anot[index] = new jalview.datamodel.Annotation ("", "", ' ', 0); +}anot[index].colour = col; +} +} else { +var type = String.fromCharCode (0); +var symbol = "\u03B1"; +if (evt.getActionCommand ().equals ("Helix")) { +type = 'H'; +} else if (evt.getActionCommand ().equals ("Sheet")) { +type = 'E'; +symbol = "\u03B2"; +} else if (evt.getActionCommand ().equals ("RNA Helix")) { +type = 'S'; +symbol = "\u03C3"; +}if (!aa[this.activeRow].hasIcons) { +aa[this.activeRow].hasIcons = true; +}label = this.enterLabel (symbol, "Enter Label"); +if (label == null) { +return; +}if ((label.length > 0) && !aa[this.activeRow].hasText) { +aa[this.activeRow].hasText = true; +if (evt.getActionCommand ().equals ("RNA Helix")) { +aa[this.activeRow].showAllColLabels = true; +}}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +var index = this.av.getColumnSelection ().columnAt (i); +if (!this.av.getColumnSelection ().isVisible (index)) { +continue; +}if (anot[index] == null) { +anot[index] = new jalview.datamodel.Annotation (label, "", type, 0); +}anot[index].secondaryStructure = type != 'S' ? type : label.length == 0 ? ' ' : label.charAt (0); +anot[index].displayCharacter = label; +} +}this.av.getAlignment ().validateAnnotation (aa[this.activeRow]); +this.ap.alignmentChanged (); +this.adjustPanelHeight (); +this.repaint (); +return; +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "enterLabel", +function (text, label) { +var dialog = new jalview.appletgui.EditNameDialog (text, null, label, null, this.ap.alignFrame, "Enter Label", 400, 200, true); +if (dialog.accept) { +return dialog.getName (); +} else { +return null; +}}, "~S,~S"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}var height = -this.scrollOffset; +this.activeRow = -1; +for (var i = 0; i < aa.length; i++) { +if (aa[i].visible) { +height += aa[i].height; +}if (evt.getY () < height) { +if (aa[i].editable) { +this.activeRow = i; +} else if (aa[i].graph > 0) { +this.graphStretch = i; +this.graphStretchY = evt.getY (); +}break; +}} +if ((evt.getModifiers () & 4) == 4 && this.activeRow != -1) { +if (this.av.getColumnSelection () == null) { +return; +}var pop = new awt2swing.PopupMenu (jalview.util.MessageManager.getString ("label.structure_type")); +var item; +if (this.av.getAlignment ().isNucleotide () == true) { +item = new awt2swing.MenuItem ("RNA Helix"); +item.addActionListener (this); +pop.add (item); +} else { +item = new awt2swing.MenuItem ("Helix"); +item.addActionListener (this); +pop.add (item); +item = new awt2swing.MenuItem ("Sheet"); +item.addActionListener (this); +pop.add (item); +}item = new awt2swing.MenuItem ("Label"); +item.addActionListener (this); +pop.add (item); +item = new awt2swing.MenuItem ("Colour"); +item.addActionListener (this); +pop.add (item); +item = new awt2swing.MenuItem ("Remove Annotation"); +item.addActionListener (this); +pop.add (item); +this.ap.alignFrame.add (pop); +pop.show (this, evt.getX (), evt.getY ()); +return; +}this.ap.scalePanel.mousePressed (evt); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.graphStretch = -1; +this.graphStretchY = -1; +this.mouseDragging = false; +if (this.needValidating) { +this.ap.validate (); +this.needValidating = false; +}this.ap.scalePanel.mouseReleased (evt); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +if (this.graphStretch > -1) { +this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight += this.graphStretchY - evt.getY (); +if (this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight < 0) { +this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight = 0; +}this.graphStretchY = evt.getY (); +this.av.calcPanelHeight (); +this.needValidating = true; +this.ap.paintAlignment (true); +} else { +this.ap.scalePanel.mouseDragged (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}var row = -1; +var height = -this.scrollOffset; +for (var i = 0; i < aa.length; i++) { +if (aa[i].visible) { +height += aa[i].height; +}if (evt.getY () < height) { +row = i; +break; +}} +var res = Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ()) + this.av.getStartRes (); +if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +}if (row > -1 && res < aa[row].annotations.length && aa[row].annotations[res] != null) { +var text = new StringBuffer ("Sequence position " + (res + 1)); +if (aa[row].annotations[res].description != null) { +text.append (" " + aa[row].annotations[res].description); +}this.ap.alignFrame.setStatus (text.toString ()); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +this.ap.scalePanel.mouseEntered (evt); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +this.ap.scalePanel.mouseExited (evt); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "adjustPanelHeight", +function () { +return this.adjustPanelHeight (true); +}); +Clazz.defineMethod (c$, "adjustPanelHeight", +function (repaint) { +var height = this.av.calcPanelHeight (); +this.setSize ( new java.awt.Dimension (this.getSize ().width, height)); +if (repaint) { +this.repaint (); +}return height; +}, "~B"); +Clazz.defineMethod (c$, "addEditableColumn", +function (i) { +if (this.activeRow == -1) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}for (var j = 0; j < aa.length; j++) { +if (aa[j].editable) { +this.activeRow = j; +break; +}} +}}, "~N"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.av.getWrapAlignment () || !this.av.isShowAnnotation ()) return; +var d = this.getSize (); +this.imgWidth = d.width; +if (this.imgWidth < 1 || d.height < 1) { +return; +}if (this.image == null || this.imgWidth != this.image.getWidth (this) || d.height != this.image.getHeight (this)) { +this.image = this.createImage (this.imgWidth, d.height); +this.gg = this.image.getGraphics (); +this.gg.setFont (this.av.getFont ()); +this.fm = this.gg.getFontMetrics (); +this.$fastPaint = false; +}if (this.$fastPaint) { +g.drawImage (this.image, 0, 0, this); +this.$fastPaint = false; +return; +}this.gg.setColor (java.awt.Color.white); +this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +this.drawComponent (this.gg, this.av.startRes, this.av.endRes + 1); +g.drawImage (this.image, 0, 0, this); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "fastPaint", +function (horizontal) { +if (horizontal == 0 || this.av.getAlignment ().getAlignmentAnnotation () == null || this.av.getAlignment ().getAlignmentAnnotation ().length < 1) { +this.repaint (); +return; +}this.gg.copyArea (0, 0, this.imgWidth, this.getSize ().height, -horizontal * this.av.getCharWidth (), 0); +var sr = this.av.startRes; +var er = this.av.endRes + 1; +var transX = 0; +if (horizontal > 0) { +transX = (er - sr - horizontal) * this.av.getCharWidth (); +sr = er - horizontal; +} else if (horizontal < 0) { +er = sr - horizontal; +}this.gg.translate (transX, 0); +this.drawComponent (this.gg, sr, er); +this.gg.translate (-transX, 0); +this.$fastPaint = true; +this.repaint (); +}, "~N"); +Clazz.defineMethod (c$, "drawComponent", +function (g, startRes, endRes) { +var ofont = this.av.getFont (); +g.setFont (ofont); +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, (endRes - startRes) * this.av.getCharWidth (), this.getSize ().height); +if (this.fm == null) { +this.fm = g.getFontMetrics (); +}if ((this.av.getAlignment ().getAlignmentAnnotation () == null) || (this.av.getAlignment ().getAlignmentAnnotation ().length < 1)) { +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +g.setColor (java.awt.Color.black); +if (this.av.validCharWidth) { +g.drawString (jalview.util.MessageManager.getString ("label.alignment_has_no_annotations"), 20, 15); +}return; +}g.translate (0, -this.scrollOffset); +this.renderer.drawComponent (this, this.av, g, this.activeRow, startRes, endRes); +g.translate (0, +this.scrollOffset); +}, "java.awt.Graphics,~N,~N"); +Clazz.defineMethod (c$, "setScrollOffset", +function (value, repaint) { +this.scrollOffset = value; +if (repaint) { +this.repaint (); +}}, "~N,~B"); +Clazz.defineMethod (c$, "getFontMetrics", +function () { +return this.fm; +}); +Clazz.overrideMethod (c$, "getFadedImage", +function () { +return this.image; +}); +Clazz.overrideMethod (c$, "getFadedImageWidth", +function () { +return this.imgWidth; +}); +Clazz.overrideMethod (c$, "getVisibleVRange", +function () { +if (this.ap != null && this.ap.alabels != null) { +var sOffset = -this.ap.alabels.scrollOffset; +var visHeight = sOffset + this.ap.annotationPanelHolder.getHeight (); +this.$bounds[0] = sOffset; +this.$bounds[1] = visHeight; +return this.$bounds; +} else { +return null; +}}); +Clazz.defineStatics (c$, +"GRAPH_HEIGHT", 40); +}); diff --git a/bin/jalview/appletgui/AnnotationRowFilter.js b/bin/jalview/appletgui/AnnotationRowFilter.js index aafbcad..8b9fe70 100644 --- a/bin/jalview/appletgui/AnnotationRowFilter.js +++ b/bin/jalview/appletgui/AnnotationRowFilter.js @@ -1,131 +1,131 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "$.Button", "$.Checkbox", "$.Scrollbar", "$.TextField"], "jalview.appletgui.AnnotationRowFilter", ["jalview.util.MessageManager", "java.lang.Float", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.ap = null; -this.annmap = null; -this.enableSeqAss = false; -this.currentAnnotation = null; -this.adjusting = false; -this.currentColours = null; -this.minColour = null; -this.maxColour = null; -this.seqAssociated = null; -this.thresholdIsMin = null; -this.slider = null; -this.thresholdValue = null; -this.frame = null; -this.ok = null; -this.cancel = null; -this.sliderDragging = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationRowFilter", awt2swing.Panel); -Clazz.prepareFields (c$, function () { -this.currentColours = new awt2swing.Checkbox (); -this.minColour = new awt2swing.Panel (); -this.maxColour = new awt2swing.Panel (); -this.seqAssociated = new awt2swing.Checkbox (); -this.thresholdIsMin = new awt2swing.Checkbox (); -this.slider = new awt2swing.Scrollbar (0); -this.thresholdValue = new awt2swing.TextField (20); -this.ok = new awt2swing.Button (); -this.cancel = new awt2swing.Button (); -}); -Clazz.makeConstructor (c$, -function (av, ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationRowFilter, []); -this.av = av; -this.ap = ap; -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.AnnotationRowFilter, []); -}); -Clazz.defineMethod (c$, "getAnnotationItems", -function (isSeqAssociated) { -var list = new java.util.Vector (); -var index = 1; -var anmap = Clazz.newIntArray (this.av.getAlignment ().getAlignmentAnnotation ().length, 0); -for (var i = 0; i < this.av.getAlignment ().getAlignmentAnnotation ().length; i++) { -if (this.av.getAlignment ().getAlignmentAnnotation ()[i].sequenceRef == null) { -if (isSeqAssociated) { -continue; -}} else { -this.enableSeqAss = true; -}var label = this.av.getAlignment ().getAlignmentAnnotation ()[i].label; -if (!list.contains (label)) { -anmap[list.size ()] = i; -list.add (label); -} else { -if (!isSeqAssociated) { -anmap[list.size ()] = i; -list.add (label + "_" + (index++)); -}}} -this.annmap = Clazz.newIntArray (list.size (), 0); -System.arraycopy (anmap, 0, this.annmap, 0, this.annmap.length); -return list; -}, "~B"); -Clazz.defineMethod (c$, "getSelectedThresholdItem", -function (indexValue) { -var selectedThresholdItem = -1; -if (indexValue == 1) { -selectedThresholdItem = 1; -} else if (indexValue == 2) { -selectedThresholdItem = 0; -}return selectedThresholdItem; -}, "~N"); -Clazz.defineMethod (c$, "modelChanged", -function () { -this.seqAssociated.setEnabled (this.enableSeqAss); -}); -Clazz.defineMethod (c$, "ok_actionPerformed", -function (e) { -this.updateView (); -this.frame.setVisible (false); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "cancel_actionPerformed", -function (e) { -this.reset (); -this.ap.paintAlignment (true); -this.frame.setVisible (false); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "thresholdCheck_actionPerformed", -function (e) { -this.updateView (); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "annotations_actionPerformed", -function (e) { -this.updateView (); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "threshold_actionPerformed", -function (e) { -this.updateView (); -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "thresholdValue_actionPerformed", -function (e) { -try { -var f = Float.parseFloat (this.thresholdValue.getText ()); -this.slider.setValue (Clazz.floatToInt (f * 1000)); -this.updateView (); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "populateThresholdComboBox", -function (threshold) { -threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); -threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); -threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); -}, "awt2swing.Choice"); -Clazz.defineMethod (c$, "getCurrentAnnotation", -function () { -return this.currentAnnotation; -}); -Clazz.defineMethod (c$, "setCurrentAnnotation", -function (currentAnnotation) { -this.currentAnnotation = currentAnnotation; -}, "jalview.datamodel.AlignmentAnnotation"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "$.Button", "$.Checkbox", "$.Scrollbar", "$.TextField"], "jalview.appletgui.AnnotationRowFilter", ["jalview.util.MessageManager", "java.lang.Float", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.ap = null; +this.annmap = null; +this.enableSeqAss = false; +this.currentAnnotation = null; +this.adjusting = false; +this.currentColours = null; +this.minColour = null; +this.maxColour = null; +this.seqAssociated = null; +this.thresholdIsMin = null; +this.slider = null; +this.thresholdValue = null; +this.frame = null; +this.ok = null; +this.cancel = null; +this.sliderDragging = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationRowFilter", awt2swing.Panel); +Clazz.prepareFields (c$, function () { +this.currentColours = new awt2swing.Checkbox (); +this.minColour = new awt2swing.Panel (); +this.maxColour = new awt2swing.Panel (); +this.seqAssociated = new awt2swing.Checkbox (); +this.thresholdIsMin = new awt2swing.Checkbox (); +this.slider = new awt2swing.Scrollbar (0); +this.thresholdValue = new awt2swing.TextField (20); +this.ok = new awt2swing.Button (); +this.cancel = new awt2swing.Button (); +}); +Clazz.makeConstructor (c$, +function (av, ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationRowFilter, []); +this.av = av; +this.ap = ap; +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.AnnotationRowFilter, []); +}); +Clazz.defineMethod (c$, "getAnnotationItems", +function (isSeqAssociated) { +var list = new java.util.Vector (); +var index = 1; +var anmap = Clazz.newIntArray (this.av.getAlignment ().getAlignmentAnnotation ().length, 0); +for (var i = 0; i < this.av.getAlignment ().getAlignmentAnnotation ().length; i++) { +if (this.av.getAlignment ().getAlignmentAnnotation ()[i].sequenceRef == null) { +if (isSeqAssociated) { +continue; +}} else { +this.enableSeqAss = true; +}var label = this.av.getAlignment ().getAlignmentAnnotation ()[i].label; +if (!list.contains (label)) { +anmap[list.size ()] = i; +list.add (label); +} else { +if (!isSeqAssociated) { +anmap[list.size ()] = i; +list.add (label + "_" + (index++)); +}}} +this.annmap = Clazz.newIntArray (list.size (), 0); +System.arraycopy (anmap, 0, this.annmap, 0, this.annmap.length); +return list; +}, "~B"); +Clazz.defineMethod (c$, "getSelectedThresholdItem", +function (indexValue) { +var selectedThresholdItem = -1; +if (indexValue == 1) { +selectedThresholdItem = 1; +} else if (indexValue == 2) { +selectedThresholdItem = 0; +}return selectedThresholdItem; +}, "~N"); +Clazz.defineMethod (c$, "modelChanged", +function () { +this.seqAssociated.setEnabled (this.enableSeqAss); +}); +Clazz.defineMethod (c$, "ok_actionPerformed", +function (e) { +this.updateView (); +this.frame.setVisible (false); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "cancel_actionPerformed", +function (e) { +this.reset (); +this.ap.paintAlignment (true); +this.frame.setVisible (false); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "thresholdCheck_actionPerformed", +function (e) { +this.updateView (); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "annotations_actionPerformed", +function (e) { +this.updateView (); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "threshold_actionPerformed", +function (e) { +this.updateView (); +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "thresholdValue_actionPerformed", +function (e) { +try { +var f = Float.parseFloat (this.thresholdValue.getText ()); +this.slider.setValue (Clazz.floatToInt (f * 1000)); +this.updateView (); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "populateThresholdComboBox", +function (threshold) { +threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); +threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); +threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); +}, "awt2swing.Choice"); +Clazz.defineMethod (c$, "getCurrentAnnotation", +function () { +return this.currentAnnotation; +}); +Clazz.defineMethod (c$, "setCurrentAnnotation", +function (currentAnnotation) { +this.currentAnnotation = currentAnnotation; +}, "jalview.datamodel.AlignmentAnnotation"); +}); diff --git a/bin/jalview/appletgui/AppletJmol.js b/bin/jalview/appletgui/AppletJmol.js index b8f808a..d2a97b8 100644 --- a/bin/jalview/appletgui/AppletJmol.js +++ b/bin/jalview/appletgui/AppletJmol.js @@ -1,48 +1,48 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.Dimension", "java.util.ArrayList"], "jalview.appletgui.AppletJmol", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.scriptWindow = null; -this.inputLine = null; -this.history = null; -this.renderPanel = null; -this.ap = null; -this._aps = null; -this.fileLoadingError = null; -this.loadedInline = false; -this.fr = null; -this.jmb = null; -if (!Clazz.isClassDefined ("jalview.appletgui.AppletJmol.RenderPanel")) { -jalview.appletgui.AppletJmol.$AppletJmol$RenderPanel$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AppletJmol"); -Clazz.prepareFields (c$, function () { -this._aps = new java.util.ArrayList (); -}); -Clazz.makeConstructor (c$, -function (entry, sequenceIs, object, ap2, uRL) { -}, "jalview.datamodel.PDBEntry,~A,~O,jalview.appletgui.AlignmentPanel,~S"); -Clazz.defineMethod (c$, "setJalviewColourScheme", -function (ucs) { -}, "jalview.schemes.UserColourScheme"); -c$.$AppletJmol$RenderPanel$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.currentSize = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.AppletJmol, "RenderPanel", awt2swing.Panel); -Clazz.prepareFields (c$, function () { -this.currentSize = new java.awt.Dimension (); -}); -Clazz.overrideMethod (c$, "update", -function (a) { -this.paint (a); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "PaintComponent", -function (a) { -this.currentSize = this.getSize (); -}, "java.awt.Graphics"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.Dimension", "java.util.ArrayList"], "jalview.appletgui.AppletJmol", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.scriptWindow = null; +this.inputLine = null; +this.history = null; +this.renderPanel = null; +this.ap = null; +this._aps = null; +this.fileLoadingError = null; +this.loadedInline = false; +this.fr = null; +this.jmb = null; +if (!Clazz.isClassDefined ("jalview.appletgui.AppletJmol.RenderPanel")) { +jalview.appletgui.AppletJmol.$AppletJmol$RenderPanel$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AppletJmol"); +Clazz.prepareFields (c$, function () { +this._aps = new java.util.ArrayList (); +}); +Clazz.makeConstructor (c$, +function (entry, sequenceIs, object, ap2, uRL) { +}, "jalview.datamodel.PDBEntry,~A,~O,jalview.appletgui.AlignmentPanel,~S"); +Clazz.defineMethod (c$, "setJalviewColourScheme", +function (ucs) { +}, "jalview.schemes.UserColourScheme"); +c$.$AppletJmol$RenderPanel$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.currentSize = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.AppletJmol, "RenderPanel", awt2swing.Panel); +Clazz.prepareFields (c$, function () { +this.currentSize = new java.awt.Dimension (); +}); +Clazz.overrideMethod (c$, "update", +function (a) { +this.paint (a); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "PaintComponent", +function (a) { +this.currentSize = this.getSize (); +}, "java.awt.Graphics"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/AppletJmolBinding.js b/bin/jalview/appletgui/AppletJmolBinding.js index 7f93e13..cdb8890 100644 --- a/bin/jalview/appletgui/AppletJmolBinding.js +++ b/bin/jalview/appletgui/AppletJmolBinding.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.appletgui"); -c$ = Clazz.declareType (jalview.appletgui, "AppletJmolBinding"); +Clazz.declarePackage ("jalview.appletgui"); +c$ = Clazz.declareType (jalview.appletgui, "AppletJmolBinding"); diff --git a/bin/jalview/appletgui/CutAndPasteTransfer.js b/bin/jalview/appletgui/CutAndPasteTransfer.js index 4030094..c1e339a 100644 --- a/bin/jalview/appletgui/CutAndPasteTransfer.js +++ b/bin/jalview/appletgui/CutAndPasteTransfer.js @@ -1,264 +1,264 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.MouseListener", "awt2swing.Button", "$.TextArea", "java.awt.BorderLayout"], "jalview.appletgui.CutAndPasteTransfer", ["awt2swing.Frame", "$.Label", "jalview.analysis.AlignmentUtils", "jalview.api.ComplexAlignFile", "jalview.appletgui.AlignFrame", "$.AppletJmol", "$.JVDialog", "$.SplitFrame", "jalview.datamodel.PDBEntry", "jalview.io.AnnotationFile", "$.AppletFormatAdapter", "$.IdentifyFile", "$.NewickFile", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.TCoffeeColourScheme", "jalview.util.MessageManager", "java.awt.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.pdbImport = false; -this.treeImport = false; -this.annotationImport = false; -this.seq = null; -this.alignFrame = null; -this.source = null; -this.textarea = null; -this.accept = null; -this.addSequences = null; -this.$cancel = null; -this.buttonPanel = null; -this.borderLayout1 = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "CutAndPasteTransfer", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.MouseListener]); -Clazz.prepareFields (c$, function () { -this.textarea = new awt2swing.TextArea (); -this.accept = new awt2swing.Button ("New Window"); -this.addSequences = new awt2swing.Button ("Add to Current Alignment"); -this.$cancel = new awt2swing.Button ("Close"); -this.buttonPanel = new awt2swing.Panel (); -this.borderLayout1 = new java.awt.BorderLayout (); -}); -Clazz.makeConstructor (c$, -function (forImport, alignFrame) { -Clazz.superConstructor (this, jalview.appletgui.CutAndPasteTransfer, []); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.alignFrame = alignFrame; -if (!forImport) { -this.buttonPanel.setVisible (false); -}}, "~B,jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "getText", -function () { -return this.textarea.getText (); -}); -Clazz.defineMethod (c$, "setText", -function (text) { -this.textarea.setText (text); -}, "~S"); -Clazz.defineMethod (c$, "setPDBImport", -function (seq) { -this.seq = seq; -this.accept.setLabel (jalview.util.MessageManager.getString ("action.accept")); -this.addSequences.setVisible (false); -this.pdbImport = true; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "setTreeImport", -function () { -this.treeImport = true; -this.accept.setLabel (jalview.util.MessageManager.getString ("action.accept")); -this.addSequences.setVisible (false); -}); -Clazz.defineMethod (c$, "setAnnotationImport", -function () { -this.annotationImport = true; -this.accept.setLabel (jalview.util.MessageManager.getString ("action.accept")); -this.addSequences.setVisible (false); -}); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.accept) { -this.ok (true); -} else if (evt.getSource () === this.addSequences) { -this.ok (false); -} else if (evt.getSource () === this.$cancel) { -this.cancel (); -}}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "ok", -function (newWindow) { -var text = this.getText (); -var length = text.length; -this.textarea.append ("\n"); -if (this.textarea.getText ().length == length) { -var warning = "\n\n#################################################\nWARNING!! THIS IS THE MAXIMUM SIZE OF TEXTAREA!!\n\nCAN\'T INPUT FULL ALIGNMENT\n\nYOU MUST DELETE THIS WARNING TO CONTINUE\n\nMAKE SURE LAST SEQUENCE PASTED IS COMPLETE\n#################################################\n"; -this.textarea.setText (text.substring (0, text.length - warning.length) + warning); -this.textarea.setCaretPosition (text.length); -}if (this.pdbImport) { -this.openPdbViewer (text); -} else if (this.treeImport) { -if (!this.loadTree ()) { -return; -}} else if (this.annotationImport) { -this.loadAnnotations (); -} else if (this.alignFrame != null) { -this.loadAlignment (text, newWindow, this.alignFrame.getAlignViewport ()); -}if (Clazz.instanceOf (this.getParent (), awt2swing.Frame)) { -(this.getParent ()).setVisible (false); -} else { -(this.getParent ()).setVisible (false); -}}, "~B"); -Clazz.defineMethod (c$, "loadTree", -function () { -try { -var fin = new jalview.io.NewickFile (this.textarea.getText (), "Paste"); -fin.parse (); -if (fin.getTree () != null) { -this.alignFrame.loadTree (fin, "Pasted tree file"); -return true; -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -this.textarea.setText (jalview.util.MessageManager.formatMessage ("label.could_not_parse_newick_file", Clazz.newArray (-1, [ex.getMessage ()]))); -return false; -} else { -throw ex; -} -} -return false; -}); -Clazz.defineMethod (c$, "loadAlignment", -function (text, newWindow, viewport) { -var al = null; -var format = new jalview.io.IdentifyFile ().Identify (text, jalview.io.AppletFormatAdapter.PASTE); -var afa = new jalview.io.AppletFormatAdapter (this.alignFrame.alignPanel); -try { -al = afa.readFile (text, jalview.io.AppletFormatAdapter.PASTE, format); -this.source = afa.getAlignFile (); -} catch (ex) { -if (Clazz.exceptionOf (ex, java.io.IOException)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -if (al != null) { -al.setDataset (null); -var allowSplitFrame = this.alignFrame.viewport.applet.getDefaultParameter ("enableSplitFrame", false); -if (allowSplitFrame && this.openSplitFrame (al, format)) { -return; -}if (newWindow) { -var af; -if (Clazz.instanceOf (this.source, jalview.api.ComplexAlignFile)) { -var colSel = (this.source).getColumnSelection (); -var hiddenSeqs = (this.source).getHiddenSequences (); -var showSeqFeatures = (this.source).isShowSeqFeatures (); -var cs = (this.source).getColourScheme (); -af = new jalview.appletgui.AlignFrame (al, hiddenSeqs, colSel, this.alignFrame.viewport.applet, "Cut & Paste input - " + format, false); -af.getAlignViewport ().setShowSequenceFeatures (showSeqFeatures); -af.changeColour (cs); -} else { -af = new jalview.appletgui.AlignFrame (al, this.alignFrame.viewport.applet, "Cut & Paste input - " + format, false); -}af.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_annotation_to_alignment")); -} else { -this.alignFrame.addSequences (al.getSequencesArray ()); -this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_alignment_file")); -}}}, "~S,~B,jalview.appletgui.AlignViewport"); -Clazz.defineMethod (c$, "openSplitFrame", -function (al, format) { -var thisAlignment = this.alignFrame.getAlignViewport ().getAlignment (); -if (thisAlignment.isNucleotide () == al.isNucleotide ()) { -return false; -}var protein = thisAlignment.isNucleotide () ? al : thisAlignment; -var dna = thisAlignment.isNucleotide () ? thisAlignment : al; -var mapped = jalview.analysis.AlignmentUtils.mapProteinToCdna (protein, dna); -if (!mapped) { -return false; -}var title = jalview.util.MessageManager.getString ("label.open_split_window"); -var dialog = new jalview.appletgui.JVDialog (this.getParent (), title, true, 100, 400); -dialog.ok.setLabel (jalview.util.MessageManager.getString ("action.yes")); -dialog.cancel.setLabel (jalview.util.MessageManager.getString ("action.no")); -var question = new awt2swing.Panel ( new java.awt.BorderLayout ()); -var text = jalview.util.MessageManager.getString ("label.open_split_window?"); -question.add ( new awt2swing.Label (text, 0), "Center"); -dialog.setMainPanel (question); -dialog.setVisible (true); -dialog.toFront (); -if (!dialog.accept) { -return false; -}var applet = this.alignFrame.viewport.applet; -var copyFrame = new jalview.appletgui.AlignFrame (this.alignFrame.viewport.getAlignment (), applet, this.alignFrame.getTitle (), false, false); -var newFrame = new jalview.appletgui.AlignFrame (al, this.alignFrame.viewport.applet, "Cut & Paste input - " + format, false, false); -var dnaFrame = al.isNucleotide () ? newFrame : copyFrame; -var proteinFrame = al.isNucleotide () ? copyFrame : newFrame; -var sf = new jalview.appletgui.SplitFrame (dnaFrame, proteinFrame); -sf.addToDisplay (false, applet); -return true; -}, "jalview.datamodel.AlignmentI,~S"); -Clazz.defineMethod (c$, "loadAnnotations", -function () { -var tcf = null; -try { -tcf = jalview.jsdev.GenericFileAdapter.getFile ("TCoffeeScoreFile", [this.textarea.getText (), jalview.io.AppletFormatAdapter.PASTE]); -if (tcf.isValid ()) { -if (tcf.annotateAlignment (this.alignFrame.viewport.getAlignment (), true)) { -this.alignFrame.tcoffeeColour.setEnabled (true); -this.alignFrame.alignPanel.fontChanged (); -this.alignFrame.changeColour ( new jalview.schemes.TCoffeeColourScheme (this.alignFrame.viewport.getAlignment ())); -this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_tcoffee_scores_to_alignment")); -} else { -this.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.failed_add_tcoffee_scores", Clazz.newArray (-1, [(tcf.getWarningMessage () != null ? tcf.getWarningMessage () : "")]))); -}} else { -tcf = null; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -tcf = null; -} else { -throw x; -} -} -if (tcf == null) { -if ( new jalview.io.AnnotationFile ().annotateAlignmentView (this.alignFrame.viewport, this.textarea.getText (), jalview.io.AppletFormatAdapter.PASTE)) { -this.alignFrame.alignPanel.fontChanged (); -this.alignFrame.alignPanel.setScrollValues (0, 0); -this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_annotation_to_alignment")); -} else { -if (!this.alignFrame.parseFeaturesFile (this.textarea.getText (), jalview.io.AppletFormatAdapter.PASTE)) { -this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.couldnt_parse_pasted_text_as_valid_annotation_feature_GFF_tcoffee_file")); -}}}}); -Clazz.defineMethod (c$, "openPdbViewer", -function (text) { -var pdb = new jalview.datamodel.PDBEntry (); -pdb.setFile (text); - new jalview.appletgui.AppletJmol (pdb, Clazz.newArray (-1, [this.seq]), null, this.alignFrame.alignPanel, jalview.io.AppletFormatAdapter.PASTE); -}, "~S"); -Clazz.defineMethod (c$, "cancel", -function () { -this.textarea.setText (""); -if (Clazz.instanceOf (this.getParent (), awt2swing.Frame)) { -(this.getParent ()).setVisible (false); -} else { -(this.getParent ()).setVisible (false); -}}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.textarea.setFont ( new java.awt.Font ("Monospaced", 0, 10)); -this.textarea.setText (jalview.util.MessageManager.getString ("label.paste_your_alignment_file")); -this.textarea.addMouseListener (this); -this.setLayout (this.borderLayout1); -this.accept.addActionListener (this); -this.addSequences.addActionListener (this); -this.$cancel.addActionListener (this); -this.add (this.buttonPanel, "South"); -this.buttonPanel.add (this.accept, null); -this.buttonPanel.add (this.addSequences); -this.buttonPanel.add (this.$cancel, null); -this.add (this.textarea, "Center"); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -if (this.textarea.getText ().startsWith (jalview.util.MessageManager.getString ("label.paste_your"))) { -this.textarea.setText (""); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.MouseListener", "awt2swing.Button", "$.TextArea", "java.awt.BorderLayout"], "jalview.appletgui.CutAndPasteTransfer", ["awt2swing.Frame", "$.Label", "jalview.analysis.AlignmentUtils", "jalview.api.ComplexAlignFile", "jalview.appletgui.AlignFrame", "$.AppletJmol", "$.JVDialog", "$.SplitFrame", "jalview.datamodel.PDBEntry", "jalview.io.AnnotationFile", "$.AppletFormatAdapter", "$.IdentifyFile", "$.NewickFile", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.TCoffeeColourScheme", "jalview.util.MessageManager", "java.awt.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.pdbImport = false; +this.treeImport = false; +this.annotationImport = false; +this.seq = null; +this.alignFrame = null; +this.source = null; +this.textarea = null; +this.accept = null; +this.addSequences = null; +this.$cancel = null; +this.buttonPanel = null; +this.borderLayout1 = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "CutAndPasteTransfer", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.MouseListener]); +Clazz.prepareFields (c$, function () { +this.textarea = new awt2swing.TextArea (); +this.accept = new awt2swing.Button ("New Window"); +this.addSequences = new awt2swing.Button ("Add to Current Alignment"); +this.$cancel = new awt2swing.Button ("Close"); +this.buttonPanel = new awt2swing.Panel (); +this.borderLayout1 = new java.awt.BorderLayout (); +}); +Clazz.makeConstructor (c$, +function (forImport, alignFrame) { +Clazz.superConstructor (this, jalview.appletgui.CutAndPasteTransfer, []); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.alignFrame = alignFrame; +if (!forImport) { +this.buttonPanel.setVisible (false); +}}, "~B,jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "getText", +function () { +return this.textarea.getText (); +}); +Clazz.defineMethod (c$, "setText", +function (text) { +this.textarea.setText (text); +}, "~S"); +Clazz.defineMethod (c$, "setPDBImport", +function (seq) { +this.seq = seq; +this.accept.setLabel (jalview.util.MessageManager.getString ("action.accept")); +this.addSequences.setVisible (false); +this.pdbImport = true; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "setTreeImport", +function () { +this.treeImport = true; +this.accept.setLabel (jalview.util.MessageManager.getString ("action.accept")); +this.addSequences.setVisible (false); +}); +Clazz.defineMethod (c$, "setAnnotationImport", +function () { +this.annotationImport = true; +this.accept.setLabel (jalview.util.MessageManager.getString ("action.accept")); +this.addSequences.setVisible (false); +}); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.accept) { +this.ok (true); +} else if (evt.getSource () === this.addSequences) { +this.ok (false); +} else if (evt.getSource () === this.$cancel) { +this.cancel (); +}}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "ok", +function (newWindow) { +var text = this.getText (); +var length = text.length; +this.textarea.append ("\n"); +if (this.textarea.getText ().length == length) { +var warning = "\n\n#################################################\nWARNING!! THIS IS THE MAXIMUM SIZE OF TEXTAREA!!\n\nCAN\'T INPUT FULL ALIGNMENT\n\nYOU MUST DELETE THIS WARNING TO CONTINUE\n\nMAKE SURE LAST SEQUENCE PASTED IS COMPLETE\n#################################################\n"; +this.textarea.setText (text.substring (0, text.length - warning.length) + warning); +this.textarea.setCaretPosition (text.length); +}if (this.pdbImport) { +this.openPdbViewer (text); +} else if (this.treeImport) { +if (!this.loadTree ()) { +return; +}} else if (this.annotationImport) { +this.loadAnnotations (); +} else if (this.alignFrame != null) { +this.loadAlignment (text, newWindow, this.alignFrame.getAlignViewport ()); +}if (Clazz.instanceOf (this.getParent (), awt2swing.Frame)) { +(this.getParent ()).setVisible (false); +} else { +(this.getParent ()).setVisible (false); +}}, "~B"); +Clazz.defineMethod (c$, "loadTree", +function () { +try { +var fin = new jalview.io.NewickFile (this.textarea.getText (), "Paste"); +fin.parse (); +if (fin.getTree () != null) { +this.alignFrame.loadTree (fin, "Pasted tree file"); +return true; +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +this.textarea.setText (jalview.util.MessageManager.formatMessage ("label.could_not_parse_newick_file", Clazz.newArray (-1, [ex.getMessage ()]))); +return false; +} else { +throw ex; +} +} +return false; +}); +Clazz.defineMethod (c$, "loadAlignment", +function (text, newWindow, viewport) { +var al = null; +var format = new jalview.io.IdentifyFile ().Identify (text, jalview.io.AppletFormatAdapter.PASTE); +var afa = new jalview.io.AppletFormatAdapter (this.alignFrame.alignPanel); +try { +al = afa.readFile (text, jalview.io.AppletFormatAdapter.PASTE, format); +this.source = afa.getAlignFile (); +} catch (ex) { +if (Clazz.exceptionOf (ex, java.io.IOException)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +if (al != null) { +al.setDataset (null); +var allowSplitFrame = this.alignFrame.viewport.applet.getDefaultParameter ("enableSplitFrame", false); +if (allowSplitFrame && this.openSplitFrame (al, format)) { +return; +}if (newWindow) { +var af; +if (Clazz.instanceOf (this.source, jalview.api.ComplexAlignFile)) { +var colSel = (this.source).getColumnSelection (); +var hiddenSeqs = (this.source).getHiddenSequences (); +var showSeqFeatures = (this.source).isShowSeqFeatures (); +var cs = (this.source).getColourScheme (); +af = new jalview.appletgui.AlignFrame (al, hiddenSeqs, colSel, this.alignFrame.viewport.applet, "Cut & Paste input - " + format, false); +af.getAlignViewport ().setShowSequenceFeatures (showSeqFeatures); +af.changeColour (cs); +} else { +af = new jalview.appletgui.AlignFrame (al, this.alignFrame.viewport.applet, "Cut & Paste input - " + format, false); +}af.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_annotation_to_alignment")); +} else { +this.alignFrame.addSequences (al.getSequencesArray ()); +this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_alignment_file")); +}}}, "~S,~B,jalview.appletgui.AlignViewport"); +Clazz.defineMethod (c$, "openSplitFrame", +function (al, format) { +var thisAlignment = this.alignFrame.getAlignViewport ().getAlignment (); +if (thisAlignment.isNucleotide () == al.isNucleotide ()) { +return false; +}var protein = thisAlignment.isNucleotide () ? al : thisAlignment; +var dna = thisAlignment.isNucleotide () ? thisAlignment : al; +var mapped = jalview.analysis.AlignmentUtils.mapProteinToCdna (protein, dna); +if (!mapped) { +return false; +}var title = jalview.util.MessageManager.getString ("label.open_split_window"); +var dialog = new jalview.appletgui.JVDialog (this.getParent (), title, true, 100, 400); +dialog.ok.setLabel (jalview.util.MessageManager.getString ("action.yes")); +dialog.cancel.setLabel (jalview.util.MessageManager.getString ("action.no")); +var question = new awt2swing.Panel ( new java.awt.BorderLayout ()); +var text = jalview.util.MessageManager.getString ("label.open_split_window?"); +question.add ( new awt2swing.Label (text, 0), "Center"); +dialog.setMainPanel (question); +dialog.setVisible (true); +dialog.toFront (); +if (!dialog.accept) { +return false; +}var applet = this.alignFrame.viewport.applet; +var copyFrame = new jalview.appletgui.AlignFrame (this.alignFrame.viewport.getAlignment (), applet, this.alignFrame.getTitle (), false, false); +var newFrame = new jalview.appletgui.AlignFrame (al, this.alignFrame.viewport.applet, "Cut & Paste input - " + format, false, false); +var dnaFrame = al.isNucleotide () ? newFrame : copyFrame; +var proteinFrame = al.isNucleotide () ? copyFrame : newFrame; +var sf = new jalview.appletgui.SplitFrame (dnaFrame, proteinFrame); +sf.addToDisplay (false, applet); +return true; +}, "jalview.datamodel.AlignmentI,~S"); +Clazz.defineMethod (c$, "loadAnnotations", +function () { +var tcf = null; +try { +tcf = jalview.jsdev.GenericFileAdapter.getFile ("TCoffeeScoreFile", [this.textarea.getText (), jalview.io.AppletFormatAdapter.PASTE]); +if (tcf.isValid ()) { +if (tcf.annotateAlignment (this.alignFrame.viewport.getAlignment (), true)) { +this.alignFrame.tcoffeeColour.setEnabled (true); +this.alignFrame.alignPanel.fontChanged (); +this.alignFrame.changeColour ( new jalview.schemes.TCoffeeColourScheme (this.alignFrame.viewport.getAlignment ())); +this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_tcoffee_scores_to_alignment")); +} else { +this.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.failed_add_tcoffee_scores", Clazz.newArray (-1, [(tcf.getWarningMessage () != null ? tcf.getWarningMessage () : "")]))); +}} else { +tcf = null; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +tcf = null; +} else { +throw x; +} +} +if (tcf == null) { +if ( new jalview.io.AnnotationFile ().annotateAlignmentView (this.alignFrame.viewport, this.textarea.getText (), jalview.io.AppletFormatAdapter.PASTE)) { +this.alignFrame.alignPanel.fontChanged (); +this.alignFrame.alignPanel.setScrollValues (0, 0); +this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.successfully_pasted_annotation_to_alignment")); +} else { +if (!this.alignFrame.parseFeaturesFile (this.textarea.getText (), jalview.io.AppletFormatAdapter.PASTE)) { +this.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.couldnt_parse_pasted_text_as_valid_annotation_feature_GFF_tcoffee_file")); +}}}}); +Clazz.defineMethod (c$, "openPdbViewer", +function (text) { +var pdb = new jalview.datamodel.PDBEntry (); +pdb.setFile (text); + new jalview.appletgui.AppletJmol (pdb, Clazz.newArray (-1, [this.seq]), null, this.alignFrame.alignPanel, jalview.io.AppletFormatAdapter.PASTE); +}, "~S"); +Clazz.defineMethod (c$, "cancel", +function () { +this.textarea.setText (""); +if (Clazz.instanceOf (this.getParent (), awt2swing.Frame)) { +(this.getParent ()).setVisible (false); +} else { +(this.getParent ()).setVisible (false); +}}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.textarea.setFont ( new java.awt.Font ("Monospaced", 0, 10)); +this.textarea.setText (jalview.util.MessageManager.getString ("label.paste_your_alignment_file")); +this.textarea.addMouseListener (this); +this.setLayout (this.borderLayout1); +this.accept.addActionListener (this); +this.addSequences.addActionListener (this); +this.$cancel.addActionListener (this); +this.add (this.buttonPanel, "South"); +this.buttonPanel.add (this.accept, null); +this.buttonPanel.add (this.addSequences); +this.buttonPanel.add (this.$cancel, null); +this.add (this.textarea, "Center"); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +if (this.textarea.getText ().startsWith (jalview.util.MessageManager.getString ("label.paste_your"))) { +this.textarea.setText (""); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +}); diff --git a/bin/jalview/appletgui/EditNameDialog.js b/bin/jalview/appletgui/EditNameDialog.js index 68044ad..efedf02 100644 --- a/bin/jalview/appletgui/EditNameDialog.js +++ b/bin/jalview/appletgui/EditNameDialog.js @@ -1,44 +1,44 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.appletgui.JVDialog"], "jalview.appletgui.EditNameDialog", ["awt2swing.Label", "$.Panel", "$.TextField", "java.awt.BorderLayout", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.id = null; -this.description = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "EditNameDialog", jalview.appletgui.JVDialog); -Clazz.overrideMethod (c$, "getName", -function () { -return this.id.getText (); -}); -Clazz.defineMethod (c$, "getDescription", -function () { -if (this.description.getText ().length < 1) { -return null; -} else { -return this.description.getText (); -}}); -Clazz.makeConstructor (c$, -function (name, desc, label1, label2, owner, title, width, height, display) { -Clazz.superConstructor (this, jalview.appletgui.EditNameDialog, [owner, title, true, width, height]); -var mono = new java.awt.Font ("Monospaced", 0, 12); -var panel = new awt2swing.Panel ( new java.awt.BorderLayout ()); -var panel2 = new awt2swing.Panel ( new java.awt.BorderLayout ()); -this.id = new awt2swing.TextField (name, 40); -this.id.setFont (mono); -var label = new awt2swing.Label (label1); -label.setFont (mono); -panel2.add (label, "West"); -panel2.add (this.id, "Center"); -panel.add (panel2, "North"); -if (label2 != null) { -panel2 = new awt2swing.Panel ( new java.awt.BorderLayout ()); -this.description = new awt2swing.TextField (desc, 40); -this.description.setFont (mono); -label = new awt2swing.Label (label2); -label.setFont (mono); -panel2.add (label, "West"); -panel2.add (this.description, "Center"); -panel.add (panel2, "Center"); -}this.setMainPanel (panel); -this.setVisible (display); -}, "~S,~S,~S,~S,awt2swing.Frame,~S,~N,~N,~B"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.appletgui.JVDialog"], "jalview.appletgui.EditNameDialog", ["awt2swing.Label", "$.Panel", "$.TextField", "java.awt.BorderLayout", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.id = null; +this.description = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "EditNameDialog", jalview.appletgui.JVDialog); +Clazz.overrideMethod (c$, "getName", +function () { +return this.id.getText (); +}); +Clazz.defineMethod (c$, "getDescription", +function () { +if (this.description.getText ().length < 1) { +return null; +} else { +return this.description.getText (); +}}); +Clazz.makeConstructor (c$, +function (name, desc, label1, label2, owner, title, width, height, display) { +Clazz.superConstructor (this, jalview.appletgui.EditNameDialog, [owner, title, true, width, height]); +var mono = new java.awt.Font ("Monospaced", 0, 12); +var panel = new awt2swing.Panel ( new java.awt.BorderLayout ()); +var panel2 = new awt2swing.Panel ( new java.awt.BorderLayout ()); +this.id = new awt2swing.TextField (name, 40); +this.id.setFont (mono); +var label = new awt2swing.Label (label1); +label.setFont (mono); +panel2.add (label, "West"); +panel2.add (this.id, "Center"); +panel.add (panel2, "North"); +if (label2 != null) { +panel2 = new awt2swing.Panel ( new java.awt.BorderLayout ()); +this.description = new awt2swing.TextField (desc, 40); +this.description.setFont (mono); +label = new awt2swing.Label (label2); +label.setFont (mono); +panel2.add (label, "West"); +panel2.add (this.description, "Center"); +panel.add (panel2, "Center"); +}this.setMainPanel (panel); +this.setVisible (display); +}, "~S,~S,~S,~S,awt2swing.Frame,~S,~N,~N,~B"); +}); diff --git a/bin/jalview/appletgui/EmbmenuFrame.js b/bin/jalview/appletgui/EmbmenuFrame.js index 7a5362c..13a7183 100644 --- a/bin/jalview/appletgui/EmbmenuFrame.js +++ b/bin/jalview/appletgui/EmbmenuFrame.js @@ -1,110 +1,110 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Frame", "java.awt.event.MouseListener", "java.awt.Font", "java.util.HashMap"], "jalview.appletgui.EmbmenuFrame", ["awt2swing.Label", "$.Panel", "$.PopupMenu", "jalview.util.Platform", "java.awt.Color", "$.FlowLayout"], function () { -c$ = Clazz.decorateAsClass (function () { -this.embeddedPopup = null; -this.embeddedMenu = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "EmbmenuFrame", awt2swing.Frame, java.awt.event.MouseListener); -Clazz.prepareFields (c$, function () { -this.embeddedPopup = new java.util.HashMap (); -}); -Clazz.defineMethod (c$, "embedMenuIfNeeded", -function (tobeAdjusted) { -var topMenuBar = this.getJMenuBar (); -if (topMenuBar == null) { -return false; -}if (jalview.util.Platform.isAMac ()) { -this.embeddedMenu = this.makeEmbeddedPopupMenu (topMenuBar, true, false); -this.unsetMenuBar (); -this.add (this.embeddedMenu, "North"); -tobeAdjusted.setSize (this.getSize ().width, this.getSize ().height - this.embeddedMenu.getHeight ()); -return true; -}return false; -}, "awt2swing.Panel"); -Clazz.defineMethod (c$, "makeEmbeddedPopupMenu", -function (menuBar, overrideFonts, append) { -if (!append) { -this.embeddedPopup.clear (); -if (this.embeddedMenu != null) { -this.embeddedMenu.removeAll (); -}}this.embeddedMenu = this.makeEmbeddedPopupMenu (menuBar, jalview.appletgui.EmbmenuFrame.DEFAULT_MENU_FONT, overrideFonts, new awt2swing.Panel (), this); -return this.embeddedMenu; -}, "awt2swing.MenuBar,~B,~B"); -Clazz.defineMethod (c$, "makeEmbeddedPopupMenu", -function (menuBar, font, overrideFonts, embeddedMenu, clickHandler) { -if (overrideFonts) { -var mbf = menuBar.getFont (); -if (mbf != null) { -font = mbf; -}}if (embeddedMenu == null) { -embeddedMenu = new awt2swing.Panel (); -}var flowLayout1 = new java.awt.FlowLayout (); -embeddedMenu.setBackground (java.awt.Color.lightGray); -embeddedMenu.setLayout (flowLayout1); -for (var mbi = 0, nMbi = menuBar.getMenuCount (); mbi < nMbi; mbi++) { -var mi = menuBar.getMenu (mbi); -var elab = new awt2swing.Label (mi.getLabel ()); -elab.setFont (font); -var popup = new awt2swing.PopupMenu (); -var m; -var mSize = mi.getItemCount (); -for (m = 0; m < mSize; m++) { -if (mi.getItem (m) == null) popup.addSeparator (); - else popup.add (mi.getItem (m)); -mSize--; -m--; -} -this.embeddedPopup.put (elab, popup); -embeddedMenu.add (elab); -elab.addMouseListener (clickHandler); -} -flowLayout1.setAlignment (0); -flowLayout1.setHgap (2); -flowLayout1.setVgap (0); -return embeddedMenu; -}, "awt2swing.MenuBar,java.awt.Font,~B,awt2swing.Panel,java.awt.event.MouseListener"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -var popup = null; -var source = evt.getSource (); -popup = this.getPopupMenu (source); -if (popup != null) { -this.embeddedMenu.add (popup); -popup.show (this.embeddedMenu, source.getBounds ().x, source.getBounds ().y + source.getBounds ().getSize ().height); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "getPopupMenu", -function (source) { -return this.embeddedPopup.get (source); -}, "awt2swing.Label"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "destroyMenus", -function () { -if (this.embeddedPopup != null) { -for (var lb, $lb = this.embeddedPopup.keySet ().iterator (); $lb.hasNext () && ((lb = $lb.next ()) || true);) { -lb.removeMouseListener (this); -} -this.embeddedPopup.clear (); -}if (this.embeddedMenu != null) { -this.embeddedMenu.removeAll (); -}}); -Clazz.defineMethod (c$, "finalize", -function () { -this.destroyMenus (); -this.embeddedPopup = null; -this.embeddedMenu = null; -Clazz.superCall (this, jalview.appletgui.EmbmenuFrame, "finalize", []); -}); -c$.FONT_ARIAL_PLAIN_11 = c$.prototype.FONT_ARIAL_PLAIN_11 = new java.awt.Font ("Arial", 0, 11); -c$.DEFAULT_MENU_FONT = c$.prototype.DEFAULT_MENU_FONT = jalview.appletgui.EmbmenuFrame.FONT_ARIAL_PLAIN_11; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Frame", "java.awt.event.MouseListener", "java.awt.Font", "java.util.HashMap"], "jalview.appletgui.EmbmenuFrame", ["awt2swing.Label", "$.Panel", "$.PopupMenu", "jalview.util.Platform", "java.awt.Color", "$.FlowLayout"], function () { +c$ = Clazz.decorateAsClass (function () { +this.embeddedPopup = null; +this.embeddedMenu = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "EmbmenuFrame", awt2swing.Frame, java.awt.event.MouseListener); +Clazz.prepareFields (c$, function () { +this.embeddedPopup = new java.util.HashMap (); +}); +Clazz.defineMethod (c$, "embedMenuIfNeeded", +function (tobeAdjusted) { +var topMenuBar = this.getJMenuBar (); +if (topMenuBar == null) { +return false; +}if (jalview.util.Platform.isAMac ()) { +this.embeddedMenu = this.makeEmbeddedPopupMenu (topMenuBar, true, false); +this.unsetMenuBar (); +this.add (this.embeddedMenu, "North"); +tobeAdjusted.setSize (this.getSize ().width, this.getSize ().height - this.embeddedMenu.getHeight ()); +return true; +}return false; +}, "awt2swing.Panel"); +Clazz.defineMethod (c$, "makeEmbeddedPopupMenu", +function (menuBar, overrideFonts, append) { +if (!append) { +this.embeddedPopup.clear (); +if (this.embeddedMenu != null) { +this.embeddedMenu.removeAll (); +}}this.embeddedMenu = this.makeEmbeddedPopupMenu (menuBar, jalview.appletgui.EmbmenuFrame.DEFAULT_MENU_FONT, overrideFonts, new awt2swing.Panel (), this); +return this.embeddedMenu; +}, "awt2swing.MenuBar,~B,~B"); +Clazz.defineMethod (c$, "makeEmbeddedPopupMenu", +function (menuBar, font, overrideFonts, embeddedMenu, clickHandler) { +if (overrideFonts) { +var mbf = menuBar.getFont (); +if (mbf != null) { +font = mbf; +}}if (embeddedMenu == null) { +embeddedMenu = new awt2swing.Panel (); +}var flowLayout1 = new java.awt.FlowLayout (); +embeddedMenu.setBackground (java.awt.Color.lightGray); +embeddedMenu.setLayout (flowLayout1); +for (var mbi = 0, nMbi = menuBar.getMenuCount (); mbi < nMbi; mbi++) { +var mi = menuBar.getMenu (mbi); +var elab = new awt2swing.Label (mi.getLabel ()); +elab.setFont (font); +var popup = new awt2swing.PopupMenu (); +var m; +var mSize = mi.getItemCount (); +for (m = 0; m < mSize; m++) { +if (mi.getItem (m) == null) popup.addSeparator (); + else popup.add (mi.getItem (m)); +mSize--; +m--; +} +this.embeddedPopup.put (elab, popup); +embeddedMenu.add (elab); +elab.addMouseListener (clickHandler); +} +flowLayout1.setAlignment (0); +flowLayout1.setHgap (2); +flowLayout1.setVgap (0); +return embeddedMenu; +}, "awt2swing.MenuBar,java.awt.Font,~B,awt2swing.Panel,java.awt.event.MouseListener"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +var popup = null; +var source = evt.getSource (); +popup = this.getPopupMenu (source); +if (popup != null) { +this.embeddedMenu.add (popup); +popup.show (this.embeddedMenu, source.getBounds ().x, source.getBounds ().y + source.getBounds ().getSize ().height); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "getPopupMenu", +function (source) { +return this.embeddedPopup.get (source); +}, "awt2swing.Label"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "destroyMenus", +function () { +if (this.embeddedPopup != null) { +for (var lb, $lb = this.embeddedPopup.keySet ().iterator (); $lb.hasNext () && ((lb = $lb.next ()) || true);) { +lb.removeMouseListener (this); +} +this.embeddedPopup.clear (); +}if (this.embeddedMenu != null) { +this.embeddedMenu.removeAll (); +}}); +Clazz.defineMethod (c$, "finalize", +function () { +this.destroyMenus (); +this.embeddedPopup = null; +this.embeddedMenu = null; +Clazz.superCall (this, jalview.appletgui.EmbmenuFrame, "finalize", []); +}); +c$.FONT_ARIAL_PLAIN_11 = c$.prototype.FONT_ARIAL_PLAIN_11 = new java.awt.Font ("Arial", 0, 11); +c$.DEFAULT_MENU_FONT = c$.prototype.DEFAULT_MENU_FONT = jalview.appletgui.EmbmenuFrame.FONT_ARIAL_PLAIN_11; +}); diff --git a/bin/jalview/appletgui/ExtJmol.js b/bin/jalview/appletgui/ExtJmol.js index 150efd5..170d005 100644 --- a/bin/jalview/appletgui/ExtJmol.js +++ b/bin/jalview/appletgui/ExtJmol.js @@ -1,17 +1,17 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.structures.models.AAStructureBindingModel"], "jalview.appletgui.ExtJmol", null, function () { -c$ = Clazz.declareType (jalview.appletgui, "ExtJmol", jalview.structures.models.AAStructureBindingModel); -Clazz.overrideMethod (c$, "getPdbFile", -function () { -return null; -}); -Clazz.overrideMethod (c$, "updateColours", -function (source) { -}, "~O"); -Clazz.overrideMethod (c$, "releaseReferences", -function (svl) { -}, "~O"); -Clazz.overrideMethod (c$, "highlightAtoms", -function (atoms) { -}, "java.util.List"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.structures.models.AAStructureBindingModel"], "jalview.appletgui.ExtJmol", null, function () { +c$ = Clazz.declareType (jalview.appletgui, "ExtJmol", jalview.structures.models.AAStructureBindingModel); +Clazz.overrideMethod (c$, "getPdbFile", +function () { +return null; +}); +Clazz.overrideMethod (c$, "updateColours", +function (source) { +}, "~O"); +Clazz.overrideMethod (c$, "releaseReferences", +function (svl) { +}, "~O"); +Clazz.overrideMethod (c$, "highlightAtoms", +function (atoms) { +}, "java.util.List"); +}); diff --git a/bin/jalview/appletgui/FeatureColourChooser.js b/bin/jalview/appletgui/FeatureColourChooser.js index 929c04b..cfa5380 100644 --- a/bin/jalview/appletgui/FeatureColourChooser.js +++ b/bin/jalview/appletgui/FeatureColourChooser.js @@ -1,292 +1,292 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField"], "jalview.appletgui.FeatureColourChooser", ["awt2swing.Label", "jalview.appletgui.JVDialog", "$.PaintRefresher", "$.UserDefinedColours", "jalview.datamodel.GraphLine", "jalview.schemes.GraduatedColor", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.FlowLayout", "$.Font", "$.GridLayout", "java.awt.event.ActionEvent", "java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.frame = null; -this.owner = null; -this.fr = null; -this.fs = null; -this.cs = null; -this.oldcs = null; -this.oldgroupColours = null; -this.adjusting = false; -this.min = 0; -this.max = 0; -this.type = null; -this.af = null; -this.minColour = null; -this.maxColour = null; -this.jPanel1 = null; -this.jPanel2 = null; -this.threshold = null; -this.jPanel3 = null; -this.jPanel4 = null; -this.slider = null; -this.thresholdValue = null; -this.thresholdIsMin = null; -this.colourFromLabel = null; -this.threshline = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "FeatureColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); -Clazz.prepareFields (c$, function () { -this.minColour = new awt2swing.Panel (); -this.maxColour = new awt2swing.Panel (); -this.jPanel1 = new awt2swing.Panel (); -this.jPanel2 = new awt2swing.Panel (); -this.threshold = new awt2swing.Choice (); -this.jPanel3 = new awt2swing.Panel (); -this.jPanel4 = new awt2swing.Panel (); -this.slider = new awt2swing.Scrollbar (0); -this.thresholdValue = new awt2swing.TextField (20); -this.thresholdIsMin = new awt2swing.Checkbox (); -this.colourFromLabel = new awt2swing.Checkbox (); -}); -Clazz.makeConstructor (c$, -function (af, type) { -Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []); -this.af = af; -this.init (af.getSeqcanvas ().getFeatureRenderer (), type); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.makeConstructor (c$, -function (fsettings, type) { -Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []); -this.fs = fsettings; -this.init (fsettings.fr, type); -}, "jalview.appletgui.FeatureSettings,~S"); -Clazz.defineMethod (c$, "init", -($fz = function (frenderer, type) { -this.type = type; -this.fr = frenderer; -var mm = (this.fr.getMinMax ().get (type))[0]; -this.min = mm[0]; -this.max = mm[1]; -this.oldcs = this.fr.getFeatureColours ().get (type); -if (Clazz.instanceOf (this.oldcs, jalview.schemes.GraduatedColor)) { -this.cs = new jalview.schemes.GraduatedColor (this.oldcs, this.min, this.max); -} else { -var bl = java.awt.Color.black; -if (Clazz.instanceOf (this.oldcs, java.awt.Color)) { -bl = this.oldcs; -}this.cs = new jalview.schemes.GraduatedColor (java.awt.Color.white, bl, mm[0], mm[1]); -}this.minColour.setBackground (this.cs.getMinColor ()); -this.maxColour.setBackground (this.cs.getMaxColor ()); -this.minColour.setForeground (this.cs.getMinColor ()); -this.maxColour.setForeground (this.cs.getMaxColor ()); -this.colourFromLabel.setState (this.cs.isColourByLabel ()); -this.adjusting = true; -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -this.threshold.select (new Integer (this.cs.getThreshType () == -1 ? 0 : this.cs.getThreshType () == 1 ? 1 : 2)); -this.adjusting = false; -this.changeColour (); -this.colourFromLabel.addItemListener (this); -this.slider.addAdjustmentListener (this); -this.slider.addMouseListener (this); -this.owner = (this.af != null) ? this.af : this.fs.frame; -this.frame = new jalview.appletgui.JVDialog (this.owner, jalview.util.MessageManager.formatMessage ("label.graduated_color_for_params", Clazz.newArray (-1, [type])), true, 480, 248); -this.frame.setMainPanel (this); -this.validate (); -this.frame.setVisible (true); -if (this.frame.accept) { -this.changeColour (); -} else { -this.reset (); -jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); -this.frame.setVisible (false); -}}, $fz.isPrivate = true, $fz), "jalview.appletgui.FeatureRenderer,~S"); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []); -try { -this.jbInit (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -var minLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.min")); -var maxLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.max")); -minLabel.setFont ( new java.awt.Font ("Verdana", 0, 11)); -maxLabel.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.minColour.setBounds (0, 0, 40, 27); -this.maxColour.setBounds (0, 0, 40, 27); -this.minColour.addMouseListener (this); -this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.maxColour.addMouseListener (this); -this.thresholdIsMin.addItemListener (this); -this.setLayout ( new java.awt.GridLayout (4, 1)); -this.jPanel1.setLayout ( new java.awt.FlowLayout ()); -this.jPanel2.setLayout ( new java.awt.FlowLayout ()); -this.jPanel3.setLayout ( new java.awt.GridLayout (1, 1)); -this.jPanel4.setLayout ( new java.awt.FlowLayout ()); -this.jPanel1.setBackground (java.awt.Color.white); -this.jPanel2.setBackground (java.awt.Color.white); -this.jPanel4.setBackground (java.awt.Color.white); -this.threshold.addItemListener (this); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); -this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); -this.thresholdValue.addActionListener (this); -this.slider.setBackground (java.awt.Color.white); -this.slider.setEnabled (false); -this.slider.setSize ( new java.awt.Dimension (93, 21)); -this.thresholdValue.setEnabled (false); -this.thresholdValue.setSize ( new java.awt.Dimension (79, 22)); -this.thresholdValue.setColumns (5); -this.jPanel3.setBackground (java.awt.Color.white); -this.colourFromLabel.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.colourFromLabel.setLabel (jalview.util.MessageManager.getString ("label.colour_by_label")); -this.colourFromLabel.setSize ( new java.awt.Dimension (139, 22)); -this.thresholdIsMin.setBackground (java.awt.Color.white); -this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax")); -this.thresholdIsMin.setSize ( new java.awt.Dimension (135, 23)); -this.jPanel1.add (minLabel); -this.jPanel1.add (this.minColour); -this.jPanel1.add (maxLabel); -this.jPanel1.add (this.maxColour); -this.jPanel1.add (this.colourFromLabel); -this.jPanel2.add (this.threshold); -this.jPanel3.add (this.slider); -this.jPanel4.add (this.thresholdValue); -this.jPanel4.add (this.thresholdIsMin); -this.add (this.jPanel1); -this.add (this.jPanel2); -this.add (this.jPanel3); -this.add (this.jPanel4); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.thresholdValue) { -try { -var f = new Float (this.thresholdValue.getText ()).floatValue (); -this.slider.setValue (Clazz.floatToInt (f * 1000)); -this.adjustmentValueChanged (null); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -} else if (evt.getSource () === this.minColour) { -this.minColour_actionPerformed (null); -} else if (evt.getSource () === this.maxColour) { -this.maxColour_actionPerformed (null); -} else { -this.changeColour (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -this.maxColour.setEnabled (!this.colourFromLabel.getState ()); -this.minColour.setEnabled (!this.colourFromLabel.getState ()); -this.changeColour (); -}, "java.awt.event.ItemEvent"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -if (!this.adjusting) { -this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); -this.valueChanged (); -}}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "valueChanged", -function () { -this.threshline.value = this.slider.getValue () / 1000; -this.cs.setThresh (this.threshline.value); -this.changeColour (); -jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); -}); -Clazz.defineMethod (c$, "minColour_actionPerformed", -function (newCol) { -if (newCol == null) { -var udc = new jalview.appletgui.UserDefinedColours (this, this.minColour.getBackground (), this.owner, jalview.util.MessageManager.getString ("label.select_colour_minimum_value")); -} else { -this.minColour.setBackground (newCol); -this.minColour.setForeground (newCol); -this.minColour.repaint (); -this.changeColour (); -}}, "java.awt.Color"); -Clazz.defineMethod (c$, "maxColour_actionPerformed", -function (newCol) { -if (newCol == null) { -var udc = new jalview.appletgui.UserDefinedColours (this, this.maxColour.getBackground (), this.owner, jalview.util.MessageManager.getString ("label.select_colour_maximum_value")); -} else { -this.maxColour.setBackground (newCol); -this.maxColour.setForeground (newCol); -this.maxColour.repaint (); -this.changeColour (); -}}, "java.awt.Color"); -Clazz.defineMethod (c$, "changeColour", -function () { -if (this.adjusting) { -return; -}var aboveThreshold = -1; -if (this.threshold.getSelectedIndex () == 1) { -aboveThreshold = 1; -} else if (this.threshold.getSelectedIndex () == 2) { -aboveThreshold = 0; -}this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -var acg = new jalview.schemes.GraduatedColor (this.minColour.getBackground (), this.maxColour.getBackground (), this.min, this.max); -acg.setColourByLabel (this.colourFromLabel.getState ()); -this.maxColour.setEnabled (!this.colourFromLabel.getState ()); -this.minColour.setEnabled (!this.colourFromLabel.getState ()); -if (aboveThreshold == -1) { -this.slider.setEnabled (false); -this.thresholdValue.setEnabled (false); -this.thresholdValue.setText (""); -} else if (aboveThreshold != -1 && this.threshline == null) { -this.threshline = new jalview.datamodel.GraphLine ((this.max - this.min) / 2, "Threshold", java.awt.Color.black); -}if (aboveThreshold != -1) { -this.adjusting = true; -acg.setThresh (this.threshline.value); -var range = this.max * 1000 - this.min * 1000; -this.slider.setMinimum (Clazz.floatToInt (this.min * 1000)); -this.slider.setMaximum (Clazz.floatToInt (this.max * 1000)); -this.slider.setValue (Clazz.floatToInt (this.threshline.value * 1000)); -this.thresholdValue.setText (this.threshline.value + ""); -this.slider.setEnabled (true); -this.thresholdValue.setEnabled (true); -this.adjusting = false; -}acg.setThreshType (aboveThreshold); -if (this.thresholdIsMin.getState () && aboveThreshold != -1) { -if (aboveThreshold == 1) { -acg = new jalview.schemes.GraduatedColor (acg, this.threshline.value, this.max); -} else { -acg = new jalview.schemes.GraduatedColor (acg, this.min, this.threshline.value); -}}this.fr.setColour (this.type, acg); -this.cs = acg; -jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); -}); -Clazz.defineMethod (c$, "reset", -function () { -this.fr.setColour (this.type, this.oldcs); -jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); -}); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -if (evt.getSource () === this.minColour || evt.getSource () === this.maxColour) { -this.actionPerformed ( new java.awt.event.ActionEvent (evt.getSource (), 1, "Clicked")); -} else { -jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "awt2swing.Checkbox", "$.Choice", "$.Scrollbar", "$.TextField"], "jalview.appletgui.FeatureColourChooser", ["awt2swing.Label", "jalview.appletgui.JVDialog", "$.PaintRefresher", "$.UserDefinedColours", "jalview.datamodel.GraphLine", "jalview.schemes.GraduatedColor", "jalview.util.MessageManager", "java.awt.Color", "$.Dimension", "$.FlowLayout", "$.Font", "$.GridLayout", "java.awt.event.ActionEvent", "java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.frame = null; +this.owner = null; +this.fr = null; +this.fs = null; +this.cs = null; +this.oldcs = null; +this.oldgroupColours = null; +this.adjusting = false; +this.min = 0; +this.max = 0; +this.type = null; +this.af = null; +this.minColour = null; +this.maxColour = null; +this.jPanel1 = null; +this.jPanel2 = null; +this.threshold = null; +this.jPanel3 = null; +this.jPanel4 = null; +this.slider = null; +this.thresholdValue = null; +this.thresholdIsMin = null; +this.colourFromLabel = null; +this.threshline = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "FeatureColourChooser", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.ItemListener, java.awt.event.MouseListener]); +Clazz.prepareFields (c$, function () { +this.minColour = new awt2swing.Panel (); +this.maxColour = new awt2swing.Panel (); +this.jPanel1 = new awt2swing.Panel (); +this.jPanel2 = new awt2swing.Panel (); +this.threshold = new awt2swing.Choice (); +this.jPanel3 = new awt2swing.Panel (); +this.jPanel4 = new awt2swing.Panel (); +this.slider = new awt2swing.Scrollbar (0); +this.thresholdValue = new awt2swing.TextField (20); +this.thresholdIsMin = new awt2swing.Checkbox (); +this.colourFromLabel = new awt2swing.Checkbox (); +}); +Clazz.makeConstructor (c$, +function (af, type) { +Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []); +this.af = af; +this.init (af.getSeqcanvas ().getFeatureRenderer (), type); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.makeConstructor (c$, +function (fsettings, type) { +Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []); +this.fs = fsettings; +this.init (fsettings.fr, type); +}, "jalview.appletgui.FeatureSettings,~S"); +Clazz.defineMethod (c$, "init", +($fz = function (frenderer, type) { +this.type = type; +this.fr = frenderer; +var mm = (this.fr.getMinMax ().get (type))[0]; +this.min = mm[0]; +this.max = mm[1]; +this.oldcs = this.fr.getFeatureColours ().get (type); +if (Clazz.instanceOf (this.oldcs, jalview.schemes.GraduatedColor)) { +this.cs = new jalview.schemes.GraduatedColor (this.oldcs, this.min, this.max); +} else { +var bl = java.awt.Color.black; +if (Clazz.instanceOf (this.oldcs, java.awt.Color)) { +bl = this.oldcs; +}this.cs = new jalview.schemes.GraduatedColor (java.awt.Color.white, bl, mm[0], mm[1]); +}this.minColour.setBackground (this.cs.getMinColor ()); +this.maxColour.setBackground (this.cs.getMaxColor ()); +this.minColour.setForeground (this.cs.getMinColor ()); +this.maxColour.setForeground (this.cs.getMaxColor ()); +this.colourFromLabel.setState (this.cs.isColourByLabel ()); +this.adjusting = true; +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +this.threshold.select (new Integer (this.cs.getThreshType () == -1 ? 0 : this.cs.getThreshType () == 1 ? 1 : 2)); +this.adjusting = false; +this.changeColour (); +this.colourFromLabel.addItemListener (this); +this.slider.addAdjustmentListener (this); +this.slider.addMouseListener (this); +this.owner = (this.af != null) ? this.af : this.fs.frame; +this.frame = new jalview.appletgui.JVDialog (this.owner, jalview.util.MessageManager.formatMessage ("label.graduated_color_for_params", Clazz.newArray (-1, [type])), true, 480, 248); +this.frame.setMainPanel (this); +this.validate (); +this.frame.setVisible (true); +if (this.frame.accept) { +this.changeColour (); +} else { +this.reset (); +jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); +this.frame.setVisible (false); +}}, $fz.isPrivate = true, $fz), "jalview.appletgui.FeatureRenderer,~S"); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.FeatureColourChooser, []); +try { +this.jbInit (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +var minLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.min")); +var maxLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.max")); +minLabel.setFont ( new java.awt.Font ("Verdana", 0, 11)); +maxLabel.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.minColour.setBounds (0, 0, 40, 27); +this.maxColour.setBounds (0, 0, 40, 27); +this.minColour.addMouseListener (this); +this.maxColour.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.maxColour.addMouseListener (this); +this.thresholdIsMin.addItemListener (this); +this.setLayout ( new java.awt.GridLayout (4, 1)); +this.jPanel1.setLayout ( new java.awt.FlowLayout ()); +this.jPanel2.setLayout ( new java.awt.FlowLayout ()); +this.jPanel3.setLayout ( new java.awt.GridLayout (1, 1)); +this.jPanel4.setLayout ( new java.awt.FlowLayout ()); +this.jPanel1.setBackground (java.awt.Color.white); +this.jPanel2.setBackground (java.awt.Color.white); +this.jPanel4.setBackground (java.awt.Color.white); +this.threshold.addItemListener (this); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_no_thereshold")); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_above_thereshold")); +this.threshold.addItem (jalview.util.MessageManager.getString ("label.threshold_feature_below_thereshold")); +this.thresholdValue.addActionListener (this); +this.slider.setBackground (java.awt.Color.white); +this.slider.setEnabled (false); +this.slider.setSize ( new java.awt.Dimension (93, 21)); +this.thresholdValue.setEnabled (false); +this.thresholdValue.setSize ( new java.awt.Dimension (79, 22)); +this.thresholdValue.setColumns (5); +this.jPanel3.setBackground (java.awt.Color.white); +this.colourFromLabel.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.colourFromLabel.setLabel (jalview.util.MessageManager.getString ("label.colour_by_label")); +this.colourFromLabel.setSize ( new java.awt.Dimension (139, 22)); +this.thresholdIsMin.setBackground (java.awt.Color.white); +this.thresholdIsMin.setLabel (jalview.util.MessageManager.getString ("label.threshold_minmax")); +this.thresholdIsMin.setSize ( new java.awt.Dimension (135, 23)); +this.jPanel1.add (minLabel); +this.jPanel1.add (this.minColour); +this.jPanel1.add (maxLabel); +this.jPanel1.add (this.maxColour); +this.jPanel1.add (this.colourFromLabel); +this.jPanel2.add (this.threshold); +this.jPanel3.add (this.slider); +this.jPanel4.add (this.thresholdValue); +this.jPanel4.add (this.thresholdIsMin); +this.add (this.jPanel1); +this.add (this.jPanel2); +this.add (this.jPanel3); +this.add (this.jPanel4); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.thresholdValue) { +try { +var f = new Float (this.thresholdValue.getText ()).floatValue (); +this.slider.setValue (Clazz.floatToInt (f * 1000)); +this.adjustmentValueChanged (null); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +} else if (evt.getSource () === this.minColour) { +this.minColour_actionPerformed (null); +} else if (evt.getSource () === this.maxColour) { +this.maxColour_actionPerformed (null); +} else { +this.changeColour (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +this.maxColour.setEnabled (!this.colourFromLabel.getState ()); +this.minColour.setEnabled (!this.colourFromLabel.getState ()); +this.changeColour (); +}, "java.awt.event.ItemEvent"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +if (!this.adjusting) { +this.thresholdValue.setText ((this.slider.getValue () / 1000) + ""); +this.valueChanged (); +}}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "valueChanged", +function () { +this.threshline.value = this.slider.getValue () / 1000; +this.cs.setThresh (this.threshline.value); +this.changeColour (); +jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); +}); +Clazz.defineMethod (c$, "minColour_actionPerformed", +function (newCol) { +if (newCol == null) { +var udc = new jalview.appletgui.UserDefinedColours (this, this.minColour.getBackground (), this.owner, jalview.util.MessageManager.getString ("label.select_colour_minimum_value")); +} else { +this.minColour.setBackground (newCol); +this.minColour.setForeground (newCol); +this.minColour.repaint (); +this.changeColour (); +}}, "java.awt.Color"); +Clazz.defineMethod (c$, "maxColour_actionPerformed", +function (newCol) { +if (newCol == null) { +var udc = new jalview.appletgui.UserDefinedColours (this, this.maxColour.getBackground (), this.owner, jalview.util.MessageManager.getString ("label.select_colour_maximum_value")); +} else { +this.maxColour.setBackground (newCol); +this.maxColour.setForeground (newCol); +this.maxColour.repaint (); +this.changeColour (); +}}, "java.awt.Color"); +Clazz.defineMethod (c$, "changeColour", +function () { +if (this.adjusting) { +return; +}var aboveThreshold = -1; +if (this.threshold.getSelectedIndex () == 1) { +aboveThreshold = 1; +} else if (this.threshold.getSelectedIndex () == 2) { +aboveThreshold = 0; +}this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +var acg = new jalview.schemes.GraduatedColor (this.minColour.getBackground (), this.maxColour.getBackground (), this.min, this.max); +acg.setColourByLabel (this.colourFromLabel.getState ()); +this.maxColour.setEnabled (!this.colourFromLabel.getState ()); +this.minColour.setEnabled (!this.colourFromLabel.getState ()); +if (aboveThreshold == -1) { +this.slider.setEnabled (false); +this.thresholdValue.setEnabled (false); +this.thresholdValue.setText (""); +} else if (aboveThreshold != -1 && this.threshline == null) { +this.threshline = new jalview.datamodel.GraphLine ((this.max - this.min) / 2, "Threshold", java.awt.Color.black); +}if (aboveThreshold != -1) { +this.adjusting = true; +acg.setThresh (this.threshline.value); +var range = this.max * 1000 - this.min * 1000; +this.slider.setMinimum (Clazz.floatToInt (this.min * 1000)); +this.slider.setMaximum (Clazz.floatToInt (this.max * 1000)); +this.slider.setValue (Clazz.floatToInt (this.threshline.value * 1000)); +this.thresholdValue.setText (this.threshline.value + ""); +this.slider.setEnabled (true); +this.thresholdValue.setEnabled (true); +this.adjusting = false; +}acg.setThreshType (aboveThreshold); +if (this.thresholdIsMin.getState () && aboveThreshold != -1) { +if (aboveThreshold == 1) { +acg = new jalview.schemes.GraduatedColor (acg, this.threshline.value, this.max); +} else { +acg = new jalview.schemes.GraduatedColor (acg, this.min, this.threshline.value); +}}this.fr.setColour (this.type, acg); +this.cs = acg; +jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); +}); +Clazz.defineMethod (c$, "reset", +function () { +this.fr.setColour (this.type, this.oldcs); +jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); +}); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +if (evt.getSource () === this.minColour || evt.getSource () === this.maxColour) { +this.actionPerformed ( new java.awt.event.ActionEvent (evt.getSource (), 1, "Clicked")); +} else { +jalview.appletgui.PaintRefresher.Refresh (this, this.fr.getViewport ().getSequenceSetId ()); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +}); diff --git a/bin/jalview/appletgui/FeatureRenderer.js b/bin/jalview/appletgui/FeatureRenderer.js index 3d688fd..05b643c 100644 --- a/bin/jalview/appletgui/FeatureRenderer.js +++ b/bin/jalview/appletgui/FeatureRenderer.js @@ -1,272 +1,272 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.renderer.seqfeatures.FeatureRenderer"], "jalview.appletgui.FeatureRenderer", ["awt2swing.Button", "$.Choice", "$.Label", "$.ScrollPane", "$.TextArea", "$.TextField", "jalview.appletgui.FeatureColourChooser", "$.JVDialog", "$.UserDefinedColours", "jalview.datamodel.SearchResults", "jalview.io.FeaturesFile", "jalview.schemes.GraduatedColor", "$.UserColourScheme", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.Font", "$.GridLayout", "java.awt.event.ActionListener", "$.ItemListener", "$.MouseAdapter", "java.lang.Error"], function () { -c$ = Clazz.decorateAsClass (function () { -this.featureLinks = null; -this.featureIndex = 0; -this.deleteFeature = false; -this.colourPanel = null; -if (!Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer.FeatureColourPanel")) { -jalview.appletgui.FeatureRenderer.$FeatureRenderer$FeatureColourPanel$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "FeatureRenderer", jalview.renderer.seqfeatures.FeatureRenderer); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.FeatureRenderer); -this.av = av; -this.setTransparencyAvailable (!System.getProperty ("java.version").startsWith ("1.1")); -}, "jalview.viewmodel.AlignmentViewport"); -Clazz.defineMethod (c$, "amendFeatures", -function (sequences, features, newFeatures, ap) { -var bigPanel = new awt2swing.Panel ( new java.awt.BorderLayout ()); -var name = new awt2swing.TextField (16); -var source = new awt2swing.TextField (16); -var description = new awt2swing.TextArea (3, 35); -var start = new awt2swing.TextField (8); -var end = new awt2swing.TextField (8); -var overlaps; -var deleteButton = new awt2swing.Button ("Delete"); -this.deleteFeature = false; -this.colourPanel = Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer.FeatureColourPanel, this, null); -this.colourPanel.setSize (110, 15); -var fr = this; -var panel = new awt2swing.Panel ( new java.awt.GridLayout (3, 1)); -this.featureIndex = 0; -var tmp; -if (!newFeatures && features.length > 1) { -panel = new awt2swing.Panel ( new java.awt.GridLayout (4, 1)); -tmp = new awt2swing.Panel (); -tmp.add ( new awt2swing.Label ("Select Feature: ")); -overlaps = new awt2swing.Choice (); -for (var i = 0; i < features.length; i++) { -var item = features[i].getType () + "/" + features[i].getBegin () + "-" + features[i].getEnd (); -if (features[i].getFeatureGroup () != null) { -item += " (" + features[i].getFeatureGroup () + ")"; -}overlaps.addItem (item); -} -tmp.add (overlaps); -overlaps.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer$1") ? 0 : jalview.appletgui.FeatureRenderer.$FeatureRenderer$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer$1, this, Clazz.cloneFinals ("overlaps", overlaps, "name", name, "features", features, "description", description, "source", source, "start", start, "end", end, "sequences", sequences, "ap", ap)))); -panel.add (tmp); -}tmp = new awt2swing.Panel (); -panel.add (tmp); -tmp.add ( new awt2swing.Label ("Name: ", 4)); -tmp.add (name); -tmp = new awt2swing.Panel (); -panel.add (tmp); -tmp.add ( new awt2swing.Label ("Group: ", 4)); -tmp.add (source); -tmp = new awt2swing.Panel (); -panel.add (tmp); -tmp.add ( new awt2swing.Label ("Colour: ", 4)); -tmp.add (this.colourPanel); -bigPanel.add (panel, "North"); -panel = new awt2swing.Panel (); -panel.add ( new awt2swing.Label ("Description: ", 4)); -panel.add ( new awt2swing.ScrollPane ().add (description)); -if (!newFeatures) { -bigPanel.add (panel, "South"); -panel = new awt2swing.Panel (); -panel.add ( new awt2swing.Label (" Start:", 4)); -panel.add (start); -panel.add ( new awt2swing.Label (" End:", 4)); -panel.add (end); -bigPanel.add (panel, "Center"); -} else { -bigPanel.add (panel, "Center"); -}if (jalview.appletgui.FeatureRenderer.lastFeatureAdded == null) { -if (features[0].type != null) { -jalview.appletgui.FeatureRenderer.lastFeatureAdded = features[0].type; -} else { -jalview.appletgui.FeatureRenderer.lastFeatureAdded = "feature_1"; -}}if (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded == null) { -if (features[0].featureGroup != null) { -jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded = features[0].featureGroup; -} else { -jalview.appletgui.FeatureRenderer.lastFeatureAdded = "Jalview"; -}}var title = newFeatures ? jalview.util.MessageManager.getString ("label.create_new_sequence_features") : jalview.util.MessageManager.formatMessage ("label.amend_delete_features", Clazz.newArray (-1, [sequences[0].getName ()])); -var dialog = new jalview.appletgui.JVDialog (ap.alignFrame, title, true, 385, 240); -dialog.setMainPanel (bigPanel); -if (newFeatures) { -name.setText (jalview.appletgui.FeatureRenderer.lastFeatureAdded); -source.setText (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded); -} else { -dialog.ok.setLabel (jalview.util.MessageManager.getString ("label.amend")); -dialog.buttonPanel.add (deleteButton, 1); -deleteButton.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer$2") ? 0 : jalview.appletgui.FeatureRenderer.$FeatureRenderer$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer$2, this, Clazz.cloneFinals ("dialog", dialog)))); -name.setText (features[0].getType ()); -source.setText (features[0].getFeatureGroup ()); -}start.setText (features[0].getBegin () + ""); -end.setText (features[0].getEnd () + ""); -description.setText (features[0].getDescription ()); -var col = this.getColour (name.getText ()); -if (col == null) { -col = new jalview.schemes.UserColourScheme ().createColourFromName (name.getText ()); -}var fcol = this.getFeatureStyle (name.getText ()); -this.colourPanel.updateColor (fcol); -dialog.setResizable (true); -this.colourPanel.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer$3") ? 0 : jalview.appletgui.FeatureRenderer.$FeatureRenderer$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer$3, this, Clazz.cloneFinals ("fr", fr, "ap", ap, "name", name, "dialog", dialog)))); -dialog.setVisible (true); -var ffile = new jalview.io.FeaturesFile (); -if (dialog.accept) { -this.lastSeq = null; -jalview.appletgui.FeatureRenderer.lastFeatureAdded = name.getText ().trim (); -jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded = source.getText ().trim (); -jalview.appletgui.FeatureRenderer.lastDescriptionAdded = description.getText ().$replace ('\n', ' '); -}if (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded != null && jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded.length < 1) { -jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded = null; -}if (!newFeatures) { -var sf = features[this.featureIndex]; -if (dialog.accept) { -sf.type = jalview.appletgui.FeatureRenderer.lastFeatureAdded; -sf.featureGroup = jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded; -sf.description = jalview.appletgui.FeatureRenderer.lastDescriptionAdded; -if (!this.colourPanel.isGcol) { -this.setColour (sf.type, this.colourPanel.getBackground ()); -}try { -sf.begin = Integer.parseInt (start.getText ()); -sf.end = Integer.parseInt (end.getText ()); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -ffile.parseDescriptionHTML (sf, false); -this.setVisible (jalview.appletgui.FeatureRenderer.lastFeatureAdded); -}if (this.deleteFeature) { -sequences[0].deleteFeature (sf); -}} else { -if (dialog.accept && name.getText ().length > 0) { -for (var i = 0; i < sequences.length; i++) { -features[i].type = jalview.appletgui.FeatureRenderer.lastFeatureAdded; -features[i].featureGroup = jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded; -features[i].description = jalview.appletgui.FeatureRenderer.lastDescriptionAdded; -sequences[i].addSequenceFeature (features[i]); -ffile.parseDescriptionHTML (features[i], false); -} -var newColour = this.colourPanel.getBackground (); -if (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded != null) { -this.setGroupVisibility (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded, true); -}this.setColour (jalview.appletgui.FeatureRenderer.lastFeatureAdded, newColour); -this.setVisible (jalview.appletgui.FeatureRenderer.lastFeatureAdded); -this.findAllFeatures (false); -} else { -return false; -}}if ((this.av).featureSettings != null) { -(this.av).featureSettings.refreshTable (); -}ap.paintAlignment (true); -return true; -}, "~A,~A,~B,jalview.appletgui.AlignmentPanel"); -c$.$FeatureRenderer$FeatureColourPanel$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.label = ""; -this.maxCol = null; -this.isColourByLabel = false; -this.isGcol = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.FeatureRenderer, "FeatureColourPanel", awt2swing.Panel); -Clazz.defineMethod (c$, "updateColor", -function (a) { -var b; -var c = null; -var d = null; -var e = ""; -if (Clazz.instanceOf (a, java.awt.Color)) { -this.isGcol = false; -c = a; -d = null; -} else if (Clazz.instanceOf (a, jalview.schemes.GraduatedColor)) { -this.isGcol = true; -d = a; -c = null; -} else { -throw new Error (jalview.util.MessageManager.getString ("error.invalid_colour_for_mycheckbox")); -}if (c != null) { -this.setBackground (b = c); -} else { -if (d.getThreshType () != -1) { -e += " " + ((d.getThreshType () == 1) ? "(>)" : "(<)"); -}if (this.isColourByLabel = d.isColourByLabel ()) { -this.setBackground (b = java.awt.Color.white); -e += " (by Label)"; -} else { -this.setBackground (b = d.getMinColor ()); -this.maxCol = d.getMaxColor (); -}}this.label = e; -this.setBackground (b); -this.repaint (); -}, "~O"); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.FeatureRenderer.FeatureColourPanel, [null]); -}); -Clazz.defineMethod (c$, "PaintComponent", -function (a) { -var b = this.getSize (); -if (this.isGcol) { -if (this.isColourByLabel) { -a.setColor (java.awt.Color.white); -a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); -a.setColor (java.awt.Color.black); -var c = new java.awt.Font ("Verdana", 0, 10); -a.setFont (c); -a.drawString (jalview.util.MessageManager.getString ("label.label"), 0, 0); -} else { -a.setColor (this.maxCol); -a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); -}}}, "java.awt.Graphics"); -c$ = Clazz.p0p (); -}; -c$.$FeatureRenderer$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureRenderer$1", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (e) { -var index = this.f$.overlaps.getSelectedIndex (); -if (index != -1) { -this.b$["jalview.appletgui.FeatureRenderer"].featureIndex = index; -this.f$.name.setText (this.f$.features[index].getType ()); -this.f$.description.setText (this.f$.features[index].getDescription ()); -this.f$.source.setText (this.f$.features[index].getFeatureGroup ()); -this.f$.start.setText (this.f$.features[index].getBegin () + ""); -this.f$.end.setText (this.f$.features[index].getEnd () + ""); -var highlight = new jalview.datamodel.SearchResults (); -highlight.addResult (this.f$.sequences[0], this.f$.features[index].getBegin (), this.f$.features[index].getEnd ()); -this.f$.ap.seqPanel.seqCanvas.highlightSearchResults (highlight); -}var col = this.b$["jalview.appletgui.FeatureRenderer"].getFeatureStyle (this.f$.name.getText ()); -if (col == null) { -col = new jalview.schemes.UserColourScheme ().createColourFromName (this.f$.name.getText ()); -}this.b$["jalview.appletgui.FeatureRenderer"].colourPanel.updateColor (col); -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$FeatureRenderer$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureRenderer$2", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -this.b$["jalview.appletgui.FeatureRenderer"].deleteFeature = true; -this.f$.dialog.setVisible (false); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$FeatureRenderer$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureRenderer$3", java.awt.event.MouseAdapter); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -if (!this.b$["jalview.appletgui.FeatureRenderer"].colourPanel.isGcol) { - new jalview.appletgui.UserDefinedColours (this.f$.fr, this.f$.ap.alignFrame); -} else { -var fcc = new jalview.appletgui.FeatureColourChooser (this.f$.ap.alignFrame, this.f$.name.getText ()); -this.f$.dialog.transferFocus (); -}}, "java.awt.event.MouseEvent"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"lastFeatureAdded", null, -"lastFeatureGroupAdded", null, -"lastDescriptionAdded", null); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.renderer.seqfeatures.FeatureRenderer"], "jalview.appletgui.FeatureRenderer", ["awt2swing.Button", "$.Choice", "$.Label", "$.ScrollPane", "$.TextArea", "$.TextField", "jalview.appletgui.FeatureColourChooser", "$.JVDialog", "$.UserDefinedColours", "jalview.datamodel.SearchResults", "jalview.io.FeaturesFile", "jalview.schemes.GraduatedColor", "$.UserColourScheme", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.Font", "$.GridLayout", "java.awt.event.ActionListener", "$.ItemListener", "$.MouseAdapter", "java.lang.Error"], function () { +c$ = Clazz.decorateAsClass (function () { +this.featureLinks = null; +this.featureIndex = 0; +this.deleteFeature = false; +this.colourPanel = null; +if (!Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer.FeatureColourPanel")) { +jalview.appletgui.FeatureRenderer.$FeatureRenderer$FeatureColourPanel$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "FeatureRenderer", jalview.renderer.seqfeatures.FeatureRenderer); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.FeatureRenderer); +this.av = av; +this.setTransparencyAvailable (!System.getProperty ("java.version").startsWith ("1.1")); +}, "jalview.viewmodel.AlignmentViewport"); +Clazz.defineMethod (c$, "amendFeatures", +function (sequences, features, newFeatures, ap) { +var bigPanel = new awt2swing.Panel ( new java.awt.BorderLayout ()); +var name = new awt2swing.TextField (16); +var source = new awt2swing.TextField (16); +var description = new awt2swing.TextArea (3, 35); +var start = new awt2swing.TextField (8); +var end = new awt2swing.TextField (8); +var overlaps; +var deleteButton = new awt2swing.Button ("Delete"); +this.deleteFeature = false; +this.colourPanel = Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer.FeatureColourPanel, this, null); +this.colourPanel.setSize (110, 15); +var fr = this; +var panel = new awt2swing.Panel ( new java.awt.GridLayout (3, 1)); +this.featureIndex = 0; +var tmp; +if (!newFeatures && features.length > 1) { +panel = new awt2swing.Panel ( new java.awt.GridLayout (4, 1)); +tmp = new awt2swing.Panel (); +tmp.add ( new awt2swing.Label ("Select Feature: ")); +overlaps = new awt2swing.Choice (); +for (var i = 0; i < features.length; i++) { +var item = features[i].getType () + "/" + features[i].getBegin () + "-" + features[i].getEnd (); +if (features[i].getFeatureGroup () != null) { +item += " (" + features[i].getFeatureGroup () + ")"; +}overlaps.addItem (item); +} +tmp.add (overlaps); +overlaps.addItemListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer$1") ? 0 : jalview.appletgui.FeatureRenderer.$FeatureRenderer$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer$1, this, Clazz.cloneFinals ("overlaps", overlaps, "name", name, "features", features, "description", description, "source", source, "start", start, "end", end, "sequences", sequences, "ap", ap)))); +panel.add (tmp); +}tmp = new awt2swing.Panel (); +panel.add (tmp); +tmp.add ( new awt2swing.Label ("Name: ", 4)); +tmp.add (name); +tmp = new awt2swing.Panel (); +panel.add (tmp); +tmp.add ( new awt2swing.Label ("Group: ", 4)); +tmp.add (source); +tmp = new awt2swing.Panel (); +panel.add (tmp); +tmp.add ( new awt2swing.Label ("Colour: ", 4)); +tmp.add (this.colourPanel); +bigPanel.add (panel, "North"); +panel = new awt2swing.Panel (); +panel.add ( new awt2swing.Label ("Description: ", 4)); +panel.add ( new awt2swing.ScrollPane ().add (description)); +if (!newFeatures) { +bigPanel.add (panel, "South"); +panel = new awt2swing.Panel (); +panel.add ( new awt2swing.Label (" Start:", 4)); +panel.add (start); +panel.add ( new awt2swing.Label (" End:", 4)); +panel.add (end); +bigPanel.add (panel, "Center"); +} else { +bigPanel.add (panel, "Center"); +}if (jalview.appletgui.FeatureRenderer.lastFeatureAdded == null) { +if (features[0].type != null) { +jalview.appletgui.FeatureRenderer.lastFeatureAdded = features[0].type; +} else { +jalview.appletgui.FeatureRenderer.lastFeatureAdded = "feature_1"; +}}if (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded == null) { +if (features[0].featureGroup != null) { +jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded = features[0].featureGroup; +} else { +jalview.appletgui.FeatureRenderer.lastFeatureAdded = "Jalview"; +}}var title = newFeatures ? jalview.util.MessageManager.getString ("label.create_new_sequence_features") : jalview.util.MessageManager.formatMessage ("label.amend_delete_features", Clazz.newArray (-1, [sequences[0].getName ()])); +var dialog = new jalview.appletgui.JVDialog (ap.alignFrame, title, true, 385, 240); +dialog.setMainPanel (bigPanel); +if (newFeatures) { +name.setText (jalview.appletgui.FeatureRenderer.lastFeatureAdded); +source.setText (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded); +} else { +dialog.ok.setLabel (jalview.util.MessageManager.getString ("label.amend")); +dialog.buttonPanel.add (deleteButton, 1); +deleteButton.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer$2") ? 0 : jalview.appletgui.FeatureRenderer.$FeatureRenderer$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer$2, this, Clazz.cloneFinals ("dialog", dialog)))); +name.setText (features[0].getType ()); +source.setText (features[0].getFeatureGroup ()); +}start.setText (features[0].getBegin () + ""); +end.setText (features[0].getEnd () + ""); +description.setText (features[0].getDescription ()); +var col = this.getColour (name.getText ()); +if (col == null) { +col = new jalview.schemes.UserColourScheme ().createColourFromName (name.getText ()); +}var fcol = this.getFeatureStyle (name.getText ()); +this.colourPanel.updateColor (fcol); +dialog.setResizable (true); +this.colourPanel.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureRenderer$3") ? 0 : jalview.appletgui.FeatureRenderer.$FeatureRenderer$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureRenderer$3, this, Clazz.cloneFinals ("fr", fr, "ap", ap, "name", name, "dialog", dialog)))); +dialog.setVisible (true); +var ffile = new jalview.io.FeaturesFile (); +if (dialog.accept) { +this.lastSeq = null; +jalview.appletgui.FeatureRenderer.lastFeatureAdded = name.getText ().trim (); +jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded = source.getText ().trim (); +jalview.appletgui.FeatureRenderer.lastDescriptionAdded = description.getText ().$replace ('\n', ' '); +}if (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded != null && jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded.length < 1) { +jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded = null; +}if (!newFeatures) { +var sf = features[this.featureIndex]; +if (dialog.accept) { +sf.type = jalview.appletgui.FeatureRenderer.lastFeatureAdded; +sf.featureGroup = jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded; +sf.description = jalview.appletgui.FeatureRenderer.lastDescriptionAdded; +if (!this.colourPanel.isGcol) { +this.setColour (sf.type, this.colourPanel.getBackground ()); +}try { +sf.begin = Integer.parseInt (start.getText ()); +sf.end = Integer.parseInt (end.getText ()); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +ffile.parseDescriptionHTML (sf, false); +this.setVisible (jalview.appletgui.FeatureRenderer.lastFeatureAdded); +}if (this.deleteFeature) { +sequences[0].deleteFeature (sf); +}} else { +if (dialog.accept && name.getText ().length > 0) { +for (var i = 0; i < sequences.length; i++) { +features[i].type = jalview.appletgui.FeatureRenderer.lastFeatureAdded; +features[i].featureGroup = jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded; +features[i].description = jalview.appletgui.FeatureRenderer.lastDescriptionAdded; +sequences[i].addSequenceFeature (features[i]); +ffile.parseDescriptionHTML (features[i], false); +} +var newColour = this.colourPanel.getBackground (); +if (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded != null) { +this.setGroupVisibility (jalview.appletgui.FeatureRenderer.lastFeatureGroupAdded, true); +}this.setColour (jalview.appletgui.FeatureRenderer.lastFeatureAdded, newColour); +this.setVisible (jalview.appletgui.FeatureRenderer.lastFeatureAdded); +this.findAllFeatures (false); +} else { +return false; +}}if ((this.av).featureSettings != null) { +(this.av).featureSettings.refreshTable (); +}ap.paintAlignment (true); +return true; +}, "~A,~A,~B,jalview.appletgui.AlignmentPanel"); +c$.$FeatureRenderer$FeatureColourPanel$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.label = ""; +this.maxCol = null; +this.isColourByLabel = false; +this.isGcol = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.FeatureRenderer, "FeatureColourPanel", awt2swing.Panel); +Clazz.defineMethod (c$, "updateColor", +function (a) { +var b; +var c = null; +var d = null; +var e = ""; +if (Clazz.instanceOf (a, java.awt.Color)) { +this.isGcol = false; +c = a; +d = null; +} else if (Clazz.instanceOf (a, jalview.schemes.GraduatedColor)) { +this.isGcol = true; +d = a; +c = null; +} else { +throw new Error (jalview.util.MessageManager.getString ("error.invalid_colour_for_mycheckbox")); +}if (c != null) { +this.setBackground (b = c); +} else { +if (d.getThreshType () != -1) { +e += " " + ((d.getThreshType () == 1) ? "(>)" : "(<)"); +}if (this.isColourByLabel = d.isColourByLabel ()) { +this.setBackground (b = java.awt.Color.white); +e += " (by Label)"; +} else { +this.setBackground (b = d.getMinColor ()); +this.maxCol = d.getMaxColor (); +}}this.label = e; +this.setBackground (b); +this.repaint (); +}, "~O"); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.FeatureRenderer.FeatureColourPanel, [null]); +}); +Clazz.defineMethod (c$, "PaintComponent", +function (a) { +var b = this.getSize (); +if (this.isGcol) { +if (this.isColourByLabel) { +a.setColor (java.awt.Color.white); +a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); +a.setColor (java.awt.Color.black); +var c = new java.awt.Font ("Verdana", 0, 10); +a.setFont (c); +a.drawString (jalview.util.MessageManager.getString ("label.label"), 0, 0); +} else { +a.setColor (this.maxCol); +a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); +}}}, "java.awt.Graphics"); +c$ = Clazz.p0p (); +}; +c$.$FeatureRenderer$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureRenderer$1", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (e) { +var index = this.f$.overlaps.getSelectedIndex (); +if (index != -1) { +this.b$["jalview.appletgui.FeatureRenderer"].featureIndex = index; +this.f$.name.setText (this.f$.features[index].getType ()); +this.f$.description.setText (this.f$.features[index].getDescription ()); +this.f$.source.setText (this.f$.features[index].getFeatureGroup ()); +this.f$.start.setText (this.f$.features[index].getBegin () + ""); +this.f$.end.setText (this.f$.features[index].getEnd () + ""); +var highlight = new jalview.datamodel.SearchResults (); +highlight.addResult (this.f$.sequences[0], this.f$.features[index].getBegin (), this.f$.features[index].getEnd ()); +this.f$.ap.seqPanel.seqCanvas.highlightSearchResults (highlight); +}var col = this.b$["jalview.appletgui.FeatureRenderer"].getFeatureStyle (this.f$.name.getText ()); +if (col == null) { +col = new jalview.schemes.UserColourScheme ().createColourFromName (this.f$.name.getText ()); +}this.b$["jalview.appletgui.FeatureRenderer"].colourPanel.updateColor (col); +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$FeatureRenderer$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureRenderer$2", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +this.b$["jalview.appletgui.FeatureRenderer"].deleteFeature = true; +this.f$.dialog.setVisible (false); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$FeatureRenderer$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureRenderer$3", java.awt.event.MouseAdapter); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +if (!this.b$["jalview.appletgui.FeatureRenderer"].colourPanel.isGcol) { + new jalview.appletgui.UserDefinedColours (this.f$.fr, this.f$.ap.alignFrame); +} else { +var fcc = new jalview.appletgui.FeatureColourChooser (this.f$.ap.alignFrame, this.f$.name.getText ()); +this.f$.dialog.transferFocus (); +}}, "java.awt.event.MouseEvent"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"lastFeatureAdded", null, +"lastFeatureGroupAdded", null, +"lastDescriptionAdded", null); +}); diff --git a/bin/jalview/appletgui/FeatureSettings.js b/bin/jalview/appletgui/FeatureSettings.js index cc92844..c10ac3f 100644 --- a/bin/jalview/appletgui/FeatureSettings.js +++ b/bin/jalview/appletgui/FeatureSettings.js @@ -1,444 +1,444 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Checkbox", "$.Panel", "jalview.api.FeatureSettingsControllerI", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.FeatureSettings", ["awt2swing.Button", "$.Frame", "$.Label", "$.MenuItem", "$.PopupMenu", "$.ScrollPane", "$.Scrollbar", "jalview.appletgui.FeatureColourChooser", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.schemes.GraduatedColor", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.Font", "$.GridLayout", "$.Toolkit", "java.awt.event.WindowAdapter", "java.lang.Boolean", "$.Error", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fr = null; -this.ap = null; -this.av = null; -this.frame = null; -this.groupPanel = null; -this.featurePanel = null; -this.scrollPane = null; -this.linkImage = null; -this.transparency = null; -this.groupItemListener = null; -this.selectedCheck = null; -this.dragging = false; -if (!Clazz.isClassDefined ("jalview.appletgui.FeatureSettings.MyCheckbox")) { -jalview.appletgui.FeatureSettings.$FeatureSettings$MyCheckbox$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "FeatureSettings", awt2swing.Panel, [java.awt.event.ItemListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ActionListener, java.awt.event.AdjustmentListener, jalview.api.FeatureSettingsControllerI]); -Clazz.prepareFields (c$, function () { -this.featurePanel = new awt2swing.Panel (); -this.groupItemListener = ((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$1") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$1, this, null)); -}); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.FeatureSettings, []); -this.ap = ap; -this.av = ap.av; -ap.av.featureSettings = this; -this.fr = ap.seqPanel.seqCanvas.getFeatureRenderer (); -this.transparency = new awt2swing.Scrollbar (0, 100 - Clazz.floatToInt (this.fr.getTransparency () * 100), 1, 1, 100); -if (this.fr.isTransparencyAvailable ()) { -this.transparency.addAdjustmentListener (this); -} else { -this.transparency.setEnabled (false); -}var url = this.getClass ().getResource ("/images/link.gif"); -if (url != null) { -this.linkImage = java.awt.Toolkit.getDefaultToolkit ().getImage (url); -}if (this.av.isShowSequenceFeatures () || !this.fr.hasRenderOrder ()) { -this.fr.findAllFeatures (true); -}this.discoverAllFeatureData (); -this.setLayout ( new java.awt.BorderLayout ()); -this.scrollPane = new awt2swing.ScrollPane (); -this.scrollPane.add (this.featurePanel); -if (this.fr.getAllFeatureColours () != null && this.fr.getAllFeatureColours ().size () > 0) { -this.add (this.scrollPane, "Center"); -}var invert = new awt2swing.Button ("Invert Selection"); -invert.addActionListener (this); -var lowerPanel = new awt2swing.Panel ( new java.awt.GridLayout (2, 1, 5, 10)); -lowerPanel.add (invert); -var tPanel = new awt2swing.Panel ( new java.awt.BorderLayout ()); -if (this.fr.isTransparencyAvailable ()) { -tPanel.add (this.transparency, "Center"); -tPanel.add ( new awt2swing.Label ("Transparency"), "East"); -} else { -tPanel.add ( new awt2swing.Label ("Transparency not available in this web browser"), "Center"); -}lowerPanel.add (tPanel, "South"); -this.add (lowerPanel, "South"); -if (this.groupPanel != null) { -this.groupPanel.setLayout ( new java.awt.GridLayout (Clazz.doubleToInt ((this.fr.getFeatureGroupsSize ()) / 4) + 1, 4)); -this.groupPanel.validate (); -this.add (this.groupPanel, "North"); -}this.frame = new awt2swing.Frame (); -this.frame.add (this); -var me = this; -this.frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$2") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$2, this, Clazz.cloneFinals ("me", me)))); -var height = this.featurePanel.getComponentCount () * 50 + 60; -height = Math.max (200, height); -height = Math.min (400, height); -var width = 300; -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.feature_settings"), width, height); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "PaintComponent", -function (g) { -g.setColor (java.awt.Color.black); -g.drawString (jalview.util.MessageManager.getString ("label.no_features_added_to_this_alignment"), 10, 20); -g.drawString (jalview.util.MessageManager.getString ("label.features_can_be_added_from_searches_1"), 10, 40); -g.drawString (jalview.util.MessageManager.getString ("label.features_can_be_added_from_searches_2"), 10, 60); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "popupSort", -function (check, minmax, x, y) { -var type = check.type; -var typeCol = this.fr.getFeatureStyle (type); -var men = new awt2swing.PopupMenu (jalview.util.MessageManager.formatMessage ("label.settings_for_type", Clazz.newArray (-1, [type]))); -var scr = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sort_by_score")); -men.add (scr); -var me = this; -scr.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$3") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$3, this, Clazz.cloneFinals ("me", me, "type", type)))); -var dens = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sort_by_density")); -dens.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$4") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$4$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$4, this, Clazz.cloneFinals ("me", me, "type", type)))); -men.add (dens); -if (minmax != null) { -var typeMinMax = minmax.get (type); -if (typeMinMax != null && (typeMinMax)[0] != null) { -var mxcol = new awt2swing.MenuItem ((Clazz.instanceOf (typeCol, java.awt.Color)) ? "Graduated Colour" : "Single Colour"); -men.add (mxcol); -mxcol.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$5") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$5$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$5, this, Clazz.cloneFinals ("typeCol", typeCol, "me", me, "type", type, "check", check)))); -}}this.featurePanel.add (men); -men.show (this.featurePanel, x, y); -}, "jalview.appletgui.FeatureSettings.MyCheckbox,java.util.Hashtable,~N,~N"); -Clazz.overrideMethod (c$, "discoverAllFeatureData", -function () { -if (this.fr.getAllFeatureColours () != null && this.fr.getAllFeatureColours ().size () > 0) { -this.rebuildGroups (); -}this.resetTable (false); -}); -Clazz.defineMethod (c$, "rebuildGroups", -function () { -var rdrw = false; -if (this.groupPanel == null) { -this.groupPanel = new awt2swing.Panel (); -} else { -rdrw = true; -this.groupPanel.removeAll (); -}for (var group, $group = this.fr.getFeatureGroups ().iterator (); $group.hasNext () && ((group = $group.next ()) || true);) { -var vis = this.fr.checkGroupVisibility (group, false); -var check = Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings.MyCheckbox, this, null, group, vis, (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (group))); -check.addMouseListener (this); -check.setFont ( new java.awt.Font ("Serif", 1, 12)); -check.addItemListener (this.groupItemListener); -check.setVisible (vis); -this.groupPanel.add (check); -} -if (rdrw) { -this.groupPanel.validate (); -}}); -Clazz.defineMethod (c$, "resetTable", -function (groupsChanged) { -var tmpfeatures; -var group = null; -var type; -var visibleChecks = new java.util.Vector (); -var alignment = this.av.getAlignment (); -for (var i = 0; i < alignment.getHeight (); i++) { -if (alignment.getSequenceAt (i).getSequenceFeatures () == null) { -continue; -}tmpfeatures = alignment.getSequenceAt (i).getSequenceFeatures (); -var index = 0; -while (index < tmpfeatures.length) { -group = tmpfeatures[index].featureGroup; -if (group == null || this.fr.checkGroupVisibility (group, true)) { -type = tmpfeatures[index].getType (); -if (!visibleChecks.contains (type)) { -visibleChecks.addElement (type); -}}index++; -} -} -var comps; -var cSize = this.featurePanel.getComponentCount (); -var check; -for (var i = 0; i < cSize; i++) { -comps = this.featurePanel.getComponents (); -check = comps[i]; -if (!visibleChecks.contains (check.type)) { -this.featurePanel.remove (i); -cSize--; -i--; -}} -if (this.fr.getRenderOrder () != null) { -var rol = this.fr.getRenderOrder (); -for (var ro = rol.size () - 1; ro > -1; ro--) { -var item = rol.get (ro); -if (!visibleChecks.contains (item)) { -continue; -}visibleChecks.removeElement (item); -this.addCheck (false, item); -} -}var en = visibleChecks.elements (); -while (en.hasMoreElements ()) { -this.addCheck (groupsChanged, en.nextElement ().toString ()); -} -this.featurePanel.setLayout ( new java.awt.GridLayout (this.featurePanel.getComponentCount (), 1, 10, 5)); -this.featurePanel.validate (); -if (this.scrollPane != null) { -this.scrollPane.validate (); -}this.itemStateChanged (null); -}, "~B"); -Clazz.defineMethod (c$, "addCheck", -function (groupsChanged, type) { -var addCheck; -var comps = this.featurePanel.getComponents (); -var check; -addCheck = true; -for (var i = 0; i < this.featurePanel.getComponentCount (); i++) { -check = comps[i]; -if (check.type.equals (type)) { -addCheck = false; -break; -}} -if (addCheck) { -var selected = false; -if (groupsChanged || this.av.getFeaturesDisplayed ().isVisible (type)) { -selected = true; -}check = Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings.MyCheckbox, this, null, type, selected, (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (type)), this.fr.getFeatureStyle (type)); -check.addMouseListener (this); -check.addMouseMotionListener (this); -check.addItemListener (this); -if (groupsChanged) { -this.featurePanel.add (check, 0); -} else { -this.featurePanel.add (check); -}}}, "~B,~S"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -for (var i = 0; i < this.featurePanel.getComponentCount (); i++) { -var check = this.featurePanel.getComponent (i); -check.setState (!check.getState ()); -} -this.selectionChanged (); -}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -this.selectionChanged (); -}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "selectionChanged", -function () { -var comps = this.featurePanel.getComponents (); -var cSize = comps.length; -var tmp = Clazz.newArray (cSize, 3, null); -var tmpSize = 0; -for (var i = 0; i < cSize; i++) { -var check = comps[i]; -tmp[tmpSize][0] = check.type; -tmp[tmpSize][1] = this.fr.getFeatureStyle (check.type); -tmp[tmpSize][2] = new Boolean (check.getState ()); -tmpSize++; -} -var data = Clazz.newArray (tmpSize, 3, null); -System.arraycopy (tmp, 0, data, 0, tmpSize); -this.fr.setFeaturePriority (data); -this.ap.paintAlignment (true); -}); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -this.selectedCheck = evt.getSource (); -if (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (this.selectedCheck.type)) { -if (evt.getX () > this.selectedCheck.stringWidth + 20) { -evt.consume (); -}}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -if ((evt.getSource ()).getParent () !== this.featurePanel) { -return; -}this.dragging = true; -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -if ((evt.getSource ()).getParent () !== this.featurePanel) { -return; -}var comp = null; -var target = null; -var height = evt.getY () + evt.getComponent ().getLocation ().y; -if (height > this.featurePanel.getSize ().height) { -comp = this.featurePanel.getComponent (this.featurePanel.getComponentCount () - 1); -} else if (height < 0) { -comp = this.featurePanel.getComponent (0); -} else { -comp = this.featurePanel.getComponentAt (evt.getX (), evt.getY () + evt.getComponent ().getLocation ().y); -}if (comp != null && Clazz.instanceOf (comp, awt2swing.Checkbox)) { -target = comp; -}if (this.selectedCheck != null && target != null && this.selectedCheck !== target) { -var targetIndex = -1; -for (var i = 0; i < this.featurePanel.getComponentCount (); i++) { -if (target === this.featurePanel.getComponent (i)) { -targetIndex = i; -break; -}} -this.featurePanel.remove (this.selectedCheck); -this.featurePanel.add (this.selectedCheck, targetIndex); -this.featurePanel.validate (); -this.itemStateChanged (null); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "setUserColour", -function (feature, originalColour) { -if (Clazz.instanceOf (originalColour, java.awt.Color) || Clazz.instanceOf (originalColour, jalview.schemes.GraduatedColor)) { -this.fr.setColour (feature, originalColour); -} else { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_unsupported_feature_colour_object")); -}this.refreshTable (); -}, "~S,~O"); -Clazz.defineMethod (c$, "refreshTable", -function () { -this.featurePanel.removeAll (); -this.resetTable (false); -this.ap.paintAlignment (true); -}); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -var check = evt.getSource (); -if ((evt.getModifiers () & 4) != 0) { -this.popupSort (check, this.fr.getMinMax (), evt.getX (), evt.getY ()); -}if (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (check.type)) { -if (evt.getX () > check.stringWidth + 20) { -evt.consume (); -var link = this.fr.featureLinks.get (check.type).toString (); -this.ap.alignFrame.showURL (link.substring (link.indexOf ("|") + 1), link.substring (0, link.indexOf ("|"))); -}}if (check.getParent () !== this.featurePanel) { -return; -}if (evt.getClickCount () > 1) { -var fcol = this.fr.getFeatureStyle (check.type); -if (Clazz.instanceOf (fcol, java.awt.Color)) { - new jalview.appletgui.UserDefinedColours (this, check.type, fcol); -} else { - new jalview.appletgui.FeatureColourChooser (this, check.type); -check.updateColor (this.fr.getFeatureStyle (check.type)); -}}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -this.fr.setTransparency ((100 - this.transparency.getValue ()) / 100); -this.ap.seqPanel.seqCanvas.repaint (); -}, "java.awt.event.AdjustmentEvent"); -c$.$FeatureSettings$MyCheckbox$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.type = null; -this.stringWidth = 0; -this.hasLink = false; -this.gcol = null; -this.col = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.FeatureSettings, "MyCheckbox", awt2swing.Checkbox); -Clazz.defineMethod (c$, "updateColor", -function (a) { -if (Clazz.instanceOf (a, java.awt.Color)) { -this.col = a; -this.gcol = null; -} else if (Clazz.instanceOf (a, jalview.schemes.GraduatedColor)) { -this.gcol = a; -this.col = null; -} else { -throw new Error (jalview.util.MessageManager.getString ("error.invalid_colour_for_mycheckbox")); -}if (this.col != null) { -this.setBackground (this.col); -} else { -var b = this.type; -if (this.gcol.getThreshType () != -1) { -b += " " + ((this.gcol.getThreshType () == 1) ? "(>)" : "(<)"); -}if (this.gcol.isColourByLabel ()) { -this.setBackground (java.awt.Color.white); -b += " (by Label)"; -} else { -this.setBackground (this.gcol.getMinColor ()); -}this.setLabel (b); -}this.repaint (); -}, "~O"); -Clazz.makeConstructor (c$, -function (a, b, c) { -Clazz.superConstructor (this, jalview.appletgui.FeatureSettings.MyCheckbox, [a, b]); -this.type = a; -var d = this.b$["jalview.appletgui.FeatureSettings"].av.nullFrame.getFontMetrics (this.b$["jalview.appletgui.FeatureSettings"].av.nullFrame.getFont ()); -this.stringWidth = d.stringWidth (a); -this.hasLink = c; -}, "~S,~B,~B"); -Clazz.makeConstructor (c$, -function (a, b, c, d) { -this.construct (a, b, c); -this.updateColor (d); -}, "~S,~B,~B,~O"); -Clazz.defineMethod (c$, "PaintComponent", -function (a) { -var b = this.getSize (); -if (this.gcol != null) { -if (this.gcol.isColourByLabel ()) { -a.setColor (java.awt.Color.white); -a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); -} else { -var c = this.gcol.getMaxColor (); -a.setColor (c); -a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); -}}if (this.hasLink) { -a.drawImage (this.b$["jalview.appletgui.FeatureSettings"].linkImage, this.stringWidth + 25, Clazz.doubleToInt ((this.getSize ().height - this.b$["jalview.appletgui.FeatureSettings"].linkImage.getHeight (this)) / 2), this); -}}, "java.awt.Graphics"); -c$ = Clazz.p0p (); -}; -c$.$FeatureSettings$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$1", null, java.awt.event.ItemListener); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -var source = evt.getSource (); -this.b$["jalview.appletgui.FeatureSettings"].fr.setGroupVisibility (source.getLabel (), source.getState ()); -this.b$["jalview.appletgui.FeatureSettings"].ap.seqPanel.seqCanvas.repaint (); -if (this.b$["jalview.appletgui.FeatureSettings"].ap.overviewPanel != null) { -this.b$["jalview.appletgui.FeatureSettings"].ap.overviewPanel.updateOverviewImage (); -}this.b$["jalview.appletgui.FeatureSettings"].resetTable (true); -return; -}, "java.awt.event.ItemEvent"); -c$ = Clazz.p0p (); -}; -c$.$FeatureSettings$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$2", java.awt.event.WindowAdapter); -Clazz.overrideMethod (c$, "windowClosing", -function (e) { -if (this.f$.me.av.featureSettings === this.f$.me) { -this.f$.me.av.featureSettings = null; -this.f$.me.ap = null; -this.f$.me.av = null; -}}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -c$.$FeatureSettings$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$3", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.f$.me.ap.alignFrame.avc.sortAlignmentByFeatureScore ( Clazz.newArray (-1, [this.f$.type])); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$FeatureSettings$4$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$4", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.f$.me.ap.alignFrame.avc.sortAlignmentByFeatureDensity ( Clazz.newArray (-1, [this.f$.type])); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$FeatureSettings$5$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$5", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -if (Clazz.instanceOf (this.f$.typeCol, java.awt.Color)) { - new jalview.appletgui.FeatureColourChooser (this.f$.me, this.f$.type); -this.f$.check.updateColor (this.b$["jalview.appletgui.FeatureSettings"].fr.getFeatureStyle (this.f$.type)); -} else { - new jalview.appletgui.UserDefinedColours (this.f$.me, this.f$.check.type, (this.f$.typeCol)); -}}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Checkbox", "$.Panel", "jalview.api.FeatureSettingsControllerI", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.ItemListener", "$.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.FeatureSettings", ["awt2swing.Button", "$.Frame", "$.Label", "$.MenuItem", "$.PopupMenu", "$.ScrollPane", "$.Scrollbar", "jalview.appletgui.FeatureColourChooser", "$.UserDefinedColours", "jalview.bin.JalviewLite", "jalview.schemes.GraduatedColor", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.Font", "$.GridLayout", "$.Toolkit", "java.awt.event.WindowAdapter", "java.lang.Boolean", "$.Error", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fr = null; +this.ap = null; +this.av = null; +this.frame = null; +this.groupPanel = null; +this.featurePanel = null; +this.scrollPane = null; +this.linkImage = null; +this.transparency = null; +this.groupItemListener = null; +this.selectedCheck = null; +this.dragging = false; +if (!Clazz.isClassDefined ("jalview.appletgui.FeatureSettings.MyCheckbox")) { +jalview.appletgui.FeatureSettings.$FeatureSettings$MyCheckbox$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "FeatureSettings", awt2swing.Panel, [java.awt.event.ItemListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ActionListener, java.awt.event.AdjustmentListener, jalview.api.FeatureSettingsControllerI]); +Clazz.prepareFields (c$, function () { +this.featurePanel = new awt2swing.Panel (); +this.groupItemListener = ((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$1") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$1, this, null)); +}); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.FeatureSettings, []); +this.ap = ap; +this.av = ap.av; +ap.av.featureSettings = this; +this.fr = ap.seqPanel.seqCanvas.getFeatureRenderer (); +this.transparency = new awt2swing.Scrollbar (0, 100 - Clazz.floatToInt (this.fr.getTransparency () * 100), 1, 1, 100); +if (this.fr.isTransparencyAvailable ()) { +this.transparency.addAdjustmentListener (this); +} else { +this.transparency.setEnabled (false); +}var url = this.getClass ().getResource ("/images/link.gif"); +if (url != null) { +this.linkImage = java.awt.Toolkit.getDefaultToolkit ().getImage (url); +}if (this.av.isShowSequenceFeatures () || !this.fr.hasRenderOrder ()) { +this.fr.findAllFeatures (true); +}this.discoverAllFeatureData (); +this.setLayout ( new java.awt.BorderLayout ()); +this.scrollPane = new awt2swing.ScrollPane (); +this.scrollPane.add (this.featurePanel); +if (this.fr.getAllFeatureColours () != null && this.fr.getAllFeatureColours ().size () > 0) { +this.add (this.scrollPane, "Center"); +}var invert = new awt2swing.Button ("Invert Selection"); +invert.addActionListener (this); +var lowerPanel = new awt2swing.Panel ( new java.awt.GridLayout (2, 1, 5, 10)); +lowerPanel.add (invert); +var tPanel = new awt2swing.Panel ( new java.awt.BorderLayout ()); +if (this.fr.isTransparencyAvailable ()) { +tPanel.add (this.transparency, "Center"); +tPanel.add ( new awt2swing.Label ("Transparency"), "East"); +} else { +tPanel.add ( new awt2swing.Label ("Transparency not available in this web browser"), "Center"); +}lowerPanel.add (tPanel, "South"); +this.add (lowerPanel, "South"); +if (this.groupPanel != null) { +this.groupPanel.setLayout ( new java.awt.GridLayout (Clazz.doubleToInt ((this.fr.getFeatureGroupsSize ()) / 4) + 1, 4)); +this.groupPanel.validate (); +this.add (this.groupPanel, "North"); +}this.frame = new awt2swing.Frame (); +this.frame.add (this); +var me = this; +this.frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$2") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$2, this, Clazz.cloneFinals ("me", me)))); +var height = this.featurePanel.getComponentCount () * 50 + 60; +height = Math.max (200, height); +height = Math.min (400, height); +var width = 300; +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.feature_settings"), width, height); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "PaintComponent", +function (g) { +g.setColor (java.awt.Color.black); +g.drawString (jalview.util.MessageManager.getString ("label.no_features_added_to_this_alignment"), 10, 20); +g.drawString (jalview.util.MessageManager.getString ("label.features_can_be_added_from_searches_1"), 10, 40); +g.drawString (jalview.util.MessageManager.getString ("label.features_can_be_added_from_searches_2"), 10, 60); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "popupSort", +function (check, minmax, x, y) { +var type = check.type; +var typeCol = this.fr.getFeatureStyle (type); +var men = new awt2swing.PopupMenu (jalview.util.MessageManager.formatMessage ("label.settings_for_type", Clazz.newArray (-1, [type]))); +var scr = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sort_by_score")); +men.add (scr); +var me = this; +scr.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$3") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$3, this, Clazz.cloneFinals ("me", me, "type", type)))); +var dens = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.sort_by_density")); +dens.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$4") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$4$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$4, this, Clazz.cloneFinals ("me", me, "type", type)))); +men.add (dens); +if (minmax != null) { +var typeMinMax = minmax.get (type); +if (typeMinMax != null && (typeMinMax)[0] != null) { +var mxcol = new awt2swing.MenuItem ((Clazz.instanceOf (typeCol, java.awt.Color)) ? "Graduated Colour" : "Single Colour"); +men.add (mxcol); +mxcol.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FeatureSettings$5") ? 0 : jalview.appletgui.FeatureSettings.$FeatureSettings$5$ ()), Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings$5, this, Clazz.cloneFinals ("typeCol", typeCol, "me", me, "type", type, "check", check)))); +}}this.featurePanel.add (men); +men.show (this.featurePanel, x, y); +}, "jalview.appletgui.FeatureSettings.MyCheckbox,java.util.Hashtable,~N,~N"); +Clazz.overrideMethod (c$, "discoverAllFeatureData", +function () { +if (this.fr.getAllFeatureColours () != null && this.fr.getAllFeatureColours ().size () > 0) { +this.rebuildGroups (); +}this.resetTable (false); +}); +Clazz.defineMethod (c$, "rebuildGroups", +function () { +var rdrw = false; +if (this.groupPanel == null) { +this.groupPanel = new awt2swing.Panel (); +} else { +rdrw = true; +this.groupPanel.removeAll (); +}for (var group, $group = this.fr.getFeatureGroups ().iterator (); $group.hasNext () && ((group = $group.next ()) || true);) { +var vis = this.fr.checkGroupVisibility (group, false); +var check = Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings.MyCheckbox, this, null, group, vis, (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (group))); +check.addMouseListener (this); +check.setFont ( new java.awt.Font ("Serif", 1, 12)); +check.addItemListener (this.groupItemListener); +check.setVisible (vis); +this.groupPanel.add (check); +} +if (rdrw) { +this.groupPanel.validate (); +}}); +Clazz.defineMethod (c$, "resetTable", +function (groupsChanged) { +var tmpfeatures; +var group = null; +var type; +var visibleChecks = new java.util.Vector (); +var alignment = this.av.getAlignment (); +for (var i = 0; i < alignment.getHeight (); i++) { +if (alignment.getSequenceAt (i).getSequenceFeatures () == null) { +continue; +}tmpfeatures = alignment.getSequenceAt (i).getSequenceFeatures (); +var index = 0; +while (index < tmpfeatures.length) { +group = tmpfeatures[index].featureGroup; +if (group == null || this.fr.checkGroupVisibility (group, true)) { +type = tmpfeatures[index].getType (); +if (!visibleChecks.contains (type)) { +visibleChecks.addElement (type); +}}index++; +} +} +var comps; +var cSize = this.featurePanel.getComponentCount (); +var check; +for (var i = 0; i < cSize; i++) { +comps = this.featurePanel.getComponents (); +check = comps[i]; +if (!visibleChecks.contains (check.type)) { +this.featurePanel.remove (i); +cSize--; +i--; +}} +if (this.fr.getRenderOrder () != null) { +var rol = this.fr.getRenderOrder (); +for (var ro = rol.size () - 1; ro > -1; ro--) { +var item = rol.get (ro); +if (!visibleChecks.contains (item)) { +continue; +}visibleChecks.removeElement (item); +this.addCheck (false, item); +} +}var en = visibleChecks.elements (); +while (en.hasMoreElements ()) { +this.addCheck (groupsChanged, en.nextElement ().toString ()); +} +this.featurePanel.setLayout ( new java.awt.GridLayout (this.featurePanel.getComponentCount (), 1, 10, 5)); +this.featurePanel.validate (); +if (this.scrollPane != null) { +this.scrollPane.validate (); +}this.itemStateChanged (null); +}, "~B"); +Clazz.defineMethod (c$, "addCheck", +function (groupsChanged, type) { +var addCheck; +var comps = this.featurePanel.getComponents (); +var check; +addCheck = true; +for (var i = 0; i < this.featurePanel.getComponentCount (); i++) { +check = comps[i]; +if (check.type.equals (type)) { +addCheck = false; +break; +}} +if (addCheck) { +var selected = false; +if (groupsChanged || this.av.getFeaturesDisplayed ().isVisible (type)) { +selected = true; +}check = Clazz.innerTypeInstance (jalview.appletgui.FeatureSettings.MyCheckbox, this, null, type, selected, (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (type)), this.fr.getFeatureStyle (type)); +check.addMouseListener (this); +check.addMouseMotionListener (this); +check.addItemListener (this); +if (groupsChanged) { +this.featurePanel.add (check, 0); +} else { +this.featurePanel.add (check); +}}}, "~B,~S"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +for (var i = 0; i < this.featurePanel.getComponentCount (); i++) { +var check = this.featurePanel.getComponent (i); +check.setState (!check.getState ()); +} +this.selectionChanged (); +}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +this.selectionChanged (); +}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "selectionChanged", +function () { +var comps = this.featurePanel.getComponents (); +var cSize = comps.length; +var tmp = Clazz.newArray (cSize, 3, null); +var tmpSize = 0; +for (var i = 0; i < cSize; i++) { +var check = comps[i]; +tmp[tmpSize][0] = check.type; +tmp[tmpSize][1] = this.fr.getFeatureStyle (check.type); +tmp[tmpSize][2] = new Boolean (check.getState ()); +tmpSize++; +} +var data = Clazz.newArray (tmpSize, 3, null); +System.arraycopy (tmp, 0, data, 0, tmpSize); +this.fr.setFeaturePriority (data); +this.ap.paintAlignment (true); +}); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +this.selectedCheck = evt.getSource (); +if (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (this.selectedCheck.type)) { +if (evt.getX () > this.selectedCheck.stringWidth + 20) { +evt.consume (); +}}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +if ((evt.getSource ()).getParent () !== this.featurePanel) { +return; +}this.dragging = true; +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +if ((evt.getSource ()).getParent () !== this.featurePanel) { +return; +}var comp = null; +var target = null; +var height = evt.getY () + evt.getComponent ().getLocation ().y; +if (height > this.featurePanel.getSize ().height) { +comp = this.featurePanel.getComponent (this.featurePanel.getComponentCount () - 1); +} else if (height < 0) { +comp = this.featurePanel.getComponent (0); +} else { +comp = this.featurePanel.getComponentAt (evt.getX (), evt.getY () + evt.getComponent ().getLocation ().y); +}if (comp != null && Clazz.instanceOf (comp, awt2swing.Checkbox)) { +target = comp; +}if (this.selectedCheck != null && target != null && this.selectedCheck !== target) { +var targetIndex = -1; +for (var i = 0; i < this.featurePanel.getComponentCount (); i++) { +if (target === this.featurePanel.getComponent (i)) { +targetIndex = i; +break; +}} +this.featurePanel.remove (this.selectedCheck); +this.featurePanel.add (this.selectedCheck, targetIndex); +this.featurePanel.validate (); +this.itemStateChanged (null); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "setUserColour", +function (feature, originalColour) { +if (Clazz.instanceOf (originalColour, java.awt.Color) || Clazz.instanceOf (originalColour, jalview.schemes.GraduatedColor)) { +this.fr.setColour (feature, originalColour); +} else { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_unsupported_feature_colour_object")); +}this.refreshTable (); +}, "~S,~O"); +Clazz.defineMethod (c$, "refreshTable", +function () { +this.featurePanel.removeAll (); +this.resetTable (false); +this.ap.paintAlignment (true); +}); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +var check = evt.getSource (); +if ((evt.getModifiers () & 4) != 0) { +this.popupSort (check, this.fr.getMinMax (), evt.getX (), evt.getY ()); +}if (this.fr.featureLinks != null && this.fr.featureLinks.containsKey (check.type)) { +if (evt.getX () > check.stringWidth + 20) { +evt.consume (); +var link = this.fr.featureLinks.get (check.type).toString (); +this.ap.alignFrame.showURL (link.substring (link.indexOf ("|") + 1), link.substring (0, link.indexOf ("|"))); +}}if (check.getParent () !== this.featurePanel) { +return; +}if (evt.getClickCount () > 1) { +var fcol = this.fr.getFeatureStyle (check.type); +if (Clazz.instanceOf (fcol, java.awt.Color)) { + new jalview.appletgui.UserDefinedColours (this, check.type, fcol); +} else { + new jalview.appletgui.FeatureColourChooser (this, check.type); +check.updateColor (this.fr.getFeatureStyle (check.type)); +}}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +this.fr.setTransparency ((100 - this.transparency.getValue ()) / 100); +this.ap.seqPanel.seqCanvas.repaint (); +}, "java.awt.event.AdjustmentEvent"); +c$.$FeatureSettings$MyCheckbox$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.type = null; +this.stringWidth = 0; +this.hasLink = false; +this.gcol = null; +this.col = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.FeatureSettings, "MyCheckbox", awt2swing.Checkbox); +Clazz.defineMethod (c$, "updateColor", +function (a) { +if (Clazz.instanceOf (a, java.awt.Color)) { +this.col = a; +this.gcol = null; +} else if (Clazz.instanceOf (a, jalview.schemes.GraduatedColor)) { +this.gcol = a; +this.col = null; +} else { +throw new Error (jalview.util.MessageManager.getString ("error.invalid_colour_for_mycheckbox")); +}if (this.col != null) { +this.setBackground (this.col); +} else { +var b = this.type; +if (this.gcol.getThreshType () != -1) { +b += " " + ((this.gcol.getThreshType () == 1) ? "(>)" : "(<)"); +}if (this.gcol.isColourByLabel ()) { +this.setBackground (java.awt.Color.white); +b += " (by Label)"; +} else { +this.setBackground (this.gcol.getMinColor ()); +}this.setLabel (b); +}this.repaint (); +}, "~O"); +Clazz.makeConstructor (c$, +function (a, b, c) { +Clazz.superConstructor (this, jalview.appletgui.FeatureSettings.MyCheckbox, [a, b]); +this.type = a; +var d = this.b$["jalview.appletgui.FeatureSettings"].av.nullFrame.getFontMetrics (this.b$["jalview.appletgui.FeatureSettings"].av.nullFrame.getFont ()); +this.stringWidth = d.stringWidth (a); +this.hasLink = c; +}, "~S,~B,~B"); +Clazz.makeConstructor (c$, +function (a, b, c, d) { +this.construct (a, b, c); +this.updateColor (d); +}, "~S,~B,~B,~O"); +Clazz.defineMethod (c$, "PaintComponent", +function (a) { +var b = this.getSize (); +if (this.gcol != null) { +if (this.gcol.isColourByLabel ()) { +a.setColor (java.awt.Color.white); +a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); +} else { +var c = this.gcol.getMaxColor (); +a.setColor (c); +a.fillRect (Clazz.doubleToInt (b.width / 2), 0, Clazz.doubleToInt (b.width / 2), b.height); +}}if (this.hasLink) { +a.drawImage (this.b$["jalview.appletgui.FeatureSettings"].linkImage, this.stringWidth + 25, Clazz.doubleToInt ((this.getSize ().height - this.b$["jalview.appletgui.FeatureSettings"].linkImage.getHeight (this)) / 2), this); +}}, "java.awt.Graphics"); +c$ = Clazz.p0p (); +}; +c$.$FeatureSettings$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$1", null, java.awt.event.ItemListener); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +var source = evt.getSource (); +this.b$["jalview.appletgui.FeatureSettings"].fr.setGroupVisibility (source.getLabel (), source.getState ()); +this.b$["jalview.appletgui.FeatureSettings"].ap.seqPanel.seqCanvas.repaint (); +if (this.b$["jalview.appletgui.FeatureSettings"].ap.overviewPanel != null) { +this.b$["jalview.appletgui.FeatureSettings"].ap.overviewPanel.updateOverviewImage (); +}this.b$["jalview.appletgui.FeatureSettings"].resetTable (true); +return; +}, "java.awt.event.ItemEvent"); +c$ = Clazz.p0p (); +}; +c$.$FeatureSettings$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$2", java.awt.event.WindowAdapter); +Clazz.overrideMethod (c$, "windowClosing", +function (e) { +if (this.f$.me.av.featureSettings === this.f$.me) { +this.f$.me.av.featureSettings = null; +this.f$.me.ap = null; +this.f$.me.av = null; +}}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +c$.$FeatureSettings$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$3", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.f$.me.ap.alignFrame.avc.sortAlignmentByFeatureScore ( Clazz.newArray (-1, [this.f$.type])); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$FeatureSettings$4$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$4", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.f$.me.ap.alignFrame.avc.sortAlignmentByFeatureDensity ( Clazz.newArray (-1, [this.f$.type])); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$FeatureSettings$5$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FeatureSettings$5", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +if (Clazz.instanceOf (this.f$.typeCol, java.awt.Color)) { + new jalview.appletgui.FeatureColourChooser (this.f$.me, this.f$.type); +this.f$.check.updateColor (this.b$["jalview.appletgui.FeatureSettings"].fr.getFeatureStyle (this.f$.type)); +} else { + new jalview.appletgui.UserDefinedColours (this.f$.me, this.f$.check.type, (this.f$.typeCol)); +}}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/Finder.js b/bin/jalview/appletgui/Finder.js index 22e3c84..d64e048 100644 --- a/bin/jalview/appletgui/Finder.js +++ b/bin/jalview/appletgui/Finder.js @@ -1,184 +1,184 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "awt2swing.Button", "$.Checkbox", "$.Label", "$.TextField", "java.awt.GridLayout"], "jalview.appletgui.Finder", ["awt2swing.Frame", "jalview.analysis.Finder", "jalview.bin.JalviewLite", "jalview.datamodel.SequenceFeature", "jalview.util.MessageManager", "java.awt.Font", "$.Rectangle", "java.awt.event.KeyAdapter", "$.WindowAdapter"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.ap = null; -this.frame = null; -this.searchResults = null; -this.seqIndex = 0; -this.resIndex = -1; -this.jLabel1 = null; -this.textfield = null; -this.findAll = null; -this.findNext = null; -this.actionsPanel = null; -this.gridLayout1 = null; -this.createNewGroup = null; -this.caseSensitive = null; -this.searchDescription = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "Finder", awt2swing.Panel, java.awt.event.ActionListener); -Clazz.prepareFields (c$, function () { -this.jLabel1 = new awt2swing.Label (); -this.textfield = new awt2swing.TextField (); -this.findAll = new awt2swing.Button (); -this.findNext = new awt2swing.Button (); -this.actionsPanel = new awt2swing.Panel (); -this.gridLayout1 = new java.awt.GridLayout (); -this.createNewGroup = new awt2swing.Button (); -this.caseSensitive = new awt2swing.Checkbox (); -this.searchDescription = new awt2swing.Checkbox (); -}); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.Finder, []); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.av = ap.av; -this.ap = ap; -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("action.find"), 340, 120); -this.frame.repaint (); -this.frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.Finder$1") ? 0 : jalview.appletgui.Finder.$Finder$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.Finder$1, this, Clazz.cloneFinals ("ap", ap)))); -this.textfield.requestFocus (); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.textfield) { -this.doSearch (false); -} else if (evt.getSource () === this.findNext) { -this.doSearch (false); -} else if (evt.getSource () === this.findAll) { -this.resIndex = -1; -this.seqIndex = 0; -this.doSearch (true); -} else if (evt.getSource () === this.createNewGroup) { -this.createNewGroup_actionPerformed (); -}}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "createNewGroup_actionPerformed", -function () { -var seqs = new Array (this.searchResults.getSize ()); -var features = new Array (this.searchResults.getSize ()); -for (var i = 0; i < this.searchResults.getSize (); i++) { -seqs[i] = this.searchResults.getResultSequence (i); -features[i] = new jalview.datamodel.SequenceFeature (this.textfield.getText ().trim (), "Search Results", null, this.searchResults.getResultStart (i), this.searchResults.getResultEnd (i), "Search Results"); -} -if (this.ap.seqPanel.seqCanvas.getFeatureRenderer ().amendFeatures (seqs, features, true, this.ap)) { -this.ap.alignFrame.sequenceFeatures.setState (true); -this.av.setShowSequenceFeatures (true); -this.ap.highlightSearchResults (null); -}}); -Clazz.defineMethod (c$, "doSearch", -function (findAll) { -if (this.ap.av.applet.currentAlignFrame != null) { -this.ap = this.ap.av.applet.currentAlignFrame.alignPanel; -this.av = this.ap.av; -}this.createNewGroup.setEnabled (false); -var finder = new jalview.analysis.Finder (this.av.getAlignment (), this.av.getSelectionGroup (), this.seqIndex, this.resIndex); -finder.setCaseSensitive (this.caseSensitive.getState ()); -finder.setIncludeDescription (this.searchDescription.getState ()); -finder.setFindAll (findAll); -var searchString = this.textfield.getText (); -finder.find (searchString); -this.seqIndex = finder.getSeqIndex (); -this.resIndex = finder.getResIndex (); -this.searchResults = finder.getSearchResults (); -var idMatch = finder.getIdMatch (); -var haveResults = false; -if ((idMatch.size () > 0)) { -haveResults = true; -this.ap.idPanel.highlightSearchResults (idMatch); -} else { -this.ap.idPanel.highlightSearchResults (null); -}if (this.searchResults.getSize () > 0) { -haveResults = true; -this.createNewGroup.setEnabled (true); -} else { -this.searchResults = null; -}this.ap.highlightSearchResults (this.searchResults); -if (!haveResults) { -this.ap.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.finished_searching")); -this.resIndex = -1; -this.seqIndex = 0; -} else { -if (findAll) { -var message = (idMatch.size () > 0) ? "" + idMatch.size () + " IDs" : ""; -if (idMatch.size () > 0 && this.searchResults != null && this.searchResults.getSize () > 0) { -message += " and "; -}if (this.searchResults != null) { -message += this.searchResults.getSize () + " subsequence matches."; -}this.ap.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.search_results", Clazz.newArray (-1, [searchString, message]))); -} else { -this.ap.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.found_match_for", Clazz.newArray (-1, [searchString]))); -}}}, "~B"); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.jLabel1.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.jLabel1.setText (jalview.util.MessageManager.getString ("action.find")); -this.jLabel1.setBounds ( new java.awt.Rectangle (3, 30, 34, 15)); -this.setLayout (null); -this.textfield.setFont ( new java.awt.Font ("Verdana", 0, 10)); -this.textfield.setText (""); -this.textfield.setBounds ( new java.awt.Rectangle (40, 17, 133, 21)); -this.textfield.addKeyListener (((Clazz.isClassDefined ("jalview.appletgui.Finder$2") ? 0 : jalview.appletgui.Finder.$Finder$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.Finder$2, this, null))); -this.textfield.addActionListener (this); -this.findAll.setFont ( new java.awt.Font ("Verdana", 0, 10)); -this.findAll.setLabel (jalview.util.MessageManager.getString ("action.find_all")); -this.findAll.addActionListener (this); -this.findNext.setEnabled (false); -this.findNext.setFont ( new java.awt.Font ("Verdana", 0, 10)); -this.findNext.setLabel (jalview.util.MessageManager.getString ("action.find_next")); -this.findNext.addActionListener (this); -this.actionsPanel.setBounds ( new java.awt.Rectangle (195, 5, 141, 64)); -this.actionsPanel.setLayout (this.gridLayout1); -this.gridLayout1.setHgap (0); -this.gridLayout1.setRows (3); -this.gridLayout1.setVgap (2); -this.createNewGroup.setEnabled (false); -this.createNewGroup.setFont ( new java.awt.Font ("Verdana", 0, 10)); -this.createNewGroup.setLabel (jalview.util.MessageManager.getString ("label.new_feature")); -this.createNewGroup.addActionListener (this); -this.caseSensitive.setLabel (jalview.util.MessageManager.getString ("label.match_case")); -this.caseSensitive.setBounds ( new java.awt.Rectangle (30, 39, 126, 23)); -this.searchDescription.setLabel (jalview.util.MessageManager.getString ("label.include_description")); -this.searchDescription.setBounds ( new java.awt.Rectangle (30, 59, 170, 23)); -this.actionsPanel.add (this.findNext, null); -this.actionsPanel.add (this.findAll, null); -this.actionsPanel.add (this.createNewGroup, null); -this.add (this.caseSensitive); -this.add (this.textfield, null); -this.add (this.jLabel1, null); -this.add (this.actionsPanel, null); -this.add (this.searchDescription); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "textfield_keyTyped", -function (e) { -this.findNext.setEnabled (true); -}, "java.awt.event.KeyEvent"); -c$.$Finder$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "Finder$1", java.awt.event.WindowAdapter); -Clazz.overrideMethod (c$, "windowClosing", -function (evt) { -this.f$.ap.highlightSearchResults (null); -}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -c$.$Finder$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "Finder$2", java.awt.event.KeyAdapter); -Clazz.overrideMethod (c$, "keyTyped", -function (e) { -this.b$["jalview.appletgui.Finder"].textfield_keyTyped (e); -}, "java.awt.event.KeyEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "awt2swing.Button", "$.Checkbox", "$.Label", "$.TextField", "java.awt.GridLayout"], "jalview.appletgui.Finder", ["awt2swing.Frame", "jalview.analysis.Finder", "jalview.bin.JalviewLite", "jalview.datamodel.SequenceFeature", "jalview.util.MessageManager", "java.awt.Font", "$.Rectangle", "java.awt.event.KeyAdapter", "$.WindowAdapter"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.ap = null; +this.frame = null; +this.searchResults = null; +this.seqIndex = 0; +this.resIndex = -1; +this.jLabel1 = null; +this.textfield = null; +this.findAll = null; +this.findNext = null; +this.actionsPanel = null; +this.gridLayout1 = null; +this.createNewGroup = null; +this.caseSensitive = null; +this.searchDescription = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "Finder", awt2swing.Panel, java.awt.event.ActionListener); +Clazz.prepareFields (c$, function () { +this.jLabel1 = new awt2swing.Label (); +this.textfield = new awt2swing.TextField (); +this.findAll = new awt2swing.Button (); +this.findNext = new awt2swing.Button (); +this.actionsPanel = new awt2swing.Panel (); +this.gridLayout1 = new java.awt.GridLayout (); +this.createNewGroup = new awt2swing.Button (); +this.caseSensitive = new awt2swing.Checkbox (); +this.searchDescription = new awt2swing.Checkbox (); +}); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.Finder, []); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.av = ap.av; +this.ap = ap; +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("action.find"), 340, 120); +this.frame.repaint (); +this.frame.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.Finder$1") ? 0 : jalview.appletgui.Finder.$Finder$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.Finder$1, this, Clazz.cloneFinals ("ap", ap)))); +this.textfield.requestFocus (); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.textfield) { +this.doSearch (false); +} else if (evt.getSource () === this.findNext) { +this.doSearch (false); +} else if (evt.getSource () === this.findAll) { +this.resIndex = -1; +this.seqIndex = 0; +this.doSearch (true); +} else if (evt.getSource () === this.createNewGroup) { +this.createNewGroup_actionPerformed (); +}}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "createNewGroup_actionPerformed", +function () { +var seqs = new Array (this.searchResults.getSize ()); +var features = new Array (this.searchResults.getSize ()); +for (var i = 0; i < this.searchResults.getSize (); i++) { +seqs[i] = this.searchResults.getResultSequence (i); +features[i] = new jalview.datamodel.SequenceFeature (this.textfield.getText ().trim (), "Search Results", null, this.searchResults.getResultStart (i), this.searchResults.getResultEnd (i), "Search Results"); +} +if (this.ap.seqPanel.seqCanvas.getFeatureRenderer ().amendFeatures (seqs, features, true, this.ap)) { +this.ap.alignFrame.sequenceFeatures.setState (true); +this.av.setShowSequenceFeatures (true); +this.ap.highlightSearchResults (null); +}}); +Clazz.defineMethod (c$, "doSearch", +function (findAll) { +if (this.ap.av.applet.currentAlignFrame != null) { +this.ap = this.ap.av.applet.currentAlignFrame.alignPanel; +this.av = this.ap.av; +}this.createNewGroup.setEnabled (false); +var finder = new jalview.analysis.Finder (this.av.getAlignment (), this.av.getSelectionGroup (), this.seqIndex, this.resIndex); +finder.setCaseSensitive (this.caseSensitive.getState ()); +finder.setIncludeDescription (this.searchDescription.getState ()); +finder.setFindAll (findAll); +var searchString = this.textfield.getText (); +finder.find (searchString); +this.seqIndex = finder.getSeqIndex (); +this.resIndex = finder.getResIndex (); +this.searchResults = finder.getSearchResults (); +var idMatch = finder.getIdMatch (); +var haveResults = false; +if ((idMatch.size () > 0)) { +haveResults = true; +this.ap.idPanel.highlightSearchResults (idMatch); +} else { +this.ap.idPanel.highlightSearchResults (null); +}if (this.searchResults.getSize () > 0) { +haveResults = true; +this.createNewGroup.setEnabled (true); +} else { +this.searchResults = null; +}this.ap.highlightSearchResults (this.searchResults); +if (!haveResults) { +this.ap.alignFrame.setStatus (jalview.util.MessageManager.getString ("label.finished_searching")); +this.resIndex = -1; +this.seqIndex = 0; +} else { +if (findAll) { +var message = (idMatch.size () > 0) ? "" + idMatch.size () + " IDs" : ""; +if (idMatch.size () > 0 && this.searchResults != null && this.searchResults.getSize () > 0) { +message += " and "; +}if (this.searchResults != null) { +message += this.searchResults.getSize () + " subsequence matches."; +}this.ap.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.search_results", Clazz.newArray (-1, [searchString, message]))); +} else { +this.ap.alignFrame.setStatus (jalview.util.MessageManager.formatMessage ("label.found_match_for", Clazz.newArray (-1, [searchString]))); +}}}, "~B"); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.jLabel1.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.jLabel1.setText (jalview.util.MessageManager.getString ("action.find")); +this.jLabel1.setBounds ( new java.awt.Rectangle (3, 30, 34, 15)); +this.setLayout (null); +this.textfield.setFont ( new java.awt.Font ("Verdana", 0, 10)); +this.textfield.setText (""); +this.textfield.setBounds ( new java.awt.Rectangle (40, 17, 133, 21)); +this.textfield.addKeyListener (((Clazz.isClassDefined ("jalview.appletgui.Finder$2") ? 0 : jalview.appletgui.Finder.$Finder$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.Finder$2, this, null))); +this.textfield.addActionListener (this); +this.findAll.setFont ( new java.awt.Font ("Verdana", 0, 10)); +this.findAll.setLabel (jalview.util.MessageManager.getString ("action.find_all")); +this.findAll.addActionListener (this); +this.findNext.setEnabled (false); +this.findNext.setFont ( new java.awt.Font ("Verdana", 0, 10)); +this.findNext.setLabel (jalview.util.MessageManager.getString ("action.find_next")); +this.findNext.addActionListener (this); +this.actionsPanel.setBounds ( new java.awt.Rectangle (195, 5, 141, 64)); +this.actionsPanel.setLayout (this.gridLayout1); +this.gridLayout1.setHgap (0); +this.gridLayout1.setRows (3); +this.gridLayout1.setVgap (2); +this.createNewGroup.setEnabled (false); +this.createNewGroup.setFont ( new java.awt.Font ("Verdana", 0, 10)); +this.createNewGroup.setLabel (jalview.util.MessageManager.getString ("label.new_feature")); +this.createNewGroup.addActionListener (this); +this.caseSensitive.setLabel (jalview.util.MessageManager.getString ("label.match_case")); +this.caseSensitive.setBounds ( new java.awt.Rectangle (30, 39, 126, 23)); +this.searchDescription.setLabel (jalview.util.MessageManager.getString ("label.include_description")); +this.searchDescription.setBounds ( new java.awt.Rectangle (30, 59, 170, 23)); +this.actionsPanel.add (this.findNext, null); +this.actionsPanel.add (this.findAll, null); +this.actionsPanel.add (this.createNewGroup, null); +this.add (this.caseSensitive); +this.add (this.textfield, null); +this.add (this.jLabel1, null); +this.add (this.actionsPanel, null); +this.add (this.searchDescription); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "textfield_keyTyped", +function (e) { +this.findNext.setEnabled (true); +}, "java.awt.event.KeyEvent"); +c$.$Finder$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "Finder$1", java.awt.event.WindowAdapter); +Clazz.overrideMethod (c$, "windowClosing", +function (evt) { +this.f$.ap.highlightSearchResults (null); +}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +c$.$Finder$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "Finder$2", java.awt.event.KeyAdapter); +Clazz.overrideMethod (c$, "keyTyped", +function (e) { +this.b$["jalview.appletgui.Finder"].textfield_keyTyped (e); +}, "java.awt.event.KeyEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/FontChooser.js b/bin/jalview/appletgui/FontChooser.js index a0154ca..c8a21c0 100644 --- a/bin/jalview/appletgui/FontChooser.js +++ b/bin/jalview/appletgui/FontChooser.js @@ -1,259 +1,259 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ItemListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "java.awt.Font"], "jalview.appletgui.FontChooser", ["awt2swing.Frame", "$.Label", "jalview.appletgui.JVDialog", "jalview.bin.JalviewLite", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.FlowLayout", "$.Toolkit", "java.awt.event.ActionListener"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fontSize = null; -this.fontStyle = null; -this.fontName = null; -this.scaleAsCdna = null; -this.ok = null; -this.cancel = null; -this.ap = null; -this.tp = null; -this.oldFont = null; -this.oldCharWidth = 0; -this.oldScaleProtein = false; -this.lastSelected = null; -this.lastSelStyle = 0; -this.lastSelSize = 0; -this.$init = true; -this.frame = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "FontChooser", awt2swing.Panel, java.awt.event.ItemListener); -Clazz.prepareFields (c$, function () { -this.fontSize = new awt2swing.Choice (); -this.fontStyle = new awt2swing.Choice (); -this.fontName = new awt2swing.Choice (); -this.scaleAsCdna = new awt2swing.Checkbox (); -this.ok = new awt2swing.Button (); -this.cancel = new awt2swing.Button (); -}); -Clazz.makeConstructor (c$, -function (tp) { -Clazz.superConstructor (this, jalview.appletgui.FontChooser, []); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.tp = tp; -this.oldFont = tp.getTreeFont (); -this.init (); -}, "jalview.appletgui.TreePanel"); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.FontChooser, []); -this.ap = ap; -this.oldFont = ap.av.getFont (); -this.oldCharWidth = ap.av.getViewStyle ().getCharWidth (); -this.oldScaleProtein = ap.av.getViewStyle ().isScaleProteinAsCdna (); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.init (); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "init", -function () { -var fonts = java.awt.Toolkit.getDefaultToolkit ().getFontList (); -for (var i = 0; i < fonts.length; i++) { -this.fontName.addItem (fonts[i]); -} -for (var i = 1; i < 31; i++) { -this.fontSize.addItem (i + ""); -} -this.fontStyle.addItem ("plain"); -this.fontStyle.addItem ("bold"); -this.fontStyle.addItem ("italic"); -this.fontName.select (this.oldFont.getName ()); -this.fontSize.select (this.oldFont.getSize () + ""); -this.fontStyle.select (new Integer (this.oldFont.getStyle ())); -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("action.change_font"), 440, 115); -this.$init = false; -}); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -var source = evt.getSource (); -if (source === this.fontName) { -this.fontName_actionPerformed (); -} else if (source === this.fontSize) { -this.fontSize_actionPerformed (); -} else if (source === this.fontStyle) { -this.fontStyle_actionPerformed (); -} else if (source === this.scaleAsCdna) { -this.scaleAsCdna_actionPerformed (); -}}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "ok_actionPerformed", -function () { -this.frame.setVisible (false); -if (this.ap != null) { -if (this.ap.getOverviewPanel () != null) { -this.ap.getOverviewPanel ().updateOverviewImage (); -}}}); -Clazz.defineMethod (c$, "cancel_actionPerformed", -function () { -if (this.ap != null) { -this.ap.av.setScaleProteinAsCdna (this.oldScaleProtein); -if (this.ap.av.getCodingComplement () != null) { -this.ap.av.getCodingComplement ().setScaleProteinAsCdna (this.oldScaleProtein); -this.ap.alignFrame.getSplitFrame ().repaint (); -}this.ap.av.setFont (this.oldFont); -var style = this.ap.av.getViewStyle (); -if (style.getCharWidth () != this.oldCharWidth) { -style.setCharWidth (this.oldCharWidth); -this.ap.av.setViewStyle (style); -}this.ap.paintAlignment (true); -} else if (this.tp != null) { -this.tp.setTreeFont (this.oldFont); -this.tp.treeCanvas.repaint (); -}this.fontName.select (this.oldFont.getName ()); -this.fontSize.select (this.oldFont.getSize () + ""); -this.fontStyle.select (new Integer (this.oldFont.getStyle ())); -this.frame.setVisible (false); -}); -Clazz.defineMethod (c$, "changeFont", -function () { -if (this.lastSelected == null) { -this.lastSelected = this.oldFont; -this.lastSelSize = this.oldFont.getSize (); -this.lastSelStyle = this.oldFont.getStyle (); -}var newFont = new java.awt.Font (this.fontName.getSelectedItem ().toString (), this.fontStyle.getSelectedIndex (), Integer.parseInt (this.fontSize.getSelectedItem ().toString ())); -var fm = this.getGraphics ().getFontMetrics (newFont); -var mw = fm.getStringBounds ("M", this.getGraphics ()).getWidth (); -var iw = fm.getStringBounds ("I", this.getGraphics ()).getWidth (); -if (mw < 1 || iw < 1) { -this.fontName.select (this.lastSelected.getName ()); -this.fontStyle.select (new Integer (this.lastSelStyle)); -this.fontSize.select ("" + this.lastSelSize); -var d = new jalview.appletgui.JVDialog (this.frame, jalview.util.MessageManager.getString ("label.invalid_font"), true, 350, 200); -var mp = new awt2swing.Panel (); -d.cancel.setVisible (false); -mp.setLayout ( new java.awt.FlowLayout ()); -mp.add ( new awt2swing.Label ("Font doesn't have letters defined\nso cannot be used\nwith alignment data.")); -d.setMainPanel (mp); -d.setVisible (true); -return; -}if (this.tp != null) { -this.tp.setTreeFont (newFont); -} else if (this.ap != null) { -this.ap.av.setFont (newFont); -this.ap.fontChanged (); -}this.lastSelected = newFont; -}); -Clazz.defineMethod (c$, "fontName_actionPerformed", -function () { -if (this.$init) { -return; -}this.changeFont (); -}); -Clazz.defineMethod (c$, "fontSize_actionPerformed", -function () { -if (this.$init) { -return; -}this.changeFont (); -}); -Clazz.defineMethod (c$, "fontStyle_actionPerformed", -function () { -if (this.$init) { -return; -}this.changeFont (); -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout ( new java.awt.BorderLayout ()); -this.setBackground (java.awt.Color.white); -var fontLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.font")); -fontLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -fontLabel.setAlignment (4); -this.fontSize.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.fontSize.addItemListener (this); -this.fontStyle.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.fontStyle.addItemListener (this); -var sizeLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.size")); -sizeLabel.setAlignment (4); -sizeLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -var styleLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.style")); -styleLabel.setAlignment (4); -styleLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.fontName.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.fontName.addItemListener (this); -this.scaleAsCdna.setLabel (jalview.util.MessageManager.getString ("label.scale_as_cdna")); -this.scaleAsCdna.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.scaleAsCdna.addItemListener (this); -this.scaleAsCdna.setState (this.ap.av.isScaleProteinAsCdna ()); -this.ok.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); -this.ok.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FontChooser$1") ? 0 : jalview.appletgui.FontChooser.$FontChooser$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FontChooser$1, this, null))); -this.cancel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); -this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); -this.cancel.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FontChooser$2") ? 0 : jalview.appletgui.FontChooser.$FontChooser$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FontChooser$2, this, null))); -var fontPanel = new awt2swing.Panel (); -fontPanel.setLayout ( new java.awt.BorderLayout ()); -var stylePanel = new awt2swing.Panel (); -stylePanel.setLayout ( new java.awt.BorderLayout ()); -var sizePanel = new awt2swing.Panel (); -sizePanel.setLayout ( new java.awt.BorderLayout ()); -var scalePanel = new awt2swing.Panel (); -scalePanel.setLayout ( new java.awt.BorderLayout ()); -var okCancelPanel = new awt2swing.Panel (); -var optionsPanel = new awt2swing.Panel (); -fontPanel.setBackground (java.awt.Color.white); -stylePanel.setBackground (java.awt.Color.white); -sizePanel.setBackground (java.awt.Color.white); -okCancelPanel.setBackground (java.awt.Color.white); -optionsPanel.setBackground (java.awt.Color.white); -fontPanel.add (fontLabel, "West"); -fontPanel.add (this.fontName, "Center"); -stylePanel.add (styleLabel, "West"); -stylePanel.add (this.fontStyle, "Center"); -sizePanel.add (sizeLabel, "West"); -sizePanel.add (this.fontSize, "Center"); -scalePanel.add (this.scaleAsCdna, "Center"); -okCancelPanel.add (this.ok, null); -okCancelPanel.add (this.cancel, null); -optionsPanel.add (fontPanel, null); -optionsPanel.add (sizePanel, null); -optionsPanel.add (stylePanel, null); -this.add (optionsPanel, "North"); -if (this.ap.alignFrame.getSplitFrame () != null) { -this.add (scalePanel, "Center"); -}this.add (okCancelPanel, "South"); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "scaleAsCdna_actionPerformed", -function () { -this.ap.av.setScaleProteinAsCdna (this.scaleAsCdna.getState ()); -this.ap.av.getCodingComplement ().setScaleProteinAsCdna (this.scaleAsCdna.getState ()); -this.ap.alignFrame.getSplitFrame ().adjustLayout (); -this.ap.paintAlignment (true); -this.ap.alignFrame.getSplitFrame ().repaint (); -}); -c$.$FontChooser$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FontChooser$1", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.FontChooser"].ok_actionPerformed (); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$FontChooser$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "FontChooser$2", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.FontChooser"].cancel_actionPerformed (); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.VERDANA_11PT = c$.prototype.VERDANA_11PT = new java.awt.Font ("Verdana", 0, 11); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ItemListener", "awt2swing.Button", "$.Checkbox", "$.Choice", "java.awt.Font"], "jalview.appletgui.FontChooser", ["awt2swing.Frame", "$.Label", "jalview.appletgui.JVDialog", "jalview.bin.JalviewLite", "jalview.util.MessageManager", "java.awt.BorderLayout", "$.Color", "$.FlowLayout", "$.Toolkit", "java.awt.event.ActionListener"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fontSize = null; +this.fontStyle = null; +this.fontName = null; +this.scaleAsCdna = null; +this.ok = null; +this.cancel = null; +this.ap = null; +this.tp = null; +this.oldFont = null; +this.oldCharWidth = 0; +this.oldScaleProtein = false; +this.lastSelected = null; +this.lastSelStyle = 0; +this.lastSelSize = 0; +this.$init = true; +this.frame = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "FontChooser", awt2swing.Panel, java.awt.event.ItemListener); +Clazz.prepareFields (c$, function () { +this.fontSize = new awt2swing.Choice (); +this.fontStyle = new awt2swing.Choice (); +this.fontName = new awt2swing.Choice (); +this.scaleAsCdna = new awt2swing.Checkbox (); +this.ok = new awt2swing.Button (); +this.cancel = new awt2swing.Button (); +}); +Clazz.makeConstructor (c$, +function (tp) { +Clazz.superConstructor (this, jalview.appletgui.FontChooser, []); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.tp = tp; +this.oldFont = tp.getTreeFont (); +this.init (); +}, "jalview.appletgui.TreePanel"); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.FontChooser, []); +this.ap = ap; +this.oldFont = ap.av.getFont (); +this.oldCharWidth = ap.av.getViewStyle ().getCharWidth (); +this.oldScaleProtein = ap.av.getViewStyle ().isScaleProteinAsCdna (); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.init (); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "init", +function () { +var fonts = java.awt.Toolkit.getDefaultToolkit ().getFontList (); +for (var i = 0; i < fonts.length; i++) { +this.fontName.addItem (fonts[i]); +} +for (var i = 1; i < 31; i++) { +this.fontSize.addItem (i + ""); +} +this.fontStyle.addItem ("plain"); +this.fontStyle.addItem ("bold"); +this.fontStyle.addItem ("italic"); +this.fontName.select (this.oldFont.getName ()); +this.fontSize.select (this.oldFont.getSize () + ""); +this.fontStyle.select (new Integer (this.oldFont.getStyle ())); +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("action.change_font"), 440, 115); +this.$init = false; +}); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +var source = evt.getSource (); +if (source === this.fontName) { +this.fontName_actionPerformed (); +} else if (source === this.fontSize) { +this.fontSize_actionPerformed (); +} else if (source === this.fontStyle) { +this.fontStyle_actionPerformed (); +} else if (source === this.scaleAsCdna) { +this.scaleAsCdna_actionPerformed (); +}}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "ok_actionPerformed", +function () { +this.frame.setVisible (false); +if (this.ap != null) { +if (this.ap.getOverviewPanel () != null) { +this.ap.getOverviewPanel ().updateOverviewImage (); +}}}); +Clazz.defineMethod (c$, "cancel_actionPerformed", +function () { +if (this.ap != null) { +this.ap.av.setScaleProteinAsCdna (this.oldScaleProtein); +if (this.ap.av.getCodingComplement () != null) { +this.ap.av.getCodingComplement ().setScaleProteinAsCdna (this.oldScaleProtein); +this.ap.alignFrame.getSplitFrame ().repaint (); +}this.ap.av.setFont (this.oldFont); +var style = this.ap.av.getViewStyle (); +if (style.getCharWidth () != this.oldCharWidth) { +style.setCharWidth (this.oldCharWidth); +this.ap.av.setViewStyle (style); +}this.ap.paintAlignment (true); +} else if (this.tp != null) { +this.tp.setTreeFont (this.oldFont); +this.tp.treeCanvas.repaint (); +}this.fontName.select (this.oldFont.getName ()); +this.fontSize.select (this.oldFont.getSize () + ""); +this.fontStyle.select (new Integer (this.oldFont.getStyle ())); +this.frame.setVisible (false); +}); +Clazz.defineMethod (c$, "changeFont", +function () { +if (this.lastSelected == null) { +this.lastSelected = this.oldFont; +this.lastSelSize = this.oldFont.getSize (); +this.lastSelStyle = this.oldFont.getStyle (); +}var newFont = new java.awt.Font (this.fontName.getSelectedItem ().toString (), this.fontStyle.getSelectedIndex (), Integer.parseInt (this.fontSize.getSelectedItem ().toString ())); +var fm = this.getGraphics ().getFontMetrics (newFont); +var mw = fm.getStringBounds ("M", this.getGraphics ()).getWidth (); +var iw = fm.getStringBounds ("I", this.getGraphics ()).getWidth (); +if (mw < 1 || iw < 1) { +this.fontName.select (this.lastSelected.getName ()); +this.fontStyle.select (new Integer (this.lastSelStyle)); +this.fontSize.select ("" + this.lastSelSize); +var d = new jalview.appletgui.JVDialog (this.frame, jalview.util.MessageManager.getString ("label.invalid_font"), true, 350, 200); +var mp = new awt2swing.Panel (); +d.cancel.setVisible (false); +mp.setLayout ( new java.awt.FlowLayout ()); +mp.add ( new awt2swing.Label ("Font doesn't have letters defined\nso cannot be used\nwith alignment data.")); +d.setMainPanel (mp); +d.setVisible (true); +return; +}if (this.tp != null) { +this.tp.setTreeFont (newFont); +} else if (this.ap != null) { +this.ap.av.setFont (newFont); +this.ap.fontChanged (); +}this.lastSelected = newFont; +}); +Clazz.defineMethod (c$, "fontName_actionPerformed", +function () { +if (this.$init) { +return; +}this.changeFont (); +}); +Clazz.defineMethod (c$, "fontSize_actionPerformed", +function () { +if (this.$init) { +return; +}this.changeFont (); +}); +Clazz.defineMethod (c$, "fontStyle_actionPerformed", +function () { +if (this.$init) { +return; +}this.changeFont (); +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout ( new java.awt.BorderLayout ()); +this.setBackground (java.awt.Color.white); +var fontLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.font")); +fontLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +fontLabel.setAlignment (4); +this.fontSize.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.fontSize.addItemListener (this); +this.fontStyle.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.fontStyle.addItemListener (this); +var sizeLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.size")); +sizeLabel.setAlignment (4); +sizeLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +var styleLabel = new awt2swing.Label (jalview.util.MessageManager.getString ("label.style")); +styleLabel.setAlignment (4); +styleLabel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.fontName.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.fontName.addItemListener (this); +this.scaleAsCdna.setLabel (jalview.util.MessageManager.getString ("label.scale_as_cdna")); +this.scaleAsCdna.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.scaleAsCdna.addItemListener (this); +this.scaleAsCdna.setState (this.ap.av.isScaleProteinAsCdna ()); +this.ok.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.ok.setLabel (jalview.util.MessageManager.getString ("action.ok")); +this.ok.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FontChooser$1") ? 0 : jalview.appletgui.FontChooser.$FontChooser$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.FontChooser$1, this, null))); +this.cancel.setFont (jalview.appletgui.FontChooser.VERDANA_11PT); +this.cancel.setLabel (jalview.util.MessageManager.getString ("action.cancel")); +this.cancel.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.FontChooser$2") ? 0 : jalview.appletgui.FontChooser.$FontChooser$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.FontChooser$2, this, null))); +var fontPanel = new awt2swing.Panel (); +fontPanel.setLayout ( new java.awt.BorderLayout ()); +var stylePanel = new awt2swing.Panel (); +stylePanel.setLayout ( new java.awt.BorderLayout ()); +var sizePanel = new awt2swing.Panel (); +sizePanel.setLayout ( new java.awt.BorderLayout ()); +var scalePanel = new awt2swing.Panel (); +scalePanel.setLayout ( new java.awt.BorderLayout ()); +var okCancelPanel = new awt2swing.Panel (); +var optionsPanel = new awt2swing.Panel (); +fontPanel.setBackground (java.awt.Color.white); +stylePanel.setBackground (java.awt.Color.white); +sizePanel.setBackground (java.awt.Color.white); +okCancelPanel.setBackground (java.awt.Color.white); +optionsPanel.setBackground (java.awt.Color.white); +fontPanel.add (fontLabel, "West"); +fontPanel.add (this.fontName, "Center"); +stylePanel.add (styleLabel, "West"); +stylePanel.add (this.fontStyle, "Center"); +sizePanel.add (sizeLabel, "West"); +sizePanel.add (this.fontSize, "Center"); +scalePanel.add (this.scaleAsCdna, "Center"); +okCancelPanel.add (this.ok, null); +okCancelPanel.add (this.cancel, null); +optionsPanel.add (fontPanel, null); +optionsPanel.add (sizePanel, null); +optionsPanel.add (stylePanel, null); +this.add (optionsPanel, "North"); +if (this.ap.alignFrame.getSplitFrame () != null) { +this.add (scalePanel, "Center"); +}this.add (okCancelPanel, "South"); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "scaleAsCdna_actionPerformed", +function () { +this.ap.av.setScaleProteinAsCdna (this.scaleAsCdna.getState ()); +this.ap.av.getCodingComplement ().setScaleProteinAsCdna (this.scaleAsCdna.getState ()); +this.ap.alignFrame.getSplitFrame ().adjustLayout (); +this.ap.paintAlignment (true); +this.ap.alignFrame.getSplitFrame ().repaint (); +}); +c$.$FontChooser$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FontChooser$1", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.FontChooser"].ok_actionPerformed (); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$FontChooser$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "FontChooser$2", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.FontChooser"].cancel_actionPerformed (); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.VERDANA_11PT = c$.prototype.VERDANA_11PT = new java.awt.Font ("Verdana", 0, 11); +}); diff --git a/bin/jalview/appletgui/IdCanvas.js b/bin/jalview/appletgui/IdCanvas.js index 673b00e..7c5a1c2 100644 --- a/bin/jalview/appletgui/IdCanvas.js +++ b/bin/jalview/appletgui/IdCanvas.js @@ -1,191 +1,191 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel"], "jalview.appletgui.IdCanvas", ["jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.PaintRefresher", "java.awt.Color", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.showScores = true; -this.maxIdLength = -1; -this.maxIdStr = null; -this.image = null; -this.gg = null; -this.imgHeight = 0; -this.$fastPaint = false; -this.searchResults = null; -this.avcharHeight = 0; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "IdCanvas", awt2swing.Panel); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.IdCanvas, []); -this.setLayout (null); -this.av = av; -jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ()); -}, "jalview.appletgui.AlignViewport"); -Clazz.defineMethod (c$, "drawIdString", -function (gg, hiddenRows, s, i, starty, ypos) { -var charHeight = this.av.getCharHeight (); -if (this.searchResults != null && this.searchResults.contains (s)) { -gg.setColor (java.awt.Color.black); -gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); -gg.setColor (java.awt.Color.white); -} else if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSequences (null).contains (s)) { -gg.setColor (java.awt.Color.lightGray); -gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); -gg.setColor (java.awt.Color.white); -} else { -gg.setColor (this.av.getSequenceColour (s)); -gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); -gg.setColor (java.awt.Color.black); -}gg.drawString (s.getDisplayId (this.av.getShowJVSuffix ()), 0, ((i - starty) * charHeight) + ypos + charHeight - (Clazz.doubleToInt (charHeight / 5))); -if (hiddenRows) { -this.drawMarker (i, starty, ypos); -}}, "java.awt.Graphics,~B,jalview.datamodel.SequenceI,~N,~N,~N"); -Clazz.defineMethod (c$, "fastPaint", -function (vertical) { -if (this.gg == null) { -this.repaint (); -return; -}this.gg.copyArea (0, 0, this.getSize ().width, this.imgHeight, 0, -vertical * this.av.getCharHeight ()); -var ss = this.av.startSeq; -var es = this.av.endSeq; -var transY = 0; -if (vertical > 0) { -ss = es - vertical; -if (ss < this.av.startSeq) { -ss = this.av.startSeq; -} else { -transY = this.imgHeight - vertical * this.av.getCharHeight (); -}} else if (vertical < 0) { -es = ss - vertical; -if (es > this.av.endSeq) { -es = this.av.endSeq; -}}this.gg.translate (0, transY); -this.drawIds (ss, es); -this.gg.translate (0, -transY); -this.$fastPaint = true; -this.repaint (); -}, "~N"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.getSize ().height < 0 || this.getSize ().width < 0) { -return; -}if (this.$fastPaint) { -this.$fastPaint = false; -g.drawImage (this.image, 0, 0, this); -return; -}this.imgHeight = this.getSize ().height; -this.imgHeight -= this.imgHeight % this.av.getCharHeight (); -if (this.imgHeight < 1) { -return; -}if (this.image == null || this.imgHeight != this.image.getHeight (this)) { -this.image = this.createImage (this.getSize ().width, this.imgHeight); -this.gg = this.image.getGraphics (); -this.gg.setFont (this.av.getFont ()); -}this.gg.setColor (java.awt.Color.white); -var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); -this.gg.setFont (italic); -this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -this.drawIds (this.av.startSeq, this.av.endSeq); -g.drawImage (this.image, 0, 0, this); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawIds", -function (starty, endy) { -var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); -this.avcharHeight = this.av.getCharHeight (); -this.gg.setFont (italic); -var currentColor = java.awt.Color.white; -var currentTextColor = java.awt.Color.black; -var doHiddenCheck = this.av.isDisplayReferenceSeq () || this.av.hasHiddenRows (); -var hiddenRows = this.av.hasHiddenRows () && this.av.getShowHiddenMarkers (); -if (this.av.getWrapAlignment ()) { -var maxwidth = this.av.getAlignment ().getWidth (); -var alheight = this.av.getAlignment ().getHeight (); -if (this.av.hasHiddenColumns ()) { -maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; -}var annotationHeight = 0; -var labels = null; -if (this.av.isShowAnnotation ()) { -var ap = new jalview.appletgui.AnnotationPanel (this.av); -annotationHeight = ap.adjustPanelHeight (); -labels = new jalview.appletgui.AnnotationLabels (this.av); -}var hgap = this.avcharHeight; -if (this.av.getScaleAboveWrapped ()) { -hgap += this.avcharHeight; -}var cHeight = alheight * this.avcharHeight + hgap + annotationHeight; -var rowSize = this.av.getEndRes () - this.av.getStartRes (); -for (var ypos = hgap, row = this.av.startRes; (ypos <= this.getSize ().height) && (row < maxwidth); ypos += cHeight, row += rowSize) { -for (var i = starty; i < alheight; i++) { -var s = this.av.getAlignment ().getSequenceAt (i); -this.gg.setFont (italic); -if (doHiddenCheck) { -this.setHiddenFont (s); -}this.drawIdString (this.gg, hiddenRows, s, i, 0, ypos); -} -if (labels != null) { -this.gg.translate (0, ypos + (alheight * this.avcharHeight)); -labels.drawComponent (this.gg, this.getSize ().width); -this.gg.translate (0, -ypos - (alheight * this.avcharHeight)); -}} -} else { -var seq; -for (var i = starty; i < endy; i++) { -seq = this.av.getAlignment ().getSequenceAt (i); -if (seq == null) { -continue; -}this.gg.setFont (italic); -if (doHiddenCheck) { -this.setHiddenFont (seq); -}if ((this.searchResults != null) && this.searchResults.contains (seq)) { -currentColor = java.awt.Color.black; -currentTextColor = java.awt.Color.white; -} else if ((this.av.getSelectionGroup () != null) && this.av.getSelectionGroup ().getSequences (null).contains (seq)) { -currentColor = java.awt.Color.lightGray; -currentTextColor = java.awt.Color.black; -} else { -currentColor = this.av.getSequenceColour (seq); -currentTextColor = java.awt.Color.black; -}this.gg.setColor (currentColor); -this.gg.fillRect (0, (i - starty) * this.avcharHeight, this.getSize ().width, this.avcharHeight); -this.gg.setColor (currentTextColor); -this.gg.drawString (seq.getDisplayId (this.av.getShowJVSuffix ()), 0, (((i - starty) * this.avcharHeight) + this.avcharHeight) - (Clazz.doubleToInt (this.avcharHeight / 5))); -if (hiddenRows) { -this.drawMarker (i, starty, 0); -}} -}}, "~N,~N"); -Clazz.defineMethod (c$, "setHighlighted", -function (list) { -this.searchResults = list; -this.repaint (); -}, "java.util.List"); -Clazz.defineMethod (c$, "drawMarker", -function (i, starty, yoffset) { -var hseqs = this.av.getAlignment ().getHiddenSequences ().hiddenSequences; -var hSize = hseqs.length; -var hiddenIndex = i; -var lastIndex = i - 1; -var nextIndex = i + 1; -for (var j = 0; j < hSize; j++) { -if (hseqs[j] != null) { -if (j - 1 < hiddenIndex) { -hiddenIndex++; -}if (j - 1 < lastIndex) { -lastIndex++; -}if (j - 1 < nextIndex) { -nextIndex++; -}}} -var below = (hiddenIndex > lastIndex + 1); -var above = (nextIndex > hiddenIndex + 1); -this.gg.setColor (java.awt.Color.blue); -if (below) { -this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty) * this.avcharHeight + yoffset, (i - starty) * this.avcharHeight + yoffset + Clazz.doubleToInt (this.avcharHeight / 4), (i - starty) * this.avcharHeight + yoffset]), 3); -}if (above) { -this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty + 1) * this.avcharHeight + yoffset, (i - starty + 1) * this.avcharHeight + yoffset - Clazz.doubleToInt (this.avcharHeight / 4), (i - starty + 1) * this.avcharHeight + yoffset]), 3); -}}, "~N,~N,~N"); -Clazz.defineMethod (c$, "setHiddenFont", -function (seq) { -var bold = new java.awt.Font (this.av.getFont ().getName (), 1, this.av.getFont ().getSize ()); -if (this.av.isHiddenRepSequence (seq)) { -this.gg.setFont (bold); -return true; -}return false; -}, "jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel"], "jalview.appletgui.IdCanvas", ["jalview.appletgui.AnnotationLabels", "$.AnnotationPanel", "$.PaintRefresher", "java.awt.Color", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.showScores = true; +this.maxIdLength = -1; +this.maxIdStr = null; +this.image = null; +this.gg = null; +this.imgHeight = 0; +this.$fastPaint = false; +this.searchResults = null; +this.avcharHeight = 0; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "IdCanvas", awt2swing.Panel); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.IdCanvas, []); +this.setLayout (null); +this.av = av; +jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ()); +}, "jalview.appletgui.AlignViewport"); +Clazz.defineMethod (c$, "drawIdString", +function (gg, hiddenRows, s, i, starty, ypos) { +var charHeight = this.av.getCharHeight (); +if (this.searchResults != null && this.searchResults.contains (s)) { +gg.setColor (java.awt.Color.black); +gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); +gg.setColor (java.awt.Color.white); +} else if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSequences (null).contains (s)) { +gg.setColor (java.awt.Color.lightGray); +gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); +gg.setColor (java.awt.Color.white); +} else { +gg.setColor (this.av.getSequenceColour (s)); +gg.fillRect (0, ((i - starty) * charHeight) + ypos, this.getSize ().width, charHeight); +gg.setColor (java.awt.Color.black); +}gg.drawString (s.getDisplayId (this.av.getShowJVSuffix ()), 0, ((i - starty) * charHeight) + ypos + charHeight - (Clazz.doubleToInt (charHeight / 5))); +if (hiddenRows) { +this.drawMarker (i, starty, ypos); +}}, "java.awt.Graphics,~B,jalview.datamodel.SequenceI,~N,~N,~N"); +Clazz.defineMethod (c$, "fastPaint", +function (vertical) { +if (this.gg == null) { +this.repaint (); +return; +}this.gg.copyArea (0, 0, this.getSize ().width, this.imgHeight, 0, -vertical * this.av.getCharHeight ()); +var ss = this.av.startSeq; +var es = this.av.endSeq; +var transY = 0; +if (vertical > 0) { +ss = es - vertical; +if (ss < this.av.startSeq) { +ss = this.av.startSeq; +} else { +transY = this.imgHeight - vertical * this.av.getCharHeight (); +}} else if (vertical < 0) { +es = ss - vertical; +if (es > this.av.endSeq) { +es = this.av.endSeq; +}}this.gg.translate (0, transY); +this.drawIds (ss, es); +this.gg.translate (0, -transY); +this.$fastPaint = true; +this.repaint (); +}, "~N"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.getSize ().height < 0 || this.getSize ().width < 0) { +return; +}if (this.$fastPaint) { +this.$fastPaint = false; +g.drawImage (this.image, 0, 0, this); +return; +}this.imgHeight = this.getSize ().height; +this.imgHeight -= this.imgHeight % this.av.getCharHeight (); +if (this.imgHeight < 1) { +return; +}if (this.image == null || this.imgHeight != this.image.getHeight (this)) { +this.image = this.createImage (this.getSize ().width, this.imgHeight); +this.gg = this.image.getGraphics (); +this.gg.setFont (this.av.getFont ()); +}this.gg.setColor (java.awt.Color.white); +var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); +this.gg.setFont (italic); +this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +this.drawIds (this.av.startSeq, this.av.endSeq); +g.drawImage (this.image, 0, 0, this); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawIds", +function (starty, endy) { +var italic = new java.awt.Font (this.av.getFont ().getName (), 2, this.av.getFont ().getSize ()); +this.avcharHeight = this.av.getCharHeight (); +this.gg.setFont (italic); +var currentColor = java.awt.Color.white; +var currentTextColor = java.awt.Color.black; +var doHiddenCheck = this.av.isDisplayReferenceSeq () || this.av.hasHiddenRows (); +var hiddenRows = this.av.hasHiddenRows () && this.av.getShowHiddenMarkers (); +if (this.av.getWrapAlignment ()) { +var maxwidth = this.av.getAlignment ().getWidth (); +var alheight = this.av.getAlignment ().getHeight (); +if (this.av.hasHiddenColumns ()) { +maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; +}var annotationHeight = 0; +var labels = null; +if (this.av.isShowAnnotation ()) { +var ap = new jalview.appletgui.AnnotationPanel (this.av); +annotationHeight = ap.adjustPanelHeight (); +labels = new jalview.appletgui.AnnotationLabels (this.av); +}var hgap = this.avcharHeight; +if (this.av.getScaleAboveWrapped ()) { +hgap += this.avcharHeight; +}var cHeight = alheight * this.avcharHeight + hgap + annotationHeight; +var rowSize = this.av.getEndRes () - this.av.getStartRes (); +for (var ypos = hgap, row = this.av.startRes; (ypos <= this.getSize ().height) && (row < maxwidth); ypos += cHeight, row += rowSize) { +for (var i = starty; i < alheight; i++) { +var s = this.av.getAlignment ().getSequenceAt (i); +this.gg.setFont (italic); +if (doHiddenCheck) { +this.setHiddenFont (s); +}this.drawIdString (this.gg, hiddenRows, s, i, 0, ypos); +} +if (labels != null) { +this.gg.translate (0, ypos + (alheight * this.avcharHeight)); +labels.drawComponent (this.gg, this.getSize ().width); +this.gg.translate (0, -ypos - (alheight * this.avcharHeight)); +}} +} else { +var seq; +for (var i = starty; i < endy; i++) { +seq = this.av.getAlignment ().getSequenceAt (i); +if (seq == null) { +continue; +}this.gg.setFont (italic); +if (doHiddenCheck) { +this.setHiddenFont (seq); +}if ((this.searchResults != null) && this.searchResults.contains (seq)) { +currentColor = java.awt.Color.black; +currentTextColor = java.awt.Color.white; +} else if ((this.av.getSelectionGroup () != null) && this.av.getSelectionGroup ().getSequences (null).contains (seq)) { +currentColor = java.awt.Color.lightGray; +currentTextColor = java.awt.Color.black; +} else { +currentColor = this.av.getSequenceColour (seq); +currentTextColor = java.awt.Color.black; +}this.gg.setColor (currentColor); +this.gg.fillRect (0, (i - starty) * this.avcharHeight, this.getSize ().width, this.avcharHeight); +this.gg.setColor (currentTextColor); +this.gg.drawString (seq.getDisplayId (this.av.getShowJVSuffix ()), 0, (((i - starty) * this.avcharHeight) + this.avcharHeight) - (Clazz.doubleToInt (this.avcharHeight / 5))); +if (hiddenRows) { +this.drawMarker (i, starty, 0); +}} +}}, "~N,~N"); +Clazz.defineMethod (c$, "setHighlighted", +function (list) { +this.searchResults = list; +this.repaint (); +}, "java.util.List"); +Clazz.defineMethod (c$, "drawMarker", +function (i, starty, yoffset) { +var hseqs = this.av.getAlignment ().getHiddenSequences ().hiddenSequences; +var hSize = hseqs.length; +var hiddenIndex = i; +var lastIndex = i - 1; +var nextIndex = i + 1; +for (var j = 0; j < hSize; j++) { +if (hseqs[j] != null) { +if (j - 1 < hiddenIndex) { +hiddenIndex++; +}if (j - 1 < lastIndex) { +lastIndex++; +}if (j - 1 < nextIndex) { +nextIndex++; +}}} +var below = (hiddenIndex > lastIndex + 1); +var above = (nextIndex > hiddenIndex + 1); +this.gg.setColor (java.awt.Color.blue); +if (below) { +this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty) * this.avcharHeight + yoffset, (i - starty) * this.avcharHeight + yoffset + Clazz.doubleToInt (this.avcharHeight / 4), (i - starty) * this.avcharHeight + yoffset]), 3); +}if (above) { +this.gg.fillPolygon ( Clazz.newIntArray (-1, [this.getSize ().width - this.avcharHeight, this.getSize ().width - this.avcharHeight, this.getSize ().width]), Clazz.newIntArray (-1, [(i - starty + 1) * this.avcharHeight + yoffset, (i - starty + 1) * this.avcharHeight + yoffset - Clazz.doubleToInt (this.avcharHeight / 4), (i - starty + 1) * this.avcharHeight + yoffset]), 3); +}}, "~N,~N,~N"); +Clazz.defineMethod (c$, "setHiddenFont", +function (seq) { +var bold = new java.awt.Font (this.av.getFont ().getName (), 1, this.av.getFont ().getSize ()); +if (this.av.isHiddenRepSequence (seq)) { +this.gg.setFont (bold); +return true; +}return false; +}, "jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/appletgui/IdPanel.js b/bin/jalview/appletgui/IdPanel.js index 4f70687..1419a24 100644 --- a/bin/jalview/appletgui/IdPanel.js +++ b/bin/jalview/appletgui/IdPanel.js @@ -1,285 +1,285 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.lang.Thread", "java.util.Vector"], "jalview.appletgui.IdPanel", ["jalview.appletgui.APopupMenu", "$.IdCanvas", "$.PaintRefresher", "$.Tooltip", "jalview.datamodel.SequenceGroup", "jalview.util.UrlLink", "java.awt.BorderLayout", "java.lang.Float", "$.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.idCanvas = null; -this.av = null; -this.alignPanel = null; -this.scrollThread = null; -this.lastid = -1; -this.mouseDragging = false; -this.links = null; -this.tooltip = null; -if (!Clazz.isClassDefined ("jalview.appletgui.IdPanel.ScrollThread")) { -jalview.appletgui.IdPanel.$IdPanel$ScrollThread$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "IdPanel", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); -Clazz.prepareFields (c$, function () { -this.links = new java.util.Vector (); -}); -Clazz.makeConstructor (c$, -function (av, parent) { -Clazz.superConstructor (this, jalview.appletgui.IdPanel, []); -this.setName ("idPanel"); -this.av = av; -this.alignPanel = parent; -this.idCanvas = new jalview.appletgui.IdCanvas (av); -this.setLayout ( new java.awt.BorderLayout ()); -this.add (this.idCanvas, "Center"); -this.idCanvas.addMouseListener (this); -this.idCanvas.addMouseMotionListener (this); -if (av.applet != null) { -av.applet.getLinkParams (this.links); -}{ -var srsPos = this.links.indexOf ("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry"); -if (srsPos > -1) { -this.links.setElementAt ("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$", srsPos); -}}if (this.links.size () < 1) { -this.links = new java.util.Vector (); -this.links.addElement ("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$"); -}}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "mouseMoved", -function (e) { -var seq = this.alignPanel.seqPanel.findSeq (e); -var sequence = this.av.getAlignment ().getSequenceAt (seq); -var tooltiptext = new StringBuffer (); -if (sequence != null) { -if (sequence.getDescription () != null) { -tooltiptext.append (sequence.getDescription ()); -tooltiptext.append ("\n"); -}var sf = sequence.getSequenceFeatures (); -for (var sl = 0; sf != null && sl < sf.length; sl++) { -if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) { -var nl = false; -if (sf[sl].getFeatureGroup () != null) { -tooltiptext.append (sf[sl].getFeatureGroup ()); -nl = true; -};if (sf[sl].getType () != null) { -tooltiptext.append (" "); -tooltiptext.append (sf[sl].getType ()); -nl = true; -};if (sf[sl].getDescription () != null) { -tooltiptext.append (" "); -tooltiptext.append (sf[sl].getDescription ()); -nl = true; -};if (!Float.isNaN (sf[sl].getScore ()) && sf[sl].getScore () != 0) { -tooltiptext.append (" Score = "); -tooltiptext.append (sf[sl].getScore ()); -nl = true; -};if (sf[sl].getStatus () != null && sf[sl].getStatus ().length > 0) { -tooltiptext.append (" ("); -tooltiptext.append (sf[sl].getStatus ()); -tooltiptext.append (")"); -nl = true; -};if (nl) { -tooltiptext.append ("\n"); -}}} -}if (tooltiptext.length () == 0) { -if (this.tooltip != null) { -this.tooltip.setVisible (false); -}this.tooltip = null; -tooltiptext = null; -return; -}if (this.tooltip == null) { -this.tooltip = new jalview.appletgui.Tooltip (sequence.getDisplayId (true) + "\n" + tooltiptext.toString (), this.idCanvas); -} else { -this.tooltip.setTip (sequence.getDisplayId (true) + "\n" + tooltiptext.toString ()); -}tooltiptext = null; -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (e) { -this.mouseDragging = true; -var seq = Math.max (0, this.alignPanel.seqPanel.findSeq (e)); -if (seq < this.lastid) { -this.selectSeqs (this.lastid - 1, seq); -} else if (seq > this.lastid) { -this.selectSeqs (this.lastid + 1, seq); -}this.lastid = seq; -this.alignPanel.paintAlignment (false); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (e) { -if (e.getClickCount () < 2) { -return; -}var seq = this.alignPanel.seqPanel.findSeq (e); -var sq = this.av.getAlignment ().getSequenceAt (seq); -if (sq == null) { -return; -}var id = sq.getName (); -var target = null; -var url = null; -var i = 0; -while (url == null && i < this.links.size ()) { -url = this.links.elementAt (i++).toString (); -var urlLink = null; -try { -urlLink = new jalview.util.UrlLink (url); -target = urlLink.getTarget (); -} catch (foo) { -if (Clazz.exceptionOf (foo, Exception)) { -System.err.println ("Exception for URLLink '" + url + "'"); -foo.printStackTrace (); -url = null; -continue; -} else { -throw foo; -} -} -;if (!urlLink.isValid ()) { -System.err.println (urlLink.getInvalidMessage ()); -url = null; -continue; -}var urls = urlLink.makeUrls (id, true); -if (urls == null || urls[0] == null || urls[0].length < 1) { -url = null; -continue; -}url = urls[1]; -} -try { -this.alignPanel.alignFrame.showURL (url, target); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (e) { -if (this.scrollThread != null) { -this.scrollThread.running = false; -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (e) { -if (this.av.getWrapAlignment ()) { -return; -}if (this.mouseDragging && e.getY () < 0 && this.av.getStartSeq () > 0) { -this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.IdPanel.ScrollThread, this, null, true); -}if (this.mouseDragging && e.getY () >= this.getSize ().height && this.av.getAlignment ().getHeight () > this.av.getEndSeq ()) { -this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.IdPanel.ScrollThread, this, null, false); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (e) { -if (e.getClickCount () > 1) { -return; -}var y = e.getY (); -if (this.av.getWrapAlignment ()) { -y -= 2 * this.av.getCharHeight (); -}var seq = this.alignPanel.seqPanel.findSeq (e); -if ((e.getModifiers () & 4) == 4) { -var sq = this.av.getAlignment ().getSequenceAt (seq); -var nlinks = new java.util.Vector (); -for (var l = 0, lSize = this.links.size (); l < lSize; l++) { -nlinks.addElement (this.links.elementAt (l)); -} -var sf = sq == null ? null : sq.getSequenceFeatures (); -for (var sl = 0; sf != null && sl < sf.length; sl++) { -if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) { -if (sf[sl].links != null && sf[sl].links.size () > 0) { -for (var l = 0, lSize = sf[sl].links.size (); l < lSize; l++) { -nlinks.addElement (sf[sl].links.elementAt (l)); -} -}}} -var popup = new jalview.appletgui.APopupMenu (this.alignPanel, sq, nlinks); -this.add (popup); -popup.show (this, e.getX (), e.getY ()); -return; -}if ((this.av.getSelectionGroup () == null) || ((!e.isControlDown () && !e.isShiftDown ()) && this.av.getSelectionGroup () != null)) { -this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); -this.av.getSelectionGroup ().setStartRes (0); -this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); -}if (e.isShiftDown () && this.lastid != -1) { -this.selectSeqs (this.lastid, seq); -} else { -this.selectSeq (seq); -}this.alignPanel.paintAlignment (false); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "selectSeq", -function (seq) { -this.lastid = seq; -var pickedSeq = this.av.getAlignment ().getSequenceAt (seq); -this.av.getSelectionGroup ().addOrRemove (pickedSeq, true); -}, "~N"); -Clazz.defineMethod (c$, "selectSeqs", -function (start, end) { -this.lastid = start; -if (end >= this.av.getAlignment ().getHeight ()) { -end = this.av.getAlignment ().getHeight () - 1; -}if (end < start) { -var tmp = start; -start = end; -end = tmp; -this.lastid = end; -}if (this.av.getSelectionGroup () == null) { -this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); -}for (var i = start; i <= end; i++) { -this.av.getSelectionGroup ().addSequence (this.av.getAlignment ().getSequenceAt (i), i == end); -} -}, "~N,~N"); -Clazz.overrideMethod (c$, "mouseReleased", -function (e) { -if (this.scrollThread != null) { -this.scrollThread.running = false; -}if (this.av.getSelectionGroup () != null) { -this.av.getSelectionGroup ().recalcConservation (); -}this.mouseDragging = false; -jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); -this.av.sendSelection (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "highlightSearchResults", -function (list) { -this.idCanvas.setHighlighted (list); -if (list == null) { -return; -}var index = this.av.getAlignment ().findIndex (list.get (0)); -if (this.av.getStartSeq () > index || this.av.getEndSeq () < index) { -this.alignPanel.setScrollValues (this.av.getStartRes (), index); -}}, "java.util.List"); -c$.$IdPanel$ScrollThread$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.running = false; -this.up = true; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.IdPanel, "ScrollThread", Thread); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.appletgui.IdPanel.ScrollThread, []); -this.up = a; -this.start (); -}, "~B"); -Clazz.defineMethod (c$, "stopScrolling", -function () { -this.running = false; -}); -Clazz.overrideMethod (c$, "run", -function () { -this.running = true; -while (this.running) { -if (this.b$["jalview.appletgui.IdPanel"].alignPanel.scrollUp (this.up)) { -var a = this.b$["jalview.appletgui.IdPanel"].av.getStartSeq (); -if (!this.up) { -a = this.b$["jalview.appletgui.IdPanel"].av.getEndSeq (); -}if (a < this.b$["jalview.appletgui.IdPanel"].lastid) { -this.b$["jalview.appletgui.IdPanel"].selectSeqs (this.b$["jalview.appletgui.IdPanel"].lastid - 1, a); -} else if (a > this.b$["jalview.appletgui.IdPanel"].lastid && a < this.b$["jalview.appletgui.IdPanel"].av.getAlignment ().getHeight ()) { -this.b$["jalview.appletgui.IdPanel"].selectSeqs (this.b$["jalview.appletgui.IdPanel"].lastid + 1, a); -}this.b$["jalview.appletgui.IdPanel"].lastid = a; -} else { -this.running = false; -}this.b$["jalview.appletgui.IdPanel"].alignPanel.paintAlignment (true); -try { -Thread.sleep (100); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -} -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.lang.Thread", "java.util.Vector"], "jalview.appletgui.IdPanel", ["jalview.appletgui.APopupMenu", "$.IdCanvas", "$.PaintRefresher", "$.Tooltip", "jalview.datamodel.SequenceGroup", "jalview.util.UrlLink", "java.awt.BorderLayout", "java.lang.Float", "$.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.idCanvas = null; +this.av = null; +this.alignPanel = null; +this.scrollThread = null; +this.lastid = -1; +this.mouseDragging = false; +this.links = null; +this.tooltip = null; +if (!Clazz.isClassDefined ("jalview.appletgui.IdPanel.ScrollThread")) { +jalview.appletgui.IdPanel.$IdPanel$ScrollThread$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "IdPanel", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); +Clazz.prepareFields (c$, function () { +this.links = new java.util.Vector (); +}); +Clazz.makeConstructor (c$, +function (av, parent) { +Clazz.superConstructor (this, jalview.appletgui.IdPanel, []); +this.setName ("idPanel"); +this.av = av; +this.alignPanel = parent; +this.idCanvas = new jalview.appletgui.IdCanvas (av); +this.setLayout ( new java.awt.BorderLayout ()); +this.add (this.idCanvas, "Center"); +this.idCanvas.addMouseListener (this); +this.idCanvas.addMouseMotionListener (this); +if (av.applet != null) { +av.applet.getLinkParams (this.links); +}{ +var srsPos = this.links.indexOf ("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry"); +if (srsPos > -1) { +this.links.setElementAt ("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$", srsPos); +}}if (this.links.size () < 1) { +this.links = new java.util.Vector (); +this.links.addElement ("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$"); +}}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "mouseMoved", +function (e) { +var seq = this.alignPanel.seqPanel.findSeq (e); +var sequence = this.av.getAlignment ().getSequenceAt (seq); +var tooltiptext = new StringBuffer (); +if (sequence != null) { +if (sequence.getDescription () != null) { +tooltiptext.append (sequence.getDescription ()); +tooltiptext.append ("\n"); +}var sf = sequence.getSequenceFeatures (); +for (var sl = 0; sf != null && sl < sf.length; sl++) { +if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) { +var nl = false; +if (sf[sl].getFeatureGroup () != null) { +tooltiptext.append (sf[sl].getFeatureGroup ()); +nl = true; +};if (sf[sl].getType () != null) { +tooltiptext.append (" "); +tooltiptext.append (sf[sl].getType ()); +nl = true; +};if (sf[sl].getDescription () != null) { +tooltiptext.append (" "); +tooltiptext.append (sf[sl].getDescription ()); +nl = true; +};if (!Float.isNaN (sf[sl].getScore ()) && sf[sl].getScore () != 0) { +tooltiptext.append (" Score = "); +tooltiptext.append (sf[sl].getScore ()); +nl = true; +};if (sf[sl].getStatus () != null && sf[sl].getStatus ().length > 0) { +tooltiptext.append (" ("); +tooltiptext.append (sf[sl].getStatus ()); +tooltiptext.append (")"); +nl = true; +};if (nl) { +tooltiptext.append ("\n"); +}}} +}if (tooltiptext.length () == 0) { +if (this.tooltip != null) { +this.tooltip.setVisible (false); +}this.tooltip = null; +tooltiptext = null; +return; +}if (this.tooltip == null) { +this.tooltip = new jalview.appletgui.Tooltip (sequence.getDisplayId (true) + "\n" + tooltiptext.toString (), this.idCanvas); +} else { +this.tooltip.setTip (sequence.getDisplayId (true) + "\n" + tooltiptext.toString ()); +}tooltiptext = null; +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (e) { +this.mouseDragging = true; +var seq = Math.max (0, this.alignPanel.seqPanel.findSeq (e)); +if (seq < this.lastid) { +this.selectSeqs (this.lastid - 1, seq); +} else if (seq > this.lastid) { +this.selectSeqs (this.lastid + 1, seq); +}this.lastid = seq; +this.alignPanel.paintAlignment (false); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (e) { +if (e.getClickCount () < 2) { +return; +}var seq = this.alignPanel.seqPanel.findSeq (e); +var sq = this.av.getAlignment ().getSequenceAt (seq); +if (sq == null) { +return; +}var id = sq.getName (); +var target = null; +var url = null; +var i = 0; +while (url == null && i < this.links.size ()) { +url = this.links.elementAt (i++).toString (); +var urlLink = null; +try { +urlLink = new jalview.util.UrlLink (url); +target = urlLink.getTarget (); +} catch (foo) { +if (Clazz.exceptionOf (foo, Exception)) { +System.err.println ("Exception for URLLink '" + url + "'"); +foo.printStackTrace (); +url = null; +continue; +} else { +throw foo; +} +} +;if (!urlLink.isValid ()) { +System.err.println (urlLink.getInvalidMessage ()); +url = null; +continue; +}var urls = urlLink.makeUrls (id, true); +if (urls == null || urls[0] == null || urls[0].length < 1) { +url = null; +continue; +}url = urls[1]; +} +try { +this.alignPanel.alignFrame.showURL (url, target); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (e) { +if (this.scrollThread != null) { +this.scrollThread.running = false; +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (e) { +if (this.av.getWrapAlignment ()) { +return; +}if (this.mouseDragging && e.getY () < 0 && this.av.getStartSeq () > 0) { +this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.IdPanel.ScrollThread, this, null, true); +}if (this.mouseDragging && e.getY () >= this.getSize ().height && this.av.getAlignment ().getHeight () > this.av.getEndSeq ()) { +this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.IdPanel.ScrollThread, this, null, false); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (e) { +if (e.getClickCount () > 1) { +return; +}var y = e.getY (); +if (this.av.getWrapAlignment ()) { +y -= 2 * this.av.getCharHeight (); +}var seq = this.alignPanel.seqPanel.findSeq (e); +if ((e.getModifiers () & 4) == 4) { +var sq = this.av.getAlignment ().getSequenceAt (seq); +var nlinks = new java.util.Vector (); +for (var l = 0, lSize = this.links.size (); l < lSize; l++) { +nlinks.addElement (this.links.elementAt (l)); +} +var sf = sq == null ? null : sq.getSequenceFeatures (); +for (var sl = 0; sf != null && sl < sf.length; sl++) { +if (sf[sl].begin == sf[sl].end && sf[sl].begin == 0) { +if (sf[sl].links != null && sf[sl].links.size () > 0) { +for (var l = 0, lSize = sf[sl].links.size (); l < lSize; l++) { +nlinks.addElement (sf[sl].links.elementAt (l)); +} +}}} +var popup = new jalview.appletgui.APopupMenu (this.alignPanel, sq, nlinks); +this.add (popup); +popup.show (this, e.getX (), e.getY ()); +return; +}if ((this.av.getSelectionGroup () == null) || ((!e.isControlDown () && !e.isShiftDown ()) && this.av.getSelectionGroup () != null)) { +this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); +this.av.getSelectionGroup ().setStartRes (0); +this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); +}if (e.isShiftDown () && this.lastid != -1) { +this.selectSeqs (this.lastid, seq); +} else { +this.selectSeq (seq); +}this.alignPanel.paintAlignment (false); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "selectSeq", +function (seq) { +this.lastid = seq; +var pickedSeq = this.av.getAlignment ().getSequenceAt (seq); +this.av.getSelectionGroup ().addOrRemove (pickedSeq, true); +}, "~N"); +Clazz.defineMethod (c$, "selectSeqs", +function (start, end) { +this.lastid = start; +if (end >= this.av.getAlignment ().getHeight ()) { +end = this.av.getAlignment ().getHeight () - 1; +}if (end < start) { +var tmp = start; +start = end; +end = tmp; +this.lastid = end; +}if (this.av.getSelectionGroup () == null) { +this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); +}for (var i = start; i <= end; i++) { +this.av.getSelectionGroup ().addSequence (this.av.getAlignment ().getSequenceAt (i), i == end); +} +}, "~N,~N"); +Clazz.overrideMethod (c$, "mouseReleased", +function (e) { +if (this.scrollThread != null) { +this.scrollThread.running = false; +}if (this.av.getSelectionGroup () != null) { +this.av.getSelectionGroup ().recalcConservation (); +}this.mouseDragging = false; +jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); +this.av.sendSelection (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "highlightSearchResults", +function (list) { +this.idCanvas.setHighlighted (list); +if (list == null) { +return; +}var index = this.av.getAlignment ().findIndex (list.get (0)); +if (this.av.getStartSeq () > index || this.av.getEndSeq () < index) { +this.alignPanel.setScrollValues (this.av.getStartRes (), index); +}}, "java.util.List"); +c$.$IdPanel$ScrollThread$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.running = false; +this.up = true; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.IdPanel, "ScrollThread", Thread); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.appletgui.IdPanel.ScrollThread, []); +this.up = a; +this.start (); +}, "~B"); +Clazz.defineMethod (c$, "stopScrolling", +function () { +this.running = false; +}); +Clazz.overrideMethod (c$, "run", +function () { +this.running = true; +while (this.running) { +if (this.b$["jalview.appletgui.IdPanel"].alignPanel.scrollUp (this.up)) { +var a = this.b$["jalview.appletgui.IdPanel"].av.getStartSeq (); +if (!this.up) { +a = this.b$["jalview.appletgui.IdPanel"].av.getEndSeq (); +}if (a < this.b$["jalview.appletgui.IdPanel"].lastid) { +this.b$["jalview.appletgui.IdPanel"].selectSeqs (this.b$["jalview.appletgui.IdPanel"].lastid - 1, a); +} else if (a > this.b$["jalview.appletgui.IdPanel"].lastid && a < this.b$["jalview.appletgui.IdPanel"].av.getAlignment ().getHeight ()) { +this.b$["jalview.appletgui.IdPanel"].selectSeqs (this.b$["jalview.appletgui.IdPanel"].lastid + 1, a); +}this.b$["jalview.appletgui.IdPanel"].lastid = a; +} else { +this.running = false; +}this.b$["jalview.appletgui.IdPanel"].alignPanel.paintAlignment (true); +try { +Thread.sleep (100); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +} +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/IdwidthAdjuster.js b/bin/jalview/appletgui/IdwidthAdjuster.js index e7b92f7..80a0c59 100644 --- a/bin/jalview/appletgui/IdwidthAdjuster.js +++ b/bin/jalview/appletgui/IdwidthAdjuster.js @@ -1,66 +1,66 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.IdwidthAdjuster", ["java.awt.Color", "$.Toolkit"], function () { -c$ = Clazz.decorateAsClass (function () { -this.active = false; -this.oldX = 0; -this.image = null; -this.ap = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "IdwidthAdjuster", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.IdwidthAdjuster, []); -this.setName ("IdwidthAdjuster"); -this.setLayout (null); -this.ap = ap; -var url = this.getClass ().getResource ("/images/idwidth.gif"); -if (url != null) { -this.image = java.awt.Toolkit.getDefaultToolkit ().getImage (url); -}this.addMouseListener (this); -this.addMouseMotionListener (this); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -this.oldX = evt.getX (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.active = false; -this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -this.active = true; -this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -this.active = false; -this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -this.active = true; -var d = this.ap.idPanel.idCanvas.getSize (); -var dif = evt.getX () - this.oldX; -var newWidth = d.width + dif; -if (newWidth > 20 || dif > 0) { -this.ap.setIdWidth (newWidth, d.height); -this.setSize (newWidth, this.getSize ().height); -this.oldX = evt.getX (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "PaintComponent", -function (g) { -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -if (this.active) { -if (this.image != null) { -g.drawImage (this.image, this.getSize ().width - 20, 2, this); -}}}, "java.awt.Graphics"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.IdwidthAdjuster", ["java.awt.Color", "$.Toolkit"], function () { +c$ = Clazz.decorateAsClass (function () { +this.active = false; +this.oldX = 0; +this.image = null; +this.ap = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "IdwidthAdjuster", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.IdwidthAdjuster, []); +this.setName ("IdwidthAdjuster"); +this.setLayout (null); +this.ap = ap; +var url = this.getClass ().getResource ("/images/idwidth.gif"); +if (url != null) { +this.image = java.awt.Toolkit.getDefaultToolkit ().getImage (url); +}this.addMouseListener (this); +this.addMouseMotionListener (this); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +this.oldX = evt.getX (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.active = false; +this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +this.active = true; +this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +this.active = false; +this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +this.active = true; +var d = this.ap.idPanel.idCanvas.getSize (); +var dif = evt.getX () - this.oldX; +var newWidth = d.width + dif; +if (newWidth > 20 || dif > 0) { +this.ap.setIdWidth (newWidth, d.height); +this.setSize (newWidth, this.getSize ().height); +this.oldX = evt.getX (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "PaintComponent", +function (g) { +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +if (this.active) { +if (this.image != null) { +g.drawImage (this.image, this.getSize ().width - 20, 2, this); +}}}, "java.awt.Graphics"); +}); diff --git a/bin/jalview/appletgui/JVDialog.js b/bin/jalview/appletgui/JVDialog.js index ed9ee14..6f85ed1 100644 --- a/bin/jalview/appletgui/JVDialog.js +++ b/bin/jalview/appletgui/JVDialog.js @@ -1,40 +1,40 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["java.awt.Dialog", "java.awt.event.ActionListener", "awt2swing.Button"], "jalview.appletgui.JVDialog", ["awt2swing.Panel", "java.awt.FlowLayout"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ap = null; -this.buttonPanel = null; -this.ok = null; -this.cancel = null; -this.accept = false; -this.owner = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "JVDialog", java.awt.Dialog, java.awt.event.ActionListener); -Clazz.prepareFields (c$, function () { -this.ok = new awt2swing.Button ("Accept"); -this.cancel = new awt2swing.Button ("Cancel"); -}); -Clazz.makeConstructor (c$, -function (owner, title, modal, width, height) { -Clazz.superConstructor (this, jalview.appletgui.JVDialog, [owner, title, modal]); -this.owner = owner; -height += owner.getInsets ().top + this.getInsets ().bottom; -this.setBounds (owner.getBounds ().x + Clazz.doubleToInt ((owner.getSize ().width - width) / 2), owner.getBounds ().y + Clazz.doubleToInt ((owner.getSize ().height - height) / 2), width, height); -}, "awt2swing.Frame,~S,~B,~N,~N"); -Clazz.defineMethod (c$, "setMainPanel", -function (panel) { -this.add (panel, "North"); -this.buttonPanel = new awt2swing.Panel ( new java.awt.FlowLayout ()); -this.buttonPanel.add (this.ok); -this.buttonPanel.add (this.cancel); -this.ok.addActionListener (this); -this.cancel.addActionListener (this); -this.add (this.buttonPanel, "South"); -this.pack (); -}, "awt2swing.Panel"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.ok) { -this.accept = true; -}this.setVisible (false); -}, "java.awt.event.ActionEvent"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["java.awt.Dialog", "java.awt.event.ActionListener", "awt2swing.Button"], "jalview.appletgui.JVDialog", ["awt2swing.Panel", "java.awt.FlowLayout"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ap = null; +this.buttonPanel = null; +this.ok = null; +this.cancel = null; +this.accept = false; +this.owner = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "JVDialog", java.awt.Dialog, java.awt.event.ActionListener); +Clazz.prepareFields (c$, function () { +this.ok = new awt2swing.Button ("Accept"); +this.cancel = new awt2swing.Button ("Cancel"); +}); +Clazz.makeConstructor (c$, +function (owner, title, modal, width, height) { +Clazz.superConstructor (this, jalview.appletgui.JVDialog, [owner, title, modal]); +this.owner = owner; +height += owner.getInsets ().top + this.getInsets ().bottom; +this.setBounds (owner.getBounds ().x + Clazz.doubleToInt ((owner.getSize ().width - width) / 2), owner.getBounds ().y + Clazz.doubleToInt ((owner.getSize ().height - height) / 2), width, height); +}, "awt2swing.Frame,~S,~B,~N,~N"); +Clazz.defineMethod (c$, "setMainPanel", +function (panel) { +this.add (panel, "North"); +this.buttonPanel = new awt2swing.Panel ( new java.awt.FlowLayout ()); +this.buttonPanel.add (this.ok); +this.buttonPanel.add (this.cancel); +this.ok.addActionListener (this); +this.cancel.addActionListener (this); +this.add (this.buttonPanel, "South"); +this.pack (); +}, "awt2swing.Panel"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.ok) { +this.accept = true; +}this.setVisible (false); +}, "java.awt.event.ActionEvent"); +}); diff --git a/bin/jalview/appletgui/OverviewPanel.js b/bin/jalview/appletgui/OverviewPanel.js index 41baadd..cadd6b7 100644 --- a/bin/jalview/appletgui/OverviewPanel.js +++ b/bin/jalview/appletgui/OverviewPanel.js @@ -1,262 +1,262 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.OverviewPanel", ["awt2swing.Frame", "jalview.appletgui.FeatureRenderer", "$.SequenceRenderer", "java.awt.Color", "$.Dimension", "java.awt.event.ComponentAdapter", "java.lang.Thread"], function () { -c$ = Clazz.decorateAsClass (function () { -this.miniMe = null; -this.offscreen = null; -this.av = null; -this.ap = null; -this.scalew = 1; -this.scaleh = 1; -this.$width = 0; -this.sequencesHeight = 0; -this.graphHeight = 20; -this.boxX = -1; -this.boxY = -1; -this.boxWidth = -1; -this.boxHeight = -1; -this.resizing = false; -this.sr = null; -this.fr = null; -this.nullFrame = null; -this.resizeAgain = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "OverviewPanel", awt2swing.Panel, [Runnable, java.awt.event.MouseMotionListener, java.awt.event.MouseListener]); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.OverviewPanel, []); -this.av = ap.av; -this.ap = ap; -this.setLayout (null); -this.nullFrame = new awt2swing.Frame (); -this.nullFrame.addNotify (); -this.sr = new jalview.appletgui.SequenceRenderer (this.av); -this.sr.graphics = this.nullFrame.getGraphics (); -this.sr.renderGaps = false; -this.sr.forOverview = true; -this.fr = new jalview.appletgui.FeatureRenderer (this.av); -var initialScale = this.av.getAlignment ().getWidth () / this.av.getAlignment ().getHeight (); -if (this.av.getSequenceConsensusHash () == null) { -this.graphHeight = 0; -}if (this.av.getAlignment ().getWidth () > this.av.getAlignment ().getHeight ()) { -this.$width = 400; -this.sequencesHeight = Clazz.floatToInt (400 / initialScale); -if (this.sequencesHeight < 40) { -this.sequencesHeight = 40; -}} else { -this.$width = Clazz.floatToInt (400 * initialScale); -this.sequencesHeight = 300; -if (this.$width < 120) { -this.$width = 120; -}}this.setSize ( new java.awt.Dimension (this.$width, this.sequencesHeight + this.graphHeight)); -this.addComponentListener (((Clazz.isClassDefined ("jalview.appletgui.OverviewPanel$1") ? 0 : jalview.appletgui.OverviewPanel.$OverviewPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.OverviewPanel$1, this, null))); -this.addMouseMotionListener (this); -this.addMouseListener (this); -this.updateOverviewImage (); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -this.boxX = evt.getX (); -this.boxY = evt.getY (); -this.checkValid (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.boxX = evt.getX (); -this.boxY = evt.getY (); -this.checkValid (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -this.boxX = evt.getX (); -this.boxY = evt.getY (); -this.checkValid (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "checkValid", -function () { -if (this.boxY < 0) { -this.boxY = 0; -}if (this.boxY > (this.sequencesHeight - this.boxHeight)) { -this.boxY = this.sequencesHeight - this.boxHeight + 1; -}if (this.boxX < 0) { -this.boxX = 0; -}if (this.boxX > (this.$width - this.boxWidth)) { -if (this.av.hasHiddenColumns ()) { -this.boxWidth = Clazz.floatToInt ((this.av.endRes - this.av.startRes + 1) * this.av.getCharWidth () * this.scalew); -}this.boxX = this.$width - this.boxWidth; -}var col = Clazz.floatToInt (this.boxX / this.scalew / this.av.getCharWidth ()); -var row = Clazz.floatToInt (this.boxY / this.scaleh / this.av.getCharHeight ()); -if (this.av.hasHiddenColumns ()) { -if (!this.av.getColumnSelection ().isVisible (col)) { -return; -}col = this.av.getColumnSelection ().findColumnPosition (col); -}if (this.av.hasHiddenRows ()) { -row = this.av.getAlignment ().getHiddenSequences ().findIndexWithoutHiddenSeqs (row); -}this.ap.setScrollValues (col, row); -this.ap.paintAlignment (false); -}); -Clazz.defineMethod (c$, "updateOverviewImage", -function () { -if (this.resizing) { -this.resizeAgain = true; -return; -}if (this.av.isShowSequenceFeatures ()) { -this.fr.transferSettings (this.ap.seqPanel.seqCanvas.fr); -}this.resizing = true; -if ((this.getSize ().width > 0) && (this.getSize ().height > 0)) { -this.$width = this.getSize ().width; -this.sequencesHeight = this.getSize ().height - this.graphHeight; -}this.setSize ( new java.awt.Dimension (this.$width, this.sequencesHeight + this.graphHeight)); -var thread = new Thread (this); -thread.start (); -this.repaint (); -}); -Clazz.overrideMethod (c$, "run", -function () { -this.miniMe = null; -var alwidth = this.av.getAlignment ().getWidth (); -var alheight = this.av.getAlignment ().getHeight (); -if (this.av.isShowSequenceFeatures ()) { -this.fr.transferSettings (this.ap.seqPanel.seqCanvas.getFeatureRenderer ()); -}if (this.getSize ().width > 0 && this.getSize ().height > 0) { -this.$width = this.getSize ().width; -this.sequencesHeight = this.getSize ().height - this.graphHeight; -}this.setSize ( new java.awt.Dimension (this.$width, this.sequencesHeight + this.graphHeight)); -var fullsizeWidth = alwidth * this.av.getCharWidth (); -var fullsizeHeight = alheight * this.av.getCharHeight (); -this.scalew = this.$width / fullsizeWidth; -this.scaleh = this.sequencesHeight / fullsizeHeight; -this.miniMe = this.nullFrame.createImage (this.$width, this.sequencesHeight + this.graphHeight); -this.offscreen = this.nullFrame.createImage (this.$width, this.sequencesHeight + this.graphHeight); -var mg = this.miniMe.getGraphics (); -var sampleCol = alwidth / this.$width; -var sampleRow = alheight / this.sequencesHeight; -var lastcol = 0; -var lastrow = 0; -var xstart = 0; -var ystart = 0; -var color = java.awt.Color.yellow; -var row; -var col; -var sameRow = 0; -var sameCol = 0; -var seq; -var hasHiddenRows = this.av.hasHiddenRows (); -var hasHiddenCols = this.av.hasHiddenColumns (); -var hiddenRow = false; -var alignment = this.av.getAlignment (); -for (row = 0; row <= this.sequencesHeight; row++) { -if (Clazz.floatToInt (row * sampleRow) == lastrow) { -sameRow++; -continue; -}hiddenRow = false; -if (hasHiddenRows) { -seq = alignment.getHiddenSequences ().getHiddenSequence (lastrow); -if (seq == null) { -var index = alignment.getHiddenSequences ().findIndexWithoutHiddenSeqs (lastrow); -seq = alignment.getSequenceAt (index); -} else { -hiddenRow = true; -}} else { -seq = alignment.getSequenceAt (lastrow); -}for (col = 0; col < this.$width; col++) { -if (Clazz.floatToInt (col * sampleCol) == lastcol && Clazz.floatToInt (row * sampleRow) == lastrow) { -sameCol++; -continue; -}lastcol = Clazz.floatToInt (col * sampleCol); -if (seq.getLength () > lastcol) { -color = this.sr.getResidueBoxColour (seq, lastcol); -if (this.av.isShowSequenceFeatures ()) { -color = this.fr.findFeatureColour (color, seq, lastcol); -}} else { -color = java.awt.Color.white; -}if (hiddenRow || (hasHiddenCols && !this.av.getColumnSelection ().isVisible (lastcol))) { -color = color.darker ().darker (); -}mg.setColor (color); -if (sameCol == 1 && sameRow == 1) { -mg.drawLine (xstart, ystart, xstart, ystart); -} else { -mg.fillRect (xstart, ystart, sameCol, sameRow); -}xstart = col; -sameCol = 1; -} -lastrow = Clazz.floatToInt (row * sampleRow); -ystart = row; -sameRow = 1; -} -if (this.av.getAlignmentConservationAnnotation () != null) { -for (col = 0; col < this.$width; col++) { -lastcol = Clazz.floatToInt (col * sampleCol); -{ -mg.translate (col, this.sequencesHeight); -this.ap.annotationPanel.renderer.drawGraph (mg, this.av.getAlignmentConservationAnnotation (), this.av.getAlignmentConservationAnnotation ().annotations, Clazz.floatToInt (sampleCol) + 1, this.graphHeight, Clazz.floatToInt (col * sampleCol), Clazz.floatToInt (col * sampleCol) + 1); -mg.translate (-col, -this.sequencesHeight); -}} -}System.gc (); -this.resizing = false; -this.setBoxPosition (); -if (this.resizeAgain) { -this.resizeAgain = false; -this.updateOverviewImage (); -}}); -Clazz.defineMethod (c$, "setBoxPosition", -function () { -var fullsizeWidth = this.av.getAlignment ().getWidth () * this.av.getCharWidth (); -var fullsizeHeight = (this.av.getAlignment ().getHeight () + this.av.getAlignment ().getHiddenSequences ().getSize ()) * this.av.getCharHeight (); -var startRes = this.av.getStartRes (); -var endRes = this.av.getEndRes (); -if (this.av.hasHiddenColumns ()) { -startRes = this.av.getColumnSelection ().adjustForHiddenColumns (startRes); -endRes = this.av.getColumnSelection ().adjustForHiddenColumns (endRes); -}var startSeq = this.av.startSeq; -var endSeq = this.av.endSeq; -if (this.av.hasHiddenRows ()) { -startSeq = this.av.getAlignment ().getHiddenSequences ().adjustForHiddenSeqs (startSeq); -endSeq = this.av.getAlignment ().getHiddenSequences ().adjustForHiddenSeqs (endSeq); -}this.scalew = this.$width / fullsizeWidth; -this.scaleh = this.sequencesHeight / fullsizeHeight; -this.boxX = Clazz.floatToInt (startRes * this.av.getCharWidth () * this.scalew); -this.boxY = Clazz.floatToInt (startSeq * this.av.getCharHeight () * this.scaleh); -if (this.av.hasHiddenColumns ()) { -this.boxWidth = Clazz.floatToInt ((endRes - startRes + 1) * this.av.getCharWidth () * this.scalew); -} else { -this.boxWidth = Clazz.floatToInt ((endRes - startRes + 1) * this.av.getCharWidth () * this.scalew); -}this.boxHeight = Clazz.floatToInt ((endSeq - startSeq) * this.av.getCharHeight () * this.scaleh); -this.repaint (); -}); -Clazz.overrideMethod (c$, "update", -function (g) { -this.paint (g); -}, "java.awt.Graphics"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -var og = this.offscreen.getGraphics (); -if (this.miniMe != null) { -og.drawImage (this.miniMe, 0, 0, this); -og.setColor (java.awt.Color.red); -og.drawRect (this.boxX, this.boxY, this.boxWidth, this.boxHeight); -og.drawRect (this.boxX + 1, this.boxY + 1, this.boxWidth - 2, this.boxHeight - 2); -g.drawImage (this.offscreen, 0, 0, this); -}}, "java.awt.Graphics"); -c$.$OverviewPanel$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "OverviewPanel$1", java.awt.event.ComponentAdapter); -Clazz.overrideMethod (c$, "componentResized", -function (evt) { -if (this.b$["jalview.appletgui.OverviewPanel"].getSize ().width != this.b$["jalview.appletgui.OverviewPanel"].$width || this.b$["jalview.appletgui.OverviewPanel"].getSize ().height != this.b$["jalview.appletgui.OverviewPanel"].sequencesHeight + this.b$["jalview.appletgui.OverviewPanel"].graphHeight) { -this.b$["jalview.appletgui.OverviewPanel"].updateOverviewImage (); -}}, "java.awt.event.ComponentEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.OverviewPanel", ["awt2swing.Frame", "jalview.appletgui.FeatureRenderer", "$.SequenceRenderer", "java.awt.Color", "$.Dimension", "java.awt.event.ComponentAdapter", "java.lang.Thread"], function () { +c$ = Clazz.decorateAsClass (function () { +this.miniMe = null; +this.offscreen = null; +this.av = null; +this.ap = null; +this.scalew = 1; +this.scaleh = 1; +this.$width = 0; +this.sequencesHeight = 0; +this.graphHeight = 20; +this.boxX = -1; +this.boxY = -1; +this.boxWidth = -1; +this.boxHeight = -1; +this.resizing = false; +this.sr = null; +this.fr = null; +this.nullFrame = null; +this.resizeAgain = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "OverviewPanel", awt2swing.Panel, [Runnable, java.awt.event.MouseMotionListener, java.awt.event.MouseListener]); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.OverviewPanel, []); +this.av = ap.av; +this.ap = ap; +this.setLayout (null); +this.nullFrame = new awt2swing.Frame (); +this.nullFrame.addNotify (); +this.sr = new jalview.appletgui.SequenceRenderer (this.av); +this.sr.graphics = this.nullFrame.getGraphics (); +this.sr.renderGaps = false; +this.sr.forOverview = true; +this.fr = new jalview.appletgui.FeatureRenderer (this.av); +var initialScale = this.av.getAlignment ().getWidth () / this.av.getAlignment ().getHeight (); +if (this.av.getSequenceConsensusHash () == null) { +this.graphHeight = 0; +}if (this.av.getAlignment ().getWidth () > this.av.getAlignment ().getHeight ()) { +this.$width = 400; +this.sequencesHeight = Clazz.floatToInt (400 / initialScale); +if (this.sequencesHeight < 40) { +this.sequencesHeight = 40; +}} else { +this.$width = Clazz.floatToInt (400 * initialScale); +this.sequencesHeight = 300; +if (this.$width < 120) { +this.$width = 120; +}}this.setSize ( new java.awt.Dimension (this.$width, this.sequencesHeight + this.graphHeight)); +this.addComponentListener (((Clazz.isClassDefined ("jalview.appletgui.OverviewPanel$1") ? 0 : jalview.appletgui.OverviewPanel.$OverviewPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.OverviewPanel$1, this, null))); +this.addMouseMotionListener (this); +this.addMouseListener (this); +this.updateOverviewImage (); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +this.boxX = evt.getX (); +this.boxY = evt.getY (); +this.checkValid (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.boxX = evt.getX (); +this.boxY = evt.getY (); +this.checkValid (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +this.boxX = evt.getX (); +this.boxY = evt.getY (); +this.checkValid (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "checkValid", +function () { +if (this.boxY < 0) { +this.boxY = 0; +}if (this.boxY > (this.sequencesHeight - this.boxHeight)) { +this.boxY = this.sequencesHeight - this.boxHeight + 1; +}if (this.boxX < 0) { +this.boxX = 0; +}if (this.boxX > (this.$width - this.boxWidth)) { +if (this.av.hasHiddenColumns ()) { +this.boxWidth = Clazz.floatToInt ((this.av.endRes - this.av.startRes + 1) * this.av.getCharWidth () * this.scalew); +}this.boxX = this.$width - this.boxWidth; +}var col = Clazz.floatToInt (this.boxX / this.scalew / this.av.getCharWidth ()); +var row = Clazz.floatToInt (this.boxY / this.scaleh / this.av.getCharHeight ()); +if (this.av.hasHiddenColumns ()) { +if (!this.av.getColumnSelection ().isVisible (col)) { +return; +}col = this.av.getColumnSelection ().findColumnPosition (col); +}if (this.av.hasHiddenRows ()) { +row = this.av.getAlignment ().getHiddenSequences ().findIndexWithoutHiddenSeqs (row); +}this.ap.setScrollValues (col, row); +this.ap.paintAlignment (false); +}); +Clazz.defineMethod (c$, "updateOverviewImage", +function () { +if (this.resizing) { +this.resizeAgain = true; +return; +}if (this.av.isShowSequenceFeatures ()) { +this.fr.transferSettings (this.ap.seqPanel.seqCanvas.fr); +}this.resizing = true; +if ((this.getSize ().width > 0) && (this.getSize ().height > 0)) { +this.$width = this.getSize ().width; +this.sequencesHeight = this.getSize ().height - this.graphHeight; +}this.setSize ( new java.awt.Dimension (this.$width, this.sequencesHeight + this.graphHeight)); +var thread = new Thread (this); +thread.start (); +this.repaint (); +}); +Clazz.overrideMethod (c$, "run", +function () { +this.miniMe = null; +var alwidth = this.av.getAlignment ().getWidth (); +var alheight = this.av.getAlignment ().getHeight (); +if (this.av.isShowSequenceFeatures ()) { +this.fr.transferSettings (this.ap.seqPanel.seqCanvas.getFeatureRenderer ()); +}if (this.getSize ().width > 0 && this.getSize ().height > 0) { +this.$width = this.getSize ().width; +this.sequencesHeight = this.getSize ().height - this.graphHeight; +}this.setSize ( new java.awt.Dimension (this.$width, this.sequencesHeight + this.graphHeight)); +var fullsizeWidth = alwidth * this.av.getCharWidth (); +var fullsizeHeight = alheight * this.av.getCharHeight (); +this.scalew = this.$width / fullsizeWidth; +this.scaleh = this.sequencesHeight / fullsizeHeight; +this.miniMe = this.nullFrame.createImage (this.$width, this.sequencesHeight + this.graphHeight); +this.offscreen = this.nullFrame.createImage (this.$width, this.sequencesHeight + this.graphHeight); +var mg = this.miniMe.getGraphics (); +var sampleCol = alwidth / this.$width; +var sampleRow = alheight / this.sequencesHeight; +var lastcol = 0; +var lastrow = 0; +var xstart = 0; +var ystart = 0; +var color = java.awt.Color.yellow; +var row; +var col; +var sameRow = 0; +var sameCol = 0; +var seq; +var hasHiddenRows = this.av.hasHiddenRows (); +var hasHiddenCols = this.av.hasHiddenColumns (); +var hiddenRow = false; +var alignment = this.av.getAlignment (); +for (row = 0; row <= this.sequencesHeight; row++) { +if (Clazz.floatToInt (row * sampleRow) == lastrow) { +sameRow++; +continue; +}hiddenRow = false; +if (hasHiddenRows) { +seq = alignment.getHiddenSequences ().getHiddenSequence (lastrow); +if (seq == null) { +var index = alignment.getHiddenSequences ().findIndexWithoutHiddenSeqs (lastrow); +seq = alignment.getSequenceAt (index); +} else { +hiddenRow = true; +}} else { +seq = alignment.getSequenceAt (lastrow); +}for (col = 0; col < this.$width; col++) { +if (Clazz.floatToInt (col * sampleCol) == lastcol && Clazz.floatToInt (row * sampleRow) == lastrow) { +sameCol++; +continue; +}lastcol = Clazz.floatToInt (col * sampleCol); +if (seq.getLength () > lastcol) { +color = this.sr.getResidueBoxColour (seq, lastcol); +if (this.av.isShowSequenceFeatures ()) { +color = this.fr.findFeatureColour (color, seq, lastcol); +}} else { +color = java.awt.Color.white; +}if (hiddenRow || (hasHiddenCols && !this.av.getColumnSelection ().isVisible (lastcol))) { +color = color.darker ().darker (); +}mg.setColor (color); +if (sameCol == 1 && sameRow == 1) { +mg.drawLine (xstart, ystart, xstart, ystart); +} else { +mg.fillRect (xstart, ystart, sameCol, sameRow); +}xstart = col; +sameCol = 1; +} +lastrow = Clazz.floatToInt (row * sampleRow); +ystart = row; +sameRow = 1; +} +if (this.av.getAlignmentConservationAnnotation () != null) { +for (col = 0; col < this.$width; col++) { +lastcol = Clazz.floatToInt (col * sampleCol); +{ +mg.translate (col, this.sequencesHeight); +this.ap.annotationPanel.renderer.drawGraph (mg, this.av.getAlignmentConservationAnnotation (), this.av.getAlignmentConservationAnnotation ().annotations, Clazz.floatToInt (sampleCol) + 1, this.graphHeight, Clazz.floatToInt (col * sampleCol), Clazz.floatToInt (col * sampleCol) + 1); +mg.translate (-col, -this.sequencesHeight); +}} +}System.gc (); +this.resizing = false; +this.setBoxPosition (); +if (this.resizeAgain) { +this.resizeAgain = false; +this.updateOverviewImage (); +}}); +Clazz.defineMethod (c$, "setBoxPosition", +function () { +var fullsizeWidth = this.av.getAlignment ().getWidth () * this.av.getCharWidth (); +var fullsizeHeight = (this.av.getAlignment ().getHeight () + this.av.getAlignment ().getHiddenSequences ().getSize ()) * this.av.getCharHeight (); +var startRes = this.av.getStartRes (); +var endRes = this.av.getEndRes (); +if (this.av.hasHiddenColumns ()) { +startRes = this.av.getColumnSelection ().adjustForHiddenColumns (startRes); +endRes = this.av.getColumnSelection ().adjustForHiddenColumns (endRes); +}var startSeq = this.av.startSeq; +var endSeq = this.av.endSeq; +if (this.av.hasHiddenRows ()) { +startSeq = this.av.getAlignment ().getHiddenSequences ().adjustForHiddenSeqs (startSeq); +endSeq = this.av.getAlignment ().getHiddenSequences ().adjustForHiddenSeqs (endSeq); +}this.scalew = this.$width / fullsizeWidth; +this.scaleh = this.sequencesHeight / fullsizeHeight; +this.boxX = Clazz.floatToInt (startRes * this.av.getCharWidth () * this.scalew); +this.boxY = Clazz.floatToInt (startSeq * this.av.getCharHeight () * this.scaleh); +if (this.av.hasHiddenColumns ()) { +this.boxWidth = Clazz.floatToInt ((endRes - startRes + 1) * this.av.getCharWidth () * this.scalew); +} else { +this.boxWidth = Clazz.floatToInt ((endRes - startRes + 1) * this.av.getCharWidth () * this.scalew); +}this.boxHeight = Clazz.floatToInt ((endSeq - startSeq) * this.av.getCharHeight () * this.scaleh); +this.repaint (); +}); +Clazz.overrideMethod (c$, "update", +function (g) { +this.paint (g); +}, "java.awt.Graphics"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +var og = this.offscreen.getGraphics (); +if (this.miniMe != null) { +og.drawImage (this.miniMe, 0, 0, this); +og.setColor (java.awt.Color.red); +og.drawRect (this.boxX, this.boxY, this.boxWidth, this.boxHeight); +og.drawRect (this.boxX + 1, this.boxY + 1, this.boxWidth - 2, this.boxHeight - 2); +g.drawImage (this.offscreen, 0, 0, this); +}}, "java.awt.Graphics"); +c$.$OverviewPanel$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "OverviewPanel$1", java.awt.event.ComponentAdapter); +Clazz.overrideMethod (c$, "componentResized", +function (evt) { +if (this.b$["jalview.appletgui.OverviewPanel"].getSize ().width != this.b$["jalview.appletgui.OverviewPanel"].$width || this.b$["jalview.appletgui.OverviewPanel"].getSize ().height != this.b$["jalview.appletgui.OverviewPanel"].sequencesHeight + this.b$["jalview.appletgui.OverviewPanel"].graphHeight) { +this.b$["jalview.appletgui.OverviewPanel"].updateOverviewImage (); +}}, "java.awt.event.ComponentEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/PCAPanel.js b/bin/jalview/appletgui/PCAPanel.js index 77168bf..7813b4d 100644 --- a/bin/jalview/appletgui/PCAPanel.js +++ b/bin/jalview/appletgui/PCAPanel.js @@ -1,253 +1,253 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.appletgui.EmbmenuFrame", "java.awt.event.ActionListener", "$.ItemListener", "awt2swing.Button", "$.CheckboxMenuItem", "$.Choice", "$.Label", "$.Menu", "$.MenuBar", "$.MenuItem", "$.Panel", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.PCAPanel", ["awt2swing.Frame", "jalview.appletgui.AlignFrame", "$.CutAndPasteTransfer", "$.RotatableCanvas", "jalview.bin.JalviewLite", "jalview.datamodel.Alignment", "jalview.util.MessageManager", "jalview.viewmodel.PCAModel", "java.awt.Color", "$.Font", "java.lang.Thread"], function () { -c$ = Clazz.decorateAsClass (function () { -this.rc = null; -this.av = null; -this.pcaModel = null; -this.top = 0; -this.jPanel2 = null; -this.jLabel1 = null; -this.jLabel2 = null; -this.jLabel3 = null; -this.xCombobox = null; -this.yCombobox = null; -this.zCombobox = null; -this.resetButton = null; -this.flowLayout1 = null; -this.borderLayout1 = null; -this.menuBar1 = null; -this.menu1 = null; -this.menu2 = null; -this.calcSettings = null; -this.labels = null; -this.protSetting = null; -this.nuclSetting = null; -this.values = null; -this.inputData = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "PCAPanel", jalview.appletgui.EmbmenuFrame, [Runnable, java.awt.event.ActionListener, java.awt.event.ItemListener]); -Clazz.prepareFields (c$, function () { -this.jPanel2 = new awt2swing.Panel (); -this.jLabel1 = new awt2swing.Label (); -this.jLabel2 = new awt2swing.Label (); -this.jLabel3 = new awt2swing.Label (); -this.xCombobox = new awt2swing.Choice (); -this.yCombobox = new awt2swing.Choice (); -this.zCombobox = new awt2swing.Choice (); -this.resetButton = new awt2swing.Button (); -this.flowLayout1 = new java.awt.FlowLayout (); -this.borderLayout1 = new java.awt.BorderLayout (); -this.menuBar1 = new awt2swing.MenuBar (); -this.menu1 = new awt2swing.Menu (); -this.menu2 = new awt2swing.Menu (); -this.calcSettings = new awt2swing.Menu (); -this.labels = new awt2swing.CheckboxMenuItem (); -this.protSetting = new awt2swing.CheckboxMenuItem (); -this.nuclSetting = new awt2swing.CheckboxMenuItem (); -this.values = new awt2swing.MenuItem (); -this.inputData = new awt2swing.MenuItem (); -}); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.PCAPanel, []); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -for (var i = 1; i < 8; i++) { -this.xCombobox.addItem ("dim " + i); -this.yCombobox.addItem ("dim " + i); -this.zCombobox.addItem ("dim " + i); -} -this.av = av; -var selected = av.getSelectionGroup () != null && av.getSelectionGroup ().getSize () > 0; -var seqstrings = av.getAlignmentView (selected); -var nucleotide = av.getAlignment ().isNucleotide (); -var seqs; -if (!selected) { -seqs = av.getAlignment ().getSequencesArray (); -} else { -seqs = av.getSelectionGroup ().getSequencesInOrder (av.getAlignment ()); -}var sq = seqstrings.getSequences (); -var length = sq[0].getWidth (); -for (var i = 0; i < seqs.length; i++) { -if (sq[i].getWidth () != length) { -System.out.println ("Sequences must be equal length for PCA analysis"); -return; -}} -this.pcaModel = new jalview.viewmodel.PCAModel (seqstrings, seqs, nucleotide); -this.rc = new jalview.appletgui.RotatableCanvas (av); -this.embedMenuIfNeeded (this.rc); -this.add (this.rc, "Center"); -jalview.bin.JalviewLite.addFrame (this, jalview.util.MessageManager.getString ("label.principal_component_analysis"), 475, 400); -var worker = new Thread (this); -worker.start (); -}, "jalview.appletgui.AlignViewport"); -Clazz.overrideMethod (c$, "run", -function () { -this.calcSettings.setEnabled (false); -this.rc.setEnabled (false); -try { -this.nuclSetting.setState (this.pcaModel.isNucleotide ()); -this.protSetting.setState (!this.pcaModel.isNucleotide ()); -this.pcaModel.run (); -this.xCombobox.select (new Integer (0)); -this.yCombobox.select (new Integer (1)); -this.zCombobox.select (new Integer (2)); -this.pcaModel.updateRc (this.rc); -this.top = this.pcaModel.getTop (); -} catch (x) { -if (Clazz.exceptionOf (x, OutOfMemoryError)) { -System.err.println ("Out of memory when calculating PCA."); -return; -} else { -throw x; -} -} -this.calcSettings.setEnabled (true); -this.rc.setEnabled (true); -this.rc.repaint (); -this.repaint (); -}); -Clazz.defineMethod (c$, "doDimensionChange", -function () { -if (this.top == 0) { -return; -}var dim1 = this.top - this.xCombobox.getSelectedIndex (); -var dim2 = this.top - this.yCombobox.getSelectedIndex (); -var dim3 = this.top - this.zCombobox.getSelectedIndex (); -this.pcaModel.updateRcView (dim1, dim2, dim3); -this.rc.img = null; -this.rc.rotmat.setIdentity (); -this.rc.initAxes (); -this.rc.paint (this.rc.getGraphics ()); -}); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.inputData) { -this.showOriginalData (); -}if (evt.getSource () === this.resetButton) { -this.xCombobox.select (new Integer (0)); -this.yCombobox.select (new Integer (1)); -this.zCombobox.select (new Integer (2)); -this.doDimensionChange (); -}if (evt.getSource () === this.values) { -this.values_actionPerformed (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -if (evt.getSource () === this.xCombobox) { -this.xCombobox_actionPerformed (); -} else if (evt.getSource () === this.yCombobox) { -this.yCombobox_actionPerformed (); -} else if (evt.getSource () === this.zCombobox) { -this.zCombobox_actionPerformed (); -} else if (evt.getSource () === this.labels) { -this.labels_itemStateChanged (evt); -} else if (evt.getSource () === this.nuclSetting) { -if (!this.pcaModel.isNucleotide ()) { -this.pcaModel.setNucleotide (true); - new Thread (this).start (); -}} else if (evt.getSource () === this.protSetting) { -if (this.pcaModel.isNucleotide ()) { -this.pcaModel.setNucleotide (false); - new Thread (this).start (); -}}}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "xCombobox_actionPerformed", -function () { -this.doDimensionChange (); -}); -Clazz.defineMethod (c$, "yCombobox_actionPerformed", -function () { -this.doDimensionChange (); -}); -Clazz.defineMethod (c$, "zCombobox_actionPerformed", -function () { -this.doDimensionChange (); -}); -Clazz.defineMethod (c$, "values_actionPerformed", -function () { -var cap = new jalview.appletgui.CutAndPasteTransfer (false, null); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.pca_details"), 500, 500); -cap.setText (this.pcaModel.getDetails ()); -}); -Clazz.defineMethod (c$, "showOriginalData", -function () { -var gc = '-'; -try { -gc = this.av.getGapCharacter (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -;var alAndColsel = this.pcaModel.getSeqtrings ().getAlignmentAndColumnSelection (gc); -if (alAndColsel != null && alAndColsel[0] != null) { -var al = new jalview.datamodel.Alignment (alAndColsel[0]); -var af = new jalview.appletgui.AlignFrame (al, this.av.applet, "Original Data for PCA", false); -af.viewport.setHiddenColumns (alAndColsel[1]); -}}); -Clazz.defineMethod (c$, "labels_itemStateChanged", -function (itemEvent) { -this.rc.showLabels (this.labels.getState ()); -}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout (this.borderLayout1); -this.jPanel2.setLayout (this.flowLayout1); -this.jLabel1.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.jLabel1.setText ("x="); -this.jLabel2.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.jLabel2.setText ("y="); -this.jLabel3.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.jLabel3.setText ("z="); -this.jPanel2.setBackground (java.awt.Color.white); -this.zCombobox.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.zCombobox.addItemListener (this); -this.yCombobox.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.yCombobox.addItemListener (this); -this.xCombobox.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.xCombobox.addItemListener (this); -this.resetButton.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.resetButton.setLabel (jalview.util.MessageManager.getString ("action.reset")); -this.resetButton.addActionListener (this); -this.setMenuBar (this.menuBar1); -this.menu1.setLabel (jalview.util.MessageManager.getString ("action.file")); -this.menu2.setLabel (jalview.util.MessageManager.getString ("action.view")); -this.calcSettings.setLabel (jalview.util.MessageManager.getString ("action.change_params")); -this.labels.setLabel (jalview.util.MessageManager.getString ("label.labels")); -this.labels.addItemListener (this); -this.values.setLabel (jalview.util.MessageManager.getString ("label.output_values")); -this.values.addActionListener (this); -this.inputData.setLabel (jalview.util.MessageManager.getString ("label.input_data")); -this.nuclSetting.setLabel (jalview.util.MessageManager.getString ("label.nucleotide_matrix")); -this.nuclSetting.addItemListener (this); -this.protSetting.setLabel (jalview.util.MessageManager.getString ("label.protein_matrix")); -this.protSetting.addItemListener (this); -this.add (this.jPanel2, "South"); -this.jPanel2.add (this.jLabel1, null); -this.jPanel2.add (this.xCombobox, null); -this.jPanel2.add (this.jLabel2, null); -this.jPanel2.add (this.yCombobox, null); -this.jPanel2.add (this.jLabel3, null); -this.jPanel2.add (this.zCombobox, null); -this.jPanel2.add (this.resetButton, null); -this.menuBar1.add (this.menu1); -this.menuBar1.add (this.menu2); -this.menuBar1.add (this.calcSettings); -this.menu2.add (this.labels); -this.menu1.add (this.values); -this.menu1.add (this.inputData); -this.calcSettings.add (this.nuclSetting); -this.calcSettings.add (this.protSetting); -this.inputData.addActionListener (this); -}, $fz.isPrivate = true, $fz)); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.appletgui.EmbmenuFrame", "java.awt.event.ActionListener", "$.ItemListener", "awt2swing.Button", "$.CheckboxMenuItem", "$.Choice", "$.Label", "$.Menu", "$.MenuBar", "$.MenuItem", "$.Panel", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.PCAPanel", ["awt2swing.Frame", "jalview.appletgui.AlignFrame", "$.CutAndPasteTransfer", "$.RotatableCanvas", "jalview.bin.JalviewLite", "jalview.datamodel.Alignment", "jalview.util.MessageManager", "jalview.viewmodel.PCAModel", "java.awt.Color", "$.Font", "java.lang.Thread"], function () { +c$ = Clazz.decorateAsClass (function () { +this.rc = null; +this.av = null; +this.pcaModel = null; +this.top = 0; +this.jPanel2 = null; +this.jLabel1 = null; +this.jLabel2 = null; +this.jLabel3 = null; +this.xCombobox = null; +this.yCombobox = null; +this.zCombobox = null; +this.resetButton = null; +this.flowLayout1 = null; +this.borderLayout1 = null; +this.menuBar1 = null; +this.menu1 = null; +this.menu2 = null; +this.calcSettings = null; +this.labels = null; +this.protSetting = null; +this.nuclSetting = null; +this.values = null; +this.inputData = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "PCAPanel", jalview.appletgui.EmbmenuFrame, [Runnable, java.awt.event.ActionListener, java.awt.event.ItemListener]); +Clazz.prepareFields (c$, function () { +this.jPanel2 = new awt2swing.Panel (); +this.jLabel1 = new awt2swing.Label (); +this.jLabel2 = new awt2swing.Label (); +this.jLabel3 = new awt2swing.Label (); +this.xCombobox = new awt2swing.Choice (); +this.yCombobox = new awt2swing.Choice (); +this.zCombobox = new awt2swing.Choice (); +this.resetButton = new awt2swing.Button (); +this.flowLayout1 = new java.awt.FlowLayout (); +this.borderLayout1 = new java.awt.BorderLayout (); +this.menuBar1 = new awt2swing.MenuBar (); +this.menu1 = new awt2swing.Menu (); +this.menu2 = new awt2swing.Menu (); +this.calcSettings = new awt2swing.Menu (); +this.labels = new awt2swing.CheckboxMenuItem (); +this.protSetting = new awt2swing.CheckboxMenuItem (); +this.nuclSetting = new awt2swing.CheckboxMenuItem (); +this.values = new awt2swing.MenuItem (); +this.inputData = new awt2swing.MenuItem (); +}); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.PCAPanel, []); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +for (var i = 1; i < 8; i++) { +this.xCombobox.addItem ("dim " + i); +this.yCombobox.addItem ("dim " + i); +this.zCombobox.addItem ("dim " + i); +} +this.av = av; +var selected = av.getSelectionGroup () != null && av.getSelectionGroup ().getSize () > 0; +var seqstrings = av.getAlignmentView (selected); +var nucleotide = av.getAlignment ().isNucleotide (); +var seqs; +if (!selected) { +seqs = av.getAlignment ().getSequencesArray (); +} else { +seqs = av.getSelectionGroup ().getSequencesInOrder (av.getAlignment ()); +}var sq = seqstrings.getSequences (); +var length = sq[0].getWidth (); +for (var i = 0; i < seqs.length; i++) { +if (sq[i].getWidth () != length) { +System.out.println ("Sequences must be equal length for PCA analysis"); +return; +}} +this.pcaModel = new jalview.viewmodel.PCAModel (seqstrings, seqs, nucleotide); +this.rc = new jalview.appletgui.RotatableCanvas (av); +this.embedMenuIfNeeded (this.rc); +this.add (this.rc, "Center"); +jalview.bin.JalviewLite.addFrame (this, jalview.util.MessageManager.getString ("label.principal_component_analysis"), 475, 400); +var worker = new Thread (this); +worker.start (); +}, "jalview.appletgui.AlignViewport"); +Clazz.overrideMethod (c$, "run", +function () { +this.calcSettings.setEnabled (false); +this.rc.setEnabled (false); +try { +this.nuclSetting.setState (this.pcaModel.isNucleotide ()); +this.protSetting.setState (!this.pcaModel.isNucleotide ()); +this.pcaModel.run (); +this.xCombobox.select (new Integer (0)); +this.yCombobox.select (new Integer (1)); +this.zCombobox.select (new Integer (2)); +this.pcaModel.updateRc (this.rc); +this.top = this.pcaModel.getTop (); +} catch (x) { +if (Clazz.exceptionOf (x, OutOfMemoryError)) { +System.err.println ("Out of memory when calculating PCA."); +return; +} else { +throw x; +} +} +this.calcSettings.setEnabled (true); +this.rc.setEnabled (true); +this.rc.repaint (); +this.repaint (); +}); +Clazz.defineMethod (c$, "doDimensionChange", +function () { +if (this.top == 0) { +return; +}var dim1 = this.top - this.xCombobox.getSelectedIndex (); +var dim2 = this.top - this.yCombobox.getSelectedIndex (); +var dim3 = this.top - this.zCombobox.getSelectedIndex (); +this.pcaModel.updateRcView (dim1, dim2, dim3); +this.rc.img = null; +this.rc.rotmat.setIdentity (); +this.rc.initAxes (); +this.rc.paint (this.rc.getGraphics ()); +}); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.inputData) { +this.showOriginalData (); +}if (evt.getSource () === this.resetButton) { +this.xCombobox.select (new Integer (0)); +this.yCombobox.select (new Integer (1)); +this.zCombobox.select (new Integer (2)); +this.doDimensionChange (); +}if (evt.getSource () === this.values) { +this.values_actionPerformed (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +if (evt.getSource () === this.xCombobox) { +this.xCombobox_actionPerformed (); +} else if (evt.getSource () === this.yCombobox) { +this.yCombobox_actionPerformed (); +} else if (evt.getSource () === this.zCombobox) { +this.zCombobox_actionPerformed (); +} else if (evt.getSource () === this.labels) { +this.labels_itemStateChanged (evt); +} else if (evt.getSource () === this.nuclSetting) { +if (!this.pcaModel.isNucleotide ()) { +this.pcaModel.setNucleotide (true); + new Thread (this).start (); +}} else if (evt.getSource () === this.protSetting) { +if (this.pcaModel.isNucleotide ()) { +this.pcaModel.setNucleotide (false); + new Thread (this).start (); +}}}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "xCombobox_actionPerformed", +function () { +this.doDimensionChange (); +}); +Clazz.defineMethod (c$, "yCombobox_actionPerformed", +function () { +this.doDimensionChange (); +}); +Clazz.defineMethod (c$, "zCombobox_actionPerformed", +function () { +this.doDimensionChange (); +}); +Clazz.defineMethod (c$, "values_actionPerformed", +function () { +var cap = new jalview.appletgui.CutAndPasteTransfer (false, null); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, jalview.util.MessageManager.getString ("label.pca_details"), 500, 500); +cap.setText (this.pcaModel.getDetails ()); +}); +Clazz.defineMethod (c$, "showOriginalData", +function () { +var gc = '-'; +try { +gc = this.av.getGapCharacter (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +;var alAndColsel = this.pcaModel.getSeqtrings ().getAlignmentAndColumnSelection (gc); +if (alAndColsel != null && alAndColsel[0] != null) { +var al = new jalview.datamodel.Alignment (alAndColsel[0]); +var af = new jalview.appletgui.AlignFrame (al, this.av.applet, "Original Data for PCA", false); +af.viewport.setHiddenColumns (alAndColsel[1]); +}}); +Clazz.defineMethod (c$, "labels_itemStateChanged", +function (itemEvent) { +this.rc.showLabels (this.labels.getState ()); +}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout (this.borderLayout1); +this.jPanel2.setLayout (this.flowLayout1); +this.jLabel1.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.jLabel1.setText ("x="); +this.jLabel2.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.jLabel2.setText ("y="); +this.jLabel3.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.jLabel3.setText ("z="); +this.jPanel2.setBackground (java.awt.Color.white); +this.zCombobox.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.zCombobox.addItemListener (this); +this.yCombobox.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.yCombobox.addItemListener (this); +this.xCombobox.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.xCombobox.addItemListener (this); +this.resetButton.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.resetButton.setLabel (jalview.util.MessageManager.getString ("action.reset")); +this.resetButton.addActionListener (this); +this.setMenuBar (this.menuBar1); +this.menu1.setLabel (jalview.util.MessageManager.getString ("action.file")); +this.menu2.setLabel (jalview.util.MessageManager.getString ("action.view")); +this.calcSettings.setLabel (jalview.util.MessageManager.getString ("action.change_params")); +this.labels.setLabel (jalview.util.MessageManager.getString ("label.labels")); +this.labels.addItemListener (this); +this.values.setLabel (jalview.util.MessageManager.getString ("label.output_values")); +this.values.addActionListener (this); +this.inputData.setLabel (jalview.util.MessageManager.getString ("label.input_data")); +this.nuclSetting.setLabel (jalview.util.MessageManager.getString ("label.nucleotide_matrix")); +this.nuclSetting.addItemListener (this); +this.protSetting.setLabel (jalview.util.MessageManager.getString ("label.protein_matrix")); +this.protSetting.addItemListener (this); +this.add (this.jPanel2, "South"); +this.jPanel2.add (this.jLabel1, null); +this.jPanel2.add (this.xCombobox, null); +this.jPanel2.add (this.jLabel2, null); +this.jPanel2.add (this.yCombobox, null); +this.jPanel2.add (this.jLabel3, null); +this.jPanel2.add (this.zCombobox, null); +this.jPanel2.add (this.resetButton, null); +this.menuBar1.add (this.menu1); +this.menuBar1.add (this.menu2); +this.menuBar1.add (this.calcSettings); +this.menu2.add (this.labels); +this.menu1.add (this.values); +this.menu1.add (this.inputData); +this.calcSettings.add (this.nuclSetting); +this.calcSettings.add (this.protSetting); +this.inputData.addActionListener (this); +}, $fz.isPrivate = true, $fz)); +}); diff --git a/bin/jalview/appletgui/PaintRefresher.js b/bin/jalview/appletgui/PaintRefresher.js index 7bd9686..09c8d0a 100644 --- a/bin/jalview/appletgui/PaintRefresher.js +++ b/bin/jalview/appletgui/PaintRefresher.js @@ -1,126 +1,126 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (null, "jalview.appletgui.PaintRefresher", ["jalview.appletgui.AlignmentPanel", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.declareType (jalview.appletgui, "PaintRefresher"); -c$.Register = Clazz.defineMethod (c$, "Register", -function (comp, seqSetId) { -if (jalview.appletgui.PaintRefresher.components == null) { -jalview.appletgui.PaintRefresher.components = new java.util.Hashtable (); -}if (jalview.appletgui.PaintRefresher.components.containsKey (seqSetId)) { -var comps = jalview.appletgui.PaintRefresher.components.get (seqSetId); -if (!comps.contains (comp)) { -comps.addElement (comp); -}} else { -var vcoms = new java.util.Vector (); -vcoms.addElement (comp); -jalview.appletgui.PaintRefresher.components.put (seqSetId, vcoms); -}}, "java.awt.Component,~S"); -c$.RemoveComponent = Clazz.defineMethod (c$, "RemoveComponent", -function (comp) { -if (jalview.appletgui.PaintRefresher.components == null) { -return; -}var en = jalview.appletgui.PaintRefresher.components.keys (); -while (en.hasMoreElements ()) { -var id = en.nextElement ().toString (); -var comps = jalview.appletgui.PaintRefresher.components.get (id); -comps.removeElement (comp); -if (comps.size () == 0) { -jalview.appletgui.PaintRefresher.components.remove (id); -}} -}, "java.awt.Component"); -c$.Refresh = Clazz.defineMethod (c$, "Refresh", -function (source, id) { -jalview.appletgui.PaintRefresher.Refresh (source, id, false, false); -}, "java.awt.Component,~S"); -c$.Refresh = Clazz.defineMethod (c$, "Refresh", -function (source, id, alignmentChanged, validateSequences) { -if (jalview.appletgui.PaintRefresher.components == null) { -return; -}var comp; -var comps = jalview.appletgui.PaintRefresher.components.get (id); -if (comps == null) { -return; -}var e = comps.elements (); -while (e.hasMoreElements ()) { -comp = e.nextElement (); -if (comp === source) { -continue; -}if (!comp.isValid ()) { -comps.removeElement (comp); -} else if (validateSequences && Clazz.instanceOf (comp, jalview.appletgui.AlignmentPanel) && Clazz.instanceOf (source, jalview.appletgui.AlignmentPanel)) { -jalview.appletgui.PaintRefresher.validateSequences ((source).av.getAlignment (), (comp).av.getAlignment ()); -}if (Clazz.instanceOf (comp, jalview.appletgui.AlignmentPanel) && alignmentChanged) { -(comp).alignmentChanged (); -}comp.repaint (); -} -}, "java.awt.Component,~S,~B,~B"); -c$.validateSequences = Clazz.defineMethod (c$, "validateSequences", -function (source, comp) { -var a1; -if (source.getHiddenSequences ().getSize () > 0) { -a1 = source.getHiddenSequences ().getFullAlignment ().getSequencesArray (); -} else { -a1 = source.getSequencesArray (); -}var a2; -if (comp.getHiddenSequences ().getSize () > 0) { -a2 = comp.getHiddenSequences ().getFullAlignment ().getSequencesArray (); -} else { -a2 = comp.getSequencesArray (); -}var i; -var iSize = a1.length; -var j; -var jSize = a2.length; -if (iSize == jSize) { -return; -}var exists = false; -for (i = 0; i < iSize; i++) { -exists = false; -for (j = 0; j < jSize; j++) { -if (a2[j] === a1[i]) { -exists = true; -break; -}} -if (!exists) { -if (i < comp.getHeight ()) { -var alsq; -{ -alsq.add (i, a1[i]); -}} else { -comp.addSequence (a1[i]); -}if (comp.getHiddenSequences ().getSize () > 0) { -a2 = comp.getHiddenSequences ().getFullAlignment ().getSequencesArray (); -} else { -a2 = comp.getSequencesArray (); -}jSize = a2.length; -}} -iSize = a1.length; -jSize = a2.length; -for (j = 0; j < jSize; j++) { -exists = false; -for (i = 0; i < iSize; i++) { -if (a2[j] === a1[i]) { -exists = true; -break; -}} -if (!exists) { -comp.deleteSequence (a2[j]); -}} -}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); -c$.getAssociatedPanels = Clazz.defineMethod (c$, "getAssociatedPanels", -function (id) { -var comps = jalview.appletgui.PaintRefresher.components.get (id); -var tmp = new java.util.Vector (); -var i; -var iSize = comps.size (); -for (i = 0; i < iSize; i++) { -if (Clazz.instanceOf (comps.elementAt (i), jalview.appletgui.AlignmentPanel)) { -tmp.addElement (comps.elementAt (i)); -}} -var result = new Array (tmp.size ()); -for (var ix = 0; ix < result.length; ix++) { -result[ix] = tmp.elementAt (ix); -} -return result; -}, "~S"); -Clazz.defineStatics (c$, -"components", null); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (null, "jalview.appletgui.PaintRefresher", ["jalview.appletgui.AlignmentPanel", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.declareType (jalview.appletgui, "PaintRefresher"); +c$.Register = Clazz.defineMethod (c$, "Register", +function (comp, seqSetId) { +if (jalview.appletgui.PaintRefresher.components == null) { +jalview.appletgui.PaintRefresher.components = new java.util.Hashtable (); +}if (jalview.appletgui.PaintRefresher.components.containsKey (seqSetId)) { +var comps = jalview.appletgui.PaintRefresher.components.get (seqSetId); +if (!comps.contains (comp)) { +comps.addElement (comp); +}} else { +var vcoms = new java.util.Vector (); +vcoms.addElement (comp); +jalview.appletgui.PaintRefresher.components.put (seqSetId, vcoms); +}}, "java.awt.Component,~S"); +c$.RemoveComponent = Clazz.defineMethod (c$, "RemoveComponent", +function (comp) { +if (jalview.appletgui.PaintRefresher.components == null) { +return; +}var en = jalview.appletgui.PaintRefresher.components.keys (); +while (en.hasMoreElements ()) { +var id = en.nextElement ().toString (); +var comps = jalview.appletgui.PaintRefresher.components.get (id); +comps.removeElement (comp); +if (comps.size () == 0) { +jalview.appletgui.PaintRefresher.components.remove (id); +}} +}, "java.awt.Component"); +c$.Refresh = Clazz.defineMethod (c$, "Refresh", +function (source, id) { +jalview.appletgui.PaintRefresher.Refresh (source, id, false, false); +}, "java.awt.Component,~S"); +c$.Refresh = Clazz.defineMethod (c$, "Refresh", +function (source, id, alignmentChanged, validateSequences) { +if (jalview.appletgui.PaintRefresher.components == null) { +return; +}var comp; +var comps = jalview.appletgui.PaintRefresher.components.get (id); +if (comps == null) { +return; +}var e = comps.elements (); +while (e.hasMoreElements ()) { +comp = e.nextElement (); +if (comp === source) { +continue; +}if (!comp.isValid ()) { +comps.removeElement (comp); +} else if (validateSequences && Clazz.instanceOf (comp, jalview.appletgui.AlignmentPanel) && Clazz.instanceOf (source, jalview.appletgui.AlignmentPanel)) { +jalview.appletgui.PaintRefresher.validateSequences ((source).av.getAlignment (), (comp).av.getAlignment ()); +}if (Clazz.instanceOf (comp, jalview.appletgui.AlignmentPanel) && alignmentChanged) { +(comp).alignmentChanged (); +}comp.repaint (); +} +}, "java.awt.Component,~S,~B,~B"); +c$.validateSequences = Clazz.defineMethod (c$, "validateSequences", +function (source, comp) { +var a1; +if (source.getHiddenSequences ().getSize () > 0) { +a1 = source.getHiddenSequences ().getFullAlignment ().getSequencesArray (); +} else { +a1 = source.getSequencesArray (); +}var a2; +if (comp.getHiddenSequences ().getSize () > 0) { +a2 = comp.getHiddenSequences ().getFullAlignment ().getSequencesArray (); +} else { +a2 = comp.getSequencesArray (); +}var i; +var iSize = a1.length; +var j; +var jSize = a2.length; +if (iSize == jSize) { +return; +}var exists = false; +for (i = 0; i < iSize; i++) { +exists = false; +for (j = 0; j < jSize; j++) { +if (a2[j] === a1[i]) { +exists = true; +break; +}} +if (!exists) { +if (i < comp.getHeight ()) { +var alsq; +{ +alsq.add (i, a1[i]); +}} else { +comp.addSequence (a1[i]); +}if (comp.getHiddenSequences ().getSize () > 0) { +a2 = comp.getHiddenSequences ().getFullAlignment ().getSequencesArray (); +} else { +a2 = comp.getSequencesArray (); +}jSize = a2.length; +}} +iSize = a1.length; +jSize = a2.length; +for (j = 0; j < jSize; j++) { +exists = false; +for (i = 0; i < iSize; i++) { +if (a2[j] === a1[i]) { +exists = true; +break; +}} +if (!exists) { +comp.deleteSequence (a2[j]); +}} +}, "jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentI"); +c$.getAssociatedPanels = Clazz.defineMethod (c$, "getAssociatedPanels", +function (id) { +var comps = jalview.appletgui.PaintRefresher.components.get (id); +var tmp = new java.util.Vector (); +var i; +var iSize = comps.size (); +for (i = 0; i < iSize; i++) { +if (Clazz.instanceOf (comps.elementAt (i), jalview.appletgui.AlignmentPanel)) { +tmp.addElement (comps.elementAt (i)); +}} +var result = new Array (tmp.size ()); +for (var ix = 0; ix < result.length; ix++) { +result[ix] = tmp.elementAt (ix); +} +return result; +}, "~S"); +Clazz.defineStatics (c$, +"components", null); +}); diff --git a/bin/jalview/appletgui/PairwiseAlignPanel.js b/bin/jalview/appletgui/PairwiseAlignPanel.js index e91c56d..ddb1948 100644 --- a/bin/jalview/appletgui/PairwiseAlignPanel.js +++ b/bin/jalview/appletgui/PairwiseAlignPanel.js @@ -1,100 +1,100 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "awt2swing.Button", "$.ScrollPane", "$.TextArea", "java.awt.BorderLayout", "java.util.Vector"], "jalview.appletgui.PairwiseAlignPanel", ["jalview.analysis.AlignSeq", "jalview.appletgui.AlignFrame", "jalview.datamodel.Alignment", "jalview.util.Format", "$.MessageManager", "java.awt.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sequences = null; -this.ap = null; -this.scrollPane = null; -this.textarea = null; -this.viewInEditorButton = null; -this.jPanel1 = null; -this.borderLayout1 = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "PairwiseAlignPanel", awt2swing.Panel, java.awt.event.ActionListener); -Clazz.prepareFields (c$, function () { -this.sequences = new java.util.Vector (); -this.scrollPane = new awt2swing.ScrollPane (); -this.textarea = new awt2swing.TextArea (); -this.viewInEditorButton = new awt2swing.Button (); -this.jPanel1 = new awt2swing.Panel (); -this.borderLayout1 = new java.awt.BorderLayout (); -}); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.PairwiseAlignPanel, []); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.ap = ap; -this.sequences = new java.util.Vector (); -var seqs; -var seqStrings = ap.av.getViewAsString (true); -if (ap.av.getSelectionGroup () == null) { -seqs = ap.av.getAlignment ().getSequencesArray (); -} else { -seqs = ap.av.getSelectionGroup ().getSequencesInOrder (ap.av.getAlignment ()); -}var scores = Clazz.newFloatArray (seqs.length, seqs.length, 0); -var totscore = 0; -var count = ap.av.getSelectionGroup ().getSize (); -var type = (ap.av.getAlignment ().isNucleotide ()) ? "dna" : "pep"; -var seq; -for (var i = 1; i < count; i++) { -for (var j = 0; j < i; j++) { -var as = new jalview.analysis.AlignSeq (seqs[i], seqStrings[i], seqs[j], seqStrings[j], type); -if (as.s1str.length == 0 || as.s2str.length == 0) { -continue; -}as.calcScoreMatrix (); -as.traceAlignment (); -as.printAlignment (System.out); -scores[i][j] = as.getMaxScore () / as.getASeq1 ().length; -totscore = totscore + scores[i][j]; -this.textarea.append (as.getOutput ()); -this.sequences.add (as.getAlignedSeq1 ()); -this.sequences.add (as.getAlignedSeq1 ()); -} -} -if (count > 2) { -System.out.println ("Pairwise alignment scaled similarity score matrix\n"); -for (var i = 0; i < count; i++) { -jalview.util.Format.print (System.out, "%s \n", ("" + i) + " " + seqs[i].getName ()); -} -System.out.println ("\n"); -for (var i = 0; i < count; i++) { -for (var j = 0; j < i; j++) { -jalview.util.Format.printDouble (System.out, "%7.3f", scores[i][j] / totscore); -} -} -System.out.println ("\n"); -}}, "jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.viewInEditorButton) { -this.viewInEditorButton_actionPerformed (); -}}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "viewInEditorButton_actionPerformed", -function () { -var seq = new Array (this.sequences.size ()); -for (var i = 0; i < this.sequences.size (); i++) { -seq[i] = this.sequences.elementAt (i); -} - new jalview.appletgui.AlignFrame ( new jalview.datamodel.Alignment (seq), this.ap.av.applet, "Pairwise Aligned Sequences", false); -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout (this.borderLayout1); -this.textarea.setFont ( new java.awt.Font ("Monospaced", 0, 12)); -this.textarea.setText (""); -this.viewInEditorButton.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.viewInEditorButton.setLabel (jalview.util.MessageManager.getString ("label.view_alignment_editor")); -this.viewInEditorButton.addActionListener (this); -this.add (this.scrollPane, "Center"); -this.scrollPane.add (this.textarea); -this.add (this.jPanel1, "South"); -this.jPanel1.add (this.viewInEditorButton, null); -}, $fz.isPrivate = true, $fz)); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "awt2swing.Button", "$.ScrollPane", "$.TextArea", "java.awt.BorderLayout", "java.util.Vector"], "jalview.appletgui.PairwiseAlignPanel", ["jalview.analysis.AlignSeq", "jalview.appletgui.AlignFrame", "jalview.datamodel.Alignment", "jalview.util.Format", "$.MessageManager", "java.awt.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sequences = null; +this.ap = null; +this.scrollPane = null; +this.textarea = null; +this.viewInEditorButton = null; +this.jPanel1 = null; +this.borderLayout1 = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "PairwiseAlignPanel", awt2swing.Panel, java.awt.event.ActionListener); +Clazz.prepareFields (c$, function () { +this.sequences = new java.util.Vector (); +this.scrollPane = new awt2swing.ScrollPane (); +this.textarea = new awt2swing.TextArea (); +this.viewInEditorButton = new awt2swing.Button (); +this.jPanel1 = new awt2swing.Panel (); +this.borderLayout1 = new java.awt.BorderLayout (); +}); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.PairwiseAlignPanel, []); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.ap = ap; +this.sequences = new java.util.Vector (); +var seqs; +var seqStrings = ap.av.getViewAsString (true); +if (ap.av.getSelectionGroup () == null) { +seqs = ap.av.getAlignment ().getSequencesArray (); +} else { +seqs = ap.av.getSelectionGroup ().getSequencesInOrder (ap.av.getAlignment ()); +}var scores = Clazz.newFloatArray (seqs.length, seqs.length, 0); +var totscore = 0; +var count = ap.av.getSelectionGroup ().getSize (); +var type = (ap.av.getAlignment ().isNucleotide ()) ? "dna" : "pep"; +var seq; +for (var i = 1; i < count; i++) { +for (var j = 0; j < i; j++) { +var as = new jalview.analysis.AlignSeq (seqs[i], seqStrings[i], seqs[j], seqStrings[j], type); +if (as.s1str.length == 0 || as.s2str.length == 0) { +continue; +}as.calcScoreMatrix (); +as.traceAlignment (); +as.printAlignment (System.out); +scores[i][j] = as.getMaxScore () / as.getASeq1 ().length; +totscore = totscore + scores[i][j]; +this.textarea.append (as.getOutput ()); +this.sequences.add (as.getAlignedSeq1 ()); +this.sequences.add (as.getAlignedSeq1 ()); +} +} +if (count > 2) { +System.out.println ("Pairwise alignment scaled similarity score matrix\n"); +for (var i = 0; i < count; i++) { +jalview.util.Format.print (System.out, "%s \n", ("" + i) + " " + seqs[i].getName ()); +} +System.out.println ("\n"); +for (var i = 0; i < count; i++) { +for (var j = 0; j < i; j++) { +jalview.util.Format.printDouble (System.out, "%7.3f", scores[i][j] / totscore); +} +} +System.out.println ("\n"); +}}, "jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.viewInEditorButton) { +this.viewInEditorButton_actionPerformed (); +}}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "viewInEditorButton_actionPerformed", +function () { +var seq = new Array (this.sequences.size ()); +for (var i = 0; i < this.sequences.size (); i++) { +seq[i] = this.sequences.elementAt (i); +} + new jalview.appletgui.AlignFrame ( new jalview.datamodel.Alignment (seq), this.ap.av.applet, "Pairwise Aligned Sequences", false); +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout (this.borderLayout1); +this.textarea.setFont ( new java.awt.Font ("Monospaced", 0, 12)); +this.textarea.setText (""); +this.viewInEditorButton.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.viewInEditorButton.setLabel (jalview.util.MessageManager.getString ("label.view_alignment_editor")); +this.viewInEditorButton.addActionListener (this); +this.add (this.scrollPane, "Center"); +this.scrollPane.add (this.textarea); +this.add (this.jPanel1, "South"); +this.jPanel1.add (this.viewInEditorButton, null); +}, $fz.isPrivate = true, $fz)); +}); diff --git a/bin/jalview/appletgui/RedundancyPanel.js b/bin/jalview/appletgui/RedundancyPanel.js index 647ac1b..f6b850d 100644 --- a/bin/jalview/appletgui/RedundancyPanel.js +++ b/bin/jalview/appletgui/RedundancyPanel.js @@ -1,165 +1,165 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.appletgui.SliderPanel", "java.awt.event.WindowListener", "java.util.Stack"], "jalview.appletgui.RedundancyPanel", ["awt2swing.Frame", "jalview.analysis.AlignSeq", "jalview.appletgui.PaintRefresher", "jalview.bin.JalviewLite", "jalview.commands.EditCommand", "jalview.util.MessageManager", "java.awt.event.AdjustmentListener", "java.lang.Thread", "java.util.ArrayList", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.historyList = null; -this.redundancy = null; -this.originalSequences = null; -this.frame = null; -this.redundantSeqs = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "RedundancyPanel", jalview.appletgui.SliderPanel, [Runnable, java.awt.event.WindowListener]); -Clazz.prepareFields (c$, function () { -this.historyList = new java.util.Stack (); -}); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.RedundancyPanel, [ap, 0, false, null]); -this.redundantSeqs = new java.util.Vector (); -this.ap = ap; -this.undoButton.setVisible (true); -this.applyButton.setVisible (true); -this.allGroupsCheck.setVisible (false); -this.label.setText (jalview.util.MessageManager.getString ("label.enter_redundancy_threshold")); -this.valueField.setText ("100"); -this.slider.setVisibleAmount (1); -this.slider.setMinimum (0); -this.slider.setMaximum (100 + this.slider.getVisibleAmount ()); -this.slider.setValue (100); -this.slider.addAdjustmentListener (((Clazz.isClassDefined ("jalview.appletgui.RedundancyPanel$1") ? 0 : jalview.appletgui.RedundancyPanel.$RedundancyPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.RedundancyPanel$1, this, null))); -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.redundancy_threshold_selection"), 400, 100); -this.frame.addWindowListener (this); -var worker = new Thread (this); -worker.start (); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "run", -function () { -this.label.setText (jalview.util.MessageManager.getString ("label.calculating")); -this.slider.setVisible (false); -this.applyButton.setEnabled (false); -this.valueField.setVisible (false); -this.validate (); -var omitHidden = null; -var sg = this.ap.av.getSelectionGroup (); -var height; -var start; -var end; -if ((sg != null) && (sg.getSize () >= 1)) { -this.originalSequences = sg.getSequencesInOrder (this.ap.av.getAlignment ()); -start = sg.getStartRes (); -end = sg.getEndRes (); -} else { -this.originalSequences = this.ap.av.getAlignment ().getSequencesArray (); -start = 0; -end = this.ap.av.getAlignment ().getWidth (); -}height = this.originalSequences.length; -this.redundancy = jalview.analysis.AlignSeq.computeRedundancyMatrix (this.originalSequences, omitHidden, start, end, false); -this.label.setText (jalview.util.MessageManager.getString ("label.enter_redundancy_threshold")); -this.slider.setVisible (true); -this.applyButton.setEnabled (true); -this.valueField.setVisible (true); -this.validate (); -this.sliderValueChanged (); -}); -Clazz.defineMethod (c$, "sliderValueChanged", -function () { -if (this.redundancy == null) { -return; -}var value = this.slider.getValue (); -var redundantSequences = new java.util.ArrayList (); -for (var i = 0; i < this.redundancy.length; i++) { -if (value <= this.redundancy[i]) { -redundantSequences.add (this.originalSequences[i]); -}} -this.ap.idPanel.idCanvas.setHighlighted (redundantSequences); -jalview.appletgui.PaintRefresher.Refresh (this, this.ap.av.getSequenceSetId (), true, true); -}); -Clazz.overrideMethod (c$, "applyButton_actionPerformed", -function () { -var del = new java.util.Vector (); -this.undoButton.setEnabled (true); -var value = this.slider.getValue (); -var sg = this.ap.av.getSelectionGroup (); -for (var i = 0; i < this.redundancy.length; i++) { -if (value <= this.redundancy[i]) { -del.addElement (this.originalSequences[i]); -}} -if (del.size () > 0) { -var deleted = new Array (del.size ()); -var width = 0; -for (var i = 0; i < del.size (); i++) { -deleted[i] = del.elementAt (i); -if (deleted[i].getLength () > width) { -width = deleted[i].getLength (); -}} -var cut = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.remove_redundancy"), jalview.commands.EditCommand.Action.CUT, deleted, 0, width, this.ap.av.getAlignment ()); -var alignment = this.ap.av.getAlignment (); -for (var i = 0; i < del.size (); i++) { -alignment.deleteSequence (deleted[i]); -if (sg != null) { -sg.deleteSequence (deleted[i], false); -}} -this.historyList.push (cut); -this.ap.alignFrame.addHistoryItem (cut); -jalview.appletgui.PaintRefresher.Refresh (this, this.ap.av.getSequenceSetId (), true, true); -this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); -}}); -Clazz.overrideMethod (c$, "undoButton_actionPerformed", -function () { -var command = this.historyList.pop (); -command.undoCommand (null); -if (this.ap.av.getHistoryList ().contains (command)) { -this.ap.av.getHistoryList ().remove (command); -this.ap.alignFrame.updateEditMenuBar (); -this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); -}this.ap.paintAlignment (true); -if (this.historyList.size () == 0) { -this.undoButton.setEnabled (false); -}}); -Clazz.defineMethod (c$, "valueField_actionPerformed", -function (e) { -try { -var i = Integer.parseInt (this.valueField.getText ()); -this.slider.setValue (i); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -this.valueField.setText (this.slider.getValue () + ""); -} else { -throw ex; -} -} -}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "windowOpened", -function (evt) { -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowClosing", -function (evt) { -this.ap.idPanel.idCanvas.setHighlighted (null); -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowClosed", -function (evt) { -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowActivated", -function (evt) { -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowDeactivated", -function (evt) { -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowIconified", -function (evt) { -}, "java.awt.event.WindowEvent"); -Clazz.overrideMethod (c$, "windowDeiconified", -function (evt) { -}, "java.awt.event.WindowEvent"); -c$.$RedundancyPanel$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "RedundancyPanel$1", null, java.awt.event.AdjustmentListener); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -this.b$["jalview.appletgui.RedundancyPanel"].valueField.setText (this.b$["jalview.appletgui.RedundancyPanel"].slider.getValue () + ""); -this.b$["jalview.appletgui.RedundancyPanel"].sliderValueChanged (); -}, "java.awt.event.AdjustmentEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.appletgui.SliderPanel", "java.awt.event.WindowListener", "java.util.Stack"], "jalview.appletgui.RedundancyPanel", ["awt2swing.Frame", "jalview.analysis.AlignSeq", "jalview.appletgui.PaintRefresher", "jalview.bin.JalviewLite", "jalview.commands.EditCommand", "jalview.util.MessageManager", "java.awt.event.AdjustmentListener", "java.lang.Thread", "java.util.ArrayList", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.historyList = null; +this.redundancy = null; +this.originalSequences = null; +this.frame = null; +this.redundantSeqs = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "RedundancyPanel", jalview.appletgui.SliderPanel, [Runnable, java.awt.event.WindowListener]); +Clazz.prepareFields (c$, function () { +this.historyList = new java.util.Stack (); +}); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.RedundancyPanel, [ap, 0, false, null]); +this.redundantSeqs = new java.util.Vector (); +this.ap = ap; +this.undoButton.setVisible (true); +this.applyButton.setVisible (true); +this.allGroupsCheck.setVisible (false); +this.label.setText (jalview.util.MessageManager.getString ("label.enter_redundancy_threshold")); +this.valueField.setText ("100"); +this.slider.setVisibleAmount (1); +this.slider.setMinimum (0); +this.slider.setMaximum (100 + this.slider.getVisibleAmount ()); +this.slider.setValue (100); +this.slider.addAdjustmentListener (((Clazz.isClassDefined ("jalview.appletgui.RedundancyPanel$1") ? 0 : jalview.appletgui.RedundancyPanel.$RedundancyPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.RedundancyPanel$1, this, null))); +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.redundancy_threshold_selection"), 400, 100); +this.frame.addWindowListener (this); +var worker = new Thread (this); +worker.start (); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "run", +function () { +this.label.setText (jalview.util.MessageManager.getString ("label.calculating")); +this.slider.setVisible (false); +this.applyButton.setEnabled (false); +this.valueField.setVisible (false); +this.validate (); +var omitHidden = null; +var sg = this.ap.av.getSelectionGroup (); +var height; +var start; +var end; +if ((sg != null) && (sg.getSize () >= 1)) { +this.originalSequences = sg.getSequencesInOrder (this.ap.av.getAlignment ()); +start = sg.getStartRes (); +end = sg.getEndRes (); +} else { +this.originalSequences = this.ap.av.getAlignment ().getSequencesArray (); +start = 0; +end = this.ap.av.getAlignment ().getWidth (); +}height = this.originalSequences.length; +this.redundancy = jalview.analysis.AlignSeq.computeRedundancyMatrix (this.originalSequences, omitHidden, start, end, false); +this.label.setText (jalview.util.MessageManager.getString ("label.enter_redundancy_threshold")); +this.slider.setVisible (true); +this.applyButton.setEnabled (true); +this.valueField.setVisible (true); +this.validate (); +this.sliderValueChanged (); +}); +Clazz.defineMethod (c$, "sliderValueChanged", +function () { +if (this.redundancy == null) { +return; +}var value = this.slider.getValue (); +var redundantSequences = new java.util.ArrayList (); +for (var i = 0; i < this.redundancy.length; i++) { +if (value <= this.redundancy[i]) { +redundantSequences.add (this.originalSequences[i]); +}} +this.ap.idPanel.idCanvas.setHighlighted (redundantSequences); +jalview.appletgui.PaintRefresher.Refresh (this, this.ap.av.getSequenceSetId (), true, true); +}); +Clazz.overrideMethod (c$, "applyButton_actionPerformed", +function () { +var del = new java.util.Vector (); +this.undoButton.setEnabled (true); +var value = this.slider.getValue (); +var sg = this.ap.av.getSelectionGroup (); +for (var i = 0; i < this.redundancy.length; i++) { +if (value <= this.redundancy[i]) { +del.addElement (this.originalSequences[i]); +}} +if (del.size () > 0) { +var deleted = new Array (del.size ()); +var width = 0; +for (var i = 0; i < del.size (); i++) { +deleted[i] = del.elementAt (i); +if (deleted[i].getLength () > width) { +width = deleted[i].getLength (); +}} +var cut = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.remove_redundancy"), jalview.commands.EditCommand.Action.CUT, deleted, 0, width, this.ap.av.getAlignment ()); +var alignment = this.ap.av.getAlignment (); +for (var i = 0; i < del.size (); i++) { +alignment.deleteSequence (deleted[i]); +if (sg != null) { +sg.deleteSequence (deleted[i], false); +}} +this.historyList.push (cut); +this.ap.alignFrame.addHistoryItem (cut); +jalview.appletgui.PaintRefresher.Refresh (this, this.ap.av.getSequenceSetId (), true, true); +this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); +}}); +Clazz.overrideMethod (c$, "undoButton_actionPerformed", +function () { +var command = this.historyList.pop (); +command.undoCommand (null); +if (this.ap.av.getHistoryList ().contains (command)) { +this.ap.av.getHistoryList ().remove (command); +this.ap.alignFrame.updateEditMenuBar (); +this.ap.av.firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); +}this.ap.paintAlignment (true); +if (this.historyList.size () == 0) { +this.undoButton.setEnabled (false); +}}); +Clazz.defineMethod (c$, "valueField_actionPerformed", +function (e) { +try { +var i = Integer.parseInt (this.valueField.getText ()); +this.slider.setValue (i); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +this.valueField.setText (this.slider.getValue () + ""); +} else { +throw ex; +} +} +}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "windowOpened", +function (evt) { +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowClosing", +function (evt) { +this.ap.idPanel.idCanvas.setHighlighted (null); +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowClosed", +function (evt) { +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowActivated", +function (evt) { +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowDeactivated", +function (evt) { +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowIconified", +function (evt) { +}, "java.awt.event.WindowEvent"); +Clazz.overrideMethod (c$, "windowDeiconified", +function (evt) { +}, "java.awt.event.WindowEvent"); +c$.$RedundancyPanel$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "RedundancyPanel$1", null, java.awt.event.AdjustmentListener); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +this.b$["jalview.appletgui.RedundancyPanel"].valueField.setText (this.b$["jalview.appletgui.RedundancyPanel"].slider.getValue () + ""); +this.b$["jalview.appletgui.RedundancyPanel"].sliderValueChanged (); +}, "java.awt.event.AdjustmentEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/RotatableCanvas.js b/bin/jalview/appletgui/RotatableCanvas.js index 5e61dea..0bb0b4a 100644 --- a/bin/jalview/appletgui/RotatableCanvas.js +++ b/bin/jalview/appletgui/RotatableCanvas.js @@ -1,371 +1,371 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.api.RotatableCanvasI", "java.awt.event.KeyListener", "$.MouseListener", "$.MouseMotionListener", "jalview.math.RotatableMatrix"], "jalview.appletgui.RotatableCanvas", ["jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "jalview.util.Format", "$.MessageManager", "java.awt.Color", "$.Dimension", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.idmat = null; -this.objmat = null; -this.rotmat = null; -this.tooltip = null; -this.toolx = 0; -this.tooly = 0; -this.$drawAxes = true; -this.omx = 0; -this.mx = 0; -this.omy = 0; -this.my = 0; -this.img = null; -this.ig = null; -this.prefsize = null; -this.centre = null; -this.$width = null; -this.max = null; -this.min = null; -this.maxwidth = 0; -this.scale = 0; -this.npoint = 0; -this.points = null; -this.orig = null; -this.axes = null; -this.startx = 0; -this.starty = 0; -this.lastx = 0; -this.lasty = 0; -this.rectx1 = 0; -this.recty1 = 0; -this.rectx2 = 0; -this.recty2 = 0; -this.scalefactor = 1; -this.av = null; -this.$showLabels = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "RotatableCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, jalview.api.RotatableCanvasI]); -Clazz.prepareFields (c$, function () { -this.idmat = new jalview.math.RotatableMatrix (3, 3); -this.objmat = new jalview.math.RotatableMatrix (3, 3); -this.rotmat = new jalview.math.RotatableMatrix (3, 3); -this.centre = Clazz.newFloatArray (3, 0); -this.$width = Clazz.newFloatArray (3, 0); -this.max = Clazz.newFloatArray (3, 0); -this.min = Clazz.newFloatArray (3, 0); -}); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.RotatableCanvas, []); -this.av = av; -}, "jalview.viewmodel.AlignmentViewport"); -Clazz.defineMethod (c$, "showLabels", -function (b) { -this.$showLabels = b; -this.repaint (); -}, "~B"); -Clazz.overrideMethod (c$, "setPoints", -function (points, npoint) { -this.points = points; -this.npoint = npoint; -jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ()); -this.prefsize = this.getPreferredSize (); -this.orig = Clazz.newFloatArray (npoint, 3, 0); -for (var i = 0; i < npoint; i++) { -var sp = points.elementAt (i); -for (var j = 0; j < 3; j++) { -this.orig[i][j] = sp.coord[j]; -} -} -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -if (i != j) { -this.idmat.addElement (i, j, 0); -this.objmat.addElement (i, j, 0); -this.rotmat.addElement (i, j, 0); -} else { -this.idmat.addElement (i, j, 0); -this.objmat.addElement (i, j, 0); -this.rotmat.addElement (i, j, 0); -}} -} -this.axes = Clazz.newFloatArray (3, 3, 0); -this.initAxes (); -this.findCentre (); -this.findWidth (); -this.scale = this.findScale (); -this.addMouseListener (this); -this.addKeyListener (this); -this.addMouseMotionListener (this); -}, "java.util.Vector,~N"); -Clazz.defineMethod (c$, "initAxes", -function () { -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -if (i != j) { -this.axes[i][j] = 0; -} else { -this.axes[i][j] = 1; -}} -} -}); -Clazz.defineMethod (c$, "findWidth", -function () { -this.max = Clazz.newFloatArray (3, 0); -this.min = Clazz.newFloatArray (3, 0); -this.max[0] = -1.0E30; -this.max[1] = -1.0E30; -this.max[2] = -1.0E30; -this.min[0] = 1e30; -this.min[1] = 1e30; -this.min[2] = 1e30; -for (var i = 0; i < 3; i++) { -for (var j = 0; j < this.npoint; j++) { -var sp = this.points.elementAt (j); -if (sp.coord[i] >= this.max[i]) { -this.max[i] = sp.coord[i]; -}if (sp.coord[i] <= this.min[i]) { -this.min[i] = sp.coord[i]; -}} -} -this.$width[0] = Math.abs (this.max[0] - this.min[0]); -this.$width[1] = Math.abs (this.max[1] - this.min[1]); -this.$width[2] = Math.abs (this.max[2] - this.min[2]); -this.maxwidth = this.$width[0]; -if (this.$width[1] > this.$width[0]) { -this.maxwidth = this.$width[1]; -}if (this.$width[2] > this.$width[1]) { -this.maxwidth = this.$width[2]; -}}); -Clazz.defineMethod (c$, "findScale", -function () { -var dim; -var width; -var height; -if (this.getSize ().width != 0) { -width = this.getSize ().width; -height = this.getSize ().height; -} else { -width = this.prefsize.width; -height = this.prefsize.height; -}if (width < height) { -dim = width; -} else { -dim = height; -}return dim * this.scalefactor / (2 * this.maxwidth); -}); -Clazz.defineMethod (c$, "findCentre", -function () { -this.findWidth (); -this.centre[0] = (this.max[0] + this.min[0]) / 2; -this.centre[1] = (this.max[1] + this.min[1]) / 2; -this.centre[2] = (this.max[2] + this.min[2]) / 2; -}); -Clazz.overrideMethod (c$, "getPreferredSize", -function () { -if (this.prefsize != null) { -return this.prefsize; -} else { -return new java.awt.Dimension (400, 400); -}}); -Clazz.overrideMethod (c$, "getMinimumSize", -function () { -return this.getPreferredSize (); -}); -Clazz.overrideMethod (c$, "update", -function (g) { -this.paint (g); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "PaintComponent", -function (g) { -if (this.points == null) { -g.setFont ( new java.awt.Font ("Verdana", 0, 18)); -g.drawString (jalview.util.MessageManager.getString ("label.calculating_pca") + "....", 20, Clazz.doubleToInt (this.getSize ().height / 2)); -} else { -if ((this.img == null) || (this.prefsize.width != this.getSize ().width) || (this.prefsize.height != this.getSize ().height)) { -this.prefsize.width = this.getSize ().width; -this.prefsize.height = this.getSize ().height; -this.scale = this.findScale (); -this.img = this.createImage (this.getSize ().width, this.getSize ().height); -this.ig = this.img.getGraphics (); -}this.drawBackground (this.ig, java.awt.Color.black); -this.drawScene (this.ig); -if (this.$drawAxes == true) { -this.drawAxes (this.ig); -}if (this.tooltip != null) { -this.ig.setColor (java.awt.Color.red); -this.ig.drawString (this.tooltip, this.toolx, this.tooly); -}g.drawImage (this.img, 0, 0, this); -}}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawAxes", -function (g) { -g.setColor (java.awt.Color.yellow); -for (var i = 0; i < 3; i++) { -g.drawLine (Clazz.doubleToInt (this.getSize ().width / 2), Clazz.doubleToInt (this.getSize ().height / 2), Clazz.floatToInt (this.axes[i][0] * this.scale * this.max[0] + Clazz.doubleToInt (this.getSize ().width / 2)), Clazz.floatToInt (this.axes[i][1] * this.scale * this.max[1] + Clazz.doubleToInt (this.getSize ().height / 2))); -} -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawBackground", -function (g, col) { -g.setColor (col); -g.fillRect (0, 0, this.prefsize.width, this.prefsize.height); -}, "java.awt.Graphics,java.awt.Color"); -Clazz.defineMethod (c$, "drawScene", -function (g) { -var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); -var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -var x = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; -var y = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; -var z = sp.coord[1] - this.centre[2]; -if (this.av.getSequenceColour (sp.sequence) === java.awt.Color.black) { -g.setColor (java.awt.Color.white); -} else { -g.setColor (this.av.getSequenceColour (sp.sequence)); -}if (this.av.getSelectionGroup () != null) { -if (this.av.getSelectionGroup ().getSequences (null).contains ((this.points.elementAt (i)).sequence)) { -g.setColor (java.awt.Color.gray); -}}if (z < 0) { -g.setColor (g.getColor ().darker ()); -}g.fillRect (x - 3, y - 3, 6, 6); -if (this.$showLabels) { -g.setColor (java.awt.Color.red); -g.drawString ((this.points.elementAt (i)).sequence.getName (), x - 3, y - 4); -}} -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "minimumsize", -function () { -return this.prefsize; -}); -Clazz.defineMethod (c$, "preferredsize", -function () { -return this.prefsize; -}); -Clazz.overrideMethod (c$, "keyTyped", -function (evt) { -}, "java.awt.event.KeyEvent"); -Clazz.overrideMethod (c$, "keyReleased", -function (evt) { -}, "java.awt.event.KeyEvent"); -Clazz.overrideMethod (c$, "keyPressed", -function (evt) { -if (evt.getKeyCode () == 38) { -this.scalefactor = (this.scalefactor * 1.1); -this.scale = this.findScale (); -} else if (evt.getKeyCode () == 40) { -this.scalefactor = (this.scalefactor * 0.9); -this.scale = this.findScale (); -} else if (evt.getKeyChar () == 's') { -System.err.println ("DEBUG: Rectangle selection"); -if (this.rectx2 != -1 && this.recty2 != -1) { -this.rectSelect (this.rectx1, this.recty1, this.rectx2, this.recty2); -}}this.repaint (); -}, "java.awt.event.KeyEvent"); -Clazz.defineMethod (c$, "printPoints", -function () { -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -jalview.util.Format.printLong (System.out, "%5d ", i); -for (var j = 0; j < 3; j++) { -jalview.util.Format.printDouble (System.out, "%13.3f ", sp.coord[j]); -} -System.out.println (); -} -}); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -var x = evt.getX (); -var y = evt.getY (); -this.mx = x; -this.my = y; -this.omx = this.mx; -this.omy = this.my; -this.startx = x; -this.starty = y; -this.rectx1 = x; -this.recty1 = y; -this.rectx2 = -1; -this.recty2 = -1; -var found = this.findPoint (x, y); -if (found != null) { -if (this.av.getSelectionGroup () != null) { -this.av.getSelectionGroup ().addOrRemove (found, true); -this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); -} else { -this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); -this.av.getSelectionGroup ().addOrRemove (found, true); -this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); -}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); -this.av.sendSelection (); -}this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -var found = this.findPoint (evt.getX (), evt.getY ()); -if (found == null) { -this.tooltip = null; -} else { -this.tooltip = found.getName (); -this.toolx = evt.getX (); -this.tooly = evt.getY (); -}this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -this.mx = evt.getX (); -this.my = evt.getY (); -this.rotmat.setIdentity (); -this.rotmat.rotate (this.my - this.omy, 'x'); -this.rotmat.rotate (this.mx - this.omx, 'y'); -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -sp.coord[0] -= this.centre[0]; -sp.coord[1] -= this.centre[1]; -sp.coord[2] -= this.centre[2]; -sp.coord = this.rotmat.vectorMultiply (sp.coord); -sp.coord[0] += this.centre[0]; -sp.coord[1] += this.centre[1]; -sp.coord[2] += this.centre[2]; -} -for (var i = 0; i < 3; i++) { -this.axes[i] = this.rotmat.vectorMultiply (this.axes[i]); -} -this.omx = this.mx; -this.omy = this.my; -this.paint (this.getGraphics ()); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "rectSelect", -function (x1, y1, x2, y2) { -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -var tmp1 = Clazz.doubleToInt ((sp.coord[0] - this.centre[0]) * this.scale + this.getSize ().width / 2.0); -var tmp2 = Clazz.doubleToInt ((sp.coord[1] - this.centre[1]) * this.scale + this.getSize ().height / 2.0); -if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) { -if (this.av != null) { -if (!this.av.getSelectionGroup ().getSequences (null).contains (sp.sequence)) { -this.av.getSelectionGroup ().addSequence (sp.sequence, true); -}}}} -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "findPoint", -function (x, y) { -var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); -var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); -var found = -1; -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -var px = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; -var py = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; -if (Math.abs (px - x) < 3 && Math.abs (py - y) < 3) { -found = i; -}} -if (found != -1) { -return (this.points.elementAt (found)).sequence; -} else { -return null; -}}, "~N,~N"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.api.RotatableCanvasI", "java.awt.event.KeyListener", "$.MouseListener", "$.MouseMotionListener", "jalview.math.RotatableMatrix"], "jalview.appletgui.RotatableCanvas", ["jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "jalview.util.Format", "$.MessageManager", "java.awt.Color", "$.Dimension", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.idmat = null; +this.objmat = null; +this.rotmat = null; +this.tooltip = null; +this.toolx = 0; +this.tooly = 0; +this.$drawAxes = true; +this.omx = 0; +this.mx = 0; +this.omy = 0; +this.my = 0; +this.img = null; +this.ig = null; +this.prefsize = null; +this.centre = null; +this.$width = null; +this.max = null; +this.min = null; +this.maxwidth = 0; +this.scale = 0; +this.npoint = 0; +this.points = null; +this.orig = null; +this.axes = null; +this.startx = 0; +this.starty = 0; +this.lastx = 0; +this.lasty = 0; +this.rectx1 = 0; +this.recty1 = 0; +this.rectx2 = 0; +this.recty2 = 0; +this.scalefactor = 1; +this.av = null; +this.$showLabels = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "RotatableCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, jalview.api.RotatableCanvasI]); +Clazz.prepareFields (c$, function () { +this.idmat = new jalview.math.RotatableMatrix (3, 3); +this.objmat = new jalview.math.RotatableMatrix (3, 3); +this.rotmat = new jalview.math.RotatableMatrix (3, 3); +this.centre = Clazz.newFloatArray (3, 0); +this.$width = Clazz.newFloatArray (3, 0); +this.max = Clazz.newFloatArray (3, 0); +this.min = Clazz.newFloatArray (3, 0); +}); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.RotatableCanvas, []); +this.av = av; +}, "jalview.viewmodel.AlignmentViewport"); +Clazz.defineMethod (c$, "showLabels", +function (b) { +this.$showLabels = b; +this.repaint (); +}, "~B"); +Clazz.overrideMethod (c$, "setPoints", +function (points, npoint) { +this.points = points; +this.npoint = npoint; +jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ()); +this.prefsize = this.getPreferredSize (); +this.orig = Clazz.newFloatArray (npoint, 3, 0); +for (var i = 0; i < npoint; i++) { +var sp = points.elementAt (i); +for (var j = 0; j < 3; j++) { +this.orig[i][j] = sp.coord[j]; +} +} +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +if (i != j) { +this.idmat.addElement (i, j, 0); +this.objmat.addElement (i, j, 0); +this.rotmat.addElement (i, j, 0); +} else { +this.idmat.addElement (i, j, 0); +this.objmat.addElement (i, j, 0); +this.rotmat.addElement (i, j, 0); +}} +} +this.axes = Clazz.newFloatArray (3, 3, 0); +this.initAxes (); +this.findCentre (); +this.findWidth (); +this.scale = this.findScale (); +this.addMouseListener (this); +this.addKeyListener (this); +this.addMouseMotionListener (this); +}, "java.util.Vector,~N"); +Clazz.defineMethod (c$, "initAxes", +function () { +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +if (i != j) { +this.axes[i][j] = 0; +} else { +this.axes[i][j] = 1; +}} +} +}); +Clazz.defineMethod (c$, "findWidth", +function () { +this.max = Clazz.newFloatArray (3, 0); +this.min = Clazz.newFloatArray (3, 0); +this.max[0] = -1.0E30; +this.max[1] = -1.0E30; +this.max[2] = -1.0E30; +this.min[0] = 1e30; +this.min[1] = 1e30; +this.min[2] = 1e30; +for (var i = 0; i < 3; i++) { +for (var j = 0; j < this.npoint; j++) { +var sp = this.points.elementAt (j); +if (sp.coord[i] >= this.max[i]) { +this.max[i] = sp.coord[i]; +}if (sp.coord[i] <= this.min[i]) { +this.min[i] = sp.coord[i]; +}} +} +this.$width[0] = Math.abs (this.max[0] - this.min[0]); +this.$width[1] = Math.abs (this.max[1] - this.min[1]); +this.$width[2] = Math.abs (this.max[2] - this.min[2]); +this.maxwidth = this.$width[0]; +if (this.$width[1] > this.$width[0]) { +this.maxwidth = this.$width[1]; +}if (this.$width[2] > this.$width[1]) { +this.maxwidth = this.$width[2]; +}}); +Clazz.defineMethod (c$, "findScale", +function () { +var dim; +var width; +var height; +if (this.getSize ().width != 0) { +width = this.getSize ().width; +height = this.getSize ().height; +} else { +width = this.prefsize.width; +height = this.prefsize.height; +}if (width < height) { +dim = width; +} else { +dim = height; +}return dim * this.scalefactor / (2 * this.maxwidth); +}); +Clazz.defineMethod (c$, "findCentre", +function () { +this.findWidth (); +this.centre[0] = (this.max[0] + this.min[0]) / 2; +this.centre[1] = (this.max[1] + this.min[1]) / 2; +this.centre[2] = (this.max[2] + this.min[2]) / 2; +}); +Clazz.overrideMethod (c$, "getPreferredSize", +function () { +if (this.prefsize != null) { +return this.prefsize; +} else { +return new java.awt.Dimension (400, 400); +}}); +Clazz.overrideMethod (c$, "getMinimumSize", +function () { +return this.getPreferredSize (); +}); +Clazz.overrideMethod (c$, "update", +function (g) { +this.paint (g); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "PaintComponent", +function (g) { +if (this.points == null) { +g.setFont ( new java.awt.Font ("Verdana", 0, 18)); +g.drawString (jalview.util.MessageManager.getString ("label.calculating_pca") + "....", 20, Clazz.doubleToInt (this.getSize ().height / 2)); +} else { +if ((this.img == null) || (this.prefsize.width != this.getSize ().width) || (this.prefsize.height != this.getSize ().height)) { +this.prefsize.width = this.getSize ().width; +this.prefsize.height = this.getSize ().height; +this.scale = this.findScale (); +this.img = this.createImage (this.getSize ().width, this.getSize ().height); +this.ig = this.img.getGraphics (); +}this.drawBackground (this.ig, java.awt.Color.black); +this.drawScene (this.ig); +if (this.$drawAxes == true) { +this.drawAxes (this.ig); +}if (this.tooltip != null) { +this.ig.setColor (java.awt.Color.red); +this.ig.drawString (this.tooltip, this.toolx, this.tooly); +}g.drawImage (this.img, 0, 0, this); +}}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawAxes", +function (g) { +g.setColor (java.awt.Color.yellow); +for (var i = 0; i < 3; i++) { +g.drawLine (Clazz.doubleToInt (this.getSize ().width / 2), Clazz.doubleToInt (this.getSize ().height / 2), Clazz.floatToInt (this.axes[i][0] * this.scale * this.max[0] + Clazz.doubleToInt (this.getSize ().width / 2)), Clazz.floatToInt (this.axes[i][1] * this.scale * this.max[1] + Clazz.doubleToInt (this.getSize ().height / 2))); +} +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawBackground", +function (g, col) { +g.setColor (col); +g.fillRect (0, 0, this.prefsize.width, this.prefsize.height); +}, "java.awt.Graphics,java.awt.Color"); +Clazz.defineMethod (c$, "drawScene", +function (g) { +var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); +var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +var x = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; +var y = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; +var z = sp.coord[1] - this.centre[2]; +if (this.av.getSequenceColour (sp.sequence) === java.awt.Color.black) { +g.setColor (java.awt.Color.white); +} else { +g.setColor (this.av.getSequenceColour (sp.sequence)); +}if (this.av.getSelectionGroup () != null) { +if (this.av.getSelectionGroup ().getSequences (null).contains ((this.points.elementAt (i)).sequence)) { +g.setColor (java.awt.Color.gray); +}}if (z < 0) { +g.setColor (g.getColor ().darker ()); +}g.fillRect (x - 3, y - 3, 6, 6); +if (this.$showLabels) { +g.setColor (java.awt.Color.red); +g.drawString ((this.points.elementAt (i)).sequence.getName (), x - 3, y - 4); +}} +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "minimumsize", +function () { +return this.prefsize; +}); +Clazz.defineMethod (c$, "preferredsize", +function () { +return this.prefsize; +}); +Clazz.overrideMethod (c$, "keyTyped", +function (evt) { +}, "java.awt.event.KeyEvent"); +Clazz.overrideMethod (c$, "keyReleased", +function (evt) { +}, "java.awt.event.KeyEvent"); +Clazz.overrideMethod (c$, "keyPressed", +function (evt) { +if (evt.getKeyCode () == 38) { +this.scalefactor = (this.scalefactor * 1.1); +this.scale = this.findScale (); +} else if (evt.getKeyCode () == 40) { +this.scalefactor = (this.scalefactor * 0.9); +this.scale = this.findScale (); +} else if (evt.getKeyChar () == 's') { +System.err.println ("DEBUG: Rectangle selection"); +if (this.rectx2 != -1 && this.recty2 != -1) { +this.rectSelect (this.rectx1, this.recty1, this.rectx2, this.recty2); +}}this.repaint (); +}, "java.awt.event.KeyEvent"); +Clazz.defineMethod (c$, "printPoints", +function () { +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +jalview.util.Format.printLong (System.out, "%5d ", i); +for (var j = 0; j < 3; j++) { +jalview.util.Format.printDouble (System.out, "%13.3f ", sp.coord[j]); +} +System.out.println (); +} +}); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +var x = evt.getX (); +var y = evt.getY (); +this.mx = x; +this.my = y; +this.omx = this.mx; +this.omy = this.my; +this.startx = x; +this.starty = y; +this.rectx1 = x; +this.recty1 = y; +this.rectx2 = -1; +this.recty2 = -1; +var found = this.findPoint (x, y); +if (found != null) { +if (this.av.getSelectionGroup () != null) { +this.av.getSelectionGroup ().addOrRemove (found, true); +this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); +} else { +this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); +this.av.getSelectionGroup ().addOrRemove (found, true); +this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); +}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); +this.av.sendSelection (); +}this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +var found = this.findPoint (evt.getX (), evt.getY ()); +if (found == null) { +this.tooltip = null; +} else { +this.tooltip = found.getName (); +this.toolx = evt.getX (); +this.tooly = evt.getY (); +}this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +this.mx = evt.getX (); +this.my = evt.getY (); +this.rotmat.setIdentity (); +this.rotmat.rotate (this.my - this.omy, 'x'); +this.rotmat.rotate (this.mx - this.omx, 'y'); +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +sp.coord[0] -= this.centre[0]; +sp.coord[1] -= this.centre[1]; +sp.coord[2] -= this.centre[2]; +sp.coord = this.rotmat.vectorMultiply (sp.coord); +sp.coord[0] += this.centre[0]; +sp.coord[1] += this.centre[1]; +sp.coord[2] += this.centre[2]; +} +for (var i = 0; i < 3; i++) { +this.axes[i] = this.rotmat.vectorMultiply (this.axes[i]); +} +this.omx = this.mx; +this.omy = this.my; +this.paint (this.getGraphics ()); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "rectSelect", +function (x1, y1, x2, y2) { +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +var tmp1 = Clazz.doubleToInt ((sp.coord[0] - this.centre[0]) * this.scale + this.getSize ().width / 2.0); +var tmp2 = Clazz.doubleToInt ((sp.coord[1] - this.centre[1]) * this.scale + this.getSize ().height / 2.0); +if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) { +if (this.av != null) { +if (!this.av.getSelectionGroup ().getSequences (null).contains (sp.sequence)) { +this.av.getSelectionGroup ().addSequence (sp.sequence, true); +}}}} +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "findPoint", +function (x, y) { +var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); +var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); +var found = -1; +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +var px = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; +var py = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; +if (Math.abs (px - x) < 3 && Math.abs (py - y) < 3) { +found = i; +}} +if (found != -1) { +return (this.points.elementAt (found)).sequence; +} else { +return null; +}}, "~N,~N"); +}); diff --git a/bin/jalview/appletgui/ScalePanel.js b/bin/jalview/appletgui/ScalePanel.js index eddee91..755df0a 100644 --- a/bin/jalview/appletgui/ScalePanel.js +++ b/bin/jalview/appletgui/ScalePanel.js @@ -1,248 +1,248 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.ScalePanel", ["awt2swing.MenuItem", "$.PopupMenu", "jalview.datamodel.SequenceGroup", "jalview.util.MessageManager", "java.awt.Color", "java.awt.event.ActionListener"], function () { -c$ = Clazz.decorateAsClass (function () { -this.offy = 4; -this.$width = 0; -this.av = null; -this.ap = null; -this.stretchingGroup = false; -this.min = 0; -this.max = 0; -this.mouseDragging = false; -this.reveal = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "ScalePanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener]); -Clazz.makeConstructor (c$, -function (av, ap) { -Clazz.superConstructor (this, jalview.appletgui.ScalePanel, []); -this.setName ("scalePanel"); -this.setLayout (null); -this.av = av; -this.ap = ap; -this.addMouseListener (this); -this.addMouseMotionListener (this); -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -var x = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); -var res; -if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (x); -} else { -res = x; -}this.min = res; -this.max = res; -if ((evt.getModifiers () & 4) == 4) { -var pop = new awt2swing.PopupMenu (); -if (this.reveal != null) { -var item = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.reveal")); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.ScalePanel$1") ? 0 : jalview.appletgui.ScalePanel.$ScalePanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.ScalePanel$1, this, null))); -pop.add (item); -if (this.av.getColumnSelection ().hasManyHiddenColumns ()) { -item = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.reveal_all")); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.ScalePanel$2") ? 0 : jalview.appletgui.ScalePanel.$ScalePanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.ScalePanel$2, this, null))); -pop.add (item); -}this.add (pop); -pop.show (this, evt.getX (), evt.getY ()); -} else if (this.av.getColumnSelection ().contains (res)) { -var item = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.hide_columns")); -item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.ScalePanel$3") ? 0 : jalview.appletgui.ScalePanel.$ScalePanel$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.ScalePanel$3, this, Clazz.cloneFinals ("res", res)))); -pop.add (item); -this.add (pop); -pop.show (this, evt.getX (), evt.getY ()); -}} else { -if (!evt.isControlDown () && !evt.isShiftDown ()) { -this.av.getColumnSelection ().clear (); -}this.av.getColumnSelection ().addElement (res); -var sg = new jalview.datamodel.SequenceGroup (); -for (var i = 0; i < this.av.getAlignment ().getSequences ().size (); i++) { -sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false); -} -sg.setStartRes (res); -sg.setEndRes (res); -this.av.setSelectionGroup (sg); -if (evt.isShiftDown ()) { -var min = Math.min (this.av.getColumnSelection ().getMin (), res); -var max = Math.max (this.av.getColumnSelection ().getMax (), res); -for (var i = min; i < max; i++) { -this.av.getColumnSelection ().addElement (i); -} -sg.setStartRes (min); -sg.setEndRes (max); -}}this.ap.paintAlignment (true); -this.av.sendSelection (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.mouseDragging = false; -var res = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); -if (res > this.av.getAlignment ().getWidth ()) { -res = this.av.getAlignment ().getWidth () - 1; -}if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -}if (!this.stretchingGroup) { -this.ap.paintAlignment (false); -return; -}var sg = this.av.getSelectionGroup (); -if (res > sg.getStartRes ()) { -sg.setEndRes (res); -} else if (res < sg.getStartRes ()) { -sg.setStartRes (res); -}this.stretchingGroup = false; -this.ap.paintAlignment (false); -this.av.sendSelection (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -this.mouseDragging = true; -var res = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); -if (res < 0) { -res = 0; -}if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -}if (res > this.av.getAlignment ().getWidth ()) { -res = this.av.getAlignment ().getWidth () - 1; -}if (res < this.min) { -this.min = res; -}if (res > this.max) { -this.max = res; -}var sg = this.av.getSelectionGroup (); -if (sg != null) { -this.stretchingGroup = true; -if (!this.av.getColumnSelection ().contains (res)) { -this.av.getColumnSelection ().addElement (res); -}if (res > sg.getStartRes ()) { -sg.setEndRes (res); -}if (res < sg.getStartRes ()) { -sg.setStartRes (res); -}var col; -for (var i = this.min; i <= this.max; i++) { -col = this.av.getColumnSelection ().adjustForHiddenColumns (i); -if ((col < sg.getStartRes ()) || (col > sg.getEndRes ())) { -this.av.getColumnSelection ().removeElement (col); -} else { -this.av.getColumnSelection ().addElement (col); -}} -this.ap.paintAlignment (false); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -if (this.mouseDragging) { -this.ap.seqPanel.scrollCanvas (null); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -if (this.mouseDragging) { -this.ap.seqPanel.scrollCanvas (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -if (!this.av.hasHiddenColumns ()) { -return; -}var res = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -this.reveal = null; -for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { -if (res + 1 == region[0] || res - 1 == region[1]) { -this.reveal = region; -break; -}} -this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.av.getWrapAlignment ()) return; -this.drawScale (g, this.av.getStartRes (), this.av.getEndRes (), this.getSize ().width, this.getSize ().height); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawScale", -function (gg, startx, endx, width, height) { -gg.setFont (this.av.getFont ()); -gg.setColor (java.awt.Color.white); -gg.fillRect (0, 0, width, height); -gg.setColor (java.awt.Color.black); -var cs = this.av.getColumnSelection (); -gg.setColor ( new java.awt.Color (220, 0, 0)); -var avcharWidth = this.av.getCharWidth (); -var avcharHeight = this.av.getCharHeight (); -for (var i = 0; i < cs.size (); i++) { -var sel = cs.columnAt (i); -if (this.av.hasHiddenColumns ()) { -sel = this.av.getColumnSelection ().findColumnPosition (sel); -}if ((sel >= startx) && (sel <= endx)) { -gg.fillRect ((sel - startx) * avcharWidth, 0, avcharWidth, this.getSize ().height); -}} -gg.setColor (java.awt.Color.black); -var scalestartx = (Clazz.doubleToInt (startx / 10)) * 10; -var fm = gg.getFontMetrics (this.av.getFont ()); -var y = avcharHeight - fm.getDescent (); -if ((scalestartx % 10) == 0) { -scalestartx += 5; -}var string; -var maxX = 0; -for (var i = scalestartx; i < endx; i += 5) { -if ((i % 10) == 0) { -string = String.valueOf (this.av.getColumnSelection ().adjustForHiddenColumns (i)); -if ((i - startx - 1) * avcharWidth > maxX) { -gg.drawString (string, (i - startx - 1) * avcharWidth, y); -maxX = (i - startx + 1) * avcharWidth + fm.stringWidth (string); -}gg.drawLine (((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + 2, ((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + (fm.getDescent () * 2)); -} else { -gg.drawLine (((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + fm.getDescent (), ((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + (fm.getDescent () * 2)); -}} -if (this.av.hasHiddenColumns ()) { -gg.setColor (java.awt.Color.blue); -var res; -if (this.av.getShowHiddenMarkers ()) { -for (var i = 0; i < this.av.getColumnSelection ().getHiddenColumns ().size (); i++) { -res = this.av.getColumnSelection ().findHiddenRegionPosition (i) - startx; -if (res < 0 || res > endx - scalestartx) { -continue; -}gg.fillPolygon ( Clazz.newIntArray (-1, [res * avcharWidth - Clazz.doubleToInt (avcharHeight / 4), res * avcharWidth + Clazz.doubleToInt (avcharHeight / 4), res * avcharWidth]), Clazz.newIntArray (-1, [y - Clazz.doubleToInt (avcharHeight / 2), y - Clazz.doubleToInt (avcharHeight / 2), y + 8]), 3); -} -}if (this.reveal != null && this.reveal[0] > startx && this.reveal[0] < endx) { -gg.drawString (jalview.util.MessageManager.getString ("label.reveal_columns"), this.reveal[0] * avcharWidth, 0); -}}}, "java.awt.Graphics,~N,~N,~N,~N"); -c$.$ScalePanel$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "ScalePanel$1", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.ScalePanel"].av.showColumn (this.b$["jalview.appletgui.ScalePanel"].reveal[0]); -this.b$["jalview.appletgui.ScalePanel"].reveal = null; -this.b$["jalview.appletgui.ScalePanel"].ap.paintAlignment (true); -if (this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel != null) { -this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel.updateOverviewImage (); -}}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$ScalePanel$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "ScalePanel$2", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.ScalePanel"].av.showAllHiddenColumns (); -this.b$["jalview.appletgui.ScalePanel"].reveal = null; -this.b$["jalview.appletgui.ScalePanel"].ap.paintAlignment (true); -if (this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel != null) { -this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel.updateOverviewImage (); -}}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$ScalePanel$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "ScalePanel$3", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -this.b$["jalview.appletgui.ScalePanel"].av.hideColumns (this.f$.res, this.f$.res); -if (this.b$["jalview.appletgui.ScalePanel"].av.getSelectionGroup () != null && this.b$["jalview.appletgui.ScalePanel"].av.getSelectionGroup ().getSize () == this.b$["jalview.appletgui.ScalePanel"].av.getAlignment ().getHeight ()) { -this.b$["jalview.appletgui.ScalePanel"].av.setSelectionGroup (null); -}this.b$["jalview.appletgui.ScalePanel"].ap.paintAlignment (true); -if (this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel != null) { -this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel.updateOverviewImage (); -}}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener"], "jalview.appletgui.ScalePanel", ["awt2swing.MenuItem", "$.PopupMenu", "jalview.datamodel.SequenceGroup", "jalview.util.MessageManager", "java.awt.Color", "java.awt.event.ActionListener"], function () { +c$ = Clazz.decorateAsClass (function () { +this.offy = 4; +this.$width = 0; +this.av = null; +this.ap = null; +this.stretchingGroup = false; +this.min = 0; +this.max = 0; +this.mouseDragging = false; +this.reveal = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "ScalePanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener]); +Clazz.makeConstructor (c$, +function (av, ap) { +Clazz.superConstructor (this, jalview.appletgui.ScalePanel, []); +this.setName ("scalePanel"); +this.setLayout (null); +this.av = av; +this.ap = ap; +this.addMouseListener (this); +this.addMouseMotionListener (this); +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +var x = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); +var res; +if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (x); +} else { +res = x; +}this.min = res; +this.max = res; +if ((evt.getModifiers () & 4) == 4) { +var pop = new awt2swing.PopupMenu (); +if (this.reveal != null) { +var item = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.reveal")); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.ScalePanel$1") ? 0 : jalview.appletgui.ScalePanel.$ScalePanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.ScalePanel$1, this, null))); +pop.add (item); +if (this.av.getColumnSelection ().hasManyHiddenColumns ()) { +item = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("action.reveal_all")); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.ScalePanel$2") ? 0 : jalview.appletgui.ScalePanel.$ScalePanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.ScalePanel$2, this, null))); +pop.add (item); +}this.add (pop); +pop.show (this, evt.getX (), evt.getY ()); +} else if (this.av.getColumnSelection ().contains (res)) { +var item = new awt2swing.MenuItem (jalview.util.MessageManager.getString ("label.hide_columns")); +item.addActionListener (((Clazz.isClassDefined ("jalview.appletgui.ScalePanel$3") ? 0 : jalview.appletgui.ScalePanel.$ScalePanel$3$ ()), Clazz.innerTypeInstance (jalview.appletgui.ScalePanel$3, this, Clazz.cloneFinals ("res", res)))); +pop.add (item); +this.add (pop); +pop.show (this, evt.getX (), evt.getY ()); +}} else { +if (!evt.isControlDown () && !evt.isShiftDown ()) { +this.av.getColumnSelection ().clear (); +}this.av.getColumnSelection ().addElement (res); +var sg = new jalview.datamodel.SequenceGroup (); +for (var i = 0; i < this.av.getAlignment ().getSequences ().size (); i++) { +sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false); +} +sg.setStartRes (res); +sg.setEndRes (res); +this.av.setSelectionGroup (sg); +if (evt.isShiftDown ()) { +var min = Math.min (this.av.getColumnSelection ().getMin (), res); +var max = Math.max (this.av.getColumnSelection ().getMax (), res); +for (var i = min; i < max; i++) { +this.av.getColumnSelection ().addElement (i); +} +sg.setStartRes (min); +sg.setEndRes (max); +}}this.ap.paintAlignment (true); +this.av.sendSelection (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.mouseDragging = false; +var res = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); +if (res > this.av.getAlignment ().getWidth ()) { +res = this.av.getAlignment ().getWidth () - 1; +}if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +}if (!this.stretchingGroup) { +this.ap.paintAlignment (false); +return; +}var sg = this.av.getSelectionGroup (); +if (res > sg.getStartRes ()) { +sg.setEndRes (res); +} else if (res < sg.getStartRes ()) { +sg.setStartRes (res); +}this.stretchingGroup = false; +this.ap.paintAlignment (false); +this.av.sendSelection (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +this.mouseDragging = true; +var res = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); +if (res < 0) { +res = 0; +}if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +}if (res > this.av.getAlignment ().getWidth ()) { +res = this.av.getAlignment ().getWidth () - 1; +}if (res < this.min) { +this.min = res; +}if (res > this.max) { +this.max = res; +}var sg = this.av.getSelectionGroup (); +if (sg != null) { +this.stretchingGroup = true; +if (!this.av.getColumnSelection ().contains (res)) { +this.av.getColumnSelection ().addElement (res); +}if (res > sg.getStartRes ()) { +sg.setEndRes (res); +}if (res < sg.getStartRes ()) { +sg.setStartRes (res); +}var col; +for (var i = this.min; i <= this.max; i++) { +col = this.av.getColumnSelection ().adjustForHiddenColumns (i); +if ((col < sg.getStartRes ()) || (col > sg.getEndRes ())) { +this.av.getColumnSelection ().removeElement (col); +} else { +this.av.getColumnSelection ().addElement (col); +}} +this.ap.paintAlignment (false); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +if (this.mouseDragging) { +this.ap.seqPanel.scrollCanvas (null); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +if (this.mouseDragging) { +this.ap.seqPanel.scrollCanvas (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +if (!this.av.hasHiddenColumns ()) { +return; +}var res = (Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ())) + this.av.getStartRes (); +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +this.reveal = null; +for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { +if (res + 1 == region[0] || res - 1 == region[1]) { +this.reveal = region; +break; +}} +this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.av.getWrapAlignment ()) return; +this.drawScale (g, this.av.getStartRes (), this.av.getEndRes (), this.getSize ().width, this.getSize ().height); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawScale", +function (gg, startx, endx, width, height) { +gg.setFont (this.av.getFont ()); +gg.setColor (java.awt.Color.white); +gg.fillRect (0, 0, width, height); +gg.setColor (java.awt.Color.black); +var cs = this.av.getColumnSelection (); +gg.setColor ( new java.awt.Color (220, 0, 0)); +var avcharWidth = this.av.getCharWidth (); +var avcharHeight = this.av.getCharHeight (); +for (var i = 0; i < cs.size (); i++) { +var sel = cs.columnAt (i); +if (this.av.hasHiddenColumns ()) { +sel = this.av.getColumnSelection ().findColumnPosition (sel); +}if ((sel >= startx) && (sel <= endx)) { +gg.fillRect ((sel - startx) * avcharWidth, 0, avcharWidth, this.getSize ().height); +}} +gg.setColor (java.awt.Color.black); +var scalestartx = (Clazz.doubleToInt (startx / 10)) * 10; +var fm = gg.getFontMetrics (this.av.getFont ()); +var y = avcharHeight - fm.getDescent (); +if ((scalestartx % 10) == 0) { +scalestartx += 5; +}var string; +var maxX = 0; +for (var i = scalestartx; i < endx; i += 5) { +if ((i % 10) == 0) { +string = String.valueOf (this.av.getColumnSelection ().adjustForHiddenColumns (i)); +if ((i - startx - 1) * avcharWidth > maxX) { +gg.drawString (string, (i - startx - 1) * avcharWidth, y); +maxX = (i - startx + 1) * avcharWidth + fm.stringWidth (string); +}gg.drawLine (((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + 2, ((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + (fm.getDescent () * 2)); +} else { +gg.drawLine (((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + fm.getDescent (), ((i - startx - 1) * avcharWidth) + (Clazz.doubleToInt (avcharWidth / 2)), y + (fm.getDescent () * 2)); +}} +if (this.av.hasHiddenColumns ()) { +gg.setColor (java.awt.Color.blue); +var res; +if (this.av.getShowHiddenMarkers ()) { +for (var i = 0; i < this.av.getColumnSelection ().getHiddenColumns ().size (); i++) { +res = this.av.getColumnSelection ().findHiddenRegionPosition (i) - startx; +if (res < 0 || res > endx - scalestartx) { +continue; +}gg.fillPolygon ( Clazz.newIntArray (-1, [res * avcharWidth - Clazz.doubleToInt (avcharHeight / 4), res * avcharWidth + Clazz.doubleToInt (avcharHeight / 4), res * avcharWidth]), Clazz.newIntArray (-1, [y - Clazz.doubleToInt (avcharHeight / 2), y - Clazz.doubleToInt (avcharHeight / 2), y + 8]), 3); +} +}if (this.reveal != null && this.reveal[0] > startx && this.reveal[0] < endx) { +gg.drawString (jalview.util.MessageManager.getString ("label.reveal_columns"), this.reveal[0] * avcharWidth, 0); +}}}, "java.awt.Graphics,~N,~N,~N,~N"); +c$.$ScalePanel$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "ScalePanel$1", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.ScalePanel"].av.showColumn (this.b$["jalview.appletgui.ScalePanel"].reveal[0]); +this.b$["jalview.appletgui.ScalePanel"].reveal = null; +this.b$["jalview.appletgui.ScalePanel"].ap.paintAlignment (true); +if (this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel != null) { +this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel.updateOverviewImage (); +}}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$ScalePanel$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "ScalePanel$2", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.ScalePanel"].av.showAllHiddenColumns (); +this.b$["jalview.appletgui.ScalePanel"].reveal = null; +this.b$["jalview.appletgui.ScalePanel"].ap.paintAlignment (true); +if (this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel != null) { +this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel.updateOverviewImage (); +}}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$ScalePanel$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "ScalePanel$3", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +this.b$["jalview.appletgui.ScalePanel"].av.hideColumns (this.f$.res, this.f$.res); +if (this.b$["jalview.appletgui.ScalePanel"].av.getSelectionGroup () != null && this.b$["jalview.appletgui.ScalePanel"].av.getSelectionGroup ().getSize () == this.b$["jalview.appletgui.ScalePanel"].av.getAlignment ().getHeight ()) { +this.b$["jalview.appletgui.ScalePanel"].av.setSelectionGroup (null); +}this.b$["jalview.appletgui.ScalePanel"].ap.paintAlignment (true); +if (this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel != null) { +this.b$["jalview.appletgui.ScalePanel"].ap.overviewPanel.updateOverviewImage (); +}}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/SeqCanvas.js b/bin/jalview/appletgui/SeqCanvas.js index af5372b..ac84c24 100644 --- a/bin/jalview/appletgui/SeqCanvas.js +++ b/bin/jalview/appletgui/SeqCanvas.js @@ -1,411 +1,411 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel"], "jalview.appletgui.SeqCanvas", ["jalview.appletgui.AnnotationPanel", "$.FeatureRenderer", "$.PaintRefresher", "$.SequenceRenderer", "jalview.util.Comparison", "java.awt.Color"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fr = null; -this.sr = null; -this.img = null; -this.gg = null; -this.imgWidth = 0; -this.imgHeight = 0; -this.av = null; -this.searchResults = null; -this.$fastPaint = false; -this.cursorX = 0; -this.cursorY = 0; -this.avcharHeight = 0; -this.avcharWidth = 0; -this.lastsr = 0; -this.LABEL_WEST = 0; -this.LABEL_EAST = 0; -this.annotations = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "SeqCanvas", awt2swing.Panel); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.SeqCanvas, []); -this.av = av; -this.fr = new jalview.appletgui.FeatureRenderer (av); -this.sr = new jalview.appletgui.SequenceRenderer (av); -jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ()); -this.updateViewport (); -}, "jalview.appletgui.AlignViewport"); -Clazz.defineMethod (c$, "updateViewport", -($fz = function () { -this.avcharHeight = this.av.getCharHeight (); -this.avcharWidth = this.av.getCharWidth (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getViewport", -function () { -return this.av; -}); -Clazz.defineMethod (c$, "getFeatureRenderer", -function () { -return this.fr; -}); -Clazz.defineMethod (c$, "getSequenceRenderer", -function () { -return this.sr; -}); -Clazz.defineMethod (c$, "drawNorthScale", -($fz = function (g, startx, endx, ypos) { -var scalestartx = startx - startx % 10 + 10; -g.setColor (java.awt.Color.black); -for (var i = scalestartx; i < endx; i += 10) { -var value = i; -if (this.av.hasHiddenColumns ()) { -value = this.av.getColumnSelection ().adjustForHiddenColumns (value); -}g.drawString (String.valueOf (value), (i - startx - 1) * this.avcharWidth, ypos - (Clazz.doubleToInt (this.avcharHeight / 2))); -g.drawLine (((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), (ypos + 2) - (Clazz.doubleToInt (this.avcharHeight / 2)), ((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), ypos - 2); -} -}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); -Clazz.defineMethod (c$, "drawWestScale", -($fz = function (g, startx, endx, ypos) { -var fm = this.getFontMetrics (this.av.getFont ()); -ypos += this.avcharHeight; -if (this.av.hasHiddenColumns ()) { -startx = this.av.getColumnSelection ().adjustForHiddenColumns (startx); -endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx); -}var maxwidth = this.av.getAlignment ().getWidth (); -if (this.av.hasHiddenColumns ()) { -maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; -}for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) { -var seq = this.av.getAlignment ().getSequenceAt (i); -var index = startx; -var value = -1; -while (index < endx) { -if (jalview.util.Comparison.isGap (seq.getCharAt (index))) { -index++; -continue; -}value = this.av.getAlignment ().getSequenceAt (i).findPosition (index); -break; -} -if (value != -1) { -var x = this.LABEL_WEST - fm.stringWidth (String.valueOf (value)) - Clazz.doubleToInt (this.avcharWidth / 2); -g.drawString (value + "", x, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5))); -}} -}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); -Clazz.defineMethod (c$, "drawEastScale", -($fz = function (g, startx, endx, ypos) { -ypos += this.avcharHeight; -if (this.av.hasHiddenColumns ()) { -endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx); -}var seq; -for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) { -seq = this.av.getAlignment ().getSequenceAt (i); -var index = endx; -var value = -1; -while (index > startx) { -if (jalview.util.Comparison.isGap (seq.getCharAt (index))) { -index--; -continue; -}value = seq.findPosition (index); -break; -} -if (value != -1) { -g.drawString (String.valueOf (value), 0, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5))); -}} -}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); -Clazz.defineMethod (c$, "fastPaint", -function (horizontal, vertical) { -if (this.$fastPaint || this.gg == null) { -return; -}this.updateViewport (); -if (this.lastsr + horizontal != this.av.startRes) { -horizontal = this.av.startRes - this.lastsr; -}this.lastsr = this.av.startRes; -this.$fastPaint = true; -this.gg.copyArea (horizontal * this.avcharWidth, vertical * this.avcharHeight, this.imgWidth - horizontal * this.avcharWidth, this.imgHeight - vertical * this.avcharHeight, -horizontal * this.avcharWidth, -vertical * this.avcharHeight); -var sr = this.av.startRes; -var er = this.av.endRes; -var ss = this.av.startSeq; -var es = this.av.endSeq; -var transX = 0; -var transY = 0; -if (horizontal > 0) { -transX = (er - sr - horizontal) * this.avcharWidth; -sr = er - horizontal; -} else if (horizontal < 0) { -er = sr - horizontal; -} else if (vertical > 0) { -ss = es - vertical; -if (ss < this.av.startSeq) { -ss = this.av.startSeq; -} else { -transY = this.imgHeight - vertical * this.avcharHeight; -}} else if (vertical < 0) { -es = ss - vertical; -if (es > this.av.endSeq) { -es = this.av.endSeq; -}}this.gg.translate (transX, transY); -this.drawPanel (this.gg, sr, er, ss, es, 0); -this.gg.translate (-transX, -transY); -this.repaint (); -}, "~N,~N"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.img != null && (this.$fastPaint || (this.getSize ().width != g.getClipBounds ().width) || (this.getSize ().height != g.getClipBounds ().height))) { -g.drawImage (this.img, 0, 0, this); -this.$fastPaint = false; -return; -}if (this.$fastPaint) { -g.drawImage (this.img, 0, 0, this); -this.$fastPaint = false; -return; -}this.updateViewport (); -this.imgWidth = this.getSize ().width; -this.imgHeight = this.getSize ().height; -this.imgWidth -= this.imgWidth % this.avcharWidth; -this.imgHeight -= this.imgHeight % this.avcharHeight; -if (this.imgWidth < 1 || this.imgHeight < 1) { -return; -}if (this.img == null || this.imgWidth != this.img.getWidth (this) || this.imgHeight != this.img.getHeight (this)) { -this.img = this.createImage (this.imgWidth, this.imgHeight); -this.gg = this.img.getGraphics (); -this.gg.setFont (this.av.getFont ()); -}this.gg.setColor (java.awt.Color.white); -this.gg.fillRect (0, 0, this.imgWidth, this.imgHeight); -if (this.av.getWrapAlignment ()) { -this.drawWrappedPanel (this.gg, this.imgWidth, this.imgHeight, this.av.startRes); -} else { -this.drawPanel (this.gg, this.av.startRes, this.av.endRes, this.av.startSeq, this.av.endSeq, 0); -}g.drawImage (this.img, 0, 0, this); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "getWrappedCanvasWidth", -function (cwidth) { -cwidth -= cwidth % this.av.getCharWidth (); -var fm = this.getFontMetrics (this.av.getFont ()); -this.LABEL_EAST = 0; -this.LABEL_WEST = 0; -if (this.av.getScaleRightWrapped ()) { -this.LABEL_EAST = fm.stringWidth (this.getMask ()); -}if (this.av.getScaleLeftWrapped ()) { -this.LABEL_WEST = fm.stringWidth (this.getMask ()); -}return Clazz.doubleToInt ((cwidth - this.LABEL_EAST - this.LABEL_WEST) / this.av.getCharWidth ()); -}, "~N"); -Clazz.defineMethod (c$, "getMask", -function () { -var mask = "0"; -var maxWidth = 0; -var tmp; -var alignment = this.av.getAlignment (); -for (var i = 0; i < alignment.getHeight (); i++) { -tmp = alignment.getSequenceAt (i).getEnd (); -if (tmp > maxWidth) { -maxWidth = tmp; -}} -for (var i = maxWidth; i > 0; i /= 10) { -mask += "0"; -} -return mask; -}); -Clazz.defineMethod (c$, "drawWrappedPanel", -($fz = function (g, canvasWidth, canvasHeight, startRes) { -var al = this.av.getAlignment (); -var fm = this.getFontMetrics (this.av.getFont ()); -if (this.av.getScaleRightWrapped ()) { -this.LABEL_EAST = fm.stringWidth (this.getMask ()); -}if (this.av.getScaleLeftWrapped ()) { -this.LABEL_WEST = fm.stringWidth (this.getMask ()); -}var hgap = this.avcharHeight; -if (this.av.getScaleAboveWrapped ()) { -hgap += this.avcharHeight; -}var cWidth = Clazz.doubleToInt ((canvasWidth - this.LABEL_EAST - this.LABEL_WEST) / this.avcharWidth); -var cHeight = this.av.getAlignment ().getHeight () * this.avcharHeight; -this.av.setWrappedWidth (cWidth); -this.av.endRes = this.av.startRes + cWidth; -var endx; -var ypos = hgap; -var maxwidth = this.av.getAlignment ().getWidth () - 1; -if (this.av.hasHiddenColumns ()) { -maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; -}while ((ypos <= canvasHeight) && (startRes < maxwidth)) { -endx = startRes + cWidth - 1; -if (endx > maxwidth) { -endx = maxwidth; -}g.setColor (java.awt.Color.black); -if (this.av.getScaleLeftWrapped ()) { -this.drawWestScale (g, startRes, endx, ypos); -}if (this.av.getScaleRightWrapped ()) { -g.translate (canvasWidth - this.LABEL_EAST, 0); -this.drawEastScale (g, startRes, endx, ypos); -g.translate (-(canvasWidth - this.LABEL_EAST), 0); -}g.translate (this.LABEL_WEST, 0); -if (this.av.getScaleAboveWrapped ()) { -this.drawNorthScale (g, startRes, endx, ypos); -}if (this.av.hasHiddenColumns () && this.av.getShowHiddenMarkers ()) { -g.setColor (java.awt.Color.blue); -var res; -for (var i = 0; i < this.av.getColumnSelection ().getHiddenColumns ().size (); i++) { -res = this.av.getColumnSelection ().findHiddenRegionPosition (i) - startRes; -if (res < 0 || res > endx - startRes) { -continue; -}this.gg.fillPolygon ( Clazz.newIntArray (-1, [res * this.avcharWidth - Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth + Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth]), Clazz.newIntArray (-1, [ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)) + 8]), 3); -} -}if (g.getClip () == null) { -g.setClip (0, 0, cWidth * this.avcharWidth, canvasHeight); -}this.drawPanel (g, startRes, endx, 0, al.getHeight (), ypos); -g.setClip (null); -if (this.av.isShowAnnotation ()) { -g.translate (0, cHeight + ypos + 4); -if (this.annotations == null) { -this.annotations = new jalview.appletgui.AnnotationPanel (this.av); -}this.annotations.drawComponent (g, startRes, endx + 1); -g.translate (0, -cHeight - ypos - 4); -}g.translate (-this.LABEL_WEST, 0); -ypos += cHeight + this.getAnnotationHeight () + hgap; -startRes += cWidth; -} -}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); -Clazz.defineMethod (c$, "getAnnotationHeight", -function () { -if (!this.av.isShowAnnotation ()) { -return 0; -}if (this.annotations == null) { -this.annotations = new jalview.appletgui.AnnotationPanel (this.av); -}return this.annotations.adjustPanelHeight (); -}); -Clazz.defineMethod (c$, "drawPanel", -($fz = function (g1, startRes, endRes, startSeq, endSeq, offset) { -if (!this.av.hasHiddenColumns ()) { -this.draw (g1, startRes, endRes, startSeq, endSeq, offset); -} else { -var screenY = 0; -var blockStart = startRes; -var blockEnd = endRes; -if (this.av.hasHiddenColumns ()) { -for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { -var hideStart = region[0]; -var hideEnd = region[1]; -if (hideStart <= blockStart) { -blockStart += (hideEnd - hideStart) + 1; -continue; -}blockEnd = hideStart - 1; -g1.translate (screenY * this.avcharWidth, 0); -this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset); -if (this.av.getShowHiddenMarkers ()) { -g1.setColor (java.awt.Color.blue); -g1.drawLine ((blockEnd - blockStart + 1) * this.avcharWidth - 1, 0 + offset, (blockEnd - blockStart + 1) * this.avcharWidth - 1, (endSeq - startSeq) * this.avcharHeight + offset); -}g1.translate (-screenY * this.avcharWidth, 0); -screenY += blockEnd - blockStart + 1; -blockStart = hideEnd + 1; -} -}if (screenY <= (endRes - startRes)) { -blockEnd = blockStart + (endRes - startRes) - screenY; -g1.translate (screenY * this.avcharWidth, 0); -this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset); -g1.translate (-screenY * this.avcharWidth, 0); -}}}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "draw", -function (g, startRes, endRes, startSeq, endSeq, offset) { -g.setFont (this.av.getFont ()); -this.sr.prepare (g, this.av.isRenderGaps ()); -this.updateViewport (); -var nextSeq; -for (var i = startSeq; i < endSeq; i++) { -nextSeq = this.av.getAlignment ().getSequenceAt (i); -if (nextSeq == null) { -continue; -}this.sr.drawSequence (nextSeq, this.av.getAlignment ().findAllGroups (nextSeq), startRes, endRes, offset + ((i - startSeq) * this.avcharHeight)); -if (this.av.isShowSequenceFeatures ()) { -this.fr.drawSequence (g, nextSeq, startRes, endRes, offset + ((i - startSeq) * this.avcharHeight)); -}if (this.searchResults != null) { -var visibleResults = this.searchResults.getResults (nextSeq, startRes, endRes); -if (visibleResults != null) { -for (var r = 0; r < visibleResults.length; r += 2) { -this.sr.drawHighlightedText (nextSeq, visibleResults[r], visibleResults[r + 1], (visibleResults[r] - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight)); -} -}}if (this.av.cursorMode && this.cursorY == i && this.cursorX >= startRes && this.cursorX <= endRes) { -this.sr.drawCursor (nextSeq, this.cursorX, (this.cursorX - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight)); -}} -if (this.av.getSelectionGroup () != null || this.av.getAlignment ().getGroups ().size () > 0) { -this.drawGroupsBoundaries (g, startRes, endRes, startSeq, endSeq, offset); -}}, "java.awt.Graphics,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "drawGroupsBoundaries", -($fz = function (g, startRes, endRes, startSeq, endSeq, offset) { -var group = this.av.getSelectionGroup (); -var sx = -1; -var sy = -1; -var ex = -1; -var groupIndex = -1; -if ((group == null) && (this.av.getAlignment ().getGroups ().size () > 0)) { -group = this.av.getAlignment ().getGroups ().get (0); -groupIndex = 0; -}if (group != null) { -do { -var oldY = -1; -var i = 0; -var inGroup = false; -var top = -1; -var bottom = -1; -var alHeight = this.av.getAlignment ().getHeight () - 1; -for (i = startSeq; i < endSeq; i++) { -sx = (group.getStartRes () - startRes) * this.avcharWidth; -sy = offset + ((i - startSeq) * this.avcharHeight); -ex = (((group.getEndRes () + 1) - group.getStartRes ()) * this.avcharWidth) - 1; -if (sx + ex < 0 || sx > this.imgWidth) { -continue; -}if ((sx <= (endRes - startRes) * this.avcharWidth) && group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i))) { -if ((bottom == -1) && (i >= alHeight || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i + 1)))) { -bottom = sy + this.avcharHeight; -}if (!inGroup) { -if (((top == -1) && (i == 0)) || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i - 1))) { -top = sy; -}oldY = sy; -inGroup = true; -if (group === this.av.getSelectionGroup ()) { -g.setColor (java.awt.Color.red); -} else { -g.setColor (group.getOutlineColour ()); -}}} else { -if (inGroup) { -if (sx >= 0 && sx < this.imgWidth) { -g.drawLine (sx, oldY, sx, sy); -}if (sx + ex < this.imgWidth) { -g.drawLine (sx + ex, oldY, sx + ex, sy); -}if (sx < 0) { -ex += sx; -sx = 0; -}if (sx + ex > this.imgWidth) { -ex = this.imgWidth; -} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) { -ex = (endRes - startRes + 1) * this.avcharWidth; -}if (top != -1) { -g.drawLine (sx, top, sx + ex, top); -top = -1; -}if (bottom != -1) { -g.drawLine (sx, bottom, sx + ex, bottom); -bottom = -1; -}inGroup = false; -}}} -if (inGroup) { -sy = offset + ((i - startSeq) * this.avcharHeight); -if (sx >= 0 && sx < this.imgWidth) { -g.drawLine (sx, oldY, sx, sy); -}if (sx + ex < this.imgWidth) { -g.drawLine (sx + ex, oldY, sx + ex, sy); -}if (sx < 0) { -ex += sx; -sx = 0; -}if (sx + ex > this.imgWidth) { -ex = this.imgWidth; -} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) { -ex = (endRes - startRes + 1) * this.avcharWidth; -}if (top != -1) { -g.drawLine (sx, top, sx + ex, top); -top = -1; -}if (bottom != -1) { -g.drawLine (sx, bottom - 1, sx + ex, bottom - 1); -bottom = -1; -}inGroup = false; -}groupIndex++; -if (groupIndex >= this.av.getAlignment ().getGroups ().size ()) { -break; -}group = this.av.getAlignment ().getGroups ().get (groupIndex); -} while (groupIndex < this.av.getAlignment ().getGroups ().size ()); -}}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "highlightSearchResults", -function (results) { -this.searchResults = results; -this.repaint (); -}, "jalview.datamodel.SearchResults"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel"], "jalview.appletgui.SeqCanvas", ["jalview.appletgui.AnnotationPanel", "$.FeatureRenderer", "$.PaintRefresher", "$.SequenceRenderer", "jalview.util.Comparison", "java.awt.Color"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fr = null; +this.sr = null; +this.img = null; +this.gg = null; +this.imgWidth = 0; +this.imgHeight = 0; +this.av = null; +this.searchResults = null; +this.$fastPaint = false; +this.cursorX = 0; +this.cursorY = 0; +this.avcharHeight = 0; +this.avcharWidth = 0; +this.lastsr = 0; +this.LABEL_WEST = 0; +this.LABEL_EAST = 0; +this.annotations = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "SeqCanvas", awt2swing.Panel); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.SeqCanvas, []); +this.av = av; +this.fr = new jalview.appletgui.FeatureRenderer (av); +this.sr = new jalview.appletgui.SequenceRenderer (av); +jalview.appletgui.PaintRefresher.Register (this, av.getSequenceSetId ()); +this.updateViewport (); +}, "jalview.appletgui.AlignViewport"); +Clazz.defineMethod (c$, "updateViewport", +($fz = function () { +this.avcharHeight = this.av.getCharHeight (); +this.avcharWidth = this.av.getCharWidth (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getViewport", +function () { +return this.av; +}); +Clazz.defineMethod (c$, "getFeatureRenderer", +function () { +return this.fr; +}); +Clazz.defineMethod (c$, "getSequenceRenderer", +function () { +return this.sr; +}); +Clazz.defineMethod (c$, "drawNorthScale", +($fz = function (g, startx, endx, ypos) { +var scalestartx = startx - startx % 10 + 10; +g.setColor (java.awt.Color.black); +for (var i = scalestartx; i < endx; i += 10) { +var value = i; +if (this.av.hasHiddenColumns ()) { +value = this.av.getColumnSelection ().adjustForHiddenColumns (value); +}g.drawString (String.valueOf (value), (i - startx - 1) * this.avcharWidth, ypos - (Clazz.doubleToInt (this.avcharHeight / 2))); +g.drawLine (((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), (ypos + 2) - (Clazz.doubleToInt (this.avcharHeight / 2)), ((i - startx - 1) * this.avcharWidth) + (Clazz.doubleToInt (this.avcharWidth / 2)), ypos - 2); +} +}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); +Clazz.defineMethod (c$, "drawWestScale", +($fz = function (g, startx, endx, ypos) { +var fm = this.getFontMetrics (this.av.getFont ()); +ypos += this.avcharHeight; +if (this.av.hasHiddenColumns ()) { +startx = this.av.getColumnSelection ().adjustForHiddenColumns (startx); +endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx); +}var maxwidth = this.av.getAlignment ().getWidth (); +if (this.av.hasHiddenColumns ()) { +maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; +}for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) { +var seq = this.av.getAlignment ().getSequenceAt (i); +var index = startx; +var value = -1; +while (index < endx) { +if (jalview.util.Comparison.isGap (seq.getCharAt (index))) { +index++; +continue; +}value = this.av.getAlignment ().getSequenceAt (i).findPosition (index); +break; +} +if (value != -1) { +var x = this.LABEL_WEST - fm.stringWidth (String.valueOf (value)) - Clazz.doubleToInt (this.avcharWidth / 2); +g.drawString (value + "", x, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5))); +}} +}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); +Clazz.defineMethod (c$, "drawEastScale", +($fz = function (g, startx, endx, ypos) { +ypos += this.avcharHeight; +if (this.av.hasHiddenColumns ()) { +endx = this.av.getColumnSelection ().adjustForHiddenColumns (endx); +}var seq; +for (var i = 0; i < this.av.getAlignment ().getHeight (); i++) { +seq = this.av.getAlignment ().getSequenceAt (i); +var index = endx; +var value = -1; +while (index > startx) { +if (jalview.util.Comparison.isGap (seq.getCharAt (index))) { +index--; +continue; +}value = seq.findPosition (index); +break; +} +if (value != -1) { +g.drawString (String.valueOf (value), 0, (ypos + (i * this.avcharHeight)) - (Clazz.doubleToInt (this.avcharHeight / 5))); +}} +}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); +Clazz.defineMethod (c$, "fastPaint", +function (horizontal, vertical) { +if (this.$fastPaint || this.gg == null) { +return; +}this.updateViewport (); +if (this.lastsr + horizontal != this.av.startRes) { +horizontal = this.av.startRes - this.lastsr; +}this.lastsr = this.av.startRes; +this.$fastPaint = true; +this.gg.copyArea (horizontal * this.avcharWidth, vertical * this.avcharHeight, this.imgWidth - horizontal * this.avcharWidth, this.imgHeight - vertical * this.avcharHeight, -horizontal * this.avcharWidth, -vertical * this.avcharHeight); +var sr = this.av.startRes; +var er = this.av.endRes; +var ss = this.av.startSeq; +var es = this.av.endSeq; +var transX = 0; +var transY = 0; +if (horizontal > 0) { +transX = (er - sr - horizontal) * this.avcharWidth; +sr = er - horizontal; +} else if (horizontal < 0) { +er = sr - horizontal; +} else if (vertical > 0) { +ss = es - vertical; +if (ss < this.av.startSeq) { +ss = this.av.startSeq; +} else { +transY = this.imgHeight - vertical * this.avcharHeight; +}} else if (vertical < 0) { +es = ss - vertical; +if (es > this.av.endSeq) { +es = this.av.endSeq; +}}this.gg.translate (transX, transY); +this.drawPanel (this.gg, sr, er, ss, es, 0); +this.gg.translate (-transX, -transY); +this.repaint (); +}, "~N,~N"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.img != null && (this.$fastPaint || (this.getSize ().width != g.getClipBounds ().width) || (this.getSize ().height != g.getClipBounds ().height))) { +g.drawImage (this.img, 0, 0, this); +this.$fastPaint = false; +return; +}if (this.$fastPaint) { +g.drawImage (this.img, 0, 0, this); +this.$fastPaint = false; +return; +}this.updateViewport (); +this.imgWidth = this.getSize ().width; +this.imgHeight = this.getSize ().height; +this.imgWidth -= this.imgWidth % this.avcharWidth; +this.imgHeight -= this.imgHeight % this.avcharHeight; +if (this.imgWidth < 1 || this.imgHeight < 1) { +return; +}if (this.img == null || this.imgWidth != this.img.getWidth (this) || this.imgHeight != this.img.getHeight (this)) { +this.img = this.createImage (this.imgWidth, this.imgHeight); +this.gg = this.img.getGraphics (); +this.gg.setFont (this.av.getFont ()); +}this.gg.setColor (java.awt.Color.white); +this.gg.fillRect (0, 0, this.imgWidth, this.imgHeight); +if (this.av.getWrapAlignment ()) { +this.drawWrappedPanel (this.gg, this.imgWidth, this.imgHeight, this.av.startRes); +} else { +this.drawPanel (this.gg, this.av.startRes, this.av.endRes, this.av.startSeq, this.av.endSeq, 0); +}g.drawImage (this.img, 0, 0, this); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "getWrappedCanvasWidth", +function (cwidth) { +cwidth -= cwidth % this.av.getCharWidth (); +var fm = this.getFontMetrics (this.av.getFont ()); +this.LABEL_EAST = 0; +this.LABEL_WEST = 0; +if (this.av.getScaleRightWrapped ()) { +this.LABEL_EAST = fm.stringWidth (this.getMask ()); +}if (this.av.getScaleLeftWrapped ()) { +this.LABEL_WEST = fm.stringWidth (this.getMask ()); +}return Clazz.doubleToInt ((cwidth - this.LABEL_EAST - this.LABEL_WEST) / this.av.getCharWidth ()); +}, "~N"); +Clazz.defineMethod (c$, "getMask", +function () { +var mask = "0"; +var maxWidth = 0; +var tmp; +var alignment = this.av.getAlignment (); +for (var i = 0; i < alignment.getHeight (); i++) { +tmp = alignment.getSequenceAt (i).getEnd (); +if (tmp > maxWidth) { +maxWidth = tmp; +}} +for (var i = maxWidth; i > 0; i /= 10) { +mask += "0"; +} +return mask; +}); +Clazz.defineMethod (c$, "drawWrappedPanel", +($fz = function (g, canvasWidth, canvasHeight, startRes) { +var al = this.av.getAlignment (); +var fm = this.getFontMetrics (this.av.getFont ()); +if (this.av.getScaleRightWrapped ()) { +this.LABEL_EAST = fm.stringWidth (this.getMask ()); +}if (this.av.getScaleLeftWrapped ()) { +this.LABEL_WEST = fm.stringWidth (this.getMask ()); +}var hgap = this.avcharHeight; +if (this.av.getScaleAboveWrapped ()) { +hgap += this.avcharHeight; +}var cWidth = Clazz.doubleToInt ((canvasWidth - this.LABEL_EAST - this.LABEL_WEST) / this.avcharWidth); +var cHeight = this.av.getAlignment ().getHeight () * this.avcharHeight; +this.av.setWrappedWidth (cWidth); +this.av.endRes = this.av.startRes + cWidth; +var endx; +var ypos = hgap; +var maxwidth = this.av.getAlignment ().getWidth () - 1; +if (this.av.hasHiddenColumns ()) { +maxwidth = this.av.getColumnSelection ().findColumnPosition (maxwidth) - 1; +}while ((ypos <= canvasHeight) && (startRes < maxwidth)) { +endx = startRes + cWidth - 1; +if (endx > maxwidth) { +endx = maxwidth; +}g.setColor (java.awt.Color.black); +if (this.av.getScaleLeftWrapped ()) { +this.drawWestScale (g, startRes, endx, ypos); +}if (this.av.getScaleRightWrapped ()) { +g.translate (canvasWidth - this.LABEL_EAST, 0); +this.drawEastScale (g, startRes, endx, ypos); +g.translate (-(canvasWidth - this.LABEL_EAST), 0); +}g.translate (this.LABEL_WEST, 0); +if (this.av.getScaleAboveWrapped ()) { +this.drawNorthScale (g, startRes, endx, ypos); +}if (this.av.hasHiddenColumns () && this.av.getShowHiddenMarkers ()) { +g.setColor (java.awt.Color.blue); +var res; +for (var i = 0; i < this.av.getColumnSelection ().getHiddenColumns ().size (); i++) { +res = this.av.getColumnSelection ().findHiddenRegionPosition (i) - startRes; +if (res < 0 || res > endx - startRes) { +continue; +}this.gg.fillPolygon ( Clazz.newIntArray (-1, [res * this.avcharWidth - Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth + Clazz.doubleToInt (this.avcharHeight / 4), res * this.avcharWidth]), Clazz.newIntArray (-1, [ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)), ypos - (Clazz.doubleToInt (this.avcharHeight / 2)) + 8]), 3); +} +}if (g.getClip () == null) { +g.setClip (0, 0, cWidth * this.avcharWidth, canvasHeight); +}this.drawPanel (g, startRes, endx, 0, al.getHeight (), ypos); +g.setClip (null); +if (this.av.isShowAnnotation ()) { +g.translate (0, cHeight + ypos + 4); +if (this.annotations == null) { +this.annotations = new jalview.appletgui.AnnotationPanel (this.av); +}this.annotations.drawComponent (g, startRes, endx + 1); +g.translate (0, -cHeight - ypos - 4); +}g.translate (-this.LABEL_WEST, 0); +ypos += cHeight + this.getAnnotationHeight () + hgap; +startRes += cWidth; +} +}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N"); +Clazz.defineMethod (c$, "getAnnotationHeight", +function () { +if (!this.av.isShowAnnotation ()) { +return 0; +}if (this.annotations == null) { +this.annotations = new jalview.appletgui.AnnotationPanel (this.av); +}return this.annotations.adjustPanelHeight (); +}); +Clazz.defineMethod (c$, "drawPanel", +($fz = function (g1, startRes, endRes, startSeq, endSeq, offset) { +if (!this.av.hasHiddenColumns ()) { +this.draw (g1, startRes, endRes, startSeq, endSeq, offset); +} else { +var screenY = 0; +var blockStart = startRes; +var blockEnd = endRes; +if (this.av.hasHiddenColumns ()) { +for (var region, $region = this.av.getColumnSelection ().getHiddenColumns ().iterator (); $region.hasNext () && ((region = $region.next ()) || true);) { +var hideStart = region[0]; +var hideEnd = region[1]; +if (hideStart <= blockStart) { +blockStart += (hideEnd - hideStart) + 1; +continue; +}blockEnd = hideStart - 1; +g1.translate (screenY * this.avcharWidth, 0); +this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset); +if (this.av.getShowHiddenMarkers ()) { +g1.setColor (java.awt.Color.blue); +g1.drawLine ((blockEnd - blockStart + 1) * this.avcharWidth - 1, 0 + offset, (blockEnd - blockStart + 1) * this.avcharWidth - 1, (endSeq - startSeq) * this.avcharHeight + offset); +}g1.translate (-screenY * this.avcharWidth, 0); +screenY += blockEnd - blockStart + 1; +blockStart = hideEnd + 1; +} +}if (screenY <= (endRes - startRes)) { +blockEnd = blockStart + (endRes - startRes) - screenY; +g1.translate (screenY * this.avcharWidth, 0); +this.draw (g1, blockStart, blockEnd, startSeq, endSeq, offset); +g1.translate (-screenY * this.avcharWidth, 0); +}}}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "draw", +function (g, startRes, endRes, startSeq, endSeq, offset) { +g.setFont (this.av.getFont ()); +this.sr.prepare (g, this.av.isRenderGaps ()); +this.updateViewport (); +var nextSeq; +for (var i = startSeq; i < endSeq; i++) { +nextSeq = this.av.getAlignment ().getSequenceAt (i); +if (nextSeq == null) { +continue; +}this.sr.drawSequence (nextSeq, this.av.getAlignment ().findAllGroups (nextSeq), startRes, endRes, offset + ((i - startSeq) * this.avcharHeight)); +if (this.av.isShowSequenceFeatures ()) { +this.fr.drawSequence (g, nextSeq, startRes, endRes, offset + ((i - startSeq) * this.avcharHeight)); +}if (this.searchResults != null) { +var visibleResults = this.searchResults.getResults (nextSeq, startRes, endRes); +if (visibleResults != null) { +for (var r = 0; r < visibleResults.length; r += 2) { +this.sr.drawHighlightedText (nextSeq, visibleResults[r], visibleResults[r + 1], (visibleResults[r] - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight)); +} +}}if (this.av.cursorMode && this.cursorY == i && this.cursorX >= startRes && this.cursorX <= endRes) { +this.sr.drawCursor (nextSeq, this.cursorX, (this.cursorX - startRes) * this.avcharWidth, offset + ((i - startSeq) * this.avcharHeight)); +}} +if (this.av.getSelectionGroup () != null || this.av.getAlignment ().getGroups ().size () > 0) { +this.drawGroupsBoundaries (g, startRes, endRes, startSeq, endSeq, offset); +}}, "java.awt.Graphics,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "drawGroupsBoundaries", +($fz = function (g, startRes, endRes, startSeq, endSeq, offset) { +var group = this.av.getSelectionGroup (); +var sx = -1; +var sy = -1; +var ex = -1; +var groupIndex = -1; +if ((group == null) && (this.av.getAlignment ().getGroups ().size () > 0)) { +group = this.av.getAlignment ().getGroups ().get (0); +groupIndex = 0; +}if (group != null) { +do { +var oldY = -1; +var i = 0; +var inGroup = false; +var top = -1; +var bottom = -1; +var alHeight = this.av.getAlignment ().getHeight () - 1; +for (i = startSeq; i < endSeq; i++) { +sx = (group.getStartRes () - startRes) * this.avcharWidth; +sy = offset + ((i - startSeq) * this.avcharHeight); +ex = (((group.getEndRes () + 1) - group.getStartRes ()) * this.avcharWidth) - 1; +if (sx + ex < 0 || sx > this.imgWidth) { +continue; +}if ((sx <= (endRes - startRes) * this.avcharWidth) && group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i))) { +if ((bottom == -1) && (i >= alHeight || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i + 1)))) { +bottom = sy + this.avcharHeight; +}if (!inGroup) { +if (((top == -1) && (i == 0)) || !group.getSequences (null).contains (this.av.getAlignment ().getSequenceAt (i - 1))) { +top = sy; +}oldY = sy; +inGroup = true; +if (group === this.av.getSelectionGroup ()) { +g.setColor (java.awt.Color.red); +} else { +g.setColor (group.getOutlineColour ()); +}}} else { +if (inGroup) { +if (sx >= 0 && sx < this.imgWidth) { +g.drawLine (sx, oldY, sx, sy); +}if (sx + ex < this.imgWidth) { +g.drawLine (sx + ex, oldY, sx + ex, sy); +}if (sx < 0) { +ex += sx; +sx = 0; +}if (sx + ex > this.imgWidth) { +ex = this.imgWidth; +} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) { +ex = (endRes - startRes + 1) * this.avcharWidth; +}if (top != -1) { +g.drawLine (sx, top, sx + ex, top); +top = -1; +}if (bottom != -1) { +g.drawLine (sx, bottom, sx + ex, bottom); +bottom = -1; +}inGroup = false; +}}} +if (inGroup) { +sy = offset + ((i - startSeq) * this.avcharHeight); +if (sx >= 0 && sx < this.imgWidth) { +g.drawLine (sx, oldY, sx, sy); +}if (sx + ex < this.imgWidth) { +g.drawLine (sx + ex, oldY, sx + ex, sy); +}if (sx < 0) { +ex += sx; +sx = 0; +}if (sx + ex > this.imgWidth) { +ex = this.imgWidth; +} else if (sx + ex >= (endRes - startRes + 1) * this.avcharWidth) { +ex = (endRes - startRes + 1) * this.avcharWidth; +}if (top != -1) { +g.drawLine (sx, top, sx + ex, top); +top = -1; +}if (bottom != -1) { +g.drawLine (sx, bottom - 1, sx + ex, bottom - 1); +bottom = -1; +}inGroup = false; +}groupIndex++; +if (groupIndex >= this.av.getAlignment ().getGroups ().size ()) { +break; +}group = this.av.getAlignment ().getGroups ().get (groupIndex); +} while (groupIndex < this.av.getAlignment ().getGroups ().size ()); +}}, $fz.isPrivate = true, $fz), "java.awt.Graphics,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "highlightSearchResults", +function (results) { +this.searchResults = results; +this.repaint (); +}, "jalview.datamodel.SearchResults"); +}); diff --git a/bin/jalview/appletgui/SeqPanel.js b/bin/jalview/appletgui/SeqPanel.js index d500d0e..7f97353 100644 --- a/bin/jalview/appletgui/SeqPanel.js +++ b/bin/jalview/appletgui/SeqPanel.js @@ -1,962 +1,962 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.structure.SelectionListener", "$.SequenceListener", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.lang.Thread"], "jalview.appletgui.SeqPanel", ["jalview.api.AlignViewportI", "jalview.appletgui.APopupMenu", "$.AlignViewport", "$.PaintRefresher", "$.SeqCanvas", "$.SliderPanel", "$.Tooltip", "jalview.commands.EditCommand", "jalview.datamodel.ColumnSelection", "$.SearchResults", "$.SequenceGroup", "jalview.schemes.ResidueProperties", "jalview.structure.StructureSelectionManager", "jalview.util.Comparison", "$.MappingUtils", "$.MessageManager", "java.awt.BorderLayout", "$.Font", "java.lang.StringBuffer", "$.StringBuilder", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.seqCanvas = null; -this.ap = null; -this.lastres = 0; -this.startseq = 0; -this.av = null; -this.seqEditOccurred = false; -this.scrollThread = null; -this.mouseDragging = false; -this.editingSeqs = false; -this.groupEditing = false; -this.oldSeq = -1; -this.changeEndSeq = false; -this.changeStartSeq = false; -this.changeEndRes = false; -this.changeStartRes = false; -this.stretchGroup = null; -this.keyboardNo1 = null; -this.keyboardNo2 = null; -this.mouseWheelPressed = false; -this.lastMousePress = null; -this.editCommand = null; -this.ssm = null; -this.startWrapBlock = -1; -this.wrappedBlock = -1; -this.lastMessage = null; -this.tooltip = null; -if (!Clazz.isClassDefined ("jalview.appletgui.SeqPanel.ScrollThread")) { -jalview.appletgui.SeqPanel.$SeqPanel$ScrollThread$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "SeqPanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener, jalview.structure.SequenceListener, jalview.structure.SelectionListener]); -Clazz.makeConstructor (c$, -function (avp, p) { -Clazz.superConstructor (this, jalview.appletgui.SeqPanel, []); -this.av = avp; -this.setName ("seqPanel"); -this.seqCanvas = new jalview.appletgui.SeqCanvas (avp); -this.setLayout ( new java.awt.BorderLayout ()); -this.add (this.seqCanvas); -this.ap = p; -this.seqCanvas.addMouseMotionListener (this); -this.seqCanvas.addMouseListener (this); -this.ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet); -this.ssm.addStructureViewerListener (this); -this.ssm.addSelectionListener (this); -this.seqCanvas.repaint (); -}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); -Clazz.defineMethod (c$, "endEditing", -function () { -if (this.editCommand != null && this.editCommand.getSize () > 0) { -this.ap.alignFrame.addHistoryItem (this.editCommand); -this.av.firePropertyChange ("alignment", null, this.av.getAlignment ().getSequences ()); -}this.startseq = -1; -this.lastres = -1; -this.editingSeqs = false; -this.groupEditing = false; -this.keyboardNo1 = null; -this.keyboardNo2 = null; -this.editCommand = null; -}); -Clazz.defineMethod (c$, "setCursorRow", -function () { -this.seqCanvas.cursorY = this.getKeyboardNo1 () - 1; -this.scrollToVisible (); -}); -Clazz.defineMethod (c$, "setCursorColumn", -function () { -this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; -this.scrollToVisible (); -}); -Clazz.defineMethod (c$, "setCursorRowAndColumn", -function () { -if (this.keyboardNo2 == null) { -this.keyboardNo2 = new StringBuffer (); -} else { -this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; -this.seqCanvas.cursorY = this.getKeyboardNo2 () - 1; -this.scrollToVisible (); -}}); -Clazz.defineMethod (c$, "setCursorPosition", -function () { -var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); -this.seqCanvas.cursorX = sequence.findIndex (this.getKeyboardNo1 ()) - 1; -this.scrollToVisible (); -}); -Clazz.defineMethod (c$, "moveCursor", -function (dx, dy) { -this.seqCanvas.cursorX += dx; -this.seqCanvas.cursorY += dy; -if (this.av.hasHiddenColumns () && !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { -var original = this.seqCanvas.cursorX - dx; -var maxWidth = this.av.getAlignment ().getWidth (); -while (!this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX) && this.seqCanvas.cursorX < maxWidth && this.seqCanvas.cursorX > 0) { -this.seqCanvas.cursorX += dx; -} -if (this.seqCanvas.cursorX >= maxWidth || !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { -this.seqCanvas.cursorX = original; -}}this.scrollToVisible (); -}, "~N,~N"); -Clazz.defineMethod (c$, "scrollToVisible", -function () { -if (this.seqCanvas.cursorX < 0) { -this.seqCanvas.cursorX = 0; -} else if (this.seqCanvas.cursorX > this.av.getAlignment ().getWidth () - 1) { -this.seqCanvas.cursorX = this.av.getAlignment ().getWidth () - 1; -}if (this.seqCanvas.cursorY < 0) { -this.seqCanvas.cursorY = 0; -} else if (this.seqCanvas.cursorY > this.av.getAlignment ().getHeight () - 1) { -this.seqCanvas.cursorY = this.av.getAlignment ().getHeight () - 1; -}this.endEditing (); -if (this.av.getWrapAlignment ()) { -this.ap.scrollToWrappedVisible (this.seqCanvas.cursorX); -} else { -while (this.seqCanvas.cursorY < this.av.startSeq) { -this.ap.scrollUp (true); -} -while (this.seqCanvas.cursorY + 1 > this.av.endSeq) { -this.ap.scrollUp (false); -} -while (this.seqCanvas.cursorX < this.av.getColumnSelection ().adjustForHiddenColumns (this.av.startRes)) { -if (!this.ap.scrollRight (false)) { -break; -}} -while (this.seqCanvas.cursorX > this.av.getColumnSelection ().adjustForHiddenColumns (this.av.endRes)) { -if (!this.ap.scrollRight (true)) { -break; -}} -}this.setStatusMessage (this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY), this.seqCanvas.cursorX, this.seqCanvas.cursorY); -this.seqCanvas.repaint (); -}); -Clazz.defineMethod (c$, "setSelectionAreaAtCursor", -function (topLeft) { -var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); -if (this.av.getSelectionGroup () != null) { -var sg = this.av.getSelectionGroup (); -var min = this.av.getAlignment ().getHeight (); -var max = 0; -for (var i = 0; i < sg.getSize (); i++) { -var index = this.av.getAlignment ().findIndex (sg.getSequenceAt (i)); -if (index > max) { -max = index; -}if (index < min) { -min = index; -}} -max++; -if (topLeft) { -sg.setStartRes (this.seqCanvas.cursorX); -if (sg.getEndRes () < this.seqCanvas.cursorX) { -sg.setEndRes (this.seqCanvas.cursorX); -}min = this.seqCanvas.cursorY; -} else { -sg.setEndRes (this.seqCanvas.cursorX); -if (sg.getStartRes () > this.seqCanvas.cursorX) { -sg.setStartRes (this.seqCanvas.cursorX); -}max = this.seqCanvas.cursorY + 1; -}if (min > max) { -this.av.setSelectionGroup (null); -} else { -sg.clear (); -for (var i = min; i < max; i++) { -sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false); -} -}}if (this.av.getSelectionGroup () == null) { -var sg = new jalview.datamodel.SequenceGroup (); -sg.setStartRes (this.seqCanvas.cursorX); -sg.setEndRes (this.seqCanvas.cursorX); -sg.addSequence (sequence, false); -this.av.setSelectionGroup (sg); -}this.ap.paintAlignment (false); -this.av.sendSelection (); -}, "~B"); -Clazz.defineMethod (c$, "insertGapAtCursor", -function (group) { -this.groupEditing = group; -this.startseq = this.seqCanvas.cursorY; -this.lastres = this.seqCanvas.cursorX; -this.editSequence (true, this.seqCanvas.cursorX + this.getKeyboardNo1 ()); -this.endEditing (); -}, "~B"); -Clazz.defineMethod (c$, "deleteGapAtCursor", -function (group) { -this.groupEditing = group; -this.startseq = this.seqCanvas.cursorY; -this.lastres = this.seqCanvas.cursorX + this.getKeyboardNo1 (); -this.editSequence (false, this.seqCanvas.cursorX); -this.endEditing (); -}, "~B"); -Clazz.defineMethod (c$, "numberPressed", -function (value) { -if (this.keyboardNo1 == null) { -this.keyboardNo1 = new StringBuffer (); -}if (this.keyboardNo2 != null) { -this.keyboardNo2.append (value); -} else { -this.keyboardNo1.append (value); -}}, "~S"); -Clazz.defineMethod (c$, "getKeyboardNo1", -function () { -try { -if (this.keyboardNo1 != null) { -var value = Integer.parseInt (this.keyboardNo1.toString ()); -this.keyboardNo1 = null; -return value; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -this.keyboardNo1 = null; -return 1; -}); -Clazz.defineMethod (c$, "getKeyboardNo2", -function () { -try { -if (this.keyboardNo2 != null) { -var value = Integer.parseInt (this.keyboardNo2.toString ()); -this.keyboardNo2 = null; -return value; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -this.keyboardNo2 = null; -return 1; -}); -Clazz.defineMethod (c$, "setStatusMessage", -function (sequence, res, seq) { -var text = new StringBuilder (32); -var seqno = seq == -1 ? "" : " " + (seq + 1); -text.append ("Sequence" + seqno + " ID: " + sequence.getName ()); -var residue = null; -var displayChar = String.valueOf (sequence.getCharAt (res)); -if (this.av.getAlignment ().isNucleotide ()) { -residue = jalview.schemes.ResidueProperties.nucleotideName.get (displayChar); -if (residue != null) { -text.append (" Nucleotide: ").append (residue); -}} else { -residue = "X".equalsIgnoreCase (displayChar) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (displayChar); -if (residue != null) { -text.append (" Residue: ").append (residue); -}}var pos = -1; -if (residue != null) { -pos = sequence.findPosition (res); -text.append (" (").append (Integer.toString (pos)).append (")"); -}this.ap.alignFrame.setStatus (text.toString ()); -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.defineMethod (c$, "setStatusMessage", -($fz = function (results) { -var matches = results.getResults (); -if (!matches.isEmpty ()) { -var m = matches.get (0); -var seq = m.getSequence (); -var sequenceIndex = this.av.getAlignment ().findIndex (seq); -var start = m.getStart () - 1; -this.setStatusMessage (seq, start, sequenceIndex); -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SearchResults"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -this.lastMousePress = evt.getPoint (); -if ((evt.getModifiers () & 8) == 8 && !this.av.MAC) { -this.mouseWheelPressed = true; -return; -}if (evt.isShiftDown () || evt.isControlDown () || evt.isAltDown ()) { -if (evt.isControlDown () || evt.isAltDown ()) { -this.groupEditing = true; -}this.editingSeqs = true; -} else { -this.doMousePressedDefineMode (evt); -return; -}var seq = this.findSeq (evt); -var res = this.findRes (evt); -if (seq < 0 || res < 0) { -return; -}if ((seq < this.av.getAlignment ().getHeight ()) && (res < this.av.getAlignment ().getSequenceAt (seq).getLength ())) { -this.startseq = seq; -this.lastres = res; -} else { -this.startseq = -1; -this.lastres = -1; -}return; -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -var sequence = this.av.getAlignment ().getSequenceAt (this.findSeq (evt)); -if (evt.getClickCount () > 1) { -if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSize () == 1 && this.av.getSelectionGroup ().getEndRes () - this.av.getSelectionGroup ().getStartRes () < 2) { -this.av.setSelectionGroup (null); -}var features = this.findFeaturesAtRes (sequence, sequence.findPosition (this.findRes (evt))); -if (features != null && features.length > 0) { -var highlight = new jalview.datamodel.SearchResults (); -highlight.addResult (sequence, features[0].getBegin (), features[0].getEnd ()); -this.seqCanvas.highlightSearchResults (highlight); -}if (features != null && features.length > 0) { -this.seqCanvas.getFeatureRenderer ().amendFeatures ( Clazz.newArray (-1, [sequence]), features, false, this.ap); -this.seqCanvas.highlightSearchResults (null); -}}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.mouseDragging = false; -this.mouseWheelPressed = false; -this.ap.paintAlignment (true); -if (!this.editingSeqs) { -this.doMouseReleasedDefineMode (evt); -return; -}this.endEditing (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findRes", -function (evt) { -var res = 0; -var x = evt.getX (); -if (this.av.getWrapAlignment ()) { -var hgap = this.av.getCharHeight (); -if (this.av.getScaleAboveWrapped ()) { -hgap += this.av.getCharHeight (); -}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); -var y = evt.getY (); -y -= hgap; -x -= this.seqCanvas.LABEL_WEST; -var cwidth = this.seqCanvas.getWrappedCanvasWidth (this.getSize ().width); -if (cwidth < 1) { -return 0; -}this.wrappedBlock = Clazz.doubleToInt (y / cHeight); -this.wrappedBlock += Clazz.doubleToInt (this.av.getStartRes () / cwidth); -res = this.wrappedBlock * cwidth + Clazz.doubleToInt (x / this.av.getCharWidth ()); -} else { -res = (Clazz.doubleToInt (x / this.av.getCharWidth ())) + this.av.getStartRes (); -}if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -}return res; -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findSeq", -function (evt) { -var sqnum = this.findAlRow (evt); -return (sqnum < 0) ? 0 : sqnum; -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findAlRow", -($fz = function (evt) { -var seq = 0; -var y = evt.getY (); -if (this.av.getWrapAlignment ()) { -var hgap = this.av.getCharHeight (); -if (this.av.getScaleAboveWrapped ()) { -hgap += this.av.getCharHeight (); -}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); -y -= hgap; -seq = Math.min (Clazz.doubleToInt ((y % cHeight) / this.av.getCharHeight ()), this.av.getAlignment ().getHeight () - 1); -if (seq < 0) { -seq = -1; -}} else { -seq = Math.min ((Clazz.doubleToInt (y / this.av.getCharHeight ())) + this.av.getStartSeq (), this.av.getAlignment ().getHeight () - 1); -if (seq < 0) { -seq = -1; -}}return seq; -}, $fz.isPrivate = true, $fz), "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "doMousePressed", -function (evt) { -var seq = this.findSeq (evt); -var res = this.findRes (evt); -if (seq < this.av.getAlignment ().getHeight () && res < this.av.getAlignment ().getSequenceAt (seq).getLength ()) { -this.startseq = seq; -this.lastres = res; -} else { -this.startseq = -1; -this.lastres = -1; -}return; -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseOverSequence", -function (sequence, index, pos) { -var tmp = sequence.hashCode () + index + ""; -if (this.lastMessage == null || !this.lastMessage.equals (tmp)) { -this.ssm.mouseOverSequence (sequence, index, pos, this.av); -}this.lastMessage = tmp; -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.overrideMethod (c$, "highlightSequence", -function (results) { -if (this.av.isFollowHighlight ()) { -if (this.ap.scrollToPosition (results, true)) { -this.ap.alignFrame.repaint (); -}}this.setStatusMessage (results); -this.seqCanvas.highlightSearchResults (results); -}, "jalview.datamodel.SearchResults"); -Clazz.overrideMethod (c$, "getVamsasSource", -function () { -return this.ap == null ? null : this.ap.av; -}); -Clazz.overrideMethod (c$, "updateColours", -function (seq, index) { -System.out.println ("update the seqPanel colours"); -}, "jalview.datamodel.SequenceI,~N"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -var res = this.findRes (evt); -var seq = this.findSeq (evt); -if (seq >= this.av.getAlignment ().getHeight () || seq < 0 || res < 0) { -if (this.tooltip != null) { -this.tooltip.setTip (""); -}return; -}var sequence = this.av.getAlignment ().getSequenceAt (seq); -if (res > sequence.getLength ()) { -if (this.tooltip != null) { -this.tooltip.setTip (""); -}return; -}var respos = sequence.findPosition (res); -if (this.ssm != null) { -this.mouseOverSequence (sequence, res, respos); -}var text = new StringBuilder (); -text.append ("Sequence ").append (Integer.toString (seq + 1)).append (" ID: ").append (sequence.getName ()); -var obj = null; -var ch = String.valueOf (sequence.getCharAt (res)); -if (this.av.getAlignment ().isNucleotide ()) { -obj = jalview.schemes.ResidueProperties.nucleotideName.get (ch); -if (obj != null) { -text.append (" Nucleotide: ").append (obj); -}} else { -obj = "X".equalsIgnoreCase (ch) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (ch); -if (obj != null) { -text.append (" Residue: ").append (obj); -}}if (obj != null) { -text.append (" (").append (Integer.toString (respos)).append (")"); -}this.ap.alignFrame.setStatus (text.toString ()); -var tooltipText = new StringBuilder (); -var groups = this.av.getAlignment ().findAllGroups (sequence); -if (groups != null) { -for (var g = 0; g < groups.length; g++) { -if (groups[g].getStartRes () <= res && groups[g].getEndRes () >= res) { -if (!groups[g].getName ().startsWith ("JTreeGroup") && !groups[g].getName ().startsWith ("JGroup")) { -tooltipText.append (groups[g].getName ()).append (" "); -}if (groups[g].getDescription () != null) { -tooltipText.append (groups[g].getDescription ()); -}tooltipText.append ("\n"); -}} -}var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); -var index = 0; -while (index < allFeatures.length) { -var sf = allFeatures[index]; -tooltipText.append (sf.getType () + " " + sf.begin + ":" + sf.end); -if (sf.getDescription () != null) { -tooltipText.append (" " + sf.getDescription ()); -}if (sf.getValue ("status") != null) { -var status = sf.getValue ("status").toString (); -if (status.length > 0) { -tooltipText.append (" (" + sf.getValue ("status") + ")"); -}}tooltipText.append ("\n"); -index++; -} -if (this.tooltip == null) { -this.tooltip = new jalview.appletgui.Tooltip (tooltipText.toString (), this.seqCanvas); -} else { -this.tooltip.setTip (tooltipText.toString ()); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "findFeaturesAtRes", -function (sequence, res) { -var tmp = new java.util.Vector (); -var features = sequence.getSequenceFeatures (); -if (features != null) { -for (var i = 0; i < features.length; i++) { -if (this.av.getFeaturesDisplayed () == null || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) { -continue; -}if (features[i].featureGroup != null && !this.seqCanvas.fr.checkGroupVisibility (features[i].featureGroup, false)) { -continue; -}if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) { -tmp.addElement (features[i]); -}} -}features = new Array (tmp.size ()); -tmp.copyInto (features); -return features; -}, "jalview.datamodel.SequenceI,~N"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -if (this.mouseWheelPressed) { -var oldWidth = this.av.getCharWidth (); -if (Math.abs (evt.getY () - this.lastMousePress.y) > Math.abs (evt.getX () - this.lastMousePress.x)) { -var fontSize = this.av.font.getSize (); -if (evt.getY () < this.lastMousePress.y && this.av.getCharHeight () > 1) { -fontSize--; -} else if (evt.getY () > this.lastMousePress.y) { -fontSize++; -}if (fontSize < 1) { -fontSize = 1; -}this.av.setFont ( new java.awt.Font (this.av.font.getName (), this.av.font.getStyle (), fontSize)); -this.av.setCharWidth (oldWidth); -} else { -if (evt.getX () < this.lastMousePress.x && this.av.getCharWidth () > 1) { -this.av.setCharWidth (this.av.getCharWidth () - 1); -} else if (evt.getX () > this.lastMousePress.x) { -this.av.setCharWidth (this.av.getCharWidth () + 1); -}if (this.av.getCharWidth () < 1) { -this.av.setCharWidth (1); -}}this.ap.fontChanged (); -var fm = this.getFontMetrics (this.av.getFont ()); -this.av.validCharWidth = fm.charWidth ('M') <= this.av.getCharWidth (); -this.lastMousePress = evt.getPoint (); -this.ap.paintAlignment (false); -this.ap.annotationPanel.image = null; -return; -}if (!this.editingSeqs) { -this.doMouseDraggedDefineMode (evt); -return; -}var res = this.findRes (evt); -if (res < 0) { -res = 0; -}if ((this.lastres == -1) || (this.lastres == res)) { -return; -}if ((res < this.av.getAlignment ().getWidth ()) && (res < this.lastres)) { -this.editSequence (false, res); -} else { -this.editSequence (true, res); -}this.mouseDragging = true; -if (this.scrollThread != null) { -this.scrollThread.setEvent (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "editSequence", -function (insertGap, startres) { -var fixedLeft = -1; -var fixedRight = -1; -var fixedColumns = false; -var sg = this.av.getSelectionGroup (); -var seq = this.av.getAlignment ().getSequenceAt (this.startseq); -if (!this.groupEditing && this.av.hasHiddenRows ()) { -if (this.av.isHiddenRepSequence (seq)) { -sg = this.av.getRepresentedSequences (seq); -this.groupEditing = true; -}}var message = new StringBuffer (); -if (this.groupEditing) { -message.append (jalview.util.MessageManager.getString ("action.edit_group")).append (":"); -if (this.editCommand == null) { -this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.edit_group")); -}} else { -message.append (jalview.util.MessageManager.getString ("label.edit_sequence")).append (" " + seq.getName ()); -var label = seq.getName (); -if (label.length > 10) { -label = label.substring (0, 10); -}if (this.editCommand == null) { -this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.formatMessage ("label.edit_params", Clazz.newArray (-1, [label]))); -}}if (insertGap) { -message.append (" insert "); -} else { -message.append (" delete "); -}message.append (Math.abs (startres - this.lastres) + " gaps."); -this.ap.alignFrame.setStatus (message.toString ()); -if (this.groupEditing || (sg != null && sg.getSequences (this.av.getHiddenRepSequences ()).contains (seq))) { -fixedColumns = true; -if (sg == null) { -if (!this.av.isHiddenRepSequence (seq)) { -this.endEditing (); -return; -}sg = this.av.getRepresentedSequences (seq); -}fixedLeft = sg.getStartRes (); -fixedRight = sg.getEndRes (); -if ((startres < fixedLeft && this.lastres >= fixedLeft) || (startres >= fixedLeft && this.lastres < fixedLeft) || (startres > fixedRight && this.lastres <= fixedRight) || (startres <= fixedRight && this.lastres > fixedRight)) { -this.endEditing (); -return; -}if (fixedLeft > startres) { -fixedRight = fixedLeft - 1; -fixedLeft = 0; -} else if (fixedRight < startres) { -fixedLeft = fixedRight; -fixedRight = -1; -}}if (this.av.hasHiddenColumns ()) { -fixedColumns = true; -var y1 = this.av.getColumnSelection ().getHiddenBoundaryLeft (startres); -var y2 = this.av.getColumnSelection ().getHiddenBoundaryRight (startres); -if ((insertGap && startres > y1 && this.lastres < y1) || (!insertGap && startres < y2 && this.lastres > y2)) { -this.endEditing (); -return; -}if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) { -if (startres >= y2) { -fixedLeft = y2; -} else { -fixedRight = y2 - 1; -}}}if (this.groupEditing) { -var groupSeqs = sg.getSequences (this.av.getHiddenRepSequences ()).toArray ( new Array (0)); -if (insertGap) { -if (sg.getStartRes () == 0 && sg.getEndRes () == fixedRight && sg.getEndRes () == this.av.getAlignment ().getWidth () - 1) { -sg.setEndRes (this.av.getAlignment ().getWidth () + startres - this.lastres); -fixedRight = sg.getEndRes (); -}var blank = false; -for (fixedRight = fixedRight; fixedRight > this.lastres; fixedRight--) { -blank = true; -for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { -for (var j = 0; j < startres - this.lastres; j++) { -if (!jalview.util.Comparison.isGap (gs.getCharAt (fixedRight - j))) { -blank = false; -break; -}} -} -if (blank) { -break; -}} -if (!blank) { -if (sg.getSize () == this.av.getAlignment ().getHeight ()) { -if ((this.av.hasHiddenColumns () && startres < this.av.getColumnSelection ().getHiddenBoundaryRight (startres))) { -this.endEditing (); -return; -}var alWidth = this.av.getAlignment ().getWidth (); -if (this.av.hasHiddenRows ()) { -var hwidth = this.av.getAlignment ().getHiddenSequences ().getWidth (); -if (hwidth > alWidth) { -alWidth = hwidth; -}}sg.setEndRes (sg.getEndRes () + startres - this.lastres); -fixedRight = alWidth + startres - this.lastres; -} else { -this.endEditing (); -return; -}}} else if (!insertGap) { -for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { -for (var j = startres; j < this.lastres; j++) { -if (gs.getLength () <= j) { -continue; -}if (!jalview.util.Comparison.isGap (gs.getCharAt (j))) { -this.endEditing (); -return; -}} -} -}if (insertGap) { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j < startres; j++) { -this.insertChar (j, groupSeqs, fixedRight); -} -} else { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, groupSeqs, startres, startres - this.lastres, this.av.getAlignment (), true); -}} else { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j > startres; j--) { -this.deleteChar (startres, groupSeqs, fixedRight); -} -} else { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, groupSeqs, startres, this.lastres - startres, this.av.getAlignment (), true); -}}} else { -if (insertGap) { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j < startres; j++) { -this.insertChar (j, Clazz.newArray (-1, [seq]), fixedRight); -} -} else { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, Clazz.newArray (-1, [seq]), this.lastres, startres - this.lastres, this.av.getAlignment (), true); -}} else { -if (fixedColumns && fixedRight != -1) { -for (var j = this.lastres; j > startres; j--) { -if (!jalview.util.Comparison.isGap (seq.getCharAt (startres))) { -this.endEditing (); -break; -}this.deleteChar (startres, Clazz.newArray (-1, [seq]), fixedRight); -} -} else { -var max = 0; -for (var m = startres; m < this.lastres; m++) { -if (!jalview.util.Comparison.isGap (seq.getCharAt (m))) { -break; -}max++; -} -if (max > 0) { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seq]), startres, max, this.av.getAlignment (), true); -}}}}this.lastres = startres; -this.seqCanvas.repaint (); -}, "~B,~N"); -Clazz.defineMethod (c$, "insertChar", -function (j, seq, fixedColumn) { -var blankColumn = fixedColumn; -for (var s = 0; s < seq.length; s++) { -for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { -if (jalview.util.Comparison.isGap (seq[s].getCharAt (blankColumn))) { -break; -}} -if (blankColumn <= j) { -blankColumn = fixedColumn; -this.endEditing (); -return; -}} -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, blankColumn, 1, this.av.getAlignment (), true); -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, j, 1, this.av.getAlignment (), true); -}, "~N,~A,~N"); -Clazz.defineMethod (c$, "deleteChar", -function (j, seq, fixedColumn) { -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, j, 1, this.av.getAlignment (), true); -this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, fixedColumn, 1, this.av.getAlignment (), true); -}, "~N,~A,~N"); -Clazz.defineMethod (c$, "doMousePressedDefineMode", -function (evt) { -if (this.scrollThread != null) { -this.scrollThread.running = false; -this.scrollThread = null; -}var res = this.findRes (evt); -var seq = this.findSeq (evt); -this.oldSeq = seq; -this.startWrapBlock = this.wrappedBlock; -if (seq == -1) { -return; -}var sequence = this.av.getAlignment ().getSequenceAt (seq); -if (sequence == null || res > sequence.getLength ()) { -return; -}this.stretchGroup = this.av.getSelectionGroup (); -if (this.stretchGroup == null) { -this.stretchGroup = this.av.getAlignment ().findGroup (sequence); -if (this.stretchGroup != null && res > this.stretchGroup.getStartRes () && res < this.stretchGroup.getEndRes ()) { -this.av.setSelectionGroup (this.stretchGroup); -} else { -this.stretchGroup = null; -}} else if (!this.stretchGroup.getSequences (null).contains (sequence) || this.stretchGroup.getStartRes () > res || this.stretchGroup.getEndRes () < res) { -this.stretchGroup = null; -var allGroups = this.av.getAlignment ().findAllGroups (sequence); -if (allGroups != null) { -for (var i = 0; i < allGroups.length; i++) { -if (allGroups[i].getStartRes () <= res && allGroups[i].getEndRes () >= res) { -this.stretchGroup = allGroups[i]; -break; -}} -}this.av.setSelectionGroup (this.stretchGroup); -}if ((evt.getModifiers () & 4) == 4) { -var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); -var links = null; -if (allFeatures != null) { -for (var i = 0; i < allFeatures.length; i++) { -if (allFeatures[i].links != null) { -if (links == null) { -links = new java.util.Vector (); -}for (var j = 0; j < allFeatures[i].links.size (); j++) { -links.addElement (allFeatures[i].links.elementAt (j)); -} -}} -}var popup = new jalview.appletgui.APopupMenu (this.ap, null, links); -this.add (popup); -popup.show (this, evt.getX (), evt.getY ()); -return; -}if (this.av.cursorMode) { -this.seqCanvas.cursorX = this.findRes (evt); -this.seqCanvas.cursorY = this.findSeq (evt); -this.seqCanvas.repaint (); -return; -}if (this.stretchGroup == null) { -var sg = new jalview.datamodel.SequenceGroup (); -sg.setStartRes (res); -sg.setEndRes (res); -sg.addSequence (sequence, false); -this.av.setSelectionGroup (sg); -this.stretchGroup = sg; -if (this.av.getConservationSelected ()) { -jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.av.getGlobalColourScheme (), "Background"); -}if (this.av.getAbovePIDThreshold ()) { -jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.av.getGlobalColourScheme (), "Background"); -}}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "doMouseReleasedDefineMode", -function (evt) { -if (this.stretchGroup == null) { -return; -}this.stretchGroup.recalcConservation (); -if (this.stretchGroup.cs != null) { -this.stretchGroup.cs.alignmentChanged (this.stretchGroup, this.av.getHiddenRepSequences ()); -if (this.stretchGroup.cs.conservationApplied ()) { -jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); -} else { -jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); -}}this.changeEndRes = false; -this.changeStartRes = false; -this.stretchGroup = null; -jalview.appletgui.PaintRefresher.Refresh (this.ap, this.av.getSequenceSetId ()); -this.ap.paintAlignment (true); -this.av.sendSelection (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "doMouseDraggedDefineMode", -function (evt) { -var res = this.findRes (evt); -var y = this.findSeq (evt); -if (this.wrappedBlock != this.startWrapBlock) { -return; -}if (this.stretchGroup == null) { -return; -}this.mouseDragging = true; -if (y > this.av.getAlignment ().getHeight ()) { -y = this.av.getAlignment ().getHeight () - 1; -}if (res >= this.av.getAlignment ().getWidth ()) { -res = this.av.getAlignment ().getWidth () - 1; -}if (this.stretchGroup.getEndRes () == res) { -this.changeEndRes = true; -} else if (this.stretchGroup.getStartRes () == res) { -this.changeStartRes = true; -}if (res < 0) { -res = 0; -}if (this.changeEndRes) { -if (res > (this.stretchGroup.getStartRes () - 1)) { -this.stretchGroup.setEndRes (res); -}} else if (this.changeStartRes) { -if (res < (this.stretchGroup.getEndRes () + 1)) { -this.stretchGroup.setStartRes (res); -}}var dragDirection = 0; -if (y > this.oldSeq) { -dragDirection = 1; -} else if (y < this.oldSeq) { -dragDirection = -1; -}while ((y != this.oldSeq) && (this.oldSeq > -1) && (y < this.av.getAlignment ().getHeight ())) { -var seq = this.av.getAlignment ().getSequenceAt (this.oldSeq); -this.oldSeq += dragDirection; -if (this.oldSeq < 0) { -break; -}var nextSeq = this.av.getAlignment ().getSequenceAt (this.oldSeq); -if (this.stretchGroup.getSequences (null).contains (nextSeq)) { -this.stretchGroup.deleteSequence (seq, false); -} else { -if (seq != null) { -this.stretchGroup.addSequence (seq, false); -}this.stretchGroup.addSequence (nextSeq, false); -}} -if (this.oldSeq < 0) { -this.oldSeq = -1; -}if (res > this.av.endRes || res < this.av.startRes || y < this.av.startSeq || y > this.av.endSeq) { -this.mouseExited (evt); -}if (this.scrollThread != null) { -this.scrollThread.setEvent (evt); -}this.seqCanvas.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (e) { -if (this.oldSeq < 0) { -this.oldSeq = 0; -}if (this.scrollThread != null) { -this.scrollThread.running = false; -this.scrollThread = null; -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (e) { -if (this.av.getWrapAlignment ()) { -return; -}if (this.mouseDragging && this.scrollThread == null) { -this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "scrollCanvas", -function (evt) { -if (evt == null) { -if (this.scrollThread != null) { -this.scrollThread.running = false; -this.scrollThread = null; -}this.mouseDragging = false; -} else { -if (this.scrollThread == null) { -this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); -}this.mouseDragging = true; -this.scrollThread.setEvent (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "selection", -function (seqsel, colsel, source) { -if (this.av != null && (this.av === source || !this.av.followSelection || (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).getSequenceSetId ().equals (this.av.getSequenceSetId ())))) { -return; -}if (this.selectionFromTranslation (seqsel, colsel, source)) { -return; -}var repaint = false; -var copycolsel = true; -if (this.av.getSelectionGroup () == null || !this.av.isSelectionGroupChanged (true)) { -var sgroup = null; -if (seqsel != null && seqsel.getSize () > 0) { -if (this.av.getAlignment () == null) { -System.out.println ("Selection message: alignviewport av SeqSetId=" + this.av.getSequenceSetId () + " ViewId=" + this.av.getViewId () + " 's alignment is NULL! returning immediatly."); -return; -}sgroup = seqsel.intersect (this.av.getAlignment (), (this.av.hasHiddenRows ()) ? this.av.getHiddenRepSequences () : null); -if ((sgroup == null || sgroup.getSize () == 0) && (colsel == null || colsel.size () == 0)) { -copycolsel = false; -}}if (sgroup != null && sgroup.getSize () > 0) { -this.av.setSelectionGroup (sgroup); -} else { -this.av.setSelectionGroup (null); -}repaint = this.av.isSelectionGroupChanged (true); -}if (copycolsel && (this.av.getColumnSelection () == null || !this.av.isColSelChanged (true))) { -if (colsel == null || colsel.size () == 0) { -if (this.av.getColumnSelection () != null) { -this.av.getColumnSelection ().clear (); -}} else { -if (this.av.getColumnSelection () == null) { -this.av.setColumnSelection ( new jalview.datamodel.ColumnSelection (colsel)); -} else { -this.av.getColumnSelection ().setElementsFrom (colsel); -}}repaint = new Boolean (repaint | this.av.isColSelChanged (true)).valueOf (); -}if (copycolsel && this.av.hasHiddenColumns () && (this.av.getColumnSelection () == null || this.av.getColumnSelection ().getHiddenColumns () == null)) { -System.err.println ("Bad things"); -}if (repaint) { -this.ap.scalePanelHolder.repaint (); -this.ap.repaint (); -}}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); -Clazz.defineMethod (c$, "scrollTo", -function (row, column) { -row = row < 0 ? this.ap.av.startSeq : row; -column = column < 0 ? this.ap.av.startRes : column; -this.ap.scrollTo (column, column, row, true, true); -}, "~N,~N"); -Clazz.defineMethod (c$, "scrollToRow", -function (row) { -row = row < 0 ? this.ap.av.startSeq : row; -this.ap.scrollTo (this.ap.av.startRes, this.ap.av.startRes, row, true, true); -}, "~N"); -Clazz.defineMethod (c$, "scrollToColumn", -function (column) { -column = column < 0 ? this.ap.av.startRes : column; -this.ap.scrollTo (column, column, this.ap.av.startSeq, true, true); -}, "~N"); -Clazz.defineMethod (c$, "selectionFromTranslation", -function (seqsel, colsel, source) { -if (!(Clazz.instanceOf (source, jalview.api.AlignViewportI))) { -return false; -}var sourceAv = source; -if (sourceAv.getCodingComplement () !== this.av && this.av.getCodingComplement () !== sourceAv) { -return false; -}var sg = jalview.util.MappingUtils.mapSequenceGroup (seqsel, sourceAv, this.av); -this.av.setSelectionGroup (sg); -this.av.isSelectionGroupChanged (true); -var cs = jalview.util.MappingUtils.mapColumnSelection (colsel, sourceAv, this.av); -this.av.setColumnSelection (cs); -this.av.isColSelChanged (true); -this.ap.scalePanelHolder.repaint (); -this.ap.repaint (); -return true; -}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); -c$.$SeqPanel$ScrollThread$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.evt = null; -this.running = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.SeqPanel, "ScrollThread", Thread); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.appletgui.SeqPanel.ScrollThread, []); -this.start (); -}); -Clazz.defineMethod (c$, "setEvent", -function (a) { -this.evt = a; -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "stopScrolling", -function () { -this.running = false; -}); -Clazz.overrideMethod (c$, "run", -function () { -this.running = true; -while (this.running) { -if (this.evt != null) { -if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () < 0 && this.b$["jalview.appletgui.SeqPanel"].av.getStartSeq () > 0) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (true); -}if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().height && this.b$["jalview.appletgui.SeqPanel"].av.getAlignment ().getHeight () > this.b$["jalview.appletgui.SeqPanel"].av.getEndSeq ()) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (false); -}if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () < 0) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (false); -} else if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().width) { -this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (true); -}}try { -Thread.sleep (75); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -} -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.structure.SelectionListener", "$.SequenceListener", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.lang.Thread"], "jalview.appletgui.SeqPanel", ["jalview.api.AlignViewportI", "jalview.appletgui.APopupMenu", "$.AlignViewport", "$.PaintRefresher", "$.SeqCanvas", "$.SliderPanel", "$.Tooltip", "jalview.commands.EditCommand", "jalview.datamodel.ColumnSelection", "$.SearchResults", "$.SequenceGroup", "jalview.schemes.ResidueProperties", "jalview.structure.StructureSelectionManager", "jalview.util.Comparison", "$.MappingUtils", "$.MessageManager", "java.awt.BorderLayout", "$.Font", "java.lang.StringBuffer", "$.StringBuilder", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.seqCanvas = null; +this.ap = null; +this.lastres = 0; +this.startseq = 0; +this.av = null; +this.seqEditOccurred = false; +this.scrollThread = null; +this.mouseDragging = false; +this.editingSeqs = false; +this.groupEditing = false; +this.oldSeq = -1; +this.changeEndSeq = false; +this.changeStartSeq = false; +this.changeEndRes = false; +this.changeStartRes = false; +this.stretchGroup = null; +this.keyboardNo1 = null; +this.keyboardNo2 = null; +this.mouseWheelPressed = false; +this.lastMousePress = null; +this.editCommand = null; +this.ssm = null; +this.startWrapBlock = -1; +this.wrappedBlock = -1; +this.lastMessage = null; +this.tooltip = null; +if (!Clazz.isClassDefined ("jalview.appletgui.SeqPanel.ScrollThread")) { +jalview.appletgui.SeqPanel.$SeqPanel$ScrollThread$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "SeqPanel", awt2swing.Panel, [java.awt.event.MouseMotionListener, java.awt.event.MouseListener, jalview.structure.SequenceListener, jalview.structure.SelectionListener]); +Clazz.makeConstructor (c$, +function (avp, p) { +Clazz.superConstructor (this, jalview.appletgui.SeqPanel, []); +this.av = avp; +this.setName ("seqPanel"); +this.seqCanvas = new jalview.appletgui.SeqCanvas (avp); +this.setLayout ( new java.awt.BorderLayout ()); +this.add (this.seqCanvas); +this.ap = p; +this.seqCanvas.addMouseMotionListener (this); +this.seqCanvas.addMouseListener (this); +this.ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.av.applet); +this.ssm.addStructureViewerListener (this); +this.ssm.addSelectionListener (this); +this.seqCanvas.repaint (); +}, "jalview.appletgui.AlignViewport,jalview.appletgui.AlignmentPanel"); +Clazz.defineMethod (c$, "endEditing", +function () { +if (this.editCommand != null && this.editCommand.getSize () > 0) { +this.ap.alignFrame.addHistoryItem (this.editCommand); +this.av.firePropertyChange ("alignment", null, this.av.getAlignment ().getSequences ()); +}this.startseq = -1; +this.lastres = -1; +this.editingSeqs = false; +this.groupEditing = false; +this.keyboardNo1 = null; +this.keyboardNo2 = null; +this.editCommand = null; +}); +Clazz.defineMethod (c$, "setCursorRow", +function () { +this.seqCanvas.cursorY = this.getKeyboardNo1 () - 1; +this.scrollToVisible (); +}); +Clazz.defineMethod (c$, "setCursorColumn", +function () { +this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; +this.scrollToVisible (); +}); +Clazz.defineMethod (c$, "setCursorRowAndColumn", +function () { +if (this.keyboardNo2 == null) { +this.keyboardNo2 = new StringBuffer (); +} else { +this.seqCanvas.cursorX = this.getKeyboardNo1 () - 1; +this.seqCanvas.cursorY = this.getKeyboardNo2 () - 1; +this.scrollToVisible (); +}}); +Clazz.defineMethod (c$, "setCursorPosition", +function () { +var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); +this.seqCanvas.cursorX = sequence.findIndex (this.getKeyboardNo1 ()) - 1; +this.scrollToVisible (); +}); +Clazz.defineMethod (c$, "moveCursor", +function (dx, dy) { +this.seqCanvas.cursorX += dx; +this.seqCanvas.cursorY += dy; +if (this.av.hasHiddenColumns () && !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { +var original = this.seqCanvas.cursorX - dx; +var maxWidth = this.av.getAlignment ().getWidth (); +while (!this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX) && this.seqCanvas.cursorX < maxWidth && this.seqCanvas.cursorX > 0) { +this.seqCanvas.cursorX += dx; +} +if (this.seqCanvas.cursorX >= maxWidth || !this.av.getColumnSelection ().isVisible (this.seqCanvas.cursorX)) { +this.seqCanvas.cursorX = original; +}}this.scrollToVisible (); +}, "~N,~N"); +Clazz.defineMethod (c$, "scrollToVisible", +function () { +if (this.seqCanvas.cursorX < 0) { +this.seqCanvas.cursorX = 0; +} else if (this.seqCanvas.cursorX > this.av.getAlignment ().getWidth () - 1) { +this.seqCanvas.cursorX = this.av.getAlignment ().getWidth () - 1; +}if (this.seqCanvas.cursorY < 0) { +this.seqCanvas.cursorY = 0; +} else if (this.seqCanvas.cursorY > this.av.getAlignment ().getHeight () - 1) { +this.seqCanvas.cursorY = this.av.getAlignment ().getHeight () - 1; +}this.endEditing (); +if (this.av.getWrapAlignment ()) { +this.ap.scrollToWrappedVisible (this.seqCanvas.cursorX); +} else { +while (this.seqCanvas.cursorY < this.av.startSeq) { +this.ap.scrollUp (true); +} +while (this.seqCanvas.cursorY + 1 > this.av.endSeq) { +this.ap.scrollUp (false); +} +while (this.seqCanvas.cursorX < this.av.getColumnSelection ().adjustForHiddenColumns (this.av.startRes)) { +if (!this.ap.scrollRight (false)) { +break; +}} +while (this.seqCanvas.cursorX > this.av.getColumnSelection ().adjustForHiddenColumns (this.av.endRes)) { +if (!this.ap.scrollRight (true)) { +break; +}} +}this.setStatusMessage (this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY), this.seqCanvas.cursorX, this.seqCanvas.cursorY); +this.seqCanvas.repaint (); +}); +Clazz.defineMethod (c$, "setSelectionAreaAtCursor", +function (topLeft) { +var sequence = this.av.getAlignment ().getSequenceAt (this.seqCanvas.cursorY); +if (this.av.getSelectionGroup () != null) { +var sg = this.av.getSelectionGroup (); +var min = this.av.getAlignment ().getHeight (); +var max = 0; +for (var i = 0; i < sg.getSize (); i++) { +var index = this.av.getAlignment ().findIndex (sg.getSequenceAt (i)); +if (index > max) { +max = index; +}if (index < min) { +min = index; +}} +max++; +if (topLeft) { +sg.setStartRes (this.seqCanvas.cursorX); +if (sg.getEndRes () < this.seqCanvas.cursorX) { +sg.setEndRes (this.seqCanvas.cursorX); +}min = this.seqCanvas.cursorY; +} else { +sg.setEndRes (this.seqCanvas.cursorX); +if (sg.getStartRes () > this.seqCanvas.cursorX) { +sg.setStartRes (this.seqCanvas.cursorX); +}max = this.seqCanvas.cursorY + 1; +}if (min > max) { +this.av.setSelectionGroup (null); +} else { +sg.clear (); +for (var i = min; i < max; i++) { +sg.addSequence (this.av.getAlignment ().getSequenceAt (i), false); +} +}}if (this.av.getSelectionGroup () == null) { +var sg = new jalview.datamodel.SequenceGroup (); +sg.setStartRes (this.seqCanvas.cursorX); +sg.setEndRes (this.seqCanvas.cursorX); +sg.addSequence (sequence, false); +this.av.setSelectionGroup (sg); +}this.ap.paintAlignment (false); +this.av.sendSelection (); +}, "~B"); +Clazz.defineMethod (c$, "insertGapAtCursor", +function (group) { +this.groupEditing = group; +this.startseq = this.seqCanvas.cursorY; +this.lastres = this.seqCanvas.cursorX; +this.editSequence (true, this.seqCanvas.cursorX + this.getKeyboardNo1 ()); +this.endEditing (); +}, "~B"); +Clazz.defineMethod (c$, "deleteGapAtCursor", +function (group) { +this.groupEditing = group; +this.startseq = this.seqCanvas.cursorY; +this.lastres = this.seqCanvas.cursorX + this.getKeyboardNo1 (); +this.editSequence (false, this.seqCanvas.cursorX); +this.endEditing (); +}, "~B"); +Clazz.defineMethod (c$, "numberPressed", +function (value) { +if (this.keyboardNo1 == null) { +this.keyboardNo1 = new StringBuffer (); +}if (this.keyboardNo2 != null) { +this.keyboardNo2.append (value); +} else { +this.keyboardNo1.append (value); +}}, "~S"); +Clazz.defineMethod (c$, "getKeyboardNo1", +function () { +try { +if (this.keyboardNo1 != null) { +var value = Integer.parseInt (this.keyboardNo1.toString ()); +this.keyboardNo1 = null; +return value; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +this.keyboardNo1 = null; +return 1; +}); +Clazz.defineMethod (c$, "getKeyboardNo2", +function () { +try { +if (this.keyboardNo2 != null) { +var value = Integer.parseInt (this.keyboardNo2.toString ()); +this.keyboardNo2 = null; +return value; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +this.keyboardNo2 = null; +return 1; +}); +Clazz.defineMethod (c$, "setStatusMessage", +function (sequence, res, seq) { +var text = new StringBuilder (32); +var seqno = seq == -1 ? "" : " " + (seq + 1); +text.append ("Sequence" + seqno + " ID: " + sequence.getName ()); +var residue = null; +var displayChar = String.valueOf (sequence.getCharAt (res)); +if (this.av.getAlignment ().isNucleotide ()) { +residue = jalview.schemes.ResidueProperties.nucleotideName.get (displayChar); +if (residue != null) { +text.append (" Nucleotide: ").append (residue); +}} else { +residue = "X".equalsIgnoreCase (displayChar) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (displayChar); +if (residue != null) { +text.append (" Residue: ").append (residue); +}}var pos = -1; +if (residue != null) { +pos = sequence.findPosition (res); +text.append (" (").append (Integer.toString (pos)).append (")"); +}this.ap.alignFrame.setStatus (text.toString ()); +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.defineMethod (c$, "setStatusMessage", +($fz = function (results) { +var matches = results.getResults (); +if (!matches.isEmpty ()) { +var m = matches.get (0); +var seq = m.getSequence (); +var sequenceIndex = this.av.getAlignment ().findIndex (seq); +var start = m.getStart () - 1; +this.setStatusMessage (seq, start, sequenceIndex); +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SearchResults"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +this.lastMousePress = evt.getPoint (); +if ((evt.getModifiers () & 8) == 8 && !this.av.MAC) { +this.mouseWheelPressed = true; +return; +}if (evt.isShiftDown () || evt.isControlDown () || evt.isAltDown ()) { +if (evt.isControlDown () || evt.isAltDown ()) { +this.groupEditing = true; +}this.editingSeqs = true; +} else { +this.doMousePressedDefineMode (evt); +return; +}var seq = this.findSeq (evt); +var res = this.findRes (evt); +if (seq < 0 || res < 0) { +return; +}if ((seq < this.av.getAlignment ().getHeight ()) && (res < this.av.getAlignment ().getSequenceAt (seq).getLength ())) { +this.startseq = seq; +this.lastres = res; +} else { +this.startseq = -1; +this.lastres = -1; +}return; +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +var sequence = this.av.getAlignment ().getSequenceAt (this.findSeq (evt)); +if (evt.getClickCount () > 1) { +if (this.av.getSelectionGroup () != null && this.av.getSelectionGroup ().getSize () == 1 && this.av.getSelectionGroup ().getEndRes () - this.av.getSelectionGroup ().getStartRes () < 2) { +this.av.setSelectionGroup (null); +}var features = this.findFeaturesAtRes (sequence, sequence.findPosition (this.findRes (evt))); +if (features != null && features.length > 0) { +var highlight = new jalview.datamodel.SearchResults (); +highlight.addResult (sequence, features[0].getBegin (), features[0].getEnd ()); +this.seqCanvas.highlightSearchResults (highlight); +}if (features != null && features.length > 0) { +this.seqCanvas.getFeatureRenderer ().amendFeatures ( Clazz.newArray (-1, [sequence]), features, false, this.ap); +this.seqCanvas.highlightSearchResults (null); +}}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.mouseDragging = false; +this.mouseWheelPressed = false; +this.ap.paintAlignment (true); +if (!this.editingSeqs) { +this.doMouseReleasedDefineMode (evt); +return; +}this.endEditing (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findRes", +function (evt) { +var res = 0; +var x = evt.getX (); +if (this.av.getWrapAlignment ()) { +var hgap = this.av.getCharHeight (); +if (this.av.getScaleAboveWrapped ()) { +hgap += this.av.getCharHeight (); +}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); +var y = evt.getY (); +y -= hgap; +x -= this.seqCanvas.LABEL_WEST; +var cwidth = this.seqCanvas.getWrappedCanvasWidth (this.getSize ().width); +if (cwidth < 1) { +return 0; +}this.wrappedBlock = Clazz.doubleToInt (y / cHeight); +this.wrappedBlock += Clazz.doubleToInt (this.av.getStartRes () / cwidth); +res = this.wrappedBlock * cwidth + Clazz.doubleToInt (x / this.av.getCharWidth ()); +} else { +res = (Clazz.doubleToInt (x / this.av.getCharWidth ())) + this.av.getStartRes (); +}if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +}return res; +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findSeq", +function (evt) { +var sqnum = this.findAlRow (evt); +return (sqnum < 0) ? 0 : sqnum; +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findAlRow", +($fz = function (evt) { +var seq = 0; +var y = evt.getY (); +if (this.av.getWrapAlignment ()) { +var hgap = this.av.getCharHeight (); +if (this.av.getScaleAboveWrapped ()) { +hgap += this.av.getCharHeight (); +}var cHeight = this.av.getAlignment ().getHeight () * this.av.getCharHeight () + hgap + this.seqCanvas.getAnnotationHeight (); +y -= hgap; +seq = Math.min (Clazz.doubleToInt ((y % cHeight) / this.av.getCharHeight ()), this.av.getAlignment ().getHeight () - 1); +if (seq < 0) { +seq = -1; +}} else { +seq = Math.min ((Clazz.doubleToInt (y / this.av.getCharHeight ())) + this.av.getStartSeq (), this.av.getAlignment ().getHeight () - 1); +if (seq < 0) { +seq = -1; +}}return seq; +}, $fz.isPrivate = true, $fz), "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "doMousePressed", +function (evt) { +var seq = this.findSeq (evt); +var res = this.findRes (evt); +if (seq < this.av.getAlignment ().getHeight () && res < this.av.getAlignment ().getSequenceAt (seq).getLength ()) { +this.startseq = seq; +this.lastres = res; +} else { +this.startseq = -1; +this.lastres = -1; +}return; +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseOverSequence", +function (sequence, index, pos) { +var tmp = sequence.hashCode () + index + ""; +if (this.lastMessage == null || !this.lastMessage.equals (tmp)) { +this.ssm.mouseOverSequence (sequence, index, pos, this.av); +}this.lastMessage = tmp; +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.overrideMethod (c$, "highlightSequence", +function (results) { +if (this.av.isFollowHighlight ()) { +if (this.ap.scrollToPosition (results, true)) { +this.ap.alignFrame.repaint (); +}}this.setStatusMessage (results); +this.seqCanvas.highlightSearchResults (results); +}, "jalview.datamodel.SearchResults"); +Clazz.overrideMethod (c$, "getVamsasSource", +function () { +return this.ap == null ? null : this.ap.av; +}); +Clazz.overrideMethod (c$, "updateColours", +function (seq, index) { +System.out.println ("update the seqPanel colours"); +}, "jalview.datamodel.SequenceI,~N"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +var res = this.findRes (evt); +var seq = this.findSeq (evt); +if (seq >= this.av.getAlignment ().getHeight () || seq < 0 || res < 0) { +if (this.tooltip != null) { +this.tooltip.setTip (""); +}return; +}var sequence = this.av.getAlignment ().getSequenceAt (seq); +if (res > sequence.getLength ()) { +if (this.tooltip != null) { +this.tooltip.setTip (""); +}return; +}var respos = sequence.findPosition (res); +if (this.ssm != null) { +this.mouseOverSequence (sequence, res, respos); +}var text = new StringBuilder (); +text.append ("Sequence ").append (Integer.toString (seq + 1)).append (" ID: ").append (sequence.getName ()); +var obj = null; +var ch = String.valueOf (sequence.getCharAt (res)); +if (this.av.getAlignment ().isNucleotide ()) { +obj = jalview.schemes.ResidueProperties.nucleotideName.get (ch); +if (obj != null) { +text.append (" Nucleotide: ").append (obj); +}} else { +obj = "X".equalsIgnoreCase (ch) ? "X" : jalview.schemes.ResidueProperties.aa2Triplet.get (ch); +if (obj != null) { +text.append (" Residue: ").append (obj); +}}if (obj != null) { +text.append (" (").append (Integer.toString (respos)).append (")"); +}this.ap.alignFrame.setStatus (text.toString ()); +var tooltipText = new StringBuilder (); +var groups = this.av.getAlignment ().findAllGroups (sequence); +if (groups != null) { +for (var g = 0; g < groups.length; g++) { +if (groups[g].getStartRes () <= res && groups[g].getEndRes () >= res) { +if (!groups[g].getName ().startsWith ("JTreeGroup") && !groups[g].getName ().startsWith ("JGroup")) { +tooltipText.append (groups[g].getName ()).append (" "); +}if (groups[g].getDescription () != null) { +tooltipText.append (groups[g].getDescription ()); +}tooltipText.append ("\n"); +}} +}var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); +var index = 0; +while (index < allFeatures.length) { +var sf = allFeatures[index]; +tooltipText.append (sf.getType () + " " + sf.begin + ":" + sf.end); +if (sf.getDescription () != null) { +tooltipText.append (" " + sf.getDescription ()); +}if (sf.getValue ("status") != null) { +var status = sf.getValue ("status").toString (); +if (status.length > 0) { +tooltipText.append (" (" + sf.getValue ("status") + ")"); +}}tooltipText.append ("\n"); +index++; +} +if (this.tooltip == null) { +this.tooltip = new jalview.appletgui.Tooltip (tooltipText.toString (), this.seqCanvas); +} else { +this.tooltip.setTip (tooltipText.toString ()); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "findFeaturesAtRes", +function (sequence, res) { +var tmp = new java.util.Vector (); +var features = sequence.getSequenceFeatures (); +if (features != null) { +for (var i = 0; i < features.length; i++) { +if (this.av.getFeaturesDisplayed () == null || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) { +continue; +}if (features[i].featureGroup != null && !this.seqCanvas.fr.checkGroupVisibility (features[i].featureGroup, false)) { +continue; +}if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) { +tmp.addElement (features[i]); +}} +}features = new Array (tmp.size ()); +tmp.copyInto (features); +return features; +}, "jalview.datamodel.SequenceI,~N"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +if (this.mouseWheelPressed) { +var oldWidth = this.av.getCharWidth (); +if (Math.abs (evt.getY () - this.lastMousePress.y) > Math.abs (evt.getX () - this.lastMousePress.x)) { +var fontSize = this.av.font.getSize (); +if (evt.getY () < this.lastMousePress.y && this.av.getCharHeight () > 1) { +fontSize--; +} else if (evt.getY () > this.lastMousePress.y) { +fontSize++; +}if (fontSize < 1) { +fontSize = 1; +}this.av.setFont ( new java.awt.Font (this.av.font.getName (), this.av.font.getStyle (), fontSize)); +this.av.setCharWidth (oldWidth); +} else { +if (evt.getX () < this.lastMousePress.x && this.av.getCharWidth () > 1) { +this.av.setCharWidth (this.av.getCharWidth () - 1); +} else if (evt.getX () > this.lastMousePress.x) { +this.av.setCharWidth (this.av.getCharWidth () + 1); +}if (this.av.getCharWidth () < 1) { +this.av.setCharWidth (1); +}}this.ap.fontChanged (); +var fm = this.getFontMetrics (this.av.getFont ()); +this.av.validCharWidth = fm.charWidth ('M') <= this.av.getCharWidth (); +this.lastMousePress = evt.getPoint (); +this.ap.paintAlignment (false); +this.ap.annotationPanel.image = null; +return; +}if (!this.editingSeqs) { +this.doMouseDraggedDefineMode (evt); +return; +}var res = this.findRes (evt); +if (res < 0) { +res = 0; +}if ((this.lastres == -1) || (this.lastres == res)) { +return; +}if ((res < this.av.getAlignment ().getWidth ()) && (res < this.lastres)) { +this.editSequence (false, res); +} else { +this.editSequence (true, res); +}this.mouseDragging = true; +if (this.scrollThread != null) { +this.scrollThread.setEvent (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "editSequence", +function (insertGap, startres) { +var fixedLeft = -1; +var fixedRight = -1; +var fixedColumns = false; +var sg = this.av.getSelectionGroup (); +var seq = this.av.getAlignment ().getSequenceAt (this.startseq); +if (!this.groupEditing && this.av.hasHiddenRows ()) { +if (this.av.isHiddenRepSequence (seq)) { +sg = this.av.getRepresentedSequences (seq); +this.groupEditing = true; +}}var message = new StringBuffer (); +if (this.groupEditing) { +message.append (jalview.util.MessageManager.getString ("action.edit_group")).append (":"); +if (this.editCommand == null) { +this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.getString ("action.edit_group")); +}} else { +message.append (jalview.util.MessageManager.getString ("label.edit_sequence")).append (" " + seq.getName ()); +var label = seq.getName (); +if (label.length > 10) { +label = label.substring (0, 10); +}if (this.editCommand == null) { +this.editCommand = new jalview.commands.EditCommand (jalview.util.MessageManager.formatMessage ("label.edit_params", Clazz.newArray (-1, [label]))); +}}if (insertGap) { +message.append (" insert "); +} else { +message.append (" delete "); +}message.append (Math.abs (startres - this.lastres) + " gaps."); +this.ap.alignFrame.setStatus (message.toString ()); +if (this.groupEditing || (sg != null && sg.getSequences (this.av.getHiddenRepSequences ()).contains (seq))) { +fixedColumns = true; +if (sg == null) { +if (!this.av.isHiddenRepSequence (seq)) { +this.endEditing (); +return; +}sg = this.av.getRepresentedSequences (seq); +}fixedLeft = sg.getStartRes (); +fixedRight = sg.getEndRes (); +if ((startres < fixedLeft && this.lastres >= fixedLeft) || (startres >= fixedLeft && this.lastres < fixedLeft) || (startres > fixedRight && this.lastres <= fixedRight) || (startres <= fixedRight && this.lastres > fixedRight)) { +this.endEditing (); +return; +}if (fixedLeft > startres) { +fixedRight = fixedLeft - 1; +fixedLeft = 0; +} else if (fixedRight < startres) { +fixedLeft = fixedRight; +fixedRight = -1; +}}if (this.av.hasHiddenColumns ()) { +fixedColumns = true; +var y1 = this.av.getColumnSelection ().getHiddenBoundaryLeft (startres); +var y2 = this.av.getColumnSelection ().getHiddenBoundaryRight (startres); +if ((insertGap && startres > y1 && this.lastres < y1) || (!insertGap && startres < y2 && this.lastres > y2)) { +this.endEditing (); +return; +}if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) { +if (startres >= y2) { +fixedLeft = y2; +} else { +fixedRight = y2 - 1; +}}}if (this.groupEditing) { +var groupSeqs = sg.getSequences (this.av.getHiddenRepSequences ()).toArray ( new Array (0)); +if (insertGap) { +if (sg.getStartRes () == 0 && sg.getEndRes () == fixedRight && sg.getEndRes () == this.av.getAlignment ().getWidth () - 1) { +sg.setEndRes (this.av.getAlignment ().getWidth () + startres - this.lastres); +fixedRight = sg.getEndRes (); +}var blank = false; +for (fixedRight = fixedRight; fixedRight > this.lastres; fixedRight--) { +blank = true; +for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { +for (var j = 0; j < startres - this.lastres; j++) { +if (!jalview.util.Comparison.isGap (gs.getCharAt (fixedRight - j))) { +blank = false; +break; +}} +} +if (blank) { +break; +}} +if (!blank) { +if (sg.getSize () == this.av.getAlignment ().getHeight ()) { +if ((this.av.hasHiddenColumns () && startres < this.av.getColumnSelection ().getHiddenBoundaryRight (startres))) { +this.endEditing (); +return; +}var alWidth = this.av.getAlignment ().getWidth (); +if (this.av.hasHiddenRows ()) { +var hwidth = this.av.getAlignment ().getHiddenSequences ().getWidth (); +if (hwidth > alWidth) { +alWidth = hwidth; +}}sg.setEndRes (sg.getEndRes () + startres - this.lastres); +fixedRight = alWidth + startres - this.lastres; +} else { +this.endEditing (); +return; +}}} else if (!insertGap) { +for (var gs, $gs = 0, $$gs = groupSeqs; $gs < $$gs.length && ((gs = $$gs[$gs]) || true); $gs++) { +for (var j = startres; j < this.lastres; j++) { +if (gs.getLength () <= j) { +continue; +}if (!jalview.util.Comparison.isGap (gs.getCharAt (j))) { +this.endEditing (); +return; +}} +} +}if (insertGap) { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j < startres; j++) { +this.insertChar (j, groupSeqs, fixedRight); +} +} else { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, groupSeqs, startres, startres - this.lastres, this.av.getAlignment (), true); +}} else { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j > startres; j--) { +this.deleteChar (startres, groupSeqs, fixedRight); +} +} else { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, groupSeqs, startres, this.lastres - startres, this.av.getAlignment (), true); +}}} else { +if (insertGap) { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j < startres; j++) { +this.insertChar (j, Clazz.newArray (-1, [seq]), fixedRight); +} +} else { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, Clazz.newArray (-1, [seq]), this.lastres, startres - this.lastres, this.av.getAlignment (), true); +}} else { +if (fixedColumns && fixedRight != -1) { +for (var j = this.lastres; j > startres; j--) { +if (!jalview.util.Comparison.isGap (seq.getCharAt (startres))) { +this.endEditing (); +break; +}this.deleteChar (startres, Clazz.newArray (-1, [seq]), fixedRight); +} +} else { +var max = 0; +for (var m = startres; m < this.lastres; m++) { +if (!jalview.util.Comparison.isGap (seq.getCharAt (m))) { +break; +}max++; +} +if (max > 0) { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seq]), startres, max, this.av.getAlignment (), true); +}}}}this.lastres = startres; +this.seqCanvas.repaint (); +}, "~B,~N"); +Clazz.defineMethod (c$, "insertChar", +function (j, seq, fixedColumn) { +var blankColumn = fixedColumn; +for (var s = 0; s < seq.length; s++) { +for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { +if (jalview.util.Comparison.isGap (seq[s].getCharAt (blankColumn))) { +break; +}} +if (blankColumn <= j) { +blankColumn = fixedColumn; +this.endEditing (); +return; +}} +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, blankColumn, 1, this.av.getAlignment (), true); +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, j, 1, this.av.getAlignment (), true); +}, "~N,~A,~N"); +Clazz.defineMethod (c$, "deleteChar", +function (j, seq, fixedColumn) { +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seq, j, 1, this.av.getAlignment (), true); +this.editCommand.appendEdit (jalview.commands.EditCommand.Action.INSERT_GAP, seq, fixedColumn, 1, this.av.getAlignment (), true); +}, "~N,~A,~N"); +Clazz.defineMethod (c$, "doMousePressedDefineMode", +function (evt) { +if (this.scrollThread != null) { +this.scrollThread.running = false; +this.scrollThread = null; +}var res = this.findRes (evt); +var seq = this.findSeq (evt); +this.oldSeq = seq; +this.startWrapBlock = this.wrappedBlock; +if (seq == -1) { +return; +}var sequence = this.av.getAlignment ().getSequenceAt (seq); +if (sequence == null || res > sequence.getLength ()) { +return; +}this.stretchGroup = this.av.getSelectionGroup (); +if (this.stretchGroup == null) { +this.stretchGroup = this.av.getAlignment ().findGroup (sequence); +if (this.stretchGroup != null && res > this.stretchGroup.getStartRes () && res < this.stretchGroup.getEndRes ()) { +this.av.setSelectionGroup (this.stretchGroup); +} else { +this.stretchGroup = null; +}} else if (!this.stretchGroup.getSequences (null).contains (sequence) || this.stretchGroup.getStartRes () > res || this.stretchGroup.getEndRes () < res) { +this.stretchGroup = null; +var allGroups = this.av.getAlignment ().findAllGroups (sequence); +if (allGroups != null) { +for (var i = 0; i < allGroups.length; i++) { +if (allGroups[i].getStartRes () <= res && allGroups[i].getEndRes () >= res) { +this.stretchGroup = allGroups[i]; +break; +}} +}this.av.setSelectionGroup (this.stretchGroup); +}if ((evt.getModifiers () & 4) == 4) { +var allFeatures = this.findFeaturesAtRes (sequence, sequence.findPosition (res)); +var links = null; +if (allFeatures != null) { +for (var i = 0; i < allFeatures.length; i++) { +if (allFeatures[i].links != null) { +if (links == null) { +links = new java.util.Vector (); +}for (var j = 0; j < allFeatures[i].links.size (); j++) { +links.addElement (allFeatures[i].links.elementAt (j)); +} +}} +}var popup = new jalview.appletgui.APopupMenu (this.ap, null, links); +this.add (popup); +popup.show (this, evt.getX (), evt.getY ()); +return; +}if (this.av.cursorMode) { +this.seqCanvas.cursorX = this.findRes (evt); +this.seqCanvas.cursorY = this.findSeq (evt); +this.seqCanvas.repaint (); +return; +}if (this.stretchGroup == null) { +var sg = new jalview.datamodel.SequenceGroup (); +sg.setStartRes (res); +sg.setEndRes (res); +sg.addSequence (sequence, false); +this.av.setSelectionGroup (sg); +this.stretchGroup = sg; +if (this.av.getConservationSelected ()) { +jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.av.getGlobalColourScheme (), "Background"); +}if (this.av.getAbovePIDThreshold ()) { +jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.av.getGlobalColourScheme (), "Background"); +}}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "doMouseReleasedDefineMode", +function (evt) { +if (this.stretchGroup == null) { +return; +}this.stretchGroup.recalcConservation (); +if (this.stretchGroup.cs != null) { +this.stretchGroup.cs.alignmentChanged (this.stretchGroup, this.av.getHiddenRepSequences ()); +if (this.stretchGroup.cs.conservationApplied ()) { +jalview.appletgui.SliderPanel.setConservationSlider (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); +} else { +jalview.appletgui.SliderPanel.setPIDSliderSource (this.ap, this.stretchGroup.cs, this.stretchGroup.getName ()); +}}this.changeEndRes = false; +this.changeStartRes = false; +this.stretchGroup = null; +jalview.appletgui.PaintRefresher.Refresh (this.ap, this.av.getSequenceSetId ()); +this.ap.paintAlignment (true); +this.av.sendSelection (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "doMouseDraggedDefineMode", +function (evt) { +var res = this.findRes (evt); +var y = this.findSeq (evt); +if (this.wrappedBlock != this.startWrapBlock) { +return; +}if (this.stretchGroup == null) { +return; +}this.mouseDragging = true; +if (y > this.av.getAlignment ().getHeight ()) { +y = this.av.getAlignment ().getHeight () - 1; +}if (res >= this.av.getAlignment ().getWidth ()) { +res = this.av.getAlignment ().getWidth () - 1; +}if (this.stretchGroup.getEndRes () == res) { +this.changeEndRes = true; +} else if (this.stretchGroup.getStartRes () == res) { +this.changeStartRes = true; +}if (res < 0) { +res = 0; +}if (this.changeEndRes) { +if (res > (this.stretchGroup.getStartRes () - 1)) { +this.stretchGroup.setEndRes (res); +}} else if (this.changeStartRes) { +if (res < (this.stretchGroup.getEndRes () + 1)) { +this.stretchGroup.setStartRes (res); +}}var dragDirection = 0; +if (y > this.oldSeq) { +dragDirection = 1; +} else if (y < this.oldSeq) { +dragDirection = -1; +}while ((y != this.oldSeq) && (this.oldSeq > -1) && (y < this.av.getAlignment ().getHeight ())) { +var seq = this.av.getAlignment ().getSequenceAt (this.oldSeq); +this.oldSeq += dragDirection; +if (this.oldSeq < 0) { +break; +}var nextSeq = this.av.getAlignment ().getSequenceAt (this.oldSeq); +if (this.stretchGroup.getSequences (null).contains (nextSeq)) { +this.stretchGroup.deleteSequence (seq, false); +} else { +if (seq != null) { +this.stretchGroup.addSequence (seq, false); +}this.stretchGroup.addSequence (nextSeq, false); +}} +if (this.oldSeq < 0) { +this.oldSeq = -1; +}if (res > this.av.endRes || res < this.av.startRes || y < this.av.startSeq || y > this.av.endSeq) { +this.mouseExited (evt); +}if (this.scrollThread != null) { +this.scrollThread.setEvent (evt); +}this.seqCanvas.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (e) { +if (this.oldSeq < 0) { +this.oldSeq = 0; +}if (this.scrollThread != null) { +this.scrollThread.running = false; +this.scrollThread = null; +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (e) { +if (this.av.getWrapAlignment ()) { +return; +}if (this.mouseDragging && this.scrollThread == null) { +this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "scrollCanvas", +function (evt) { +if (evt == null) { +if (this.scrollThread != null) { +this.scrollThread.running = false; +this.scrollThread = null; +}this.mouseDragging = false; +} else { +if (this.scrollThread == null) { +this.scrollThread = Clazz.innerTypeInstance (jalview.appletgui.SeqPanel.ScrollThread, this, null); +}this.mouseDragging = true; +this.scrollThread.setEvent (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "selection", +function (seqsel, colsel, source) { +if (this.av != null && (this.av === source || !this.av.followSelection || (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).getSequenceSetId ().equals (this.av.getSequenceSetId ())))) { +return; +}if (this.selectionFromTranslation (seqsel, colsel, source)) { +return; +}var repaint = false; +var copycolsel = true; +if (this.av.getSelectionGroup () == null || !this.av.isSelectionGroupChanged (true)) { +var sgroup = null; +if (seqsel != null && seqsel.getSize () > 0) { +if (this.av.getAlignment () == null) { +System.out.println ("Selection message: alignviewport av SeqSetId=" + this.av.getSequenceSetId () + " ViewId=" + this.av.getViewId () + " 's alignment is NULL! returning immediatly."); +return; +}sgroup = seqsel.intersect (this.av.getAlignment (), (this.av.hasHiddenRows ()) ? this.av.getHiddenRepSequences () : null); +if ((sgroup == null || sgroup.getSize () == 0) && (colsel == null || colsel.size () == 0)) { +copycolsel = false; +}}if (sgroup != null && sgroup.getSize () > 0) { +this.av.setSelectionGroup (sgroup); +} else { +this.av.setSelectionGroup (null); +}repaint = this.av.isSelectionGroupChanged (true); +}if (copycolsel && (this.av.getColumnSelection () == null || !this.av.isColSelChanged (true))) { +if (colsel == null || colsel.size () == 0) { +if (this.av.getColumnSelection () != null) { +this.av.getColumnSelection ().clear (); +}} else { +if (this.av.getColumnSelection () == null) { +this.av.setColumnSelection ( new jalview.datamodel.ColumnSelection (colsel)); +} else { +this.av.getColumnSelection ().setElementsFrom (colsel); +}}repaint = new Boolean (repaint | this.av.isColSelChanged (true)).valueOf (); +}if (copycolsel && this.av.hasHiddenColumns () && (this.av.getColumnSelection () == null || this.av.getColumnSelection ().getHiddenColumns () == null)) { +System.err.println ("Bad things"); +}if (repaint) { +this.ap.scalePanelHolder.repaint (); +this.ap.repaint (); +}}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); +Clazz.defineMethod (c$, "scrollTo", +function (row, column) { +row = row < 0 ? this.ap.av.startSeq : row; +column = column < 0 ? this.ap.av.startRes : column; +this.ap.scrollTo (column, column, row, true, true); +}, "~N,~N"); +Clazz.defineMethod (c$, "scrollToRow", +function (row) { +row = row < 0 ? this.ap.av.startSeq : row; +this.ap.scrollTo (this.ap.av.startRes, this.ap.av.startRes, row, true, true); +}, "~N"); +Clazz.defineMethod (c$, "scrollToColumn", +function (column) { +column = column < 0 ? this.ap.av.startRes : column; +this.ap.scrollTo (column, column, this.ap.av.startSeq, true, true); +}, "~N"); +Clazz.defineMethod (c$, "selectionFromTranslation", +function (seqsel, colsel, source) { +if (!(Clazz.instanceOf (source, jalview.api.AlignViewportI))) { +return false; +}var sourceAv = source; +if (sourceAv.getCodingComplement () !== this.av && this.av.getCodingComplement () !== sourceAv) { +return false; +}var sg = jalview.util.MappingUtils.mapSequenceGroup (seqsel, sourceAv, this.av); +this.av.setSelectionGroup (sg); +this.av.isSelectionGroupChanged (true); +var cs = jalview.util.MappingUtils.mapColumnSelection (colsel, sourceAv, this.av); +this.av.setColumnSelection (cs); +this.av.isColSelChanged (true); +this.ap.scalePanelHolder.repaint (); +this.ap.repaint (); +return true; +}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); +c$.$SeqPanel$ScrollThread$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.evt = null; +this.running = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.SeqPanel, "ScrollThread", Thread); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.appletgui.SeqPanel.ScrollThread, []); +this.start (); +}); +Clazz.defineMethod (c$, "setEvent", +function (a) { +this.evt = a; +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "stopScrolling", +function () { +this.running = false; +}); +Clazz.overrideMethod (c$, "run", +function () { +this.running = true; +while (this.running) { +if (this.evt != null) { +if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () < 0 && this.b$["jalview.appletgui.SeqPanel"].av.getStartSeq () > 0) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (true); +}if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getY () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().height && this.b$["jalview.appletgui.SeqPanel"].av.getAlignment ().getHeight () > this.b$["jalview.appletgui.SeqPanel"].av.getEndSeq ()) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollUp (false); +}if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () < 0) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (false); +} else if (this.b$["jalview.appletgui.SeqPanel"].mouseDragging && this.evt.getX () >= this.b$["jalview.appletgui.SeqPanel"].getSize ().width) { +this.running = this.b$["jalview.appletgui.SeqPanel"].ap.scrollRight (true); +}}try { +Thread.sleep (75); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +} +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/SequenceRenderer.js b/bin/jalview/appletgui/SequenceRenderer.js index 43ee455..449c271 100644 --- a/bin/jalview/appletgui/SequenceRenderer.js +++ b/bin/jalview/appletgui/SequenceRenderer.js @@ -1,196 +1,196 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.api.SequenceRenderer"], "jalview.appletgui.SequenceRenderer", ["jalview.util.Comparison", "java.awt.Color", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.fm = null; -this.renderGaps = true; -this.currentSequenceGroup = null; -this.allGroups = null; -this.resBoxColour = null; -this.graphics = null; -this.forOverview = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "SequenceRenderer", null, jalview.api.SequenceRenderer); -Clazz.makeConstructor (c$, -function (av) { -this.av = av; -}, "jalview.appletgui.AlignViewport"); -Clazz.defineMethod (c$, "prepare", -function (g, renderGaps) { -this.graphics = g; -this.fm = g.getFontMetrics (); -this.renderGaps = renderGaps; -}, "java.awt.Graphics,~B"); -Clazz.overrideMethod (c$, "getResidueBoxColour", -function (seq, i) { -this.allGroups = this.av.getAlignment ().findAllGroups (seq); -if (this.inCurrentSequenceGroup (i)) { -if (this.currentSequenceGroup.getDisplayBoxes ()) { -this.getBoxColour (this.currentSequenceGroup.cs, seq, i); -}} else if (this.av.getShowBoxes ()) { -this.getBoxColour (this.av.getGlobalColourScheme (), seq, i); -}return this.resBoxColour; -}, "jalview.datamodel.SequenceI,~N"); -Clazz.overrideMethod (c$, "getResidueColour", -function (seq, position, fr) { -var col = this.getResidueBoxColour (seq, position); -if (fr != null) { -col = fr.findFeatureColour (col, seq, position); -}return col; -}, "jalview.datamodel.SequenceI,~N,jalview.api.FeatureRenderer"); -Clazz.defineMethod (c$, "getBoxColour", -function (cs, seq, i) { -if (cs != null) { -this.resBoxColour = cs.findColour (seq.getCharAt (i), i, seq); -} else if (this.forOverview && !jalview.util.Comparison.isGap (seq.getCharAt (i))) { -this.resBoxColour = java.awt.Color.lightGray; -} else { -this.resBoxColour = java.awt.Color.white; -}}, "jalview.schemes.ColourSchemeI,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "findSequenceColour", -function (seq, i) { -this.allGroups = this.av.getAlignment ().findAllGroups (seq); -this.drawBoxes (seq, i, i, 0); -return this.resBoxColour; -}, "jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "drawSequence", -function (seq, sg, start, end, y1) { -if (seq == null) { -return; -}this.allGroups = sg; -this.drawBoxes (seq, start, end, y1); -if (this.av.validCharWidth) { -this.drawText (seq, start, end, y1); -}}, "jalview.datamodel.SequenceI,~A,~N,~N,~N"); -Clazz.defineMethod (c$, "drawBoxes", -function (seq, start, end, y1) { -var i = start; -var length = seq.getLength (); -var curStart = -1; -var curWidth = this.av.getCharWidth (); -var avCharWidth = this.av.getCharWidth (); -var avCharHeight = this.av.getCharHeight (); -var tempColour = null; -while (i <= end) { -this.resBoxColour = java.awt.Color.white; -if (i < length) { -if (this.inCurrentSequenceGroup (i)) { -if (this.currentSequenceGroup.getDisplayBoxes ()) { -this.getBoxColour (this.currentSequenceGroup.cs, seq, i); -}} else if (this.av.getShowBoxes ()) { -this.getBoxColour (this.av.getGlobalColourScheme (), seq, i); -}}if (this.resBoxColour !== tempColour) { -if (tempColour != null) { -this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight); -}this.graphics.setColor (this.resBoxColour); -curStart = i; -curWidth = avCharWidth; -tempColour = this.resBoxColour; -} else { -curWidth += avCharWidth; -}i++; -} -this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight); -}, "jalview.datamodel.SequenceI,~N,~N,~N"); -Clazz.defineMethod (c$, "drawText", -function (seq, start, end, y1) { -var avCharWidth = this.av.getCharWidth (); -var avCharHeight = this.av.getCharHeight (); -var boldFont = null; -var bold = false; -if (this.av.isUpperCasebold ()) { -boldFont = new java.awt.Font (this.av.getFont ().getName (), 1, avCharHeight); -this.graphics.setFont (this.av.getFont ()); -}y1 += avCharHeight - Clazz.doubleToInt (avCharHeight / 5); -var charOffset = 0; -if (end + 1 >= seq.getLength ()) { -end = seq.getLength () - 1; -}var s = ' '; -var srep = this.av.isDisplayReferenceSeq (); -for (var i = start; i <= end; i++) { -this.graphics.setColor (java.awt.Color.black); -s = seq.getCharAt (i); -if (!this.renderGaps && jalview.util.Comparison.isGap (s)) { -continue; -}if (this.inCurrentSequenceGroup (i)) { -if (!this.currentSequenceGroup.getDisplayText ()) { -continue; -}if (this.currentSequenceGroup.getColourText ()) { -this.getBoxColour (this.currentSequenceGroup.cs, seq, i); -this.graphics.setColor (this.resBoxColour.darker ()); -}if (this.currentSequenceGroup.getShowNonconserved ()) { -s = this.getDisplayChar (srep, i, s, '.'); -}} else { -if (!this.av.getShowText ()) { -continue; -}if (this.av.getColourText ()) { -this.getBoxColour (this.av.getGlobalColourScheme (), seq, i); -if (this.av.getShowBoxes ()) { -this.graphics.setColor (this.resBoxColour.darker ()); -} else { -this.graphics.setColor (this.resBoxColour); -}}if (this.av.getShowUnconserved ()) { -s = this.getDisplayChar (srep, i, s, '.'); -}}if (this.av.isUpperCasebold ()) { -this.fm = this.graphics.getFontMetrics (); -if ('A' <= s && s <= 'Z') { -if (!bold) { -this.graphics.setFont (boldFont); -}bold = true; -} else if (bold) { -this.graphics.setFont (this.av.font); -bold = false; -}}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2); -this.graphics.drawString (String.valueOf (s), charOffset + avCharWidth * (i - start), y1); -} -}, "jalview.datamodel.SequenceI,~N,~N,~N"); -Clazz.defineMethod (c$, "getDisplayChar", -($fz = function (usesrep, position, s, c) { -var conschar = (usesrep) ? this.av.getAlignment ().getSeqrep ().getCharAt (position) : this.av.getAlignmentConsensusAnnotation ().annotations[position].displayCharacter.charAt (0); -if (conschar != '-' && s == conschar) { -s = c; -}return s; -}, $fz.isPrivate = true, $fz), "~B,~N,~S,~S"); -Clazz.defineMethod (c$, "inCurrentSequenceGroup", -function (res) { -if (this.allGroups == null) { -return false; -}for (var i = 0; i < this.allGroups.length; i++) { -if (this.allGroups[i].getStartRes () <= res && this.allGroups[i].getEndRes () >= res) { -this.currentSequenceGroup = this.allGroups[i]; -return true; -}} -return false; -}, "~N"); -Clazz.defineMethod (c$, "drawHighlightedText", -function (seq, start, end, x1, y1) { -var avCharWidth = this.av.getCharWidth (); -var avCharHeight = this.av.getCharHeight (); -var pady = Clazz.doubleToInt (avCharHeight / 5); -var charOffset = 0; -this.graphics.setColor (java.awt.Color.black); -this.graphics.fillRect (x1, y1, avCharWidth * (end - start + 1), avCharHeight); -this.graphics.setColor (java.awt.Color.white); -var s = '~'; -if (this.av.validCharWidth) { -for (var i = start; i <= end; i++) { -if (i < seq.getLength ()) { -s = seq.getCharAt (i); -}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2); -this.graphics.drawString (String.valueOf (s), charOffset + x1 + avCharWidth * (i - start), y1 + avCharHeight - pady); -} -}}, "jalview.datamodel.SequenceI,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "drawCursor", -function (seq, res, x1, y1) { -var pady = Clazz.doubleToInt (this.av.getCharHeight () / 5); -var charOffset = 0; -this.graphics.setColor (java.awt.Color.black); -this.graphics.fillRect (x1, y1, this.av.getCharWidth (), this.av.getCharHeight ()); -this.graphics.setColor (java.awt.Color.white); -this.graphics.setColor (java.awt.Color.white); -var s = seq.getCharAt (res); -if (this.av.validCharWidth) { -charOffset = Clazz.doubleToInt ((this.av.getCharWidth () - this.fm.charWidth (s)) / 2); -this.graphics.drawString (String.valueOf (s), charOffset + x1, (y1 + this.av.getCharHeight ()) - pady); -}}, "jalview.datamodel.SequenceI,~N,~N,~N"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.api.SequenceRenderer"], "jalview.appletgui.SequenceRenderer", ["jalview.util.Comparison", "java.awt.Color", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.fm = null; +this.renderGaps = true; +this.currentSequenceGroup = null; +this.allGroups = null; +this.resBoxColour = null; +this.graphics = null; +this.forOverview = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "SequenceRenderer", null, jalview.api.SequenceRenderer); +Clazz.makeConstructor (c$, +function (av) { +this.av = av; +}, "jalview.appletgui.AlignViewport"); +Clazz.defineMethod (c$, "prepare", +function (g, renderGaps) { +this.graphics = g; +this.fm = g.getFontMetrics (); +this.renderGaps = renderGaps; +}, "java.awt.Graphics,~B"); +Clazz.overrideMethod (c$, "getResidueBoxColour", +function (seq, i) { +this.allGroups = this.av.getAlignment ().findAllGroups (seq); +if (this.inCurrentSequenceGroup (i)) { +if (this.currentSequenceGroup.getDisplayBoxes ()) { +this.getBoxColour (this.currentSequenceGroup.cs, seq, i); +}} else if (this.av.getShowBoxes ()) { +this.getBoxColour (this.av.getGlobalColourScheme (), seq, i); +}return this.resBoxColour; +}, "jalview.datamodel.SequenceI,~N"); +Clazz.overrideMethod (c$, "getResidueColour", +function (seq, position, fr) { +var col = this.getResidueBoxColour (seq, position); +if (fr != null) { +col = fr.findFeatureColour (col, seq, position); +}return col; +}, "jalview.datamodel.SequenceI,~N,jalview.api.FeatureRenderer"); +Clazz.defineMethod (c$, "getBoxColour", +function (cs, seq, i) { +if (cs != null) { +this.resBoxColour = cs.findColour (seq.getCharAt (i), i, seq); +} else if (this.forOverview && !jalview.util.Comparison.isGap (seq.getCharAt (i))) { +this.resBoxColour = java.awt.Color.lightGray; +} else { +this.resBoxColour = java.awt.Color.white; +}}, "jalview.schemes.ColourSchemeI,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "findSequenceColour", +function (seq, i) { +this.allGroups = this.av.getAlignment ().findAllGroups (seq); +this.drawBoxes (seq, i, i, 0); +return this.resBoxColour; +}, "jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "drawSequence", +function (seq, sg, start, end, y1) { +if (seq == null) { +return; +}this.allGroups = sg; +this.drawBoxes (seq, start, end, y1); +if (this.av.validCharWidth) { +this.drawText (seq, start, end, y1); +}}, "jalview.datamodel.SequenceI,~A,~N,~N,~N"); +Clazz.defineMethod (c$, "drawBoxes", +function (seq, start, end, y1) { +var i = start; +var length = seq.getLength (); +var curStart = -1; +var curWidth = this.av.getCharWidth (); +var avCharWidth = this.av.getCharWidth (); +var avCharHeight = this.av.getCharHeight (); +var tempColour = null; +while (i <= end) { +this.resBoxColour = java.awt.Color.white; +if (i < length) { +if (this.inCurrentSequenceGroup (i)) { +if (this.currentSequenceGroup.getDisplayBoxes ()) { +this.getBoxColour (this.currentSequenceGroup.cs, seq, i); +}} else if (this.av.getShowBoxes ()) { +this.getBoxColour (this.av.getGlobalColourScheme (), seq, i); +}}if (this.resBoxColour !== tempColour) { +if (tempColour != null) { +this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight); +}this.graphics.setColor (this.resBoxColour); +curStart = i; +curWidth = avCharWidth; +tempColour = this.resBoxColour; +} else { +curWidth += avCharWidth; +}i++; +} +this.graphics.fillRect (avCharWidth * (curStart - start), y1, curWidth, avCharHeight); +}, "jalview.datamodel.SequenceI,~N,~N,~N"); +Clazz.defineMethod (c$, "drawText", +function (seq, start, end, y1) { +var avCharWidth = this.av.getCharWidth (); +var avCharHeight = this.av.getCharHeight (); +var boldFont = null; +var bold = false; +if (this.av.isUpperCasebold ()) { +boldFont = new java.awt.Font (this.av.getFont ().getName (), 1, avCharHeight); +this.graphics.setFont (this.av.getFont ()); +}y1 += avCharHeight - Clazz.doubleToInt (avCharHeight / 5); +var charOffset = 0; +if (end + 1 >= seq.getLength ()) { +end = seq.getLength () - 1; +}var s = ' '; +var srep = this.av.isDisplayReferenceSeq (); +for (var i = start; i <= end; i++) { +this.graphics.setColor (java.awt.Color.black); +s = seq.getCharAt (i); +if (!this.renderGaps && jalview.util.Comparison.isGap (s)) { +continue; +}if (this.inCurrentSequenceGroup (i)) { +if (!this.currentSequenceGroup.getDisplayText ()) { +continue; +}if (this.currentSequenceGroup.getColourText ()) { +this.getBoxColour (this.currentSequenceGroup.cs, seq, i); +this.graphics.setColor (this.resBoxColour.darker ()); +}if (this.currentSequenceGroup.getShowNonconserved ()) { +s = this.getDisplayChar (srep, i, s, '.'); +}} else { +if (!this.av.getShowText ()) { +continue; +}if (this.av.getColourText ()) { +this.getBoxColour (this.av.getGlobalColourScheme (), seq, i); +if (this.av.getShowBoxes ()) { +this.graphics.setColor (this.resBoxColour.darker ()); +} else { +this.graphics.setColor (this.resBoxColour); +}}if (this.av.getShowUnconserved ()) { +s = this.getDisplayChar (srep, i, s, '.'); +}}if (this.av.isUpperCasebold ()) { +this.fm = this.graphics.getFontMetrics (); +if ('A' <= s && s <= 'Z') { +if (!bold) { +this.graphics.setFont (boldFont); +}bold = true; +} else if (bold) { +this.graphics.setFont (this.av.font); +bold = false; +}}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2); +this.graphics.drawString (String.valueOf (s), charOffset + avCharWidth * (i - start), y1); +} +}, "jalview.datamodel.SequenceI,~N,~N,~N"); +Clazz.defineMethod (c$, "getDisplayChar", +($fz = function (usesrep, position, s, c) { +var conschar = (usesrep) ? this.av.getAlignment ().getSeqrep ().getCharAt (position) : this.av.getAlignmentConsensusAnnotation ().annotations[position].displayCharacter.charAt (0); +if (conschar != '-' && s == conschar) { +s = c; +}return s; +}, $fz.isPrivate = true, $fz), "~B,~N,~S,~S"); +Clazz.defineMethod (c$, "inCurrentSequenceGroup", +function (res) { +if (this.allGroups == null) { +return false; +}for (var i = 0; i < this.allGroups.length; i++) { +if (this.allGroups[i].getStartRes () <= res && this.allGroups[i].getEndRes () >= res) { +this.currentSequenceGroup = this.allGroups[i]; +return true; +}} +return false; +}, "~N"); +Clazz.defineMethod (c$, "drawHighlightedText", +function (seq, start, end, x1, y1) { +var avCharWidth = this.av.getCharWidth (); +var avCharHeight = this.av.getCharHeight (); +var pady = Clazz.doubleToInt (avCharHeight / 5); +var charOffset = 0; +this.graphics.setColor (java.awt.Color.black); +this.graphics.fillRect (x1, y1, avCharWidth * (end - start + 1), avCharHeight); +this.graphics.setColor (java.awt.Color.white); +var s = '~'; +if (this.av.validCharWidth) { +for (var i = start; i <= end; i++) { +if (i < seq.getLength ()) { +s = seq.getCharAt (i); +}charOffset = Clazz.doubleToInt ((avCharWidth - this.fm.charWidth (s)) / 2); +this.graphics.drawString (String.valueOf (s), charOffset + x1 + avCharWidth * (i - start), y1 + avCharHeight - pady); +} +}}, "jalview.datamodel.SequenceI,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "drawCursor", +function (seq, res, x1, y1) { +var pady = Clazz.doubleToInt (this.av.getCharHeight () / 5); +var charOffset = 0; +this.graphics.setColor (java.awt.Color.black); +this.graphics.fillRect (x1, y1, this.av.getCharWidth (), this.av.getCharHeight ()); +this.graphics.setColor (java.awt.Color.white); +this.graphics.setColor (java.awt.Color.white); +var s = seq.getCharAt (res); +if (this.av.validCharWidth) { +charOffset = Clazz.doubleToInt ((this.av.getCharWidth () - this.fm.charWidth (s)) / 2); +this.graphics.drawString (String.valueOf (s), charOffset + x1, (y1 + this.av.getCharHeight ()) - pady); +}}, "jalview.datamodel.SequenceI,~N,~N,~N"); +}); diff --git a/bin/jalview/appletgui/SliderPanel.js b/bin/jalview/appletgui/SliderPanel.js index 8ba7a20..dc38cc2 100644 --- a/bin/jalview/appletgui/SliderPanel.js +++ b/bin/jalview/appletgui/SliderPanel.js @@ -1,270 +1,270 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Label", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.SliderPanel", ["awt2swing.Frame", "jalview.bin.JalviewLite", "jalview.util.MessageManager", "java.awt.Color", "$.Font", "java.awt.event.WindowAdapter"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ap = null; -this.forConservation = true; -this.cs = null; -this.slider = null; -this.valueField = null; -this.label = null; -this.jPanel1 = null; -this.jPanel2 = null; -this.applyButton = null; -this.undoButton = null; -this.flowLayout1 = null; -this.allGroupsCheck = null; -this.borderLayout1 = null; -this.borderLayout2 = null; -this.flowLayout2 = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "SliderPanel", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.MouseListener]); -Clazz.prepareFields (c$, function () { -this.slider = new awt2swing.Scrollbar (); -this.valueField = new awt2swing.TextField (); -this.label = new awt2swing.Label (); -this.jPanel1 = new awt2swing.Panel (); -this.jPanel2 = new awt2swing.Panel (); -this.applyButton = new awt2swing.Button (); -this.undoButton = new awt2swing.Button (); -this.flowLayout1 = new java.awt.FlowLayout (); -this.allGroupsCheck = new awt2swing.Checkbox (); -this.borderLayout1 = new java.awt.BorderLayout (); -this.borderLayout2 = new java.awt.BorderLayout (); -this.flowLayout2 = new java.awt.FlowLayout (); -}); -c$.setConservationSlider = Clazz.defineMethod (c$, "setConservationSlider", -function (ap, cs, source) { -var sp = null; -if (jalview.appletgui.SliderPanel.conservationSlider == null) { -sp = new jalview.appletgui.SliderPanel (ap, cs.getConservationInc (), true, cs); -jalview.appletgui.SliderPanel.conservationSlider = new awt2swing.Frame (); -jalview.appletgui.SliderPanel.conservationSlider.add (sp); -} else { -sp = jalview.appletgui.SliderPanel.conservationSlider.getComponent (0); -sp.cs = cs; -}jalview.appletgui.SliderPanel.conservationSlider.setTitle (jalview.util.MessageManager.formatMessage ("label.conservation_colour_increment", Clazz.newArray (-1, [source]))); -if (ap.av.getAlignment ().getGroups () != null) { -sp.setAllGroupsCheckEnabled (true); -} else { -sp.setAllGroupsCheckEnabled (false); -}return sp.getValue (); -}, "jalview.appletgui.AlignmentPanel,jalview.schemes.ColourSchemeI,~S"); -c$.showConservationSlider = Clazz.defineMethod (c$, "showConservationSlider", -function () { -try { -jalview.appletgui.SliderPanel.PIDSlider.setVisible (false); -jalview.appletgui.SliderPanel.PIDSlider = null; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -if (!jalview.appletgui.SliderPanel.conservationSlider.isVisible ()) { -jalview.bin.JalviewLite.addFrame (jalview.appletgui.SliderPanel.conservationSlider, jalview.appletgui.SliderPanel.conservationSlider.getTitle (), 420, 100); -jalview.appletgui.SliderPanel.conservationSlider.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.SliderPanel$1") ? 0 : jalview.appletgui.SliderPanel.$SliderPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.SliderPanel$1, this, null))); -}}); -c$.setPIDSliderSource = Clazz.defineMethod (c$, "setPIDSliderSource", -function (ap, cs, source) { -var pid = null; -if (jalview.appletgui.SliderPanel.PIDSlider == null) { -pid = new jalview.appletgui.SliderPanel (ap, 50, false, cs); -jalview.appletgui.SliderPanel.PIDSlider = new awt2swing.Frame (); -jalview.appletgui.SliderPanel.PIDSlider.add (pid); -} else { -pid = jalview.appletgui.SliderPanel.PIDSlider.getComponent (0); -pid.cs = cs; -}jalview.appletgui.SliderPanel.PIDSlider.setTitle (jalview.util.MessageManager.formatMessage ("label.percentage_identity_thereshold", Clazz.newArray (-1, [source]))); -if (ap.av.getAlignment ().getGroups () != null) { -pid.setAllGroupsCheckEnabled (true); -} else { -pid.setAllGroupsCheckEnabled (false); -}return pid.getValue (); -}, "jalview.appletgui.AlignmentPanel,jalview.schemes.ColourSchemeI,~S"); -c$.showPIDSlider = Clazz.defineMethod (c$, "showPIDSlider", -function () { -try { -jalview.appletgui.SliderPanel.conservationSlider.setVisible (false); -jalview.appletgui.SliderPanel.conservationSlider = null; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -if (!jalview.appletgui.SliderPanel.PIDSlider.isVisible ()) { -jalview.bin.JalviewLite.addFrame (jalview.appletgui.SliderPanel.PIDSlider, jalview.appletgui.SliderPanel.PIDSlider.getTitle (), 420, 100); -jalview.appletgui.SliderPanel.PIDSlider.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.SliderPanel$2") ? 0 : jalview.appletgui.SliderPanel.$SliderPanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.SliderPanel$2, this, null))); -}}); -Clazz.makeConstructor (c$, -function (ap, value, forConserve, cs) { -Clazz.superConstructor (this, jalview.appletgui.SliderPanel, []); -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.ap = ap; -this.cs = cs; -this.forConservation = forConserve; -this.undoButton.setVisible (false); -this.applyButton.setVisible (false); -if (this.forConservation) { -this.label.setText (jalview.util.MessageManager.getString ("label.modify_conservation_visibility")); -this.slider.setMinimum (0); -this.slider.setMaximum (50 + this.slider.getVisibleAmount ()); -this.slider.setUnitIncrement (1); -} else { -this.label.setText (jalview.util.MessageManager.getString ("label.colour_residues_above_occurence")); -this.slider.setMinimum (0); -this.slider.setMaximum (100 + this.slider.getVisibleAmount ()); -this.slider.setBlockIncrement (1); -}this.slider.addAdjustmentListener (this); -this.slider.addMouseListener (this); -this.slider.setValue (value); -this.valueField.setText (value + ""); -}, "jalview.appletgui.AlignmentPanel,~N,~B,jalview.schemes.ColourSchemeI"); -Clazz.defineMethod (c$, "valueChanged", -function (i) { -if (this.cs == null) { -return; -}var toChange = this.cs; -var allGroups = null; -if (this.allGroupsCheck.getState ()) { -allGroups = this.ap.av.getAlignment ().getGroups ().listIterator (); -}while (toChange != null) { -if (this.forConservation) { -toChange.setConservationInc (i); -} else { -toChange.setThreshold (i, this.ap.av.isIgnoreGapsConsensus ()); -}if (allGroups != null && allGroups.hasNext ()) { -while ((toChange = allGroups.next ().cs) == null && allGroups.hasNext ()) { -;} -} else { -toChange = null; -}} -this.ap.seqPanel.seqCanvas.repaint (); -}, "~N"); -Clazz.defineMethod (c$, "setAllGroupsCheckEnabled", -function (b) { -this.allGroupsCheck.setEnabled (b); -}, "~B"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.applyButton) { -this.applyButton_actionPerformed (); -} else if (evt.getSource () === this.undoButton) { -this.undoButton_actionPerformed (); -} else if (evt.getSource () === this.valueField) { -this.valueField_actionPerformed (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -this.valueField.setText (this.slider.getValue () + ""); -this.valueChanged (this.slider.getValue ()); -}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "valueField_actionPerformed", -function () { -try { -var i = Integer.parseInt (this.valueField.getText ()); -this.slider.setValue (i); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -this.valueField.setText (this.slider.getValue () + ""); -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "setValue", -function (value) { -this.slider.setValue (value); -}, "~N"); -Clazz.defineMethod (c$, "getValue", -function () { -return Integer.parseInt (this.valueField.getText ()); -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout (this.borderLayout2); -this.slider.setBackground (java.awt.Color.white); -this.slider.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.slider.setOrientation (0); -this.valueField.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.valueField.setText (" "); -this.valueField.addActionListener (this); -this.valueField.setColumns (3); -this.label.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.label.setText (jalview.util.MessageManager.getString ("label.set_this_label_text")); -this.jPanel1.setLayout (this.borderLayout1); -this.jPanel2.setLayout (this.flowLayout1); -this.applyButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.applyButton.setLabel (jalview.util.MessageManager.getString ("action.apply")); -this.applyButton.addActionListener (this); -this.undoButton.setEnabled (false); -this.undoButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.undoButton.setLabel (jalview.util.MessageManager.getString ("action.undo")); -this.undoButton.addActionListener (this); -this.allGroupsCheck.setEnabled (false); -this.allGroupsCheck.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.allGroupsCheck.setLabel (jalview.util.MessageManager.getString ("action.apply_threshold_all_groups")); -this.allGroupsCheck.setName (jalview.util.MessageManager.getString ("action.apply_all_groups")); -this.setBackground (java.awt.Color.white); -this.setForeground (java.awt.Color.black); -this.jPanel2.add (this.label, null); -this.jPanel2.add (this.applyButton, null); -this.jPanel2.add (this.undoButton, null); -this.jPanel2.add (this.allGroupsCheck); -this.jPanel1.add (this.valueField, "East"); -this.jPanel1.add (this.slider, "Center"); -this.add (this.jPanel1, "South"); -this.add (this.jPanel2, "Center"); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "applyButton_actionPerformed", -function () { -}); -Clazz.defineMethod (c$, "undoButton_actionPerformed", -function () { -}); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.ap.paintAlignment (true); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -c$.$SliderPanel$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "SliderPanel$1", java.awt.event.WindowAdapter); -Clazz.overrideMethod (c$, "windowClosing", -function (e) { -jalview.appletgui.SliderPanel.conservationSlider = null; -}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -c$.$SliderPanel$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "SliderPanel$2", java.awt.event.WindowAdapter); -Clazz.overrideMethod (c$, "windowClosing", -function (e) { -jalview.appletgui.SliderPanel.PIDSlider = null; -}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"conservationSlider", null, -"PIDSlider", null); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "awt2swing.Button", "$.Checkbox", "$.Label", "$.Scrollbar", "$.TextField", "java.awt.BorderLayout", "$.FlowLayout"], "jalview.appletgui.SliderPanel", ["awt2swing.Frame", "jalview.bin.JalviewLite", "jalview.util.MessageManager", "java.awt.Color", "$.Font", "java.awt.event.WindowAdapter"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ap = null; +this.forConservation = true; +this.cs = null; +this.slider = null; +this.valueField = null; +this.label = null; +this.jPanel1 = null; +this.jPanel2 = null; +this.applyButton = null; +this.undoButton = null; +this.flowLayout1 = null; +this.allGroupsCheck = null; +this.borderLayout1 = null; +this.borderLayout2 = null; +this.flowLayout2 = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "SliderPanel", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.MouseListener]); +Clazz.prepareFields (c$, function () { +this.slider = new awt2swing.Scrollbar (); +this.valueField = new awt2swing.TextField (); +this.label = new awt2swing.Label (); +this.jPanel1 = new awt2swing.Panel (); +this.jPanel2 = new awt2swing.Panel (); +this.applyButton = new awt2swing.Button (); +this.undoButton = new awt2swing.Button (); +this.flowLayout1 = new java.awt.FlowLayout (); +this.allGroupsCheck = new awt2swing.Checkbox (); +this.borderLayout1 = new java.awt.BorderLayout (); +this.borderLayout2 = new java.awt.BorderLayout (); +this.flowLayout2 = new java.awt.FlowLayout (); +}); +c$.setConservationSlider = Clazz.defineMethod (c$, "setConservationSlider", +function (ap, cs, source) { +var sp = null; +if (jalview.appletgui.SliderPanel.conservationSlider == null) { +sp = new jalview.appletgui.SliderPanel (ap, cs.getConservationInc (), true, cs); +jalview.appletgui.SliderPanel.conservationSlider = new awt2swing.Frame (); +jalview.appletgui.SliderPanel.conservationSlider.add (sp); +} else { +sp = jalview.appletgui.SliderPanel.conservationSlider.getComponent (0); +sp.cs = cs; +}jalview.appletgui.SliderPanel.conservationSlider.setTitle (jalview.util.MessageManager.formatMessage ("label.conservation_colour_increment", Clazz.newArray (-1, [source]))); +if (ap.av.getAlignment ().getGroups () != null) { +sp.setAllGroupsCheckEnabled (true); +} else { +sp.setAllGroupsCheckEnabled (false); +}return sp.getValue (); +}, "jalview.appletgui.AlignmentPanel,jalview.schemes.ColourSchemeI,~S"); +c$.showConservationSlider = Clazz.defineMethod (c$, "showConservationSlider", +function () { +try { +jalview.appletgui.SliderPanel.PIDSlider.setVisible (false); +jalview.appletgui.SliderPanel.PIDSlider = null; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +if (!jalview.appletgui.SliderPanel.conservationSlider.isVisible ()) { +jalview.bin.JalviewLite.addFrame (jalview.appletgui.SliderPanel.conservationSlider, jalview.appletgui.SliderPanel.conservationSlider.getTitle (), 420, 100); +jalview.appletgui.SliderPanel.conservationSlider.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.SliderPanel$1") ? 0 : jalview.appletgui.SliderPanel.$SliderPanel$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.SliderPanel$1, this, null))); +}}); +c$.setPIDSliderSource = Clazz.defineMethod (c$, "setPIDSliderSource", +function (ap, cs, source) { +var pid = null; +if (jalview.appletgui.SliderPanel.PIDSlider == null) { +pid = new jalview.appletgui.SliderPanel (ap, 50, false, cs); +jalview.appletgui.SliderPanel.PIDSlider = new awt2swing.Frame (); +jalview.appletgui.SliderPanel.PIDSlider.add (pid); +} else { +pid = jalview.appletgui.SliderPanel.PIDSlider.getComponent (0); +pid.cs = cs; +}jalview.appletgui.SliderPanel.PIDSlider.setTitle (jalview.util.MessageManager.formatMessage ("label.percentage_identity_thereshold", Clazz.newArray (-1, [source]))); +if (ap.av.getAlignment ().getGroups () != null) { +pid.setAllGroupsCheckEnabled (true); +} else { +pid.setAllGroupsCheckEnabled (false); +}return pid.getValue (); +}, "jalview.appletgui.AlignmentPanel,jalview.schemes.ColourSchemeI,~S"); +c$.showPIDSlider = Clazz.defineMethod (c$, "showPIDSlider", +function () { +try { +jalview.appletgui.SliderPanel.conservationSlider.setVisible (false); +jalview.appletgui.SliderPanel.conservationSlider = null; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +if (!jalview.appletgui.SliderPanel.PIDSlider.isVisible ()) { +jalview.bin.JalviewLite.addFrame (jalview.appletgui.SliderPanel.PIDSlider, jalview.appletgui.SliderPanel.PIDSlider.getTitle (), 420, 100); +jalview.appletgui.SliderPanel.PIDSlider.addWindowListener (((Clazz.isClassDefined ("jalview.appletgui.SliderPanel$2") ? 0 : jalview.appletgui.SliderPanel.$SliderPanel$2$ ()), Clazz.innerTypeInstance (jalview.appletgui.SliderPanel$2, this, null))); +}}); +Clazz.makeConstructor (c$, +function (ap, value, forConserve, cs) { +Clazz.superConstructor (this, jalview.appletgui.SliderPanel, []); +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.ap = ap; +this.cs = cs; +this.forConservation = forConserve; +this.undoButton.setVisible (false); +this.applyButton.setVisible (false); +if (this.forConservation) { +this.label.setText (jalview.util.MessageManager.getString ("label.modify_conservation_visibility")); +this.slider.setMinimum (0); +this.slider.setMaximum (50 + this.slider.getVisibleAmount ()); +this.slider.setUnitIncrement (1); +} else { +this.label.setText (jalview.util.MessageManager.getString ("label.colour_residues_above_occurence")); +this.slider.setMinimum (0); +this.slider.setMaximum (100 + this.slider.getVisibleAmount ()); +this.slider.setBlockIncrement (1); +}this.slider.addAdjustmentListener (this); +this.slider.addMouseListener (this); +this.slider.setValue (value); +this.valueField.setText (value + ""); +}, "jalview.appletgui.AlignmentPanel,~N,~B,jalview.schemes.ColourSchemeI"); +Clazz.defineMethod (c$, "valueChanged", +function (i) { +if (this.cs == null) { +return; +}var toChange = this.cs; +var allGroups = null; +if (this.allGroupsCheck.getState ()) { +allGroups = this.ap.av.getAlignment ().getGroups ().listIterator (); +}while (toChange != null) { +if (this.forConservation) { +toChange.setConservationInc (i); +} else { +toChange.setThreshold (i, this.ap.av.isIgnoreGapsConsensus ()); +}if (allGroups != null && allGroups.hasNext ()) { +while ((toChange = allGroups.next ().cs) == null && allGroups.hasNext ()) { +;} +} else { +toChange = null; +}} +this.ap.seqPanel.seqCanvas.repaint (); +}, "~N"); +Clazz.defineMethod (c$, "setAllGroupsCheckEnabled", +function (b) { +this.allGroupsCheck.setEnabled (b); +}, "~B"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.applyButton) { +this.applyButton_actionPerformed (); +} else if (evt.getSource () === this.undoButton) { +this.undoButton_actionPerformed (); +} else if (evt.getSource () === this.valueField) { +this.valueField_actionPerformed (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +this.valueField.setText (this.slider.getValue () + ""); +this.valueChanged (this.slider.getValue ()); +}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "valueField_actionPerformed", +function () { +try { +var i = Integer.parseInt (this.valueField.getText ()); +this.slider.setValue (i); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +this.valueField.setText (this.slider.getValue () + ""); +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "setValue", +function (value) { +this.slider.setValue (value); +}, "~N"); +Clazz.defineMethod (c$, "getValue", +function () { +return Integer.parseInt (this.valueField.getText ()); +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout (this.borderLayout2); +this.slider.setBackground (java.awt.Color.white); +this.slider.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.slider.setOrientation (0); +this.valueField.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.valueField.setText (" "); +this.valueField.addActionListener (this); +this.valueField.setColumns (3); +this.label.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.label.setText (jalview.util.MessageManager.getString ("label.set_this_label_text")); +this.jPanel1.setLayout (this.borderLayout1); +this.jPanel2.setLayout (this.flowLayout1); +this.applyButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.applyButton.setLabel (jalview.util.MessageManager.getString ("action.apply")); +this.applyButton.addActionListener (this); +this.undoButton.setEnabled (false); +this.undoButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.undoButton.setLabel (jalview.util.MessageManager.getString ("action.undo")); +this.undoButton.addActionListener (this); +this.allGroupsCheck.setEnabled (false); +this.allGroupsCheck.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.allGroupsCheck.setLabel (jalview.util.MessageManager.getString ("action.apply_threshold_all_groups")); +this.allGroupsCheck.setName (jalview.util.MessageManager.getString ("action.apply_all_groups")); +this.setBackground (java.awt.Color.white); +this.setForeground (java.awt.Color.black); +this.jPanel2.add (this.label, null); +this.jPanel2.add (this.applyButton, null); +this.jPanel2.add (this.undoButton, null); +this.jPanel2.add (this.allGroupsCheck); +this.jPanel1.add (this.valueField, "East"); +this.jPanel1.add (this.slider, "Center"); +this.add (this.jPanel1, "South"); +this.add (this.jPanel2, "Center"); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "applyButton_actionPerformed", +function () { +}); +Clazz.defineMethod (c$, "undoButton_actionPerformed", +function () { +}); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.ap.paintAlignment (true); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +c$.$SliderPanel$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "SliderPanel$1", java.awt.event.WindowAdapter); +Clazz.overrideMethod (c$, "windowClosing", +function (e) { +jalview.appletgui.SliderPanel.conservationSlider = null; +}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +c$.$SliderPanel$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "SliderPanel$2", java.awt.event.WindowAdapter); +Clazz.overrideMethod (c$, "windowClosing", +function (e) { +jalview.appletgui.SliderPanel.PIDSlider = null; +}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"conservationSlider", null, +"PIDSlider", null); +}); diff --git a/bin/jalview/appletgui/SplitFrame.js b/bin/jalview/appletgui/SplitFrame.js index eb3570a..7818eaf 100644 --- a/bin/jalview/appletgui/SplitFrame.js +++ b/bin/jalview/appletgui/SplitFrame.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.appletgui.EmbmenuFrame"], "jalview.appletgui.SplitFrame", ["awt2swing.Panel", "jalview.analysis.AlignmentUtils", "jalview.bin.JalviewLite", "jalview.structure.StructureSelectionManager", "java.awt.BorderLayout", "$.Dimension", "$.GridLayout"], function () { -c$ = Clazz.decorateAsClass (function () { -this.topFrame = null; -this.bottomFrame = null; -this.outermost = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "SplitFrame", jalview.appletgui.EmbmenuFrame); -Clazz.makeConstructor (c$, -function (af1, af2) { -Clazz.superConstructor (this, jalview.appletgui.SplitFrame, []); -this.topFrame = af1; -this.bottomFrame = af2; -this.init (); -}, "jalview.appletgui.AlignFrame,jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "init", -function () { -var $private = Clazz.checkPrivateMethod (arguments); -if ($private != null) { -return $private.apply (this, arguments); -} -this.constructSplit (); -var topViewport = this.topFrame.viewport; -var bottomViewport = this.bottomFrame.viewport; -var topAlignment = topViewport.getAlignment (); -var bottomAlignment = bottomViewport.getAlignment (); -var cdna = topAlignment.isNucleotide () ? topViewport : (bottomAlignment.isNucleotide () ? bottomViewport : null); -var protein = !topAlignment.isNucleotide () ? topViewport : (!bottomAlignment.isNucleotide () ? bottomViewport : null); -var mapped = jalview.analysis.AlignmentUtils.mapProteinToCdna (protein.getAlignment (), cdna.getAlignment ()); -if (mapped) { -var ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (topViewport.applet); -ssm.addMappings (protein.getAlignment ().getCodonFrames ()); -topViewport.setCodingComplement (bottomViewport); -ssm.addCommandListener (cdna); -ssm.addCommandListener (protein); -}protein.initComplementConsensus (); -var ap = topAlignment.isNucleotide () ? this.bottomFrame.alignPanel : this.topFrame.alignPanel; -protein.updateConsensus (ap); -this.adjustLayout (); -}); -Clazz.defineMethod (c$, "constructSplit", -function () { -this.unsetMenuBar (); -this.outermost = new awt2swing.Panel ( new java.awt.GridLayout (2, 1)); -var topPanel = new awt2swing.Panel (); -var bottomPanel = new awt2swing.Panel (); -this.outermost.add (topPanel); -this.outermost.add (bottomPanel); -this.addAlignFrameComponents (this.topFrame, topPanel); -this.addAlignFrameComponents (this.bottomFrame, bottomPanel); -}); -Clazz.defineMethod (c$, "adjustLayout", -function () { -var cdna = this.topFrame.getAlignViewport ().getAlignment ().isNucleotide () ? this.topFrame.viewport : this.bottomFrame.viewport; -var protein = cdna === this.topFrame.viewport ? this.bottomFrame.viewport : this.topFrame.viewport; -var w1 = this.topFrame.alignPanel.idPanel.idCanvas.getWidth (); -var w2 = this.bottomFrame.alignPanel.idPanel.idCanvas.getWidth (); -var w3 = Math.max (w1, w2); -if (w1 != w3) { -var d = this.topFrame.alignPanel.idPanel.idCanvas.getSize (); -this.topFrame.alignPanel.idPanel.idCanvas.setSize ( new java.awt.Dimension (w3, d.height)); -}if (w2 != w3) { -var d = this.bottomFrame.alignPanel.idPanel.idCanvas.getSize (); -this.bottomFrame.alignPanel.idPanel.idCanvas.setSize ( new java.awt.Dimension (w3, d.height)); -}if (protein != null && cdna != null) { -var vs = protein.getViewStyle (); -var scale = vs.isScaleProteinAsCdna () ? 3 : 1; -vs.setCharWidth (scale * cdna.getViewStyle ().getCharWidth ()); -protein.setViewStyle (vs); -}}); -Clazz.defineMethod (c$, "addAlignFrameComponents", -($fz = function (af, panel) { -panel.setLayout ( new java.awt.BorderLayout ()); -var menuPanel = af.makeEmbeddedPopupMenu (af.getJMenuBar (), true, false); -panel.add (menuPanel, "North"); -panel.add (af.statusBar, "South"); -panel.add (af.alignPanel, "Center"); -af.setSplitFrame (this); -}, $fz.isPrivate = true, $fz), "jalview.appletgui.AlignFrame,awt2swing.Panel"); -Clazz.defineMethod (c$, "addToDisplay", -function (embedded, applet) { -this.createSplitFrameWindow (embedded, applet); -this.validate (); -this.topFrame.alignPanel.adjustAnnotationHeight (); -this.topFrame.alignPanel.paintAlignment (true); -this.bottomFrame.alignPanel.adjustAnnotationHeight (); -this.bottomFrame.alignPanel.paintAlignment (true); -}, "~B,jalview.bin.JalviewLite"); -Clazz.defineMethod (c$, "createSplitFrameWindow", -function (embed, applet) { -if (embed) { -applet.add (this.outermost); -applet.validate (); -} else { -this.add (this.outermost); -var width = Math.max (this.topFrame.frameWidth, this.bottomFrame.frameWidth); -var height = this.topFrame.frameHeight + this.bottomFrame.frameHeight; -jalview.bin.JalviewLite.addFrame (this, this.getTitle (), width, height); -}}, "~B,jalview.bin.JalviewLite"); -Clazz.defineMethod (c$, "getComplement", -function (af) { -if (this.topFrame === af) { -return this.bottomFrame; -} else if (this.bottomFrame === af) { -return this.topFrame; -}return null; -}, "jalview.appletgui.AlignFrame"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.appletgui.EmbmenuFrame"], "jalview.appletgui.SplitFrame", ["awt2swing.Panel", "jalview.analysis.AlignmentUtils", "jalview.bin.JalviewLite", "jalview.structure.StructureSelectionManager", "java.awt.BorderLayout", "$.Dimension", "$.GridLayout"], function () { +c$ = Clazz.decorateAsClass (function () { +this.topFrame = null; +this.bottomFrame = null; +this.outermost = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "SplitFrame", jalview.appletgui.EmbmenuFrame); +Clazz.makeConstructor (c$, +function (af1, af2) { +Clazz.superConstructor (this, jalview.appletgui.SplitFrame, []); +this.topFrame = af1; +this.bottomFrame = af2; +this.init (); +}, "jalview.appletgui.AlignFrame,jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "init", +function () { +var $private = Clazz.checkPrivateMethod (arguments); +if ($private != null) { +return $private.apply (this, arguments); +} +this.constructSplit (); +var topViewport = this.topFrame.viewport; +var bottomViewport = this.bottomFrame.viewport; +var topAlignment = topViewport.getAlignment (); +var bottomAlignment = bottomViewport.getAlignment (); +var cdna = topAlignment.isNucleotide () ? topViewport : (bottomAlignment.isNucleotide () ? bottomViewport : null); +var protein = !topAlignment.isNucleotide () ? topViewport : (!bottomAlignment.isNucleotide () ? bottomViewport : null); +var mapped = jalview.analysis.AlignmentUtils.mapProteinToCdna (protein.getAlignment (), cdna.getAlignment ()); +if (mapped) { +var ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (topViewport.applet); +ssm.addMappings (protein.getAlignment ().getCodonFrames ()); +topViewport.setCodingComplement (bottomViewport); +ssm.addCommandListener (cdna); +ssm.addCommandListener (protein); +}protein.initComplementConsensus (); +var ap = topAlignment.isNucleotide () ? this.bottomFrame.alignPanel : this.topFrame.alignPanel; +protein.updateConsensus (ap); +this.adjustLayout (); +}); +Clazz.defineMethod (c$, "constructSplit", +function () { +this.unsetMenuBar (); +this.outermost = new awt2swing.Panel ( new java.awt.GridLayout (2, 1)); +var topPanel = new awt2swing.Panel (); +var bottomPanel = new awt2swing.Panel (); +this.outermost.add (topPanel); +this.outermost.add (bottomPanel); +this.addAlignFrameComponents (this.topFrame, topPanel); +this.addAlignFrameComponents (this.bottomFrame, bottomPanel); +}); +Clazz.defineMethod (c$, "adjustLayout", +function () { +var cdna = this.topFrame.getAlignViewport ().getAlignment ().isNucleotide () ? this.topFrame.viewport : this.bottomFrame.viewport; +var protein = cdna === this.topFrame.viewport ? this.bottomFrame.viewport : this.topFrame.viewport; +var w1 = this.topFrame.alignPanel.idPanel.idCanvas.getWidth (); +var w2 = this.bottomFrame.alignPanel.idPanel.idCanvas.getWidth (); +var w3 = Math.max (w1, w2); +if (w1 != w3) { +var d = this.topFrame.alignPanel.idPanel.idCanvas.getSize (); +this.topFrame.alignPanel.idPanel.idCanvas.setSize ( new java.awt.Dimension (w3, d.height)); +}if (w2 != w3) { +var d = this.bottomFrame.alignPanel.idPanel.idCanvas.getSize (); +this.bottomFrame.alignPanel.idPanel.idCanvas.setSize ( new java.awt.Dimension (w3, d.height)); +}if (protein != null && cdna != null) { +var vs = protein.getViewStyle (); +var scale = vs.isScaleProteinAsCdna () ? 3 : 1; +vs.setCharWidth (scale * cdna.getViewStyle ().getCharWidth ()); +protein.setViewStyle (vs); +}}); +Clazz.defineMethod (c$, "addAlignFrameComponents", +($fz = function (af, panel) { +panel.setLayout ( new java.awt.BorderLayout ()); +var menuPanel = af.makeEmbeddedPopupMenu (af.getJMenuBar (), true, false); +panel.add (menuPanel, "North"); +panel.add (af.statusBar, "South"); +panel.add (af.alignPanel, "Center"); +af.setSplitFrame (this); +}, $fz.isPrivate = true, $fz), "jalview.appletgui.AlignFrame,awt2swing.Panel"); +Clazz.defineMethod (c$, "addToDisplay", +function (embedded, applet) { +this.createSplitFrameWindow (embedded, applet); +this.validate (); +this.topFrame.alignPanel.adjustAnnotationHeight (); +this.topFrame.alignPanel.paintAlignment (true); +this.bottomFrame.alignPanel.adjustAnnotationHeight (); +this.bottomFrame.alignPanel.paintAlignment (true); +}, "~B,jalview.bin.JalviewLite"); +Clazz.defineMethod (c$, "createSplitFrameWindow", +function (embed, applet) { +if (embed) { +applet.add (this.outermost); +applet.validate (); +} else { +this.add (this.outermost); +var width = Math.max (this.topFrame.frameWidth, this.bottomFrame.frameWidth); +var height = this.topFrame.frameHeight + this.bottomFrame.frameHeight; +jalview.bin.JalviewLite.addFrame (this, this.getTitle (), width, height); +}}, "~B,jalview.bin.JalviewLite"); +Clazz.defineMethod (c$, "getComplement", +function (af) { +if (this.topFrame === af) { +return this.bottomFrame; +} else if (this.bottomFrame === af) { +return this.topFrame; +}return null; +}, "jalview.appletgui.AlignFrame"); +}); diff --git a/bin/jalview/appletgui/TitledPanel.js b/bin/jalview/appletgui/TitledPanel.js index 026a455..351c3ff 100644 --- a/bin/jalview/appletgui/TitledPanel.js +++ b/bin/jalview/appletgui/TitledPanel.js @@ -1,43 +1,43 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.Insets"], "jalview.appletgui.TitledPanel", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.title = null; -this.$insets = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "TitledPanel", awt2swing.Panel); -Clazz.prepareFields (c$, function () { -this.$insets = new java.awt.Insets (10, 10, 10, 10); -}); -Clazz.makeConstructor (c$, -function () { -this.construct (""); -}); -Clazz.makeConstructor (c$, -function (title) { -Clazz.superConstructor (this, jalview.appletgui.TitledPanel, []); -this.setTitle (title); -}, "~S"); -Clazz.defineMethod (c$, "getInsets", -function () { -return this.$insets; -}); -Clazz.defineMethod (c$, "paintComponent", -function (g) { -Clazz.superCall (this, jalview.appletgui.TitledPanel, "paintComponent", [g]); -g.setColor (this.getForeground ()); -g.drawRect (5, 5, this.getWidth () - 10, this.getHeight () - 10); -var width = g.getFontMetrics ().stringWidth (this.getTitle ()); -g.setColor (this.getBackground ()); -g.fillRect (10, 0, width, 10); -g.setColor (this.getForeground ()); -g.drawString (this.getTitle (), 10, 10); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "getTitle", -function () { -return this.title; -}); -Clazz.defineMethod (c$, "setTitle", -function (title) { -this.title = title; -}, "~S"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.Insets"], "jalview.appletgui.TitledPanel", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.title = null; +this.$insets = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "TitledPanel", awt2swing.Panel); +Clazz.prepareFields (c$, function () { +this.$insets = new java.awt.Insets (10, 10, 10, 10); +}); +Clazz.makeConstructor (c$, +function () { +this.construct (""); +}); +Clazz.makeConstructor (c$, +function (title) { +Clazz.superConstructor (this, jalview.appletgui.TitledPanel, []); +this.setTitle (title); +}, "~S"); +Clazz.defineMethod (c$, "getInsets", +function () { +return this.$insets; +}); +Clazz.defineMethod (c$, "paintComponent", +function (g) { +Clazz.superCall (this, jalview.appletgui.TitledPanel, "paintComponent", [g]); +g.setColor (this.getForeground ()); +g.drawRect (5, 5, this.getWidth () - 10, this.getHeight () - 10); +var width = g.getFontMetrics ().stringWidth (this.getTitle ()); +g.setColor (this.getBackground ()); +g.fillRect (10, 0, width, 10); +g.setColor (this.getForeground ()); +g.drawString (this.getTitle (), 10, 10); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "getTitle", +function () { +return this.title; +}); +Clazz.defineMethod (c$, "setTitle", +function (title) { +this.title = title; +}, "~S"); +}); diff --git a/bin/jalview/appletgui/Tooltip.js b/bin/jalview/appletgui/Tooltip.js index 425b8d7..cb48e62 100644 --- a/bin/jalview/appletgui/Tooltip.js +++ b/bin/jalview/appletgui/Tooltip.js @@ -1,67 +1,67 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (null, "jalview.appletgui.Tooltip", ["awt2swing.Frame", "java.applet.Applet", "java.awt.Toolkit"], function () { -c$ = Clazz.decorateAsClass (function () { -this.tip = null; -this.lastTip = ""; -this.setPosition = false; -this.owner = null; -this.mainContainer = null; -this.mainLayout = null; -this.shown = false; -this.VERTICAL_OFFSET = 20; -this.HORIZONTAL_ENLARGE = 10; -this.fontHeight = 0; -this.linkImage = null; -this.fm = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "Tooltip"); -Clazz.defineMethod (c$, "setVisible", -function (b) { -}, "~B"); -Clazz.makeConstructor (c$, -function (tip, owner) { -this.owner = owner; -this.setTip (tip); -var url = this.getClass ().getResource ("/images/link.gif"); -if (url != null) { -this.linkImage = java.awt.Toolkit.getDefaultToolkit ().getImage (url); -}}, "~S,java.awt.Component"); -Clazz.defineMethod (c$, "setTip", -function (tip) { -System.err.println ("Tooltip: " + tip); -}, "~S"); -Clazz.defineMethod (c$, "setTipLocation", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "removeToolTip", -($fz = function () { -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "mouseEntered", -function (me) { -this.setTipLocation (me); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mouseExited", -function (me) { -this.removeToolTip (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mousePressed", -function (me) { -this.removeToolTip (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mouseReleased", -function (me) { -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mouseClicked", -function (me) { -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mouseMoved", -function (me) { -if (!this.shown) { -this.setTipLocation (me); -} else if (this.setPosition) { -this.setTipLocation (me); -}}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "mouseDragged", -function (me) { -}, "java.awt.event.MouseEvent"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (null, "jalview.appletgui.Tooltip", ["awt2swing.Frame", "java.applet.Applet", "java.awt.Toolkit"], function () { +c$ = Clazz.decorateAsClass (function () { +this.tip = null; +this.lastTip = ""; +this.setPosition = false; +this.owner = null; +this.mainContainer = null; +this.mainLayout = null; +this.shown = false; +this.VERTICAL_OFFSET = 20; +this.HORIZONTAL_ENLARGE = 10; +this.fontHeight = 0; +this.linkImage = null; +this.fm = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "Tooltip"); +Clazz.defineMethod (c$, "setVisible", +function (b) { +}, "~B"); +Clazz.makeConstructor (c$, +function (tip, owner) { +this.owner = owner; +this.setTip (tip); +var url = this.getClass ().getResource ("/images/link.gif"); +if (url != null) { +this.linkImage = java.awt.Toolkit.getDefaultToolkit ().getImage (url); +}}, "~S,java.awt.Component"); +Clazz.defineMethod (c$, "setTip", +function (tip) { +System.err.println ("Tooltip: " + tip); +}, "~S"); +Clazz.defineMethod (c$, "setTipLocation", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "removeToolTip", +($fz = function () { +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "mouseEntered", +function (me) { +this.setTipLocation (me); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mouseExited", +function (me) { +this.removeToolTip (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mousePressed", +function (me) { +this.removeToolTip (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mouseReleased", +function (me) { +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mouseClicked", +function (me) { +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mouseMoved", +function (me) { +if (!this.shown) { +this.setTipLocation (me); +} else if (this.setPosition) { +this.setTipLocation (me); +}}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "mouseDragged", +function (me) { +}, "java.awt.event.MouseEvent"); +}); diff --git a/bin/jalview/appletgui/TreeCanvas.js b/bin/jalview/appletgui/TreeCanvas.js index 69da9f2..da76a3e 100644 --- a/bin/jalview/appletgui/TreeCanvas.js +++ b/bin/jalview/appletgui/TreeCanvas.js @@ -1,375 +1,375 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.util.Hashtable"], "jalview.appletgui.TreeCanvas", ["jalview.analysis.Conservation", "jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "$.SequenceI", "$.SequenceNode", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Format", "$.MappingUtils", "java.awt.Color", "$.Dimension", "$.Point", "$.Rectangle", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.tree = null; -this.scrollPane = null; -this.av = null; -this.$font = null; -this.fitToWindow = true; -this.showDistances = false; -this.showBootstrap = false; -this.markPlaceholders = false; -this.offx = 20; -this.offy = 0; -this.threshold = 0; -this.longestName = null; -this.labelLength = -1; -this.nameHash = null; -this.nodeHash = null; -this.highlightNode = null; -this.ap = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "TreeCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); -Clazz.prepareFields (c$, function () { -this.nameHash = new java.util.Hashtable (); -this.nodeHash = new java.util.Hashtable (); -}); -Clazz.makeConstructor (c$, -function (ap, scroller) { -Clazz.superConstructor (this, jalview.appletgui.TreeCanvas, []); -this.ap = ap; -this.av = ap.av; -this.$font = this.av.getFont (); -this.scrollPane = scroller; -this.addMouseListener (this); -this.addMouseMotionListener (this); -this.setLayout (null); -jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ()); -}, "jalview.appletgui.AlignmentPanel,awt2swing.ScrollPane"); -Clazz.defineMethod (c$, "treeSelectionChanged", -function (sequence) { -var selected = this.av.getSelectionGroup (); -if (selected == null) { -selected = new jalview.datamodel.SequenceGroup (); -this.av.setSelectionGroup (selected); -}selected.setEndRes (this.av.getAlignment ().getWidth () - 1); -selected.addOrRemove (sequence, true); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "setTree", -function (tree) { -this.tree = tree; -tree.findHeight (tree.getTopNode ()); -var leaves = tree.findLeaves (tree.getTopNode (), new java.util.Vector ()); -var has_placeholders = false; -this.longestName = ""; -for (var i = 0; i < leaves.size (); i++) { -var lf = leaves.elementAt (i); -if (lf.isPlaceholder ()) { -has_placeholders = true; -}if (this.longestName.length < (lf.element ()).getName ().length) { -this.longestName = " * " + (lf.element ()).getName (); -}} -this.setMarkPlaceholders (has_placeholders); -}, "jalview.analysis.NJTree"); -Clazz.defineMethod (c$, "drawNode", -function (g, node, chunk, scale, width, offx, offy) { -if (node == null) { -return; -}if (node.left () == null && node.right () == null) { -var height = node.height; -var dist = node.dist; -var xstart = Clazz.floatToInt ((height - dist) * scale) + offx; -var xend = Clazz.floatToInt (height * scale) + offx; -var ypos = Clazz.floatToInt (node.ycount * chunk) + offy; -if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { -var seq = node.element (); -if (this.av.getSequenceColour (seq) === java.awt.Color.white) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (this.av.getSequenceColour (seq).darker ()); -}} else { -g.setColor (java.awt.Color.black); -}g.drawLine (xstart, ypos, xend, ypos); -var nodeLabel = ""; -if (this.showDistances && node.dist > 0) { -nodeLabel = new jalview.util.Format ("%-.2f").formDouble (node.dist); -}if (this.showBootstrap) { -var btstrap = node.getBootstrap (); -if (btstrap > -1) { -if (this.showDistances) { -nodeLabel = nodeLabel + " : "; -}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ()); -}}if (!nodeLabel.equals ("")) { -g.drawString (nodeLabel, xstart + 2, ypos - 2); -}var name = (this.markPlaceholders && node.isPlaceholder ()) ? (" * " + node.getName ()) : node.getName (); -var fm = g.getFontMetrics (this.$font); -var charWidth = fm.stringWidth (name) + 3; -var charHeight = fm.getHeight (); -var rect = new java.awt.Rectangle (xend + 10, ypos - charHeight, charWidth, charHeight); -this.nameHash.put (node.element (), rect); -var selected = this.av.getSelectionGroup (); -if (selected != null && selected.getSequences (null).contains (node.element ())) { -g.setColor (java.awt.Color.gray); -g.fillRect (xend + 10, ypos - charHeight + 3, charWidth, charHeight); -g.setColor (java.awt.Color.white); -}g.drawString (name, xend + 10, ypos); -g.setColor (java.awt.Color.black); -} else { -this.drawNode (g, node.left (), chunk, scale, width, offx, offy); -this.drawNode (g, node.right (), chunk, scale, width, offx, offy); -var height = node.height; -var dist = node.dist; -var xstart = Clazz.floatToInt ((height - dist) * scale) + offx; -var xend = Clazz.floatToInt (height * scale) + offx; -var ypos = Clazz.floatToInt (node.ycount * chunk) + offy; -g.setColor (node.color.darker ()); -g.drawLine (xstart, ypos, xend, ypos); -if (node === this.highlightNode) { -g.fillRect (xend - 3, ypos - 3, 6, 6); -} else { -g.fillRect (xend - 2, ypos - 2, 4, 4); -}var ystart = Clazz.floatToInt ((node.left ()).ycount * chunk) + offy; -var yend = Clazz.floatToInt ((node.right ()).ycount * chunk) + offy; -var pos = new java.awt.Rectangle (xend - 2, ypos - 2, 5, 5); -this.nodeHash.put (node, pos); -g.drawLine (Clazz.floatToInt (height * scale) + offx, ystart, Clazz.floatToInt (height * scale) + offx, yend); -var nodeLabel = ""; -if (this.showDistances && (node.dist > 0)) { -nodeLabel = new jalview.util.Format ("%-.2f").formDouble (node.dist); -}if (this.showBootstrap) { -var btstrap = node.getBootstrap (); -if (btstrap > -1) { -if (this.showDistances) { -nodeLabel = nodeLabel + " : "; -}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ()); -}}if (!nodeLabel.equals ("")) { -g.drawString (nodeLabel, xstart + 2, ypos - 2); -}}}, "java.awt.Graphics,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "findElement", -function (x, y) { -var keys = this.nameHash.keys (); -while (keys.hasMoreElements ()) { -var ob = keys.nextElement (); -var rect = this.nameHash.get (ob); -if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) { -return ob; -}} -keys = this.nodeHash.keys (); -while (keys.hasMoreElements ()) { -var ob = keys.nextElement (); -var rect = this.nodeHash.get (ob); -if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) { -return ob; -}} -return null; -}, "~N,~N"); -Clazz.defineMethod (c$, "pickNodes", -function (pickBox) { -var width = this.getSize ().width; -var height = this.getSize ().height; -var top = this.tree.getTopNode (); -var wscale = (width * .8 - this.offx * 2) / this.tree.getMaxHeight (); -if (top.count == 0) { -top.count = (top.left ()).count + (top.right ()).count; -}var chunk = (height - this.offy) / top.count; -this.pickNode (pickBox, top, chunk, wscale, width, this.offx, this.offy); -}, "java.awt.Rectangle"); -Clazz.defineMethod (c$, "pickNode", -function (pickBox, node, chunk, scale, width, offx, offy) { -if (node == null) { -return; -}if (node.left () == null && node.right () == null) { -var height = node.height; -var xend = Clazz.floatToInt (height * scale) + offx; -var ypos = Clazz.floatToInt (node.ycount * chunk) + offy; -if (pickBox.contains ( new java.awt.Point (xend, ypos))) { -if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { -var seq = node.element (); -var sg = this.av.getSelectionGroup (); -if (sg != null) { -sg.addOrRemove (seq, true); -}}}} else { -this.pickNode (pickBox, node.left (), chunk, scale, width, offx, offy); -this.pickNode (pickBox, node.right (), chunk, scale, width, offx, offy); -}}, "java.awt.Rectangle,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "setColor", -function (node, c) { -if (node == null) { -return; -}if (node.left () == null && node.right () == null) { -node.color = c; -if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { -this.av.setSequenceColour (node.element (), c); -}} else { -node.color = c; -this.setColor (node.left (), c); -this.setColor (node.right (), c); -}}, "jalview.datamodel.SequenceNode,java.awt.Color"); -Clazz.overrideMethod (c$, "update", -function (g) { -this.paint (g); -}, "java.awt.Graphics"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.tree == null) { -return; -}if (this.nameHash.size () == 0) { -this.repaint (); -}var width = this.scrollPane.getSize ().width; -var height = this.scrollPane.getSize ().height; -if (!this.fitToWindow) { -height = g.getFontMetrics (this.$font).getHeight () * this.nameHash.size (); -}if (this.getSize ().width > width) { -this.setSize ( new java.awt.Dimension (width, height)); -this.scrollPane.validate (); -return; -}this.setSize ( new java.awt.Dimension (width, height)); -g.setFont (this.$font); -this.draw (g, width, height); -this.validate (); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "draw", -function (g, width, height) { -this.offy = this.$font.getSize () + 10; -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, width, height); -this.labelLength = g.getFontMetrics (this.$font).stringWidth (this.longestName) + 20; -var wscale = (width - this.labelLength - this.offx * 2) / this.tree.getMaxHeight (); -var top = this.tree.getTopNode (); -if (top.count == 0) { -top.count = (top.left ()).count + (top.right ()).count; -}var chunk = (height - this.offy) / top.count; -this.drawNode (g, this.tree.getTopNode (), chunk, wscale, width, this.offx, this.offy); -if (this.threshold != 0) { -if (this.av.getCurrentTree () === this.tree) { -g.setColor (java.awt.Color.red); -} else { -g.setColor (java.awt.Color.gray); -}var x = Clazz.floatToInt (this.threshold * (this.getSize ().width - this.labelLength - 2 * this.offx) + this.offx); -g.drawLine (x, 0, x, this.getSize ().height); -}}, "java.awt.Graphics,~N,~N"); -Clazz.overrideMethod (c$, "mouseReleased", -function (e) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (e) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (e) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -if (this.highlightNode != null) { -if (evt.getClickCount () > 1) { -this.tree.swapNodes (this.highlightNode); -this.tree.reCount (this.tree.getTopNode ()); -this.tree.findHeight (this.tree.getTopNode ()); -} else { -var leaves = new java.util.Vector (); -this.tree.findLeaves (this.highlightNode, leaves); -for (var i = 0; i < leaves.size (); i++) { -var seq = (leaves.elementAt (i)).element (); -this.treeSelectionChanged (seq); -} -}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); -this.repaint (); -this.av.sendSelection (); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (ect) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -this.av.setCurrentTree (this.tree); -var ob = this.findElement (evt.getX (), evt.getY ()); -if (Clazz.instanceOf (ob, jalview.datamodel.SequenceNode)) { -this.highlightNode = ob; -this.repaint (); -} else { -if (this.highlightNode != null) { -this.highlightNode = null; -this.repaint (); -}}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (e) { -this.av.setCurrentTree (this.tree); -var x = e.getX (); -var y = e.getY (); -var ob = this.findElement (x, y); -if (Clazz.instanceOf (ob, jalview.datamodel.SequenceI)) { -this.treeSelectionChanged (ob); -jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); -this.repaint (); -this.av.sendSelection (); -return; -} else if (!(Clazz.instanceOf (ob, jalview.datamodel.SequenceNode))) { -if (this.tree.getMaxHeight () != 0) { -this.threshold = (x - this.offx) / (this.getSize ().width - this.labelLength - 2 * this.offx); -this.tree.getGroups ().removeAllElements (); -this.tree.groupNodes (this.tree.getTopNode (), this.threshold); -this.setColor (this.tree.getTopNode (), java.awt.Color.black); -this.av.setSelectionGroup (null); -this.av.getAlignment ().deleteAllGroups (); -this.av.clearSequenceColours (); -var codingComplement = this.av.getCodingComplement (); -if (codingComplement != null) { -codingComplement.setSelectionGroup (null); -codingComplement.getAlignment ().deleteAllGroups (); -codingComplement.clearSequenceColours (); -}this.colourGroups (); -}}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); -this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "colourGroups", -function () { -for (var i = 0; i < this.tree.getGroups ().size (); i++) { -var col = new java.awt.Color (Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255)); -this.setColor (this.tree.getGroups ().elementAt (i), col.brighter ()); -var l = this.tree.findLeaves (this.tree.getGroups ().elementAt (i), new java.util.Vector ()); -var sequences = new java.util.Vector (); -for (var j = 0; j < l.size (); j++) { -var s1 = (l.elementAt (j)).element (); -if (!sequences.contains (s1)) { -sequences.addElement (s1); -}} -var cs = null; -var sg = new jalview.datamodel.SequenceGroup (sequences, "", cs, true, true, false, 0, this.av.getAlignment ().getWidth () - 1); -if (this.av.getGlobalColourScheme () != null) { -if (Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.UserColourScheme)) { -cs = new jalview.schemes.UserColourScheme ((this.av.getGlobalColourScheme ()).getColours ()); -} else { -cs = jalview.schemes.ColourSchemeProperty.getColour (sg, jalview.schemes.ColourSchemeProperty.getColourName (this.av.getGlobalColourScheme ())); -}if (cs != null) { -cs.setThreshold (this.av.getGlobalColourScheme ().getThreshold (), this.av.isIgnoreGapsConsensus ()); -}}sg.cs = cs; -sg.setName ("JTreeGroup:" + sg.hashCode ()); -sg.setIdColour (col); -if (this.av.getGlobalColourScheme () != null && this.av.getGlobalColourScheme ().conservationApplied ()) { -var c = new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes ()); -c.calculate (); -c.verdict (false, this.av.getConsPercGaps ()); -cs.setConservation (c); -sg.cs = cs; -}this.av.getAlignment ().addGroup (sg); -this.av.getAlignment ().addGroup (sg); -var codingComplement = this.av.getCodingComplement (); -if (codingComplement != null) { -var mappedGroup = jalview.util.MappingUtils.mapSequenceGroup (sg, this.av, codingComplement); -if (mappedGroup.getSequences ().size () > 0) { -codingComplement.getAlignment ().addGroup (mappedGroup); -for (var seq, $seq = mappedGroup.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -codingComplement.setSequenceColour (seq, col); -} -}}} -this.ap.updateAnnotation (); -if (this.av.getCodingComplement () != null) { -(this.av.getCodingComplement ()).firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); -}}); -Clazz.defineMethod (c$, "setShowDistances", -function (state) { -this.showDistances = state; -this.repaint (); -}, "~B"); -Clazz.defineMethod (c$, "setShowBootstrap", -function (state) { -this.showBootstrap = state; -this.repaint (); -}, "~B"); -Clazz.defineMethod (c$, "setMarkPlaceholders", -function (state) { -this.markPlaceholders = state; -this.repaint (); -}, "~B"); -Clazz.defineStatics (c$, -"PLACEHOLDER", " * "); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.MouseListener", "$.MouseMotionListener", "java.util.Hashtable"], "jalview.appletgui.TreeCanvas", ["jalview.analysis.Conservation", "jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "$.SequenceI", "$.SequenceNode", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Format", "$.MappingUtils", "java.awt.Color", "$.Dimension", "$.Point", "$.Rectangle", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.tree = null; +this.scrollPane = null; +this.av = null; +this.$font = null; +this.fitToWindow = true; +this.showDistances = false; +this.showBootstrap = false; +this.markPlaceholders = false; +this.offx = 20; +this.offy = 0; +this.threshold = 0; +this.longestName = null; +this.labelLength = -1; +this.nameHash = null; +this.nodeHash = null; +this.highlightNode = null; +this.ap = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "TreeCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); +Clazz.prepareFields (c$, function () { +this.nameHash = new java.util.Hashtable (); +this.nodeHash = new java.util.Hashtable (); +}); +Clazz.makeConstructor (c$, +function (ap, scroller) { +Clazz.superConstructor (this, jalview.appletgui.TreeCanvas, []); +this.ap = ap; +this.av = ap.av; +this.$font = this.av.getFont (); +this.scrollPane = scroller; +this.addMouseListener (this); +this.addMouseMotionListener (this); +this.setLayout (null); +jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ()); +}, "jalview.appletgui.AlignmentPanel,awt2swing.ScrollPane"); +Clazz.defineMethod (c$, "treeSelectionChanged", +function (sequence) { +var selected = this.av.getSelectionGroup (); +if (selected == null) { +selected = new jalview.datamodel.SequenceGroup (); +this.av.setSelectionGroup (selected); +}selected.setEndRes (this.av.getAlignment ().getWidth () - 1); +selected.addOrRemove (sequence, true); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "setTree", +function (tree) { +this.tree = tree; +tree.findHeight (tree.getTopNode ()); +var leaves = tree.findLeaves (tree.getTopNode (), new java.util.Vector ()); +var has_placeholders = false; +this.longestName = ""; +for (var i = 0; i < leaves.size (); i++) { +var lf = leaves.elementAt (i); +if (lf.isPlaceholder ()) { +has_placeholders = true; +}if (this.longestName.length < (lf.element ()).getName ().length) { +this.longestName = " * " + (lf.element ()).getName (); +}} +this.setMarkPlaceholders (has_placeholders); +}, "jalview.analysis.NJTree"); +Clazz.defineMethod (c$, "drawNode", +function (g, node, chunk, scale, width, offx, offy) { +if (node == null) { +return; +}if (node.left () == null && node.right () == null) { +var height = node.height; +var dist = node.dist; +var xstart = Clazz.floatToInt ((height - dist) * scale) + offx; +var xend = Clazz.floatToInt (height * scale) + offx; +var ypos = Clazz.floatToInt (node.ycount * chunk) + offy; +if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { +var seq = node.element (); +if (this.av.getSequenceColour (seq) === java.awt.Color.white) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (this.av.getSequenceColour (seq).darker ()); +}} else { +g.setColor (java.awt.Color.black); +}g.drawLine (xstart, ypos, xend, ypos); +var nodeLabel = ""; +if (this.showDistances && node.dist > 0) { +nodeLabel = new jalview.util.Format ("%-.2f").formDouble (node.dist); +}if (this.showBootstrap) { +var btstrap = node.getBootstrap (); +if (btstrap > -1) { +if (this.showDistances) { +nodeLabel = nodeLabel + " : "; +}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ()); +}}if (!nodeLabel.equals ("")) { +g.drawString (nodeLabel, xstart + 2, ypos - 2); +}var name = (this.markPlaceholders && node.isPlaceholder ()) ? (" * " + node.getName ()) : node.getName (); +var fm = g.getFontMetrics (this.$font); +var charWidth = fm.stringWidth (name) + 3; +var charHeight = fm.getHeight (); +var rect = new java.awt.Rectangle (xend + 10, ypos - charHeight, charWidth, charHeight); +this.nameHash.put (node.element (), rect); +var selected = this.av.getSelectionGroup (); +if (selected != null && selected.getSequences (null).contains (node.element ())) { +g.setColor (java.awt.Color.gray); +g.fillRect (xend + 10, ypos - charHeight + 3, charWidth, charHeight); +g.setColor (java.awt.Color.white); +}g.drawString (name, xend + 10, ypos); +g.setColor (java.awt.Color.black); +} else { +this.drawNode (g, node.left (), chunk, scale, width, offx, offy); +this.drawNode (g, node.right (), chunk, scale, width, offx, offy); +var height = node.height; +var dist = node.dist; +var xstart = Clazz.floatToInt ((height - dist) * scale) + offx; +var xend = Clazz.floatToInt (height * scale) + offx; +var ypos = Clazz.floatToInt (node.ycount * chunk) + offy; +g.setColor (node.color.darker ()); +g.drawLine (xstart, ypos, xend, ypos); +if (node === this.highlightNode) { +g.fillRect (xend - 3, ypos - 3, 6, 6); +} else { +g.fillRect (xend - 2, ypos - 2, 4, 4); +}var ystart = Clazz.floatToInt ((node.left ()).ycount * chunk) + offy; +var yend = Clazz.floatToInt ((node.right ()).ycount * chunk) + offy; +var pos = new java.awt.Rectangle (xend - 2, ypos - 2, 5, 5); +this.nodeHash.put (node, pos); +g.drawLine (Clazz.floatToInt (height * scale) + offx, ystart, Clazz.floatToInt (height * scale) + offx, yend); +var nodeLabel = ""; +if (this.showDistances && (node.dist > 0)) { +nodeLabel = new jalview.util.Format ("%-.2f").formDouble (node.dist); +}if (this.showBootstrap) { +var btstrap = node.getBootstrap (); +if (btstrap > -1) { +if (this.showDistances) { +nodeLabel = nodeLabel + " : "; +}nodeLabel = nodeLabel + String.valueOf (node.getBootstrap ()); +}}if (!nodeLabel.equals ("")) { +g.drawString (nodeLabel, xstart + 2, ypos - 2); +}}}, "java.awt.Graphics,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "findElement", +function (x, y) { +var keys = this.nameHash.keys (); +while (keys.hasMoreElements ()) { +var ob = keys.nextElement (); +var rect = this.nameHash.get (ob); +if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) { +return ob; +}} +keys = this.nodeHash.keys (); +while (keys.hasMoreElements ()) { +var ob = keys.nextElement (); +var rect = this.nodeHash.get (ob); +if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height)) { +return ob; +}} +return null; +}, "~N,~N"); +Clazz.defineMethod (c$, "pickNodes", +function (pickBox) { +var width = this.getSize ().width; +var height = this.getSize ().height; +var top = this.tree.getTopNode (); +var wscale = (width * .8 - this.offx * 2) / this.tree.getMaxHeight (); +if (top.count == 0) { +top.count = (top.left ()).count + (top.right ()).count; +}var chunk = (height - this.offy) / top.count; +this.pickNode (pickBox, top, chunk, wscale, width, this.offx, this.offy); +}, "java.awt.Rectangle"); +Clazz.defineMethod (c$, "pickNode", +function (pickBox, node, chunk, scale, width, offx, offy) { +if (node == null) { +return; +}if (node.left () == null && node.right () == null) { +var height = node.height; +var xend = Clazz.floatToInt (height * scale) + offx; +var ypos = Clazz.floatToInt (node.ycount * chunk) + offy; +if (pickBox.contains ( new java.awt.Point (xend, ypos))) { +if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { +var seq = node.element (); +var sg = this.av.getSelectionGroup (); +if (sg != null) { +sg.addOrRemove (seq, true); +}}}} else { +this.pickNode (pickBox, node.left (), chunk, scale, width, offx, offy); +this.pickNode (pickBox, node.right (), chunk, scale, width, offx, offy); +}}, "java.awt.Rectangle,jalview.datamodel.SequenceNode,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "setColor", +function (node, c) { +if (node == null) { +return; +}if (node.left () == null && node.right () == null) { +node.color = c; +if (Clazz.instanceOf (node.element (), jalview.datamodel.SequenceI)) { +this.av.setSequenceColour (node.element (), c); +}} else { +node.color = c; +this.setColor (node.left (), c); +this.setColor (node.right (), c); +}}, "jalview.datamodel.SequenceNode,java.awt.Color"); +Clazz.overrideMethod (c$, "update", +function (g) { +this.paint (g); +}, "java.awt.Graphics"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.tree == null) { +return; +}if (this.nameHash.size () == 0) { +this.repaint (); +}var width = this.scrollPane.getSize ().width; +var height = this.scrollPane.getSize ().height; +if (!this.fitToWindow) { +height = g.getFontMetrics (this.$font).getHeight () * this.nameHash.size (); +}if (this.getSize ().width > width) { +this.setSize ( new java.awt.Dimension (width, height)); +this.scrollPane.validate (); +return; +}this.setSize ( new java.awt.Dimension (width, height)); +g.setFont (this.$font); +this.draw (g, width, height); +this.validate (); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "draw", +function (g, width, height) { +this.offy = this.$font.getSize () + 10; +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, width, height); +this.labelLength = g.getFontMetrics (this.$font).stringWidth (this.longestName) + 20; +var wscale = (width - this.labelLength - this.offx * 2) / this.tree.getMaxHeight (); +var top = this.tree.getTopNode (); +if (top.count == 0) { +top.count = (top.left ()).count + (top.right ()).count; +}var chunk = (height - this.offy) / top.count; +this.drawNode (g, this.tree.getTopNode (), chunk, wscale, width, this.offx, this.offy); +if (this.threshold != 0) { +if (this.av.getCurrentTree () === this.tree) { +g.setColor (java.awt.Color.red); +} else { +g.setColor (java.awt.Color.gray); +}var x = Clazz.floatToInt (this.threshold * (this.getSize ().width - this.labelLength - 2 * this.offx) + this.offx); +g.drawLine (x, 0, x, this.getSize ().height); +}}, "java.awt.Graphics,~N,~N"); +Clazz.overrideMethod (c$, "mouseReleased", +function (e) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (e) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (e) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +if (this.highlightNode != null) { +if (evt.getClickCount () > 1) { +this.tree.swapNodes (this.highlightNode); +this.tree.reCount (this.tree.getTopNode ()); +this.tree.findHeight (this.tree.getTopNode ()); +} else { +var leaves = new java.util.Vector (); +this.tree.findLeaves (this.highlightNode, leaves); +for (var i = 0; i < leaves.size (); i++) { +var seq = (leaves.elementAt (i)).element (); +this.treeSelectionChanged (seq); +} +}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); +this.repaint (); +this.av.sendSelection (); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (ect) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +this.av.setCurrentTree (this.tree); +var ob = this.findElement (evt.getX (), evt.getY ()); +if (Clazz.instanceOf (ob, jalview.datamodel.SequenceNode)) { +this.highlightNode = ob; +this.repaint (); +} else { +if (this.highlightNode != null) { +this.highlightNode = null; +this.repaint (); +}}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (e) { +this.av.setCurrentTree (this.tree); +var x = e.getX (); +var y = e.getY (); +var ob = this.findElement (x, y); +if (Clazz.instanceOf (ob, jalview.datamodel.SequenceI)) { +this.treeSelectionChanged (ob); +jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); +this.repaint (); +this.av.sendSelection (); +return; +} else if (!(Clazz.instanceOf (ob, jalview.datamodel.SequenceNode))) { +if (this.tree.getMaxHeight () != 0) { +this.threshold = (x - this.offx) / (this.getSize ().width - this.labelLength - 2 * this.offx); +this.tree.getGroups ().removeAllElements (); +this.tree.groupNodes (this.tree.getTopNode (), this.threshold); +this.setColor (this.tree.getTopNode (), java.awt.Color.black); +this.av.setSelectionGroup (null); +this.av.getAlignment ().deleteAllGroups (); +this.av.clearSequenceColours (); +var codingComplement = this.av.getCodingComplement (); +if (codingComplement != null) { +codingComplement.setSelectionGroup (null); +codingComplement.getAlignment ().deleteAllGroups (); +codingComplement.clearSequenceColours (); +}this.colourGroups (); +}}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); +this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "colourGroups", +function () { +for (var i = 0; i < this.tree.getGroups ().size (); i++) { +var col = new java.awt.Color (Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255)); +this.setColor (this.tree.getGroups ().elementAt (i), col.brighter ()); +var l = this.tree.findLeaves (this.tree.getGroups ().elementAt (i), new java.util.Vector ()); +var sequences = new java.util.Vector (); +for (var j = 0; j < l.size (); j++) { +var s1 = (l.elementAt (j)).element (); +if (!sequences.contains (s1)) { +sequences.addElement (s1); +}} +var cs = null; +var sg = new jalview.datamodel.SequenceGroup (sequences, "", cs, true, true, false, 0, this.av.getAlignment ().getWidth () - 1); +if (this.av.getGlobalColourScheme () != null) { +if (Clazz.instanceOf (this.av.getGlobalColourScheme (), jalview.schemes.UserColourScheme)) { +cs = new jalview.schemes.UserColourScheme ((this.av.getGlobalColourScheme ()).getColours ()); +} else { +cs = jalview.schemes.ColourSchemeProperty.getColour (sg, jalview.schemes.ColourSchemeProperty.getColourName (this.av.getGlobalColourScheme ())); +}if (cs != null) { +cs.setThreshold (this.av.getGlobalColourScheme ().getThreshold (), this.av.isIgnoreGapsConsensus ()); +}}sg.cs = cs; +sg.setName ("JTreeGroup:" + sg.hashCode ()); +sg.setIdColour (col); +if (this.av.getGlobalColourScheme () != null && this.av.getGlobalColourScheme ().conservationApplied ()) { +var c = new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes ()); +c.calculate (); +c.verdict (false, this.av.getConsPercGaps ()); +cs.setConservation (c); +sg.cs = cs; +}this.av.getAlignment ().addGroup (sg); +this.av.getAlignment ().addGroup (sg); +var codingComplement = this.av.getCodingComplement (); +if (codingComplement != null) { +var mappedGroup = jalview.util.MappingUtils.mapSequenceGroup (sg, this.av, codingComplement); +if (mappedGroup.getSequences ().size () > 0) { +codingComplement.getAlignment ().addGroup (mappedGroup); +for (var seq, $seq = mappedGroup.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +codingComplement.setSequenceColour (seq, col); +} +}}} +this.ap.updateAnnotation (); +if (this.av.getCodingComplement () != null) { +(this.av.getCodingComplement ()).firePropertyChange ("alignment", null, this.ap.av.getAlignment ().getSequences ()); +}}); +Clazz.defineMethod (c$, "setShowDistances", +function (state) { +this.showDistances = state; +this.repaint (); +}, "~B"); +Clazz.defineMethod (c$, "setShowBootstrap", +function (state) { +this.showBootstrap = state; +this.repaint (); +}, "~B"); +Clazz.defineMethod (c$, "setMarkPlaceholders", +function (state) { +this.markPlaceholders = state; +this.repaint (); +}, "~B"); +Clazz.defineStatics (c$, +"PLACEHOLDER", " * "); +}); diff --git a/bin/jalview/appletgui/TreePanel.js b/bin/jalview/appletgui/TreePanel.js index 77a1db5..4d0d747 100644 --- a/bin/jalview/appletgui/TreePanel.js +++ b/bin/jalview/appletgui/TreePanel.js @@ -1,261 +1,261 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["jalview.appletgui.EmbmenuFrame", "java.awt.event.ActionListener", "$.ItemListener", "java.lang.Thread", "awt2swing.CheckboxMenuItem", "$.Menu", "$.MenuBar", "$.MenuItem", "$.ScrollPane", "java.awt.BorderLayout"], "jalview.appletgui.TreePanel", ["awt2swing.Frame", "jalview.analysis.NJTree", "jalview.api.analysis.ViewBasedAnalysisI", "jalview.appletgui.AlignFrame", "$.CutAndPasteTransfer", "$.FontChooser", "$.TreeCanvas", "jalview.bin.JalviewLite", "jalview.datamodel.Alignment", "jalview.io.NewickFile", "jalview.schemes.ResidueProperties", "jalview.util.MessageManager", "java.awt.Color", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.seq = null; -this.$type = null; -this.pwtype = null; -this.start = 0; -this.end = 0; -this.treeCanvas = null; -this.tree = null; -this.ap = null; -this.av = null; -if (!Clazz.isClassDefined ("jalview.appletgui.TreePanel.TreeLoader")) { -jalview.appletgui.TreePanel.$TreePanel$TreeLoader$ (); -} -this.borderLayout1 = null; -this.scrollPane = null; -this.jMenuBar1 = null; -this.jMenu2 = null; -this.fontSize = null; -this.bootstrapMenu = null; -this.distanceMenu = null; -this.placeholdersMenu = null; -this.fitToWindow = null; -this.fileMenu = null; -this.newickOutput = null; -this.inputData = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "TreePanel", jalview.appletgui.EmbmenuFrame, [java.awt.event.ActionListener, java.awt.event.ItemListener]); -Clazz.prepareFields (c$, function () { -this.borderLayout1 = new java.awt.BorderLayout (); -this.scrollPane = new awt2swing.ScrollPane (); -this.jMenuBar1 = new awt2swing.MenuBar (); -this.jMenu2 = new awt2swing.Menu (); -this.fontSize = new awt2swing.MenuItem (); -this.bootstrapMenu = new awt2swing.CheckboxMenuItem (); -this.distanceMenu = new awt2swing.CheckboxMenuItem (); -this.placeholdersMenu = new awt2swing.CheckboxMenuItem (); -this.fitToWindow = new awt2swing.CheckboxMenuItem (); -this.fileMenu = new awt2swing.Menu (); -this.newickOutput = new awt2swing.MenuItem (); -this.inputData = new awt2swing.MenuItem (); -}); -Clazz.defineMethod (c$, "getTree", -function () { -return this.tree; -}); -Clazz.defineMethod (c$, "finalize", -function () { -this.ap = null; -this.av = null; -Clazz.superCall (this, jalview.appletgui.TreePanel, "finalize", []); -}); -Clazz.makeConstructor (c$, -function (ap, type, pwtype) { -Clazz.superConstructor (this, jalview.appletgui.TreePanel, []); -try { -this.jbInit (); -this.setMenuBar (this.jMenuBar1); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -this.initTreePanel (ap, type, pwtype, null); -}, "jalview.appletgui.AlignmentPanel,~S,~S"); -Clazz.makeConstructor (c$, -function (ap, type, pwtype, newtree) { -Clazz.superConstructor (this, jalview.appletgui.TreePanel, []); -try { -this.jbInit (); -this.setMenuBar (this.jMenuBar1); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.initTreePanel (ap, type, pwtype, newtree); -}, "jalview.appletgui.AlignmentPanel,~S,~S,jalview.io.NewickFile"); -Clazz.defineMethod (c$, "initTreePanel", -function (ap, type, pwtype, newTree) { -this.ap = ap; -this.av = ap.av; -this.$type = type; -this.pwtype = pwtype; -this.treeCanvas = new jalview.appletgui.TreeCanvas (ap, this.scrollPane); -var tl = Clazz.innerTypeInstance (jalview.appletgui.TreePanel.TreeLoader, this, null, newTree); -tl.start (); -this.embedMenuIfNeeded (this.treeCanvas); -this.scrollPane.add (this.treeCanvas, "Center"); -}, "jalview.appletgui.AlignmentPanel,~S,~S,jalview.io.NewickFile"); -Clazz.defineMethod (c$, "showOriginalData", -function () { -if (this.tree.seqData != null) { -var gc = '-'; -try { -gc = this.av.getGapCharacter (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -;var alAndColsel = this.tree.seqData.getAlignmentAndColumnSelection (gc); -if (alAndColsel != null && alAndColsel[0] != null) { -var al = new jalview.datamodel.Alignment (alAndColsel[0]); -var af = new jalview.appletgui.AlignFrame (al, this.av.applet, "Original Data for Tree", false); -af.viewport.setHiddenColumns (alAndColsel[1]); -}} else { -System.out.println ("Original Tree Data not available"); -}}); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -if (evt.getSource () === this.newickOutput) { -this.newickOutput_actionPerformed (); -} else if (evt.getSource () === this.fontSize) { -this.fontSize_actionPerformed (); -} else if (evt.getSource () === this.inputData) { -this.showOriginalData (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "itemStateChanged", -function (evt) { -if (evt.getSource () === this.fitToWindow) { -this.treeCanvas.fitToWindow = this.fitToWindow.getState (); -} else if (evt.getSource () === this.distanceMenu) { -this.treeCanvas.setShowDistances (this.distanceMenu.getState ()); -} else if (evt.getSource () === this.bootstrapMenu) { -this.treeCanvas.setShowBootstrap (this.bootstrapMenu.getState ()); -} else if (evt.getSource () === this.placeholdersMenu) { -this.treeCanvas.setMarkPlaceholders (this.placeholdersMenu.getState ()); -}this.treeCanvas.repaint (); -}, "java.awt.event.ItemEvent"); -Clazz.defineMethod (c$, "newickOutput_actionPerformed", -function () { -var fout = new jalview.io.NewickFile (this.tree.getTopNode ()); -var output = fout.print (false, true); -var cap = new jalview.appletgui.CutAndPasteTransfer (false, null); -cap.setText (output); -var frame = new awt2swing.Frame (); -frame.add (cap); -jalview.bin.JalviewLite.addFrame (frame, this.$type + " " + this.pwtype, 500, 100); -}); -Clazz.defineMethod (c$, "getTreeFont", -function () { -return this.treeCanvas.$font; -}); -Clazz.defineMethod (c$, "setTreeFont", -function (font) { -this.treeCanvas.$font = font; -this.treeCanvas.repaint (); -}, "java.awt.Font"); -Clazz.defineMethod (c$, "fontSize_actionPerformed", -function () { -if (this.treeCanvas == null) { -return; -} new jalview.appletgui.FontChooser (this); -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout (this.borderLayout1); -this.setBackground (java.awt.Color.white); -this.setFont ( new java.awt.Font ("Verdana", 0, 12)); -this.jMenu2.setLabel (jalview.util.MessageManager.getString ("action.view")); -this.fontSize.setLabel (jalview.util.MessageManager.getString ("action.font")); -this.fontSize.addActionListener (this); -this.bootstrapMenu.setLabel (jalview.util.MessageManager.getString ("label.show_bootstrap_values")); -this.bootstrapMenu.addItemListener (this); -this.distanceMenu.setLabel (jalview.util.MessageManager.getString ("label.show_distances")); -this.distanceMenu.addItemListener (this); -this.placeholdersMenu.setLabel (jalview.util.MessageManager.getString ("label.mark_unassociated_leaves")); -this.placeholdersMenu.addItemListener (this); -this.fitToWindow.setState (true); -this.fitToWindow.setLabel (jalview.util.MessageManager.getString ("label.fit_to_window")); -this.fitToWindow.addItemListener (this); -this.fileMenu.setLabel (jalview.util.MessageManager.getString ("action.file")); -this.newickOutput.setLabel (jalview.util.MessageManager.getString ("label.newick_format")); -this.newickOutput.addActionListener (this); -this.inputData.setLabel (jalview.util.MessageManager.getString ("label.input_data")); -this.add (this.scrollPane, "Center"); -this.jMenuBar1.add (this.fileMenu); -this.jMenuBar1.add (this.jMenu2); -this.jMenu2.add (this.fitToWindow); -this.jMenu2.add (this.fontSize); -this.jMenu2.add (this.distanceMenu); -this.jMenu2.add (this.bootstrapMenu); -this.jMenu2.add (this.placeholdersMenu); -this.fileMenu.add (this.newickOutput); -this.fileMenu.add (this.inputData); -this.inputData.addActionListener (this); -}, $fz.isPrivate = true, $fz)); -c$.$TreePanel$TreeLoader$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.newtree = null; -this.odata = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui.TreePanel, "TreeLoader", Thread); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.appletgui.TreePanel.TreeLoader, []); -this.newtree = a; -}, "jalview.io.NewickFile"); -Clazz.overrideMethod (c$, "run", -function () { -if (this.newtree != null) { -if (this.odata == null) { -this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getSequencesArray (), this.newtree); -} else { -this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getSequencesArray (), this.odata, this.newtree); -}} else { -var a; -var b; -var c; -var d = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup () != null && this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getSize () > 1; -var e = this.b$["jalview.appletgui.TreePanel"].av.getAlignmentView (d); -if (!d) { -a = 0; -b = this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getWidth (); -c = this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getSequencesArray (); -} else { -a = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getStartRes (); -b = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getEndRes () + 1; -c = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getSequencesInOrder (this.b$["jalview.appletgui.TreePanel"].av.getAlignment ()); -}var f = jalview.schemes.ResidueProperties.getScoreModel (this.b$["jalview.appletgui.TreePanel"].pwtype); -if (Clazz.instanceOf (f, jalview.api.analysis.ViewBasedAnalysisI)) { -try { -f = f.getClass ().newInstance (); -(f).configureFromAlignmentView (this.b$["jalview.appletgui.TreePanel"].treeCanvas.ap); -} catch (q) { -if (Clazz.exceptionOf (q, Exception)) { -System.err.println ("Couldn't create a scoremodel instance for " + f.getName ()); -q.printStackTrace (); -} else { -throw q; -} -} -this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (c, e, this.b$["jalview.appletgui.TreePanel"].$type, this.b$["jalview.appletgui.TreePanel"].pwtype, f, a, b); -} else { -this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (c, e, this.b$["jalview.appletgui.TreePanel"].$type, this.b$["jalview.appletgui.TreePanel"].pwtype, null, a, b); -}}this.b$["jalview.appletgui.TreePanel"].tree.reCount (this.b$["jalview.appletgui.TreePanel"].tree.getTopNode ()); -this.b$["jalview.appletgui.TreePanel"].tree.findHeight (this.b$["jalview.appletgui.TreePanel"].tree.getTopNode ()); -this.b$["jalview.appletgui.TreePanel"].treeCanvas.setTree (this.b$["jalview.appletgui.TreePanel"].tree); -if (this.newtree != null) { -var a = this.newtree.HasDistances () && this.b$["jalview.appletgui.TreePanel"].av.applet.getDefaultParameter ("showTreeDistances", this.newtree.HasDistances ()); -var b = this.newtree.HasBootstrap () && this.b$["jalview.appletgui.TreePanel"].av.applet.getDefaultParameter ("showTreeBootstraps", this.newtree.HasBootstrap ()); -this.b$["jalview.appletgui.TreePanel"].distanceMenu.setState (a); -this.b$["jalview.appletgui.TreePanel"].bootstrapMenu.setState (b); -this.b$["jalview.appletgui.TreePanel"].treeCanvas.setShowBootstrap (b); -this.b$["jalview.appletgui.TreePanel"].treeCanvas.setShowDistances (a); -this.b$["jalview.appletgui.TreePanel"].treeCanvas.setMarkPlaceholders (this.b$["jalview.appletgui.TreePanel"].av.applet.getDefaultParameter ("showUnlinkedTreeNodes", false)); -}this.b$["jalview.appletgui.TreePanel"].treeCanvas.repaint (); -this.b$["jalview.appletgui.TreePanel"].av.setCurrentTree (this.b$["jalview.appletgui.TreePanel"].tree); -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["jalview.appletgui.EmbmenuFrame", "java.awt.event.ActionListener", "$.ItemListener", "java.lang.Thread", "awt2swing.CheckboxMenuItem", "$.Menu", "$.MenuBar", "$.MenuItem", "$.ScrollPane", "java.awt.BorderLayout"], "jalview.appletgui.TreePanel", ["awt2swing.Frame", "jalview.analysis.NJTree", "jalview.api.analysis.ViewBasedAnalysisI", "jalview.appletgui.AlignFrame", "$.CutAndPasteTransfer", "$.FontChooser", "$.TreeCanvas", "jalview.bin.JalviewLite", "jalview.datamodel.Alignment", "jalview.io.NewickFile", "jalview.schemes.ResidueProperties", "jalview.util.MessageManager", "java.awt.Color", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.seq = null; +this.$type = null; +this.pwtype = null; +this.start = 0; +this.end = 0; +this.treeCanvas = null; +this.tree = null; +this.ap = null; +this.av = null; +if (!Clazz.isClassDefined ("jalview.appletgui.TreePanel.TreeLoader")) { +jalview.appletgui.TreePanel.$TreePanel$TreeLoader$ (); +} +this.borderLayout1 = null; +this.scrollPane = null; +this.jMenuBar1 = null; +this.jMenu2 = null; +this.fontSize = null; +this.bootstrapMenu = null; +this.distanceMenu = null; +this.placeholdersMenu = null; +this.fitToWindow = null; +this.fileMenu = null; +this.newickOutput = null; +this.inputData = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "TreePanel", jalview.appletgui.EmbmenuFrame, [java.awt.event.ActionListener, java.awt.event.ItemListener]); +Clazz.prepareFields (c$, function () { +this.borderLayout1 = new java.awt.BorderLayout (); +this.scrollPane = new awt2swing.ScrollPane (); +this.jMenuBar1 = new awt2swing.MenuBar (); +this.jMenu2 = new awt2swing.Menu (); +this.fontSize = new awt2swing.MenuItem (); +this.bootstrapMenu = new awt2swing.CheckboxMenuItem (); +this.distanceMenu = new awt2swing.CheckboxMenuItem (); +this.placeholdersMenu = new awt2swing.CheckboxMenuItem (); +this.fitToWindow = new awt2swing.CheckboxMenuItem (); +this.fileMenu = new awt2swing.Menu (); +this.newickOutput = new awt2swing.MenuItem (); +this.inputData = new awt2swing.MenuItem (); +}); +Clazz.defineMethod (c$, "getTree", +function () { +return this.tree; +}); +Clazz.defineMethod (c$, "finalize", +function () { +this.ap = null; +this.av = null; +Clazz.superCall (this, jalview.appletgui.TreePanel, "finalize", []); +}); +Clazz.makeConstructor (c$, +function (ap, type, pwtype) { +Clazz.superConstructor (this, jalview.appletgui.TreePanel, []); +try { +this.jbInit (); +this.setMenuBar (this.jMenuBar1); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +this.initTreePanel (ap, type, pwtype, null); +}, "jalview.appletgui.AlignmentPanel,~S,~S"); +Clazz.makeConstructor (c$, +function (ap, type, pwtype, newtree) { +Clazz.superConstructor (this, jalview.appletgui.TreePanel, []); +try { +this.jbInit (); +this.setMenuBar (this.jMenuBar1); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.initTreePanel (ap, type, pwtype, newtree); +}, "jalview.appletgui.AlignmentPanel,~S,~S,jalview.io.NewickFile"); +Clazz.defineMethod (c$, "initTreePanel", +function (ap, type, pwtype, newTree) { +this.ap = ap; +this.av = ap.av; +this.$type = type; +this.pwtype = pwtype; +this.treeCanvas = new jalview.appletgui.TreeCanvas (ap, this.scrollPane); +var tl = Clazz.innerTypeInstance (jalview.appletgui.TreePanel.TreeLoader, this, null, newTree); +tl.start (); +this.embedMenuIfNeeded (this.treeCanvas); +this.scrollPane.add (this.treeCanvas, "Center"); +}, "jalview.appletgui.AlignmentPanel,~S,~S,jalview.io.NewickFile"); +Clazz.defineMethod (c$, "showOriginalData", +function () { +if (this.tree.seqData != null) { +var gc = '-'; +try { +gc = this.av.getGapCharacter (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +;var alAndColsel = this.tree.seqData.getAlignmentAndColumnSelection (gc); +if (alAndColsel != null && alAndColsel[0] != null) { +var al = new jalview.datamodel.Alignment (alAndColsel[0]); +var af = new jalview.appletgui.AlignFrame (al, this.av.applet, "Original Data for Tree", false); +af.viewport.setHiddenColumns (alAndColsel[1]); +}} else { +System.out.println ("Original Tree Data not available"); +}}); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +if (evt.getSource () === this.newickOutput) { +this.newickOutput_actionPerformed (); +} else if (evt.getSource () === this.fontSize) { +this.fontSize_actionPerformed (); +} else if (evt.getSource () === this.inputData) { +this.showOriginalData (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "itemStateChanged", +function (evt) { +if (evt.getSource () === this.fitToWindow) { +this.treeCanvas.fitToWindow = this.fitToWindow.getState (); +} else if (evt.getSource () === this.distanceMenu) { +this.treeCanvas.setShowDistances (this.distanceMenu.getState ()); +} else if (evt.getSource () === this.bootstrapMenu) { +this.treeCanvas.setShowBootstrap (this.bootstrapMenu.getState ()); +} else if (evt.getSource () === this.placeholdersMenu) { +this.treeCanvas.setMarkPlaceholders (this.placeholdersMenu.getState ()); +}this.treeCanvas.repaint (); +}, "java.awt.event.ItemEvent"); +Clazz.defineMethod (c$, "newickOutput_actionPerformed", +function () { +var fout = new jalview.io.NewickFile (this.tree.getTopNode ()); +var output = fout.print (false, true); +var cap = new jalview.appletgui.CutAndPasteTransfer (false, null); +cap.setText (output); +var frame = new awt2swing.Frame (); +frame.add (cap); +jalview.bin.JalviewLite.addFrame (frame, this.$type + " " + this.pwtype, 500, 100); +}); +Clazz.defineMethod (c$, "getTreeFont", +function () { +return this.treeCanvas.$font; +}); +Clazz.defineMethod (c$, "setTreeFont", +function (font) { +this.treeCanvas.$font = font; +this.treeCanvas.repaint (); +}, "java.awt.Font"); +Clazz.defineMethod (c$, "fontSize_actionPerformed", +function () { +if (this.treeCanvas == null) { +return; +} new jalview.appletgui.FontChooser (this); +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout (this.borderLayout1); +this.setBackground (java.awt.Color.white); +this.setFont ( new java.awt.Font ("Verdana", 0, 12)); +this.jMenu2.setLabel (jalview.util.MessageManager.getString ("action.view")); +this.fontSize.setLabel (jalview.util.MessageManager.getString ("action.font")); +this.fontSize.addActionListener (this); +this.bootstrapMenu.setLabel (jalview.util.MessageManager.getString ("label.show_bootstrap_values")); +this.bootstrapMenu.addItemListener (this); +this.distanceMenu.setLabel (jalview.util.MessageManager.getString ("label.show_distances")); +this.distanceMenu.addItemListener (this); +this.placeholdersMenu.setLabel (jalview.util.MessageManager.getString ("label.mark_unassociated_leaves")); +this.placeholdersMenu.addItemListener (this); +this.fitToWindow.setState (true); +this.fitToWindow.setLabel (jalview.util.MessageManager.getString ("label.fit_to_window")); +this.fitToWindow.addItemListener (this); +this.fileMenu.setLabel (jalview.util.MessageManager.getString ("action.file")); +this.newickOutput.setLabel (jalview.util.MessageManager.getString ("label.newick_format")); +this.newickOutput.addActionListener (this); +this.inputData.setLabel (jalview.util.MessageManager.getString ("label.input_data")); +this.add (this.scrollPane, "Center"); +this.jMenuBar1.add (this.fileMenu); +this.jMenuBar1.add (this.jMenu2); +this.jMenu2.add (this.fitToWindow); +this.jMenu2.add (this.fontSize); +this.jMenu2.add (this.distanceMenu); +this.jMenu2.add (this.bootstrapMenu); +this.jMenu2.add (this.placeholdersMenu); +this.fileMenu.add (this.newickOutput); +this.fileMenu.add (this.inputData); +this.inputData.addActionListener (this); +}, $fz.isPrivate = true, $fz)); +c$.$TreePanel$TreeLoader$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.newtree = null; +this.odata = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui.TreePanel, "TreeLoader", Thread); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.appletgui.TreePanel.TreeLoader, []); +this.newtree = a; +}, "jalview.io.NewickFile"); +Clazz.overrideMethod (c$, "run", +function () { +if (this.newtree != null) { +if (this.odata == null) { +this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getSequencesArray (), this.newtree); +} else { +this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getSequencesArray (), this.odata, this.newtree); +}} else { +var a; +var b; +var c; +var d = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup () != null && this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getSize () > 1; +var e = this.b$["jalview.appletgui.TreePanel"].av.getAlignmentView (d); +if (!d) { +a = 0; +b = this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getWidth (); +c = this.b$["jalview.appletgui.TreePanel"].av.getAlignment ().getSequencesArray (); +} else { +a = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getStartRes (); +b = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getEndRes () + 1; +c = this.b$["jalview.appletgui.TreePanel"].av.getSelectionGroup ().getSequencesInOrder (this.b$["jalview.appletgui.TreePanel"].av.getAlignment ()); +}var f = jalview.schemes.ResidueProperties.getScoreModel (this.b$["jalview.appletgui.TreePanel"].pwtype); +if (Clazz.instanceOf (f, jalview.api.analysis.ViewBasedAnalysisI)) { +try { +f = f.getClass ().newInstance (); +(f).configureFromAlignmentView (this.b$["jalview.appletgui.TreePanel"].treeCanvas.ap); +} catch (q) { +if (Clazz.exceptionOf (q, Exception)) { +System.err.println ("Couldn't create a scoremodel instance for " + f.getName ()); +q.printStackTrace (); +} else { +throw q; +} +} +this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (c, e, this.b$["jalview.appletgui.TreePanel"].$type, this.b$["jalview.appletgui.TreePanel"].pwtype, f, a, b); +} else { +this.b$["jalview.appletgui.TreePanel"].tree = new jalview.analysis.NJTree (c, e, this.b$["jalview.appletgui.TreePanel"].$type, this.b$["jalview.appletgui.TreePanel"].pwtype, null, a, b); +}}this.b$["jalview.appletgui.TreePanel"].tree.reCount (this.b$["jalview.appletgui.TreePanel"].tree.getTopNode ()); +this.b$["jalview.appletgui.TreePanel"].tree.findHeight (this.b$["jalview.appletgui.TreePanel"].tree.getTopNode ()); +this.b$["jalview.appletgui.TreePanel"].treeCanvas.setTree (this.b$["jalview.appletgui.TreePanel"].tree); +if (this.newtree != null) { +var a = this.newtree.HasDistances () && this.b$["jalview.appletgui.TreePanel"].av.applet.getDefaultParameter ("showTreeDistances", this.newtree.HasDistances ()); +var b = this.newtree.HasBootstrap () && this.b$["jalview.appletgui.TreePanel"].av.applet.getDefaultParameter ("showTreeBootstraps", this.newtree.HasBootstrap ()); +this.b$["jalview.appletgui.TreePanel"].distanceMenu.setState (a); +this.b$["jalview.appletgui.TreePanel"].bootstrapMenu.setState (b); +this.b$["jalview.appletgui.TreePanel"].treeCanvas.setShowBootstrap (b); +this.b$["jalview.appletgui.TreePanel"].treeCanvas.setShowDistances (a); +this.b$["jalview.appletgui.TreePanel"].treeCanvas.setMarkPlaceholders (this.b$["jalview.appletgui.TreePanel"].av.applet.getDefaultParameter ("showUnlinkedTreeNodes", false)); +}this.b$["jalview.appletgui.TreePanel"].treeCanvas.repaint (); +this.b$["jalview.appletgui.TreePanel"].av.setCurrentTree (this.b$["jalview.appletgui.TreePanel"].tree); +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/appletgui/UserDefinedColours.js b/bin/jalview/appletgui/UserDefinedColours.js index a1b23f6..2cc0d9b 100644 --- a/bin/jalview/appletgui/UserDefinedColours.js +++ b/bin/jalview/appletgui/UserDefinedColours.js @@ -1,481 +1,481 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.FocusListener", "awt2swing.Button", "$.Label", "$.Scrollbar", "$.TextField", "java.awt.GridLayout", "java.util.Vector"], "jalview.appletgui.UserDefinedColours", ["awt2swing.Frame", "jalview.appletgui.AnnotationColourChooser", "$.FeatureColourChooser", "$.FeatureRenderer", "$.FeatureSettings", "jalview.bin.JalviewLite", "jalview.schemes.ResidueProperties", "$.UserColourScheme", "jalview.util.MessageManager", "java.awt.Color", "$.Dialog", "$.Font", "$.Rectangle", "java.awt.event.MouseAdapter", "java.lang.Error"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ap = null; -this.seqGroup = null; -this.selectedButton = null; -this.oldColours = null; -this.oldColourScheme = null; -this.frame = null; -this.jmol = null; -this.dialog = null; -this.caller = null; -this.originalLabel = null; -this.originalColour = null; -this.R = 0; -this.G = 0; -this.B = 0; -this.buttonPanel = null; -this.gridLayout = null; -this.okcancelPanel = null; -this.okButton = null; -this.applyButton = null; -this.cancelButton = null; -this.rScroller = null; -this.label1 = null; -this.rText = null; -this.label4 = null; -this.gScroller = null; -this.gText = null; -this.label5 = null; -this.bScroller = null; -this.bText = null; -this.target = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "UserDefinedColours", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.FocusListener]); -Clazz.prepareFields (c$, function () { -this.oldColours = new java.util.Vector (); -this.buttonPanel = new awt2swing.Panel (); -this.gridLayout = new java.awt.GridLayout (); -this.okcancelPanel = new awt2swing.Panel (); -this.okButton = new awt2swing.Button (); -this.applyButton = new awt2swing.Button (); -this.cancelButton = new awt2swing.Button (); -this.rScroller = new awt2swing.Scrollbar (); -this.label1 = new awt2swing.Label (); -this.rText = new awt2swing.TextField (); -this.label4 = new awt2swing.Label (); -this.gScroller = new awt2swing.Scrollbar (); -this.gText = new awt2swing.TextField (); -this.label5 = new awt2swing.Label (); -this.bScroller = new awt2swing.Scrollbar (); -this.bText = new awt2swing.TextField (); -this.target = new awt2swing.Panel (); -}); -Clazz.defineMethod (c$, "loadDefaultColours", -function () { -return null; -}); -Clazz.makeConstructor (c$, -function (ap, sg) { -Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); -this.ap = ap; -this.seqGroup = sg; -if (this.seqGroup != null) { -this.oldColourScheme = this.seqGroup.cs; -} else { -this.oldColourScheme = ap.av.getGlobalColourScheme (); -}this.init (); -}, "jalview.appletgui.AlignmentPanel,jalview.datamodel.SequenceGroup"); -Clazz.makeConstructor (c$, -function (jmol) { -Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); -this.jmol = jmol; -this.init (); -}, "jalview.appletgui.AppletJmol"); -Clazz.makeConstructor (c$, -function (fr, alignframe) { -Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); -this.caller = fr; -this.originalColour = fr.colourPanel.getBackground (); -this.originalLabel = "Feature Colour"; -this.setForDialog ("Select Feature Colour", alignframe); -this.setTargetColour (fr.colourPanel.getBackground ()); -this.dialog.setVisible (true); -}, "jalview.appletgui.FeatureRenderer,awt2swing.Frame"); -Clazz.makeConstructor (c$, -function (caller, col1, alignframe) { -this.construct (caller, col1, alignframe, "Select Colour"); -}, "java.awt.Component,java.awt.Color,awt2swing.Frame"); -Clazz.makeConstructor (c$, -function (caller, col1, alignframe, title) { -Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); -this.caller = caller; -this.originalColour = col1; -this.originalLabel = title; -this.setForDialog (title, alignframe); -this.setTargetColour (col1); -this.dialog.setVisible (true); -}, "java.awt.Component,java.awt.Color,awt2swing.Frame,~S"); -Clazz.makeConstructor (c$, -function (caller, label, colour) { -this.construct (caller, label, colour, colour); -}, "~O,~S,java.awt.Color"); -Clazz.makeConstructor (c$, -function (me, type, graduatedColor) { -this.construct (me, type, graduatedColor, graduatedColor.getMaxColor ()); -}, "jalview.appletgui.FeatureSettings,~S,jalview.schemes.GraduatedColor"); -Clazz.makeConstructor (c$, -($fz = function (caller, label, ocolour, colour) { -Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); -this.caller = caller; -this.originalColour = ocolour; -this.originalLabel = label; -this.init (); -this.remove (this.buttonPanel); -this.setTargetColour (colour); -this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 113, 400, 35)); -this.frame.setTitle (jalview.util.MessageManager.getString ("label.user_defined_colours") + " - " + label); -this.frame.setSize (420, 200); -}, $fz.isPrivate = true, $fz), "~O,~S,~O,java.awt.Color"); -Clazz.defineMethod (c$, "setForDialog", -function (title, alignframe) { -this.init (); -this.frame.setVisible (false); -this.remove (this.buttonPanel); -if (Clazz.instanceOf (alignframe, awt2swing.Frame)) { -this.dialog = new java.awt.Dialog (alignframe, title, true); -} else { -throw new Error (jalview.util.MessageManager.getString ("label.error_unsupported_owwner_user_colour_scheme")); -}this.dialog.add (this); -this.setSize (400, 123); -this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 123, 400, 35)); -var height = 160 + alignframe.getInsets ().top + this.getInsets ().bottom; -var width = 400; -this.dialog.setBounds (alignframe.getBounds ().x + Clazz.doubleToInt ((alignframe.getSize ().width - width) / 2), alignframe.getBounds ().y + Clazz.doubleToInt ((alignframe.getSize ().height - height) / 2), width, height); -}, "~S,java.awt.Container"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -var source = evt.getSource (); -if (source === this.okButton) { -this.okButton_actionPerformed (); -} else if (source === this.applyButton) { -this.applyButton_actionPerformed (); -} else if (source === this.cancelButton) { -this.cancelButton_actionPerformed (); -} else if (source === this.rText) { -this.rText_actionPerformed (); -} else if (source === this.gText) { -this.gText_actionPerformed (); -} else if (source === this.bText) { -this.bText_actionPerformed (); -}}, "java.awt.event.ActionEvent"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -if (evt.getSource () === this.rScroller) { -this.rScroller_adjustmentValueChanged (); -} else if (evt.getSource () === this.gScroller) { -this.gScroller_adjustmentValueChanged (); -} else if (evt.getSource () === this.bScroller) { -this.bScroller_adjustmentValueChanged (); -}}, "java.awt.event.AdjustmentEvent"); -Clazz.defineMethod (c$, "init", -function () { -try { -this.jbInit (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -} else { -throw e; -} -} -this.frame = new awt2swing.Frame (); -this.frame.add (this); -jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.user_defined_colours"), 420, 345); -if (this.seqGroup != null) { -this.frame.setTitle (this.frame.getTitle () + " (" + this.seqGroup.getName () + ")"); -}for (var i = 0; i < 20; i++) { -this.makeButton (jalview.schemes.ResidueProperties.aa2Triplet.get (jalview.schemes.ResidueProperties.aa[i]) + "", jalview.schemes.ResidueProperties.aa[i]); -} -this.makeButton ("B", "B"); -this.makeButton ("Z", "Z"); -this.makeButton ("X", "X"); -this.makeButton ("Gap", "'.','-',' '"); -this.validate (); -}); -Clazz.defineMethod (c$, "rText_actionPerformed", -function () { -try { -var i = Integer.parseInt (this.rText.getText ()); -this.rScroller.setValue (i); -this.rScroller_adjustmentValueChanged (); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "gText_actionPerformed", -function () { -try { -var i = Integer.parseInt (this.gText.getText ()); -this.gScroller.setValue (i); -this.gScroller_adjustmentValueChanged (); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "bText_actionPerformed", -function () { -try { -var i = Integer.parseInt (this.bText.getText ()); -this.bScroller.setValue (i); -this.bScroller_adjustmentValueChanged (); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -}); -Clazz.defineMethod (c$, "rScroller_adjustmentValueChanged", -function () { -this.R = this.rScroller.getValue (); -this.rText.setText (this.R + ""); -this.colourChanged (); -}); -Clazz.defineMethod (c$, "gScroller_adjustmentValueChanged", -function () { -this.G = this.gScroller.getValue (); -this.gText.setText (this.G + ""); -this.colourChanged (); -}); -Clazz.defineMethod (c$, "bScroller_adjustmentValueChanged", -function () { -this.B = this.bScroller.getValue (); -this.bText.setText (this.B + ""); -this.colourChanged (); -}); -Clazz.defineMethod (c$, "colourChanged", -function () { -var col = new java.awt.Color (this.R, this.G, this.B); -this.target.setBackground (col); -this.target.repaint (); -if (this.selectedButton != null) { -this.selectedButton.setBackground (col); -this.selectedButton.repaint (); -}}); -Clazz.defineMethod (c$, "setTargetColour", -function (col) { -this.R = col.getRed (); -this.G = col.getGreen (); -this.B = col.getBlue (); -this.rScroller.setValue (this.R); -this.gScroller.setValue (this.G); -this.bScroller.setValue (this.B); -this.rText.setText (this.R + ""); -this.gText.setText (this.G + ""); -this.bText.setText (this.B + ""); -this.colourChanged (); -}, "java.awt.Color"); -Clazz.defineMethod (c$, "colourButtonPressed", -function (e) { -this.selectedButton = e.getSource (); -this.setTargetColour (this.selectedButton.getBackground ()); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "makeButton", -function (label, aa) { -var button = new awt2swing.Button (); -var col = java.awt.Color.white; -if (this.oldColourScheme != null) { -try { -col = this.oldColourScheme.findColour (aa.charAt (0), -1, null); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -}button.setBackground (col); -this.oldColours.addElement (col); -button.setLabel (label); -button.setForeground (col.darker ().darker ().darker ()); -button.setFont ( new java.awt.Font ("Verdana", 1, 10)); -button.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.UserDefinedColours$1") ? 0 : jalview.appletgui.UserDefinedColours.$UserDefinedColours$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.UserDefinedColours$1, this, null))); -this.buttonPanel.add (button, null); -}, "~S,~S"); -Clazz.defineMethod (c$, "okButton_actionPerformed", -function () { -this.applyButton_actionPerformed (); -if (this.dialog != null) { -this.dialog.setVisible (false); -}this.frame.setVisible (false); -}); -Clazz.defineMethod (c$, "getColor", -function () { -return new java.awt.Color (this.R, this.G, this.B); -}); -Clazz.defineMethod (c$, "applyButton_actionPerformed", -function () { -if (this.caller != null) { -if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureSettings)) { -(this.caller).setUserColour (this.originalLabel, this.getColor ()); -} else if (Clazz.instanceOf (this.caller, jalview.appletgui.AnnotationColourChooser)) { -if (this.originalLabel.equals ("Min Colour")) { -(this.caller).minColour_actionPerformed (this.getColor ()); -} else { -(this.caller).maxColour_actionPerformed (this.getColor ()); -}} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureRenderer)) { -(this.caller).colourPanel.updateColor (this.getColor ()); -} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureColourChooser)) { -if (this.originalLabel.indexOf ("inimum") > -1) { -(this.caller).minColour_actionPerformed (this.getColor ()); -} else { -(this.caller).maxColour_actionPerformed (this.getColor ()); -}}return; -}var newColours = new Array (24); -for (var i = 0; i < 24; i++) { -var button = this.buttonPanel.getComponent (i); -newColours[i] = button.getBackground (); -} -var ucs = new jalview.schemes.UserColourScheme (newColours); -if (this.ap != null) { -ucs.setThreshold (0, this.ap.av.isIgnoreGapsConsensus ()); -}if (this.ap != null) { -if (this.seqGroup != null) { -this.seqGroup.cs = ucs; -} else { -this.ap.av.setGlobalColourScheme (ucs); -}this.ap.seqPanel.seqCanvas.img = null; -this.ap.paintAlignment (true); -} else if (this.jmol != null) { -this.jmol.setJalviewColourScheme (ucs); -}}); -Clazz.defineMethod (c$, "cancelButton_actionPerformed", -function () { -if (this.caller != null) { -if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureSettings)) { -(this.caller).setUserColour (this.originalLabel, this.originalColour); -} else if (Clazz.instanceOf (this.caller, jalview.appletgui.AnnotationColourChooser)) { -if (this.originalLabel.equals ("Min Colour")) { -(this.caller).minColour_actionPerformed (this.originalColour); -} else { -(this.caller).maxColour_actionPerformed (this.originalColour); -}} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureRenderer)) { -(this.caller).colourPanel.updateColor (this.originalColour); -} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureColourChooser)) { -if (this.originalLabel.indexOf ("inimum") > -1) { -(this.caller).minColour_actionPerformed (this.originalColour); -} else { -(this.caller).maxColour_actionPerformed (this.originalColour); -}}if (this.dialog != null) { -this.dialog.setVisible (false); -}this.frame.setVisible (false); -return; -}var newColours = new Array (24); -for (var i = 0; i < 24; i++) { -newColours[i] = this.oldColours.elementAt (i); -this.buttonPanel.getComponent (i).setBackground (newColours[i]); -} -var ucs = new jalview.schemes.UserColourScheme (newColours); -if (this.ap != null) { -if (this.seqGroup != null) { -this.seqGroup.cs = ucs; -} else { -this.ap.av.setGlobalColourScheme (ucs); -}this.ap.paintAlignment (true); -} else if (this.jmol != null) { -this.jmol.setJalviewColourScheme (ucs); -}this.frame.setVisible (false); -}); -Clazz.defineMethod (c$, "jbInit", -($fz = function () { -this.setLayout (null); -this.buttonPanel.setLayout (this.gridLayout); -this.gridLayout.setColumns (6); -this.gridLayout.setRows (4); -this.okButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.okButton.setLabel (jalview.util.MessageManager.getString ("action.ok")); -this.okButton.addActionListener (this); -this.applyButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.applyButton.setLabel (jalview.util.MessageManager.getString ("action.apply")); -this.applyButton.addActionListener (this); -this.cancelButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); -this.cancelButton.setLabel (jalview.util.MessageManager.getString ("action.cancel")); -this.cancelButton.addActionListener (this); -this.setBackground ( new java.awt.Color (212, 208, 223)); -this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 265, 400, 35)); -this.buttonPanel.setBounds ( new java.awt.Rectangle (0, 123, 400, 142)); -this.rScroller.setMaximum (256); -this.rScroller.setMinimum (0); -this.rScroller.setOrientation (0); -this.rScroller.setUnitIncrement (1); -this.rScroller.setVisibleAmount (1); -this.rScroller.setBounds ( new java.awt.Rectangle (36, 27, 119, 19)); -this.rScroller.addAdjustmentListener (this); -this.label1.setAlignment (4); -this.label1.setText ("R"); -this.label1.setBounds ( new java.awt.Rectangle (19, 30, 16, 15)); -this.rText.setFont ( new java.awt.Font ("Dialog", 0, 10)); -this.rText.setText ("0 "); -this.rText.setBounds ( new java.awt.Rectangle (156, 27, 53, 19)); -this.rText.addActionListener (this); -this.rText.addFocusListener (this); -this.label4.setAlignment (4); -this.label4.setText ("G"); -this.label4.setBounds ( new java.awt.Rectangle (15, 56, 20, 15)); -this.gScroller.setMaximum (256); -this.gScroller.setMinimum (0); -this.gScroller.setOrientation (0); -this.gScroller.setUnitIncrement (1); -this.gScroller.setVisibleAmount (1); -this.gScroller.setBounds ( new java.awt.Rectangle (35, 52, 120, 20)); -this.gScroller.addAdjustmentListener (this); -this.gText.setFont ( new java.awt.Font ("Dialog", 0, 10)); -this.gText.setText ("0 "); -this.gText.setBounds ( new java.awt.Rectangle (156, 52, 53, 20)); -this.gText.addActionListener (this); -this.gText.addFocusListener (this); -this.label5.setAlignment (4); -this.label5.setText ("B"); -this.label5.setBounds ( new java.awt.Rectangle (14, 82, 20, 15)); -this.bScroller.setMaximum (256); -this.bScroller.setMinimum (0); -this.bScroller.setOrientation (0); -this.bScroller.setUnitIncrement (1); -this.bScroller.setVisibleAmount (1); -this.bScroller.setBounds ( new java.awt.Rectangle (35, 78, 120, 20)); -this.bScroller.addAdjustmentListener (this); -this.bText.setFont ( new java.awt.Font ("Dialog", 0, 10)); -this.bText.setText ("0 "); -this.bText.setBounds ( new java.awt.Rectangle (157, 78, 52, 20)); -this.bText.addActionListener (this); -this.bText.addFocusListener (this); -this.target.setBackground (java.awt.Color.black); -this.target.setBounds ( new java.awt.Rectangle (229, 26, 134, 79)); -this.add (this.okcancelPanel, null); -this.okcancelPanel.add (this.okButton, null); -this.okcancelPanel.add (this.applyButton, null); -this.okcancelPanel.add (this.cancelButton, null); -this.add (this.rText); -this.add (this.gText); -this.add (this.bText); -this.add (this.buttonPanel, null); -this.add (this.target, null); -this.add (this.gScroller); -this.add (this.rScroller); -this.add (this.bScroller); -this.add (this.label5); -this.add (this.label4); -this.add (this.label1); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "focusGained", -function (e) { -}, "java.awt.event.FocusEvent"); -Clazz.overrideMethod (c$, "focusLost", -function (e) { -var c = e.getComponent (); -if (c === this.rText) { -this.rText_actionPerformed (); -} else { -if (c === this.gText) { -this.gText_actionPerformed (); -} else { -if (c === this.bText) { -this.bText_actionPerformed (); -}}}}, "java.awt.event.FocusEvent"); -c$.$UserDefinedColours$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.appletgui, "UserDefinedColours$1", java.awt.event.MouseAdapter); -Clazz.overrideMethod (c$, "mousePressed", -function (e) { -this.b$["jalview.appletgui.UserDefinedColours"].colourButtonPressed (e); -}, "java.awt.event.MouseEvent"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.FocusListener", "awt2swing.Button", "$.Label", "$.Scrollbar", "$.TextField", "java.awt.GridLayout", "java.util.Vector"], "jalview.appletgui.UserDefinedColours", ["awt2swing.Frame", "jalview.appletgui.AnnotationColourChooser", "$.FeatureColourChooser", "$.FeatureRenderer", "$.FeatureSettings", "jalview.bin.JalviewLite", "jalview.schemes.ResidueProperties", "$.UserColourScheme", "jalview.util.MessageManager", "java.awt.Color", "$.Dialog", "$.Font", "$.Rectangle", "java.awt.event.MouseAdapter", "java.lang.Error"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ap = null; +this.seqGroup = null; +this.selectedButton = null; +this.oldColours = null; +this.oldColourScheme = null; +this.frame = null; +this.jmol = null; +this.dialog = null; +this.caller = null; +this.originalLabel = null; +this.originalColour = null; +this.R = 0; +this.G = 0; +this.B = 0; +this.buttonPanel = null; +this.gridLayout = null; +this.okcancelPanel = null; +this.okButton = null; +this.applyButton = null; +this.cancelButton = null; +this.rScroller = null; +this.label1 = null; +this.rText = null; +this.label4 = null; +this.gScroller = null; +this.gText = null; +this.label5 = null; +this.bScroller = null; +this.bText = null; +this.target = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "UserDefinedColours", awt2swing.Panel, [java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.FocusListener]); +Clazz.prepareFields (c$, function () { +this.oldColours = new java.util.Vector (); +this.buttonPanel = new awt2swing.Panel (); +this.gridLayout = new java.awt.GridLayout (); +this.okcancelPanel = new awt2swing.Panel (); +this.okButton = new awt2swing.Button (); +this.applyButton = new awt2swing.Button (); +this.cancelButton = new awt2swing.Button (); +this.rScroller = new awt2swing.Scrollbar (); +this.label1 = new awt2swing.Label (); +this.rText = new awt2swing.TextField (); +this.label4 = new awt2swing.Label (); +this.gScroller = new awt2swing.Scrollbar (); +this.gText = new awt2swing.TextField (); +this.label5 = new awt2swing.Label (); +this.bScroller = new awt2swing.Scrollbar (); +this.bText = new awt2swing.TextField (); +this.target = new awt2swing.Panel (); +}); +Clazz.defineMethod (c$, "loadDefaultColours", +function () { +return null; +}); +Clazz.makeConstructor (c$, +function (ap, sg) { +Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); +this.ap = ap; +this.seqGroup = sg; +if (this.seqGroup != null) { +this.oldColourScheme = this.seqGroup.cs; +} else { +this.oldColourScheme = ap.av.getGlobalColourScheme (); +}this.init (); +}, "jalview.appletgui.AlignmentPanel,jalview.datamodel.SequenceGroup"); +Clazz.makeConstructor (c$, +function (jmol) { +Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); +this.jmol = jmol; +this.init (); +}, "jalview.appletgui.AppletJmol"); +Clazz.makeConstructor (c$, +function (fr, alignframe) { +Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); +this.caller = fr; +this.originalColour = fr.colourPanel.getBackground (); +this.originalLabel = "Feature Colour"; +this.setForDialog ("Select Feature Colour", alignframe); +this.setTargetColour (fr.colourPanel.getBackground ()); +this.dialog.setVisible (true); +}, "jalview.appletgui.FeatureRenderer,awt2swing.Frame"); +Clazz.makeConstructor (c$, +function (caller, col1, alignframe) { +this.construct (caller, col1, alignframe, "Select Colour"); +}, "java.awt.Component,java.awt.Color,awt2swing.Frame"); +Clazz.makeConstructor (c$, +function (caller, col1, alignframe, title) { +Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); +this.caller = caller; +this.originalColour = col1; +this.originalLabel = title; +this.setForDialog (title, alignframe); +this.setTargetColour (col1); +this.dialog.setVisible (true); +}, "java.awt.Component,java.awt.Color,awt2swing.Frame,~S"); +Clazz.makeConstructor (c$, +function (caller, label, colour) { +this.construct (caller, label, colour, colour); +}, "~O,~S,java.awt.Color"); +Clazz.makeConstructor (c$, +function (me, type, graduatedColor) { +this.construct (me, type, graduatedColor, graduatedColor.getMaxColor ()); +}, "jalview.appletgui.FeatureSettings,~S,jalview.schemes.GraduatedColor"); +Clazz.makeConstructor (c$, +($fz = function (caller, label, ocolour, colour) { +Clazz.superConstructor (this, jalview.appletgui.UserDefinedColours, []); +this.caller = caller; +this.originalColour = ocolour; +this.originalLabel = label; +this.init (); +this.remove (this.buttonPanel); +this.setTargetColour (colour); +this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 113, 400, 35)); +this.frame.setTitle (jalview.util.MessageManager.getString ("label.user_defined_colours") + " - " + label); +this.frame.setSize (420, 200); +}, $fz.isPrivate = true, $fz), "~O,~S,~O,java.awt.Color"); +Clazz.defineMethod (c$, "setForDialog", +function (title, alignframe) { +this.init (); +this.frame.setVisible (false); +this.remove (this.buttonPanel); +if (Clazz.instanceOf (alignframe, awt2swing.Frame)) { +this.dialog = new java.awt.Dialog (alignframe, title, true); +} else { +throw new Error (jalview.util.MessageManager.getString ("label.error_unsupported_owwner_user_colour_scheme")); +}this.dialog.add (this); +this.setSize (400, 123); +this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 123, 400, 35)); +var height = 160 + alignframe.getInsets ().top + this.getInsets ().bottom; +var width = 400; +this.dialog.setBounds (alignframe.getBounds ().x + Clazz.doubleToInt ((alignframe.getSize ().width - width) / 2), alignframe.getBounds ().y + Clazz.doubleToInt ((alignframe.getSize ().height - height) / 2), width, height); +}, "~S,java.awt.Container"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +var source = evt.getSource (); +if (source === this.okButton) { +this.okButton_actionPerformed (); +} else if (source === this.applyButton) { +this.applyButton_actionPerformed (); +} else if (source === this.cancelButton) { +this.cancelButton_actionPerformed (); +} else if (source === this.rText) { +this.rText_actionPerformed (); +} else if (source === this.gText) { +this.gText_actionPerformed (); +} else if (source === this.bText) { +this.bText_actionPerformed (); +}}, "java.awt.event.ActionEvent"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +if (evt.getSource () === this.rScroller) { +this.rScroller_adjustmentValueChanged (); +} else if (evt.getSource () === this.gScroller) { +this.gScroller_adjustmentValueChanged (); +} else if (evt.getSource () === this.bScroller) { +this.bScroller_adjustmentValueChanged (); +}}, "java.awt.event.AdjustmentEvent"); +Clazz.defineMethod (c$, "init", +function () { +try { +this.jbInit (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +} else { +throw e; +} +} +this.frame = new awt2swing.Frame (); +this.frame.add (this); +jalview.bin.JalviewLite.addFrame (this.frame, jalview.util.MessageManager.getString ("label.user_defined_colours"), 420, 345); +if (this.seqGroup != null) { +this.frame.setTitle (this.frame.getTitle () + " (" + this.seqGroup.getName () + ")"); +}for (var i = 0; i < 20; i++) { +this.makeButton (jalview.schemes.ResidueProperties.aa2Triplet.get (jalview.schemes.ResidueProperties.aa[i]) + "", jalview.schemes.ResidueProperties.aa[i]); +} +this.makeButton ("B", "B"); +this.makeButton ("Z", "Z"); +this.makeButton ("X", "X"); +this.makeButton ("Gap", "'.','-',' '"); +this.validate (); +}); +Clazz.defineMethod (c$, "rText_actionPerformed", +function () { +try { +var i = Integer.parseInt (this.rText.getText ()); +this.rScroller.setValue (i); +this.rScroller_adjustmentValueChanged (); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "gText_actionPerformed", +function () { +try { +var i = Integer.parseInt (this.gText.getText ()); +this.gScroller.setValue (i); +this.gScroller_adjustmentValueChanged (); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "bText_actionPerformed", +function () { +try { +var i = Integer.parseInt (this.bText.getText ()); +this.bScroller.setValue (i); +this.bScroller_adjustmentValueChanged (); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +}); +Clazz.defineMethod (c$, "rScroller_adjustmentValueChanged", +function () { +this.R = this.rScroller.getValue (); +this.rText.setText (this.R + ""); +this.colourChanged (); +}); +Clazz.defineMethod (c$, "gScroller_adjustmentValueChanged", +function () { +this.G = this.gScroller.getValue (); +this.gText.setText (this.G + ""); +this.colourChanged (); +}); +Clazz.defineMethod (c$, "bScroller_adjustmentValueChanged", +function () { +this.B = this.bScroller.getValue (); +this.bText.setText (this.B + ""); +this.colourChanged (); +}); +Clazz.defineMethod (c$, "colourChanged", +function () { +var col = new java.awt.Color (this.R, this.G, this.B); +this.target.setBackground (col); +this.target.repaint (); +if (this.selectedButton != null) { +this.selectedButton.setBackground (col); +this.selectedButton.repaint (); +}}); +Clazz.defineMethod (c$, "setTargetColour", +function (col) { +this.R = col.getRed (); +this.G = col.getGreen (); +this.B = col.getBlue (); +this.rScroller.setValue (this.R); +this.gScroller.setValue (this.G); +this.bScroller.setValue (this.B); +this.rText.setText (this.R + ""); +this.gText.setText (this.G + ""); +this.bText.setText (this.B + ""); +this.colourChanged (); +}, "java.awt.Color"); +Clazz.defineMethod (c$, "colourButtonPressed", +function (e) { +this.selectedButton = e.getSource (); +this.setTargetColour (this.selectedButton.getBackground ()); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "makeButton", +function (label, aa) { +var button = new awt2swing.Button (); +var col = java.awt.Color.white; +if (this.oldColourScheme != null) { +try { +col = this.oldColourScheme.findColour (aa.charAt (0), -1, null); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +}button.setBackground (col); +this.oldColours.addElement (col); +button.setLabel (label); +button.setForeground (col.darker ().darker ().darker ()); +button.setFont ( new java.awt.Font ("Verdana", 1, 10)); +button.addMouseListener (((Clazz.isClassDefined ("jalview.appletgui.UserDefinedColours$1") ? 0 : jalview.appletgui.UserDefinedColours.$UserDefinedColours$1$ ()), Clazz.innerTypeInstance (jalview.appletgui.UserDefinedColours$1, this, null))); +this.buttonPanel.add (button, null); +}, "~S,~S"); +Clazz.defineMethod (c$, "okButton_actionPerformed", +function () { +this.applyButton_actionPerformed (); +if (this.dialog != null) { +this.dialog.setVisible (false); +}this.frame.setVisible (false); +}); +Clazz.defineMethod (c$, "getColor", +function () { +return new java.awt.Color (this.R, this.G, this.B); +}); +Clazz.defineMethod (c$, "applyButton_actionPerformed", +function () { +if (this.caller != null) { +if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureSettings)) { +(this.caller).setUserColour (this.originalLabel, this.getColor ()); +} else if (Clazz.instanceOf (this.caller, jalview.appletgui.AnnotationColourChooser)) { +if (this.originalLabel.equals ("Min Colour")) { +(this.caller).minColour_actionPerformed (this.getColor ()); +} else { +(this.caller).maxColour_actionPerformed (this.getColor ()); +}} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureRenderer)) { +(this.caller).colourPanel.updateColor (this.getColor ()); +} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureColourChooser)) { +if (this.originalLabel.indexOf ("inimum") > -1) { +(this.caller).minColour_actionPerformed (this.getColor ()); +} else { +(this.caller).maxColour_actionPerformed (this.getColor ()); +}}return; +}var newColours = new Array (24); +for (var i = 0; i < 24; i++) { +var button = this.buttonPanel.getComponent (i); +newColours[i] = button.getBackground (); +} +var ucs = new jalview.schemes.UserColourScheme (newColours); +if (this.ap != null) { +ucs.setThreshold (0, this.ap.av.isIgnoreGapsConsensus ()); +}if (this.ap != null) { +if (this.seqGroup != null) { +this.seqGroup.cs = ucs; +} else { +this.ap.av.setGlobalColourScheme (ucs); +}this.ap.seqPanel.seqCanvas.img = null; +this.ap.paintAlignment (true); +} else if (this.jmol != null) { +this.jmol.setJalviewColourScheme (ucs); +}}); +Clazz.defineMethod (c$, "cancelButton_actionPerformed", +function () { +if (this.caller != null) { +if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureSettings)) { +(this.caller).setUserColour (this.originalLabel, this.originalColour); +} else if (Clazz.instanceOf (this.caller, jalview.appletgui.AnnotationColourChooser)) { +if (this.originalLabel.equals ("Min Colour")) { +(this.caller).minColour_actionPerformed (this.originalColour); +} else { +(this.caller).maxColour_actionPerformed (this.originalColour); +}} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureRenderer)) { +(this.caller).colourPanel.updateColor (this.originalColour); +} else if (Clazz.instanceOf (this.caller, jalview.appletgui.FeatureColourChooser)) { +if (this.originalLabel.indexOf ("inimum") > -1) { +(this.caller).minColour_actionPerformed (this.originalColour); +} else { +(this.caller).maxColour_actionPerformed (this.originalColour); +}}if (this.dialog != null) { +this.dialog.setVisible (false); +}this.frame.setVisible (false); +return; +}var newColours = new Array (24); +for (var i = 0; i < 24; i++) { +newColours[i] = this.oldColours.elementAt (i); +this.buttonPanel.getComponent (i).setBackground (newColours[i]); +} +var ucs = new jalview.schemes.UserColourScheme (newColours); +if (this.ap != null) { +if (this.seqGroup != null) { +this.seqGroup.cs = ucs; +} else { +this.ap.av.setGlobalColourScheme (ucs); +}this.ap.paintAlignment (true); +} else if (this.jmol != null) { +this.jmol.setJalviewColourScheme (ucs); +}this.frame.setVisible (false); +}); +Clazz.defineMethod (c$, "jbInit", +($fz = function () { +this.setLayout (null); +this.buttonPanel.setLayout (this.gridLayout); +this.gridLayout.setColumns (6); +this.gridLayout.setRows (4); +this.okButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.okButton.setLabel (jalview.util.MessageManager.getString ("action.ok")); +this.okButton.addActionListener (this); +this.applyButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.applyButton.setLabel (jalview.util.MessageManager.getString ("action.apply")); +this.applyButton.addActionListener (this); +this.cancelButton.setFont ( new java.awt.Font ("Verdana", 0, 11)); +this.cancelButton.setLabel (jalview.util.MessageManager.getString ("action.cancel")); +this.cancelButton.addActionListener (this); +this.setBackground ( new java.awt.Color (212, 208, 223)); +this.okcancelPanel.setBounds ( new java.awt.Rectangle (0, 265, 400, 35)); +this.buttonPanel.setBounds ( new java.awt.Rectangle (0, 123, 400, 142)); +this.rScroller.setMaximum (256); +this.rScroller.setMinimum (0); +this.rScroller.setOrientation (0); +this.rScroller.setUnitIncrement (1); +this.rScroller.setVisibleAmount (1); +this.rScroller.setBounds ( new java.awt.Rectangle (36, 27, 119, 19)); +this.rScroller.addAdjustmentListener (this); +this.label1.setAlignment (4); +this.label1.setText ("R"); +this.label1.setBounds ( new java.awt.Rectangle (19, 30, 16, 15)); +this.rText.setFont ( new java.awt.Font ("Dialog", 0, 10)); +this.rText.setText ("0 "); +this.rText.setBounds ( new java.awt.Rectangle (156, 27, 53, 19)); +this.rText.addActionListener (this); +this.rText.addFocusListener (this); +this.label4.setAlignment (4); +this.label4.setText ("G"); +this.label4.setBounds ( new java.awt.Rectangle (15, 56, 20, 15)); +this.gScroller.setMaximum (256); +this.gScroller.setMinimum (0); +this.gScroller.setOrientation (0); +this.gScroller.setUnitIncrement (1); +this.gScroller.setVisibleAmount (1); +this.gScroller.setBounds ( new java.awt.Rectangle (35, 52, 120, 20)); +this.gScroller.addAdjustmentListener (this); +this.gText.setFont ( new java.awt.Font ("Dialog", 0, 10)); +this.gText.setText ("0 "); +this.gText.setBounds ( new java.awt.Rectangle (156, 52, 53, 20)); +this.gText.addActionListener (this); +this.gText.addFocusListener (this); +this.label5.setAlignment (4); +this.label5.setText ("B"); +this.label5.setBounds ( new java.awt.Rectangle (14, 82, 20, 15)); +this.bScroller.setMaximum (256); +this.bScroller.setMinimum (0); +this.bScroller.setOrientation (0); +this.bScroller.setUnitIncrement (1); +this.bScroller.setVisibleAmount (1); +this.bScroller.setBounds ( new java.awt.Rectangle (35, 78, 120, 20)); +this.bScroller.addAdjustmentListener (this); +this.bText.setFont ( new java.awt.Font ("Dialog", 0, 10)); +this.bText.setText ("0 "); +this.bText.setBounds ( new java.awt.Rectangle (157, 78, 52, 20)); +this.bText.addActionListener (this); +this.bText.addFocusListener (this); +this.target.setBackground (java.awt.Color.black); +this.target.setBounds ( new java.awt.Rectangle (229, 26, 134, 79)); +this.add (this.okcancelPanel, null); +this.okcancelPanel.add (this.okButton, null); +this.okcancelPanel.add (this.applyButton, null); +this.okcancelPanel.add (this.cancelButton, null); +this.add (this.rText); +this.add (this.gText); +this.add (this.bText); +this.add (this.buttonPanel, null); +this.add (this.target, null); +this.add (this.gScroller); +this.add (this.rScroller); +this.add (this.bScroller); +this.add (this.label5); +this.add (this.label4); +this.add (this.label1); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "focusGained", +function (e) { +}, "java.awt.event.FocusEvent"); +Clazz.overrideMethod (c$, "focusLost", +function (e) { +var c = e.getComponent (); +if (c === this.rText) { +this.rText_actionPerformed (); +} else { +if (c === this.gText) { +this.gText_actionPerformed (); +} else { +if (c === this.bText) { +this.bText_actionPerformed (); +}}}}, "java.awt.event.FocusEvent"); +c$.$UserDefinedColours$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.appletgui, "UserDefinedColours$1", java.awt.event.MouseAdapter); +Clazz.overrideMethod (c$, "mousePressed", +function (e) { +this.b$["jalview.appletgui.UserDefinedColours"].colourButtonPressed (e); +}, "java.awt.event.MouseEvent"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/bin/Cache.js b/bin/jalview/bin/Cache.js index 3013f58..b2a7cae 100644 --- a/bin/jalview/bin/Cache.js +++ b/bin/jalview/bin/Cache.js @@ -1,29 +1,29 @@ -Clazz.declarePackage ("jalview.bin"); -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.bin.Cache.Log")) { -jalview.bin.Cache.$Cache$Log$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.bin, "Cache"); -c$.getDefault = Clazz.defineMethod (c$, "getDefault", -function (string, string2) { -return null; -}, "~S,~S"); -c$.$Cache$Log$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.bin.Cache, "Log"); -Clazz.defineMethod (c$, "error", -function (a) { -}, "~S"); -Clazz.defineMethod (c$, "isDebugEnabled", -function () { -return false; -}); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"CASTORLOGLEVEL", null, -"log", null); +Clazz.declarePackage ("jalview.bin"); +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.bin.Cache.Log")) { +jalview.bin.Cache.$Cache$Log$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.bin, "Cache"); +c$.getDefault = Clazz.defineMethod (c$, "getDefault", +function (string, string2) { +return null; +}, "~S,~S"); +c$.$Cache$Log$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.bin.Cache, "Log"); +Clazz.defineMethod (c$, "error", +function (a) { +}, "~S"); +Clazz.defineMethod (c$, "isDebugEnabled", +function () { +return false; +}); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"CASTORLOGLEVEL", null, +"log", null); diff --git a/bin/jalview/bin/JalviewLite.js b/bin/jalview/bin/JalviewLite.js index 1049dcb..23d66b7 100644 --- a/bin/jalview/bin/JalviewLite.js +++ b/bin/jalview/bin/JalviewLite.js @@ -1,1617 +1,1617 @@ -Clazz.declarePackage ("jalview.bin"); -Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.javascript.JalviewLiteJsApi", "java.lang.Thread", "javax.swing.JApplet", "jalview.util.MessageManager", "java.util.Hashtable", "$.Vector", "javax.swing.JButton"], "jalview.bin.JalviewLite", ["jalview.analysis.SequenceIdMatcher", "jalview.appletgui.AlignFrame", "$.EmbmenuFrame", "$.FeatureSettings", "$.SplitFrame", "jalview.datamodel.Alignment", "$.AlignmentOrder", "$.ColumnSelection", "$.PDBEntry", "$.SequenceGroup", "jalview.io.AnnotationFile", "$.AppletFormatAdapter", "$.FileParse", "$.IdentifyFile", "$.JnetAnnotationMaker", "$.NewickFile", "jalview.javascript.JSFunctionExec", "$.JsSelectionSender", "$.MouseOverListener", "$.MouseOverStructureListener", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.UserColourScheme", "jalview.structure.SelectionListener", "$.StructureSelectionManager", "java.awt.Color", "$.EventQueue", "$.Font", "java.awt.event.ActionListener", "$.WindowAdapter", "java.io.BufferedReader", "$.InputStreamReader", "java.lang.Error", "$.StringBuffer", "java.net.URL", "java.util.StringTokenizer", "netscape.javascript.JSObject"], function () { -c$ = Clazz.decorateAsClass (function () { -this.embedded = false; -this.enableSplitFrame = false; -this.showButton = true; -this.checkForJmol = true; -this.jalviewServletURL = null; -this.startupFile = "No file"; -this.helpUrl = null; -this.externalstructureviewer = null; -this.sep = null; -this.rgb = null; -this.labelColour = null; -this.initjscallback = null; -this.pdbFile = null; -this.sequence = null; -this.jnetFile = null; -this.annotations = null; -this.hideFeatureGroups = null; -this.showFeatureGroups = null; -this.features = null; -this.showFeatureSettings = null; -this.scoreFile = null; -this.treeFile = null; -this.windowWidth = null; -this.windowHeight = null; -this.defaultColour = null; -this.sortBy = null; -this.wrap = null; -this.centrecolumnlabels = null; -this.userDefinedColour = null; -this.widthScale = null; -this.heightScale = null; -this.upperCase = null; -this.file2 = null; -this.javascriptListeners = null; -this.jsFunctionExec = null; -this.fileFound = true; -this.launcher = null; -this.currentAlignFrame = null; -this.initialAlignFrame = null; -this.checkedForJmol = false; -this.jmolAvailable = false; -this.alignPdbStructures = false; -this.useXtrnalSviewer = false; -this.haveShownLoadMessage = false; -if (!Clazz.isClassDefined ("jalview.bin.JalviewLite.LoadJmolThread")) { -jalview.bin.JalviewLite.$JalviewLite$LoadJmolThread$ (); -} -if (!Clazz.isClassDefined ("jalview.bin.JalviewLite.LoadingThread")) { -jalview.bin.JalviewLite.$JalviewLite$LoadingThread$ (); -} -this.separator = "\u00ac"; -this.jsfallbackEnabled = false; -this.jshashes = null; -this.jsmessages = null; -this.jsExecQueue = null; -Clazz.instantialize (this, arguments); -}, jalview.bin, "JalviewLite", javax.swing.JApplet, [jalview.api.StructureSelectionManagerProvider, jalview.javascript.JalviewLiteJsApi]); -Clazz.prepareFields (c$, function () { -this.javascriptListeners = new java.util.Vector (); -this.launcher = new javax.swing.JButton (jalview.util.MessageManager.getString ("label.start_jalview")); -this.jshashes = new java.util.Hashtable (); -this.jsmessages = new java.util.Hashtable (); -this.jsExecQueue = new java.util.Vector (); -}); -Clazz.defineMethod (c$, "setParams", -($fz = function () { -jalview.bin.JalviewLite.debug = "true".equalsIgnoreCase (this.getParameter ("debug")); -this.enableSplitFrame = "true".equalsIgnoreCase (this.getParameter ("enableSplitFrame")); -this.embedded = "true".equalsIgnoreCase (this.getParameter ("embedded")); -this.showButton = !"false".equalsIgnoreCase (this.getParameter ("showbutton")); -this.jalviewServletURL = this.getParameter ("APPLICATION_URL"); -this.startupFile = this.getParameter ("file"); -this.helpUrl = this.getParameter ("jalviewhelpurl"); -this.externalstructureviewer = this.getParameter ("externalstructureviewer"); -this.checkForJmol = !"true".equals (this.getParameter ("nojmol")); -this.sep = this.getParameter ("separator"); -this.rgb = this.getParameter ("RGB"); -this.labelColour = this.getParameter ("label"); -this.initjscallback = this.getParameter ("oninit"); -this.pdbFile = this.getParameter ("PDBFILE"); -this.sequence = this.getParameter ("PDBSEQ"); -this.jnetFile = this.getParameter ("jnetfile"); -this.annotations = this.getParameter ("annotations"); -this.hideFeatureGroups = this.getParameter ("hidefeaturegroups"); -this.showFeatureGroups = this.getParameter ("showfeaturegroups"); -this.features = this.getParameter ("features"); -this.showFeatureSettings = this.getParameter ("showFeatureSettings"); -this.scoreFile = this.getParameter ("scoreFile"); -this.treeFile = this.getParameter ("tree"); -if (this.treeFile == null) this.treeFile = this.getParameter ("treeFile"); -this.windowWidth = this.getParameter ("windowWidth"); -this.windowHeight = this.getParameter ("windowHeight"); -this.defaultColour = this.getParameter ("defaultColour"); -this.sortBy = this.getParameter ("sortBy"); -this.wrap = this.getParameter ("wrap"); -this.centrecolumnlabels = this.getParameter ("centrecolumnlabels"); -this.userDefinedColour = this.getParameter ("userDefinedColour"); -this.widthScale = this.getParameter ("widthScale"); -this.heightScale = this.getParameter ("heightScale"); -this.upperCase = this.getParameter ("upperCase"); -this.file2 = this.getParameter ("file2"); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getDefaultParameter", -function (name, def) { -var stn; -if ((stn = this.getParameter (name)) == null) { -return def; -}if (stn.toLowerCase ().equals ("true")) { -return true; -}return false; -}, "~S,~B"); -Clazz.defineMethod (c$, "getLinkParams", -function (links) { -var label; -var url; -for (var i = 1; i < 10; i++) { -label = this.getParameter ("linkLabel_" + i); -url = this.getParameter ("linkURL_" + i); -if (label != null && url != null) { -links.addElement (label + "|" + url); -}} -}, "java.util.Vector"); -Clazz.defineMethod (c$, "getStructureSelectionManager", -function () { -return jalview.structure.StructureSelectionManager.getStructureSelectionManager (this); -}); -Clazz.defineMethod (c$, "getSelectedSequences", -function () { -return this.getSelectedSequencesFrom (this.getDefaultTargetFrame ()); -}); -Clazz.defineMethod (c$, "getSelectedSequences", -function (sep) { -return this.getSelectedSequencesFrom (this.getDefaultTargetFrame (), sep); -}, "~S"); -Clazz.defineMethod (c$, "getSelectedSequencesFrom", -function (alf) { -return this.getSelectedSequencesFrom (alf, this.separator); -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "getSelectedSequencesFrom", -function (alf, sep) { -var result = new StringBuffer (""); -if (sep == null || sep.length == 0) { -sep = this.separator; -}if (alf.viewport.getSelectionGroup () != null) { -var seqs = alf.viewport.getSelectionGroup ().getSequencesInOrder (alf.viewport.getAlignment ()); -for (var i = 0; i < seqs.length; i++) { -result.append (seqs[i].getName ()); -result.append (sep); -} -}return result.toString (); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "highlight", -function (sequenceId, position, alignedPosition) { -this.highlightIn (this.getDefaultTargetFrame (), sequenceId, position, alignedPosition); -}, "~S,~S,~S"); -Clazz.overrideMethod (c$, "highlightIn", -function (alf, sequenceId, position, alignedPosition) { -var matcher = new jalview.analysis.SequenceIdMatcher (alf.viewport.getAlignment ().getSequencesArray ()); -var sq = matcher.findIdMatch (sequenceId); -if (sq != null) { -var apos = -1; -try { -apos = new Integer (position).intValue (); -apos--; -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -return; -} else { -throw ex; -} -} -var me = this; -var pos = apos; -if (alignedPosition != null && (alignedPosition.trim ().length == 0 || alignedPosition.toLowerCase ().indexOf ("false") > -1)) { -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$1") ? 0 : jalview.bin.JalviewLite.$JalviewLite$1$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$1, this, Clazz.cloneFinals ("me", me, "sq", sq, "pos", pos)))); -} else { -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$2") ? 0 : jalview.bin.JalviewLite.$JalviewLite$2$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$2, this, Clazz.cloneFinals ("me", me, "sq", sq, "pos", pos)))); -}}}, "jalview.appletgui.AlignFrame,~S,~S,~S"); -Clazz.defineMethod (c$, "select", -function (sequenceIds, columns) { -this.selectIn (this.getDefaultTargetFrame (), sequenceIds, columns, this.separator); -}, "~S,~S"); -Clazz.defineMethod (c$, "select", -function (sequenceIds, columns, sep) { -this.selectIn (this.getDefaultTargetFrame (), sequenceIds, columns, sep); -}, "~S,~S,~S"); -Clazz.defineMethod (c$, "selectIn", -function (alf, sequenceIds, columns) { -this.selectIn (alf, sequenceIds, columns, this.separator); -}, "jalview.appletgui.AlignFrame,~S,~S"); -Clazz.defineMethod (c$, "selectIn", -function (alf, sequenceIds, columns, sep) { -if (sep == null || sep.length == 0) { -sep = this.separator; -} else { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Selecting region using separator string '" + this.separator + "'"); -}}var ids = this.separatorListToArray (sequenceIds, sep); -var cols = this.separatorListToArray (columns, sep); -var sel = new jalview.datamodel.SequenceGroup (); -var csel = new jalview.datamodel.ColumnSelection (); -var al = alf.viewport.getAlignment (); -var matcher = new jalview.analysis.SequenceIdMatcher (alf.viewport.getAlignment ().getSequencesArray ()); -var start = 0; -var end = al.getWidth (); -var alw = al.getWidth (); -var seqsfound = true; -if (ids != null && ids.length > 0) { -seqsfound = false; -for (var i = 0; i < ids.length; i++) { -if (ids[i].trim ().length == 0) { -continue; -}var sq = matcher.findIdMatch (ids[i]); -if (sq != null) { -seqsfound = true; -sel.addSequence (sq, false); -}} -}var inseqpos = false; -if (cols != null && cols.length > 0) { -var seset = false; -for (var i = 0; i < cols.length; i++) { -var cl = cols[i].trim (); -if (cl.length == 0) { -continue; -}var p; -if ((p = cl.indexOf ("-")) > -1) { -var from = -1; -var to = -1; -try { -from = new Integer (cl.substring (0, p)).intValue (); -from--; -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -System.err.println ("ERROR: Couldn't parse first integer in range element column selection string '" + cl + "' - format is 'from-to'"); -return; -} else { -throw ex; -} -} -try { -to = new Integer (cl.substring (p + 1)).intValue (); -to--; -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -System.err.println ("ERROR: Couldn't parse second integer in range element column selection string '" + cl + "' - format is 'from-to'"); -return; -} else { -throw ex; -} -} -if (from >= 0 && to >= 0) { -if (from < to) { -var t = to; -to = from; -to = t; -}if (!seset) { -start = from; -end = to; -seset = true; -} else { -if (start > from) { -start = from; -}if (end < to) { -end = to; -}}for (var r = from; r <= to; r++) { -if (r >= 0 && r < alw) { -csel.addElement (r); -}} -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Range '" + cl + "' deparsed as [" + from + "," + to + "]"); -}} else { -System.err.println ("ERROR: Invalid Range '" + cl + "' deparsed as [" + from + "," + to + "]"); -}} else { -var r = -1; -try { -r = new Integer (cl).intValue (); -r--; -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -if (cl.toLowerCase ().equals ("sequence")) { -inseqpos = true; -} else { -System.err.println ("ERROR: Couldn't parse integer from point selection element of column selection string '" + cl + "'"); -return; -}} else { -throw ex; -} -} -if (r >= 0 && r <= alw) { -if (!seset) { -start = r; -end = r; -seset = true; -} else { -if (start > r) { -start = r; -}if (end < r) { -end = r; -}}csel.addElement (r); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Point selection '" + cl + "' deparsed as [" + r + "]"); -}} else { -System.err.println ("ERROR: Invalid Point selection '" + cl + "' deparsed as [" + r + "]"); -}}} -}if (seqsfound) { -if (inseqpos && sel.getSize () > 0) { -var rs = sel.getSequenceAt (0); -start = rs.findIndex (start); -end = rs.findIndex (end); -if (csel != null) { -var cs = csel.getSelected (); -csel.clear (); -for (var selectedCol, $selectedCol = cs.iterator (); $selectedCol.hasNext () && ((selectedCol = $selectedCol.next ()) || true);) { -csel.addElement (rs.findIndex ((selectedCol).intValue ())); -} -}}sel.setStartRes (start); -sel.setEndRes (end); -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$3") ? 0 : jalview.bin.JalviewLite.$JalviewLite$3$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$3, this, Clazz.cloneFinals ("alf", alf, "sel", sel, "csel", csel)))); -}}, "jalview.appletgui.AlignFrame,~S,~S,~S"); -Clazz.overrideMethod (c$, "getSelectedSequencesAsAlignment", -function (format, suffix) { -return this.getSelectedSequencesAsAlignmentFrom (this.getDefaultTargetFrame (), format, suffix); -}, "~S,~S"); -Clazz.overrideMethod (c$, "getSelectedSequencesAsAlignmentFrom", -function (alf, format, suffix) { -try { -var seqlimits = suffix.equalsIgnoreCase ("true"); -if (alf.viewport.getSelectionGroup () != null) { -var reply = new jalview.io.AppletFormatAdapter ().formatSequences (format, new jalview.datamodel.Alignment (alf.viewport.getSelectionAsNewSequence ()), seqlimits); -return reply; -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -return "Error retrieving alignment in " + format + " format. "; -} else { -throw ex; -} -} -return ""; -}, "jalview.appletgui.AlignFrame,~S,~S"); -Clazz.overrideMethod (c$, "getAlignmentOrder", -function () { -return this.getAlignmentOrderFrom (this.getDefaultTargetFrame ()); -}); -Clazz.defineMethod (c$, "getAlignmentOrderFrom", -function (alf) { -return this.getAlignmentOrderFrom (alf, this.separator); -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "getAlignmentOrderFrom", -function (alf, sep) { -var alorder = alf.getAlignViewport ().getAlignment (); -var order = new Array (alorder.getHeight ()); -for (var i = 0; i < order.length; i++) { -order[i] = alorder.getSequenceAt (i).getName (); -} -return this.arrayToSeparatorList (order); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.defineMethod (c$, "orderBy", -function (order, undoName) { -return this.orderBy (order, undoName, this.separator); -}, "~S,~S"); -Clazz.defineMethod (c$, "orderBy", -function (order, undoName, sep) { -return this.orderAlignmentBy (this.getDefaultTargetFrame (), order, undoName, sep); -}, "~S,~S,~S"); -Clazz.overrideMethod (c$, "orderAlignmentBy", -function (alf, order, undoName, sep) { -var ids = this.separatorListToArray (order, sep); -var sqs = null; -if (ids != null && ids.length > 0) { -var matcher = new jalview.analysis.SequenceIdMatcher (alf.viewport.getAlignment ().getSequencesArray ()); -var s = 0; -sqs = new Array (ids.length); -for (var i = 0; i < ids.length; i++) { -if (ids[i].trim ().length == 0) { -continue; -}var sq = matcher.findIdMatch (ids[i]); -if (sq != null) { -sqs[s++] = sq; -}} -if (s > 0) { -var sqq = new Array (s); -System.arraycopy (sqs, 0, sqq, 0, s); -sqs = sqq; -} else { -sqs = null; -}}if (sqs == null) { -return ""; -};var aorder = new jalview.datamodel.AlignmentOrder (sqs); -if (undoName != null && undoName.trim ().length == 0) { -undoName = null; -}var _undoName = undoName; -return alf.sortBy (aorder, _undoName) ? "true" : ""; -}, "jalview.appletgui.AlignFrame,~S,~S,~S"); -Clazz.defineMethod (c$, "getAlignment", -function (format) { -return this.getAlignmentFrom (this.getDefaultTargetFrame (), format, "true"); -}, "~S"); -Clazz.defineMethod (c$, "getAlignmentFrom", -function (alf, format) { -return this.getAlignmentFrom (alf, format, "true"); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.defineMethod (c$, "getAlignment", -function (format, suffix) { -return this.getAlignmentFrom (this.getDefaultTargetFrame (), format, suffix); -}, "~S,~S"); -Clazz.defineMethod (c$, "getAlignmentFrom", -function (alf, format, suffix) { -try { -var seqlimits = suffix.equalsIgnoreCase ("true"); -var reply = new jalview.io.AppletFormatAdapter ().formatSequences (format, alf.viewport.getAlignment (), seqlimits); -return reply; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -return "Error retrieving alignment in " + format + " format. "; -} else { -throw ex; -} -} -}, "jalview.appletgui.AlignFrame,~S,~S"); -Clazz.overrideMethod (c$, "loadAnnotation", -function (annotation) { -this.loadAnnotationFrom (this.getDefaultTargetFrame (), annotation); -}, "~S"); -Clazz.overrideMethod (c$, "loadAnnotationFrom", -function (alf, annotation) { -if ( new jalview.io.AnnotationFile ().annotateAlignmentView (alf.getAlignViewport (), annotation, jalview.io.AppletFormatAdapter.PASTE)) { -alf.alignPanel.fontChanged (); -alf.alignPanel.setScrollValues (0, 0); -} else { -alf.parseFeaturesFile (annotation, jalview.io.AppletFormatAdapter.PASTE); -}}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "loadFeatures", -function (features, autoenabledisplay) { -this.loadFeaturesFrom (this.getDefaultTargetFrame (), features, autoenabledisplay); -}, "~S,~B"); -Clazz.overrideMethod (c$, "loadFeaturesFrom", -function (alf, features, autoenabledisplay) { -return alf.parseFeaturesFile (features, jalview.io.AppletFormatAdapter.PASTE, autoenabledisplay); -}, "jalview.appletgui.AlignFrame,~S,~B"); -Clazz.overrideMethod (c$, "getFeatures", -function (format) { -return this.getFeaturesFrom (this.getDefaultTargetFrame (), format); -}, "~S"); -Clazz.overrideMethod (c$, "getFeaturesFrom", -function (alf, format) { -return alf.outputFeatures (false, format); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "getAnnotation", -function () { -return this.getAnnotationFrom (this.getDefaultTargetFrame ()); -}); -Clazz.overrideMethod (c$, "getAnnotationFrom", -function (alf) { -return alf.outputAnnotations (false); -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "newView", -function () { -return this.newViewFrom (this.getDefaultTargetFrame ()); -}); -Clazz.defineMethod (c$, "newView", -function (name) { -return this.newViewFrom (this.getDefaultTargetFrame (), name); -}, "~S"); -Clazz.defineMethod (c$, "newViewFrom", -function (alf) { -return alf.newView (null); -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "newViewFrom", -function (alf, name) { -return alf.newView (name); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "loadAlignment", -function (text, title) { -var al = null; -var format = new jalview.io.IdentifyFile ().Identify (text, jalview.io.AppletFormatAdapter.PASTE); -try { -al = new jalview.io.AppletFormatAdapter ().readFile (text, jalview.io.AppletFormatAdapter.PASTE, format); -if (al.getHeight () > 0) { -return new jalview.appletgui.AlignFrame (al, this, title, false); -}} catch (ex) { -if (Clazz.exceptionOf (ex, java.io.IOException)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -return null; -}, "~S,~S"); -Clazz.defineMethod (c$, "setMouseoverListener", -function (listener) { -this.setMouseoverListener (this.currentAlignFrame, listener); -}, "~S"); -Clazz.defineMethod (c$, "setMouseoverListener", -function (af, listener) { -if (listener != null) { -listener = listener.trim (); -if (listener.length == 0) { -System.err.println ("jalview Javascript error: Ignoring empty function for mouseover listener."); -return; -}}var mol = new jalview.javascript.MouseOverListener (this, af, listener); -this.javascriptListeners.addElement (mol); -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).addStructureViewerListener (mol); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Added a mouseover listener for " + ((af == null) ? "All frames" : "Just views for " + af.getAlignViewport ().getSequenceSetId ())); -System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); -}}, "jalview.appletgui.AlignFrame,~S"); -Clazz.defineMethod (c$, "setSelectionListener", -function (listener) { -this.setSelectionListener (null, listener); -}, "~S"); -Clazz.defineMethod (c$, "setSelectionListener", -function (af, listener) { -if (listener != null) { -listener = listener.trim (); -if (listener.length == 0) { -System.err.println ("jalview Javascript error: Ignoring empty function for selection listener."); -return; -}}var mol = new jalview.javascript.JsSelectionSender (this, af, listener); -this.javascriptListeners.addElement (mol); -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).addSelectionListener (mol); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Added a selection listener for " + ((af == null) ? "All frames" : "Just views for " + af.getAlignViewport ().getSequenceSetId ())); -System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); -}}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "setStructureListener", -function (listener, modelSet) { -if (listener != null) { -listener = listener.trim (); -if (listener.length == 0) { -System.err.println ("jalview Javascript error: Ignoring empty function for selection listener."); -return; -}}var mol = new jalview.javascript.MouseOverStructureListener (this, listener, this.separatorListToArray (modelSet)); -this.javascriptListeners.addElement (mol); -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).addStructureViewerListener (mol); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Added a javascript structure viewer listener '" + listener + "'"); -System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); -}}, "~S,~S"); -Clazz.overrideMethod (c$, "removeJavascriptListener", -function (af, listener) { -if (listener != null) { -listener = listener.trim (); -if (listener.length == 0) { -listener = null; -}}var rprt = false; -for (var ms = 0, msSize = this.javascriptListeners.size (); ms < msSize; ) { -var lstn = this.javascriptListeners.elementAt (ms); -var lstner = lstn; -if ((af == null || lstner.getAlignFrame () === af) && (listener == null || lstner.getListenerFunction ().equals (listener))) { -this.javascriptListeners.removeElement (lstner); -msSize--; -if (Clazz.instanceOf (lstner, jalview.structure.SelectionListener)) { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeSelectionListener (lstner); -} else { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeStructureViewerListener (lstner, null); -}rprt = jalview.bin.JalviewLite.debug; -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Removed listener '" + listener + "'"); -}} else { -ms++; -}} -if (rprt) { -System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); -}}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "stop", -function () { -System.err.println ("Applet " + this.getName () + " stop()."); -this.tidyUp (); -}); -Clazz.overrideMethod (c$, "destroy", -function () { -System.err.println ("Applet " + this.getName () + " destroy()."); -this.tidyUp (); -}); -Clazz.defineMethod (c$, "tidyUp", -($fz = function () { -this.removeAll (); -if (this.currentAlignFrame != null && this.currentAlignFrame.viewport != null && this.currentAlignFrame.viewport.applet != null) { -var av = this.currentAlignFrame.viewport; -this.currentAlignFrame.closeMenuItem_actionPerformed (); -av.applet = null; -this.currentAlignFrame = null; -}if (this.javascriptListeners != null) { -while (this.javascriptListeners.size () > 0) { -var mol = this.javascriptListeners.elementAt (0); -this.javascriptListeners.removeElement (mol); -if (Clazz.instanceOf (mol, jalview.structure.SelectionListener)) { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeSelectionListener (mol); -} else { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeStructureViewerListener (mol, null); -}mol.jvlite = null; -} -}if (this.jsFunctionExec != null) { -this.jsFunctionExec.stopQueue (); -this.jsFunctionExec.jvlite = null; -}this.initialAlignFrame = null; -this.jsFunctionExec = null; -this.javascriptListeners = null; -jalview.structure.StructureSelectionManager.release (this); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "mouseOverStructure", -function (pdbResNum, chain, pdbfile) { -var me = this; -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$4") ? 0 : jalview.bin.JalviewLite.$JalviewLite$4$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$4, this, Clazz.cloneFinals ("me", me, "pdbResNum", pdbResNum, "chain", chain, "pdbfile", pdbfile)))); -}, "~S,~S,~S"); -Clazz.overrideMethod (c$, "scrollViewToIn", -function (alf, topRow, leftHandColumn) { -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$5") ? 0 : jalview.bin.JalviewLite.$JalviewLite$5$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$5, this, Clazz.cloneFinals ("alf", alf, "topRow", topRow, "leftHandColumn", leftHandColumn)))); -}, "jalview.appletgui.AlignFrame,~S,~S"); -Clazz.overrideMethod (c$, "scrollViewToRowIn", -function (alf, topRow) { -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$6") ? 0 : jalview.bin.JalviewLite.$JalviewLite$6$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$6, this, Clazz.cloneFinals ("alf", alf, "topRow", topRow)))); -}, "jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "scrollViewToColumnIn", -function (alf, leftHandColumn) { -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$7") ? 0 : jalview.bin.JalviewLite.$JalviewLite$7$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$7, this, Clazz.cloneFinals ("alf", alf, "leftHandColumn", leftHandColumn)))); -}, "jalview.appletgui.AlignFrame,~S"); -c$.initBuildDetails = Clazz.defineMethod (c$, "initBuildDetails", -($fz = function () { -if (jalview.bin.JalviewLite.builddate == null) { -jalview.bin.JalviewLite.builddate = "unknown"; -jalview.bin.JalviewLite.version = "test"; -jalview.bin.JalviewLite.installation = "Webstart"; -var url = jalview.bin.JalviewLite.getResource ("/.build_properties"); -if (url != null) { -try { -var reader = new java.io.BufferedReader ( new java.io.InputStreamReader (url.openStream ())); -var line; -while ((line = reader.readLine ()) != null) { -if (line.indexOf ("VERSION") > -1) { -jalview.bin.JalviewLite.version = line.substring (line.indexOf ("=") + 1); -}if (line.indexOf ("BUILD_DATE") > -1) { -jalview.bin.JalviewLite.builddate = line.substring (line.indexOf ("=") + 1); -}if (line.indexOf ("INSTALLATION") > -1) { -jalview.bin.JalviewLite.installation = line.substring (line.indexOf ("=") + 1); -}} -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}}}, $fz.isPrivate = true, $fz)); -c$.getBuildDate = Clazz.defineMethod (c$, "getBuildDate", -function () { -jalview.bin.JalviewLite.initBuildDetails (); -return jalview.bin.JalviewLite.builddate; -}); -c$.getInstallation = Clazz.defineMethod (c$, "getInstallation", -function () { -jalview.bin.JalviewLite.initBuildDetails (); -return jalview.bin.JalviewLite.installation; -}); -c$.getVersion = Clazz.defineMethod (c$, "getVersion", -function () { -jalview.bin.JalviewLite.initBuildDetails (); -return jalview.bin.JalviewLite.version; -}); -Clazz.overrideMethod (c$, "init", -function () { -this.setParams (); -try { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Applet context is '" + this.getAppletContext ().getClass ().toString () + "'"); -}var scriptObject = netscape.javascript.JSObject.getWindow (this); -if (jalview.bin.JalviewLite.debug && scriptObject != null) { -System.err.println ("Applet has Javascript callback support."); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Warning: No JalviewLite javascript callbacks available."); -if (jalview.bin.JalviewLite.debug) { -ex.printStackTrace (); -}} else { -throw ex; -} -} -if (jalview.bin.JalviewLite.debug) { -System.err.println ("JalviewLite Version " + jalview.bin.JalviewLite.getVersion ()); -System.err.println ("Build Date : " + jalview.bin.JalviewLite.getBuildDate ()); -System.err.println ("Installation : " + jalview.bin.JalviewLite.getInstallation ()); -}if (this.externalstructureviewer != null) { -this.useXtrnalSviewer = this.externalstructureviewer.trim ().toLowerCase ().equals ("true"); -}if (this.sep != null) { -if (this.sep.length > 0) { -this.separator = this.sep; -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Separator set to '" + this.separator + "'"); -}} else { -throw new Error (jalview.util.MessageManager.getString ("error.invalid_separator_parameter")); -}}var r = 255; -var g = 255; -var b = 255; -if (this.rgb != null) { -try { -r = Integer.parseInt (this.rgb.substring (0, 2), 16); -g = Integer.parseInt (this.rgb.substring (2, 4), 16); -b = Integer.parseInt (this.rgb.substring (4, 6), 16); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -r = 255; -g = 255; -b = 255; -} else { -throw ex; -} -} -}this.rgb = this.labelColour; -if (this.rgb != null) { -this.launcher.setLabel (this.rgb); -}this.setBackground ( new java.awt.Color (r, g, b)); -if (this.startupFile == null) { -var data = new StringBuffer ("PASTE"); -var i = 1; -while ((this.startupFile = this.getParameter ("sequence" + i)) != null) { -data.append (this.startupFile.toString () + "\n"); -i++; -} -if (data.length () > 5) { -this.startupFile = data.toString (); -}}if (!this.enableSplitFrame) { -this.file2 = null; -}if (this.embedded) { -var loader = Clazz.innerTypeInstance (jalview.bin.JalviewLite.LoadingThread, this, null, this.startupFile, this.file2, this); -{ -loader.run(); -}} else if (this.startupFile != null) { -if (!this.showButton) { -var loader = Clazz.innerTypeInstance (jalview.bin.JalviewLite.LoadingThread, this, null, this.startupFile, this.file2, this); -loader.start (); -} else { -this.add (this.launcher); -this.launcher.addActionListener (((Clazz.isClassDefined ("jalview.bin.JalviewLite$8") ? 0 : jalview.bin.JalviewLite.$JalviewLite$8$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$8, this, null))); -}} else { -this.startupFile = "NO FILE"; -this.fileFound = false; -this.callInitCallback (); -}}); -Clazz.defineMethod (c$, "initLiveConnect", -($fz = function () { -var notFailed = false; -var tries = 0; -while (!notFailed && tries < 10) { -if (tries > 0) { -System.err.println ("LiveConnect request thread going to sleep."); -}try { -Thread.sleep (700 * (1 + tries)); -} catch (q) { -if (Clazz.exceptionOf (q, InterruptedException)) { -} else { -throw q; -} -} -;if (tries++ > 0) { -System.err.println ("LiveConnect request thread woken up."); -}try { -var scriptObject = netscape.javascript.JSObject.getWindow (this); -if (scriptObject.eval ("navigator") != null) { -notFailed = true; -}} catch (jsex) { -if (Clazz.exceptionOf (jsex, Exception)) { -System.err.println ("Attempt " + tries + " to access LiveConnect javascript failed."); -} else { -throw jsex; -} -} -} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "callInitCallback", -($fz = function () { -if (this.initjscallback == null) { -return; -}this.initjscallback = this.initjscallback.trim (); -if (this.initjscallback.length > 0) { -var scriptObject = null; -try { -scriptObject = netscape.javascript.JSObject.getWindow (this); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -;this.initLiveConnect (); -if (scriptObject != null) { -try { - new jalview.javascript.JSFunctionExec (this).executeJavascriptFunction (true, this.initjscallback, null, "Calling oninit callback '" + this.initjscallback + "'."); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Exception when executing _oninit callback '" + this.initjscallback + "'."); -e.printStackTrace (); -} else { -throw e; -} -} -} else { -System.err.println ("Not executing _oninit callback '" + this.initjscallback + "' - no scripting allowed."); -}}}, $fz.isPrivate = true, $fz)); -c$.addFrame = Clazz.defineMethod (c$, "addFrame", -function (frame, title, width, height) { -frame.setLocation (jalview.bin.JalviewLite.lastFrameX, jalview.bin.JalviewLite.lastFrameY); -jalview.bin.JalviewLite.lastFrameX += 40; -jalview.bin.JalviewLite.lastFrameY += 40; -frame.setSize (width, height); -frame.setTitle (title); -frame.addWindowListener (((Clazz.isClassDefined ("jalview.bin.JalviewLite$9") ? 0 : jalview.bin.JalviewLite.$JalviewLite$9$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$9, this, Clazz.cloneFinals ("frame", frame)))); -frame.setVisible (true); -}, "javax.swing.JFrame,~S,~N,~N"); -Clazz.defineMethod (c$, "paintComponent", -function (g) { -if (!this.fileFound) { -g.setColor ( new java.awt.Color (200, 200, 200)); -g.setColor (java.awt.Color.cyan); -g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -g.setColor (java.awt.Color.red); -g.drawString (jalview.util.MessageManager.getString ("label.jalview_cannot_open_file"), 5, 15); -g.drawString ("\"" + this.startupFile + "\"", 5, 30); -} else if (this.embedded && !this.haveShownLoadMessage) { -g.setColor (java.awt.Color.black); -g.setFont ( new java.awt.Font ("Arial", 1, 24)); -g.drawString (jalview.util.MessageManager.getString ("label.jalview_applet"), 50, Clazz.doubleToInt (this.getSize ().height / 2) - 30); -g.drawString (jalview.util.MessageManager.getString ("label.loading_data") + "...", 50, Clazz.doubleToInt (this.getSize ().height / 2)); -this.haveShownLoadMessage = true; -}}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "getAppletWindow", -function (class1) { -var wnds = new java.util.Vector (); -var cmp = this.getComponents (); -if (cmp != null) { -for (var i = 0; i < cmp.length; i++) { -if (class1.isAssignableFrom (cmp[i].getClass ())) { -wnds.addElement (cmp); -}} -}return wnds; -}, "Class"); -Clazz.defineMethod (c$, "getDefaultTargetFrame", -function () { -if (this.currentAlignFrame != null) { -return this.currentAlignFrame; -}if (this.initialAlignFrame != null) { -return this.initialAlignFrame; -}System.err.println ("Implementation error: Jalview Applet API cannot work out which AlignFrame to use."); -return null; -}); -Clazz.defineMethod (c$, "separatorListToArray", -function (list) { -return this.separatorListToArray (list, this.separator); -}, "~S"); -Clazz.defineMethod (c$, "separatorListToArray", -function (list, separator) { -var seplen = separator.length; -if (list == null || list.equals ("") || list.equals (separator)) { -return null; -}var jv = new java.util.Vector (); -var cp = 0; -var pos; -while ((pos = list.indexOf (separator, cp)) > cp) { -jv.addElement (list.substring (cp, pos)); -cp = pos + seplen; -} -if (cp < list.length) { -var c = list.substring (cp); -if (!c.equals (separator)) { -jv.addElement (c); -}}if (jv.size () > 0) { -var v = new Array (jv.size ()); -for (var i = 0; i < v.length; i++) { -v[i] = jv.elementAt (i); -} -jv.removeAllElements (); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Array from '" + separator + "' separated List:\n" + v.length); -for (var i = 0; i < v.length; i++) { -System.err.println ("item " + i + " '" + v[i] + "'"); -} -}return v; -}if (jalview.bin.JalviewLite.debug) { -System.err.println ("Empty Array from '" + separator + "' separated List"); -}return null; -}, "~S,~S"); -Clazz.defineMethod (c$, "arrayToSeparatorList", -function (list) { -return this.arrayToSeparatorList (list, this.separator); -}, "~A"); -Clazz.defineMethod (c$, "arrayToSeparatorList", -function (list, separator) { -var v = new StringBuffer (); -if (list != null && list.length > 0) { -for (var i = 0, iSize = list.length; i < iSize; i++) { -if (list[i] != null) { -if (i > 0) { -v.append (separator); -}v.append (list[i]); -}} -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Returning '" + separator + "' separated List:\n"); -System.err.println (v); -}return v.toString (); -}if (jalview.bin.JalviewLite.debug) { -System.err.println ("Returning empty '" + separator + "' separated List\n"); -}return "" + separator; -}, "~A,~S"); -Clazz.overrideMethod (c$, "getFeatureGroups", -function () { -var lst = this.arrayToSeparatorList (this.getDefaultTargetFrame ().getFeatureGroups ()); -return lst; -}); -Clazz.overrideMethod (c$, "getFeatureGroupsOn", -function (alf) { -var lst = this.arrayToSeparatorList (alf.getFeatureGroups ()); -return lst; -}, "jalview.appletgui.AlignFrame"); -Clazz.overrideMethod (c$, "getFeatureGroupsOfState", -function (visible) { -return this.arrayToSeparatorList (this.getDefaultTargetFrame ().getFeatureGroupsOfState (visible)); -}, "~B"); -Clazz.overrideMethod (c$, "getFeatureGroupsOfStateOn", -function (alf, visible) { -return this.arrayToSeparatorList (alf.getFeatureGroupsOfState (visible)); -}, "jalview.appletgui.AlignFrame,~B"); -Clazz.overrideMethod (c$, "setFeatureGroupStateOn", -function (alf, groups, state) { -var st = state; -java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$10") ? 0 : jalview.bin.JalviewLite.$JalviewLite$10$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$10, this, Clazz.cloneFinals ("alf", alf, "groups", groups, "st", st)))); -}, "jalview.appletgui.AlignFrame,~S,~B"); -Clazz.overrideMethod (c$, "setFeatureGroupState", -function (groups, state) { -this.setFeatureGroupStateOn (this.getDefaultTargetFrame (), groups, state); -}, "~S,~B"); -Clazz.overrideMethod (c$, "getSeparator", -function () { -return this.separator; -}); -Clazz.overrideMethod (c$, "setSeparator", -function (separator) { -if (separator == null || separator.length < 1) { -separator = "\u00ac"; -}this.separator = separator; -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Default Separator now: '" + separator + "'"); -}}, "~S"); -Clazz.overrideMethod (c$, "addPdbFile", -function (alFrame, sequenceId, pdbEntryString, pdbFile) { -return alFrame.addPdbFile (sequenceId, pdbEntryString, pdbFile); -}, "jalview.appletgui.AlignFrame,~S,~S,~S"); -Clazz.defineMethod (c$, "setAlignPdbStructures", -function (alignPdbStructures) { -this.alignPdbStructures = alignPdbStructures; -}, "~B"); -Clazz.defineMethod (c$, "isAlignPdbStructures", -function () { -return this.alignPdbStructures; -}); -Clazz.overrideMethod (c$, "start", -function () { -}); -Clazz.defineMethod (c$, "setJsMessageSet", -function (messageclass, viewId, colcommands) { -var msgset = this.jsmessages.get (messageclass); -if (msgset == null) { -msgset = new java.util.Hashtable (); -this.jsmessages.put (messageclass, msgset); -}msgset.put (viewId, colcommands); -var l = Clazz.newLongArray (colcommands.length, 0); -for (var i = 0; i < colcommands.length; i++) { -l[i] = colcommands[i].hashCode (); -} -this.jshashes.put (messageclass + "|" + viewId, l); -}, "~S,~S,~A"); -Clazz.overrideMethod (c$, "getJsMessage", -function (messageclass, viewId) { -var msgset = this.jsmessages.get (messageclass); -if (msgset != null) { -var msgs = msgset.get (viewId); -if (msgs != null) { -for (var i = 0; i < msgs.length; i++) { -if (msgs[i] != null) { -var m = msgs[i]; -msgs[i] = null; -return m; -}} -}}return ""; -}, "~S,~S"); -Clazz.defineMethod (c$, "isJsMessageSetChanged", -function (string, string2, colcommands) { -var l = this.jshashes.get (string + "|" + string2); -if (l == null && colcommands != null) { -return true; -}for (var i = 0; i < colcommands.length; i++) { -if (l[i] != colcommands[i].hashCode ()) { -return true; -}} -return false; -}, "~S,~S,~A"); -Clazz.defineMethod (c$, "getJsExecQueue", -function () { -return this.jsExecQueue; -}); -Clazz.defineMethod (c$, "setExecutor", -function (jsFunctionExec2) { -this.jsFunctionExec = jsFunctionExec2; -}, "jalview.javascript.JSFunctionExec"); -Clazz.defineMethod (c$, "getDefaultColourParameter", -function (colparam, defcolour) { -var colprop = this.getParameter (colparam); -if (colprop == null || colprop.trim ().length == 0) { -return defcolour; -}var col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName (colprop); -if (col == null) { -try { -col = new jalview.schemes.UserColourScheme (colprop).findColour ('A'); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Couldn't parse '" + colprop + "' as a colour for " + colparam); -col = null; -} else { -throw ex; -} -} -}return (col == null) ? defcolour : col; -}, "~S,java.awt.Color"); -Clazz.defineMethod (c$, "openJalviewHelpUrl", -function () { -if (this.helpUrl == null || this.helpUrl.trim ().length < 5) { -this.helpUrl = "http://www.jalview.org/help.html"; -}this.showURL (this.helpUrl, "HELP"); -}); -Clazz.defineMethod (c$, "resolveUrlForLocalOrAbsolute", -($fz = function (url, localref) { -var codebase = localref.toString (); -var pt = codebase.indexOf ("?"); -if (pt < 0) pt = codebase.length; -codebase = codebase.substring (0, pt); -codebase = codebase.substring (0, codebase.lastIndexOf ("/") + 1); -if (url.indexOf ("/") == 0 && !localref.getProtocol ().equals ("file")) { -pt = codebase.indexOf ("/", 8); -return codebase.substring (0, pt) + url; -}return codebase + url; -}, $fz.isPrivate = true, $fz), "~S,java.net.URL"); -Clazz.defineMethod (c$, "showURL", -function (url, target) { -try { -if (url.indexOf (":") == -1) { -var prepend; -url = this.resolveUrlForLocalOrAbsolute (url, prepend = this.getDefaultParameter ("resolvetocodebase", false) ? this.getDocumentBase () : this.getCodeBase ()); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Show url (prepended " + prepend + " - toggle resolvetocodebase if code/docbase resolution is wrong): " + url); -}} else { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Show url: " + url); -}}if (url.indexOf ("javascript:") == 0) { -this.getAppletContext ().showDocument ( new java.net.URL (url)); -} else { -this.getAppletContext ().showDocument ( new java.net.URL (url), target); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}, "~S,~S"); -c$.$JalviewLite$LoadJmolThread$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.running = false; -Clazz.instantialize (this, arguments); -}, jalview.bin.JalviewLite, "LoadJmolThread", Thread); -Clazz.overrideMethod (c$, "run", -function () { -if (this.running || this.b$["jalview.bin.JalviewLite"].checkedForJmol) { -return; -}this.running = true; -if (this.b$["jalview.bin.JalviewLite"].checkForJmol) { -try { -if (!System.getProperty ("java.version").startsWith ("1.1")) { -Class.forName ("org.jmol.adapter.smarter.SmarterJmolAdapter"); -this.b$["jalview.bin.JalviewLite"].jmolAvailable = true; -}if (!this.b$["jalview.bin.JalviewLite"].jmolAvailable) { -System.out.println ("Jmol not available - Using MCview for structures"); -}} catch (ex) { -if (Clazz.exceptionOf (ex, ClassNotFoundException)) { -} else { -throw ex; -} -} -} else { -this.b$["jalview.bin.JalviewLite"].jmolAvailable = false; -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Skipping Jmol check. Will use MCView (probably)"); -}}this.b$["jalview.bin.JalviewLite"].checkedForJmol = true; -this.running = false; -}); -Clazz.defineMethod (c$, "notFinished", -function () { -return this.running || !this.b$["jalview.bin.JalviewLite"].checkedForJmol; -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$LoadingThread$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.protocol = null; -this._file = null; -this._file2 = null; -this.applet = null; -Clazz.instantialize (this, arguments); -}, jalview.bin.JalviewLite, "LoadingThread", Thread); -Clazz.defineMethod (c$, "dbgMsg", -($fz = function (a) { -if (jalview.bin.JalviewLite.debug) { -System.err.println (a); -}}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "setProtocolState", -function (a) { -if (a.startsWith ("PASTE")) { -a = a.substring (5); -this.protocol = jalview.io.AppletFormatAdapter.PASTE; -} else if (this.inArchive (a)) { -this.protocol = jalview.io.AppletFormatAdapter.CLASSLOADER; -} else { -a = this.addProtocol (a); -this.protocol = jalview.io.AppletFormatAdapter.URL; -}this.dbgMsg ("Protocol identified as '" + this.protocol + "'"); -return a; -}, "~S"); -Clazz.makeConstructor (c$, -function (a, b, c) { -Clazz.superConstructor (this, jalview.bin.JalviewLite.LoadingThread, []); -this._file = a; -this._file2 = b; -this.applet = c; -}, "~S,~S,jalview.bin.JalviewLite"); -Clazz.overrideMethod (c$, "run", -function () { -{ -System.out.println("BYPASSING JMOL LOADING FOR NOW. THIS WILL BE DONE ANOTHER WAY") -}this.startLoading (); -}); -Clazz.defineMethod (c$, "startLoading", -($fz = function () { -this.dbgMsg ("Loading thread started with:\n>>file\n" + this._file + ">>endfile"); -this.dbgMsg ("Loading started."); -var a = this.readAlignment (this._file); -var b = this.readAlignment (this._file2); -if (a != null) { -this.addToDisplay (a, b); -this.loadTree (a); -this.loadScoreFile (a); -this.loadFeatures (a); -this.loadAnnotations (a); -this.loadJnetFile (a); -this.loadPdbFiles (a); -} else { -this.b$["jalview.bin.JalviewLite"].fileFound = false; -this.applet.remove (this.b$["jalview.bin.JalviewLite"].launcher); -this.applet.repaint (); -}this.b$["jalview.bin.JalviewLite"].callInitCallback (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "addToDisplay", -function (a, b) { -if (b == null) { -a.addToDisplay (this.b$["jalview.bin.JalviewLite"].embedded); -} else { -var c = new jalview.appletgui.SplitFrame (a, b); -c.addToDisplay (this.b$["jalview.bin.JalviewLite"].embedded, this.b$["jalview.bin.JalviewLite"]); -}}, "jalview.appletgui.AlignFrame,jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "readAlignment", -function (a) { -if (a == null) { -return null; -}var b = this.setProtocolState (a); -var c = new jalview.io.IdentifyFile ().Identify (b, this.protocol); -this.dbgMsg ("File identified as '" + c + "'"); -var d = null; -try { -d = new jalview.io.AppletFormatAdapter ().readFile (b, this.protocol, c); -if ((d != null) && (d.getHeight () > 0)) { -this.dbgMsg ("Successfully loaded file."); -d.setDataset (null); -var e = new jalview.appletgui.AlignFrame (d, this.applet, b, this.b$["jalview.bin.JalviewLite"].embedded, false); -e.setTitle (b); -if (this.b$["jalview.bin.JalviewLite"].initialAlignFrame == null) { -this.b$["jalview.bin.JalviewLite"].initialAlignFrame = e; -}this.b$["jalview.bin.JalviewLite"].currentAlignFrame = e; -if (this.protocol === jalview.io.AppletFormatAdapter.PASTE) { -e.setTitle (jalview.util.MessageManager.formatMessage ("label.sequences_from", Clazz.newArray (-1, [this.applet.getDocumentBase ().toString ()]))); -}e.setStatus (jalview.util.MessageManager.formatMessage ("label.successfully_loaded_file", Clazz.newArray (-1, [b]))); -return e; -}} catch (ex) { -if (Clazz.exceptionOf (ex, java.io.IOException)) { -this.dbgMsg ("File load exception."); -ex.printStackTrace (); -if (jalview.bin.JalviewLite.debug) { -try { -var e = new jalview.io.FileParse (b, this.protocol); -var f = null; -this.dbgMsg (">>>Dumping contents of '" + b + "' " + "(" + this.protocol + ")"); -while ((f = e.nextLine ()) != null) { -this.dbgMsg (f); -} -this.dbgMsg (">>>Dump finished."); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Exception when trying to dump the content of the file parameter."); -e.printStackTrace (); -} else { -throw e; -} -} -}} else { -throw ex; -} -} -return null; -}, "~S"); -Clazz.defineMethod (c$, "loadPdbFiles", -function (a) { -var b = false; -this.applet.setAlignPdbStructures (this.b$["jalview.bin.JalviewLite"].getDefaultParameter ("alignpdbfiles", false)); -var c = 0; -var d = new java.util.Vector (); -var e = (this.applet.getDefaultParameter ("relaxedidmatch", false)) ? new jalview.analysis.SequenceIdMatcher (a.getAlignViewport ().getAlignment ().getSequencesArray ()) : null; -var f; -do { -if (c > 0) { -f = this.applet.getParameter ("PDBFILE" + c); -} else { -f = this.b$["jalview.bin.JalviewLite"].pdbFile; -}if (f != null) { -var g = new jalview.datamodel.PDBEntry (); -var h; -var i = null; -var j = null; -var k = new java.util.StringTokenizer (f, " "); -if (k.countTokens () < 2) { -if (this.b$["jalview.bin.JalviewLite"].sequence != null) { -i = Clazz.newArray (-1, [e == null ? a.getAlignViewport ().getAlignment ().findName (this.b$["jalview.bin.JalviewLite"].sequence) : e.findIdMatch (this.b$["jalview.bin.JalviewLite"].sequence)]); -}} else { -f = k.nextToken (); -var l = new java.util.Vector (); -var m = new java.util.Vector (); -while (k.hasMoreTokens ()) { -h = k.nextToken (); -var n = new java.util.StringTokenizer (h, "="); -if (n.countTokens () > 1) { -m.addElement (n.nextToken ()); -h = n.nextToken (); -}l.addElement (e == null ? a.getAlignViewport ().getAlignment ().findName (h) : e.findIdMatch (h)); -} -i = new Array (l.size ()); -l.copyInto (i); -if (m.size () == l.size ()) { -j = new Array (m.size ()); -m.copyInto (j); -}}f = this.setProtocolState (f); -if (this.protocol === jalview.io.AppletFormatAdapter.CLASSLOADER && !this.b$["jalview.bin.JalviewLite"].useXtrnalSviewer) { -this.protocol = jalview.io.AppletFormatAdapter.URL; -f = this.addProtocol (f); -}g.setFile (f); -if (i != null) { -for (var l = 0; l < i.length; l++) { -if (i[l] != null) { -(i[l]).addPDBId (g); -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.applet).registerPDBEntry (g); -} else { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Warning: Possible input parsing error: Null sequence for attachment of PDB (sequence " + l + ")"); -}}} -if (!this.b$["jalview.bin.JalviewLite"].alignPdbStructures) { -a.newStructureView (this.applet, g, i, j, this.protocol); -} else { -d.addElement ( Clazz.newArray (-1, [g, i, j, String.instantialize (this.protocol)])); -}}}c++; -} while (f != null || c < 10); -if (d.size () > 0) { -var g = new Array (d.size ()); -var h = new Array (d.size ()); -var i = new Array (d.size ()); -var j = new Array (d.size ()); -for (var k = 0, l = d.size (); k < l; k++) { -var m = d.elementAt (k); -h[k] = m[0]; -g[k] = m[1]; -i[k] = m[2]; -j[k] = m[3]; -} -a.alignedStructureView (this.applet, h, g, i, j); -b = true; -}return b; -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "loadJnetFile", -function (a) { -var b = false; -var c = this.b$["jalview.bin.JalviewLite"].jnetFile; -if (c != null) { -try { -c = this.setProtocolState (c); -var d = jalview.jsdev.GenericFileAdapter.getFile ("JPredFile", [c, this.protocol]); -jalview.io.JnetAnnotationMaker.add_annotation (d, a.viewport.getAlignment (), 0, false); -var e = a.viewport.getAlignment ().getSequenceAt (0); -a.viewport.getAlignment ().setSeqrep (e); -var f = new jalview.datamodel.ColumnSelection (); -f.hideInsertionsFor (e); -a.viewport.setColumnSelection (f); -a.alignPanel.fontChanged (); -a.alignPanel.setScrollValues (0, 0); -b = true; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}return b; -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "loadAnnotations", -function (a) { -var b = false; -var c = this.b$["jalview.bin.JalviewLite"].annotations; -if (c != null) { -c = this.setProtocolState (c); -if ( new jalview.io.AnnotationFile ().annotateAlignmentView (a.viewport, c, this.protocol)) { -a.alignPanel.fontChanged (); -a.alignPanel.setScrollValues (0, 0); -b = true; -} else { -System.err.println ("Annotations were not added from annotation file '" + c + "'"); -}}return b; -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "loadFeatures", -function (a) { -var b = false; -var c = this.b$["jalview.bin.JalviewLite"].hideFeatureGroups; -if (c != null) { -a.setFeatureGroupState (this.b$["jalview.bin.JalviewLite"].separatorListToArray (c), false); -}c = this.b$["jalview.bin.JalviewLite"].showFeatureGroups; -if (c != null) { -a.setFeatureGroupState (this.b$["jalview.bin.JalviewLite"].separatorListToArray (c), true); -}c = this.b$["jalview.bin.JalviewLite"].features; -if (c != null) { -c = this.setProtocolState (c); -b = a.parseFeaturesFile (c, this.protocol); -}c = this.b$["jalview.bin.JalviewLite"].showFeatureSettings; -if (c != null && c.equalsIgnoreCase ("true")) { -a.viewport.setShowSequenceFeatures (true); - new jalview.appletgui.FeatureSettings (a.alignPanel); -}return b; -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "loadScoreFile", -function (a) { -var b = false; -if (this.b$["jalview.bin.JalviewLite"].scoreFile != null && !"".equals (this.b$["jalview.bin.JalviewLite"].scoreFile)) { -try { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Attempting to load T-COFFEE score file from the scoreFile parameter"); -}b = a.loadScoreFile (this.b$["jalview.bin.JalviewLite"].scoreFile); -if (!b) { -System.err.println ("Failed to parse T-COFFEE parameter as a valid score file ('" + this.b$["jalview.bin.JalviewLite"].scoreFile + "')"); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.printf ("Cannot read score file: '%s'. Cause: %s \n", [this.b$["jalview.bin.JalviewLite"].scoreFile, e.getMessage ()]); -} else { -throw e; -} -} -}return b; -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "loadTree", -function (a) { -var b = false; -if (this.b$["jalview.bin.JalviewLite"].treeFile == null) { -this.b$["jalview.bin.JalviewLite"].treeFile = this.applet.getParameter ("treeFile"); -}if (this.b$["jalview.bin.JalviewLite"].treeFile != null) { -try { -this.b$["jalview.bin.JalviewLite"].treeFile = this.setProtocolState (this.b$["jalview.bin.JalviewLite"].treeFile); -var c = new jalview.io.NewickFile (this.b$["jalview.bin.JalviewLite"].treeFile, this.protocol); -c.parse (); -if (c.getTree () != null) { -a.loadTree (c, this.b$["jalview.bin.JalviewLite"].treeFile); -b = true; -this.dbgMsg ("Successfully imported tree."); -} else { -this.dbgMsg ("Tree parameter did not resolve to a valid tree."); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -}return b; -}, "jalview.appletgui.AlignFrame"); -Clazz.defineMethod (c$, "inArchive", -function (a) { -try { -var b = (this.getClass ().getResourceAsStream ("/" + a) != null); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Resource '" + a + "' was " + (b ? "" : "not") + " located by classloader."); -}return b; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.out.println ("Exception checking resources: " + a + " " + ex); -return false; -} else { -throw ex; -} -} -}, "~S"); -Clazz.defineMethod (c$, "addProtocol", -function (a) { -if (a.indexOf ("://") == -1) { -var b = this.applet.resolveUrlForLocalOrAbsolute (a, this.b$["jalview.bin.JalviewLite"].getDocumentBase ()); -if (this.urlExists (b)) { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Prepended document base for resource: '" + a + "'"); -}return b; -}b = this.applet.resolveUrlForLocalOrAbsolute (a, this.b$["jalview.bin.JalviewLite"].getCodeBase ()); -if (this.urlExists (b)) { -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Prepended codebase for resource: '" + a + "'"); -}return b; -}}return a; -}, "~S"); -Clazz.defineMethod (c$, "urlExists", -($fz = function (a) { -var b = null; -try { -b = new java.net.URL (a).openStream (); -if (b != null) { -return true; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} finally { -if (b != null) { -try { -b.close (); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -}} -return false; -}, $fz.isPrivate = true, $fz), "~S"); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$1", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.f$.me).mouseOverVamsasSequence (this.f$.sq, this.f$.sq.findIndex (this.f$.pos), null); -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$2", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.f$.me).mouseOverVamsasSequence (this.f$.sq, this.f$.pos, null); -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$3", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -this.f$.alf.select (this.f$.sel, this.f$.csel); -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$4$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$4", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -try { -jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.f$.me).mouseOverStructure ( new Integer (this.f$.pdbResNum).intValue (), this.f$.chain, this.f$.pdbfile); -if (jalview.bin.JalviewLite.debug) { -System.err.println ("mouseOver for '" + this.f$.pdbResNum + "' in chain '" + this.f$.chain + "' in structure '" + this.f$.pdbfile + "'"); -}} catch (e) { -if (Clazz.exceptionOf (e, NumberFormatException)) { -System.err.println ("Ignoring invalid residue number string '" + this.f$.pdbResNum + "'"); -} else { -throw e; -} -} -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$5$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$5", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -try { -this.f$.alf.scrollTo ( new Integer (this.f$.topRow).intValue (), new Integer (this.f$.leftHandColumn).intValue ()); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Couldn't parse integer arguments (topRow='" + this.f$.topRow + "' and leftHandColumn='" + this.f$.leftHandColumn + "')"); -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$6$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$6", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -try { -this.f$.alf.scrollToRow ( new Integer (this.f$.topRow).intValue ()); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Couldn't parse integer arguments (topRow='" + this.f$.topRow + "')"); -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$7$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$7", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -try { -this.f$.alf.scrollToColumn ( new Integer (this.f$.leftHandColumn).intValue ()); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Couldn't parse integer arguments (leftHandColumn='" + this.f$.leftHandColumn + "')"); -ex.printStackTrace (); -} else { -throw ex; -} -} -}); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$8$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$8", null, java.awt.event.ActionListener); -Clazz.overrideMethod (c$, "actionPerformed", -function (e) { -var loader = Clazz.innerTypeInstance (jalview.bin.JalviewLite.LoadingThread, this, null, this.b$["jalview.bin.JalviewLite"].startupFile, this.b$["jalview.bin.JalviewLite"].file2, this.b$["jalview.bin.JalviewLite"]); -loader.start (); -}, "java.awt.event.ActionEvent"); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$9$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$9", java.awt.event.WindowAdapter); -Clazz.overrideMethod (c$, "windowClosing", -function (e) { -if (Clazz.instanceOf (this.f$.frame, jalview.appletgui.AlignFrame)) { -var vp = (this.f$.frame).viewport; -(this.f$.frame).closeMenuItem_actionPerformed (); -if (vp.applet.currentAlignFrame === this.f$.frame) { -vp.applet.currentAlignFrame = null; -}vp.applet = null; -vp = null; -}jalview.bin.JalviewLite.lastFrameX -= 40; -jalview.bin.JalviewLite.lastFrameY -= 40; -if (Clazz.instanceOf (this.f$.frame, jalview.appletgui.EmbmenuFrame)) { -(this.f$.frame).destroyMenus (); -}this.f$.frame.setMenuBar (null); -this.f$.frame.dispose (); -}, "java.awt.event.WindowEvent"); -Clazz.defineMethod (c$, "windowActivated", -function (e) { -if (Clazz.instanceOf (this.f$.frame, jalview.appletgui.AlignFrame)) { -(this.f$.frame).viewport.applet.currentAlignFrame = this.f$.frame; -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Activated window " + this.f$.frame); -}}Clazz.superCall (this, jalview.bin.JalviewLite$9, "windowActivated", [e]); -}, "java.awt.event.WindowEvent"); -c$ = Clazz.p0p (); -}; -c$.$JalviewLite$10$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$10", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -this.f$.alf.setFeatureGroupState (this.b$["jalview.bin.JalviewLite"].separatorListToArray (this.f$.groups), this.f$.st); -}); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"TRUE", "true", -"FALSE", "false", -"debug", false, -"lastFrameX", 200, -"lastFrameY", 200, -"builddate", null, -"version", null, -"installation", null); -}); +Clazz.declarePackage ("jalview.bin"); +Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.javascript.JalviewLiteJsApi", "java.lang.Thread", "javax.swing.JApplet", "jalview.util.MessageManager", "java.util.Hashtable", "$.Vector", "javax.swing.JButton"], "jalview.bin.JalviewLite", ["jalview.analysis.SequenceIdMatcher", "jalview.appletgui.AlignFrame", "$.EmbmenuFrame", "$.FeatureSettings", "$.SplitFrame", "jalview.datamodel.Alignment", "$.AlignmentOrder", "$.ColumnSelection", "$.PDBEntry", "$.SequenceGroup", "jalview.io.AnnotationFile", "$.AppletFormatAdapter", "$.FileParse", "$.IdentifyFile", "$.JnetAnnotationMaker", "$.NewickFile", "jalview.javascript.JSFunctionExec", "$.JsSelectionSender", "$.MouseOverListener", "$.MouseOverStructureListener", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.UserColourScheme", "jalview.structure.SelectionListener", "$.StructureSelectionManager", "java.awt.Color", "$.EventQueue", "$.Font", "java.awt.event.ActionListener", "$.WindowAdapter", "java.io.BufferedReader", "$.InputStreamReader", "java.lang.Error", "$.StringBuffer", "java.net.URL", "java.util.StringTokenizer", "netscape.javascript.JSObject"], function () { +c$ = Clazz.decorateAsClass (function () { +this.embedded = false; +this.enableSplitFrame = false; +this.showButton = true; +this.checkForJmol = true; +this.jalviewServletURL = null; +this.startupFile = "No file"; +this.helpUrl = null; +this.externalstructureviewer = null; +this.sep = null; +this.rgb = null; +this.labelColour = null; +this.initjscallback = null; +this.pdbFile = null; +this.sequence = null; +this.jnetFile = null; +this.annotations = null; +this.hideFeatureGroups = null; +this.showFeatureGroups = null; +this.features = null; +this.showFeatureSettings = null; +this.scoreFile = null; +this.treeFile = null; +this.windowWidth = null; +this.windowHeight = null; +this.defaultColour = null; +this.sortBy = null; +this.wrap = null; +this.centrecolumnlabels = null; +this.userDefinedColour = null; +this.widthScale = null; +this.heightScale = null; +this.upperCase = null; +this.file2 = null; +this.javascriptListeners = null; +this.jsFunctionExec = null; +this.fileFound = true; +this.launcher = null; +this.currentAlignFrame = null; +this.initialAlignFrame = null; +this.checkedForJmol = false; +this.jmolAvailable = false; +this.alignPdbStructures = false; +this.useXtrnalSviewer = false; +this.haveShownLoadMessage = false; +if (!Clazz.isClassDefined ("jalview.bin.JalviewLite.LoadJmolThread")) { +jalview.bin.JalviewLite.$JalviewLite$LoadJmolThread$ (); +} +if (!Clazz.isClassDefined ("jalview.bin.JalviewLite.LoadingThread")) { +jalview.bin.JalviewLite.$JalviewLite$LoadingThread$ (); +} +this.separator = "\u00ac"; +this.jsfallbackEnabled = false; +this.jshashes = null; +this.jsmessages = null; +this.jsExecQueue = null; +Clazz.instantialize (this, arguments); +}, jalview.bin, "JalviewLite", javax.swing.JApplet, [jalview.api.StructureSelectionManagerProvider, jalview.javascript.JalviewLiteJsApi]); +Clazz.prepareFields (c$, function () { +this.javascriptListeners = new java.util.Vector (); +this.launcher = new javax.swing.JButton (jalview.util.MessageManager.getString ("label.start_jalview")); +this.jshashes = new java.util.Hashtable (); +this.jsmessages = new java.util.Hashtable (); +this.jsExecQueue = new java.util.Vector (); +}); +Clazz.defineMethod (c$, "setParams", +($fz = function () { +jalview.bin.JalviewLite.debug = "true".equalsIgnoreCase (this.getParameter ("debug")); +this.enableSplitFrame = "true".equalsIgnoreCase (this.getParameter ("enableSplitFrame")); +this.embedded = "true".equalsIgnoreCase (this.getParameter ("embedded")); +this.showButton = !"false".equalsIgnoreCase (this.getParameter ("showbutton")); +this.jalviewServletURL = this.getParameter ("APPLICATION_URL"); +this.startupFile = this.getParameter ("file"); +this.helpUrl = this.getParameter ("jalviewhelpurl"); +this.externalstructureviewer = this.getParameter ("externalstructureviewer"); +this.checkForJmol = !"true".equals (this.getParameter ("nojmol")); +this.sep = this.getParameter ("separator"); +this.rgb = this.getParameter ("RGB"); +this.labelColour = this.getParameter ("label"); +this.initjscallback = this.getParameter ("oninit"); +this.pdbFile = this.getParameter ("PDBFILE"); +this.sequence = this.getParameter ("PDBSEQ"); +this.jnetFile = this.getParameter ("jnetfile"); +this.annotations = this.getParameter ("annotations"); +this.hideFeatureGroups = this.getParameter ("hidefeaturegroups"); +this.showFeatureGroups = this.getParameter ("showfeaturegroups"); +this.features = this.getParameter ("features"); +this.showFeatureSettings = this.getParameter ("showFeatureSettings"); +this.scoreFile = this.getParameter ("scoreFile"); +this.treeFile = this.getParameter ("tree"); +if (this.treeFile == null) this.treeFile = this.getParameter ("treeFile"); +this.windowWidth = this.getParameter ("windowWidth"); +this.windowHeight = this.getParameter ("windowHeight"); +this.defaultColour = this.getParameter ("defaultColour"); +this.sortBy = this.getParameter ("sortBy"); +this.wrap = this.getParameter ("wrap"); +this.centrecolumnlabels = this.getParameter ("centrecolumnlabels"); +this.userDefinedColour = this.getParameter ("userDefinedColour"); +this.widthScale = this.getParameter ("widthScale"); +this.heightScale = this.getParameter ("heightScale"); +this.upperCase = this.getParameter ("upperCase"); +this.file2 = this.getParameter ("file2"); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getDefaultParameter", +function (name, def) { +var stn; +if ((stn = this.getParameter (name)) == null) { +return def; +}if (stn.toLowerCase ().equals ("true")) { +return true; +}return false; +}, "~S,~B"); +Clazz.defineMethod (c$, "getLinkParams", +function (links) { +var label; +var url; +for (var i = 1; i < 10; i++) { +label = this.getParameter ("linkLabel_" + i); +url = this.getParameter ("linkURL_" + i); +if (label != null && url != null) { +links.addElement (label + "|" + url); +}} +}, "java.util.Vector"); +Clazz.defineMethod (c$, "getStructureSelectionManager", +function () { +return jalview.structure.StructureSelectionManager.getStructureSelectionManager (this); +}); +Clazz.defineMethod (c$, "getSelectedSequences", +function () { +return this.getSelectedSequencesFrom (this.getDefaultTargetFrame ()); +}); +Clazz.defineMethod (c$, "getSelectedSequences", +function (sep) { +return this.getSelectedSequencesFrom (this.getDefaultTargetFrame (), sep); +}, "~S"); +Clazz.defineMethod (c$, "getSelectedSequencesFrom", +function (alf) { +return this.getSelectedSequencesFrom (alf, this.separator); +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "getSelectedSequencesFrom", +function (alf, sep) { +var result = new StringBuffer (""); +if (sep == null || sep.length == 0) { +sep = this.separator; +}if (alf.viewport.getSelectionGroup () != null) { +var seqs = alf.viewport.getSelectionGroup ().getSequencesInOrder (alf.viewport.getAlignment ()); +for (var i = 0; i < seqs.length; i++) { +result.append (seqs[i].getName ()); +result.append (sep); +} +}return result.toString (); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "highlight", +function (sequenceId, position, alignedPosition) { +this.highlightIn (this.getDefaultTargetFrame (), sequenceId, position, alignedPosition); +}, "~S,~S,~S"); +Clazz.overrideMethod (c$, "highlightIn", +function (alf, sequenceId, position, alignedPosition) { +var matcher = new jalview.analysis.SequenceIdMatcher (alf.viewport.getAlignment ().getSequencesArray ()); +var sq = matcher.findIdMatch (sequenceId); +if (sq != null) { +var apos = -1; +try { +apos = new Integer (position).intValue (); +apos--; +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +return; +} else { +throw ex; +} +} +var me = this; +var pos = apos; +if (alignedPosition != null && (alignedPosition.trim ().length == 0 || alignedPosition.toLowerCase ().indexOf ("false") > -1)) { +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$1") ? 0 : jalview.bin.JalviewLite.$JalviewLite$1$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$1, this, Clazz.cloneFinals ("me", me, "sq", sq, "pos", pos)))); +} else { +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$2") ? 0 : jalview.bin.JalviewLite.$JalviewLite$2$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$2, this, Clazz.cloneFinals ("me", me, "sq", sq, "pos", pos)))); +}}}, "jalview.appletgui.AlignFrame,~S,~S,~S"); +Clazz.defineMethod (c$, "select", +function (sequenceIds, columns) { +this.selectIn (this.getDefaultTargetFrame (), sequenceIds, columns, this.separator); +}, "~S,~S"); +Clazz.defineMethod (c$, "select", +function (sequenceIds, columns, sep) { +this.selectIn (this.getDefaultTargetFrame (), sequenceIds, columns, sep); +}, "~S,~S,~S"); +Clazz.defineMethod (c$, "selectIn", +function (alf, sequenceIds, columns) { +this.selectIn (alf, sequenceIds, columns, this.separator); +}, "jalview.appletgui.AlignFrame,~S,~S"); +Clazz.defineMethod (c$, "selectIn", +function (alf, sequenceIds, columns, sep) { +if (sep == null || sep.length == 0) { +sep = this.separator; +} else { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Selecting region using separator string '" + this.separator + "'"); +}}var ids = this.separatorListToArray (sequenceIds, sep); +var cols = this.separatorListToArray (columns, sep); +var sel = new jalview.datamodel.SequenceGroup (); +var csel = new jalview.datamodel.ColumnSelection (); +var al = alf.viewport.getAlignment (); +var matcher = new jalview.analysis.SequenceIdMatcher (alf.viewport.getAlignment ().getSequencesArray ()); +var start = 0; +var end = al.getWidth (); +var alw = al.getWidth (); +var seqsfound = true; +if (ids != null && ids.length > 0) { +seqsfound = false; +for (var i = 0; i < ids.length; i++) { +if (ids[i].trim ().length == 0) { +continue; +}var sq = matcher.findIdMatch (ids[i]); +if (sq != null) { +seqsfound = true; +sel.addSequence (sq, false); +}} +}var inseqpos = false; +if (cols != null && cols.length > 0) { +var seset = false; +for (var i = 0; i < cols.length; i++) { +var cl = cols[i].trim (); +if (cl.length == 0) { +continue; +}var p; +if ((p = cl.indexOf ("-")) > -1) { +var from = -1; +var to = -1; +try { +from = new Integer (cl.substring (0, p)).intValue (); +from--; +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +System.err.println ("ERROR: Couldn't parse first integer in range element column selection string '" + cl + "' - format is 'from-to'"); +return; +} else { +throw ex; +} +} +try { +to = new Integer (cl.substring (p + 1)).intValue (); +to--; +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +System.err.println ("ERROR: Couldn't parse second integer in range element column selection string '" + cl + "' - format is 'from-to'"); +return; +} else { +throw ex; +} +} +if (from >= 0 && to >= 0) { +if (from < to) { +var t = to; +to = from; +to = t; +}if (!seset) { +start = from; +end = to; +seset = true; +} else { +if (start > from) { +start = from; +}if (end < to) { +end = to; +}}for (var r = from; r <= to; r++) { +if (r >= 0 && r < alw) { +csel.addElement (r); +}} +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Range '" + cl + "' deparsed as [" + from + "," + to + "]"); +}} else { +System.err.println ("ERROR: Invalid Range '" + cl + "' deparsed as [" + from + "," + to + "]"); +}} else { +var r = -1; +try { +r = new Integer (cl).intValue (); +r--; +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +if (cl.toLowerCase ().equals ("sequence")) { +inseqpos = true; +} else { +System.err.println ("ERROR: Couldn't parse integer from point selection element of column selection string '" + cl + "'"); +return; +}} else { +throw ex; +} +} +if (r >= 0 && r <= alw) { +if (!seset) { +start = r; +end = r; +seset = true; +} else { +if (start > r) { +start = r; +}if (end < r) { +end = r; +}}csel.addElement (r); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Point selection '" + cl + "' deparsed as [" + r + "]"); +}} else { +System.err.println ("ERROR: Invalid Point selection '" + cl + "' deparsed as [" + r + "]"); +}}} +}if (seqsfound) { +if (inseqpos && sel.getSize () > 0) { +var rs = sel.getSequenceAt (0); +start = rs.findIndex (start); +end = rs.findIndex (end); +if (csel != null) { +var cs = csel.getSelected (); +csel.clear (); +for (var selectedCol, $selectedCol = cs.iterator (); $selectedCol.hasNext () && ((selectedCol = $selectedCol.next ()) || true);) { +csel.addElement (rs.findIndex ((selectedCol).intValue ())); +} +}}sel.setStartRes (start); +sel.setEndRes (end); +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$3") ? 0 : jalview.bin.JalviewLite.$JalviewLite$3$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$3, this, Clazz.cloneFinals ("alf", alf, "sel", sel, "csel", csel)))); +}}, "jalview.appletgui.AlignFrame,~S,~S,~S"); +Clazz.overrideMethod (c$, "getSelectedSequencesAsAlignment", +function (format, suffix) { +return this.getSelectedSequencesAsAlignmentFrom (this.getDefaultTargetFrame (), format, suffix); +}, "~S,~S"); +Clazz.overrideMethod (c$, "getSelectedSequencesAsAlignmentFrom", +function (alf, format, suffix) { +try { +var seqlimits = suffix.equalsIgnoreCase ("true"); +if (alf.viewport.getSelectionGroup () != null) { +var reply = new jalview.io.AppletFormatAdapter ().formatSequences (format, new jalview.datamodel.Alignment (alf.viewport.getSelectionAsNewSequence ()), seqlimits); +return reply; +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +return "Error retrieving alignment in " + format + " format. "; +} else { +throw ex; +} +} +return ""; +}, "jalview.appletgui.AlignFrame,~S,~S"); +Clazz.overrideMethod (c$, "getAlignmentOrder", +function () { +return this.getAlignmentOrderFrom (this.getDefaultTargetFrame ()); +}); +Clazz.defineMethod (c$, "getAlignmentOrderFrom", +function (alf) { +return this.getAlignmentOrderFrom (alf, this.separator); +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "getAlignmentOrderFrom", +function (alf, sep) { +var alorder = alf.getAlignViewport ().getAlignment (); +var order = new Array (alorder.getHeight ()); +for (var i = 0; i < order.length; i++) { +order[i] = alorder.getSequenceAt (i).getName (); +} +return this.arrayToSeparatorList (order); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.defineMethod (c$, "orderBy", +function (order, undoName) { +return this.orderBy (order, undoName, this.separator); +}, "~S,~S"); +Clazz.defineMethod (c$, "orderBy", +function (order, undoName, sep) { +return this.orderAlignmentBy (this.getDefaultTargetFrame (), order, undoName, sep); +}, "~S,~S,~S"); +Clazz.overrideMethod (c$, "orderAlignmentBy", +function (alf, order, undoName, sep) { +var ids = this.separatorListToArray (order, sep); +var sqs = null; +if (ids != null && ids.length > 0) { +var matcher = new jalview.analysis.SequenceIdMatcher (alf.viewport.getAlignment ().getSequencesArray ()); +var s = 0; +sqs = new Array (ids.length); +for (var i = 0; i < ids.length; i++) { +if (ids[i].trim ().length == 0) { +continue; +}var sq = matcher.findIdMatch (ids[i]); +if (sq != null) { +sqs[s++] = sq; +}} +if (s > 0) { +var sqq = new Array (s); +System.arraycopy (sqs, 0, sqq, 0, s); +sqs = sqq; +} else { +sqs = null; +}}if (sqs == null) { +return ""; +};var aorder = new jalview.datamodel.AlignmentOrder (sqs); +if (undoName != null && undoName.trim ().length == 0) { +undoName = null; +}var _undoName = undoName; +return alf.sortBy (aorder, _undoName) ? "true" : ""; +}, "jalview.appletgui.AlignFrame,~S,~S,~S"); +Clazz.defineMethod (c$, "getAlignment", +function (format) { +return this.getAlignmentFrom (this.getDefaultTargetFrame (), format, "true"); +}, "~S"); +Clazz.defineMethod (c$, "getAlignmentFrom", +function (alf, format) { +return this.getAlignmentFrom (alf, format, "true"); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.defineMethod (c$, "getAlignment", +function (format, suffix) { +return this.getAlignmentFrom (this.getDefaultTargetFrame (), format, suffix); +}, "~S,~S"); +Clazz.defineMethod (c$, "getAlignmentFrom", +function (alf, format, suffix) { +try { +var seqlimits = suffix.equalsIgnoreCase ("true"); +var reply = new jalview.io.AppletFormatAdapter ().formatSequences (format, alf.viewport.getAlignment (), seqlimits); +return reply; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +return "Error retrieving alignment in " + format + " format. "; +} else { +throw ex; +} +} +}, "jalview.appletgui.AlignFrame,~S,~S"); +Clazz.overrideMethod (c$, "loadAnnotation", +function (annotation) { +this.loadAnnotationFrom (this.getDefaultTargetFrame (), annotation); +}, "~S"); +Clazz.overrideMethod (c$, "loadAnnotationFrom", +function (alf, annotation) { +if ( new jalview.io.AnnotationFile ().annotateAlignmentView (alf.getAlignViewport (), annotation, jalview.io.AppletFormatAdapter.PASTE)) { +alf.alignPanel.fontChanged (); +alf.alignPanel.setScrollValues (0, 0); +} else { +alf.parseFeaturesFile (annotation, jalview.io.AppletFormatAdapter.PASTE); +}}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "loadFeatures", +function (features, autoenabledisplay) { +this.loadFeaturesFrom (this.getDefaultTargetFrame (), features, autoenabledisplay); +}, "~S,~B"); +Clazz.overrideMethod (c$, "loadFeaturesFrom", +function (alf, features, autoenabledisplay) { +return alf.parseFeaturesFile (features, jalview.io.AppletFormatAdapter.PASTE, autoenabledisplay); +}, "jalview.appletgui.AlignFrame,~S,~B"); +Clazz.overrideMethod (c$, "getFeatures", +function (format) { +return this.getFeaturesFrom (this.getDefaultTargetFrame (), format); +}, "~S"); +Clazz.overrideMethod (c$, "getFeaturesFrom", +function (alf, format) { +return alf.outputFeatures (false, format); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "getAnnotation", +function () { +return this.getAnnotationFrom (this.getDefaultTargetFrame ()); +}); +Clazz.overrideMethod (c$, "getAnnotationFrom", +function (alf) { +return alf.outputAnnotations (false); +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "newView", +function () { +return this.newViewFrom (this.getDefaultTargetFrame ()); +}); +Clazz.defineMethod (c$, "newView", +function (name) { +return this.newViewFrom (this.getDefaultTargetFrame (), name); +}, "~S"); +Clazz.defineMethod (c$, "newViewFrom", +function (alf) { +return alf.newView (null); +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "newViewFrom", +function (alf, name) { +return alf.newView (name); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "loadAlignment", +function (text, title) { +var al = null; +var format = new jalview.io.IdentifyFile ().Identify (text, jalview.io.AppletFormatAdapter.PASTE); +try { +al = new jalview.io.AppletFormatAdapter ().readFile (text, jalview.io.AppletFormatAdapter.PASTE, format); +if (al.getHeight () > 0) { +return new jalview.appletgui.AlignFrame (al, this, title, false); +}} catch (ex) { +if (Clazz.exceptionOf (ex, java.io.IOException)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +return null; +}, "~S,~S"); +Clazz.defineMethod (c$, "setMouseoverListener", +function (listener) { +this.setMouseoverListener (this.currentAlignFrame, listener); +}, "~S"); +Clazz.defineMethod (c$, "setMouseoverListener", +function (af, listener) { +if (listener != null) { +listener = listener.trim (); +if (listener.length == 0) { +System.err.println ("jalview Javascript error: Ignoring empty function for mouseover listener."); +return; +}}var mol = new jalview.javascript.MouseOverListener (this, af, listener); +this.javascriptListeners.addElement (mol); +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).addStructureViewerListener (mol); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Added a mouseover listener for " + ((af == null) ? "All frames" : "Just views for " + af.getAlignViewport ().getSequenceSetId ())); +System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); +}}, "jalview.appletgui.AlignFrame,~S"); +Clazz.defineMethod (c$, "setSelectionListener", +function (listener) { +this.setSelectionListener (null, listener); +}, "~S"); +Clazz.defineMethod (c$, "setSelectionListener", +function (af, listener) { +if (listener != null) { +listener = listener.trim (); +if (listener.length == 0) { +System.err.println ("jalview Javascript error: Ignoring empty function for selection listener."); +return; +}}var mol = new jalview.javascript.JsSelectionSender (this, af, listener); +this.javascriptListeners.addElement (mol); +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).addSelectionListener (mol); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Added a selection listener for " + ((af == null) ? "All frames" : "Just views for " + af.getAlignViewport ().getSequenceSetId ())); +System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); +}}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "setStructureListener", +function (listener, modelSet) { +if (listener != null) { +listener = listener.trim (); +if (listener.length == 0) { +System.err.println ("jalview Javascript error: Ignoring empty function for selection listener."); +return; +}}var mol = new jalview.javascript.MouseOverStructureListener (this, listener, this.separatorListToArray (modelSet)); +this.javascriptListeners.addElement (mol); +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).addStructureViewerListener (mol); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Added a javascript structure viewer listener '" + listener + "'"); +System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); +}}, "~S,~S"); +Clazz.overrideMethod (c$, "removeJavascriptListener", +function (af, listener) { +if (listener != null) { +listener = listener.trim (); +if (listener.length == 0) { +listener = null; +}}var rprt = false; +for (var ms = 0, msSize = this.javascriptListeners.size (); ms < msSize; ) { +var lstn = this.javascriptListeners.elementAt (ms); +var lstner = lstn; +if ((af == null || lstner.getAlignFrame () === af) && (listener == null || lstner.getListenerFunction ().equals (listener))) { +this.javascriptListeners.removeElement (lstner); +msSize--; +if (Clazz.instanceOf (lstner, jalview.structure.SelectionListener)) { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeSelectionListener (lstner); +} else { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeStructureViewerListener (lstner, null); +}rprt = jalview.bin.JalviewLite.debug; +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Removed listener '" + listener + "'"); +}} else { +ms++; +}} +if (rprt) { +System.err.println ("There are now " + this.javascriptListeners.size () + " listeners in total."); +}}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "stop", +function () { +System.err.println ("Applet " + this.getName () + " stop()."); +this.tidyUp (); +}); +Clazz.overrideMethod (c$, "destroy", +function () { +System.err.println ("Applet " + this.getName () + " destroy()."); +this.tidyUp (); +}); +Clazz.defineMethod (c$, "tidyUp", +($fz = function () { +this.removeAll (); +if (this.currentAlignFrame != null && this.currentAlignFrame.viewport != null && this.currentAlignFrame.viewport.applet != null) { +var av = this.currentAlignFrame.viewport; +this.currentAlignFrame.closeMenuItem_actionPerformed (); +av.applet = null; +this.currentAlignFrame = null; +}if (this.javascriptListeners != null) { +while (this.javascriptListeners.size () > 0) { +var mol = this.javascriptListeners.elementAt (0); +this.javascriptListeners.removeElement (mol); +if (Clazz.instanceOf (mol, jalview.structure.SelectionListener)) { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeSelectionListener (mol); +} else { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this).removeStructureViewerListener (mol, null); +}mol.jvlite = null; +} +}if (this.jsFunctionExec != null) { +this.jsFunctionExec.stopQueue (); +this.jsFunctionExec.jvlite = null; +}this.initialAlignFrame = null; +this.jsFunctionExec = null; +this.javascriptListeners = null; +jalview.structure.StructureSelectionManager.release (this); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "mouseOverStructure", +function (pdbResNum, chain, pdbfile) { +var me = this; +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$4") ? 0 : jalview.bin.JalviewLite.$JalviewLite$4$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$4, this, Clazz.cloneFinals ("me", me, "pdbResNum", pdbResNum, "chain", chain, "pdbfile", pdbfile)))); +}, "~S,~S,~S"); +Clazz.overrideMethod (c$, "scrollViewToIn", +function (alf, topRow, leftHandColumn) { +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$5") ? 0 : jalview.bin.JalviewLite.$JalviewLite$5$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$5, this, Clazz.cloneFinals ("alf", alf, "topRow", topRow, "leftHandColumn", leftHandColumn)))); +}, "jalview.appletgui.AlignFrame,~S,~S"); +Clazz.overrideMethod (c$, "scrollViewToRowIn", +function (alf, topRow) { +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$6") ? 0 : jalview.bin.JalviewLite.$JalviewLite$6$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$6, this, Clazz.cloneFinals ("alf", alf, "topRow", topRow)))); +}, "jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "scrollViewToColumnIn", +function (alf, leftHandColumn) { +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$7") ? 0 : jalview.bin.JalviewLite.$JalviewLite$7$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$7, this, Clazz.cloneFinals ("alf", alf, "leftHandColumn", leftHandColumn)))); +}, "jalview.appletgui.AlignFrame,~S"); +c$.initBuildDetails = Clazz.defineMethod (c$, "initBuildDetails", +($fz = function () { +if (jalview.bin.JalviewLite.builddate == null) { +jalview.bin.JalviewLite.builddate = "unknown"; +jalview.bin.JalviewLite.version = "test"; +jalview.bin.JalviewLite.installation = "Webstart"; +var url = jalview.bin.JalviewLite.getResource ("/.build_properties"); +if (url != null) { +try { +var reader = new java.io.BufferedReader ( new java.io.InputStreamReader (url.openStream ())); +var line; +while ((line = reader.readLine ()) != null) { +if (line.indexOf ("VERSION") > -1) { +jalview.bin.JalviewLite.version = line.substring (line.indexOf ("=") + 1); +}if (line.indexOf ("BUILD_DATE") > -1) { +jalview.bin.JalviewLite.builddate = line.substring (line.indexOf ("=") + 1); +}if (line.indexOf ("INSTALLATION") > -1) { +jalview.bin.JalviewLite.installation = line.substring (line.indexOf ("=") + 1); +}} +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}}}, $fz.isPrivate = true, $fz)); +c$.getBuildDate = Clazz.defineMethod (c$, "getBuildDate", +function () { +jalview.bin.JalviewLite.initBuildDetails (); +return jalview.bin.JalviewLite.builddate; +}); +c$.getInstallation = Clazz.defineMethod (c$, "getInstallation", +function () { +jalview.bin.JalviewLite.initBuildDetails (); +return jalview.bin.JalviewLite.installation; +}); +c$.getVersion = Clazz.defineMethod (c$, "getVersion", +function () { +jalview.bin.JalviewLite.initBuildDetails (); +return jalview.bin.JalviewLite.version; +}); +Clazz.overrideMethod (c$, "init", +function () { +this.setParams (); +try { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Applet context is '" + this.getAppletContext ().getClass ().toString () + "'"); +}var scriptObject = netscape.javascript.JSObject.getWindow (this); +if (jalview.bin.JalviewLite.debug && scriptObject != null) { +System.err.println ("Applet has Javascript callback support."); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Warning: No JalviewLite javascript callbacks available."); +if (jalview.bin.JalviewLite.debug) { +ex.printStackTrace (); +}} else { +throw ex; +} +} +if (jalview.bin.JalviewLite.debug) { +System.err.println ("JalviewLite Version " + jalview.bin.JalviewLite.getVersion ()); +System.err.println ("Build Date : " + jalview.bin.JalviewLite.getBuildDate ()); +System.err.println ("Installation : " + jalview.bin.JalviewLite.getInstallation ()); +}if (this.externalstructureviewer != null) { +this.useXtrnalSviewer = this.externalstructureviewer.trim ().toLowerCase ().equals ("true"); +}if (this.sep != null) { +if (this.sep.length > 0) { +this.separator = this.sep; +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Separator set to '" + this.separator + "'"); +}} else { +throw new Error (jalview.util.MessageManager.getString ("error.invalid_separator_parameter")); +}}var r = 255; +var g = 255; +var b = 255; +if (this.rgb != null) { +try { +r = Integer.parseInt (this.rgb.substring (0, 2), 16); +g = Integer.parseInt (this.rgb.substring (2, 4), 16); +b = Integer.parseInt (this.rgb.substring (4, 6), 16); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +r = 255; +g = 255; +b = 255; +} else { +throw ex; +} +} +}this.rgb = this.labelColour; +if (this.rgb != null) { +this.launcher.setLabel (this.rgb); +}this.setBackground ( new java.awt.Color (r, g, b)); +if (this.startupFile == null) { +var data = new StringBuffer ("PASTE"); +var i = 1; +while ((this.startupFile = this.getParameter ("sequence" + i)) != null) { +data.append (this.startupFile.toString () + "\n"); +i++; +} +if (data.length () > 5) { +this.startupFile = data.toString (); +}}if (!this.enableSplitFrame) { +this.file2 = null; +}if (this.embedded) { +var loader = Clazz.innerTypeInstance (jalview.bin.JalviewLite.LoadingThread, this, null, this.startupFile, this.file2, this); +{ +loader.run(); +}} else if (this.startupFile != null) { +if (!this.showButton) { +var loader = Clazz.innerTypeInstance (jalview.bin.JalviewLite.LoadingThread, this, null, this.startupFile, this.file2, this); +loader.start (); +} else { +this.add (this.launcher); +this.launcher.addActionListener (((Clazz.isClassDefined ("jalview.bin.JalviewLite$8") ? 0 : jalview.bin.JalviewLite.$JalviewLite$8$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$8, this, null))); +}} else { +this.startupFile = "NO FILE"; +this.fileFound = false; +this.callInitCallback (); +}}); +Clazz.defineMethod (c$, "initLiveConnect", +($fz = function () { +var notFailed = false; +var tries = 0; +while (!notFailed && tries < 10) { +if (tries > 0) { +System.err.println ("LiveConnect request thread going to sleep."); +}try { +Thread.sleep (700 * (1 + tries)); +} catch (q) { +if (Clazz.exceptionOf (q, InterruptedException)) { +} else { +throw q; +} +} +;if (tries++ > 0) { +System.err.println ("LiveConnect request thread woken up."); +}try { +var scriptObject = netscape.javascript.JSObject.getWindow (this); +if (scriptObject.eval ("navigator") != null) { +notFailed = true; +}} catch (jsex) { +if (Clazz.exceptionOf (jsex, Exception)) { +System.err.println ("Attempt " + tries + " to access LiveConnect javascript failed."); +} else { +throw jsex; +} +} +} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "callInitCallback", +($fz = function () { +if (this.initjscallback == null) { +return; +}this.initjscallback = this.initjscallback.trim (); +if (this.initjscallback.length > 0) { +var scriptObject = null; +try { +scriptObject = netscape.javascript.JSObject.getWindow (this); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +;this.initLiveConnect (); +if (scriptObject != null) { +try { + new jalview.javascript.JSFunctionExec (this).executeJavascriptFunction (true, this.initjscallback, null, "Calling oninit callback '" + this.initjscallback + "'."); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Exception when executing _oninit callback '" + this.initjscallback + "'."); +e.printStackTrace (); +} else { +throw e; +} +} +} else { +System.err.println ("Not executing _oninit callback '" + this.initjscallback + "' - no scripting allowed."); +}}}, $fz.isPrivate = true, $fz)); +c$.addFrame = Clazz.defineMethod (c$, "addFrame", +function (frame, title, width, height) { +frame.setLocation (jalview.bin.JalviewLite.lastFrameX, jalview.bin.JalviewLite.lastFrameY); +jalview.bin.JalviewLite.lastFrameX += 40; +jalview.bin.JalviewLite.lastFrameY += 40; +frame.setSize (width, height); +frame.setTitle (title); +frame.addWindowListener (((Clazz.isClassDefined ("jalview.bin.JalviewLite$9") ? 0 : jalview.bin.JalviewLite.$JalviewLite$9$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$9, this, Clazz.cloneFinals ("frame", frame)))); +frame.setVisible (true); +}, "javax.swing.JFrame,~S,~N,~N"); +Clazz.defineMethod (c$, "paintComponent", +function (g) { +if (!this.fileFound) { +g.setColor ( new java.awt.Color (200, 200, 200)); +g.setColor (java.awt.Color.cyan); +g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +g.setColor (java.awt.Color.red); +g.drawString (jalview.util.MessageManager.getString ("label.jalview_cannot_open_file"), 5, 15); +g.drawString ("\"" + this.startupFile + "\"", 5, 30); +} else if (this.embedded && !this.haveShownLoadMessage) { +g.setColor (java.awt.Color.black); +g.setFont ( new java.awt.Font ("Arial", 1, 24)); +g.drawString (jalview.util.MessageManager.getString ("label.jalview_applet"), 50, Clazz.doubleToInt (this.getSize ().height / 2) - 30); +g.drawString (jalview.util.MessageManager.getString ("label.loading_data") + "...", 50, Clazz.doubleToInt (this.getSize ().height / 2)); +this.haveShownLoadMessage = true; +}}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "getAppletWindow", +function (class1) { +var wnds = new java.util.Vector (); +var cmp = this.getComponents (); +if (cmp != null) { +for (var i = 0; i < cmp.length; i++) { +if (class1.isAssignableFrom (cmp[i].getClass ())) { +wnds.addElement (cmp); +}} +}return wnds; +}, "Class"); +Clazz.defineMethod (c$, "getDefaultTargetFrame", +function () { +if (this.currentAlignFrame != null) { +return this.currentAlignFrame; +}if (this.initialAlignFrame != null) { +return this.initialAlignFrame; +}System.err.println ("Implementation error: Jalview Applet API cannot work out which AlignFrame to use."); +return null; +}); +Clazz.defineMethod (c$, "separatorListToArray", +function (list) { +return this.separatorListToArray (list, this.separator); +}, "~S"); +Clazz.defineMethod (c$, "separatorListToArray", +function (list, separator) { +var seplen = separator.length; +if (list == null || list.equals ("") || list.equals (separator)) { +return null; +}var jv = new java.util.Vector (); +var cp = 0; +var pos; +while ((pos = list.indexOf (separator, cp)) > cp) { +jv.addElement (list.substring (cp, pos)); +cp = pos + seplen; +} +if (cp < list.length) { +var c = list.substring (cp); +if (!c.equals (separator)) { +jv.addElement (c); +}}if (jv.size () > 0) { +var v = new Array (jv.size ()); +for (var i = 0; i < v.length; i++) { +v[i] = jv.elementAt (i); +} +jv.removeAllElements (); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Array from '" + separator + "' separated List:\n" + v.length); +for (var i = 0; i < v.length; i++) { +System.err.println ("item " + i + " '" + v[i] + "'"); +} +}return v; +}if (jalview.bin.JalviewLite.debug) { +System.err.println ("Empty Array from '" + separator + "' separated List"); +}return null; +}, "~S,~S"); +Clazz.defineMethod (c$, "arrayToSeparatorList", +function (list) { +return this.arrayToSeparatorList (list, this.separator); +}, "~A"); +Clazz.defineMethod (c$, "arrayToSeparatorList", +function (list, separator) { +var v = new StringBuffer (); +if (list != null && list.length > 0) { +for (var i = 0, iSize = list.length; i < iSize; i++) { +if (list[i] != null) { +if (i > 0) { +v.append (separator); +}v.append (list[i]); +}} +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Returning '" + separator + "' separated List:\n"); +System.err.println (v); +}return v.toString (); +}if (jalview.bin.JalviewLite.debug) { +System.err.println ("Returning empty '" + separator + "' separated List\n"); +}return "" + separator; +}, "~A,~S"); +Clazz.overrideMethod (c$, "getFeatureGroups", +function () { +var lst = this.arrayToSeparatorList (this.getDefaultTargetFrame ().getFeatureGroups ()); +return lst; +}); +Clazz.overrideMethod (c$, "getFeatureGroupsOn", +function (alf) { +var lst = this.arrayToSeparatorList (alf.getFeatureGroups ()); +return lst; +}, "jalview.appletgui.AlignFrame"); +Clazz.overrideMethod (c$, "getFeatureGroupsOfState", +function (visible) { +return this.arrayToSeparatorList (this.getDefaultTargetFrame ().getFeatureGroupsOfState (visible)); +}, "~B"); +Clazz.overrideMethod (c$, "getFeatureGroupsOfStateOn", +function (alf, visible) { +return this.arrayToSeparatorList (alf.getFeatureGroupsOfState (visible)); +}, "jalview.appletgui.AlignFrame,~B"); +Clazz.overrideMethod (c$, "setFeatureGroupStateOn", +function (alf, groups, state) { +var st = state; +java.awt.EventQueue.invokeLater (((Clazz.isClassDefined ("jalview.bin.JalviewLite$10") ? 0 : jalview.bin.JalviewLite.$JalviewLite$10$ ()), Clazz.innerTypeInstance (jalview.bin.JalviewLite$10, this, Clazz.cloneFinals ("alf", alf, "groups", groups, "st", st)))); +}, "jalview.appletgui.AlignFrame,~S,~B"); +Clazz.overrideMethod (c$, "setFeatureGroupState", +function (groups, state) { +this.setFeatureGroupStateOn (this.getDefaultTargetFrame (), groups, state); +}, "~S,~B"); +Clazz.overrideMethod (c$, "getSeparator", +function () { +return this.separator; +}); +Clazz.overrideMethod (c$, "setSeparator", +function (separator) { +if (separator == null || separator.length < 1) { +separator = "\u00ac"; +}this.separator = separator; +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Default Separator now: '" + separator + "'"); +}}, "~S"); +Clazz.overrideMethod (c$, "addPdbFile", +function (alFrame, sequenceId, pdbEntryString, pdbFile) { +return alFrame.addPdbFile (sequenceId, pdbEntryString, pdbFile); +}, "jalview.appletgui.AlignFrame,~S,~S,~S"); +Clazz.defineMethod (c$, "setAlignPdbStructures", +function (alignPdbStructures) { +this.alignPdbStructures = alignPdbStructures; +}, "~B"); +Clazz.defineMethod (c$, "isAlignPdbStructures", +function () { +return this.alignPdbStructures; +}); +Clazz.overrideMethod (c$, "start", +function () { +}); +Clazz.defineMethod (c$, "setJsMessageSet", +function (messageclass, viewId, colcommands) { +var msgset = this.jsmessages.get (messageclass); +if (msgset == null) { +msgset = new java.util.Hashtable (); +this.jsmessages.put (messageclass, msgset); +}msgset.put (viewId, colcommands); +var l = Clazz.newLongArray (colcommands.length, 0); +for (var i = 0; i < colcommands.length; i++) { +l[i] = colcommands[i].hashCode (); +} +this.jshashes.put (messageclass + "|" + viewId, l); +}, "~S,~S,~A"); +Clazz.overrideMethod (c$, "getJsMessage", +function (messageclass, viewId) { +var msgset = this.jsmessages.get (messageclass); +if (msgset != null) { +var msgs = msgset.get (viewId); +if (msgs != null) { +for (var i = 0; i < msgs.length; i++) { +if (msgs[i] != null) { +var m = msgs[i]; +msgs[i] = null; +return m; +}} +}}return ""; +}, "~S,~S"); +Clazz.defineMethod (c$, "isJsMessageSetChanged", +function (string, string2, colcommands) { +var l = this.jshashes.get (string + "|" + string2); +if (l == null && colcommands != null) { +return true; +}for (var i = 0; i < colcommands.length; i++) { +if (l[i] != colcommands[i].hashCode ()) { +return true; +}} +return false; +}, "~S,~S,~A"); +Clazz.defineMethod (c$, "getJsExecQueue", +function () { +return this.jsExecQueue; +}); +Clazz.defineMethod (c$, "setExecutor", +function (jsFunctionExec2) { +this.jsFunctionExec = jsFunctionExec2; +}, "jalview.javascript.JSFunctionExec"); +Clazz.defineMethod (c$, "getDefaultColourParameter", +function (colparam, defcolour) { +var colprop = this.getParameter (colparam); +if (colprop == null || colprop.trim ().length == 0) { +return defcolour; +}var col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName (colprop); +if (col == null) { +try { +col = new jalview.schemes.UserColourScheme (colprop).findColour ('A'); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Couldn't parse '" + colprop + "' as a colour for " + colparam); +col = null; +} else { +throw ex; +} +} +}return (col == null) ? defcolour : col; +}, "~S,java.awt.Color"); +Clazz.defineMethod (c$, "openJalviewHelpUrl", +function () { +if (this.helpUrl == null || this.helpUrl.trim ().length < 5) { +this.helpUrl = "http://www.jalview.org/help.html"; +}this.showURL (this.helpUrl, "HELP"); +}); +Clazz.defineMethod (c$, "resolveUrlForLocalOrAbsolute", +($fz = function (url, localref) { +var codebase = localref.toString (); +var pt = codebase.indexOf ("?"); +if (pt < 0) pt = codebase.length; +codebase = codebase.substring (0, pt); +codebase = codebase.substring (0, codebase.lastIndexOf ("/") + 1); +if (url.indexOf ("/") == 0 && !localref.getProtocol ().equals ("file")) { +pt = codebase.indexOf ("/", 8); +return codebase.substring (0, pt) + url; +}return codebase + url; +}, $fz.isPrivate = true, $fz), "~S,java.net.URL"); +Clazz.defineMethod (c$, "showURL", +function (url, target) { +try { +if (url.indexOf (":") == -1) { +var prepend; +url = this.resolveUrlForLocalOrAbsolute (url, prepend = this.getDefaultParameter ("resolvetocodebase", false) ? this.getDocumentBase () : this.getCodeBase ()); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Show url (prepended " + prepend + " - toggle resolvetocodebase if code/docbase resolution is wrong): " + url); +}} else { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Show url: " + url); +}}if (url.indexOf ("javascript:") == 0) { +this.getAppletContext ().showDocument ( new java.net.URL (url)); +} else { +this.getAppletContext ().showDocument ( new java.net.URL (url), target); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}, "~S,~S"); +c$.$JalviewLite$LoadJmolThread$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.running = false; +Clazz.instantialize (this, arguments); +}, jalview.bin.JalviewLite, "LoadJmolThread", Thread); +Clazz.overrideMethod (c$, "run", +function () { +if (this.running || this.b$["jalview.bin.JalviewLite"].checkedForJmol) { +return; +}this.running = true; +if (this.b$["jalview.bin.JalviewLite"].checkForJmol) { +try { +if (!System.getProperty ("java.version").startsWith ("1.1")) { +Class.forName ("org.jmol.adapter.smarter.SmarterJmolAdapter"); +this.b$["jalview.bin.JalviewLite"].jmolAvailable = true; +}if (!this.b$["jalview.bin.JalviewLite"].jmolAvailable) { +System.out.println ("Jmol not available - Using MCview for structures"); +}} catch (ex) { +if (Clazz.exceptionOf (ex, ClassNotFoundException)) { +} else { +throw ex; +} +} +} else { +this.b$["jalview.bin.JalviewLite"].jmolAvailable = false; +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Skipping Jmol check. Will use MCView (probably)"); +}}this.b$["jalview.bin.JalviewLite"].checkedForJmol = true; +this.running = false; +}); +Clazz.defineMethod (c$, "notFinished", +function () { +return this.running || !this.b$["jalview.bin.JalviewLite"].checkedForJmol; +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$LoadingThread$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.protocol = null; +this._file = null; +this._file2 = null; +this.applet = null; +Clazz.instantialize (this, arguments); +}, jalview.bin.JalviewLite, "LoadingThread", Thread); +Clazz.defineMethod (c$, "dbgMsg", +($fz = function (a) { +if (jalview.bin.JalviewLite.debug) { +System.err.println (a); +}}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "setProtocolState", +function (a) { +if (a.startsWith ("PASTE")) { +a = a.substring (5); +this.protocol = jalview.io.AppletFormatAdapter.PASTE; +} else if (this.inArchive (a)) { +this.protocol = jalview.io.AppletFormatAdapter.CLASSLOADER; +} else { +a = this.addProtocol (a); +this.protocol = jalview.io.AppletFormatAdapter.URL; +}this.dbgMsg ("Protocol identified as '" + this.protocol + "'"); +return a; +}, "~S"); +Clazz.makeConstructor (c$, +function (a, b, c) { +Clazz.superConstructor (this, jalview.bin.JalviewLite.LoadingThread, []); +this._file = a; +this._file2 = b; +this.applet = c; +}, "~S,~S,jalview.bin.JalviewLite"); +Clazz.overrideMethod (c$, "run", +function () { +{ +System.out.println("BYPASSING JMOL LOADING FOR NOW. THIS WILL BE DONE ANOTHER WAY") +}this.startLoading (); +}); +Clazz.defineMethod (c$, "startLoading", +($fz = function () { +this.dbgMsg ("Loading thread started with:\n>>file\n" + this._file + ">>endfile"); +this.dbgMsg ("Loading started."); +var a = this.readAlignment (this._file); +var b = this.readAlignment (this._file2); +if (a != null) { +this.addToDisplay (a, b); +this.loadTree (a); +this.loadScoreFile (a); +this.loadFeatures (a); +this.loadAnnotations (a); +this.loadJnetFile (a); +this.loadPdbFiles (a); +} else { +this.b$["jalview.bin.JalviewLite"].fileFound = false; +this.applet.remove (this.b$["jalview.bin.JalviewLite"].launcher); +this.applet.repaint (); +}this.b$["jalview.bin.JalviewLite"].callInitCallback (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "addToDisplay", +function (a, b) { +if (b == null) { +a.addToDisplay (this.b$["jalview.bin.JalviewLite"].embedded); +} else { +var c = new jalview.appletgui.SplitFrame (a, b); +c.addToDisplay (this.b$["jalview.bin.JalviewLite"].embedded, this.b$["jalview.bin.JalviewLite"]); +}}, "jalview.appletgui.AlignFrame,jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "readAlignment", +function (a) { +if (a == null) { +return null; +}var b = this.setProtocolState (a); +var c = new jalview.io.IdentifyFile ().Identify (b, this.protocol); +this.dbgMsg ("File identified as '" + c + "'"); +var d = null; +try { +d = new jalview.io.AppletFormatAdapter ().readFile (b, this.protocol, c); +if ((d != null) && (d.getHeight () > 0)) { +this.dbgMsg ("Successfully loaded file."); +d.setDataset (null); +var e = new jalview.appletgui.AlignFrame (d, this.applet, b, this.b$["jalview.bin.JalviewLite"].embedded, false); +e.setTitle (b); +if (this.b$["jalview.bin.JalviewLite"].initialAlignFrame == null) { +this.b$["jalview.bin.JalviewLite"].initialAlignFrame = e; +}this.b$["jalview.bin.JalviewLite"].currentAlignFrame = e; +if (this.protocol === jalview.io.AppletFormatAdapter.PASTE) { +e.setTitle (jalview.util.MessageManager.formatMessage ("label.sequences_from", Clazz.newArray (-1, [this.applet.getDocumentBase ().toString ()]))); +}e.setStatus (jalview.util.MessageManager.formatMessage ("label.successfully_loaded_file", Clazz.newArray (-1, [b]))); +return e; +}} catch (ex) { +if (Clazz.exceptionOf (ex, java.io.IOException)) { +this.dbgMsg ("File load exception."); +ex.printStackTrace (); +if (jalview.bin.JalviewLite.debug) { +try { +var e = new jalview.io.FileParse (b, this.protocol); +var f = null; +this.dbgMsg (">>>Dumping contents of '" + b + "' " + "(" + this.protocol + ")"); +while ((f = e.nextLine ()) != null) { +this.dbgMsg (f); +} +this.dbgMsg (">>>Dump finished."); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Exception when trying to dump the content of the file parameter."); +e.printStackTrace (); +} else { +throw e; +} +} +}} else { +throw ex; +} +} +return null; +}, "~S"); +Clazz.defineMethod (c$, "loadPdbFiles", +function (a) { +var b = false; +this.applet.setAlignPdbStructures (this.b$["jalview.bin.JalviewLite"].getDefaultParameter ("alignpdbfiles", false)); +var c = 0; +var d = new java.util.Vector (); +var e = (this.applet.getDefaultParameter ("relaxedidmatch", false)) ? new jalview.analysis.SequenceIdMatcher (a.getAlignViewport ().getAlignment ().getSequencesArray ()) : null; +var f; +do { +if (c > 0) { +f = this.applet.getParameter ("PDBFILE" + c); +} else { +f = this.b$["jalview.bin.JalviewLite"].pdbFile; +}if (f != null) { +var g = new jalview.datamodel.PDBEntry (); +var h; +var i = null; +var j = null; +var k = new java.util.StringTokenizer (f, " "); +if (k.countTokens () < 2) { +if (this.b$["jalview.bin.JalviewLite"].sequence != null) { +i = Clazz.newArray (-1, [e == null ? a.getAlignViewport ().getAlignment ().findName (this.b$["jalview.bin.JalviewLite"].sequence) : e.findIdMatch (this.b$["jalview.bin.JalviewLite"].sequence)]); +}} else { +f = k.nextToken (); +var l = new java.util.Vector (); +var m = new java.util.Vector (); +while (k.hasMoreTokens ()) { +h = k.nextToken (); +var n = new java.util.StringTokenizer (h, "="); +if (n.countTokens () > 1) { +m.addElement (n.nextToken ()); +h = n.nextToken (); +}l.addElement (e == null ? a.getAlignViewport ().getAlignment ().findName (h) : e.findIdMatch (h)); +} +i = new Array (l.size ()); +l.copyInto (i); +if (m.size () == l.size ()) { +j = new Array (m.size ()); +m.copyInto (j); +}}f = this.setProtocolState (f); +if (this.protocol === jalview.io.AppletFormatAdapter.CLASSLOADER && !this.b$["jalview.bin.JalviewLite"].useXtrnalSviewer) { +this.protocol = jalview.io.AppletFormatAdapter.URL; +f = this.addProtocol (f); +}g.setFile (f); +if (i != null) { +for (var l = 0; l < i.length; l++) { +if (i[l] != null) { +(i[l]).addPDBId (g); +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.applet).registerPDBEntry (g); +} else { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Warning: Possible input parsing error: Null sequence for attachment of PDB (sequence " + l + ")"); +}}} +if (!this.b$["jalview.bin.JalviewLite"].alignPdbStructures) { +a.newStructureView (this.applet, g, i, j, this.protocol); +} else { +d.addElement ( Clazz.newArray (-1, [g, i, j, String.instantialize (this.protocol)])); +}}}c++; +} while (f != null || c < 10); +if (d.size () > 0) { +var g = new Array (d.size ()); +var h = new Array (d.size ()); +var i = new Array (d.size ()); +var j = new Array (d.size ()); +for (var k = 0, l = d.size (); k < l; k++) { +var m = d.elementAt (k); +h[k] = m[0]; +g[k] = m[1]; +i[k] = m[2]; +j[k] = m[3]; +} +a.alignedStructureView (this.applet, h, g, i, j); +b = true; +}return b; +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "loadJnetFile", +function (a) { +var b = false; +var c = this.b$["jalview.bin.JalviewLite"].jnetFile; +if (c != null) { +try { +c = this.setProtocolState (c); +var d = jalview.jsdev.GenericFileAdapter.getFile ("JPredFile", [c, this.protocol]); +jalview.io.JnetAnnotationMaker.add_annotation (d, a.viewport.getAlignment (), 0, false); +var e = a.viewport.getAlignment ().getSequenceAt (0); +a.viewport.getAlignment ().setSeqrep (e); +var f = new jalview.datamodel.ColumnSelection (); +f.hideInsertionsFor (e); +a.viewport.setColumnSelection (f); +a.alignPanel.fontChanged (); +a.alignPanel.setScrollValues (0, 0); +b = true; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}return b; +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "loadAnnotations", +function (a) { +var b = false; +var c = this.b$["jalview.bin.JalviewLite"].annotations; +if (c != null) { +c = this.setProtocolState (c); +if ( new jalview.io.AnnotationFile ().annotateAlignmentView (a.viewport, c, this.protocol)) { +a.alignPanel.fontChanged (); +a.alignPanel.setScrollValues (0, 0); +b = true; +} else { +System.err.println ("Annotations were not added from annotation file '" + c + "'"); +}}return b; +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "loadFeatures", +function (a) { +var b = false; +var c = this.b$["jalview.bin.JalviewLite"].hideFeatureGroups; +if (c != null) { +a.setFeatureGroupState (this.b$["jalview.bin.JalviewLite"].separatorListToArray (c), false); +}c = this.b$["jalview.bin.JalviewLite"].showFeatureGroups; +if (c != null) { +a.setFeatureGroupState (this.b$["jalview.bin.JalviewLite"].separatorListToArray (c), true); +}c = this.b$["jalview.bin.JalviewLite"].features; +if (c != null) { +c = this.setProtocolState (c); +b = a.parseFeaturesFile (c, this.protocol); +}c = this.b$["jalview.bin.JalviewLite"].showFeatureSettings; +if (c != null && c.equalsIgnoreCase ("true")) { +a.viewport.setShowSequenceFeatures (true); + new jalview.appletgui.FeatureSettings (a.alignPanel); +}return b; +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "loadScoreFile", +function (a) { +var b = false; +if (this.b$["jalview.bin.JalviewLite"].scoreFile != null && !"".equals (this.b$["jalview.bin.JalviewLite"].scoreFile)) { +try { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Attempting to load T-COFFEE score file from the scoreFile parameter"); +}b = a.loadScoreFile (this.b$["jalview.bin.JalviewLite"].scoreFile); +if (!b) { +System.err.println ("Failed to parse T-COFFEE parameter as a valid score file ('" + this.b$["jalview.bin.JalviewLite"].scoreFile + "')"); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.printf ("Cannot read score file: '%s'. Cause: %s \n", [this.b$["jalview.bin.JalviewLite"].scoreFile, e.getMessage ()]); +} else { +throw e; +} +} +}return b; +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "loadTree", +function (a) { +var b = false; +if (this.b$["jalview.bin.JalviewLite"].treeFile == null) { +this.b$["jalview.bin.JalviewLite"].treeFile = this.applet.getParameter ("treeFile"); +}if (this.b$["jalview.bin.JalviewLite"].treeFile != null) { +try { +this.b$["jalview.bin.JalviewLite"].treeFile = this.setProtocolState (this.b$["jalview.bin.JalviewLite"].treeFile); +var c = new jalview.io.NewickFile (this.b$["jalview.bin.JalviewLite"].treeFile, this.protocol); +c.parse (); +if (c.getTree () != null) { +a.loadTree (c, this.b$["jalview.bin.JalviewLite"].treeFile); +b = true; +this.dbgMsg ("Successfully imported tree."); +} else { +this.dbgMsg ("Tree parameter did not resolve to a valid tree."); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +}return b; +}, "jalview.appletgui.AlignFrame"); +Clazz.defineMethod (c$, "inArchive", +function (a) { +try { +var b = (this.getClass ().getResourceAsStream ("/" + a) != null); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Resource '" + a + "' was " + (b ? "" : "not") + " located by classloader."); +}return b; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.out.println ("Exception checking resources: " + a + " " + ex); +return false; +} else { +throw ex; +} +} +}, "~S"); +Clazz.defineMethod (c$, "addProtocol", +function (a) { +if (a.indexOf ("://") == -1) { +var b = this.applet.resolveUrlForLocalOrAbsolute (a, this.b$["jalview.bin.JalviewLite"].getDocumentBase ()); +if (this.urlExists (b)) { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Prepended document base for resource: '" + a + "'"); +}return b; +}b = this.applet.resolveUrlForLocalOrAbsolute (a, this.b$["jalview.bin.JalviewLite"].getCodeBase ()); +if (this.urlExists (b)) { +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Prepended codebase for resource: '" + a + "'"); +}return b; +}}return a; +}, "~S"); +Clazz.defineMethod (c$, "urlExists", +($fz = function (a) { +var b = null; +try { +b = new java.net.URL (a).openStream (); +if (b != null) { +return true; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} finally { +if (b != null) { +try { +b.close (); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +}} +return false; +}, $fz.isPrivate = true, $fz), "~S"); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$1", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.f$.me).mouseOverVamsasSequence (this.f$.sq, this.f$.sq.findIndex (this.f$.pos), null); +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$2", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.f$.me).mouseOverVamsasSequence (this.f$.sq, this.f$.pos, null); +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$3", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +this.f$.alf.select (this.f$.sel, this.f$.csel); +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$4$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$4", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +try { +jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.f$.me).mouseOverStructure ( new Integer (this.f$.pdbResNum).intValue (), this.f$.chain, this.f$.pdbfile); +if (jalview.bin.JalviewLite.debug) { +System.err.println ("mouseOver for '" + this.f$.pdbResNum + "' in chain '" + this.f$.chain + "' in structure '" + this.f$.pdbfile + "'"); +}} catch (e) { +if (Clazz.exceptionOf (e, NumberFormatException)) { +System.err.println ("Ignoring invalid residue number string '" + this.f$.pdbResNum + "'"); +} else { +throw e; +} +} +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$5$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$5", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +try { +this.f$.alf.scrollTo ( new Integer (this.f$.topRow).intValue (), new Integer (this.f$.leftHandColumn).intValue ()); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Couldn't parse integer arguments (topRow='" + this.f$.topRow + "' and leftHandColumn='" + this.f$.leftHandColumn + "')"); +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$6$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$6", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +try { +this.f$.alf.scrollToRow ( new Integer (this.f$.topRow).intValue ()); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Couldn't parse integer arguments (topRow='" + this.f$.topRow + "')"); +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$7$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$7", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +try { +this.f$.alf.scrollToColumn ( new Integer (this.f$.leftHandColumn).intValue ()); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Couldn't parse integer arguments (leftHandColumn='" + this.f$.leftHandColumn + "')"); +ex.printStackTrace (); +} else { +throw ex; +} +} +}); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$8$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$8", null, java.awt.event.ActionListener); +Clazz.overrideMethod (c$, "actionPerformed", +function (e) { +var loader = Clazz.innerTypeInstance (jalview.bin.JalviewLite.LoadingThread, this, null, this.b$["jalview.bin.JalviewLite"].startupFile, this.b$["jalview.bin.JalviewLite"].file2, this.b$["jalview.bin.JalviewLite"]); +loader.start (); +}, "java.awt.event.ActionEvent"); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$9$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$9", java.awt.event.WindowAdapter); +Clazz.overrideMethod (c$, "windowClosing", +function (e) { +if (Clazz.instanceOf (this.f$.frame, jalview.appletgui.AlignFrame)) { +var vp = (this.f$.frame).viewport; +(this.f$.frame).closeMenuItem_actionPerformed (); +if (vp.applet.currentAlignFrame === this.f$.frame) { +vp.applet.currentAlignFrame = null; +}vp.applet = null; +vp = null; +}jalview.bin.JalviewLite.lastFrameX -= 40; +jalview.bin.JalviewLite.lastFrameY -= 40; +if (Clazz.instanceOf (this.f$.frame, jalview.appletgui.EmbmenuFrame)) { +(this.f$.frame).destroyMenus (); +}this.f$.frame.setMenuBar (null); +this.f$.frame.dispose (); +}, "java.awt.event.WindowEvent"); +Clazz.defineMethod (c$, "windowActivated", +function (e) { +if (Clazz.instanceOf (this.f$.frame, jalview.appletgui.AlignFrame)) { +(this.f$.frame).viewport.applet.currentAlignFrame = this.f$.frame; +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Activated window " + this.f$.frame); +}}Clazz.superCall (this, jalview.bin.JalviewLite$9, "windowActivated", [e]); +}, "java.awt.event.WindowEvent"); +c$ = Clazz.p0p (); +}; +c$.$JalviewLite$10$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.bin, "JalviewLite$10", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +this.f$.alf.setFeatureGroupState (this.b$["jalview.bin.JalviewLite"].separatorListToArray (this.f$.groups), this.f$.st); +}); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"TRUE", "true", +"FALSE", "false", +"debug", false, +"lastFrameX", 200, +"lastFrameY", 200, +"builddate", null, +"version", null, +"installation", null); +}); diff --git a/bin/jalview/commands/ChangeCaseCommand.js b/bin/jalview/commands/ChangeCaseCommand.js index 0ebfc96..fb085d6 100644 --- a/bin/jalview/commands/ChangeCaseCommand.js +++ b/bin/jalview/commands/ChangeCaseCommand.js @@ -1,74 +1,74 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.CommandI"], "jalview.commands.ChangeCaseCommand", ["java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.description = null; -this.caseChange = -1; -this.seqs = null; -this.regions = null; -Clazz.instantialize (this, arguments); -}, jalview.commands, "ChangeCaseCommand", null, jalview.commands.CommandI); -Clazz.makeConstructor (c$, -function (description, seqs, regions, caseChange) { -this.description = description; -this.seqs = seqs; -this.regions = regions; -this.caseChange = caseChange; -this.doCommand (null); -}, "~S,~A,java.util.List,~N"); -Clazz.overrideMethod (c$, "getDescription", -function () { -return this.description; -}); -Clazz.overrideMethod (c$, "getSize", -function () { -return 1; -}); -Clazz.overrideMethod (c$, "doCommand", -function (views) { -this.changeCase (true); -}, "~A"); -Clazz.overrideMethod (c$, "undoCommand", -function (views) { -this.changeCase (false); -}, "~A"); -Clazz.defineMethod (c$, "changeCase", -function (doCommand) { -var sequence; -var start; -var end; -var nextChar; -for (var r, $r = this.regions.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { -start = r[0]; -for (var s = 0; s < this.seqs.length; s++) { -sequence = this.seqs[s].getSequenceAsString (); -var newSeq = new StringBuffer (); -if (r[1] > sequence.length) { -end = sequence.length; -} else { -end = r[1]; -}if (start > 0) { -newSeq.append (sequence.substring (0, start)); -}if ((this.caseChange == jalview.commands.ChangeCaseCommand.TO_UPPER && doCommand) || (this.caseChange == jalview.commands.ChangeCaseCommand.TO_LOWER && !doCommand)) { -newSeq.append (sequence.substring (start, end).toUpperCase ()); -} else if ((this.caseChange == jalview.commands.ChangeCaseCommand.TO_LOWER && doCommand) || (this.caseChange == jalview.commands.ChangeCaseCommand.TO_UPPER && !doCommand)) { -newSeq.append (sequence.substring (start, end).toLowerCase ()); -} else { -for (var c = start; c < end; c++) { -nextChar = sequence.charAt (c); -if ('a' <= nextChar && nextChar <= 'z') { -nextChar = String.fromCharCode (nextChar.charCodeAt (0) - (32)); -} else if ('A' <= nextChar && nextChar <= 'Z') { -nextChar = String.fromCharCode (nextChar.charCodeAt (0) + (32)); -}newSeq.append (nextChar); -} -}if (end < sequence.length) { -newSeq.append (sequence.substring (end)); -}this.seqs[s].setSequence (newSeq.toString ()); -} -} -}, "~B"); -Clazz.defineStatics (c$, -"TO_LOWER", 0, -"TO_UPPER", 1, -"TOGGLE_CASE", 2); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.CommandI"], "jalview.commands.ChangeCaseCommand", ["java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.description = null; +this.caseChange = -1; +this.seqs = null; +this.regions = null; +Clazz.instantialize (this, arguments); +}, jalview.commands, "ChangeCaseCommand", null, jalview.commands.CommandI); +Clazz.makeConstructor (c$, +function (description, seqs, regions, caseChange) { +this.description = description; +this.seqs = seqs; +this.regions = regions; +this.caseChange = caseChange; +this.doCommand (null); +}, "~S,~A,java.util.List,~N"); +Clazz.overrideMethod (c$, "getDescription", +function () { +return this.description; +}); +Clazz.overrideMethod (c$, "getSize", +function () { +return 1; +}); +Clazz.overrideMethod (c$, "doCommand", +function (views) { +this.changeCase (true); +}, "~A"); +Clazz.overrideMethod (c$, "undoCommand", +function (views) { +this.changeCase (false); +}, "~A"); +Clazz.defineMethod (c$, "changeCase", +function (doCommand) { +var sequence; +var start; +var end; +var nextChar; +for (var r, $r = this.regions.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { +start = r[0]; +for (var s = 0; s < this.seqs.length; s++) { +sequence = this.seqs[s].getSequenceAsString (); +var newSeq = new StringBuffer (); +if (r[1] > sequence.length) { +end = sequence.length; +} else { +end = r[1]; +}if (start > 0) { +newSeq.append (sequence.substring (0, start)); +}if ((this.caseChange == jalview.commands.ChangeCaseCommand.TO_UPPER && doCommand) || (this.caseChange == jalview.commands.ChangeCaseCommand.TO_LOWER && !doCommand)) { +newSeq.append (sequence.substring (start, end).toUpperCase ()); +} else if ((this.caseChange == jalview.commands.ChangeCaseCommand.TO_LOWER && doCommand) || (this.caseChange == jalview.commands.ChangeCaseCommand.TO_UPPER && !doCommand)) { +newSeq.append (sequence.substring (start, end).toLowerCase ()); +} else { +for (var c = start; c < end; c++) { +nextChar = sequence.charAt (c); +if ('a' <= nextChar && nextChar <= 'z') { +nextChar = String.fromCharCode (nextChar.charCodeAt (0) - (32)); +} else if ('A' <= nextChar && nextChar <= 'Z') { +nextChar = String.fromCharCode (nextChar.charCodeAt (0) + (32)); +}newSeq.append (nextChar); +} +}if (end < sequence.length) { +newSeq.append (sequence.substring (end)); +}this.seqs[s].setSequence (newSeq.toString ()); +} +} +}, "~B"); +Clazz.defineStatics (c$, +"TO_LOWER", 0, +"TO_UPPER", 1, +"TOGGLE_CASE", 2); +}); diff --git a/bin/jalview/commands/CommandI.js b/bin/jalview/commands/CommandI.js index 598c931..792918f 100644 --- a/bin/jalview/commands/CommandI.js +++ b/bin/jalview/commands/CommandI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.declareInterface (jalview.commands, "CommandI"); +Clazz.declarePackage ("jalview.commands"); +Clazz.declareInterface (jalview.commands, "CommandI"); diff --git a/bin/jalview/commands/EditCommand.js b/bin/jalview/commands/EditCommand.js index 0839473..b556231 100644 --- a/bin/jalview/commands/EditCommand.js +++ b/bin/jalview/commands/EditCommand.js @@ -1,661 +1,661 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.CommandI", "java.lang.Enum", "java.util.ArrayList"], "jalview.commands.EditCommand", ["jalview.analysis.AlignSeq", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.Sequence", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.ReverseListIterator", "$.StringUtils", "java.lang.StringBuffer", "java.util.HashMap", "$.Hashtable"], function () { -c$ = Clazz.decorateAsClass (function () { -this.edits = null; -this.description = null; -if (!Clazz.isClassDefined ("jalview.commands.EditCommand.Edit")) { -jalview.commands.EditCommand.$EditCommand$Edit$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.commands, "EditCommand", null, jalview.commands.CommandI); -Clazz.prepareFields (c$, function () { -this.edits = new java.util.ArrayList (); -}); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (description) { -this.description = description; -}, "~S"); -Clazz.makeConstructor (c$, -function (description, command, seqs, position, number, al) { -this.description = description; -if (command === jalview.commands.EditCommand.Action.CUT || command === jalview.commands.EditCommand.Action.PASTE) { -this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, command, seqs, position, number, al)); -}this.performEdit (0, null); -}, "~S,jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI"); -Clazz.makeConstructor (c$, -function (description, command, replace, seqs, position, number, al) { -this.description = description; -if (command === jalview.commands.EditCommand.Action.REPLACE) { -this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, command, seqs, position, number, al, replace)); -}this.performEdit (0, null); -}, "~S,jalview.commands.EditCommand.Action,~S,~A,~N,~N,jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "setEdit", -function (e) { -this.edits.clear (); -this.edits.add (e); -}, "jalview.commands.EditCommand.Edit"); -Clazz.defineMethod (c$, "addEdit", -function (e) { -if (!jalview.commands.EditCommand.expandEdit (this.edits, e)) { -this.edits.add (e); -}}, "jalview.commands.EditCommand.Edit"); -c$.expandEdit = Clazz.defineMethod (c$, "expandEdit", -function (edits, e) { -if (edits == null || edits.isEmpty ()) { -return false; -}var lastEdit = edits.get (edits.size () - 1); -var action = e.command; -if (lastEdit.command !== action) { -return false; -}if (lastEdit.seqs.length != e.seqs.length) { -return false; -}for (var i = 0; i < e.seqs.length; i++) { -if (lastEdit.seqs[i].getDatasetSequence () !== e.seqs[i].getDatasetSequence ()) { -return false; -}} -var contiguous = (action === jalview.commands.EditCommand.Action.INSERT_GAP && e.position == lastEdit.position + lastEdit.number) || (action === jalview.commands.EditCommand.Action.DELETE_GAP && e.position + e.number == lastEdit.position); -if (contiguous) { -lastEdit.number += e.number; -lastEdit.seqs = e.seqs; -if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { -lastEdit.position--; -}return true; -}return false; -}, "java.util.List,jalview.commands.EditCommand.Edit"); -Clazz.defineMethod (c$, "clearEdits", -function () { -this.edits.clear (); -}); -Clazz.defineMethod (c$, "getEdit", -function (i) { -if (i >= 0 && i < this.edits.size ()) { -return this.edits.get (i); -}return null; -}, "~N"); -Clazz.overrideMethod (c$, "getDescription", -function () { -return this.description; -}); -Clazz.overrideMethod (c$, "getSize", -function () { -return this.edits.size (); -}); -Clazz.defineMethod (c$, "getAlignment", -function () { -return (this.edits.isEmpty () ? null : this.edits.get (0).al); -}); -Clazz.defineMethod (c$, "appendEdit", -function (command, seqs, position, number, al, performEdit) { -this.appendEdit (command, seqs, position, number, al, performEdit, null); -}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI,~B"); -Clazz.defineMethod (c$, "appendEdit", -function (command, seqs, position, number, al, performEdit, views) { -var edit = Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, command, seqs, position, number, al.getGapCharacter ()); -if (al.getHeight () == seqs.length) { -edit.al = al; -edit.fullAlignmentHeight = true; -}this.addEdit (edit); -if (performEdit) { -jalview.commands.EditCommand.performEdit (edit, views); -}}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI,~B,~A"); -Clazz.defineMethod (c$, "appendEdit", -function (edit, al, performEdit, views) { -if (al.getHeight () == edit.seqs.length) { -edit.al = al; -edit.fullAlignmentHeight = true; -}this.addEdit (edit); -if (performEdit) { -jalview.commands.EditCommand.performEdit (edit, views); -}}, "jalview.commands.EditCommand.Edit,jalview.datamodel.AlignmentI,~B,~A"); -Clazz.defineMethod (c$, "performEdit", -function (commandIndex, views) { -var iterator = this.edits.listIterator (commandIndex); -while (iterator.hasNext ()) { -var edit = iterator.next (); -jalview.commands.EditCommand.performEdit (edit, views); -} -}, "~N,~A"); -c$.performEdit = Clazz.defineMethod (c$, "performEdit", -function (edit, views) { -switch (edit.command) { -case jalview.commands.EditCommand.Action.INSERT_GAP: -jalview.commands.EditCommand.insertGap (edit); -break; -case jalview.commands.EditCommand.Action.DELETE_GAP: -jalview.commands.EditCommand.deleteGap (edit); -break; -case jalview.commands.EditCommand.Action.CUT: -jalview.commands.EditCommand.cut (edit, views); -break; -case jalview.commands.EditCommand.Action.PASTE: -jalview.commands.EditCommand.paste (edit, views); -break; -case jalview.commands.EditCommand.Action.REPLACE: -jalview.commands.EditCommand.replace (edit); -break; -case jalview.commands.EditCommand.Action.INSERT_NUC: -break; -default: -break; -} -}, "jalview.commands.EditCommand.Edit,~A"); -Clazz.overrideMethod (c$, "doCommand", -function (views) { -this.performEdit (0, views); -}, "~A"); -Clazz.overrideMethod (c$, "undoCommand", -function (views) { -var iterator = this.edits.listIterator (this.edits.size ()); -while (iterator.hasPrevious ()) { -var e = iterator.previous (); -switch (e.command) { -case jalview.commands.EditCommand.Action.INSERT_GAP: -jalview.commands.EditCommand.deleteGap (e); -break; -case jalview.commands.EditCommand.Action.DELETE_GAP: -jalview.commands.EditCommand.insertGap (e); -break; -case jalview.commands.EditCommand.Action.CUT: -jalview.commands.EditCommand.paste (e, views); -break; -case jalview.commands.EditCommand.Action.PASTE: -jalview.commands.EditCommand.cut (e, views); -break; -case jalview.commands.EditCommand.Action.REPLACE: -jalview.commands.EditCommand.replace (e); -break; -case jalview.commands.EditCommand.Action.INSERT_NUC: -break; -default: -break; -} -} -}, "~A"); -c$.insertGap = Clazz.defineMethod (c$, "insertGap", -($fz = function (command) { -for (var s = 0; s < command.seqs.length; s++) { -command.seqs[s].insertCharAt (command.position, command.number, command.gapChar); -} -jalview.commands.EditCommand.adjustAnnotations (command, true, false, null); -}, $fz.isPrivate = true, $fz), "jalview.commands.EditCommand.Edit"); -c$.deleteGap = Clazz.defineMethod (c$, "deleteGap", -($fz = function (command) { -for (var s = 0; s < command.seqs.length; s++) { -command.seqs[s].deleteChars (command.position, command.position + command.number); -} -jalview.commands.EditCommand.adjustAnnotations (command, false, false, null); -}, $fz.isPrivate = true, $fz), "jalview.commands.EditCommand.Edit"); -c$.cut = Clazz.defineMethod (c$, "cut", -function (command, views) { -var seqDeleted = false; -command.string = Clazz.newCharArray (command.seqs.length, '\0'); -for (var i = 0; i < command.seqs.length; i++) { -var sequence = command.seqs[i]; -if (sequence.getLength () > command.position) { -command.string[i] = sequence.getSequence (command.position, command.position + command.number); -var oldds = sequence.getDatasetSequence (); -if (command.oldds != null && command.oldds[i] != null) { -sequence.setDatasetSequence (null); -}sequence.deleteChars (command.position, command.position + command.number); -if (command.oldds != null && command.oldds[i] != null) { -sequence.setDatasetSequence (command.oldds[i]); -command.oldds[i] = oldds; -} else { -if (oldds !== sequence.getDatasetSequence () || sequence.getSequenceFeatures () != null) { -if (command.oldds == null) { -command.oldds = new Array (command.seqs.length); -}command.oldds[i] = oldds; -jalview.commands.EditCommand.adjustFeatures (command, i, sequence.findPosition (command.position), sequence.findPosition (command.position + command.number), false); -}}}if (sequence.getLength () < 1) { -command.al.deleteSequence (sequence); -seqDeleted = true; -}} -jalview.commands.EditCommand.adjustAnnotations (command, false, seqDeleted, views); -}, "jalview.commands.EditCommand.Edit,~A"); -c$.paste = Clazz.defineMethod (c$, "paste", -function (command, views) { -var tmp; -var newDSNeeded; -var newDSWasNeeded; -var newstart; -var newend; -var seqWasDeleted = false; -var start = 0; -var end = 0; -for (var i = 0; i < command.seqs.length; i++) { -newDSNeeded = false; -newDSWasNeeded = command.oldds != null && command.oldds[i] != null; -if (command.seqs[i].getLength () < 1) { -if (command.alIndex[i] < command.al.getHeight ()) { -var sequences; -{ -if (!(command.alIndex[i] < 0)) { -sequences.add (command.alIndex[i], command.seqs[i]); -}}} else { -command.al.addSequence (command.seqs[i]); -}seqWasDeleted = true; -}newstart = command.seqs[i].getStart (); -newend = command.seqs[i].getEnd (); -tmp = new StringBuffer (); -tmp.append (command.seqs[i].getSequence ()); -if (command.string != null && command.string[i] != null) { -if (command.position >= tmp.length ()) { -var length = command.position - tmp.length (); -while (length > 0) { -tmp.append (command.gapChar); -length--; -} -}tmp.insert (command.position, command.string[i]); -for (var s = 0; s < command.string[i].length; s++) { -if (jalview.schemes.ResidueProperties.aaIndex[command.string[i][s].charCodeAt (0)] != 23) { -if (!newDSNeeded) { -newDSNeeded = true; -start = command.seqs[i].findPosition (command.position); -end = command.seqs[i].findPosition (command.position + command.number); -}if (command.seqs[i].getStart () == start) { -newstart--; -} else { -newend++; -}}} -command.string[i] = null; -}command.seqs[i].setSequence (tmp.toString ()); -command.seqs[i].setStart (newstart); -command.seqs[i].setEnd (newend); -if (newDSNeeded) { -if (command.seqs[i].getDatasetSequence () != null) { -var ds; -if (newDSWasNeeded) { -ds = command.oldds[i]; -} else { -ds = new jalview.datamodel.Sequence (command.seqs[i].getName (), jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, command.seqs[i].getSequenceAsString ()), command.seqs[i].getStart (), command.seqs[i].getEnd ()); -ds.setDescription (command.seqs[i].getDescription ()); -}if (command.oldds == null) { -command.oldds = new Array (command.seqs.length); -}command.oldds[i] = command.seqs[i].getDatasetSequence (); -command.seqs[i].setDatasetSequence (ds); -}jalview.commands.EditCommand.adjustFeatures (command, i, start, end, true); -}} -jalview.commands.EditCommand.adjustAnnotations (command, true, seqWasDeleted, views); -command.string = null; -}, "jalview.commands.EditCommand.Edit,~A"); -c$.replace = Clazz.defineMethod (c$, "replace", -function (command) { -var tmp; -var oldstring; -var start = command.position; -var end = command.number; -command.number = start + command.string[0].length; -for (var i = 0; i < command.seqs.length; i++) { -var newDSWasNeeded = command.oldds != null && command.oldds[i] != null; -oldstring = command.seqs[i].getSequenceAsString (); -tmp = new StringBuffer (oldstring.substring (0, start)); -tmp.append (command.string[i]); -var nogaprep = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (command.string[i])); -var ipos = command.seqs[i].findPosition (start) - command.seqs[i].getStart (); -tmp.append (oldstring.substring (end)); -command.seqs[i].setSequence (tmp.toString ()); -command.string[i] = oldstring.substring (start, end).toCharArray (); -var nogapold = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (command.string[i])); -if (!nogaprep.toLowerCase ().equals (nogapold.toLowerCase ())) { -if (newDSWasNeeded) { -var oldds = command.seqs[i].getDatasetSequence (); -command.seqs[i].setDatasetSequence (command.oldds[i]); -command.oldds[i] = oldds; -} else { -if (command.oldds == null) { -command.oldds = new Array (command.seqs.length); -}command.oldds[i] = command.seqs[i].getDatasetSequence (); -var newds = new jalview.datamodel.Sequence (command.seqs[i].getDatasetSequence ()); -var fullseq; -var osp = newds.getSequenceAsString (); -fullseq = osp.substring (0, ipos) + nogaprep + osp.substring (ipos + nogaprep.length); -newds.setSequence (fullseq.toUpperCase ()); -command.seqs[i].setDatasetSequence (newds); -}}tmp = null; -oldstring = null; -} -}, "jalview.commands.EditCommand.Edit"); -c$.adjustAnnotations = Clazz.defineMethod (c$, "adjustAnnotations", -function (command, insert, modifyVisibility, views) { -var annotations = null; -if (modifyVisibility && !insert) { -command.deletedAnnotationRows = new java.util.Hashtable (); -}if (command.fullAlignmentHeight) { -annotations = command.al.getAlignmentAnnotation (); -} else { -var aSize = 0; -var tmp; -for (var s = 0; s < command.seqs.length; s++) { -if (modifyVisibility) { -if (!insert) { -tmp = command.seqs[s].getAnnotation (); -if (tmp != null) { -var alen = tmp.length; -for (var aa = 0; aa < tmp.length; aa++) { -if (!command.al.deleteAnnotation (tmp[aa])) { -tmp[aa] = null; -alen--; -}} -command.seqs[s].setAlignmentAnnotation (null); -if (alen != tmp.length) { -var saved = new Array (alen); -for (var aa = 0, aapos = 0; aa < tmp.length; aa++) { -if (tmp[aa] != null) { -saved[aapos++] = tmp[aa]; -tmp[aa] = null; -}} -tmp = saved; -command.deletedAnnotationRows.put (command.seqs[s], saved); -for (var alview = 0; views != null && alview < views.length; alview++) { -if (views[alview] !== command.al) { -var toremove = views[alview].getAlignmentAnnotation (); -if (toremove == null || toremove.length == 0) { -continue; -}for (var aa = 0; aa < toremove.length; aa++) { -if (toremove[aa].sequenceRef === command.seqs[s]) { -views[alview].deleteAnnotation (toremove[aa]); -}} -}} -} else { -command.deletedAnnotationRows.put (command.seqs[s], tmp); -}}} else { -if (command.deletedAnnotationRows != null && command.deletedAnnotationRows.containsKey (command.seqs[s])) { -var revealed = command.deletedAnnotationRows.get (command.seqs[s]); -command.seqs[s].setAlignmentAnnotation (revealed); -if (revealed != null) { -for (var aa = 0; aa < revealed.length; aa++) { -command.al.addAnnotation (revealed[aa]); -} -for (var aa = 0; aa < revealed.length; aa++) { -command.al.setAnnotationIndex (revealed[aa], aa); -} -for (var vnum = 0; views != null && vnum < views.length; vnum++) { -if (views[vnum] !== command.al) { -var avwidth = views[vnum].getWidth () + 1; -for (var a = 0; a < revealed.length; a++) { -var newann = new jalview.datamodel.AlignmentAnnotation (revealed[a]); -command.seqs[s].addAlignmentAnnotation (newann); -newann.padAnnotation (avwidth); -views[vnum].addAnnotation (newann); -views[vnum].setAnnotationIndex (newann, a); -} -}} -}}}continue; -}if (command.seqs[s].getAnnotation () == null) { -continue; -}if (aSize == 0) { -annotations = command.seqs[s].getAnnotation (); -} else { -tmp = new Array (aSize + command.seqs[s].getAnnotation ().length); -System.arraycopy (annotations, 0, tmp, 0, aSize); -System.arraycopy (command.seqs[s].getAnnotation (), 0, tmp, aSize, command.seqs[s].getAnnotation ().length); -annotations = tmp; -}aSize = annotations.length; -} -}if (annotations == null) { -return; -}if (!insert) { -command.deletedAnnotations = new java.util.Hashtable (); -}var aSize; -var temp; -for (var a = 0; a < annotations.length; a++) { -if (annotations[a].autoCalculated || annotations[a].annotations == null) { -continue; -}var tSize = 0; -aSize = annotations[a].annotations.length; -if (insert) { -temp = new Array (aSize + command.number); -if (annotations[a].padGaps) { -for (var aa = 0; aa < temp.length; aa++) { -temp[aa] = new jalview.datamodel.Annotation (command.gapChar + "", null, ' ', 0); -} -}} else { -if (command.position < aSize) { -if (command.position + command.number >= aSize) { -tSize = aSize; -} else { -tSize = aSize - command.number; -}} else { -tSize = aSize; -}if (tSize < 0) { -tSize = aSize; -}temp = new Array (tSize); -}if (insert) { -if (command.position < annotations[a].annotations.length) { -System.arraycopy (annotations[a].annotations, 0, temp, 0, command.position); -if (command.deletedAnnotations != null && command.deletedAnnotations.containsKey (annotations[a].annotationId)) { -var restore = command.deletedAnnotations.get (annotations[a].annotationId); -System.arraycopy (restore, 0, temp, command.position, command.number); -}System.arraycopy (annotations[a].annotations, command.position, temp, command.position + command.number, aSize - command.position); -} else { -if (command.deletedAnnotations != null && command.deletedAnnotations.containsKey (annotations[a].annotationId)) { -var restore = command.deletedAnnotations.get (annotations[a].annotationId); -temp = new Array (annotations[a].annotations.length + restore.length); -System.arraycopy (annotations[a].annotations, 0, temp, 0, annotations[a].annotations.length); -System.arraycopy (restore, 0, temp, annotations[a].annotations.length, restore.length); -} else { -temp = annotations[a].annotations; -}}} else { -if (tSize != aSize || command.position < 2) { -var copylen = Math.min (command.position, annotations[a].annotations.length); -if (copylen > 0) { -System.arraycopy (annotations[a].annotations, 0, temp, 0, copylen); -}var deleted = new Array (command.number); -if (copylen >= command.position) { -copylen = Math.min (command.number, annotations[a].annotations.length - command.position); -if (copylen > 0) { -System.arraycopy (annotations[a].annotations, command.position, deleted, 0, copylen); -}}command.deletedAnnotations.put (annotations[a].annotationId, deleted); -if (annotations[a].annotations.length > command.position + command.number) { -System.arraycopy (annotations[a].annotations, command.position + command.number, temp, command.position, annotations[a].annotations.length - command.position - command.number); -}} else { -var dSize = aSize - command.position; -if (dSize > 0) { -var deleted = new Array (command.number); -System.arraycopy (annotations[a].annotations, command.position, deleted, 0, dSize); -command.deletedAnnotations.put (annotations[a].annotationId, deleted); -tSize = Math.min (annotations[a].annotations.length, command.position); -temp = new Array (tSize); -System.arraycopy (annotations[a].annotations, 0, temp, 0, tSize); -} else { -temp = annotations[a].annotations; -}}}annotations[a].annotations = temp; -} -}, "jalview.commands.EditCommand.Edit,~B,~B,~A"); -c$.adjustFeatures = Clazz.defineMethod (c$, "adjustFeatures", -function (command, index, i, j, insert) { -var seq = command.seqs[index]; -var sequence = seq.getDatasetSequence (); -if (sequence == null) { -sequence = seq; -}if (insert) { -if (command.editedFeatures != null && command.editedFeatures.containsKey (seq)) { -sequence.setSequenceFeatures (command.editedFeatures.get (seq)); -}return; -}var sf = sequence.getSequenceFeatures (); -if (sf == null) { -return; -}var oldsf = new Array (sf.length); -var cSize = j - i; -for (var s = 0; s < sf.length; s++) { -var copy = new jalview.datamodel.SequenceFeature (sf[s]); -oldsf[s] = copy; -if (sf[s].getEnd () < i) { -continue; -}if (sf[s].getBegin () > j) { -sf[s].setBegin (copy.getBegin () - cSize); -sf[s].setEnd (copy.getEnd () - cSize); -continue; -}if (sf[s].getBegin () >= i) { -sf[s].setBegin (i); -}if (sf[s].getEnd () < j) { -sf[s].setEnd (j - 1); -}sf[s].setEnd (sf[s].getEnd () - (cSize)); -if (sf[s].getBegin () > sf[s].getEnd ()) { -sequence.deleteFeature (sf[s]); -}} -if (command.editedFeatures == null) { -command.editedFeatures = new java.util.Hashtable (); -}command.editedFeatures.put (seq, oldsf); -}, "jalview.commands.EditCommand.Edit,~N,~N,~N,~B"); -Clazz.defineMethod (c$, "getEdits", -function () { -return this.edits; -}); -Clazz.defineMethod (c$, "priorState", -function (forUndo) { -var result = new java.util.HashMap (); -if (this.getEdits () == null) { -return result; -}if (forUndo) { -for (var e, $e = this.getEdits ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) { -for (var seq, $seq = 0, $$seq = e.getSequences (); $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { -var ds = seq.getDatasetSequence (); -var preEdit = result.get (ds); -if (preEdit == null) { -preEdit = new jalview.datamodel.Sequence ("", seq.getSequenceAsString ()); -preEdit.setDatasetSequence (ds); -result.put (ds, preEdit); -}} -} -return result; -}var edits = new jalview.util.ReverseListIterator (this.getEdits ()); -while (edits.hasNext ()) { -var oldEdit = edits.next (); -var action = oldEdit.getAction (); -var position = oldEdit.getPosition (); -var number = oldEdit.getNumber (); -var gap = oldEdit.getGapCharacter (); -for (var seq, $seq = 0, $$seq = oldEdit.getSequences (); $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { -var ds = seq.getDatasetSequence (); -var preEdit = result.get (ds); -if (preEdit == null) { -preEdit = new jalview.datamodel.Sequence ("", seq.getSequenceAsString ()); -preEdit.setDatasetSequence (ds); -result.put (ds, preEdit); -}if (ds != null) { -if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { -preEdit.setSequence ( String.instantialize (jalview.util.StringUtils.insertCharAt (preEdit.getSequence (), position, number, gap))); -} else if (action === jalview.commands.EditCommand.Action.INSERT_GAP) { -preEdit.setSequence ( String.instantialize (jalview.util.StringUtils.deleteChars (preEdit.getSequence (), position, position + number))); -} else { -System.err.println ("Can't undo edit action " + action); -}}} -} -return result; -}, "~B"); -Clazz.defineMethod (c$, "getEditIterator", -function (forwards) { -if (forwards) { -return this.getEdits ().iterator (); -} else { -return new jalview.util.ReverseListIterator (this.getEdits ()); -}}, "~B"); -c$.$EditCommand$Edit$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.oldds = null; -this.fullAlignmentHeight = false; -this.deletedAnnotationRows = null; -this.deletedAnnotations = null; -this.editedFeatures = null; -this.al = null; -this.command = null; -this.string = null; -this.seqs = null; -this.alIndex = null; -this.position = 0; -this.number = 0; -this.gapChar = '\0'; -Clazz.instantialize (this, arguments); -}, jalview.commands.EditCommand, "Edit"); -Clazz.makeConstructor (c$, -function (a, b, c, d, e) { -this.command = a; -this.seqs = b; -this.position = c; -this.number = d; -this.gapChar = e; -}, "jalview.commands.EditCommand.Action,~A,~N,~N,~S"); -Clazz.makeConstructor (c$, -function (a, b, c, d, e) { -this.gapChar = e.getGapCharacter (); -this.command = a; -this.seqs = b; -this.position = c; -this.number = d; -this.al = e; -this.alIndex = Clazz.newIntArray (b.length, 0); -for (var f = 0; f < b.length; f++) { -this.alIndex[f] = e.findIndex (b[f]); -} -this.fullAlignmentHeight = (e.getHeight () == b.length); -}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI"); -Clazz.makeConstructor (c$, -function (a, b, c, d, e, f) { -this.command = a; -this.seqs = b; -this.position = c; -this.number = d; -this.al = e; -this.gapChar = e.getGapCharacter (); -this.string = Clazz.newCharArray (b.length, '\0'); -for (var g = 0; g < b.length; g++) { -this.string[g] = f.toCharArray (); -} -this.fullAlignmentHeight = (e.getHeight () == b.length); -}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI,~S"); -Clazz.defineMethod (c$, "getSequences", -function () { -return this.seqs; -}); -Clazz.defineMethod (c$, "getPosition", -function () { -return this.position; -}); -Clazz.defineMethod (c$, "getAction", -function () { -return this.command; -}); -Clazz.defineMethod (c$, "getNumber", -function () { -return this.number; -}); -Clazz.defineMethod (c$, "getGapCharacter", -function () { -return this.gapChar; -}); -c$ = Clazz.p0p (); -}; -Clazz.pu$h (); -c$ = Clazz.declareType (jalview.commands.EditCommand, "Action", Enum); -Clazz.defineMethod (c$, "getUndoAction", -function () { -switch (this) { -case jalview.commands.EditCommand.Action.INSERT_GAP: -return jalview.commands.EditCommand.Action.DELETE_GAP; -case jalview.commands.EditCommand.Action.CUT: -return jalview.commands.EditCommand.Action.PASTE; -case jalview.commands.EditCommand.Action.DELETE_GAP: -return jalview.commands.EditCommand.Action.INSERT_GAP; -case jalview.commands.EditCommand.Action.INSERT_NUC: -return null; -case jalview.commands.EditCommand.Action.PASTE: -return jalview.commands.EditCommand.Action.CUT; -case jalview.commands.EditCommand.Action.REPLACE: -return jalview.commands.EditCommand.Action.REPLACE; -} -return null; -}); -Clazz.defineEnumConstant (c$, "INSERT_GAP", 0, []); -Clazz.defineEnumConstant (c$, "DELETE_GAP", 1, []); -Clazz.defineEnumConstant (c$, "CUT", 2, []); -Clazz.defineEnumConstant (c$, "PASTE", 3, []); -Clazz.defineEnumConstant (c$, "REPLACE", 4, []); -Clazz.defineEnumConstant (c$, "INSERT_NUC", 5, []); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.CommandI", "java.lang.Enum", "java.util.ArrayList"], "jalview.commands.EditCommand", ["jalview.analysis.AlignSeq", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.Sequence", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.ReverseListIterator", "$.StringUtils", "java.lang.StringBuffer", "java.util.HashMap", "$.Hashtable"], function () { +c$ = Clazz.decorateAsClass (function () { +this.edits = null; +this.description = null; +if (!Clazz.isClassDefined ("jalview.commands.EditCommand.Edit")) { +jalview.commands.EditCommand.$EditCommand$Edit$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.commands, "EditCommand", null, jalview.commands.CommandI); +Clazz.prepareFields (c$, function () { +this.edits = new java.util.ArrayList (); +}); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (description) { +this.description = description; +}, "~S"); +Clazz.makeConstructor (c$, +function (description, command, seqs, position, number, al) { +this.description = description; +if (command === jalview.commands.EditCommand.Action.CUT || command === jalview.commands.EditCommand.Action.PASTE) { +this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, command, seqs, position, number, al)); +}this.performEdit (0, null); +}, "~S,jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI"); +Clazz.makeConstructor (c$, +function (description, command, replace, seqs, position, number, al) { +this.description = description; +if (command === jalview.commands.EditCommand.Action.REPLACE) { +this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, command, seqs, position, number, al, replace)); +}this.performEdit (0, null); +}, "~S,jalview.commands.EditCommand.Action,~S,~A,~N,~N,jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "setEdit", +function (e) { +this.edits.clear (); +this.edits.add (e); +}, "jalview.commands.EditCommand.Edit"); +Clazz.defineMethod (c$, "addEdit", +function (e) { +if (!jalview.commands.EditCommand.expandEdit (this.edits, e)) { +this.edits.add (e); +}}, "jalview.commands.EditCommand.Edit"); +c$.expandEdit = Clazz.defineMethod (c$, "expandEdit", +function (edits, e) { +if (edits == null || edits.isEmpty ()) { +return false; +}var lastEdit = edits.get (edits.size () - 1); +var action = e.command; +if (lastEdit.command !== action) { +return false; +}if (lastEdit.seqs.length != e.seqs.length) { +return false; +}for (var i = 0; i < e.seqs.length; i++) { +if (lastEdit.seqs[i].getDatasetSequence () !== e.seqs[i].getDatasetSequence ()) { +return false; +}} +var contiguous = (action === jalview.commands.EditCommand.Action.INSERT_GAP && e.position == lastEdit.position + lastEdit.number) || (action === jalview.commands.EditCommand.Action.DELETE_GAP && e.position + e.number == lastEdit.position); +if (contiguous) { +lastEdit.number += e.number; +lastEdit.seqs = e.seqs; +if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { +lastEdit.position--; +}return true; +}return false; +}, "java.util.List,jalview.commands.EditCommand.Edit"); +Clazz.defineMethod (c$, "clearEdits", +function () { +this.edits.clear (); +}); +Clazz.defineMethod (c$, "getEdit", +function (i) { +if (i >= 0 && i < this.edits.size ()) { +return this.edits.get (i); +}return null; +}, "~N"); +Clazz.overrideMethod (c$, "getDescription", +function () { +return this.description; +}); +Clazz.overrideMethod (c$, "getSize", +function () { +return this.edits.size (); +}); +Clazz.defineMethod (c$, "getAlignment", +function () { +return (this.edits.isEmpty () ? null : this.edits.get (0).al); +}); +Clazz.defineMethod (c$, "appendEdit", +function (command, seqs, position, number, al, performEdit) { +this.appendEdit (command, seqs, position, number, al, performEdit, null); +}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI,~B"); +Clazz.defineMethod (c$, "appendEdit", +function (command, seqs, position, number, al, performEdit, views) { +var edit = Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, command, seqs, position, number, al.getGapCharacter ()); +if (al.getHeight () == seqs.length) { +edit.al = al; +edit.fullAlignmentHeight = true; +}this.addEdit (edit); +if (performEdit) { +jalview.commands.EditCommand.performEdit (edit, views); +}}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI,~B,~A"); +Clazz.defineMethod (c$, "appendEdit", +function (edit, al, performEdit, views) { +if (al.getHeight () == edit.seqs.length) { +edit.al = al; +edit.fullAlignmentHeight = true; +}this.addEdit (edit); +if (performEdit) { +jalview.commands.EditCommand.performEdit (edit, views); +}}, "jalview.commands.EditCommand.Edit,jalview.datamodel.AlignmentI,~B,~A"); +Clazz.defineMethod (c$, "performEdit", +function (commandIndex, views) { +var iterator = this.edits.listIterator (commandIndex); +while (iterator.hasNext ()) { +var edit = iterator.next (); +jalview.commands.EditCommand.performEdit (edit, views); +} +}, "~N,~A"); +c$.performEdit = Clazz.defineMethod (c$, "performEdit", +function (edit, views) { +switch (edit.command) { +case jalview.commands.EditCommand.Action.INSERT_GAP: +jalview.commands.EditCommand.insertGap (edit); +break; +case jalview.commands.EditCommand.Action.DELETE_GAP: +jalview.commands.EditCommand.deleteGap (edit); +break; +case jalview.commands.EditCommand.Action.CUT: +jalview.commands.EditCommand.cut (edit, views); +break; +case jalview.commands.EditCommand.Action.PASTE: +jalview.commands.EditCommand.paste (edit, views); +break; +case jalview.commands.EditCommand.Action.REPLACE: +jalview.commands.EditCommand.replace (edit); +break; +case jalview.commands.EditCommand.Action.INSERT_NUC: +break; +default: +break; +} +}, "jalview.commands.EditCommand.Edit,~A"); +Clazz.overrideMethod (c$, "doCommand", +function (views) { +this.performEdit (0, views); +}, "~A"); +Clazz.overrideMethod (c$, "undoCommand", +function (views) { +var iterator = this.edits.listIterator (this.edits.size ()); +while (iterator.hasPrevious ()) { +var e = iterator.previous (); +switch (e.command) { +case jalview.commands.EditCommand.Action.INSERT_GAP: +jalview.commands.EditCommand.deleteGap (e); +break; +case jalview.commands.EditCommand.Action.DELETE_GAP: +jalview.commands.EditCommand.insertGap (e); +break; +case jalview.commands.EditCommand.Action.CUT: +jalview.commands.EditCommand.paste (e, views); +break; +case jalview.commands.EditCommand.Action.PASTE: +jalview.commands.EditCommand.cut (e, views); +break; +case jalview.commands.EditCommand.Action.REPLACE: +jalview.commands.EditCommand.replace (e); +break; +case jalview.commands.EditCommand.Action.INSERT_NUC: +break; +default: +break; +} +} +}, "~A"); +c$.insertGap = Clazz.defineMethod (c$, "insertGap", +($fz = function (command) { +for (var s = 0; s < command.seqs.length; s++) { +command.seqs[s].insertCharAt (command.position, command.number, command.gapChar); +} +jalview.commands.EditCommand.adjustAnnotations (command, true, false, null); +}, $fz.isPrivate = true, $fz), "jalview.commands.EditCommand.Edit"); +c$.deleteGap = Clazz.defineMethod (c$, "deleteGap", +($fz = function (command) { +for (var s = 0; s < command.seqs.length; s++) { +command.seqs[s].deleteChars (command.position, command.position + command.number); +} +jalview.commands.EditCommand.adjustAnnotations (command, false, false, null); +}, $fz.isPrivate = true, $fz), "jalview.commands.EditCommand.Edit"); +c$.cut = Clazz.defineMethod (c$, "cut", +function (command, views) { +var seqDeleted = false; +command.string = Clazz.newCharArray (command.seqs.length, '\0'); +for (var i = 0; i < command.seqs.length; i++) { +var sequence = command.seqs[i]; +if (sequence.getLength () > command.position) { +command.string[i] = sequence.getSequence (command.position, command.position + command.number); +var oldds = sequence.getDatasetSequence (); +if (command.oldds != null && command.oldds[i] != null) { +sequence.setDatasetSequence (null); +}sequence.deleteChars (command.position, command.position + command.number); +if (command.oldds != null && command.oldds[i] != null) { +sequence.setDatasetSequence (command.oldds[i]); +command.oldds[i] = oldds; +} else { +if (oldds !== sequence.getDatasetSequence () || sequence.getSequenceFeatures () != null) { +if (command.oldds == null) { +command.oldds = new Array (command.seqs.length); +}command.oldds[i] = oldds; +jalview.commands.EditCommand.adjustFeatures (command, i, sequence.findPosition (command.position), sequence.findPosition (command.position + command.number), false); +}}}if (sequence.getLength () < 1) { +command.al.deleteSequence (sequence); +seqDeleted = true; +}} +jalview.commands.EditCommand.adjustAnnotations (command, false, seqDeleted, views); +}, "jalview.commands.EditCommand.Edit,~A"); +c$.paste = Clazz.defineMethod (c$, "paste", +function (command, views) { +var tmp; +var newDSNeeded; +var newDSWasNeeded; +var newstart; +var newend; +var seqWasDeleted = false; +var start = 0; +var end = 0; +for (var i = 0; i < command.seqs.length; i++) { +newDSNeeded = false; +newDSWasNeeded = command.oldds != null && command.oldds[i] != null; +if (command.seqs[i].getLength () < 1) { +if (command.alIndex[i] < command.al.getHeight ()) { +var sequences; +{ +if (!(command.alIndex[i] < 0)) { +sequences.add (command.alIndex[i], command.seqs[i]); +}}} else { +command.al.addSequence (command.seqs[i]); +}seqWasDeleted = true; +}newstart = command.seqs[i].getStart (); +newend = command.seqs[i].getEnd (); +tmp = new StringBuffer (); +tmp.append (command.seqs[i].getSequence ()); +if (command.string != null && command.string[i] != null) { +if (command.position >= tmp.length ()) { +var length = command.position - tmp.length (); +while (length > 0) { +tmp.append (command.gapChar); +length--; +} +}tmp.insert (command.position, command.string[i]); +for (var s = 0; s < command.string[i].length; s++) { +if (jalview.schemes.ResidueProperties.aaIndex[command.string[i][s].charCodeAt (0)] != 23) { +if (!newDSNeeded) { +newDSNeeded = true; +start = command.seqs[i].findPosition (command.position); +end = command.seqs[i].findPosition (command.position + command.number); +}if (command.seqs[i].getStart () == start) { +newstart--; +} else { +newend++; +}}} +command.string[i] = null; +}command.seqs[i].setSequence (tmp.toString ()); +command.seqs[i].setStart (newstart); +command.seqs[i].setEnd (newend); +if (newDSNeeded) { +if (command.seqs[i].getDatasetSequence () != null) { +var ds; +if (newDSWasNeeded) { +ds = command.oldds[i]; +} else { +ds = new jalview.datamodel.Sequence (command.seqs[i].getName (), jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, command.seqs[i].getSequenceAsString ()), command.seqs[i].getStart (), command.seqs[i].getEnd ()); +ds.setDescription (command.seqs[i].getDescription ()); +}if (command.oldds == null) { +command.oldds = new Array (command.seqs.length); +}command.oldds[i] = command.seqs[i].getDatasetSequence (); +command.seqs[i].setDatasetSequence (ds); +}jalview.commands.EditCommand.adjustFeatures (command, i, start, end, true); +}} +jalview.commands.EditCommand.adjustAnnotations (command, true, seqWasDeleted, views); +command.string = null; +}, "jalview.commands.EditCommand.Edit,~A"); +c$.replace = Clazz.defineMethod (c$, "replace", +function (command) { +var tmp; +var oldstring; +var start = command.position; +var end = command.number; +command.number = start + command.string[0].length; +for (var i = 0; i < command.seqs.length; i++) { +var newDSWasNeeded = command.oldds != null && command.oldds[i] != null; +oldstring = command.seqs[i].getSequenceAsString (); +tmp = new StringBuffer (oldstring.substring (0, start)); +tmp.append (command.string[i]); +var nogaprep = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (command.string[i])); +var ipos = command.seqs[i].findPosition (start) - command.seqs[i].getStart (); +tmp.append (oldstring.substring (end)); +command.seqs[i].setSequence (tmp.toString ()); +command.string[i] = oldstring.substring (start, end).toCharArray (); +var nogapold = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (command.string[i])); +if (!nogaprep.toLowerCase ().equals (nogapold.toLowerCase ())) { +if (newDSWasNeeded) { +var oldds = command.seqs[i].getDatasetSequence (); +command.seqs[i].setDatasetSequence (command.oldds[i]); +command.oldds[i] = oldds; +} else { +if (command.oldds == null) { +command.oldds = new Array (command.seqs.length); +}command.oldds[i] = command.seqs[i].getDatasetSequence (); +var newds = new jalview.datamodel.Sequence (command.seqs[i].getDatasetSequence ()); +var fullseq; +var osp = newds.getSequenceAsString (); +fullseq = osp.substring (0, ipos) + nogaprep + osp.substring (ipos + nogaprep.length); +newds.setSequence (fullseq.toUpperCase ()); +command.seqs[i].setDatasetSequence (newds); +}}tmp = null; +oldstring = null; +} +}, "jalview.commands.EditCommand.Edit"); +c$.adjustAnnotations = Clazz.defineMethod (c$, "adjustAnnotations", +function (command, insert, modifyVisibility, views) { +var annotations = null; +if (modifyVisibility && !insert) { +command.deletedAnnotationRows = new java.util.Hashtable (); +}if (command.fullAlignmentHeight) { +annotations = command.al.getAlignmentAnnotation (); +} else { +var aSize = 0; +var tmp; +for (var s = 0; s < command.seqs.length; s++) { +if (modifyVisibility) { +if (!insert) { +tmp = command.seqs[s].getAnnotation (); +if (tmp != null) { +var alen = tmp.length; +for (var aa = 0; aa < tmp.length; aa++) { +if (!command.al.deleteAnnotation (tmp[aa])) { +tmp[aa] = null; +alen--; +}} +command.seqs[s].setAlignmentAnnotation (null); +if (alen != tmp.length) { +var saved = new Array (alen); +for (var aa = 0, aapos = 0; aa < tmp.length; aa++) { +if (tmp[aa] != null) { +saved[aapos++] = tmp[aa]; +tmp[aa] = null; +}} +tmp = saved; +command.deletedAnnotationRows.put (command.seqs[s], saved); +for (var alview = 0; views != null && alview < views.length; alview++) { +if (views[alview] !== command.al) { +var toremove = views[alview].getAlignmentAnnotation (); +if (toremove == null || toremove.length == 0) { +continue; +}for (var aa = 0; aa < toremove.length; aa++) { +if (toremove[aa].sequenceRef === command.seqs[s]) { +views[alview].deleteAnnotation (toremove[aa]); +}} +}} +} else { +command.deletedAnnotationRows.put (command.seqs[s], tmp); +}}} else { +if (command.deletedAnnotationRows != null && command.deletedAnnotationRows.containsKey (command.seqs[s])) { +var revealed = command.deletedAnnotationRows.get (command.seqs[s]); +command.seqs[s].setAlignmentAnnotation (revealed); +if (revealed != null) { +for (var aa = 0; aa < revealed.length; aa++) { +command.al.addAnnotation (revealed[aa]); +} +for (var aa = 0; aa < revealed.length; aa++) { +command.al.setAnnotationIndex (revealed[aa], aa); +} +for (var vnum = 0; views != null && vnum < views.length; vnum++) { +if (views[vnum] !== command.al) { +var avwidth = views[vnum].getWidth () + 1; +for (var a = 0; a < revealed.length; a++) { +var newann = new jalview.datamodel.AlignmentAnnotation (revealed[a]); +command.seqs[s].addAlignmentAnnotation (newann); +newann.padAnnotation (avwidth); +views[vnum].addAnnotation (newann); +views[vnum].setAnnotationIndex (newann, a); +} +}} +}}}continue; +}if (command.seqs[s].getAnnotation () == null) { +continue; +}if (aSize == 0) { +annotations = command.seqs[s].getAnnotation (); +} else { +tmp = new Array (aSize + command.seqs[s].getAnnotation ().length); +System.arraycopy (annotations, 0, tmp, 0, aSize); +System.arraycopy (command.seqs[s].getAnnotation (), 0, tmp, aSize, command.seqs[s].getAnnotation ().length); +annotations = tmp; +}aSize = annotations.length; +} +}if (annotations == null) { +return; +}if (!insert) { +command.deletedAnnotations = new java.util.Hashtable (); +}var aSize; +var temp; +for (var a = 0; a < annotations.length; a++) { +if (annotations[a].autoCalculated || annotations[a].annotations == null) { +continue; +}var tSize = 0; +aSize = annotations[a].annotations.length; +if (insert) { +temp = new Array (aSize + command.number); +if (annotations[a].padGaps) { +for (var aa = 0; aa < temp.length; aa++) { +temp[aa] = new jalview.datamodel.Annotation (command.gapChar + "", null, ' ', 0); +} +}} else { +if (command.position < aSize) { +if (command.position + command.number >= aSize) { +tSize = aSize; +} else { +tSize = aSize - command.number; +}} else { +tSize = aSize; +}if (tSize < 0) { +tSize = aSize; +}temp = new Array (tSize); +}if (insert) { +if (command.position < annotations[a].annotations.length) { +System.arraycopy (annotations[a].annotations, 0, temp, 0, command.position); +if (command.deletedAnnotations != null && command.deletedAnnotations.containsKey (annotations[a].annotationId)) { +var restore = command.deletedAnnotations.get (annotations[a].annotationId); +System.arraycopy (restore, 0, temp, command.position, command.number); +}System.arraycopy (annotations[a].annotations, command.position, temp, command.position + command.number, aSize - command.position); +} else { +if (command.deletedAnnotations != null && command.deletedAnnotations.containsKey (annotations[a].annotationId)) { +var restore = command.deletedAnnotations.get (annotations[a].annotationId); +temp = new Array (annotations[a].annotations.length + restore.length); +System.arraycopy (annotations[a].annotations, 0, temp, 0, annotations[a].annotations.length); +System.arraycopy (restore, 0, temp, annotations[a].annotations.length, restore.length); +} else { +temp = annotations[a].annotations; +}}} else { +if (tSize != aSize || command.position < 2) { +var copylen = Math.min (command.position, annotations[a].annotations.length); +if (copylen > 0) { +System.arraycopy (annotations[a].annotations, 0, temp, 0, copylen); +}var deleted = new Array (command.number); +if (copylen >= command.position) { +copylen = Math.min (command.number, annotations[a].annotations.length - command.position); +if (copylen > 0) { +System.arraycopy (annotations[a].annotations, command.position, deleted, 0, copylen); +}}command.deletedAnnotations.put (annotations[a].annotationId, deleted); +if (annotations[a].annotations.length > command.position + command.number) { +System.arraycopy (annotations[a].annotations, command.position + command.number, temp, command.position, annotations[a].annotations.length - command.position - command.number); +}} else { +var dSize = aSize - command.position; +if (dSize > 0) { +var deleted = new Array (command.number); +System.arraycopy (annotations[a].annotations, command.position, deleted, 0, dSize); +command.deletedAnnotations.put (annotations[a].annotationId, deleted); +tSize = Math.min (annotations[a].annotations.length, command.position); +temp = new Array (tSize); +System.arraycopy (annotations[a].annotations, 0, temp, 0, tSize); +} else { +temp = annotations[a].annotations; +}}}annotations[a].annotations = temp; +} +}, "jalview.commands.EditCommand.Edit,~B,~B,~A"); +c$.adjustFeatures = Clazz.defineMethod (c$, "adjustFeatures", +function (command, index, i, j, insert) { +var seq = command.seqs[index]; +var sequence = seq.getDatasetSequence (); +if (sequence == null) { +sequence = seq; +}if (insert) { +if (command.editedFeatures != null && command.editedFeatures.containsKey (seq)) { +sequence.setSequenceFeatures (command.editedFeatures.get (seq)); +}return; +}var sf = sequence.getSequenceFeatures (); +if (sf == null) { +return; +}var oldsf = new Array (sf.length); +var cSize = j - i; +for (var s = 0; s < sf.length; s++) { +var copy = new jalview.datamodel.SequenceFeature (sf[s]); +oldsf[s] = copy; +if (sf[s].getEnd () < i) { +continue; +}if (sf[s].getBegin () > j) { +sf[s].setBegin (copy.getBegin () - cSize); +sf[s].setEnd (copy.getEnd () - cSize); +continue; +}if (sf[s].getBegin () >= i) { +sf[s].setBegin (i); +}if (sf[s].getEnd () < j) { +sf[s].setEnd (j - 1); +}sf[s].setEnd (sf[s].getEnd () - (cSize)); +if (sf[s].getBegin () > sf[s].getEnd ()) { +sequence.deleteFeature (sf[s]); +}} +if (command.editedFeatures == null) { +command.editedFeatures = new java.util.Hashtable (); +}command.editedFeatures.put (seq, oldsf); +}, "jalview.commands.EditCommand.Edit,~N,~N,~N,~B"); +Clazz.defineMethod (c$, "getEdits", +function () { +return this.edits; +}); +Clazz.defineMethod (c$, "priorState", +function (forUndo) { +var result = new java.util.HashMap (); +if (this.getEdits () == null) { +return result; +}if (forUndo) { +for (var e, $e = this.getEdits ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) { +for (var seq, $seq = 0, $$seq = e.getSequences (); $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { +var ds = seq.getDatasetSequence (); +var preEdit = result.get (ds); +if (preEdit == null) { +preEdit = new jalview.datamodel.Sequence ("", seq.getSequenceAsString ()); +preEdit.setDatasetSequence (ds); +result.put (ds, preEdit); +}} +} +return result; +}var edits = new jalview.util.ReverseListIterator (this.getEdits ()); +while (edits.hasNext ()) { +var oldEdit = edits.next (); +var action = oldEdit.getAction (); +var position = oldEdit.getPosition (); +var number = oldEdit.getNumber (); +var gap = oldEdit.getGapCharacter (); +for (var seq, $seq = 0, $$seq = oldEdit.getSequences (); $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { +var ds = seq.getDatasetSequence (); +var preEdit = result.get (ds); +if (preEdit == null) { +preEdit = new jalview.datamodel.Sequence ("", seq.getSequenceAsString ()); +preEdit.setDatasetSequence (ds); +result.put (ds, preEdit); +}if (ds != null) { +if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { +preEdit.setSequence ( String.instantialize (jalview.util.StringUtils.insertCharAt (preEdit.getSequence (), position, number, gap))); +} else if (action === jalview.commands.EditCommand.Action.INSERT_GAP) { +preEdit.setSequence ( String.instantialize (jalview.util.StringUtils.deleteChars (preEdit.getSequence (), position, position + number))); +} else { +System.err.println ("Can't undo edit action " + action); +}}} +} +return result; +}, "~B"); +Clazz.defineMethod (c$, "getEditIterator", +function (forwards) { +if (forwards) { +return this.getEdits ().iterator (); +} else { +return new jalview.util.ReverseListIterator (this.getEdits ()); +}}, "~B"); +c$.$EditCommand$Edit$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.oldds = null; +this.fullAlignmentHeight = false; +this.deletedAnnotationRows = null; +this.deletedAnnotations = null; +this.editedFeatures = null; +this.al = null; +this.command = null; +this.string = null; +this.seqs = null; +this.alIndex = null; +this.position = 0; +this.number = 0; +this.gapChar = '\0'; +Clazz.instantialize (this, arguments); +}, jalview.commands.EditCommand, "Edit"); +Clazz.makeConstructor (c$, +function (a, b, c, d, e) { +this.command = a; +this.seqs = b; +this.position = c; +this.number = d; +this.gapChar = e; +}, "jalview.commands.EditCommand.Action,~A,~N,~N,~S"); +Clazz.makeConstructor (c$, +function (a, b, c, d, e) { +this.gapChar = e.getGapCharacter (); +this.command = a; +this.seqs = b; +this.position = c; +this.number = d; +this.al = e; +this.alIndex = Clazz.newIntArray (b.length, 0); +for (var f = 0; f < b.length; f++) { +this.alIndex[f] = e.findIndex (b[f]); +} +this.fullAlignmentHeight = (e.getHeight () == b.length); +}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI"); +Clazz.makeConstructor (c$, +function (a, b, c, d, e, f) { +this.command = a; +this.seqs = b; +this.position = c; +this.number = d; +this.al = e; +this.gapChar = e.getGapCharacter (); +this.string = Clazz.newCharArray (b.length, '\0'); +for (var g = 0; g < b.length; g++) { +this.string[g] = f.toCharArray (); +} +this.fullAlignmentHeight = (e.getHeight () == b.length); +}, "jalview.commands.EditCommand.Action,~A,~N,~N,jalview.datamodel.AlignmentI,~S"); +Clazz.defineMethod (c$, "getSequences", +function () { +return this.seqs; +}); +Clazz.defineMethod (c$, "getPosition", +function () { +return this.position; +}); +Clazz.defineMethod (c$, "getAction", +function () { +return this.command; +}); +Clazz.defineMethod (c$, "getNumber", +function () { +return this.number; +}); +Clazz.defineMethod (c$, "getGapCharacter", +function () { +return this.gapChar; +}); +c$ = Clazz.p0p (); +}; +Clazz.pu$h (); +c$ = Clazz.declareType (jalview.commands.EditCommand, "Action", Enum); +Clazz.defineMethod (c$, "getUndoAction", +function () { +switch (this) { +case jalview.commands.EditCommand.Action.INSERT_GAP: +return jalview.commands.EditCommand.Action.DELETE_GAP; +case jalview.commands.EditCommand.Action.CUT: +return jalview.commands.EditCommand.Action.PASTE; +case jalview.commands.EditCommand.Action.DELETE_GAP: +return jalview.commands.EditCommand.Action.INSERT_GAP; +case jalview.commands.EditCommand.Action.INSERT_NUC: +return null; +case jalview.commands.EditCommand.Action.PASTE: +return jalview.commands.EditCommand.Action.CUT; +case jalview.commands.EditCommand.Action.REPLACE: +return jalview.commands.EditCommand.Action.REPLACE; +} +return null; +}); +Clazz.defineEnumConstant (c$, "INSERT_GAP", 0, []); +Clazz.defineEnumConstant (c$, "DELETE_GAP", 1, []); +Clazz.defineEnumConstant (c$, "CUT", 2, []); +Clazz.defineEnumConstant (c$, "PASTE", 3, []); +Clazz.defineEnumConstant (c$, "REPLACE", 4, []); +Clazz.defineEnumConstant (c$, "INSERT_NUC", 5, []); +c$ = Clazz.p0p (); +}); diff --git a/bin/jalview/commands/OrderCommand.js b/bin/jalview/commands/OrderCommand.js index 8939653..c85c70b 100644 --- a/bin/jalview/commands/OrderCommand.js +++ b/bin/jalview/commands/OrderCommand.js @@ -1,38 +1,38 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.CommandI"], "jalview.commands.OrderCommand", ["jalview.analysis.AlignmentSorter"], function () { -c$ = Clazz.decorateAsClass (function () { -this.description = null; -this.seqs = null; -this.seqs2 = null; -this.al = null; -Clazz.instantialize (this, arguments); -}, jalview.commands, "OrderCommand", null, jalview.commands.CommandI); -Clazz.makeConstructor (c$, -function (description, seqs, al) { -this.description = description; -this.seqs = seqs; -this.seqs2 = al.getSequencesArray (); -this.al = al; -this.doCommand (null); -}, "~S,~A,jalview.datamodel.AlignmentI"); -Clazz.overrideMethod (c$, "getDescription", -function () { -return this.description; -}); -Clazz.overrideMethod (c$, "getSize", -function () { -return 1; -}); -Clazz.overrideMethod (c$, "doCommand", -function (views) { -jalview.analysis.AlignmentSorter.setOrder (this.al, this.seqs2); -}, "~A"); -Clazz.overrideMethod (c$, "undoCommand", -function (views) { -jalview.analysis.AlignmentSorter.setOrder (this.al, this.seqs); -}, "~A"); -Clazz.defineMethod (c$, "getSequenceOrder", -function (undo) { -return undo ? this.seqs : this.seqs2; -}, "~B"); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.CommandI"], "jalview.commands.OrderCommand", ["jalview.analysis.AlignmentSorter"], function () { +c$ = Clazz.decorateAsClass (function () { +this.description = null; +this.seqs = null; +this.seqs2 = null; +this.al = null; +Clazz.instantialize (this, arguments); +}, jalview.commands, "OrderCommand", null, jalview.commands.CommandI); +Clazz.makeConstructor (c$, +function (description, seqs, al) { +this.description = description; +this.seqs = seqs; +this.seqs2 = al.getSequencesArray (); +this.al = al; +this.doCommand (null); +}, "~S,~A,jalview.datamodel.AlignmentI"); +Clazz.overrideMethod (c$, "getDescription", +function () { +return this.description; +}); +Clazz.overrideMethod (c$, "getSize", +function () { +return 1; +}); +Clazz.overrideMethod (c$, "doCommand", +function (views) { +jalview.analysis.AlignmentSorter.setOrder (this.al, this.seqs2); +}, "~A"); +Clazz.overrideMethod (c$, "undoCommand", +function (views) { +jalview.analysis.AlignmentSorter.setOrder (this.al, this.seqs); +}, "~A"); +Clazz.defineMethod (c$, "getSequenceOrder", +function (undo) { +return undo ? this.seqs : this.seqs2; +}, "~B"); +}); diff --git a/bin/jalview/commands/RemoveGapColCommand.js b/bin/jalview/commands/RemoveGapColCommand.js index 511279b..a41e76e 100644 --- a/bin/jalview/commands/RemoveGapColCommand.js +++ b/bin/jalview/commands/RemoveGapColCommand.js @@ -1,45 +1,45 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.RemoveGapColCommand", ["jalview.util.Comparison"], function () { -c$ = Clazz.decorateAsClass (function () { -this.columnsDeleted = 0; -Clazz.instantialize (this, arguments); -}, jalview.commands, "RemoveGapColCommand", jalview.commands.EditCommand); -Clazz.makeConstructor (c$, -function (description, seqs, start, end, al) { -Clazz.superConstructor (this, jalview.commands.RemoveGapColCommand, []); -this.description = description; -var j; -var jSize = seqs.length; -var startCol = -1; -var endCol = -1; -this.columnsDeleted = 0; -this.clearEdits (); -var $delete = true; -for (var i = start; i <= end; i++) { -$delete = true; -for (j = 0; j < jSize; j++) { -if (seqs[j].getLength () > i) { -if (!jalview.util.Comparison.isGap (seqs[j].getCharAt (i))) { -if ($delete) { -endCol = i; -}$delete = false; -break; -}}} -if ($delete && startCol == -1) { -startCol = i; -}if (!$delete && startCol > -1) { -this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seqs, startCol - this.columnsDeleted, endCol - startCol, al, false, null); -this.columnsDeleted += (endCol - startCol); -startCol = -1; -endCol = -1; -}} -if ($delete && startCol > -1) { -this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seqs, startCol - this.columnsDeleted, end - startCol + 1, al, false, null); -this.columnsDeleted += (end - startCol + 1); -}this.performEdit (0, null); -}, "~S,~A,~N,~N,jalview.datamodel.AlignmentI"); -Clazz.overrideMethod (c$, "getSize", -function () { -return this.columnsDeleted; -}); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.RemoveGapColCommand", ["jalview.util.Comparison"], function () { +c$ = Clazz.decorateAsClass (function () { +this.columnsDeleted = 0; +Clazz.instantialize (this, arguments); +}, jalview.commands, "RemoveGapColCommand", jalview.commands.EditCommand); +Clazz.makeConstructor (c$, +function (description, seqs, start, end, al) { +Clazz.superConstructor (this, jalview.commands.RemoveGapColCommand, []); +this.description = description; +var j; +var jSize = seqs.length; +var startCol = -1; +var endCol = -1; +this.columnsDeleted = 0; +this.clearEdits (); +var $delete = true; +for (var i = start; i <= end; i++) { +$delete = true; +for (j = 0; j < jSize; j++) { +if (seqs[j].getLength () > i) { +if (!jalview.util.Comparison.isGap (seqs[j].getCharAt (i))) { +if ($delete) { +endCol = i; +}$delete = false; +break; +}}} +if ($delete && startCol == -1) { +startCol = i; +}if (!$delete && startCol > -1) { +this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seqs, startCol - this.columnsDeleted, endCol - startCol, al, false, null); +this.columnsDeleted += (endCol - startCol); +startCol = -1; +endCol = -1; +}} +if ($delete && startCol > -1) { +this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, seqs, startCol - this.columnsDeleted, end - startCol + 1, al, false, null); +this.columnsDeleted += (end - startCol + 1); +}this.performEdit (0, null); +}, "~S,~A,~N,~N,jalview.datamodel.AlignmentI"); +Clazz.overrideMethod (c$, "getSize", +function () { +return this.columnsDeleted; +}); +}); diff --git a/bin/jalview/commands/RemoveGapsCommand.js b/bin/jalview/commands/RemoveGapsCommand.js index 3cc233d..7097db3 100644 --- a/bin/jalview/commands/RemoveGapsCommand.js +++ b/bin/jalview/commands/RemoveGapsCommand.js @@ -1,56 +1,56 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.RemoveGapsCommand", ["jalview.util.Comparison"], function () { -c$ = Clazz.declareType (jalview.commands, "RemoveGapsCommand", jalview.commands.EditCommand); -Clazz.makeConstructor (c$, -function (description, seqs, al) { -Clazz.superConstructor (this, jalview.commands.RemoveGapsCommand, []); -this.description = description; -var width = 0; -for (var i = 0; i < seqs.length; i++) { -if (seqs[i].getLength () > width) { -width = seqs[i].getLength (); -}} -this.findGaps (seqs, 0, width, al); -}, "~S,~A,jalview.datamodel.AlignmentI"); -Clazz.makeConstructor (c$, -function (description, seqs, start, end, al) { -Clazz.superConstructor (this, jalview.commands.RemoveGapsCommand, []); -this.description = description; -this.findGaps (seqs, start, end, al); -}, "~S,~A,~N,~N,jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "findGaps", -function (seqs, start, end, al) { -var startCol = -1; -var endCol = -1; -var deletedCols = 0; -var j; -var jSize; -this.clearEdits (); -var $delete = true; -var sequence; -for (var s = 0; s < seqs.length; s++) { -deletedCols = 0; -startCol = -1; -endCol = -1; -sequence = seqs[s].getSequence (start, end + 1); -jSize = sequence.length; -for (j = 0; j < jSize; j++) { -$delete = true; -if (!jalview.util.Comparison.isGap (sequence[j])) { -if ($delete) { -endCol = j; -}$delete = false; -}if ($delete && startCol == -1) { -startCol = j; -}if (!$delete && startCol > -1) { -this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seqs[s]]), start + startCol - deletedCols, endCol - startCol, al, false, null); -deletedCols += (endCol - startCol); -startCol = -1; -endCol = -1; -}} -if ($delete && startCol > -1) { -this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seqs[s]]), start + startCol - deletedCols, jSize - startCol, al, false, null); -}} -this.performEdit (0, null); -}, "~A,~N,~N,jalview.datamodel.AlignmentI"); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.RemoveGapsCommand", ["jalview.util.Comparison"], function () { +c$ = Clazz.declareType (jalview.commands, "RemoveGapsCommand", jalview.commands.EditCommand); +Clazz.makeConstructor (c$, +function (description, seqs, al) { +Clazz.superConstructor (this, jalview.commands.RemoveGapsCommand, []); +this.description = description; +var width = 0; +for (var i = 0; i < seqs.length; i++) { +if (seqs[i].getLength () > width) { +width = seqs[i].getLength (); +}} +this.findGaps (seqs, 0, width, al); +}, "~S,~A,jalview.datamodel.AlignmentI"); +Clazz.makeConstructor (c$, +function (description, seqs, start, end, al) { +Clazz.superConstructor (this, jalview.commands.RemoveGapsCommand, []); +this.description = description; +this.findGaps (seqs, start, end, al); +}, "~S,~A,~N,~N,jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "findGaps", +function (seqs, start, end, al) { +var startCol = -1; +var endCol = -1; +var deletedCols = 0; +var j; +var jSize; +this.clearEdits (); +var $delete = true; +var sequence; +for (var s = 0; s < seqs.length; s++) { +deletedCols = 0; +startCol = -1; +endCol = -1; +sequence = seqs[s].getSequence (start, end + 1); +jSize = sequence.length; +for (j = 0; j < jSize; j++) { +$delete = true; +if (!jalview.util.Comparison.isGap (sequence[j])) { +if ($delete) { +endCol = j; +}$delete = false; +}if ($delete && startCol == -1) { +startCol = j; +}if (!$delete && startCol > -1) { +this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seqs[s]]), start + startCol - deletedCols, endCol - startCol, al, false, null); +deletedCols += (endCol - startCol); +startCol = -1; +endCol = -1; +}} +if ($delete && startCol > -1) { +this.appendEdit (jalview.commands.EditCommand.Action.DELETE_GAP, Clazz.newArray (-1, [seqs[s]]), start + startCol - deletedCols, jSize - startCol, al, false, null); +}} +this.performEdit (0, null); +}, "~A,~N,~N,jalview.datamodel.AlignmentI"); +}); diff --git a/bin/jalview/commands/SlideSequencesCommand.js b/bin/jalview/commands/SlideSequencesCommand.js index 5a79b67..125c732 100644 --- a/bin/jalview/commands/SlideSequencesCommand.js +++ b/bin/jalview/commands/SlideSequencesCommand.js @@ -1,48 +1,48 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.SlideSequencesCommand", ["jalview.util.Comparison"], function () { -c$ = Clazz.decorateAsClass (function () { -this.gapsInsertedBegin = false; -Clazz.instantialize (this, arguments); -}, jalview.commands, "SlideSequencesCommand", jalview.commands.EditCommand); -Clazz.makeConstructor (c$, -function (description, seqsLeft, seqsRight, slideSize, gapChar) { -Clazz.superConstructor (this, jalview.commands.SlideSequencesCommand, []); -this.description = description; -var lSize = seqsLeft.length; -this.gapsInsertedBegin = false; -var i; -var j; -for (i = 0; i < lSize; i++) { -for (j = 0; j < slideSize; j++) { -if (!jalview.util.Comparison.isGap (seqsLeft[i].getCharAt (j))) { -this.gapsInsertedBegin = true; -break; -}} -} -var e = null; -if (!this.gapsInsertedBegin) { -e = Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.DELETE_GAP, seqsLeft, 0, slideSize, gapChar); -this.setEdit (e); -} else { -e = Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.INSERT_GAP, seqsRight, 0, slideSize, gapChar); -this.setEdit (e); -}jalview.commands.EditCommand.performEdit (e, null); -}, "~S,~A,~A,~N,~S"); -Clazz.defineMethod (c$, "getGapsInsertedBegin", -function () { -return this.gapsInsertedBegin; -}); -Clazz.defineMethod (c$, "appendSlideCommand", -function (command) { -var same = false; -if (command.getEdit (0).seqs.length == this.getEdit (0).seqs.length) { -same = true; -for (var i = 0; i < command.getEdit (0).seqs.length; i++) { -if (this.getEdit (0).seqs[i] !== command.getEdit (0).seqs[i]) { -same = false; -}} -}if (same) { -command.addEdit (this.getEdit (0)); -}return same; -}, "jalview.commands.SlideSequencesCommand"); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.SlideSequencesCommand", ["jalview.util.Comparison"], function () { +c$ = Clazz.decorateAsClass (function () { +this.gapsInsertedBegin = false; +Clazz.instantialize (this, arguments); +}, jalview.commands, "SlideSequencesCommand", jalview.commands.EditCommand); +Clazz.makeConstructor (c$, +function (description, seqsLeft, seqsRight, slideSize, gapChar) { +Clazz.superConstructor (this, jalview.commands.SlideSequencesCommand, []); +this.description = description; +var lSize = seqsLeft.length; +this.gapsInsertedBegin = false; +var i; +var j; +for (i = 0; i < lSize; i++) { +for (j = 0; j < slideSize; j++) { +if (!jalview.util.Comparison.isGap (seqsLeft[i].getCharAt (j))) { +this.gapsInsertedBegin = true; +break; +}} +} +var e = null; +if (!this.gapsInsertedBegin) { +e = Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.DELETE_GAP, seqsLeft, 0, slideSize, gapChar); +this.setEdit (e); +} else { +e = Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.INSERT_GAP, seqsRight, 0, slideSize, gapChar); +this.setEdit (e); +}jalview.commands.EditCommand.performEdit (e, null); +}, "~S,~A,~A,~N,~S"); +Clazz.defineMethod (c$, "getGapsInsertedBegin", +function () { +return this.gapsInsertedBegin; +}); +Clazz.defineMethod (c$, "appendSlideCommand", +function (command) { +var same = false; +if (command.getEdit (0).seqs.length == this.getEdit (0).seqs.length) { +same = true; +for (var i = 0; i < command.getEdit (0).seqs.length; i++) { +if (this.getEdit (0).seqs[i] !== command.getEdit (0).seqs[i]) { +same = false; +}} +}if (same) { +command.addEdit (this.getEdit (0)); +}return same; +}, "jalview.commands.SlideSequencesCommand"); +}); diff --git a/bin/jalview/commands/TrimRegionCommand.js b/bin/jalview/commands/TrimRegionCommand.js index 2732ca0..ff06747 100644 --- a/bin/jalview/commands/TrimRegionCommand.js +++ b/bin/jalview/commands/TrimRegionCommand.js @@ -1,91 +1,91 @@ -Clazz.declarePackage ("jalview.commands"); -Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.TrimRegionCommand", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.colSel = null; -this.start = null; -this.shiftList = null; -this.selectionGroup = null; -this.deletedHiddenColumns = null; -this.columnsDeleted = 0; -Clazz.instantialize (this, arguments); -}, jalview.commands, "TrimRegionCommand", jalview.commands.EditCommand); -Clazz.makeConstructor (c$, -function (description, command, seqs, column, al, colSel, selectedRegion) { -Clazz.superConstructor (this, jalview.commands.TrimRegionCommand, []); -this.description = description; -this.selectionGroup = selectedRegion; -this.colSel = colSel; -if (command.equalsIgnoreCase (jalview.commands.TrimRegionCommand.TRIM_LEFT)) { -if (column == 0) { -return; -}this.columnsDeleted = column; -this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.CUT, seqs, 0, column, al)); -} else if (command.equalsIgnoreCase (jalview.commands.TrimRegionCommand.TRIM_RIGHT)) { -var width = al.getWidth () - column - 1; -if (width < 2) { -return; -}this.columnsDeleted = width - 1; -this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.CUT, seqs, column + 1, width, al)); -}var i; -var isize = this.getEdit (0).seqs.length; -this.start = Clazz.newIntArray (isize, 0); -for (i = 0; i < isize; i++) { -this.start[i] = this.getEdit (0).seqs[i].getStart (); -} -this.performEdit (0, null); -}, "~S,~S,~A,~N,jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "cut", -function (command) { -var column; -var j; -var jSize = command.seqs.length; -for (j = 0; j < jSize; j++) { -if (command.position == 0) { -column = command.seqs[j].findPosition (command.number); -command.seqs[j].setStart (column); -} else { -column = command.seqs[j].findPosition (command.position) - 1; -command.seqs[j].setEnd (column); -}} -Clazz.superCall (this, jalview.commands.TrimRegionCommand, "cut", [command, null]); -if (command.position == 0) { -this.deletedHiddenColumns = this.colSel.compensateForEdit (0, command.number); -if (this.selectionGroup != null) { -this.selectionGroup.adjustForRemoveLeft (command.number); -}} else { -this.deletedHiddenColumns = this.colSel.compensateForEdit (command.position, command.number); -if (this.selectionGroup != null) { -this.selectionGroup.adjustForRemoveRight (command.position); -}}}, "jalview.commands.EditCommand.Edit"); -Clazz.defineMethod (c$, "paste", -function (command) { -Clazz.superCall (this, jalview.commands.TrimRegionCommand, "paste", [command, null]); -var column; -var j; -var jSize = command.seqs.length; -for (j = 0; j < jSize; j++) { -if (command.position == 0) { -command.seqs[j].setStart (this.start[j]); -} else { -column = command.seqs[j].findPosition (command.number + command.position) - 1; -command.seqs[j].setEnd (column); -}} -if (command.position == 0) { -this.colSel.compensateForEdit (0, -command.number); -if (this.selectionGroup != null) { -this.selectionGroup.adjustForRemoveLeft (-command.number); -}}if (this.deletedHiddenColumns != null) { -var region; -for (var i = 0; i < this.deletedHiddenColumns.size (); i++) { -region = this.deletedHiddenColumns.get (i); -this.colSel.hideColumns (region[0], region[1]); -} -}}, "jalview.commands.EditCommand.Edit"); -Clazz.overrideMethod (c$, "getSize", -function () { -return this.columnsDeleted; -}); -Clazz.defineStatics (c$, -"TRIM_LEFT", "TrimLeft", -"TRIM_RIGHT", "TrimRight"); -}); +Clazz.declarePackage ("jalview.commands"); +Clazz.load (["jalview.commands.EditCommand"], "jalview.commands.TrimRegionCommand", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.colSel = null; +this.start = null; +this.shiftList = null; +this.selectionGroup = null; +this.deletedHiddenColumns = null; +this.columnsDeleted = 0; +Clazz.instantialize (this, arguments); +}, jalview.commands, "TrimRegionCommand", jalview.commands.EditCommand); +Clazz.makeConstructor (c$, +function (description, command, seqs, column, al, colSel, selectedRegion) { +Clazz.superConstructor (this, jalview.commands.TrimRegionCommand, []); +this.description = description; +this.selectionGroup = selectedRegion; +this.colSel = colSel; +if (command.equalsIgnoreCase (jalview.commands.TrimRegionCommand.TRIM_LEFT)) { +if (column == 0) { +return; +}this.columnsDeleted = column; +this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.CUT, seqs, 0, column, al)); +} else if (command.equalsIgnoreCase (jalview.commands.TrimRegionCommand.TRIM_RIGHT)) { +var width = al.getWidth () - column - 1; +if (width < 2) { +return; +}this.columnsDeleted = width - 1; +this.setEdit (Clazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, jalview.commands.EditCommand.Action.CUT, seqs, column + 1, width, al)); +}var i; +var isize = this.getEdit (0).seqs.length; +this.start = Clazz.newIntArray (isize, 0); +for (i = 0; i < isize; i++) { +this.start[i] = this.getEdit (0).seqs[i].getStart (); +} +this.performEdit (0, null); +}, "~S,~S,~A,~N,jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "cut", +function (command) { +var column; +var j; +var jSize = command.seqs.length; +for (j = 0; j < jSize; j++) { +if (command.position == 0) { +column = command.seqs[j].findPosition (command.number); +command.seqs[j].setStart (column); +} else { +column = command.seqs[j].findPosition (command.position) - 1; +command.seqs[j].setEnd (column); +}} +Clazz.superCall (this, jalview.commands.TrimRegionCommand, "cut", [command, null]); +if (command.position == 0) { +this.deletedHiddenColumns = this.colSel.compensateForEdit (0, command.number); +if (this.selectionGroup != null) { +this.selectionGroup.adjustForRemoveLeft (command.number); +}} else { +this.deletedHiddenColumns = this.colSel.compensateForEdit (command.position, command.number); +if (this.selectionGroup != null) { +this.selectionGroup.adjustForRemoveRight (command.position); +}}}, "jalview.commands.EditCommand.Edit"); +Clazz.defineMethod (c$, "paste", +function (command) { +Clazz.superCall (this, jalview.commands.TrimRegionCommand, "paste", [command, null]); +var column; +var j; +var jSize = command.seqs.length; +for (j = 0; j < jSize; j++) { +if (command.position == 0) { +command.seqs[j].setStart (this.start[j]); +} else { +column = command.seqs[j].findPosition (command.number + command.position) - 1; +command.seqs[j].setEnd (column); +}} +if (command.position == 0) { +this.colSel.compensateForEdit (0, -command.number); +if (this.selectionGroup != null) { +this.selectionGroup.adjustForRemoveLeft (-command.number); +}}if (this.deletedHiddenColumns != null) { +var region; +for (var i = 0; i < this.deletedHiddenColumns.size (); i++) { +region = this.deletedHiddenColumns.get (i); +this.colSel.hideColumns (region[0], region[1]); +} +}}, "jalview.commands.EditCommand.Edit"); +Clazz.overrideMethod (c$, "getSize", +function () { +return this.columnsDeleted; +}); +Clazz.defineStatics (c$, +"TRIM_LEFT", "TrimLeft", +"TRIM_RIGHT", "TrimRight"); +}); diff --git a/bin/jalview/controller/AlignViewController.js b/bin/jalview/controller/AlignViewController.js index c773729..966223d 100644 --- a/bin/jalview/controller/AlignViewController.js +++ b/bin/jalview/controller/AlignViewController.js @@ -1,219 +1,219 @@ -Clazz.declarePackage ("jalview.controller"); -Clazz.load (["jalview.api.AlignViewControllerI"], "jalview.controller.AlignViewController", ["jalview.analysis.AlignmentSorter", "$.Grouping", "jalview.commands.OrderCommand", "jalview.datamodel.ColumnSelection", "jalview.io.FeaturesFile", "jalview.util.MessageManager", "java.awt.Color", "java.util.ArrayList", "$.BitSet"], function () { -c$ = Clazz.decorateAsClass (function () { -this.viewport = null; -this.alignPanel = null; -this.avcg = null; -Clazz.instantialize (this, arguments); -}, jalview.controller, "AlignViewController", null, jalview.api.AlignViewControllerI); -Clazz.overrideMethod (c$, "finalize", -function () { -this.viewport = null; -this.alignPanel = null; -this.avcg = null; -}); -Clazz.makeConstructor (c$, -function (alignFrame, viewport, alignPanel) { -this.avcg = alignFrame; -this.viewport = viewport; -this.alignPanel = alignPanel; -}, "jalview.api.AlignViewControllerGuiI,jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); -Clazz.overrideMethod (c$, "setViewportAndAlignmentPanel", -function (viewport, alignPanel) { -this.alignPanel = alignPanel; -this.viewport = viewport; -}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); -Clazz.overrideMethod (c$, "makeGroupsFromSelection", -function () { -var sg = this.viewport.getSelectionGroup (); -var cs = this.viewport.getColumnSelection (); -var gps = null; -if (sg != null && (cs == null || cs.getSelected () == null || cs.size () == 0)) { -gps = jalview.analysis.Grouping.makeGroupsFrom (this.viewport.getSequenceSelection (), this.viewport.getAlignmentView (true).getSequenceStrings (this.viewport.getGapCharacter ()), this.viewport.getAlignment ().getGroups ()); -} else { -if (cs != null) { -gps = jalview.analysis.Grouping.makeGroupsFromCols ((sg == null) ? this.viewport.getAlignment ().getSequencesArray () : sg.getSequences ().toArray ( new Array (0)), cs, this.viewport.getAlignment ().getGroups ()); -}}if (gps != null) { -this.viewport.getAlignment ().deleteAllGroups (); -this.viewport.clearSequenceColours (); -this.viewport.setSelectionGroup (null); -for (var g = 0; g < gps.length; g++) { -gps[g].setshowSequenceLogo (this.viewport.isShowSequenceLogo ()); -this.viewport.getAlignment ().addGroup (gps[g]); -var col = new java.awt.Color (Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255)); -col = col.brighter (); -for (var sq, $sq = gps[g].getSequences (null).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -this.viewport.setSequenceColour (sq, col); -} -} -return true; -}return false; -}); -Clazz.overrideMethod (c$, "createGroup", -function () { -var sg = this.viewport.getSelectionGroup (); -if (sg != null) { -this.viewport.getAlignment ().addGroup (sg); -return true; -}return false; -}); -Clazz.overrideMethod (c$, "unGroup", -function () { -var sg = this.viewport.getSelectionGroup (); -if (sg != null) { -this.viewport.getAlignment ().deleteGroup (sg); -return true; -}return false; -}); -Clazz.overrideMethod (c$, "deleteGroups", -function () { -if (this.viewport.getAlignment ().getGroups () != null && this.viewport.getAlignment ().getGroups ().size () > 0) { -this.viewport.getAlignment ().deleteAllGroups (); -this.viewport.clearSequenceColours (); -this.viewport.setSelectionGroup (null); -return true; -}return false; -}); -Clazz.overrideMethod (c$, "markColumnsContainingFeatures", -function (invert, extendCurrent, toggle, featureType) { -var bs = new java.util.BitSet (); -var alw; -var alStart; -var sqcol = (this.viewport.getSelectionGroup () == null ? this.viewport.getAlignment () : this.viewport.getSelectionGroup ()); -alStart = sqcol.getStartRes (); -alw = sqcol.getEndRes () + 1; -var seqs = sqcol.getSequences (); -var nseq = 0; -for (var sq, $sq = seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -var tfeat = 0; -if (sq != null) { -var sf = sq.getSequenceFeatures (); -if (sf != null) { -var ist = sq.findIndex (sq.getStart ()); -var iend = sq.findIndex (sq.getEnd ()); -if (iend < alStart || ist > alw) { -continue; -}for (var sfpos, $sfpos = 0, $$sfpos = sf; $sfpos < $$sfpos.length && ((sfpos = $$sfpos[$sfpos]) || true); $sfpos++) { -if (sfpos != null && (featureType.equals (sfpos.getType ()))) { -tfeat++; -var i = sq.findIndex (sfpos.getBegin ()); -var j = sq.findIndex (sfpos.getEnd ()); -if (j < alStart || i > alw) { -continue; -}if (i < alStart) { -i = alStart; -}if (i < ist) { -i = ist; -}if (j > alw) { -j = alw; -}for (; i <= j; i++) { -bs.set (i - 1); -} -}} -}if (tfeat > 0) { -nseq++; -}}} -var cs = this.viewport.getColumnSelection (); -if (bs.cardinality () > 0 || invert) { -if (cs == null) { -cs = new jalview.datamodel.ColumnSelection (); -} else { -if (!extendCurrent) { -cs.clear (); -}}if (invert) { -for (var i = bs.nextClearBit (alStart), ibs = bs.nextSetBit (alStart); i >= alStart && i < (alw); ) { -if (ibs < 0 || i < ibs) { -if (toggle && cs.contains (i)) { -cs.removeElement (i++); -} else { -cs.addElement (i++); -}} else { -i = bs.nextClearBit (ibs); -ibs = bs.nextSetBit (i); -}} -} else { -for (var i = bs.nextSetBit (alStart); i >= alStart; i = bs.nextSetBit (i + 1)) { -if (toggle && cs.contains (i)) { -cs.removeElement (i); -} else { -cs.addElement (i); -}} -}this.viewport.setColumnSelection (cs); -this.alignPanel.paintAlignment (true); -this.avcg.setStatus (jalview.util.MessageManager.formatMessage ("label.view_controller_toggled_marked", Clazz.newArray (-1, [(toggle ? jalview.util.MessageManager.getString ("label.toggled") : jalview.util.MessageManager.getString ("label.marked")), (invert ? (Integer.$valueOf ((alw - alStart) - bs.cardinality ()).toString ()) : (Integer.$valueOf (bs.cardinality ()).toString ())), featureType, Integer.$valueOf (nseq).toString ()]))); -return true; -} else { -this.avcg.setStatus (jalview.util.MessageManager.formatMessage ("label.no_feature_of_type_found", Clazz.newArray (-1, [featureType]))); -if (!extendCurrent && cs != null) { -cs.clear (); -this.alignPanel.paintAlignment (true); -}return false; -}}, "~B,~B,~B,~S"); -Clazz.overrideMethod (c$, "sortAlignmentByFeatureDensity", -function (typ) { -this.sortBy (typ, "Sort by Density", jalview.analysis.AlignmentSorter.FEATURE_DENSITY); -}, "~A"); -Clazz.defineMethod (c$, "sortBy", -function (typ, methodText, method) { -var fr = this.alignPanel.getFeatureRenderer (); -if (typ == null) { -typ = fr == null ? null : fr.getDisplayedFeatureTypes (); -}var gps = null; -gps = fr == null ? null : fr.getDisplayedFeatureGroups (); -if (typ != null) { -var types = new java.util.ArrayList (); -for (var i = 0; i < typ.length; i++) { -if (typ[i] != null) { -types.add (typ[i]); -}typ = new Array (types.size ()); -types.toArray (typ); -} -}if (gps != null) { -var grps = new java.util.ArrayList (); -for (var i = 0; i < gps.length; i++) { -if (gps[i] != null) { -grps.add (gps[i]); -}} -gps = new Array (grps.size ()); -grps.toArray (gps); -}var al = this.viewport.getAlignment (); -var start; -var stop; -var sg = this.viewport.getSelectionGroup (); -if (sg != null) { -start = sg.getStartRes (); -stop = sg.getEndRes (); -} else { -start = 0; -stop = al.getWidth (); -}var oldOrder = al.getSequencesArray (); -jalview.analysis.AlignmentSorter.sortByFeature (typ, gps, start, stop, al, method); -this.avcg.addHistoryItem ( new jalview.commands.OrderCommand (methodText, oldOrder, this.viewport.getAlignment ())); -this.alignPanel.paintAlignment (true); -}, "~A,~S,~S"); -Clazz.overrideMethod (c$, "sortAlignmentByFeatureScore", -function (typ) { -this.sortBy (typ, "Sort by Feature Score", jalview.analysis.AlignmentSorter.FEATURE_SCORE); -}, "~A"); -Clazz.overrideMethod (c$, "parseFeaturesFile", -function (file, protocol, relaxedIdMatching) { -var featuresFile = false; -try { -featuresFile = new jalview.io.FeaturesFile (file, protocol).parse (this.viewport.getAlignment ().getDataset (), this.alignPanel.getFeatureRenderer ().getFeatureColours (), false, relaxedIdMatching); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -if (featuresFile) { -this.avcg.refreshFeatureUI (true); -if (this.alignPanel.getFeatureRenderer () != null) { -this.alignPanel.getFeatureRenderer ().findAllFeatures (true); -}if (this.avcg.getFeatureSettingsUI () != null) { -this.avcg.getFeatureSettingsUI ().discoverAllFeatureData (); -}this.alignPanel.paintAlignment (true); -}return featuresFile; -}, "~S,~S,~B"); -}); +Clazz.declarePackage ("jalview.controller"); +Clazz.load (["jalview.api.AlignViewControllerI"], "jalview.controller.AlignViewController", ["jalview.analysis.AlignmentSorter", "$.Grouping", "jalview.commands.OrderCommand", "jalview.datamodel.ColumnSelection", "jalview.io.FeaturesFile", "jalview.util.MessageManager", "java.awt.Color", "java.util.ArrayList", "$.BitSet"], function () { +c$ = Clazz.decorateAsClass (function () { +this.viewport = null; +this.alignPanel = null; +this.avcg = null; +Clazz.instantialize (this, arguments); +}, jalview.controller, "AlignViewController", null, jalview.api.AlignViewControllerI); +Clazz.overrideMethod (c$, "finalize", +function () { +this.viewport = null; +this.alignPanel = null; +this.avcg = null; +}); +Clazz.makeConstructor (c$, +function (alignFrame, viewport, alignPanel) { +this.avcg = alignFrame; +this.viewport = viewport; +this.alignPanel = alignPanel; +}, "jalview.api.AlignViewControllerGuiI,jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); +Clazz.overrideMethod (c$, "setViewportAndAlignmentPanel", +function (viewport, alignPanel) { +this.alignPanel = alignPanel; +this.viewport = viewport; +}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); +Clazz.overrideMethod (c$, "makeGroupsFromSelection", +function () { +var sg = this.viewport.getSelectionGroup (); +var cs = this.viewport.getColumnSelection (); +var gps = null; +if (sg != null && (cs == null || cs.getSelected () == null || cs.size () == 0)) { +gps = jalview.analysis.Grouping.makeGroupsFrom (this.viewport.getSequenceSelection (), this.viewport.getAlignmentView (true).getSequenceStrings (this.viewport.getGapCharacter ()), this.viewport.getAlignment ().getGroups ()); +} else { +if (cs != null) { +gps = jalview.analysis.Grouping.makeGroupsFromCols ((sg == null) ? this.viewport.getAlignment ().getSequencesArray () : sg.getSequences ().toArray ( new Array (0)), cs, this.viewport.getAlignment ().getGroups ()); +}}if (gps != null) { +this.viewport.getAlignment ().deleteAllGroups (); +this.viewport.clearSequenceColours (); +this.viewport.setSelectionGroup (null); +for (var g = 0; g < gps.length; g++) { +gps[g].setshowSequenceLogo (this.viewport.isShowSequenceLogo ()); +this.viewport.getAlignment ().addGroup (gps[g]); +var col = new java.awt.Color (Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255), Clazz.doubleToInt (Math.random () * 255)); +col = col.brighter (); +for (var sq, $sq = gps[g].getSequences (null).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +this.viewport.setSequenceColour (sq, col); +} +} +return true; +}return false; +}); +Clazz.overrideMethod (c$, "createGroup", +function () { +var sg = this.viewport.getSelectionGroup (); +if (sg != null) { +this.viewport.getAlignment ().addGroup (sg); +return true; +}return false; +}); +Clazz.overrideMethod (c$, "unGroup", +function () { +var sg = this.viewport.getSelectionGroup (); +if (sg != null) { +this.viewport.getAlignment ().deleteGroup (sg); +return true; +}return false; +}); +Clazz.overrideMethod (c$, "deleteGroups", +function () { +if (this.viewport.getAlignment ().getGroups () != null && this.viewport.getAlignment ().getGroups ().size () > 0) { +this.viewport.getAlignment ().deleteAllGroups (); +this.viewport.clearSequenceColours (); +this.viewport.setSelectionGroup (null); +return true; +}return false; +}); +Clazz.overrideMethod (c$, "markColumnsContainingFeatures", +function (invert, extendCurrent, toggle, featureType) { +var bs = new java.util.BitSet (); +var alw; +var alStart; +var sqcol = (this.viewport.getSelectionGroup () == null ? this.viewport.getAlignment () : this.viewport.getSelectionGroup ()); +alStart = sqcol.getStartRes (); +alw = sqcol.getEndRes () + 1; +var seqs = sqcol.getSequences (); +var nseq = 0; +for (var sq, $sq = seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +var tfeat = 0; +if (sq != null) { +var sf = sq.getSequenceFeatures (); +if (sf != null) { +var ist = sq.findIndex (sq.getStart ()); +var iend = sq.findIndex (sq.getEnd ()); +if (iend < alStart || ist > alw) { +continue; +}for (var sfpos, $sfpos = 0, $$sfpos = sf; $sfpos < $$sfpos.length && ((sfpos = $$sfpos[$sfpos]) || true); $sfpos++) { +if (sfpos != null && (featureType.equals (sfpos.getType ()))) { +tfeat++; +var i = sq.findIndex (sfpos.getBegin ()); +var j = sq.findIndex (sfpos.getEnd ()); +if (j < alStart || i > alw) { +continue; +}if (i < alStart) { +i = alStart; +}if (i < ist) { +i = ist; +}if (j > alw) { +j = alw; +}for (; i <= j; i++) { +bs.set (i - 1); +} +}} +}if (tfeat > 0) { +nseq++; +}}} +var cs = this.viewport.getColumnSelection (); +if (bs.cardinality () > 0 || invert) { +if (cs == null) { +cs = new jalview.datamodel.ColumnSelection (); +} else { +if (!extendCurrent) { +cs.clear (); +}}if (invert) { +for (var i = bs.nextClearBit (alStart), ibs = bs.nextSetBit (alStart); i >= alStart && i < (alw); ) { +if (ibs < 0 || i < ibs) { +if (toggle && cs.contains (i)) { +cs.removeElement (i++); +} else { +cs.addElement (i++); +}} else { +i = bs.nextClearBit (ibs); +ibs = bs.nextSetBit (i); +}} +} else { +for (var i = bs.nextSetBit (alStart); i >= alStart; i = bs.nextSetBit (i + 1)) { +if (toggle && cs.contains (i)) { +cs.removeElement (i); +} else { +cs.addElement (i); +}} +}this.viewport.setColumnSelection (cs); +this.alignPanel.paintAlignment (true); +this.avcg.setStatus (jalview.util.MessageManager.formatMessage ("label.view_controller_toggled_marked", Clazz.newArray (-1, [(toggle ? jalview.util.MessageManager.getString ("label.toggled") : jalview.util.MessageManager.getString ("label.marked")), (invert ? (Integer.$valueOf ((alw - alStart) - bs.cardinality ()).toString ()) : (Integer.$valueOf (bs.cardinality ()).toString ())), featureType, Integer.$valueOf (nseq).toString ()]))); +return true; +} else { +this.avcg.setStatus (jalview.util.MessageManager.formatMessage ("label.no_feature_of_type_found", Clazz.newArray (-1, [featureType]))); +if (!extendCurrent && cs != null) { +cs.clear (); +this.alignPanel.paintAlignment (true); +}return false; +}}, "~B,~B,~B,~S"); +Clazz.overrideMethod (c$, "sortAlignmentByFeatureDensity", +function (typ) { +this.sortBy (typ, "Sort by Density", jalview.analysis.AlignmentSorter.FEATURE_DENSITY); +}, "~A"); +Clazz.defineMethod (c$, "sortBy", +function (typ, methodText, method) { +var fr = this.alignPanel.getFeatureRenderer (); +if (typ == null) { +typ = fr == null ? null : fr.getDisplayedFeatureTypes (); +}var gps = null; +gps = fr == null ? null : fr.getDisplayedFeatureGroups (); +if (typ != null) { +var types = new java.util.ArrayList (); +for (var i = 0; i < typ.length; i++) { +if (typ[i] != null) { +types.add (typ[i]); +}typ = new Array (types.size ()); +types.toArray (typ); +} +}if (gps != null) { +var grps = new java.util.ArrayList (); +for (var i = 0; i < gps.length; i++) { +if (gps[i] != null) { +grps.add (gps[i]); +}} +gps = new Array (grps.size ()); +grps.toArray (gps); +}var al = this.viewport.getAlignment (); +var start; +var stop; +var sg = this.viewport.getSelectionGroup (); +if (sg != null) { +start = sg.getStartRes (); +stop = sg.getEndRes (); +} else { +start = 0; +stop = al.getWidth (); +}var oldOrder = al.getSequencesArray (); +jalview.analysis.AlignmentSorter.sortByFeature (typ, gps, start, stop, al, method); +this.avcg.addHistoryItem ( new jalview.commands.OrderCommand (methodText, oldOrder, this.viewport.getAlignment ())); +this.alignPanel.paintAlignment (true); +}, "~A,~S,~S"); +Clazz.overrideMethod (c$, "sortAlignmentByFeatureScore", +function (typ) { +this.sortBy (typ, "Sort by Feature Score", jalview.analysis.AlignmentSorter.FEATURE_SCORE); +}, "~A"); +Clazz.overrideMethod (c$, "parseFeaturesFile", +function (file, protocol, relaxedIdMatching) { +var featuresFile = false; +try { +featuresFile = new jalview.io.FeaturesFile (file, protocol).parse (this.viewport.getAlignment ().getDataset (), this.alignPanel.getFeatureRenderer ().getFeatureColours (), false, relaxedIdMatching); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +if (featuresFile) { +this.avcg.refreshFeatureUI (true); +if (this.alignPanel.getFeatureRenderer () != null) { +this.alignPanel.getFeatureRenderer ().findAllFeatures (true); +}if (this.avcg.getFeatureSettingsUI () != null) { +this.avcg.getFeatureSettingsUI ().discoverAllFeatureData (); +}this.alignPanel.paintAlignment (true); +}return featuresFile; +}, "~S,~S,~B"); +}); diff --git a/bin/jalview/controller/FeatureSettingsController.js b/bin/jalview/controller/FeatureSettingsController.js index 8a9666e..1a3acab 100644 --- a/bin/jalview/controller/FeatureSettingsController.js +++ b/bin/jalview/controller/FeatureSettingsController.js @@ -1,7 +1,7 @@ -Clazz.declarePackage ("jalview.controller"); -c$ = Clazz.decorateAsClass (function () { -this.settingUI = null; -this.fr = null; -this.fsettings = null; -Clazz.instantialize (this, arguments); -}, jalview.controller, "FeatureSettingsController"); +Clazz.declarePackage ("jalview.controller"); +c$ = Clazz.decorateAsClass (function () { +this.settingUI = null; +this.fr = null; +this.fsettings = null; +Clazz.instantialize (this, arguments); +}, jalview.controller, "FeatureSettingsController"); diff --git a/bin/jalview/controller/FeatureSettingsControllerGuiI.js b/bin/jalview/controller/FeatureSettingsControllerGuiI.js index c092514..ec98397 100644 --- a/bin/jalview/controller/FeatureSettingsControllerGuiI.js +++ b/bin/jalview/controller/FeatureSettingsControllerGuiI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.controller"); -Clazz.declareInterface (jalview.controller, "FeatureSettingsControllerGuiI"); +Clazz.declarePackage ("jalview.controller"); +Clazz.declareInterface (jalview.controller, "FeatureSettingsControllerGuiI"); diff --git a/bin/jalview/datamodel/ASequence.js b/bin/jalview/datamodel/ASequence.js index 76a4493..1c80545 100644 --- a/bin/jalview/datamodel/ASequence.js +++ b/bin/jalview/datamodel/ASequence.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.ASequenceI"], "jalview.datamodel.ASequence", null, function () { -c$ = Clazz.declareType (jalview.datamodel, "ASequence", null, jalview.datamodel.ASequenceI); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.ASequenceI"], "jalview.datamodel.ASequence", null, function () { +c$ = Clazz.declareType (jalview.datamodel, "ASequence", null, jalview.datamodel.ASequenceI); +}); diff --git a/bin/jalview/datamodel/ASequenceI.js b/bin/jalview/datamodel/ASequenceI.js index 3d17914..91b3544 100644 --- a/bin/jalview/datamodel/ASequenceI.js +++ b/bin/jalview/datamodel/ASequenceI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.declareInterface (jalview.datamodel, "ASequenceI"); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.declareInterface (jalview.datamodel, "ASequenceI"); diff --git a/bin/jalview/datamodel/AlignedCodon.js b/bin/jalview/datamodel/AlignedCodon.js index 3b95647..d02ac8a 100644 --- a/bin/jalview/datamodel/AlignedCodon.js +++ b/bin/jalview/datamodel/AlignedCodon.js @@ -1,42 +1,42 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.AlignedCodon", ["java.lang.IllegalArgumentException", "$.StringBuilder"], function () { -c$ = Clazz.decorateAsClass (function () { -this.pos1 = 0; -this.pos2 = 0; -this.pos3 = 0; -this.product = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "AlignedCodon"); -Clazz.makeConstructor (c$, -function (i, j, k) { -this.construct (i, j, k, null); -}, "~N,~N,~N"); -Clazz.makeConstructor (c$, -function (i, j, k, prod) { -this.pos1 = i; -this.pos2 = j; -this.pos3 = k; -this.product = prod; -}, "~N,~N,~N,~S"); -Clazz.defineMethod (c$, "getBaseColumn", -function (base) { -if (base < 1 || base > 3) { -throw new IllegalArgumentException (Integer.toString (base)); -}return base == 1 ? this.pos1 : (base == 2 ? this.pos2 : this.pos3); -}, "~N"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (o == null) { -return true; -}if (!(Clazz.instanceOf (o, jalview.datamodel.AlignedCodon))) { -return false; -}var ac = o; -return (this.pos1 == ac.pos1 && this.pos2 == ac.pos2 && this.pos3 == ac.pos3); -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -var sb = new StringBuilder (); -sb.append ("[").append (this.pos1).append (", ").append (this.pos2).append (", ").append (this.pos3).append ("]"); -return sb.toString (); -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.AlignedCodon", ["java.lang.IllegalArgumentException", "$.StringBuilder"], function () { +c$ = Clazz.decorateAsClass (function () { +this.pos1 = 0; +this.pos2 = 0; +this.pos3 = 0; +this.product = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "AlignedCodon"); +Clazz.makeConstructor (c$, +function (i, j, k) { +this.construct (i, j, k, null); +}, "~N,~N,~N"); +Clazz.makeConstructor (c$, +function (i, j, k, prod) { +this.pos1 = i; +this.pos2 = j; +this.pos3 = k; +this.product = prod; +}, "~N,~N,~N,~S"); +Clazz.defineMethod (c$, "getBaseColumn", +function (base) { +if (base < 1 || base > 3) { +throw new IllegalArgumentException (Integer.toString (base)); +}return base == 1 ? this.pos1 : (base == 2 ? this.pos2 : this.pos3); +}, "~N"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (o == null) { +return true; +}if (!(Clazz.instanceOf (o, jalview.datamodel.AlignedCodon))) { +return false; +}var ac = o; +return (this.pos1 == ac.pos1 && this.pos2 == ac.pos2 && this.pos3 == ac.pos3); +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +var sb = new StringBuilder (); +sb.append ("[").append (this.pos1).append (", ").append (this.pos2).append (", ").append (this.pos3).append ("]"); +return sb.toString (); +}); +}); diff --git a/bin/jalview/datamodel/AlignedCodonFrame.js b/bin/jalview/datamodel/AlignedCodonFrame.js index 043b032..8d854b4 100644 --- a/bin/jalview/datamodel/AlignedCodonFrame.js +++ b/bin/jalview/datamodel/AlignedCodonFrame.js @@ -1,198 +1,198 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.AlignedCodonFrame", ["jalview.datamodel.Mapping", "jalview.util.MappingUtils", "java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.dnaSeqs = null; -this.dnaToProt = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "AlignedCodonFrame"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "addMap", -function (dnaseq, aaseq, map) { -var nlen = 1; -if (this.dnaSeqs != null) { -nlen = this.dnaSeqs.length + 1; -}var ndna = new Array (nlen); -var ndtp = new Array (nlen); -if (this.dnaSeqs != null) { -System.arraycopy (this.dnaSeqs, 0, ndna, 0, this.dnaSeqs.length); -System.arraycopy (this.dnaToProt, 0, ndtp, 0, this.dnaSeqs.length); -}this.dnaSeqs = ndna; -this.dnaToProt = ndtp; -nlen--; -this.dnaSeqs[nlen] = (dnaseq.getDatasetSequence () == null) ? dnaseq : dnaseq.getDatasetSequence (); -var mp = new jalview.datamodel.Mapping (map); -mp.to = (aaseq.getDatasetSequence () == null) ? aaseq : aaseq.getDatasetSequence (); -this.dnaToProt[nlen] = mp; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList"); -Clazz.defineMethod (c$, "getdnaSeqs", -function () { -return this.dnaSeqs; -}); -Clazz.defineMethod (c$, "getAaSeqs", -function () { -if (this.dnaToProt == null) { -return null; -}var sqs = new Array (this.dnaToProt.length); -for (var sz = 0; sz < this.dnaToProt.length; sz++) { -sqs[sz] = this.dnaToProt[sz].to; -} -return sqs; -}); -Clazz.defineMethod (c$, "getdnaToProt", -function () { -if (this.dnaToProt == null) { -return null; -}var sqs = new Array (this.dnaToProt.length); -for (var sz = 0; sz < this.dnaToProt.length; sz++) { -sqs[sz] = this.dnaToProt[sz].map; -} -return sqs; -}); -Clazz.defineMethod (c$, "getProtMappings", -function () { -return this.dnaToProt; -}); -Clazz.defineMethod (c$, "getMappingForSequence", -function (seq) { -if (this.dnaSeqs == null) { -return null; -}var seqDs = seq.getDatasetSequence (); -seqDs = seqDs != null ? seqDs : seq; -for (var ds = 0; ds < this.dnaSeqs.length; ds++) { -if (this.dnaSeqs[ds] === seqDs || this.dnaToProt[ds].to === seqDs) { -return this.dnaToProt[ds]; -}} -return null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getAaForDnaSeq", -function (dnaSeqRef) { -if (this.dnaSeqs == null) { -return null; -}var dnads = dnaSeqRef.getDatasetSequence (); -for (var ds = 0; ds < this.dnaSeqs.length; ds++) { -if (this.dnaSeqs[ds] === dnaSeqRef || this.dnaSeqs[ds] === dnads) { -return this.dnaToProt[ds].to; -}} -return null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getDnaForAaSeq", -function (aaSeqRef) { -if (this.dnaToProt == null) { -return null; -}var aads = aaSeqRef.getDatasetSequence (); -for (var as = 0; as < this.dnaToProt.length; as++) { -if (this.dnaToProt[as].to === aaSeqRef || this.dnaToProt[as].to === aads) { -return this.dnaSeqs[as]; -}} -return null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "involvesSequence", -function (seq) { -return this.getAaForDnaSeq (seq) != null || this.getDnaForAaSeq (seq) != null; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "markMappedRegion", -function (seq, index, results) { -if (this.dnaToProt == null) { -return; -}var codon; -var ds = seq.getDatasetSequence (); -for (var mi = 0; mi < this.dnaToProt.length; mi++) { -if (this.dnaSeqs[mi] === seq || this.dnaSeqs[mi] === ds) { -codon = this.dnaToProt[mi].map.locateInTo (index, index); -if (codon != null) { -for (var i = 0; i < codon.length; i += 2) { -results.addResult (this.dnaToProt[mi].to, codon[i], codon[i + 1]); -} -}} else if (this.dnaToProt[mi].to === seq || this.dnaToProt[mi].to === ds) { -{ -codon = this.dnaToProt[mi].map.locateInFrom (index, index); -if (codon != null) { -for (var i = 0; i < codon.length; i += 2) { -results.addResult (this.dnaSeqs[mi], codon[i], codon[i + 1]); -} -}}}} -}, "jalview.datamodel.SequenceI,~N,jalview.datamodel.SearchResults"); -Clazz.defineMethod (c$, "getDnaPosition", -function (seq, aaPos) { -var ml = null; -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaSeqs[i] === seq) { -ml = this.getdnaToProt ()[i]; -break; -}} -return ml == null ? null : ml.locateInFrom (aaPos, aaPos); -}, "jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "findAlignedSequence", -function (seq, al) { -if (this.dnaToProt != null) { -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaSeqs[i] === seq) { -for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { -if (this.dnaToProt[i].to === sourceAligned.getDatasetSequence ()) { -return sourceAligned; -}} -}} -}if (this.dnaToProt != null) { -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaToProt[i].to === seq) { -for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { -if (this.dnaSeqs[i] === sourceAligned.getDatasetSequence ()) { -return sourceAligned; -}} -}} -}return null; -}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "getMappedRegion", -function (mappedFrom, mappedTo, pos) { -var targetDs = mappedFrom.getDatasetSequence () == null ? mappedFrom : mappedFrom.getDatasetSequence (); -var sourceDs = mappedTo.getDatasetSequence () == null ? mappedTo : mappedTo.getDatasetSequence (); -if (targetDs == null || sourceDs == null || this.dnaToProt == null) { -return null; -}for (var mi = 0; mi < this.dnaToProt.length; mi++) { -if (this.dnaSeqs[mi] === targetDs && this.dnaToProt[mi].to === sourceDs) { -var codon = this.dnaToProt[mi].map.locateInFrom (pos, pos); -if (codon != null) { -return codon; -}}} -return null; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "getMappedCodon", -function (protein, aaPos) { -if (this.dnaToProt == null) { -return null; -}var ml = null; -var dnaSeq = null; -for (var i = 0; i < this.dnaToProt.length; i++) { -if (this.dnaToProt[i].to === protein) { -ml = this.getdnaToProt ()[i]; -dnaSeq = this.dnaSeqs[i].getSequence (); -break; -}} -if (ml == null) { -return null; -}var codonPos = ml.locateInFrom (aaPos, aaPos); -if (codonPos == null) { -return null; -}codonPos = jalview.util.MappingUtils.flattenRanges (codonPos); -return Clazz.newCharArray (-1, [dnaSeq[codonPos[0] - 1], dnaSeq[codonPos[1] - 1], dnaSeq[codonPos[2] - 1]]); -}, "jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "getMappingsForSequence", -function (seq) { -var result = new java.util.ArrayList (); -if (this.dnaSeqs == null) { -return result; -}var related = new java.util.ArrayList (); -var seqDs = seq.getDatasetSequence (); -seqDs = seqDs != null ? seqDs : seq; -for (var ds = 0; ds < this.dnaSeqs.length; ds++) { -var mapping = this.dnaToProt[ds]; -if (this.dnaSeqs[ds] === seqDs || mapping.to === seqDs) { -if (!related.contains (mapping.to)) { -result.add (mapping); -related.add (mapping.to); -}}} -return result; -}, "jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.AlignedCodonFrame", ["jalview.datamodel.Mapping", "jalview.util.MappingUtils", "java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.dnaSeqs = null; +this.dnaToProt = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "AlignedCodonFrame"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "addMap", +function (dnaseq, aaseq, map) { +var nlen = 1; +if (this.dnaSeqs != null) { +nlen = this.dnaSeqs.length + 1; +}var ndna = new Array (nlen); +var ndtp = new Array (nlen); +if (this.dnaSeqs != null) { +System.arraycopy (this.dnaSeqs, 0, ndna, 0, this.dnaSeqs.length); +System.arraycopy (this.dnaToProt, 0, ndtp, 0, this.dnaSeqs.length); +}this.dnaSeqs = ndna; +this.dnaToProt = ndtp; +nlen--; +this.dnaSeqs[nlen] = (dnaseq.getDatasetSequence () == null) ? dnaseq : dnaseq.getDatasetSequence (); +var mp = new jalview.datamodel.Mapping (map); +mp.to = (aaseq.getDatasetSequence () == null) ? aaseq : aaseq.getDatasetSequence (); +this.dnaToProt[nlen] = mp; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,jalview.util.MapList"); +Clazz.defineMethod (c$, "getdnaSeqs", +function () { +return this.dnaSeqs; +}); +Clazz.defineMethod (c$, "getAaSeqs", +function () { +if (this.dnaToProt == null) { +return null; +}var sqs = new Array (this.dnaToProt.length); +for (var sz = 0; sz < this.dnaToProt.length; sz++) { +sqs[sz] = this.dnaToProt[sz].to; +} +return sqs; +}); +Clazz.defineMethod (c$, "getdnaToProt", +function () { +if (this.dnaToProt == null) { +return null; +}var sqs = new Array (this.dnaToProt.length); +for (var sz = 0; sz < this.dnaToProt.length; sz++) { +sqs[sz] = this.dnaToProt[sz].map; +} +return sqs; +}); +Clazz.defineMethod (c$, "getProtMappings", +function () { +return this.dnaToProt; +}); +Clazz.defineMethod (c$, "getMappingForSequence", +function (seq) { +if (this.dnaSeqs == null) { +return null; +}var seqDs = seq.getDatasetSequence (); +seqDs = seqDs != null ? seqDs : seq; +for (var ds = 0; ds < this.dnaSeqs.length; ds++) { +if (this.dnaSeqs[ds] === seqDs || this.dnaToProt[ds].to === seqDs) { +return this.dnaToProt[ds]; +}} +return null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getAaForDnaSeq", +function (dnaSeqRef) { +if (this.dnaSeqs == null) { +return null; +}var dnads = dnaSeqRef.getDatasetSequence (); +for (var ds = 0; ds < this.dnaSeqs.length; ds++) { +if (this.dnaSeqs[ds] === dnaSeqRef || this.dnaSeqs[ds] === dnads) { +return this.dnaToProt[ds].to; +}} +return null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getDnaForAaSeq", +function (aaSeqRef) { +if (this.dnaToProt == null) { +return null; +}var aads = aaSeqRef.getDatasetSequence (); +for (var as = 0; as < this.dnaToProt.length; as++) { +if (this.dnaToProt[as].to === aaSeqRef || this.dnaToProt[as].to === aads) { +return this.dnaSeqs[as]; +}} +return null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "involvesSequence", +function (seq) { +return this.getAaForDnaSeq (seq) != null || this.getDnaForAaSeq (seq) != null; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "markMappedRegion", +function (seq, index, results) { +if (this.dnaToProt == null) { +return; +}var codon; +var ds = seq.getDatasetSequence (); +for (var mi = 0; mi < this.dnaToProt.length; mi++) { +if (this.dnaSeqs[mi] === seq || this.dnaSeqs[mi] === ds) { +codon = this.dnaToProt[mi].map.locateInTo (index, index); +if (codon != null) { +for (var i = 0; i < codon.length; i += 2) { +results.addResult (this.dnaToProt[mi].to, codon[i], codon[i + 1]); +} +}} else if (this.dnaToProt[mi].to === seq || this.dnaToProt[mi].to === ds) { +{ +codon = this.dnaToProt[mi].map.locateInFrom (index, index); +if (codon != null) { +for (var i = 0; i < codon.length; i += 2) { +results.addResult (this.dnaSeqs[mi], codon[i], codon[i + 1]); +} +}}}} +}, "jalview.datamodel.SequenceI,~N,jalview.datamodel.SearchResults"); +Clazz.defineMethod (c$, "getDnaPosition", +function (seq, aaPos) { +var ml = null; +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaSeqs[i] === seq) { +ml = this.getdnaToProt ()[i]; +break; +}} +return ml == null ? null : ml.locateInFrom (aaPos, aaPos); +}, "jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "findAlignedSequence", +function (seq, al) { +if (this.dnaToProt != null) { +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaSeqs[i] === seq) { +for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { +if (this.dnaToProt[i].to === sourceAligned.getDatasetSequence ()) { +return sourceAligned; +}} +}} +}if (this.dnaToProt != null) { +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaToProt[i].to === seq) { +for (var sourceAligned, $sourceAligned = al.getSequences ().iterator (); $sourceAligned.hasNext () && ((sourceAligned = $sourceAligned.next ()) || true);) { +if (this.dnaSeqs[i] === sourceAligned.getDatasetSequence ()) { +return sourceAligned; +}} +}} +}return null; +}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "getMappedRegion", +function (mappedFrom, mappedTo, pos) { +var targetDs = mappedFrom.getDatasetSequence () == null ? mappedFrom : mappedFrom.getDatasetSequence (); +var sourceDs = mappedTo.getDatasetSequence () == null ? mappedTo : mappedTo.getDatasetSequence (); +if (targetDs == null || sourceDs == null || this.dnaToProt == null) { +return null; +}for (var mi = 0; mi < this.dnaToProt.length; mi++) { +if (this.dnaSeqs[mi] === targetDs && this.dnaToProt[mi].to === sourceDs) { +var codon = this.dnaToProt[mi].map.locateInFrom (pos, pos); +if (codon != null) { +return codon; +}}} +return null; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "getMappedCodon", +function (protein, aaPos) { +if (this.dnaToProt == null) { +return null; +}var ml = null; +var dnaSeq = null; +for (var i = 0; i < this.dnaToProt.length; i++) { +if (this.dnaToProt[i].to === protein) { +ml = this.getdnaToProt ()[i]; +dnaSeq = this.dnaSeqs[i].getSequence (); +break; +}} +if (ml == null) { +return null; +}var codonPos = ml.locateInFrom (aaPos, aaPos); +if (codonPos == null) { +return null; +}codonPos = jalview.util.MappingUtils.flattenRanges (codonPos); +return Clazz.newCharArray (-1, [dnaSeq[codonPos[0] - 1], dnaSeq[codonPos[1] - 1], dnaSeq[codonPos[2] - 1]]); +}, "jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "getMappingsForSequence", +function (seq) { +var result = new java.util.ArrayList (); +if (this.dnaSeqs == null) { +return result; +}var related = new java.util.ArrayList (); +var seqDs = seq.getDatasetSequence (); +seqDs = seqDs != null ? seqDs : seq; +for (var ds = 0; ds < this.dnaSeqs.length; ds++) { +var mapping = this.dnaToProt[ds]; +if (this.dnaSeqs[ds] === seqDs || mapping.to === seqDs) { +if (!related.contains (mapping.to)) { +result.add (mapping); +related.add (mapping.to); +}}} +return result; +}, "jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/datamodel/Alignment.js b/bin/jalview/datamodel/Alignment.js index a4d45ee..f70f6ce 100644 --- a/bin/jalview/datamodel/Alignment.js +++ b/bin/jalview/datamodel/Alignment.js @@ -1,815 +1,815 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.AlignmentI", "$.HiddenSequences", "java.util.ArrayList", "$.Collections", "$.LinkedHashSet"], "jalview.datamodel.Alignment", ["jalview.analysis.AlignmentUtils", "jalview.datamodel.AlignmentAnnotation", "$.CigarArray", "$.SeqCigar", "$.Sequence", "jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "java.util.HashSet", "$.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.dataset = null; -this.sequences = null; -this.groups = null; -this.gapCharacter = '-'; -this.type = 1; -this.$hasRNAStructure = false; -this.annotations = null; -this.hiddenSequences = null; -this.alignmentProperties = null; -this.codonFrameList = null; -this.alignmentRefs = 0; -this.seqrep = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Alignment", null, jalview.datamodel.AlignmentI); -Clazz.prepareFields (c$, function () { -this.groups = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); -this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); -this.codonFrameList = new java.util.LinkedHashSet (); -}); -Clazz.defineMethod (c$, "initAlignment", -($fz = function (seqs) { -var i = 0; -if (jalview.util.Comparison.isNucleotide (seqs)) { -this.type = 1; -} else { -this.type = 0; -}this.sequences = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); -for (i = 0; i < seqs.length; i++) { -this.sequences.add (seqs[i]); -} -}, $fz.isPrivate = true, $fz), "~A"); -Clazz.makeConstructor (c$, -function (al) { -var seqs = al.getSequencesArray (); -for (var i = 0; i < seqs.length; i++) { -seqs[i] = new jalview.datamodel.Sequence (seqs[i]); -} -this.codonFrameList = (al).codonFrameList; -this.initAlignment (seqs); -}, "jalview.datamodel.AlignmentI"); -Clazz.makeConstructor (c$, -function (seqs) { -this.initAlignment (seqs); -}, "~A"); -c$.createAlignment = Clazz.defineMethod (c$, "createAlignment", -function (compactAlignment) { -throw new Error (jalview.util.MessageManager.getString ("error.alignment_cigararray_not_implemented")); -}, "jalview.datamodel.CigarArray"); -Clazz.defineMethod (c$, "getSequences", -function () { -return this.sequences; -}); -Clazz.defineMethod (c$, "getSequences", -function (hiddenReps) { -return this.sequences; -}, "java.util.Map"); -Clazz.defineMethod (c$, "getSequencesArray", -function () { -if (this.sequences == null) { -return null; -}{ -return this.sequences.toArray ( new Array (this.sequences.size ())); -}}); -Clazz.overrideMethod (c$, "getSequencesByName", -function () { -return jalview.analysis.AlignmentUtils.getSequencesByName (this); -}); -Clazz.overrideMethod (c$, "getSequenceAt", -function (i) { -{ -if (i > -1 && i < this.sequences.size ()) { -return this.sequences.get (i); -}}return null; -}, "~N"); -Clazz.overrideMethod (c$, "addSequence", -function (snew) { -if (this.dataset != null) { -if (snew.getDatasetSequence () != null) { -this.getDataset ().addSequence (snew.getDatasetSequence ()); -} else { -var adding = snew.deriveSequence (); -this.getDataset ().addSequence (adding.getDatasetSequence ()); -snew = adding; -}}if (this.sequences == null) { -this.initAlignment ( Clazz.newArray (-1, [snew])); -} else { -{ -this.sequences.add (snew); -}}if (this.hiddenSequences != null) { -this.hiddenSequences.adjustHeightSequenceAdded (); -}}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "setSequenceAt", -function (i, snew) { -{ -this.deleteSequence (i); -this.sequences.set (i, snew); -}}, "~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getGroups", -function () { -return this.groups; -}); -Clazz.overrideMethod (c$, "finalize", -function () { -if (this.getDataset () != null) { -this.getDataset ().removeAlignmentRef (); -}this.dataset = null; -this.sequences = null; -this.groups = null; -this.annotations = null; -this.hiddenSequences = null; -}); -Clazz.defineMethod (c$, "removeAlignmentRef", -($fz = function () { -if (--this.alignmentRefs == 0) { -this.finalize (); -}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "deleteSequence", -function (s) { -this.deleteSequence (this.findIndex (s)); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "deleteSequence", -function (i) { -if (i > -1 && i < this.getHeight ()) { -{ -this.sequences.remove (i); -this.hiddenSequences.adjustHeightSequenceDeleted (i); -}}}, "~N"); -Clazz.overrideMethod (c$, "findGroup", -function (s) { -{ -for (var i = 0; i < this.groups.size (); i++) { -var sg = this.groups.get (i); -if (sg.getSequences (null).contains (s)) { -return sg; -}} -}return null; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "findAllGroups", -function (s) { -var temp = new java.util.ArrayList (); -{ -var gSize = this.groups.size (); -for (var i = 0; i < gSize; i++) { -var sg = this.groups.get (i); -if (sg == null || sg.getSequences () == null) { -this.deleteGroup (sg); -gSize--; -continue; -}if (sg.getSequences ().contains (s)) { -temp.add (sg); -}} -}var ret = new Array (temp.size ()); -return temp.toArray (ret); -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "addGroup", -function (sg) { -{ -if (!this.groups.contains (sg)) { -if (this.hiddenSequences.getSize () > 0) { -var i; -var iSize = sg.getSize (); -for (i = 0; i < iSize; i++) { -if (!this.sequences.contains (sg.getSequenceAt (i))) { -sg.deleteSequence (sg.getSequenceAt (i), false); -iSize--; -i--; -}} -if (sg.getSize () < 1) { -return; -}}sg.setContext (this); -this.groups.add (sg); -}}}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "removeAnnotationForGroup", -($fz = function (gp) { -if (this.annotations == null || this.annotations.length == 0) { -return; -}var t; -var todelete = new Array (this.annotations.length); -var tokeep = new Array (this.annotations.length); -var i; -var p; -var k; -if (gp == null) { -for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { -if (this.annotations[i].groupRef != null) { -todelete[p++] = this.annotations[i]; -} else { -tokeep[k++] = this.annotations[i]; -}} -} else { -for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { -if (this.annotations[i].groupRef === gp) { -todelete[p++] = this.annotations[i]; -} else { -tokeep[k++] = this.annotations[i]; -}} -}if (p > 0) { -for (i = 0; i < p; i++) { -this.unhookAnnotation (todelete[i]); -todelete[i] = null; -} -t = new Array (k); -for (i = 0; i < k; i++) { -t[i] = tokeep[i]; -} -this.annotations = t; -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup"); -Clazz.overrideMethod (c$, "deleteAllGroups", -function () { -{ -if (this.annotations != null) { -this.removeAnnotationForGroup (null); -}for (var sg, $sg = this.groups.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -sg.setContext (null); -} -this.groups.clear (); -}}); -Clazz.overrideMethod (c$, "deleteGroup", -function (g) { -{ -if (this.groups.contains (g)) { -this.removeAnnotationForGroup (g); -this.groups.remove (g); -g.setContext (null); -}}}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "findName", -function (name) { -return this.findName (name, false); -}, "~S"); -Clazz.defineMethod (c$, "findName", -function (token, b) { -return this.findName (null, token, b); -}, "~S,~B"); -Clazz.defineMethod (c$, "findName", -function (startAfter, token, b) { -var i = 0; -var sq = null; -var sqname = null; -if (startAfter != null) { -var matched = false; -while (i < this.sequences.size ()) { -if (this.getSequenceAt (i++) === startAfter) { -matched = true; -break; -}} -if (!matched) { -i = 0; -}}while (i < this.sequences.size ()) { -sq = this.getSequenceAt (i); -sqname = sq.getName (); -if (sqname.equals (token) || (b && (sqname.equalsIgnoreCase (token)))) { -return this.getSequenceAt (i); -}i++; -} -return null; -}, "jalview.datamodel.SequenceI,~S,~B"); -Clazz.overrideMethod (c$, "findSequenceMatch", -function (name) { -var matches = new java.util.Vector (); -var i = 0; -while (i < this.sequences.size ()) { -if (this.getSequenceAt (i).getName ().equals (name)) { -matches.addElement (this.getSequenceAt (i)); -}i++; -} -var result = new Array (matches.size ()); -for (i = 0; i < result.length; i++) { -result[i] = matches.elementAt (i); -} -return result; -}, "~S"); -Clazz.defineMethod (c$, "findIndex", -function (s) { -var i = 0; -while (i < this.sequences.size ()) { -if (s === this.getSequenceAt (i)) { -return i; -}i++; -} -return -1; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "findIndex", -function (results) { -var i = 0; -while (i < this.sequences.size ()) { -if (results.involvesSequence (this.getSequenceAt (i))) { -return i; -}i++; -} -return -1; -}, "jalview.datamodel.SearchResults"); -Clazz.overrideMethod (c$, "getHeight", -function () { -return this.sequences.size (); -}); -Clazz.overrideMethod (c$, "getWidth", -function () { -var maxLength = -1; -for (var i = 0; i < this.sequences.size (); i++) { -if (this.getSequenceAt (i).getLength () > maxLength) { -maxLength = this.getSequenceAt (i).getLength (); -}} -return maxLength; -}); -Clazz.overrideMethod (c$, "setGapCharacter", -function (gc) { -this.gapCharacter = gc; -{ -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -seq.setSequence (seq.getSequenceAsString ().$replace ('.', gc).$replace ('-', gc).$replace (' ', gc)); -} -}}, "~S"); -Clazz.defineMethod (c$, "getGapCharacter", -function () { -return this.gapCharacter; -}); -Clazz.defineMethod (c$, "isAligned", -function () { -return this.isAligned (false); -}); -Clazz.defineMethod (c$, "isAligned", -function (includeHidden) { -var width = this.getWidth (); -if (this.hiddenSequences == null || this.hiddenSequences.getSize () == 0) { -includeHidden = true; -}for (var i = 0; i < this.sequences.size (); i++) { -if (includeHidden || !this.hiddenSequences.isHidden (this.getSequenceAt (i))) { -if (this.getSequenceAt (i).getLength () != width) { -return false; -}}} -return true; -}, "~B"); -Clazz.overrideMethod (c$, "deleteAllAnnotations", -function (includingAutoCalculated) { -var result = false; -for (var alan, $alan = 0, $$alan = this.getAlignmentAnnotation (); $alan < $$alan.length && ((alan = $$alan[$alan]) || true); $alan++) { -if (!alan.autoCalculated || includingAutoCalculated) { -this.deleteAnnotation (alan); -result = true; -}} -return result; -}, "~B"); -Clazz.defineMethod (c$, "deleteAnnotation", -function (aa) { -return this.deleteAnnotation (aa, true); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "deleteAnnotation", -function (aa, unhook) { -var aSize = 1; -if (this.annotations != null) { -aSize = this.annotations.length; -}if (aSize < 1) { -return false; -}var temp = new Array (aSize - 1); -var swap = false; -var tIndex = 0; -for (var i = 0; i < aSize; i++) { -if (this.annotations[i] === aa) { -swap = true; -continue; -}if (tIndex < temp.length) { -temp[tIndex++] = this.annotations[i]; -}} -if (swap) { -this.annotations = temp; -if (unhook) { -this.unhookAnnotation (aa); -}}return swap; -}, "jalview.datamodel.AlignmentAnnotation,~B"); -Clazz.defineMethod (c$, "unhookAnnotation", -($fz = function (aa) { -if (aa.sequenceRef != null) { -aa.sequenceRef.removeAlignmentAnnotation (aa); -}if (aa.groupRef != null) { -aa.groupRef = null; -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "addAnnotation", -function (aa) { -this.addAnnotation (aa, -1); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "addAnnotation", -function (aa, pos) { -if (aa.getRNAStruc () != null) { -this.$hasRNAStructure = true; -}var aSize = 1; -if (this.annotations != null) { -aSize = this.annotations.length + 1; -}var temp = new Array (aSize); -var i = 0; -if (pos == -1 || pos >= aSize) { -temp[aSize - 1] = aa; -} else { -temp[pos] = aa; -}if (aSize > 1) { -var p = 0; -for (i = 0; i < (aSize - 1); i++, p++) { -if (p == pos) { -p++; -}if (p < temp.length) { -temp[p] = this.annotations[i]; -}} -}this.annotations = temp; -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.overrideMethod (c$, "setAnnotationIndex", -function (aa, index) { -if (aa == null || this.annotations == null || this.annotations.length - 1 < index) { -return; -}var aSize = this.annotations.length; -var temp = new Array (aSize); -temp[index] = aa; -for (var i = 0; i < aSize; i++) { -if (i == index) { -continue; -}if (i < index) { -temp[i] = this.annotations[i]; -} else { -temp[i] = this.annotations[i - 1]; -}} -this.annotations = temp; -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.defineMethod (c$, "getAlignmentAnnotation", -function () { -return this.annotations; -}); -Clazz.overrideMethod (c$, "setNucleotide", -function (b) { -if (b) { -this.type = 1; -} else { -this.type = 0; -}}, "~B"); -Clazz.defineMethod (c$, "isNucleotide", -function () { -if (this.type == 1) { -return true; -} else { -return false; -}}); -Clazz.overrideMethod (c$, "hasRNAStructure", -function () { -return this.$hasRNAStructure; -}); -Clazz.overrideMethod (c$, "setDataset", -function (data) { -if (this.dataset == null && data == null) { -var seqs = new Array (this.getHeight ()); -var currentSeq; -for (var i = 0; i < this.getHeight (); i++) { -currentSeq = this.getSequenceAt (i); -if (currentSeq.getDatasetSequence () != null) { -seqs[i] = currentSeq.getDatasetSequence (); -} else { -seqs[i] = currentSeq.createDatasetSequence (); -}} -this.dataset = new jalview.datamodel.Alignment (seqs); -} else if (this.dataset == null && data != null) { -this.dataset = data; -for (var i = 0; i < this.getHeight (); i++) { -var currentSeq = this.getSequenceAt (i); -var dsq = currentSeq.getDatasetSequence (); -if (dsq == null) { -dsq = currentSeq.createDatasetSequence (); -this.dataset.addSequence (dsq); -} else { -while (dsq.getDatasetSequence () != null) { -dsq = dsq.getDatasetSequence (); -} -if (this.dataset.findIndex (dsq) == -1) { -this.dataset.addSequence (dsq); -}}} -}this.dataset.addAlignmentRef (); -}, "jalview.datamodel.Alignment"); -Clazz.defineMethod (c$, "addAlignmentRef", -($fz = function () { -this.alignmentRefs++; -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "getDataset", -function () { -return this.dataset; -}); -Clazz.overrideMethod (c$, "padGaps", -function () { -var modified = false; -var maxLength = -1; -var current; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -for (var j = current.getLength (); j > maxLength; j--) { -if (j > maxLength && !jalview.util.Comparison.isGap (current.getCharAt (j))) { -maxLength = j; -break; -}} -} -maxLength++; -var cLength; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -cLength = current.getLength (); -if (cLength < maxLength) { -current.insertCharAt (cLength, maxLength - cLength, this.gapCharacter); -modified = true; -} else if (current.getLength () > maxLength) { -current.deleteChars (maxLength, current.getLength ()); -}} -return modified; -}); -Clazz.overrideMethod (c$, "justify", -function (right) { -var modified = false; -var maxLength = -1; -var ends = Clazz.newIntArray (this.sequences.size () * 2, 0); -var current; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -ends[i * 2] = current.findIndex (current.getStart ()); -ends[i * 2 + 1] = current.findIndex (current.getStart () + current.getLength ()); -var hitres = false; -for (var j = 0, rs = 0, ssiz = current.getLength (); j < ssiz; j++) { -if (!jalview.util.Comparison.isGap (current.getCharAt (j))) { -if (!hitres) { -ends[i * 2] = j; -hitres = true; -} else { -ends[i * 2 + 1] = j; -if (j - ends[i * 2] > maxLength) { -maxLength = j - ends[i * 2]; -}}}} -} -maxLength++; -var cLength; -var extent; -var diff; -for (var i = 0; i < this.sequences.size (); i++) { -current = this.getSequenceAt (i); -cLength = 1 + ends[i * 2 + 1] - ends[i * 2]; -diff = maxLength - cLength; -extent = current.getLength (); -if (right) { -if (extent > ends[i * 2 + 1]) { -current.deleteChars (ends[i * 2 + 1] + 1, extent); -modified = true; -}if (ends[i * 2] > diff) { -current.deleteChars (0, ends[i * 2] - diff); -modified = true; -} else { -if (ends[i * 2] < diff) { -current.insertCharAt (0, diff - ends[i * 2], this.gapCharacter); -modified = true; -}}} else { -if (ends[i * 2] > 0) { -current.deleteChars (0, ends[i * 2]); -modified = true; -ends[i * 2 + 1] -= ends[i * 2]; -extent -= ends[i * 2]; -}if (extent > maxLength) { -current.deleteChars (maxLength + 1, extent); -modified = true; -} else { -if (extent < maxLength) { -current.insertCharAt (extent, maxLength - extent, this.gapCharacter); -modified = true; -}}}} -return modified; -}, "~B"); -Clazz.defineMethod (c$, "getHiddenSequences", -function () { -return this.hiddenSequences; -}); -Clazz.overrideMethod (c$, "getCompactAlignment", -function () { -{ -var alseqs = new Array (this.sequences.size ()); -var i = 0; -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -alseqs[i++] = new jalview.datamodel.SeqCigar (seq); -} -var cal = new jalview.datamodel.CigarArray (alseqs); -cal.addOperation ('M', this.getWidth ()); -return cal; -}}); -Clazz.overrideMethod (c$, "setProperty", -function (key, value) { -if (this.alignmentProperties == null) { -this.alignmentProperties = new java.util.Hashtable (); -}this.alignmentProperties.put (key, value); -}, "~O,~O"); -Clazz.defineMethod (c$, "getProperty", -function (key) { -if (this.alignmentProperties != null) { -return this.alignmentProperties.get (key); -} else { -return null; -}}, "~O"); -Clazz.defineMethod (c$, "getProperties", -function () { -return this.alignmentProperties; -}); -Clazz.overrideMethod (c$, "addCodonFrame", -function (codons) { -if (codons != null) { -this.codonFrameList.add (codons); -}}, "jalview.datamodel.AlignedCodonFrame"); -Clazz.overrideMethod (c$, "getCodonFrame", -function (seq) { -if (seq == null) { -return null; -}var cframes = new java.util.ArrayList (); -for (var acf, $acf = this.codonFrameList.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -if (acf.involvesSequence (seq)) { -cframes.add (acf); -}} -return cframes; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "setCodonFrames", -function (acfs) { -this.codonFrameList = acfs; -}, "java.util.Set"); -Clazz.defineMethod (c$, "getCodonFrames", -function () { -return this.codonFrameList; -}); -Clazz.overrideMethod (c$, "removeCodonFrame", -function (codons) { -if (codons == null || this.codonFrameList == null) { -return false; -}return this.codonFrameList.remove (codons); -}, "jalview.datamodel.AlignedCodonFrame"); -Clazz.overrideMethod (c$, "append", -function (toappend) { -if (toappend === this) { -System.err.println ("Self append may cause a deadlock."); -}var samegap = toappend.getGapCharacter () == this.getGapCharacter (); -var oldc = toappend.getGapCharacter (); -var hashidden = toappend.getHiddenSequences () != null && toappend.getHiddenSequences ().hiddenSequences != null; -var sqs = (hashidden) ? toappend.getHiddenSequences ().getFullAlignment ().getSequences () : toappend.getSequences (); -if (sqs != null) { -{ -for (var addedsq, $addedsq = sqs.iterator (); $addedsq.hasNext () && ((addedsq = $addedsq.next ()) || true);) { -if (!samegap) { -var oldseq = addedsq.getSequence (); -for (var c = 0; c < oldseq.length; c++) { -if (oldseq[c] == oldc) { -oldseq[c] = this.gapCharacter; -}} -}this.addSequence (addedsq); -} -}}var alan = toappend.getAlignmentAnnotation (); -for (var a = 0; alan != null && a < alan.length; a++) { -this.addAnnotation (alan[a]); -} -this.codonFrameList.addAll (toappend.getCodonFrames ()); -var sg = toappend.getGroups (); -if (sg != null) { -for (var _sg, $_sg = sg.iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) { -this.addGroup (_sg); -} -}if (toappend.getHiddenSequences () != null) { -var hs = toappend.getHiddenSequences (); -if (this.hiddenSequences == null) { -this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); -}if (hs.hiddenSequences != null) { -for (var s = 0; s < hs.hiddenSequences.length; s++) { -if (hs.hiddenSequences[s] != null) { -this.hiddenSequences.hideSequence (hs.hiddenSequences[s]); -}} -}}if (toappend.getProperties () != null) { -var key = toappend.getProperties ().keys (); -while (key.hasMoreElements ()) { -var k = key.nextElement (); -var ourval = this.getProperty (k); -var toapprop = toappend.getProperty (k); -if (ourval != null) { -if (ourval.getClass ().equals (toapprop.getClass ()) && !ourval.equals (toapprop)) { -if (Clazz.instanceOf (ourval, String)) { -this.setProperty (k, (ourval) + "; " + (toapprop)); -} else { -if (Clazz.instanceOf (ourval, java.util.Vector)) { -var theirv = (toapprop).elements (); -while (theirv.hasMoreElements ()) { -(ourval).addElement (theirv); -} -}}}} else { -this.setProperty (k, toapprop); -}} -}}, "jalview.datamodel.AlignmentI"); -Clazz.overrideMethod (c$, "findOrCreateAnnotation", -function (name, calcId, autoCalc, seqRef, groupRef) { -if (this.annotations != null) { -for (var annot, $annot = 0, $$annot = this.getAlignmentAnnotation (); $annot < $$annot.length && ((annot = $$annot[$annot]) || true); $annot++) { -if (annot.autoCalculated == autoCalc && (name.equals (annot.label)) && (calcId == null || annot.getCalcId ().equals (calcId)) && annot.sequenceRef === seqRef && annot.groupRef === groupRef) { -return annot; -}} -}var annot = new jalview.datamodel.AlignmentAnnotation (name, name, new Array (1), 0, 0, 1); -annot.hasText = false; -annot.setCalcId ( String.instantialize (calcId)); -annot.autoCalculated = autoCalc; -if (seqRef != null) { -annot.setSequenceRef (seqRef); -}annot.groupRef = groupRef; -this.addAnnotation (annot); -return annot; -}, "~S,~S,~B,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); -Clazz.overrideMethod (c$, "findAnnotation", -function (calcId) { -var aa = new java.util.ArrayList (); -for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { -if (a.getCalcId () === calcId || (a.getCalcId () != null && calcId != null && a.getCalcId ().equals (calcId))) { -aa.add (a); -}} -return aa; -}, "~S"); -Clazz.overrideMethod (c$, "findAnnotations", -function (seq, calcId, label) { -var aa = new java.util.ArrayList (); -for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { -if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) { -aa.add (ann); -}} -return aa; -}, "jalview.datamodel.SequenceI,~S,~S"); -Clazz.overrideMethod (c$, "moveSelectedSequencesByOne", -function (sg, map, up) { -{ -if (up) { -for (var i = 1, iSize = this.sequences.size (); i < iSize; i++) { -var seq = this.sequences.get (i); -if (!sg.getSequences (map).contains (seq)) { -continue; -}var temp = this.sequences.get (i - 1); -if (sg.getSequences (null).contains (temp)) { -continue; -}this.sequences.set (i, temp); -this.sequences.set (i - 1, seq); -} -} else { -for (var i = this.sequences.size () - 2; i > -1; i--) { -var seq = this.sequences.get (i); -if (!sg.getSequences (map).contains (seq)) { -continue; -}var temp = this.sequences.get (i + 1); -if (sg.getSequences (map).contains (temp)) { -continue; -}this.sequences.set (i, temp); -this.sequences.set (i + 1, seq); -} -}}}, "jalview.datamodel.SequenceGroup,java.util.Map,~B"); -Clazz.overrideMethod (c$, "validateAnnotation", -function (alignmentAnnotation) { -alignmentAnnotation.validateRangeAndDisplay (); -if (this.isNucleotide () && alignmentAnnotation.isValidStruc ()) { -this.$hasRNAStructure = true; -}}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "getSeqrep", -function () { -return this.seqrep; -}); -Clazz.overrideMethod (c$, "setSeqrep", -function (seqrep) { -this.seqrep = seqrep; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "hasSeqrep", -function () { -return this.seqrep != null; -}); -Clazz.overrideMethod (c$, "getEndRes", -function () { -return this.getWidth () - 1; -}); -Clazz.overrideMethod (c$, "getStartRes", -function () { -return 0; -}); -Clazz.overrideMethod (c$, "getContext", -function () { -return this.dataset; -}); -Clazz.defineMethod (c$, "alignAs", -function (al) { -return this.alignAs (al, false, true); -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "alignAs", -function (al, preserveMappedGaps, preserveUnmappedGaps) { -var count = 0; -var thisIsNucleotide = this.isNucleotide (); -var thatIsProtein = !al.isNucleotide (); -if (!thatIsProtein && !thisIsNucleotide) { -return jalview.analysis.AlignmentUtils.alignProteinAsDna (this, al); -}var thisGapChar = this.getGapCharacter (); -var gap = thisIsNucleotide && thatIsProtein ? String.valueOf ( Clazz.newCharArray (-1, [thisGapChar, thisGapChar, thisGapChar])) : String.valueOf (thisGapChar); -for (var alignTo, $alignTo = this.getSequences ().iterator (); $alignTo.hasNext () && ((alignTo = $alignTo.next ()) || true);) { -count += jalview.analysis.AlignmentUtils.alignSequenceAs (alignTo, al, gap, preserveMappedGaps, preserveUnmappedGaps) ? 1 : 0; -} -return count; -}, "jalview.datamodel.AlignmentI,~B,~B"); -Clazz.overrideMethod (c$, "getSequenceNames", -function () { -var names = new java.util.HashSet (); -for (var seq, $seq = this.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -names.add (seq.getName ()); -} -return names; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var seq = this.getSequencesArray (); -{ -return "" + JSON.stringify(seq); -}}); -Clazz.defineStatics (c$, -"PROTEIN", 0, -"NUCLEOTIDE", 1); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.AlignmentI", "$.HiddenSequences", "java.util.ArrayList", "$.Collections", "$.LinkedHashSet"], "jalview.datamodel.Alignment", ["jalview.analysis.AlignmentUtils", "jalview.datamodel.AlignmentAnnotation", "$.CigarArray", "$.SeqCigar", "$.Sequence", "jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "java.util.HashSet", "$.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.dataset = null; +this.sequences = null; +this.groups = null; +this.gapCharacter = '-'; +this.type = 1; +this.$hasRNAStructure = false; +this.annotations = null; +this.hiddenSequences = null; +this.alignmentProperties = null; +this.codonFrameList = null; +this.alignmentRefs = 0; +this.seqrep = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Alignment", null, jalview.datamodel.AlignmentI); +Clazz.prepareFields (c$, function () { +this.groups = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); +this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); +this.codonFrameList = new java.util.LinkedHashSet (); +}); +Clazz.defineMethod (c$, "initAlignment", +($fz = function (seqs) { +var i = 0; +if (jalview.util.Comparison.isNucleotide (seqs)) { +this.type = 1; +} else { +this.type = 0; +}this.sequences = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); +for (i = 0; i < seqs.length; i++) { +this.sequences.add (seqs[i]); +} +}, $fz.isPrivate = true, $fz), "~A"); +Clazz.makeConstructor (c$, +function (al) { +var seqs = al.getSequencesArray (); +for (var i = 0; i < seqs.length; i++) { +seqs[i] = new jalview.datamodel.Sequence (seqs[i]); +} +this.codonFrameList = (al).codonFrameList; +this.initAlignment (seqs); +}, "jalview.datamodel.AlignmentI"); +Clazz.makeConstructor (c$, +function (seqs) { +this.initAlignment (seqs); +}, "~A"); +c$.createAlignment = Clazz.defineMethod (c$, "createAlignment", +function (compactAlignment) { +throw new Error (jalview.util.MessageManager.getString ("error.alignment_cigararray_not_implemented")); +}, "jalview.datamodel.CigarArray"); +Clazz.defineMethod (c$, "getSequences", +function () { +return this.sequences; +}); +Clazz.defineMethod (c$, "getSequences", +function (hiddenReps) { +return this.sequences; +}, "java.util.Map"); +Clazz.defineMethod (c$, "getSequencesArray", +function () { +if (this.sequences == null) { +return null; +}{ +return this.sequences.toArray ( new Array (this.sequences.size ())); +}}); +Clazz.overrideMethod (c$, "getSequencesByName", +function () { +return jalview.analysis.AlignmentUtils.getSequencesByName (this); +}); +Clazz.overrideMethod (c$, "getSequenceAt", +function (i) { +{ +if (i > -1 && i < this.sequences.size ()) { +return this.sequences.get (i); +}}return null; +}, "~N"); +Clazz.overrideMethod (c$, "addSequence", +function (snew) { +if (this.dataset != null) { +if (snew.getDatasetSequence () != null) { +this.getDataset ().addSequence (snew.getDatasetSequence ()); +} else { +var adding = snew.deriveSequence (); +this.getDataset ().addSequence (adding.getDatasetSequence ()); +snew = adding; +}}if (this.sequences == null) { +this.initAlignment ( Clazz.newArray (-1, [snew])); +} else { +{ +this.sequences.add (snew); +}}if (this.hiddenSequences != null) { +this.hiddenSequences.adjustHeightSequenceAdded (); +}}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "setSequenceAt", +function (i, snew) { +{ +this.deleteSequence (i); +this.sequences.set (i, snew); +}}, "~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getGroups", +function () { +return this.groups; +}); +Clazz.overrideMethod (c$, "finalize", +function () { +if (this.getDataset () != null) { +this.getDataset ().removeAlignmentRef (); +}this.dataset = null; +this.sequences = null; +this.groups = null; +this.annotations = null; +this.hiddenSequences = null; +}); +Clazz.defineMethod (c$, "removeAlignmentRef", +($fz = function () { +if (--this.alignmentRefs == 0) { +this.finalize (); +}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "deleteSequence", +function (s) { +this.deleteSequence (this.findIndex (s)); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "deleteSequence", +function (i) { +if (i > -1 && i < this.getHeight ()) { +{ +this.sequences.remove (i); +this.hiddenSequences.adjustHeightSequenceDeleted (i); +}}}, "~N"); +Clazz.overrideMethod (c$, "findGroup", +function (s) { +{ +for (var i = 0; i < this.groups.size (); i++) { +var sg = this.groups.get (i); +if (sg.getSequences (null).contains (s)) { +return sg; +}} +}return null; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "findAllGroups", +function (s) { +var temp = new java.util.ArrayList (); +{ +var gSize = this.groups.size (); +for (var i = 0; i < gSize; i++) { +var sg = this.groups.get (i); +if (sg == null || sg.getSequences () == null) { +this.deleteGroup (sg); +gSize--; +continue; +}if (sg.getSequences ().contains (s)) { +temp.add (sg); +}} +}var ret = new Array (temp.size ()); +return temp.toArray (ret); +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "addGroup", +function (sg) { +{ +if (!this.groups.contains (sg)) { +if (this.hiddenSequences.getSize () > 0) { +var i; +var iSize = sg.getSize (); +for (i = 0; i < iSize; i++) { +if (!this.sequences.contains (sg.getSequenceAt (i))) { +sg.deleteSequence (sg.getSequenceAt (i), false); +iSize--; +i--; +}} +if (sg.getSize () < 1) { +return; +}}sg.setContext (this); +this.groups.add (sg); +}}}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "removeAnnotationForGroup", +($fz = function (gp) { +if (this.annotations == null || this.annotations.length == 0) { +return; +}var t; +var todelete = new Array (this.annotations.length); +var tokeep = new Array (this.annotations.length); +var i; +var p; +var k; +if (gp == null) { +for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { +if (this.annotations[i].groupRef != null) { +todelete[p++] = this.annotations[i]; +} else { +tokeep[k++] = this.annotations[i]; +}} +} else { +for (i = 0, p = 0, k = 0; i < this.annotations.length; i++) { +if (this.annotations[i].groupRef === gp) { +todelete[p++] = this.annotations[i]; +} else { +tokeep[k++] = this.annotations[i]; +}} +}if (p > 0) { +for (i = 0; i < p; i++) { +this.unhookAnnotation (todelete[i]); +todelete[i] = null; +} +t = new Array (k); +for (i = 0; i < k; i++) { +t[i] = tokeep[i]; +} +this.annotations = t; +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup"); +Clazz.overrideMethod (c$, "deleteAllGroups", +function () { +{ +if (this.annotations != null) { +this.removeAnnotationForGroup (null); +}for (var sg, $sg = this.groups.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +sg.setContext (null); +} +this.groups.clear (); +}}); +Clazz.overrideMethod (c$, "deleteGroup", +function (g) { +{ +if (this.groups.contains (g)) { +this.removeAnnotationForGroup (g); +this.groups.remove (g); +g.setContext (null); +}}}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "findName", +function (name) { +return this.findName (name, false); +}, "~S"); +Clazz.defineMethod (c$, "findName", +function (token, b) { +return this.findName (null, token, b); +}, "~S,~B"); +Clazz.defineMethod (c$, "findName", +function (startAfter, token, b) { +var i = 0; +var sq = null; +var sqname = null; +if (startAfter != null) { +var matched = false; +while (i < this.sequences.size ()) { +if (this.getSequenceAt (i++) === startAfter) { +matched = true; +break; +}} +if (!matched) { +i = 0; +}}while (i < this.sequences.size ()) { +sq = this.getSequenceAt (i); +sqname = sq.getName (); +if (sqname.equals (token) || (b && (sqname.equalsIgnoreCase (token)))) { +return this.getSequenceAt (i); +}i++; +} +return null; +}, "jalview.datamodel.SequenceI,~S,~B"); +Clazz.overrideMethod (c$, "findSequenceMatch", +function (name) { +var matches = new java.util.Vector (); +var i = 0; +while (i < this.sequences.size ()) { +if (this.getSequenceAt (i).getName ().equals (name)) { +matches.addElement (this.getSequenceAt (i)); +}i++; +} +var result = new Array (matches.size ()); +for (i = 0; i < result.length; i++) { +result[i] = matches.elementAt (i); +} +return result; +}, "~S"); +Clazz.defineMethod (c$, "findIndex", +function (s) { +var i = 0; +while (i < this.sequences.size ()) { +if (s === this.getSequenceAt (i)) { +return i; +}i++; +} +return -1; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "findIndex", +function (results) { +var i = 0; +while (i < this.sequences.size ()) { +if (results.involvesSequence (this.getSequenceAt (i))) { +return i; +}i++; +} +return -1; +}, "jalview.datamodel.SearchResults"); +Clazz.overrideMethod (c$, "getHeight", +function () { +return this.sequences.size (); +}); +Clazz.overrideMethod (c$, "getWidth", +function () { +var maxLength = -1; +for (var i = 0; i < this.sequences.size (); i++) { +if (this.getSequenceAt (i).getLength () > maxLength) { +maxLength = this.getSequenceAt (i).getLength (); +}} +return maxLength; +}); +Clazz.overrideMethod (c$, "setGapCharacter", +function (gc) { +this.gapCharacter = gc; +{ +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +seq.setSequence (seq.getSequenceAsString ().$replace ('.', gc).$replace ('-', gc).$replace (' ', gc)); +} +}}, "~S"); +Clazz.defineMethod (c$, "getGapCharacter", +function () { +return this.gapCharacter; +}); +Clazz.defineMethod (c$, "isAligned", +function () { +return this.isAligned (false); +}); +Clazz.defineMethod (c$, "isAligned", +function (includeHidden) { +var width = this.getWidth (); +if (this.hiddenSequences == null || this.hiddenSequences.getSize () == 0) { +includeHidden = true; +}for (var i = 0; i < this.sequences.size (); i++) { +if (includeHidden || !this.hiddenSequences.isHidden (this.getSequenceAt (i))) { +if (this.getSequenceAt (i).getLength () != width) { +return false; +}}} +return true; +}, "~B"); +Clazz.overrideMethod (c$, "deleteAllAnnotations", +function (includingAutoCalculated) { +var result = false; +for (var alan, $alan = 0, $$alan = this.getAlignmentAnnotation (); $alan < $$alan.length && ((alan = $$alan[$alan]) || true); $alan++) { +if (!alan.autoCalculated || includingAutoCalculated) { +this.deleteAnnotation (alan); +result = true; +}} +return result; +}, "~B"); +Clazz.defineMethod (c$, "deleteAnnotation", +function (aa) { +return this.deleteAnnotation (aa, true); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "deleteAnnotation", +function (aa, unhook) { +var aSize = 1; +if (this.annotations != null) { +aSize = this.annotations.length; +}if (aSize < 1) { +return false; +}var temp = new Array (aSize - 1); +var swap = false; +var tIndex = 0; +for (var i = 0; i < aSize; i++) { +if (this.annotations[i] === aa) { +swap = true; +continue; +}if (tIndex < temp.length) { +temp[tIndex++] = this.annotations[i]; +}} +if (swap) { +this.annotations = temp; +if (unhook) { +this.unhookAnnotation (aa); +}}return swap; +}, "jalview.datamodel.AlignmentAnnotation,~B"); +Clazz.defineMethod (c$, "unhookAnnotation", +($fz = function (aa) { +if (aa.sequenceRef != null) { +aa.sequenceRef.removeAlignmentAnnotation (aa); +}if (aa.groupRef != null) { +aa.groupRef = null; +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "addAnnotation", +function (aa) { +this.addAnnotation (aa, -1); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "addAnnotation", +function (aa, pos) { +if (aa.getRNAStruc () != null) { +this.$hasRNAStructure = true; +}var aSize = 1; +if (this.annotations != null) { +aSize = this.annotations.length + 1; +}var temp = new Array (aSize); +var i = 0; +if (pos == -1 || pos >= aSize) { +temp[aSize - 1] = aa; +} else { +temp[pos] = aa; +}if (aSize > 1) { +var p = 0; +for (i = 0; i < (aSize - 1); i++, p++) { +if (p == pos) { +p++; +}if (p < temp.length) { +temp[p] = this.annotations[i]; +}} +}this.annotations = temp; +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.overrideMethod (c$, "setAnnotationIndex", +function (aa, index) { +if (aa == null || this.annotations == null || this.annotations.length - 1 < index) { +return; +}var aSize = this.annotations.length; +var temp = new Array (aSize); +temp[index] = aa; +for (var i = 0; i < aSize; i++) { +if (i == index) { +continue; +}if (i < index) { +temp[i] = this.annotations[i]; +} else { +temp[i] = this.annotations[i - 1]; +}} +this.annotations = temp; +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.defineMethod (c$, "getAlignmentAnnotation", +function () { +return this.annotations; +}); +Clazz.overrideMethod (c$, "setNucleotide", +function (b) { +if (b) { +this.type = 1; +} else { +this.type = 0; +}}, "~B"); +Clazz.defineMethod (c$, "isNucleotide", +function () { +if (this.type == 1) { +return true; +} else { +return false; +}}); +Clazz.overrideMethod (c$, "hasRNAStructure", +function () { +return this.$hasRNAStructure; +}); +Clazz.overrideMethod (c$, "setDataset", +function (data) { +if (this.dataset == null && data == null) { +var seqs = new Array (this.getHeight ()); +var currentSeq; +for (var i = 0; i < this.getHeight (); i++) { +currentSeq = this.getSequenceAt (i); +if (currentSeq.getDatasetSequence () != null) { +seqs[i] = currentSeq.getDatasetSequence (); +} else { +seqs[i] = currentSeq.createDatasetSequence (); +}} +this.dataset = new jalview.datamodel.Alignment (seqs); +} else if (this.dataset == null && data != null) { +this.dataset = data; +for (var i = 0; i < this.getHeight (); i++) { +var currentSeq = this.getSequenceAt (i); +var dsq = currentSeq.getDatasetSequence (); +if (dsq == null) { +dsq = currentSeq.createDatasetSequence (); +this.dataset.addSequence (dsq); +} else { +while (dsq.getDatasetSequence () != null) { +dsq = dsq.getDatasetSequence (); +} +if (this.dataset.findIndex (dsq) == -1) { +this.dataset.addSequence (dsq); +}}} +}this.dataset.addAlignmentRef (); +}, "jalview.datamodel.Alignment"); +Clazz.defineMethod (c$, "addAlignmentRef", +($fz = function () { +this.alignmentRefs++; +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "getDataset", +function () { +return this.dataset; +}); +Clazz.overrideMethod (c$, "padGaps", +function () { +var modified = false; +var maxLength = -1; +var current; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +for (var j = current.getLength (); j > maxLength; j--) { +if (j > maxLength && !jalview.util.Comparison.isGap (current.getCharAt (j))) { +maxLength = j; +break; +}} +} +maxLength++; +var cLength; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +cLength = current.getLength (); +if (cLength < maxLength) { +current.insertCharAt (cLength, maxLength - cLength, this.gapCharacter); +modified = true; +} else if (current.getLength () > maxLength) { +current.deleteChars (maxLength, current.getLength ()); +}} +return modified; +}); +Clazz.overrideMethod (c$, "justify", +function (right) { +var modified = false; +var maxLength = -1; +var ends = Clazz.newIntArray (this.sequences.size () * 2, 0); +var current; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +ends[i * 2] = current.findIndex (current.getStart ()); +ends[i * 2 + 1] = current.findIndex (current.getStart () + current.getLength ()); +var hitres = false; +for (var j = 0, rs = 0, ssiz = current.getLength (); j < ssiz; j++) { +if (!jalview.util.Comparison.isGap (current.getCharAt (j))) { +if (!hitres) { +ends[i * 2] = j; +hitres = true; +} else { +ends[i * 2 + 1] = j; +if (j - ends[i * 2] > maxLength) { +maxLength = j - ends[i * 2]; +}}}} +} +maxLength++; +var cLength; +var extent; +var diff; +for (var i = 0; i < this.sequences.size (); i++) { +current = this.getSequenceAt (i); +cLength = 1 + ends[i * 2 + 1] - ends[i * 2]; +diff = maxLength - cLength; +extent = current.getLength (); +if (right) { +if (extent > ends[i * 2 + 1]) { +current.deleteChars (ends[i * 2 + 1] + 1, extent); +modified = true; +}if (ends[i * 2] > diff) { +current.deleteChars (0, ends[i * 2] - diff); +modified = true; +} else { +if (ends[i * 2] < diff) { +current.insertCharAt (0, diff - ends[i * 2], this.gapCharacter); +modified = true; +}}} else { +if (ends[i * 2] > 0) { +current.deleteChars (0, ends[i * 2]); +modified = true; +ends[i * 2 + 1] -= ends[i * 2]; +extent -= ends[i * 2]; +}if (extent > maxLength) { +current.deleteChars (maxLength + 1, extent); +modified = true; +} else { +if (extent < maxLength) { +current.insertCharAt (extent, maxLength - extent, this.gapCharacter); +modified = true; +}}}} +return modified; +}, "~B"); +Clazz.defineMethod (c$, "getHiddenSequences", +function () { +return this.hiddenSequences; +}); +Clazz.overrideMethod (c$, "getCompactAlignment", +function () { +{ +var alseqs = new Array (this.sequences.size ()); +var i = 0; +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +alseqs[i++] = new jalview.datamodel.SeqCigar (seq); +} +var cal = new jalview.datamodel.CigarArray (alseqs); +cal.addOperation ('M', this.getWidth ()); +return cal; +}}); +Clazz.overrideMethod (c$, "setProperty", +function (key, value) { +if (this.alignmentProperties == null) { +this.alignmentProperties = new java.util.Hashtable (); +}this.alignmentProperties.put (key, value); +}, "~O,~O"); +Clazz.defineMethod (c$, "getProperty", +function (key) { +if (this.alignmentProperties != null) { +return this.alignmentProperties.get (key); +} else { +return null; +}}, "~O"); +Clazz.defineMethod (c$, "getProperties", +function () { +return this.alignmentProperties; +}); +Clazz.overrideMethod (c$, "addCodonFrame", +function (codons) { +if (codons != null) { +this.codonFrameList.add (codons); +}}, "jalview.datamodel.AlignedCodonFrame"); +Clazz.overrideMethod (c$, "getCodonFrame", +function (seq) { +if (seq == null) { +return null; +}var cframes = new java.util.ArrayList (); +for (var acf, $acf = this.codonFrameList.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +if (acf.involvesSequence (seq)) { +cframes.add (acf); +}} +return cframes; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "setCodonFrames", +function (acfs) { +this.codonFrameList = acfs; +}, "java.util.Set"); +Clazz.defineMethod (c$, "getCodonFrames", +function () { +return this.codonFrameList; +}); +Clazz.overrideMethod (c$, "removeCodonFrame", +function (codons) { +if (codons == null || this.codonFrameList == null) { +return false; +}return this.codonFrameList.remove (codons); +}, "jalview.datamodel.AlignedCodonFrame"); +Clazz.overrideMethod (c$, "append", +function (toappend) { +if (toappend === this) { +System.err.println ("Self append may cause a deadlock."); +}var samegap = toappend.getGapCharacter () == this.getGapCharacter (); +var oldc = toappend.getGapCharacter (); +var hashidden = toappend.getHiddenSequences () != null && toappend.getHiddenSequences ().hiddenSequences != null; +var sqs = (hashidden) ? toappend.getHiddenSequences ().getFullAlignment ().getSequences () : toappend.getSequences (); +if (sqs != null) { +{ +for (var addedsq, $addedsq = sqs.iterator (); $addedsq.hasNext () && ((addedsq = $addedsq.next ()) || true);) { +if (!samegap) { +var oldseq = addedsq.getSequence (); +for (var c = 0; c < oldseq.length; c++) { +if (oldseq[c] == oldc) { +oldseq[c] = this.gapCharacter; +}} +}this.addSequence (addedsq); +} +}}var alan = toappend.getAlignmentAnnotation (); +for (var a = 0; alan != null && a < alan.length; a++) { +this.addAnnotation (alan[a]); +} +this.codonFrameList.addAll (toappend.getCodonFrames ()); +var sg = toappend.getGroups (); +if (sg != null) { +for (var _sg, $_sg = sg.iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) { +this.addGroup (_sg); +} +}if (toappend.getHiddenSequences () != null) { +var hs = toappend.getHiddenSequences (); +if (this.hiddenSequences == null) { +this.hiddenSequences = new jalview.datamodel.HiddenSequences (this); +}if (hs.hiddenSequences != null) { +for (var s = 0; s < hs.hiddenSequences.length; s++) { +if (hs.hiddenSequences[s] != null) { +this.hiddenSequences.hideSequence (hs.hiddenSequences[s]); +}} +}}if (toappend.getProperties () != null) { +var key = toappend.getProperties ().keys (); +while (key.hasMoreElements ()) { +var k = key.nextElement (); +var ourval = this.getProperty (k); +var toapprop = toappend.getProperty (k); +if (ourval != null) { +if (ourval.getClass ().equals (toapprop.getClass ()) && !ourval.equals (toapprop)) { +if (Clazz.instanceOf (ourval, String)) { +this.setProperty (k, (ourval) + "; " + (toapprop)); +} else { +if (Clazz.instanceOf (ourval, java.util.Vector)) { +var theirv = (toapprop).elements (); +while (theirv.hasMoreElements ()) { +(ourval).addElement (theirv); +} +}}}} else { +this.setProperty (k, toapprop); +}} +}}, "jalview.datamodel.AlignmentI"); +Clazz.overrideMethod (c$, "findOrCreateAnnotation", +function (name, calcId, autoCalc, seqRef, groupRef) { +if (this.annotations != null) { +for (var annot, $annot = 0, $$annot = this.getAlignmentAnnotation (); $annot < $$annot.length && ((annot = $$annot[$annot]) || true); $annot++) { +if (annot.autoCalculated == autoCalc && (name.equals (annot.label)) && (calcId == null || annot.getCalcId ().equals (calcId)) && annot.sequenceRef === seqRef && annot.groupRef === groupRef) { +return annot; +}} +}var annot = new jalview.datamodel.AlignmentAnnotation (name, name, new Array (1), 0, 0, 1); +annot.hasText = false; +annot.setCalcId ( String.instantialize (calcId)); +annot.autoCalculated = autoCalc; +if (seqRef != null) { +annot.setSequenceRef (seqRef); +}annot.groupRef = groupRef; +this.addAnnotation (annot); +return annot; +}, "~S,~S,~B,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); +Clazz.overrideMethod (c$, "findAnnotation", +function (calcId) { +var aa = new java.util.ArrayList (); +for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { +if (a.getCalcId () === calcId || (a.getCalcId () != null && calcId != null && a.getCalcId ().equals (calcId))) { +aa.add (a); +}} +return aa; +}, "~S"); +Clazz.overrideMethod (c$, "findAnnotations", +function (seq, calcId, label) { +var aa = new java.util.ArrayList (); +for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { +if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) { +aa.add (ann); +}} +return aa; +}, "jalview.datamodel.SequenceI,~S,~S"); +Clazz.overrideMethod (c$, "moveSelectedSequencesByOne", +function (sg, map, up) { +{ +if (up) { +for (var i = 1, iSize = this.sequences.size (); i < iSize; i++) { +var seq = this.sequences.get (i); +if (!sg.getSequences (map).contains (seq)) { +continue; +}var temp = this.sequences.get (i - 1); +if (sg.getSequences (null).contains (temp)) { +continue; +}this.sequences.set (i, temp); +this.sequences.set (i - 1, seq); +} +} else { +for (var i = this.sequences.size () - 2; i > -1; i--) { +var seq = this.sequences.get (i); +if (!sg.getSequences (map).contains (seq)) { +continue; +}var temp = this.sequences.get (i + 1); +if (sg.getSequences (map).contains (temp)) { +continue; +}this.sequences.set (i, temp); +this.sequences.set (i + 1, seq); +} +}}}, "jalview.datamodel.SequenceGroup,java.util.Map,~B"); +Clazz.overrideMethod (c$, "validateAnnotation", +function (alignmentAnnotation) { +alignmentAnnotation.validateRangeAndDisplay (); +if (this.isNucleotide () && alignmentAnnotation.isValidStruc ()) { +this.$hasRNAStructure = true; +}}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "getSeqrep", +function () { +return this.seqrep; +}); +Clazz.overrideMethod (c$, "setSeqrep", +function (seqrep) { +this.seqrep = seqrep; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "hasSeqrep", +function () { +return this.seqrep != null; +}); +Clazz.overrideMethod (c$, "getEndRes", +function () { +return this.getWidth () - 1; +}); +Clazz.overrideMethod (c$, "getStartRes", +function () { +return 0; +}); +Clazz.overrideMethod (c$, "getContext", +function () { +return this.dataset; +}); +Clazz.defineMethod (c$, "alignAs", +function (al) { +return this.alignAs (al, false, true); +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "alignAs", +function (al, preserveMappedGaps, preserveUnmappedGaps) { +var count = 0; +var thisIsNucleotide = this.isNucleotide (); +var thatIsProtein = !al.isNucleotide (); +if (!thatIsProtein && !thisIsNucleotide) { +return jalview.analysis.AlignmentUtils.alignProteinAsDna (this, al); +}var thisGapChar = this.getGapCharacter (); +var gap = thisIsNucleotide && thatIsProtein ? String.valueOf ( Clazz.newCharArray (-1, [thisGapChar, thisGapChar, thisGapChar])) : String.valueOf (thisGapChar); +for (var alignTo, $alignTo = this.getSequences ().iterator (); $alignTo.hasNext () && ((alignTo = $alignTo.next ()) || true);) { +count += jalview.analysis.AlignmentUtils.alignSequenceAs (alignTo, al, gap, preserveMappedGaps, preserveUnmappedGaps) ? 1 : 0; +} +return count; +}, "jalview.datamodel.AlignmentI,~B,~B"); +Clazz.overrideMethod (c$, "getSequenceNames", +function () { +var names = new java.util.HashSet (); +for (var seq, $seq = this.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +names.add (seq.getName ()); +} +return names; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var seq = this.getSequencesArray (); +{ +return "" + JSON.stringify(seq); +}}); +Clazz.defineStatics (c$, +"PROTEIN", 0, +"NUCLEOTIDE", 1); +}); diff --git a/bin/jalview/datamodel/AlignmentAnnotation.js b/bin/jalview/datamodel/AlignmentAnnotation.js index e321a8d..0be7f1c 100644 --- a/bin/jalview/datamodel/AlignmentAnnotation.js +++ b/bin/jalview/datamodel/AlignmentAnnotation.js @@ -1,623 +1,623 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.HashMap"], "jalview.datamodel.AlignmentAnnotation", ["jalview.analysis.Rna", "jalview.datamodel.Annotation", "$.GraphLine", "jalview.schemes.ResidueProperties", "java.lang.Double", "$.Error", "$.Long", "$.StringBuffer", "$.StringBuilder", "java.util.Collections"], function () { -c$ = Clazz.decorateAsClass (function () { -this.autoCalculated = false; -this.annotationId = null; -this.sequenceRef = null; -this.label = null; -this.description = null; -this.annotations = null; -this.bps = null; -this._rnasecstr = null; -this.invalidrnastruc = -2; -this.sequenceMapping = null; -this.graphMin = 0; -this.graphMax = 0; -this.score = NaN; -this.$hasScore = false; -this.threshold = null; -this.editable = false; -this.hasIcons = false; -this.hasText = false; -this.visible = true; -this.graphGroup = -1; -this.height = 0; -this.graph = 0; -this.graphHeight = 40; -this.padGaps = false; -this.belowAlignment = true; -this.groupRef = null; -this.showAllColLabels = false; -this.scaleColLabel = false; -this.centreColLabels = false; -this.isrna = false; -if (!Clazz.isClassDefined ("jalview.datamodel.AlignmentAnnotation.AnnotCharSequence")) { -jalview.datamodel.AlignmentAnnotation.$AlignmentAnnotation$AnnotCharSequence$ (); -} -this._lastrnaannot = -1; -this.calcId = ""; -this.properties = null; -this._linecolour = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "AlignmentAnnotation"); -Clazz.prepareFields (c$, function () { -this.properties = new java.util.HashMap (); -}); -Clazz.defineMethod (c$, "_updateRnaSecStr", -($fz = function (RNAannot) { -try { -this._rnasecstr = jalview.analysis.Rna.GetBasePairs (RNAannot); -this.bps = jalview.analysis.Rna.GetModeleBP (RNAannot); -this.invalidrnastruc = -1; -} catch (px) { -if (Clazz.exceptionOf (px, jalview.analysis.WUSSParseException)) { -this.invalidrnastruc = px.getProblemPos (); -} else { -throw px; -} -} -if (this.invalidrnastruc > -1) { -return; -}jalview.analysis.Rna.HelixMap (this._rnasecstr); -if (this._rnasecstr != null && this._rnasecstr.length > 0) { -this.isrna = true; -this.showAllColLabels = true; -this.scaleColLabel = true; -this._markRnaHelices (); -}}, $fz.isPrivate = true, $fz), "CharSequence"); -Clazz.defineMethod (c$, "_markRnaHelices", -($fz = function () { -var mxval = 0; -for (var x = 0; x < this._rnasecstr.length; x++) { -var val = 0; -try { -val = (Integer.$valueOf (this._rnasecstr[x].getFeatureGroup ())).intValue (); -if (mxval < val) { -mxval = val; -}} catch (q) { -if (Clazz.exceptionOf (q, NumberFormatException)) { -} else { -throw q; -} -} -;this.annotations[this._rnasecstr[x].getBegin ()].value = val; -this.annotations[this._rnasecstr[x].getEnd ()].value = val; -} -this.setScore (mxval); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "finalize", -function () { -this.sequenceRef = null; -this.groupRef = null; -Clazz.superCall (this, jalview.datamodel.AlignmentAnnotation, "finalize", []); -}); -c$.getGraphValueFromString = Clazz.defineMethod (c$, "getGraphValueFromString", -function (string) { -if (string.equalsIgnoreCase ("BAR_GRAPH")) { -return 1; -} else if (string.equalsIgnoreCase ("LINE_GRAPH")) { -return 2; -} else { -return 0; -}}, "~S"); -Clazz.defineMethod (c$, "ConcenStru", -function (RNAannot) { -this.bps = jalview.analysis.Rna.GetModeleBP (RNAannot); -}, "CharSequence"); -Clazz.makeConstructor (c$, -function (label, description, annotations) { -this.setAnnotationId (); -this.editable = true; -this.label = label; -this.description = description; -this.annotations = annotations; -this.validateRangeAndDisplay (); -}, "~S,~S,~A"); -Clazz.defineMethod (c$, "areLabelsSecondaryStructure", -function () { -var nonSSLabel = false; -this.isrna = false; -var rnastring = new StringBuffer (); -var firstChar = String.fromCharCode (0); -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] == null) { -continue; -}if (this.annotations[i].secondaryStructure == 'H' || this.annotations[i].secondaryStructure == 'E') { -this.hasIcons = new Boolean (this.hasIcons | true).valueOf (); -} else { -if (this.annotations[i].secondaryStructure == '(' || this.annotations[i].secondaryStructure == '[' || this.annotations[i].secondaryStructure == '<' || this.annotations[i].secondaryStructure == '{' || this.annotations[i].secondaryStructure == 'A' || this.annotations[i].secondaryStructure == 'B' || this.annotations[i].secondaryStructure == 'C' || this.annotations[i].secondaryStructure == 'D' || this.annotations[i].secondaryStructure == 'E' || this.annotations[i].secondaryStructure == 'F' || this.annotations[i].secondaryStructure == 'G' || this.annotations[i].secondaryStructure == 'H' || this.annotations[i].secondaryStructure == 'I' || this.annotations[i].secondaryStructure == 'J' || this.annotations[i].secondaryStructure == 'K' || this.annotations[i].secondaryStructure == 'L' || this.annotations[i].secondaryStructure == 'M' || this.annotations[i].secondaryStructure == 'N' || this.annotations[i].secondaryStructure == 'O' || this.annotations[i].secondaryStructure == 'P' || this.annotations[i].secondaryStructure == 'Q' || this.annotations[i].secondaryStructure == 'R' || this.annotations[i].secondaryStructure == 'S' || this.annotations[i].secondaryStructure == 'T' || this.annotations[i].secondaryStructure == 'U' || this.annotations[i].secondaryStructure == 'V' || this.annotations[i].secondaryStructure == 'W' || this.annotations[i].secondaryStructure == 'X' || this.annotations[i].secondaryStructure == 'Y' || this.annotations[i].secondaryStructure == 'Z') { -this.hasIcons = new Boolean (this.hasIcons | true).valueOf (); -this.isrna = new Boolean (this.isrna | true).valueOf (); -}}if (this.annotations[i].displayCharacter == null || this.annotations[i].displayCharacter.length == 0) { -rnastring.append ('.'); -continue; -}if (this.annotations[i].displayCharacter.length == 1) { -firstChar = this.annotations[i].displayCharacter.charAt (0); -if (this.annotations[i].secondaryStructure != ' ' && !this.hasIcons && firstChar != ' ' && firstChar != '$' && firstChar.charCodeAt (0) != 0xCE && firstChar != '(' && firstChar != '[' && firstChar != '>' && firstChar != '{' && firstChar != 'A' && firstChar != 'B' && firstChar != 'C' && firstChar != 'D' && firstChar != 'E' && firstChar != 'F' && firstChar != 'G' && firstChar != 'H' && firstChar != 'I' && firstChar != 'J' && firstChar != 'K' && firstChar != 'L' && firstChar != 'M' && firstChar != 'N' && firstChar != 'O' && firstChar != 'P' && firstChar != 'Q' && firstChar != 'R' && firstChar != 'S' && firstChar != 'T' && firstChar != 'U' && firstChar != 'V' && firstChar != 'W' && firstChar != 'X' && firstChar != 'Y' && firstChar != 'Z' && firstChar != '-' && firstChar.charCodeAt (0) < jalview.schemes.ResidueProperties.aaIndex.length) { -if (jalview.schemes.ResidueProperties.aaIndex[firstChar.charCodeAt (0)] < 23) { -nonSSLabel = true; -}}} else { -rnastring.append (this.annotations[i].displayCharacter.charAt (1)); -}if (this.annotations[i].displayCharacter.length > 0) { -this.hasText = true; -}} -if (nonSSLabel) { -this.hasIcons = false; -for (var j = 0; j < this.annotations.length; j++) { -if (this.annotations[j] != null && this.annotations[j].secondaryStructure != ' ') { -this.annotations[j].displayCharacter = String.valueOf (this.annotations[j].secondaryStructure); -this.annotations[j].secondaryStructure = ' '; -}} -} else { -if (this.isrna) { -this._updateRnaSecStr (Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null)); -}}}); -Clazz.defineMethod (c$, "getRNAStruc", -function () { -if (this.isrna) { -var rnastruc = Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null).toString (); -if (this._lastrnaannot != rnastruc.hashCode ()) { -this._lastrnaannot = rnastruc.hashCode (); -this._updateRnaSecStr (rnastruc); -}return rnastruc; -}return null; -}); -Clazz.makeConstructor (c$, -function (label, description, annotations, min, max, graphType) { -this.setAnnotationId (); -this.editable = graphType == 0; -this.label = label; -this.description = description; -this.annotations = annotations; -this.graph = graphType; -this.graphMin = min; -this.graphMax = max; -this.validateRangeAndDisplay (); -}, "~S,~S,~A,~N,~N,~N"); -Clazz.defineMethod (c$, "validateRangeAndDisplay", -function () { -if (this.annotations == null) { -this.visible = false; -return; -}var graphType = this.graph; -var min = this.graphMin; -var max = this.graphMax; -var drawValues = true; -this._linecolour = null; -if (min == max) { -min = 999999999; -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] == null) { -continue; -}if (drawValues && this.annotations[i].displayCharacter != null && this.annotations[i].displayCharacter.length > 1) { -drawValues = false; -}if (this.annotations[i].value > max) { -max = this.annotations[i].value; -}if (this.annotations[i].value < min) { -min = this.annotations[i].value; -}if (this._linecolour == null && this.annotations[i].colour != null) { -this._linecolour = this.annotations[i].colour; -}} -if (min > 0) { -min = 0; -} else { -if (max < 0) { -max = 0; -}}}this.graphMin = min; -this.graphMax = max; -this.areLabelsSecondaryStructure (); -if (!drawValues && graphType != 0) { -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] != null) { -this.annotations[i].displayCharacter = ""; -}} -}}); -Clazz.makeConstructor (c$, -function (annotation) { -this.setAnnotationId (); -this.label = String.instantialize (annotation.label); -if (annotation.description != null) { -this.description = String.instantialize (annotation.description); -}this.graphMin = annotation.graphMin; -this.graphMax = annotation.graphMax; -this.graph = annotation.graph; -this.graphHeight = annotation.graphHeight; -this.graphGroup = annotation.graphGroup; -this.groupRef = annotation.groupRef; -this.editable = annotation.editable; -this.autoCalculated = annotation.autoCalculated; -this.hasIcons = annotation.hasIcons; -this.hasText = annotation.hasText; -this.height = annotation.height; -this.label = annotation.label; -this.padGaps = annotation.padGaps; -this.visible = annotation.visible; -this.centreColLabels = annotation.centreColLabels; -this.scaleColLabel = annotation.scaleColLabel; -this.showAllColLabels = annotation.showAllColLabels; -this.calcId = annotation.calcId; -if (annotation.properties != null) { -this.properties = new java.util.HashMap (); -for (var val, $val = annotation.properties.entrySet ().iterator (); $val.hasNext () && ((val = $val.next ()) || true);) { -this.properties.put (val.getKey (), val.getValue ()); -} -}if (this.$hasScore = annotation.$hasScore) { -this.score = annotation.score; -}if (annotation.threshold != null) { -this.threshold = new jalview.datamodel.GraphLine (annotation.threshold); -}var ann = annotation.annotations; -if (annotation.annotations != null) { -this.annotations = new Array (ann.length); -for (var i = 0; i < ann.length; i++) { -if (ann[i] != null) { -this.annotations[i] = new jalview.datamodel.Annotation (ann[i]); -if (this._linecolour != null) { -this._linecolour = this.annotations[i].colour; -}}} -}if (annotation.sequenceRef != null) { -this.sequenceRef = annotation.sequenceRef; -if (annotation.sequenceMapping != null) { -var p = null; -this.sequenceMapping = new java.util.HashMap (); -var pos = annotation.sequenceMapping.keySet ().iterator (); -while (pos.hasNext ()) { -p = pos.next (); -var a = annotation.sequenceMapping.get (p); -if (a == null) { -continue; -}if (ann != null) { -for (var i = 0; i < ann.length; i++) { -if (ann[i] === a) { -this.sequenceMapping.put (p, this.annotations[i]); -}} -}} -} else { -this.sequenceMapping = null; -}}{ -}this.validateRangeAndDisplay (); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "restrict", -function (startRes, endRes) { -if (this.annotations == null) { -return; -}if (startRes < 0) { -startRes = 0; -}if (startRes >= this.annotations.length) { -startRes = this.annotations.length - 1; -}if (endRes >= this.annotations.length) { -endRes = this.annotations.length - 1; -}if (this.annotations == null) { -return; -}var temp = new Array (endRes - startRes + 1); -if (startRes < this.annotations.length) { -System.arraycopy (this.annotations, startRes, temp, 0, endRes - startRes + 1); -}if (this.sequenceRef != null) { -var spos = this.sequenceRef.findPosition (startRes); -var epos = this.sequenceRef.findPosition (endRes); -if (this.sequenceMapping != null) { -var newmapping = new java.util.HashMap (); -var e = this.sequenceMapping.keySet ().iterator (); -while (e.hasNext ()) { -var pos = e.next (); -if (pos.intValue () >= spos && pos.intValue () <= epos) { -newmapping.put (pos, this.sequenceMapping.get (pos)); -}} -this.sequenceMapping.clear (); -this.sequenceMapping = newmapping; -}}this.annotations = temp; -}, "~N,~N"); -Clazz.defineMethod (c$, "padAnnotation", -function (length) { -if (this.annotations == null) { -return true; -}if (this.annotations.length < length) { -var na = new Array (length); -System.arraycopy (this.annotations, 0, na, 0, this.annotations.length); -this.annotations = na; -return true; -}return this.annotations.length > length; -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -var buffer = new StringBuilder (256); -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] != null) { -if (this.graph != 0) { -buffer.append (this.annotations[i].value); -} else if (this.hasIcons) { -buffer.append (this.annotations[i].secondaryStructure); -} else { -buffer.append (this.annotations[i].displayCharacter); -}}buffer.append (", "); -} -if (this.label.indexOf ("Consensus") == 0) { -buffer.append ("\n"); -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] != null) { -buffer.append (this.annotations[i].description); -}buffer.append (", "); -} -}return buffer.toString (); -}); -Clazz.defineMethod (c$, "setThreshold", -function (line) { -this.threshold = line; -}, "jalview.datamodel.GraphLine"); -Clazz.defineMethod (c$, "getThreshold", -function () { -return this.threshold; -}); -Clazz.defineMethod (c$, "createSequenceMapping", -function (seqRef, startRes, alreadyMapped) { -if (seqRef == null) { -return; -}this.sequenceRef = seqRef; -if (this.annotations == null) { -return; -}this.sequenceMapping = new java.util.HashMap (); -var seqPos; -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] != null) { -if (alreadyMapped) { -seqPos = seqRef.findPosition (i); -} else { -seqPos = i + startRes; -}this.sequenceMapping.put ( new Integer (seqPos), this.annotations[i]); -}} -}, "jalview.datamodel.SequenceI,~N,~B"); -Clazz.defineMethod (c$, "adjustForAlignment", -function () { -if (this.sequenceRef == null) { -return; -}if (this.annotations == null) { -return; -}var a = 0; -var aSize = this.sequenceRef.getLength (); -if (aSize == 0) { -return; -}var position; -var temp = new Array (aSize); -var index; -for (a = this.sequenceRef.getStart (); a <= this.sequenceRef.getEnd (); a++) { -index = new Integer (a); -if (this.sequenceMapping.containsKey (index)) { -position = this.sequenceRef.findIndex (a) - 1; -temp[position] = this.sequenceMapping.get (index); -}} -this.annotations = temp; -}); -Clazz.defineMethod (c$, "compactAnnotationArray", -function () { -var i = 0; -var iSize = this.annotations.length; -while (i < iSize) { -if (this.annotations[i] == null) { -if (i + 1 < iSize) { -System.arraycopy (this.annotations, i + 1, this.annotations, i, iSize - i - 1); -}iSize--; -} else { -i++; -}} -var ann = this.annotations; -this.annotations = new Array (i); -System.arraycopy (ann, 0, this.annotations, 0, i); -ann = null; -return iSize; -}); -Clazz.defineMethod (c$, "setSequenceRef", -function (sequenceI) { -if (sequenceI != null) { -if (this.sequenceRef != null) { -var rIsDs = this.sequenceRef.getDatasetSequence () == null; -var tIsDs = sequenceI.getDatasetSequence () == null; -if (this.sequenceRef !== sequenceI && (rIsDs && !tIsDs && this.sequenceRef !== sequenceI.getDatasetSequence ()) && (!rIsDs && tIsDs && this.sequenceRef.getDatasetSequence () !== sequenceI) && (!rIsDs && !tIsDs && this.sequenceRef.getDatasetSequence () !== sequenceI.getDatasetSequence ()) && !this.sequenceRef.equals (sequenceI)) { -this.sequenceRef = null; -if (this.sequenceMapping != null) { -this.sequenceMapping = null; -}this.createSequenceMapping (sequenceI, 1, true); -this.adjustForAlignment (); -} else { -this.sequenceRef = sequenceI; -}} else { -this.createSequenceMapping (sequenceI, 1, true); -this.adjustForAlignment (); -}} else { -this.sequenceMapping = null; -this.sequenceRef = null; -}}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getScore", -function () { -return this.score; -}); -Clazz.defineMethod (c$, "setScore", -function (score) { -this.$hasScore = true; -this.score = score; -}, "~N"); -Clazz.defineMethod (c$, "hasScore", -function () { -return this.$hasScore || !Double.isNaN (this.score); -}); -Clazz.makeConstructor (c$, -function (label, description, score) { -this.construct (label, description, null); -this.setScore (score); -}, "~S,~S,~N"); -Clazz.makeConstructor (c$, -function (alignmentAnnotation, colSel) { -this.construct (alignmentAnnotation); -if (this.annotations == null) { -return; -}colSel.makeVisibleAnnotation (this); -}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.ColumnSelection"); -Clazz.defineMethod (c$, "setPadGaps", -function (padgaps, gapchar) { -this.padGaps = padgaps; -if (padgaps) { -this.hasText = true; -for (var i = 0; i < this.annotations.length; i++) { -if (this.annotations[i] == null) { -this.annotations[i] = new jalview.datamodel.Annotation (String.valueOf (gapchar), null, ' ', 0, null); -} else if (this.annotations[i].displayCharacter == null || this.annotations[i].displayCharacter.equals (" ")) { -this.annotations[i].displayCharacter = String.valueOf (gapchar); -}} -}}, "~B,~S"); -Clazz.defineMethod (c$, "getDescription", -function (seqname) { -if (seqname && this.sequenceRef != null) { -var i = this.description.toLowerCase ().indexOf (""); -if (i > -1) { -return "" + this.sequenceRef.getName () + " : " + this.description.substring (i + 6); -}return this.sequenceRef.getName () + " : " + this.description; -}return this.description; -}, "~B"); -Clazz.defineMethod (c$, "isValidStruc", -function () { -return this.invalidrnastruc == -1; -}); -Clazz.defineMethod (c$, "getInvalidStrucPos", -function () { -return this.invalidrnastruc; -}); -Clazz.defineMethod (c$, "getCalcId", -function () { -return this.calcId; -}); -Clazz.defineMethod (c$, "setCalcId", -function (calcId) { -this.calcId = calcId; -}, "~S"); -Clazz.defineMethod (c$, "isRNA", -function () { -return this.isrna; -}); -Clazz.defineMethod (c$, "liftOver", -function (sq, sp2sq) { -if (sp2sq.getMappedWidth () != sp2sq.getWidth ()) { -throw new Error ("liftOver currently not implemented for transfer of annotation between different types of seqeunce"); -}var mapIsTo = (sp2sq != null) ? (sp2sq.getTo () === sq || sp2sq.getTo () === sq.getDatasetSequence ()) : false; -var mapForsq = new java.util.HashMap (); -if (this.sequenceMapping != null) { -if (sp2sq != null) { -for (var ie, $ie = this.sequenceMapping.entrySet ().iterator (); $ie.hasNext () && ((ie = $ie.next ()) || true);) { -var mpos = Integer.$valueOf (mapIsTo ? sp2sq.getMappedPosition ((ie.getKey ()).intValue ()) : sp2sq.getPosition ((ie.getKey ()).intValue ())); -if ((mpos).intValue () >= sq.getStart () && (mpos).intValue () <= sq.getEnd ()) { -mapForsq.put (mpos, ie.getValue ()); -}} -this.sequenceMapping = mapForsq; -this.sequenceRef = sq; -this.adjustForAlignment (); -} else { -}}}, "jalview.datamodel.SequenceI,jalview.datamodel.Mapping"); -Clazz.defineMethod (c$, "remap", -function (newref, mapping, from, to, idxoffset) { -if (mapping != null) { -var old = this.sequenceMapping; -var remap = new java.util.HashMap (); -var index = -1; -for (var mp, $mp = 0, $$mp = mapping; $mp < $$mp.length && ((mp = $$mp[$mp]) || true); $mp++) { -if (index++ < 0) { -continue; -}var ann = null; -if (from == -1) { -ann = this.sequenceMapping.get (Integer.$valueOf (idxoffset + index)); -} else { -if (mp != null && mp.length > from) { -ann = this.sequenceMapping.get (Integer.$valueOf (mp[from])); -}}if (ann != null) { -if (to == -1) { -remap.put (Integer.$valueOf (idxoffset + index), ann); -} else { -if (to > -1 && to < mp.length) { -remap.put (Integer.$valueOf (mp[to]), ann); -}}}} -this.sequenceMapping = remap; -old.clear (); -if (newref != null) { -this.sequenceRef = newref; -}this.adjustForAlignment (); -}}, "jalview.datamodel.SequenceI,~A,~N,~N,~N"); -Clazz.defineMethod (c$, "getProperty", -function (property) { -if (this.properties == null) { -return null; -}return this.properties.get (property); -}, "~S"); -Clazz.defineMethod (c$, "setProperty", -function (property, value) { -if (this.properties == null) { -this.properties = new java.util.HashMap (); -}this.properties.put (property, value); -}, "~S,~S"); -Clazz.defineMethod (c$, "hasProperties", -function () { -return this.properties != null && this.properties.size () > 0; -}); -Clazz.defineMethod (c$, "getProperties", -function () { -if (this.properties == null) { -return java.util.Collections.emptyList (); -}return this.properties.keySet (); -}); -Clazz.defineMethod (c$, "getAnnotationForPosition", -function (position) { -return this.sequenceMapping == null ? null : this.sequenceMapping.get (new Integer (position)); -}, "~N"); -Clazz.defineMethod (c$, "setAnnotationId", -function () { -this.annotationId = "ann" + Long.toString (jalview.datamodel.AlignmentAnnotation.nextId ()); -}); -c$.nextId = Clazz.defineMethod (c$, "nextId", -function () { -return jalview.datamodel.AlignmentAnnotation.counter++; -}); -c$.$AlignmentAnnotation$AnnotCharSequence$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.offset = 0; -this.max = 0; -Clazz.instantialize (this, arguments); -}, jalview.datamodel.AlignmentAnnotation, "AnnotCharSequence", null, CharSequence); -Clazz.makeConstructor (c$, -function () { -this.construct (0, this.b$["jalview.datamodel.AlignmentAnnotation"].annotations.length); -}); -Clazz.makeConstructor (c$, -function (a, b) { -this.offset = a; -this.max = b; -}, "~N,~N"); -Clazz.overrideMethod (c$, "subSequence", -function (a, b) { -return Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null, this.offset + a, this.offset + b); -}, "~N,~N"); -Clazz.overrideMethod (c$, "length", -function () { -return this.max - this.offset; -}); -Clazz.overrideMethod (c$, "charAt", -function (a) { -return ((a + this.offset < 0) || (a + this.offset) >= this.max || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset] == null || (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].secondaryStructure <= ' ') ? ' ' : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter == null || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter.length == 0 ? this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].secondaryStructure : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter.charAt (0)); -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -var a = Clazz.newCharArray (this.max - this.offset, '\0'); -var b = this.b$["jalview.datamodel.AlignmentAnnotation"].annotations.length; -for (var c = this.offset; c < b; c++) { -a[c] = (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c] == null || ((this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].secondaryStructure).charCodeAt (0) <= 32)) ? ' ' : (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter == null || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter.length == 0 ? this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].secondaryStructure : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter.charAt (0)); -} -return String.instantialize (a); -}); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"ANNOTATION_ID_PREFIX", "ann", -"SEQUENCE_PROFILE", 0, -"STRUCTURE_PROFILE", 1, -"CDNA_PROFILE", 2, -"counter", 0, -"NO_GRAPH", 0, -"BAR_GRAPH", 1, -"LINE_GRAPH", 2); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.HashMap"], "jalview.datamodel.AlignmentAnnotation", ["jalview.analysis.Rna", "jalview.datamodel.Annotation", "$.GraphLine", "jalview.schemes.ResidueProperties", "java.lang.Double", "$.Error", "$.Long", "$.StringBuffer", "$.StringBuilder", "java.util.Collections"], function () { +c$ = Clazz.decorateAsClass (function () { +this.autoCalculated = false; +this.annotationId = null; +this.sequenceRef = null; +this.label = null; +this.description = null; +this.annotations = null; +this.bps = null; +this._rnasecstr = null; +this.invalidrnastruc = -2; +this.sequenceMapping = null; +this.graphMin = 0; +this.graphMax = 0; +this.score = NaN; +this.$hasScore = false; +this.threshold = null; +this.editable = false; +this.hasIcons = false; +this.hasText = false; +this.visible = true; +this.graphGroup = -1; +this.height = 0; +this.graph = 0; +this.graphHeight = 40; +this.padGaps = false; +this.belowAlignment = true; +this.groupRef = null; +this.showAllColLabels = false; +this.scaleColLabel = false; +this.centreColLabels = false; +this.isrna = false; +if (!Clazz.isClassDefined ("jalview.datamodel.AlignmentAnnotation.AnnotCharSequence")) { +jalview.datamodel.AlignmentAnnotation.$AlignmentAnnotation$AnnotCharSequence$ (); +} +this._lastrnaannot = -1; +this.calcId = ""; +this.properties = null; +this._linecolour = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "AlignmentAnnotation"); +Clazz.prepareFields (c$, function () { +this.properties = new java.util.HashMap (); +}); +Clazz.defineMethod (c$, "_updateRnaSecStr", +($fz = function (RNAannot) { +try { +this._rnasecstr = jalview.analysis.Rna.GetBasePairs (RNAannot); +this.bps = jalview.analysis.Rna.GetModeleBP (RNAannot); +this.invalidrnastruc = -1; +} catch (px) { +if (Clazz.exceptionOf (px, jalview.analysis.WUSSParseException)) { +this.invalidrnastruc = px.getProblemPos (); +} else { +throw px; +} +} +if (this.invalidrnastruc > -1) { +return; +}jalview.analysis.Rna.HelixMap (this._rnasecstr); +if (this._rnasecstr != null && this._rnasecstr.length > 0) { +this.isrna = true; +this.showAllColLabels = true; +this.scaleColLabel = true; +this._markRnaHelices (); +}}, $fz.isPrivate = true, $fz), "CharSequence"); +Clazz.defineMethod (c$, "_markRnaHelices", +($fz = function () { +var mxval = 0; +for (var x = 0; x < this._rnasecstr.length; x++) { +var val = 0; +try { +val = (Integer.$valueOf (this._rnasecstr[x].getFeatureGroup ())).intValue (); +if (mxval < val) { +mxval = val; +}} catch (q) { +if (Clazz.exceptionOf (q, NumberFormatException)) { +} else { +throw q; +} +} +;this.annotations[this._rnasecstr[x].getBegin ()].value = val; +this.annotations[this._rnasecstr[x].getEnd ()].value = val; +} +this.setScore (mxval); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "finalize", +function () { +this.sequenceRef = null; +this.groupRef = null; +Clazz.superCall (this, jalview.datamodel.AlignmentAnnotation, "finalize", []); +}); +c$.getGraphValueFromString = Clazz.defineMethod (c$, "getGraphValueFromString", +function (string) { +if (string.equalsIgnoreCase ("BAR_GRAPH")) { +return 1; +} else if (string.equalsIgnoreCase ("LINE_GRAPH")) { +return 2; +} else { +return 0; +}}, "~S"); +Clazz.defineMethod (c$, "ConcenStru", +function (RNAannot) { +this.bps = jalview.analysis.Rna.GetModeleBP (RNAannot); +}, "CharSequence"); +Clazz.makeConstructor (c$, +function (label, description, annotations) { +this.setAnnotationId (); +this.editable = true; +this.label = label; +this.description = description; +this.annotations = annotations; +this.validateRangeAndDisplay (); +}, "~S,~S,~A"); +Clazz.defineMethod (c$, "areLabelsSecondaryStructure", +function () { +var nonSSLabel = false; +this.isrna = false; +var rnastring = new StringBuffer (); +var firstChar = String.fromCharCode (0); +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] == null) { +continue; +}if (this.annotations[i].secondaryStructure == 'H' || this.annotations[i].secondaryStructure == 'E') { +this.hasIcons = new Boolean (this.hasIcons | true).valueOf (); +} else { +if (this.annotations[i].secondaryStructure == '(' || this.annotations[i].secondaryStructure == '[' || this.annotations[i].secondaryStructure == '<' || this.annotations[i].secondaryStructure == '{' || this.annotations[i].secondaryStructure == 'A' || this.annotations[i].secondaryStructure == 'B' || this.annotations[i].secondaryStructure == 'C' || this.annotations[i].secondaryStructure == 'D' || this.annotations[i].secondaryStructure == 'E' || this.annotations[i].secondaryStructure == 'F' || this.annotations[i].secondaryStructure == 'G' || this.annotations[i].secondaryStructure == 'H' || this.annotations[i].secondaryStructure == 'I' || this.annotations[i].secondaryStructure == 'J' || this.annotations[i].secondaryStructure == 'K' || this.annotations[i].secondaryStructure == 'L' || this.annotations[i].secondaryStructure == 'M' || this.annotations[i].secondaryStructure == 'N' || this.annotations[i].secondaryStructure == 'O' || this.annotations[i].secondaryStructure == 'P' || this.annotations[i].secondaryStructure == 'Q' || this.annotations[i].secondaryStructure == 'R' || this.annotations[i].secondaryStructure == 'S' || this.annotations[i].secondaryStructure == 'T' || this.annotations[i].secondaryStructure == 'U' || this.annotations[i].secondaryStructure == 'V' || this.annotations[i].secondaryStructure == 'W' || this.annotations[i].secondaryStructure == 'X' || this.annotations[i].secondaryStructure == 'Y' || this.annotations[i].secondaryStructure == 'Z') { +this.hasIcons = new Boolean (this.hasIcons | true).valueOf (); +this.isrna = new Boolean (this.isrna | true).valueOf (); +}}if (this.annotations[i].displayCharacter == null || this.annotations[i].displayCharacter.length == 0) { +rnastring.append ('.'); +continue; +}if (this.annotations[i].displayCharacter.length == 1) { +firstChar = this.annotations[i].displayCharacter.charAt (0); +if (this.annotations[i].secondaryStructure != ' ' && !this.hasIcons && firstChar != ' ' && firstChar != '$' && firstChar.charCodeAt (0) != 0xCE && firstChar != '(' && firstChar != '[' && firstChar != '>' && firstChar != '{' && firstChar != 'A' && firstChar != 'B' && firstChar != 'C' && firstChar != 'D' && firstChar != 'E' && firstChar != 'F' && firstChar != 'G' && firstChar != 'H' && firstChar != 'I' && firstChar != 'J' && firstChar != 'K' && firstChar != 'L' && firstChar != 'M' && firstChar != 'N' && firstChar != 'O' && firstChar != 'P' && firstChar != 'Q' && firstChar != 'R' && firstChar != 'S' && firstChar != 'T' && firstChar != 'U' && firstChar != 'V' && firstChar != 'W' && firstChar != 'X' && firstChar != 'Y' && firstChar != 'Z' && firstChar != '-' && firstChar.charCodeAt (0) < jalview.schemes.ResidueProperties.aaIndex.length) { +if (jalview.schemes.ResidueProperties.aaIndex[firstChar.charCodeAt (0)] < 23) { +nonSSLabel = true; +}}} else { +rnastring.append (this.annotations[i].displayCharacter.charAt (1)); +}if (this.annotations[i].displayCharacter.length > 0) { +this.hasText = true; +}} +if (nonSSLabel) { +this.hasIcons = false; +for (var j = 0; j < this.annotations.length; j++) { +if (this.annotations[j] != null && this.annotations[j].secondaryStructure != ' ') { +this.annotations[j].displayCharacter = String.valueOf (this.annotations[j].secondaryStructure); +this.annotations[j].secondaryStructure = ' '; +}} +} else { +if (this.isrna) { +this._updateRnaSecStr (Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null)); +}}}); +Clazz.defineMethod (c$, "getRNAStruc", +function () { +if (this.isrna) { +var rnastruc = Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null).toString (); +if (this._lastrnaannot != rnastruc.hashCode ()) { +this._lastrnaannot = rnastruc.hashCode (); +this._updateRnaSecStr (rnastruc); +}return rnastruc; +}return null; +}); +Clazz.makeConstructor (c$, +function (label, description, annotations, min, max, graphType) { +this.setAnnotationId (); +this.editable = graphType == 0; +this.label = label; +this.description = description; +this.annotations = annotations; +this.graph = graphType; +this.graphMin = min; +this.graphMax = max; +this.validateRangeAndDisplay (); +}, "~S,~S,~A,~N,~N,~N"); +Clazz.defineMethod (c$, "validateRangeAndDisplay", +function () { +if (this.annotations == null) { +this.visible = false; +return; +}var graphType = this.graph; +var min = this.graphMin; +var max = this.graphMax; +var drawValues = true; +this._linecolour = null; +if (min == max) { +min = 999999999; +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] == null) { +continue; +}if (drawValues && this.annotations[i].displayCharacter != null && this.annotations[i].displayCharacter.length > 1) { +drawValues = false; +}if (this.annotations[i].value > max) { +max = this.annotations[i].value; +}if (this.annotations[i].value < min) { +min = this.annotations[i].value; +}if (this._linecolour == null && this.annotations[i].colour != null) { +this._linecolour = this.annotations[i].colour; +}} +if (min > 0) { +min = 0; +} else { +if (max < 0) { +max = 0; +}}}this.graphMin = min; +this.graphMax = max; +this.areLabelsSecondaryStructure (); +if (!drawValues && graphType != 0) { +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] != null) { +this.annotations[i].displayCharacter = ""; +}} +}}); +Clazz.makeConstructor (c$, +function (annotation) { +this.setAnnotationId (); +this.label = String.instantialize (annotation.label); +if (annotation.description != null) { +this.description = String.instantialize (annotation.description); +}this.graphMin = annotation.graphMin; +this.graphMax = annotation.graphMax; +this.graph = annotation.graph; +this.graphHeight = annotation.graphHeight; +this.graphGroup = annotation.graphGroup; +this.groupRef = annotation.groupRef; +this.editable = annotation.editable; +this.autoCalculated = annotation.autoCalculated; +this.hasIcons = annotation.hasIcons; +this.hasText = annotation.hasText; +this.height = annotation.height; +this.label = annotation.label; +this.padGaps = annotation.padGaps; +this.visible = annotation.visible; +this.centreColLabels = annotation.centreColLabels; +this.scaleColLabel = annotation.scaleColLabel; +this.showAllColLabels = annotation.showAllColLabels; +this.calcId = annotation.calcId; +if (annotation.properties != null) { +this.properties = new java.util.HashMap (); +for (var val, $val = annotation.properties.entrySet ().iterator (); $val.hasNext () && ((val = $val.next ()) || true);) { +this.properties.put (val.getKey (), val.getValue ()); +} +}if (this.$hasScore = annotation.$hasScore) { +this.score = annotation.score; +}if (annotation.threshold != null) { +this.threshold = new jalview.datamodel.GraphLine (annotation.threshold); +}var ann = annotation.annotations; +if (annotation.annotations != null) { +this.annotations = new Array (ann.length); +for (var i = 0; i < ann.length; i++) { +if (ann[i] != null) { +this.annotations[i] = new jalview.datamodel.Annotation (ann[i]); +if (this._linecolour != null) { +this._linecolour = this.annotations[i].colour; +}}} +}if (annotation.sequenceRef != null) { +this.sequenceRef = annotation.sequenceRef; +if (annotation.sequenceMapping != null) { +var p = null; +this.sequenceMapping = new java.util.HashMap (); +var pos = annotation.sequenceMapping.keySet ().iterator (); +while (pos.hasNext ()) { +p = pos.next (); +var a = annotation.sequenceMapping.get (p); +if (a == null) { +continue; +}if (ann != null) { +for (var i = 0; i < ann.length; i++) { +if (ann[i] === a) { +this.sequenceMapping.put (p, this.annotations[i]); +}} +}} +} else { +this.sequenceMapping = null; +}}{ +}this.validateRangeAndDisplay (); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "restrict", +function (startRes, endRes) { +if (this.annotations == null) { +return; +}if (startRes < 0) { +startRes = 0; +}if (startRes >= this.annotations.length) { +startRes = this.annotations.length - 1; +}if (endRes >= this.annotations.length) { +endRes = this.annotations.length - 1; +}if (this.annotations == null) { +return; +}var temp = new Array (endRes - startRes + 1); +if (startRes < this.annotations.length) { +System.arraycopy (this.annotations, startRes, temp, 0, endRes - startRes + 1); +}if (this.sequenceRef != null) { +var spos = this.sequenceRef.findPosition (startRes); +var epos = this.sequenceRef.findPosition (endRes); +if (this.sequenceMapping != null) { +var newmapping = new java.util.HashMap (); +var e = this.sequenceMapping.keySet ().iterator (); +while (e.hasNext ()) { +var pos = e.next (); +if (pos.intValue () >= spos && pos.intValue () <= epos) { +newmapping.put (pos, this.sequenceMapping.get (pos)); +}} +this.sequenceMapping.clear (); +this.sequenceMapping = newmapping; +}}this.annotations = temp; +}, "~N,~N"); +Clazz.defineMethod (c$, "padAnnotation", +function (length) { +if (this.annotations == null) { +return true; +}if (this.annotations.length < length) { +var na = new Array (length); +System.arraycopy (this.annotations, 0, na, 0, this.annotations.length); +this.annotations = na; +return true; +}return this.annotations.length > length; +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +var buffer = new StringBuilder (256); +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] != null) { +if (this.graph != 0) { +buffer.append (this.annotations[i].value); +} else if (this.hasIcons) { +buffer.append (this.annotations[i].secondaryStructure); +} else { +buffer.append (this.annotations[i].displayCharacter); +}}buffer.append (", "); +} +if (this.label.indexOf ("Consensus") == 0) { +buffer.append ("\n"); +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] != null) { +buffer.append (this.annotations[i].description); +}buffer.append (", "); +} +}return buffer.toString (); +}); +Clazz.defineMethod (c$, "setThreshold", +function (line) { +this.threshold = line; +}, "jalview.datamodel.GraphLine"); +Clazz.defineMethod (c$, "getThreshold", +function () { +return this.threshold; +}); +Clazz.defineMethod (c$, "createSequenceMapping", +function (seqRef, startRes, alreadyMapped) { +if (seqRef == null) { +return; +}this.sequenceRef = seqRef; +if (this.annotations == null) { +return; +}this.sequenceMapping = new java.util.HashMap (); +var seqPos; +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] != null) { +if (alreadyMapped) { +seqPos = seqRef.findPosition (i); +} else { +seqPos = i + startRes; +}this.sequenceMapping.put ( new Integer (seqPos), this.annotations[i]); +}} +}, "jalview.datamodel.SequenceI,~N,~B"); +Clazz.defineMethod (c$, "adjustForAlignment", +function () { +if (this.sequenceRef == null) { +return; +}if (this.annotations == null) { +return; +}var a = 0; +var aSize = this.sequenceRef.getLength (); +if (aSize == 0) { +return; +}var position; +var temp = new Array (aSize); +var index; +for (a = this.sequenceRef.getStart (); a <= this.sequenceRef.getEnd (); a++) { +index = new Integer (a); +if (this.sequenceMapping.containsKey (index)) { +position = this.sequenceRef.findIndex (a) - 1; +temp[position] = this.sequenceMapping.get (index); +}} +this.annotations = temp; +}); +Clazz.defineMethod (c$, "compactAnnotationArray", +function () { +var i = 0; +var iSize = this.annotations.length; +while (i < iSize) { +if (this.annotations[i] == null) { +if (i + 1 < iSize) { +System.arraycopy (this.annotations, i + 1, this.annotations, i, iSize - i - 1); +}iSize--; +} else { +i++; +}} +var ann = this.annotations; +this.annotations = new Array (i); +System.arraycopy (ann, 0, this.annotations, 0, i); +ann = null; +return iSize; +}); +Clazz.defineMethod (c$, "setSequenceRef", +function (sequenceI) { +if (sequenceI != null) { +if (this.sequenceRef != null) { +var rIsDs = this.sequenceRef.getDatasetSequence () == null; +var tIsDs = sequenceI.getDatasetSequence () == null; +if (this.sequenceRef !== sequenceI && (rIsDs && !tIsDs && this.sequenceRef !== sequenceI.getDatasetSequence ()) && (!rIsDs && tIsDs && this.sequenceRef.getDatasetSequence () !== sequenceI) && (!rIsDs && !tIsDs && this.sequenceRef.getDatasetSequence () !== sequenceI.getDatasetSequence ()) && !this.sequenceRef.equals (sequenceI)) { +this.sequenceRef = null; +if (this.sequenceMapping != null) { +this.sequenceMapping = null; +}this.createSequenceMapping (sequenceI, 1, true); +this.adjustForAlignment (); +} else { +this.sequenceRef = sequenceI; +}} else { +this.createSequenceMapping (sequenceI, 1, true); +this.adjustForAlignment (); +}} else { +this.sequenceMapping = null; +this.sequenceRef = null; +}}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getScore", +function () { +return this.score; +}); +Clazz.defineMethod (c$, "setScore", +function (score) { +this.$hasScore = true; +this.score = score; +}, "~N"); +Clazz.defineMethod (c$, "hasScore", +function () { +return this.$hasScore || !Double.isNaN (this.score); +}); +Clazz.makeConstructor (c$, +function (label, description, score) { +this.construct (label, description, null); +this.setScore (score); +}, "~S,~S,~N"); +Clazz.makeConstructor (c$, +function (alignmentAnnotation, colSel) { +this.construct (alignmentAnnotation); +if (this.annotations == null) { +return; +}colSel.makeVisibleAnnotation (this); +}, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.ColumnSelection"); +Clazz.defineMethod (c$, "setPadGaps", +function (padgaps, gapchar) { +this.padGaps = padgaps; +if (padgaps) { +this.hasText = true; +for (var i = 0; i < this.annotations.length; i++) { +if (this.annotations[i] == null) { +this.annotations[i] = new jalview.datamodel.Annotation (String.valueOf (gapchar), null, ' ', 0, null); +} else if (this.annotations[i].displayCharacter == null || this.annotations[i].displayCharacter.equals (" ")) { +this.annotations[i].displayCharacter = String.valueOf (gapchar); +}} +}}, "~B,~S"); +Clazz.defineMethod (c$, "getDescription", +function (seqname) { +if (seqname && this.sequenceRef != null) { +var i = this.description.toLowerCase ().indexOf (""); +if (i > -1) { +return "" + this.sequenceRef.getName () + " : " + this.description.substring (i + 6); +}return this.sequenceRef.getName () + " : " + this.description; +}return this.description; +}, "~B"); +Clazz.defineMethod (c$, "isValidStruc", +function () { +return this.invalidrnastruc == -1; +}); +Clazz.defineMethod (c$, "getInvalidStrucPos", +function () { +return this.invalidrnastruc; +}); +Clazz.defineMethod (c$, "getCalcId", +function () { +return this.calcId; +}); +Clazz.defineMethod (c$, "setCalcId", +function (calcId) { +this.calcId = calcId; +}, "~S"); +Clazz.defineMethod (c$, "isRNA", +function () { +return this.isrna; +}); +Clazz.defineMethod (c$, "liftOver", +function (sq, sp2sq) { +if (sp2sq.getMappedWidth () != sp2sq.getWidth ()) { +throw new Error ("liftOver currently not implemented for transfer of annotation between different types of seqeunce"); +}var mapIsTo = (sp2sq != null) ? (sp2sq.getTo () === sq || sp2sq.getTo () === sq.getDatasetSequence ()) : false; +var mapForsq = new java.util.HashMap (); +if (this.sequenceMapping != null) { +if (sp2sq != null) { +for (var ie, $ie = this.sequenceMapping.entrySet ().iterator (); $ie.hasNext () && ((ie = $ie.next ()) || true);) { +var mpos = Integer.$valueOf (mapIsTo ? sp2sq.getMappedPosition ((ie.getKey ()).intValue ()) : sp2sq.getPosition ((ie.getKey ()).intValue ())); +if ((mpos).intValue () >= sq.getStart () && (mpos).intValue () <= sq.getEnd ()) { +mapForsq.put (mpos, ie.getValue ()); +}} +this.sequenceMapping = mapForsq; +this.sequenceRef = sq; +this.adjustForAlignment (); +} else { +}}}, "jalview.datamodel.SequenceI,jalview.datamodel.Mapping"); +Clazz.defineMethod (c$, "remap", +function (newref, mapping, from, to, idxoffset) { +if (mapping != null) { +var old = this.sequenceMapping; +var remap = new java.util.HashMap (); +var index = -1; +for (var mp, $mp = 0, $$mp = mapping; $mp < $$mp.length && ((mp = $$mp[$mp]) || true); $mp++) { +if (index++ < 0) { +continue; +}var ann = null; +if (from == -1) { +ann = this.sequenceMapping.get (Integer.$valueOf (idxoffset + index)); +} else { +if (mp != null && mp.length > from) { +ann = this.sequenceMapping.get (Integer.$valueOf (mp[from])); +}}if (ann != null) { +if (to == -1) { +remap.put (Integer.$valueOf (idxoffset + index), ann); +} else { +if (to > -1 && to < mp.length) { +remap.put (Integer.$valueOf (mp[to]), ann); +}}}} +this.sequenceMapping = remap; +old.clear (); +if (newref != null) { +this.sequenceRef = newref; +}this.adjustForAlignment (); +}}, "jalview.datamodel.SequenceI,~A,~N,~N,~N"); +Clazz.defineMethod (c$, "getProperty", +function (property) { +if (this.properties == null) { +return null; +}return this.properties.get (property); +}, "~S"); +Clazz.defineMethod (c$, "setProperty", +function (property, value) { +if (this.properties == null) { +this.properties = new java.util.HashMap (); +}this.properties.put (property, value); +}, "~S,~S"); +Clazz.defineMethod (c$, "hasProperties", +function () { +return this.properties != null && this.properties.size () > 0; +}); +Clazz.defineMethod (c$, "getProperties", +function () { +if (this.properties == null) { +return java.util.Collections.emptyList (); +}return this.properties.keySet (); +}); +Clazz.defineMethod (c$, "getAnnotationForPosition", +function (position) { +return this.sequenceMapping == null ? null : this.sequenceMapping.get (new Integer (position)); +}, "~N"); +Clazz.defineMethod (c$, "setAnnotationId", +function () { +this.annotationId = "ann" + Long.toString (jalview.datamodel.AlignmentAnnotation.nextId ()); +}); +c$.nextId = Clazz.defineMethod (c$, "nextId", +function () { +return jalview.datamodel.AlignmentAnnotation.counter++; +}); +c$.$AlignmentAnnotation$AnnotCharSequence$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.offset = 0; +this.max = 0; +Clazz.instantialize (this, arguments); +}, jalview.datamodel.AlignmentAnnotation, "AnnotCharSequence", null, CharSequence); +Clazz.makeConstructor (c$, +function () { +this.construct (0, this.b$["jalview.datamodel.AlignmentAnnotation"].annotations.length); +}); +Clazz.makeConstructor (c$, +function (a, b) { +this.offset = a; +this.max = b; +}, "~N,~N"); +Clazz.overrideMethod (c$, "subSequence", +function (a, b) { +return Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null, this.offset + a, this.offset + b); +}, "~N,~N"); +Clazz.overrideMethod (c$, "length", +function () { +return this.max - this.offset; +}); +Clazz.overrideMethod (c$, "charAt", +function (a) { +return ((a + this.offset < 0) || (a + this.offset) >= this.max || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset] == null || (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].secondaryStructure <= ' ') ? ' ' : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter == null || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter.length == 0 ? this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].secondaryStructure : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter.charAt (0)); +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +var a = Clazz.newCharArray (this.max - this.offset, '\0'); +var b = this.b$["jalview.datamodel.AlignmentAnnotation"].annotations.length; +for (var c = this.offset; c < b; c++) { +a[c] = (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c] == null || ((this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].secondaryStructure).charCodeAt (0) <= 32)) ? ' ' : (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter == null || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter.length == 0 ? this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].secondaryStructure : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter.charAt (0)); +} +return String.instantialize (a); +}); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"ANNOTATION_ID_PREFIX", "ann", +"SEQUENCE_PROFILE", 0, +"STRUCTURE_PROFILE", 1, +"CDNA_PROFILE", 2, +"counter", 0, +"NO_GRAPH", 0, +"BAR_GRAPH", 1, +"LINE_GRAPH", 2); +}); diff --git a/bin/jalview/datamodel/AlignmentI.js b/bin/jalview/datamodel/AlignmentI.js index 80e1794..d1f3174 100644 --- a/bin/jalview/datamodel/AlignmentI.js +++ b/bin/jalview/datamodel/AlignmentI.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.AnnotatedCollectionI"], "jalview.datamodel.AlignmentI", null, function () { -Clazz.declareInterface (jalview.datamodel, "AlignmentI", jalview.datamodel.AnnotatedCollectionI); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.AnnotatedCollectionI"], "jalview.datamodel.AlignmentI", null, function () { +Clazz.declareInterface (jalview.datamodel, "AlignmentI", jalview.datamodel.AnnotatedCollectionI); +}); diff --git a/bin/jalview/datamodel/AlignmentOrder.js b/bin/jalview/datamodel/AlignmentOrder.js index 0fb0cbb..281aa17 100644 --- a/bin/jalview/datamodel/AlignmentOrder.js +++ b/bin/jalview/datamodel/AlignmentOrder.js @@ -1,118 +1,118 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.AlignmentOrder", ["java.lang.Error", "java.util.ArrayList", "$.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.Type = 0; -this.Name = null; -this.Order = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "AlignmentOrder"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (anOrder) { -this.Order = anOrder; -}, "java.util.List"); -Clazz.makeConstructor (c$, -function (orderFrom) { -this.Order = new java.util.ArrayList (); -for (var seq, $seq = orderFrom.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -this.Order.add (seq); -} -}, "jalview.datamodel.AlignmentI"); -Clazz.makeConstructor (c$, -function (orderFrom) { -this.Order = new java.util.ArrayList (java.util.Arrays.asList (orderFrom)); -}, "~A"); -Clazz.defineMethod (c$, "setType", -function (Type) { -this.Type = Type; -}, "~N"); -Clazz.defineMethod (c$, "getType", -function () { -return this.Type; -}); -Clazz.defineMethod (c$, "setName", -function (Name) { -this.Name = Name; -}, "~S"); -Clazz.defineMethod (c$, "getName", -function () { -return this.Name; -}); -Clazz.defineMethod (c$, "setOrder", -function (Order) { -this.Order = Order; -}, "java.util.List"); -Clazz.defineMethod (c$, "getOrder", -function () { -return this.Order; -}); -Clazz.defineMethod (c$, "updateSequence", -function (oldref, newref) { -var found = this.Order.indexOf (oldref); -if (found > -1) { -this.Order.set (found, newref); -}return found > -1; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "equals", -function (o) { -if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.AlignmentOrder))) { -return false; -}return this.equals (o, true); -}, "~O"); -Clazz.defineMethod (c$, "equals", -function (o, identity) { -if (o !== this) { -if (o == null) { -return false; -}if (this.Order != null && o.Order != null && this.Order.size () == o.Order.size ()) { -if (!identity) { -throw new Error ("Weak sequenceI equivalence not yet implemented."); -} else { -for (var i = 0, j = o.Order.size (); i < j; i++) { -if (this.Order.get (i) !== o.Order.get (i)) { -return false; -}} -}} else { -return false; -}}return true; -}, "jalview.datamodel.AlignmentOrder,~B"); -Clazz.defineMethod (c$, "isConsistent", -function (o) { -return this.isConsistent (o, true); -}, "jalview.datamodel.AlignmentOrder"); -Clazz.defineMethod (c$, "isConsistent", -function (o, identity) { -if (o !== this) { -if (o == null) { -return false; -}if (this.Order != null && o.Order != null) { -var c; -var s; -if (o.Order.size () > this.Order.size ()) { -c = o.Order; -s = this.Order; -} else { -c = this.Order; -s = o.Order; -}if (!identity) { -throw new Error ("Weak sequenceI equivalence not yet implemented."); -} else { -var last = -1; -for (var i = 0, j = s.size (); i < j; i++) { -var pos = c.indexOf (s.get (i)); -if (pos > last) { -last = pos; -} else { -return false; -}} -}} else { -return false; -}}return true; -}, "jalview.datamodel.AlignmentOrder,~B"); -Clazz.defineStatics (c$, -"FILE", 0, -"MSA", 1, -"USER", 2); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.AlignmentOrder", ["java.lang.Error", "java.util.ArrayList", "$.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.Type = 0; +this.Name = null; +this.Order = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "AlignmentOrder"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (anOrder) { +this.Order = anOrder; +}, "java.util.List"); +Clazz.makeConstructor (c$, +function (orderFrom) { +this.Order = new java.util.ArrayList (); +for (var seq, $seq = orderFrom.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +this.Order.add (seq); +} +}, "jalview.datamodel.AlignmentI"); +Clazz.makeConstructor (c$, +function (orderFrom) { +this.Order = new java.util.ArrayList (java.util.Arrays.asList (orderFrom)); +}, "~A"); +Clazz.defineMethod (c$, "setType", +function (Type) { +this.Type = Type; +}, "~N"); +Clazz.defineMethod (c$, "getType", +function () { +return this.Type; +}); +Clazz.defineMethod (c$, "setName", +function (Name) { +this.Name = Name; +}, "~S"); +Clazz.defineMethod (c$, "getName", +function () { +return this.Name; +}); +Clazz.defineMethod (c$, "setOrder", +function (Order) { +this.Order = Order; +}, "java.util.List"); +Clazz.defineMethod (c$, "getOrder", +function () { +return this.Order; +}); +Clazz.defineMethod (c$, "updateSequence", +function (oldref, newref) { +var found = this.Order.indexOf (oldref); +if (found > -1) { +this.Order.set (found, newref); +}return found > -1; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "equals", +function (o) { +if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.AlignmentOrder))) { +return false; +}return this.equals (o, true); +}, "~O"); +Clazz.defineMethod (c$, "equals", +function (o, identity) { +if (o !== this) { +if (o == null) { +return false; +}if (this.Order != null && o.Order != null && this.Order.size () == o.Order.size ()) { +if (!identity) { +throw new Error ("Weak sequenceI equivalence not yet implemented."); +} else { +for (var i = 0, j = o.Order.size (); i < j; i++) { +if (this.Order.get (i) !== o.Order.get (i)) { +return false; +}} +}} else { +return false; +}}return true; +}, "jalview.datamodel.AlignmentOrder,~B"); +Clazz.defineMethod (c$, "isConsistent", +function (o) { +return this.isConsistent (o, true); +}, "jalview.datamodel.AlignmentOrder"); +Clazz.defineMethod (c$, "isConsistent", +function (o, identity) { +if (o !== this) { +if (o == null) { +return false; +}if (this.Order != null && o.Order != null) { +var c; +var s; +if (o.Order.size () > this.Order.size ()) { +c = o.Order; +s = this.Order; +} else { +c = this.Order; +s = o.Order; +}if (!identity) { +throw new Error ("Weak sequenceI equivalence not yet implemented."); +} else { +var last = -1; +for (var i = 0, j = s.size (); i < j; i++) { +var pos = c.indexOf (s.get (i)); +if (pos > last) { +last = pos; +} else { +return false; +}} +}} else { +return false; +}}return true; +}, "jalview.datamodel.AlignmentOrder,~B"); +Clazz.defineStatics (c$, +"FILE", 0, +"MSA", 1, +"USER", 2); +}); diff --git a/bin/jalview/datamodel/AlignmentView.js b/bin/jalview/datamodel/AlignmentView.js index e559e79..e88c405 100644 --- a/bin/jalview/datamodel/AlignmentView.js +++ b/bin/jalview/datamodel/AlignmentView.js @@ -1,625 +1,625 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.AlignmentView", ["jalview.datamodel.Alignment", "$.CigarArray", "$.ColumnSelection", "$.SeqCigar", "$.SequenceGroup", "jalview.util.MessageManager", "$.ShiftList", "java.lang.Error", "java.util.ArrayList", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.sequences = null; -this.contigs = null; -this.width = 0; -this.firstCol = 0; -this.scGroups = null; -this.$isNa = false; -if (!Clazz.isClassDefined ("jalview.datamodel.AlignmentView.ScGroup")) { -jalview.datamodel.AlignmentView.$AlignmentView$ScGroup$ (); -} -this.selected = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "AlignmentView"); -Clazz.defineMethod (c$, "isNa", -function () { -return this.$isNa; -}); -Clazz.makeConstructor (c$, -function (alignment, columnSelection, selection, hasHiddenColumns, selectedRegionOnly, recordGroups) { -this.construct ( new jalview.datamodel.CigarArray (alignment, (hasHiddenColumns ? columnSelection : null), (selectedRegionOnly ? selection : null)), (selectedRegionOnly && selection != null) ? selection.getStartRes () : 0); -this.$isNa = alignment.isNucleotide (); -var selseqs; -if (selection != null && selection.getSize () > 0) { -var sel = selection.getSequences (null); -this.selected = new java.util.Vector (); -selseqs = selection.getSequencesInOrder (alignment, selectedRegionOnly); -} else { -selseqs = alignment.getSequencesArray (); -}var seqsets = new java.util.ArrayList (); -var grps = new java.util.ArrayList (); -var gg = alignment.getGroups (); -grps.addAll (gg); -var sgrps = null; -var addedgps = null; -if (grps != null) { -if (selection != null && selectedRegionOnly) { -var ssel = selection.getStartRes (); -var esel = selection.getEndRes (); -var isg = new java.util.ArrayList (); -for (var sg, $sg = grps.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (!(sg.getStartRes () > esel || sg.getEndRes () < ssel)) { -if (sg.getStartRes () < ssel) { -sg.setStartRes (ssel); -}if (sg.getEndRes () > esel) { -sg.setEndRes (esel); -}sg.setStartRes (sg.getStartRes () - ssel + 1); -sg.setEndRes (sg.getEndRes () - ssel + 1); -isg.add (sg); -}} -grps = isg; -}sgrps = new Array (grps.size ()); -addedgps = Clazz.newBooleanArray (grps.size (), false); -for (var g = 0; g < sgrps.length; g++) { -var sg = grps.get (g); -sgrps[g] = Clazz.innerTypeInstance (jalview.datamodel.AlignmentView.ScGroup, this, null); -sgrps[g].sg = new jalview.datamodel.SequenceGroup (sg); -addedgps[g] = false; -seqsets.add (sg.getSequences ()); -} -}var csi = 0; -for (var i = 0; i < selseqs.length; i++) { -if (selseqs[i] != null) { -if (selection != null && selection.getSize () > 0 && !selectedRegionOnly) { -this.sequences[csi].setGroupMembership (this.selected); -this.selected.addElement (this.sequences[csi]); -}if (seqsets != null) { -for (var sg = 0; sg < sgrps.length; sg++) { -if ((seqsets.get (sg)).contains (selseqs[i])) { -this.sequences[csi].setGroupMembership (sgrps[sg]); -sgrps[sg].sg.deleteSequence (selseqs[i], false); -sgrps[sg].seqs.addElement (this.sequences[csi]); -if (!addedgps[sg]) { -if (this.scGroups == null) { -this.scGroups = new java.util.ArrayList (); -}addedgps[sg] = true; -this.scGroups.add (sgrps[sg]); -}}} -}csi++; -}} -for (var sg = 0; sg < sgrps.length; sg++) { -var sqs = sgrps[sg].sg.getSequencesAsArray (null); -for (var si = 0; si < sqs.length; si++) { -sgrps[sg].sg.deleteSequence (sqs[si], false); -} -sgrps[sg] = null; -} -}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup,~B,~B,~B"); -Clazz.makeConstructor (c$, -function (seqcigararray) { -if (!seqcigararray.isSeqCigarArray ()) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_can_only_make_alignmnet_from_cigararray")); -}this.contigs = seqcigararray.getDeletedRegions (); -this.sequences = seqcigararray.getSeqCigarArray (); -this.width = seqcigararray.getWidth (); -}, "jalview.datamodel.CigarArray"); -Clazz.makeConstructor (c$, -function (sdata, firstcol) { -this.construct (sdata); -this.firstCol = firstcol; -}, "jalview.datamodel.CigarArray,~N"); -Clazz.defineMethod (c$, "setSequences", -function (sequences) { -this.sequences = sequences; -}, "~A"); -Clazz.defineMethod (c$, "setContigs", -function (contigs) { -this.contigs = contigs; -}, "~A"); -Clazz.defineMethod (c$, "getSequences", -function () { -return this.sequences; -}); -Clazz.defineMethod (c$, "getContigs", -function () { -return this.contigs; -}); -Clazz.defineMethod (c$, "getAlignmentAndColumnSelection", -function (gapCharacter) { -var colsel = new jalview.datamodel.ColumnSelection (); -return Clazz.newArray (-1, [jalview.datamodel.SeqCigar.createAlignmentSequences (this.sequences, gapCharacter, colsel, this.contigs), colsel]); -}, "~S"); -Clazz.defineMethod (c$, "getVisibleAlignment", -function (c) { -var aln = this.getVisibleSeqs (c); -var vcal = new jalview.datamodel.Alignment (aln); -this.addPrunedGroupsInOrder (vcal, -1, -1, true); -return vcal; -}, "~S"); -Clazz.defineMethod (c$, "addPrunedGroupsInOrder", -($fz = function (vcal, gstart, gend, viscontigs) { -var r = false; -if (gstart > -1 && gstart <= gend) { -r = true; -}var aln = vcal.getSequencesArray (); -{ -{ -var nvg = (this.scGroups != null) ? this.scGroups.size () : 0; -if (nvg > 0) { -var nsg = new Array (nvg); -for (var g = 0; g < nvg; g++) { -var sg = this.scGroups.get (g).sg; -if (r) { -if (sg.getStartRes () > gend || sg.getEndRes () < gstart) { -nsg[g] = null; -continue; -}}nsg[g] = new jalview.datamodel.SequenceGroup (sg); -if (r && !viscontigs) { -if (nsg[g].getStartRes () < gstart) { -nsg[g].setStartRes (0); -} else { -nsg[g].setStartRes (nsg[g].getStartRes () - gstart); -nsg[g].setEndRes (nsg[g].getEndRes () - gstart); -}if (nsg[g].getEndRes () > (gend - gstart)) { -nsg[g].setEndRes (gend - gstart); -}}} -if (viscontigs) { -if (this.contigs != null) { -var p = 0; -var prune = new jalview.util.ShiftList (); -if (r) { -prune.addShift (gstart, -gstart); -}for (var h = 0; h < this.contigs.length; h += 3) { -{ -prune.addShift (p + this.contigs[h + 1], this.contigs[h + 2] - this.contigs[h + 1]); -}p = this.contigs[h + 1] + this.contigs[h + 2]; -} -for (var g = 0; g < nsg.length; g++) { -if (nsg[g] != null) { -var s = nsg[g].getStartRes (); -var t = nsg[g].getEndRes (); -var w = 1 + t - s; -if (r) { -if (s < gstart) { -s = gstart; -}if (t > gend) { -t = gend; -}}s = prune.shift (s); -t = prune.shift (t); -nsg[g].setStartRes (s); -nsg[g].setEndRes (t); -}} -}}for (var nsq = 0; nsq < aln.length; nsq++) { -for (var g = 0; g < nvg; g++) { -if (nsg[g] != null && this.sequences[nsq].isMemberOf (this.scGroups.get (g))) { -nsg[g].addSequence (aln[nsq], false); -}} -} -for (var g = 0; g < nvg; g++) { -if (nsg[g] != null && nsg[g].getSize () > 0) { -vcal.addGroup (nsg[g]); -}nsg[g] = null; -} -}}}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,~N,~N,~B"); -Clazz.defineMethod (c$, "getVisibleSeqs", -($fz = function (c) { -var aln = new Array (this.sequences.length); -for (var i = 0, j = this.sequences.length; i < j; i++) { -aln[i] = this.sequences[i].getSeq ('-'); -} -var seqs = this.getSequenceStrings ('-'); -for (var i = 0, j = aln.length; i < j; i++) { -aln[i].setSequence (seqs[i]); -} -return aln; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "getVisibleContigAlignments", -function (c) { -var nvc = 0; -var vcontigs = this.getVisibleContigs (); -var contigviews = this.getVisibleContigs (c); -var vcals = new Array (contigviews.length); -for (nvc = 0; nvc < contigviews.length; nvc++) { -vcals[nvc] = new jalview.datamodel.Alignment (contigviews[nvc]); -if (this.scGroups != null && this.scGroups.size () > 0) { -this.addPrunedGroupsInOrder (vcals[nvc], vcontigs[nvc * 2], vcontigs[nvc * 2 + 1], true); -}} -return vcals; -}, "~S"); -Clazz.defineMethod (c$, "getSequenceStrings", -function (c) { -var seqs = new Array (this.sequences.length); -for (var n = 0; n < this.sequences.length; n++) { -var fullseq = this.sequences[n].getSequenceString (c); -if (this.contigs != null) { -seqs[n] = ""; -var p = 0; -for (var h = 0; h < this.contigs.length; h += 3) { -seqs[n] += fullseq.substring (p, this.contigs[h + 1]); -p = this.contigs[h + 1] + this.contigs[h + 2]; -} -seqs[n] += fullseq.substring (p); -} else { -seqs[n] = fullseq; -}} -return seqs; -}, "~S"); -Clazz.defineMethod (c$, "getWidth", -function () { -return this.width; -}); -Clazz.defineMethod (c$, "setWidth", -function (width) { -this.width = width; -}, "~N"); -Clazz.defineMethod (c$, "getVisibleContigs", -function (gapCharacter) { -var smsa; -var njobs = 1; -if (this.sequences == null || this.width <= 0) { -return null; -}if (this.contigs != null && this.contigs.length > 0) { -var start = 0; -njobs = 0; -var fwidth = this.width; -for (var contig = 0; contig < this.contigs.length; contig += 3) { -if ((this.contigs[contig + 1] - start) > 0) { -njobs++; -}fwidth += this.contigs[contig + 2]; -start = this.contigs[contig + 1] + this.contigs[contig + 2]; -} -if (start < fwidth) { -njobs++; -}smsa = new Array (njobs); -start = 0; -var j = 0; -for (var contig = 0; contig < this.contigs.length; contig += 3) { -if (this.contigs[contig + 1] - start > 0) { -var mseq = new Array (this.sequences.length); -for (var s = 0; s < mseq.length; s++) { -mseq[s] = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, this.contigs[contig + 1]); -} -smsa[j] = mseq; -j++; -}start = this.contigs[contig + 1] + this.contigs[contig + 2]; -} -if (start < fwidth) { -var mseq = new Array (this.sequences.length); -for (var s = 0; s < mseq.length; s++) { -mseq[s] = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, fwidth + 1); -} -smsa[j] = mseq; -j++; -}} else { -smsa = new Array (1); -smsa[0] = new Array (this.sequences.length); -for (var s = 0; s < this.sequences.length; s++) { -smsa[0][s] = this.sequences[s].getSeq (gapCharacter); -} -}return smsa; -}, "~S"); -Clazz.defineMethod (c$, "getUpdatedView", -function (nvismsa, orders, gapCharacter) { -if (this.sequences == null || this.width <= 0) { -throw new Error (jalview.util.MessageManager.getString ("error.empty_view_cannot_be_updated")); -}if (nvismsa == null) { -throw new Error ("nvismsa==null. use getAlignmentAndColumnSelection() instead."); -}if (this.contigs != null && this.contigs.length > 0) { -var alignment = new Array (this.sequences.length); -var columnselection = new jalview.datamodel.ColumnSelection (); -if (this.contigs != null && this.contigs.length > 0) { -var start = 0; -var nwidth = 0; -var owidth = this.width; -var j = 0; -for (var contig = 0; contig < this.contigs.length; contig += 3) { -owidth += this.contigs[contig + 2]; -if (this.contigs[contig + 1] - start > 0) { -var swidth = 0; -if (nvismsa[j] != null) { -var mseq = nvismsa[j]; -var order = (orders == null) ? null : orders[j]; -j++; -if (mseq.length != this.sequences.length) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.mismatch_between_number_of_sequences_in_block", Clazz.newArray (-1, [Integer.$valueOf (j).toString (), Integer.$valueOf (mseq.length).toString (), Integer.$valueOf (this.sequences.length).toString ()]))); -}swidth = mseq[0].getLength (); -for (var s = 0; s < mseq.length; s++) { -if (alignment[s] == null) { -alignment[s] = mseq[s]; -} else { -alignment[s].setSequence (alignment[s].getSequenceAsString () + mseq[s].getSequenceAsString ()); -if (mseq[s].getStart () <= mseq[s].getEnd ()) { -alignment[s].setEnd (mseq[s].getEnd ()); -}if (order != null) { -order.updateSequence (mseq[s], alignment[s]); -}}} -} else { -if (true) { -for (var s = 0; s < this.sequences.length; s++) { -var oseq = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, this.contigs[contig + 1]); -if (swidth < oseq.getLength ()) { -swidth = oseq.getLength (); -}if (alignment[s] == null) { -alignment[s] = oseq; -} else { -alignment[s].setSequence (alignment[s].getSequenceAsString () + oseq.getSequenceAsString ()); -if (oseq.getEnd () >= oseq.getStart ()) { -alignment[s].setEnd (oseq.getEnd ()); -}}} -}j++; -}nwidth += swidth; -}start = this.contigs[contig + 1] + this.contigs[contig + 2]; -for (var s = 0; s < this.sequences.length; s++) { -var hseq = this.sequences[s].getSeq (gapCharacter).getSubSequence (this.contigs[contig + 1], start); -if (alignment[s] == null) { -alignment[s] = hseq; -} else { -alignment[s].setSequence (alignment[s].getSequenceAsString () + hseq.getSequenceAsString ()); -if (hseq.getEnd () >= hseq.getStart ()) { -alignment[s].setEnd (hseq.getEnd ()); -}}} -columnselection.hideColumns (nwidth, nwidth + this.contigs[contig + 2] - 1); -nwidth += this.contigs[contig + 2]; -} -if (j < nvismsa.length) { -var swidth = 0; -if (nvismsa[j] != null) { -var mseq = nvismsa[j]; -var order = (orders != null) ? orders[j] : null; -swidth = mseq[0].getLength (); -for (var s = 0; s < mseq.length; s++) { -if (alignment[s] == null) { -alignment[s] = mseq[s]; -} else { -alignment[s].setSequence (alignment[s].getSequenceAsString () + mseq[s].getSequenceAsString ()); -if (mseq[s].getEnd () >= mseq[s].getStart ()) { -alignment[s].setEnd (mseq[s].getEnd ()); -}if (order != null) { -order.updateSequence (mseq[s], alignment[s]); -}}} -} else { -if (start < owidth) { -if (true) { -for (var s = 0; s < this.sequences.length; s++) { -var oseq = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, owidth + 1); -if (swidth < oseq.getLength ()) { -swidth = oseq.getLength (); -}if (alignment[s] == null) { -alignment[s] = oseq; -} else { -alignment[s].setSequence (alignment[s].getSequenceAsString () + oseq.getSequenceAsString ()); -if (oseq.getEnd () >= oseq.getStart ()) { -alignment[s].setEnd (oseq.getEnd ()); -}}} -nwidth += swidth; -} else { -throw new Error (jalview.util.MessageManager.getString ("error.padding_not_yet_implemented")); -}}}}}return Clazz.newArray (-1, [alignment, columnselection]); -} else { -if (nvismsa.length != 1) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.mismatch_between_visible_blocks_to_update_and_number_of_contigs_in_view", Clazz.newArray (-1, [Integer.$valueOf (nvismsa.length).toString ()]))); -}if (nvismsa[0] != null) { -return Clazz.newArray (-1, [nvismsa[0], new jalview.datamodel.ColumnSelection ()]); -} else { -return this.getAlignmentAndColumnSelection (gapCharacter); -}}}, "~A,~A,~S"); -Clazz.defineMethod (c$, "getVisibleContigs", -function () { -if (this.contigs != null && this.contigs.length > 0) { -var start = 0; -var nvis = 0; -var fwidth = this.width; -for (var contig = 0; contig < this.contigs.length; contig += 3) { -if ((this.contigs[contig + 1] - start) > 0) { -nvis++; -}fwidth += this.contigs[contig + 2]; -start = this.contigs[contig + 1] + this.contigs[contig + 2]; -} -if (start < fwidth) { -nvis++; -}var viscontigs = Clazz.newIntArray (nvis * 2, 0); -nvis = 0; -start = 0; -for (var contig = 0; contig < this.contigs.length; contig += 3) { -if ((this.contigs[contig + 1] - start) > 0) { -viscontigs[nvis] = start; -viscontigs[nvis + 1] = this.contigs[contig + 1] - 1; -nvis += 2; -}start = this.contigs[contig + 1] + this.contigs[contig + 2]; -} -if (start < fwidth) { -viscontigs[nvis] = start; -viscontigs[nvis + 1] = fwidth; -nvis += 2; -}return viscontigs; -} else { -return Clazz.newIntArray (-1, [0, this.width]); -}}); -Clazz.defineMethod (c$, "getAlignmentOrigin", -function () { -return this.firstCol; -}); -Clazz.defineMethod (c$, "getVisibleContigMapFor", -function (gapMap) { -var delMap = null; -var viscontigs = this.getVisibleContigs (); -var spos = 0; -var i = 0; -if (viscontigs != null) { -delMap = Clazz.newIntArray (gapMap.length, 0); -for (var contig = 0; contig < viscontigs.length; contig += 2) { -while (spos < gapMap.length && gapMap[spos] < viscontigs[contig]) { -spos++; -} -while (spos < gapMap.length && gapMap[spos] <= viscontigs[contig + 1]) { -delMap[i++] = spos++; -} -} -var tmap = Clazz.newIntArray (i, 0); -System.arraycopy (delMap, 0, tmap, 0, i); -delMap = tmap; -}return delMap; -}, "~A"); -Clazz.defineMethod (c$, "getEditedSequences", -function (gc, $delete) { -var msf = this.getSequences (); -var aln = new Array (msf.length); -for (var i = 0, j = msf.length; i < j; i++) { -aln[i] = msf[i].getSeq (gc); -} -if ($delete) { -var sqs = this.getSequenceStrings (gc); -for (var i = 0; i < sqs.length; i++) { -aln[i].setSequence (sqs[i]); -sqs[i] = null; -} -}return aln; -}, "~S,~B"); -c$.summariseAlignmentView = Clazz.defineMethod (c$, "summariseAlignmentView", -function (view, os) { -os.print ("View has " + view.sequences.length + " of which "); -if (view.selected == null) { -os.print ("None"); -} else { -os.print (" " + view.selected.size ()); -}os.println (" are selected."); -os.print ("View is " + view.getWidth () + " columns wide"); -var viswid = 0; -var contigs = view.getContigs (); -if (contigs != null) { -viswid = view.width; -for (var i = 0; i < contigs.length; i += 3) { -viswid += contigs[i + 2]; -} -os.println ("with " + viswid + " visible columns spread over " + Clazz.doubleToInt (contigs.length / 3) + " regions."); -} else { -viswid = view.width; -os.println ("."); -}if (view.scGroups != null) { -os.println ("There are " + view.scGroups.size () + " groups defined on the view."); -for (var g = 0; g < view.scGroups.size (); g++) { -var sgr = view.scGroups.get (g); -os.println ("Group " + g + ": Name = " + sgr.sg.getName () + " Contains " + sgr.seqs.size () + " Seqs."); -os.println ("This group runs from " + sgr.sg.getStartRes () + " to " + sgr.sg.getEndRes ()); -for (var s = 0; s < sgr.seqs.size (); s++) { -if (!(sgr.seqs.elementAt (s)).isMemberOf (sgr)) { -os.println ("** WARNING: sequence " + (sgr.seqs.elementAt (s)).toString () + " is not marked as member of group."); -}} -} -var visal = view.getVisibleAlignment ('-'); -if (visal != null) { -os.println ("Vis. alignment is " + visal.getWidth () + " wide and has " + visal.getHeight () + " seqs."); -if (visal.getGroups () != null && visal.getGroups ().size () > 0) { -var i = 1; -for (var sg, $sg = visal.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -os.println ("Group " + (i++) + " begins at column " + sg.getStartRes () + " and ends at " + sg.getEndRes ()); -} -}}}}, "jalview.datamodel.AlignmentView,java.io.PrintStream"); -c$.testSelectionViews = Clazz.defineMethod (c$, "testSelectionViews", -function (alignment, csel, selection) { -System.out.println ("Testing standard view creation:\n"); -var view = null; -try { -System.out.println ("View with no hidden columns, no limit to selection, no groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, false, false); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection but no groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View with no hidden columns, no limit to selection, and all groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, false, true); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection marked but no groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View with no hidden columns, limited to selection and no groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, true, false); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection restricted but no groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View with no hidden columns, limited to selection, and all groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, true, true); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection restricted and groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View *with* hidden columns, no limit to selection, no groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, false, false); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection but no groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View *with* hidden columns, no limit to selection, and all groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, false, true); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection marked but no groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View *with* hidden columns, limited to selection and no groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, true, false); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection restricted but no groups marked."); -} else { -throw e; -} -} -try { -System.out.println ("View *with* hidden columns, limited to selection, and all groups to be collected:"); -view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, true, true); -jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to generate alignment with selection restricted and groups marked."); -} else { -throw e; -} -} -}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup"); -c$.$AlignmentView$ScGroup$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.seqs = null; -this.sg = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel.AlignmentView, "ScGroup"); -Clazz.makeConstructor (c$, -function () { -this.seqs = new java.util.Vector (); -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.AlignmentView", ["jalview.datamodel.Alignment", "$.CigarArray", "$.ColumnSelection", "$.SeqCigar", "$.SequenceGroup", "jalview.util.MessageManager", "$.ShiftList", "java.lang.Error", "java.util.ArrayList", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.sequences = null; +this.contigs = null; +this.width = 0; +this.firstCol = 0; +this.scGroups = null; +this.$isNa = false; +if (!Clazz.isClassDefined ("jalview.datamodel.AlignmentView.ScGroup")) { +jalview.datamodel.AlignmentView.$AlignmentView$ScGroup$ (); +} +this.selected = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "AlignmentView"); +Clazz.defineMethod (c$, "isNa", +function () { +return this.$isNa; +}); +Clazz.makeConstructor (c$, +function (alignment, columnSelection, selection, hasHiddenColumns, selectedRegionOnly, recordGroups) { +this.construct ( new jalview.datamodel.CigarArray (alignment, (hasHiddenColumns ? columnSelection : null), (selectedRegionOnly ? selection : null)), (selectedRegionOnly && selection != null) ? selection.getStartRes () : 0); +this.$isNa = alignment.isNucleotide (); +var selseqs; +if (selection != null && selection.getSize () > 0) { +var sel = selection.getSequences (null); +this.selected = new java.util.Vector (); +selseqs = selection.getSequencesInOrder (alignment, selectedRegionOnly); +} else { +selseqs = alignment.getSequencesArray (); +}var seqsets = new java.util.ArrayList (); +var grps = new java.util.ArrayList (); +var gg = alignment.getGroups (); +grps.addAll (gg); +var sgrps = null; +var addedgps = null; +if (grps != null) { +if (selection != null && selectedRegionOnly) { +var ssel = selection.getStartRes (); +var esel = selection.getEndRes (); +var isg = new java.util.ArrayList (); +for (var sg, $sg = grps.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (!(sg.getStartRes () > esel || sg.getEndRes () < ssel)) { +if (sg.getStartRes () < ssel) { +sg.setStartRes (ssel); +}if (sg.getEndRes () > esel) { +sg.setEndRes (esel); +}sg.setStartRes (sg.getStartRes () - ssel + 1); +sg.setEndRes (sg.getEndRes () - ssel + 1); +isg.add (sg); +}} +grps = isg; +}sgrps = new Array (grps.size ()); +addedgps = Clazz.newBooleanArray (grps.size (), false); +for (var g = 0; g < sgrps.length; g++) { +var sg = grps.get (g); +sgrps[g] = Clazz.innerTypeInstance (jalview.datamodel.AlignmentView.ScGroup, this, null); +sgrps[g].sg = new jalview.datamodel.SequenceGroup (sg); +addedgps[g] = false; +seqsets.add (sg.getSequences ()); +} +}var csi = 0; +for (var i = 0; i < selseqs.length; i++) { +if (selseqs[i] != null) { +if (selection != null && selection.getSize () > 0 && !selectedRegionOnly) { +this.sequences[csi].setGroupMembership (this.selected); +this.selected.addElement (this.sequences[csi]); +}if (seqsets != null) { +for (var sg = 0; sg < sgrps.length; sg++) { +if ((seqsets.get (sg)).contains (selseqs[i])) { +this.sequences[csi].setGroupMembership (sgrps[sg]); +sgrps[sg].sg.deleteSequence (selseqs[i], false); +sgrps[sg].seqs.addElement (this.sequences[csi]); +if (!addedgps[sg]) { +if (this.scGroups == null) { +this.scGroups = new java.util.ArrayList (); +}addedgps[sg] = true; +this.scGroups.add (sgrps[sg]); +}}} +}csi++; +}} +for (var sg = 0; sg < sgrps.length; sg++) { +var sqs = sgrps[sg].sg.getSequencesAsArray (null); +for (var si = 0; si < sqs.length; si++) { +sgrps[sg].sg.deleteSequence (sqs[si], false); +} +sgrps[sg] = null; +} +}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup,~B,~B,~B"); +Clazz.makeConstructor (c$, +function (seqcigararray) { +if (!seqcigararray.isSeqCigarArray ()) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_can_only_make_alignmnet_from_cigararray")); +}this.contigs = seqcigararray.getDeletedRegions (); +this.sequences = seqcigararray.getSeqCigarArray (); +this.width = seqcigararray.getWidth (); +}, "jalview.datamodel.CigarArray"); +Clazz.makeConstructor (c$, +function (sdata, firstcol) { +this.construct (sdata); +this.firstCol = firstcol; +}, "jalview.datamodel.CigarArray,~N"); +Clazz.defineMethod (c$, "setSequences", +function (sequences) { +this.sequences = sequences; +}, "~A"); +Clazz.defineMethod (c$, "setContigs", +function (contigs) { +this.contigs = contigs; +}, "~A"); +Clazz.defineMethod (c$, "getSequences", +function () { +return this.sequences; +}); +Clazz.defineMethod (c$, "getContigs", +function () { +return this.contigs; +}); +Clazz.defineMethod (c$, "getAlignmentAndColumnSelection", +function (gapCharacter) { +var colsel = new jalview.datamodel.ColumnSelection (); +return Clazz.newArray (-1, [jalview.datamodel.SeqCigar.createAlignmentSequences (this.sequences, gapCharacter, colsel, this.contigs), colsel]); +}, "~S"); +Clazz.defineMethod (c$, "getVisibleAlignment", +function (c) { +var aln = this.getVisibleSeqs (c); +var vcal = new jalview.datamodel.Alignment (aln); +this.addPrunedGroupsInOrder (vcal, -1, -1, true); +return vcal; +}, "~S"); +Clazz.defineMethod (c$, "addPrunedGroupsInOrder", +($fz = function (vcal, gstart, gend, viscontigs) { +var r = false; +if (gstart > -1 && gstart <= gend) { +r = true; +}var aln = vcal.getSequencesArray (); +{ +{ +var nvg = (this.scGroups != null) ? this.scGroups.size () : 0; +if (nvg > 0) { +var nsg = new Array (nvg); +for (var g = 0; g < nvg; g++) { +var sg = this.scGroups.get (g).sg; +if (r) { +if (sg.getStartRes () > gend || sg.getEndRes () < gstart) { +nsg[g] = null; +continue; +}}nsg[g] = new jalview.datamodel.SequenceGroup (sg); +if (r && !viscontigs) { +if (nsg[g].getStartRes () < gstart) { +nsg[g].setStartRes (0); +} else { +nsg[g].setStartRes (nsg[g].getStartRes () - gstart); +nsg[g].setEndRes (nsg[g].getEndRes () - gstart); +}if (nsg[g].getEndRes () > (gend - gstart)) { +nsg[g].setEndRes (gend - gstart); +}}} +if (viscontigs) { +if (this.contigs != null) { +var p = 0; +var prune = new jalview.util.ShiftList (); +if (r) { +prune.addShift (gstart, -gstart); +}for (var h = 0; h < this.contigs.length; h += 3) { +{ +prune.addShift (p + this.contigs[h + 1], this.contigs[h + 2] - this.contigs[h + 1]); +}p = this.contigs[h + 1] + this.contigs[h + 2]; +} +for (var g = 0; g < nsg.length; g++) { +if (nsg[g] != null) { +var s = nsg[g].getStartRes (); +var t = nsg[g].getEndRes (); +var w = 1 + t - s; +if (r) { +if (s < gstart) { +s = gstart; +}if (t > gend) { +t = gend; +}}s = prune.shift (s); +t = prune.shift (t); +nsg[g].setStartRes (s); +nsg[g].setEndRes (t); +}} +}}for (var nsq = 0; nsq < aln.length; nsq++) { +for (var g = 0; g < nvg; g++) { +if (nsg[g] != null && this.sequences[nsq].isMemberOf (this.scGroups.get (g))) { +nsg[g].addSequence (aln[nsq], false); +}} +} +for (var g = 0; g < nvg; g++) { +if (nsg[g] != null && nsg[g].getSize () > 0) { +vcal.addGroup (nsg[g]); +}nsg[g] = null; +} +}}}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,~N,~N,~B"); +Clazz.defineMethod (c$, "getVisibleSeqs", +($fz = function (c) { +var aln = new Array (this.sequences.length); +for (var i = 0, j = this.sequences.length; i < j; i++) { +aln[i] = this.sequences[i].getSeq ('-'); +} +var seqs = this.getSequenceStrings ('-'); +for (var i = 0, j = aln.length; i < j; i++) { +aln[i].setSequence (seqs[i]); +} +return aln; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "getVisibleContigAlignments", +function (c) { +var nvc = 0; +var vcontigs = this.getVisibleContigs (); +var contigviews = this.getVisibleContigs (c); +var vcals = new Array (contigviews.length); +for (nvc = 0; nvc < contigviews.length; nvc++) { +vcals[nvc] = new jalview.datamodel.Alignment (contigviews[nvc]); +if (this.scGroups != null && this.scGroups.size () > 0) { +this.addPrunedGroupsInOrder (vcals[nvc], vcontigs[nvc * 2], vcontigs[nvc * 2 + 1], true); +}} +return vcals; +}, "~S"); +Clazz.defineMethod (c$, "getSequenceStrings", +function (c) { +var seqs = new Array (this.sequences.length); +for (var n = 0; n < this.sequences.length; n++) { +var fullseq = this.sequences[n].getSequenceString (c); +if (this.contigs != null) { +seqs[n] = ""; +var p = 0; +for (var h = 0; h < this.contigs.length; h += 3) { +seqs[n] += fullseq.substring (p, this.contigs[h + 1]); +p = this.contigs[h + 1] + this.contigs[h + 2]; +} +seqs[n] += fullseq.substring (p); +} else { +seqs[n] = fullseq; +}} +return seqs; +}, "~S"); +Clazz.defineMethod (c$, "getWidth", +function () { +return this.width; +}); +Clazz.defineMethod (c$, "setWidth", +function (width) { +this.width = width; +}, "~N"); +Clazz.defineMethod (c$, "getVisibleContigs", +function (gapCharacter) { +var smsa; +var njobs = 1; +if (this.sequences == null || this.width <= 0) { +return null; +}if (this.contigs != null && this.contigs.length > 0) { +var start = 0; +njobs = 0; +var fwidth = this.width; +for (var contig = 0; contig < this.contigs.length; contig += 3) { +if ((this.contigs[contig + 1] - start) > 0) { +njobs++; +}fwidth += this.contigs[contig + 2]; +start = this.contigs[contig + 1] + this.contigs[contig + 2]; +} +if (start < fwidth) { +njobs++; +}smsa = new Array (njobs); +start = 0; +var j = 0; +for (var contig = 0; contig < this.contigs.length; contig += 3) { +if (this.contigs[contig + 1] - start > 0) { +var mseq = new Array (this.sequences.length); +for (var s = 0; s < mseq.length; s++) { +mseq[s] = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, this.contigs[contig + 1]); +} +smsa[j] = mseq; +j++; +}start = this.contigs[contig + 1] + this.contigs[contig + 2]; +} +if (start < fwidth) { +var mseq = new Array (this.sequences.length); +for (var s = 0; s < mseq.length; s++) { +mseq[s] = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, fwidth + 1); +} +smsa[j] = mseq; +j++; +}} else { +smsa = new Array (1); +smsa[0] = new Array (this.sequences.length); +for (var s = 0; s < this.sequences.length; s++) { +smsa[0][s] = this.sequences[s].getSeq (gapCharacter); +} +}return smsa; +}, "~S"); +Clazz.defineMethod (c$, "getUpdatedView", +function (nvismsa, orders, gapCharacter) { +if (this.sequences == null || this.width <= 0) { +throw new Error (jalview.util.MessageManager.getString ("error.empty_view_cannot_be_updated")); +}if (nvismsa == null) { +throw new Error ("nvismsa==null. use getAlignmentAndColumnSelection() instead."); +}if (this.contigs != null && this.contigs.length > 0) { +var alignment = new Array (this.sequences.length); +var columnselection = new jalview.datamodel.ColumnSelection (); +if (this.contigs != null && this.contigs.length > 0) { +var start = 0; +var nwidth = 0; +var owidth = this.width; +var j = 0; +for (var contig = 0; contig < this.contigs.length; contig += 3) { +owidth += this.contigs[contig + 2]; +if (this.contigs[contig + 1] - start > 0) { +var swidth = 0; +if (nvismsa[j] != null) { +var mseq = nvismsa[j]; +var order = (orders == null) ? null : orders[j]; +j++; +if (mseq.length != this.sequences.length) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.mismatch_between_number_of_sequences_in_block", Clazz.newArray (-1, [Integer.$valueOf (j).toString (), Integer.$valueOf (mseq.length).toString (), Integer.$valueOf (this.sequences.length).toString ()]))); +}swidth = mseq[0].getLength (); +for (var s = 0; s < mseq.length; s++) { +if (alignment[s] == null) { +alignment[s] = mseq[s]; +} else { +alignment[s].setSequence (alignment[s].getSequenceAsString () + mseq[s].getSequenceAsString ()); +if (mseq[s].getStart () <= mseq[s].getEnd ()) { +alignment[s].setEnd (mseq[s].getEnd ()); +}if (order != null) { +order.updateSequence (mseq[s], alignment[s]); +}}} +} else { +if (true) { +for (var s = 0; s < this.sequences.length; s++) { +var oseq = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, this.contigs[contig + 1]); +if (swidth < oseq.getLength ()) { +swidth = oseq.getLength (); +}if (alignment[s] == null) { +alignment[s] = oseq; +} else { +alignment[s].setSequence (alignment[s].getSequenceAsString () + oseq.getSequenceAsString ()); +if (oseq.getEnd () >= oseq.getStart ()) { +alignment[s].setEnd (oseq.getEnd ()); +}}} +}j++; +}nwidth += swidth; +}start = this.contigs[contig + 1] + this.contigs[contig + 2]; +for (var s = 0; s < this.sequences.length; s++) { +var hseq = this.sequences[s].getSeq (gapCharacter).getSubSequence (this.contigs[contig + 1], start); +if (alignment[s] == null) { +alignment[s] = hseq; +} else { +alignment[s].setSequence (alignment[s].getSequenceAsString () + hseq.getSequenceAsString ()); +if (hseq.getEnd () >= hseq.getStart ()) { +alignment[s].setEnd (hseq.getEnd ()); +}}} +columnselection.hideColumns (nwidth, nwidth + this.contigs[contig + 2] - 1); +nwidth += this.contigs[contig + 2]; +} +if (j < nvismsa.length) { +var swidth = 0; +if (nvismsa[j] != null) { +var mseq = nvismsa[j]; +var order = (orders != null) ? orders[j] : null; +swidth = mseq[0].getLength (); +for (var s = 0; s < mseq.length; s++) { +if (alignment[s] == null) { +alignment[s] = mseq[s]; +} else { +alignment[s].setSequence (alignment[s].getSequenceAsString () + mseq[s].getSequenceAsString ()); +if (mseq[s].getEnd () >= mseq[s].getStart ()) { +alignment[s].setEnd (mseq[s].getEnd ()); +}if (order != null) { +order.updateSequence (mseq[s], alignment[s]); +}}} +} else { +if (start < owidth) { +if (true) { +for (var s = 0; s < this.sequences.length; s++) { +var oseq = this.sequences[s].getSeq (gapCharacter).getSubSequence (start, owidth + 1); +if (swidth < oseq.getLength ()) { +swidth = oseq.getLength (); +}if (alignment[s] == null) { +alignment[s] = oseq; +} else { +alignment[s].setSequence (alignment[s].getSequenceAsString () + oseq.getSequenceAsString ()); +if (oseq.getEnd () >= oseq.getStart ()) { +alignment[s].setEnd (oseq.getEnd ()); +}}} +nwidth += swidth; +} else { +throw new Error (jalview.util.MessageManager.getString ("error.padding_not_yet_implemented")); +}}}}}return Clazz.newArray (-1, [alignment, columnselection]); +} else { +if (nvismsa.length != 1) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.mismatch_between_visible_blocks_to_update_and_number_of_contigs_in_view", Clazz.newArray (-1, [Integer.$valueOf (nvismsa.length).toString ()]))); +}if (nvismsa[0] != null) { +return Clazz.newArray (-1, [nvismsa[0], new jalview.datamodel.ColumnSelection ()]); +} else { +return this.getAlignmentAndColumnSelection (gapCharacter); +}}}, "~A,~A,~S"); +Clazz.defineMethod (c$, "getVisibleContigs", +function () { +if (this.contigs != null && this.contigs.length > 0) { +var start = 0; +var nvis = 0; +var fwidth = this.width; +for (var contig = 0; contig < this.contigs.length; contig += 3) { +if ((this.contigs[contig + 1] - start) > 0) { +nvis++; +}fwidth += this.contigs[contig + 2]; +start = this.contigs[contig + 1] + this.contigs[contig + 2]; +} +if (start < fwidth) { +nvis++; +}var viscontigs = Clazz.newIntArray (nvis * 2, 0); +nvis = 0; +start = 0; +for (var contig = 0; contig < this.contigs.length; contig += 3) { +if ((this.contigs[contig + 1] - start) > 0) { +viscontigs[nvis] = start; +viscontigs[nvis + 1] = this.contigs[contig + 1] - 1; +nvis += 2; +}start = this.contigs[contig + 1] + this.contigs[contig + 2]; +} +if (start < fwidth) { +viscontigs[nvis] = start; +viscontigs[nvis + 1] = fwidth; +nvis += 2; +}return viscontigs; +} else { +return Clazz.newIntArray (-1, [0, this.width]); +}}); +Clazz.defineMethod (c$, "getAlignmentOrigin", +function () { +return this.firstCol; +}); +Clazz.defineMethod (c$, "getVisibleContigMapFor", +function (gapMap) { +var delMap = null; +var viscontigs = this.getVisibleContigs (); +var spos = 0; +var i = 0; +if (viscontigs != null) { +delMap = Clazz.newIntArray (gapMap.length, 0); +for (var contig = 0; contig < viscontigs.length; contig += 2) { +while (spos < gapMap.length && gapMap[spos] < viscontigs[contig]) { +spos++; +} +while (spos < gapMap.length && gapMap[spos] <= viscontigs[contig + 1]) { +delMap[i++] = spos++; +} +} +var tmap = Clazz.newIntArray (i, 0); +System.arraycopy (delMap, 0, tmap, 0, i); +delMap = tmap; +}return delMap; +}, "~A"); +Clazz.defineMethod (c$, "getEditedSequences", +function (gc, $delete) { +var msf = this.getSequences (); +var aln = new Array (msf.length); +for (var i = 0, j = msf.length; i < j; i++) { +aln[i] = msf[i].getSeq (gc); +} +if ($delete) { +var sqs = this.getSequenceStrings (gc); +for (var i = 0; i < sqs.length; i++) { +aln[i].setSequence (sqs[i]); +sqs[i] = null; +} +}return aln; +}, "~S,~B"); +c$.summariseAlignmentView = Clazz.defineMethod (c$, "summariseAlignmentView", +function (view, os) { +os.print ("View has " + view.sequences.length + " of which "); +if (view.selected == null) { +os.print ("None"); +} else { +os.print (" " + view.selected.size ()); +}os.println (" are selected."); +os.print ("View is " + view.getWidth () + " columns wide"); +var viswid = 0; +var contigs = view.getContigs (); +if (contigs != null) { +viswid = view.width; +for (var i = 0; i < contigs.length; i += 3) { +viswid += contigs[i + 2]; +} +os.println ("with " + viswid + " visible columns spread over " + Clazz.doubleToInt (contigs.length / 3) + " regions."); +} else { +viswid = view.width; +os.println ("."); +}if (view.scGroups != null) { +os.println ("There are " + view.scGroups.size () + " groups defined on the view."); +for (var g = 0; g < view.scGroups.size (); g++) { +var sgr = view.scGroups.get (g); +os.println ("Group " + g + ": Name = " + sgr.sg.getName () + " Contains " + sgr.seqs.size () + " Seqs."); +os.println ("This group runs from " + sgr.sg.getStartRes () + " to " + sgr.sg.getEndRes ()); +for (var s = 0; s < sgr.seqs.size (); s++) { +if (!(sgr.seqs.elementAt (s)).isMemberOf (sgr)) { +os.println ("** WARNING: sequence " + (sgr.seqs.elementAt (s)).toString () + " is not marked as member of group."); +}} +} +var visal = view.getVisibleAlignment ('-'); +if (visal != null) { +os.println ("Vis. alignment is " + visal.getWidth () + " wide and has " + visal.getHeight () + " seqs."); +if (visal.getGroups () != null && visal.getGroups ().size () > 0) { +var i = 1; +for (var sg, $sg = visal.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +os.println ("Group " + (i++) + " begins at column " + sg.getStartRes () + " and ends at " + sg.getEndRes ()); +} +}}}}, "jalview.datamodel.AlignmentView,java.io.PrintStream"); +c$.testSelectionViews = Clazz.defineMethod (c$, "testSelectionViews", +function (alignment, csel, selection) { +System.out.println ("Testing standard view creation:\n"); +var view = null; +try { +System.out.println ("View with no hidden columns, no limit to selection, no groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, false, false); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection but no groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View with no hidden columns, no limit to selection, and all groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, false, true); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection marked but no groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View with no hidden columns, limited to selection and no groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, true, false); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection restricted but no groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View with no hidden columns, limited to selection, and all groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, false, true, true); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection restricted and groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View *with* hidden columns, no limit to selection, no groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, false, false); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection but no groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View *with* hidden columns, no limit to selection, and all groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, false, true); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection marked but no groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View *with* hidden columns, limited to selection and no groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, true, false); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection restricted but no groups marked."); +} else { +throw e; +} +} +try { +System.out.println ("View *with* hidden columns, limited to selection, and all groups to be collected:"); +view = new jalview.datamodel.AlignmentView (alignment, csel, selection, true, true, true); +jalview.datamodel.AlignmentView.summariseAlignmentView (view, System.out); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to generate alignment with selection restricted and groups marked."); +} else { +throw e; +} +} +}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup"); +c$.$AlignmentView$ScGroup$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.seqs = null; +this.sg = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel.AlignmentView, "ScGroup"); +Clazz.makeConstructor (c$, +function () { +this.seqs = new java.util.Vector (); +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/datamodel/AnnotatedCollectionI.js b/bin/jalview/datamodel/AnnotatedCollectionI.js index fd7a804..0dda32c 100644 --- a/bin/jalview/datamodel/AnnotatedCollectionI.js +++ b/bin/jalview/datamodel/AnnotatedCollectionI.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.SequenceCollectionI"], "jalview.datamodel.AnnotatedCollectionI", null, function () { -Clazz.declareInterface (jalview.datamodel, "AnnotatedCollectionI", jalview.datamodel.SequenceCollectionI); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.SequenceCollectionI"], "jalview.datamodel.AnnotatedCollectionI", null, function () { +Clazz.declareInterface (jalview.datamodel, "AnnotatedCollectionI", jalview.datamodel.SequenceCollectionI); +}); diff --git a/bin/jalview/datamodel/Annotation.js b/bin/jalview/datamodel/Annotation.js index 76f42d8..d704ba4 100644 --- a/bin/jalview/datamodel/Annotation.js +++ b/bin/jalview/datamodel/Annotation.js @@ -1,72 +1,72 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.Annotation", ["java.lang.Float", "$.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.displayCharacter = ""; -this.description = ""; -this.secondaryStructure = ' '; -this.value = 0; -this.colour = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Annotation"); -Clazz.makeConstructor (c$, -function (displayChar, desc, ss, val) { -this.displayCharacter = displayChar; -this.description = desc; -this.secondaryStructure = ss; -this.value = val; -}, "~S,~S,~S,~N"); -Clazz.makeConstructor (c$, -function (displayChar, desc, ss, val, colour) { -this.construct (displayChar, desc, ss, val); -this.colour = colour; -}, "~S,~S,~S,~N,java.awt.Color"); -Clazz.makeConstructor (c$, -function (that) { -if (that == null || this === that) { -return; -}if (that.displayCharacter != null) this.displayCharacter = String.instantialize (that.displayCharacter); -if (that.description != null) this.description = String.instantialize (that.description); -this.secondaryStructure = that.secondaryStructure; -this.value = that.value; -this.colour = that.colour; -}, "jalview.datamodel.Annotation"); -Clazz.makeConstructor (c$, -function (val) { -this.construct (null, null, ' ', val, null); -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -var sb = new StringBuffer (); -if (this.displayCharacter != null) { -sb.append ("\'"); -sb.append (this.displayCharacter); -sb.append ("\'"); -}{ -sb.append (","); -}if (this.secondaryStructure.charCodeAt (0) != 0 && !("" + this.displayCharacter).equals ("" + this.secondaryStructure)) { -sb.append ("\'"); -sb.append (this.secondaryStructure); -sb.append ("\'"); -}{ -sb.append (","); -}if (this.description != null && this.description.length > 0) { -sb.append ("\""); -sb.append (this.description); -sb.append ("\""); -}{ -sb.append (","); -}if (!Float.isNaN (this.value)) { -sb.append (this.value); -}if (this.colour != null) { -if (sb.length () > 0) { -sb.append (","); -}sb.append ("["); -sb.append ("" + this.colour.getRed ()); -sb.append (","); -sb.append ("" + this.colour.getGreen ()); -sb.append (","); -sb.append ("" + this.colour.getBlue ()); -sb.append ("]"); -}return sb.toString (); -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.Annotation", ["java.lang.Float", "$.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.displayCharacter = ""; +this.description = ""; +this.secondaryStructure = ' '; +this.value = 0; +this.colour = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Annotation"); +Clazz.makeConstructor (c$, +function (displayChar, desc, ss, val) { +this.displayCharacter = displayChar; +this.description = desc; +this.secondaryStructure = ss; +this.value = val; +}, "~S,~S,~S,~N"); +Clazz.makeConstructor (c$, +function (displayChar, desc, ss, val, colour) { +this.construct (displayChar, desc, ss, val); +this.colour = colour; +}, "~S,~S,~S,~N,java.awt.Color"); +Clazz.makeConstructor (c$, +function (that) { +if (that == null || this === that) { +return; +}if (that.displayCharacter != null) this.displayCharacter = String.instantialize (that.displayCharacter); +if (that.description != null) this.description = String.instantialize (that.description); +this.secondaryStructure = that.secondaryStructure; +this.value = that.value; +this.colour = that.colour; +}, "jalview.datamodel.Annotation"); +Clazz.makeConstructor (c$, +function (val) { +this.construct (null, null, ' ', val, null); +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +var sb = new StringBuffer (); +if (this.displayCharacter != null) { +sb.append ("\'"); +sb.append (this.displayCharacter); +sb.append ("\'"); +}{ +sb.append (","); +}if (this.secondaryStructure.charCodeAt (0) != 0 && !("" + this.displayCharacter).equals ("" + this.secondaryStructure)) { +sb.append ("\'"); +sb.append (this.secondaryStructure); +sb.append ("\'"); +}{ +sb.append (","); +}if (this.description != null && this.description.length > 0) { +sb.append ("\""); +sb.append (this.description); +sb.append ("\""); +}{ +sb.append (","); +}if (!Float.isNaN (this.value)) { +sb.append (this.value); +}if (this.colour != null) { +if (sb.length () > 0) { +sb.append (","); +}sb.append ("["); +sb.append ("" + this.colour.getRed ()); +sb.append (","); +sb.append ("" + this.colour.getGreen ()); +sb.append (","); +sb.append ("" + this.colour.getBlue ()); +sb.append ("]"); +}return sb.toString (); +}); +}); diff --git a/bin/jalview/datamodel/BinaryNode.js b/bin/jalview/datamodel/BinaryNode.js index 7575508..64fb764 100644 --- a/bin/jalview/datamodel/BinaryNode.js +++ b/bin/jalview/datamodel/BinaryNode.js @@ -1,112 +1,112 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this.$element = null; -this.name = null; -this.$left = null; -this.$right = null; -this.$parent = null; -this.bootstrap = 0; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "BinaryNode"); -Clazz.makeConstructor (c$, -function () { -this.$left = this.$right = this.$parent = null; -this.bootstrap = 0; -}); -Clazz.makeConstructor (c$, -function (element, parent, name) { -this.$element = element; -this.$parent = parent; -this.name = name; -this.$left = this.$right = null; -}, "~O,jalview.datamodel.BinaryNode,~S"); -Clazz.defineMethod (c$, "element", -function () { -return this.$element; -}); -Clazz.defineMethod (c$, "setElement", -function (v) { -return this.$element = v; -}, "~O"); -Clazz.defineMethod (c$, "left", -function () { -return this.$left; -}); -Clazz.defineMethod (c$, "setLeft", -function (n) { -return this.$left = n; -}, "jalview.datamodel.BinaryNode"); -Clazz.defineMethod (c$, "right", -function () { -return this.$right; -}); -Clazz.defineMethod (c$, "setRight", -function (n) { -return this.$right = n; -}, "jalview.datamodel.BinaryNode"); -Clazz.defineMethod (c$, "parent", -function () { -return this.$parent; -}); -Clazz.defineMethod (c$, "setParent", -function (n) { -return this.$parent = n; -}, "jalview.datamodel.BinaryNode"); -Clazz.defineMethod (c$, "isLeaf", -function () { -return (this.$left == null) && (this.$right == null); -}); -Clazz.defineMethod (c$, "SetChildren", -function (leftchild, rightchild) { -if (leftchild != null) { -this.setLeft (leftchild); -leftchild.detach (); -leftchild.setParent (this); -}if (rightchild != null) { -this.setRight (rightchild); -rightchild.detach (); -rightchild.setParent (this); -}}, "jalview.datamodel.BinaryNode,jalview.datamodel.BinaryNode"); -Clazz.defineMethod (c$, "detach", -function () { -if (this.$parent != null) { -if (this.$parent.$left === this) { -this.$parent.$left = null; -} else { -if (this.$parent.$right === this) { -this.$parent.$right = null; -}}}this.$parent = null; -return this; -}); -Clazz.defineMethod (c$, "ascendLeft", -function () { -var c = this; -do { -c = c.parent (); -} while ((c != null) && (c.left () != null) && !c.left ().isLeaf ()); -return c; -}); -Clazz.defineMethod (c$, "ascendRight", -function () { -var c = this; -do { -c = c.parent (); -} while ((c != null) && (c.right () != null) && !c.right ().isLeaf ()); -return c; -}); -Clazz.defineMethod (c$, "setName", -function (name) { -this.name = name; -}, "~S"); -Clazz.defineMethod (c$, "getName", -function () { -return this.name; -}); -Clazz.defineMethod (c$, "setBootstrap", -function (boot) { -this.bootstrap = boot; -}, "~N"); -Clazz.defineMethod (c$, "getBootstrap", -function () { -return this.bootstrap; -}); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this.$element = null; +this.name = null; +this.$left = null; +this.$right = null; +this.$parent = null; +this.bootstrap = 0; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "BinaryNode"); +Clazz.makeConstructor (c$, +function () { +this.$left = this.$right = this.$parent = null; +this.bootstrap = 0; +}); +Clazz.makeConstructor (c$, +function (element, parent, name) { +this.$element = element; +this.$parent = parent; +this.name = name; +this.$left = this.$right = null; +}, "~O,jalview.datamodel.BinaryNode,~S"); +Clazz.defineMethod (c$, "element", +function () { +return this.$element; +}); +Clazz.defineMethod (c$, "setElement", +function (v) { +return this.$element = v; +}, "~O"); +Clazz.defineMethod (c$, "left", +function () { +return this.$left; +}); +Clazz.defineMethod (c$, "setLeft", +function (n) { +return this.$left = n; +}, "jalview.datamodel.BinaryNode"); +Clazz.defineMethod (c$, "right", +function () { +return this.$right; +}); +Clazz.defineMethod (c$, "setRight", +function (n) { +return this.$right = n; +}, "jalview.datamodel.BinaryNode"); +Clazz.defineMethod (c$, "parent", +function () { +return this.$parent; +}); +Clazz.defineMethod (c$, "setParent", +function (n) { +return this.$parent = n; +}, "jalview.datamodel.BinaryNode"); +Clazz.defineMethod (c$, "isLeaf", +function () { +return (this.$left == null) && (this.$right == null); +}); +Clazz.defineMethod (c$, "SetChildren", +function (leftchild, rightchild) { +if (leftchild != null) { +this.setLeft (leftchild); +leftchild.detach (); +leftchild.setParent (this); +}if (rightchild != null) { +this.setRight (rightchild); +rightchild.detach (); +rightchild.setParent (this); +}}, "jalview.datamodel.BinaryNode,jalview.datamodel.BinaryNode"); +Clazz.defineMethod (c$, "detach", +function () { +if (this.$parent != null) { +if (this.$parent.$left === this) { +this.$parent.$left = null; +} else { +if (this.$parent.$right === this) { +this.$parent.$right = null; +}}}this.$parent = null; +return this; +}); +Clazz.defineMethod (c$, "ascendLeft", +function () { +var c = this; +do { +c = c.parent (); +} while ((c != null) && (c.left () != null) && !c.left ().isLeaf ()); +return c; +}); +Clazz.defineMethod (c$, "ascendRight", +function () { +var c = this; +do { +c = c.parent (); +} while ((c != null) && (c.right () != null) && !c.right ().isLeaf ()); +return c; +}); +Clazz.defineMethod (c$, "setName", +function (name) { +this.name = name; +}, "~S"); +Clazz.defineMethod (c$, "getName", +function () { +return this.name; +}); +Clazz.defineMethod (c$, "setBootstrap", +function (boot) { +this.bootstrap = boot; +}, "~N"); +Clazz.defineMethod (c$, "getBootstrap", +function () { +return this.bootstrap; +}); diff --git a/bin/jalview/datamodel/BinarySequence.js b/bin/jalview/datamodel/BinarySequence.js index 90b6b95..2285387 100644 --- a/bin/jalview/datamodel/BinarySequence.js +++ b/bin/jalview/datamodel/BinarySequence.js @@ -1,99 +1,99 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.Sequence", "java.lang.Exception"], "jalview.datamodel.BinarySequence", ["jalview.schemes.ResidueProperties"], function () { -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.datamodel.BinarySequence.InvalidSequenceTypeException")) { -jalview.datamodel.BinarySequence.$BinarySequence$InvalidSequenceTypeException$ (); -} -this.binary = null; -this.dbinary = null; -this.isNa = false; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "BinarySequence", jalview.datamodel.Sequence); -Clazz.makeConstructor (c$, -function (s, isNa) { -Clazz.superConstructor (this, jalview.datamodel.BinarySequence, ["", s, 0, s.length]); -this.isNa = isNa; -}, "~S,~B"); -Clazz.defineMethod (c$, "initMatrixGetNoRes", -($fz = function () { -var nores = (this.isNa) ? 10 : 23; -this.dbinary = Clazz.newDoubleArray (this.getSequence ().length * nores, 0); -for (var i = 0; i < this.dbinary.length; i++) { -this.dbinary[i] = 0.0; -} -return nores; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getSymbolmatrix", -($fz = function () { -return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "encode", -function () { -var nores = this.initMatrixGetNoRes (); -var sindex = this.getSymbolmatrix (); -for (var i = 0; i < this.getSequence ().length; i++) { -var aanum = nores - 1; -try { -aanum = sindex[this.getCharAt (i).charCodeAt (0)]; -} catch (e) { -if (Clazz.exceptionOf (e, NullPointerException)) { -aanum = nores - 1; -} else { -throw e; -} -} -if (aanum >= nores) { -aanum = nores - 1; -}this.dbinary[(i * nores) + aanum] = 1.0; -} -}); -Clazz.defineMethod (c$, "matrixEncode", -function (matrix) { -if (this.isNa != matrix.isDNA ()) { -throw Clazz.innerTypeInstance (jalview.datamodel.BinarySequence.InvalidSequenceTypeException, this, null, "matrix " + matrix.getClass ().getCanonicalName () + " is not a valid matrix for " + (this.isNa ? "nucleotide" : "protein") + "sequences"); -}this.matrixEncode (matrix.isDNA () ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex, matrix.getMatrix ()); -}, "jalview.schemes.ScoreMatrix"); -Clazz.defineMethod (c$, "matrixEncode", -($fz = function (aaIndex, matrix) { -var nores = this.initMatrixGetNoRes (); -for (var i = 0, iSize = this.getSequence ().length; i < iSize; i++) { -var aanum = nores - 1; -try { -aanum = aaIndex[this.getCharAt (i).charCodeAt (0)]; -} catch (e) { -if (Clazz.exceptionOf (e, NullPointerException)) { -aanum = nores - 1; -} else { -throw e; -} -} -if (aanum >= nores) { -aanum = nores - 1; -}for (var j = 0; j < nores; j++) { -this.dbinary[(i * nores) + j] = matrix[aanum][j]; -} -} -}, $fz.isPrivate = true, $fz), "~A,~A"); -Clazz.defineMethod (c$, "toBinaryString", -function () { -var out = ""; -for (var i = 0; i < this.binary.length; i++) { -out += ( new Integer (this.binary[i])).toString (); -if (i < (this.binary.length - 1)) { -out += " "; -}} -return out; -}); -Clazz.defineMethod (c$, "getDBinary", -function () { -return this.dbinary; -}); -c$.$BinarySequence$InvalidSequenceTypeException$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.datamodel.BinarySequence, "InvalidSequenceTypeException", Exception); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.Sequence", "java.lang.Exception"], "jalview.datamodel.BinarySequence", ["jalview.schemes.ResidueProperties"], function () { +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.datamodel.BinarySequence.InvalidSequenceTypeException")) { +jalview.datamodel.BinarySequence.$BinarySequence$InvalidSequenceTypeException$ (); +} +this.binary = null; +this.dbinary = null; +this.isNa = false; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "BinarySequence", jalview.datamodel.Sequence); +Clazz.makeConstructor (c$, +function (s, isNa) { +Clazz.superConstructor (this, jalview.datamodel.BinarySequence, ["", s, 0, s.length]); +this.isNa = isNa; +}, "~S,~B"); +Clazz.defineMethod (c$, "initMatrixGetNoRes", +($fz = function () { +var nores = (this.isNa) ? 10 : 23; +this.dbinary = Clazz.newDoubleArray (this.getSequence ().length * nores, 0); +for (var i = 0; i < this.dbinary.length; i++) { +this.dbinary[i] = 0.0; +} +return nores; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getSymbolmatrix", +($fz = function () { +return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "encode", +function () { +var nores = this.initMatrixGetNoRes (); +var sindex = this.getSymbolmatrix (); +for (var i = 0; i < this.getSequence ().length; i++) { +var aanum = nores - 1; +try { +aanum = sindex[this.getCharAt (i).charCodeAt (0)]; +} catch (e) { +if (Clazz.exceptionOf (e, NullPointerException)) { +aanum = nores - 1; +} else { +throw e; +} +} +if (aanum >= nores) { +aanum = nores - 1; +}this.dbinary[(i * nores) + aanum] = 1.0; +} +}); +Clazz.defineMethod (c$, "matrixEncode", +function (matrix) { +if (this.isNa != matrix.isDNA ()) { +throw Clazz.innerTypeInstance (jalview.datamodel.BinarySequence.InvalidSequenceTypeException, this, null, "matrix " + matrix.getClass ().getCanonicalName () + " is not a valid matrix for " + (this.isNa ? "nucleotide" : "protein") + "sequences"); +}this.matrixEncode (matrix.isDNA () ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex, matrix.getMatrix ()); +}, "jalview.schemes.ScoreMatrix"); +Clazz.defineMethod (c$, "matrixEncode", +($fz = function (aaIndex, matrix) { +var nores = this.initMatrixGetNoRes (); +for (var i = 0, iSize = this.getSequence ().length; i < iSize; i++) { +var aanum = nores - 1; +try { +aanum = aaIndex[this.getCharAt (i).charCodeAt (0)]; +} catch (e) { +if (Clazz.exceptionOf (e, NullPointerException)) { +aanum = nores - 1; +} else { +throw e; +} +} +if (aanum >= nores) { +aanum = nores - 1; +}for (var j = 0; j < nores; j++) { +this.dbinary[(i * nores) + j] = matrix[aanum][j]; +} +} +}, $fz.isPrivate = true, $fz), "~A,~A"); +Clazz.defineMethod (c$, "toBinaryString", +function () { +var out = ""; +for (var i = 0; i < this.binary.length; i++) { +out += ( new Integer (this.binary[i])).toString (); +if (i < (this.binary.length - 1)) { +out += " "; +}} +return out; +}); +Clazz.defineMethod (c$, "getDBinary", +function () { +return this.dbinary; +}); +c$.$BinarySequence$InvalidSequenceTypeException$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.datamodel.BinarySequence, "InvalidSequenceTypeException", Exception); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/datamodel/CigarArray.js b/bin/jalview/datamodel/CigarArray.js index 7f45aff..b18df9f 100644 --- a/bin/jalview/datamodel/CigarArray.js +++ b/bin/jalview/datamodel/CigarArray.js @@ -1,188 +1,188 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.CigarBase"], "jalview.datamodel.CigarArray", ["jalview.datamodel.CigarCigar", "$.SeqCigar", "java.lang.StringBuffer", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.refCigars = null; -this.seqcigararray = false; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "CigarArray", jalview.datamodel.CigarBase); -Clazz.defineMethod (c$, "isSeqCigarArray", -function () { -return this.seqcigararray; -}); -Clazz.makeConstructor (c$, -function (cigars) { -Clazz.superConstructor (this, jalview.datamodel.CigarArray); -this.seqcigararray = true; -if (cigars != null && cigars.length > 0) { -this.refCigars = new Array (cigars.length); -for (var c = 0; c < cigars.length; c++) { -this.refCigars[c] = cigars[c]; -if (!((Clazz.instanceOf (cigars[c], jalview.datamodel.SeqCigar)) || Clazz.instanceOf (cigars[c], jalview.datamodel.CigarCigar))) { -this.seqcigararray = false; -}} -}}, "~A"); -Clazz.makeConstructor (c$, -function (alignment, columnSelection, selectionGroup) { -this.construct (jalview.datamodel.CigarArray.constructSeqCigarArray (alignment, selectionGroup)); -this.constructFromAlignment (alignment, columnSelection != null ? columnSelection.getHiddenColumns () : null, selectionGroup); -}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup"); -c$._calcStartEndBounds = Clazz.defineMethod (c$, "_calcStartEndBounds", -($fz = function (alignment, selectionGroup) { -var startend = Clazz.newIntArray (-1, [0, 0, 0]); -if (selectionGroup != null) { -startend[0] = selectionGroup.getSize (); -startend[1] = selectionGroup.getStartRes (); -startend[2] = selectionGroup.getEndRes (); -} else { -startend[0] = alignment.getHeight (); -startend[2] = alignment.getWidth () - 1; -}return startend; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); -c$.constructSeqCigarArray = Clazz.defineMethod (c$, "constructSeqCigarArray", -function (alignment, selectionGroup) { -var seqs = null; -var i; -var iSize; -var _startend = jalview.datamodel.CigarArray._calcStartEndBounds (alignment, selectionGroup); -var start = _startend[1]; -var end = _startend[2]; -if (selectionGroup != null) { -iSize = selectionGroup.getSize (); -seqs = selectionGroup.getSequencesInOrder (alignment); -start = selectionGroup.getStartRes (); -end = selectionGroup.getEndRes (); -} else { -iSize = alignment.getHeight (); -seqs = alignment.getSequencesArray (); -end = alignment.getWidth () - 1; -}var selseqs = new Array (iSize); -for (i = 0; i < iSize; i++) { -selseqs[i] = new jalview.datamodel.SeqCigar (seqs[i], start, end); -} -return selseqs; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "constructFromAlignment", -($fz = function (alignment, list, selectionGroup) { -var _startend = jalview.datamodel.CigarArray._calcStartEndBounds (alignment, selectionGroup); -var start = _startend[1]; -var end = _startend[2]; -if (list != null) { -var region; -var hideStart; -var hideEnd; -var last = start; -for (var j = 0; new Boolean (last < end & j < list.size ()).valueOf (); j++) { -region = list.get (j); -hideStart = region[0]; -hideEnd = region[1]; -if (hideStart < last) { -if (hideEnd > last) { -hideStart = last; -} else { -continue; -}}if (hideStart > end) { -break; -}if (hideEnd > end) { -hideEnd = end; -}if (hideStart > hideEnd) { -break; -}if (last < hideStart) { -this.addOperation ('M', hideStart - last); -}this.addOperation ('D', 1 + hideEnd - hideStart); -last = hideEnd + 1; -} -if (last < end) { -this.addOperation ('M', end - last + 1); -}} else { -this.addOperation ('M', end - start + 1); -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "getArrayofSequenceAndDeletions", -function (GapChar) { -if (this.refCigars == null || this.refCigars.length == 0 || this.length == 0) { -return null; -}var sqanddels = new Array (this.refCigars.length); -for (var c = 0; c < this.refCigars.length; c++) { -var refString = this.refCigars[c].getSequenceString (GapChar); -if (refString != null) { -sqanddels[c] = this.getSequenceAndDeletions (refString, GapChar); -} else { -sqanddels[c] = null; -}} -return sqanddels; -}, "~S"); -Clazz.defineMethod (c$, "getSequenceString", -function (GapChar) { -if (this.length == 0 || this.refCigars == null) { -return ""; -}var seqStrings = new StringBuffer (); -var sqanddels = this.getArrayofSequenceAndDeletions (GapChar); -for (var c = 0; c < this.refCigars.length; c++) { -if (sqanddels[c] != null) { -seqStrings.append (sqanddels[c][0]); -sqanddels[c][0] = null; -}seqStrings.append ('\n'); -} -return seqStrings.toString (); -}, "~S"); -Clazz.defineMethod (c$, "getSequenceStrings", -function (GapChar) { -if (this.length == 0 || this.refCigars == null || this.refCigars.length == 0) { -return null; -}var sqanddels = this.getArrayofSequenceAndDeletions (GapChar); -var seqs = new Array (sqanddels.length); -for (var c = 0; c < this.refCigars.length; c++) { -seqs[c] = sqanddels[c][0]; -} -return seqs; -}, "~S"); -Clazz.defineMethod (c$, "applyDeletions", -function () { -var delpos = null; -if (this.length == 0) { -return null; -}var cursor = 0; -var vcursor = 0; -var offset = 0; -var i = 0; -while (i < this.length) { -if (this.operation[i] != 'D') { -if (this.operation[i] == 'M') { -cursor += this.range[i]; -}vcursor += this.range[i++]; -} else { -if (delpos == null) { -delpos = new java.util.Vector (); -}var delstart = cursor; -var delend = cursor + this.range[i] - 1; -delpos.addElement ( Clazz.newIntArray (-1, [vcursor + offset, this.range[i]])); -offset += this.range[i] - 1; -System.arraycopy (this.operation, i + 1, this.operation, i, this.length - i); -System.arraycopy (this.range, i + 1, this.range, i, this.length - i); -this.length--; -for (var s = 0; s < this.refCigars.length; s++) { -var d = this.refCigars[s].deleteRange (delstart, delend); -} -}} -if (delpos != null) { -var pos = Clazz.newIntArray (delpos.size () * 2, 0); -for (var k = 0, l = delpos.size (); k < l; k++) { -var dr = (delpos.elementAt (k)); -pos[k * 2] = dr[0]; -pos[k * 2 + 1] = dr[1]; -delpos.setElementAt (null, k); -} -delpos = null; -return pos; -}return null; -}); -Clazz.defineMethod (c$, "getSeqCigarArray", -function () { -if (!this.isSeqCigarArray ()) { -return null; -}var sa = new Array (this.refCigars.length); -for (var i = 0; i < this.refCigars.length; i++) { -sa[i] = this.refCigars[i]; -} -return sa; -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.CigarBase"], "jalview.datamodel.CigarArray", ["jalview.datamodel.CigarCigar", "$.SeqCigar", "java.lang.StringBuffer", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.refCigars = null; +this.seqcigararray = false; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "CigarArray", jalview.datamodel.CigarBase); +Clazz.defineMethod (c$, "isSeqCigarArray", +function () { +return this.seqcigararray; +}); +Clazz.makeConstructor (c$, +function (cigars) { +Clazz.superConstructor (this, jalview.datamodel.CigarArray); +this.seqcigararray = true; +if (cigars != null && cigars.length > 0) { +this.refCigars = new Array (cigars.length); +for (var c = 0; c < cigars.length; c++) { +this.refCigars[c] = cigars[c]; +if (!((Clazz.instanceOf (cigars[c], jalview.datamodel.SeqCigar)) || Clazz.instanceOf (cigars[c], jalview.datamodel.CigarCigar))) { +this.seqcigararray = false; +}} +}}, "~A"); +Clazz.makeConstructor (c$, +function (alignment, columnSelection, selectionGroup) { +this.construct (jalview.datamodel.CigarArray.constructSeqCigarArray (alignment, selectionGroup)); +this.constructFromAlignment (alignment, columnSelection != null ? columnSelection.getHiddenColumns () : null, selectionGroup); +}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,jalview.datamodel.SequenceGroup"); +c$._calcStartEndBounds = Clazz.defineMethod (c$, "_calcStartEndBounds", +($fz = function (alignment, selectionGroup) { +var startend = Clazz.newIntArray (-1, [0, 0, 0]); +if (selectionGroup != null) { +startend[0] = selectionGroup.getSize (); +startend[1] = selectionGroup.getStartRes (); +startend[2] = selectionGroup.getEndRes (); +} else { +startend[0] = alignment.getHeight (); +startend[2] = alignment.getWidth () - 1; +}return startend; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); +c$.constructSeqCigarArray = Clazz.defineMethod (c$, "constructSeqCigarArray", +function (alignment, selectionGroup) { +var seqs = null; +var i; +var iSize; +var _startend = jalview.datamodel.CigarArray._calcStartEndBounds (alignment, selectionGroup); +var start = _startend[1]; +var end = _startend[2]; +if (selectionGroup != null) { +iSize = selectionGroup.getSize (); +seqs = selectionGroup.getSequencesInOrder (alignment); +start = selectionGroup.getStartRes (); +end = selectionGroup.getEndRes (); +} else { +iSize = alignment.getHeight (); +seqs = alignment.getSequencesArray (); +end = alignment.getWidth () - 1; +}var selseqs = new Array (iSize); +for (i = 0; i < iSize; i++) { +selseqs[i] = new jalview.datamodel.SeqCigar (seqs[i], start, end); +} +return selseqs; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "constructFromAlignment", +($fz = function (alignment, list, selectionGroup) { +var _startend = jalview.datamodel.CigarArray._calcStartEndBounds (alignment, selectionGroup); +var start = _startend[1]; +var end = _startend[2]; +if (list != null) { +var region; +var hideStart; +var hideEnd; +var last = start; +for (var j = 0; new Boolean (last < end & j < list.size ()).valueOf (); j++) { +region = list.get (j); +hideStart = region[0]; +hideEnd = region[1]; +if (hideStart < last) { +if (hideEnd > last) { +hideStart = last; +} else { +continue; +}}if (hideStart > end) { +break; +}if (hideEnd > end) { +hideEnd = end; +}if (hideStart > hideEnd) { +break; +}if (last < hideStart) { +this.addOperation ('M', hideStart - last); +}this.addOperation ('D', 1 + hideEnd - hideStart); +last = hideEnd + 1; +} +if (last < end) { +this.addOperation ('M', end - last + 1); +}} else { +this.addOperation ('M', end - start + 1); +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "getArrayofSequenceAndDeletions", +function (GapChar) { +if (this.refCigars == null || this.refCigars.length == 0 || this.length == 0) { +return null; +}var sqanddels = new Array (this.refCigars.length); +for (var c = 0; c < this.refCigars.length; c++) { +var refString = this.refCigars[c].getSequenceString (GapChar); +if (refString != null) { +sqanddels[c] = this.getSequenceAndDeletions (refString, GapChar); +} else { +sqanddels[c] = null; +}} +return sqanddels; +}, "~S"); +Clazz.defineMethod (c$, "getSequenceString", +function (GapChar) { +if (this.length == 0 || this.refCigars == null) { +return ""; +}var seqStrings = new StringBuffer (); +var sqanddels = this.getArrayofSequenceAndDeletions (GapChar); +for (var c = 0; c < this.refCigars.length; c++) { +if (sqanddels[c] != null) { +seqStrings.append (sqanddels[c][0]); +sqanddels[c][0] = null; +}seqStrings.append ('\n'); +} +return seqStrings.toString (); +}, "~S"); +Clazz.defineMethod (c$, "getSequenceStrings", +function (GapChar) { +if (this.length == 0 || this.refCigars == null || this.refCigars.length == 0) { +return null; +}var sqanddels = this.getArrayofSequenceAndDeletions (GapChar); +var seqs = new Array (sqanddels.length); +for (var c = 0; c < this.refCigars.length; c++) { +seqs[c] = sqanddels[c][0]; +} +return seqs; +}, "~S"); +Clazz.defineMethod (c$, "applyDeletions", +function () { +var delpos = null; +if (this.length == 0) { +return null; +}var cursor = 0; +var vcursor = 0; +var offset = 0; +var i = 0; +while (i < this.length) { +if (this.operation[i] != 'D') { +if (this.operation[i] == 'M') { +cursor += this.range[i]; +}vcursor += this.range[i++]; +} else { +if (delpos == null) { +delpos = new java.util.Vector (); +}var delstart = cursor; +var delend = cursor + this.range[i] - 1; +delpos.addElement ( Clazz.newIntArray (-1, [vcursor + offset, this.range[i]])); +offset += this.range[i] - 1; +System.arraycopy (this.operation, i + 1, this.operation, i, this.length - i); +System.arraycopy (this.range, i + 1, this.range, i, this.length - i); +this.length--; +for (var s = 0; s < this.refCigars.length; s++) { +var d = this.refCigars[s].deleteRange (delstart, delend); +} +}} +if (delpos != null) { +var pos = Clazz.newIntArray (delpos.size () * 2, 0); +for (var k = 0, l = delpos.size (); k < l; k++) { +var dr = (delpos.elementAt (k)); +pos[k * 2] = dr[0]; +pos[k * 2 + 1] = dr[1]; +delpos.setElementAt (null, k); +} +delpos = null; +return pos; +}return null; +}); +Clazz.defineMethod (c$, "getSeqCigarArray", +function () { +if (!this.isSeqCigarArray ()) { +return null; +}var sa = new Array (this.refCigars.length); +for (var i = 0; i < this.refCigars.length; i++) { +sa[i] = this.refCigars[i]; +} +return sa; +}); +}); diff --git a/bin/jalview/datamodel/CigarBase.js b/bin/jalview/datamodel/CigarBase.js index 5b88b3f..bd75085 100644 --- a/bin/jalview/datamodel/CigarBase.js +++ b/bin/jalview/datamodel/CigarBase.js @@ -1,310 +1,310 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.CigarBase", ["jalview.util.MessageManager", "java.lang.Error", "$.Exception", "$.StringBuffer", "java.util.Vector", "javajs.util.AU"], function () { -c$ = Clazz.decorateAsClass (function () { -this.length = 0; -this._inc_length = 10; -this.operation = null; -this.range = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "CigarBase"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "getSequenceAndDeletions", -function (reference, GapChar) { -var rlength = 0; -var deletions = javajs.util.AU.newInt2 (this.length); -var trunc_deletions = null; -var sq = new StringBuffer (); -var cursor = 0; -var alcursor = 0; -var start = 0; -var startpos = 0; -var end = 0; -var endpos = 0; -var delcount = -1; -var consecutive_del = false; -if (this.length == 0) { -return null; -}if (reference != null) { -rlength = reference.length; -}var modstart = true; -for (var i = 0; i < this.length; i++) { -switch (this.operation[i]) { -case 'D': -if (!consecutive_del) { -deletions[++delcount] = Clazz.newIntArray (-1, [cursor, 0, alcursor]); -}cursor += this.range[i]; -deletions[delcount][1] = cursor - 1; -consecutive_del = true; -break; -case 'I': -consecutive_del = false; -for (var r = 0; r < this.range[i]; r++) { -sq.append (GapChar); -alcursor++; -} -break; -case 'M': -consecutive_del = false; -if (modstart) { -start = cursor; -startpos = alcursor; -modstart = false; -}if (reference != null) { -var sbend = cursor + this.range[i]; -if (sbend > rlength) { -sq.append (reference.substring (cursor, rlength)); -while (sbend-- >= rlength) { -sq.append (GapChar); -} -} else { -sq.append (reference.substring (cursor, sbend)); -}}alcursor += this.range[i]; -cursor += this.range[i]; -end = cursor - 1; -endpos = alcursor; -break; -default: -throw new Error (jalview.util.MessageManager.formatMessage ("error.unknown_seq_cigar_operation", Clazz.newArray (-1, [ new StringBuffer (this.operation[i].charCodeAt (0)).toString ()]))); -} -} -if (++delcount > 0) { -trunc_deletions = Clazz.newIntArray (delcount, 0); -System.arraycopy (deletions, 0, trunc_deletions, 0, delcount); -}deletions = null; -return Clazz.newArray (-1, [((reference != null) ? sq.toString () : null), Clazz.newIntArray (-1, [start, startpos, end, endpos]), trunc_deletions]); -}, "~S,~S"); -Clazz.defineMethod (c$, "compact_operations", -function () { -var i = 1; -if (this.operation == null) { -return; -}var last = this.operation[0]; -while (i < this.length) { -if (last == this.operation[i]) { -this.range[i - 1] += this.range[i]; -var r = this.length - i; -if (r > 0) { -System.arraycopy (this.range, i + 1, this.range, i, r); -System.arraycopy (this.operation, i + 1, this.operation, i, r); -}this.length--; -} else { -last = this.operation[i++]; -}} -}); -c$.parseCigarString = Clazz.defineMethod (c$, "parseCigarString", -function (cigarString) { -var ops = 0; -for (var i = 0, l = cigarString.length; i < l; i++) { -var c = cigarString.charAt (i); -if (c == 'M' || c.charCodeAt (0) == (45) || c == 'I' || c.charCodeAt (0) == (41) || c == 'D' || c.charCodeAt (0) == (36)) { -ops++; -}} -var operation = Clazz.newCharArray (ops, '\0'); -var range = Clazz.newIntArray (ops, 0); -var op = 0; -var i = 0; -var l = cigarString.length; -while (i < l) { -var c; -var j = i; -do { -c = cigarString.charAt (j++); -} while (c >= '0' && c <= '9' && j < l); -if (j >= l && c >= '0' && c <= '9') { -throw new Exception (jalview.util.MessageManager.getString ("exception.unterminated_cigar_string")); -}try { -var rangeint = cigarString.substring (i, j - 1); -range[op] = Integer.parseInt (rangeint); -i = j; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_bug_parse_cigar_string")); -} else { -throw e; -} -} -if (c >= 'a' && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - 32); -}if ((c == 'M' || c == 'I' || c == 'D')) { -operation[op++] = c; -} else { -throw new Exception (jalview.util.MessageManager.formatMessage ("exception.unexpected_operation_cigar_string_pos", Clazz.newArray (-1, [ new StringBuffer (c.charCodeAt (0)).toString (), Integer.$valueOf (i).toString (), cigarString]))); -}} -return Clazz.newArray (-1, [operation, range]); -}, "~S"); -Clazz.defineMethod (c$, "addOperation", -function (op, range) { -if (op >= 'a' && op <= 'z') { -op = String.fromCharCode (op.charCodeAt (0) - 32); -}if (op != 'M' && op != 'D' && op != 'I') { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_invalid_operation_string")); -}if (range == 0) { -return; -}if (range < 0) { -throw new Error (jalview.util.MessageManager.getString ("error.invalid_range_string")); -}var lngth = 0; -if (this.operation == null) { -this.operation = Clazz.newCharArray (this._inc_length, '\0'); -this.range = Clazz.newIntArray (this._inc_length, 0); -}if (this.length + 1 == this.operation.length) { -var ops = this.operation; -this.operation = Clazz.newCharArray (this.length + 1 + this._inc_length, '\0'); -System.arraycopy (ops, 0, this.operation, 0, this.length); -ops = null; -var rng = this.range; -this.range = Clazz.newIntArray (this.length + 1 + this._inc_length, 0); -System.arraycopy (rng, 0, this.range, 0, this.length); -rng = null; -}if ((this.length > 0) && (this.operation[this.length - 1] == op)) { -this.length--; -} else { -this.range[this.length] = 0; -}this.operation[this.length] = op; -this.range[this.length++] += range; -}, "~S,~N"); -Clazz.defineMethod (c$, "deleteRange", -function (start, end) { -var deleted = 0; -if (this.length == 0) { -return deleted; -}if (start < 0 || start > end) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_delete_range_out_of_bounds")); -}var cursor = 0; -var rlength = 1 + end - start; -var oldlen = this.length; -var o = 0; -var editing = false; -var oldops = this.operation; -var oldrange = this.range; -this.length = 0; -this.operation = null; -this.range = null; -this.compact_operations (); -while (o < oldlen && cursor <= end && rlength > 0) { -if (oldops[o] == 'D') { -this.addDeleted (oldrange[o++]); -continue; -}var remain = oldrange[o]; -if (!editing) { -if ((cursor + remain) <= start) { -this.addOperation (oldops[o], oldrange[o]); -cursor += oldrange[o++]; -continue; -}editing = true; -if (start - cursor > 0) { -this.addOperation (oldops[o], start - cursor); -remain -= start - cursor; -}}if (o < oldlen && editing && rlength > 0 && remain > 0) { -switch (oldops[o]) { -case 'M': -if (rlength > remain) { -this.addDeleted (remain); -deleted += remain; -} else { -deleted += rlength; -this.addDeleted (rlength); -if (remain - rlength > 0) { -this.addOperation ('M', remain - rlength); -}rlength = 0; -remain = 0; -}break; -case 'I': -if (remain - rlength > 0) { -this.addInsertion (remain - rlength); -rlength = 0; -}break; -case 'D': -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error")); -default: -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_unknown_operation", Clazz.newArray (-1, [ new StringBuffer (oldops[o].charCodeAt (0)).toString ()]))); -} -rlength -= remain; -remain = oldrange[++o]; -}} -while (o < oldlen) { -this.addOperation (oldops[o], oldrange[o++]); -} -return deleted; -}, "~N,~N"); -Clazz.defineMethod (c$, "hasDeletedRegions", -function () { -for (var i = 0; i < this.length; i++) { -if (this.operation[i] == 'D') { -return true; -}} -return false; -}); -Clazz.defineMethod (c$, "getDeletedRegions", -function () { -if (this.length == 0) { -return null; -}var dr = new java.util.Vector (); -var cursor = 0; -var vcursor = 0; -for (var i = 0; i < this.length; i++) { -switch (this.operation[i]) { -case 'M': -cursor += this.range[i]; -case 'I': -vcursor += this.range[i]; -break; -case 'D': -dr.addElement ( Clazz.newIntArray (-1, [vcursor, cursor, this.range[i]])); -cursor += this.range[i]; -} -} -if (dr.size () == 0) { -return null; -}var delregions = Clazz.newIntArray (dr.size () * 3, 0); -for (var i = 0, l = dr.size (); i < l; i++) { -var reg = dr.elementAt (i); -delregions[i * 3] = reg[0]; -delregions[i * 3 + 1] = reg[1]; -delregions[i * 3 + 2] = reg[2]; -} -return delregions; -}); -Clazz.defineMethod (c$, "getFullWidth", -function () { -var w = 0; -if (this.range != null) { -for (var i = 0; i < this.length; i++) { -w += this.range[i]; -} -}return w; -}); -Clazz.defineMethod (c$, "getWidth", -function () { -var w = 0; -if (this.range != null) { -for (var i = 0; i < this.length; i++) { -if (this.operation[i] == 'M' || this.operation[i] == 'I') { -w += this.range[i]; -}} -}return w; -}); -Clazz.defineMethod (c$, "addInsertion", -function (range) { -this.addOperation ('I', range); -}, "~N"); -Clazz.defineMethod (c$, "addDeleted", -function (range) { -this.addOperation ('D', range); -}, "~N"); -Clazz.defineMethod (c$, "getCigarstring", -function () { -var cigarString = new StringBuffer (); -for (var i = 0; i < this.length; i++) { -cigarString.append ("" + this.range[i]); -cigarString.append (this.operation[i]); -} -return cigarString.toString (); -}); -Clazz.defineStatics (c$, -"D", 'D', -"I", 'I', -"M", 'M', -"_case_shift", String.fromCharCode (32)); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.CigarBase", ["jalview.util.MessageManager", "java.lang.Error", "$.Exception", "$.StringBuffer", "java.util.Vector", "javajs.util.AU"], function () { +c$ = Clazz.decorateAsClass (function () { +this.length = 0; +this._inc_length = 10; +this.operation = null; +this.range = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "CigarBase"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "getSequenceAndDeletions", +function (reference, GapChar) { +var rlength = 0; +var deletions = javajs.util.AU.newInt2 (this.length); +var trunc_deletions = null; +var sq = new StringBuffer (); +var cursor = 0; +var alcursor = 0; +var start = 0; +var startpos = 0; +var end = 0; +var endpos = 0; +var delcount = -1; +var consecutive_del = false; +if (this.length == 0) { +return null; +}if (reference != null) { +rlength = reference.length; +}var modstart = true; +for (var i = 0; i < this.length; i++) { +switch (this.operation[i]) { +case 'D': +if (!consecutive_del) { +deletions[++delcount] = Clazz.newIntArray (-1, [cursor, 0, alcursor]); +}cursor += this.range[i]; +deletions[delcount][1] = cursor - 1; +consecutive_del = true; +break; +case 'I': +consecutive_del = false; +for (var r = 0; r < this.range[i]; r++) { +sq.append (GapChar); +alcursor++; +} +break; +case 'M': +consecutive_del = false; +if (modstart) { +start = cursor; +startpos = alcursor; +modstart = false; +}if (reference != null) { +var sbend = cursor + this.range[i]; +if (sbend > rlength) { +sq.append (reference.substring (cursor, rlength)); +while (sbend-- >= rlength) { +sq.append (GapChar); +} +} else { +sq.append (reference.substring (cursor, sbend)); +}}alcursor += this.range[i]; +cursor += this.range[i]; +end = cursor - 1; +endpos = alcursor; +break; +default: +throw new Error (jalview.util.MessageManager.formatMessage ("error.unknown_seq_cigar_operation", Clazz.newArray (-1, [ new StringBuffer (this.operation[i].charCodeAt (0)).toString ()]))); +} +} +if (++delcount > 0) { +trunc_deletions = Clazz.newIntArray (delcount, 0); +System.arraycopy (deletions, 0, trunc_deletions, 0, delcount); +}deletions = null; +return Clazz.newArray (-1, [((reference != null) ? sq.toString () : null), Clazz.newIntArray (-1, [start, startpos, end, endpos]), trunc_deletions]); +}, "~S,~S"); +Clazz.defineMethod (c$, "compact_operations", +function () { +var i = 1; +if (this.operation == null) { +return; +}var last = this.operation[0]; +while (i < this.length) { +if (last == this.operation[i]) { +this.range[i - 1] += this.range[i]; +var r = this.length - i; +if (r > 0) { +System.arraycopy (this.range, i + 1, this.range, i, r); +System.arraycopy (this.operation, i + 1, this.operation, i, r); +}this.length--; +} else { +last = this.operation[i++]; +}} +}); +c$.parseCigarString = Clazz.defineMethod (c$, "parseCigarString", +function (cigarString) { +var ops = 0; +for (var i = 0, l = cigarString.length; i < l; i++) { +var c = cigarString.charAt (i); +if (c == 'M' || c.charCodeAt (0) == (45) || c == 'I' || c.charCodeAt (0) == (41) || c == 'D' || c.charCodeAt (0) == (36)) { +ops++; +}} +var operation = Clazz.newCharArray (ops, '\0'); +var range = Clazz.newIntArray (ops, 0); +var op = 0; +var i = 0; +var l = cigarString.length; +while (i < l) { +var c; +var j = i; +do { +c = cigarString.charAt (j++); +} while (c >= '0' && c <= '9' && j < l); +if (j >= l && c >= '0' && c <= '9') { +throw new Exception (jalview.util.MessageManager.getString ("exception.unterminated_cigar_string")); +}try { +var rangeint = cigarString.substring (i, j - 1); +range[op] = Integer.parseInt (rangeint); +i = j; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_bug_parse_cigar_string")); +} else { +throw e; +} +} +if (c >= 'a' && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - 32); +}if ((c == 'M' || c == 'I' || c == 'D')) { +operation[op++] = c; +} else { +throw new Exception (jalview.util.MessageManager.formatMessage ("exception.unexpected_operation_cigar_string_pos", Clazz.newArray (-1, [ new StringBuffer (c.charCodeAt (0)).toString (), Integer.$valueOf (i).toString (), cigarString]))); +}} +return Clazz.newArray (-1, [operation, range]); +}, "~S"); +Clazz.defineMethod (c$, "addOperation", +function (op, range) { +if (op >= 'a' && op <= 'z') { +op = String.fromCharCode (op.charCodeAt (0) - 32); +}if (op != 'M' && op != 'D' && op != 'I') { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_invalid_operation_string")); +}if (range == 0) { +return; +}if (range < 0) { +throw new Error (jalview.util.MessageManager.getString ("error.invalid_range_string")); +}var lngth = 0; +if (this.operation == null) { +this.operation = Clazz.newCharArray (this._inc_length, '\0'); +this.range = Clazz.newIntArray (this._inc_length, 0); +}if (this.length + 1 == this.operation.length) { +var ops = this.operation; +this.operation = Clazz.newCharArray (this.length + 1 + this._inc_length, '\0'); +System.arraycopy (ops, 0, this.operation, 0, this.length); +ops = null; +var rng = this.range; +this.range = Clazz.newIntArray (this.length + 1 + this._inc_length, 0); +System.arraycopy (rng, 0, this.range, 0, this.length); +rng = null; +}if ((this.length > 0) && (this.operation[this.length - 1] == op)) { +this.length--; +} else { +this.range[this.length] = 0; +}this.operation[this.length] = op; +this.range[this.length++] += range; +}, "~S,~N"); +Clazz.defineMethod (c$, "deleteRange", +function (start, end) { +var deleted = 0; +if (this.length == 0) { +return deleted; +}if (start < 0 || start > end) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_delete_range_out_of_bounds")); +}var cursor = 0; +var rlength = 1 + end - start; +var oldlen = this.length; +var o = 0; +var editing = false; +var oldops = this.operation; +var oldrange = this.range; +this.length = 0; +this.operation = null; +this.range = null; +this.compact_operations (); +while (o < oldlen && cursor <= end && rlength > 0) { +if (oldops[o] == 'D') { +this.addDeleted (oldrange[o++]); +continue; +}var remain = oldrange[o]; +if (!editing) { +if ((cursor + remain) <= start) { +this.addOperation (oldops[o], oldrange[o]); +cursor += oldrange[o++]; +continue; +}editing = true; +if (start - cursor > 0) { +this.addOperation (oldops[o], start - cursor); +remain -= start - cursor; +}}if (o < oldlen && editing && rlength > 0 && remain > 0) { +switch (oldops[o]) { +case 'M': +if (rlength > remain) { +this.addDeleted (remain); +deleted += remain; +} else { +deleted += rlength; +this.addDeleted (rlength); +if (remain - rlength > 0) { +this.addOperation ('M', remain - rlength); +}rlength = 0; +remain = 0; +}break; +case 'I': +if (remain - rlength > 0) { +this.addInsertion (remain - rlength); +rlength = 0; +}break; +case 'D': +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error")); +default: +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_unknown_operation", Clazz.newArray (-1, [ new StringBuffer (oldops[o].charCodeAt (0)).toString ()]))); +} +rlength -= remain; +remain = oldrange[++o]; +}} +while (o < oldlen) { +this.addOperation (oldops[o], oldrange[o++]); +} +return deleted; +}, "~N,~N"); +Clazz.defineMethod (c$, "hasDeletedRegions", +function () { +for (var i = 0; i < this.length; i++) { +if (this.operation[i] == 'D') { +return true; +}} +return false; +}); +Clazz.defineMethod (c$, "getDeletedRegions", +function () { +if (this.length == 0) { +return null; +}var dr = new java.util.Vector (); +var cursor = 0; +var vcursor = 0; +for (var i = 0; i < this.length; i++) { +switch (this.operation[i]) { +case 'M': +cursor += this.range[i]; +case 'I': +vcursor += this.range[i]; +break; +case 'D': +dr.addElement ( Clazz.newIntArray (-1, [vcursor, cursor, this.range[i]])); +cursor += this.range[i]; +} +} +if (dr.size () == 0) { +return null; +}var delregions = Clazz.newIntArray (dr.size () * 3, 0); +for (var i = 0, l = dr.size (); i < l; i++) { +var reg = dr.elementAt (i); +delregions[i * 3] = reg[0]; +delregions[i * 3 + 1] = reg[1]; +delregions[i * 3 + 2] = reg[2]; +} +return delregions; +}); +Clazz.defineMethod (c$, "getFullWidth", +function () { +var w = 0; +if (this.range != null) { +for (var i = 0; i < this.length; i++) { +w += this.range[i]; +} +}return w; +}); +Clazz.defineMethod (c$, "getWidth", +function () { +var w = 0; +if (this.range != null) { +for (var i = 0; i < this.length; i++) { +if (this.operation[i] == 'M' || this.operation[i] == 'I') { +w += this.range[i]; +}} +}return w; +}); +Clazz.defineMethod (c$, "addInsertion", +function (range) { +this.addOperation ('I', range); +}, "~N"); +Clazz.defineMethod (c$, "addDeleted", +function (range) { +this.addOperation ('D', range); +}, "~N"); +Clazz.defineMethod (c$, "getCigarstring", +function () { +var cigarString = new StringBuffer (); +for (var i = 0; i < this.length; i++) { +cigarString.append ("" + this.range[i]); +cigarString.append (this.operation[i]); +} +return cigarString.toString (); +}); +Clazz.defineStatics (c$, +"D", 'D', +"I", 'I', +"M", 'M', +"_case_shift", String.fromCharCode (32)); +}); diff --git a/bin/jalview/datamodel/CigarCigar.js b/bin/jalview/datamodel/CigarCigar.js index 9448de4..12f3e39 100644 --- a/bin/jalview/datamodel/CigarCigar.js +++ b/bin/jalview/datamodel/CigarCigar.js @@ -1,22 +1,22 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.CigarSimple"], "jalview.datamodel.CigarCigar", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.refCigar = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "CigarCigar", jalview.datamodel.CigarSimple); -Clazz.makeConstructor (c$, -function (cigar) { -Clazz.superConstructor (this, jalview.datamodel.CigarCigar); -this.refCigar = cigar; -}, "jalview.datamodel.SeqCigar"); -Clazz.overrideMethod (c$, "getSequenceString", -function (GapChar) { -if (this.length == 0) { -return ""; -}var refString = this.refCigar.getSequenceString (GapChar); -if (refString != null) { -return (this.length == 0) ? "" : this.getSequenceAndDeletions (refString, GapChar)[0]; -} else { -return null; -}}, "~S"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.CigarSimple"], "jalview.datamodel.CigarCigar", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.refCigar = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "CigarCigar", jalview.datamodel.CigarSimple); +Clazz.makeConstructor (c$, +function (cigar) { +Clazz.superConstructor (this, jalview.datamodel.CigarCigar); +this.refCigar = cigar; +}, "jalview.datamodel.SeqCigar"); +Clazz.overrideMethod (c$, "getSequenceString", +function (GapChar) { +if (this.length == 0) { +return ""; +}var refString = this.refCigar.getSequenceString (GapChar); +if (refString != null) { +return (this.length == 0) ? "" : this.getSequenceAndDeletions (refString, GapChar)[0]; +} else { +return null; +}}, "~S"); +}); diff --git a/bin/jalview/datamodel/CigarSimple.js b/bin/jalview/datamodel/CigarSimple.js index 1f9da1c..776f62a 100644 --- a/bin/jalview/datamodel/CigarSimple.js +++ b/bin/jalview/datamodel/CigarSimple.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.CigarBase"], "jalview.datamodel.CigarSimple", null, function () { -c$ = Clazz.declareType (jalview.datamodel, "CigarSimple", jalview.datamodel.CigarBase); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.CigarBase"], "jalview.datamodel.CigarSimple", null, function () { +c$ = Clazz.declareType (jalview.datamodel, "CigarSimple", jalview.datamodel.CigarBase); +}); diff --git a/bin/jalview/datamodel/ColumnSelection.js b/bin/jalview/datamodel/ColumnSelection.js index b9e3e99..6cab54c 100644 --- a/bin/jalview/datamodel/ColumnSelection.js +++ b/bin/jalview/datamodel/ColumnSelection.js @@ -1,682 +1,682 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.Vector"], "jalview.datamodel.ColumnSelection", ["jalview.util.ShiftList", "jalview.viewmodel.annotationfilter.AnnotationFilterParameter", "java.lang.StringBuffer", "java.util.ArrayList", "$.Collections"], function () { -c$ = Clazz.decorateAsClass (function () { -this.selected = null; -this.hiddenColumns = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "ColumnSelection"); -Clazz.prepareFields (c$, function () { -this.selected = new java.util.Vector (); -}); -Clazz.defineMethod (c$, "addElement", -function (col) { -var column = new Integer (col); -if (!this.selected.contains (column)) { -this.selected.addElement (column); -}}, "~N"); -Clazz.defineMethod (c$, "clear", -function () { -this.selected.removeAllElements (); -}); -Clazz.defineMethod (c$, "removeElement", -function (col) { -var colInt = new Integer (col); -if (this.selected.contains (colInt)) { -this.selected.removeElement (colInt); -}}, "~N"); -Clazz.defineMethod (c$, "removeElements", -function (start, end) { -var colInt; -for (var i = start; i < end; i++) { -colInt = new Integer (i); -if (this.selected.contains (colInt)) { -this.selected.removeElement (colInt); -}} -}, "~N,~N"); -Clazz.defineMethod (c$, "getSelected", -function () { -return this.selected; -}); -Clazz.defineMethod (c$, "contains", -function (col) { -return this.selected.contains ( new Integer (col)); -}, "~N"); -Clazz.defineMethod (c$, "columnAt", -function (i) { -return this.selected.elementAt (i).intValue (); -}, "~N"); -Clazz.defineMethod (c$, "size", -function () { -return this.selected.size (); -}); -Clazz.defineMethod (c$, "getMax", -function () { -var max = -1; -for (var i = 0; i < this.selected.size (); i++) { -if (this.columnAt (i) > max) { -max = this.columnAt (i); -}} -return max; -}); -Clazz.defineMethod (c$, "getMin", -function () { -var min = 1000000000; -for (var i = 0; i < this.selected.size (); i++) { -if (this.columnAt (i) < min) { -min = this.columnAt (i); -}} -return min; -}); -Clazz.defineMethod (c$, "compensateForEdit", -function (start, change) { -var deletedHiddenColumns = null; -for (var i = 0; i < this.size (); i++) { -var temp = this.columnAt (i); -if (temp >= start) { -this.selected.setElementAt ( new Integer (temp - change), i); -}} -if (this.hiddenColumns != null) { -deletedHiddenColumns = new java.util.ArrayList (); -var hSize = this.hiddenColumns.size (); -for (var i = 0; i < hSize; i++) { -var region = this.hiddenColumns.elementAt (i); -if (region[0] > start && start + change > region[1]) { -deletedHiddenColumns.add (region); -this.hiddenColumns.removeElementAt (i); -i--; -hSize--; -continue; -}if (region[0] > start) { -region[0] -= change; -region[1] -= change; -}if (region[0] < 0) { -region[0] = 0; -}} -this.revealHiddenColumns (0); -}return deletedHiddenColumns; -}, "~N,~N"); -Clazz.defineMethod (c$, "compensateForDelEdits", -($fz = function (start, change) { -for (var i = 0; i < this.size (); i++) { -var temp = this.columnAt (i); -if (temp >= start) { -this.selected.setElementAt ( new Integer (temp - change), i); -}} -if (this.hiddenColumns != null) { -for (var i = 0; i < this.hiddenColumns.size (); i++) { -var region = this.hiddenColumns.elementAt (i); -if (region[0] >= start) { -region[0] -= change; -}if (region[1] >= start) { -region[1] -= change; -}if (region[1] < region[0]) { -this.hiddenColumns.removeElementAt (i--); -}if (region[0] < 0) { -region[0] = 0; -}if (region[1] < 0) { -region[1] = 0; -}} -}}, $fz.isPrivate = true, $fz), "~N,~N"); -Clazz.defineMethod (c$, "compensateForEdits", -function (shiftrecord) { -if (shiftrecord != null) { -var shifts = shiftrecord.getShifts (); -if (shifts != null && shifts.size () > 0) { -var shifted = 0; -for (var i = 0, j = shifts.size (); i < j; i++) { -var sh = shifts.get (i); -this.compensateForDelEdits (shifted + sh[0], sh[1]); -shifted -= sh[1]; -} -}return shiftrecord.getInverse (); -}return null; -}, "jalview.util.ShiftList"); -Clazz.defineMethod (c$, "pruneIntervalVector", -($fz = function (shifts, intervals) { -var pruned = false; -var i = 0; -var j = intervals.size () - 1; -var s = 0; -var t = shifts.size () - 1; -var hr = intervals.elementAt (i); -var sr = shifts.get (s); -while (i <= j && s <= t) { -var trailinghn = hr[1] >= sr[0]; -if (!trailinghn) { -if (i < j) { -hr = intervals.elementAt (++i); -} else { -i++; -}continue; -}var endshift = sr[0] + sr[1]; -if (endshift < hr[0] || endshift < sr[0]) { -if (s < t) { -sr = shifts.get (++s); -} else { -s++; -}continue; -}var leadinghn = hr[0] >= sr[0]; -var leadinghc = hr[0] < endshift; -var trailinghc = hr[1] < endshift; -if (leadinghn) { -if (trailinghc) { -intervals.removeElementAt (i); -pruned = true; -j--; -if (i <= j) { -hr = intervals.elementAt (i); -}continue; -}if (leadinghc) { -hr[0] = endshift; -leadinghn = !leadinghn; -pruned = true; -}}if (!leadinghn) { -if (trailinghc) { -if (trailinghn) { -hr[1] = sr[0] - 1; -pruned = true; -}} else { -if (s < t) { -sr = shifts.get (++s); -} else { -s++; -}continue; -}}} -return pruned; -}, $fz.isPrivate = true, $fz), "java.util.List,java.util.Vector"); -Clazz.defineMethod (c$, "pruneColumnList", -($fz = function (shifts, list) { -var s = 0; -var t = shifts.size (); -var sr = shifts.get (s++); -var pruned = false; -var i = 0; -var j = list.size (); -while (i < j && s <= t) { -var c = list.elementAt (i++).intValue (); -if (sr[0] <= c) { -if (sr[1] + sr[0] >= c) { -list.removeElementAt (--i); -j--; -} else { -if (s < t) { -sr = shifts.get (s); -}s++; -}}} -return pruned; -}, $fz.isPrivate = true, $fz), "java.util.List,java.util.Vector"); -Clazz.defineMethod (c$, "pruneDeletions", -function (deletions) { -if (deletions != null) { -var shifts = deletions.getShifts (); -if (shifts != null && shifts.size () > 0) { -if (this.hiddenColumns != null) { -this.pruneIntervalVector (shifts, this.hiddenColumns); -if (this.hiddenColumns != null && this.hiddenColumns.size () == 0) { -this.hiddenColumns = null; -}}if (this.selected != null && this.selected.size () > 0) { -this.pruneColumnList (shifts, this.selected); -if (this.selected != null && this.selected.size () == 0) { -this.selected = null; -}}this.compensateForEdits (deletions); -}}}, "jalview.util.ShiftList"); -Clazz.defineMethod (c$, "getHiddenColumns", -function () { -return this.hiddenColumns == null ? java.util.Collections.emptyList () : this.hiddenColumns; -}); -Clazz.defineMethod (c$, "adjustForHiddenColumns", -function (column) { -var result = column; -if (this.hiddenColumns != null) { -for (var i = 0; i < this.hiddenColumns.size (); i++) { -var region = this.hiddenColumns.elementAt (i); -if (result >= region[0]) { -result += region[1] - region[0] + 1; -}} -}return result; -}, "~N"); -Clazz.defineMethod (c$, "findColumnPosition", -function (hiddenColumn) { -var result = hiddenColumn; -if (this.hiddenColumns != null) { -var index = 0; -var region; -do { -region = this.hiddenColumns.elementAt (index++); -if (hiddenColumn > region[1]) { -result -= region[1] + 1 - region[0]; -}} while ((hiddenColumn > region[1]) && (index < this.hiddenColumns.size ())); -if (hiddenColumn > region[0] && hiddenColumn < region[1]) { -return region[0] + hiddenColumn - result; -}}return result; -}, "~N"); -Clazz.defineMethod (c$, "findHiddenRegionPosition", -function (hiddenRegion) { -var result = 0; -if (this.hiddenColumns != null) { -var index = 0; -var gaps = 0; -do { -var region = this.hiddenColumns.elementAt (index); -if (hiddenRegion == 0) { -return region[0]; -}gaps += region[1] + 1 - region[0]; -result = region[1] + 1; -index++; -} while (index < hiddenRegion + 1); -result -= gaps; -}return result; -}, "~N"); -Clazz.defineMethod (c$, "getHiddenBoundaryRight", -function (alPos) { -if (this.hiddenColumns != null) { -var index = 0; -do { -var region = this.hiddenColumns.elementAt (index); -if (alPos < region[0]) { -return region[0]; -}index++; -} while (index < this.hiddenColumns.size ()); -}return alPos; -}, "~N"); -Clazz.defineMethod (c$, "getHiddenBoundaryLeft", -function (alPos) { -if (this.hiddenColumns != null) { -var index = this.hiddenColumns.size () - 1; -do { -var region = this.hiddenColumns.elementAt (index); -if (alPos > region[1]) { -return region[1]; -}index--; -} while (index > -1); -}return alPos; -}, "~N"); -Clazz.defineMethod (c$, "hideSelectedColumns", -function () { -while (this.size () > 0) { -var column = this.getSelected ().firstElement ().intValue (); -this.hideColumns (column); -} -}); -Clazz.defineMethod (c$, "hideColumns", -function (start, end) { -if (this.hiddenColumns == null) { -this.hiddenColumns = new java.util.Vector (); -}var added = false; -var overlap = false; -for (var i = 0; i < this.hiddenColumns.size (); i++) { -var region = this.hiddenColumns.elementAt (i); -if (start <= region[1] && end >= region[0]) { -this.hiddenColumns.removeElementAt (i); -overlap = true; -break; -} else if (end < region[0] && start < region[0]) { -this.hiddenColumns.insertElementAt ( Clazz.newIntArray (-1, [start, end]), i); -added = true; -break; -}} -if (overlap) { -this.hideColumns (start, end); -} else if (!added) { -this.hiddenColumns.addElement ( Clazz.newIntArray (-1, [start, end])); -}}, "~N,~N"); -Clazz.defineMethod (c$, "hideColumns", -function (col) { -var min = col; -var max = col + 1; -while (this.contains (min)) { -this.removeElement (min); -min--; -} -while (this.contains (max)) { -this.removeElement (max); -max++; -} -min++; -max--; -if (min > max) { -min = max; -}this.hideColumns (min, max); -}, "~N"); -Clazz.defineMethod (c$, "revealAllHiddenColumns", -function () { -if (this.hiddenColumns != null) { -for (var i = 0; i < this.hiddenColumns.size (); i++) { -var region = this.hiddenColumns.elementAt (i); -for (var j = region[0]; j < region[1] + 1; j++) { -this.addElement (j); -} -} -}this.hiddenColumns = null; -}); -Clazz.defineMethod (c$, "revealHiddenColumns", -function (res) { -for (var i = 0; i < this.hiddenColumns.size (); i++) { -var region = this.hiddenColumns.elementAt (i); -if (res == region[0]) { -for (var j = region[0]; j < region[1] + 1; j++) { -this.addElement (j); -} -this.hiddenColumns.removeElement (region); -break; -}} -if (this.hiddenColumns.size () == 0) { -this.hiddenColumns = null; -}}, "~N"); -Clazz.defineMethod (c$, "isVisible", -function (column) { -if (this.hiddenColumns != null) { -for (var i = 0; i < this.hiddenColumns.size (); i++) { -var region = this.hiddenColumns.elementAt (i); -if (column >= region[0] && column <= region[1]) { -return false; -}} -}return true; -}, "~N"); -Clazz.makeConstructor (c$, -function (copy) { -if (copy != null) { -if (copy.selected != null) { -this.selected = new java.util.Vector (); -for (var i = 0, j = copy.selected.size (); i < j; i++) { -this.selected.addElement (copy.selected.elementAt (i)); -} -}if (copy.hiddenColumns != null) { -this.hiddenColumns = new java.util.Vector (copy.hiddenColumns.size ()); -for (var i = 0, j = copy.hiddenColumns.size (); i < j; i++) { -var rh; -var cp; -rh = copy.hiddenColumns.elementAt (i); -if (rh != null) { -cp = Clazz.newIntArray (rh.length, 0); -System.arraycopy (rh, 0, cp, 0, rh.length); -this.hiddenColumns.addElement (cp); -}} -}}}, "jalview.datamodel.ColumnSelection"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "getVisibleSequenceStrings", -function (start, end, seqs) { -var i; -var iSize = seqs.length; -var selection = new Array (iSize); -if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { -for (i = 0; i < iSize; i++) { -var visibleSeq = new StringBuffer (); -var regions = this.getHiddenColumns (); -var blockStart = start; -var blockEnd = end; -var region; -var hideStart; -var hideEnd; -for (var j = 0; j < regions.size (); j++) { -region = regions.get (j); -hideStart = region[0]; -hideEnd = region[1]; -if (hideStart < start) { -continue; -}blockStart = Math.min (blockStart, hideEnd + 1); -blockEnd = Math.min (blockEnd, hideStart); -if (blockStart > blockEnd) { -break; -}visibleSeq.append (seqs[i].getSequence (blockStart, blockEnd)); -blockStart = hideEnd + 1; -blockEnd = end; -} -if (end > blockStart) { -visibleSeq.append (seqs[i].getSequence (blockStart, end)); -}selection[i] = visibleSeq.toString (); -} -} else { -for (i = 0; i < iSize; i++) { -selection[i] = seqs[i].getSequenceAsString (start, end); -} -}return selection; -}, "~N,~N,~A"); -Clazz.defineMethod (c$, "getVisibleContigs", -function (start, end) { -if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { -var visiblecontigs = new java.util.ArrayList (); -var regions = this.getHiddenColumns (); -var vstart = start; -var region; -var hideStart; -var hideEnd; -for (var j = 0; vstart < end && j < regions.size (); j++) { -region = regions.get (j); -hideStart = region[0]; -hideEnd = region[1]; -if (hideEnd < vstart) { -continue; -}if (hideStart > vstart) { -visiblecontigs.add ( Clazz.newIntArray (-1, [vstart, hideStart - 1])); -}vstart = hideEnd + 1; -} -if (vstart < end) { -visiblecontigs.add ( Clazz.newIntArray (-1, [vstart, end - 1])); -}var vcontigs = Clazz.newIntArray (visiblecontigs.size () * 2, 0); -for (var i = 0, j = visiblecontigs.size (); i < j; i++) { -var vc = visiblecontigs.get (i); -visiblecontigs.set (i, null); -vcontigs[i * 2] = vc[0]; -vcontigs[i * 2 + 1] = vc[1]; -} -visiblecontigs.clear (); -return vcontigs; -} else { -return Clazz.newIntArray (-1, [start, end - 1]); -}}, "~N,~N"); -Clazz.defineMethod (c$, "makeVisibleAnnotation", -function (alignmentAnnotation) { -this.makeVisibleAnnotation (-1, -1, alignmentAnnotation); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "makeVisibleAnnotation", -function (start, end, alignmentAnnotation) { -if (alignmentAnnotation.annotations == null) { -return; -}if (start == end && end == -1) { -start = 0; -end = alignmentAnnotation.annotations.length; -}if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { -var annels = new java.util.Vector (); -var els = null; -var regions = this.getHiddenColumns (); -var blockStart = start; -var blockEnd = end; -var region; -var hideStart; -var hideEnd; -var w = 0; -for (var j = 0; j < regions.size (); j++) { -region = regions.get (j); -hideStart = region[0]; -hideEnd = region[1]; -if (hideStart < start) { -continue; -}blockStart = Math.min (blockStart, hideEnd + 1); -blockEnd = Math.min (blockEnd, hideStart); -if (blockStart > blockEnd) { -break; -}annels.addElement (els = new Array (blockEnd - blockStart)); -System.arraycopy (alignmentAnnotation.annotations, blockStart, els, 0, els.length); -w += els.length; -blockStart = hideEnd + 1; -blockEnd = end; -} -if (end > blockStart) { -annels.addElement (els = new Array (end - blockStart + 1)); -if ((els.length + blockStart) <= alignmentAnnotation.annotations.length) { -System.arraycopy (alignmentAnnotation.annotations, blockStart, els, 0, els.length); -} else { -System.arraycopy (alignmentAnnotation.annotations, blockStart, els, 0, (alignmentAnnotation.annotations.length - blockStart)); -}w += els.length; -}if (w == 0) { -return; -}alignmentAnnotation.annotations = new Array (w); -w = 0; -for (var chnk, $chnk = annels.iterator (); $chnk.hasNext () && ((chnk = $chnk.next ()) || true);) { -System.arraycopy (chnk, 0, alignmentAnnotation.annotations, w, chnk.length); -w += chnk.length; -} -} else { -alignmentAnnotation.restrict (start, end); -}}, "~N,~N,jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "invertColumnSelection", -function (first, width) { -var hasHidden = this.hiddenColumns != null && this.hiddenColumns.size () > 0; -for (var i = first; i < width; i++) { -if (this.contains (i)) { -this.removeElement (i); -} else { -if (!hasHidden || this.isVisible (i)) { -this.addElement (i); -}}} -}, "~N,~N"); -Clazz.defineMethod (c$, "addElementsFrom", -function (colsel) { -if (colsel != null && colsel.size () > 0) { -for (var col, $col = colsel.getSelected ().iterator (); $col.hasNext () && ((col = $col.next ()) || true);) { -if (this.hiddenColumns != null && this.isVisible (col.intValue ())) { -if (!this.selected.contains (col)) { -this.selected.addElement (col); -}}} -}}, "jalview.datamodel.ColumnSelection"); -Clazz.defineMethod (c$, "setElementsFrom", -function (colsel) { -this.selected = new java.util.Vector (); -if (colsel.selected != null && colsel.selected.size () > 0) { -if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { -this.addElementsFrom (colsel); -} else { -for (var col, $col = colsel.getSelected ().iterator (); $col.hasNext () && ((col = $col.next ()) || true);) { -this.addElement ((col).intValue ()); -} -}}}, "jalview.datamodel.ColumnSelection"); -c$.propagateInsertions = Clazz.defineMethod (c$, "propagateInsertions", -function (profileseq, al, input) { -var profsqpos = 0; -var gc = al.getGapCharacter (); -var alandcolsel = input.getAlignmentAndColumnSelection (gc); -var nview = alandcolsel[1]; -var origseq = (alandcolsel[0])[profsqpos]; -nview.propagateInsertions (profileseq, al, origseq); -return nview; -}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentView"); -Clazz.defineMethod (c$, "propagateInsertions", -function (profileseq, al, origseq) { -var gc = al.getGapCharacter (); -this.pruneDeletions (jalview.util.ShiftList.parseMap (origseq.gapMap ())); -var viscontigs = this.getVisibleContigs (0, profileseq.getLength ()); -var spos = 0; -var offset = 0; -for (var v = 0; v < viscontigs.length; v += 2) { -if (viscontigs[v] > spos) { -var sb = new StringBuffer (); -for (var s = 0, ns = viscontigs[v] - spos; s < ns; s++) { -sb.append (gc); -} -for (var s = 0, ns = al.getHeight (); s < ns; s++) { -var sqobj = al.getSequenceAt (s); -if (sqobj !== profileseq) { -var sq = al.getSequenceAt (s).getSequenceAsString (); -if (sq.length <= spos + offset) { -var diff = spos + offset - sq.length - 1; -if (diff > 0) { -sq = sq + sb; -while ((diff = spos + offset - sq.length - 1) > 0) { -if (diff >= sb.length ()) { -sq += sb.toString (); -} else { -var buf = Clazz.newCharArray (diff, '\0'); -sb.getChars (0, diff, buf, 0); -sq += buf.toString (); -}} -}sq += sb.toString (); -} else { -al.getSequenceAt (s).setSequence (sq.substring (0, spos + offset) + sb.toString () + sq.substring (spos + offset)); -}}} -}spos = viscontigs[v + 1] + 1; -} -if ((offset + spos) < profileseq.getLength ()) { -var sb = new StringBuffer (); -for (var s = 0, ns = profileseq.getLength () - spos - offset; s < ns; s++) { -sb.append (gc); -} -for (var s = 0, ns = al.getHeight (); s < ns; s++) { -var sqobj = al.getSequenceAt (s); -if (sqobj === profileseq) { -continue; -}var sq = sqobj.getSequenceAsString (); -var diff = origseq.getLength () - sq.length; -while (diff > 0) { -if (diff >= sb.length ()) { -sq += sb.toString (); -} else { -var buf = Clazz.newCharArray (diff, '\0'); -sb.getChars (0, diff, buf, 0); -sq += buf.toString (); -}diff = origseq.getLength () - sq.length; -} -} -}}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "hasSelectedColumns", -function () { -return (this.selected != null && this.selected.size () > 0); -}); -Clazz.defineMethod (c$, "hasHiddenColumns", -function () { -return this.hiddenColumns != null && this.hiddenColumns.size () > 0; -}); -Clazz.defineMethod (c$, "hasManyHiddenColumns", -function () { -return this.hiddenColumns != null && this.hiddenColumns.size () > 1; -}); -Clazz.defineMethod (c$, "hideInsertionsFor", -function (sr) { -var inserts = sr.getInsertions (); -for (var r, $r = inserts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { -this.hideColumns (r[0], r[1]); -} -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "filterAnnotations", -function (annotations, filterParams) { -this.revealAllHiddenColumns (); -this.clear (); -var count = 0; -do { -if (annotations[count] != null) { -var itemMatched = false; -if (filterParams.getThresholdType () === jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD && annotations[count].value >= filterParams.getThresholdValue ()) { -itemMatched = true; -}if (filterParams.getThresholdType () === jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD && annotations[count].value <= filterParams.getThresholdValue ()) { -itemMatched = true; -}if (filterParams.isFilterAlphaHelix () && annotations[count].secondaryStructure == 'H') { -itemMatched = true; -}if (filterParams.isFilterBetaSheet () && annotations[count].secondaryStructure == 'E') { -itemMatched = true; -}if (filterParams.isFilterTurn () && annotations[count].secondaryStructure == 'S') { -itemMatched = true; -}var regexSearchString = filterParams.getRegexString (); -if (regexSearchString != null && !filterParams.getRegexSearchFields ().isEmpty ()) { -var fields = filterParams.getRegexSearchFields (); -try { -if (fields.contains (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING) && annotations[count].displayCharacter.matches (regexSearchString)) { -itemMatched = true; -}} catch (pse) { -if (Clazz.exceptionOf (pse, java.util.regex.PatternSyntaxException)) { -if (annotations[count].displayCharacter.equals (regexSearchString)) { -itemMatched = true; -}} else { -throw pse; -} -} -if (fields.contains (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION) && annotations[count].description != null && annotations[count].description.matches (regexSearchString)) { -itemMatched = true; -}}if (itemMatched) { -this.addElement (count); -}}count++; -} while (count < annotations.length); -return false; -}, "~A,jalview.viewmodel.annotationfilter.AnnotationFilterParameter"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.Vector"], "jalview.datamodel.ColumnSelection", ["jalview.util.ShiftList", "jalview.viewmodel.annotationfilter.AnnotationFilterParameter", "java.lang.StringBuffer", "java.util.ArrayList", "$.Collections"], function () { +c$ = Clazz.decorateAsClass (function () { +this.selected = null; +this.hiddenColumns = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "ColumnSelection"); +Clazz.prepareFields (c$, function () { +this.selected = new java.util.Vector (); +}); +Clazz.defineMethod (c$, "addElement", +function (col) { +var column = new Integer (col); +if (!this.selected.contains (column)) { +this.selected.addElement (column); +}}, "~N"); +Clazz.defineMethod (c$, "clear", +function () { +this.selected.removeAllElements (); +}); +Clazz.defineMethod (c$, "removeElement", +function (col) { +var colInt = new Integer (col); +if (this.selected.contains (colInt)) { +this.selected.removeElement (colInt); +}}, "~N"); +Clazz.defineMethod (c$, "removeElements", +function (start, end) { +var colInt; +for (var i = start; i < end; i++) { +colInt = new Integer (i); +if (this.selected.contains (colInt)) { +this.selected.removeElement (colInt); +}} +}, "~N,~N"); +Clazz.defineMethod (c$, "getSelected", +function () { +return this.selected; +}); +Clazz.defineMethod (c$, "contains", +function (col) { +return this.selected.contains ( new Integer (col)); +}, "~N"); +Clazz.defineMethod (c$, "columnAt", +function (i) { +return this.selected.elementAt (i).intValue (); +}, "~N"); +Clazz.defineMethod (c$, "size", +function () { +return this.selected.size (); +}); +Clazz.defineMethod (c$, "getMax", +function () { +var max = -1; +for (var i = 0; i < this.selected.size (); i++) { +if (this.columnAt (i) > max) { +max = this.columnAt (i); +}} +return max; +}); +Clazz.defineMethod (c$, "getMin", +function () { +var min = 1000000000; +for (var i = 0; i < this.selected.size (); i++) { +if (this.columnAt (i) < min) { +min = this.columnAt (i); +}} +return min; +}); +Clazz.defineMethod (c$, "compensateForEdit", +function (start, change) { +var deletedHiddenColumns = null; +for (var i = 0; i < this.size (); i++) { +var temp = this.columnAt (i); +if (temp >= start) { +this.selected.setElementAt ( new Integer (temp - change), i); +}} +if (this.hiddenColumns != null) { +deletedHiddenColumns = new java.util.ArrayList (); +var hSize = this.hiddenColumns.size (); +for (var i = 0; i < hSize; i++) { +var region = this.hiddenColumns.elementAt (i); +if (region[0] > start && start + change > region[1]) { +deletedHiddenColumns.add (region); +this.hiddenColumns.removeElementAt (i); +i--; +hSize--; +continue; +}if (region[0] > start) { +region[0] -= change; +region[1] -= change; +}if (region[0] < 0) { +region[0] = 0; +}} +this.revealHiddenColumns (0); +}return deletedHiddenColumns; +}, "~N,~N"); +Clazz.defineMethod (c$, "compensateForDelEdits", +($fz = function (start, change) { +for (var i = 0; i < this.size (); i++) { +var temp = this.columnAt (i); +if (temp >= start) { +this.selected.setElementAt ( new Integer (temp - change), i); +}} +if (this.hiddenColumns != null) { +for (var i = 0; i < this.hiddenColumns.size (); i++) { +var region = this.hiddenColumns.elementAt (i); +if (region[0] >= start) { +region[0] -= change; +}if (region[1] >= start) { +region[1] -= change; +}if (region[1] < region[0]) { +this.hiddenColumns.removeElementAt (i--); +}if (region[0] < 0) { +region[0] = 0; +}if (region[1] < 0) { +region[1] = 0; +}} +}}, $fz.isPrivate = true, $fz), "~N,~N"); +Clazz.defineMethod (c$, "compensateForEdits", +function (shiftrecord) { +if (shiftrecord != null) { +var shifts = shiftrecord.getShifts (); +if (shifts != null && shifts.size () > 0) { +var shifted = 0; +for (var i = 0, j = shifts.size (); i < j; i++) { +var sh = shifts.get (i); +this.compensateForDelEdits (shifted + sh[0], sh[1]); +shifted -= sh[1]; +} +}return shiftrecord.getInverse (); +}return null; +}, "jalview.util.ShiftList"); +Clazz.defineMethod (c$, "pruneIntervalVector", +($fz = function (shifts, intervals) { +var pruned = false; +var i = 0; +var j = intervals.size () - 1; +var s = 0; +var t = shifts.size () - 1; +var hr = intervals.elementAt (i); +var sr = shifts.get (s); +while (i <= j && s <= t) { +var trailinghn = hr[1] >= sr[0]; +if (!trailinghn) { +if (i < j) { +hr = intervals.elementAt (++i); +} else { +i++; +}continue; +}var endshift = sr[0] + sr[1]; +if (endshift < hr[0] || endshift < sr[0]) { +if (s < t) { +sr = shifts.get (++s); +} else { +s++; +}continue; +}var leadinghn = hr[0] >= sr[0]; +var leadinghc = hr[0] < endshift; +var trailinghc = hr[1] < endshift; +if (leadinghn) { +if (trailinghc) { +intervals.removeElementAt (i); +pruned = true; +j--; +if (i <= j) { +hr = intervals.elementAt (i); +}continue; +}if (leadinghc) { +hr[0] = endshift; +leadinghn = !leadinghn; +pruned = true; +}}if (!leadinghn) { +if (trailinghc) { +if (trailinghn) { +hr[1] = sr[0] - 1; +pruned = true; +}} else { +if (s < t) { +sr = shifts.get (++s); +} else { +s++; +}continue; +}}} +return pruned; +}, $fz.isPrivate = true, $fz), "java.util.List,java.util.Vector"); +Clazz.defineMethod (c$, "pruneColumnList", +($fz = function (shifts, list) { +var s = 0; +var t = shifts.size (); +var sr = shifts.get (s++); +var pruned = false; +var i = 0; +var j = list.size (); +while (i < j && s <= t) { +var c = list.elementAt (i++).intValue (); +if (sr[0] <= c) { +if (sr[1] + sr[0] >= c) { +list.removeElementAt (--i); +j--; +} else { +if (s < t) { +sr = shifts.get (s); +}s++; +}}} +return pruned; +}, $fz.isPrivate = true, $fz), "java.util.List,java.util.Vector"); +Clazz.defineMethod (c$, "pruneDeletions", +function (deletions) { +if (deletions != null) { +var shifts = deletions.getShifts (); +if (shifts != null && shifts.size () > 0) { +if (this.hiddenColumns != null) { +this.pruneIntervalVector (shifts, this.hiddenColumns); +if (this.hiddenColumns != null && this.hiddenColumns.size () == 0) { +this.hiddenColumns = null; +}}if (this.selected != null && this.selected.size () > 0) { +this.pruneColumnList (shifts, this.selected); +if (this.selected != null && this.selected.size () == 0) { +this.selected = null; +}}this.compensateForEdits (deletions); +}}}, "jalview.util.ShiftList"); +Clazz.defineMethod (c$, "getHiddenColumns", +function () { +return this.hiddenColumns == null ? java.util.Collections.emptyList () : this.hiddenColumns; +}); +Clazz.defineMethod (c$, "adjustForHiddenColumns", +function (column) { +var result = column; +if (this.hiddenColumns != null) { +for (var i = 0; i < this.hiddenColumns.size (); i++) { +var region = this.hiddenColumns.elementAt (i); +if (result >= region[0]) { +result += region[1] - region[0] + 1; +}} +}return result; +}, "~N"); +Clazz.defineMethod (c$, "findColumnPosition", +function (hiddenColumn) { +var result = hiddenColumn; +if (this.hiddenColumns != null) { +var index = 0; +var region; +do { +region = this.hiddenColumns.elementAt (index++); +if (hiddenColumn > region[1]) { +result -= region[1] + 1 - region[0]; +}} while ((hiddenColumn > region[1]) && (index < this.hiddenColumns.size ())); +if (hiddenColumn > region[0] && hiddenColumn < region[1]) { +return region[0] + hiddenColumn - result; +}}return result; +}, "~N"); +Clazz.defineMethod (c$, "findHiddenRegionPosition", +function (hiddenRegion) { +var result = 0; +if (this.hiddenColumns != null) { +var index = 0; +var gaps = 0; +do { +var region = this.hiddenColumns.elementAt (index); +if (hiddenRegion == 0) { +return region[0]; +}gaps += region[1] + 1 - region[0]; +result = region[1] + 1; +index++; +} while (index < hiddenRegion + 1); +result -= gaps; +}return result; +}, "~N"); +Clazz.defineMethod (c$, "getHiddenBoundaryRight", +function (alPos) { +if (this.hiddenColumns != null) { +var index = 0; +do { +var region = this.hiddenColumns.elementAt (index); +if (alPos < region[0]) { +return region[0]; +}index++; +} while (index < this.hiddenColumns.size ()); +}return alPos; +}, "~N"); +Clazz.defineMethod (c$, "getHiddenBoundaryLeft", +function (alPos) { +if (this.hiddenColumns != null) { +var index = this.hiddenColumns.size () - 1; +do { +var region = this.hiddenColumns.elementAt (index); +if (alPos > region[1]) { +return region[1]; +}index--; +} while (index > -1); +}return alPos; +}, "~N"); +Clazz.defineMethod (c$, "hideSelectedColumns", +function () { +while (this.size () > 0) { +var column = this.getSelected ().firstElement ().intValue (); +this.hideColumns (column); +} +}); +Clazz.defineMethod (c$, "hideColumns", +function (start, end) { +if (this.hiddenColumns == null) { +this.hiddenColumns = new java.util.Vector (); +}var added = false; +var overlap = false; +for (var i = 0; i < this.hiddenColumns.size (); i++) { +var region = this.hiddenColumns.elementAt (i); +if (start <= region[1] && end >= region[0]) { +this.hiddenColumns.removeElementAt (i); +overlap = true; +break; +} else if (end < region[0] && start < region[0]) { +this.hiddenColumns.insertElementAt ( Clazz.newIntArray (-1, [start, end]), i); +added = true; +break; +}} +if (overlap) { +this.hideColumns (start, end); +} else if (!added) { +this.hiddenColumns.addElement ( Clazz.newIntArray (-1, [start, end])); +}}, "~N,~N"); +Clazz.defineMethod (c$, "hideColumns", +function (col) { +var min = col; +var max = col + 1; +while (this.contains (min)) { +this.removeElement (min); +min--; +} +while (this.contains (max)) { +this.removeElement (max); +max++; +} +min++; +max--; +if (min > max) { +min = max; +}this.hideColumns (min, max); +}, "~N"); +Clazz.defineMethod (c$, "revealAllHiddenColumns", +function () { +if (this.hiddenColumns != null) { +for (var i = 0; i < this.hiddenColumns.size (); i++) { +var region = this.hiddenColumns.elementAt (i); +for (var j = region[0]; j < region[1] + 1; j++) { +this.addElement (j); +} +} +}this.hiddenColumns = null; +}); +Clazz.defineMethod (c$, "revealHiddenColumns", +function (res) { +for (var i = 0; i < this.hiddenColumns.size (); i++) { +var region = this.hiddenColumns.elementAt (i); +if (res == region[0]) { +for (var j = region[0]; j < region[1] + 1; j++) { +this.addElement (j); +} +this.hiddenColumns.removeElement (region); +break; +}} +if (this.hiddenColumns.size () == 0) { +this.hiddenColumns = null; +}}, "~N"); +Clazz.defineMethod (c$, "isVisible", +function (column) { +if (this.hiddenColumns != null) { +for (var i = 0; i < this.hiddenColumns.size (); i++) { +var region = this.hiddenColumns.elementAt (i); +if (column >= region[0] && column <= region[1]) { +return false; +}} +}return true; +}, "~N"); +Clazz.makeConstructor (c$, +function (copy) { +if (copy != null) { +if (copy.selected != null) { +this.selected = new java.util.Vector (); +for (var i = 0, j = copy.selected.size (); i < j; i++) { +this.selected.addElement (copy.selected.elementAt (i)); +} +}if (copy.hiddenColumns != null) { +this.hiddenColumns = new java.util.Vector (copy.hiddenColumns.size ()); +for (var i = 0, j = copy.hiddenColumns.size (); i < j; i++) { +var rh; +var cp; +rh = copy.hiddenColumns.elementAt (i); +if (rh != null) { +cp = Clazz.newIntArray (rh.length, 0); +System.arraycopy (rh, 0, cp, 0, rh.length); +this.hiddenColumns.addElement (cp); +}} +}}}, "jalview.datamodel.ColumnSelection"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "getVisibleSequenceStrings", +function (start, end, seqs) { +var i; +var iSize = seqs.length; +var selection = new Array (iSize); +if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { +for (i = 0; i < iSize; i++) { +var visibleSeq = new StringBuffer (); +var regions = this.getHiddenColumns (); +var blockStart = start; +var blockEnd = end; +var region; +var hideStart; +var hideEnd; +for (var j = 0; j < regions.size (); j++) { +region = regions.get (j); +hideStart = region[0]; +hideEnd = region[1]; +if (hideStart < start) { +continue; +}blockStart = Math.min (blockStart, hideEnd + 1); +blockEnd = Math.min (blockEnd, hideStart); +if (blockStart > blockEnd) { +break; +}visibleSeq.append (seqs[i].getSequence (blockStart, blockEnd)); +blockStart = hideEnd + 1; +blockEnd = end; +} +if (end > blockStart) { +visibleSeq.append (seqs[i].getSequence (blockStart, end)); +}selection[i] = visibleSeq.toString (); +} +} else { +for (i = 0; i < iSize; i++) { +selection[i] = seqs[i].getSequenceAsString (start, end); +} +}return selection; +}, "~N,~N,~A"); +Clazz.defineMethod (c$, "getVisibleContigs", +function (start, end) { +if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { +var visiblecontigs = new java.util.ArrayList (); +var regions = this.getHiddenColumns (); +var vstart = start; +var region; +var hideStart; +var hideEnd; +for (var j = 0; vstart < end && j < regions.size (); j++) { +region = regions.get (j); +hideStart = region[0]; +hideEnd = region[1]; +if (hideEnd < vstart) { +continue; +}if (hideStart > vstart) { +visiblecontigs.add ( Clazz.newIntArray (-1, [vstart, hideStart - 1])); +}vstart = hideEnd + 1; +} +if (vstart < end) { +visiblecontigs.add ( Clazz.newIntArray (-1, [vstart, end - 1])); +}var vcontigs = Clazz.newIntArray (visiblecontigs.size () * 2, 0); +for (var i = 0, j = visiblecontigs.size (); i < j; i++) { +var vc = visiblecontigs.get (i); +visiblecontigs.set (i, null); +vcontigs[i * 2] = vc[0]; +vcontigs[i * 2 + 1] = vc[1]; +} +visiblecontigs.clear (); +return vcontigs; +} else { +return Clazz.newIntArray (-1, [start, end - 1]); +}}, "~N,~N"); +Clazz.defineMethod (c$, "makeVisibleAnnotation", +function (alignmentAnnotation) { +this.makeVisibleAnnotation (-1, -1, alignmentAnnotation); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "makeVisibleAnnotation", +function (start, end, alignmentAnnotation) { +if (alignmentAnnotation.annotations == null) { +return; +}if (start == end && end == -1) { +start = 0; +end = alignmentAnnotation.annotations.length; +}if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { +var annels = new java.util.Vector (); +var els = null; +var regions = this.getHiddenColumns (); +var blockStart = start; +var blockEnd = end; +var region; +var hideStart; +var hideEnd; +var w = 0; +for (var j = 0; j < regions.size (); j++) { +region = regions.get (j); +hideStart = region[0]; +hideEnd = region[1]; +if (hideStart < start) { +continue; +}blockStart = Math.min (blockStart, hideEnd + 1); +blockEnd = Math.min (blockEnd, hideStart); +if (blockStart > blockEnd) { +break; +}annels.addElement (els = new Array (blockEnd - blockStart)); +System.arraycopy (alignmentAnnotation.annotations, blockStart, els, 0, els.length); +w += els.length; +blockStart = hideEnd + 1; +blockEnd = end; +} +if (end > blockStart) { +annels.addElement (els = new Array (end - blockStart + 1)); +if ((els.length + blockStart) <= alignmentAnnotation.annotations.length) { +System.arraycopy (alignmentAnnotation.annotations, blockStart, els, 0, els.length); +} else { +System.arraycopy (alignmentAnnotation.annotations, blockStart, els, 0, (alignmentAnnotation.annotations.length - blockStart)); +}w += els.length; +}if (w == 0) { +return; +}alignmentAnnotation.annotations = new Array (w); +w = 0; +for (var chnk, $chnk = annels.iterator (); $chnk.hasNext () && ((chnk = $chnk.next ()) || true);) { +System.arraycopy (chnk, 0, alignmentAnnotation.annotations, w, chnk.length); +w += chnk.length; +} +} else { +alignmentAnnotation.restrict (start, end); +}}, "~N,~N,jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "invertColumnSelection", +function (first, width) { +var hasHidden = this.hiddenColumns != null && this.hiddenColumns.size () > 0; +for (var i = first; i < width; i++) { +if (this.contains (i)) { +this.removeElement (i); +} else { +if (!hasHidden || this.isVisible (i)) { +this.addElement (i); +}}} +}, "~N,~N"); +Clazz.defineMethod (c$, "addElementsFrom", +function (colsel) { +if (colsel != null && colsel.size () > 0) { +for (var col, $col = colsel.getSelected ().iterator (); $col.hasNext () && ((col = $col.next ()) || true);) { +if (this.hiddenColumns != null && this.isVisible (col.intValue ())) { +if (!this.selected.contains (col)) { +this.selected.addElement (col); +}}} +}}, "jalview.datamodel.ColumnSelection"); +Clazz.defineMethod (c$, "setElementsFrom", +function (colsel) { +this.selected = new java.util.Vector (); +if (colsel.selected != null && colsel.selected.size () > 0) { +if (this.hiddenColumns != null && this.hiddenColumns.size () > 0) { +this.addElementsFrom (colsel); +} else { +for (var col, $col = colsel.getSelected ().iterator (); $col.hasNext () && ((col = $col.next ()) || true);) { +this.addElement ((col).intValue ()); +} +}}}, "jalview.datamodel.ColumnSelection"); +c$.propagateInsertions = Clazz.defineMethod (c$, "propagateInsertions", +function (profileseq, al, input) { +var profsqpos = 0; +var gc = al.getGapCharacter (); +var alandcolsel = input.getAlignmentAndColumnSelection (gc); +var nview = alandcolsel[1]; +var origseq = (alandcolsel[0])[profsqpos]; +nview.propagateInsertions (profileseq, al, origseq); +return nview; +}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,jalview.datamodel.AlignmentView"); +Clazz.defineMethod (c$, "propagateInsertions", +function (profileseq, al, origseq) { +var gc = al.getGapCharacter (); +this.pruneDeletions (jalview.util.ShiftList.parseMap (origseq.gapMap ())); +var viscontigs = this.getVisibleContigs (0, profileseq.getLength ()); +var spos = 0; +var offset = 0; +for (var v = 0; v < viscontigs.length; v += 2) { +if (viscontigs[v] > spos) { +var sb = new StringBuffer (); +for (var s = 0, ns = viscontigs[v] - spos; s < ns; s++) { +sb.append (gc); +} +for (var s = 0, ns = al.getHeight (); s < ns; s++) { +var sqobj = al.getSequenceAt (s); +if (sqobj !== profileseq) { +var sq = al.getSequenceAt (s).getSequenceAsString (); +if (sq.length <= spos + offset) { +var diff = spos + offset - sq.length - 1; +if (diff > 0) { +sq = sq + sb; +while ((diff = spos + offset - sq.length - 1) > 0) { +if (diff >= sb.length ()) { +sq += sb.toString (); +} else { +var buf = Clazz.newCharArray (diff, '\0'); +sb.getChars (0, diff, buf, 0); +sq += buf.toString (); +}} +}sq += sb.toString (); +} else { +al.getSequenceAt (s).setSequence (sq.substring (0, spos + offset) + sb.toString () + sq.substring (spos + offset)); +}}} +}spos = viscontigs[v + 1] + 1; +} +if ((offset + spos) < profileseq.getLength ()) { +var sb = new StringBuffer (); +for (var s = 0, ns = profileseq.getLength () - spos - offset; s < ns; s++) { +sb.append (gc); +} +for (var s = 0, ns = al.getHeight (); s < ns; s++) { +var sqobj = al.getSequenceAt (s); +if (sqobj === profileseq) { +continue; +}var sq = sqobj.getSequenceAsString (); +var diff = origseq.getLength () - sq.length; +while (diff > 0) { +if (diff >= sb.length ()) { +sq += sb.toString (); +} else { +var buf = Clazz.newCharArray (diff, '\0'); +sb.getChars (0, diff, buf, 0); +sq += buf.toString (); +}diff = origseq.getLength () - sq.length; +} +} +}}, "jalview.datamodel.SequenceI,jalview.datamodel.AlignmentI,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "hasSelectedColumns", +function () { +return (this.selected != null && this.selected.size () > 0); +}); +Clazz.defineMethod (c$, "hasHiddenColumns", +function () { +return this.hiddenColumns != null && this.hiddenColumns.size () > 0; +}); +Clazz.defineMethod (c$, "hasManyHiddenColumns", +function () { +return this.hiddenColumns != null && this.hiddenColumns.size () > 1; +}); +Clazz.defineMethod (c$, "hideInsertionsFor", +function (sr) { +var inserts = sr.getInsertions (); +for (var r, $r = inserts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { +this.hideColumns (r[0], r[1]); +} +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "filterAnnotations", +function (annotations, filterParams) { +this.revealAllHiddenColumns (); +this.clear (); +var count = 0; +do { +if (annotations[count] != null) { +var itemMatched = false; +if (filterParams.getThresholdType () === jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD && annotations[count].value >= filterParams.getThresholdValue ()) { +itemMatched = true; +}if (filterParams.getThresholdType () === jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD && annotations[count].value <= filterParams.getThresholdValue ()) { +itemMatched = true; +}if (filterParams.isFilterAlphaHelix () && annotations[count].secondaryStructure == 'H') { +itemMatched = true; +}if (filterParams.isFilterBetaSheet () && annotations[count].secondaryStructure == 'E') { +itemMatched = true; +}if (filterParams.isFilterTurn () && annotations[count].secondaryStructure == 'S') { +itemMatched = true; +}var regexSearchString = filterParams.getRegexString (); +if (regexSearchString != null && !filterParams.getRegexSearchFields ().isEmpty ()) { +var fields = filterParams.getRegexSearchFields (); +try { +if (fields.contains (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING) && annotations[count].displayCharacter.matches (regexSearchString)) { +itemMatched = true; +}} catch (pse) { +if (Clazz.exceptionOf (pse, java.util.regex.PatternSyntaxException)) { +if (annotations[count].displayCharacter.equals (regexSearchString)) { +itemMatched = true; +}} else { +throw pse; +} +} +if (fields.contains (jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION) && annotations[count].description != null && annotations[count].description.matches (regexSearchString)) { +itemMatched = true; +}}if (itemMatched) { +this.addElement (count); +}}count++; +} while (count < annotations.length); +return false; +}, "~A,jalview.viewmodel.annotationfilter.AnnotationFilterParameter"); +}); diff --git a/bin/jalview/datamodel/DBRefEntry.js b/bin/jalview/datamodel/DBRefEntry.js index 148cf99..da2e0cb 100644 --- a/bin/jalview/datamodel/DBRefEntry.js +++ b/bin/jalview/datamodel/DBRefEntry.js @@ -1,93 +1,93 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.DBRefEntry", ["jalview.datamodel.Mapping"], function () { -c$ = Clazz.decorateAsClass (function () { -this.source = ""; -this.version = ""; -this.accessionId = ""; -this.map = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "DBRefEntry"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (source, version, accessionId) { -this.construct (source, version, accessionId, null); -}, "~S,~S,~S"); -Clazz.makeConstructor (c$, -function (source, version, accessionId, map) { -this.source = source.toUpperCase (); -this.version = version; -this.accessionId = accessionId; -this.map = map; -}, "~S,~S,~S,jalview.datamodel.Mapping"); -Clazz.makeConstructor (c$, -function (entry) { -this.construct ((entry.source == null ? "" : String.instantialize (entry.source)), (entry.version == null ? "" : String.instantialize (entry.version)), (entry.accessionId == null ? "" : String.instantialize (entry.accessionId)), (entry.map == null ? null : new jalview.datamodel.Mapping (entry.map))); -}, "jalview.datamodel.DBRefEntry"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.DBRefEntry))) { -return false; -}var entry = o; -if (entry === this) { -return true; -}if (this.equalRef (entry) && ((this.map == null && entry.map == null) || (this.map != null && entry.map != null && this.map.equals (entry.map)))) { -return true; -}return false; -}, "~O"); -Clazz.defineMethod (c$, "equalRef", -function (entry) { -if (entry == null) { -return false; -}if (entry === this) { -return true; -}if ((this.source != null && entry.source != null && this.source.equalsIgnoreCase (entry.source)) && (this.accessionId != null && entry.accessionId != null && this.accessionId.equalsIgnoreCase (entry.accessionId)) && (this.version != null && entry.version != null && this.version.equalsIgnoreCase (entry.version))) { -return true; -}return false; -}, "jalview.datamodel.DBRefEntry"); -Clazz.defineMethod (c$, "getSource", -function () { -return this.source; -}); -Clazz.defineMethod (c$, "getVersion", -function () { -return this.version; -}); -Clazz.defineMethod (c$, "getAccessionId", -function () { -return this.accessionId; -}); -Clazz.defineMethod (c$, "setAccessionId", -function (accessionId) { -this.accessionId = accessionId; -}, "~S"); -Clazz.defineMethod (c$, "setSource", -function (source) { -this.source = source; -}, "~S"); -Clazz.defineMethod (c$, "setVersion", -function (version) { -this.version = version; -}, "~S"); -Clazz.defineMethod (c$, "getMap", -function () { -return this.map; -}); -Clazz.defineMethod (c$, "setMap", -function (map) { -this.map = map; -}, "jalview.datamodel.Mapping"); -Clazz.defineMethod (c$, "hasMap", -function () { -return this.map != null; -}); -Clazz.defineMethod (c$, "getSrcAccString", -function () { -return ((this.source != null) ? this.source : "") + ":" + ((this.accessionId != null) ? this.accessionId : ""); -}); -Clazz.overrideMethod (c$, "toString", -function () { -return this.getSrcAccString (); -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.DBRefEntry", ["jalview.datamodel.Mapping"], function () { +c$ = Clazz.decorateAsClass (function () { +this.source = ""; +this.version = ""; +this.accessionId = ""; +this.map = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "DBRefEntry"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (source, version, accessionId) { +this.construct (source, version, accessionId, null); +}, "~S,~S,~S"); +Clazz.makeConstructor (c$, +function (source, version, accessionId, map) { +this.source = source.toUpperCase (); +this.version = version; +this.accessionId = accessionId; +this.map = map; +}, "~S,~S,~S,jalview.datamodel.Mapping"); +Clazz.makeConstructor (c$, +function (entry) { +this.construct ((entry.source == null ? "" : String.instantialize (entry.source)), (entry.version == null ? "" : String.instantialize (entry.version)), (entry.accessionId == null ? "" : String.instantialize (entry.accessionId)), (entry.map == null ? null : new jalview.datamodel.Mapping (entry.map))); +}, "jalview.datamodel.DBRefEntry"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.DBRefEntry))) { +return false; +}var entry = o; +if (entry === this) { +return true; +}if (this.equalRef (entry) && ((this.map == null && entry.map == null) || (this.map != null && entry.map != null && this.map.equals (entry.map)))) { +return true; +}return false; +}, "~O"); +Clazz.defineMethod (c$, "equalRef", +function (entry) { +if (entry == null) { +return false; +}if (entry === this) { +return true; +}if ((this.source != null && entry.source != null && this.source.equalsIgnoreCase (entry.source)) && (this.accessionId != null && entry.accessionId != null && this.accessionId.equalsIgnoreCase (entry.accessionId)) && (this.version != null && entry.version != null && this.version.equalsIgnoreCase (entry.version))) { +return true; +}return false; +}, "jalview.datamodel.DBRefEntry"); +Clazz.defineMethod (c$, "getSource", +function () { +return this.source; +}); +Clazz.defineMethod (c$, "getVersion", +function () { +return this.version; +}); +Clazz.defineMethod (c$, "getAccessionId", +function () { +return this.accessionId; +}); +Clazz.defineMethod (c$, "setAccessionId", +function (accessionId) { +this.accessionId = accessionId; +}, "~S"); +Clazz.defineMethod (c$, "setSource", +function (source) { +this.source = source; +}, "~S"); +Clazz.defineMethod (c$, "setVersion", +function (version) { +this.version = version; +}, "~S"); +Clazz.defineMethod (c$, "getMap", +function () { +return this.map; +}); +Clazz.defineMethod (c$, "setMap", +function (map) { +this.map = map; +}, "jalview.datamodel.Mapping"); +Clazz.defineMethod (c$, "hasMap", +function () { +return this.map != null; +}); +Clazz.defineMethod (c$, "getSrcAccString", +function () { +return ((this.source != null) ? this.source : "") + ":" + ((this.accessionId != null) ? this.accessionId : ""); +}); +Clazz.overrideMethod (c$, "toString", +function () { +return this.getSrcAccString (); +}); +}); diff --git a/bin/jalview/datamodel/DBRefSource.js b/bin/jalview/datamodel/DBRefSource.js index 00d7337..587f6f3 100644 --- a/bin/jalview/datamodel/DBRefSource.js +++ b/bin/jalview/datamodel/DBRefSource.js @@ -1,29 +1,29 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.declareType (jalview.datamodel, "DBRefSource"); -Clazz.defineStatics (c$, -"UNIPROT", "UNIPROT"); -c$.UP_NAME = c$.prototype.UP_NAME = "UNIPROT_NAME".toUpperCase (); -c$.UNIPROTKB = c$.prototype.UNIPROTKB = "UniProtKB/TrEMBL".toUpperCase (); -c$.EMBLCDSProduct = c$.prototype.EMBLCDSProduct = "EMBLCDSProtein".toUpperCase (); -Clazz.defineStatics (c$, -"PDB", "PDB", -"EMBL", "EMBL", -"EMBLCDS", "EMBLCDS", -"PFAM", "PFAM", -"RFAM", "RFAM"); -c$.GENEDB = c$.prototype.GENEDB = "GeneDB".toUpperCase (); -c$.DNACODINGDBS = c$.prototype.DNACODINGDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.EMBL, jalview.datamodel.DBRefSource.EMBLCDS, jalview.datamodel.DBRefSource.GENEDB]); -c$.CODINGDBS = c$.prototype.CODINGDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.EMBLCDS, jalview.datamodel.DBRefSource.GENEDB]); -c$.PROTEINDBS = c$.prototype.PROTEINDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.UNIPROT, jalview.datamodel.DBRefSource.PDB, jalview.datamodel.DBRefSource.UNIPROTKB, jalview.datamodel.DBRefSource.EMBLCDSProduct]); -c$.PROTEINSEQ = c$.prototype.PROTEINSEQ = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.UNIPROT, jalview.datamodel.DBRefSource.UNIPROTKB, jalview.datamodel.DBRefSource.EMBLCDSProduct]); -c$.PROTEINSTR = c$.prototype.PROTEINSTR = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.PDB]); -c$.DOMAINDBS = c$.prototype.DOMAINDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.PFAM, jalview.datamodel.DBRefSource.RFAM]); -Clazz.defineStatics (c$, -"SEQDB", "SQ", -"DNASEQDB", "NASQ", -"PROTSEQDB", "PROTSQ", -"CODINGSEQDB", "CODING", -"DNACODINGSEQDB", "XONCODING", -"DOMAINDB", "DOMAIN", -"MULTIACC", "MULTIACC", -"ALIGNMENTDB", "ALIGNMENTS"); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.declareType (jalview.datamodel, "DBRefSource"); +Clazz.defineStatics (c$, +"UNIPROT", "UNIPROT"); +c$.UP_NAME = c$.prototype.UP_NAME = "UNIPROT_NAME".toUpperCase (); +c$.UNIPROTKB = c$.prototype.UNIPROTKB = "UniProtKB/TrEMBL".toUpperCase (); +c$.EMBLCDSProduct = c$.prototype.EMBLCDSProduct = "EMBLCDSProtein".toUpperCase (); +Clazz.defineStatics (c$, +"PDB", "PDB", +"EMBL", "EMBL", +"EMBLCDS", "EMBLCDS", +"PFAM", "PFAM", +"RFAM", "RFAM"); +c$.GENEDB = c$.prototype.GENEDB = "GeneDB".toUpperCase (); +c$.DNACODINGDBS = c$.prototype.DNACODINGDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.EMBL, jalview.datamodel.DBRefSource.EMBLCDS, jalview.datamodel.DBRefSource.GENEDB]); +c$.CODINGDBS = c$.prototype.CODINGDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.EMBLCDS, jalview.datamodel.DBRefSource.GENEDB]); +c$.PROTEINDBS = c$.prototype.PROTEINDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.UNIPROT, jalview.datamodel.DBRefSource.PDB, jalview.datamodel.DBRefSource.UNIPROTKB, jalview.datamodel.DBRefSource.EMBLCDSProduct]); +c$.PROTEINSEQ = c$.prototype.PROTEINSEQ = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.UNIPROT, jalview.datamodel.DBRefSource.UNIPROTKB, jalview.datamodel.DBRefSource.EMBLCDSProduct]); +c$.PROTEINSTR = c$.prototype.PROTEINSTR = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.PDB]); +c$.DOMAINDBS = c$.prototype.DOMAINDBS = Clazz.newArray (-1, [jalview.datamodel.DBRefSource.PFAM, jalview.datamodel.DBRefSource.RFAM]); +Clazz.defineStatics (c$, +"SEQDB", "SQ", +"DNASEQDB", "NASQ", +"PROTSEQDB", "PROTSQ", +"CODINGSEQDB", "CODING", +"DNACODINGSEQDB", "XONCODING", +"DOMAINDB", "DOMAIN", +"MULTIACC", "MULTIACC", +"ALIGNMENTDB", "ALIGNMENTS"); diff --git a/bin/jalview/datamodel/FeatureProperties.js b/bin/jalview/datamodel/FeatureProperties.js index 350148d..6df3e2b 100644 --- a/bin/jalview/datamodel/FeatureProperties.js +++ b/bin/jalview/datamodel/FeatureProperties.js @@ -1,20 +1,20 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.FeatureProperties", ["jalview.datamodel.DBRefSource"], function () { -c$ = Clazz.declareType (jalview.datamodel, "FeatureProperties"); -c$.isCodingFeature = Clazz.defineMethod (c$, "isCodingFeature", -function (dbrefsource, type) { -if (type.equalsIgnoreCase ("CDS")) { -return (dbrefsource == null || dbrefsource.equalsIgnoreCase (jalview.datamodel.DBRefSource.EMBL) || dbrefsource.equalsIgnoreCase (jalview.datamodel.DBRefSource.EMBLCDS)); -}return false; -}, "~S,~S"); -c$.getCodingFeature = Clazz.defineMethod (c$, "getCodingFeature", -function (dbrefsource) { -if (jalview.datamodel.DBRefSource.EMBL.equalsIgnoreCase (dbrefsource) || jalview.datamodel.DBRefSource.EMBLCDS.equalsIgnoreCase (dbrefsource)) { -return "CDS"; -}return null; -}, "~S"); -Clazz.defineStatics (c$, -"EMBL_CODING_FEATURE", "CDS", -"EXONPOS", "exon number", -"EXONPRODUCT", "product"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.FeatureProperties", ["jalview.datamodel.DBRefSource"], function () { +c$ = Clazz.declareType (jalview.datamodel, "FeatureProperties"); +c$.isCodingFeature = Clazz.defineMethod (c$, "isCodingFeature", +function (dbrefsource, type) { +if (type.equalsIgnoreCase ("CDS")) { +return (dbrefsource == null || dbrefsource.equalsIgnoreCase (jalview.datamodel.DBRefSource.EMBL) || dbrefsource.equalsIgnoreCase (jalview.datamodel.DBRefSource.EMBLCDS)); +}return false; +}, "~S,~S"); +c$.getCodingFeature = Clazz.defineMethod (c$, "getCodingFeature", +function (dbrefsource) { +if (jalview.datamodel.DBRefSource.EMBL.equalsIgnoreCase (dbrefsource) || jalview.datamodel.DBRefSource.EMBLCDS.equalsIgnoreCase (dbrefsource)) { +return "CDS"; +}return null; +}, "~S"); +Clazz.defineStatics (c$, +"EMBL_CODING_FEATURE", "CDS", +"EXONPOS", "exon number", +"EXONPRODUCT", "product"); +}); diff --git a/bin/jalview/datamodel/GraphLine.js b/bin/jalview/datamodel/GraphLine.js index 83ffc69..564e7f4 100644 --- a/bin/jalview/datamodel/GraphLine.js +++ b/bin/jalview/datamodel/GraphLine.js @@ -1,36 +1,36 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.awt.Color"], "jalview.datamodel.GraphLine", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.value = 0; -this.label = ""; -this.colour = null; -this.displayed = true; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "GraphLine"); -Clazz.prepareFields (c$, function () { -this.colour = java.awt.Color.black; -}); -Clazz.makeConstructor (c$, -function (value, label, col) { -this.value = value; -if (label != null) { -this.label = label; -}if (col != null) { -this.colour = col; -}}, "~N,~S,java.awt.Color"); -Clazz.makeConstructor (c$, -function (from) { -if (from != null) { -this.value = from.value; -this.label = String.instantialize (from.label); -this.colour = from.colour; -this.displayed = from.displayed; -}}, "jalview.datamodel.GraphLine"); -Clazz.overrideMethod (c$, "equals", -function (obj) { -if (obj != null && Clazz.instanceOf (obj, jalview.datamodel.GraphLine)) { -var other = obj; -return this.displayed == other.displayed && this.value == other.value && (this.colour != null ? (other.colour != null && other.colour.equals (this.colour)) : other.colour == null) && (this.label != null ? (other.label != null && other.label.equals (this.label)) : other.label == null); -}return false; -}, "~O"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.awt.Color"], "jalview.datamodel.GraphLine", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.value = 0; +this.label = ""; +this.colour = null; +this.displayed = true; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "GraphLine"); +Clazz.prepareFields (c$, function () { +this.colour = java.awt.Color.black; +}); +Clazz.makeConstructor (c$, +function (value, label, col) { +this.value = value; +if (label != null) { +this.label = label; +}if (col != null) { +this.colour = col; +}}, "~N,~S,java.awt.Color"); +Clazz.makeConstructor (c$, +function (from) { +if (from != null) { +this.value = from.value; +this.label = String.instantialize (from.label); +this.colour = from.colour; +this.displayed = from.displayed; +}}, "jalview.datamodel.GraphLine"); +Clazz.overrideMethod (c$, "equals", +function (obj) { +if (obj != null && Clazz.instanceOf (obj, jalview.datamodel.GraphLine)) { +var other = obj; +return this.displayed == other.displayed && this.value == other.value && (this.colour != null ? (other.colour != null && other.colour.equals (this.colour)) : other.colour == null) && (this.label != null ? (other.label != null && other.label.equals (this.label)) : other.label == null); +}return false; +}, "~O"); +}); diff --git a/bin/jalview/datamodel/HiddenSequences.js b/bin/jalview/datamodel/HiddenSequences.js index 65b1c2b..9111dd8 100644 --- a/bin/jalview/datamodel/HiddenSequences.js +++ b/bin/jalview/datamodel/HiddenSequences.js @@ -1,162 +1,162 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.HiddenSequences", ["jalview.datamodel.Alignment", "java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.hiddenSequences = null; -this.alignment = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "HiddenSequences"); -Clazz.makeConstructor (c$, -function (al) { -this.alignment = al; -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "getSize", -function () { -if (this.hiddenSequences == null) { -return 0; -}var count = 0; -for (var i = 0; i < this.hiddenSequences.length; i++) { -if (this.hiddenSequences[i] != null) { -count++; -}} -return count; -}); -Clazz.defineMethod (c$, "getWidth", -function () { -var width = 0; -for (var i = 0; i < this.hiddenSequences.length; i++) { -if (this.hiddenSequences[i] != null && this.hiddenSequences[i].getLength () > width) { -width = this.hiddenSequences[i].getLength (); -}} -return width; -}); -Clazz.defineMethod (c$, "adjustHeightSequenceDeleted", -function (seqIndex) { -if (this.hiddenSequences == null) { -return; -}var alHeight = this.alignment.getHeight (); -var tmp = new Array (alHeight + this.getSize ()); -var deletionIndex = this.adjustForHiddenSeqs (seqIndex); -for (var i = 0; i < this.hiddenSequences.length; i++) { -if (this.hiddenSequences[i] == null) { -continue; -}if (i > deletionIndex) { -tmp[i - 1] = this.hiddenSequences[i]; -} else { -tmp[i] = this.hiddenSequences[i]; -}} -this.hiddenSequences = tmp; -}, "~N"); -Clazz.defineMethod (c$, "adjustHeightSequenceAdded", -function () { -if (this.hiddenSequences == null) { -return; -}var alHeight = this.alignment.getHeight (); -var tmp = new Array (alHeight + this.getSize ()); -System.arraycopy (this.hiddenSequences, 0, tmp, 0, this.hiddenSequences.length); -this.hiddenSequences = tmp; -}); -Clazz.defineMethod (c$, "hideSequence", -function (sequence) { -if (this.hiddenSequences == null) { -this.hiddenSequences = new Array (this.alignment.getHeight ()); -}var alignmentIndex = this.alignment.findIndex (sequence); -alignmentIndex = this.adjustForHiddenSeqs (alignmentIndex); -if (this.hiddenSequences[alignmentIndex] != null) { -System.out.println ("ERROR!!!!!!!!!!!"); -}this.hiddenSequences[alignmentIndex] = sequence; -this.alignment.deleteSequence (sequence); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "showAll", -function (hiddenRepSequences) { -var revealedSeqs = new java.util.ArrayList (); -for (var i = 0; i < this.hiddenSequences.length; i++) { -if (this.hiddenSequences[i] != null) { -var tmp = this.showSequence (i, hiddenRepSequences); -for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -revealedSeqs.add (seq); -} -}} -return revealedSeqs; -}, "java.util.Map"); -Clazz.defineMethod (c$, "showSequence", -function (alignmentIndex, hiddenRepSequences) { -var revealedSeqs = new java.util.ArrayList (); -var repSequence = this.alignment.getSequenceAt (alignmentIndex); -if (repSequence != null && hiddenRepSequences != null && hiddenRepSequences.containsKey (repSequence)) { -hiddenRepSequences.remove (repSequence); -revealedSeqs.add (repSequence); -}var start = this.adjustForHiddenSeqs (alignmentIndex - 1); -var end = this.adjustForHiddenSeqs (alignmentIndex); -if (end >= this.hiddenSequences.length) { -end = this.hiddenSequences.length - 1; -}var asequences; -{ -for (var index = end; index > start; index--) { -var seq = this.hiddenSequences[index]; -this.hiddenSequences[index] = null; -if (seq != null) { -if (seq.getLength () > 0) { -revealedSeqs.add (seq); -asequences.add (alignmentIndex, seq); -} else { -System.out.println (seq.getName () + " has been deleted whilst hidden"); -}}} -}return revealedSeqs; -}, "~N,java.util.Map"); -Clazz.defineMethod (c$, "getHiddenSequence", -function (alignmentIndex) { -return this.hiddenSequences[alignmentIndex]; -}, "~N"); -Clazz.defineMethod (c$, "findIndexWithoutHiddenSeqs", -function (alignmentIndex) { -var index = 0; -var hiddenSeqs = 0; -if (this.hiddenSequences.length <= alignmentIndex) { -alignmentIndex = this.hiddenSequences.length - 1; -}while (index <= alignmentIndex) { -if (this.hiddenSequences[index] != null) { -hiddenSeqs++; -}index++; -} -;return (alignmentIndex - hiddenSeqs); -}, "~N"); -Clazz.defineMethod (c$, "adjustForHiddenSeqs", -function (alignmentIndex) { -var index = 0; -var hSize = this.hiddenSequences.length; -while (index <= alignmentIndex && index < hSize) { -if (this.hiddenSequences[index] != null) { -alignmentIndex++; -}index++; -} -;return alignmentIndex; -}, "~N"); -Clazz.defineMethod (c$, "getFullAlignment", -function () { -var isize = this.hiddenSequences.length; -var seq = new Array (isize); -var index = 0; -for (var i = 0; i < this.hiddenSequences.length; i++) { -if (this.hiddenSequences[i] != null) { -seq[i] = this.hiddenSequences[i]; -} else { -seq[i] = this.alignment.getSequenceAt (index); -index++; -}} -var fAlignmt = new jalview.datamodel.Alignment (seq); -fAlignmt.annotations = this.alignment.getAlignmentAnnotation (); -fAlignmt.alignmentProperties = this.alignment.getProperties (); -fAlignmt.groups = this.alignment.getGroups (); -fAlignmt.$hasRNAStructure = this.alignment.hasRNAStructure (); -return fAlignmt; -}); -Clazz.defineMethod (c$, "isHidden", -function (seq) { -if (this.hiddenSequences != null) { -for (var i = 0; i < this.hiddenSequences.length; i++) { -if (this.hiddenSequences[i] != null && this.hiddenSequences[i] === seq) { -return true; -}} -}return false; -}, "jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.HiddenSequences", ["jalview.datamodel.Alignment", "java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.hiddenSequences = null; +this.alignment = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "HiddenSequences"); +Clazz.makeConstructor (c$, +function (al) { +this.alignment = al; +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "getSize", +function () { +if (this.hiddenSequences == null) { +return 0; +}var count = 0; +for (var i = 0; i < this.hiddenSequences.length; i++) { +if (this.hiddenSequences[i] != null) { +count++; +}} +return count; +}); +Clazz.defineMethod (c$, "getWidth", +function () { +var width = 0; +for (var i = 0; i < this.hiddenSequences.length; i++) { +if (this.hiddenSequences[i] != null && this.hiddenSequences[i].getLength () > width) { +width = this.hiddenSequences[i].getLength (); +}} +return width; +}); +Clazz.defineMethod (c$, "adjustHeightSequenceDeleted", +function (seqIndex) { +if (this.hiddenSequences == null) { +return; +}var alHeight = this.alignment.getHeight (); +var tmp = new Array (alHeight + this.getSize ()); +var deletionIndex = this.adjustForHiddenSeqs (seqIndex); +for (var i = 0; i < this.hiddenSequences.length; i++) { +if (this.hiddenSequences[i] == null) { +continue; +}if (i > deletionIndex) { +tmp[i - 1] = this.hiddenSequences[i]; +} else { +tmp[i] = this.hiddenSequences[i]; +}} +this.hiddenSequences = tmp; +}, "~N"); +Clazz.defineMethod (c$, "adjustHeightSequenceAdded", +function () { +if (this.hiddenSequences == null) { +return; +}var alHeight = this.alignment.getHeight (); +var tmp = new Array (alHeight + this.getSize ()); +System.arraycopy (this.hiddenSequences, 0, tmp, 0, this.hiddenSequences.length); +this.hiddenSequences = tmp; +}); +Clazz.defineMethod (c$, "hideSequence", +function (sequence) { +if (this.hiddenSequences == null) { +this.hiddenSequences = new Array (this.alignment.getHeight ()); +}var alignmentIndex = this.alignment.findIndex (sequence); +alignmentIndex = this.adjustForHiddenSeqs (alignmentIndex); +if (this.hiddenSequences[alignmentIndex] != null) { +System.out.println ("ERROR!!!!!!!!!!!"); +}this.hiddenSequences[alignmentIndex] = sequence; +this.alignment.deleteSequence (sequence); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "showAll", +function (hiddenRepSequences) { +var revealedSeqs = new java.util.ArrayList (); +for (var i = 0; i < this.hiddenSequences.length; i++) { +if (this.hiddenSequences[i] != null) { +var tmp = this.showSequence (i, hiddenRepSequences); +for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +revealedSeqs.add (seq); +} +}} +return revealedSeqs; +}, "java.util.Map"); +Clazz.defineMethod (c$, "showSequence", +function (alignmentIndex, hiddenRepSequences) { +var revealedSeqs = new java.util.ArrayList (); +var repSequence = this.alignment.getSequenceAt (alignmentIndex); +if (repSequence != null && hiddenRepSequences != null && hiddenRepSequences.containsKey (repSequence)) { +hiddenRepSequences.remove (repSequence); +revealedSeqs.add (repSequence); +}var start = this.adjustForHiddenSeqs (alignmentIndex - 1); +var end = this.adjustForHiddenSeqs (alignmentIndex); +if (end >= this.hiddenSequences.length) { +end = this.hiddenSequences.length - 1; +}var asequences; +{ +for (var index = end; index > start; index--) { +var seq = this.hiddenSequences[index]; +this.hiddenSequences[index] = null; +if (seq != null) { +if (seq.getLength () > 0) { +revealedSeqs.add (seq); +asequences.add (alignmentIndex, seq); +} else { +System.out.println (seq.getName () + " has been deleted whilst hidden"); +}}} +}return revealedSeqs; +}, "~N,java.util.Map"); +Clazz.defineMethod (c$, "getHiddenSequence", +function (alignmentIndex) { +return this.hiddenSequences[alignmentIndex]; +}, "~N"); +Clazz.defineMethod (c$, "findIndexWithoutHiddenSeqs", +function (alignmentIndex) { +var index = 0; +var hiddenSeqs = 0; +if (this.hiddenSequences.length <= alignmentIndex) { +alignmentIndex = this.hiddenSequences.length - 1; +}while (index <= alignmentIndex) { +if (this.hiddenSequences[index] != null) { +hiddenSeqs++; +}index++; +} +;return (alignmentIndex - hiddenSeqs); +}, "~N"); +Clazz.defineMethod (c$, "adjustForHiddenSeqs", +function (alignmentIndex) { +var index = 0; +var hSize = this.hiddenSequences.length; +while (index <= alignmentIndex && index < hSize) { +if (this.hiddenSequences[index] != null) { +alignmentIndex++; +}index++; +} +;return alignmentIndex; +}, "~N"); +Clazz.defineMethod (c$, "getFullAlignment", +function () { +var isize = this.hiddenSequences.length; +var seq = new Array (isize); +var index = 0; +for (var i = 0; i < this.hiddenSequences.length; i++) { +if (this.hiddenSequences[i] != null) { +seq[i] = this.hiddenSequences[i]; +} else { +seq[i] = this.alignment.getSequenceAt (index); +index++; +}} +var fAlignmt = new jalview.datamodel.Alignment (seq); +fAlignmt.annotations = this.alignment.getAlignmentAnnotation (); +fAlignmt.alignmentProperties = this.alignment.getProperties (); +fAlignmt.groups = this.alignment.getGroups (); +fAlignmt.$hasRNAStructure = this.alignment.hasRNAStructure (); +return fAlignmt; +}); +Clazz.defineMethod (c$, "isHidden", +function (seq) { +if (this.hiddenSequences != null) { +for (var i = 0; i < this.hiddenSequences.length; i++) { +if (this.hiddenSequences[i] != null && this.hiddenSequences[i] === seq) { +return true; +}} +}return false; +}, "jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/datamodel/IncompleteCodonException.js b/bin/jalview/datamodel/IncompleteCodonException.js index 924024c..372d9dd 100644 --- a/bin/jalview/datamodel/IncompleteCodonException.js +++ b/bin/jalview/datamodel/IncompleteCodonException.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.lang.RuntimeException"], "jalview.datamodel.IncompleteCodonException", null, function () { -c$ = Clazz.declareType (jalview.datamodel, "IncompleteCodonException", RuntimeException); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.lang.RuntimeException"], "jalview.datamodel.IncompleteCodonException", null, function () { +c$ = Clazz.declareType (jalview.datamodel, "IncompleteCodonException", RuntimeException); +}); diff --git a/bin/jalview/datamodel/Mapping.js b/bin/jalview/datamodel/Mapping.js index a25222e..fe06fda 100644 --- a/bin/jalview/datamodel/Mapping.js +++ b/bin/jalview/datamodel/Mapping.js @@ -1,304 +1,304 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.Iterator"], "jalview.datamodel.Mapping", ["jalview.datamodel.AlignedCodon", "$.IncompleteCodonException", "$.SequenceFeature", "jalview.util.MapList", "java.util.NoSuchElementException", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.datamodel.Mapping.AlignedCodonIterator")) { -jalview.datamodel.Mapping.$Mapping$AlignedCodonIterator$ (); -} -this.map = null; -this.to = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Mapping"); -Clazz.makeConstructor (c$, -function (map) { -this.map = map; -}, "jalview.util.MapList"); -Clazz.makeConstructor (c$, -function (to, map) { -this.construct (map); -this.to = to; -}, "jalview.datamodel.SequenceI,jalview.util.MapList"); -Clazz.makeConstructor (c$, -function (to, exon, is, i, j) { -this.construct (to, new jalview.util.MapList (exon, is, i, j)); -}, "jalview.datamodel.SequenceI,~A,~A,~N,~N"); -Clazz.makeConstructor (c$, -function (map2) { -if (map2 !== this && map2 != null) { -if (map2.map != null) { -this.map = new jalview.util.MapList (map2.map); -}this.to = map2.to; -}}, "jalview.datamodel.Mapping"); -Clazz.defineMethod (c$, "getMap", -function () { -return this.map; -}); -Clazz.defineMethod (c$, "setMap", -function (map) { -this.map = map; -}, "jalview.util.MapList"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.Mapping))) { -return false; -}var other = o; -if (other === this) { -return true; -}if (other.to !== this.to) { -return false; -}if ((this.map != null && other.map == null) || (this.map == null && other.map != null)) { -return false; -}if ((this.map == null && other.map == null) || this.map.equals (other.map)) { -return true; -}return false; -}, "~O"); -Clazz.defineMethod (c$, "getPosition", -function (mpos) { -if (this.map != null) { -var mp = this.map.shiftTo (mpos); -if (mp != null) { -return mp[0]; -}}return mpos; -}, "~N"); -Clazz.defineMethod (c$, "getWord", -function (mpos) { -if (this.map != null) { -return this.map.getToWord (mpos); -}return null; -}, "~N"); -Clazz.defineMethod (c$, "getWidth", -function () { -if (this.map != null) { -return this.map.getFromRatio (); -}return 1; -}); -Clazz.defineMethod (c$, "getMappedWidth", -function () { -if (this.map != null) { -return this.map.getToRatio (); -}return 1; -}); -Clazz.defineMethod (c$, "getMappedPosition", -function (pos) { -if (this.map != null) { -var mp = this.map.shiftFrom (pos); -if (mp != null) { -return mp[0]; -}}return pos; -}, "~N"); -Clazz.defineMethod (c$, "getMappedWord", -function (pos) { -if (this.map != null) { -var mp = this.map.shiftFrom (pos); -if (mp != null) { -return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.map.getToRatio () - 1)]); -}}return null; -}, "~N"); -Clazz.defineMethod (c$, "locateFeature", -function (f) { -if (true) { -if (this.map != null) { -var frange = this.map.locateInFrom (f.getBegin (), f.getEnd ()); -if (frange == null) { -return null; -}var vf = new Array (Clazz.doubleToInt (frange.length / 2)); -for (var i = 0, v = 0; i < frange.length; i += 2, v++) { -vf[v] = new jalview.datamodel.SequenceFeature (f); -vf[v].setBegin (frange[i]); -vf[v].setEnd (frange[i + 1]); -if (frange.length > 2) { -vf[v].setDescription (f.getDescription () + "\nPart " + (v + 1)); -}} -return vf; -}}if (false) { -var word = this.getWord (f.getBegin ()); -if (word[0] < word[1]) { -f.setBegin (word[0]); -} else { -f.setBegin (word[1]); -}word = this.getWord (f.getEnd ()); -if (word[0] > word[1]) { -f.setEnd (word[0]); -} else { -f.setEnd (word[1]); -}}return Clazz.newArray (-1, [f]); -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "locateRange", -function (from, to) { -if (this.map != null) { -if (from <= to) { -from = (this.map.getToLowest () < from) ? from : this.map.getToLowest (); -to = (this.map.getToHighest () > to) ? to : this.map.getToHighest (); -if (from > to) { -return null; -}} else { -from = (this.map.getToHighest () > from) ? from : this.map.getToHighest (); -to = (this.map.getToLowest () < to) ? to : this.map.getToLowest (); -if (from < to) { -return null; -}}return this.map.locateInFrom (from, to); -}return Clazz.newIntArray (-1, [from, to]); -}, "~N,~N"); -Clazz.defineMethod (c$, "locateMappedRange", -function (from, to) { -if (this.map != null) { -if (from <= to) { -from = (this.map.getFromLowest () < from) ? from : this.map.getFromLowest (); -to = (this.map.getFromHighest () > to) ? to : this.map.getFromHighest (); -if (from > to) { -return null; -}} else { -from = (this.map.getFromHighest () > from) ? from : this.map.getFromHighest (); -to = (this.map.getFromLowest () < to) ? to : this.map.getFromLowest (); -if (from < to) { -return null; -}}return this.map.locateInTo (from, to); -}return Clazz.newIntArray (-1, [from, to]); -}, "~N,~N"); -Clazz.defineMethod (c$, "intersectVisContigs", -function (viscontigs) { -var copy = new jalview.datamodel.Mapping (this); -if (this.map != null) { -var vpos = 0; -var apos = 0; -var toRange = new java.util.Vector (); -var fromRange = new java.util.Vector (); -for (var vc = 0; vc < viscontigs.length; vc += 2) { -var mpr = this.locateMappedRange (1 + viscontigs[vc], viscontigs[vc + 1] - 1); -if (mpr != null) { -for (var m = 0; m < mpr.length; m += 2) { -toRange.addElement ( Clazz.newIntArray (-1, [mpr[m], mpr[m + 1]])); -var xpos = this.locateRange (mpr[m], mpr[m + 1]); -for (var x = 0; x < xpos.length; x += 2) { -fromRange.addElement ( Clazz.newIntArray (-1, [xpos[x], xpos[x + 1]])); -} -} -}} -var from = Clazz.newIntArray (fromRange.size () * 2, 0); -var to = Clazz.newIntArray (toRange.size () * 2, 0); -var r; -for (var f = 0, fSize = fromRange.size (); f < fSize; f++) { -r = fromRange.elementAt (f); -from[f * 2] = r[0]; -from[f * 2 + 1] = r[1]; -} -for (var f = 0, fSize = toRange.size (); f < fSize; f++) { -r = toRange.elementAt (f); -to[f * 2] = r[0]; -to[f * 2 + 1] = r[1]; -} -copy.setMap ( new jalview.util.MapList (from, to, this.map.getFromRatio (), this.map.getToRatio ())); -}return copy; -}, "~A"); -Clazz.defineMethod (c$, "getTo", -function () { -return this.to; -}); -Clazz.defineMethod (c$, "setTo", -function (tto) { -this.to = tto; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "finalize", -function () { -this.map = null; -this.to = null; -Clazz.superCall (this, jalview.datamodel.Mapping, "finalize", []); -}); -Clazz.defineMethod (c$, "getCodonIterator", -function (seq, gapChar) { -return Clazz.innerTypeInstance (jalview.datamodel.Mapping.AlignedCodonIterator, this, null, seq.getSequence (), gapChar); -}, "jalview.datamodel.SequenceI,~S"); -c$.$Mapping$AlignedCodonIterator$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.gap = '\0'; -this.alignedSeq = null; -this.alignedColumn = 0; -this.alignedBases = 0; -this.fromRanges = null; -this.toRanges = null; -this.currentFromRange = null; -this.currentToRange = null; -this.fromPosition = 0; -this.toPosition = 0; -Clazz.instantialize (this, arguments); -}, jalview.datamodel.Mapping, "AlignedCodonIterator", null, java.util.Iterator); -Clazz.makeConstructor (c$, -function (a, b) { -this.alignedSeq = a; -this.gap = b; -this.fromRanges = this.b$["jalview.datamodel.Mapping"].map.getFromRanges ().iterator (); -this.toRanges = this.b$["jalview.datamodel.Mapping"].map.getToRanges ().iterator (); -if (this.fromRanges.hasNext ()) { -this.currentFromRange = this.fromRanges.next (); -this.fromPosition = this.currentFromRange[0]; -}if (this.toRanges.hasNext ()) { -this.currentToRange = this.toRanges.next (); -this.toPosition = this.currentToRange[0]; -}}, "~A,~S"); -Clazz.defineMethod (c$, "hasNext", -function () { -if (this.fromRanges.hasNext ()) { -return true; -}if (this.currentFromRange == null || this.fromPosition >= this.currentFromRange[1]) { -return false; -}return true; -}); -Clazz.overrideMethod (c$, "next", -function () { -if (!this.hasNext ()) { -throw new java.util.NoSuchElementException (); -}var a = this.getNextCodon (); -var b = this.getAlignedCodon (a); -var c = this.getPeptide (); -return new jalview.datamodel.AlignedCodon (b[0], b[1], b[2], c); -}); -Clazz.defineMethod (c$, "getPeptide", -($fz = function () { -if (this.toPosition <= this.currentToRange[1]) { -var a = this.b$["jalview.datamodel.Mapping"].to.getSequence ()[this.toPosition - 1]; -this.toPosition++; -return String.valueOf (a); -}if (!this.toRanges.hasNext ()) { -throw new java.util.NoSuchElementException ("Ran out of peptide at position " + this.toPosition); -}this.currentToRange = this.toRanges.next (); -this.toPosition = this.currentToRange[0]; -return this.getPeptide (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getNextCodon", -($fz = function () { -var a = Clazz.newIntArray (3, 0); -var b = 0; -while (b < 3) { -if (this.fromPosition <= this.currentFromRange[1]) { -a[b++] = this.fromPosition++; -} else { -if (!this.fromRanges.hasNext ()) { -throw new jalview.datamodel.IncompleteCodonException (); -}this.currentFromRange = this.fromRanges.next (); -this.fromPosition = this.currentFromRange[0]; -}} -return a; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getAlignedCodon", -($fz = function (a) { -var b = Clazz.newIntArray (a.length, 0); -for (var c = 0; c < a.length; c++) { -b[c] = this.getAlignedColumn (a[c]); -} -return b; -}, $fz.isPrivate = true, $fz), "~A"); -Clazz.defineMethod (c$, "getAlignedColumn", -($fz = function (a) { -while (this.alignedBases < a && this.alignedColumn < this.alignedSeq.length) { -if (this.alignedSeq[this.alignedColumn++] != this.gap) { -this.alignedBases++; -}} -return this.alignedColumn - 1; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.overrideMethod (c$, "remove", -function () { -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.Iterator"], "jalview.datamodel.Mapping", ["jalview.datamodel.AlignedCodon", "$.IncompleteCodonException", "$.SequenceFeature", "jalview.util.MapList", "java.util.NoSuchElementException", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.datamodel.Mapping.AlignedCodonIterator")) { +jalview.datamodel.Mapping.$Mapping$AlignedCodonIterator$ (); +} +this.map = null; +this.to = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Mapping"); +Clazz.makeConstructor (c$, +function (map) { +this.map = map; +}, "jalview.util.MapList"); +Clazz.makeConstructor (c$, +function (to, map) { +this.construct (map); +this.to = to; +}, "jalview.datamodel.SequenceI,jalview.util.MapList"); +Clazz.makeConstructor (c$, +function (to, exon, is, i, j) { +this.construct (to, new jalview.util.MapList (exon, is, i, j)); +}, "jalview.datamodel.SequenceI,~A,~A,~N,~N"); +Clazz.makeConstructor (c$, +function (map2) { +if (map2 !== this && map2 != null) { +if (map2.map != null) { +this.map = new jalview.util.MapList (map2.map); +}this.to = map2.to; +}}, "jalview.datamodel.Mapping"); +Clazz.defineMethod (c$, "getMap", +function () { +return this.map; +}); +Clazz.defineMethod (c$, "setMap", +function (map) { +this.map = map; +}, "jalview.util.MapList"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (o == null || !(Clazz.instanceOf (o, jalview.datamodel.Mapping))) { +return false; +}var other = o; +if (other === this) { +return true; +}if (other.to !== this.to) { +return false; +}if ((this.map != null && other.map == null) || (this.map == null && other.map != null)) { +return false; +}if ((this.map == null && other.map == null) || this.map.equals (other.map)) { +return true; +}return false; +}, "~O"); +Clazz.defineMethod (c$, "getPosition", +function (mpos) { +if (this.map != null) { +var mp = this.map.shiftTo (mpos); +if (mp != null) { +return mp[0]; +}}return mpos; +}, "~N"); +Clazz.defineMethod (c$, "getWord", +function (mpos) { +if (this.map != null) { +return this.map.getToWord (mpos); +}return null; +}, "~N"); +Clazz.defineMethod (c$, "getWidth", +function () { +if (this.map != null) { +return this.map.getFromRatio (); +}return 1; +}); +Clazz.defineMethod (c$, "getMappedWidth", +function () { +if (this.map != null) { +return this.map.getToRatio (); +}return 1; +}); +Clazz.defineMethod (c$, "getMappedPosition", +function (pos) { +if (this.map != null) { +var mp = this.map.shiftFrom (pos); +if (mp != null) { +return mp[0]; +}}return pos; +}, "~N"); +Clazz.defineMethod (c$, "getMappedWord", +function (pos) { +if (this.map != null) { +var mp = this.map.shiftFrom (pos); +if (mp != null) { +return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.map.getToRatio () - 1)]); +}}return null; +}, "~N"); +Clazz.defineMethod (c$, "locateFeature", +function (f) { +if (true) { +if (this.map != null) { +var frange = this.map.locateInFrom (f.getBegin (), f.getEnd ()); +if (frange == null) { +return null; +}var vf = new Array (Clazz.doubleToInt (frange.length / 2)); +for (var i = 0, v = 0; i < frange.length; i += 2, v++) { +vf[v] = new jalview.datamodel.SequenceFeature (f); +vf[v].setBegin (frange[i]); +vf[v].setEnd (frange[i + 1]); +if (frange.length > 2) { +vf[v].setDescription (f.getDescription () + "\nPart " + (v + 1)); +}} +return vf; +}}if (false) { +var word = this.getWord (f.getBegin ()); +if (word[0] < word[1]) { +f.setBegin (word[0]); +} else { +f.setBegin (word[1]); +}word = this.getWord (f.getEnd ()); +if (word[0] > word[1]) { +f.setEnd (word[0]); +} else { +f.setEnd (word[1]); +}}return Clazz.newArray (-1, [f]); +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "locateRange", +function (from, to) { +if (this.map != null) { +if (from <= to) { +from = (this.map.getToLowest () < from) ? from : this.map.getToLowest (); +to = (this.map.getToHighest () > to) ? to : this.map.getToHighest (); +if (from > to) { +return null; +}} else { +from = (this.map.getToHighest () > from) ? from : this.map.getToHighest (); +to = (this.map.getToLowest () < to) ? to : this.map.getToLowest (); +if (from < to) { +return null; +}}return this.map.locateInFrom (from, to); +}return Clazz.newIntArray (-1, [from, to]); +}, "~N,~N"); +Clazz.defineMethod (c$, "locateMappedRange", +function (from, to) { +if (this.map != null) { +if (from <= to) { +from = (this.map.getFromLowest () < from) ? from : this.map.getFromLowest (); +to = (this.map.getFromHighest () > to) ? to : this.map.getFromHighest (); +if (from > to) { +return null; +}} else { +from = (this.map.getFromHighest () > from) ? from : this.map.getFromHighest (); +to = (this.map.getFromLowest () < to) ? to : this.map.getFromLowest (); +if (from < to) { +return null; +}}return this.map.locateInTo (from, to); +}return Clazz.newIntArray (-1, [from, to]); +}, "~N,~N"); +Clazz.defineMethod (c$, "intersectVisContigs", +function (viscontigs) { +var copy = new jalview.datamodel.Mapping (this); +if (this.map != null) { +var vpos = 0; +var apos = 0; +var toRange = new java.util.Vector (); +var fromRange = new java.util.Vector (); +for (var vc = 0; vc < viscontigs.length; vc += 2) { +var mpr = this.locateMappedRange (1 + viscontigs[vc], viscontigs[vc + 1] - 1); +if (mpr != null) { +for (var m = 0; m < mpr.length; m += 2) { +toRange.addElement ( Clazz.newIntArray (-1, [mpr[m], mpr[m + 1]])); +var xpos = this.locateRange (mpr[m], mpr[m + 1]); +for (var x = 0; x < xpos.length; x += 2) { +fromRange.addElement ( Clazz.newIntArray (-1, [xpos[x], xpos[x + 1]])); +} +} +}} +var from = Clazz.newIntArray (fromRange.size () * 2, 0); +var to = Clazz.newIntArray (toRange.size () * 2, 0); +var r; +for (var f = 0, fSize = fromRange.size (); f < fSize; f++) { +r = fromRange.elementAt (f); +from[f * 2] = r[0]; +from[f * 2 + 1] = r[1]; +} +for (var f = 0, fSize = toRange.size (); f < fSize; f++) { +r = toRange.elementAt (f); +to[f * 2] = r[0]; +to[f * 2 + 1] = r[1]; +} +copy.setMap ( new jalview.util.MapList (from, to, this.map.getFromRatio (), this.map.getToRatio ())); +}return copy; +}, "~A"); +Clazz.defineMethod (c$, "getTo", +function () { +return this.to; +}); +Clazz.defineMethod (c$, "setTo", +function (tto) { +this.to = tto; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "finalize", +function () { +this.map = null; +this.to = null; +Clazz.superCall (this, jalview.datamodel.Mapping, "finalize", []); +}); +Clazz.defineMethod (c$, "getCodonIterator", +function (seq, gapChar) { +return Clazz.innerTypeInstance (jalview.datamodel.Mapping.AlignedCodonIterator, this, null, seq.getSequence (), gapChar); +}, "jalview.datamodel.SequenceI,~S"); +c$.$Mapping$AlignedCodonIterator$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.gap = '\0'; +this.alignedSeq = null; +this.alignedColumn = 0; +this.alignedBases = 0; +this.fromRanges = null; +this.toRanges = null; +this.currentFromRange = null; +this.currentToRange = null; +this.fromPosition = 0; +this.toPosition = 0; +Clazz.instantialize (this, arguments); +}, jalview.datamodel.Mapping, "AlignedCodonIterator", null, java.util.Iterator); +Clazz.makeConstructor (c$, +function (a, b) { +this.alignedSeq = a; +this.gap = b; +this.fromRanges = this.b$["jalview.datamodel.Mapping"].map.getFromRanges ().iterator (); +this.toRanges = this.b$["jalview.datamodel.Mapping"].map.getToRanges ().iterator (); +if (this.fromRanges.hasNext ()) { +this.currentFromRange = this.fromRanges.next (); +this.fromPosition = this.currentFromRange[0]; +}if (this.toRanges.hasNext ()) { +this.currentToRange = this.toRanges.next (); +this.toPosition = this.currentToRange[0]; +}}, "~A,~S"); +Clazz.defineMethod (c$, "hasNext", +function () { +if (this.fromRanges.hasNext ()) { +return true; +}if (this.currentFromRange == null || this.fromPosition >= this.currentFromRange[1]) { +return false; +}return true; +}); +Clazz.overrideMethod (c$, "next", +function () { +if (!this.hasNext ()) { +throw new java.util.NoSuchElementException (); +}var a = this.getNextCodon (); +var b = this.getAlignedCodon (a); +var c = this.getPeptide (); +return new jalview.datamodel.AlignedCodon (b[0], b[1], b[2], c); +}); +Clazz.defineMethod (c$, "getPeptide", +($fz = function () { +if (this.toPosition <= this.currentToRange[1]) { +var a = this.b$["jalview.datamodel.Mapping"].to.getSequence ()[this.toPosition - 1]; +this.toPosition++; +return String.valueOf (a); +}if (!this.toRanges.hasNext ()) { +throw new java.util.NoSuchElementException ("Ran out of peptide at position " + this.toPosition); +}this.currentToRange = this.toRanges.next (); +this.toPosition = this.currentToRange[0]; +return this.getPeptide (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getNextCodon", +($fz = function () { +var a = Clazz.newIntArray (3, 0); +var b = 0; +while (b < 3) { +if (this.fromPosition <= this.currentFromRange[1]) { +a[b++] = this.fromPosition++; +} else { +if (!this.fromRanges.hasNext ()) { +throw new jalview.datamodel.IncompleteCodonException (); +}this.currentFromRange = this.fromRanges.next (); +this.fromPosition = this.currentFromRange[0]; +}} +return a; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getAlignedCodon", +($fz = function (a) { +var b = Clazz.newIntArray (a.length, 0); +for (var c = 0; c < a.length; c++) { +b[c] = this.getAlignedColumn (a[c]); +} +return b; +}, $fz.isPrivate = true, $fz), "~A"); +Clazz.defineMethod (c$, "getAlignedColumn", +($fz = function (a) { +while (this.alignedBases < a && this.alignedColumn < this.alignedSeq.length) { +if (this.alignedSeq[this.alignedColumn++] != this.gap) { +this.alignedBases++; +}} +return this.alignedColumn - 1; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.overrideMethod (c$, "remove", +function () { +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/datamodel/NodeTransformI.js b/bin/jalview/datamodel/NodeTransformI.js index 0f7a757..83ace63 100644 --- a/bin/jalview/datamodel/NodeTransformI.js +++ b/bin/jalview/datamodel/NodeTransformI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.declareInterface (jalview.datamodel, "NodeTransformI"); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.declareInterface (jalview.datamodel, "NodeTransformI"); diff --git a/bin/jalview/datamodel/PDBEntry.js b/bin/jalview/datamodel/PDBEntry.js index e153399..e52f785 100644 --- a/bin/jalview/datamodel/PDBEntry.js +++ b/bin/jalview/datamodel/PDBEntry.js @@ -1,88 +1,88 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.lang.Enum"], "jalview.datamodel.PDBEntry", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.file = null; -this.type = null; -this.id = null; -this.chainCode = null; -this.properties = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "PDBEntry"); -Clazz.overrideMethod (c$, "equals", -function (obj) { -if (obj == null || !(Clazz.instanceOf (obj, jalview.datamodel.PDBEntry))) { -return false; -}if (obj === this) { -return true; -}var o = obj; -return (this.type === o.type || (this.type != null && o.type != null && o.type.equals (this.type))) && (this.id === o.id || (this.id != null && o.id != null && o.id.equalsIgnoreCase (this.id))) && (this.chainCode === o.chainCode || (this.chainCode != null && o.chainCode != null && o.chainCode.equalsIgnoreCase (this.chainCode))) && (this.properties === o.properties || (this.properties != null && o.properties != null && this.properties.equals (o.properties))); -}, "~O"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (pdbId, chain, type, filePath) { -this.id = pdbId; -this.chainCode = chain; -this.type = type == null ? null : type.toString (); -this.file = filePath; -}, "~S,~S,jalview.datamodel.PDBEntry.Type,~S"); -Clazz.makeConstructor (c$, -function (entry) { -this.file = entry.file; -this.type = entry.type; -this.id = entry.id; -this.chainCode = entry.chainCode; -if (entry.properties != null) { -this.properties = entry.properties.clone (); -}}, "jalview.datamodel.PDBEntry"); -Clazz.defineMethod (c$, "setFile", -function (file) { -this.file = file; -}, "~S"); -Clazz.defineMethod (c$, "getFile", -function () { -return this.file; -}); -Clazz.defineMethod (c$, "setType", -function (t) { -this.type = t; -}, "~S"); -Clazz.defineMethod (c$, "setType", -function (type) { -this.type = type == null ? null : type.toString (); -}, "jalview.datamodel.PDBEntry.Type"); -Clazz.defineMethod (c$, "getType", -function () { -return this.type; -}); -Clazz.defineMethod (c$, "setId", -function (id) { -this.id = id; -}, "~S"); -Clazz.defineMethod (c$, "getId", -function () { -return this.id; -}); -Clazz.defineMethod (c$, "setProperty", -function (property) { -this.properties = property; -}, "java.util.Hashtable"); -Clazz.defineMethod (c$, "getProperty", -function () { -return this.properties; -}); -Clazz.defineMethod (c$, "getChainCode", -function () { -return this.chainCode; -}); -Clazz.defineMethod (c$, "setChainCode", -function (chainCode) { -this.chainCode = chainCode; -}, "~S"); -Clazz.pu$h (); -c$ = Clazz.declareType (jalview.datamodel.PDBEntry, "Type", Enum); -Clazz.defineEnumConstant (c$, "PDB", 0, []); -Clazz.defineEnumConstant (c$, "FILE", 1, []); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.lang.Enum"], "jalview.datamodel.PDBEntry", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.file = null; +this.type = null; +this.id = null; +this.chainCode = null; +this.properties = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "PDBEntry"); +Clazz.overrideMethod (c$, "equals", +function (obj) { +if (obj == null || !(Clazz.instanceOf (obj, jalview.datamodel.PDBEntry))) { +return false; +}if (obj === this) { +return true; +}var o = obj; +return (this.type === o.type || (this.type != null && o.type != null && o.type.equals (this.type))) && (this.id === o.id || (this.id != null && o.id != null && o.id.equalsIgnoreCase (this.id))) && (this.chainCode === o.chainCode || (this.chainCode != null && o.chainCode != null && o.chainCode.equalsIgnoreCase (this.chainCode))) && (this.properties === o.properties || (this.properties != null && o.properties != null && this.properties.equals (o.properties))); +}, "~O"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (pdbId, chain, type, filePath) { +this.id = pdbId; +this.chainCode = chain; +this.type = type == null ? null : type.toString (); +this.file = filePath; +}, "~S,~S,jalview.datamodel.PDBEntry.Type,~S"); +Clazz.makeConstructor (c$, +function (entry) { +this.file = entry.file; +this.type = entry.type; +this.id = entry.id; +this.chainCode = entry.chainCode; +if (entry.properties != null) { +this.properties = entry.properties.clone (); +}}, "jalview.datamodel.PDBEntry"); +Clazz.defineMethod (c$, "setFile", +function (file) { +this.file = file; +}, "~S"); +Clazz.defineMethod (c$, "getFile", +function () { +return this.file; +}); +Clazz.defineMethod (c$, "setType", +function (t) { +this.type = t; +}, "~S"); +Clazz.defineMethod (c$, "setType", +function (type) { +this.type = type == null ? null : type.toString (); +}, "jalview.datamodel.PDBEntry.Type"); +Clazz.defineMethod (c$, "getType", +function () { +return this.type; +}); +Clazz.defineMethod (c$, "setId", +function (id) { +this.id = id; +}, "~S"); +Clazz.defineMethod (c$, "getId", +function () { +return this.id; +}); +Clazz.defineMethod (c$, "setProperty", +function (property) { +this.properties = property; +}, "java.util.Hashtable"); +Clazz.defineMethod (c$, "getProperty", +function () { +return this.properties; +}); +Clazz.defineMethod (c$, "getChainCode", +function () { +return this.chainCode; +}); +Clazz.defineMethod (c$, "setChainCode", +function (chainCode) { +this.chainCode = chainCode; +}, "~S"); +Clazz.pu$h (); +c$ = Clazz.declareType (jalview.datamodel.PDBEntry, "Type", Enum); +Clazz.defineEnumConstant (c$, "PDB", 0, []); +Clazz.defineEnumConstant (c$, "FILE", 1, []); +c$ = Clazz.p0p (); +}); diff --git a/bin/jalview/datamodel/Provenance.js b/bin/jalview/datamodel/Provenance.js index c0180ea..04f873e 100644 --- a/bin/jalview/datamodel/Provenance.js +++ b/bin/jalview/datamodel/Provenance.js @@ -1,25 +1,25 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.Vector"], "jalview.datamodel.Provenance", ["jalview.datamodel.ProvenanceEntry"], function () { -c$ = Clazz.decorateAsClass (function () { -this.entries = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Provenance"); -Clazz.prepareFields (c$, function () { -this.entries = new java.util.Vector (); -}); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "getEntries", -function () { -var ret = new Array (this.entries.size ()); -for (var i = 0; i < this.entries.size (); i++) { -ret[i] = this.entries.elementAt (i); -} -return ret; -}); -Clazz.defineMethod (c$, "addEntry", -function (user, action, date, id) { -this.entries.addElement ( new jalview.datamodel.ProvenanceEntry (user, action, date, id)); -}, "~S,~S,java.util.Date,~S"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.Vector"], "jalview.datamodel.Provenance", ["jalview.datamodel.ProvenanceEntry"], function () { +c$ = Clazz.decorateAsClass (function () { +this.entries = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Provenance"); +Clazz.prepareFields (c$, function () { +this.entries = new java.util.Vector (); +}); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "getEntries", +function () { +var ret = new Array (this.entries.size ()); +for (var i = 0; i < this.entries.size (); i++) { +ret[i] = this.entries.elementAt (i); +} +return ret; +}); +Clazz.defineMethod (c$, "addEntry", +function (user, action, date, id) { +this.entries.addElement ( new jalview.datamodel.ProvenanceEntry (user, action, date, id)); +}, "~S,~S,java.util.Date,~S"); +}); diff --git a/bin/jalview/datamodel/ProvenanceEntry.js b/bin/jalview/datamodel/ProvenanceEntry.js index 1283717..5077d90 100644 --- a/bin/jalview/datamodel/ProvenanceEntry.js +++ b/bin/jalview/datamodel/ProvenanceEntry.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this.user = null; -this.action = null; -this.id = null; -this.date = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "ProvenanceEntry"); -Clazz.makeConstructor (c$, -function (u, a, d, i) { -this.user = u; -this.action = a; -this.date = d; -this.id = i; -}, "~S,~S,java.util.Date,~S"); -Clazz.defineMethod (c$, "getUser", -function () { -return this.user; -}); -Clazz.defineMethod (c$, "getAction", -function () { -return this.action; -}); -Clazz.defineMethod (c$, "getDate", -function () { -return this.date; -}); -Clazz.defineMethod (c$, "getID", -function () { -return this.id; -}); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this.user = null; +this.action = null; +this.id = null; +this.date = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "ProvenanceEntry"); +Clazz.makeConstructor (c$, +function (u, a, d, i) { +this.user = u; +this.action = a; +this.date = d; +this.id = i; +}, "~S,~S,java.util.Date,~S"); +Clazz.defineMethod (c$, "getUser", +function () { +return this.user; +}); +Clazz.defineMethod (c$, "getAction", +function () { +return this.action; +}); +Clazz.defineMethod (c$, "getDate", +function () { +return this.date; +}); +Clazz.defineMethod (c$, "getID", +function () { +return this.id; +}); diff --git a/bin/jalview/datamodel/RnaViewerModel.js b/bin/jalview/datamodel/RnaViewerModel.js index 612cdda..2e64a80 100644 --- a/bin/jalview/datamodel/RnaViewerModel.js +++ b/bin/jalview/datamodel/RnaViewerModel.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this.viewId = null; -this.title = null; -this.x = 0; -this.y = 0; -this.width = 0; -this.height = 0; -this.dividerLocation = 0; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "RnaViewerModel"); -Clazz.makeConstructor (c$, -function (viewId, title, xpos, ypos, width, height, dividerLocation) { -this.viewId = viewId; -this.title = title; -this.x = xpos; -this.y = ypos; -this.width = width; -this.height = height; -this.dividerLocation = dividerLocation; -}, "~S,~S,~N,~N,~N,~N,~N"); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this.viewId = null; +this.title = null; +this.x = 0; +this.y = 0; +this.width = 0; +this.height = 0; +this.dividerLocation = 0; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "RnaViewerModel"); +Clazz.makeConstructor (c$, +function (viewId, title, xpos, ypos, width, height, dividerLocation) { +this.viewId = viewId; +this.title = title; +this.x = xpos; +this.y = ypos; +this.width = width; +this.height = height; +this.dividerLocation = dividerLocation; +}, "~S,~S,~N,~N,~N,~N,~N"); diff --git a/bin/jalview/datamodel/SearchResults.js b/bin/jalview/datamodel/SearchResults.js index e82bfa5..74170de 100644 --- a/bin/jalview/datamodel/SearchResults.js +++ b/bin/jalview/datamodel/SearchResults.js @@ -1,137 +1,137 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.ArrayList"], "jalview.datamodel.SearchResults", ["java.lang.StringBuilder", "java.util.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.matches = null; -if (!Clazz.isClassDefined ("jalview.datamodel.SearchResults.Match")) { -jalview.datamodel.SearchResults.$SearchResults$Match$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SearchResults"); -Clazz.prepareFields (c$, function () { -this.matches = new java.util.ArrayList (); -}); -Clazz.defineMethod (c$, "addResult", -function (seq, start, end) { -this.matches.add (Clazz.innerTypeInstance (jalview.datamodel.SearchResults.Match, this, null, seq, start, end)); -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.defineMethod (c$, "involvesSequence", -function (sequence) { -var ds = sequence.getDatasetSequence (); -for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -if (m.sequence != null && (m.sequence === sequence || m.sequence === ds)) { -return true; -}} -return false; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getResults", -function (sequence, start, end) { -if (this.matches.isEmpty ()) { -return null; -}var result = null; -var tmp = null; -var resultLength; -var matchStart = 0; -var matchEnd = 0; -var mfound; -for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -mfound = false; -if (m.sequence === sequence) { -mfound = true; -matchStart = sequence.findIndex (m.start) - 1; -matchEnd = sequence.findIndex (m.end) - 1; -} else if (m.sequence === sequence.getDatasetSequence ()) { -mfound = true; -matchStart = sequence.findIndex (m.start) - 1; -matchEnd = sequence.findIndex (m.end) - 1; -}if (mfound) { -if (matchStart <= end && matchEnd >= start) { -if (matchStart < start) { -matchStart = start; -}if (matchEnd > end) { -matchEnd = end; -}if (result == null) { -result = Clazz.newIntArray (-1, [matchStart, matchEnd]); -} else { -resultLength = result.length; -tmp = Clazz.newIntArray (resultLength + 2, 0); -System.arraycopy (result, 0, tmp, 0, resultLength); -result = tmp; -result[resultLength] = matchStart; -result[resultLength + 1] = matchEnd; -}} else { -}}} -return result; -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.defineMethod (c$, "getSize", -function () { -return this.matches.size (); -}); -Clazz.defineMethod (c$, "getResultSequence", -function (index) { -return this.matches.get (index).sequence; -}, "~N"); -Clazz.defineMethod (c$, "getResultStart", -function (i) { -return this.matches.get (i).start; -}, "~N"); -Clazz.defineMethod (c$, "getResultEnd", -function (i) { -return this.matches.get (i).end; -}, "~N"); -Clazz.defineMethod (c$, "isEmpty", -function () { -return this.matches.isEmpty (); -}); -Clazz.defineMethod (c$, "getResults", -function () { -return this.matches; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var result = new StringBuilder (256); -for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -result.append (m.toString ()); -} -return result.toString (); -}); -c$.$SearchResults$Match$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.sequence = null; -this.start = 0; -this.end = 0; -Clazz.instantialize (this, arguments); -}, jalview.datamodel.SearchResults, "Match"); -Clazz.makeConstructor (c$, -function (a, b, c) { -this.sequence = a; -this.start = b; -this.end = c; -}, "jalview.datamodel.SequenceI,~N,~N"); -Clazz.defineMethod (c$, "getSequence", -function () { -return this.sequence; -}); -Clazz.defineMethod (c$, "getStart", -function () { -return this.start; -}); -Clazz.defineMethod (c$, "getEnd", -function () { -return this.end; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var a = this.sequence.getSequence (); -var b = Math.max (this.start - 1, 0); -var c = Math.min (this.end, a.length + 1); -return String.valueOf (java.util.Arrays.copyOfRange (a, b, c)); -}); -Clazz.defineMethod (c$, "setSequence", -function (a) { -this.sequence = a; -}, "jalview.datamodel.SequenceI"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.ArrayList"], "jalview.datamodel.SearchResults", ["java.lang.StringBuilder", "java.util.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.matches = null; +if (!Clazz.isClassDefined ("jalview.datamodel.SearchResults.Match")) { +jalview.datamodel.SearchResults.$SearchResults$Match$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SearchResults"); +Clazz.prepareFields (c$, function () { +this.matches = new java.util.ArrayList (); +}); +Clazz.defineMethod (c$, "addResult", +function (seq, start, end) { +this.matches.add (Clazz.innerTypeInstance (jalview.datamodel.SearchResults.Match, this, null, seq, start, end)); +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.defineMethod (c$, "involvesSequence", +function (sequence) { +var ds = sequence.getDatasetSequence (); +for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +if (m.sequence != null && (m.sequence === sequence || m.sequence === ds)) { +return true; +}} +return false; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getResults", +function (sequence, start, end) { +if (this.matches.isEmpty ()) { +return null; +}var result = null; +var tmp = null; +var resultLength; +var matchStart = 0; +var matchEnd = 0; +var mfound; +for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +mfound = false; +if (m.sequence === sequence) { +mfound = true; +matchStart = sequence.findIndex (m.start) - 1; +matchEnd = sequence.findIndex (m.end) - 1; +} else if (m.sequence === sequence.getDatasetSequence ()) { +mfound = true; +matchStart = sequence.findIndex (m.start) - 1; +matchEnd = sequence.findIndex (m.end) - 1; +}if (mfound) { +if (matchStart <= end && matchEnd >= start) { +if (matchStart < start) { +matchStart = start; +}if (matchEnd > end) { +matchEnd = end; +}if (result == null) { +result = Clazz.newIntArray (-1, [matchStart, matchEnd]); +} else { +resultLength = result.length; +tmp = Clazz.newIntArray (resultLength + 2, 0); +System.arraycopy (result, 0, tmp, 0, resultLength); +result = tmp; +result[resultLength] = matchStart; +result[resultLength + 1] = matchEnd; +}} else { +}}} +return result; +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.defineMethod (c$, "getSize", +function () { +return this.matches.size (); +}); +Clazz.defineMethod (c$, "getResultSequence", +function (index) { +return this.matches.get (index).sequence; +}, "~N"); +Clazz.defineMethod (c$, "getResultStart", +function (i) { +return this.matches.get (i).start; +}, "~N"); +Clazz.defineMethod (c$, "getResultEnd", +function (i) { +return this.matches.get (i).end; +}, "~N"); +Clazz.defineMethod (c$, "isEmpty", +function () { +return this.matches.isEmpty (); +}); +Clazz.defineMethod (c$, "getResults", +function () { +return this.matches; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var result = new StringBuilder (256); +for (var m, $m = this.matches.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +result.append (m.toString ()); +} +return result.toString (); +}); +c$.$SearchResults$Match$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.sequence = null; +this.start = 0; +this.end = 0; +Clazz.instantialize (this, arguments); +}, jalview.datamodel.SearchResults, "Match"); +Clazz.makeConstructor (c$, +function (a, b, c) { +this.sequence = a; +this.start = b; +this.end = c; +}, "jalview.datamodel.SequenceI,~N,~N"); +Clazz.defineMethod (c$, "getSequence", +function () { +return this.sequence; +}); +Clazz.defineMethod (c$, "getStart", +function () { +return this.start; +}); +Clazz.defineMethod (c$, "getEnd", +function () { +return this.end; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var a = this.sequence.getSequence (); +var b = Math.max (this.start - 1, 0); +var c = Math.min (this.end, a.length + 1); +return String.valueOf (java.util.Arrays.copyOfRange (a, b, c)); +}); +Clazz.defineMethod (c$, "setSequence", +function (a) { +this.sequence = a; +}, "jalview.datamodel.SequenceI"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/datamodel/SecondaryStructureAnnotation.js b/bin/jalview/datamodel/SecondaryStructureAnnotation.js index 2d1eb58..6a35ad3 100644 --- a/bin/jalview/datamodel/SecondaryStructureAnnotation.js +++ b/bin/jalview/datamodel/SecondaryStructureAnnotation.js @@ -1,23 +1,23 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.AlignmentAnnotation"], "jalview.datamodel.SecondaryStructureAnnotation", ["jalview.datamodel.Annotation"], function () { -c$ = Clazz.declareType (jalview.datamodel, "SecondaryStructureAnnotation", jalview.datamodel.AlignmentAnnotation); -Clazz.makeConstructor (c$, -function (rna) { -Clazz.superConstructor (this, jalview.datamodel.SecondaryStructureAnnotation, ["Secondary Structure", "Un truc trop cool", jalview.datamodel.SecondaryStructureAnnotation.getAnnotation (rna)]); -jalview.datamodel.SecondaryStructureAnnotation._rna = rna; -}, "fr.orsay.lri.varna.models.rna.RNA"); -Clazz.defineMethod (c$, "getRNA", -function () { -return jalview.datamodel.SecondaryStructureAnnotation._rna; -}); -c$.getAnnotation = Clazz.defineMethod (c$, "getAnnotation", -function (rna) { -var ann = new Array (rna.getSize ()); -for (var i = 0; i < ann.length; i++) { -ann[i] = new jalview.datamodel.Annotation (jalview.datamodel.SecondaryStructureAnnotation._rna.getStructDBN (true), "", ' ', 0); -;} -return ann; -}, "fr.orsay.lri.varna.models.rna.RNA"); -Clazz.defineStatics (c$, -"_rna", null); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.AlignmentAnnotation"], "jalview.datamodel.SecondaryStructureAnnotation", ["jalview.datamodel.Annotation"], function () { +c$ = Clazz.declareType (jalview.datamodel, "SecondaryStructureAnnotation", jalview.datamodel.AlignmentAnnotation); +Clazz.makeConstructor (c$, +function (rna) { +Clazz.superConstructor (this, jalview.datamodel.SecondaryStructureAnnotation, ["Secondary Structure", "Un truc trop cool", jalview.datamodel.SecondaryStructureAnnotation.getAnnotation (rna)]); +jalview.datamodel.SecondaryStructureAnnotation._rna = rna; +}, "fr.orsay.lri.varna.models.rna.RNA"); +Clazz.defineMethod (c$, "getRNA", +function () { +return jalview.datamodel.SecondaryStructureAnnotation._rna; +}); +c$.getAnnotation = Clazz.defineMethod (c$, "getAnnotation", +function (rna) { +var ann = new Array (rna.getSize ()); +for (var i = 0; i < ann.length; i++) { +ann[i] = new jalview.datamodel.Annotation (jalview.datamodel.SecondaryStructureAnnotation._rna.getStructDBN (true), "", ' ', 0); +;} +return ann; +}, "fr.orsay.lri.varna.models.rna.RNA"); +Clazz.defineStatics (c$, +"_rna", null); +}); diff --git a/bin/jalview/datamodel/SeqCigar.js b/bin/jalview/datamodel/SeqCigar.js index d35d16f..c9304ac 100644 --- a/bin/jalview/datamodel/SeqCigar.js +++ b/bin/jalview/datamodel/SeqCigar.js @@ -1,259 +1,259 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.CigarSimple"], "jalview.datamodel.SeqCigar", ["jalview.analysis.AlignSeq", "$.SeqsetUtils", "jalview.datamodel.Sequence", "jalview.util.Comparison", "$.MessageManager", "$.ShiftList", "java.lang.Error", "$.StringBuffer", "java.util.Hashtable"], function () { -c$ = Clazz.decorateAsClass (function () { -this.start = 0; -this.end = 0; -this.refseq = null; -this.seqProps = null; -this.selGroups = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SeqCigar", jalview.datamodel.CigarSimple); -Clazz.defineMethod (c$, "getRefSeq", -function () { -return this.refseq; -}); -Clazz.defineMethod (c$, "getStart", -function () { -return this.start; -}); -Clazz.defineMethod (c$, "getEnd", -function () { -return this.end; -}); -Clazz.overrideMethod (c$, "getSequenceString", -function (GapChar) { -return (this.length == 0) ? "" : this.getSequenceAndDeletions (this.refseq.getSequenceAsString (this.start, this.end), GapChar)[0]; -}, "~S"); -Clazz.defineMethod (c$, "getSeq", -function (GapChar) { -var seq; -if (this.refseq == null || this.length == 0) { -return null; -}var edit_result = this.getSequenceAndDeletions (this.refseq.getSequenceAsString (this.start, this.end), GapChar); -if (edit_result == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_unexpected_null_from_get_sequence_and_deletions")); -}var bounds = edit_result[1]; -seq = new jalview.datamodel.Sequence (this.refseq.getName (), edit_result[0], this.refseq.getStart () + this.start + bounds[0], this.refseq.getStart () + this.start + ((bounds[2] == 0) ? -1 : bounds[2])); -seq.setDescription (this.refseq.getDescription ()); -var sstart = seq.getStart (); -var send = seq.getEnd (); -if (this.seqProps != null) { -jalview.analysis.SeqsetUtils.SeqCharacterUnhash (seq, this.seqProps); -}seq.setDatasetSequence (this.refseq); -seq.setStart (sstart); -seq.setEnd (send); -return seq; -}, "~S"); -Clazz.defineMethod (c$, "_setSeq", -($fz = function (seq, initialDeletion, _s, _e) { -var hasgaps = false; -if (seq == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_set_seq_null")); -}if (_s < 0) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_s", Clazz.newArray (-1, [Integer.$valueOf (_s).toString ()]))); -}var seq_string = seq.getSequenceAsString (); -if (_e == 0 || _e < _s || _e > seq_string.length) { -_e = seq_string.length; -}this.start = seq.findPosition (_s) - seq.getStart (); -this.end = seq.findPosition (_e) - seq.getStart (); -var l_ungapped = this.end - this.start; -var ds = seq.getDatasetSequence (); -if (ds == null) { -var ungapped = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (seq_string)); -l_ungapped = ungapped.length; -if (l_ungapped == seq.getLength ()) { -ds = seq; -} else { -ds = new jalview.datamodel.Sequence (seq.getName (), ungapped, seq.getStart (), seq.getStart () + ungapped.length - 1); -}}if (ds.getStart () < seq.getStart ()) { -var offset = seq.getStart () - ds.getStart (); -if (initialDeletion) { -this.addDeleted (_s + offset); -this.start = 0; -this.end += offset; -} else { -this.start += offset; -this.end += offset; -}}if (l_ungapped != (_e - _s)) { -hasgaps = true; -}this.refseq = ds; -this.seqProps = jalview.analysis.SeqsetUtils.SeqCharacterHash (seq); -if (this.end > ds.getLength ()) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_seqcigar_possible")); -}return hasgaps; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,~B,~N,~N"); -Clazz.makeConstructor (c$, -function (seq, operation, range) { -Clazz.superConstructor (this, jalview.datamodel.SeqCigar); -if (seq == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implmentation_bug_seq_null")); -}if (operation.length != range.length) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_bug_cigar_operation_list_range_list")); -}if (operation != null) { -this.operation = Clazz.newCharArray (operation.length + this._inc_length, '\0'); -this.range = Clazz.newIntArray (operation.length + this._inc_length, 0); -if (this._setSeq (seq, false, 0, 0)) { -throw new Error (jalview.util.MessageManager.getString ("error.not_yet_implemented_cigar_object_from_cigar_string")); -}for (var i = this.length, j = 0; j < operation.length; i++, j++) { -var op = operation[j]; -if (op != 'M' && op != 'I' && op != 'D') { -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_bug_cigar_operation", Clazz.newArray (-1, [Integer.$valueOf (j).toString (), Integer.$valueOf (op.charCodeAt (0)).toString (), Integer.$valueOf ('M'.charCodeAt (0)).toString (), Integer.$valueOf ('I'.charCodeAt (0)).toString (), Integer.$valueOf ('D'.charCodeAt (0)).toString ()]))); -}this.operation[i] = op; -this.range[i] = range[j]; -} -this.length += operation.length; -} else { -this.operation = null; -this.range = null; -this.length = 0; -if (this._setSeq (seq, false, 0, 0)) { -throw new Error (jalview.util.MessageManager.getString ("error.not_yet_implemented_cigar_object_from_cigar_string")); -}}}, "jalview.datamodel.SequenceI,~A,~A"); -Clazz.defineMethod (c$, "addMatch", -function (range) { -this.addOperation ('M', range); -}, "~N"); -c$.addSequenceOps = Clazz.defineMethod (c$, "addSequenceOps", -function (cigar, seq, startpos, endpos, initialDeletions) { -var op = '\u0000'; -var range = 0; -var p = 0; -var res = seq.getLength (); -if (!initialDeletions) { -p = startpos; -}while (p <= endpos) { -var isGap = (p < res) ? jalview.util.Comparison.isGap (seq.getCharAt (p)) : true; -if ((startpos <= p) && (p <= endpos)) { -if (isGap) { -if (range > 0 && op != 'I') { -cigar.addOperation (op, range); -range = 0; -}op = 'I'; -range++; -} else { -if (range > 0 && op != 'M') { -cigar.addOperation (op, range); -range = 0; -}op = 'M'; -range++; -}} else { -if (!isGap) { -if (range > 0 && op != 'D') { -cigar.addOperation (op, range); -range = 0; -}op = 'D'; -range++; -} else { -}}p++; -} -if (range > 0) { -cigar.addOperation (op, range); -}}, "jalview.datamodel.CigarBase,jalview.datamodel.SequenceI,~N,~N,~B"); -Clazz.makeConstructor (c$, -function (seq) { -Clazz.superConstructor (this, jalview.datamodel.SeqCigar); -if (seq == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_for_new_cigar")); -}this._setSeq (seq, false, 0, 0); -jalview.datamodel.SeqCigar.addSequenceOps (this, seq, 0, seq.getLength () - 1, false); -}, "jalview.datamodel.SequenceI"); -Clazz.makeConstructor (c$, -function (seq, start, end) { -Clazz.superConstructor (this, jalview.datamodel.SeqCigar); -if (seq == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_for_new_cigar")); -}this._setSeq (seq, false, start, end + 1); -jalview.datamodel.SeqCigar.addSequenceOps (this, seq, start, end, false); -}, "jalview.datamodel.SequenceI,~N,~N"); -c$.parseCigar = Clazz.defineMethod (c$, "parseCigar", -function (seq, cigarString) { -var opsandrange = jalview.datamodel.CigarBase.parseCigarString (cigarString); -return new jalview.datamodel.SeqCigar (seq, opsandrange[0], opsandrange[1]); -}, "jalview.datamodel.SequenceI,~S"); -c$.createAlignmentSequences = Clazz.defineMethod (c$, "createAlignmentSequences", -function (alseqs, gapCharacter, colsel, segments) { -var seqs = new Array (alseqs.length); -var g_seqs = new Array (alseqs.length); -var alseqs_string = new Array (alseqs.length); -var gs_regions = new Array (alseqs.length); -for (var i = 0; i < alseqs.length; i++) { -alseqs_string[i] = alseqs[i].getRefSeq ().getSequenceAsString (alseqs[i].start, alseqs[i].end); -gs_regions[i] = alseqs[i].getSequenceAndDeletions (alseqs_string[i], gapCharacter); -if (gs_regions[i] == null) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cigar_seq_no_operations", Clazz.newArray (-1, [Integer.$valueOf (i).toString ()]))); -}g_seqs[i] = new StringBuffer ((gs_regions[i])[0]); -} -var shifts = new jalview.util.ShiftList (); -for (var i = 0; i < alseqs.length; i++) { -var gs_region = ((gs_regions[i])[2]); -if (gs_region != null) { -for (var hr = 0; hr < gs_region.length; hr++) { -var region = gs_region[hr]; -var insert = Clazz.newCharArray (region[1] - region[0] + 1, '\0'); -for (var s = 0; s < insert.length; s++) { -insert[s] = gapCharacter; -} -var inspos = shifts.shift (region[2]); -for (var s = 0; s < alseqs.length; s++) { -if (s != i) { -if (g_seqs[s].length () <= inspos) { -for (var l = inspos - g_seqs[s].length (); l > 0; l--) { -g_seqs[s].append (gapCharacter); -} -}g_seqs[s].insert (inspos, insert); -} else { -g_seqs[s].insert (inspos, alseqs_string[i].substring (region[0], region[1] + 1)); -}} -shifts.addShift (region[2], insert.length); -if (segments == null) { -colsel.hideColumns (inspos, inspos + insert.length - 1); -}} -}} -for (var i = 0; i < alseqs.length; i++) { -var bounds = ((gs_regions[i])[1]); -var ref = alseqs[i].getRefSeq (); -seqs[i] = new jalview.datamodel.Sequence (ref.getName (), g_seqs[i].toString (), ref.getStart () + alseqs[i].start + bounds[0], ref.getStart () + alseqs[i].start + (bounds[2] == 0 ? -1 : bounds[2])); -seqs[i].setDatasetSequence (ref); -seqs[i].setDescription (ref.getDescription ()); -} -if (segments != null) { -for (var i = 0; i < segments.length; i += 3) { -colsel.hideColumns (segments[i + 1], segments[i + 1] + segments[i + 2] - 1); -} -}return seqs; -}, "~A,~S,jalview.datamodel.ColumnSelection,~A"); -Clazz.defineMethod (c$, "setGroupMembership", -function (group) { -if (this.selGroups == null) { -this.selGroups = new java.util.Hashtable (); -}this.selGroups.put (group, Clazz.newIntArray (0, 0)); -}, "~O"); -Clazz.defineMethod (c$, "removeGroupMembership", -function (group) { -if (this.selGroups != null && this.selGroups.containsKey (group)) { -this.selGroups.remove (group); -return true; -}return false; -}, "~O"); -Clazz.defineMethod (c$, "clearMemberships", -function () { -if (this.selGroups != null) { -this.selGroups.clear (); -}this.selGroups = null; -}); -Clazz.defineMethod (c$, "getAllMemberships", -function () { -if (this.selGroups == null) { -return null; -}var mmbs = new Array (this.selGroups.size ()); -var en = this.selGroups.keys (); -for (var i = 0; en.hasMoreElements (); i++) { -mmbs[i] = en.nextElement (); -} -return mmbs; -}); -Clazz.defineMethod (c$, "isMemberOf", -function (sgr) { -return (this.selGroups != null) && this.selGroups.get (sgr) != null; -}, "~O"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.CigarSimple"], "jalview.datamodel.SeqCigar", ["jalview.analysis.AlignSeq", "$.SeqsetUtils", "jalview.datamodel.Sequence", "jalview.util.Comparison", "$.MessageManager", "$.ShiftList", "java.lang.Error", "$.StringBuffer", "java.util.Hashtable"], function () { +c$ = Clazz.decorateAsClass (function () { +this.start = 0; +this.end = 0; +this.refseq = null; +this.seqProps = null; +this.selGroups = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SeqCigar", jalview.datamodel.CigarSimple); +Clazz.defineMethod (c$, "getRefSeq", +function () { +return this.refseq; +}); +Clazz.defineMethod (c$, "getStart", +function () { +return this.start; +}); +Clazz.defineMethod (c$, "getEnd", +function () { +return this.end; +}); +Clazz.overrideMethod (c$, "getSequenceString", +function (GapChar) { +return (this.length == 0) ? "" : this.getSequenceAndDeletions (this.refseq.getSequenceAsString (this.start, this.end), GapChar)[0]; +}, "~S"); +Clazz.defineMethod (c$, "getSeq", +function (GapChar) { +var seq; +if (this.refseq == null || this.length == 0) { +return null; +}var edit_result = this.getSequenceAndDeletions (this.refseq.getSequenceAsString (this.start, this.end), GapChar); +if (edit_result == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_unexpected_null_from_get_sequence_and_deletions")); +}var bounds = edit_result[1]; +seq = new jalview.datamodel.Sequence (this.refseq.getName (), edit_result[0], this.refseq.getStart () + this.start + bounds[0], this.refseq.getStart () + this.start + ((bounds[2] == 0) ? -1 : bounds[2])); +seq.setDescription (this.refseq.getDescription ()); +var sstart = seq.getStart (); +var send = seq.getEnd (); +if (this.seqProps != null) { +jalview.analysis.SeqsetUtils.SeqCharacterUnhash (seq, this.seqProps); +}seq.setDatasetSequence (this.refseq); +seq.setStart (sstart); +seq.setEnd (send); +return seq; +}, "~S"); +Clazz.defineMethod (c$, "_setSeq", +($fz = function (seq, initialDeletion, _s, _e) { +var hasgaps = false; +if (seq == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_set_seq_null")); +}if (_s < 0) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_s", Clazz.newArray (-1, [Integer.$valueOf (_s).toString ()]))); +}var seq_string = seq.getSequenceAsString (); +if (_e == 0 || _e < _s || _e > seq_string.length) { +_e = seq_string.length; +}this.start = seq.findPosition (_s) - seq.getStart (); +this.end = seq.findPosition (_e) - seq.getStart (); +var l_ungapped = this.end - this.start; +var ds = seq.getDatasetSequence (); +if (ds == null) { +var ungapped = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (seq_string)); +l_ungapped = ungapped.length; +if (l_ungapped == seq.getLength ()) { +ds = seq; +} else { +ds = new jalview.datamodel.Sequence (seq.getName (), ungapped, seq.getStart (), seq.getStart () + ungapped.length - 1); +}}if (ds.getStart () < seq.getStart ()) { +var offset = seq.getStart () - ds.getStart (); +if (initialDeletion) { +this.addDeleted (_s + offset); +this.start = 0; +this.end += offset; +} else { +this.start += offset; +this.end += offset; +}}if (l_ungapped != (_e - _s)) { +hasgaps = true; +}this.refseq = ds; +this.seqProps = jalview.analysis.SeqsetUtils.SeqCharacterHash (seq); +if (this.end > ds.getLength ()) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_seqcigar_possible")); +}return hasgaps; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,~B,~N,~N"); +Clazz.makeConstructor (c$, +function (seq, operation, range) { +Clazz.superConstructor (this, jalview.datamodel.SeqCigar); +if (seq == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implmentation_bug_seq_null")); +}if (operation.length != range.length) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_bug_cigar_operation_list_range_list")); +}if (operation != null) { +this.operation = Clazz.newCharArray (operation.length + this._inc_length, '\0'); +this.range = Clazz.newIntArray (operation.length + this._inc_length, 0); +if (this._setSeq (seq, false, 0, 0)) { +throw new Error (jalview.util.MessageManager.getString ("error.not_yet_implemented_cigar_object_from_cigar_string")); +}for (var i = this.length, j = 0; j < operation.length; i++, j++) { +var op = operation[j]; +if (op != 'M' && op != 'I' && op != 'D') { +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_bug_cigar_operation", Clazz.newArray (-1, [Integer.$valueOf (j).toString (), Integer.$valueOf (op.charCodeAt (0)).toString (), Integer.$valueOf ('M'.charCodeAt (0)).toString (), Integer.$valueOf ('I'.charCodeAt (0)).toString (), Integer.$valueOf ('D'.charCodeAt (0)).toString ()]))); +}this.operation[i] = op; +this.range[i] = range[j]; +} +this.length += operation.length; +} else { +this.operation = null; +this.range = null; +this.length = 0; +if (this._setSeq (seq, false, 0, 0)) { +throw new Error (jalview.util.MessageManager.getString ("error.not_yet_implemented_cigar_object_from_cigar_string")); +}}}, "jalview.datamodel.SequenceI,~A,~A"); +Clazz.defineMethod (c$, "addMatch", +function (range) { +this.addOperation ('M', range); +}, "~N"); +c$.addSequenceOps = Clazz.defineMethod (c$, "addSequenceOps", +function (cigar, seq, startpos, endpos, initialDeletions) { +var op = '\u0000'; +var range = 0; +var p = 0; +var res = seq.getLength (); +if (!initialDeletions) { +p = startpos; +}while (p <= endpos) { +var isGap = (p < res) ? jalview.util.Comparison.isGap (seq.getCharAt (p)) : true; +if ((startpos <= p) && (p <= endpos)) { +if (isGap) { +if (range > 0 && op != 'I') { +cigar.addOperation (op, range); +range = 0; +}op = 'I'; +range++; +} else { +if (range > 0 && op != 'M') { +cigar.addOperation (op, range); +range = 0; +}op = 'M'; +range++; +}} else { +if (!isGap) { +if (range > 0 && op != 'D') { +cigar.addOperation (op, range); +range = 0; +}op = 'D'; +range++; +} else { +}}p++; +} +if (range > 0) { +cigar.addOperation (op, range); +}}, "jalview.datamodel.CigarBase,jalview.datamodel.SequenceI,~N,~N,~B"); +Clazz.makeConstructor (c$, +function (seq) { +Clazz.superConstructor (this, jalview.datamodel.SeqCigar); +if (seq == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_for_new_cigar")); +}this._setSeq (seq, false, 0, 0); +jalview.datamodel.SeqCigar.addSequenceOps (this, seq, 0, seq.getLength () - 1, false); +}, "jalview.datamodel.SequenceI"); +Clazz.makeConstructor (c$, +function (seq, start, end) { +Clazz.superConstructor (this, jalview.datamodel.SeqCigar); +if (seq == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_for_new_cigar")); +}this._setSeq (seq, false, start, end + 1); +jalview.datamodel.SeqCigar.addSequenceOps (this, seq, start, end, false); +}, "jalview.datamodel.SequenceI,~N,~N"); +c$.parseCigar = Clazz.defineMethod (c$, "parseCigar", +function (seq, cigarString) { +var opsandrange = jalview.datamodel.CigarBase.parseCigarString (cigarString); +return new jalview.datamodel.SeqCigar (seq, opsandrange[0], opsandrange[1]); +}, "jalview.datamodel.SequenceI,~S"); +c$.createAlignmentSequences = Clazz.defineMethod (c$, "createAlignmentSequences", +function (alseqs, gapCharacter, colsel, segments) { +var seqs = new Array (alseqs.length); +var g_seqs = new Array (alseqs.length); +var alseqs_string = new Array (alseqs.length); +var gs_regions = new Array (alseqs.length); +for (var i = 0; i < alseqs.length; i++) { +alseqs_string[i] = alseqs[i].getRefSeq ().getSequenceAsString (alseqs[i].start, alseqs[i].end); +gs_regions[i] = alseqs[i].getSequenceAndDeletions (alseqs_string[i], gapCharacter); +if (gs_regions[i] == null) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cigar_seq_no_operations", Clazz.newArray (-1, [Integer.$valueOf (i).toString ()]))); +}g_seqs[i] = new StringBuffer ((gs_regions[i])[0]); +} +var shifts = new jalview.util.ShiftList (); +for (var i = 0; i < alseqs.length; i++) { +var gs_region = ((gs_regions[i])[2]); +if (gs_region != null) { +for (var hr = 0; hr < gs_region.length; hr++) { +var region = gs_region[hr]; +var insert = Clazz.newCharArray (region[1] - region[0] + 1, '\0'); +for (var s = 0; s < insert.length; s++) { +insert[s] = gapCharacter; +} +var inspos = shifts.shift (region[2]); +for (var s = 0; s < alseqs.length; s++) { +if (s != i) { +if (g_seqs[s].length () <= inspos) { +for (var l = inspos - g_seqs[s].length (); l > 0; l--) { +g_seqs[s].append (gapCharacter); +} +}g_seqs[s].insert (inspos, insert); +} else { +g_seqs[s].insert (inspos, alseqs_string[i].substring (region[0], region[1] + 1)); +}} +shifts.addShift (region[2], insert.length); +if (segments == null) { +colsel.hideColumns (inspos, inspos + insert.length - 1); +}} +}} +for (var i = 0; i < alseqs.length; i++) { +var bounds = ((gs_regions[i])[1]); +var ref = alseqs[i].getRefSeq (); +seqs[i] = new jalview.datamodel.Sequence (ref.getName (), g_seqs[i].toString (), ref.getStart () + alseqs[i].start + bounds[0], ref.getStart () + alseqs[i].start + (bounds[2] == 0 ? -1 : bounds[2])); +seqs[i].setDatasetSequence (ref); +seqs[i].setDescription (ref.getDescription ()); +} +if (segments != null) { +for (var i = 0; i < segments.length; i += 3) { +colsel.hideColumns (segments[i + 1], segments[i + 1] + segments[i + 2] - 1); +} +}return seqs; +}, "~A,~S,jalview.datamodel.ColumnSelection,~A"); +Clazz.defineMethod (c$, "setGroupMembership", +function (group) { +if (this.selGroups == null) { +this.selGroups = new java.util.Hashtable (); +}this.selGroups.put (group, Clazz.newIntArray (0, 0)); +}, "~O"); +Clazz.defineMethod (c$, "removeGroupMembership", +function (group) { +if (this.selGroups != null && this.selGroups.containsKey (group)) { +this.selGroups.remove (group); +return true; +}return false; +}, "~O"); +Clazz.defineMethod (c$, "clearMemberships", +function () { +if (this.selGroups != null) { +this.selGroups.clear (); +}this.selGroups = null; +}); +Clazz.defineMethod (c$, "getAllMemberships", +function () { +if (this.selGroups == null) { +return null; +}var mmbs = new Array (this.selGroups.size ()); +var en = this.selGroups.keys (); +for (var i = 0; en.hasMoreElements (); i++) { +mmbs[i] = en.nextElement (); +} +return mmbs; +}); +Clazz.defineMethod (c$, "isMemberOf", +function (sgr) { +return (this.selGroups != null) && this.selGroups.get (sgr) != null; +}, "~O"); +}); diff --git a/bin/jalview/datamodel/Sequence.js b/bin/jalview/datamodel/Sequence.js index 06c8329..6a15091 100644 --- a/bin/jalview/datamodel/Sequence.js +++ b/bin/jalview/datamodel/Sequence.js @@ -1,658 +1,658 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.ASequence", "$.SequenceI", "jalview.jsdev.RegExp"], "jalview.datamodel.Sequence", ["jalview.analysis.AlignSeq", "jalview.datamodel.AlignmentAnnotation", "$.DBRefEntry", "$.DBRefSource", "$.PDBEntry", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.StringUtils", "java.lang.StringBuffer", "java.util.ArrayList", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.datasetSequence = null; -this.name = null; -this.sequence = null; -this.description = null; -this.start = 0; -this.end = 0; -this.pdbIds = null; -this.vamsasId = null; -this.dbrefs = null; -this.rna = null; -this.annotation = null; -this.index = -1; -this.sequenceFeatures = null; -this.limitrx = null; -this.endrx = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "Sequence", jalview.datamodel.ASequence, jalview.datamodel.SequenceI); -Clazz.prepareFields (c$, function () { -this.limitrx = jalview.jsdev.RegExp.newRegex (["[/][0-9]{1,}[-][0-9]{1,}$"]); -this.endrx = jalview.jsdev.RegExp.newRegex (["[0-9]{1,}$"]); -}); -Clazz.makeConstructor (c$, -function (name, sequence, start, end) { -Clazz.superConstructor (this, jalview.datamodel.Sequence, []); -this.initSeqAndName (name, sequence.toCharArray (), start, end); -}, "~S,~S,~N,~N"); -Clazz.makeConstructor (c$, -function (name, sequence, start, end) { -Clazz.superConstructor (this, jalview.datamodel.Sequence, []); -this.initSeqAndName (name, sequence, start, end); -}, "~S,~A,~N,~N"); -Clazz.defineMethod (c$, "initSeqAndName", -function (name2, sequence2, start2, end2) { -this.name = name2; -this.sequence = sequence2; -this.start = start2; -this.end = end2; -this.parseId (); -this.checkValidRange (); -}, "~S,~A,~N,~N"); -Clazz.defineMethod (c$, "parseId", -function () { -if (this.name == null) { -System.err.println ("POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor."); -this.name = ""; -}if (this.limitrx.search (this.name)) { -this.name = this.limitrx.left (); -this.endrx.search (this.limitrx.stringMatched ()); -this.setStart (Integer.parseInt (this.limitrx.stringMatched ().substring (1, this.endrx.matchedFrom () - 1))); -this.setEnd (Integer.parseInt (this.endrx.stringMatched ())); -}}); -Clazz.defineMethod (c$, "checkValidRange", -function () { -{ -var endRes = 0; -for (var j = 0; j < this.sequence.length; j++) { -if (!jalview.util.Comparison.isGap (this.sequence[j])) { -endRes++; -}} -if (endRes > 0) { -endRes += this.start - 1; -}if (this.end < endRes) { -this.end = endRes; -}}}); -Clazz.makeConstructor (c$, -function (name, sequence) { -this.construct (name, sequence, 1, -1); -}, "~S,~S"); -Clazz.makeConstructor (c$, -function (seq) { -this.construct (seq, seq.getAnnotation ()); -}, "jalview.datamodel.SequenceI"); -Clazz.makeConstructor (c$, -function (seq, alAnnotation) { -Clazz.superConstructor (this, jalview.datamodel.Sequence, []); -this.initSeqFrom (seq, alAnnotation); -}, "jalview.datamodel.SequenceI,~A"); -Clazz.defineMethod (c$, "initSeqFrom", -function (seq, alAnnotation) { -this.initSeqAndName (seq.getName (), seq.getSequence (), seq.getStart (), seq.getEnd ()); -this.description = seq.getDescription (); -if (seq.getSequenceFeatures () != null) { -var sf = seq.getSequenceFeatures (); -for (var i = 0; i < sf.length; i++) { -this.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf[i])); -} -}this.setDatasetSequence (seq.getDatasetSequence ()); -if (this.datasetSequence == null && seq.getDBRef () != null) { -var dbr = seq.getDBRef (); -for (var i = 0; i < dbr.length; i++) { -this.addDBRef ( new jalview.datamodel.DBRefEntry (dbr[i])); -} -}if (seq.getAnnotation () != null) { -var sqann = seq.getAnnotation (); -for (var i = 0; i < sqann.length; i++) { -if (sqann[i] == null) { -continue; -}var found = (alAnnotation == null); -if (!found) { -for (var apos = 0; !found && apos < alAnnotation.length; apos++) { -found = (alAnnotation[apos] === sqann[i]); -} -}if (found) { -var newann = new jalview.datamodel.AlignmentAnnotation (sqann[i]); -this.addAlignmentAnnotation (newann); -}} -}if (seq.getPDBId () != null) { -var ids = seq.getPDBId (); -var e = ids.elements (); -while (e.hasMoreElements ()) { -this.addPDBId ( new jalview.datamodel.PDBEntry (e.nextElement ())); -} -}}, "jalview.datamodel.SequenceI,~A"); -Clazz.defineMethod (c$, "setSequenceFeatures", -function (features) { -this.sequenceFeatures = features; -}, "~A"); -Clazz.overrideMethod (c$, "addSequenceFeature", -function (sf) { -if (this.sequenceFeatures == null) { -this.sequenceFeatures = new Array (0); -}for (var i = 0; i < this.sequenceFeatures.length; i++) { -if (this.sequenceFeatures[i].equals (sf)) { -return; -}} -var temp = new Array (this.sequenceFeatures.length + 1); -System.arraycopy (this.sequenceFeatures, 0, temp, 0, this.sequenceFeatures.length); -temp[this.sequenceFeatures.length] = sf; -this.sequenceFeatures = temp; -}, "jalview.datamodel.SequenceFeature"); -Clazz.overrideMethod (c$, "deleteFeature", -function (sf) { -if (this.sequenceFeatures == null) { -return; -}var index = 0; -for (index = 0; index < this.sequenceFeatures.length; index++) { -if (this.sequenceFeatures[index].equals (sf)) { -break; -}} -if (index == this.sequenceFeatures.length) { -return; -}var sfLength = this.sequenceFeatures.length; -if (sfLength < 2) { -this.sequenceFeatures = null; -} else { -var temp = new Array (sfLength - 1); -System.arraycopy (this.sequenceFeatures, 0, temp, 0, index); -if (index < sfLength) { -System.arraycopy (this.sequenceFeatures, index + 1, temp, index, this.sequenceFeatures.length - index - 1); -}this.sequenceFeatures = temp; -}}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "getSequenceFeatures", -function () { -var features = this.sequenceFeatures; -var seq = this; -var count = 0; -while (features == null && seq.getDatasetSequence () != null && count++ < 10) { -seq = seq.getDatasetSequence (); -features = (seq).sequenceFeatures; -} -return features; -}); -Clazz.overrideMethod (c$, "addPDBId", -function (entry) { -if (this.pdbIds == null) { -this.pdbIds = new java.util.Vector (); -}if (this.pdbIds.contains (entry)) { -jalview.datamodel.Sequence.updatePDBEntry (this.pdbIds.get (this.pdbIds.indexOf (entry)), entry); -} else { -this.pdbIds.addElement (entry); -}}, "jalview.datamodel.PDBEntry"); -c$.updatePDBEntry = Clazz.defineMethod (c$, "updatePDBEntry", -($fz = function (oldEntry, newEntry) { -if (newEntry.getFile () != null) { -oldEntry.setFile (newEntry.getFile ()); -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.PDBEntry,jalview.datamodel.PDBEntry"); -Clazz.defineMethod (c$, "setPDBId", -function (id) { -this.pdbIds = id; -}, "java.util.Vector"); -Clazz.defineMethod (c$, "getPDBId", -function () { -return this.pdbIds; -}); -Clazz.overrideMethod (c$, "getDisplayId", -function (jvsuffix) { -var result = new StringBuffer (this.name); -if (jvsuffix) { -result.append ("/" + this.start + "-" + this.end); -}return result.toString (); -}, "~B"); -Clazz.overrideMethod (c$, "setName", -function (name) { -this.name = name; -this.parseId (); -}, "~S"); -Clazz.defineMethod (c$, "getName", -function () { -return this.name; -}); -Clazz.overrideMethod (c$, "setStart", -function (start) { -this.start = start; -}, "~N"); -Clazz.defineMethod (c$, "getStart", -function () { -return this.start; -}); -Clazz.overrideMethod (c$, "setEnd", -function (end) { -this.end = end; -}, "~N"); -Clazz.defineMethod (c$, "getEnd", -function () { -return this.end; -}); -Clazz.overrideMethod (c$, "getLength", -function () { -return this.sequence.length; -}); -Clazz.defineMethod (c$, "setSequence", -function (seq) { -this.sequence = seq.toCharArray (); -this.checkValidRange (); -}, "~S"); -Clazz.defineMethod (c$, "getSequenceAsString", -function () { -return String.instantialize (this.sequence); -}); -Clazz.defineMethod (c$, "getSequenceAsString", -function (start, end) { -return String.instantialize (this.getSequence (start, end)); -}, "~N,~N"); -Clazz.defineMethod (c$, "getSequence", -function () { -return this.sequence; -}); -Clazz.defineMethod (c$, "getSequence", -function (start, end) { -if (start < 0) { -start = 0; -}if (start >= this.sequence.length) { -return Clazz.newCharArray (0, '\0'); -}if (end >= this.sequence.length) { -end = this.sequence.length; -}var reply = Clazz.newCharArray (end - start, '\0'); -System.arraycopy (this.sequence, start, reply, 0, end - start); -return reply; -}, "~N,~N"); -Clazz.overrideMethod (c$, "getSubSequence", -function (start, end) { -if (start < 0) { -start = 0; -}var seq = this.getSequence (start, end); -if (seq.length == 0) { -return null; -}var nstart = this.findPosition (start); -var nend = this.findPosition (end) - 1; -var nseq = new jalview.datamodel.Sequence (this.getName (), seq, nstart, nend); -nseq.setDescription (this.description); -if (this.datasetSequence != null) { -nseq.setDatasetSequence (this.datasetSequence); -} else { -nseq.setDatasetSequence (this); -}return nseq; -}, "~N,~N"); -Clazz.overrideMethod (c$, "getCharAt", -function (i) { -if (i < this.sequence.length) { -return this.sequence[i]; -} else { -return ' '; -}}, "~N"); -Clazz.defineMethod (c$, "setDescription", -function (desc) { -this.description = desc; -}, "~S"); -Clazz.defineMethod (c$, "getDescription", -function () { -return this.description; -}); -Clazz.overrideMethod (c$, "findIndex", -function (pos) { -var j = this.start; -var i = 0; -while ((i < this.sequence.length) && (j <= this.end) && (j <= pos)) { -if (!jalview.util.Comparison.isGap (this.sequence[i])) { -j++; -}i++; -} -if ((j == this.end) && (j < pos)) { -return this.end + 1; -} else { -return i; -}}, "~N"); -Clazz.overrideMethod (c$, "findPosition", -function (i) { -var j = 0; -var pos = this.start; -var seqlen = this.sequence.length; -while ((j < i) && (j < seqlen)) { -if (!jalview.util.Comparison.isGap (this.sequence[j])) { -pos++; -}j++; -} -return pos; -}, "~N"); -Clazz.overrideMethod (c$, "gapMap", -function () { -var seq = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (this.sequence)); -var map = Clazz.newIntArray (seq.length, 0); -var j = 0; -var p = 0; -while (j < this.sequence.length) { -if (!jalview.util.Comparison.isGap (this.sequence[j])) { -map[p++] = j; -}j++; -} -return map; -}); -Clazz.overrideMethod (c$, "findPositionMap", -function () { -var map = Clazz.newIntArray (this.sequence.length, 0); -var j = 0; -var pos = this.start; -var seqlen = this.sequence.length; -while ((j < seqlen)) { -map[j] = pos; -if (!jalview.util.Comparison.isGap (this.sequence[j])) { -pos++; -}j++; -} -return map; -}); -Clazz.overrideMethod (c$, "getInsertions", -function () { -var map = new java.util.ArrayList (); -var lastj = -1; -var j = 0; -var pos = this.start; -var seqlen = this.sequence.length; -while ((j < seqlen)) { -if (jalview.util.Comparison.isGap (this.sequence[j])) { -if (lastj == -1) { -lastj = j; -}} else { -if (lastj != -1) { -map.add ( Clazz.newIntArray (-1, [lastj, j - 1])); -lastj = -1; -}}j++; -} -if (lastj != -1) { -map.add ( Clazz.newIntArray (-1, [lastj, j - 1])); -lastj = -1; -}return map; -}); -Clazz.overrideMethod (c$, "deleteChars", -function (i, j) { -var newstart = this.start; -var newend = this.end; -if (i >= this.sequence.length || i < 0) { -return; -}var tmp = jalview.util.StringUtils.deleteChars (this.sequence, i, j); -var createNewDs = false; -var eindex = -1; -var sindex = -1; -var ecalc = false; -var scalc = false; -for (var s = i; s < j; s++) { -if (jalview.schemes.ResidueProperties.aaIndex[this.sequence[s].charCodeAt (0)] != 23) { -if (createNewDs) { -newend--; -} else { -if (!scalc) { -sindex = this.findIndex (this.start) - 1; -scalc = true; -}if (sindex == s) { -newstart = this.findPosition (j); -break; -} else { -if (!ecalc) { -eindex = this.findIndex (this.end) - 1; -ecalc = true; -}if (eindex < j) { -newend = this.findPosition (i - 1); -break; -} else { -createNewDs = true; -newend--; -}}}}} -if (createNewDs && this.datasetSequence != null) { -var ds = new jalview.datamodel.Sequence (this.datasetSequence); -ds.deleteChars (i, j); -this.datasetSequence = ds; -}this.start = newstart; -this.end = newend; -this.sequence = tmp; -}, "~N,~N"); -Clazz.defineMethod (c$, "insertCharAt", -function (i, length, c) { -var tmp = Clazz.newCharArray (this.sequence.length + length, '\0'); -if (i >= this.sequence.length) { -System.arraycopy (this.sequence, 0, tmp, 0, this.sequence.length); -i = this.sequence.length; -} else { -System.arraycopy (this.sequence, 0, tmp, 0, i); -}var index = i; -while (length > 0) { -tmp[index++] = c; -length--; -} -if (i < this.sequence.length) { -System.arraycopy (this.sequence, i, tmp, index, this.sequence.length - i); -}this.sequence = tmp; -}, "~N,~N,~S"); -Clazz.defineMethod (c$, "insertCharAt", -function (i, c) { -this.insertCharAt (i, 1, c); -}, "~N,~S"); -Clazz.overrideMethod (c$, "getVamsasId", -function () { -return this.vamsasId; -}); -Clazz.overrideMethod (c$, "setVamsasId", -function (id) { -this.vamsasId = id; -}, "~S"); -Clazz.defineMethod (c$, "setDBRef", -function (dbref) { -this.dbrefs = dbref; -}, "~A"); -Clazz.defineMethod (c$, "getDBRef", -function () { -if (this.dbrefs == null && this.datasetSequence != null && this !== this.datasetSequence) { -return this.datasetSequence.getDBRef (); -}return this.dbrefs; -}); -Clazz.overrideMethod (c$, "addDBRef", -function (entry) { -if (this.dbrefs == null) { -this.dbrefs = new Array (0); -}var i; -var iSize = this.dbrefs.length; -for (i = 0; i < iSize; i++) { -if (this.dbrefs[i].equalRef (entry)) { -if (entry.getMap () != null) { -if (this.dbrefs[i].getMap () == null) { -this.dbrefs[i] = entry; -}}return; -}} -var temp = new Array (iSize + 1); -System.arraycopy (this.dbrefs, 0, temp, 0, iSize); -temp[temp.length - 1] = entry; -this.dbrefs = temp; -}, "jalview.datamodel.DBRefEntry"); -Clazz.defineMethod (c$, "setDatasetSequence", -function (seq) { -this.datasetSequence = seq; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getDatasetSequence", -function () { -return this.datasetSequence; -}); -Clazz.defineMethod (c$, "getAnnotation", -function () { -return this.annotation == null ? null : this.annotation.toArray ( new Array (this.annotation.size ())); -}); -Clazz.overrideMethod (c$, "hasAnnotation", -function (ann) { -return this.annotation == null ? false : this.annotation.contains (ann); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "addAlignmentAnnotation", -function (annotation) { -if (this.annotation == null) { -this.annotation = new java.util.Vector (); -}if (!this.annotation.contains (annotation)) { -this.annotation.addElement (annotation); -}annotation.setSequenceRef (this); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "removeAlignmentAnnotation", -function (annotation) { -if (this.annotation != null) { -this.annotation.removeElement (annotation); -if (this.annotation.size () == 0) { -this.annotation = null; -}}}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "isValidDatasetSequence", -($fz = function () { -if (this.datasetSequence != null) { -return false; -}for (var i = 0; i < this.sequence.length; i++) { -if (jalview.util.Comparison.isGap (this.sequence[i])) { -return false; -}} -return true; -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "deriveSequence", -function () { -var seq = new jalview.datamodel.Sequence (this); -if (this.datasetSequence != null) { -seq.setDatasetSequence (this.datasetSequence); -} else { -if (this.isValidDatasetSequence ()) { -seq.setDatasetSequence (this); -} else { -var ds = seq; -ds.setSequence (jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (this.sequence))); -this.setDatasetSequence (ds); -ds.setSequenceFeatures (this.getSequenceFeatures ()); -seq = this; -}}return seq; -}); -Clazz.overrideMethod (c$, "createDatasetSequence", -function () { -if (this.datasetSequence == null) { -this.datasetSequence = new jalview.datamodel.Sequence (this.getName (), jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, this.getSequenceAsString ()), this.getStart (), this.getEnd ()); -this.datasetSequence.setSequenceFeatures (this.getSequenceFeatures ()); -this.datasetSequence.setDescription (this.getDescription ()); -this.setSequenceFeatures (null); -this.datasetSequence.setDBRef (this.getDBRef ()); -this.setDBRef (null); -this.datasetSequence.setPDBId (this.getPDBId ()); -this.setPDBId (null); -this.datasetSequence.updatePDBIds (); -if (this.annotation != null) { -for (var aa, $aa = this.annotation.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { -var _aa = new jalview.datamodel.AlignmentAnnotation (aa); -_aa.sequenceRef = this.datasetSequence; -_aa.adjustForAlignment (); -this.datasetSequence.addAlignmentAnnotation (_aa); -} -}}return this.datasetSequence; -}); -Clazz.overrideMethod (c$, "setAlignmentAnnotation", -function (annotations) { -if (this.annotation != null) { -this.annotation.removeAllElements (); -}if (annotations != null) { -for (var i = 0; i < annotations.length; i++) { -if (annotations[i] != null) { -this.addAlignmentAnnotation (annotations[i]); -}} -}}, "~A"); -Clazz.defineMethod (c$, "getAnnotation", -function (label) { -if (this.annotation == null || this.annotation.size () == 0) { -return null; -}var subset = new java.util.Vector (); -var e = this.annotation.elements (); -while (e.hasMoreElements ()) { -var ann = e.nextElement (); -if (ann.label != null && ann.label.equals (label)) { -subset.addElement (ann); -}} -if (subset.size () == 0) { -return null; -}var anns = new Array (subset.size ()); -var i = 0; -e = subset.elements (); -while (e.hasMoreElements ()) { -anns[i++] = e.nextElement (); -} -subset.removeAllElements (); -return anns; -}, "~S"); -Clazz.defineMethod (c$, "updatePDBIds", -function () { -if (this.datasetSequence != null) { -return this.datasetSequence.updatePDBIds (); -}if (this.dbrefs == null || this.dbrefs.length == 0) { -return false; -}var newpdb = new java.util.Vector (); -for (var i = 0; i < this.dbrefs.length; i++) { -if (jalview.datamodel.DBRefSource.PDB.equals (this.dbrefs[i].getSource ())) { -var pdbe = new jalview.datamodel.PDBEntry (); -pdbe.setId (this.dbrefs[i].getAccessionId ()); -if (this.pdbIds == null || this.pdbIds.size () == 0) { -newpdb.addElement (pdbe); -} else { -var en = this.pdbIds.elements (); -var matched = false; -while (!matched && en.hasMoreElements ()) { -var anentry = en.nextElement (); -if (anentry.getId ().equals (pdbe.getId ())) { -matched = true; -}} -if (!matched) { -newpdb.addElement (pdbe); -}}}} -if (newpdb.size () > 0) { -var en = newpdb.elements (); -while (en.hasMoreElements ()) { -this.addPDBId (en.nextElement ()); -} -return true; -}return false; -}); -Clazz.defineMethod (c$, "transferAnnotation", -function (entry, mp) { -if (this.datasetSequence != null) { -this.datasetSequence.transferAnnotation (entry, mp); -return; -}if (entry.getDatasetSequence () != null) { -this.transferAnnotation (entry.getDatasetSequence (), mp); -return; -}if (entry.getSequenceFeatures () != null) { -var sfs = entry.getSequenceFeatures (); -for (var si = 0; si < sfs.length; si++) { -var sf = (mp != null) ? mp.locateFeature (sfs[si]) : Clazz.newArray (-1, [ new jalview.datamodel.SequenceFeature (sfs[si])]); -if (sf != null && sf.length > 0) { -for (var sfi = 0; sfi < sf.length; sfi++) { -this.addSequenceFeature (sf[sfi]); -} -}} -}if (entry.getPDBId () != null) { -var e = entry.getPDBId ().elements (); -while (e.hasMoreElements ()) { -var pdb = e.nextElement (); -this.addPDBId (pdb); -} -}var entryRefs = entry.getDBRef (); -if (entryRefs != null) { -for (var r = 0; r < entryRefs.length; r++) { -var newref = new jalview.datamodel.DBRefEntry (entryRefs[r]); -if (newref.getMap () != null && mp != null) { -}this.addDBRef (newref); -} -}}, "jalview.datamodel.SequenceI,jalview.datamodel.Mapping"); -Clazz.overrideMethod (c$, "getIndex", -function () { -return this.index; -}); -Clazz.overrideMethod (c$, "setIndex", -function (value) { -this.index = value; -}, "~N"); -Clazz.overrideMethod (c$, "setRNA", -function (r) { -this.rna = r; -}, "jalview.jsdev.api.VarnaRNA"); -Clazz.overrideMethod (c$, "getRNA", -function () { -return this.rna; -}); -Clazz.overrideMethod (c$, "getAlignmentAnnotations", -function (calcId, label) { -var result = new java.util.ArrayList (); -if (this.annotation != null) { -for (var ann, $ann = this.annotation.iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) { -if (ann.calcId != null && ann.calcId.equals (calcId) && ann.label != null && ann.label.equals (label)) { -result.add (ann); -}} -}return result; -}, "~S,~S"); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.ASequence", "$.SequenceI", "jalview.jsdev.RegExp"], "jalview.datamodel.Sequence", ["jalview.analysis.AlignSeq", "jalview.datamodel.AlignmentAnnotation", "$.DBRefEntry", "$.DBRefSource", "$.PDBEntry", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.StringUtils", "java.lang.StringBuffer", "java.util.ArrayList", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.datasetSequence = null; +this.name = null; +this.sequence = null; +this.description = null; +this.start = 0; +this.end = 0; +this.pdbIds = null; +this.vamsasId = null; +this.dbrefs = null; +this.rna = null; +this.annotation = null; +this.index = -1; +this.sequenceFeatures = null; +this.limitrx = null; +this.endrx = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "Sequence", jalview.datamodel.ASequence, jalview.datamodel.SequenceI); +Clazz.prepareFields (c$, function () { +this.limitrx = jalview.jsdev.RegExp.newRegex (["[/][0-9]{1,}[-][0-9]{1,}$"]); +this.endrx = jalview.jsdev.RegExp.newRegex (["[0-9]{1,}$"]); +}); +Clazz.makeConstructor (c$, +function (name, sequence, start, end) { +Clazz.superConstructor (this, jalview.datamodel.Sequence, []); +this.initSeqAndName (name, sequence.toCharArray (), start, end); +}, "~S,~S,~N,~N"); +Clazz.makeConstructor (c$, +function (name, sequence, start, end) { +Clazz.superConstructor (this, jalview.datamodel.Sequence, []); +this.initSeqAndName (name, sequence, start, end); +}, "~S,~A,~N,~N"); +Clazz.defineMethod (c$, "initSeqAndName", +function (name2, sequence2, start2, end2) { +this.name = name2; +this.sequence = sequence2; +this.start = start2; +this.end = end2; +this.parseId (); +this.checkValidRange (); +}, "~S,~A,~N,~N"); +Clazz.defineMethod (c$, "parseId", +function () { +if (this.name == null) { +System.err.println ("POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor."); +this.name = ""; +}if (this.limitrx.search (this.name)) { +this.name = this.limitrx.left (); +this.endrx.search (this.limitrx.stringMatched ()); +this.setStart (Integer.parseInt (this.limitrx.stringMatched ().substring (1, this.endrx.matchedFrom () - 1))); +this.setEnd (Integer.parseInt (this.endrx.stringMatched ())); +}}); +Clazz.defineMethod (c$, "checkValidRange", +function () { +{ +var endRes = 0; +for (var j = 0; j < this.sequence.length; j++) { +if (!jalview.util.Comparison.isGap (this.sequence[j])) { +endRes++; +}} +if (endRes > 0) { +endRes += this.start - 1; +}if (this.end < endRes) { +this.end = endRes; +}}}); +Clazz.makeConstructor (c$, +function (name, sequence) { +this.construct (name, sequence, 1, -1); +}, "~S,~S"); +Clazz.makeConstructor (c$, +function (seq) { +this.construct (seq, seq.getAnnotation ()); +}, "jalview.datamodel.SequenceI"); +Clazz.makeConstructor (c$, +function (seq, alAnnotation) { +Clazz.superConstructor (this, jalview.datamodel.Sequence, []); +this.initSeqFrom (seq, alAnnotation); +}, "jalview.datamodel.SequenceI,~A"); +Clazz.defineMethod (c$, "initSeqFrom", +function (seq, alAnnotation) { +this.initSeqAndName (seq.getName (), seq.getSequence (), seq.getStart (), seq.getEnd ()); +this.description = seq.getDescription (); +if (seq.getSequenceFeatures () != null) { +var sf = seq.getSequenceFeatures (); +for (var i = 0; i < sf.length; i++) { +this.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf[i])); +} +}this.setDatasetSequence (seq.getDatasetSequence ()); +if (this.datasetSequence == null && seq.getDBRef () != null) { +var dbr = seq.getDBRef (); +for (var i = 0; i < dbr.length; i++) { +this.addDBRef ( new jalview.datamodel.DBRefEntry (dbr[i])); +} +}if (seq.getAnnotation () != null) { +var sqann = seq.getAnnotation (); +for (var i = 0; i < sqann.length; i++) { +if (sqann[i] == null) { +continue; +}var found = (alAnnotation == null); +if (!found) { +for (var apos = 0; !found && apos < alAnnotation.length; apos++) { +found = (alAnnotation[apos] === sqann[i]); +} +}if (found) { +var newann = new jalview.datamodel.AlignmentAnnotation (sqann[i]); +this.addAlignmentAnnotation (newann); +}} +}if (seq.getPDBId () != null) { +var ids = seq.getPDBId (); +var e = ids.elements (); +while (e.hasMoreElements ()) { +this.addPDBId ( new jalview.datamodel.PDBEntry (e.nextElement ())); +} +}}, "jalview.datamodel.SequenceI,~A"); +Clazz.defineMethod (c$, "setSequenceFeatures", +function (features) { +this.sequenceFeatures = features; +}, "~A"); +Clazz.overrideMethod (c$, "addSequenceFeature", +function (sf) { +if (this.sequenceFeatures == null) { +this.sequenceFeatures = new Array (0); +}for (var i = 0; i < this.sequenceFeatures.length; i++) { +if (this.sequenceFeatures[i].equals (sf)) { +return; +}} +var temp = new Array (this.sequenceFeatures.length + 1); +System.arraycopy (this.sequenceFeatures, 0, temp, 0, this.sequenceFeatures.length); +temp[this.sequenceFeatures.length] = sf; +this.sequenceFeatures = temp; +}, "jalview.datamodel.SequenceFeature"); +Clazz.overrideMethod (c$, "deleteFeature", +function (sf) { +if (this.sequenceFeatures == null) { +return; +}var index = 0; +for (index = 0; index < this.sequenceFeatures.length; index++) { +if (this.sequenceFeatures[index].equals (sf)) { +break; +}} +if (index == this.sequenceFeatures.length) { +return; +}var sfLength = this.sequenceFeatures.length; +if (sfLength < 2) { +this.sequenceFeatures = null; +} else { +var temp = new Array (sfLength - 1); +System.arraycopy (this.sequenceFeatures, 0, temp, 0, index); +if (index < sfLength) { +System.arraycopy (this.sequenceFeatures, index + 1, temp, index, this.sequenceFeatures.length - index - 1); +}this.sequenceFeatures = temp; +}}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "getSequenceFeatures", +function () { +var features = this.sequenceFeatures; +var seq = this; +var count = 0; +while (features == null && seq.getDatasetSequence () != null && count++ < 10) { +seq = seq.getDatasetSequence (); +features = (seq).sequenceFeatures; +} +return features; +}); +Clazz.overrideMethod (c$, "addPDBId", +function (entry) { +if (this.pdbIds == null) { +this.pdbIds = new java.util.Vector (); +}if (this.pdbIds.contains (entry)) { +jalview.datamodel.Sequence.updatePDBEntry (this.pdbIds.get (this.pdbIds.indexOf (entry)), entry); +} else { +this.pdbIds.addElement (entry); +}}, "jalview.datamodel.PDBEntry"); +c$.updatePDBEntry = Clazz.defineMethod (c$, "updatePDBEntry", +($fz = function (oldEntry, newEntry) { +if (newEntry.getFile () != null) { +oldEntry.setFile (newEntry.getFile ()); +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.PDBEntry,jalview.datamodel.PDBEntry"); +Clazz.defineMethod (c$, "setPDBId", +function (id) { +this.pdbIds = id; +}, "java.util.Vector"); +Clazz.defineMethod (c$, "getPDBId", +function () { +return this.pdbIds; +}); +Clazz.overrideMethod (c$, "getDisplayId", +function (jvsuffix) { +var result = new StringBuffer (this.name); +if (jvsuffix) { +result.append ("/" + this.start + "-" + this.end); +}return result.toString (); +}, "~B"); +Clazz.overrideMethod (c$, "setName", +function (name) { +this.name = name; +this.parseId (); +}, "~S"); +Clazz.defineMethod (c$, "getName", +function () { +return this.name; +}); +Clazz.overrideMethod (c$, "setStart", +function (start) { +this.start = start; +}, "~N"); +Clazz.defineMethod (c$, "getStart", +function () { +return this.start; +}); +Clazz.overrideMethod (c$, "setEnd", +function (end) { +this.end = end; +}, "~N"); +Clazz.defineMethod (c$, "getEnd", +function () { +return this.end; +}); +Clazz.overrideMethod (c$, "getLength", +function () { +return this.sequence.length; +}); +Clazz.defineMethod (c$, "setSequence", +function (seq) { +this.sequence = seq.toCharArray (); +this.checkValidRange (); +}, "~S"); +Clazz.defineMethod (c$, "getSequenceAsString", +function () { +return String.instantialize (this.sequence); +}); +Clazz.defineMethod (c$, "getSequenceAsString", +function (start, end) { +return String.instantialize (this.getSequence (start, end)); +}, "~N,~N"); +Clazz.defineMethod (c$, "getSequence", +function () { +return this.sequence; +}); +Clazz.defineMethod (c$, "getSequence", +function (start, end) { +if (start < 0) { +start = 0; +}if (start >= this.sequence.length) { +return Clazz.newCharArray (0, '\0'); +}if (end >= this.sequence.length) { +end = this.sequence.length; +}var reply = Clazz.newCharArray (end - start, '\0'); +System.arraycopy (this.sequence, start, reply, 0, end - start); +return reply; +}, "~N,~N"); +Clazz.overrideMethod (c$, "getSubSequence", +function (start, end) { +if (start < 0) { +start = 0; +}var seq = this.getSequence (start, end); +if (seq.length == 0) { +return null; +}var nstart = this.findPosition (start); +var nend = this.findPosition (end) - 1; +var nseq = new jalview.datamodel.Sequence (this.getName (), seq, nstart, nend); +nseq.setDescription (this.description); +if (this.datasetSequence != null) { +nseq.setDatasetSequence (this.datasetSequence); +} else { +nseq.setDatasetSequence (this); +}return nseq; +}, "~N,~N"); +Clazz.overrideMethod (c$, "getCharAt", +function (i) { +if (i < this.sequence.length) { +return this.sequence[i]; +} else { +return ' '; +}}, "~N"); +Clazz.defineMethod (c$, "setDescription", +function (desc) { +this.description = desc; +}, "~S"); +Clazz.defineMethod (c$, "getDescription", +function () { +return this.description; +}); +Clazz.overrideMethod (c$, "findIndex", +function (pos) { +var j = this.start; +var i = 0; +while ((i < this.sequence.length) && (j <= this.end) && (j <= pos)) { +if (!jalview.util.Comparison.isGap (this.sequence[i])) { +j++; +}i++; +} +if ((j == this.end) && (j < pos)) { +return this.end + 1; +} else { +return i; +}}, "~N"); +Clazz.overrideMethod (c$, "findPosition", +function (i) { +var j = 0; +var pos = this.start; +var seqlen = this.sequence.length; +while ((j < i) && (j < seqlen)) { +if (!jalview.util.Comparison.isGap (this.sequence[j])) { +pos++; +}j++; +} +return pos; +}, "~N"); +Clazz.overrideMethod (c$, "gapMap", +function () { +var seq = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (this.sequence)); +var map = Clazz.newIntArray (seq.length, 0); +var j = 0; +var p = 0; +while (j < this.sequence.length) { +if (!jalview.util.Comparison.isGap (this.sequence[j])) { +map[p++] = j; +}j++; +} +return map; +}); +Clazz.overrideMethod (c$, "findPositionMap", +function () { +var map = Clazz.newIntArray (this.sequence.length, 0); +var j = 0; +var pos = this.start; +var seqlen = this.sequence.length; +while ((j < seqlen)) { +map[j] = pos; +if (!jalview.util.Comparison.isGap (this.sequence[j])) { +pos++; +}j++; +} +return map; +}); +Clazz.overrideMethod (c$, "getInsertions", +function () { +var map = new java.util.ArrayList (); +var lastj = -1; +var j = 0; +var pos = this.start; +var seqlen = this.sequence.length; +while ((j < seqlen)) { +if (jalview.util.Comparison.isGap (this.sequence[j])) { +if (lastj == -1) { +lastj = j; +}} else { +if (lastj != -1) { +map.add ( Clazz.newIntArray (-1, [lastj, j - 1])); +lastj = -1; +}}j++; +} +if (lastj != -1) { +map.add ( Clazz.newIntArray (-1, [lastj, j - 1])); +lastj = -1; +}return map; +}); +Clazz.overrideMethod (c$, "deleteChars", +function (i, j) { +var newstart = this.start; +var newend = this.end; +if (i >= this.sequence.length || i < 0) { +return; +}var tmp = jalview.util.StringUtils.deleteChars (this.sequence, i, j); +var createNewDs = false; +var eindex = -1; +var sindex = -1; +var ecalc = false; +var scalc = false; +for (var s = i; s < j; s++) { +if (jalview.schemes.ResidueProperties.aaIndex[this.sequence[s].charCodeAt (0)] != 23) { +if (createNewDs) { +newend--; +} else { +if (!scalc) { +sindex = this.findIndex (this.start) - 1; +scalc = true; +}if (sindex == s) { +newstart = this.findPosition (j); +break; +} else { +if (!ecalc) { +eindex = this.findIndex (this.end) - 1; +ecalc = true; +}if (eindex < j) { +newend = this.findPosition (i - 1); +break; +} else { +createNewDs = true; +newend--; +}}}}} +if (createNewDs && this.datasetSequence != null) { +var ds = new jalview.datamodel.Sequence (this.datasetSequence); +ds.deleteChars (i, j); +this.datasetSequence = ds; +}this.start = newstart; +this.end = newend; +this.sequence = tmp; +}, "~N,~N"); +Clazz.defineMethod (c$, "insertCharAt", +function (i, length, c) { +var tmp = Clazz.newCharArray (this.sequence.length + length, '\0'); +if (i >= this.sequence.length) { +System.arraycopy (this.sequence, 0, tmp, 0, this.sequence.length); +i = this.sequence.length; +} else { +System.arraycopy (this.sequence, 0, tmp, 0, i); +}var index = i; +while (length > 0) { +tmp[index++] = c; +length--; +} +if (i < this.sequence.length) { +System.arraycopy (this.sequence, i, tmp, index, this.sequence.length - i); +}this.sequence = tmp; +}, "~N,~N,~S"); +Clazz.defineMethod (c$, "insertCharAt", +function (i, c) { +this.insertCharAt (i, 1, c); +}, "~N,~S"); +Clazz.overrideMethod (c$, "getVamsasId", +function () { +return this.vamsasId; +}); +Clazz.overrideMethod (c$, "setVamsasId", +function (id) { +this.vamsasId = id; +}, "~S"); +Clazz.defineMethod (c$, "setDBRef", +function (dbref) { +this.dbrefs = dbref; +}, "~A"); +Clazz.defineMethod (c$, "getDBRef", +function () { +if (this.dbrefs == null && this.datasetSequence != null && this !== this.datasetSequence) { +return this.datasetSequence.getDBRef (); +}return this.dbrefs; +}); +Clazz.overrideMethod (c$, "addDBRef", +function (entry) { +if (this.dbrefs == null) { +this.dbrefs = new Array (0); +}var i; +var iSize = this.dbrefs.length; +for (i = 0; i < iSize; i++) { +if (this.dbrefs[i].equalRef (entry)) { +if (entry.getMap () != null) { +if (this.dbrefs[i].getMap () == null) { +this.dbrefs[i] = entry; +}}return; +}} +var temp = new Array (iSize + 1); +System.arraycopy (this.dbrefs, 0, temp, 0, iSize); +temp[temp.length - 1] = entry; +this.dbrefs = temp; +}, "jalview.datamodel.DBRefEntry"); +Clazz.defineMethod (c$, "setDatasetSequence", +function (seq) { +this.datasetSequence = seq; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getDatasetSequence", +function () { +return this.datasetSequence; +}); +Clazz.defineMethod (c$, "getAnnotation", +function () { +return this.annotation == null ? null : this.annotation.toArray ( new Array (this.annotation.size ())); +}); +Clazz.overrideMethod (c$, "hasAnnotation", +function (ann) { +return this.annotation == null ? false : this.annotation.contains (ann); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "addAlignmentAnnotation", +function (annotation) { +if (this.annotation == null) { +this.annotation = new java.util.Vector (); +}if (!this.annotation.contains (annotation)) { +this.annotation.addElement (annotation); +}annotation.setSequenceRef (this); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "removeAlignmentAnnotation", +function (annotation) { +if (this.annotation != null) { +this.annotation.removeElement (annotation); +if (this.annotation.size () == 0) { +this.annotation = null; +}}}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "isValidDatasetSequence", +($fz = function () { +if (this.datasetSequence != null) { +return false; +}for (var i = 0; i < this.sequence.length; i++) { +if (jalview.util.Comparison.isGap (this.sequence[i])) { +return false; +}} +return true; +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "deriveSequence", +function () { +var seq = new jalview.datamodel.Sequence (this); +if (this.datasetSequence != null) { +seq.setDatasetSequence (this.datasetSequence); +} else { +if (this.isValidDatasetSequence ()) { +seq.setDatasetSequence (this); +} else { +var ds = seq; +ds.setSequence (jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, String.instantialize (this.sequence))); +this.setDatasetSequence (ds); +ds.setSequenceFeatures (this.getSequenceFeatures ()); +seq = this; +}}return seq; +}); +Clazz.overrideMethod (c$, "createDatasetSequence", +function () { +if (this.datasetSequence == null) { +this.datasetSequence = new jalview.datamodel.Sequence (this.getName (), jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, this.getSequenceAsString ()), this.getStart (), this.getEnd ()); +this.datasetSequence.setSequenceFeatures (this.getSequenceFeatures ()); +this.datasetSequence.setDescription (this.getDescription ()); +this.setSequenceFeatures (null); +this.datasetSequence.setDBRef (this.getDBRef ()); +this.setDBRef (null); +this.datasetSequence.setPDBId (this.getPDBId ()); +this.setPDBId (null); +this.datasetSequence.updatePDBIds (); +if (this.annotation != null) { +for (var aa, $aa = this.annotation.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { +var _aa = new jalview.datamodel.AlignmentAnnotation (aa); +_aa.sequenceRef = this.datasetSequence; +_aa.adjustForAlignment (); +this.datasetSequence.addAlignmentAnnotation (_aa); +} +}}return this.datasetSequence; +}); +Clazz.overrideMethod (c$, "setAlignmentAnnotation", +function (annotations) { +if (this.annotation != null) { +this.annotation.removeAllElements (); +}if (annotations != null) { +for (var i = 0; i < annotations.length; i++) { +if (annotations[i] != null) { +this.addAlignmentAnnotation (annotations[i]); +}} +}}, "~A"); +Clazz.defineMethod (c$, "getAnnotation", +function (label) { +if (this.annotation == null || this.annotation.size () == 0) { +return null; +}var subset = new java.util.Vector (); +var e = this.annotation.elements (); +while (e.hasMoreElements ()) { +var ann = e.nextElement (); +if (ann.label != null && ann.label.equals (label)) { +subset.addElement (ann); +}} +if (subset.size () == 0) { +return null; +}var anns = new Array (subset.size ()); +var i = 0; +e = subset.elements (); +while (e.hasMoreElements ()) { +anns[i++] = e.nextElement (); +} +subset.removeAllElements (); +return anns; +}, "~S"); +Clazz.defineMethod (c$, "updatePDBIds", +function () { +if (this.datasetSequence != null) { +return this.datasetSequence.updatePDBIds (); +}if (this.dbrefs == null || this.dbrefs.length == 0) { +return false; +}var newpdb = new java.util.Vector (); +for (var i = 0; i < this.dbrefs.length; i++) { +if (jalview.datamodel.DBRefSource.PDB.equals (this.dbrefs[i].getSource ())) { +var pdbe = new jalview.datamodel.PDBEntry (); +pdbe.setId (this.dbrefs[i].getAccessionId ()); +if (this.pdbIds == null || this.pdbIds.size () == 0) { +newpdb.addElement (pdbe); +} else { +var en = this.pdbIds.elements (); +var matched = false; +while (!matched && en.hasMoreElements ()) { +var anentry = en.nextElement (); +if (anentry.getId ().equals (pdbe.getId ())) { +matched = true; +}} +if (!matched) { +newpdb.addElement (pdbe); +}}}} +if (newpdb.size () > 0) { +var en = newpdb.elements (); +while (en.hasMoreElements ()) { +this.addPDBId (en.nextElement ()); +} +return true; +}return false; +}); +Clazz.defineMethod (c$, "transferAnnotation", +function (entry, mp) { +if (this.datasetSequence != null) { +this.datasetSequence.transferAnnotation (entry, mp); +return; +}if (entry.getDatasetSequence () != null) { +this.transferAnnotation (entry.getDatasetSequence (), mp); +return; +}if (entry.getSequenceFeatures () != null) { +var sfs = entry.getSequenceFeatures (); +for (var si = 0; si < sfs.length; si++) { +var sf = (mp != null) ? mp.locateFeature (sfs[si]) : Clazz.newArray (-1, [ new jalview.datamodel.SequenceFeature (sfs[si])]); +if (sf != null && sf.length > 0) { +for (var sfi = 0; sfi < sf.length; sfi++) { +this.addSequenceFeature (sf[sfi]); +} +}} +}if (entry.getPDBId () != null) { +var e = entry.getPDBId ().elements (); +while (e.hasMoreElements ()) { +var pdb = e.nextElement (); +this.addPDBId (pdb); +} +}var entryRefs = entry.getDBRef (); +if (entryRefs != null) { +for (var r = 0; r < entryRefs.length; r++) { +var newref = new jalview.datamodel.DBRefEntry (entryRefs[r]); +if (newref.getMap () != null && mp != null) { +}this.addDBRef (newref); +} +}}, "jalview.datamodel.SequenceI,jalview.datamodel.Mapping"); +Clazz.overrideMethod (c$, "getIndex", +function () { +return this.index; +}); +Clazz.overrideMethod (c$, "setIndex", +function (value) { +this.index = value; +}, "~N"); +Clazz.overrideMethod (c$, "setRNA", +function (r) { +this.rna = r; +}, "jalview.jsdev.api.VarnaRNA"); +Clazz.overrideMethod (c$, "getRNA", +function () { +return this.rna; +}); +Clazz.overrideMethod (c$, "getAlignmentAnnotations", +function (calcId, label) { +var result = new java.util.ArrayList (); +if (this.annotation != null) { +for (var ann, $ann = this.annotation.iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) { +if (ann.calcId != null && ann.calcId.equals (calcId) && ann.label != null && ann.label.equals (label)) { +result.add (ann); +}} +}return result; +}, "~S,~S"); +}); diff --git a/bin/jalview/datamodel/SequenceCollectionI.js b/bin/jalview/datamodel/SequenceCollectionI.js index 6f0107b..b0849db 100644 --- a/bin/jalview/datamodel/SequenceCollectionI.js +++ b/bin/jalview/datamodel/SequenceCollectionI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.declareInterface (jalview.datamodel, "SequenceCollectionI"); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.declareInterface (jalview.datamodel, "SequenceCollectionI"); diff --git a/bin/jalview/datamodel/SequenceDummy.js b/bin/jalview/datamodel/SequenceDummy.js index d5a179c..38b0a3c 100644 --- a/bin/jalview/datamodel/SequenceDummy.js +++ b/bin/jalview/datamodel/SequenceDummy.js @@ -1,20 +1,20 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.Sequence", "$.SequenceI"], "jalview.datamodel.SequenceDummy", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.dummy = true; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SequenceDummy", jalview.datamodel.Sequence, jalview.datamodel.SequenceI); -Clazz.makeConstructor (c$, -function (sequenceId) { -Clazz.superConstructor (this, jalview.datamodel.SequenceDummy, [sequenceId, "THISAPLACEHOLDER"]); -}, "~S"); -Clazz.defineMethod (c$, "become", -function (mseq) { -this.initSeqFrom (mseq, null); -this.dummy = false; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "isDummy", -function () { -return this.dummy; -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.Sequence", "$.SequenceI"], "jalview.datamodel.SequenceDummy", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.dummy = true; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SequenceDummy", jalview.datamodel.Sequence, jalview.datamodel.SequenceI); +Clazz.makeConstructor (c$, +function (sequenceId) { +Clazz.superConstructor (this, jalview.datamodel.SequenceDummy, [sequenceId, "THISAPLACEHOLDER"]); +}, "~S"); +Clazz.defineMethod (c$, "become", +function (mseq) { +this.initSeqFrom (mseq, null); +this.dummy = false; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "isDummy", +function () { +return this.dummy; +}); +}); diff --git a/bin/jalview/datamodel/SequenceFeature.js b/bin/jalview/datamodel/SequenceFeature.js index d2f14a8..f8ce548 100644 --- a/bin/jalview/datamodel/SequenceFeature.js +++ b/bin/jalview/datamodel/SequenceFeature.js @@ -1,170 +1,170 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.SequenceFeature", ["java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.begin = 0; -this.end = 0; -this.score = 0; -this.type = null; -this.description = null; -this.otherDetails = null; -this.links = null; -this.featureGroup = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SequenceFeature"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (cpy) { -if (cpy != null) { -this.begin = cpy.begin; -this.end = cpy.end; -this.score = cpy.score; -if (cpy.type != null) { -this.type = String.instantialize (cpy.type); -}if (cpy.description != null) { -this.description = String.instantialize (cpy.description); -}if (cpy.featureGroup != null) { -this.featureGroup = String.instantialize (cpy.featureGroup); -}if (cpy.otherDetails != null) { -try { -this.otherDetails = cpy.otherDetails.clone (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -}if (cpy.links != null && cpy.links.size () > 0) { -this.links = new java.util.Vector (); -for (var i = 0, iSize = cpy.links.size (); i < iSize; i++) { -this.links.addElement (cpy.links.elementAt (i)); -} -}}}, "jalview.datamodel.SequenceFeature"); -Clazz.makeConstructor (c$, -function (type, desc, status, begin, end, featureGroup) { -this.type = type; -this.description = desc; -this.setValue ("status", status); -this.begin = begin; -this.end = end; -this.featureGroup = featureGroup; -}, "~S,~S,~S,~N,~N,~S"); -Clazz.makeConstructor (c$, -function (type, desc, begin, end, score, featureGroup) { -this.type = type; -this.description = desc; -this.begin = begin; -this.end = end; -this.score = score; -this.featureGroup = featureGroup; -}, "~S,~S,~N,~N,~N,~S"); -Clazz.defineMethod (c$, "equals", -function (sf) { -if (this.begin != sf.begin || this.end != sf.end || this.score != sf.score) { -return false; -}if (!(this.type + this.description + this.featureGroup).equals (sf.type + sf.description + sf.featureGroup)) { -return false; -}return true; -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "getBegin", -function () { -return this.begin; -}); -Clazz.defineMethod (c$, "setBegin", -function (start) { -this.begin = start; -}, "~N"); -Clazz.defineMethod (c$, "getEnd", -function () { -return this.end; -}); -Clazz.defineMethod (c$, "setEnd", -function (end) { -this.end = end; -}, "~N"); -Clazz.defineMethod (c$, "getType", -function () { -return this.type; -}); -Clazz.defineMethod (c$, "setType", -function (type) { -this.type = type; -}, "~S"); -Clazz.defineMethod (c$, "getDescription", -function () { -return this.description; -}); -Clazz.defineMethod (c$, "setDescription", -function (desc) { -this.description = desc; -}, "~S"); -Clazz.defineMethod (c$, "getFeatureGroup", -function () { -return this.featureGroup; -}); -Clazz.defineMethod (c$, "setFeatureGroup", -function (featureGroup) { -this.featureGroup = featureGroup; -}, "~S"); -Clazz.defineMethod (c$, "addLink", -function (labelLink) { -if (this.links == null) { -this.links = new java.util.Vector (); -}this.links.insertElementAt (labelLink, 0); -}, "~S"); -Clazz.defineMethod (c$, "getScore", -function () { -return this.score; -}); -Clazz.defineMethod (c$, "setScore", -function (value) { -this.score = value; -}, "~N"); -Clazz.defineMethod (c$, "getValue", -function (key) { -if (this.otherDetails == null) { -return null; -} else { -return this.otherDetails.get (key); -}}, "~S"); -Clazz.defineMethod (c$, "setValue", -function (key, value) { -if (value != null) { -if (this.otherDetails == null) { -this.otherDetails = new java.util.Hashtable (); -}this.otherDetails.put (key, value); -}}, "~S,~O"); -Clazz.defineMethod (c$, "setStatus", -function (status) { -this.setValue ("status", status); -}, "~S"); -Clazz.defineMethod (c$, "getStatus", -function () { -if (this.otherDetails != null) { -var stat = this.otherDetails.get ("status"); -if (stat != null) { -return String.instantialize (stat); -}}return null; -}); -Clazz.defineMethod (c$, "setPosition", -function (pos) { -this.begin = pos; -this.end = pos; -}, "~N"); -Clazz.defineMethod (c$, "getPosition", -function () { -return this.begin; -}); -Clazz.defineMethod (c$, "getStrand", -function () { -var str; -if (this.otherDetails == null || (str = this.otherDetails.get ("STRAND").toString ()) == null) { -return 0; -}if (str.equals ("-")) { -return -1; -}if (str.equals ("+")) { -return 1; -}return 0; -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.SequenceFeature", ["java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.begin = 0; +this.end = 0; +this.score = 0; +this.type = null; +this.description = null; +this.otherDetails = null; +this.links = null; +this.featureGroup = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SequenceFeature"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (cpy) { +if (cpy != null) { +this.begin = cpy.begin; +this.end = cpy.end; +this.score = cpy.score; +if (cpy.type != null) { +this.type = String.instantialize (cpy.type); +}if (cpy.description != null) { +this.description = String.instantialize (cpy.description); +}if (cpy.featureGroup != null) { +this.featureGroup = String.instantialize (cpy.featureGroup); +}if (cpy.otherDetails != null) { +try { +this.otherDetails = cpy.otherDetails.clone (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +}if (cpy.links != null && cpy.links.size () > 0) { +this.links = new java.util.Vector (); +for (var i = 0, iSize = cpy.links.size (); i < iSize; i++) { +this.links.addElement (cpy.links.elementAt (i)); +} +}}}, "jalview.datamodel.SequenceFeature"); +Clazz.makeConstructor (c$, +function (type, desc, status, begin, end, featureGroup) { +this.type = type; +this.description = desc; +this.setValue ("status", status); +this.begin = begin; +this.end = end; +this.featureGroup = featureGroup; +}, "~S,~S,~S,~N,~N,~S"); +Clazz.makeConstructor (c$, +function (type, desc, begin, end, score, featureGroup) { +this.type = type; +this.description = desc; +this.begin = begin; +this.end = end; +this.score = score; +this.featureGroup = featureGroup; +}, "~S,~S,~N,~N,~N,~S"); +Clazz.defineMethod (c$, "equals", +function (sf) { +if (this.begin != sf.begin || this.end != sf.end || this.score != sf.score) { +return false; +}if (!(this.type + this.description + this.featureGroup).equals (sf.type + sf.description + sf.featureGroup)) { +return false; +}return true; +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "getBegin", +function () { +return this.begin; +}); +Clazz.defineMethod (c$, "setBegin", +function (start) { +this.begin = start; +}, "~N"); +Clazz.defineMethod (c$, "getEnd", +function () { +return this.end; +}); +Clazz.defineMethod (c$, "setEnd", +function (end) { +this.end = end; +}, "~N"); +Clazz.defineMethod (c$, "getType", +function () { +return this.type; +}); +Clazz.defineMethod (c$, "setType", +function (type) { +this.type = type; +}, "~S"); +Clazz.defineMethod (c$, "getDescription", +function () { +return this.description; +}); +Clazz.defineMethod (c$, "setDescription", +function (desc) { +this.description = desc; +}, "~S"); +Clazz.defineMethod (c$, "getFeatureGroup", +function () { +return this.featureGroup; +}); +Clazz.defineMethod (c$, "setFeatureGroup", +function (featureGroup) { +this.featureGroup = featureGroup; +}, "~S"); +Clazz.defineMethod (c$, "addLink", +function (labelLink) { +if (this.links == null) { +this.links = new java.util.Vector (); +}this.links.insertElementAt (labelLink, 0); +}, "~S"); +Clazz.defineMethod (c$, "getScore", +function () { +return this.score; +}); +Clazz.defineMethod (c$, "setScore", +function (value) { +this.score = value; +}, "~N"); +Clazz.defineMethod (c$, "getValue", +function (key) { +if (this.otherDetails == null) { +return null; +} else { +return this.otherDetails.get (key); +}}, "~S"); +Clazz.defineMethod (c$, "setValue", +function (key, value) { +if (value != null) { +if (this.otherDetails == null) { +this.otherDetails = new java.util.Hashtable (); +}this.otherDetails.put (key, value); +}}, "~S,~O"); +Clazz.defineMethod (c$, "setStatus", +function (status) { +this.setValue ("status", status); +}, "~S"); +Clazz.defineMethod (c$, "getStatus", +function () { +if (this.otherDetails != null) { +var stat = this.otherDetails.get ("status"); +if (stat != null) { +return String.instantialize (stat); +}}return null; +}); +Clazz.defineMethod (c$, "setPosition", +function (pos) { +this.begin = pos; +this.end = pos; +}, "~N"); +Clazz.defineMethod (c$, "getPosition", +function () { +return this.begin; +}); +Clazz.defineMethod (c$, "getStrand", +function () { +var str; +if (this.otherDetails == null || (str = this.otherDetails.get ("STRAND").toString ()) == null) { +return 0; +}if (str.equals ("-")) { +return -1; +}if (str.equals ("+")) { +return 1; +}return 0; +}); +}); diff --git a/bin/jalview/datamodel/SequenceGroup.js b/bin/jalview/datamodel/SequenceGroup.js index b8ea520..0e59a62 100644 --- a/bin/jalview/datamodel/SequenceGroup.js +++ b/bin/jalview/datamodel/SequenceGroup.js @@ -1,601 +1,601 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.AnnotatedCollectionI", "java.awt.Color", "java.util.ArrayList"], "jalview.datamodel.SequenceGroup", ["jalview.analysis.AAFrequency", "$.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.groupName = null; -this.description = null; -this.conserve = null; -this.aaFrequency = null; -this.displayBoxes = true; -this.displayText = true; -this.colourText = false; -this.showNonconserved = false; -this.sequences = null; -this.seqrep = null; -this.width = -1; -this.cs = null; -this.startRes = 0; -this.endRes = 0; -this.outlineColour = null; -this.idColour = null; -this.thresholdTextColour = 0; -this.textColour = null; -this.textColour2 = null; -this.ignoreGapsInConsensus = true; -this.showSequenceLogo = false; -this.normaliseSequenceLogo = false; -this.consPercGaps = 25; -this.consensusData = null; -this.hidereps = false; -this.hidecols = false; -this.consensus = null; -this.conservation = null; -this.showConsensusHistogram = false; -this.context = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SequenceGroup", null, jalview.datamodel.AnnotatedCollectionI); -Clazz.prepareFields (c$, function () { -this.sequences = new java.util.ArrayList (); -this.outlineColour = java.awt.Color.black; -this.textColour = java.awt.Color.black; -this.textColour2 = java.awt.Color.white; -}); -Clazz.defineMethod (c$, "isShowSequenceLogo", -function () { -return this.showSequenceLogo; -}); -Clazz.makeConstructor (c$, -function () { -this.groupName = "JGroup:" + this.hashCode (); -}); -Clazz.makeConstructor (c$, -function (sequences, groupName, scheme, displayBoxes, displayText, colourText, start, end) { -this.sequences = sequences; -this.groupName = groupName; -this.displayBoxes = displayBoxes; -this.displayText = displayText; -this.colourText = colourText; -this.cs = scheme; -this.startRes = start; -this.endRes = end; -this.recalcConservation (); -}, "java.util.List,~S,jalview.schemes.ColourSchemeI,~B,~B,~B,~N,~N"); -Clazz.makeConstructor (c$, -function (seqsel) { -if (seqsel != null) { -this.sequences = new java.util.ArrayList (); -this.sequences.addAll (seqsel.sequences); -if (seqsel.groupName != null) { -this.groupName = String.instantialize (seqsel.groupName); -}this.displayBoxes = seqsel.displayBoxes; -this.displayText = seqsel.displayText; -this.colourText = seqsel.colourText; -this.startRes = seqsel.startRes; -this.endRes = seqsel.endRes; -this.cs = seqsel.cs; -if (seqsel.description != null) { -this.description = String.instantialize (seqsel.description); -}this.hidecols = seqsel.hidecols; -this.hidereps = seqsel.hidereps; -this.idColour = seqsel.idColour; -this.outlineColour = seqsel.outlineColour; -this.seqrep = seqsel.seqrep; -this.textColour = seqsel.textColour; -this.textColour2 = seqsel.textColour2; -this.thresholdTextColour = seqsel.thresholdTextColour; -this.width = seqsel.width; -this.ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus; -if (seqsel.conserve != null) { -this.recalcConservation (); -}}}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "getSelectionAsNewSequences", -function (align) { -var iSize = this.sequences.size (); -var seqs = new Array (iSize); -var inorder = this.getSequencesInOrder (align); -for (var i = 0, ipos = 0; i < inorder.length; i++) { -var seq = inorder[i]; -seqs[ipos] = seq.getSubSequence (this.startRes, this.endRes + 1); -if (seqs[ipos] != null) { -seqs[ipos].setDescription (seq.getDescription ()); -seqs[ipos].setDBRef (seq.getDBRef ()); -seqs[ipos].setSequenceFeatures (seq.getSequenceFeatures ()); -if (seq.getDatasetSequence () != null) { -seqs[ipos].setDatasetSequence (seq.getDatasetSequence ()); -}if (seq.getAnnotation () != null) { -var alann = align.getAlignmentAnnotation (); -for (var a = 0; a < seq.getAnnotation ().length; a++) { -var tocopy = seq.getAnnotation ()[a]; -if (alann != null) { -var found = false; -for (var pos = 0; pos < alann.length; pos++) { -if (alann[pos] === tocopy) { -found = true; -break; -}} -if (!found) { -continue; -}}var newannot = new jalview.datamodel.AlignmentAnnotation (seq.getAnnotation ()[a]); -newannot.restrict (this.startRes, this.endRes); -newannot.setSequenceRef (seqs[ipos]); -newannot.adjustForAlignment (); -seqs[ipos].addAlignmentAnnotation (newannot); -} -}ipos++; -} else { -iSize--; -}} -if (iSize != inorder.length) { -var nseqs = new Array (iSize); -System.arraycopy (seqs, 0, nseqs, 0, iSize); -seqs = nseqs; -}return seqs; -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "findEndRes", -function (seq) { -var eres = 0; -var ch; -for (var j = 0; j < this.endRes + 1 && j < seq.getLength (); j++) { -ch = seq.getCharAt (j); -if (!jalview.util.Comparison.isGap ((ch))) { -eres++; -}} -if (eres > 0) { -eres += seq.getStart () - 1; -}return eres; -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getSequences", -function () { -return this.sequences; -}); -Clazz.defineMethod (c$, "getSequences", -function (hiddenReps) { -if (hiddenReps == null) { -return this.sequences; -} else { -var allSequences = new java.util.ArrayList (); -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -allSequences.add (seq); -if (hiddenReps.containsKey (seq)) { -var hsg = hiddenReps.get (seq); -for (var seq2, $seq2 = hsg.getSequences ().iterator (); $seq2.hasNext () && ((seq2 = $seq2.next ()) || true);) { -if (seq2 !== seq && !allSequences.contains (seq2)) { -allSequences.add (seq2); -}} -}} -return allSequences; -}}, "java.util.Map"); -Clazz.defineMethod (c$, "getSequencesAsArray", -function (map) { -var tmp = this.getSequences (map); -if (tmp == null) { -return null; -}return tmp.toArray ( new Array (tmp.size ())); -}, "java.util.Map"); -Clazz.defineMethod (c$, "adjustForRemoveLeft", -function (col) { -if (this.startRes >= col) { -this.startRes = this.startRes - col; -}if (this.endRes >= col) { -this.endRes = this.endRes - col; -if (this.startRes > this.endRes) { -this.startRes = 0; -}} else { -return false; -}return true; -}, "~N"); -Clazz.defineMethod (c$, "adjustForRemoveRight", -function (col) { -if (this.startRes > col) { -return false; -}if (this.endRes >= col) { -this.endRes = col; -}return true; -}, "~N"); -Clazz.defineMethod (c$, "getName", -function () { -return this.groupName; -}); -Clazz.defineMethod (c$, "getDescription", -function () { -return this.description; -}); -Clazz.defineMethod (c$, "setName", -function (name) { -this.groupName = name; -}, "~S"); -Clazz.defineMethod (c$, "setDescription", -function (desc) { -this.description = desc; -}, "~S"); -Clazz.defineMethod (c$, "getConservation", -function () { -return this.conserve; -}); -Clazz.defineMethod (c$, "setConservation", -function (c) { -this.conserve = c; -}, "jalview.analysis.Conservation"); -Clazz.defineMethod (c$, "addSequence", -function (s, recalc) { -{ -if (s != null && !this.sequences.contains (s)) { -this.sequences.add (s); -}if (recalc) { -this.recalcConservation (); -}}}, "jalview.datamodel.SequenceI,~B"); -Clazz.defineMethod (c$, "getConsPercGaps", -function () { -return this.consPercGaps; -}); -Clazz.defineMethod (c$, "setConsPercGaps", -function (consPercGaps) { -this.consPercGaps = consPercGaps; -}, "~N"); -Clazz.defineMethod (c$, "recalcConservation", -function () { -if (this.cs == null && this.consensus == null && this.conservation == null) { -return; -}try { -var cnsns = jalview.analysis.AAFrequency.calculate (this.sequences, this.startRes, this.endRes + 1, this.showSequenceLogo); -if (this.consensus != null) { -this._updateConsensusRow (cnsns, this.sequences.size ()); -}if (this.cs != null) { -this.cs.setConsensus (cnsns); -}if ((this.conservation != null) || (this.cs != null && this.cs.conservationApplied ())) { -var c = new jalview.analysis.Conservation (this.groupName, jalview.schemes.ResidueProperties.propHash, 3, this.sequences, this.startRes, this.endRes + 1); -c.calculate (); -c.verdict (false, this.consPercGaps); -if (this.conservation != null) { -this._updateConservationRow (c); -}if (this.cs != null) { -if (this.cs.conservationApplied ()) { -this.cs.setConservation (c); -}}}if (this.cs != null) { -this.cs.alignmentChanged (this.context != null ? this.context : this, null); -}} catch (err) { -if (Clazz.exceptionOf (err, OutOfMemoryError)) { -System.out.println ("Out of memory loading groups: " + err); -} else { -throw err; -} -} -}); -Clazz.defineMethod (c$, "_updateConservationRow", -($fz = function (c) { -if (this.conservation == null) { -this.getConservation (); -}this.conservation.label = "Conservation for " + this.getName (); -this.conservation.description = "Conservation for group " + this.getName () + " less than " + this.consPercGaps + "% gaps"; -var aWidth = (this.conservation.annotations != null) ? (this.endRes < this.conservation.annotations.length ? this.conservation.annotations.length : this.endRes + 1) : this.endRes + 1; -this.conservation.annotations = null; -this.conservation.annotations = new Array (aWidth); -c.completeAnnotations (this.conservation, null, this.startRes, this.endRes + 1); -}, $fz.isPrivate = true, $fz), "jalview.analysis.Conservation"); -Clazz.defineMethod (c$, "_updateConsensusRow", -($fz = function (cnsns, nseq) { -if (this.consensus == null) { -this.getConsensus (); -}this.consensus.label = "Consensus for " + this.getName (); -this.consensus.description = "Percent Identity"; -this.consensusData = cnsns; -var aWidth = (this.consensus.annotations != null) ? (this.endRes < this.consensus.annotations.length ? this.consensus.annotations.length : this.endRes + 1) : this.endRes + 1; -this.consensus.annotations = null; -this.consensus.annotations = new Array (aWidth); -jalview.analysis.AAFrequency.completeConsensus (this.consensus, cnsns, this.startRes, this.endRes + 1, this.ignoreGapsInConsensus, this.showSequenceLogo, nseq); -}, $fz.isPrivate = true, $fz), "~A,~N"); -Clazz.defineMethod (c$, "addOrRemove", -function (s, recalc) { -{ -if (this.sequences.contains (s)) { -this.deleteSequence (s, recalc); -} else { -this.addSequence (s, recalc); -}}}, "jalview.datamodel.SequenceI,~B"); -Clazz.defineMethod (c$, "deleteSequence", -function (s, recalc) { -{ -this.sequences.remove (s); -if (recalc) { -this.recalcConservation (); -}}}, "jalview.datamodel.SequenceI,~B"); -Clazz.overrideMethod (c$, "getStartRes", -function () { -return this.startRes; -}); -Clazz.overrideMethod (c$, "getEndRes", -function () { -return this.endRes; -}); -Clazz.defineMethod (c$, "setStartRes", -function (i) { -this.startRes = i; -}, "~N"); -Clazz.defineMethod (c$, "setEndRes", -function (i) { -this.endRes = i; -}, "~N"); -Clazz.defineMethod (c$, "getSize", -function () { -return this.sequences.size (); -}); -Clazz.defineMethod (c$, "getSequenceAt", -function (i) { -return this.sequences.get (i); -}, "~N"); -Clazz.defineMethod (c$, "setColourText", -function (state) { -this.colourText = state; -}, "~B"); -Clazz.defineMethod (c$, "getColourText", -function () { -return this.colourText; -}); -Clazz.defineMethod (c$, "setDisplayText", -function (state) { -this.displayText = state; -}, "~B"); -Clazz.defineMethod (c$, "getDisplayText", -function () { -return this.displayText; -}); -Clazz.defineMethod (c$, "setDisplayBoxes", -function (state) { -this.displayBoxes = state; -}, "~B"); -Clazz.defineMethod (c$, "getDisplayBoxes", -function () { -return this.displayBoxes; -}); -Clazz.overrideMethod (c$, "getWidth", -function () { -{ -var first = true; -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -if (first || seq.getLength () > this.width) { -this.width = seq.getLength (); -first = false; -}} -return this.width; -}}); -Clazz.defineMethod (c$, "setOutlineColour", -function (c) { -this.outlineColour = c; -}, "java.awt.Color"); -Clazz.defineMethod (c$, "getOutlineColour", -function () { -return this.outlineColour; -}); -Clazz.defineMethod (c$, "getSequencesInOrder", -function (al) { -return this.getSequencesInOrder (al, true); -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "getSequencesInOrder", -function (al, trim) { -{ -var sSize = this.sequences.size (); -var alHeight = al.getHeight (); -var seqs = new Array ((trim) ? sSize : alHeight); -var index = 0; -for (var i = 0; i < alHeight && index < sSize; i++) { -if (this.sequences.contains (al.getSequenceAt (i))) { -seqs[(trim) ? index : i] = al.getSequenceAt (i); -index++; -}} -if (index == 0) { -return null; -}if (!trim) { -return seqs; -}if (index < seqs.length) { -var dummy = seqs; -seqs = new Array (index); -while (--index >= 0) { -seqs[index] = dummy[index]; -dummy[index] = null; -} -}return seqs; -}}, "jalview.datamodel.AlignmentI,~B"); -Clazz.defineMethod (c$, "getIdColour", -function () { -return this.idColour; -}); -Clazz.defineMethod (c$, "setIdColour", -function (idColour) { -this.idColour = idColour; -}, "java.awt.Color"); -Clazz.overrideMethod (c$, "getSeqrep", -function () { -return this.seqrep; -}); -Clazz.overrideMethod (c$, "setSeqrep", -function (seqrep) { -this.seqrep = seqrep; -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "hasSeqrep", -function () { -return this.seqrep != null; -}); -Clazz.defineMethod (c$, "setHidereps", -function (visibility) { -this.hidereps = visibility; -}, "~B"); -Clazz.defineMethod (c$, "isHidereps", -function () { -return this.hidereps; -}); -Clazz.defineMethod (c$, "setHideCols", -function (visibility) { -this.hidecols = visibility; -}, "~B"); -Clazz.defineMethod (c$, "isHideCols", -function () { -return this.hidecols; -}); -Clazz.defineMethod (c$, "intersect", -function (alignment, map) { -var sgroup = new jalview.datamodel.SequenceGroup (this); -var insect = this.getSequencesInOrder (alignment); -sgroup.sequences = new java.util.ArrayList (); -for (var s = 0; insect != null && s < insect.length; s++) { -if (map == null || map.containsKey (insect[s])) { -sgroup.sequences.add (insect[s]); -}} -return sgroup; -}, "jalview.datamodel.AlignmentI,java.util.Map"); -Clazz.defineMethod (c$, "getShowNonconserved", -function () { -return this.showNonconserved; -}); -Clazz.defineMethod (c$, "setShowNonconserved", -function (displayNonconserved) { -this.showNonconserved = displayNonconserved; -}, "~B"); -Clazz.defineMethod (c$, "setConsensus", -function (aan) { -if (this.consensus == null) { -this.consensus = aan; -}}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "getConsensus", -function () { -var aWidth = this.getWidth (); -if (aWidth < 0) { -return null; -}if (this.consensus == null) { -this.consensus = new jalview.datamodel.AlignmentAnnotation ("", "", new Array (1), 0, 100, 1); -this.consensus.hasText = true; -this.consensus.autoCalculated = true; -this.consensus.groupRef = this; -this.consensus.label = "Consensus for " + this.getName (); -this.consensus.description = "Percent Identity"; -}return this.consensus; -}); -Clazz.defineMethod (c$, "setConservationRow", -function (aan) { -if (this.conservation == null) { -this.conservation = aan; -}}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "getConservationRow", -function () { -if (this.conservation == null) { -this.conservation = new jalview.datamodel.AlignmentAnnotation ("", "", new Array (1), 0, 11, 1); -}this.conservation.hasText = true; -this.conservation.autoCalculated = true; -this.conservation.groupRef = this; -this.conservation.label = "Conservation for " + this.getName (); -this.conservation.description = "Conservation for group " + this.getName () + " less than " + this.consPercGaps + "% gaps"; -return this.conservation; -}); -Clazz.defineMethod (c$, "hasAnnotationRows", -function () { -return this.consensus != null || this.conservation != null; -}); -Clazz.defineMethod (c$, "getConsensusSeq", -function () { -this.getConsensus (); -var seqs = new StringBuffer (); -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 ("Group" + this.getName () + " Consensus", seqs.toString ()); -sq.setDescription ("Percentage Identity Consensus " + ((this.ignoreGapsInConsensus) ? " without gaps" : "")); -return sq; -}); -Clazz.defineMethod (c$, "setIgnoreGapsConsensus", -function (state) { -if (this.ignoreGapsInConsensus != state && this.consensus != null) { -this.ignoreGapsInConsensus = state; -this.recalcConservation (); -}this.ignoreGapsInConsensus = state; -}, "~B"); -Clazz.defineMethod (c$, "getIgnoreGapsConsensus", -function () { -return this.ignoreGapsInConsensus; -}); -Clazz.defineMethod (c$, "setshowSequenceLogo", -function (showSequenceLogo) { -if (this.showSequenceLogo != showSequenceLogo && this.consensus != null) { -this.showSequenceLogo = showSequenceLogo; -this.recalcConservation (); -}this.showSequenceLogo = showSequenceLogo; -}, "~B"); -Clazz.defineMethod (c$, "setShowConsensusHistogram", -function (showConsHist) { -if (this.showConsensusHistogram != showConsHist && this.consensus != null) { -this.showConsensusHistogram = showConsHist; -this.recalcConservation (); -}this.showConsensusHistogram = showConsHist; -}, "~B"); -Clazz.defineMethod (c$, "isShowConsensusHistogram", -function () { -return this.showConsensusHistogram; -}); -Clazz.defineMethod (c$, "setNormaliseSequenceLogo", -function (norm) { -this.normaliseSequenceLogo = norm; -}, "~B"); -Clazz.defineMethod (c$, "isNormaliseSequenceLogo", -function () { -return this.normaliseSequenceLogo; -}); -Clazz.overrideMethod (c$, "getAlignmentAnnotation", -function () { -var annot = new java.util.ArrayList (); -{ -for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -var aa = seq.getAnnotation (); -if (aa != null) { -for (var al, $al = 0, $$al = aa; $al < $$al.length && ((al = $$al[$al]) || true); $al++) { -if (al.groupRef === this) { -annot.add (al); -}} -}} -if (this.consensus != null) { -annot.add (this.consensus); -}if (this.conservation != null) { -annot.add (this.conservation); -}}return annot.toArray ( new Array (0)); -}); -Clazz.overrideMethod (c$, "findAnnotation", -function (calcId) { -var aa = new java.util.ArrayList (); -for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { -if (a.getCalcId () === calcId) { -aa.add (a); -}} -return aa; -}, "~S"); -Clazz.overrideMethod (c$, "findAnnotations", -function (seq, calcId, label) { -var aa = new java.util.ArrayList (); -for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { -if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) { -aa.add (ann); -}} -return aa; -}, "jalview.datamodel.SequenceI,~S,~S"); -Clazz.defineMethod (c$, "hasAnnotation", -function (calcId) { -if (calcId != null && !"".equals (calcId)) { -for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { -if (a.getCalcId () === calcId) { -return true; -}} -}return false; -}, "~S"); -Clazz.defineMethod (c$, "clear", -function () { -{ -this.sequences.clear (); -}}); -Clazz.defineMethod (c$, "setContext", -function (context) { -this.context = context; -}, "jalview.datamodel.AnnotatedCollectionI"); -Clazz.overrideMethod (c$, "getContext", -function () { -return this.context; -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.AnnotatedCollectionI", "java.awt.Color", "java.util.ArrayList"], "jalview.datamodel.SequenceGroup", ["jalview.analysis.AAFrequency", "$.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.groupName = null; +this.description = null; +this.conserve = null; +this.aaFrequency = null; +this.displayBoxes = true; +this.displayText = true; +this.colourText = false; +this.showNonconserved = false; +this.sequences = null; +this.seqrep = null; +this.width = -1; +this.cs = null; +this.startRes = 0; +this.endRes = 0; +this.outlineColour = null; +this.idColour = null; +this.thresholdTextColour = 0; +this.textColour = null; +this.textColour2 = null; +this.ignoreGapsInConsensus = true; +this.showSequenceLogo = false; +this.normaliseSequenceLogo = false; +this.consPercGaps = 25; +this.consensusData = null; +this.hidereps = false; +this.hidecols = false; +this.consensus = null; +this.conservation = null; +this.showConsensusHistogram = false; +this.context = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SequenceGroup", null, jalview.datamodel.AnnotatedCollectionI); +Clazz.prepareFields (c$, function () { +this.sequences = new java.util.ArrayList (); +this.outlineColour = java.awt.Color.black; +this.textColour = java.awt.Color.black; +this.textColour2 = java.awt.Color.white; +}); +Clazz.defineMethod (c$, "isShowSequenceLogo", +function () { +return this.showSequenceLogo; +}); +Clazz.makeConstructor (c$, +function () { +this.groupName = "JGroup:" + this.hashCode (); +}); +Clazz.makeConstructor (c$, +function (sequences, groupName, scheme, displayBoxes, displayText, colourText, start, end) { +this.sequences = sequences; +this.groupName = groupName; +this.displayBoxes = displayBoxes; +this.displayText = displayText; +this.colourText = colourText; +this.cs = scheme; +this.startRes = start; +this.endRes = end; +this.recalcConservation (); +}, "java.util.List,~S,jalview.schemes.ColourSchemeI,~B,~B,~B,~N,~N"); +Clazz.makeConstructor (c$, +function (seqsel) { +if (seqsel != null) { +this.sequences = new java.util.ArrayList (); +this.sequences.addAll (seqsel.sequences); +if (seqsel.groupName != null) { +this.groupName = String.instantialize (seqsel.groupName); +}this.displayBoxes = seqsel.displayBoxes; +this.displayText = seqsel.displayText; +this.colourText = seqsel.colourText; +this.startRes = seqsel.startRes; +this.endRes = seqsel.endRes; +this.cs = seqsel.cs; +if (seqsel.description != null) { +this.description = String.instantialize (seqsel.description); +}this.hidecols = seqsel.hidecols; +this.hidereps = seqsel.hidereps; +this.idColour = seqsel.idColour; +this.outlineColour = seqsel.outlineColour; +this.seqrep = seqsel.seqrep; +this.textColour = seqsel.textColour; +this.textColour2 = seqsel.textColour2; +this.thresholdTextColour = seqsel.thresholdTextColour; +this.width = seqsel.width; +this.ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus; +if (seqsel.conserve != null) { +this.recalcConservation (); +}}}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "getSelectionAsNewSequences", +function (align) { +var iSize = this.sequences.size (); +var seqs = new Array (iSize); +var inorder = this.getSequencesInOrder (align); +for (var i = 0, ipos = 0; i < inorder.length; i++) { +var seq = inorder[i]; +seqs[ipos] = seq.getSubSequence (this.startRes, this.endRes + 1); +if (seqs[ipos] != null) { +seqs[ipos].setDescription (seq.getDescription ()); +seqs[ipos].setDBRef (seq.getDBRef ()); +seqs[ipos].setSequenceFeatures (seq.getSequenceFeatures ()); +if (seq.getDatasetSequence () != null) { +seqs[ipos].setDatasetSequence (seq.getDatasetSequence ()); +}if (seq.getAnnotation () != null) { +var alann = align.getAlignmentAnnotation (); +for (var a = 0; a < seq.getAnnotation ().length; a++) { +var tocopy = seq.getAnnotation ()[a]; +if (alann != null) { +var found = false; +for (var pos = 0; pos < alann.length; pos++) { +if (alann[pos] === tocopy) { +found = true; +break; +}} +if (!found) { +continue; +}}var newannot = new jalview.datamodel.AlignmentAnnotation (seq.getAnnotation ()[a]); +newannot.restrict (this.startRes, this.endRes); +newannot.setSequenceRef (seqs[ipos]); +newannot.adjustForAlignment (); +seqs[ipos].addAlignmentAnnotation (newannot); +} +}ipos++; +} else { +iSize--; +}} +if (iSize != inorder.length) { +var nseqs = new Array (iSize); +System.arraycopy (seqs, 0, nseqs, 0, iSize); +seqs = nseqs; +}return seqs; +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "findEndRes", +function (seq) { +var eres = 0; +var ch; +for (var j = 0; j < this.endRes + 1 && j < seq.getLength (); j++) { +ch = seq.getCharAt (j); +if (!jalview.util.Comparison.isGap ((ch))) { +eres++; +}} +if (eres > 0) { +eres += seq.getStart () - 1; +}return eres; +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getSequences", +function () { +return this.sequences; +}); +Clazz.defineMethod (c$, "getSequences", +function (hiddenReps) { +if (hiddenReps == null) { +return this.sequences; +} else { +var allSequences = new java.util.ArrayList (); +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +allSequences.add (seq); +if (hiddenReps.containsKey (seq)) { +var hsg = hiddenReps.get (seq); +for (var seq2, $seq2 = hsg.getSequences ().iterator (); $seq2.hasNext () && ((seq2 = $seq2.next ()) || true);) { +if (seq2 !== seq && !allSequences.contains (seq2)) { +allSequences.add (seq2); +}} +}} +return allSequences; +}}, "java.util.Map"); +Clazz.defineMethod (c$, "getSequencesAsArray", +function (map) { +var tmp = this.getSequences (map); +if (tmp == null) { +return null; +}return tmp.toArray ( new Array (tmp.size ())); +}, "java.util.Map"); +Clazz.defineMethod (c$, "adjustForRemoveLeft", +function (col) { +if (this.startRes >= col) { +this.startRes = this.startRes - col; +}if (this.endRes >= col) { +this.endRes = this.endRes - col; +if (this.startRes > this.endRes) { +this.startRes = 0; +}} else { +return false; +}return true; +}, "~N"); +Clazz.defineMethod (c$, "adjustForRemoveRight", +function (col) { +if (this.startRes > col) { +return false; +}if (this.endRes >= col) { +this.endRes = col; +}return true; +}, "~N"); +Clazz.defineMethod (c$, "getName", +function () { +return this.groupName; +}); +Clazz.defineMethod (c$, "getDescription", +function () { +return this.description; +}); +Clazz.defineMethod (c$, "setName", +function (name) { +this.groupName = name; +}, "~S"); +Clazz.defineMethod (c$, "setDescription", +function (desc) { +this.description = desc; +}, "~S"); +Clazz.defineMethod (c$, "getConservation", +function () { +return this.conserve; +}); +Clazz.defineMethod (c$, "setConservation", +function (c) { +this.conserve = c; +}, "jalview.analysis.Conservation"); +Clazz.defineMethod (c$, "addSequence", +function (s, recalc) { +{ +if (s != null && !this.sequences.contains (s)) { +this.sequences.add (s); +}if (recalc) { +this.recalcConservation (); +}}}, "jalview.datamodel.SequenceI,~B"); +Clazz.defineMethod (c$, "getConsPercGaps", +function () { +return this.consPercGaps; +}); +Clazz.defineMethod (c$, "setConsPercGaps", +function (consPercGaps) { +this.consPercGaps = consPercGaps; +}, "~N"); +Clazz.defineMethod (c$, "recalcConservation", +function () { +if (this.cs == null && this.consensus == null && this.conservation == null) { +return; +}try { +var cnsns = jalview.analysis.AAFrequency.calculate (this.sequences, this.startRes, this.endRes + 1, this.showSequenceLogo); +if (this.consensus != null) { +this._updateConsensusRow (cnsns, this.sequences.size ()); +}if (this.cs != null) { +this.cs.setConsensus (cnsns); +}if ((this.conservation != null) || (this.cs != null && this.cs.conservationApplied ())) { +var c = new jalview.analysis.Conservation (this.groupName, jalview.schemes.ResidueProperties.propHash, 3, this.sequences, this.startRes, this.endRes + 1); +c.calculate (); +c.verdict (false, this.consPercGaps); +if (this.conservation != null) { +this._updateConservationRow (c); +}if (this.cs != null) { +if (this.cs.conservationApplied ()) { +this.cs.setConservation (c); +}}}if (this.cs != null) { +this.cs.alignmentChanged (this.context != null ? this.context : this, null); +}} catch (err) { +if (Clazz.exceptionOf (err, OutOfMemoryError)) { +System.out.println ("Out of memory loading groups: " + err); +} else { +throw err; +} +} +}); +Clazz.defineMethod (c$, "_updateConservationRow", +($fz = function (c) { +if (this.conservation == null) { +this.getConservation (); +}this.conservation.label = "Conservation for " + this.getName (); +this.conservation.description = "Conservation for group " + this.getName () + " less than " + this.consPercGaps + "% gaps"; +var aWidth = (this.conservation.annotations != null) ? (this.endRes < this.conservation.annotations.length ? this.conservation.annotations.length : this.endRes + 1) : this.endRes + 1; +this.conservation.annotations = null; +this.conservation.annotations = new Array (aWidth); +c.completeAnnotations (this.conservation, null, this.startRes, this.endRes + 1); +}, $fz.isPrivate = true, $fz), "jalview.analysis.Conservation"); +Clazz.defineMethod (c$, "_updateConsensusRow", +($fz = function (cnsns, nseq) { +if (this.consensus == null) { +this.getConsensus (); +}this.consensus.label = "Consensus for " + this.getName (); +this.consensus.description = "Percent Identity"; +this.consensusData = cnsns; +var aWidth = (this.consensus.annotations != null) ? (this.endRes < this.consensus.annotations.length ? this.consensus.annotations.length : this.endRes + 1) : this.endRes + 1; +this.consensus.annotations = null; +this.consensus.annotations = new Array (aWidth); +jalview.analysis.AAFrequency.completeConsensus (this.consensus, cnsns, this.startRes, this.endRes + 1, this.ignoreGapsInConsensus, this.showSequenceLogo, nseq); +}, $fz.isPrivate = true, $fz), "~A,~N"); +Clazz.defineMethod (c$, "addOrRemove", +function (s, recalc) { +{ +if (this.sequences.contains (s)) { +this.deleteSequence (s, recalc); +} else { +this.addSequence (s, recalc); +}}}, "jalview.datamodel.SequenceI,~B"); +Clazz.defineMethod (c$, "deleteSequence", +function (s, recalc) { +{ +this.sequences.remove (s); +if (recalc) { +this.recalcConservation (); +}}}, "jalview.datamodel.SequenceI,~B"); +Clazz.overrideMethod (c$, "getStartRes", +function () { +return this.startRes; +}); +Clazz.overrideMethod (c$, "getEndRes", +function () { +return this.endRes; +}); +Clazz.defineMethod (c$, "setStartRes", +function (i) { +this.startRes = i; +}, "~N"); +Clazz.defineMethod (c$, "setEndRes", +function (i) { +this.endRes = i; +}, "~N"); +Clazz.defineMethod (c$, "getSize", +function () { +return this.sequences.size (); +}); +Clazz.defineMethod (c$, "getSequenceAt", +function (i) { +return this.sequences.get (i); +}, "~N"); +Clazz.defineMethod (c$, "setColourText", +function (state) { +this.colourText = state; +}, "~B"); +Clazz.defineMethod (c$, "getColourText", +function () { +return this.colourText; +}); +Clazz.defineMethod (c$, "setDisplayText", +function (state) { +this.displayText = state; +}, "~B"); +Clazz.defineMethod (c$, "getDisplayText", +function () { +return this.displayText; +}); +Clazz.defineMethod (c$, "setDisplayBoxes", +function (state) { +this.displayBoxes = state; +}, "~B"); +Clazz.defineMethod (c$, "getDisplayBoxes", +function () { +return this.displayBoxes; +}); +Clazz.overrideMethod (c$, "getWidth", +function () { +{ +var first = true; +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +if (first || seq.getLength () > this.width) { +this.width = seq.getLength (); +first = false; +}} +return this.width; +}}); +Clazz.defineMethod (c$, "setOutlineColour", +function (c) { +this.outlineColour = c; +}, "java.awt.Color"); +Clazz.defineMethod (c$, "getOutlineColour", +function () { +return this.outlineColour; +}); +Clazz.defineMethod (c$, "getSequencesInOrder", +function (al) { +return this.getSequencesInOrder (al, true); +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "getSequencesInOrder", +function (al, trim) { +{ +var sSize = this.sequences.size (); +var alHeight = al.getHeight (); +var seqs = new Array ((trim) ? sSize : alHeight); +var index = 0; +for (var i = 0; i < alHeight && index < sSize; i++) { +if (this.sequences.contains (al.getSequenceAt (i))) { +seqs[(trim) ? index : i] = al.getSequenceAt (i); +index++; +}} +if (index == 0) { +return null; +}if (!trim) { +return seqs; +}if (index < seqs.length) { +var dummy = seqs; +seqs = new Array (index); +while (--index >= 0) { +seqs[index] = dummy[index]; +dummy[index] = null; +} +}return seqs; +}}, "jalview.datamodel.AlignmentI,~B"); +Clazz.defineMethod (c$, "getIdColour", +function () { +return this.idColour; +}); +Clazz.defineMethod (c$, "setIdColour", +function (idColour) { +this.idColour = idColour; +}, "java.awt.Color"); +Clazz.overrideMethod (c$, "getSeqrep", +function () { +return this.seqrep; +}); +Clazz.overrideMethod (c$, "setSeqrep", +function (seqrep) { +this.seqrep = seqrep; +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "hasSeqrep", +function () { +return this.seqrep != null; +}); +Clazz.defineMethod (c$, "setHidereps", +function (visibility) { +this.hidereps = visibility; +}, "~B"); +Clazz.defineMethod (c$, "isHidereps", +function () { +return this.hidereps; +}); +Clazz.defineMethod (c$, "setHideCols", +function (visibility) { +this.hidecols = visibility; +}, "~B"); +Clazz.defineMethod (c$, "isHideCols", +function () { +return this.hidecols; +}); +Clazz.defineMethod (c$, "intersect", +function (alignment, map) { +var sgroup = new jalview.datamodel.SequenceGroup (this); +var insect = this.getSequencesInOrder (alignment); +sgroup.sequences = new java.util.ArrayList (); +for (var s = 0; insect != null && s < insect.length; s++) { +if (map == null || map.containsKey (insect[s])) { +sgroup.sequences.add (insect[s]); +}} +return sgroup; +}, "jalview.datamodel.AlignmentI,java.util.Map"); +Clazz.defineMethod (c$, "getShowNonconserved", +function () { +return this.showNonconserved; +}); +Clazz.defineMethod (c$, "setShowNonconserved", +function (displayNonconserved) { +this.showNonconserved = displayNonconserved; +}, "~B"); +Clazz.defineMethod (c$, "setConsensus", +function (aan) { +if (this.consensus == null) { +this.consensus = aan; +}}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "getConsensus", +function () { +var aWidth = this.getWidth (); +if (aWidth < 0) { +return null; +}if (this.consensus == null) { +this.consensus = new jalview.datamodel.AlignmentAnnotation ("", "", new Array (1), 0, 100, 1); +this.consensus.hasText = true; +this.consensus.autoCalculated = true; +this.consensus.groupRef = this; +this.consensus.label = "Consensus for " + this.getName (); +this.consensus.description = "Percent Identity"; +}return this.consensus; +}); +Clazz.defineMethod (c$, "setConservationRow", +function (aan) { +if (this.conservation == null) { +this.conservation = aan; +}}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "getConservationRow", +function () { +if (this.conservation == null) { +this.conservation = new jalview.datamodel.AlignmentAnnotation ("", "", new Array (1), 0, 11, 1); +}this.conservation.hasText = true; +this.conservation.autoCalculated = true; +this.conservation.groupRef = this; +this.conservation.label = "Conservation for " + this.getName (); +this.conservation.description = "Conservation for group " + this.getName () + " less than " + this.consPercGaps + "% gaps"; +return this.conservation; +}); +Clazz.defineMethod (c$, "hasAnnotationRows", +function () { +return this.consensus != null || this.conservation != null; +}); +Clazz.defineMethod (c$, "getConsensusSeq", +function () { +this.getConsensus (); +var seqs = new StringBuffer (); +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 ("Group" + this.getName () + " Consensus", seqs.toString ()); +sq.setDescription ("Percentage Identity Consensus " + ((this.ignoreGapsInConsensus) ? " without gaps" : "")); +return sq; +}); +Clazz.defineMethod (c$, "setIgnoreGapsConsensus", +function (state) { +if (this.ignoreGapsInConsensus != state && this.consensus != null) { +this.ignoreGapsInConsensus = state; +this.recalcConservation (); +}this.ignoreGapsInConsensus = state; +}, "~B"); +Clazz.defineMethod (c$, "getIgnoreGapsConsensus", +function () { +return this.ignoreGapsInConsensus; +}); +Clazz.defineMethod (c$, "setshowSequenceLogo", +function (showSequenceLogo) { +if (this.showSequenceLogo != showSequenceLogo && this.consensus != null) { +this.showSequenceLogo = showSequenceLogo; +this.recalcConservation (); +}this.showSequenceLogo = showSequenceLogo; +}, "~B"); +Clazz.defineMethod (c$, "setShowConsensusHistogram", +function (showConsHist) { +if (this.showConsensusHistogram != showConsHist && this.consensus != null) { +this.showConsensusHistogram = showConsHist; +this.recalcConservation (); +}this.showConsensusHistogram = showConsHist; +}, "~B"); +Clazz.defineMethod (c$, "isShowConsensusHistogram", +function () { +return this.showConsensusHistogram; +}); +Clazz.defineMethod (c$, "setNormaliseSequenceLogo", +function (norm) { +this.normaliseSequenceLogo = norm; +}, "~B"); +Clazz.defineMethod (c$, "isNormaliseSequenceLogo", +function () { +return this.normaliseSequenceLogo; +}); +Clazz.overrideMethod (c$, "getAlignmentAnnotation", +function () { +var annot = new java.util.ArrayList (); +{ +for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +var aa = seq.getAnnotation (); +if (aa != null) { +for (var al, $al = 0, $$al = aa; $al < $$al.length && ((al = $$al[$al]) || true); $al++) { +if (al.groupRef === this) { +annot.add (al); +}} +}} +if (this.consensus != null) { +annot.add (this.consensus); +}if (this.conservation != null) { +annot.add (this.conservation); +}}return annot.toArray ( new Array (0)); +}); +Clazz.overrideMethod (c$, "findAnnotation", +function (calcId) { +var aa = new java.util.ArrayList (); +for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { +if (a.getCalcId () === calcId) { +aa.add (a); +}} +return aa; +}, "~S"); +Clazz.overrideMethod (c$, "findAnnotations", +function (seq, calcId, label) { +var aa = new java.util.ArrayList (); +for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { +if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) { +aa.add (ann); +}} +return aa; +}, "jalview.datamodel.SequenceI,~S,~S"); +Clazz.defineMethod (c$, "hasAnnotation", +function (calcId) { +if (calcId != null && !"".equals (calcId)) { +for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) { +if (a.getCalcId () === calcId) { +return true; +}} +}return false; +}, "~S"); +Clazz.defineMethod (c$, "clear", +function () { +{ +this.sequences.clear (); +}}); +Clazz.defineMethod (c$, "setContext", +function (context) { +this.context = context; +}, "jalview.datamodel.AnnotatedCollectionI"); +Clazz.overrideMethod (c$, "getContext", +function () { +return this.context; +}); +}); diff --git a/bin/jalview/datamodel/SequenceI.js b/bin/jalview/datamodel/SequenceI.js index dcf0724..242d5a5 100644 --- a/bin/jalview/datamodel/SequenceI.js +++ b/bin/jalview/datamodel/SequenceI.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.ASequenceI"], "jalview.datamodel.SequenceI", null, function () { -Clazz.declareInterface (jalview.datamodel, "SequenceI", jalview.datamodel.ASequenceI); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.ASequenceI"], "jalview.datamodel.SequenceI", null, function () { +Clazz.declareInterface (jalview.datamodel, "SequenceI", jalview.datamodel.ASequenceI); +}); diff --git a/bin/jalview/datamodel/SequenceNode.js b/bin/jalview/datamodel/SequenceNode.js index 2069471..54cb491 100644 --- a/bin/jalview/datamodel/SequenceNode.js +++ b/bin/jalview/datamodel/SequenceNode.js @@ -1,64 +1,64 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.BinaryNode", "java.awt.Color"], "jalview.datamodel.SequenceNode", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.dist = 0; -this.count = 0; -this.height = 0; -this.ycount = 0; -this.color = null; -this.dummy = false; -this.placeholder = false; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SequenceNode", jalview.datamodel.BinaryNode); -Clazz.prepareFields (c$, function () { -this.color = java.awt.Color.black; -}); -Clazz.makeConstructor (c$, -function (val, parent, dist, name) { -Clazz.superConstructor (this, jalview.datamodel.SequenceNode, [val, parent, name]); -this.dist = dist; -}, "~O,jalview.datamodel.SequenceNode,~N,~S"); -Clazz.makeConstructor (c$, -function (val, parent, name, dist, bootstrap, dummy) { -Clazz.superConstructor (this, jalview.datamodel.SequenceNode, [val, parent, name]); -this.dist = dist; -this.bootstrap = bootstrap; -this.dummy = dummy; -}, "~O,jalview.datamodel.SequenceNode,~S,~N,~N,~B"); -Clazz.defineMethod (c$, "isDummy", -function () { -return this.dummy; -}); -Clazz.defineMethod (c$, "isPlaceholder", -function () { -return this.placeholder; -}); -Clazz.defineMethod (c$, "setDummy", -function (newstate) { -var oldstate = this.dummy; -this.dummy = newstate; -return oldstate; -}, "~B"); -Clazz.defineMethod (c$, "setPlaceholder", -function (Placeholder) { -this.placeholder = Placeholder; -}, "~B"); -Clazz.defineMethod (c$, "AscendTree", -function () { -var c = this; -do { -c = c.parent (); -} while ((c != null) && c.dummy); -return c; -}); -Clazz.defineMethod (c$, "isSequenceLabel", -function () { -if (this.name != null && this.name.length > 0) { -for (var c = 0, s = this.name.length; c < s; c++) { -var q = this.name.charAt (c); -if ('0' <= q && q <= '9') continue; -return true; -} -}return false; -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.BinaryNode", "java.awt.Color"], "jalview.datamodel.SequenceNode", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.dist = 0; +this.count = 0; +this.height = 0; +this.ycount = 0; +this.color = null; +this.dummy = false; +this.placeholder = false; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SequenceNode", jalview.datamodel.BinaryNode); +Clazz.prepareFields (c$, function () { +this.color = java.awt.Color.black; +}); +Clazz.makeConstructor (c$, +function (val, parent, dist, name) { +Clazz.superConstructor (this, jalview.datamodel.SequenceNode, [val, parent, name]); +this.dist = dist; +}, "~O,jalview.datamodel.SequenceNode,~N,~S"); +Clazz.makeConstructor (c$, +function (val, parent, name, dist, bootstrap, dummy) { +Clazz.superConstructor (this, jalview.datamodel.SequenceNode, [val, parent, name]); +this.dist = dist; +this.bootstrap = bootstrap; +this.dummy = dummy; +}, "~O,jalview.datamodel.SequenceNode,~S,~N,~N,~B"); +Clazz.defineMethod (c$, "isDummy", +function () { +return this.dummy; +}); +Clazz.defineMethod (c$, "isPlaceholder", +function () { +return this.placeholder; +}); +Clazz.defineMethod (c$, "setDummy", +function (newstate) { +var oldstate = this.dummy; +this.dummy = newstate; +return oldstate; +}, "~B"); +Clazz.defineMethod (c$, "setPlaceholder", +function (Placeholder) { +this.placeholder = Placeholder; +}, "~B"); +Clazz.defineMethod (c$, "AscendTree", +function () { +var c = this; +do { +c = c.parent (); +} while ((c != null) && c.dummy); +return c; +}); +Clazz.defineMethod (c$, "isSequenceLabel", +function () { +if (this.name != null && this.name.length > 0) { +for (var c = 0, s = this.name.length; c < s; c++) { +var q = this.name.charAt (c); +if ('0' <= q && q <= '9') continue; +return true; +} +}return false; +}); +}); diff --git a/bin/jalview/datamodel/SequencePoint.js b/bin/jalview/datamodel/SequencePoint.js index 549eae1..0616692 100644 --- a/bin/jalview/datamodel/SequencePoint.js +++ b/bin/jalview/datamodel/SequencePoint.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this.isPlaceholder = false; -this.sequence = null; -this.coord = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "SequencePoint"); -Clazz.makeConstructor (c$, -function (sequence, coord) { -this.sequence = sequence; -this.coord = coord; -}, "jalview.datamodel.SequenceI,~A"); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this.isPlaceholder = false; +this.sequence = null; +this.coord = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "SequencePoint"); +Clazz.makeConstructor (c$, +function (sequence, coord) { +this.sequence = sequence; +this.coord = coord; +}, "jalview.datamodel.SequenceI,~A"); diff --git a/bin/jalview/datamodel/StructureViewerModel.js b/bin/jalview/datamodel/StructureViewerModel.js index cc11e43..e21d3fc 100644 --- a/bin/jalview/datamodel/StructureViewerModel.js +++ b/bin/jalview/datamodel/StructureViewerModel.js @@ -1,156 +1,156 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["java.util.HashMap"], "jalview.datamodel.StructureViewerModel", ["java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.width = 0; -this.height = 0; -this.alignWithPanel = false; -this.colourWithAlignPanel = false; -this.colourByViewer = false; -this.stateData = ""; -this.viewId = null; -this.type = null; -this.fileData = null; -if (!Clazz.isClassDefined ("jalview.datamodel.StructureViewerModel.StructureData")) { -jalview.datamodel.StructureViewerModel.$StructureViewerModel$StructureData$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "StructureViewerModel"); -Clazz.prepareFields (c$, function () { -this.fileData = new java.util.HashMap (); -}); -Clazz.makeConstructor (c$, -function (x, y, width, height, alignWithPanel, colourWithAlignPanel, colourByViewer, viewId, type) { -this.x = x; -this.y = y; -this.width = width; -this.height = height; -this.alignWithPanel = alignWithPanel; -this.colourWithAlignPanel = colourWithAlignPanel; -this.colourByViewer = colourByViewer; -this.viewId = viewId; -this.type = type; -}, "~N,~N,~N,~N,~B,~B,~B,~S,~S"); -Clazz.defineMethod (c$, "getX", -function () { -return this.x; -}); -Clazz.defineMethod (c$, "setX", -function (x) { -this.x = x; -}, "~N"); -Clazz.defineMethod (c$, "getY", -function () { -return this.y; -}); -Clazz.defineMethod (c$, "setY", -function (y) { -this.y = y; -}, "~N"); -Clazz.defineMethod (c$, "getWidth", -function () { -return this.width; -}); -Clazz.defineMethod (c$, "setWidth", -function (width) { -this.width = width; -}, "~N"); -Clazz.defineMethod (c$, "getHeight", -function () { -return this.height; -}); -Clazz.defineMethod (c$, "setHeight", -function (height) { -this.height = height; -}, "~N"); -Clazz.defineMethod (c$, "isAlignWithPanel", -function () { -return this.alignWithPanel; -}); -Clazz.defineMethod (c$, "setAlignWithPanel", -function (alignWithPanel) { -this.alignWithPanel = alignWithPanel; -}, "~B"); -Clazz.defineMethod (c$, "isColourWithAlignPanel", -function () { -return this.colourWithAlignPanel; -}); -Clazz.defineMethod (c$, "setColourWithAlignPanel", -function (colourWithAlignPanel) { -this.colourWithAlignPanel = colourWithAlignPanel; -}, "~B"); -Clazz.defineMethod (c$, "isColourByViewer", -function () { -return this.colourByViewer; -}); -Clazz.defineMethod (c$, "setColourByViewer", -function (colourByViewer) { -this.colourByViewer = colourByViewer; -}, "~B"); -Clazz.defineMethod (c$, "getStateData", -function () { -return this.stateData; -}); -Clazz.defineMethod (c$, "setStateData", -function (stateData) { -this.stateData = stateData; -}, "~S"); -Clazz.defineMethod (c$, "getFileData", -function () { -return this.fileData; -}); -Clazz.defineMethod (c$, "setFileData", -function (fileData) { -this.fileData = fileData; -}, "java.util.Map"); -Clazz.defineMethod (c$, "getViewId", -function () { -return this.viewId; -}); -Clazz.defineMethod (c$, "getType", -function () { -return this.type; -}); -c$.$StructureViewerModel$StructureData$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.filePath = null; -this.pdbId = null; -this.seqList = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel.StructureViewerModel, "StructureData"); -Clazz.makeConstructor (c$, -function (a, b) { -this.filePath = a; -this.pdbId = b; -this.seqList = new java.util.ArrayList (); -}, "~S,~S"); -Clazz.defineMethod (c$, "getFilePath", -function () { -return this.filePath; -}); -Clazz.defineMethod (c$, "setFilePath", -function (a) { -this.filePath = a; -}, "~S"); -Clazz.defineMethod (c$, "getPdbId", -function () { -return this.pdbId; -}); -Clazz.defineMethod (c$, "setPdbId", -function (a) { -this.pdbId = a; -}, "~S"); -Clazz.defineMethod (c$, "getSeqList", -function () { -return this.seqList; -}); -Clazz.defineMethod (c$, "setSeqList", -function (a) { -this.seqList = a; -}, "java.util.List"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["java.util.HashMap"], "jalview.datamodel.StructureViewerModel", ["java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.width = 0; +this.height = 0; +this.alignWithPanel = false; +this.colourWithAlignPanel = false; +this.colourByViewer = false; +this.stateData = ""; +this.viewId = null; +this.type = null; +this.fileData = null; +if (!Clazz.isClassDefined ("jalview.datamodel.StructureViewerModel.StructureData")) { +jalview.datamodel.StructureViewerModel.$StructureViewerModel$StructureData$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "StructureViewerModel"); +Clazz.prepareFields (c$, function () { +this.fileData = new java.util.HashMap (); +}); +Clazz.makeConstructor (c$, +function (x, y, width, height, alignWithPanel, colourWithAlignPanel, colourByViewer, viewId, type) { +this.x = x; +this.y = y; +this.width = width; +this.height = height; +this.alignWithPanel = alignWithPanel; +this.colourWithAlignPanel = colourWithAlignPanel; +this.colourByViewer = colourByViewer; +this.viewId = viewId; +this.type = type; +}, "~N,~N,~N,~N,~B,~B,~B,~S,~S"); +Clazz.defineMethod (c$, "getX", +function () { +return this.x; +}); +Clazz.defineMethod (c$, "setX", +function (x) { +this.x = x; +}, "~N"); +Clazz.defineMethod (c$, "getY", +function () { +return this.y; +}); +Clazz.defineMethod (c$, "setY", +function (y) { +this.y = y; +}, "~N"); +Clazz.defineMethod (c$, "getWidth", +function () { +return this.width; +}); +Clazz.defineMethod (c$, "setWidth", +function (width) { +this.width = width; +}, "~N"); +Clazz.defineMethod (c$, "getHeight", +function () { +return this.height; +}); +Clazz.defineMethod (c$, "setHeight", +function (height) { +this.height = height; +}, "~N"); +Clazz.defineMethod (c$, "isAlignWithPanel", +function () { +return this.alignWithPanel; +}); +Clazz.defineMethod (c$, "setAlignWithPanel", +function (alignWithPanel) { +this.alignWithPanel = alignWithPanel; +}, "~B"); +Clazz.defineMethod (c$, "isColourWithAlignPanel", +function () { +return this.colourWithAlignPanel; +}); +Clazz.defineMethod (c$, "setColourWithAlignPanel", +function (colourWithAlignPanel) { +this.colourWithAlignPanel = colourWithAlignPanel; +}, "~B"); +Clazz.defineMethod (c$, "isColourByViewer", +function () { +return this.colourByViewer; +}); +Clazz.defineMethod (c$, "setColourByViewer", +function (colourByViewer) { +this.colourByViewer = colourByViewer; +}, "~B"); +Clazz.defineMethod (c$, "getStateData", +function () { +return this.stateData; +}); +Clazz.defineMethod (c$, "setStateData", +function (stateData) { +this.stateData = stateData; +}, "~S"); +Clazz.defineMethod (c$, "getFileData", +function () { +return this.fileData; +}); +Clazz.defineMethod (c$, "setFileData", +function (fileData) { +this.fileData = fileData; +}, "java.util.Map"); +Clazz.defineMethod (c$, "getViewId", +function () { +return this.viewId; +}); +Clazz.defineMethod (c$, "getType", +function () { +return this.type; +}); +c$.$StructureViewerModel$StructureData$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.filePath = null; +this.pdbId = null; +this.seqList = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel.StructureViewerModel, "StructureData"); +Clazz.makeConstructor (c$, +function (a, b) { +this.filePath = a; +this.pdbId = b; +this.seqList = new java.util.ArrayList (); +}, "~S,~S"); +Clazz.defineMethod (c$, "getFilePath", +function () { +return this.filePath; +}); +Clazz.defineMethod (c$, "setFilePath", +function (a) { +this.filePath = a; +}, "~S"); +Clazz.defineMethod (c$, "getPdbId", +function () { +return this.pdbId; +}); +Clazz.defineMethod (c$, "setPdbId", +function (a) { +this.pdbId = a; +}, "~S"); +Clazz.defineMethod (c$, "getSeqList", +function () { +return this.seqList; +}); +Clazz.defineMethod (c$, "setSeqList", +function (a) { +this.seqList = a; +}, "java.util.List"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/datamodel/UniprotEntry.js b/bin/jalview/datamodel/UniprotEntry.js index 5b80f48..24b3ce2 100644 --- a/bin/jalview/datamodel/UniprotEntry.js +++ b/bin/jalview/datamodel/UniprotEntry.js @@ -1,58 +1,58 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this.sequence = null; -this.name = null; -this.accession = null; -this.feature = null; -this.dbrefs = null; -this.protName = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "UniprotEntry"); -Clazz.defineMethod (c$, "setAccession", -function (items) { -this.accession = items; -}, "java.util.Vector"); -Clazz.defineMethod (c$, "setFeature", -function (items) { -this.feature = items; -}, "java.util.Vector"); -Clazz.defineMethod (c$, "getFeature", -function () { -return this.feature; -}); -Clazz.defineMethod (c$, "getAccession", -function () { -return this.accession; -}); -Clazz.defineMethod (c$, "setProtein", -function (names) { -this.protName = names; -}, "jalview.datamodel.UniprotProteinName"); -Clazz.defineMethod (c$, "getProtein", -function () { -return this.protName; -}); -Clazz.defineMethod (c$, "setName", -function (na) { -this.name = na; -}, "java.util.Vector"); -Clazz.defineMethod (c$, "getName", -function () { -return this.name; -}); -Clazz.defineMethod (c$, "getUniprotSequence", -function () { -return this.sequence; -}); -Clazz.defineMethod (c$, "setUniprotSequence", -function (seq) { -this.sequence = seq; -}, "jalview.datamodel.UniprotSequence"); -Clazz.defineMethod (c$, "getDbReference", -function () { -return this.dbrefs; -}); -Clazz.defineMethod (c$, "setDbReference", -function (dbref) { -this.dbrefs = dbref; -}, "java.util.Vector"); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this.sequence = null; +this.name = null; +this.accession = null; +this.feature = null; +this.dbrefs = null; +this.protName = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "UniprotEntry"); +Clazz.defineMethod (c$, "setAccession", +function (items) { +this.accession = items; +}, "java.util.Vector"); +Clazz.defineMethod (c$, "setFeature", +function (items) { +this.feature = items; +}, "java.util.Vector"); +Clazz.defineMethod (c$, "getFeature", +function () { +return this.feature; +}); +Clazz.defineMethod (c$, "getAccession", +function () { +return this.accession; +}); +Clazz.defineMethod (c$, "setProtein", +function (names) { +this.protName = names; +}, "jalview.datamodel.UniprotProteinName"); +Clazz.defineMethod (c$, "getProtein", +function () { +return this.protName; +}); +Clazz.defineMethod (c$, "setName", +function (na) { +this.name = na; +}, "java.util.Vector"); +Clazz.defineMethod (c$, "getName", +function () { +return this.name; +}); +Clazz.defineMethod (c$, "getUniprotSequence", +function () { +return this.sequence; +}); +Clazz.defineMethod (c$, "setUniprotSequence", +function (seq) { +this.sequence = seq; +}, "jalview.datamodel.UniprotSequence"); +Clazz.defineMethod (c$, "getDbReference", +function () { +return this.dbrefs; +}); +Clazz.defineMethod (c$, "setDbReference", +function (dbref) { +this.dbrefs = dbref; +}, "java.util.Vector"); diff --git a/bin/jalview/datamodel/UniprotFile.js b/bin/jalview/datamodel/UniprotFile.js index e0f80f8..f779f79 100644 --- a/bin/jalview/datamodel/UniprotFile.js +++ b/bin/jalview/datamodel/UniprotFile.js @@ -1,13 +1,13 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this._items = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "UniprotFile"); -Clazz.defineMethod (c$, "setUniprotEntries", -function (items) { -this._items = items; -}, "java.util.Vector"); -Clazz.defineMethod (c$, "getUniprotEntries", -function () { -return this._items; -}); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this._items = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "UniprotFile"); +Clazz.defineMethod (c$, "setUniprotEntries", +function (items) { +this._items = items; +}, "java.util.Vector"); +Clazz.defineMethod (c$, "getUniprotEntries", +function () { +return this._items; +}); diff --git a/bin/jalview/datamodel/UniprotProteinName.js b/bin/jalview/datamodel/UniprotProteinName.js index 931e26c..fd4ce5b 100644 --- a/bin/jalview/datamodel/UniprotProteinName.js +++ b/bin/jalview/datamodel/UniprotProteinName.js @@ -1,13 +1,13 @@ -Clazz.declarePackage ("jalview.datamodel"); -c$ = Clazz.decorateAsClass (function () { -this.names = null; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "UniprotProteinName"); -Clazz.defineMethod (c$, "setName", -function (names) { -this.names = names; -}, "java.util.Vector"); -Clazz.defineMethod (c$, "getName", -function () { -return this.names; -}); +Clazz.declarePackage ("jalview.datamodel"); +c$ = Clazz.decorateAsClass (function () { +this.names = null; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "UniprotProteinName"); +Clazz.defineMethod (c$, "setName", +function (names) { +this.names = names; +}, "java.util.Vector"); +Clazz.defineMethod (c$, "getName", +function () { +return this.names; +}); diff --git a/bin/jalview/datamodel/UniprotSequence.js b/bin/jalview/datamodel/UniprotSequence.js index d6ae549..039f1db 100644 --- a/bin/jalview/datamodel/UniprotSequence.js +++ b/bin/jalview/datamodel/UniprotSequence.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (null, "jalview.datamodel.UniprotSequence", ["java.lang.StringBuilder"], function () { -c$ = Clazz.decorateAsClass (function () { -this._content = ""; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "UniprotSequence"); -Clazz.defineMethod (c$, "setContent", -function (seq) { -if (seq != null) { -var sb = new StringBuilder (seq.length); -for (var i = 0; i < seq.length; i++) { -if (seq.charAt (i) != ' ') { -sb.append (seq.charAt (i)); -}} -this._content = sb.toString (); -}}, "~S"); -Clazz.defineMethod (c$, "getContent", -function () { -return this._content; -}); -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (null, "jalview.datamodel.UniprotSequence", ["java.lang.StringBuilder"], function () { +c$ = Clazz.decorateAsClass (function () { +this._content = ""; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "UniprotSequence"); +Clazz.defineMethod (c$, "setContent", +function (seq) { +if (seq != null) { +var sb = new StringBuilder (seq.length); +for (var i = 0; i < seq.length; i++) { +if (seq.charAt (i) != ' ') { +sb.append (seq.charAt (i)); +}} +this._content = sb.toString (); +}}, "~S"); +Clazz.defineMethod (c$, "getContent", +function () { +return this._content; +}); +}); diff --git a/bin/jalview/ext/jmol/JmolCommands.js b/bin/jalview/ext/jmol/JmolCommands.js index b08a4e3..495572c 100644 --- a/bin/jalview/ext/jmol/JmolCommands.js +++ b/bin/jalview/ext/jmol/JmolCommands.js @@ -1,69 +1,69 @@ -Clazz.declarePackage ("jalview.ext.jmol"); -Clazz.load (null, "jalview.ext.jmol.JmolCommands", ["jalview.structure.StructureMappingcommandSet", "jalview.util.Comparison", "java.lang.StringBuffer", "java.util.ArrayList"], function () { -c$ = Clazz.declareType (jalview.ext.jmol, "JmolCommands"); -c$.getColourBySequenceCommand = Clazz.defineMethod (c$, "getColourBySequenceCommand", -function (ssm, files, sequence, sr, fr, alignment) { -var cset = new java.util.ArrayList (); -for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { -var mapping = ssm.getMapping (files[pdbfnum]); -var command = new StringBuffer (); -var smc; -var str = new java.util.ArrayList (); -if (mapping == null || mapping.length < 1) { -continue; -}var lastPos = -1; -for (var s = 0; s < sequence[pdbfnum].length; s++) { -for (var sp, m = 0; m < mapping.length; m++) { -if (mapping[m].getSequence () === sequence[pdbfnum][s] && (sp = alignment.findIndex (sequence[pdbfnum][s])) > -1) { -var asp = alignment.getSequenceAt (sp); -for (var r = 0; r < asp.getLength (); r++) { -if (jalview.util.Comparison.isGap (asp.getCharAt (r))) { -continue; -}var pos = mapping[m].getPDBResNum (asp.findPosition (r)); -if (pos < 1 || pos == lastPos) { -continue; -}lastPos = pos; -var col = sr.getResidueBoxColour (sequence[pdbfnum][s], r); -if (fr != null) { -col = fr.findFeatureColour (col, sequence[pdbfnum][s], r); -}var newSelcom = (mapping[m].getChain () !== " " ? ":" + mapping[m].getChain () : "") + "/" + (pdbfnum + 1) + ".1" + ";color[" + col.getRed () + "," + col.getGreen () + "," + col.getBlue () + "]"; -if (command.length () > newSelcom.length && command.substring (command.length () - newSelcom.length).equals (newSelcom)) { -command = jalview.ext.jmol.JmolCommands.condenseCommand (command, pos); -continue; -}command.append (";"); -if (command.length () > 51200) { -str.add (command.toString ()); -command.setLength (0); -}command.append ("select " + pos); -command.append (newSelcom); -} -break; -}} -} -{ -str.add (command.toString ()); -command.setLength (0); -}cset.add ( new jalview.structure.StructureMappingcommandSet (jalview.ext.jmol.JmolCommands, files[pdbfnum], str.toArray ( new Array (str.size ())))); -} -return cset.toArray ( new Array (cset.size ())); -}, "jalview.structure.StructureSelectionManager,~A,~A,jalview.api.SequenceRenderer,jalview.api.FeatureRenderer,jalview.datamodel.AlignmentI"); -c$.condenseCommand = Clazz.defineMethod (c$, "condenseCommand", -function (command, pos) { -var p = command.length (); -var q = p; -do { -p -= 6; -if (p < 1) { -p = 0; -};} while ((q = command.indexOf ("select", p)) == -1 && p > 0); -var sb = new StringBuffer (command.substring (0, q + 7)); -command = command.$delete (0, q + 7); -var start; -if (command.indexOf ("-") > -1) { -start = command.substring (0, command.indexOf ("-")); -} else { -start = command.substring (0, command.indexOf (":")); -}sb.append (start + "-" + pos + command.substring (command.indexOf (":"))); -return sb; -}, "StringBuffer,~N"); -}); +Clazz.declarePackage ("jalview.ext.jmol"); +Clazz.load (null, "jalview.ext.jmol.JmolCommands", ["jalview.structure.StructureMappingcommandSet", "jalview.util.Comparison", "java.lang.StringBuffer", "java.util.ArrayList"], function () { +c$ = Clazz.declareType (jalview.ext.jmol, "JmolCommands"); +c$.getColourBySequenceCommand = Clazz.defineMethod (c$, "getColourBySequenceCommand", +function (ssm, files, sequence, sr, fr, alignment) { +var cset = new java.util.ArrayList (); +for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { +var mapping = ssm.getMapping (files[pdbfnum]); +var command = new StringBuffer (); +var smc; +var str = new java.util.ArrayList (); +if (mapping == null || mapping.length < 1) { +continue; +}var lastPos = -1; +for (var s = 0; s < sequence[pdbfnum].length; s++) { +for (var sp, m = 0; m < mapping.length; m++) { +if (mapping[m].getSequence () === sequence[pdbfnum][s] && (sp = alignment.findIndex (sequence[pdbfnum][s])) > -1) { +var asp = alignment.getSequenceAt (sp); +for (var r = 0; r < asp.getLength (); r++) { +if (jalview.util.Comparison.isGap (asp.getCharAt (r))) { +continue; +}var pos = mapping[m].getPDBResNum (asp.findPosition (r)); +if (pos < 1 || pos == lastPos) { +continue; +}lastPos = pos; +var col = sr.getResidueBoxColour (sequence[pdbfnum][s], r); +if (fr != null) { +col = fr.findFeatureColour (col, sequence[pdbfnum][s], r); +}var newSelcom = (mapping[m].getChain () !== " " ? ":" + mapping[m].getChain () : "") + "/" + (pdbfnum + 1) + ".1" + ";color[" + col.getRed () + "," + col.getGreen () + "," + col.getBlue () + "]"; +if (command.length () > newSelcom.length && command.substring (command.length () - newSelcom.length).equals (newSelcom)) { +command = jalview.ext.jmol.JmolCommands.condenseCommand (command, pos); +continue; +}command.append (";"); +if (command.length () > 51200) { +str.add (command.toString ()); +command.setLength (0); +}command.append ("select " + pos); +command.append (newSelcom); +} +break; +}} +} +{ +str.add (command.toString ()); +command.setLength (0); +}cset.add ( new jalview.structure.StructureMappingcommandSet (jalview.ext.jmol.JmolCommands, files[pdbfnum], str.toArray ( new Array (str.size ())))); +} +return cset.toArray ( new Array (cset.size ())); +}, "jalview.structure.StructureSelectionManager,~A,~A,jalview.api.SequenceRenderer,jalview.api.FeatureRenderer,jalview.datamodel.AlignmentI"); +c$.condenseCommand = Clazz.defineMethod (c$, "condenseCommand", +function (command, pos) { +var p = command.length (); +var q = p; +do { +p -= 6; +if (p < 1) { +p = 0; +};} while ((q = command.indexOf ("select", p)) == -1 && p > 0); +var sb = new StringBuffer (command.substring (0, q + 7)); +command = command.$delete (0, q + 7); +var start; +if (command.indexOf ("-") > -1) { +start = command.substring (0, command.indexOf ("-")); +} else { +start = command.substring (0, command.indexOf (":")); +}sb.append (start + "-" + pos + command.substring (command.indexOf (":"))); +return sb; +}, "StringBuffer,~N"); +}); diff --git a/bin/jalview/ext/varna/JalviewVarnaBinding.js b/bin/jalview/ext/varna/JalviewVarnaBinding.js index 61bd3e7..f8bdf18 100644 --- a/bin/jalview/ext/varna/JalviewVarnaBinding.js +++ b/bin/jalview/ext/varna/JalviewVarnaBinding.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.ext.varna"); -Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.structure.StructureListener", "jalview.structures.models.SequenceStructureBindingModel", "java.awt.event.ComponentListener"], "jalview.ext.varna.JalviewVarnaBinding", null, function () { -c$ = Clazz.declareType (jalview.ext.varna, "JalviewVarnaBinding", jalview.structures.models.SequenceStructureBindingModel, [jalview.structure.StructureListener, java.awt.event.ComponentListener, jalview.api.StructureSelectionManagerProvider]); -}); +Clazz.declarePackage ("jalview.ext.varna"); +Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.structure.StructureListener", "jalview.structures.models.SequenceStructureBindingModel", "java.awt.event.ComponentListener"], "jalview.ext.varna.JalviewVarnaBinding", null, function () { +c$ = Clazz.declareType (jalview.ext.varna, "JalviewVarnaBinding", jalview.structures.models.SequenceStructureBindingModel, [jalview.structure.StructureListener, java.awt.event.ComponentListener, jalview.api.StructureSelectionManagerProvider]); +}); diff --git a/bin/jalview/ext/varna/RnaModel.js b/bin/jalview/ext/varna/RnaModel.js index f125256..9916e8e 100644 --- a/bin/jalview/ext/varna/RnaModel.js +++ b/bin/jalview/ext/varna/RnaModel.js @@ -1,17 +1,17 @@ -Clazz.declarePackage ("jalview.ext.varna"); -c$ = Clazz.decorateAsClass (function () { -this.title = null; -this.ann = null; -this.seq = null; -this.gapped = false; -this.rna = null; -Clazz.instantialize (this, arguments); -}, jalview.ext.varna, "RnaModel"); -Clazz.makeConstructor (c$, -function (t, aa, s, r, g) { -this.title = t; -this.ann = aa; -this.seq = s; -this.rna = r; -this.gapped = g; -}, "~S,jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,fr.orsay.lri.varna.models.rna.RNA,~B"); +Clazz.declarePackage ("jalview.ext.varna"); +c$ = Clazz.decorateAsClass (function () { +this.title = null; +this.ann = null; +this.seq = null; +this.gapped = false; +this.rna = null; +Clazz.instantialize (this, arguments); +}, jalview.ext.varna, "RnaModel"); +Clazz.makeConstructor (c$, +function (t, aa, s, r, g) { +this.title = t; +this.ann = aa; +this.seq = s; +this.rna = r; +this.gapped = g; +}, "~S,jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,fr.orsay.lri.varna.models.rna.RNA,~B"); diff --git a/bin/jalview/ext/varna/VarnaCommands.js b/bin/jalview/ext/varna/VarnaCommands.js index 6562f80..b609d09 100644 --- a/bin/jalview/ext/varna/VarnaCommands.js +++ b/bin/jalview/ext/varna/VarnaCommands.js @@ -1,66 +1,66 @@ -Clazz.declarePackage ("jalview.ext.varna"); -Clazz.load (null, "jalview.ext.varna.VarnaCommands", ["jalview.util.Comparison", "java.lang.StringBuffer", "java.util.ArrayList"], function () { -c$ = Clazz.declareType (jalview.ext.varna, "VarnaCommands"); -c$.getColourBySequenceCommand = Clazz.defineMethod (c$, "getColourBySequenceCommand", -function (ssm, files, sequence, sr, fr, alignment) { -var str = new java.util.ArrayList (); -var command = new StringBuffer (); -for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { -var mapping = ssm.getMapping (files[pdbfnum]); -if (mapping == null || mapping.length < 1) { -continue; -}var lastPos = -1; -for (var s = 0; s < sequence[pdbfnum].length; s++) { -for (var sp, m = 0; m < mapping.length; m++) { -if (mapping[m].getSequence () === sequence[pdbfnum][s] && (sp = alignment.findIndex (sequence[pdbfnum][s])) > -1) { -var asp = alignment.getSequenceAt (sp); -for (var r = 0; r < asp.getLength (); r++) { -if (jalview.util.Comparison.isGap (asp.getCharAt (r))) { -continue; -}var pos = mapping[m].getPDBResNum (asp.findPosition (r)); -if (pos < 1 || pos == lastPos) { -continue; -}lastPos = pos; -var col = sr.getResidueBoxColour (sequence[pdbfnum][s], r); -if (fr != null) { -col = fr.findFeatureColour (col, sequence[pdbfnum][s], r); -}var newSelcom = (mapping[m].getChain () !== " " ? ":" + mapping[m].getChain () : "") + "/" + (pdbfnum + 1) + ".1" + ";color[" + col.getRed () + "," + col.getGreen () + "," + col.getBlue () + "]"; -if (command.length () > newSelcom.length && command.substring (command.length () - newSelcom.length).equals (newSelcom)) { -command = jalview.ext.varna.VarnaCommands.condenseCommand (command, pos); -continue; -}command.append (";"); -if (command.length () > 51200) { -str.add (command.toString ()); -command.setLength (0); -}command.append ("select " + pos); -command.append (newSelcom); -} -break; -}} -} -} -{ -str.add (command.toString ()); -command.setLength (0); -}return str.toArray ( new Array (str.size ())); -}, "jalview.structure.StructureSelectionManager,~A,~A,jalview.api.SequenceRenderer,jalview.api.FeatureRenderer,jalview.datamodel.AlignmentI"); -c$.condenseCommand = Clazz.defineMethod (c$, "condenseCommand", -function (command, pos) { -var p = command.length (); -var q = p; -do { -p -= 6; -if (p < 1) { -p = 0; -};} while ((q = command.indexOf ("select", p)) == -1 && p > 0); -var sb = new StringBuffer (command.substring (0, q + 7)); -command = command.$delete (0, q + 7); -var start; -if (command.indexOf ("-") > -1) { -start = command.substring (0, command.indexOf ("-")); -} else { -start = command.substring (0, command.indexOf (":")); -}sb.append (start + "-" + pos + command.substring (command.indexOf (":"))); -return sb; -}, "StringBuffer,~N"); -}); +Clazz.declarePackage ("jalview.ext.varna"); +Clazz.load (null, "jalview.ext.varna.VarnaCommands", ["jalview.util.Comparison", "java.lang.StringBuffer", "java.util.ArrayList"], function () { +c$ = Clazz.declareType (jalview.ext.varna, "VarnaCommands"); +c$.getColourBySequenceCommand = Clazz.defineMethod (c$, "getColourBySequenceCommand", +function (ssm, files, sequence, sr, fr, alignment) { +var str = new java.util.ArrayList (); +var command = new StringBuffer (); +for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { +var mapping = ssm.getMapping (files[pdbfnum]); +if (mapping == null || mapping.length < 1) { +continue; +}var lastPos = -1; +for (var s = 0; s < sequence[pdbfnum].length; s++) { +for (var sp, m = 0; m < mapping.length; m++) { +if (mapping[m].getSequence () === sequence[pdbfnum][s] && (sp = alignment.findIndex (sequence[pdbfnum][s])) > -1) { +var asp = alignment.getSequenceAt (sp); +for (var r = 0; r < asp.getLength (); r++) { +if (jalview.util.Comparison.isGap (asp.getCharAt (r))) { +continue; +}var pos = mapping[m].getPDBResNum (asp.findPosition (r)); +if (pos < 1 || pos == lastPos) { +continue; +}lastPos = pos; +var col = sr.getResidueBoxColour (sequence[pdbfnum][s], r); +if (fr != null) { +col = fr.findFeatureColour (col, sequence[pdbfnum][s], r); +}var newSelcom = (mapping[m].getChain () !== " " ? ":" + mapping[m].getChain () : "") + "/" + (pdbfnum + 1) + ".1" + ";color[" + col.getRed () + "," + col.getGreen () + "," + col.getBlue () + "]"; +if (command.length () > newSelcom.length && command.substring (command.length () - newSelcom.length).equals (newSelcom)) { +command = jalview.ext.varna.VarnaCommands.condenseCommand (command, pos); +continue; +}command.append (";"); +if (command.length () > 51200) { +str.add (command.toString ()); +command.setLength (0); +}command.append ("select " + pos); +command.append (newSelcom); +} +break; +}} +} +} +{ +str.add (command.toString ()); +command.setLength (0); +}return str.toArray ( new Array (str.size ())); +}, "jalview.structure.StructureSelectionManager,~A,~A,jalview.api.SequenceRenderer,jalview.api.FeatureRenderer,jalview.datamodel.AlignmentI"); +c$.condenseCommand = Clazz.defineMethod (c$, "condenseCommand", +function (command, pos) { +var p = command.length (); +var q = p; +do { +p -= 6; +if (p < 1) { +p = 0; +};} while ((q = command.indexOf ("select", p)) == -1 && p > 0); +var sb = new StringBuffer (command.substring (0, q + 7)); +command = command.$delete (0, q + 7); +var start; +if (command.indexOf ("-") > -1) { +start = command.substring (0, command.indexOf ("-")); +} else { +start = command.substring (0, command.indexOf (":")); +}sb.append (start + "-" + pos + command.substring (command.indexOf (":"))); +return sb; +}, "StringBuffer,~N"); +}); diff --git a/bin/jalview/io/AlignFile.js b/bin/jalview/io/AlignFile.js index 142c507..f3247de 100644 --- a/bin/jalview/io/AlignFile.js +++ b/bin/jalview/io/AlignFile.js @@ -1,158 +1,158 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.FileParse"], "jalview.io.AlignFile", ["jalview.datamodel.Sequence", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Error", "java.util.ArrayList", "$.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.noSeqs = 0; -this.maxLength = 0; -this.seqs = null; -this.annotations = null; -this.seqGroups = null; -this.properties = null; -this.start = 0; -this.end = 0; -this.jvSuffix = true; -this.parseCalled = false; -this.newickStrings = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "AlignFile", jalview.io.FileParse); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.AlignFile, []); -this.initData (); -}); -Clazz.makeConstructor (c$, -function (inFile, type) { -this.construct (true, inFile, type); -}, "~S,~S"); -Clazz.makeConstructor (c$, -function (parseImmediately, inFile, type) { -Clazz.superConstructor (this, jalview.io.AlignFile, [inFile, type]); -this.initData (); -if (parseImmediately) { -this.doParse (); -}}, "~B,~S,~S"); -Clazz.makeConstructor (c$, -function (source) { -this.construct (true, source); -}, "jalview.io.FileParse"); -Clazz.makeConstructor (c$, -function (parseImmediately, source) { -Clazz.superConstructor (this, jalview.io.AlignFile, [source]); -this.initData (); -if (parseImmediately) { -this.doParse (); -}}, "~B,jalview.io.FileParse"); -Clazz.defineMethod (c$, "doParse", -function () { -if (this.parseCalled) { -throw new java.io.IOException ("Implementation error: Parser called twice for same data.\nNeed to call initData() again before parsing can be reattempted."); -}this.parseCalled = true; -this.parse (); -for (var i = 0, c = this.seqs.size (); i < c; i++) { -this.seqs.get (i).setIndex (i); -} -}); -Clazz.defineMethod (c$, "getSeqs", -function () { -return this.seqs; -}); -Clazz.defineMethod (c$, "getSeqGroups", -function () { -return this.seqGroups; -}); -Clazz.defineMethod (c$, "getSeqsAsArray", -function () { -var s = new Array (this.seqs.size ()); -for (var i = 0; i < this.seqs.size (); i++) { -s[i] = this.seqs.elementAt (i); -} -return s; -}); -Clazz.defineMethod (c$, "addAnnotations", -function (al) { -this.addProperties (al); -for (var i = 0; i < this.annotations.size (); i++) { -var an = this.annotations.elementAt (i); -an.validateRangeAndDisplay (); -al.addAnnotation (an); -} -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "addSeqGroups", -function (al) { -this.seqGroups = al.getGroups (); -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "addProperties", -function (al) { -if (this.properties != null && this.properties.size () > 0) { -var keys = this.properties.keys (); -var vals = this.properties.elements (); -while (keys.hasMoreElements ()) { -al.setProperty (keys.nextElement (), vals.nextElement ()); -} -}}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "setAlignmentProperty", -function (key, value) { -if (key == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_cannot_have_null_alignment")); -}if (value == null) { -return; -}if (this.properties == null) { -this.properties = new java.util.Hashtable (); -}this.properties.put (key, value); -}, "~O,~O"); -Clazz.defineMethod (c$, "getAlignmentProperty", -function (key) { -if (this.properties != null && key != null) { -return this.properties.get (key); -}return null; -}, "~O"); -Clazz.defineMethod (c$, "initData", -function () { -this.seqs = new java.util.Vector (); -this.annotations = new java.util.Vector (); -this.seqGroups = new java.util.ArrayList (); -this.parseCalled = false; -}); -Clazz.defineMethod (c$, "setSeqs", -function (s) { -this.seqs = new java.util.Vector (); -for (var i = 0; i < s.length; i++) { -this.seqs.addElement (s[i]); -} -}, "~A"); -Clazz.defineMethod (c$, "addJVSuffix", -function (b) { -this.jvSuffix = b; -}, "~B"); -Clazz.defineMethod (c$, "parseId", -function (id) { -var seq = null; -id = id.trim (); -var space = id.indexOf (" "); -if (space > -1) { -seq = new jalview.datamodel.Sequence (id.substring (0, space), ""); -seq.setDescription (id.substring (space + 1)); -} else { -seq = new jalview.datamodel.Sequence (id, ""); -}return seq; -}, "~S"); -Clazz.defineMethod (c$, "printId", -function (seq) { -return seq.getDisplayId (this.jvSuffix); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "addNewickTree", -function (treeName, newickString) { -if (this.newickStrings == null) { -this.newickStrings = new java.util.Vector (); -}this.newickStrings.addElement ( Clazz.newArray (-1, [treeName, newickString])); -}, "~S,~S"); -Clazz.defineMethod (c$, "getTreeCount", -function () { -return this.newickStrings == null ? 0 : this.newickStrings.size (); -}); -Clazz.defineMethod (c$, "addGroups", -function (al) { -for (var sg, $sg = this.getSeqGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -al.addGroup (sg); -} -}, "jalview.datamodel.AlignmentI"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.FileParse"], "jalview.io.AlignFile", ["jalview.datamodel.Sequence", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Error", "java.util.ArrayList", "$.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.noSeqs = 0; +this.maxLength = 0; +this.seqs = null; +this.annotations = null; +this.seqGroups = null; +this.properties = null; +this.start = 0; +this.end = 0; +this.jvSuffix = true; +this.parseCalled = false; +this.newickStrings = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "AlignFile", jalview.io.FileParse); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.AlignFile, []); +this.initData (); +}); +Clazz.makeConstructor (c$, +function (inFile, type) { +this.construct (true, inFile, type); +}, "~S,~S"); +Clazz.makeConstructor (c$, +function (parseImmediately, inFile, type) { +Clazz.superConstructor (this, jalview.io.AlignFile, [inFile, type]); +this.initData (); +if (parseImmediately) { +this.doParse (); +}}, "~B,~S,~S"); +Clazz.makeConstructor (c$, +function (source) { +this.construct (true, source); +}, "jalview.io.FileParse"); +Clazz.makeConstructor (c$, +function (parseImmediately, source) { +Clazz.superConstructor (this, jalview.io.AlignFile, [source]); +this.initData (); +if (parseImmediately) { +this.doParse (); +}}, "~B,jalview.io.FileParse"); +Clazz.defineMethod (c$, "doParse", +function () { +if (this.parseCalled) { +throw new java.io.IOException ("Implementation error: Parser called twice for same data.\nNeed to call initData() again before parsing can be reattempted."); +}this.parseCalled = true; +this.parse (); +for (var i = 0, c = this.seqs.size (); i < c; i++) { +this.seqs.get (i).setIndex (i); +} +}); +Clazz.defineMethod (c$, "getSeqs", +function () { +return this.seqs; +}); +Clazz.defineMethod (c$, "getSeqGroups", +function () { +return this.seqGroups; +}); +Clazz.defineMethod (c$, "getSeqsAsArray", +function () { +var s = new Array (this.seqs.size ()); +for (var i = 0; i < this.seqs.size (); i++) { +s[i] = this.seqs.elementAt (i); +} +return s; +}); +Clazz.defineMethod (c$, "addAnnotations", +function (al) { +this.addProperties (al); +for (var i = 0; i < this.annotations.size (); i++) { +var an = this.annotations.elementAt (i); +an.validateRangeAndDisplay (); +al.addAnnotation (an); +} +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "addSeqGroups", +function (al) { +this.seqGroups = al.getGroups (); +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "addProperties", +function (al) { +if (this.properties != null && this.properties.size () > 0) { +var keys = this.properties.keys (); +var vals = this.properties.elements (); +while (keys.hasMoreElements ()) { +al.setProperty (keys.nextElement (), vals.nextElement ()); +} +}}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "setAlignmentProperty", +function (key, value) { +if (key == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_cannot_have_null_alignment")); +}if (value == null) { +return; +}if (this.properties == null) { +this.properties = new java.util.Hashtable (); +}this.properties.put (key, value); +}, "~O,~O"); +Clazz.defineMethod (c$, "getAlignmentProperty", +function (key) { +if (this.properties != null && key != null) { +return this.properties.get (key); +}return null; +}, "~O"); +Clazz.defineMethod (c$, "initData", +function () { +this.seqs = new java.util.Vector (); +this.annotations = new java.util.Vector (); +this.seqGroups = new java.util.ArrayList (); +this.parseCalled = false; +}); +Clazz.defineMethod (c$, "setSeqs", +function (s) { +this.seqs = new java.util.Vector (); +for (var i = 0; i < s.length; i++) { +this.seqs.addElement (s[i]); +} +}, "~A"); +Clazz.defineMethod (c$, "addJVSuffix", +function (b) { +this.jvSuffix = b; +}, "~B"); +Clazz.defineMethod (c$, "parseId", +function (id) { +var seq = null; +id = id.trim (); +var space = id.indexOf (" "); +if (space > -1) { +seq = new jalview.datamodel.Sequence (id.substring (0, space), ""); +seq.setDescription (id.substring (space + 1)); +} else { +seq = new jalview.datamodel.Sequence (id, ""); +}return seq; +}, "~S"); +Clazz.defineMethod (c$, "printId", +function (seq) { +return seq.getDisplayId (this.jvSuffix); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "addNewickTree", +function (treeName, newickString) { +if (this.newickStrings == null) { +this.newickStrings = new java.util.Vector (); +}this.newickStrings.addElement ( Clazz.newArray (-1, [treeName, newickString])); +}, "~S,~S"); +Clazz.defineMethod (c$, "getTreeCount", +function () { +return this.newickStrings == null ? 0 : this.newickStrings.size (); +}); +Clazz.defineMethod (c$, "addGroups", +function (al) { +for (var sg, $sg = this.getSeqGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +al.addGroup (sg); +} +}, "jalview.datamodel.AlignmentI"); +}); diff --git a/bin/jalview/io/AlignmentProperties.js b/bin/jalview/io/AlignmentProperties.js index 6030bea..0092589 100644 --- a/bin/jalview/io/AlignmentProperties.js +++ b/bin/jalview/io/AlignmentProperties.js @@ -1,78 +1,78 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.AlignmentProperties", ["java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.alignment = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "AlignmentProperties"); -Clazz.makeConstructor (c$, -function (alignment) { -this.alignment = alignment; -}, "jalview.datamodel.AlignmentI"); -Clazz.defineMethod (c$, "writeProperties", -function (sb, html) { -var nl = html ? "
" : System.getProperty ("line.separator"); -var avg = 0; -var min = 2147483647; -var max = 0; -for (var i = 0; i < this.alignment.getHeight (); i++) { -var size = 1 + this.alignment.getSequenceAt (i).getEnd () - this.alignment.getSequenceAt (i).getStart (); -avg += size; -if (size > max) { -max = size; -}if (size < min) { -min = size; -}} -avg = avg / this.alignment.getHeight (); -sb.append (nl); -sb.append ("Sequences: " + this.alignment.getHeight ()); -sb.append (nl); -sb.append ("Minimum Sequence Length: " + min); -sb.append (nl); -sb.append ("Maximum Sequence Length: " + max); -sb.append (nl); -sb.append ("Average Length: " + Clazz.floatToInt (avg)); -if ((this.alignment).alignmentProperties != null) { -sb.append (nl); -sb.append (nl); -if (html) { -sb.append (""); -}var props = (this.alignment).alignmentProperties; -var en = props.keys (); -while (en.hasMoreElements ()) { -var key = en.nextElement ().toString (); -var vals = props.get (key).toString (); -if (html) { -var val = new StringBuffer (); -var pos = 0; -var npos; -do { -npos = vals.indexOf ("\n", pos); -if (npos == -1) { -val.append (vals.substring (pos)); -} else { -val.append (vals.substring (pos, npos)); -val.append ("
"); -}pos = npos + 1; -} while (npos != -1); -sb.append (""); -} else { -sb.append (nl + key + "\t" + vals); -}} -if (html) { -sb.append ("
" + key + "" + val + "
"); -}}}, "StringBuffer,~B"); -Clazz.defineMethod (c$, "formatAsString", -function () { -return this.formatReport (false); -}); -Clazz.defineMethod (c$, "formatReport", -function (html) { -var sb = new StringBuffer (); -this.writeProperties (sb, html); -return sb; -}, "~B"); -Clazz.defineMethod (c$, "formatAsHtml", -function () { -return this.formatReport (true); -}); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.AlignmentProperties", ["java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.alignment = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "AlignmentProperties"); +Clazz.makeConstructor (c$, +function (alignment) { +this.alignment = alignment; +}, "jalview.datamodel.AlignmentI"); +Clazz.defineMethod (c$, "writeProperties", +function (sb, html) { +var nl = html ? "
" : System.getProperty ("line.separator"); +var avg = 0; +var min = 2147483647; +var max = 0; +for (var i = 0; i < this.alignment.getHeight (); i++) { +var size = 1 + this.alignment.getSequenceAt (i).getEnd () - this.alignment.getSequenceAt (i).getStart (); +avg += size; +if (size > max) { +max = size; +}if (size < min) { +min = size; +}} +avg = avg / this.alignment.getHeight (); +sb.append (nl); +sb.append ("Sequences: " + this.alignment.getHeight ()); +sb.append (nl); +sb.append ("Minimum Sequence Length: " + min); +sb.append (nl); +sb.append ("Maximum Sequence Length: " + max); +sb.append (nl); +sb.append ("Average Length: " + Clazz.floatToInt (avg)); +if ((this.alignment).alignmentProperties != null) { +sb.append (nl); +sb.append (nl); +if (html) { +sb.append (""); +}var props = (this.alignment).alignmentProperties; +var en = props.keys (); +while (en.hasMoreElements ()) { +var key = en.nextElement ().toString (); +var vals = props.get (key).toString (); +if (html) { +var val = new StringBuffer (); +var pos = 0; +var npos; +do { +npos = vals.indexOf ("\n", pos); +if (npos == -1) { +val.append (vals.substring (pos)); +} else { +val.append (vals.substring (pos, npos)); +val.append ("
"); +}pos = npos + 1; +} while (npos != -1); +sb.append (""); +} else { +sb.append (nl + key + "\t" + vals); +}} +if (html) { +sb.append ("
" + key + "" + val + "
"); +}}}, "StringBuffer,~B"); +Clazz.defineMethod (c$, "formatAsString", +function () { +return this.formatReport (false); +}); +Clazz.defineMethod (c$, "formatReport", +function (html) { +var sb = new StringBuffer (); +this.writeProperties (sb, html); +return sb; +}, "~B"); +Clazz.defineMethod (c$, "formatAsHtml", +function () { +return this.formatReport (true); +}); +}); diff --git a/bin/jalview/io/AnnotationFile.js b/bin/jalview/io/AnnotationFile.js index 4c4c01e..a707ee4 100644 --- a/bin/jalview/io/AnnotationFile.js +++ b/bin/jalview/io/AnnotationFile.js @@ -1,1003 +1,1003 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.AnnotationFile", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.ColumnSelection", "$.GraphLine", "$.SequenceGroup", "jalview.io.AppletFormatAdapter", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Comparison", "$.Format", "java.awt.Color", "java.io.BufferedReader", "$.InputStreamReader", "$.StringReader", "java.lang.Boolean", "$.Float", "$.StringBuffer", "java.util.ArrayList", "$.BitSet", "$.Date", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.newline = null; -this.text = null; -if (!Clazz.isClassDefined ("jalview.io.AnnotationFile.ViewDef")) { -jalview.io.AnnotationFile.$AnnotationFile$ViewDef$ (); -} -this.refSeq = null; -this.refSeqId = null; -this.nlinesread = 0; -this.lastread = ""; -Clazz.instantialize (this, arguments); -}, jalview.io, "AnnotationFile"); -Clazz.prepareFields (c$, function () { -this.newline = System.getProperty ("line.separator"); -}); -Clazz.makeConstructor (c$, -function () { -this.init (); -}); -Clazz.defineMethod (c$, "setNewlineString", -function (nl) { -this.newline = nl; -this.init (); -}, "~S"); -Clazz.defineMethod (c$, "getNewlineString", -function () { -return this.newline; -}); -Clazz.defineMethod (c$, "init", -($fz = function () { -this.text = new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " + new java.util.Date () + this.newline + this.newline); -this.refSeq = null; -this.refSeqId = null; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "printAnnotations", -function (annotations, list, properties) { -return this.printAnnotations (annotations, list, properties, null, null, null); -}, "~A,java.util.List,java.util.Hashtable"); -Clazz.defineMethod (c$, "printAnnotations", -function (annotations, list, properties, cs, al, view) { -if (view != null) { -if (view.viewname != null) { -this.text.append ("VIEW_DEF\t" + view.viewname + "\n"); -}if (list == null) { -list = view.visibleGroups; -}if (cs == null) { -cs = view.hiddencols; -}if (al == null) { -}}if (al != null && al.hasSeqrep ()) { -this.text.append ("VIEW_SETREF\t" + al.getSeqrep ().getName () + "\n"); -}if (cs != null && cs.hasHiddenColumns ()) { -this.text.append ("VIEW_HIDECOLS\t"); -var hc = cs.getHiddenColumns (); -var comma = false; -for (var r, $r = hc.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { -if (!comma) { -comma = true; -} else { -this.text.append (","); -}this.text.append ("" + r[0]); -this.text.append ("-"); -this.text.append ("" + r[1]); -} -this.text.append ("\n"); -}if (annotations != null) { -var oneColour = true; -var row; -var comma; -var refSeq = null; -var refGroup = null; -var colours = new StringBuffer (); -var graphLine = new StringBuffer (); -var rowprops = new StringBuffer (); -var graphGroup = new java.util.Hashtable (); -var graphGroup_refs = new java.util.Hashtable (); -var graphGroupSeen = new java.util.BitSet (); -var color; -for (var i = 0; i < annotations.length; i++) { -row = annotations[i]; -if (!row.visible && !row.hasScore () && !(row.graphGroup > -1 && graphGroupSeen.get (row.graphGroup))) { -continue; -}color = null; -oneColour = true; -this.writeSequence_Ref (refSeq, row.sequenceRef); -refSeq = row.sequenceRef; -this.writeGroup_Ref (refGroup, row.groupRef); -refGroup = row.groupRef; -var hasGlyphs = row.hasIcons; -var hasLabels = row.hasText; -var hasValues = row.$hasScore; -var hasText = false; -for (var j = 0; row.annotations != null && j < row.annotations.length && (!hasGlyphs || !hasLabels || !hasValues); j++) { -if (row.annotations[j] != null) { -hasLabels = new Boolean (hasLabels | (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" "))).valueOf (); -hasGlyphs = new Boolean (hasGlyphs | ((row.annotations[j].secondaryStructure).charCodeAt (0) != 0 && row.annotations[j].secondaryStructure != ' ')).valueOf (); -hasValues = new Boolean (hasValues | (!Float.isNaN (row.annotations[j].value))).valueOf (); -hasText = new Boolean (hasText | (row.annotations[j].description != null && row.annotations[j].description.length > 0)).valueOf (); -}} -if (row.graph == 0) { -this.text.append ("NO_GRAPH\t"); -hasValues = false; -} else { -if (row.graph == 1) { -this.text.append ("BAR_GRAPH\t"); -hasGlyphs = false; -} else if (row.graph == 2) { -hasGlyphs = false; -this.text.append ("LINE_GRAPH\t"); -}if (row.getThreshold () != null) { -graphLine.append ("GRAPHLINE\t"); -graphLine.append (row.label); -graphLine.append ("\t"); -graphLine.append (row.getThreshold ().value); -graphLine.append ("\t"); -graphLine.append (row.getThreshold ().label); -graphLine.append ("\t"); -graphLine.append (jalview.util.Format.getHexString (row.getThreshold ().colour)); -graphLine.append (this.newline); -}if (row.graphGroup > -1) { -graphGroupSeen.set (row.graphGroup); -var key = new Integer (row.graphGroup); -if (graphGroup.containsKey (key)) { -graphGroup.put (key, graphGroup.get (key) + "\t" + row.label); -} else { -graphGroup_refs.put (key, Clazz.newArray (-1, [refSeq, refGroup])); -graphGroup.put (key, row.label); -}}}this.text.append (row.label + "\t"); -if (row.description != null) { -this.text.append (row.description + "\t"); -}for (var j = 0; row.annotations != null && j < row.annotations.length; j++) { -if (refSeq != null && jalview.util.Comparison.isGap (refSeq.getCharAt (j))) { -continue; -}if (row.annotations[j] != null) { -comma = ""; -if (hasGlyphs) { -this.text.append (comma); -if (row.annotations[j].secondaryStructure != ' ') { -this.text.append (row.annotations[j].secondaryStructure); -}comma = ","; -}if (hasValues) { -if (!Float.isNaN (row.annotations[j].value)) { -this.text.append (comma + row.annotations[j].value); -} else { -System.err.println ("Skipping NaN - not valid value."); -this.text.append (comma + 0); -}comma = ","; -}if (hasLabels) { -if (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" ")) { -this.text.append (comma + row.annotations[j].displayCharacter); -comma = ","; -}}if (hasText) { -if (row.annotations[j].description != null && row.annotations[j].description.length > 0 && !row.annotations[j].description.equals (row.annotations[j].displayCharacter)) { -this.text.append (comma + row.annotations[j].description); -comma = ","; -}}if (color != null && !color.equals (row.annotations[j].colour)) { -oneColour = false; -}color = row.annotations[j].colour; -if (row.annotations[j].colour != null && row.annotations[j].colour !== java.awt.Color.black) { -this.text.append (comma + "[" + jalview.util.Format.getHexString (row.annotations[j].colour) + "]"); -comma = ","; -}}this.text.append ("|"); -} -if (row.hasScore ()) { -this.text.append ("\t" + row.score); -}this.text.append (this.newline); -if (color != null && color !== java.awt.Color.black && oneColour) { -colours.append ("COLOUR\t"); -colours.append (row.label); -colours.append ("\t"); -colours.append (jalview.util.Format.getHexString (color)); -colours.append (this.newline); -}if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) { -rowprops.append ("ROWPROPERTIES\t"); -rowprops.append (row.label); -rowprops.append ("\tscaletofit="); -rowprops.append (row.scaleColLabel); -rowprops.append ("\tshowalllabs="); -rowprops.append (row.showAllColLabels); -rowprops.append ("\tcentrelabs="); -rowprops.append (row.centreColLabels); -rowprops.append (this.newline); -}if (graphLine.length () > 0) { -this.text.append (graphLine.toString ()); -graphLine.setLength (0); -}} -this.text.append (this.newline); -this.text.append (colours.toString ()); -if (graphGroup.size () > 0) { -var oldRefSeq = refSeq; -var oldRefGroup = refGroup; -for (var combine_statement, $combine_statement = graphGroup.entrySet ().iterator (); $combine_statement.hasNext () && ((combine_statement = $combine_statement.next ()) || true);) { -var seqRefAndGroup = graphGroup_refs.get (combine_statement.getKey ()); -this.writeSequence_Ref (refSeq, seqRefAndGroup[0]); -refSeq = seqRefAndGroup[0]; -this.writeGroup_Ref (refGroup, seqRefAndGroup[1]); -refGroup = seqRefAndGroup[1]; -this.text.append ("COMBINE\t"); -this.text.append (combine_statement.getValue ()); -this.text.append (this.newline); -} -this.writeSequence_Ref (refSeq, oldRefSeq); -refSeq = oldRefSeq; -this.writeGroup_Ref (refGroup, oldRefGroup); -refGroup = oldRefGroup; -}this.text.append (rowprops.toString ()); -}if (list != null) { -this.printGroups (list); -}if (properties != null) { -this.text.append (this.newline); -this.text.append (this.newline); -this.text.append ("ALIGNMENT"); -var en = properties.keys (); -while (en.hasMoreElements ()) { -var key = en.nextElement ().toString (); -this.text.append ("\t"); -this.text.append (key); -this.text.append ("="); -this.text.append (properties.get (key)); -} -}return this.text.toString (); -}, "~A,java.util.List,java.util.Hashtable,jalview.datamodel.ColumnSelection,jalview.datamodel.AlignmentI,jalview.io.AnnotationFile.ViewDef"); -Clazz.defineMethod (c$, "writeGroup_Ref", -($fz = function (refGroup, next_refGroup) { -if (next_refGroup == null) { -if (refGroup != null) { -this.text.append (this.newline); -this.text.append ("GROUP_REF\t"); -this.text.append ("ALIGNMENT"); -this.text.append (this.newline); -}return true; -} else { -if (refGroup == null || refGroup !== next_refGroup) { -this.text.append (this.newline); -this.text.append ("GROUP_REF\t"); -this.text.append (next_refGroup.getName ()); -this.text.append (this.newline); -return true; -}}return false; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "writeSequence_Ref", -($fz = function (refSeq, next_refSeq) { -if (next_refSeq == null) { -if (refSeq != null) { -this.text.append (this.newline); -this.text.append ("SEQUENCE_REF\t"); -this.text.append ("ALIGNMENT"); -this.text.append (this.newline); -return true; -}} else { -if (refSeq == null || refSeq !== next_refSeq) { -this.text.append (this.newline); -this.text.append ("SEQUENCE_REF\t"); -this.text.append (next_refSeq.getName ()); -this.text.append (this.newline); -return true; -}}return false; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "printGroups", -function (list) { -var seqrep = null; -for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (!sg.hasSeqrep ()) { -this.text.append ("SEQUENCE_GROUP\t" + sg.getName () + "\t" + (sg.getStartRes () + 1) + "\t" + (sg.getEndRes () + 1) + "\t" + "-1\t"); -seqrep = null; -} else { -seqrep = sg.getSeqrep (); -this.text.append ("SEQUENCE_REF\t"); -this.text.append (seqrep.getName ()); -this.text.append (this.newline); -this.text.append ("SEQUENCE_GROUP\t"); -this.text.append (sg.getName ()); -this.text.append ("\t"); -this.text.append ("" + (seqrep.findPosition (sg.getStartRes ()))); -this.text.append ("\t"); -this.text.append ((seqrep.findPosition (sg.getEndRes ()))); -this.text.append ("\t"); -this.text.append ("-1\t"); -}for (var s = 0; s < sg.getSize (); s++) { -this.text.append (sg.getSequenceAt (s).getName ()); -this.text.append ("\t"); -} -this.text.append (this.newline); -this.text.append ("PROPERTIES\t"); -this.text.append (sg.getName ()); -this.text.append ("\t"); -if (sg.getDescription () != null) { -this.text.append ("description="); -this.text.append (sg.getDescription ()); -this.text.append ("\t"); -}if (sg.cs != null) { -this.text.append ("colour="); -this.text.append (jalview.schemes.ColourSchemeProperty.getColourName (sg.cs)); -this.text.append ("\t"); -if (sg.cs.getThreshold () != 0) { -this.text.append ("pidThreshold="); -this.text.append (sg.cs.getThreshold ()); -}if (sg.cs.conservationApplied ()) { -this.text.append ("consThreshold="); -this.text.append (sg.cs.getConservationInc ()); -this.text.append ("\t"); -}}this.text.append ("outlineColour="); -this.text.append (jalview.util.Format.getHexString (sg.getOutlineColour ())); -this.text.append ("\t"); -this.text.append ("displayBoxes="); -this.text.append (sg.getDisplayBoxes ()); -this.text.append ("\t"); -this.text.append ("displayText="); -this.text.append (sg.getDisplayText ()); -this.text.append ("\t"); -this.text.append ("colourText="); -this.text.append (sg.getColourText ()); -this.text.append ("\t"); -this.text.append ("showUnconserved="); -this.text.append (sg.getShowNonconserved ()); -this.text.append ("\t"); -if (sg.textColour !== java.awt.Color.black) { -this.text.append ("textCol1="); -this.text.append (jalview.util.Format.getHexString (sg.textColour)); -this.text.append ("\t"); -}if (sg.textColour2 !== java.awt.Color.white) { -this.text.append ("textCol2="); -this.text.append (jalview.util.Format.getHexString (sg.textColour2)); -this.text.append ("\t"); -}if (sg.thresholdTextColour != 0) { -this.text.append ("textColThreshold="); -this.text.append (sg.thresholdTextColour); -this.text.append ("\t"); -}if (sg.idColour != null) { -this.text.append ("idColour="); -this.text.append (jalview.util.Format.getHexString (sg.idColour)); -this.text.append ("\t"); -}if (sg.isHidereps ()) { -this.text.append ("hide=true\t"); -}if (sg.isHideCols ()) { -this.text.append ("hidecols=true\t"); -}if (seqrep != null) { -this.text.append (this.newline); -this.text.append ("SEQUENCE_REF"); -}this.text.append (this.newline); -this.text.append (this.newline); -} -}, "java.util.List"); -Clazz.defineMethod (c$, "annotateAlignmentView", -function (viewport, file, protocol) { -var colSel = viewport.getColumnSelection (); -if (colSel == null) { -colSel = new jalview.datamodel.ColumnSelection (); -}var rslt = this.readAnnotationFile (viewport.getAlignment (), colSel, file, protocol); -if (rslt && (colSel.hasSelectedColumns () || colSel.hasHiddenColumns ())) { -viewport.setColumnSelection (colSel); -}return rslt; -}, "jalview.api.AlignViewportI,~S,~S"); -Clazz.defineMethod (c$, "readAnnotationFile", -function (al, file, protocol) { -return this.readAnnotationFile (al, null, file, protocol); -}, "jalview.datamodel.AlignmentI,~S,~S"); -Clazz.defineMethod (c$, "readAnnotationFile", -function (al, colSel, file, protocol) { -var $in = null; -try { -if (protocol.equals (jalview.io.AppletFormatAdapter.FILE)) { -$in = jalview.jsdev.GenericFileAdapter.getReader (file, false); -} else if (protocol.equals (jalview.io.AppletFormatAdapter.URL)) { -$in = jalview.jsdev.GenericFileAdapter.getReader (file, true); -} else if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) { -$in = new java.io.BufferedReader ( new java.io.StringReader (file)); -} else if (protocol.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) { -var is = this.getClass ().getResourceAsStream ("/" + file); -if (is != null) { -$in = new java.io.BufferedReader ( new java.io.InputStreamReader (is)); -}}if ($in != null) { -return this.parseAnnotationFrom (al, colSel, $in); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -System.out.println ("Problem reading annotation file: " + ex); -if (this.nlinesread > 0) { -System.out.println ("Last read line " + this.nlinesread + ": '" + this.lastread + "' (first 80 chars) ..."); -}return false; -} else { -throw ex; -} -} -return false; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,~S,~S"); -Clazz.defineMethod (c$, "parseAnnotationFrom", -function (al, colSel, $in) { -this.nlinesread = 0; -var combineAnnotation_calls = new java.util.ArrayList (); -var deferredAnnotation_calls = new java.util.ArrayList (); -var modified = false; -var groupRef = null; -var groupRefRows = new java.util.Hashtable (); -var autoAnnots = new java.util.Hashtable (); -{ -var line; -var label; -var description; -var token; -var graphStyle; -var index; -var refSeqIndex = 1; -var existingAnnotations = 0; -var overrideAutoAnnot = false; -if (al.getAlignmentAnnotation () != null) { -existingAnnotations = al.getAlignmentAnnotation ().length; -if (existingAnnotations > 0) { -var aa = al.getAlignmentAnnotation (); -for (var aai = 0; aai < aa.length; aai++) { -if (aa[aai].autoCalculated) { -autoAnnots.put (this.autoAnnotsKey (aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName ())), new Integer (1)); -}} -}}var alWidth = al.getWidth (); -var st; -var annotations; -var annotation = null; -var jvAnnotationFile = false; -while ((line = $in.readLine ()) != null) { -this.nlinesread++; -this.lastread = String.instantialize (line); -if (line.indexOf ("#") == 0) { -continue; -}if (line.indexOf ("JALVIEW_ANNOTATION") > -1) { -jvAnnotationFile = true; -break; -}} -if (!jvAnnotationFile) { -$in.close (); -return false; -}while ((line = $in.readLine ()) != null) { -this.nlinesread++; -this.lastread = String.instantialize (line); -if (line.indexOf ("#") == 0 || line.indexOf ("JALVIEW_ANNOTATION") > -1 || line.length == 0) { -continue; -}st = new java.util.StringTokenizer (line, "\t"); -token = st.nextToken (); -if (token.equalsIgnoreCase ("COLOUR")) { -this.colourAnnotations (al, st.nextToken (), st.nextToken ()); -modified = true; -continue; -} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.COMBINE)) { -combineAnnotation_calls.add ( Clazz.newArray (-1, [st, this.refSeq, groupRef])); -modified = true; -continue; -} else if (token.equalsIgnoreCase ("ROWPROPERTIES")) { -this.addRowProperties (al, st); -modified = true; -continue; -} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.GRAPHLINE)) { -deferredAnnotation_calls.add ( Clazz.newArray (-1, [jalview.io.AnnotationFile.GRAPHLINE, st, this.refSeq, groupRef])); -modified = true; -continue; -} else if (token.equalsIgnoreCase ("SEQUENCE_REF")) { -if (st.hasMoreTokens ()) { -this.refSeq = al.findName (this.refSeqId = st.nextToken ()); -if (this.refSeq == null) { -this.refSeqId = null; -}try { -refSeqIndex = Integer.parseInt (st.nextToken ()); -if (refSeqIndex < 1) { -refSeqIndex = 1; -System.out.println ("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile"); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -refSeqIndex = 1; -} else { -throw ex; -} -} -} else { -this.refSeq = null; -this.refSeqId = null; -}continue; -} else if (token.equalsIgnoreCase ("GROUP_REF")) { -groupRef = null; -if (st.hasMoreTokens ()) { -groupRef = st.nextToken (); -if (groupRef.length < 1) { -groupRef = null; -} else { -if (groupRefRows.get (groupRef) == null) { -groupRefRows.put (groupRef, new java.util.Vector ()); -}}}continue; -} else if (token.equalsIgnoreCase ("SEQUENCE_GROUP")) { -this.addGroup (al, st); -modified = true; -continue; -} else if (token.equalsIgnoreCase ("PROPERTIES")) { -this.addProperties (al, st); -modified = true; -continue; -} else if (token.equalsIgnoreCase ("BELOW_ALIGNMENT")) { -this.setBelowAlignment (al, st); -modified = true; -continue; -} else if (token.equalsIgnoreCase ("ALIGNMENT")) { -this.addAlignmentDetails (al, st); -modified = true; -continue; -} else if (token.equalsIgnoreCase ("VIEW_SETREF")) { -if (this.refSeq != null) { -al.setSeqrep (this.refSeq); -}modified = true; -continue; -} else if (token.equalsIgnoreCase ("VIEW_HIDECOLS")) { -if (st.hasMoreTokens ()) { -if (colSel == null) { -colSel = new jalview.datamodel.ColumnSelection (); -}this.parseHideCols (colSel, st.nextToken ()); -}modified = true; -continue; -} else if (token.equalsIgnoreCase ("HIDE_INSERTIONS")) { -var sr = this.refSeq == null ? al.getSeqrep () : this.refSeq; -if (sr == null) { -sr = al.getSequenceAt (0); -}if (sr != null) { -if (colSel == null) { -System.err.println ("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: " + line); -} else { -colSel.hideInsertionsFor (sr); -}}modified = true; -continue; -}graphStyle = jalview.datamodel.AlignmentAnnotation.getGraphValueFromString (token); -label = st.nextToken (); -index = 0; -annotations = new Array (alWidth); -description = null; -var score = NaN; -if (st.hasMoreTokens ()) { -line = st.nextToken (); -if (line.indexOf ("|") == -1) { -description = line; -if (st.hasMoreTokens ()) { -line = st.nextToken (); -}}if (st.hasMoreTokens ()) { -score = Float.$valueOf (st.nextToken ()).floatValue (); -}st = new java.util.StringTokenizer (line, "|", true); -var emptyColumn = true; -var onlyOneElement = (st.countTokens () == 1); -while (st.hasMoreElements () && index < alWidth) { -token = st.nextToken ().trim (); -if (onlyOneElement) { -try { -score = Float.$valueOf (token).floatValue (); -break; -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -}if (token.equals ("|")) { -if (emptyColumn) { -index++; -}emptyColumn = true; -} else { -annotations[index++] = this.parseAnnotation (token, graphStyle); -emptyColumn = false; -}} -}annotation = new jalview.datamodel.AlignmentAnnotation (label, description, (index == 0) ? null : annotations, 0, 0, graphStyle); -annotation.score = score; -if (!overrideAutoAnnot && autoAnnots.containsKey (this.autoAnnotsKey (annotation, this.refSeq, groupRef))) { -continue; -}if (this.refSeq != null) { -annotation.belowAlignment = false; -var referedSeq = this.refSeq; -do { -var ann = new jalview.datamodel.AlignmentAnnotation (annotation); -annotation.createSequenceMapping (referedSeq, refSeqIndex, false); -annotation.adjustForAlignment (); -referedSeq.addAlignmentAnnotation (annotation); -al.addAnnotation (annotation); -al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1); -if (groupRef != null) { -(groupRefRows.get (groupRef)).addElement (annotation); -}annotation = ann; -} while (this.refSeqId != null && (referedSeq = al.findName (referedSeq, this.refSeqId, true)) != null); -} else { -al.addAnnotation (annotation); -al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1); -if (groupRef != null) { -(groupRefRows.get (groupRef)).addElement (annotation); -}}modified = true; -} -var groupRefLookup = new java.util.Hashtable (); -var en = groupRefRows.keys (); -while (en.hasMoreElements ()) { -groupRef = en.nextElement (); -var matched = false; -for (var theGroup, $theGroup = al.getGroups ().iterator (); $theGroup.hasNext () && ((theGroup = $theGroup.next ()) || true);) { -if (theGroup.getName ().equals (groupRef)) { -if (matched) { -System.err.println ("Ignoring 1:many group reference mappings for group name '" + groupRef + "'"); -} else { -matched = true; -var rowset = groupRefRows.get (groupRef); -groupRefLookup.put (groupRef, theGroup); -if (rowset != null && rowset.size () > 0) { -var alan = null; -for (var elm = 0, elmSize = rowset.size (); elm < elmSize; elm++) { -alan = rowset.elementAt (elm); -alan.groupRef = theGroup; -} -}}}} -(groupRefRows.get (groupRef)).removeAllElements (); -} -for (var _deferred_args, $_deferred_args = deferredAnnotation_calls.iterator (); $_deferred_args.hasNext () && ((_deferred_args = $_deferred_args.next ()) || true);) { -if (_deferred_args[0] === jalview.io.AnnotationFile.GRAPHLINE) { -this.addLine (al, _deferred_args[1], _deferred_args[2], (_deferred_args[3] == null) ? null : groupRefLookup.get (_deferred_args[3])); -}} -var combinecount = 0; -for (var _combine_args, $_combine_args = combineAnnotation_calls.iterator (); $_combine_args.hasNext () && ((_combine_args = $_combine_args.next ()) || true);) { -this.combineAnnotations (al, ++combinecount, _combine_args[0], _combine_args[1], (_combine_args[2] == null) ? null : groupRefLookup.get (_combine_args[2])); -} -}return modified; -}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,java.io.BufferedReader"); -Clazz.defineMethod (c$, "parseHideCols", -($fz = function (colSel, nextToken) { -var inval = new java.util.StringTokenizer (nextToken, ","); -while (inval.hasMoreTokens ()) { -var range = inval.nextToken ().trim (); -var from; -var to = range.indexOf ("-"); -if (to == -1) { -from = to = Integer.parseInt (range); -if (from >= 0) { -colSel.hideColumns (from, to); -}} else { -from = Integer.parseInt (range.substring (0, to)); -if (to < range.length - 1) { -to = Integer.parseInt (range.substring (to + 1)); -} else { -to = from; -}if (from > 0 && to >= from) { -colSel.hideColumns (from, to); -}}} -}, $fz.isPrivate = true, $fz), "jalview.datamodel.ColumnSelection,~S"); -Clazz.defineMethod (c$, "autoAnnotsKey", -($fz = function (annotation, refSeq, groupRef) { -return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : ""); -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,~S"); -Clazz.defineMethod (c$, "parseAnnotation", -function (string, graphStyle) { -var hasSymbols = (graphStyle == 0); -var desc = null; -var displayChar = null; -var ss = ' '; -var value = 0; -var parsedValue = false; -var dcset = false; -var colour = null; -var i = string.indexOf ("["); -var j = string.indexOf ("]"); -if (i > -1 && j > -1) { -var ucs = new jalview.schemes.UserColourScheme (); -colour = ucs.getColourFromString (string.substring (i + 1, j)); -if (i > 0 && string.charAt (i - 1) == ',') { -i--; -}string = string.substring (0, i) + string.substring (j + 1); -}var st = new java.util.StringTokenizer (string, ",", true); -var token; -var seenContent = false; -var pass = 0; -while (st.hasMoreTokens ()) { -pass++; -token = st.nextToken ().trim (); -if (token.equals (",")) { -if (!seenContent && parsedValue && !dcset) { -dcset = true; -displayChar = " "; -}seenContent = false; -continue; -} else { -seenContent = true; -}if (!parsedValue) { -try { -displayChar = token; -value = new Float (token).floatValue (); -parsedValue = true; -continue; -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -} else { -if (token.length == 1) { -displayChar = token; -}}if (hasSymbols && (token.equals ("H") || token.equals ("E") || token.equals ("S") || token.equals (" "))) { -ss = token.charAt (0); -if (displayChar.equals (token.substring (0, 1))) { -displayChar = ""; -}} else if (desc == null || (parsedValue && pass > 2)) { -desc = token; -}} -if (displayChar != null && desc != null && desc.length == 1) { -if (displayChar.length > 1) { -var tmp = displayChar; -displayChar = desc; -desc = tmp; -} else { -if (displayChar.equals (desc)) { -desc = null; -}}}var anot = new jalview.datamodel.Annotation (displayChar, desc, ss, value); -anot.colour = colour; -return anot; -}, "~S,~N"); -Clazz.defineMethod (c$, "colourAnnotations", -function (al, label, colour) { -var ucs = new jalview.schemes.UserColourScheme (colour); -var annotations; -for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { -if (al.getAlignmentAnnotation ()[i].label.equalsIgnoreCase (label)) { -annotations = al.getAlignmentAnnotation ()[i].annotations; -for (var j = 0; j < annotations.length; j++) { -if (annotations[j] != null) { -annotations[j].colour = ucs.findColour ('A'); -}} -}} -}, "jalview.datamodel.AlignmentI,~S,~S"); -Clazz.defineMethod (c$, "combineAnnotations", -function (al, combineCount, st, seqRef, groupRef) { -var group = st.nextToken (); -var graphGroup = 0; -if (al.getAlignmentAnnotation () != null) { -for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { -var aa = al.getAlignmentAnnotation ()[i]; -if (aa.graphGroup > graphGroup) { -graphGroup = aa.graphGroup + 1; -}if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) { -if (aa.graphGroup > -1) { -graphGroup = aa.graphGroup; -} else { -if (graphGroup <= combineCount) { -graphGroup = combineCount + 1; -}aa.graphGroup = graphGroup; -}break; -}} -while (st.hasMoreTokens ()) { -group = st.nextToken (); -for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { -var aa = al.getAlignmentAnnotation ()[i]; -if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) { -aa.graphGroup = graphGroup; -break; -}} -} -} else { -System.err.println ("Couldn't combine annotations. None are added to alignment yet!"); -}}, "jalview.datamodel.AlignmentI,~N,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "addLine", -function (al, st, seqRef, groupRef) { -var group = st.nextToken (); -var annotation = null; -var alannot = al.getAlignmentAnnotation (); -var value = new Float (st.nextToken ()).floatValue (); -var label = st.hasMoreTokens () ? st.nextToken () : null; -var colour = null; -if (st.hasMoreTokens ()) { -var ucs = new jalview.schemes.UserColourScheme (st.nextToken ()); -colour = ucs.findColour ('A'); -}if (alannot != null) { -for (var i = 0; i < alannot.length; i++) { -if (alannot[i].label.equalsIgnoreCase (group) && (seqRef == null || alannot[i].sequenceRef === seqRef) && (groupRef == null || alannot[i].groupRef === groupRef)) { -alannot[i].setThreshold ( new jalview.datamodel.GraphLine (value, label, colour)); -}} -}if (annotation == null) { -return; -}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "addGroup", -function (al, st) { -var sg = new jalview.datamodel.SequenceGroup (); -sg.setName (st.nextToken ()); -var rng = ""; -try { -rng = st.nextToken (); -if (rng.length > 0 && !rng.startsWith ("*")) { -sg.setStartRes (Integer.parseInt (rng) - 1); -} else { -sg.setStartRes (0); -}rng = st.nextToken (); -if (rng.length > 0 && !rng.startsWith ("*")) { -sg.setEndRes (Integer.parseInt (rng) - 1); -} else { -sg.setEndRes (al.getWidth () - 1); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '" + rng + "' - assuming alignment width for group."); -sg.setStartRes (0); -sg.setEndRes (al.getWidth () - 1); -} else { -throw e; -} -} -var index = st.nextToken (); -if (index.equals ("-1")) { -while (st.hasMoreElements ()) { -sg.addSequence (al.findName (st.nextToken ()), false); -} -} else { -var st2 = new java.util.StringTokenizer (index, ","); -while (st2.hasMoreTokens ()) { -var tmp = st2.nextToken (); -if (tmp.equals ("*")) { -for (var i = 0; i < al.getHeight (); i++) { -sg.addSequence (al.getSequenceAt (i), false); -} -} else if (tmp.indexOf ("-") >= 0) { -var st3 = new java.util.StringTokenizer (tmp, "-"); -var start = (Integer.parseInt (st3.nextToken ())); -var end = (Integer.parseInt (st3.nextToken ())); -if (end > start) { -for (var i = start; i <= end; i++) { -sg.addSequence (al.getSequenceAt (i - 1), false); -} -}} else { -sg.addSequence (al.getSequenceAt (Integer.parseInt (tmp) - 1), false); -}} -}if (this.refSeq != null) { -sg.setStartRes (this.refSeq.findIndex (sg.getStartRes () + 1) - 1); -sg.setEndRes (this.refSeq.findIndex (sg.getEndRes () + 1) - 1); -sg.setSeqrep (this.refSeq); -}if (sg.getSize () > 0) { -al.addGroup (sg); -}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); -Clazz.defineMethod (c$, "addRowProperties", -function (al, st) { -var label = st.nextToken (); -var keyValue; -var key; -var value; -var scaletofit = false; -var centerlab = false; -var showalllabs = false; -while (st.hasMoreTokens ()) { -keyValue = st.nextToken (); -key = keyValue.substring (0, keyValue.indexOf ("=")); -value = keyValue.substring (keyValue.indexOf ("=") + 1); -if (key.equalsIgnoreCase ("scaletofit")) { -scaletofit = Boolean.$valueOf (value).booleanValue (); -}if (key.equalsIgnoreCase ("showalllabs")) { -showalllabs = Boolean.$valueOf (value).booleanValue (); -}if (key.equalsIgnoreCase ("centrelabs")) { -centerlab = Boolean.$valueOf (value).booleanValue (); -}var alr = al.getAlignmentAnnotation (); -if (alr != null) { -for (var i = 0; i < alr.length; i++) { -if (alr[i].label.equalsIgnoreCase (label)) { -alr[i].centreColLabels = centerlab; -alr[i].scaleColLabel = scaletofit; -alr[i].showAllColLabels = showalllabs; -}} -}} -}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); -Clazz.defineMethod (c$, "addProperties", -function (al, st) { -if (al.getGroups () == null) { -return; -}var name = st.nextToken (); -var sg = null; -for (var _sg, $_sg = al.getGroups ().iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) { -if ((sg = _sg).getName ().equals (name)) { -break; -} else { -sg = null; -}} -if (sg != null) { -var keyValue; -var key; -var value; -var def = sg.cs; -sg.cs = null; -while (st.hasMoreTokens ()) { -keyValue = st.nextToken (); -key = keyValue.substring (0, keyValue.indexOf ("=")); -value = keyValue.substring (keyValue.indexOf ("=") + 1); -if (key.equalsIgnoreCase ("description")) { -sg.setDescription (value); -} else if (key.equalsIgnoreCase ("colour")) { -sg.cs = jalview.schemes.ColourSchemeProperty.getColour (al, value); -} else if (key.equalsIgnoreCase ("pidThreshold")) { -sg.cs.setThreshold (Integer.parseInt (value), true); -} else if (key.equalsIgnoreCase ("consThreshold")) { -sg.cs.setConservationInc (Integer.parseInt (value)); -var c = new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes () + 1); -c.calculate (); -c.verdict (false, 25); -sg.cs.setConservation (c); -} else if (key.equalsIgnoreCase ("outlineColour")) { -sg.setOutlineColour ( new jalview.schemes.UserColourScheme (value).findColour ('A')); -} else if (key.equalsIgnoreCase ("displayBoxes")) { -sg.setDisplayBoxes (Boolean.$valueOf (value).booleanValue ()); -} else if (key.equalsIgnoreCase ("showUnconserved")) { -sg.setShowNonconserved (Boolean.$valueOf (value).booleanValue ()); -} else if (key.equalsIgnoreCase ("displayText")) { -sg.setDisplayText (Boolean.$valueOf (value).booleanValue ()); -} else if (key.equalsIgnoreCase ("colourText")) { -sg.setColourText (Boolean.$valueOf (value).booleanValue ()); -} else if (key.equalsIgnoreCase ("textCol1")) { -sg.textColour = new jalview.schemes.UserColourScheme (value).findColour ('A'); -} else if (key.equalsIgnoreCase ("textCol2")) { -sg.textColour2 = new jalview.schemes.UserColourScheme (value).findColour ('A'); -} else if (key.equalsIgnoreCase ("textColThreshold")) { -sg.thresholdTextColour = Integer.parseInt (value); -} else if (key.equalsIgnoreCase ("idColour")) { -sg.setIdColour ((def = new jalview.schemes.UserColourScheme (value)).findColour ('A')); -} else if (key.equalsIgnoreCase ("hide")) { -sg.setHidereps (true); -} else if (key.equalsIgnoreCase ("hidecols")) { -sg.setHideCols (true); -}sg.recalcConservation (); -} -if (sg.cs == null) { -sg.cs = def; -}}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); -Clazz.defineMethod (c$, "setBelowAlignment", -function (al, st) { -var token; -var aa; -var ala = al.getAlignmentAnnotation (); -if (ala == null) { -System.err.print ("Warning - no annotation to set below for sequence associated annotation:"); -}while (st.hasMoreTokens ()) { -token = st.nextToken (); -if (ala == null) { -System.err.print (" " + token); -} else { -for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { -aa = al.getAlignmentAnnotation ()[i]; -if (aa.sequenceRef === this.refSeq && aa.label.equals (token)) { -aa.belowAlignment = true; -}} -}} -if (ala == null) { -System.err.print ("\n"); -}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); -Clazz.defineMethod (c$, "addAlignmentDetails", -function (al, st) { -var keyValue; -var key; -var value; -while (st.hasMoreTokens ()) { -keyValue = st.nextToken (); -key = keyValue.substring (0, keyValue.indexOf ("=")); -value = keyValue.substring (keyValue.indexOf ("=") + 1); -al.setProperty (key, value); -} -}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); -Clazz.defineMethod (c$, "printCSVAnnotations", -function (annotations) { -var sp = new StringBuffer (); -for (var i = 0; i < annotations.length; i++) { -var atos = annotations[i].toString (); -var p = 0; -do { -var cp = atos.indexOf ("\n", p); -sp.append (annotations[i].label); -sp.append (","); -if (cp > p) { -sp.append (atos.substring (p, cp + 1)); -} else { -sp.append (atos.substring (p)); -sp.append (this.newline); -}p = cp + 1; -} while (p > 0); -} -return sp.toString (); -}, "~A"); -Clazz.defineMethod (c$, "printAnnotationsForView", -function (viewport) { -return this.printAnnotations (viewport.isShowAnnotation () ? viewport.getAlignment ().getAlignmentAnnotation () : null, viewport.getAlignment ().getGroups (), viewport.getAlignment ().getProperties (), viewport.getColumnSelection (), viewport.getAlignment (), null); -}, "jalview.api.AlignViewportI"); -Clazz.defineMethod (c$, "printAnnotationsForAlignment", -function (al) { -return this.printAnnotations (al.getAlignmentAnnotation (), al.getGroups (), al.getProperties (), null, al, null); -}, "jalview.datamodel.AlignmentI"); -c$.$AnnotationFile$ViewDef$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.viewname = null; -this.hidseqs = null; -this.hiddencols = null; -this.visibleGroups = null; -this.hiddenRepSeqs = null; -Clazz.instantialize (this, arguments); -}, jalview.io.AnnotationFile, "ViewDef"); -Clazz.makeConstructor (c$, -function (a, b, c, d) { -this.viewname = a; -this.hidseqs = b; -this.hiddencols = c; -this.hiddenRepSeqs = d; -}, "~S,jalview.datamodel.HiddenSequences,jalview.datamodel.ColumnSelection,java.util.Hashtable"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"GRAPHLINE", "GRAPHLINE", -"COMBINE", "COMBINE"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.AnnotationFile", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.ColumnSelection", "$.GraphLine", "$.SequenceGroup", "jalview.io.AppletFormatAdapter", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Comparison", "$.Format", "java.awt.Color", "java.io.BufferedReader", "$.InputStreamReader", "$.StringReader", "java.lang.Boolean", "$.Float", "$.StringBuffer", "java.util.ArrayList", "$.BitSet", "$.Date", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.newline = null; +this.text = null; +if (!Clazz.isClassDefined ("jalview.io.AnnotationFile.ViewDef")) { +jalview.io.AnnotationFile.$AnnotationFile$ViewDef$ (); +} +this.refSeq = null; +this.refSeqId = null; +this.nlinesread = 0; +this.lastread = ""; +Clazz.instantialize (this, arguments); +}, jalview.io, "AnnotationFile"); +Clazz.prepareFields (c$, function () { +this.newline = System.getProperty ("line.separator"); +}); +Clazz.makeConstructor (c$, +function () { +this.init (); +}); +Clazz.defineMethod (c$, "setNewlineString", +function (nl) { +this.newline = nl; +this.init (); +}, "~S"); +Clazz.defineMethod (c$, "getNewlineString", +function () { +return this.newline; +}); +Clazz.defineMethod (c$, "init", +($fz = function () { +this.text = new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " + new java.util.Date () + this.newline + this.newline); +this.refSeq = null; +this.refSeqId = null; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "printAnnotations", +function (annotations, list, properties) { +return this.printAnnotations (annotations, list, properties, null, null, null); +}, "~A,java.util.List,java.util.Hashtable"); +Clazz.defineMethod (c$, "printAnnotations", +function (annotations, list, properties, cs, al, view) { +if (view != null) { +if (view.viewname != null) { +this.text.append ("VIEW_DEF\t" + view.viewname + "\n"); +}if (list == null) { +list = view.visibleGroups; +}if (cs == null) { +cs = view.hiddencols; +}if (al == null) { +}}if (al != null && al.hasSeqrep ()) { +this.text.append ("VIEW_SETREF\t" + al.getSeqrep ().getName () + "\n"); +}if (cs != null && cs.hasHiddenColumns ()) { +this.text.append ("VIEW_HIDECOLS\t"); +var hc = cs.getHiddenColumns (); +var comma = false; +for (var r, $r = hc.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { +if (!comma) { +comma = true; +} else { +this.text.append (","); +}this.text.append ("" + r[0]); +this.text.append ("-"); +this.text.append ("" + r[1]); +} +this.text.append ("\n"); +}if (annotations != null) { +var oneColour = true; +var row; +var comma; +var refSeq = null; +var refGroup = null; +var colours = new StringBuffer (); +var graphLine = new StringBuffer (); +var rowprops = new StringBuffer (); +var graphGroup = new java.util.Hashtable (); +var graphGroup_refs = new java.util.Hashtable (); +var graphGroupSeen = new java.util.BitSet (); +var color; +for (var i = 0; i < annotations.length; i++) { +row = annotations[i]; +if (!row.visible && !row.hasScore () && !(row.graphGroup > -1 && graphGroupSeen.get (row.graphGroup))) { +continue; +}color = null; +oneColour = true; +this.writeSequence_Ref (refSeq, row.sequenceRef); +refSeq = row.sequenceRef; +this.writeGroup_Ref (refGroup, row.groupRef); +refGroup = row.groupRef; +var hasGlyphs = row.hasIcons; +var hasLabels = row.hasText; +var hasValues = row.$hasScore; +var hasText = false; +for (var j = 0; row.annotations != null && j < row.annotations.length && (!hasGlyphs || !hasLabels || !hasValues); j++) { +if (row.annotations[j] != null) { +hasLabels = new Boolean (hasLabels | (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" "))).valueOf (); +hasGlyphs = new Boolean (hasGlyphs | ((row.annotations[j].secondaryStructure).charCodeAt (0) != 0 && row.annotations[j].secondaryStructure != ' ')).valueOf (); +hasValues = new Boolean (hasValues | (!Float.isNaN (row.annotations[j].value))).valueOf (); +hasText = new Boolean (hasText | (row.annotations[j].description != null && row.annotations[j].description.length > 0)).valueOf (); +}} +if (row.graph == 0) { +this.text.append ("NO_GRAPH\t"); +hasValues = false; +} else { +if (row.graph == 1) { +this.text.append ("BAR_GRAPH\t"); +hasGlyphs = false; +} else if (row.graph == 2) { +hasGlyphs = false; +this.text.append ("LINE_GRAPH\t"); +}if (row.getThreshold () != null) { +graphLine.append ("GRAPHLINE\t"); +graphLine.append (row.label); +graphLine.append ("\t"); +graphLine.append (row.getThreshold ().value); +graphLine.append ("\t"); +graphLine.append (row.getThreshold ().label); +graphLine.append ("\t"); +graphLine.append (jalview.util.Format.getHexString (row.getThreshold ().colour)); +graphLine.append (this.newline); +}if (row.graphGroup > -1) { +graphGroupSeen.set (row.graphGroup); +var key = new Integer (row.graphGroup); +if (graphGroup.containsKey (key)) { +graphGroup.put (key, graphGroup.get (key) + "\t" + row.label); +} else { +graphGroup_refs.put (key, Clazz.newArray (-1, [refSeq, refGroup])); +graphGroup.put (key, row.label); +}}}this.text.append (row.label + "\t"); +if (row.description != null) { +this.text.append (row.description + "\t"); +}for (var j = 0; row.annotations != null && j < row.annotations.length; j++) { +if (refSeq != null && jalview.util.Comparison.isGap (refSeq.getCharAt (j))) { +continue; +}if (row.annotations[j] != null) { +comma = ""; +if (hasGlyphs) { +this.text.append (comma); +if (row.annotations[j].secondaryStructure != ' ') { +this.text.append (row.annotations[j].secondaryStructure); +}comma = ","; +}if (hasValues) { +if (!Float.isNaN (row.annotations[j].value)) { +this.text.append (comma + row.annotations[j].value); +} else { +System.err.println ("Skipping NaN - not valid value."); +this.text.append (comma + 0); +}comma = ","; +}if (hasLabels) { +if (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" ")) { +this.text.append (comma + row.annotations[j].displayCharacter); +comma = ","; +}}if (hasText) { +if (row.annotations[j].description != null && row.annotations[j].description.length > 0 && !row.annotations[j].description.equals (row.annotations[j].displayCharacter)) { +this.text.append (comma + row.annotations[j].description); +comma = ","; +}}if (color != null && !color.equals (row.annotations[j].colour)) { +oneColour = false; +}color = row.annotations[j].colour; +if (row.annotations[j].colour != null && row.annotations[j].colour !== java.awt.Color.black) { +this.text.append (comma + "[" + jalview.util.Format.getHexString (row.annotations[j].colour) + "]"); +comma = ","; +}}this.text.append ("|"); +} +if (row.hasScore ()) { +this.text.append ("\t" + row.score); +}this.text.append (this.newline); +if (color != null && color !== java.awt.Color.black && oneColour) { +colours.append ("COLOUR\t"); +colours.append (row.label); +colours.append ("\t"); +colours.append (jalview.util.Format.getHexString (color)); +colours.append (this.newline); +}if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) { +rowprops.append ("ROWPROPERTIES\t"); +rowprops.append (row.label); +rowprops.append ("\tscaletofit="); +rowprops.append (row.scaleColLabel); +rowprops.append ("\tshowalllabs="); +rowprops.append (row.showAllColLabels); +rowprops.append ("\tcentrelabs="); +rowprops.append (row.centreColLabels); +rowprops.append (this.newline); +}if (graphLine.length () > 0) { +this.text.append (graphLine.toString ()); +graphLine.setLength (0); +}} +this.text.append (this.newline); +this.text.append (colours.toString ()); +if (graphGroup.size () > 0) { +var oldRefSeq = refSeq; +var oldRefGroup = refGroup; +for (var combine_statement, $combine_statement = graphGroup.entrySet ().iterator (); $combine_statement.hasNext () && ((combine_statement = $combine_statement.next ()) || true);) { +var seqRefAndGroup = graphGroup_refs.get (combine_statement.getKey ()); +this.writeSequence_Ref (refSeq, seqRefAndGroup[0]); +refSeq = seqRefAndGroup[0]; +this.writeGroup_Ref (refGroup, seqRefAndGroup[1]); +refGroup = seqRefAndGroup[1]; +this.text.append ("COMBINE\t"); +this.text.append (combine_statement.getValue ()); +this.text.append (this.newline); +} +this.writeSequence_Ref (refSeq, oldRefSeq); +refSeq = oldRefSeq; +this.writeGroup_Ref (refGroup, oldRefGroup); +refGroup = oldRefGroup; +}this.text.append (rowprops.toString ()); +}if (list != null) { +this.printGroups (list); +}if (properties != null) { +this.text.append (this.newline); +this.text.append (this.newline); +this.text.append ("ALIGNMENT"); +var en = properties.keys (); +while (en.hasMoreElements ()) { +var key = en.nextElement ().toString (); +this.text.append ("\t"); +this.text.append (key); +this.text.append ("="); +this.text.append (properties.get (key)); +} +}return this.text.toString (); +}, "~A,java.util.List,java.util.Hashtable,jalview.datamodel.ColumnSelection,jalview.datamodel.AlignmentI,jalview.io.AnnotationFile.ViewDef"); +Clazz.defineMethod (c$, "writeGroup_Ref", +($fz = function (refGroup, next_refGroup) { +if (next_refGroup == null) { +if (refGroup != null) { +this.text.append (this.newline); +this.text.append ("GROUP_REF\t"); +this.text.append ("ALIGNMENT"); +this.text.append (this.newline); +}return true; +} else { +if (refGroup == null || refGroup !== next_refGroup) { +this.text.append (this.newline); +this.text.append ("GROUP_REF\t"); +this.text.append (next_refGroup.getName ()); +this.text.append (this.newline); +return true; +}}return false; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "writeSequence_Ref", +($fz = function (refSeq, next_refSeq) { +if (next_refSeq == null) { +if (refSeq != null) { +this.text.append (this.newline); +this.text.append ("SEQUENCE_REF\t"); +this.text.append ("ALIGNMENT"); +this.text.append (this.newline); +return true; +}} else { +if (refSeq == null || refSeq !== next_refSeq) { +this.text.append (this.newline); +this.text.append ("SEQUENCE_REF\t"); +this.text.append (next_refSeq.getName ()); +this.text.append (this.newline); +return true; +}}return false; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "printGroups", +function (list) { +var seqrep = null; +for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (!sg.hasSeqrep ()) { +this.text.append ("SEQUENCE_GROUP\t" + sg.getName () + "\t" + (sg.getStartRes () + 1) + "\t" + (sg.getEndRes () + 1) + "\t" + "-1\t"); +seqrep = null; +} else { +seqrep = sg.getSeqrep (); +this.text.append ("SEQUENCE_REF\t"); +this.text.append (seqrep.getName ()); +this.text.append (this.newline); +this.text.append ("SEQUENCE_GROUP\t"); +this.text.append (sg.getName ()); +this.text.append ("\t"); +this.text.append ("" + (seqrep.findPosition (sg.getStartRes ()))); +this.text.append ("\t"); +this.text.append ((seqrep.findPosition (sg.getEndRes ()))); +this.text.append ("\t"); +this.text.append ("-1\t"); +}for (var s = 0; s < sg.getSize (); s++) { +this.text.append (sg.getSequenceAt (s).getName ()); +this.text.append ("\t"); +} +this.text.append (this.newline); +this.text.append ("PROPERTIES\t"); +this.text.append (sg.getName ()); +this.text.append ("\t"); +if (sg.getDescription () != null) { +this.text.append ("description="); +this.text.append (sg.getDescription ()); +this.text.append ("\t"); +}if (sg.cs != null) { +this.text.append ("colour="); +this.text.append (jalview.schemes.ColourSchemeProperty.getColourName (sg.cs)); +this.text.append ("\t"); +if (sg.cs.getThreshold () != 0) { +this.text.append ("pidThreshold="); +this.text.append (sg.cs.getThreshold ()); +}if (sg.cs.conservationApplied ()) { +this.text.append ("consThreshold="); +this.text.append (sg.cs.getConservationInc ()); +this.text.append ("\t"); +}}this.text.append ("outlineColour="); +this.text.append (jalview.util.Format.getHexString (sg.getOutlineColour ())); +this.text.append ("\t"); +this.text.append ("displayBoxes="); +this.text.append (sg.getDisplayBoxes ()); +this.text.append ("\t"); +this.text.append ("displayText="); +this.text.append (sg.getDisplayText ()); +this.text.append ("\t"); +this.text.append ("colourText="); +this.text.append (sg.getColourText ()); +this.text.append ("\t"); +this.text.append ("showUnconserved="); +this.text.append (sg.getShowNonconserved ()); +this.text.append ("\t"); +if (sg.textColour !== java.awt.Color.black) { +this.text.append ("textCol1="); +this.text.append (jalview.util.Format.getHexString (sg.textColour)); +this.text.append ("\t"); +}if (sg.textColour2 !== java.awt.Color.white) { +this.text.append ("textCol2="); +this.text.append (jalview.util.Format.getHexString (sg.textColour2)); +this.text.append ("\t"); +}if (sg.thresholdTextColour != 0) { +this.text.append ("textColThreshold="); +this.text.append (sg.thresholdTextColour); +this.text.append ("\t"); +}if (sg.idColour != null) { +this.text.append ("idColour="); +this.text.append (jalview.util.Format.getHexString (sg.idColour)); +this.text.append ("\t"); +}if (sg.isHidereps ()) { +this.text.append ("hide=true\t"); +}if (sg.isHideCols ()) { +this.text.append ("hidecols=true\t"); +}if (seqrep != null) { +this.text.append (this.newline); +this.text.append ("SEQUENCE_REF"); +}this.text.append (this.newline); +this.text.append (this.newline); +} +}, "java.util.List"); +Clazz.defineMethod (c$, "annotateAlignmentView", +function (viewport, file, protocol) { +var colSel = viewport.getColumnSelection (); +if (colSel == null) { +colSel = new jalview.datamodel.ColumnSelection (); +}var rslt = this.readAnnotationFile (viewport.getAlignment (), colSel, file, protocol); +if (rslt && (colSel.hasSelectedColumns () || colSel.hasHiddenColumns ())) { +viewport.setColumnSelection (colSel); +}return rslt; +}, "jalview.api.AlignViewportI,~S,~S"); +Clazz.defineMethod (c$, "readAnnotationFile", +function (al, file, protocol) { +return this.readAnnotationFile (al, null, file, protocol); +}, "jalview.datamodel.AlignmentI,~S,~S"); +Clazz.defineMethod (c$, "readAnnotationFile", +function (al, colSel, file, protocol) { +var $in = null; +try { +if (protocol.equals (jalview.io.AppletFormatAdapter.FILE)) { +$in = jalview.jsdev.GenericFileAdapter.getReader (file, false); +} else if (protocol.equals (jalview.io.AppletFormatAdapter.URL)) { +$in = jalview.jsdev.GenericFileAdapter.getReader (file, true); +} else if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) { +$in = new java.io.BufferedReader ( new java.io.StringReader (file)); +} else if (protocol.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) { +var is = this.getClass ().getResourceAsStream ("/" + file); +if (is != null) { +$in = new java.io.BufferedReader ( new java.io.InputStreamReader (is)); +}}if ($in != null) { +return this.parseAnnotationFrom (al, colSel, $in); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +System.out.println ("Problem reading annotation file: " + ex); +if (this.nlinesread > 0) { +System.out.println ("Last read line " + this.nlinesread + ": '" + this.lastread + "' (first 80 chars) ..."); +}return false; +} else { +throw ex; +} +} +return false; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,~S,~S"); +Clazz.defineMethod (c$, "parseAnnotationFrom", +function (al, colSel, $in) { +this.nlinesread = 0; +var combineAnnotation_calls = new java.util.ArrayList (); +var deferredAnnotation_calls = new java.util.ArrayList (); +var modified = false; +var groupRef = null; +var groupRefRows = new java.util.Hashtable (); +var autoAnnots = new java.util.Hashtable (); +{ +var line; +var label; +var description; +var token; +var graphStyle; +var index; +var refSeqIndex = 1; +var existingAnnotations = 0; +var overrideAutoAnnot = false; +if (al.getAlignmentAnnotation () != null) { +existingAnnotations = al.getAlignmentAnnotation ().length; +if (existingAnnotations > 0) { +var aa = al.getAlignmentAnnotation (); +for (var aai = 0; aai < aa.length; aai++) { +if (aa[aai].autoCalculated) { +autoAnnots.put (this.autoAnnotsKey (aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName ())), new Integer (1)); +}} +}}var alWidth = al.getWidth (); +var st; +var annotations; +var annotation = null; +var jvAnnotationFile = false; +while ((line = $in.readLine ()) != null) { +this.nlinesread++; +this.lastread = String.instantialize (line); +if (line.indexOf ("#") == 0) { +continue; +}if (line.indexOf ("JALVIEW_ANNOTATION") > -1) { +jvAnnotationFile = true; +break; +}} +if (!jvAnnotationFile) { +$in.close (); +return false; +}while ((line = $in.readLine ()) != null) { +this.nlinesread++; +this.lastread = String.instantialize (line); +if (line.indexOf ("#") == 0 || line.indexOf ("JALVIEW_ANNOTATION") > -1 || line.length == 0) { +continue; +}st = new java.util.StringTokenizer (line, "\t"); +token = st.nextToken (); +if (token.equalsIgnoreCase ("COLOUR")) { +this.colourAnnotations (al, st.nextToken (), st.nextToken ()); +modified = true; +continue; +} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.COMBINE)) { +combineAnnotation_calls.add ( Clazz.newArray (-1, [st, this.refSeq, groupRef])); +modified = true; +continue; +} else if (token.equalsIgnoreCase ("ROWPROPERTIES")) { +this.addRowProperties (al, st); +modified = true; +continue; +} else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.GRAPHLINE)) { +deferredAnnotation_calls.add ( Clazz.newArray (-1, [jalview.io.AnnotationFile.GRAPHLINE, st, this.refSeq, groupRef])); +modified = true; +continue; +} else if (token.equalsIgnoreCase ("SEQUENCE_REF")) { +if (st.hasMoreTokens ()) { +this.refSeq = al.findName (this.refSeqId = st.nextToken ()); +if (this.refSeq == null) { +this.refSeqId = null; +}try { +refSeqIndex = Integer.parseInt (st.nextToken ()); +if (refSeqIndex < 1) { +refSeqIndex = 1; +System.out.println ("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile"); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +refSeqIndex = 1; +} else { +throw ex; +} +} +} else { +this.refSeq = null; +this.refSeqId = null; +}continue; +} else if (token.equalsIgnoreCase ("GROUP_REF")) { +groupRef = null; +if (st.hasMoreTokens ()) { +groupRef = st.nextToken (); +if (groupRef.length < 1) { +groupRef = null; +} else { +if (groupRefRows.get (groupRef) == null) { +groupRefRows.put (groupRef, new java.util.Vector ()); +}}}continue; +} else if (token.equalsIgnoreCase ("SEQUENCE_GROUP")) { +this.addGroup (al, st); +modified = true; +continue; +} else if (token.equalsIgnoreCase ("PROPERTIES")) { +this.addProperties (al, st); +modified = true; +continue; +} else if (token.equalsIgnoreCase ("BELOW_ALIGNMENT")) { +this.setBelowAlignment (al, st); +modified = true; +continue; +} else if (token.equalsIgnoreCase ("ALIGNMENT")) { +this.addAlignmentDetails (al, st); +modified = true; +continue; +} else if (token.equalsIgnoreCase ("VIEW_SETREF")) { +if (this.refSeq != null) { +al.setSeqrep (this.refSeq); +}modified = true; +continue; +} else if (token.equalsIgnoreCase ("VIEW_HIDECOLS")) { +if (st.hasMoreTokens ()) { +if (colSel == null) { +colSel = new jalview.datamodel.ColumnSelection (); +}this.parseHideCols (colSel, st.nextToken ()); +}modified = true; +continue; +} else if (token.equalsIgnoreCase ("HIDE_INSERTIONS")) { +var sr = this.refSeq == null ? al.getSeqrep () : this.refSeq; +if (sr == null) { +sr = al.getSequenceAt (0); +}if (sr != null) { +if (colSel == null) { +System.err.println ("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: " + line); +} else { +colSel.hideInsertionsFor (sr); +}}modified = true; +continue; +}graphStyle = jalview.datamodel.AlignmentAnnotation.getGraphValueFromString (token); +label = st.nextToken (); +index = 0; +annotations = new Array (alWidth); +description = null; +var score = NaN; +if (st.hasMoreTokens ()) { +line = st.nextToken (); +if (line.indexOf ("|") == -1) { +description = line; +if (st.hasMoreTokens ()) { +line = st.nextToken (); +}}if (st.hasMoreTokens ()) { +score = Float.$valueOf (st.nextToken ()).floatValue (); +}st = new java.util.StringTokenizer (line, "|", true); +var emptyColumn = true; +var onlyOneElement = (st.countTokens () == 1); +while (st.hasMoreElements () && index < alWidth) { +token = st.nextToken ().trim (); +if (onlyOneElement) { +try { +score = Float.$valueOf (token).floatValue (); +break; +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +}if (token.equals ("|")) { +if (emptyColumn) { +index++; +}emptyColumn = true; +} else { +annotations[index++] = this.parseAnnotation (token, graphStyle); +emptyColumn = false; +}} +}annotation = new jalview.datamodel.AlignmentAnnotation (label, description, (index == 0) ? null : annotations, 0, 0, graphStyle); +annotation.score = score; +if (!overrideAutoAnnot && autoAnnots.containsKey (this.autoAnnotsKey (annotation, this.refSeq, groupRef))) { +continue; +}if (this.refSeq != null) { +annotation.belowAlignment = false; +var referedSeq = this.refSeq; +do { +var ann = new jalview.datamodel.AlignmentAnnotation (annotation); +annotation.createSequenceMapping (referedSeq, refSeqIndex, false); +annotation.adjustForAlignment (); +referedSeq.addAlignmentAnnotation (annotation); +al.addAnnotation (annotation); +al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1); +if (groupRef != null) { +(groupRefRows.get (groupRef)).addElement (annotation); +}annotation = ann; +} while (this.refSeqId != null && (referedSeq = al.findName (referedSeq, this.refSeqId, true)) != null); +} else { +al.addAnnotation (annotation); +al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1); +if (groupRef != null) { +(groupRefRows.get (groupRef)).addElement (annotation); +}}modified = true; +} +var groupRefLookup = new java.util.Hashtable (); +var en = groupRefRows.keys (); +while (en.hasMoreElements ()) { +groupRef = en.nextElement (); +var matched = false; +for (var theGroup, $theGroup = al.getGroups ().iterator (); $theGroup.hasNext () && ((theGroup = $theGroup.next ()) || true);) { +if (theGroup.getName ().equals (groupRef)) { +if (matched) { +System.err.println ("Ignoring 1:many group reference mappings for group name '" + groupRef + "'"); +} else { +matched = true; +var rowset = groupRefRows.get (groupRef); +groupRefLookup.put (groupRef, theGroup); +if (rowset != null && rowset.size () > 0) { +var alan = null; +for (var elm = 0, elmSize = rowset.size (); elm < elmSize; elm++) { +alan = rowset.elementAt (elm); +alan.groupRef = theGroup; +} +}}}} +(groupRefRows.get (groupRef)).removeAllElements (); +} +for (var _deferred_args, $_deferred_args = deferredAnnotation_calls.iterator (); $_deferred_args.hasNext () && ((_deferred_args = $_deferred_args.next ()) || true);) { +if (_deferred_args[0] === jalview.io.AnnotationFile.GRAPHLINE) { +this.addLine (al, _deferred_args[1], _deferred_args[2], (_deferred_args[3] == null) ? null : groupRefLookup.get (_deferred_args[3])); +}} +var combinecount = 0; +for (var _combine_args, $_combine_args = combineAnnotation_calls.iterator (); $_combine_args.hasNext () && ((_combine_args = $_combine_args.next ()) || true);) { +this.combineAnnotations (al, ++combinecount, _combine_args[0], _combine_args[1], (_combine_args[2] == null) ? null : groupRefLookup.get (_combine_args[2])); +} +}return modified; +}, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,java.io.BufferedReader"); +Clazz.defineMethod (c$, "parseHideCols", +($fz = function (colSel, nextToken) { +var inval = new java.util.StringTokenizer (nextToken, ","); +while (inval.hasMoreTokens ()) { +var range = inval.nextToken ().trim (); +var from; +var to = range.indexOf ("-"); +if (to == -1) { +from = to = Integer.parseInt (range); +if (from >= 0) { +colSel.hideColumns (from, to); +}} else { +from = Integer.parseInt (range.substring (0, to)); +if (to < range.length - 1) { +to = Integer.parseInt (range.substring (to + 1)); +} else { +to = from; +}if (from > 0 && to >= from) { +colSel.hideColumns (from, to); +}}} +}, $fz.isPrivate = true, $fz), "jalview.datamodel.ColumnSelection,~S"); +Clazz.defineMethod (c$, "autoAnnotsKey", +($fz = function (annotation, refSeq, groupRef) { +return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : ""); +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,~S"); +Clazz.defineMethod (c$, "parseAnnotation", +function (string, graphStyle) { +var hasSymbols = (graphStyle == 0); +var desc = null; +var displayChar = null; +var ss = ' '; +var value = 0; +var parsedValue = false; +var dcset = false; +var colour = null; +var i = string.indexOf ("["); +var j = string.indexOf ("]"); +if (i > -1 && j > -1) { +var ucs = new jalview.schemes.UserColourScheme (); +colour = ucs.getColourFromString (string.substring (i + 1, j)); +if (i > 0 && string.charAt (i - 1) == ',') { +i--; +}string = string.substring (0, i) + string.substring (j + 1); +}var st = new java.util.StringTokenizer (string, ",", true); +var token; +var seenContent = false; +var pass = 0; +while (st.hasMoreTokens ()) { +pass++; +token = st.nextToken ().trim (); +if (token.equals (",")) { +if (!seenContent && parsedValue && !dcset) { +dcset = true; +displayChar = " "; +}seenContent = false; +continue; +} else { +seenContent = true; +}if (!parsedValue) { +try { +displayChar = token; +value = new Float (token).floatValue (); +parsedValue = true; +continue; +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +} else { +if (token.length == 1) { +displayChar = token; +}}if (hasSymbols && (token.equals ("H") || token.equals ("E") || token.equals ("S") || token.equals (" "))) { +ss = token.charAt (0); +if (displayChar.equals (token.substring (0, 1))) { +displayChar = ""; +}} else if (desc == null || (parsedValue && pass > 2)) { +desc = token; +}} +if (displayChar != null && desc != null && desc.length == 1) { +if (displayChar.length > 1) { +var tmp = displayChar; +displayChar = desc; +desc = tmp; +} else { +if (displayChar.equals (desc)) { +desc = null; +}}}var anot = new jalview.datamodel.Annotation (displayChar, desc, ss, value); +anot.colour = colour; +return anot; +}, "~S,~N"); +Clazz.defineMethod (c$, "colourAnnotations", +function (al, label, colour) { +var ucs = new jalview.schemes.UserColourScheme (colour); +var annotations; +for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { +if (al.getAlignmentAnnotation ()[i].label.equalsIgnoreCase (label)) { +annotations = al.getAlignmentAnnotation ()[i].annotations; +for (var j = 0; j < annotations.length; j++) { +if (annotations[j] != null) { +annotations[j].colour = ucs.findColour ('A'); +}} +}} +}, "jalview.datamodel.AlignmentI,~S,~S"); +Clazz.defineMethod (c$, "combineAnnotations", +function (al, combineCount, st, seqRef, groupRef) { +var group = st.nextToken (); +var graphGroup = 0; +if (al.getAlignmentAnnotation () != null) { +for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { +var aa = al.getAlignmentAnnotation ()[i]; +if (aa.graphGroup > graphGroup) { +graphGroup = aa.graphGroup + 1; +}if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) { +if (aa.graphGroup > -1) { +graphGroup = aa.graphGroup; +} else { +if (graphGroup <= combineCount) { +graphGroup = combineCount + 1; +}aa.graphGroup = graphGroup; +}break; +}} +while (st.hasMoreTokens ()) { +group = st.nextToken (); +for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { +var aa = al.getAlignmentAnnotation ()[i]; +if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) { +aa.graphGroup = graphGroup; +break; +}} +} +} else { +System.err.println ("Couldn't combine annotations. None are added to alignment yet!"); +}}, "jalview.datamodel.AlignmentI,~N,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "addLine", +function (al, st, seqRef, groupRef) { +var group = st.nextToken (); +var annotation = null; +var alannot = al.getAlignmentAnnotation (); +var value = new Float (st.nextToken ()).floatValue (); +var label = st.hasMoreTokens () ? st.nextToken () : null; +var colour = null; +if (st.hasMoreTokens ()) { +var ucs = new jalview.schemes.UserColourScheme (st.nextToken ()); +colour = ucs.findColour ('A'); +}if (alannot != null) { +for (var i = 0; i < alannot.length; i++) { +if (alannot[i].label.equalsIgnoreCase (group) && (seqRef == null || alannot[i].sequenceRef === seqRef) && (groupRef == null || alannot[i].groupRef === groupRef)) { +alannot[i].setThreshold ( new jalview.datamodel.GraphLine (value, label, colour)); +}} +}if (annotation == null) { +return; +}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "addGroup", +function (al, st) { +var sg = new jalview.datamodel.SequenceGroup (); +sg.setName (st.nextToken ()); +var rng = ""; +try { +rng = st.nextToken (); +if (rng.length > 0 && !rng.startsWith ("*")) { +sg.setStartRes (Integer.parseInt (rng) - 1); +} else { +sg.setStartRes (0); +}rng = st.nextToken (); +if (rng.length > 0 && !rng.startsWith ("*")) { +sg.setEndRes (Integer.parseInt (rng) - 1); +} else { +sg.setEndRes (al.getWidth () - 1); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '" + rng + "' - assuming alignment width for group."); +sg.setStartRes (0); +sg.setEndRes (al.getWidth () - 1); +} else { +throw e; +} +} +var index = st.nextToken (); +if (index.equals ("-1")) { +while (st.hasMoreElements ()) { +sg.addSequence (al.findName (st.nextToken ()), false); +} +} else { +var st2 = new java.util.StringTokenizer (index, ","); +while (st2.hasMoreTokens ()) { +var tmp = st2.nextToken (); +if (tmp.equals ("*")) { +for (var i = 0; i < al.getHeight (); i++) { +sg.addSequence (al.getSequenceAt (i), false); +} +} else if (tmp.indexOf ("-") >= 0) { +var st3 = new java.util.StringTokenizer (tmp, "-"); +var start = (Integer.parseInt (st3.nextToken ())); +var end = (Integer.parseInt (st3.nextToken ())); +if (end > start) { +for (var i = start; i <= end; i++) { +sg.addSequence (al.getSequenceAt (i - 1), false); +} +}} else { +sg.addSequence (al.getSequenceAt (Integer.parseInt (tmp) - 1), false); +}} +}if (this.refSeq != null) { +sg.setStartRes (this.refSeq.findIndex (sg.getStartRes () + 1) - 1); +sg.setEndRes (this.refSeq.findIndex (sg.getEndRes () + 1) - 1); +sg.setSeqrep (this.refSeq); +}if (sg.getSize () > 0) { +al.addGroup (sg); +}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); +Clazz.defineMethod (c$, "addRowProperties", +function (al, st) { +var label = st.nextToken (); +var keyValue; +var key; +var value; +var scaletofit = false; +var centerlab = false; +var showalllabs = false; +while (st.hasMoreTokens ()) { +keyValue = st.nextToken (); +key = keyValue.substring (0, keyValue.indexOf ("=")); +value = keyValue.substring (keyValue.indexOf ("=") + 1); +if (key.equalsIgnoreCase ("scaletofit")) { +scaletofit = Boolean.$valueOf (value).booleanValue (); +}if (key.equalsIgnoreCase ("showalllabs")) { +showalllabs = Boolean.$valueOf (value).booleanValue (); +}if (key.equalsIgnoreCase ("centrelabs")) { +centerlab = Boolean.$valueOf (value).booleanValue (); +}var alr = al.getAlignmentAnnotation (); +if (alr != null) { +for (var i = 0; i < alr.length; i++) { +if (alr[i].label.equalsIgnoreCase (label)) { +alr[i].centreColLabels = centerlab; +alr[i].scaleColLabel = scaletofit; +alr[i].showAllColLabels = showalllabs; +}} +}} +}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); +Clazz.defineMethod (c$, "addProperties", +function (al, st) { +if (al.getGroups () == null) { +return; +}var name = st.nextToken (); +var sg = null; +for (var _sg, $_sg = al.getGroups ().iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) { +if ((sg = _sg).getName ().equals (name)) { +break; +} else { +sg = null; +}} +if (sg != null) { +var keyValue; +var key; +var value; +var def = sg.cs; +sg.cs = null; +while (st.hasMoreTokens ()) { +keyValue = st.nextToken (); +key = keyValue.substring (0, keyValue.indexOf ("=")); +value = keyValue.substring (keyValue.indexOf ("=") + 1); +if (key.equalsIgnoreCase ("description")) { +sg.setDescription (value); +} else if (key.equalsIgnoreCase ("colour")) { +sg.cs = jalview.schemes.ColourSchemeProperty.getColour (al, value); +} else if (key.equalsIgnoreCase ("pidThreshold")) { +sg.cs.setThreshold (Integer.parseInt (value), true); +} else if (key.equalsIgnoreCase ("consThreshold")) { +sg.cs.setConservationInc (Integer.parseInt (value)); +var c = new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes () + 1); +c.calculate (); +c.verdict (false, 25); +sg.cs.setConservation (c); +} else if (key.equalsIgnoreCase ("outlineColour")) { +sg.setOutlineColour ( new jalview.schemes.UserColourScheme (value).findColour ('A')); +} else if (key.equalsIgnoreCase ("displayBoxes")) { +sg.setDisplayBoxes (Boolean.$valueOf (value).booleanValue ()); +} else if (key.equalsIgnoreCase ("showUnconserved")) { +sg.setShowNonconserved (Boolean.$valueOf (value).booleanValue ()); +} else if (key.equalsIgnoreCase ("displayText")) { +sg.setDisplayText (Boolean.$valueOf (value).booleanValue ()); +} else if (key.equalsIgnoreCase ("colourText")) { +sg.setColourText (Boolean.$valueOf (value).booleanValue ()); +} else if (key.equalsIgnoreCase ("textCol1")) { +sg.textColour = new jalview.schemes.UserColourScheme (value).findColour ('A'); +} else if (key.equalsIgnoreCase ("textCol2")) { +sg.textColour2 = new jalview.schemes.UserColourScheme (value).findColour ('A'); +} else if (key.equalsIgnoreCase ("textColThreshold")) { +sg.thresholdTextColour = Integer.parseInt (value); +} else if (key.equalsIgnoreCase ("idColour")) { +sg.setIdColour ((def = new jalview.schemes.UserColourScheme (value)).findColour ('A')); +} else if (key.equalsIgnoreCase ("hide")) { +sg.setHidereps (true); +} else if (key.equalsIgnoreCase ("hidecols")) { +sg.setHideCols (true); +}sg.recalcConservation (); +} +if (sg.cs == null) { +sg.cs = def; +}}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); +Clazz.defineMethod (c$, "setBelowAlignment", +function (al, st) { +var token; +var aa; +var ala = al.getAlignmentAnnotation (); +if (ala == null) { +System.err.print ("Warning - no annotation to set below for sequence associated annotation:"); +}while (st.hasMoreTokens ()) { +token = st.nextToken (); +if (ala == null) { +System.err.print (" " + token); +} else { +for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) { +aa = al.getAlignmentAnnotation ()[i]; +if (aa.sequenceRef === this.refSeq && aa.label.equals (token)) { +aa.belowAlignment = true; +}} +}} +if (ala == null) { +System.err.print ("\n"); +}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); +Clazz.defineMethod (c$, "addAlignmentDetails", +function (al, st) { +var keyValue; +var key; +var value; +while (st.hasMoreTokens ()) { +keyValue = st.nextToken (); +key = keyValue.substring (0, keyValue.indexOf ("=")); +value = keyValue.substring (keyValue.indexOf ("=") + 1); +al.setProperty (key, value); +} +}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer"); +Clazz.defineMethod (c$, "printCSVAnnotations", +function (annotations) { +var sp = new StringBuffer (); +for (var i = 0; i < annotations.length; i++) { +var atos = annotations[i].toString (); +var p = 0; +do { +var cp = atos.indexOf ("\n", p); +sp.append (annotations[i].label); +sp.append (","); +if (cp > p) { +sp.append (atos.substring (p, cp + 1)); +} else { +sp.append (atos.substring (p)); +sp.append (this.newline); +}p = cp + 1; +} while (p > 0); +} +return sp.toString (); +}, "~A"); +Clazz.defineMethod (c$, "printAnnotationsForView", +function (viewport) { +return this.printAnnotations (viewport.isShowAnnotation () ? viewport.getAlignment ().getAlignmentAnnotation () : null, viewport.getAlignment ().getGroups (), viewport.getAlignment ().getProperties (), viewport.getColumnSelection (), viewport.getAlignment (), null); +}, "jalview.api.AlignViewportI"); +Clazz.defineMethod (c$, "printAnnotationsForAlignment", +function (al) { +return this.printAnnotations (al.getAlignmentAnnotation (), al.getGroups (), al.getProperties (), null, al, null); +}, "jalview.datamodel.AlignmentI"); +c$.$AnnotationFile$ViewDef$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.viewname = null; +this.hidseqs = null; +this.hiddencols = null; +this.visibleGroups = null; +this.hiddenRepSeqs = null; +Clazz.instantialize (this, arguments); +}, jalview.io.AnnotationFile, "ViewDef"); +Clazz.makeConstructor (c$, +function (a, b, c, d) { +this.viewname = a; +this.hidseqs = b; +this.hiddencols = c; +this.hiddenRepSeqs = d; +}, "~S,jalview.datamodel.HiddenSequences,jalview.datamodel.ColumnSelection,java.util.Hashtable"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"GRAPHLINE", "GRAPHLINE", +"COMBINE", "COMBINE"); +}); diff --git a/bin/jalview/io/AppletFormatAdapter.js b/bin/jalview/io/AppletFormatAdapter.js index f4dab9f..681a44d 100644 --- a/bin/jalview/io/AppletFormatAdapter.js +++ b/bin/jalview/io/AppletFormatAdapter.js @@ -1,389 +1,389 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.AppletFormatAdapter", ["MCview.PDBfile", "jalview.datamodel.Alignment", "jalview.io.FileParse", "$.IdentifyFile", "jalview.jsdev.GenericFileAdapter", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Exception", "$.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.viewpanel = null; -this.annotFromStructure = false; -this.localSecondaryStruct = false; -this.serviceSecondaryStruct = false; -this.alignFile = null; -this.inFile = null; -this.newline = null; -this.exportSettings = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "AppletFormatAdapter"); -Clazz.prepareFields (c$, function () { -this.newline = System.getProperty ("line.separator"); -}); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (viewpanel) { -this.viewpanel = viewpanel; -}, "jalview.api.AlignmentViewPanel"); -Clazz.makeConstructor (c$, -function (alignPanel, settings) { -this.viewpanel = alignPanel; -this.exportSettings = settings; -}, "jalview.api.AlignmentViewPanel,jalview.api.AlignExportSettingI"); -c$.prettyPrint = Clazz.defineMethod (c$, "prettyPrint", -function (els) { -var list = new StringBuffer (); -for (var i = 0, iSize = els.length - 1; i < iSize; i++) { -list.append (els[i]); -list.append (", "); -} -list.append (" and " + els[els.length - 1] + "."); -return list.toString (); -}, "~A"); -Clazz.defineMethod (c$, "setNewlineString", -function (nl) { -this.newline = nl; -}, "~S"); -Clazz.defineMethod (c$, "getNewlineString", -function () { -return this.newline; -}); -c$.isValidFormat = Clazz.defineMethod (c$, "isValidFormat", -function (format) { -return jalview.io.AppletFormatAdapter.isValidFormat (format, false); -}, "~S"); -c$.isValidFormat = Clazz.defineMethod (c$, "isValidFormat", -function (format, forwriting) { -var valid = false; -var format_list = (forwriting) ? jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS : jalview.io.AppletFormatAdapter.READABLE_FORMATS; -for (var element, $element = 0, $$element = format_list; $element < $$element.length && ((element = $$element[$element]) || true); $element++) { -if (element.equalsIgnoreCase (format)) { -return true; -}} -return valid; -}, "~S,~B"); -Clazz.defineMethod (c$, "readFile", -function (inFile, type, format) { -this.inFile = inFile; -try { -if (format.equals ("FASTA")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [inFile, type]); -} else if (format.equals ("MSF")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("MSFfile", [inFile, type]); -} else if (format.equals ("PileUp")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PileUpfile", [inFile, type]); -} else if (format.equals ("CLUSTAL")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("ClustalFile", [inFile, type]); -} else if (format.equals ("BLC")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("BLCFile", [inFile, type]); -} else if (format.equals ("PIR")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PIRFile", [inFile, type]); -} else if (format.equals ("PFAM")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PfamFile", [inFile, type]); -} else if (format.equals ("JnetFile")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JPredFile", [inFile, type]); -(this.alignFile).removeNonSequences (); -} else if (format.equals ("PDB")) { -this.alignFile = new MCview.PDBfile (this.annotFromStructure, this.localSecondaryStruct, this.serviceSecondaryStruct, inFile, type); -} else if (format.equals ("STH")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("StockholmFile", [inFile, type]); -} else if (format.equals ("SimpleBLAST")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("SimpleBlastFile", [inFile, type]); -} else if (format.equals ("PHYLIP")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PhylipFile", [inFile, type]); -} else if (format.equals ("JSON")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JSONFile", [inFile, type]); -} else if (format.equals ("HTML")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("HtmlFile", [inFile, type]); -} else if (format.equals ("RNAML")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("RnamlFile", [inFile, type]); -} else if (format.equals ("GFF v2 or v3")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("Gff3File", [inFile, type]); -}return this.buildAlignmentFrom (this.alignFile); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to read alignment using the '" + format + "' reader.\n" + e); -if (e.getMessage () != null && e.getMessage ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { -throw new java.io.IOException (e.getMessage ()); -}if (type.equalsIgnoreCase ("Paste")) { -try { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [">UNKNOWN\n" + inFile, "Paste"]); -return this.buildAlignmentFrom (this.alignFile); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -if (ex.toString ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { -throw new java.io.IOException (e.getMessage ()); -}ex.printStackTrace (); -} else { -throw ex; -} -} -}throw new java.io.IOException (jalview.io.AppletFormatAdapter.SUPPORTED_FORMATS); -} else { -throw e; -} -} -}, "~S,~S,~S"); -Clazz.defineMethod (c$, "readFromFile", -function (source, format) { -this.inFile = source.getInFile (); -var type = source.type; -try { -if (format.equals ("FASTA")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [source]); -} else if (format.equals ("MSF")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("MSFfile", [source]); -} else if (format.equals ("PileUp")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PileUpfile", [source]); -} else if (format.equals ("CLUSTAL")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("ClustalFile", [source]); -} else if (format.equals ("BLC")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("BLCFile", [source]); -} else if (format.equals ("PIR")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PIRFile", [source]); -} else if (format.equals ("PFAM")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PfamFile", [source]); -} else if (format.equals ("JnetFile")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JPredFile", [source]); -(this.alignFile).removeNonSequences (); -} else if (format.equals ("PDB")) { -this.alignFile = new MCview.PDBfile (this.annotFromStructure, this.localSecondaryStruct, this.serviceSecondaryStruct, source); -} else if (format.equals ("STH")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("StockholmFile", [source]); -} else if (format.equals ("RNAML")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("RnamlFile", [source]); -} else if (format.equals ("SimpleBLAST")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("SimpleBlastFile", [source]); -} else if (format.equals ("PHYLIP")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PhylipFile", [source]); -} else if (format.equals ("GFF v2 or v3")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("Gff3File", [this.inFile, type]); -} else if (format.equals ("JSON")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JSONFile", [source]); -} else if (format.equals ("HTML")) { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("HtmlFile", [source]); -}return this.buildAlignmentFrom (this.alignFile); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -e.printStackTrace (); -System.err.println ("Failed to read alignment using the '" + format + "' reader.\n" + e); -if (e.getMessage () != null && e.getMessage ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { -throw new java.io.IOException (e.getMessage ()); -}if (type.equalsIgnoreCase ("Paste")) { -try { -this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [">UNKNOWN\n" + this.inFile, "Paste"]); -return this.buildAlignmentFrom (this.alignFile); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -if (ex.toString ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { -throw new java.io.IOException (e.getMessage ()); -}ex.printStackTrace (); -} else { -throw ex; -} -} -}throw new java.io.IOException (jalview.io.AppletFormatAdapter.SUPPORTED_FORMATS); -} else { -throw e; -} -} -}, "jalview.io.FileParse,~S"); -Clazz.defineMethod (c$, "buildAlignmentFrom", -($fz = function (alignFile2) { -var al = new jalview.datamodel.Alignment (this.alignFile.getSeqsAsArray ()); -this.alignFile.addAnnotations (al); -this.alignFile.addGroups (al); -return al; -}, $fz.isPrivate = true, $fz), "jalview.io.AlignFile"); -Clazz.defineMethod (c$, "formatSequences", -function (format, jvsuffix, ap, selectedOnly) { -var selvew = ap.getAlignViewport ().getAlignmentView (selectedOnly, false); -var aselview = selvew.getVisibleAlignment (ap.getAlignViewport ().getGapCharacter ()); -var ala = (ap.getAlignViewport ().getVisibleAlignmentAnnotation (selectedOnly)); -if (ala != null) { -for (var aa, $aa = ala.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { -aselview.addAnnotation (aa); -} -}this.viewpanel = ap; -return this.formatSequences (format, aselview, jvsuffix); -}, "~S,~B,jalview.api.AlignmentViewPanel,~B"); -Clazz.defineMethod (c$, "formatSequences", -function (format, alignment, jvsuffix) { -try { -var afile = null; -if (format.equalsIgnoreCase ("FASTA")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", []); -} else if (format.equalsIgnoreCase ("MSF")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("MSFfile", []); -} else if (format.equalsIgnoreCase ("PileUp")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("PileUpfile", []); -} else if (format.equalsIgnoreCase ("CLUSTAL")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("ClustalFile", []); -} else if (format.equalsIgnoreCase ("BLC")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("BLCFile", []); -} else if (format.equalsIgnoreCase ("PIR")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("PIRFile", []); -} else if (format.equalsIgnoreCase ("PFAM")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("PfamFile", []); -} else if (format.equalsIgnoreCase ("STH")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("StockholmFile", [alignment]); -} else if (format.equalsIgnoreCase ("AMSA")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("AMSAFile", [alignment]); -} else if (format.equalsIgnoreCase ("PHYLIP")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("PhylipFile", []); -} else if (format.equalsIgnoreCase ("JSON")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("JSONFile", []); -} else if (format.equalsIgnoreCase ("RNAML")) { -afile = jalview.jsdev.GenericFileAdapter.getFile ("RnamlFile", []); -} else { -throw new Exception (jalview.util.MessageManager.getString ("error.implementation_error_unknown_file_format_string")); -}afile.setNewlineString (this.newline); -afile.addJVSuffix (jvsuffix); -afile.setExportSettings (this.exportSettings); -afile.configureForView (this.viewpanel); -if (this.viewpanel == null || this.viewpanel.getAlignment () == null || this.viewpanel.getAlignment () !== alignment) { -afile.setSeqs (alignment.getSequencesArray ()); -} else { -afile.setSeqs (this.viewpanel.getAlignment ().getSequencesArray ()); -}var afileresp = afile.print (); -if (afile.hasWarningMessage ()) { -System.err.println ("Warning raised when writing as " + format + " : " + afile.getWarningMessage ()); -}return afileresp; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Failed to write alignment as a '" + format + "' file\n"); -e.printStackTrace (); -} else { -throw e; -} -} -return null; -}, "~S,jalview.datamodel.AlignmentI,~B"); -c$.checkProtocol = Clazz.defineMethod (c$, "checkProtocol", -function (file) { -var protocol = jalview.io.AppletFormatAdapter.FILE; -var ft = file.toLowerCase ().trim (); -if (ft.indexOf ("http:") == 0 || ft.indexOf ("https:") == 0 || ft.indexOf ("file:") == 0) { -protocol = jalview.io.AppletFormatAdapter.URL; -}return protocol; -}, "~S"); -c$.resolveProtocol = Clazz.defineMethod (c$, "resolveProtocol", -function (file, format) { -return jalview.io.AppletFormatAdapter.resolveProtocol (file, format, false); -}, "~S,~S"); -c$.resolveProtocol = Clazz.defineMethod (c$, "resolveProtocol", -function (file, format, debug) { -var protocol = null; -if (debug) { -System.out.println ("resolving datasource started with:\n>>file\n" + file + ">>endfile"); -}try { -var rtn = false; -var is = System.getSecurityManager ().getClass ().getResourceAsStream ("/" + file); -if (is != null) { -rtn = true; -is.close (); -}if (debug) { -System.err.println ("Resource '" + file + "' was " + (rtn ? "" : "not") + " located by classloader."); -};if (rtn) { -protocol = jalview.io.AppletFormatAdapter.CLASSLOADER; -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Exception checking resources: " + file + " " + ex); -} else { -throw ex; -} -} -if (file.indexOf ("://") > -1) { -protocol = jalview.io.AppletFormatAdapter.URL; -} else { -protocol = jalview.io.AppletFormatAdapter.FILE; -}var fp = null; -try { -if (debug) { -System.out.println ("Trying to get contents of resource as " + protocol + ":"); -}fp = new jalview.io.FileParse (file, protocol); -if (!fp.isValid ()) { -fp = null; -} else { -if (debug) { -System.out.println ("Successful."); -}}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -if (debug) { -System.err.println ("Exception when accessing content: " + e); -}fp = null; -} else { -throw e; -} -} -if (fp == null) { -if (debug) { -System.out.println ("Accessing as paste."); -}protocol = jalview.io.AppletFormatAdapter.PASTE; -fp = null; -try { -fp = new jalview.io.FileParse (file, protocol); -if (!fp.isValid ()) { -fp = null; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Failed to access content as paste!"); -e.printStackTrace (); -fp = null; -} else { -throw e; -} -} -}if (fp == null) { -return null; -}if (format == null || format.length == 0) { -return protocol; -} else { -try { -var idformat = new jalview.io.IdentifyFile ().Identify (file, protocol); -if (idformat == null) { -if (debug) { -System.out.println ("Format not identified. Inaccessible file."); -}return null; -}if (debug) { -System.out.println ("Format identified as " + idformat + "and expected as " + format); -}if (idformat.equals (format)) { -if (debug) { -System.out.println ("Protocol identified as " + protocol); -}return protocol; -} else { -if (debug) { -System.out.println ("File deemed not accessible via " + protocol); -}fp.close (); -return null; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -if (debug) { -System.err.println ("File deemed not accessible via " + protocol); -e.printStackTrace (); -};} else { -throw e; -} -} -}return null; -}, "~S,~S,~B"); -Clazz.defineMethod (c$, "getAlignFile", -function () { -return this.alignFile; -}); -Clazz.defineMethod (c$, "setAlignFile", -function (alignFile) { -this.alignFile = alignFile; -}, "jalview.io.AlignFile"); -Clazz.defineStatics (c$, -"FILE", "File", -"URL", "URL", -"PASTE", "Paste", -"CLASSLOADER", "ClassLoader"); -c$.READABLE_FORMATS = c$.prototype.READABLE_FORMATS = Clazz.newArray (-1, ["BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", "PDB", "JnetFile", "RNAML", "PHYLIP", "JSON", "GFF v2 or v3", "HTML"]); -c$.READABLE_EXTENSIONS = c$.prototype.READABLE_EXTENSIONS = Clazz.newArray (-1, ["fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", "sto,stk", "xml,rnaml", "phy", "json", ".gff2,gff3", "jar,jvp", "html"]); -c$.READABLE_FNAMES = c$.prototype.READABLE_FNAMES = Clazz.newArray (-1, ["Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm", "RNAML", "PHYLIP", "JSON", "GFF v2 or v3", "Jalview", "HTML"]); -c$.WRITEABLE_FORMATS = c$.prototype.WRITEABLE_FORMATS = Clazz.newArray (-1, ["BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA", "STH", "PHYLIP", "JSON"]); -c$.WRITABLE_EXTENSIONS = c$.prototype.WRITABLE_EXTENSIONS = Clazz.newArray (-1, ["fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", "sto,stk", "phy", "json", "jvp"]); -c$.WRITABLE_FNAMES = c$.prototype.WRITABLE_FNAMES = Clazz.newArray (-1, ["Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH", "PHYLIP", "JSON", "Jalview"]); -Clazz.defineStatics (c$, -"INVALID_CHARACTERS", "Contains invalid characters"); -c$.SUPPORTED_FORMATS = c$.prototype.SUPPORTED_FORMATS = "Formats currently supported are\n" + jalview.io.AppletFormatAdapter.prettyPrint (jalview.io.AppletFormatAdapter.READABLE_FORMATS); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.AppletFormatAdapter", ["MCview.PDBfile", "jalview.datamodel.Alignment", "jalview.io.FileParse", "$.IdentifyFile", "jalview.jsdev.GenericFileAdapter", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Exception", "$.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.viewpanel = null; +this.annotFromStructure = false; +this.localSecondaryStruct = false; +this.serviceSecondaryStruct = false; +this.alignFile = null; +this.inFile = null; +this.newline = null; +this.exportSettings = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "AppletFormatAdapter"); +Clazz.prepareFields (c$, function () { +this.newline = System.getProperty ("line.separator"); +}); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (viewpanel) { +this.viewpanel = viewpanel; +}, "jalview.api.AlignmentViewPanel"); +Clazz.makeConstructor (c$, +function (alignPanel, settings) { +this.viewpanel = alignPanel; +this.exportSettings = settings; +}, "jalview.api.AlignmentViewPanel,jalview.api.AlignExportSettingI"); +c$.prettyPrint = Clazz.defineMethod (c$, "prettyPrint", +function (els) { +var list = new StringBuffer (); +for (var i = 0, iSize = els.length - 1; i < iSize; i++) { +list.append (els[i]); +list.append (", "); +} +list.append (" and " + els[els.length - 1] + "."); +return list.toString (); +}, "~A"); +Clazz.defineMethod (c$, "setNewlineString", +function (nl) { +this.newline = nl; +}, "~S"); +Clazz.defineMethod (c$, "getNewlineString", +function () { +return this.newline; +}); +c$.isValidFormat = Clazz.defineMethod (c$, "isValidFormat", +function (format) { +return jalview.io.AppletFormatAdapter.isValidFormat (format, false); +}, "~S"); +c$.isValidFormat = Clazz.defineMethod (c$, "isValidFormat", +function (format, forwriting) { +var valid = false; +var format_list = (forwriting) ? jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS : jalview.io.AppletFormatAdapter.READABLE_FORMATS; +for (var element, $element = 0, $$element = format_list; $element < $$element.length && ((element = $$element[$element]) || true); $element++) { +if (element.equalsIgnoreCase (format)) { +return true; +}} +return valid; +}, "~S,~B"); +Clazz.defineMethod (c$, "readFile", +function (inFile, type, format) { +this.inFile = inFile; +try { +if (format.equals ("FASTA")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [inFile, type]); +} else if (format.equals ("MSF")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("MSFfile", [inFile, type]); +} else if (format.equals ("PileUp")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PileUpfile", [inFile, type]); +} else if (format.equals ("CLUSTAL")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("ClustalFile", [inFile, type]); +} else if (format.equals ("BLC")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("BLCFile", [inFile, type]); +} else if (format.equals ("PIR")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PIRFile", [inFile, type]); +} else if (format.equals ("PFAM")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PfamFile", [inFile, type]); +} else if (format.equals ("JnetFile")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JPredFile", [inFile, type]); +(this.alignFile).removeNonSequences (); +} else if (format.equals ("PDB")) { +this.alignFile = new MCview.PDBfile (this.annotFromStructure, this.localSecondaryStruct, this.serviceSecondaryStruct, inFile, type); +} else if (format.equals ("STH")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("StockholmFile", [inFile, type]); +} else if (format.equals ("SimpleBLAST")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("SimpleBlastFile", [inFile, type]); +} else if (format.equals ("PHYLIP")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PhylipFile", [inFile, type]); +} else if (format.equals ("JSON")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JSONFile", [inFile, type]); +} else if (format.equals ("HTML")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("HtmlFile", [inFile, type]); +} else if (format.equals ("RNAML")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("RnamlFile", [inFile, type]); +} else if (format.equals ("GFF v2 or v3")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("Gff3File", [inFile, type]); +}return this.buildAlignmentFrom (this.alignFile); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to read alignment using the '" + format + "' reader.\n" + e); +if (e.getMessage () != null && e.getMessage ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { +throw new java.io.IOException (e.getMessage ()); +}if (type.equalsIgnoreCase ("Paste")) { +try { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [">UNKNOWN\n" + inFile, "Paste"]); +return this.buildAlignmentFrom (this.alignFile); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +if (ex.toString ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { +throw new java.io.IOException (e.getMessage ()); +}ex.printStackTrace (); +} else { +throw ex; +} +} +}throw new java.io.IOException (jalview.io.AppletFormatAdapter.SUPPORTED_FORMATS); +} else { +throw e; +} +} +}, "~S,~S,~S"); +Clazz.defineMethod (c$, "readFromFile", +function (source, format) { +this.inFile = source.getInFile (); +var type = source.type; +try { +if (format.equals ("FASTA")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [source]); +} else if (format.equals ("MSF")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("MSFfile", [source]); +} else if (format.equals ("PileUp")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PileUpfile", [source]); +} else if (format.equals ("CLUSTAL")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("ClustalFile", [source]); +} else if (format.equals ("BLC")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("BLCFile", [source]); +} else if (format.equals ("PIR")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PIRFile", [source]); +} else if (format.equals ("PFAM")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PfamFile", [source]); +} else if (format.equals ("JnetFile")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JPredFile", [source]); +(this.alignFile).removeNonSequences (); +} else if (format.equals ("PDB")) { +this.alignFile = new MCview.PDBfile (this.annotFromStructure, this.localSecondaryStruct, this.serviceSecondaryStruct, source); +} else if (format.equals ("STH")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("StockholmFile", [source]); +} else if (format.equals ("RNAML")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("RnamlFile", [source]); +} else if (format.equals ("SimpleBLAST")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("SimpleBlastFile", [source]); +} else if (format.equals ("PHYLIP")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("PhylipFile", [source]); +} else if (format.equals ("GFF v2 or v3")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("Gff3File", [this.inFile, type]); +} else if (format.equals ("JSON")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("JSONFile", [source]); +} else if (format.equals ("HTML")) { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("HtmlFile", [source]); +}return this.buildAlignmentFrom (this.alignFile); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +e.printStackTrace (); +System.err.println ("Failed to read alignment using the '" + format + "' reader.\n" + e); +if (e.getMessage () != null && e.getMessage ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { +throw new java.io.IOException (e.getMessage ()); +}if (type.equalsIgnoreCase ("Paste")) { +try { +this.alignFile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", [">UNKNOWN\n" + this.inFile, "Paste"]); +return this.buildAlignmentFrom (this.alignFile); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +if (ex.toString ().startsWith (jalview.io.AppletFormatAdapter.INVALID_CHARACTERS)) { +throw new java.io.IOException (e.getMessage ()); +}ex.printStackTrace (); +} else { +throw ex; +} +} +}throw new java.io.IOException (jalview.io.AppletFormatAdapter.SUPPORTED_FORMATS); +} else { +throw e; +} +} +}, "jalview.io.FileParse,~S"); +Clazz.defineMethod (c$, "buildAlignmentFrom", +($fz = function (alignFile2) { +var al = new jalview.datamodel.Alignment (this.alignFile.getSeqsAsArray ()); +this.alignFile.addAnnotations (al); +this.alignFile.addGroups (al); +return al; +}, $fz.isPrivate = true, $fz), "jalview.io.AlignFile"); +Clazz.defineMethod (c$, "formatSequences", +function (format, jvsuffix, ap, selectedOnly) { +var selvew = ap.getAlignViewport ().getAlignmentView (selectedOnly, false); +var aselview = selvew.getVisibleAlignment (ap.getAlignViewport ().getGapCharacter ()); +var ala = (ap.getAlignViewport ().getVisibleAlignmentAnnotation (selectedOnly)); +if (ala != null) { +for (var aa, $aa = ala.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { +aselview.addAnnotation (aa); +} +}this.viewpanel = ap; +return this.formatSequences (format, aselview, jvsuffix); +}, "~S,~B,jalview.api.AlignmentViewPanel,~B"); +Clazz.defineMethod (c$, "formatSequences", +function (format, alignment, jvsuffix) { +try { +var afile = null; +if (format.equalsIgnoreCase ("FASTA")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", []); +} else if (format.equalsIgnoreCase ("MSF")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("MSFfile", []); +} else if (format.equalsIgnoreCase ("PileUp")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("PileUpfile", []); +} else if (format.equalsIgnoreCase ("CLUSTAL")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("ClustalFile", []); +} else if (format.equalsIgnoreCase ("BLC")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("BLCFile", []); +} else if (format.equalsIgnoreCase ("PIR")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("PIRFile", []); +} else if (format.equalsIgnoreCase ("PFAM")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("PfamFile", []); +} else if (format.equalsIgnoreCase ("STH")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("StockholmFile", [alignment]); +} else if (format.equalsIgnoreCase ("AMSA")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("AMSAFile", [alignment]); +} else if (format.equalsIgnoreCase ("PHYLIP")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("PhylipFile", []); +} else if (format.equalsIgnoreCase ("JSON")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("JSONFile", []); +} else if (format.equalsIgnoreCase ("RNAML")) { +afile = jalview.jsdev.GenericFileAdapter.getFile ("RnamlFile", []); +} else { +throw new Exception (jalview.util.MessageManager.getString ("error.implementation_error_unknown_file_format_string")); +}afile.setNewlineString (this.newline); +afile.addJVSuffix (jvsuffix); +afile.setExportSettings (this.exportSettings); +afile.configureForView (this.viewpanel); +if (this.viewpanel == null || this.viewpanel.getAlignment () == null || this.viewpanel.getAlignment () !== alignment) { +afile.setSeqs (alignment.getSequencesArray ()); +} else { +afile.setSeqs (this.viewpanel.getAlignment ().getSequencesArray ()); +}var afileresp = afile.print (); +if (afile.hasWarningMessage ()) { +System.err.println ("Warning raised when writing as " + format + " : " + afile.getWarningMessage ()); +}return afileresp; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Failed to write alignment as a '" + format + "' file\n"); +e.printStackTrace (); +} else { +throw e; +} +} +return null; +}, "~S,jalview.datamodel.AlignmentI,~B"); +c$.checkProtocol = Clazz.defineMethod (c$, "checkProtocol", +function (file) { +var protocol = jalview.io.AppletFormatAdapter.FILE; +var ft = file.toLowerCase ().trim (); +if (ft.indexOf ("http:") == 0 || ft.indexOf ("https:") == 0 || ft.indexOf ("file:") == 0) { +protocol = jalview.io.AppletFormatAdapter.URL; +}return protocol; +}, "~S"); +c$.resolveProtocol = Clazz.defineMethod (c$, "resolveProtocol", +function (file, format) { +return jalview.io.AppletFormatAdapter.resolveProtocol (file, format, false); +}, "~S,~S"); +c$.resolveProtocol = Clazz.defineMethod (c$, "resolveProtocol", +function (file, format, debug) { +var protocol = null; +if (debug) { +System.out.println ("resolving datasource started with:\n>>file\n" + file + ">>endfile"); +}try { +var rtn = false; +var is = System.getSecurityManager ().getClass ().getResourceAsStream ("/" + file); +if (is != null) { +rtn = true; +is.close (); +}if (debug) { +System.err.println ("Resource '" + file + "' was " + (rtn ? "" : "not") + " located by classloader."); +};if (rtn) { +protocol = jalview.io.AppletFormatAdapter.CLASSLOADER; +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Exception checking resources: " + file + " " + ex); +} else { +throw ex; +} +} +if (file.indexOf ("://") > -1) { +protocol = jalview.io.AppletFormatAdapter.URL; +} else { +protocol = jalview.io.AppletFormatAdapter.FILE; +}var fp = null; +try { +if (debug) { +System.out.println ("Trying to get contents of resource as " + protocol + ":"); +}fp = new jalview.io.FileParse (file, protocol); +if (!fp.isValid ()) { +fp = null; +} else { +if (debug) { +System.out.println ("Successful."); +}}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +if (debug) { +System.err.println ("Exception when accessing content: " + e); +}fp = null; +} else { +throw e; +} +} +if (fp == null) { +if (debug) { +System.out.println ("Accessing as paste."); +}protocol = jalview.io.AppletFormatAdapter.PASTE; +fp = null; +try { +fp = new jalview.io.FileParse (file, protocol); +if (!fp.isValid ()) { +fp = null; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Failed to access content as paste!"); +e.printStackTrace (); +fp = null; +} else { +throw e; +} +} +}if (fp == null) { +return null; +}if (format == null || format.length == 0) { +return protocol; +} else { +try { +var idformat = new jalview.io.IdentifyFile ().Identify (file, protocol); +if (idformat == null) { +if (debug) { +System.out.println ("Format not identified. Inaccessible file."); +}return null; +}if (debug) { +System.out.println ("Format identified as " + idformat + "and expected as " + format); +}if (idformat.equals (format)) { +if (debug) { +System.out.println ("Protocol identified as " + protocol); +}return protocol; +} else { +if (debug) { +System.out.println ("File deemed not accessible via " + protocol); +}fp.close (); +return null; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +if (debug) { +System.err.println ("File deemed not accessible via " + protocol); +e.printStackTrace (); +};} else { +throw e; +} +} +}return null; +}, "~S,~S,~B"); +Clazz.defineMethod (c$, "getAlignFile", +function () { +return this.alignFile; +}); +Clazz.defineMethod (c$, "setAlignFile", +function (alignFile) { +this.alignFile = alignFile; +}, "jalview.io.AlignFile"); +Clazz.defineStatics (c$, +"FILE", "File", +"URL", "URL", +"PASTE", "Paste", +"CLASSLOADER", "ClassLoader"); +c$.READABLE_FORMATS = c$.prototype.READABLE_FORMATS = Clazz.newArray (-1, ["BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", "PDB", "JnetFile", "RNAML", "PHYLIP", "JSON", "GFF v2 or v3", "HTML"]); +c$.READABLE_EXTENSIONS = c$.prototype.READABLE_EXTENSIONS = Clazz.newArray (-1, ["fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", "sto,stk", "xml,rnaml", "phy", "json", ".gff2,gff3", "jar,jvp", "html"]); +c$.READABLE_FNAMES = c$.prototype.READABLE_FNAMES = Clazz.newArray (-1, ["Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm", "RNAML", "PHYLIP", "JSON", "GFF v2 or v3", "Jalview", "HTML"]); +c$.WRITEABLE_FORMATS = c$.prototype.WRITEABLE_FORMATS = Clazz.newArray (-1, ["BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA", "STH", "PHYLIP", "JSON"]); +c$.WRITABLE_EXTENSIONS = c$.prototype.WRITABLE_EXTENSIONS = Clazz.newArray (-1, ["fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", "sto,stk", "phy", "json", "jvp"]); +c$.WRITABLE_FNAMES = c$.prototype.WRITABLE_FNAMES = Clazz.newArray (-1, ["Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH", "PHYLIP", "JSON", "Jalview"]); +Clazz.defineStatics (c$, +"INVALID_CHARACTERS", "Contains invalid characters"); +c$.SUPPORTED_FORMATS = c$.prototype.SUPPORTED_FORMATS = "Formats currently supported are\n" + jalview.io.AppletFormatAdapter.prettyPrint (jalview.io.AppletFormatAdapter.READABLE_FORMATS); +}); diff --git a/bin/jalview/io/FastaFile.js b/bin/jalview/io/FastaFile.js index 5dc3155..38f827f 100644 --- a/bin/jalview/io/FastaFile.js +++ b/bin/jalview/io/FastaFile.js @@ -1,94 +1,94 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile"], "jalview.io.FastaFile", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.len = 72; -this.out = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "FastaFile", jalview.io.AlignFile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.FastaFile, []); -}); -Clazz.overrideMethod (c$, "parse", -function () { -var sb = new StringBuffer (); -var firstLine = true; -var line; -var uline; -var seq = null; -var annotation = false; -while ((uline = this.nextLine ()) != null) { -line = uline.trim (); -if (line.length > 0) { -if (line.charAt (0) == '>') { -if (line.startsWith (">#_")) { -if (annotation) { -this.annotations.addElement (this.makeAnnotation (seq, sb)); -}} else { -annotation = false; -}if (!firstLine) { -seq.setSequence (sb.toString ()); -if (!annotation) { -this.seqs.addElement (seq); -}}seq = this.parseId (line.substring (1)); -firstLine = false; -sb = new StringBuffer (); -if (line.startsWith (">#_")) { -annotation = true; -}} else { -sb.append (annotation ? uline : line); -}}} -if (annotation) { -this.annotations.addElement (this.makeAnnotation (seq, sb)); -} else if (!firstLine) { -seq.setSequence (sb.toString ()); -this.seqs.addElement (seq); -}}); -Clazz.defineMethod (c$, "makeAnnotation", -($fz = function (seq, sb) { -var anots = new Array (sb.length ()); -var cb; -for (var i = 0; i < anots.length; i++) { -var cn = sb.charAt (i); -if (cn != ' ') { -anots[i] = new jalview.datamodel.Annotation ("" + cn, null, ' ', NaN); -}} -var aa = new jalview.datamodel.AlignmentAnnotation (seq.getName ().substring (2), seq.getDescription (), anots); -return aa; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,StringBuffer"); -Clazz.defineMethod (c$, "addAnnotations", -function (al) { -this.addProperties (al); -for (var i = 0; i < this.annotations.size (); i++) { -var aa = this.annotations.elementAt (i); -aa.setPadGaps (true, al.getGapCharacter ()); -al.addAnnotation (aa); -} -}, "jalview.datamodel.Alignment"); -Clazz.defineMethod (c$, "print", -function (s) { -this.out = new StringBuffer (); -var i = 0; -while ((i < s.length) && (s[i] != null)) { -this.out.append (">" + this.printId (s[i])); -if (s[i].getDescription () != null) { -this.out.append (" " + s[i].getDescription ()); -}this.out.append (this.newline); -var nochunks = (Clazz.doubleToInt (s[i].getLength () / this.len)) + 1; -for (var j = 0; j < nochunks; j++) { -var start = j * this.len; -var end = start + this.len; -if (end < s[i].getLength ()) { -this.out.append (s[i].getSequenceAsString (start, end) + this.newline); -} else if (start < s[i].getLength ()) { -this.out.append (s[i].getSequenceAsString (start, s[i].getLength ()) + this.newline); -}} -i++; -} -return this.out.toString (); -}, "~A"); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile"], "jalview.io.FastaFile", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.len = 72; +this.out = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "FastaFile", jalview.io.AlignFile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.FastaFile, []); +}); +Clazz.overrideMethod (c$, "parse", +function () { +var sb = new StringBuffer (); +var firstLine = true; +var line; +var uline; +var seq = null; +var annotation = false; +while ((uline = this.nextLine ()) != null) { +line = uline.trim (); +if (line.length > 0) { +if (line.charAt (0) == '>') { +if (line.startsWith (">#_")) { +if (annotation) { +this.annotations.addElement (this.makeAnnotation (seq, sb)); +}} else { +annotation = false; +}if (!firstLine) { +seq.setSequence (sb.toString ()); +if (!annotation) { +this.seqs.addElement (seq); +}}seq = this.parseId (line.substring (1)); +firstLine = false; +sb = new StringBuffer (); +if (line.startsWith (">#_")) { +annotation = true; +}} else { +sb.append (annotation ? uline : line); +}}} +if (annotation) { +this.annotations.addElement (this.makeAnnotation (seq, sb)); +} else if (!firstLine) { +seq.setSequence (sb.toString ()); +this.seqs.addElement (seq); +}}); +Clazz.defineMethod (c$, "makeAnnotation", +($fz = function (seq, sb) { +var anots = new Array (sb.length ()); +var cb; +for (var i = 0; i < anots.length; i++) { +var cn = sb.charAt (i); +if (cn != ' ') { +anots[i] = new jalview.datamodel.Annotation ("" + cn, null, ' ', NaN); +}} +var aa = new jalview.datamodel.AlignmentAnnotation (seq.getName ().substring (2), seq.getDescription (), anots); +return aa; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,StringBuffer"); +Clazz.defineMethod (c$, "addAnnotations", +function (al) { +this.addProperties (al); +for (var i = 0; i < this.annotations.size (); i++) { +var aa = this.annotations.elementAt (i); +aa.setPadGaps (true, al.getGapCharacter ()); +al.addAnnotation (aa); +} +}, "jalview.datamodel.Alignment"); +Clazz.defineMethod (c$, "print", +function (s) { +this.out = new StringBuffer (); +var i = 0; +while ((i < s.length) && (s[i] != null)) { +this.out.append (">" + this.printId (s[i])); +if (s[i].getDescription () != null) { +this.out.append (" " + s[i].getDescription ()); +}this.out.append (this.newline); +var nochunks = (Clazz.doubleToInt (s[i].getLength () / this.len)) + 1; +for (var j = 0; j < nochunks; j++) { +var start = j * this.len; +var end = start + this.len; +if (end < s[i].getLength ()) { +this.out.append (s[i].getSequenceAsString (start, end) + this.newline); +} else if (start < s[i].getLength ()) { +this.out.append (s[i].getSequenceAsString (start, s[i].getLength ()) + this.newline); +}} +i++; +} +return this.out.toString (); +}, "~A"); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +}); diff --git a/bin/jalview/io/FeaturesFile.js b/bin/jalview/io/FeaturesFile.js index 458787b..9d03dfb 100644 --- a/bin/jalview/io/FeaturesFile.js +++ b/bin/jalview/io/FeaturesFile.js @@ -1,772 +1,772 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile", "java.lang.Enum", "$.Exception"], "jalview.io.FeaturesFile", ["jalview.analysis.SequenceIdMatcher", "jalview.datamodel.AlignedCodonFrame", "$.SequenceDummy", "$.SequenceFeature", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.GraduatedColor", "$.UserColourScheme", "jalview.util.Format", "$.MapList", "$.ParseHtmlBodyAndLinks", "java.awt.Color", "java.lang.Float", "$.StringBuffer", "java.util.ArrayList", "$.Arrays", "$.HashMap", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.doGffSource = true; -this.gffversion = 0; -if (!Clazz.isClassDefined ("jalview.io.FeaturesFile.InvalidGFF3FieldException")) { -jalview.io.FeaturesFile.$FeaturesFile$InvalidGFF3FieldException$ (); -} -this.lastmatchedAl = null; -this.matcher = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "FeaturesFile", jalview.io.AlignFile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.FeaturesFile, []); -}); -Clazz.defineMethod (c$, "parse", -function (align, colours, removeHTML) { -return this.parse (align, colours, null, removeHTML, false); -}, "jalview.datamodel.AlignmentI,java.util.Hashtable,~B"); -Clazz.defineMethod (c$, "parse", -function (align, colours, removeHTML, relaxedIdMatching) { -return this.parse (align, colours, null, removeHTML, relaxedIdMatching); -}, "jalview.datamodel.AlignmentI,java.util.Map,~B,~B"); -Clazz.defineMethod (c$, "parse", -function (align, colours, featureLink, removeHTML) { -return this.parse (align, colours, featureLink, removeHTML, false); -}, "jalview.datamodel.AlignmentI,java.util.Map,java.util.Map,~B"); -Clazz.defineMethod (c$, "parse", -function (align, colours, featureLink, removeHTML, relaxedIdmatching) { -var line = null; -try { -var seq = null; -var newseqs = new java.util.ArrayList (); -var type; -var desc; -var token = null; -var index; -var start; -var end; -var score; -var st; -var sf; -var featureGroup = null; -var groupLink = null; -var typeLink = new java.util.Hashtable (); -var GFFFile = true; -var gffProps = new java.util.HashMap (); -while ((line = this.nextLine ()) != null) { -if (line.startsWith ("#")) { -if (line.startsWith ("##")) { -this.processGffPragma (line, gffProps, align, newseqs); -line = ""; -}continue; -}st = new java.util.StringTokenizer (line, "\t"); -if (st.countTokens () == 1) { -if (line.trim ().equalsIgnoreCase ("GFF")) { -GFFFile = true; -continue; -}}if (st.countTokens () > 1 && st.countTokens () < 4) { -GFFFile = false; -type = st.nextToken (); -if (type.equalsIgnoreCase ("startgroup")) { -featureGroup = st.nextToken (); -if (st.hasMoreElements ()) { -groupLink = st.nextToken (); -featureLink.put (featureGroup, groupLink); -}} else if (type.equalsIgnoreCase ("endgroup")) { -st.nextToken (); -featureGroup = null; -groupLink = null; -} else { -var colour = null; -var colscheme = st.nextToken (); -if (colscheme.indexOf ("|") > -1 || colscheme.trim ().equalsIgnoreCase ("label")) { -var gcol = new java.util.StringTokenizer (colscheme, "|", true); -var threshtype = -1; -var min = 1.4E-45; -var max = 3.4028235E38; -var threshval = NaN; -var labelCol = false; -var mincol = gcol.nextToken (); -if (mincol === "|") { -System.err.println ("Expected either 'label' or a colour specification in the line: " + line); -continue; -}var maxcol = null; -if (mincol.toLowerCase ().indexOf ("label") == 0) { -labelCol = true; -mincol = (gcol.hasMoreTokens () ? gcol.nextToken () : null); -mincol = (gcol.hasMoreTokens () ? gcol.nextToken () : null); -}var abso = null; -var minval; -var maxval; -if (mincol != null) { -if (mincol.equals ("|")) { -mincol = ""; -} else { -gcol.nextToken (); -}maxcol = gcol.nextToken (); -if (maxcol.equals ("|")) { -maxcol = ""; -} else { -gcol.nextToken (); -}abso = gcol.nextToken (); -gcol.nextToken (); -if (abso.toLowerCase ().indexOf ("abso") != 0) { -minval = abso; -abso = null; -} else { -minval = gcol.nextToken (); -gcol.nextToken (); -}maxval = gcol.nextToken (); -if (gcol.hasMoreTokens ()) { -gcol.nextToken (); -}try { -if (minval.length > 0) { -min = new Float (minval).floatValue (); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Couldn't parse the minimum value for graduated colour for type (" + colscheme + ") - did you misspell 'auto' for the optional automatic colour switch ?"); -e.printStackTrace (); -} else { -throw e; -} -} -try { -if (maxval.length > 0) { -max = new Float (maxval).floatValue (); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Couldn't parse the maximum value for graduated colour for type (" + colscheme + ")"); -e.printStackTrace (); -} else { -throw e; -} -} -} else { -mincol = "FFFFFF"; -maxcol = "000000"; -}try { -colour = new jalview.schemes.GraduatedColor ( new jalview.schemes.UserColourScheme (mincol).findColour ('A'), new jalview.schemes.UserColourScheme (maxcol).findColour ('A'), min, max); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Couldn't parse the graduated colour scheme (" + colscheme + ")"); -e.printStackTrace (); -} else { -throw e; -} -} -if (colour != null) { -(colour).setColourByLabel (labelCol); -(colour).setAutoScaled (abso == null); -var ttype = null; -var tval = null; -if (gcol.hasMoreTokens ()) { -ttype = gcol.nextToken (); -if (ttype.toLowerCase ().startsWith ("below")) { -(colour).setThreshType (0); -} else if (ttype.toLowerCase ().startsWith ("above")) { -(colour).setThreshType (1); -} else { -(colour).setThreshType (-1); -if (!ttype.toLowerCase ().startsWith ("no")) { -System.err.println ("Ignoring unrecognised threshold type : " + ttype); -}}}if ((colour).getThreshType () != -1) { -try { -gcol.nextToken (); -tval = gcol.nextToken (); -(colour).setThresh ( new Float (tval).floatValue ()); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Couldn't parse threshold value as a float: (" + tval + ")"); -e.printStackTrace (); -} else { -throw e; -} -} -}if (gcol.hasMoreTokens ()) { -System.err.println ("Ignoring additional tokens in parameters in graduated colour specification\n"); -while (gcol.hasMoreTokens ()) { -System.err.println ("|" + gcol.nextToken ()); -} -System.err.println ("\n"); -}}} else { -var ucs = new jalview.schemes.UserColourScheme (colscheme); -colour = ucs.findColour ('A'); -}if (colour != null) { -colours.put (type, colour); -}if (st.hasMoreElements ()) { -var link = st.nextToken (); -typeLink.put (type, link); -if (featureLink == null) { -featureLink = new java.util.Hashtable (); -}featureLink.put (type, link); -}}continue; -}var seqId = ""; -while (st.hasMoreElements ()) { -if (GFFFile) { -seqId = token = st.nextToken (); -seq = this.findName (align, seqId, relaxedIdmatching, newseqs); -if (seq != null) { -desc = st.nextToken (); -var group = null; -if (this.doGffSource && desc.indexOf (' ') == -1) { -group = String.instantialize (desc); -}type = st.nextToken (); -try { -var stt = st.nextToken (); -if (stt.length == 0 || stt.equals ("-")) { -start = 0; -} else { -start = Integer.parseInt (stt); -}} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -start = 0; -} else { -throw ex; -} -} -try { -var stt = st.nextToken (); -if (stt.length == 0 || stt.equals ("-")) { -end = 0; -} else { -end = Integer.parseInt (stt); -}} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -end = 0; -} else { -throw ex; -} -} -if (end == 0) { -start = 0; -}try { -score = new Float (st.nextToken ()).floatValue (); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -score = 0; -} else { -throw ex; -} -} -sf = new jalview.datamodel.SequenceFeature (type, desc, start, end, score, group); -try { -sf.setValue ("STRAND", st.nextToken ()); -sf.setValue ("FRAME", st.nextToken ()); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -if (st.hasMoreTokens ()) { -var attributes = new StringBuffer (); -var sep = false; -while (st.hasMoreTokens ()) { -attributes.append ((sep ? "\t" : "") + st.nextElement ()); -sep = true; -} -sf.setValue ("ATTRIBUTES", attributes.toString ()); -}if (this.processOrAddSeqFeature (align, newseqs, seq, sf, GFFFile, relaxedIdmatching)) { -while ((seq = align.findName (seq, seqId, true)) != null) { -seq.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf)); -} -}break; -}}if (GFFFile && seq == null) { -desc = token; -} else { -desc = st.nextToken (); -}if (!st.hasMoreTokens ()) { -System.err.println ("DEBUG: Run out of tokens when trying to identify the destination for the feature.. giving up."); -return false; -}token = st.nextToken (); -if (!token.equals ("ID_NOT_SPECIFIED")) { -seq = this.findName (align, seqId = token, relaxedIdmatching, null); -st.nextToken (); -} else { -seqId = null; -try { -index = Integer.parseInt (st.nextToken ()); -seq = align.getSequenceAt (index); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -seq = null; -} else { -throw ex; -} -} -}if (seq == null) { -System.out.println ("Sequence not found: " + line); -break; -}start = Integer.parseInt (st.nextToken ()); -end = Integer.parseInt (st.nextToken ()); -type = st.nextToken (); -if (!colours.containsKey (type)) { -var ucs = new jalview.schemes.UserColourScheme (type); -colours.put (type, ucs.findColour ('A')); -}sf = new jalview.datamodel.SequenceFeature (type, desc, "", start, end, featureGroup); -if (st.hasMoreTokens ()) { -try { -score = new Float (st.nextToken ()).floatValue (); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -score = 0; -} else { -throw ex; -} -} -sf.setScore (score); -}if (groupLink != null && removeHTML) { -sf.addLink (groupLink); -sf.description += "%LINK%"; -}if (typeLink.containsKey (type) && removeHTML) { -sf.addLink (typeLink.get (type).toString ()); -sf.description += "%LINK%"; -}this.parseDescriptionHTML (sf, removeHTML); -seq.addSequenceFeature (sf); -while (seqId != null && (seq = align.findName (seq, seqId, false)) != null) { -seq.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf)); -} -GFFFile = false; -} -} -this.resetMatcher (); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -this.warningMessage = ((this.warningMessage == null) ? "" : this.warningMessage) + "Parsing error at\n" + line; -System.out.println ("Error parsing feature file: " + ex + "\n" + line); -ex.printStackTrace (System.err); -this.resetMatcher (); -return false; -} else { -throw ex; -} -} -return true; -}, "jalview.datamodel.AlignmentI,java.util.Map,java.util.Map,~B,~B"); -Clazz.defineMethod (c$, "processGffPragma", -($fz = function (line, gffProps, align, newseqs) { -var spacepos = line.indexOf (' '); -var pragma = spacepos == -1 ? line.substring (2).trim () : line.substring (2, spacepos); -var gffpragma = jalview.io.FeaturesFile.GFFPRAGMA.get (pragma.toLowerCase ()); -if (gffpragma == null) { -return; -}switch (gffpragma) { -case jalview.io.FeaturesFile.GffPragmas.gff_version: -try { -this.gffversion = Integer.parseInt (line.substring (spacepos + 1)); -} finally { -} -break; -case jalview.io.FeaturesFile.GffPragmas.feature_ontology: -break; -case jalview.io.FeaturesFile.GffPragmas.attribute_ontology: -break; -case jalview.io.FeaturesFile.GffPragmas.source_ontology: -break; -case jalview.io.FeaturesFile.GffPragmas.species_build: -break; -case jalview.io.FeaturesFile.GffPragmas.hash: -break; -case jalview.io.FeaturesFile.GffPragmas.fasta: -this.process_as_fasta (align, newseqs); -break; -default: -System.err.println ("Ignoring unknown pragma:\n" + line); -} -}, $fz.isPrivate = true, $fz), "~S,java.util.Map,jalview.datamodel.AlignmentI,java.util.ArrayList"); -Clazz.defineMethod (c$, "process_as_fasta", -($fz = function (align, newseqs) { -try { -this.mark (); -} catch (q) { -if (Clazz.exceptionOf (q, java.io.IOException)) { -} else { -throw q; -} -} -var parser = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", []); -var includedseqs = parser.getSeqs (); -var smatcher = new jalview.analysis.SequenceIdMatcher (newseqs); -for (var p = 0, pSize = includedseqs.size (); p < pSize; p++) { -var dummyseq = smatcher.findIdMatch (includedseqs.get (p)); -if (dummyseq != null) { -var mseq = includedseqs.get (p); -if (Clazz.instanceOf (dummyseq, jalview.datamodel.SequenceDummy)) { -(dummyseq).become (mseq); -includedseqs.set (p, dummyseq); -}}} -for (var seq, $seq = includedseqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -align.addSequence (seq); -} -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List"); -Clazz.defineMethod (c$, "processOrAddSeqFeature", -function (align, newseqs, seq, sf, gFFFile, relaxedIdMatching) { -var attr = sf.getValue ("ATTRIBUTES"); -var add = true; -if (gFFFile && attr != null) { -var nattr = 8; -for (var attset, $attset = 0, $$attset = attr.$plit ("\t"); $attset < $$attset.length && ((attset = $$attset[$attset]) || true); $attset++) { -if (attset == null || attset.trim ().length == 0) { -continue; -}nattr++; -var set = new java.util.HashMap (); -for (var pair, $pair = 0, $$pair = attset.trim ().$plit (";"); $pair < $$pair.length && ((pair = $$pair[$pair]) || true); $pair++) { -pair = pair.trim (); -if (pair.length == 0) { -continue; -}var eqpos = pair.indexOf ('='); -var sppos = pair.indexOf (' '); -var key = null; -var value = null; -if (sppos > -1 && (eqpos == -1 || sppos < eqpos)) { -key = pair.substring (0, sppos); -value = pair.substring (sppos + 1); -} else { -if (eqpos > -1 && (sppos == -1 || eqpos < sppos)) { -key = pair.substring (0, eqpos); -value = pair.substring (eqpos + 1); -} else { -key = pair; -}}if (key != null) { -var vals = set.get (key); -if (vals == null) { -vals = new java.util.ArrayList (); -set.put (key, vals); -}if (value != null) { -vals.add (value.trim ()); -}}} -try { -add = new Boolean (add & this.processGffKey (set, nattr, seq, sf, align, newseqs, relaxedIdMatching)).valueOf (); -} catch (ivfe) { -if (Clazz.exceptionOf (ivfe, jalview.io.FeaturesFile.InvalidGFF3FieldException)) { -System.err.println (ivfe); -} else { -throw ivfe; -} -} -} -}if (add) { -seq.addSequenceFeature (sf); -}return add; -}, "jalview.datamodel.AlignmentI,java.util.List,jalview.datamodel.SequenceI,jalview.datamodel.SequenceFeature,~B,~B"); -Clazz.defineMethod (c$, "processGffKey", -function (set, nattr, seq, sf, align, newseqs, relaxedIdMatching) { -var attr; -if (sf.getType ().equals ("similarity")) { -var strand = sf.getStrand (); -var querySeq = this.findNames (align, newseqs, relaxedIdMatching, set.get (attr = "Query")); -if (querySeq == null || querySeq.size () != 1) { -throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Expecting exactly one sequence in Query field (got " + set.get (attr) + ")"); -}if (set.containsKey (attr = "Align")) { -var alco = new jalview.datamodel.AlignedCodonFrame (); -var codonmapping = this.constructCodonMappingFromAlign (set, attr, strand); -alco.addMap (seq, querySeq.get (0), codonmapping); -align.addCodonFrame (alco); -return false; -}}return true; -}, "java.util.Map,~N,jalview.datamodel.SequenceI,jalview.datamodel.SequenceFeature,jalview.datamodel.AlignmentI,java.util.List,~B"); -Clazz.defineMethod (c$, "constructCodonMappingFromAlign", -($fz = function (set, attr, strand) { -if (strand == 0) { -throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Invalid strand for a codon mapping (cannot be 0)"); -}var fromrange = new java.util.ArrayList (); -var torange = new java.util.ArrayList (); -var lastppos = 0; -var lastpframe = 0; -for (var range, $range = set.get (attr).iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { -var ints = new java.util.ArrayList (); -var st = new java.util.StringTokenizer (range, " "); -while (st.hasMoreTokens ()) { -var num = st.nextToken (); -try { -ints.add ( new Integer (num)); -} catch (nfe) { -if (Clazz.exceptionOf (nfe, NumberFormatException)) { -throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Invalid number in field " + num); -} else { -throw nfe; -} -} -} -if (ints.size () != 3) { -throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Invalid number of fields for this attribute (" + ints.size () + ")"); -}fromrange.add ( new Integer (ints.get (0).intValue ())); -fromrange.add ( new Integer (ints.get (0).intValue () + strand * ints.get (2).intValue ())); -if (ints.get (1).equals (new Integer (lastppos)) && lastpframe > 0) { -lastppos += (ints.get (2)).intValue () / 3; -lastpframe = (ints.get (2)).intValue () % 3; -torange.set (torange.size () - 1, new Integer (lastppos)); -} else { -torange.add (ints.get (1)); -lastppos = (ints.get (1)).intValue () + (ints.get (2)).intValue () / 3; -lastpframe = (ints.get (2)).intValue () % 3; -torange.add ( new Integer (lastppos)); -}} -if (fromrange.size () % 2 == 1) { -throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Couldn't parse the DNA alignment range correctly"); -}if (torange.size () % 2 == 1) { -throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Couldn't parse the protein alignment range correctly"); -}var frommap = Clazz.newIntArray (fromrange.size (), 0); -var tomap = Clazz.newIntArray (torange.size (), 0); -var p = 0; -for (var ip, $ip = fromrange.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { -frommap[p++] = ip.intValue (); -} -p = 0; -for (var ip, $ip = torange.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { -tomap[p++] = ip.intValue (); -} -return new jalview.util.MapList (frommap, tomap, 3, 1); -}, $fz.isPrivate = true, $fz), "java.util.Map,~S,~N"); -Clazz.defineMethod (c$, "findNames", -($fz = function (align, newseqs, relaxedIdMatching, list) { -var found = new java.util.ArrayList (); -for (var seqId, $seqId = list.iterator (); $seqId.hasNext () && ((seqId = $seqId.next ()) || true);) { -var seq = this.findName (align, seqId, relaxedIdMatching, newseqs); -if (seq != null) { -found.add (seq); -}} -return found; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List,~B,java.util.List"); -Clazz.defineMethod (c$, "resetMatcher", -($fz = function () { -this.lastmatchedAl = null; -this.matcher = null; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "findName", -($fz = function (align, seqId, relaxedIdMatching, newseqs) { -var match = null; -if (relaxedIdMatching) { -if (this.lastmatchedAl !== align) { -this.matcher = new jalview.analysis.SequenceIdMatcher ((this.lastmatchedAl = align).getSequencesArray ()); -if (newseqs != null) { -this.matcher.addAll (newseqs); -}}match = this.matcher.findIdMatch (seqId); -} else { -match = align.findName (seqId, true); -if (match == null && newseqs != null) { -for (var m, $m = newseqs.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -if (seqId.equals (m.getName ())) { -return m; -}} -}}if (match == null && newseqs != null) { -match = new jalview.datamodel.SequenceDummy (seqId); -if (relaxedIdMatching) { -this.matcher.addAll (java.util.Arrays.asList ( Clazz.newArray (-1, [match]))); -}newseqs.add (match); -}return match; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,~S,~B,java.util.List"); -Clazz.defineMethod (c$, "parseDescriptionHTML", -function (sf, removeHTML) { -if (sf.getDescription () == null) { -return; -}var parsed = new jalview.util.ParseHtmlBodyAndLinks (sf.getDescription (), removeHTML, this.newline); -sf.description = (removeHTML) ? parsed.getNonHtmlContent () : sf.description; -for (var link, $link = parsed.getLinks ().iterator (); $link.hasNext () && ((link = $link.next ()) || true);) { -sf.addLink (link); -} -}, "jalview.datamodel.SequenceFeature,~B"); -Clazz.defineMethod (c$, "printJalviewFormat", -function (seqs, visible) { -return this.printJalviewFormat (seqs, visible, true, true); -}, "~A,java.util.Map"); -Clazz.defineMethod (c$, "printJalviewFormat", -function (seqs, visible, visOnly, nonpos) { -var out = new StringBuffer (); -var next; -var featuresGen = false; -if (visOnly && !nonpos && (visible == null || visible.size () < 1)) { -return "No Features Visible"; -}if (visible != null && visOnly) { -var en = visible.keySet ().iterator (); -var type; -var color; -while (en.hasNext ()) { -type = en.next ().toString (); -if (Clazz.instanceOf (visible.get (type), jalview.schemes.GraduatedColor)) { -var gc = visible.get (type); -color = (gc.isColourByLabel () ? "label|" : "") + jalview.util.Format.getHexString (gc.getMinColor ()) + "|" + jalview.util.Format.getHexString (gc.getMaxColor ()) + (gc.isAutoScale () ? "|" : "|abso|") + gc.getMin () + "|" + gc.getMax () + "|"; -if (gc.getThreshType () != -1) { -if (gc.getThreshType () == 0) { -color += "below"; -} else { -if (gc.getThreshType () != 1) { -System.err.println ("WARNING: Unsupported threshold type (" + gc.getThreshType () + ") : Assuming 'above'"); -}color += "above"; -}color += "|" + gc.getThresh (); -} else { -color += "none"; -}} else if (Clazz.instanceOf (visible.get (type), java.awt.Color)) { -color = jalview.util.Format.getHexString (visible.get (type)); -} else { -color = jalview.util.Format.getHexString ( new java.awt.Color (Integer.parseInt (visible.get (type).toString ()))); -}out.append (type); -out.append ("\t"); -out.append (color); -out.append (this.newline); -} -}var groups = new java.util.Vector (); -var groupIndex = 0; -var isnonpos = false; -for (var i = 0; i < seqs.length; i++) { -next = seqs[i].getSequenceFeatures (); -if (next != null) { -for (var j = 0; j < next.length; j++) { -isnonpos = next[j].begin == 0 && next[j].end == 0; -if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !visible.containsKey (next[j].type))) { -continue; -}if (next[j].featureGroup != null && !groups.contains (next[j].featureGroup)) { -groups.addElement (next[j].featureGroup); -}} -}} -var group = null; -do { -if (groups.size () > 0 && groupIndex < groups.size ()) { -group = groups.elementAt (groupIndex).toString (); -out.append (this.newline); -out.append ("STARTGROUP\t"); -out.append (group); -out.append (this.newline); -} else { -group = null; -}for (var i = 0; i < seqs.length; i++) { -next = seqs[i].getSequenceFeatures (); -if (next != null) { -for (var j = 0; j < next.length; j++) { -isnonpos = next[j].begin == 0 && next[j].end == 0; -if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !visible.containsKey (next[j].type))) { -continue; -}if (group != null && (next[j].featureGroup == null || !next[j].featureGroup.equals (group))) { -continue; -}if (group == null && next[j].featureGroup != null) { -continue; -}featuresGen = true; -if (next[j].description == null || next[j].description.equals ("")) { -out.append (next[j].type + "\t"); -} else { -if (next[j].links != null && next[j].getDescription ().indexOf ("") == -1) { -out.append (""); -}out.append (next[j].description + " "); -if (next[j].links != null) { -for (var l = 0; l < next[j].links.size (); l++) { -var label = next[j].links.elementAt (l).toString (); -var href = label.substring (label.indexOf ("|") + 1); -label = label.substring (0, label.indexOf ("|")); -if (next[j].description.indexOf (href) == -1) { -out.append ("" + label + ""); -}} -if (next[j].getDescription ().indexOf ("") == -1) { -out.append (""); -}}out.append ("\t"); -}out.append (seqs[i].getName ()); -out.append ("\t-1\t"); -out.append ("" + next[j].begin); -out.append ("\t"); -out.append ("" + next[j].end); -out.append ("\t"); -out.append (next[j].type); -if (!Float.isNaN (next[j].score)) { -out.append ("\t"); -out.append (next[j].score); -}out.append (this.newline); -} -}} -if (group != null) { -out.append ("ENDGROUP\t"); -out.append (group); -out.append (this.newline); -groupIndex++; -} else { -break; -}} while (groupIndex < groups.size () + 1); -if (!featuresGen) { -return "No Features Visible"; -}return out.toString (); -}, "~A,java.util.Map,~B,~B"); -Clazz.defineMethod (c$, "printGFFFormat", -function (seqs, visible) { -return this.printGFFFormat (seqs, visible, true, true); -}, "~A,java.util.Map"); -Clazz.defineMethod (c$, "printGFFFormat", -function (seqs, visible, visOnly, nonpos) { -var out = new StringBuffer (); -var next; -var source; -var isnonpos; -for (var i = 0; i < seqs.length; i++) { -if (seqs[i].getSequenceFeatures () != null) { -next = seqs[i].getSequenceFeatures (); -for (var j = 0; j < next.length; j++) { -isnonpos = next[j].begin == 0 && next[j].end == 0; -if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !visible.containsKey (next[j].type))) { -continue; -}source = next[j].featureGroup; -if (source == null) { -source = next[j].getDescription (); -}out.append (seqs[i].getName ()); -out.append ("\t"); -out.append (source); -out.append ("\t"); -out.append (next[j].type); -out.append ("\t"); -out.append ("" + next[j].begin); -out.append ("\t"); -out.append ("" + next[j].end); -out.append ("\t"); -out.append (next[j].score); -out.append ("\t"); -if (next[j].getValue ("STRAND") != null) { -out.append (next[j].getValue ("STRAND")); -out.append ("\t"); -} else { -out.append (".\t"); -}if (next[j].getValue ("FRAME") != null) { -out.append (next[j].getValue ("FRAME")); -} else { -out.append ("."); -}if (next[j].getValue ("ATTRIBUTES") != null) { -out.append (next[j].getValue ("ATTRIBUTES")); -}out.append (this.newline); -} -}} -return out.toString (); -}, "~A,java.util.Map,~B,~B"); -Clazz.defineMethod (c$, "parse", -function () { -}); -Clazz.overrideMethod (c$, "print", -function () { -return "USE printGFFFormat() or printJalviewFormat()"; -}); -c$.$FeaturesFile$InvalidGFF3FieldException$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.field = null; -this.value = null; -Clazz.instantialize (this, arguments); -}, jalview.io.FeaturesFile, "InvalidGFF3FieldException", Exception); -Clazz.makeConstructor (c$, -function (a, b, c) { -Clazz.superConstructor (this, jalview.io.FeaturesFile.InvalidGFF3FieldException, [c + " (Field was " + a + " and value was " + b.get (a).toString ()]); -this.field = a; -this.value = b.get (a).toString (); -}, "~S,java.util.Map,~S"); -c$ = Clazz.p0p (); -}; -Clazz.pu$h (); -c$ = Clazz.declareType (jalview.io.FeaturesFile, "GffPragmas", Enum); -Clazz.defineEnumConstant (c$, "gff_version", 0, []); -Clazz.defineEnumConstant (c$, "sequence_region", 1, []); -Clazz.defineEnumConstant (c$, "feature_ontology", 2, []); -Clazz.defineEnumConstant (c$, "attribute_ontology", 3, []); -Clazz.defineEnumConstant (c$, "source_ontology", 4, []); -Clazz.defineEnumConstant (c$, "species_build", 5, []); -Clazz.defineEnumConstant (c$, "fasta", 6, []); -Clazz.defineEnumConstant (c$, "hash", 7, []); -c$ = Clazz.p0p (); -Clazz.defineStatics (c$, -"GFFPRAGMA", null); -{ -jalview.io.FeaturesFile.GFFPRAGMA = new java.util.HashMap (); -jalview.io.FeaturesFile.GFFPRAGMA.put ("sequence-region", jalview.io.FeaturesFile.GffPragmas.sequence_region); -jalview.io.FeaturesFile.GFFPRAGMA.put ("feature-ontology", jalview.io.FeaturesFile.GffPragmas.feature_ontology); -jalview.io.FeaturesFile.GFFPRAGMA.put ("#", jalview.io.FeaturesFile.GffPragmas.hash); -jalview.io.FeaturesFile.GFFPRAGMA.put ("fasta", jalview.io.FeaturesFile.GffPragmas.fasta); -jalview.io.FeaturesFile.GFFPRAGMA.put ("species-build", jalview.io.FeaturesFile.GffPragmas.species_build); -jalview.io.FeaturesFile.GFFPRAGMA.put ("source-ontology", jalview.io.FeaturesFile.GffPragmas.source_ontology); -jalview.io.FeaturesFile.GFFPRAGMA.put ("attribute-ontology", jalview.io.FeaturesFile.GffPragmas.attribute_ontology); -}}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile", "java.lang.Enum", "$.Exception"], "jalview.io.FeaturesFile", ["jalview.analysis.SequenceIdMatcher", "jalview.datamodel.AlignedCodonFrame", "$.SequenceDummy", "$.SequenceFeature", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.GraduatedColor", "$.UserColourScheme", "jalview.util.Format", "$.MapList", "$.ParseHtmlBodyAndLinks", "java.awt.Color", "java.lang.Float", "$.StringBuffer", "java.util.ArrayList", "$.Arrays", "$.HashMap", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.doGffSource = true; +this.gffversion = 0; +if (!Clazz.isClassDefined ("jalview.io.FeaturesFile.InvalidGFF3FieldException")) { +jalview.io.FeaturesFile.$FeaturesFile$InvalidGFF3FieldException$ (); +} +this.lastmatchedAl = null; +this.matcher = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "FeaturesFile", jalview.io.AlignFile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.FeaturesFile, []); +}); +Clazz.defineMethod (c$, "parse", +function (align, colours, removeHTML) { +return this.parse (align, colours, null, removeHTML, false); +}, "jalview.datamodel.AlignmentI,java.util.Hashtable,~B"); +Clazz.defineMethod (c$, "parse", +function (align, colours, removeHTML, relaxedIdMatching) { +return this.parse (align, colours, null, removeHTML, relaxedIdMatching); +}, "jalview.datamodel.AlignmentI,java.util.Map,~B,~B"); +Clazz.defineMethod (c$, "parse", +function (align, colours, featureLink, removeHTML) { +return this.parse (align, colours, featureLink, removeHTML, false); +}, "jalview.datamodel.AlignmentI,java.util.Map,java.util.Map,~B"); +Clazz.defineMethod (c$, "parse", +function (align, colours, featureLink, removeHTML, relaxedIdmatching) { +var line = null; +try { +var seq = null; +var newseqs = new java.util.ArrayList (); +var type; +var desc; +var token = null; +var index; +var start; +var end; +var score; +var st; +var sf; +var featureGroup = null; +var groupLink = null; +var typeLink = new java.util.Hashtable (); +var GFFFile = true; +var gffProps = new java.util.HashMap (); +while ((line = this.nextLine ()) != null) { +if (line.startsWith ("#")) { +if (line.startsWith ("##")) { +this.processGffPragma (line, gffProps, align, newseqs); +line = ""; +}continue; +}st = new java.util.StringTokenizer (line, "\t"); +if (st.countTokens () == 1) { +if (line.trim ().equalsIgnoreCase ("GFF")) { +GFFFile = true; +continue; +}}if (st.countTokens () > 1 && st.countTokens () < 4) { +GFFFile = false; +type = st.nextToken (); +if (type.equalsIgnoreCase ("startgroup")) { +featureGroup = st.nextToken (); +if (st.hasMoreElements ()) { +groupLink = st.nextToken (); +featureLink.put (featureGroup, groupLink); +}} else if (type.equalsIgnoreCase ("endgroup")) { +st.nextToken (); +featureGroup = null; +groupLink = null; +} else { +var colour = null; +var colscheme = st.nextToken (); +if (colscheme.indexOf ("|") > -1 || colscheme.trim ().equalsIgnoreCase ("label")) { +var gcol = new java.util.StringTokenizer (colscheme, "|", true); +var threshtype = -1; +var min = 1.4E-45; +var max = 3.4028235E38; +var threshval = NaN; +var labelCol = false; +var mincol = gcol.nextToken (); +if (mincol === "|") { +System.err.println ("Expected either 'label' or a colour specification in the line: " + line); +continue; +}var maxcol = null; +if (mincol.toLowerCase ().indexOf ("label") == 0) { +labelCol = true; +mincol = (gcol.hasMoreTokens () ? gcol.nextToken () : null); +mincol = (gcol.hasMoreTokens () ? gcol.nextToken () : null); +}var abso = null; +var minval; +var maxval; +if (mincol != null) { +if (mincol.equals ("|")) { +mincol = ""; +} else { +gcol.nextToken (); +}maxcol = gcol.nextToken (); +if (maxcol.equals ("|")) { +maxcol = ""; +} else { +gcol.nextToken (); +}abso = gcol.nextToken (); +gcol.nextToken (); +if (abso.toLowerCase ().indexOf ("abso") != 0) { +minval = abso; +abso = null; +} else { +minval = gcol.nextToken (); +gcol.nextToken (); +}maxval = gcol.nextToken (); +if (gcol.hasMoreTokens ()) { +gcol.nextToken (); +}try { +if (minval.length > 0) { +min = new Float (minval).floatValue (); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Couldn't parse the minimum value for graduated colour for type (" + colscheme + ") - did you misspell 'auto' for the optional automatic colour switch ?"); +e.printStackTrace (); +} else { +throw e; +} +} +try { +if (maxval.length > 0) { +max = new Float (maxval).floatValue (); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Couldn't parse the maximum value for graduated colour for type (" + colscheme + ")"); +e.printStackTrace (); +} else { +throw e; +} +} +} else { +mincol = "FFFFFF"; +maxcol = "000000"; +}try { +colour = new jalview.schemes.GraduatedColor ( new jalview.schemes.UserColourScheme (mincol).findColour ('A'), new jalview.schemes.UserColourScheme (maxcol).findColour ('A'), min, max); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Couldn't parse the graduated colour scheme (" + colscheme + ")"); +e.printStackTrace (); +} else { +throw e; +} +} +if (colour != null) { +(colour).setColourByLabel (labelCol); +(colour).setAutoScaled (abso == null); +var ttype = null; +var tval = null; +if (gcol.hasMoreTokens ()) { +ttype = gcol.nextToken (); +if (ttype.toLowerCase ().startsWith ("below")) { +(colour).setThreshType (0); +} else if (ttype.toLowerCase ().startsWith ("above")) { +(colour).setThreshType (1); +} else { +(colour).setThreshType (-1); +if (!ttype.toLowerCase ().startsWith ("no")) { +System.err.println ("Ignoring unrecognised threshold type : " + ttype); +}}}if ((colour).getThreshType () != -1) { +try { +gcol.nextToken (); +tval = gcol.nextToken (); +(colour).setThresh ( new Float (tval).floatValue ()); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Couldn't parse threshold value as a float: (" + tval + ")"); +e.printStackTrace (); +} else { +throw e; +} +} +}if (gcol.hasMoreTokens ()) { +System.err.println ("Ignoring additional tokens in parameters in graduated colour specification\n"); +while (gcol.hasMoreTokens ()) { +System.err.println ("|" + gcol.nextToken ()); +} +System.err.println ("\n"); +}}} else { +var ucs = new jalview.schemes.UserColourScheme (colscheme); +colour = ucs.findColour ('A'); +}if (colour != null) { +colours.put (type, colour); +}if (st.hasMoreElements ()) { +var link = st.nextToken (); +typeLink.put (type, link); +if (featureLink == null) { +featureLink = new java.util.Hashtable (); +}featureLink.put (type, link); +}}continue; +}var seqId = ""; +while (st.hasMoreElements ()) { +if (GFFFile) { +seqId = token = st.nextToken (); +seq = this.findName (align, seqId, relaxedIdmatching, newseqs); +if (seq != null) { +desc = st.nextToken (); +var group = null; +if (this.doGffSource && desc.indexOf (' ') == -1) { +group = String.instantialize (desc); +}type = st.nextToken (); +try { +var stt = st.nextToken (); +if (stt.length == 0 || stt.equals ("-")) { +start = 0; +} else { +start = Integer.parseInt (stt); +}} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +start = 0; +} else { +throw ex; +} +} +try { +var stt = st.nextToken (); +if (stt.length == 0 || stt.equals ("-")) { +end = 0; +} else { +end = Integer.parseInt (stt); +}} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +end = 0; +} else { +throw ex; +} +} +if (end == 0) { +start = 0; +}try { +score = new Float (st.nextToken ()).floatValue (); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +score = 0; +} else { +throw ex; +} +} +sf = new jalview.datamodel.SequenceFeature (type, desc, start, end, score, group); +try { +sf.setValue ("STRAND", st.nextToken ()); +sf.setValue ("FRAME", st.nextToken ()); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +if (st.hasMoreTokens ()) { +var attributes = new StringBuffer (); +var sep = false; +while (st.hasMoreTokens ()) { +attributes.append ((sep ? "\t" : "") + st.nextElement ()); +sep = true; +} +sf.setValue ("ATTRIBUTES", attributes.toString ()); +}if (this.processOrAddSeqFeature (align, newseqs, seq, sf, GFFFile, relaxedIdmatching)) { +while ((seq = align.findName (seq, seqId, true)) != null) { +seq.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf)); +} +}break; +}}if (GFFFile && seq == null) { +desc = token; +} else { +desc = st.nextToken (); +}if (!st.hasMoreTokens ()) { +System.err.println ("DEBUG: Run out of tokens when trying to identify the destination for the feature.. giving up."); +return false; +}token = st.nextToken (); +if (!token.equals ("ID_NOT_SPECIFIED")) { +seq = this.findName (align, seqId = token, relaxedIdmatching, null); +st.nextToken (); +} else { +seqId = null; +try { +index = Integer.parseInt (st.nextToken ()); +seq = align.getSequenceAt (index); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +seq = null; +} else { +throw ex; +} +} +}if (seq == null) { +System.out.println ("Sequence not found: " + line); +break; +}start = Integer.parseInt (st.nextToken ()); +end = Integer.parseInt (st.nextToken ()); +type = st.nextToken (); +if (!colours.containsKey (type)) { +var ucs = new jalview.schemes.UserColourScheme (type); +colours.put (type, ucs.findColour ('A')); +}sf = new jalview.datamodel.SequenceFeature (type, desc, "", start, end, featureGroup); +if (st.hasMoreTokens ()) { +try { +score = new Float (st.nextToken ()).floatValue (); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +score = 0; +} else { +throw ex; +} +} +sf.setScore (score); +}if (groupLink != null && removeHTML) { +sf.addLink (groupLink); +sf.description += "%LINK%"; +}if (typeLink.containsKey (type) && removeHTML) { +sf.addLink (typeLink.get (type).toString ()); +sf.description += "%LINK%"; +}this.parseDescriptionHTML (sf, removeHTML); +seq.addSequenceFeature (sf); +while (seqId != null && (seq = align.findName (seq, seqId, false)) != null) { +seq.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf)); +} +GFFFile = false; +} +} +this.resetMatcher (); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +this.warningMessage = ((this.warningMessage == null) ? "" : this.warningMessage) + "Parsing error at\n" + line; +System.out.println ("Error parsing feature file: " + ex + "\n" + line); +ex.printStackTrace (System.err); +this.resetMatcher (); +return false; +} else { +throw ex; +} +} +return true; +}, "jalview.datamodel.AlignmentI,java.util.Map,java.util.Map,~B,~B"); +Clazz.defineMethod (c$, "processGffPragma", +($fz = function (line, gffProps, align, newseqs) { +var spacepos = line.indexOf (' '); +var pragma = spacepos == -1 ? line.substring (2).trim () : line.substring (2, spacepos); +var gffpragma = jalview.io.FeaturesFile.GFFPRAGMA.get (pragma.toLowerCase ()); +if (gffpragma == null) { +return; +}switch (gffpragma) { +case jalview.io.FeaturesFile.GffPragmas.gff_version: +try { +this.gffversion = Integer.parseInt (line.substring (spacepos + 1)); +} finally { +} +break; +case jalview.io.FeaturesFile.GffPragmas.feature_ontology: +break; +case jalview.io.FeaturesFile.GffPragmas.attribute_ontology: +break; +case jalview.io.FeaturesFile.GffPragmas.source_ontology: +break; +case jalview.io.FeaturesFile.GffPragmas.species_build: +break; +case jalview.io.FeaturesFile.GffPragmas.hash: +break; +case jalview.io.FeaturesFile.GffPragmas.fasta: +this.process_as_fasta (align, newseqs); +break; +default: +System.err.println ("Ignoring unknown pragma:\n" + line); +} +}, $fz.isPrivate = true, $fz), "~S,java.util.Map,jalview.datamodel.AlignmentI,java.util.ArrayList"); +Clazz.defineMethod (c$, "process_as_fasta", +($fz = function (align, newseqs) { +try { +this.mark (); +} catch (q) { +if (Clazz.exceptionOf (q, java.io.IOException)) { +} else { +throw q; +} +} +var parser = jalview.jsdev.GenericFileAdapter.getFile ("FastaFile", []); +var includedseqs = parser.getSeqs (); +var smatcher = new jalview.analysis.SequenceIdMatcher (newseqs); +for (var p = 0, pSize = includedseqs.size (); p < pSize; p++) { +var dummyseq = smatcher.findIdMatch (includedseqs.get (p)); +if (dummyseq != null) { +var mseq = includedseqs.get (p); +if (Clazz.instanceOf (dummyseq, jalview.datamodel.SequenceDummy)) { +(dummyseq).become (mseq); +includedseqs.set (p, dummyseq); +}}} +for (var seq, $seq = includedseqs.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +align.addSequence (seq); +} +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List"); +Clazz.defineMethod (c$, "processOrAddSeqFeature", +function (align, newseqs, seq, sf, gFFFile, relaxedIdMatching) { +var attr = sf.getValue ("ATTRIBUTES"); +var add = true; +if (gFFFile && attr != null) { +var nattr = 8; +for (var attset, $attset = 0, $$attset = attr.$plit ("\t"); $attset < $$attset.length && ((attset = $$attset[$attset]) || true); $attset++) { +if (attset == null || attset.trim ().length == 0) { +continue; +}nattr++; +var set = new java.util.HashMap (); +for (var pair, $pair = 0, $$pair = attset.trim ().$plit (";"); $pair < $$pair.length && ((pair = $$pair[$pair]) || true); $pair++) { +pair = pair.trim (); +if (pair.length == 0) { +continue; +}var eqpos = pair.indexOf ('='); +var sppos = pair.indexOf (' '); +var key = null; +var value = null; +if (sppos > -1 && (eqpos == -1 || sppos < eqpos)) { +key = pair.substring (0, sppos); +value = pair.substring (sppos + 1); +} else { +if (eqpos > -1 && (sppos == -1 || eqpos < sppos)) { +key = pair.substring (0, eqpos); +value = pair.substring (eqpos + 1); +} else { +key = pair; +}}if (key != null) { +var vals = set.get (key); +if (vals == null) { +vals = new java.util.ArrayList (); +set.put (key, vals); +}if (value != null) { +vals.add (value.trim ()); +}}} +try { +add = new Boolean (add & this.processGffKey (set, nattr, seq, sf, align, newseqs, relaxedIdMatching)).valueOf (); +} catch (ivfe) { +if (Clazz.exceptionOf (ivfe, jalview.io.FeaturesFile.InvalidGFF3FieldException)) { +System.err.println (ivfe); +} else { +throw ivfe; +} +} +} +}if (add) { +seq.addSequenceFeature (sf); +}return add; +}, "jalview.datamodel.AlignmentI,java.util.List,jalview.datamodel.SequenceI,jalview.datamodel.SequenceFeature,~B,~B"); +Clazz.defineMethod (c$, "processGffKey", +function (set, nattr, seq, sf, align, newseqs, relaxedIdMatching) { +var attr; +if (sf.getType ().equals ("similarity")) { +var strand = sf.getStrand (); +var querySeq = this.findNames (align, newseqs, relaxedIdMatching, set.get (attr = "Query")); +if (querySeq == null || querySeq.size () != 1) { +throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Expecting exactly one sequence in Query field (got " + set.get (attr) + ")"); +}if (set.containsKey (attr = "Align")) { +var alco = new jalview.datamodel.AlignedCodonFrame (); +var codonmapping = this.constructCodonMappingFromAlign (set, attr, strand); +alco.addMap (seq, querySeq.get (0), codonmapping); +align.addCodonFrame (alco); +return false; +}}return true; +}, "java.util.Map,~N,jalview.datamodel.SequenceI,jalview.datamodel.SequenceFeature,jalview.datamodel.AlignmentI,java.util.List,~B"); +Clazz.defineMethod (c$, "constructCodonMappingFromAlign", +($fz = function (set, attr, strand) { +if (strand == 0) { +throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Invalid strand for a codon mapping (cannot be 0)"); +}var fromrange = new java.util.ArrayList (); +var torange = new java.util.ArrayList (); +var lastppos = 0; +var lastpframe = 0; +for (var range, $range = set.get (attr).iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { +var ints = new java.util.ArrayList (); +var st = new java.util.StringTokenizer (range, " "); +while (st.hasMoreTokens ()) { +var num = st.nextToken (); +try { +ints.add ( new Integer (num)); +} catch (nfe) { +if (Clazz.exceptionOf (nfe, NumberFormatException)) { +throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Invalid number in field " + num); +} else { +throw nfe; +} +} +} +if (ints.size () != 3) { +throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Invalid number of fields for this attribute (" + ints.size () + ")"); +}fromrange.add ( new Integer (ints.get (0).intValue ())); +fromrange.add ( new Integer (ints.get (0).intValue () + strand * ints.get (2).intValue ())); +if (ints.get (1).equals (new Integer (lastppos)) && lastpframe > 0) { +lastppos += (ints.get (2)).intValue () / 3; +lastpframe = (ints.get (2)).intValue () % 3; +torange.set (torange.size () - 1, new Integer (lastppos)); +} else { +torange.add (ints.get (1)); +lastppos = (ints.get (1)).intValue () + (ints.get (2)).intValue () / 3; +lastpframe = (ints.get (2)).intValue () % 3; +torange.add ( new Integer (lastppos)); +}} +if (fromrange.size () % 2 == 1) { +throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Couldn't parse the DNA alignment range correctly"); +}if (torange.size () % 2 == 1) { +throw Clazz.innerTypeInstance (jalview.io.FeaturesFile.InvalidGFF3FieldException, this, null, attr, set, "Couldn't parse the protein alignment range correctly"); +}var frommap = Clazz.newIntArray (fromrange.size (), 0); +var tomap = Clazz.newIntArray (torange.size (), 0); +var p = 0; +for (var ip, $ip = fromrange.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { +frommap[p++] = ip.intValue (); +} +p = 0; +for (var ip, $ip = torange.iterator (); $ip.hasNext () && ((ip = $ip.next ()) || true);) { +tomap[p++] = ip.intValue (); +} +return new jalview.util.MapList (frommap, tomap, 3, 1); +}, $fz.isPrivate = true, $fz), "java.util.Map,~S,~N"); +Clazz.defineMethod (c$, "findNames", +($fz = function (align, newseqs, relaxedIdMatching, list) { +var found = new java.util.ArrayList (); +for (var seqId, $seqId = list.iterator (); $seqId.hasNext () && ((seqId = $seqId.next ()) || true);) { +var seq = this.findName (align, seqId, relaxedIdMatching, newseqs); +if (seq != null) { +found.add (seq); +}} +return found; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,java.util.List,~B,java.util.List"); +Clazz.defineMethod (c$, "resetMatcher", +($fz = function () { +this.lastmatchedAl = null; +this.matcher = null; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "findName", +($fz = function (align, seqId, relaxedIdMatching, newseqs) { +var match = null; +if (relaxedIdMatching) { +if (this.lastmatchedAl !== align) { +this.matcher = new jalview.analysis.SequenceIdMatcher ((this.lastmatchedAl = align).getSequencesArray ()); +if (newseqs != null) { +this.matcher.addAll (newseqs); +}}match = this.matcher.findIdMatch (seqId); +} else { +match = align.findName (seqId, true); +if (match == null && newseqs != null) { +for (var m, $m = newseqs.iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +if (seqId.equals (m.getName ())) { +return m; +}} +}}if (match == null && newseqs != null) { +match = new jalview.datamodel.SequenceDummy (seqId); +if (relaxedIdMatching) { +this.matcher.addAll (java.util.Arrays.asList ( Clazz.newArray (-1, [match]))); +}newseqs.add (match); +}return match; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentI,~S,~B,java.util.List"); +Clazz.defineMethod (c$, "parseDescriptionHTML", +function (sf, removeHTML) { +if (sf.getDescription () == null) { +return; +}var parsed = new jalview.util.ParseHtmlBodyAndLinks (sf.getDescription (), removeHTML, this.newline); +sf.description = (removeHTML) ? parsed.getNonHtmlContent () : sf.description; +for (var link, $link = parsed.getLinks ().iterator (); $link.hasNext () && ((link = $link.next ()) || true);) { +sf.addLink (link); +} +}, "jalview.datamodel.SequenceFeature,~B"); +Clazz.defineMethod (c$, "printJalviewFormat", +function (seqs, visible) { +return this.printJalviewFormat (seqs, visible, true, true); +}, "~A,java.util.Map"); +Clazz.defineMethod (c$, "printJalviewFormat", +function (seqs, visible, visOnly, nonpos) { +var out = new StringBuffer (); +var next; +var featuresGen = false; +if (visOnly && !nonpos && (visible == null || visible.size () < 1)) { +return "No Features Visible"; +}if (visible != null && visOnly) { +var en = visible.keySet ().iterator (); +var type; +var color; +while (en.hasNext ()) { +type = en.next ().toString (); +if (Clazz.instanceOf (visible.get (type), jalview.schemes.GraduatedColor)) { +var gc = visible.get (type); +color = (gc.isColourByLabel () ? "label|" : "") + jalview.util.Format.getHexString (gc.getMinColor ()) + "|" + jalview.util.Format.getHexString (gc.getMaxColor ()) + (gc.isAutoScale () ? "|" : "|abso|") + gc.getMin () + "|" + gc.getMax () + "|"; +if (gc.getThreshType () != -1) { +if (gc.getThreshType () == 0) { +color += "below"; +} else { +if (gc.getThreshType () != 1) { +System.err.println ("WARNING: Unsupported threshold type (" + gc.getThreshType () + ") : Assuming 'above'"); +}color += "above"; +}color += "|" + gc.getThresh (); +} else { +color += "none"; +}} else if (Clazz.instanceOf (visible.get (type), java.awt.Color)) { +color = jalview.util.Format.getHexString (visible.get (type)); +} else { +color = jalview.util.Format.getHexString ( new java.awt.Color (Integer.parseInt (visible.get (type).toString ()))); +}out.append (type); +out.append ("\t"); +out.append (color); +out.append (this.newline); +} +}var groups = new java.util.Vector (); +var groupIndex = 0; +var isnonpos = false; +for (var i = 0; i < seqs.length; i++) { +next = seqs[i].getSequenceFeatures (); +if (next != null) { +for (var j = 0; j < next.length; j++) { +isnonpos = next[j].begin == 0 && next[j].end == 0; +if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !visible.containsKey (next[j].type))) { +continue; +}if (next[j].featureGroup != null && !groups.contains (next[j].featureGroup)) { +groups.addElement (next[j].featureGroup); +}} +}} +var group = null; +do { +if (groups.size () > 0 && groupIndex < groups.size ()) { +group = groups.elementAt (groupIndex).toString (); +out.append (this.newline); +out.append ("STARTGROUP\t"); +out.append (group); +out.append (this.newline); +} else { +group = null; +}for (var i = 0; i < seqs.length; i++) { +next = seqs[i].getSequenceFeatures (); +if (next != null) { +for (var j = 0; j < next.length; j++) { +isnonpos = next[j].begin == 0 && next[j].end == 0; +if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !visible.containsKey (next[j].type))) { +continue; +}if (group != null && (next[j].featureGroup == null || !next[j].featureGroup.equals (group))) { +continue; +}if (group == null && next[j].featureGroup != null) { +continue; +}featuresGen = true; +if (next[j].description == null || next[j].description.equals ("")) { +out.append (next[j].type + "\t"); +} else { +if (next[j].links != null && next[j].getDescription ().indexOf ("") == -1) { +out.append (""); +}out.append (next[j].description + " "); +if (next[j].links != null) { +for (var l = 0; l < next[j].links.size (); l++) { +var label = next[j].links.elementAt (l).toString (); +var href = label.substring (label.indexOf ("|") + 1); +label = label.substring (0, label.indexOf ("|")); +if (next[j].description.indexOf (href) == -1) { +out.append ("" + label + ""); +}} +if (next[j].getDescription ().indexOf ("") == -1) { +out.append (""); +}}out.append ("\t"); +}out.append (seqs[i].getName ()); +out.append ("\t-1\t"); +out.append ("" + next[j].begin); +out.append ("\t"); +out.append ("" + next[j].end); +out.append ("\t"); +out.append (next[j].type); +if (!Float.isNaN (next[j].score)) { +out.append ("\t"); +out.append (next[j].score); +}out.append (this.newline); +} +}} +if (group != null) { +out.append ("ENDGROUP\t"); +out.append (group); +out.append (this.newline); +groupIndex++; +} else { +break; +}} while (groupIndex < groups.size () + 1); +if (!featuresGen) { +return "No Features Visible"; +}return out.toString (); +}, "~A,java.util.Map,~B,~B"); +Clazz.defineMethod (c$, "printGFFFormat", +function (seqs, visible) { +return this.printGFFFormat (seqs, visible, true, true); +}, "~A,java.util.Map"); +Clazz.defineMethod (c$, "printGFFFormat", +function (seqs, visible, visOnly, nonpos) { +var out = new StringBuffer (); +var next; +var source; +var isnonpos; +for (var i = 0; i < seqs.length; i++) { +if (seqs[i].getSequenceFeatures () != null) { +next = seqs[i].getSequenceFeatures (); +for (var j = 0; j < next.length; j++) { +isnonpos = next[j].begin == 0 && next[j].end == 0; +if ((!nonpos && isnonpos) || (!isnonpos && visOnly && !visible.containsKey (next[j].type))) { +continue; +}source = next[j].featureGroup; +if (source == null) { +source = next[j].getDescription (); +}out.append (seqs[i].getName ()); +out.append ("\t"); +out.append (source); +out.append ("\t"); +out.append (next[j].type); +out.append ("\t"); +out.append ("" + next[j].begin); +out.append ("\t"); +out.append ("" + next[j].end); +out.append ("\t"); +out.append (next[j].score); +out.append ("\t"); +if (next[j].getValue ("STRAND") != null) { +out.append (next[j].getValue ("STRAND")); +out.append ("\t"); +} else { +out.append (".\t"); +}if (next[j].getValue ("FRAME") != null) { +out.append (next[j].getValue ("FRAME")); +} else { +out.append ("."); +}if (next[j].getValue ("ATTRIBUTES") != null) { +out.append (next[j].getValue ("ATTRIBUTES")); +}out.append (this.newline); +} +}} +return out.toString (); +}, "~A,java.util.Map,~B,~B"); +Clazz.defineMethod (c$, "parse", +function () { +}); +Clazz.overrideMethod (c$, "print", +function () { +return "USE printGFFFormat() or printJalviewFormat()"; +}); +c$.$FeaturesFile$InvalidGFF3FieldException$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.field = null; +this.value = null; +Clazz.instantialize (this, arguments); +}, jalview.io.FeaturesFile, "InvalidGFF3FieldException", Exception); +Clazz.makeConstructor (c$, +function (a, b, c) { +Clazz.superConstructor (this, jalview.io.FeaturesFile.InvalidGFF3FieldException, [c + " (Field was " + a + " and value was " + b.get (a).toString ()]); +this.field = a; +this.value = b.get (a).toString (); +}, "~S,java.util.Map,~S"); +c$ = Clazz.p0p (); +}; +Clazz.pu$h (); +c$ = Clazz.declareType (jalview.io.FeaturesFile, "GffPragmas", Enum); +Clazz.defineEnumConstant (c$, "gff_version", 0, []); +Clazz.defineEnumConstant (c$, "sequence_region", 1, []); +Clazz.defineEnumConstant (c$, "feature_ontology", 2, []); +Clazz.defineEnumConstant (c$, "attribute_ontology", 3, []); +Clazz.defineEnumConstant (c$, "source_ontology", 4, []); +Clazz.defineEnumConstant (c$, "species_build", 5, []); +Clazz.defineEnumConstant (c$, "fasta", 6, []); +Clazz.defineEnumConstant (c$, "hash", 7, []); +c$ = Clazz.p0p (); +Clazz.defineStatics (c$, +"GFFPRAGMA", null); +{ +jalview.io.FeaturesFile.GFFPRAGMA = new java.util.HashMap (); +jalview.io.FeaturesFile.GFFPRAGMA.put ("sequence-region", jalview.io.FeaturesFile.GffPragmas.sequence_region); +jalview.io.FeaturesFile.GFFPRAGMA.put ("feature-ontology", jalview.io.FeaturesFile.GffPragmas.feature_ontology); +jalview.io.FeaturesFile.GFFPRAGMA.put ("#", jalview.io.FeaturesFile.GffPragmas.hash); +jalview.io.FeaturesFile.GFFPRAGMA.put ("fasta", jalview.io.FeaturesFile.GffPragmas.fasta); +jalview.io.FeaturesFile.GFFPRAGMA.put ("species-build", jalview.io.FeaturesFile.GffPragmas.species_build); +jalview.io.FeaturesFile.GFFPRAGMA.put ("source-ontology", jalview.io.FeaturesFile.GffPragmas.source_ontology); +jalview.io.FeaturesFile.GFFPRAGMA.put ("attribute-ontology", jalview.io.FeaturesFile.GffPragmas.attribute_ontology); +}}); diff --git a/bin/jalview/io/FileParse.js b/bin/jalview/io/FileParse.js index a16b90a..51d1e87 100644 --- a/bin/jalview/io/FileParse.js +++ b/bin/jalview/io/FileParse.js @@ -1,250 +1,250 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.FileParse", ["jalview.io.AppletFormatAdapter", "jalview.util.MessageManager", "java.io.BufferedReader", "$.IOException", "$.InputStreamReader", "$.StringReader", "java.lang.Error", "java.net.URL", "java.util.zip.GZIPInputStream"], function () { -c$ = Clazz.decorateAsClass (function () { -this.dataName = "unknown source"; -this.inFile = null; -this.viewport = null; -this.exportSettings = null; -this.index = 1; -this.suffixSeparator = '#'; -this.newline = null; -this.suffix = null; -this.type = null; -this.dataIn = null; -this.errormessage = "UNITIALISED SOURCE"; -this.error = true; -this.warningMessage = null; -this.READAHEAD_LIMIT = 2048; -Clazz.instantialize (this, arguments); -}, jalview.io, "FileParse"); -Clazz.prepareFields (c$, function () { -this.newline = System.getProperty ("line.separator"); -}); -Clazz.defineMethod (c$, "setNewlineString", -function (nl) { -this.newline = nl; -}, "~S"); -Clazz.defineMethod (c$, "getNewlineString", -function () { -return this.newline; -}); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.makeConstructor (c$, -function (from) { -if (from == null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_null_fileparse")); -}if (from === this) { -return; -}this.index = ++from.index; -this.inFile = from.inFile; -this.suffixSeparator = from.suffixSeparator; -this.suffix = from.suffix; -this.errormessage = from.errormessage; -this.error = false; -this.type = from.type; -this.dataIn = from.dataIn; -if (this.dataIn != null) { -this.mark (); -}this.dataName = from.dataName; -}, "jalview.io.FileParse"); -Clazz.defineMethod (c$, "tryAsGzipSource", -($fz = function (inputStream) { -var inData = new java.io.BufferedReader ( new java.io.InputStreamReader ( new java.util.zip.GZIPInputStream (inputStream))); -inData.mark (2048); -inData.read (); -inData.reset (); -return inData; -}, $fz.isPrivate = true, $fz), "java.io.InputStream"); -Clazz.defineMethod (c$, "checkURLSource", -($fz = function (fileStr) { -this.errormessage = "URL NOT FOUND"; -var url = new java.net.URL (fileStr); -var e = null; -if (fileStr.toLowerCase ().endsWith (".gz")) { -try { -var inputStream = url.openStream (); -this.dataIn = this.tryAsGzipSource (inputStream); -this.dataName = fileStr; -return false; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -e = ex; -} else { -throw ex; -} -} -}try { -this.dataIn = new java.io.BufferedReader ( new java.io.InputStreamReader (url.openStream ())); -} catch (q) { -if (Clazz.exceptionOf (q, java.io.IOException)) { -if (e != null) { -throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.failed_to_resolve_gzip_stream"), e); -}throw q; -} else { -throw q; -} -} -this.dataName = fileStr; -return false; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "extractSuffix", -($fz = function (fileStr) { -var sfpos = fileStr.lastIndexOf (this.suffixSeparator); -if (sfpos > -1 && sfpos < fileStr.length - 1) { -this.suffix = fileStr.substring (sfpos + 1); -return fileStr.substring (0, sfpos); -}return null; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.makeConstructor (c$, -function (fileStr, type) { -this.type = type; -this.error = false; -if (type.equals (jalview.io.AppletFormatAdapter.FILE)) { -{ -}} else if (type.equals (jalview.io.AppletFormatAdapter.URL)) { -try { -try { -this.checkURLSource (fileStr); -if (this.suffixSeparator == '#') { -this.extractSuffix (fileStr); -}} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -var suffixLess = this.extractSuffix (fileStr); -if (suffixLess == null) { -throw (e); -} else { -try { -this.checkURLSource (suffixLess); -} catch (e2) { -if (Clazz.exceptionOf (e2, java.io.IOException)) { -this.errormessage = "BAD URL WITH OR WITHOUT SUFFIX"; -throw (e); -} else { -throw e2; -} -} -}} else { -throw e; -} -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -this.errormessage = "CANNOT ACCESS DATA AT URL '" + fileStr + "' (" + e.getMessage () + ")"; -this.error = true; -} else { -throw e; -} -} -} else if (type.equals (jalview.io.AppletFormatAdapter.PASTE)) { -this.errormessage = "PASTE INACCESSIBLE!"; -this.dataIn = new java.io.BufferedReader ( new java.io.StringReader (fileStr)); -this.dataName = "Paste"; -} else if (type.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) { -this.errormessage = "RESOURCE CANNOT BE LOCATED"; -var is = this.getClass ().getResourceAsStream ("/" + fileStr); -if (is == null) { -var suffixLess = this.extractSuffix (fileStr); -if (suffixLess != null) { -is = this.getClass ().getResourceAsStream ("/" + suffixLess); -}}if (is != null) { -this.dataIn = new java.io.BufferedReader ( new java.io.InputStreamReader (is)); -this.dataName = fileStr; -} else { -this.error = true; -}} else { -this.errormessage = "PROBABLE IMPLEMENTATION ERROR : Datasource Type given as '" + (type != null ? type : "null") + "'"; -this.error = true; -}if (this.dataIn == null || this.error) { -throw new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.failed_to_read_data_from_source", Clazz.newArray (-1, [this.errormessage]))); -}this.error = false; -this.dataIn.mark (2048); -}, "~S,~S"); -Clazz.defineMethod (c$, "mark", -function () { -if (this.dataIn != null) { -this.dataIn.mark (2048); -} else { -throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.no_init_source_stream")); -}}); -Clazz.defineMethod (c$, "nextLine", -function () { -if (!this.error) { -return this.dataIn.readLine (); -}throw new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.invalid_source_stream", Clazz.newArray (-1, [this.errormessage]))); -}); -Clazz.defineMethod (c$, "isExporting", -function () { -return !this.error && this.dataIn == null; -}); -Clazz.defineMethod (c$, "isValid", -function () { -return !this.error; -}); -Clazz.defineMethod (c$, "close", -function () { -this.errormessage = "EXCEPTION ON CLOSE"; -this.error = true; -this.dataIn.close (); -this.dataIn = null; -this.errormessage = "SOURCE IS CLOSED"; -}); -Clazz.defineMethod (c$, "reset", -function () { -if (this.dataIn != null && !this.error) { -this.dataIn.reset (); -} else { -throw new java.io.IOException (jalview.util.MessageManager.getString ("error.implementation_error_reset_called_for_invalid_source")); -}}); -Clazz.defineMethod (c$, "hasWarningMessage", -function () { -return (this.warningMessage != null && this.warningMessage.length > 0); -}); -Clazz.defineMethod (c$, "getWarningMessage", -function () { -return this.warningMessage; -}); -Clazz.defineMethod (c$, "getInFile", -function () { -if (this.inFile != null) { -return this.inFile.getAbsolutePath () + " (" + this.index + ")"; -} else { -return "From Paste + (" + this.index + ")"; -}}); -Clazz.defineMethod (c$, "getDataName", -function () { -return this.dataName; -}); -Clazz.defineMethod (c$, "setDataName", -function (dataname) { -this.dataName = dataname; -}, "~S"); -Clazz.defineMethod (c$, "getReader", -function () { -if (this.dataIn != null) { -return this.dataIn; -}return null; -}); -Clazz.defineMethod (c$, "getViewport", -function () { -return this.viewport; -}); -Clazz.defineMethod (c$, "setViewport", -function (viewport) { -this.viewport = viewport; -}, "jalview.api.AlignViewportI"); -Clazz.defineMethod (c$, "getExportSettings", -function () { -return this.exportSettings; -}); -Clazz.defineMethod (c$, "setExportSettings", -function (exportSettings) { -this.exportSettings = exportSettings; -}, "jalview.api.AlignExportSettingI"); -Clazz.defineMethod (c$, "configureForView", -function (avpanel) { -if (avpanel != null) { -this.setViewport (avpanel.getAlignViewport ()); -}}, "jalview.api.AlignmentViewPanel"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.FileParse", ["jalview.io.AppletFormatAdapter", "jalview.util.MessageManager", "java.io.BufferedReader", "$.IOException", "$.InputStreamReader", "$.StringReader", "java.lang.Error", "java.net.URL", "java.util.zip.GZIPInputStream"], function () { +c$ = Clazz.decorateAsClass (function () { +this.dataName = "unknown source"; +this.inFile = null; +this.viewport = null; +this.exportSettings = null; +this.index = 1; +this.suffixSeparator = '#'; +this.newline = null; +this.suffix = null; +this.type = null; +this.dataIn = null; +this.errormessage = "UNITIALISED SOURCE"; +this.error = true; +this.warningMessage = null; +this.READAHEAD_LIMIT = 2048; +Clazz.instantialize (this, arguments); +}, jalview.io, "FileParse"); +Clazz.prepareFields (c$, function () { +this.newline = System.getProperty ("line.separator"); +}); +Clazz.defineMethod (c$, "setNewlineString", +function (nl) { +this.newline = nl; +}, "~S"); +Clazz.defineMethod (c$, "getNewlineString", +function () { +return this.newline; +}); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.makeConstructor (c$, +function (from) { +if (from == null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_null_fileparse")); +}if (from === this) { +return; +}this.index = ++from.index; +this.inFile = from.inFile; +this.suffixSeparator = from.suffixSeparator; +this.suffix = from.suffix; +this.errormessage = from.errormessage; +this.error = false; +this.type = from.type; +this.dataIn = from.dataIn; +if (this.dataIn != null) { +this.mark (); +}this.dataName = from.dataName; +}, "jalview.io.FileParse"); +Clazz.defineMethod (c$, "tryAsGzipSource", +($fz = function (inputStream) { +var inData = new java.io.BufferedReader ( new java.io.InputStreamReader ( new java.util.zip.GZIPInputStream (inputStream))); +inData.mark (2048); +inData.read (); +inData.reset (); +return inData; +}, $fz.isPrivate = true, $fz), "java.io.InputStream"); +Clazz.defineMethod (c$, "checkURLSource", +($fz = function (fileStr) { +this.errormessage = "URL NOT FOUND"; +var url = new java.net.URL (fileStr); +var e = null; +if (fileStr.toLowerCase ().endsWith (".gz")) { +try { +var inputStream = url.openStream (); +this.dataIn = this.tryAsGzipSource (inputStream); +this.dataName = fileStr; +return false; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +e = ex; +} else { +throw ex; +} +} +}try { +this.dataIn = new java.io.BufferedReader ( new java.io.InputStreamReader (url.openStream ())); +} catch (q) { +if (Clazz.exceptionOf (q, java.io.IOException)) { +if (e != null) { +throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.failed_to_resolve_gzip_stream"), e); +}throw q; +} else { +throw q; +} +} +this.dataName = fileStr; +return false; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "extractSuffix", +($fz = function (fileStr) { +var sfpos = fileStr.lastIndexOf (this.suffixSeparator); +if (sfpos > -1 && sfpos < fileStr.length - 1) { +this.suffix = fileStr.substring (sfpos + 1); +return fileStr.substring (0, sfpos); +}return null; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.makeConstructor (c$, +function (fileStr, type) { +this.type = type; +this.error = false; +if (type.equals (jalview.io.AppletFormatAdapter.FILE)) { +{ +}} else if (type.equals (jalview.io.AppletFormatAdapter.URL)) { +try { +try { +this.checkURLSource (fileStr); +if (this.suffixSeparator == '#') { +this.extractSuffix (fileStr); +}} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +var suffixLess = this.extractSuffix (fileStr); +if (suffixLess == null) { +throw (e); +} else { +try { +this.checkURLSource (suffixLess); +} catch (e2) { +if (Clazz.exceptionOf (e2, java.io.IOException)) { +this.errormessage = "BAD URL WITH OR WITHOUT SUFFIX"; +throw (e); +} else { +throw e2; +} +} +}} else { +throw e; +} +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +this.errormessage = "CANNOT ACCESS DATA AT URL '" + fileStr + "' (" + e.getMessage () + ")"; +this.error = true; +} else { +throw e; +} +} +} else if (type.equals (jalview.io.AppletFormatAdapter.PASTE)) { +this.errormessage = "PASTE INACCESSIBLE!"; +this.dataIn = new java.io.BufferedReader ( new java.io.StringReader (fileStr)); +this.dataName = "Paste"; +} else if (type.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) { +this.errormessage = "RESOURCE CANNOT BE LOCATED"; +var is = this.getClass ().getResourceAsStream ("/" + fileStr); +if (is == null) { +var suffixLess = this.extractSuffix (fileStr); +if (suffixLess != null) { +is = this.getClass ().getResourceAsStream ("/" + suffixLess); +}}if (is != null) { +this.dataIn = new java.io.BufferedReader ( new java.io.InputStreamReader (is)); +this.dataName = fileStr; +} else { +this.error = true; +}} else { +this.errormessage = "PROBABLE IMPLEMENTATION ERROR : Datasource Type given as '" + (type != null ? type : "null") + "'"; +this.error = true; +}if (this.dataIn == null || this.error) { +throw new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.failed_to_read_data_from_source", Clazz.newArray (-1, [this.errormessage]))); +}this.error = false; +this.dataIn.mark (2048); +}, "~S,~S"); +Clazz.defineMethod (c$, "mark", +function () { +if (this.dataIn != null) { +this.dataIn.mark (2048); +} else { +throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.no_init_source_stream")); +}}); +Clazz.defineMethod (c$, "nextLine", +function () { +if (!this.error) { +return this.dataIn.readLine (); +}throw new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.invalid_source_stream", Clazz.newArray (-1, [this.errormessage]))); +}); +Clazz.defineMethod (c$, "isExporting", +function () { +return !this.error && this.dataIn == null; +}); +Clazz.defineMethod (c$, "isValid", +function () { +return !this.error; +}); +Clazz.defineMethod (c$, "close", +function () { +this.errormessage = "EXCEPTION ON CLOSE"; +this.error = true; +this.dataIn.close (); +this.dataIn = null; +this.errormessage = "SOURCE IS CLOSED"; +}); +Clazz.defineMethod (c$, "reset", +function () { +if (this.dataIn != null && !this.error) { +this.dataIn.reset (); +} else { +throw new java.io.IOException (jalview.util.MessageManager.getString ("error.implementation_error_reset_called_for_invalid_source")); +}}); +Clazz.defineMethod (c$, "hasWarningMessage", +function () { +return (this.warningMessage != null && this.warningMessage.length > 0); +}); +Clazz.defineMethod (c$, "getWarningMessage", +function () { +return this.warningMessage; +}); +Clazz.defineMethod (c$, "getInFile", +function () { +if (this.inFile != null) { +return this.inFile.getAbsolutePath () + " (" + this.index + ")"; +} else { +return "From Paste + (" + this.index + ")"; +}}); +Clazz.defineMethod (c$, "getDataName", +function () { +return this.dataName; +}); +Clazz.defineMethod (c$, "setDataName", +function (dataname) { +this.dataName = dataname; +}, "~S"); +Clazz.defineMethod (c$, "getReader", +function () { +if (this.dataIn != null) { +return this.dataIn; +}return null; +}); +Clazz.defineMethod (c$, "getViewport", +function () { +return this.viewport; +}); +Clazz.defineMethod (c$, "setViewport", +function (viewport) { +this.viewport = viewport; +}, "jalview.api.AlignViewportI"); +Clazz.defineMethod (c$, "getExportSettings", +function () { +return this.exportSettings; +}); +Clazz.defineMethod (c$, "setExportSettings", +function (exportSettings) { +this.exportSettings = exportSettings; +}, "jalview.api.AlignExportSettingI"); +Clazz.defineMethod (c$, "configureForView", +function (avpanel) { +if (avpanel != null) { +this.setViewport (avpanel.getAlignViewport ()); +}}, "jalview.api.AlignmentViewPanel"); +}); diff --git a/bin/jalview/io/IdentifyFile.js b/bin/jalview/io/IdentifyFile.js index cf35241..4d88cdd 100644 --- a/bin/jalview/io/IdentifyFile.js +++ b/bin/jalview/io/IdentifyFile.js @@ -1,157 +1,157 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.IdentifyFile", ["jalview.io.FileParse"], function () { -c$ = Clazz.declareType (jalview.io, "IdentifyFile"); -Clazz.defineMethod (c$, "Identify", -function (file, protocol) { -var emessage = "UNIDENTIFIED FILE PARSING ERROR"; -var parser = null; -try { -parser = new jalview.io.FileParse (file, protocol); -if (parser.isValid ()) { -return this.Identify (parser); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Error whilst identifying"); -e.printStackTrace (System.err); -emessage = e.getMessage (); -} else { -throw e; -} -} -if (parser != null) { -return parser.errormessage; -}return emessage; -}, "~S,~S"); -Clazz.defineMethod (c$, "Identify", -function (source) { -return this.Identify (source, true); -}, "jalview.io.FileParse"); -Clazz.defineMethod (c$, "Identify", -function (source, closeSource) { -var reply = "PFAM"; -var data; -var length = 0; -var lineswereskipped = false; -var isBinary = false; -try { -if (!closeSource) { -source.mark (); -}while ((data = source.nextLine ()) != null) { -length += data.trim ().length; -if (!lineswereskipped) { -for (var i = 0; !isBinary && i < data.length; i++) { -var c = data.charAt (i); -isBinary = (c.charCodeAt (0) < 32 && c != '\t' && c != '\n' && c != '\r' && c.charCodeAt (0) != 5 && c.charCodeAt (0) != 27); -} -}if (isBinary) { -if (source.inFile != null) { -var fileStr = source.inFile.getName (); -if (fileStr.lastIndexOf (".jar") > -1 || fileStr.lastIndexOf (".zip") > -1) { -reply = "Jalview"; -}}if (!lineswereskipped && data.startsWith ("PK")) { -reply = "Jalview"; -break; -}}data = data.toUpperCase (); -if (data.startsWith ("##GFF-VERSION")) { -reply = "GFF v2 or v3"; -break; -}if (data.indexOf ("# STOCKHOLM") > -1) { -reply = "STH"; -break; -}if (data.matches ("])*>")) { -reply = "HTML"; -break; -}if (data.matches ("])*>")) { -reply = "RNAML"; -break; -}if (data.indexOf ("{\"") > -1) { -reply = "JSON"; -break; -}if ((data.length < 1) || (data.indexOf ("#") == 0)) { -lineswereskipped = true; -continue; -}if (data.indexOf ("PILEUP") > -1) { -reply = "PileUp"; -break; -}if ((data.indexOf ("//") == 0) || ((data.indexOf ("!!") > -1) && (data.indexOf ("!!") < data.indexOf ("_MULTIPLE_ALIGNMENT ")))) { -reply = "MSF"; -break; -} else if (data.indexOf ("CLUSTAL") > -1) { -reply = "CLUSTAL"; -break; -} else if (data.indexOf (">") > -1) { -var checkPIR = false; -var starterm = false; -if ((data.indexOf (">P1;") > -1) || (data.indexOf (">DL;") > -1)) { -checkPIR = true; -reply = "PIR"; -}data = source.nextLine (); -if (data.indexOf (">") > -1) { -reply = "BLC"; -} else { -var data1 = source.nextLine (); -var data2 = source.nextLine (); -var c1; -if (checkPIR) { -starterm = (data1 != null && data1.indexOf ("*") > -1) || (data2 != null && data2.indexOf ("*") > -1); -}if (data2 != null && (c1 = data.indexOf ("*")) > -1) { -if (c1 == 0 && c1 == data2.indexOf ("*")) { -reply = "BLC"; -} else { -reply = "FASTA"; -}} else { -reply = "FASTA"; -if (!checkPIR) { -break; -}}}if (checkPIR) { -var dta = null; -if (!starterm) { -do { -try { -dta = source.nextLine (); -} catch (ex) { -if (Clazz.exceptionOf (ex, java.io.IOException)) { -} else { -throw ex; -} -} -;if (dta != null && dta.indexOf ("*") > -1) { -starterm = true; -}} while (dta != null && !starterm); -}if (starterm) { -reply = "PIR"; -break; -} else { -reply = "FASTA"; -}}break; -} else if (data.indexOf ("HEADER") == 0 || data.indexOf ("ATOM") == 0) { -reply = "PDB"; -break; -} else if (data.matches ("\\s*\\d+\\s+\\d+\\s*")) { -reply = "PHYLIP"; -break; -} else if (!lineswereskipped && data.charAt (0) != '*' && data.charAt (0) != ' ' && data.indexOf (":") < data.indexOf (",")) { -reply = "JnetFile"; -break; -}lineswereskipped = true; -} -if (closeSource) { -source.close (); -} else { -source.reset (); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("File Identification failed!\n" + ex); -return source.errormessage; -} else { -throw ex; -} -} -if (length == 0) { -System.err.println ("File Identification failed! - Empty file was read."); -return "EMPTY DATA FILE"; -}return reply; -}, "jalview.io.FileParse,~B"); -Clazz.defineStatics (c$, -"GFF3File", "GFF v2 or v3"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.IdentifyFile", ["jalview.io.FileParse"], function () { +c$ = Clazz.declareType (jalview.io, "IdentifyFile"); +Clazz.defineMethod (c$, "Identify", +function (file, protocol) { +var emessage = "UNIDENTIFIED FILE PARSING ERROR"; +var parser = null; +try { +parser = new jalview.io.FileParse (file, protocol); +if (parser.isValid ()) { +return this.Identify (parser); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Error whilst identifying"); +e.printStackTrace (System.err); +emessage = e.getMessage (); +} else { +throw e; +} +} +if (parser != null) { +return parser.errormessage; +}return emessage; +}, "~S,~S"); +Clazz.defineMethod (c$, "Identify", +function (source) { +return this.Identify (source, true); +}, "jalview.io.FileParse"); +Clazz.defineMethod (c$, "Identify", +function (source, closeSource) { +var reply = "PFAM"; +var data; +var length = 0; +var lineswereskipped = false; +var isBinary = false; +try { +if (!closeSource) { +source.mark (); +}while ((data = source.nextLine ()) != null) { +length += data.trim ().length; +if (!lineswereskipped) { +for (var i = 0; !isBinary && i < data.length; i++) { +var c = data.charAt (i); +isBinary = (c.charCodeAt (0) < 32 && c != '\t' && c != '\n' && c != '\r' && c.charCodeAt (0) != 5 && c.charCodeAt (0) != 27); +} +}if (isBinary) { +if (source.inFile != null) { +var fileStr = source.inFile.getName (); +if (fileStr.lastIndexOf (".jar") > -1 || fileStr.lastIndexOf (".zip") > -1) { +reply = "Jalview"; +}}if (!lineswereskipped && data.startsWith ("PK")) { +reply = "Jalview"; +break; +}}data = data.toUpperCase (); +if (data.startsWith ("##GFF-VERSION")) { +reply = "GFF v2 or v3"; +break; +}if (data.indexOf ("# STOCKHOLM") > -1) { +reply = "STH"; +break; +}if (data.matches ("])*>")) { +reply = "HTML"; +break; +}if (data.matches ("])*>")) { +reply = "RNAML"; +break; +}if (data.indexOf ("{\"") > -1) { +reply = "JSON"; +break; +}if ((data.length < 1) || (data.indexOf ("#") == 0)) { +lineswereskipped = true; +continue; +}if (data.indexOf ("PILEUP") > -1) { +reply = "PileUp"; +break; +}if ((data.indexOf ("//") == 0) || ((data.indexOf ("!!") > -1) && (data.indexOf ("!!") < data.indexOf ("_MULTIPLE_ALIGNMENT ")))) { +reply = "MSF"; +break; +} else if (data.indexOf ("CLUSTAL") > -1) { +reply = "CLUSTAL"; +break; +} else if (data.indexOf (">") > -1) { +var checkPIR = false; +var starterm = false; +if ((data.indexOf (">P1;") > -1) || (data.indexOf (">DL;") > -1)) { +checkPIR = true; +reply = "PIR"; +}data = source.nextLine (); +if (data.indexOf (">") > -1) { +reply = "BLC"; +} else { +var data1 = source.nextLine (); +var data2 = source.nextLine (); +var c1; +if (checkPIR) { +starterm = (data1 != null && data1.indexOf ("*") > -1) || (data2 != null && data2.indexOf ("*") > -1); +}if (data2 != null && (c1 = data.indexOf ("*")) > -1) { +if (c1 == 0 && c1 == data2.indexOf ("*")) { +reply = "BLC"; +} else { +reply = "FASTA"; +}} else { +reply = "FASTA"; +if (!checkPIR) { +break; +}}}if (checkPIR) { +var dta = null; +if (!starterm) { +do { +try { +dta = source.nextLine (); +} catch (ex) { +if (Clazz.exceptionOf (ex, java.io.IOException)) { +} else { +throw ex; +} +} +;if (dta != null && dta.indexOf ("*") > -1) { +starterm = true; +}} while (dta != null && !starterm); +}if (starterm) { +reply = "PIR"; +break; +} else { +reply = "FASTA"; +}}break; +} else if (data.indexOf ("HEADER") == 0 || data.indexOf ("ATOM") == 0) { +reply = "PDB"; +break; +} else if (data.matches ("\\s*\\d+\\s+\\d+\\s*")) { +reply = "PHYLIP"; +break; +} else if (!lineswereskipped && data.charAt (0) != '*' && data.charAt (0) != ' ' && data.indexOf (":") < data.indexOf (",")) { +reply = "JnetFile"; +break; +}lineswereskipped = true; +} +if (closeSource) { +source.close (); +} else { +source.reset (); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("File Identification failed!\n" + ex); +return source.errormessage; +} else { +throw ex; +} +} +if (length == 0) { +System.err.println ("File Identification failed! - Empty file was read."); +return "EMPTY DATA FILE"; +}return reply; +}, "jalview.io.FileParse,~B"); +Clazz.defineStatics (c$, +"GFF3File", "GFF v2 or v3"); +}); diff --git a/bin/jalview/io/JPredFile.js b/bin/jalview/io/JPredFile.js index 1975edb..9dc5044 100644 --- a/bin/jalview/io/JPredFile.js +++ b/bin/jalview/io/JPredFile.js @@ -1,185 +1,185 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile"], "jalview.io.JPredFile", ["jalview.datamodel.Alignment", "$.Sequence", "jalview.io.JnetAnnotationMaker", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Float", "$.StringBuffer", "java.util.Hashtable", "$.StringTokenizer", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ids = null; -this.conf = null; -this.Scores = null; -this.Symscores = null; -this.QuerySeqPosition = 0; -this.annotSeqs = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "JPredFile", jalview.io.AlignFile); -Clazz.defineMethod (c$, "setQuerySeqPosition", -function (QuerySeqPosition) { -this.QuerySeqPosition = QuerySeqPosition; -}, "~N"); -Clazz.defineMethod (c$, "getQuerySeqPosition", -function () { -return this.QuerySeqPosition; -}); -Clazz.defineMethod (c$, "getScores", -function () { -return this.Scores; -}); -Clazz.defineMethod (c$, "getSymscores", -function () { -return this.Symscores; -}); -Clazz.defineMethod (c$, "initData", -function () { -Clazz.superCall (this, jalview.io.JPredFile, "initData", []); -this.Scores = new java.util.Hashtable (); -this.ids = null; -this.conf = null; -}); -Clazz.overrideMethod (c$, "parse", -function () { -var line; -this.QuerySeqPosition = -1; -this.noSeqs = 0; -var seq_entries = new java.util.Vector (); -var ids = new java.util.Vector (); -var Symscores = new java.util.Hashtable (); -while ((line = this.nextLine ()) != null) { -var str = new java.util.StringTokenizer (line, ":"); -var id = ""; -if (!str.hasMoreTokens ()) { -continue; -}id = str.nextToken (); -var seqsym = str.nextToken (); -var symbols = new java.util.StringTokenizer (seqsym, ","); -var numSymbols = symbols.countTokens (); -if (numSymbols == 0) { -continue; -}if (seqsym.length != (2 * numSymbols)) { -if (this.Scores.containsKey (id)) { -var i = 1; -while (this.Scores.containsKey (id + "_" + i)) { -i++; -} -id = id + "_" + i; -}var scores = new java.util.Vector (); -var i = 0; -var ascore = "dead"; -try { -while (symbols.hasMoreTokens ()) { -ascore = symbols.nextToken (); -var score = new Float (ascore); -scores.addElement (score); -} -this.Scores.put (id, scores); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -i = scores.size (); -for (var j = 0; j < i; j++) { -scores.setElementAt ((scores.elementAt (j)).toString (), j); -} -scores.addElement (ascore); -while (symbols.hasMoreTokens ()) { -ascore = symbols.nextToken (); -scores.addElement (ascore); -} -this.Scores.put (id, scores); -} else { -throw e; -} -} -} else if (id.equals ("jnetconf")) { -id = "Prediction Confidence"; -this.conf = new java.util.Vector (numSymbols); -for (var i = 0; i < numSymbols; i++) { -this.conf.setElementAt (symbols.nextToken (), i); -} -} else { -var newseq = new StringBuffer (); -for (var i = 0; i < numSymbols; i++) { -newseq.append (symbols.nextToken ()); -} -if (id.indexOf (";") > -1) { -seq_entries.addElement (newseq); -var i = 1; -var name = id.substring (id.indexOf (";") + 1); -while (ids.lastIndexOf (name) > -1) { -name = id.substring (id.indexOf (";") + 1) + "_" + ++i; -} -if (this.QuerySeqPosition == -1) this.QuerySeqPosition = ids.size (); -ids.addElement (name); -this.noSeqs++; -} else { -if (id.equals ("JNETPRED")) { -id = "Predicted Secondary Structure"; -}seq_entries.addElement (newseq.toString ()); -ids.addElement (id); -Symscores.put (id, new Integer (ids.size () - 1)); -}}} -this.maxLength = seq_entries.elementAt (0).toString ().length; -for (var i = 0; i < ids.size (); i++) { -var newSeq = new jalview.datamodel.Sequence (ids.elementAt (i).toString (), seq_entries.elementAt (i).toString (), 1, seq_entries.elementAt (i).toString ().length); -if (this.maxLength != seq_entries.elementAt (i).toString ().length) { -throw new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.jpredconcide_entry_has_unexpected_number_of_columns", Clazz.newArray (-1, [ids.elementAt (i).toString ()]))); -}if ((newSeq.getName ().startsWith ("QUERY") || newSeq.getName ().startsWith ("align;")) && (this.QuerySeqPosition == -1)) { -this.QuerySeqPosition = this.seqs.size (); -}this.seqs.addElement (newSeq); -} -if (this.seqs.size () > 0 && this.QuerySeqPosition > -1) { -var tal = new jalview.datamodel.Alignment (this.getSeqsAsArray ()); -try { -jalview.io.JnetAnnotationMaker.add_annotation (this, tal, this.QuerySeqPosition, true); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -tal = null; -var ex = new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.couldnt_parse_concise_annotation_for_prediction", Clazz.newArray (-1, [e.getMessage ()]))); -e.printStackTrace (); -throw ex; -} else { -throw e; -} -} -this.annotations = new java.util.Vector (); -var aan = tal.getAlignmentAnnotation (); -for (var aai = 0; aan != null && aai < aan.length; aai++) { -this.annotations.addElement (aan[aai]); -} -}}); -Clazz.overrideMethod (c$, "print", -function () { -return "Not Supported"; -}); -c$.main = Clazz.defineMethod (c$, "main", -function (args) { -try { -var blc = new jalview.io.JPredFile (args[0], "File"); -for (var i = 0; i < blc.seqs.size (); i++) { -System.out.println ((blc.seqs.elementAt (i)).getName () + "\n" + (blc.seqs.elementAt (i)).getSequenceAsString () + "\n"); -} -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -System.err.println ("Exception " + e); -} else { -throw e; -} -} -}, "~A"); -Clazz.defineMethod (c$, "removeNonSequences", -function () { -if (this.annotSeqs != null) { -return; -}this.annotSeqs = new java.util.Vector (); -var newseqs = new java.util.Vector (); -var i = 0; -var j = this.seqs.size (); -for (; i < this.QuerySeqPosition; i++) { -this.annotSeqs.addElement (this.seqs.elementAt (i)); -} -{ -var sq = this.seqs.elementAt (j - 1); -if (sq.getName ().toUpperCase ().startsWith ("JPRED")) { -this.annotSeqs.addElement (sq); -this.seqs.removeElementAt (--j); -}}for (; i < j; i++) { -newseqs.addElement (this.seqs.elementAt (i)); -} -this.seqs.removeAllElements (); -this.seqs = newseqs; -}); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile"], "jalview.io.JPredFile", ["jalview.datamodel.Alignment", "$.Sequence", "jalview.io.JnetAnnotationMaker", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Float", "$.StringBuffer", "java.util.Hashtable", "$.StringTokenizer", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ids = null; +this.conf = null; +this.Scores = null; +this.Symscores = null; +this.QuerySeqPosition = 0; +this.annotSeqs = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "JPredFile", jalview.io.AlignFile); +Clazz.defineMethod (c$, "setQuerySeqPosition", +function (QuerySeqPosition) { +this.QuerySeqPosition = QuerySeqPosition; +}, "~N"); +Clazz.defineMethod (c$, "getQuerySeqPosition", +function () { +return this.QuerySeqPosition; +}); +Clazz.defineMethod (c$, "getScores", +function () { +return this.Scores; +}); +Clazz.defineMethod (c$, "getSymscores", +function () { +return this.Symscores; +}); +Clazz.defineMethod (c$, "initData", +function () { +Clazz.superCall (this, jalview.io.JPredFile, "initData", []); +this.Scores = new java.util.Hashtable (); +this.ids = null; +this.conf = null; +}); +Clazz.overrideMethod (c$, "parse", +function () { +var line; +this.QuerySeqPosition = -1; +this.noSeqs = 0; +var seq_entries = new java.util.Vector (); +var ids = new java.util.Vector (); +var Symscores = new java.util.Hashtable (); +while ((line = this.nextLine ()) != null) { +var str = new java.util.StringTokenizer (line, ":"); +var id = ""; +if (!str.hasMoreTokens ()) { +continue; +}id = str.nextToken (); +var seqsym = str.nextToken (); +var symbols = new java.util.StringTokenizer (seqsym, ","); +var numSymbols = symbols.countTokens (); +if (numSymbols == 0) { +continue; +}if (seqsym.length != (2 * numSymbols)) { +if (this.Scores.containsKey (id)) { +var i = 1; +while (this.Scores.containsKey (id + "_" + i)) { +i++; +} +id = id + "_" + i; +}var scores = new java.util.Vector (); +var i = 0; +var ascore = "dead"; +try { +while (symbols.hasMoreTokens ()) { +ascore = symbols.nextToken (); +var score = new Float (ascore); +scores.addElement (score); +} +this.Scores.put (id, scores); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +i = scores.size (); +for (var j = 0; j < i; j++) { +scores.setElementAt ((scores.elementAt (j)).toString (), j); +} +scores.addElement (ascore); +while (symbols.hasMoreTokens ()) { +ascore = symbols.nextToken (); +scores.addElement (ascore); +} +this.Scores.put (id, scores); +} else { +throw e; +} +} +} else if (id.equals ("jnetconf")) { +id = "Prediction Confidence"; +this.conf = new java.util.Vector (numSymbols); +for (var i = 0; i < numSymbols; i++) { +this.conf.setElementAt (symbols.nextToken (), i); +} +} else { +var newseq = new StringBuffer (); +for (var i = 0; i < numSymbols; i++) { +newseq.append (symbols.nextToken ()); +} +if (id.indexOf (";") > -1) { +seq_entries.addElement (newseq); +var i = 1; +var name = id.substring (id.indexOf (";") + 1); +while (ids.lastIndexOf (name) > -1) { +name = id.substring (id.indexOf (";") + 1) + "_" + ++i; +} +if (this.QuerySeqPosition == -1) this.QuerySeqPosition = ids.size (); +ids.addElement (name); +this.noSeqs++; +} else { +if (id.equals ("JNETPRED")) { +id = "Predicted Secondary Structure"; +}seq_entries.addElement (newseq.toString ()); +ids.addElement (id); +Symscores.put (id, new Integer (ids.size () - 1)); +}}} +this.maxLength = seq_entries.elementAt (0).toString ().length; +for (var i = 0; i < ids.size (); i++) { +var newSeq = new jalview.datamodel.Sequence (ids.elementAt (i).toString (), seq_entries.elementAt (i).toString (), 1, seq_entries.elementAt (i).toString ().length); +if (this.maxLength != seq_entries.elementAt (i).toString ().length) { +throw new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.jpredconcide_entry_has_unexpected_number_of_columns", Clazz.newArray (-1, [ids.elementAt (i).toString ()]))); +}if ((newSeq.getName ().startsWith ("QUERY") || newSeq.getName ().startsWith ("align;")) && (this.QuerySeqPosition == -1)) { +this.QuerySeqPosition = this.seqs.size (); +}this.seqs.addElement (newSeq); +} +if (this.seqs.size () > 0 && this.QuerySeqPosition > -1) { +var tal = new jalview.datamodel.Alignment (this.getSeqsAsArray ()); +try { +jalview.io.JnetAnnotationMaker.add_annotation (this, tal, this.QuerySeqPosition, true); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +tal = null; +var ex = new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.couldnt_parse_concise_annotation_for_prediction", Clazz.newArray (-1, [e.getMessage ()]))); +e.printStackTrace (); +throw ex; +} else { +throw e; +} +} +this.annotations = new java.util.Vector (); +var aan = tal.getAlignmentAnnotation (); +for (var aai = 0; aan != null && aai < aan.length; aai++) { +this.annotations.addElement (aan[aai]); +} +}}); +Clazz.overrideMethod (c$, "print", +function () { +return "Not Supported"; +}); +c$.main = Clazz.defineMethod (c$, "main", +function (args) { +try { +var blc = new jalview.io.JPredFile (args[0], "File"); +for (var i = 0; i < blc.seqs.size (); i++) { +System.out.println ((blc.seqs.elementAt (i)).getName () + "\n" + (blc.seqs.elementAt (i)).getSequenceAsString () + "\n"); +} +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +System.err.println ("Exception " + e); +} else { +throw e; +} +} +}, "~A"); +Clazz.defineMethod (c$, "removeNonSequences", +function () { +if (this.annotSeqs != null) { +return; +}this.annotSeqs = new java.util.Vector (); +var newseqs = new java.util.Vector (); +var i = 0; +var j = this.seqs.size (); +for (; i < this.QuerySeqPosition; i++) { +this.annotSeqs.addElement (this.seqs.elementAt (i)); +} +{ +var sq = this.seqs.elementAt (j - 1); +if (sq.getName ().toUpperCase ().startsWith ("JPRED")) { +this.annotSeqs.addElement (sq); +this.seqs.removeElementAt (--j); +}}for (; i < j; i++) { +newseqs.addElement (this.seqs.elementAt (i)); +} +this.seqs.removeAllElements (); +this.seqs = newseqs; +}); +}); diff --git a/bin/jalview/io/JnetAnnotationMaker.js b/bin/jalview/io/JnetAnnotationMaker.js index e2f51a5..f39d55b 100644 --- a/bin/jalview/io/JnetAnnotationMaker.js +++ b/bin/jalview/io/JnetAnnotationMaker.js @@ -1,90 +1,90 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.JnetAnnotationMaker", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "jalview.util.MessageManager", "java.lang.Exception", "$.Float"], function () { -c$ = Clazz.declareType (jalview.io, "JnetAnnotationMaker"); -c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", -function (prediction, al, firstSeq, noMsa) { -jalview.io.JnetAnnotationMaker.add_annotation (prediction, al, firstSeq, noMsa, Clazz.castNullAs ("Array")); -}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B"); -c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", -function (prediction, al, firstSeq, noMsa, delMap) { -var i = 0; -var preds = prediction.getSeqsAsArray (); -var seqRef = al.getSequenceAt (firstSeq); -var width = preds[0].getSequence ().length; -var gapmap = al.getSequenceAt (firstSeq).gapMap (); -if ((delMap != null && delMap.length > width) || (delMap == null && gapmap.length != width)) { -throw ( new Exception (jalview.util.MessageManager.formatMessage ("exception.number_of_residues_in_query_sequence_differ_from_prediction", Clazz.newArray (-1, [(delMap == null ? "" : jalview.util.MessageManager.getString ("label.mapped")), al.getSequenceAt (firstSeq).getName (), al.getSequenceAt (firstSeq).getSequenceAsString (), Integer.$valueOf (width).toString ()])))); -}var annot; -var annotations = null; -var existingAnnotations = 0; -if (al.getAlignmentAnnotation () != null) { -existingAnnotations = al.getAlignmentAnnotation ().length; -}var sol = new Array (al.getWidth ()); -var firstsol = true; -while (i < preds.length) { -var id = preds[i].getName ().toUpperCase (); -if (id.startsWith ("LUPAS") || id.startsWith ("JNET") || id.startsWith ("JPRED")) { -if (id.startsWith ("JNETSOL")) { -var amnt = (id.endsWith ("25") ? 3 : id.endsWith ("5") ? 6 : 9); -for (var spos = 0; spos < width; spos++) { -var sposw = (delMap == null) ? gapmap[spos] : gapmap[delMap[spos]]; -if (firstsol) { -sol[sposw] = new jalview.datamodel.Annotation (0); -}if (preds[i].getCharAt (spos) == 'B' && (sol[sposw].value == 0 || sol[sposw].value < amnt)) { -sol[sposw].value = amnt; -}} -firstsol = false; -} else { -annotations = new Array (al.getWidth ()); -if (id.equals ("JNETPRED") || id.equals ("JNETPSSM") || id.equals ("JNETFREQ") || id.equals ("JNETHMM") || id.equals ("JNETALIGN") || id.equals ("JPRED")) { -if (delMap == null) { -for (var j = 0; j < width; j++) { -annotations[gapmap[j]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); -} -} else { -for (var j = 0; j < width; j++) { -annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); -} -}} else if (id.equals ("JNETCONF")) { -if (delMap == null) { -for (var j = 0; j < width; j++) { -var value = new Float (preds[i].getCharAt (j) + "").floatValue (); -annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); -} -} else { -for (var j = 0; j < width; j++) { -var value = new Float (preds[i].getCharAt (j) + "").floatValue (); -annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); -} -}} else { -if (delMap == null) { -for (var j = 0; j < width; j++) { -annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); -} -} else { -for (var j = 0; j < width; j++) { -annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); -} -}}if (id.equals ("JNETCONF")) { -annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations, 0, 10, 1); -} else { -annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations); -}if (seqRef != null) { -annot.createSequenceMapping (seqRef, 1, true); -seqRef.addAlignmentAnnotation (annot); -}al.addAnnotation (annot); -al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); -}if (noMsa) { -al.deleteSequence (preds[i]); -}}i++; -} -if (!firstsol) { -annot = new jalview.datamodel.AlignmentAnnotation ("Jnet Burial", "Prediction of Solvent Accessibility
levels are
  • 0 - Exposed
  • 3 - 25% or more S.A. accessible
  • 6 - 5% or more S.A. accessible
  • 9 - Buried (<5% exposed)
", sol, 0, 9, 1); -annot.validateRangeAndDisplay (); -if (seqRef != null) { -annot.createSequenceMapping (seqRef, 1, true); -seqRef.addAlignmentAnnotation (annot); -}al.addAnnotation (annot); -al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); -}}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B,~A"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.JnetAnnotationMaker", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "jalview.util.MessageManager", "java.lang.Exception", "$.Float"], function () { +c$ = Clazz.declareType (jalview.io, "JnetAnnotationMaker"); +c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", +function (prediction, al, firstSeq, noMsa) { +jalview.io.JnetAnnotationMaker.add_annotation (prediction, al, firstSeq, noMsa, Clazz.castNullAs ("Array")); +}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B"); +c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", +function (prediction, al, firstSeq, noMsa, delMap) { +var i = 0; +var preds = prediction.getSeqsAsArray (); +var seqRef = al.getSequenceAt (firstSeq); +var width = preds[0].getSequence ().length; +var gapmap = al.getSequenceAt (firstSeq).gapMap (); +if ((delMap != null && delMap.length > width) || (delMap == null && gapmap.length != width)) { +throw ( new Exception (jalview.util.MessageManager.formatMessage ("exception.number_of_residues_in_query_sequence_differ_from_prediction", Clazz.newArray (-1, [(delMap == null ? "" : jalview.util.MessageManager.getString ("label.mapped")), al.getSequenceAt (firstSeq).getName (), al.getSequenceAt (firstSeq).getSequenceAsString (), Integer.$valueOf (width).toString ()])))); +}var annot; +var annotations = null; +var existingAnnotations = 0; +if (al.getAlignmentAnnotation () != null) { +existingAnnotations = al.getAlignmentAnnotation ().length; +}var sol = new Array (al.getWidth ()); +var firstsol = true; +while (i < preds.length) { +var id = preds[i].getName ().toUpperCase (); +if (id.startsWith ("LUPAS") || id.startsWith ("JNET") || id.startsWith ("JPRED")) { +if (id.startsWith ("JNETSOL")) { +var amnt = (id.endsWith ("25") ? 3 : id.endsWith ("5") ? 6 : 9); +for (var spos = 0; spos < width; spos++) { +var sposw = (delMap == null) ? gapmap[spos] : gapmap[delMap[spos]]; +if (firstsol) { +sol[sposw] = new jalview.datamodel.Annotation (0); +}if (preds[i].getCharAt (spos) == 'B' && (sol[sposw].value == 0 || sol[sposw].value < amnt)) { +sol[sposw].value = amnt; +}} +firstsol = false; +} else { +annotations = new Array (al.getWidth ()); +if (id.equals ("JNETPRED") || id.equals ("JNETPSSM") || id.equals ("JNETFREQ") || id.equals ("JNETHMM") || id.equals ("JNETALIGN") || id.equals ("JPRED")) { +if (delMap == null) { +for (var j = 0; j < width; j++) { +annotations[gapmap[j]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); +} +} else { +for (var j = 0; j < width; j++) { +annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); +} +}} else if (id.equals ("JNETCONF")) { +if (delMap == null) { +for (var j = 0; j < width; j++) { +var value = new Float (preds[i].getCharAt (j) + "").floatValue (); +annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); +} +} else { +for (var j = 0; j < width; j++) { +var value = new Float (preds[i].getCharAt (j) + "").floatValue (); +annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); +} +}} else { +if (delMap == null) { +for (var j = 0; j < width; j++) { +annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); +} +} else { +for (var j = 0; j < width; j++) { +annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); +} +}}if (id.equals ("JNETCONF")) { +annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations, 0, 10, 1); +} else { +annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations); +}if (seqRef != null) { +annot.createSequenceMapping (seqRef, 1, true); +seqRef.addAlignmentAnnotation (annot); +}al.addAnnotation (annot); +al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); +}if (noMsa) { +al.deleteSequence (preds[i]); +}}i++; +} +if (!firstsol) { +annot = new jalview.datamodel.AlignmentAnnotation ("Jnet Burial", "Prediction of Solvent Accessibility
levels are
  • 0 - Exposed
  • 3 - 25% or more S.A. accessible
  • 6 - 5% or more S.A. accessible
  • 9 - Buried (<5% exposed)
", sol, 0, 9, 1); +annot.validateRangeAndDisplay (); +if (seqRef != null) { +annot.createSequenceMapping (seqRef, 1, true); +seqRef.addAlignmentAnnotation (annot); +}al.addAnnotation (annot); +al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); +}}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B,~A"); +}); diff --git a/bin/jalview/io/MSFfile.js b/bin/jalview/io/MSFfile.js index ee2e3af..d80fbdc 100644 --- a/bin/jalview/io/MSFfile.js +++ b/bin/jalview/io/MSFfile.js @@ -1,190 +1,190 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile"], "jalview.io.MSFfile", ["jalview.datamodel.Sequence", "jalview.util.Comparison", "$.Format", "java.lang.StringBuffer", "java.util.Hashtable", "$.StringTokenizer", "$.Vector"], function () { -c$ = Clazz.declareType (jalview.io, "MSFfile", jalview.io.AlignFile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.MSFfile, []); -}); -Clazz.overrideMethod (c$, "parse", -function () { -var i = 0; -var seqFlag = false; -var key = String.instantialize (); -var headers = new java.util.Vector (); -var seqhash = new java.util.Hashtable (); -var line; -try { -while ((line = this.nextLine ()) != null) { -var str = new java.util.StringTokenizer (line); -while (str.hasMoreTokens ()) { -var inStr = str.nextToken (); -if (inStr.indexOf ("Name:") != -1) { -key = str.nextToken (); -headers.addElement (key); -}if (inStr.indexOf ("//") != -1) { -seqFlag = true; -}if ((inStr.indexOf ("//") == -1) && (seqFlag == true)) { -key = inStr; -var tempseq; -if (seqhash.containsKey (key)) { -tempseq = seqhash.get (key); -} else { -tempseq = new StringBuffer (); -seqhash.put (key, tempseq); -}while (str.hasMoreTokens ()) { -tempseq.append (str.nextToken ()); -} -}} -} -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -System.err.println ("Exception parsing MSFFile " + e); -e.printStackTrace (); -} else { -throw e; -} -} -this.noSeqs = headers.size (); -for (i = 0; i < headers.size (); i++) { -if (seqhash.get (headers.elementAt (i)) != null) { -var head = headers.elementAt (i).toString (); -var seq = seqhash.get (head).toString (); -if (this.maxLength < head.length) { -this.maxLength = head.length; -}seq = seq.$replace ('~', '-'); -var newSeq = this.parseId (head); -newSeq.setSequence (seq); -this.seqs.addElement (newSeq); -} else { -System.err.println ("MSFFile Parser: Can't find sequence for " + headers.elementAt (i)); -}} -}); -Clazz.defineMethod (c$, "checkSum", -function (seq) { -var check = 0; -var sequence = seq.toUpperCase (); -for (var i = 0; i < sequence.length; i++) { -try { -var value = sequence.charCodeAt (i); -if (value != -1) { -check += (i % 57 + 1) * value; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Exception during MSF Checksum calculation"); -e.printStackTrace (); -} else { -throw e; -} -} -} -return check % 10000; -}, "~S"); -Clazz.defineMethod (c$, "print", -function (seqs) { -var is_NA = jalview.util.Comparison.isNucleotide (seqs); -var s = new Array (seqs.length); -var out = new StringBuffer ("!!" + (is_NA ? "NA" : "AA") + "_MULTIPLE_ALIGNMENT 1.0"); -out.append (this.newline); -out.append (this.newline); -var max = 0; -var maxid = 0; -var i = 0; -while ((i < seqs.length) && (seqs[i] != null)) { -s[i] = new jalview.datamodel.Sequence (seqs[i].getName (), seqs[i].getSequenceAsString ().$replace ('-', '.'), seqs[i].getStart (), seqs[i].getEnd ()); -var sb = new StringBuffer (); -sb.append (s[i].getSequence ()); -for (var ii = 0; ii < sb.length (); ii++) { -if (sb.charAt (ii) == '.') { -sb.setCharAt (ii, '~'); -} else { -break; -}} -for (var ii = sb.length () - 1; ii > 0; ii--) { -if (sb.charAt (ii) == '.') { -sb.setCharAt (ii, '~'); -} else { -break; -}} -s[i].setSequence (sb.toString ()); -if (s[i].getSequence ().length > max) { -max = s[i].getSequence ().length; -}i++; -} -var maxLenpad = new jalview.util.Format ("%" + ( String.instantialize ("" + max)).length + "d"); -var maxChkpad = new jalview.util.Format ("%" + ( String.instantialize ("1" + max)).length + "d"); -i = 0; -var bigChecksum = 0; -var checksums = Clazz.newIntArray (s.length, 0); -while (i < s.length) { -checksums[i] = this.checkSum (s[i].getSequenceAsString ()); -bigChecksum += checksums[i]; -i++; -} -var maxNB = 0; -out.append (" MSF: " + s[0].getSequence ().length + " Type: " + (is_NA ? "N" : "P") + " Check: " + (bigChecksum % 10000) + " .."); -out.append (this.newline); -out.append (this.newline); -out.append (this.newline); -var nameBlock = new Array (s.length); -var idBlock = new Array (s.length); -i = 0; -while ((i < s.length) && (s[i] != null)) { -nameBlock[i] = String.instantialize (" Name: " + this.printId (s[i]) + " "); -idBlock[i] = String.instantialize ("Len: " + maxLenpad.formLong (s[i].getSequence ().length) + " Check: " + maxChkpad.formLong (checksums[i]) + " Weight: 1.00" + this.newline); -if (s[i].getName ().length > maxid) { -maxid = s[i].getName ().length; -}if (nameBlock[i].length > maxNB) { -maxNB = nameBlock[i].length; -}i++; -} -if (maxid < 10) { -maxid = 10; -}if (maxNB < 15) { -maxNB = 15; -}var nbFormat = new jalview.util.Format ("%-" + maxNB + "s"); -for (i = 0; (i < s.length) && (s[i] != null); i++) { -out.append (nbFormat.form (nameBlock[i]) + idBlock[i]); -} -maxid++; -out.append (this.newline); -out.append (this.newline); -out.append ("//"); -out.append (this.newline); -out.append (this.newline); -var len = 50; -var nochunks = (Clazz.doubleToInt (max / len)) + 1; -if ((max % len) == 0) { -nochunks--; -}for (i = 0; i < nochunks; i++) { -var j = 0; -while ((j < s.length) && (s[j] != null)) { -var name = this.printId (s[j]); -out.append ( new jalview.util.Format ("%-" + maxid + "s").form (name + " ")); -for (var k = 0; k < 5; k++) { -var start = (i * 50) + (k * 10); -var end = start + 10; -if ((end < s[j].getSequence ().length) && (start < s[j].getSequence ().length)) { -out.append (s[j].getSequence (start, end)); -if (k < 4) { -out.append (" "); -} else { -out.append (this.newline); -}} else { -if (start < s[j].getSequence ().length) { -out.append (s[j].getSequenceAsString ().substring (start)); -out.append (this.newline); -} else { -if (k == 0) { -out.append (this.newline); -}}}} -j++; -} -out.append (this.newline); -} -return out.toString (); -}, "~A"); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile"], "jalview.io.MSFfile", ["jalview.datamodel.Sequence", "jalview.util.Comparison", "$.Format", "java.lang.StringBuffer", "java.util.Hashtable", "$.StringTokenizer", "$.Vector"], function () { +c$ = Clazz.declareType (jalview.io, "MSFfile", jalview.io.AlignFile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.MSFfile, []); +}); +Clazz.overrideMethod (c$, "parse", +function () { +var i = 0; +var seqFlag = false; +var key = String.instantialize (); +var headers = new java.util.Vector (); +var seqhash = new java.util.Hashtable (); +var line; +try { +while ((line = this.nextLine ()) != null) { +var str = new java.util.StringTokenizer (line); +while (str.hasMoreTokens ()) { +var inStr = str.nextToken (); +if (inStr.indexOf ("Name:") != -1) { +key = str.nextToken (); +headers.addElement (key); +}if (inStr.indexOf ("//") != -1) { +seqFlag = true; +}if ((inStr.indexOf ("//") == -1) && (seqFlag == true)) { +key = inStr; +var tempseq; +if (seqhash.containsKey (key)) { +tempseq = seqhash.get (key); +} else { +tempseq = new StringBuffer (); +seqhash.put (key, tempseq); +}while (str.hasMoreTokens ()) { +tempseq.append (str.nextToken ()); +} +}} +} +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +System.err.println ("Exception parsing MSFFile " + e); +e.printStackTrace (); +} else { +throw e; +} +} +this.noSeqs = headers.size (); +for (i = 0; i < headers.size (); i++) { +if (seqhash.get (headers.elementAt (i)) != null) { +var head = headers.elementAt (i).toString (); +var seq = seqhash.get (head).toString (); +if (this.maxLength < head.length) { +this.maxLength = head.length; +}seq = seq.$replace ('~', '-'); +var newSeq = this.parseId (head); +newSeq.setSequence (seq); +this.seqs.addElement (newSeq); +} else { +System.err.println ("MSFFile Parser: Can't find sequence for " + headers.elementAt (i)); +}} +}); +Clazz.defineMethod (c$, "checkSum", +function (seq) { +var check = 0; +var sequence = seq.toUpperCase (); +for (var i = 0; i < sequence.length; i++) { +try { +var value = sequence.charCodeAt (i); +if (value != -1) { +check += (i % 57 + 1) * value; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Exception during MSF Checksum calculation"); +e.printStackTrace (); +} else { +throw e; +} +} +} +return check % 10000; +}, "~S"); +Clazz.defineMethod (c$, "print", +function (seqs) { +var is_NA = jalview.util.Comparison.isNucleotide (seqs); +var s = new Array (seqs.length); +var out = new StringBuffer ("!!" + (is_NA ? "NA" : "AA") + "_MULTIPLE_ALIGNMENT 1.0"); +out.append (this.newline); +out.append (this.newline); +var max = 0; +var maxid = 0; +var i = 0; +while ((i < seqs.length) && (seqs[i] != null)) { +s[i] = new jalview.datamodel.Sequence (seqs[i].getName (), seqs[i].getSequenceAsString ().$replace ('-', '.'), seqs[i].getStart (), seqs[i].getEnd ()); +var sb = new StringBuffer (); +sb.append (s[i].getSequence ()); +for (var ii = 0; ii < sb.length (); ii++) { +if (sb.charAt (ii) == '.') { +sb.setCharAt (ii, '~'); +} else { +break; +}} +for (var ii = sb.length () - 1; ii > 0; ii--) { +if (sb.charAt (ii) == '.') { +sb.setCharAt (ii, '~'); +} else { +break; +}} +s[i].setSequence (sb.toString ()); +if (s[i].getSequence ().length > max) { +max = s[i].getSequence ().length; +}i++; +} +var maxLenpad = new jalview.util.Format ("%" + ( String.instantialize ("" + max)).length + "d"); +var maxChkpad = new jalview.util.Format ("%" + ( String.instantialize ("1" + max)).length + "d"); +i = 0; +var bigChecksum = 0; +var checksums = Clazz.newIntArray (s.length, 0); +while (i < s.length) { +checksums[i] = this.checkSum (s[i].getSequenceAsString ()); +bigChecksum += checksums[i]; +i++; +} +var maxNB = 0; +out.append (" MSF: " + s[0].getSequence ().length + " Type: " + (is_NA ? "N" : "P") + " Check: " + (bigChecksum % 10000) + " .."); +out.append (this.newline); +out.append (this.newline); +out.append (this.newline); +var nameBlock = new Array (s.length); +var idBlock = new Array (s.length); +i = 0; +while ((i < s.length) && (s[i] != null)) { +nameBlock[i] = String.instantialize (" Name: " + this.printId (s[i]) + " "); +idBlock[i] = String.instantialize ("Len: " + maxLenpad.formLong (s[i].getSequence ().length) + " Check: " + maxChkpad.formLong (checksums[i]) + " Weight: 1.00" + this.newline); +if (s[i].getName ().length > maxid) { +maxid = s[i].getName ().length; +}if (nameBlock[i].length > maxNB) { +maxNB = nameBlock[i].length; +}i++; +} +if (maxid < 10) { +maxid = 10; +}if (maxNB < 15) { +maxNB = 15; +}var nbFormat = new jalview.util.Format ("%-" + maxNB + "s"); +for (i = 0; (i < s.length) && (s[i] != null); i++) { +out.append (nbFormat.form (nameBlock[i]) + idBlock[i]); +} +maxid++; +out.append (this.newline); +out.append (this.newline); +out.append ("//"); +out.append (this.newline); +out.append (this.newline); +var len = 50; +var nochunks = (Clazz.doubleToInt (max / len)) + 1; +if ((max % len) == 0) { +nochunks--; +}for (i = 0; i < nochunks; i++) { +var j = 0; +while ((j < s.length) && (s[j] != null)) { +var name = this.printId (s[j]); +out.append ( new jalview.util.Format ("%-" + maxid + "s").form (name + " ")); +for (var k = 0; k < 5; k++) { +var start = (i * 50) + (k * 10); +var end = start + 10; +if ((end < s[j].getSequence ().length) && (start < s[j].getSequence ().length)) { +out.append (s[j].getSequence (start, end)); +if (k < 4) { +out.append (" "); +} else { +out.append (this.newline); +}} else { +if (start < s[j].getSequence ().length) { +out.append (s[j].getSequenceAsString ().substring (start)); +out.append (this.newline); +} else { +if (k == 0) { +out.append (this.newline); +}}}} +j++; +} +out.append (this.newline); +} +return out.toString (); +}, "~A"); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +}); diff --git a/bin/jalview/io/ModellerDescription.js b/bin/jalview/io/ModellerDescription.js index c08736d..1232c05 100644 --- a/bin/jalview/io/ModellerDescription.js +++ b/bin/jalview/io/ModellerDescription.js @@ -1,236 +1,236 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["java.util.Hashtable"], "jalview.io.ModellerDescription", ["jalview.datamodel.DBRefSource", "jalview.jsdev.RegExp", "java.util.StringTokenizer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.seqTypes = null; -this.Fields = null; -this.TYPE = 0; -this.LOCALID = 1; -this.START = 2; -this.START_CHAIN = 3; -this.END = 4; -this.END_CHAIN = 5; -this.DESCRIPTION1 = 6; -this.DESCRIPTION2 = 7; -this.RESOLUTION = 8; -this.TAIL = 9; -this.Types = null; -this.Padding = null; -this.fields = null; -if (!Clazz.isClassDefined ("jalview.io.ModellerDescription.resCode")) { -jalview.io.ModellerDescription.$ModellerDescription$resCode$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.io, "ModellerDescription"); -Clazz.prepareFields (c$, function () { -this.seqTypes = Clazz.newArray (-1, ["sequence", "structure", "structureX", "structureN"]); -this.Fields = Clazz.newArray (-1, ["objectType", "objectId", "startField", "startCode", "endField", "endCode", "description1", "description2", "resolutionField", "tailField"]); -this.Types = Clazz.newIntArray (-1, [0, 0, 1, 0, 1, 0, 0, 0, 0, 0]); -this.Padding = Clazz.newCharArray (-1, [' ', ' ', ' ', '.', ' ', '.', '.', '.', '.', '.']); -this.fields = new java.util.Hashtable (); -}); -Clazz.makeConstructor (c$, -function () { -this.fields.put (this.Fields[9], ""); -}); -Clazz.defineMethod (c$, "validResidueCode", -($fz = function (field) { -var val = null; -var r = jalview.jsdev.RegExp.newRegex (["\\s*((([-0-9]+).?)|FIRST|LAST|@)"]); -if (!r.search (field)) { -return null; -}var value = r.stringMatchedI (3); -if (value == null) { -value = r.stringMatchedI (1); -}try { -val = Integer.$valueOf (value); -return Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, field, val); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -return Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, field, null); -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "parseDescription", -($fz = function (desc) { -var fields = new java.util.Hashtable (); -var st = new java.util.StringTokenizer (desc, ":", true); -var field; -var type = -1; -if (st.countTokens () > 0) { -var i = 0; -field = st.nextToken (":"); -do { -if (this.seqTypes[i].equalsIgnoreCase (field)) { -break; -}} while (++i < this.seqTypes.length); -if (i < this.seqTypes.length) { -st.nextToken (); -type = i; -i = 1; -while (i < 9 && st.hasMoreTokens ()) { -if ((field = st.nextToken (":")) != null) { -if (!field.equals (":")) { -if (this.Types[i] == 1) { -var val = this.validResidueCode (field); -if (val != null) { -fields.put ( String.instantialize (this.Fields[i] + "num"), val); -} else { -type = -1; -};}fields.put (this.Fields[i++], field); -if (st.hasMoreTokens ()) { -st.nextToken (); -}} else { -i++; -}}} -if (i == 9) { -while (st.hasMoreTokens ()) { -var tl = st.nextToken (":"); -field += tl.equals (":") ? tl : (":" + tl); -} -fields.put (this.Fields[9], field); -}}}if (type == -1) { -fields = new java.util.Hashtable (); -fields.put (this.Fields[9], String.instantialize (desc)); -} else { -fields.put (this.Fields[0], this.seqTypes[type]); -}return fields; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.makeConstructor (c$, -function (desc) { -if (desc == null) { -desc = ""; -}this.fields = this.parseDescription (desc); -}, "~S"); -Clazz.defineMethod (c$, "setStartCode", -function (v) { -var r; -this.fields.put (this.Fields[2] + "num", r = Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, v)); -this.fields.put (this.Fields[2], r.field); -}, "~N"); -Clazz.defineMethod (c$, "setEndCode", -function (v) { -var r; -this.fields.put (this.Fields[4] + "num", r = Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, v)); -this.fields.put (this.Fields[4], r.field); -}, "~N"); -Clazz.makeConstructor (c$, -function (seq) { -if (seq.getDescription () != null) { -this.fields = this.parseDescription (seq.getDescription ()); -}if (this.isModellerFieldset ()) { -if (this.getStartCode () == null || (this.getStartNum () != seq.getStart () && this.getStartCode ().val != null)) { -this.setStartCode (seq.getStart ()); -}if (this.getEndCode () == null || (this.getEndNum () != seq.getEnd () && this.getStartCode () != null && this.getStartCode ().val != null)) { -this.setEndCode (seq.getEnd ()); -}} else { -this.setStartCode (seq.getStart ()); -this.setEndCode (seq.getEnd ()); -this.fields.put (this.Fields[1], seq.getName ()); -var t = 0; -if (seq.getDatasetSequence () != null && seq.getDatasetSequence ().getDBRef () != null) { -var dbr = seq.getDatasetSequence ().getDBRef (); -var i; -var j; -for (i = 0, j = dbr.length; i < j; i++) { -if (dbr[i] != null) { -if (dbr[i].getSource ().equals (jalview.datamodel.DBRefSource.PDB)) { -this.fields.put (this.Fields[1], dbr[i].getAccessionId ()); -t = 2; -break; -}}} -}this.fields.put (this.Fields[0], this.seqTypes[t]); -}}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "isModellerFieldset", -function () { -return (this.fields.containsKey (this.Fields[0])); -}); -Clazz.defineMethod (c$, "getDescriptionLine", -function () { -var desc = ""; -var lastfield = this.Fields.length - 1; -if (this.isModellerFieldset ()) { -var value; -for (; lastfield > 6; lastfield--) { -if (this.fields.containsKey (this.Fields[lastfield])) { -break; -}} -for (var i = 0; i < lastfield; i++) { -value = this.fields.get (this.Fields[i]); -if (value != null && value.length > 0) { -desc += (this.fields.get (this.Fields[i])) + ":"; -} else { -desc += this.Padding[i] + ":"; -}} -}if (this.fields.containsKey (this.Fields[lastfield])) { -desc += this.fields.get (this.Fields[lastfield]); -} else { -desc += "."; -}return desc; -}); -Clazz.defineMethod (c$, "getStartNum", -function () { -var start = 0; -var val = this.getStartCode (); -if (val != null && val.val != null) { -return val.val.intValue (); -}return start; -}); -Clazz.defineMethod (c$, "getStartCode", -function () { -if (this.isModellerFieldset () && this.fields.containsKey (this.Fields[2] + "num")) { -return this.fields.get (this.Fields[2] + "num"); -}return null; -}); -Clazz.defineMethod (c$, "getEndCode", -function () { -if (this.isModellerFieldset () && this.fields.containsKey (this.Fields[4] + "num")) { -return this.fields.get (this.Fields[4] + "num"); -}return null; -}); -Clazz.defineMethod (c$, "getEndNum", -function () { -var end = 0; -var val = this.getEndCode (); -if (val != null && val.val != null) { -return val.val.intValue (); -}return end; -}); -Clazz.defineMethod (c$, "updateSequenceI", -function (newSeq) { -if (this.isModellerFieldset ()) { -var rc = this.getStartCode (); -if (rc != null && rc.val != null) { -newSeq.setStart (this.getStartNum ()); -} else { -newSeq.setStart (1); -}rc = this.getEndCode (); -if (rc != null && rc.val != null) { -newSeq.setEnd (this.getEndNum ()); -} else { -newSeq.setEnd (newSeq.getStart () + newSeq.getLength ()); -}return true; -}return false; -}, "jalview.datamodel.SequenceI"); -c$.$ModellerDescription$resCode$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.val = null; -this.field = null; -Clazz.instantialize (this, arguments); -}, jalview.io.ModellerDescription, "resCode"); -Clazz.makeConstructor (c$, -function (a, b) { -this.val = b; -this.field = a; -}, "~S,Integer"); -Clazz.makeConstructor (c$, -function (a) { -this.val = new Integer (a); -this.field = this.val.toString (); -}, "~N"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["java.util.Hashtable"], "jalview.io.ModellerDescription", ["jalview.datamodel.DBRefSource", "jalview.jsdev.RegExp", "java.util.StringTokenizer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.seqTypes = null; +this.Fields = null; +this.TYPE = 0; +this.LOCALID = 1; +this.START = 2; +this.START_CHAIN = 3; +this.END = 4; +this.END_CHAIN = 5; +this.DESCRIPTION1 = 6; +this.DESCRIPTION2 = 7; +this.RESOLUTION = 8; +this.TAIL = 9; +this.Types = null; +this.Padding = null; +this.fields = null; +if (!Clazz.isClassDefined ("jalview.io.ModellerDescription.resCode")) { +jalview.io.ModellerDescription.$ModellerDescription$resCode$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.io, "ModellerDescription"); +Clazz.prepareFields (c$, function () { +this.seqTypes = Clazz.newArray (-1, ["sequence", "structure", "structureX", "structureN"]); +this.Fields = Clazz.newArray (-1, ["objectType", "objectId", "startField", "startCode", "endField", "endCode", "description1", "description2", "resolutionField", "tailField"]); +this.Types = Clazz.newIntArray (-1, [0, 0, 1, 0, 1, 0, 0, 0, 0, 0]); +this.Padding = Clazz.newCharArray (-1, [' ', ' ', ' ', '.', ' ', '.', '.', '.', '.', '.']); +this.fields = new java.util.Hashtable (); +}); +Clazz.makeConstructor (c$, +function () { +this.fields.put (this.Fields[9], ""); +}); +Clazz.defineMethod (c$, "validResidueCode", +($fz = function (field) { +var val = null; +var r = jalview.jsdev.RegExp.newRegex (["\\s*((([-0-9]+).?)|FIRST|LAST|@)"]); +if (!r.search (field)) { +return null; +}var value = r.stringMatchedI (3); +if (value == null) { +value = r.stringMatchedI (1); +}try { +val = Integer.$valueOf (value); +return Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, field, val); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +return Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, field, null); +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "parseDescription", +($fz = function (desc) { +var fields = new java.util.Hashtable (); +var st = new java.util.StringTokenizer (desc, ":", true); +var field; +var type = -1; +if (st.countTokens () > 0) { +var i = 0; +field = st.nextToken (":"); +do { +if (this.seqTypes[i].equalsIgnoreCase (field)) { +break; +}} while (++i < this.seqTypes.length); +if (i < this.seqTypes.length) { +st.nextToken (); +type = i; +i = 1; +while (i < 9 && st.hasMoreTokens ()) { +if ((field = st.nextToken (":")) != null) { +if (!field.equals (":")) { +if (this.Types[i] == 1) { +var val = this.validResidueCode (field); +if (val != null) { +fields.put ( String.instantialize (this.Fields[i] + "num"), val); +} else { +type = -1; +};}fields.put (this.Fields[i++], field); +if (st.hasMoreTokens ()) { +st.nextToken (); +}} else { +i++; +}}} +if (i == 9) { +while (st.hasMoreTokens ()) { +var tl = st.nextToken (":"); +field += tl.equals (":") ? tl : (":" + tl); +} +fields.put (this.Fields[9], field); +}}}if (type == -1) { +fields = new java.util.Hashtable (); +fields.put (this.Fields[9], String.instantialize (desc)); +} else { +fields.put (this.Fields[0], this.seqTypes[type]); +}return fields; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.makeConstructor (c$, +function (desc) { +if (desc == null) { +desc = ""; +}this.fields = this.parseDescription (desc); +}, "~S"); +Clazz.defineMethod (c$, "setStartCode", +function (v) { +var r; +this.fields.put (this.Fields[2] + "num", r = Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, v)); +this.fields.put (this.Fields[2], r.field); +}, "~N"); +Clazz.defineMethod (c$, "setEndCode", +function (v) { +var r; +this.fields.put (this.Fields[4] + "num", r = Clazz.innerTypeInstance (jalview.io.ModellerDescription.resCode, this, null, v)); +this.fields.put (this.Fields[4], r.field); +}, "~N"); +Clazz.makeConstructor (c$, +function (seq) { +if (seq.getDescription () != null) { +this.fields = this.parseDescription (seq.getDescription ()); +}if (this.isModellerFieldset ()) { +if (this.getStartCode () == null || (this.getStartNum () != seq.getStart () && this.getStartCode ().val != null)) { +this.setStartCode (seq.getStart ()); +}if (this.getEndCode () == null || (this.getEndNum () != seq.getEnd () && this.getStartCode () != null && this.getStartCode ().val != null)) { +this.setEndCode (seq.getEnd ()); +}} else { +this.setStartCode (seq.getStart ()); +this.setEndCode (seq.getEnd ()); +this.fields.put (this.Fields[1], seq.getName ()); +var t = 0; +if (seq.getDatasetSequence () != null && seq.getDatasetSequence ().getDBRef () != null) { +var dbr = seq.getDatasetSequence ().getDBRef (); +var i; +var j; +for (i = 0, j = dbr.length; i < j; i++) { +if (dbr[i] != null) { +if (dbr[i].getSource ().equals (jalview.datamodel.DBRefSource.PDB)) { +this.fields.put (this.Fields[1], dbr[i].getAccessionId ()); +t = 2; +break; +}}} +}this.fields.put (this.Fields[0], this.seqTypes[t]); +}}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "isModellerFieldset", +function () { +return (this.fields.containsKey (this.Fields[0])); +}); +Clazz.defineMethod (c$, "getDescriptionLine", +function () { +var desc = ""; +var lastfield = this.Fields.length - 1; +if (this.isModellerFieldset ()) { +var value; +for (; lastfield > 6; lastfield--) { +if (this.fields.containsKey (this.Fields[lastfield])) { +break; +}} +for (var i = 0; i < lastfield; i++) { +value = this.fields.get (this.Fields[i]); +if (value != null && value.length > 0) { +desc += (this.fields.get (this.Fields[i])) + ":"; +} else { +desc += this.Padding[i] + ":"; +}} +}if (this.fields.containsKey (this.Fields[lastfield])) { +desc += this.fields.get (this.Fields[lastfield]); +} else { +desc += "."; +}return desc; +}); +Clazz.defineMethod (c$, "getStartNum", +function () { +var start = 0; +var val = this.getStartCode (); +if (val != null && val.val != null) { +return val.val.intValue (); +}return start; +}); +Clazz.defineMethod (c$, "getStartCode", +function () { +if (this.isModellerFieldset () && this.fields.containsKey (this.Fields[2] + "num")) { +return this.fields.get (this.Fields[2] + "num"); +}return null; +}); +Clazz.defineMethod (c$, "getEndCode", +function () { +if (this.isModellerFieldset () && this.fields.containsKey (this.Fields[4] + "num")) { +return this.fields.get (this.Fields[4] + "num"); +}return null; +}); +Clazz.defineMethod (c$, "getEndNum", +function () { +var end = 0; +var val = this.getEndCode (); +if (val != null && val.val != null) { +return val.val.intValue (); +}return end; +}); +Clazz.defineMethod (c$, "updateSequenceI", +function (newSeq) { +if (this.isModellerFieldset ()) { +var rc = this.getStartCode (); +if (rc != null && rc.val != null) { +newSeq.setStart (this.getStartNum ()); +} else { +newSeq.setStart (1); +}rc = this.getEndCode (); +if (rc != null && rc.val != null) { +newSeq.setEnd (this.getEndNum ()); +} else { +newSeq.setEnd (newSeq.getStart () + newSeq.getLength ()); +}return true; +}return false; +}, "jalview.datamodel.SequenceI"); +c$.$ModellerDescription$resCode$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.val = null; +this.field = null; +Clazz.instantialize (this, arguments); +}, jalview.io.ModellerDescription, "resCode"); +Clazz.makeConstructor (c$, +function (a, b) { +this.val = b; +this.field = a; +}, "~S,Integer"); +Clazz.makeConstructor (c$, +function (a) { +this.val = new Integer (a); +this.field = this.val.toString (); +}, "~N"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/io/NewickFile.js b/bin/jalview/io/NewickFile.js index 2975319..886a07b 100644 --- a/bin/jalview/io/NewickFile.js +++ b/bin/jalview/io/NewickFile.js @@ -1,408 +1,408 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.FileParse", "jalview.jsdev.RegExp"], "jalview.io.NewickFile", ["jalview.datamodel.SequenceNode", "jalview.util.MessageManager", "java.io.BufferedReader", "$.IOException", "java.lang.Float", "$.StringBuffer", "java.util.StringTokenizer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.root = null; -this.$HasBootstrap = false; -this.$HasDistances = false; -this.RootHasDistance = false; -this.ReplaceUnderscores = false; -this.printRootInfo = true; -this.NodeSafeName = null; -this.QuoteChar = '\''; -Clazz.instantialize (this, arguments); -}, jalview.io, "NewickFile", jalview.io.FileParse); -Clazz.prepareFields (c$, function () { -this.NodeSafeName = Clazz.newArray (-1, [jalview.jsdev.RegExp.perlCode ("m/[\\[,:'()]/"), jalview.jsdev.RegExp.perlCode ("s/'/''/"), jalview.jsdev.RegExp.perlCode ("s/\\/w/_/")]); -}); -Clazz.makeConstructor (c$, -function (inStr) { -Clazz.superConstructor (this, jalview.io.NewickFile, [inStr, "Paste"]); -}, "~S"); -Clazz.makeConstructor (c$, -function (newtree) { -Clazz.superConstructor (this, jalview.io.NewickFile, []); -this.root = newtree; -}, "jalview.datamodel.SequenceNode"); -Clazz.makeConstructor (c$, -function (newtree, bootstrap) { -Clazz.superConstructor (this, jalview.io.NewickFile, []); -this.$HasBootstrap = bootstrap; -this.root = newtree; -}, "jalview.datamodel.SequenceNode,~B"); -Clazz.makeConstructor (c$, -function (newtree, bootstrap, distances) { -Clazz.superConstructor (this, jalview.io.NewickFile, []); -this.root = newtree; -this.$HasBootstrap = bootstrap; -this.$HasDistances = distances; -}, "jalview.datamodel.SequenceNode,~B,~B"); -Clazz.makeConstructor (c$, -function (newtree, bootstrap, distances, rootdistance) { -Clazz.superConstructor (this, jalview.io.NewickFile, []); -this.root = newtree; -this.$HasBootstrap = bootstrap; -this.$HasDistances = distances; -this.RootHasDistance = rootdistance; -}, "jalview.datamodel.SequenceNode,~B,~B,~B"); -Clazz.defineMethod (c$, "ErrorStringrange", -($fz = function (Error, Er, r, p, s) { -return ((Error == null) ? "" : Error) + Er + " at position " + p + " ( " + s.substring (((p - r) < 0) ? 0 : (p - r), ((p + r) > s.length) ? s.length : (p + r)) + " )\n"; -}, $fz.isPrivate = true, $fz), "~S,~S,~N,~N,~S"); -Clazz.defineMethod (c$, "HasBootstrap", -function () { -return this.$HasBootstrap; -}); -Clazz.defineMethod (c$, "HasDistances", -function () { -return this.$HasDistances; -}); -Clazz.defineMethod (c$, "HasRootDistance", -function () { -return this.RootHasDistance; -}); -Clazz.defineMethod (c$, "parse", -function () { -var nf; -{ -var file = new StringBuffer (); -while ((nf = this.nextLine ()) != null) { -file.append (nf); -} -nf = file.toString (); -}this.root = new jalview.datamodel.SequenceNode (); -var realroot = null; -var c = this.root; -var d = -1; -var cp = 0; -var Error = null; -var nodename = null; -var commentString2 = null; -var DefDistance = 0.001; -var DefBootstrap = -1; -var distance = DefDistance; -var bootstrap = DefBootstrap; -var ascending = false; -var majorsyms = jalview.jsdev.RegExp.newRegex (["[(\\['),;]"]); -var nextcp = 0; -var ncp = cp; -var parsednodename = false; -while (majorsyms.searchFrom (nf, cp) && (Error == null)) { -var fcp = majorsyms.matchedFrom (); -var schar; -switch (schar = nf.charAt (fcp)) { -case '(': -if (ascending) { -Error = this.ErrorStringrange (Error, "Unexpected '('", 7, fcp, nf); -continue; -};d++; -if (c.right () == null) { -c.setRight ( new jalview.datamodel.SequenceNode (null, c, null, DefDistance, DefBootstrap, false)); -c = c.right (); -} else { -if (c.left () != null) { -var tmpn = new jalview.datamodel.SequenceNode (null, c, null, 0, 0, true); -tmpn.SetChildren (c.left (), c.right ()); -c.setRight (tmpn); -}c.setLeft ( new jalview.datamodel.SequenceNode (null, c, null, DefDistance, DefBootstrap, false)); -c = c.left (); -}if (realroot == null) { -realroot = c; -}nodename = null; -distance = DefDistance; -bootstrap = DefBootstrap; -cp = fcp + 1; -break; -case '\'': -var qnodename = jalview.jsdev.RegExp.newRegex (["'([^']|'')+'"]); -if (qnodename.searchFrom (nf, fcp)) { -var nl = qnodename.stringMatched ().length; -nodename = String.instantialize (qnodename.stringMatched ().substring (1, nl - 1)); -var xpandquotes = jalview.jsdev.RegExp.perlCode ("s/''/'/"); -var widernodename = xpandquotes.replaceAll (nodename); -nodename = widernodename; -nextcp = fcp + nl + 1; -parsednodename = true; -} else { -Error = this.ErrorStringrange (Error, "Unterminated quotes for nodename", 7, fcp, nf); -}break; -default: -if (schar == ';') { -if (d != -1) { -Error = this.ErrorStringrange (Error, "Wayward semicolon (depth=" + d + ")", 7, fcp, nf); -}}if (schar == '[') { -var comment = jalview.jsdev.RegExp.newRegex (["]"]); -if (comment.searchFrom (nf, fcp)) { -nextcp = comment.matchedFrom () + 1; -this.warningMessage = "Tree file contained comments which may confuse input algorithm."; -break; -} else { -Error = this.ErrorStringrange (Error, "Unterminated comment", 3, fcp, nf); -};}var fstring = nf.substring (ncp, fcp); -while (fstring.indexOf (']') > -1) { -var cstart = fstring.indexOf ('['); -var cend = fstring.indexOf (']'); -commentString2 = fstring.substring (cstart + 1, cend); -fstring = fstring.substring (0, cstart) + fstring.substring (cend + 1); -} -var uqnodename = jalview.jsdev.RegExp.newRegex (["\\b([^' :;\\](),]+)"]); -var nbootstrap = jalview.jsdev.RegExp.newRegex (["\\s*([0-9+]+)\\s*:"]); -var ndist = jalview.jsdev.RegExp.newRegex ([":([-0-9Ee.+]+)"]); -if (!parsednodename && uqnodename.search (fstring) && ((uqnodename.matchedFromI (1) == 0) || (fstring.charAt (uqnodename.matchedFromI (1) - 1) != ':'))) { -if (nodename == null) { -if (this.ReplaceUnderscores) { -nodename = uqnodename.stringMatchedI (1).$replace ('_', ' '); -} else { -nodename = uqnodename.stringMatchedI (1); -}} else { -Error = this.ErrorStringrange (Error, "File has broken algorithm - overwritten nodename", 10, fcp, nf); -}}if (nbootstrap.search (fstring)) { -if (nbootstrap.stringMatchedI (1).equals (uqnodename.stringMatchedI (1))) { -nodename = null; -}if (nodename == null || nodename.length == 0 || nbootstrap.matchedFromI (1) > (uqnodename.matchedFromI (1) + uqnodename.stringMatched ().length)) { -try { -bootstrap = ( new Integer (nbootstrap.stringMatchedI (1))).intValue (); -this.$HasBootstrap = true; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -Error = this.ErrorStringrange (Error, "Can't parse bootstrap value", 4, ncp + nbootstrap.matchedFrom (), nf); -} else { -throw e; -} -} -}}var nodehasdistance = false; -if (ndist.search (fstring)) { -try { -distance = ( new Float (ndist.stringMatchedI (1))).floatValue (); -this.$HasDistances = true; -nodehasdistance = true; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -Error = this.ErrorStringrange (Error, "Can't parse node distance value", 7, ncp + ndist.matchedFrom (), nf); -} else { -throw e; -} -} -}if (ascending) { -c.setName (nodename); -c.dist = (this.$HasDistances) ? distance : DefDistance; -c.setBootstrap ((this.$HasBootstrap) ? bootstrap : DefBootstrap); -if (c === realroot) { -this.RootHasDistance = nodehasdistance; -}this.parseNHXNodeProps (c, commentString2); -commentString2 = null; -} else { -var newnode = new jalview.datamodel.SequenceNode (null, c, nodename, (this.$HasDistances) ? distance : DefDistance, (this.$HasBootstrap) ? bootstrap : DefBootstrap, false); -this.parseNHXNodeProps (c, commentString2); -commentString2 = null; -if (c.right () == null) { -c.setRight (newnode); -} else { -if (c.left () == null) { -c.setLeft (newnode); -} else { -var newdummy = new jalview.datamodel.SequenceNode (null, c, null, (this.$HasDistances ? 0 : DefDistance), 0, true); -newdummy.SetChildren (c.left (), newnode); -c.setLeft (newdummy); -}}}if (ascending) { -c = c.AscendTree (); -if ((d > -1) && (c == null)) { -Error = this.ErrorStringrange (Error, "File broke algorithm: Lost place in tree (is there an extra ')' ?)", 7, fcp, nf); -}}if (nf.charAt (fcp) == ')') { -d--; -ascending = true; -} else { -if (nf.charAt (fcp) == ',') { -if (ascending) { -ascending = false; -} else { -if ((c.left () != null) && (!c.left ().isLeaf ())) { -c = c.left (); -}}}}nodename = null; -distance = DefDistance; -bootstrap = DefBootstrap; -commentString2 = null; -parsednodename = false; -} -if (nextcp == 0) { -ncp = cp = fcp + 1; -} else { -cp = nextcp; -nextcp = 0; -}} -if (Error != null) { -throw ( new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.newfile", Clazz.newArray (-1, [Error.toString ()])))); -}if (this.root == null) { -throw ( new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.newfile", Clazz.newArray (-1, [jalview.util.MessageManager.getString ("label.no_tree_read_in")])))); -}this.root = this.root.right ().detach (); -if (!this.RootHasDistance) { -this.root.dist = (this.$HasDistances) ? 0 : DefDistance; -}}); -Clazz.defineMethod (c$, "parseNHXNodeProps", -($fz = function (c, commentString) { -if (commentString != null && commentString.startsWith ("&&NHX")) { -var st = new java.util.StringTokenizer (commentString.substring (5), ":"); -while (st.hasMoreTokens ()) { -var tok = st.nextToken (); -var colpos = tok.indexOf ("="); -if (colpos > -1) { -var code = tok.substring (0, colpos); -var value = tok.substring (colpos + 1); -try { -if (code.toLowerCase ().equals ("b")) { -var v = -1; -var iv = new Float (value); -v = iv.intValue (); -c.setBootstrap (v); -this.$HasBootstrap = true; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.err.println ("Couldn't parse code '" + code + "' = '" + value + "'"); -e.printStackTrace (System.err); -} else { -throw e; -} -} -}} -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode,~S"); -Clazz.defineMethod (c$, "getTree", -function () { -return this.root; -}); -Clazz.defineMethod (c$, "print", -function () { -{ -var tf = new StringBuffer (); -this.print (tf, this.root); -return (tf.append (";").toString ()); -}}); -Clazz.defineMethod (c$, "print", -function (withbootstraps) { -{ -var boots = this.$HasBootstrap; -this.$HasBootstrap = withbootstraps; -var rv = this.print (); -this.$HasBootstrap = boots; -return rv; -}}, "~B"); -Clazz.defineMethod (c$, "print", -function (withbootstraps, withdists) { -{ -var dists = this.$HasDistances; -this.$HasDistances = withdists; -var rv = this.print (withbootstraps); -this.$HasDistances = dists; -return rv; -}}, "~B,~B"); -Clazz.defineMethod (c$, "print", -function (withbootstraps, withdists, printRootInfo) { -{ -var rootinfo = printRootInfo; -this.printRootInfo = printRootInfo; -var rv = this.print (withbootstraps, withdists); -this.printRootInfo = rootinfo; -return rv; -}}, "~B,~B,~B"); -Clazz.defineMethod (c$, "getQuoteChar", -function () { -return this.QuoteChar; -}); -Clazz.defineMethod (c$, "setQuoteChar", -function (c) { -var old = this.QuoteChar; -this.QuoteChar = c; -return old; -}, "~S"); -Clazz.defineMethod (c$, "nodeName", -($fz = function (name) { -if (this.NodeSafeName[0].search (name)) { -return this.QuoteChar + this.NodeSafeName[1].replaceAll (name) + this.QuoteChar; -} else { -return this.NodeSafeName[2].replaceAll (name); -}}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "printNodeField", -($fz = function (c) { -return ((c.getName () == null) ? "" : this.nodeName (c.getName ())) + ((this.$HasBootstrap) ? ((c.getBootstrap () > -1) ? ((c.getName () != null ? " " : "") + c.getBootstrap ()) : "") : "") + ((this.$HasDistances) ? (":" + c.dist) : ""); -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "printRootField", -($fz = function (root) { -return (this.printRootInfo) ? (((root.getName () == null) ? "" : this.nodeName (root.getName ())) + ((this.$HasBootstrap) ? ((root.getBootstrap () > -1) ? ((root.getName () != null ? " " : "") + +root.getBootstrap ()) : "") : "") + ((this.RootHasDistance) ? (":" + root.dist) : "")) : ""; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "print", -function (tf, root) { -if (root != null) { -if (root.isLeaf () && this.printRootInfo) { -tf.append (this.printRootField (root)); -} else { -if (root.isDummy ()) { -this._print (tf, root.right ()); -this._print (tf, root.left ()); -} else { -tf.append ("("); -this._print (tf, root.right ()); -if (root.left () != null) { -tf.append (","); -}this._print (tf, root.left ()); -tf.append (")" + this.printRootField (root)); -}}}}, "StringBuffer,jalview.datamodel.SequenceNode"); -Clazz.defineMethod (c$, "_print", -function (tf, c) { -if (c != null) { -if (c.isLeaf ()) { -tf.append (this.printNodeField (c)); -} else { -if (c.isDummy ()) { -this._print (tf, c.left ()); -if (c.left () != null) { -tf.append (","); -}this._print (tf, c.right ()); -} else { -tf.append ("("); -this._print (tf, c.right ()); -if (c.left () != null) { -tf.append (","); -}this._print (tf, c.left ()); -tf.append (")" + this.printNodeField (c)); -}}}}, "StringBuffer,jalview.datamodel.SequenceNode"); -c$.main = Clazz.defineMethod (c$, "main", -function (args) { -try { -if (args == null || args.length != 1) { -System.err.println ("Takes one argument - file name of a newick tree file."); -System.exit (0); -}var fn = new java.io.File (args[0]); -var newickfile = new StringBuffer (); -var treefile = new java.io.BufferedReader ( new java.io.FileReader (fn)); -var l; -while ((l = treefile.readLine ()) != null) { -newickfile.append (l); -} -treefile.close (); -System.out.println ("Read file :\n"); -var trf = new jalview.io.NewickFile (args[0], "File"); -trf.parse (); -System.out.println ("Original file :\n"); -var nonl = jalview.jsdev.RegExp.newRegex (["\n+", ""]); -System.out.println (nonl.replaceAll (newickfile.toString ()) + "\n"); -System.out.println ("Parsed file.\n"); -System.out.println ("Default output type for original input.\n"); -System.out.println (trf.print ()); -System.out.println ("Without bootstraps.\n"); -System.out.println (trf.print (false)); -System.out.println ("Without distances.\n"); -System.out.println (trf.print (true, false)); -System.out.println ("Without bootstraps but with distanecs.\n"); -System.out.println (trf.print (false, true)); -System.out.println ("Without bootstraps or distanecs.\n"); -System.out.println (trf.print (false, false)); -System.out.println ("With bootstraps and with distances.\n"); -System.out.println (trf.print (true, true)); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -System.err.println ("Exception\n" + e); -e.printStackTrace (); -} else { -throw e; -} -} -}, "~A"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.FileParse", "jalview.jsdev.RegExp"], "jalview.io.NewickFile", ["jalview.datamodel.SequenceNode", "jalview.util.MessageManager", "java.io.BufferedReader", "$.IOException", "java.lang.Float", "$.StringBuffer", "java.util.StringTokenizer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.root = null; +this.$HasBootstrap = false; +this.$HasDistances = false; +this.RootHasDistance = false; +this.ReplaceUnderscores = false; +this.printRootInfo = true; +this.NodeSafeName = null; +this.QuoteChar = '\''; +Clazz.instantialize (this, arguments); +}, jalview.io, "NewickFile", jalview.io.FileParse); +Clazz.prepareFields (c$, function () { +this.NodeSafeName = Clazz.newArray (-1, [jalview.jsdev.RegExp.perlCode ("m/[\\[,:'()]/"), jalview.jsdev.RegExp.perlCode ("s/'/''/"), jalview.jsdev.RegExp.perlCode ("s/\\/w/_/")]); +}); +Clazz.makeConstructor (c$, +function (inStr) { +Clazz.superConstructor (this, jalview.io.NewickFile, [inStr, "Paste"]); +}, "~S"); +Clazz.makeConstructor (c$, +function (newtree) { +Clazz.superConstructor (this, jalview.io.NewickFile, []); +this.root = newtree; +}, "jalview.datamodel.SequenceNode"); +Clazz.makeConstructor (c$, +function (newtree, bootstrap) { +Clazz.superConstructor (this, jalview.io.NewickFile, []); +this.$HasBootstrap = bootstrap; +this.root = newtree; +}, "jalview.datamodel.SequenceNode,~B"); +Clazz.makeConstructor (c$, +function (newtree, bootstrap, distances) { +Clazz.superConstructor (this, jalview.io.NewickFile, []); +this.root = newtree; +this.$HasBootstrap = bootstrap; +this.$HasDistances = distances; +}, "jalview.datamodel.SequenceNode,~B,~B"); +Clazz.makeConstructor (c$, +function (newtree, bootstrap, distances, rootdistance) { +Clazz.superConstructor (this, jalview.io.NewickFile, []); +this.root = newtree; +this.$HasBootstrap = bootstrap; +this.$HasDistances = distances; +this.RootHasDistance = rootdistance; +}, "jalview.datamodel.SequenceNode,~B,~B,~B"); +Clazz.defineMethod (c$, "ErrorStringrange", +($fz = function (Error, Er, r, p, s) { +return ((Error == null) ? "" : Error) + Er + " at position " + p + " ( " + s.substring (((p - r) < 0) ? 0 : (p - r), ((p + r) > s.length) ? s.length : (p + r)) + " )\n"; +}, $fz.isPrivate = true, $fz), "~S,~S,~N,~N,~S"); +Clazz.defineMethod (c$, "HasBootstrap", +function () { +return this.$HasBootstrap; +}); +Clazz.defineMethod (c$, "HasDistances", +function () { +return this.$HasDistances; +}); +Clazz.defineMethod (c$, "HasRootDistance", +function () { +return this.RootHasDistance; +}); +Clazz.defineMethod (c$, "parse", +function () { +var nf; +{ +var file = new StringBuffer (); +while ((nf = this.nextLine ()) != null) { +file.append (nf); +} +nf = file.toString (); +}this.root = new jalview.datamodel.SequenceNode (); +var realroot = null; +var c = this.root; +var d = -1; +var cp = 0; +var Error = null; +var nodename = null; +var commentString2 = null; +var DefDistance = 0.001; +var DefBootstrap = -1; +var distance = DefDistance; +var bootstrap = DefBootstrap; +var ascending = false; +var majorsyms = jalview.jsdev.RegExp.newRegex (["[(\\['),;]"]); +var nextcp = 0; +var ncp = cp; +var parsednodename = false; +while (majorsyms.searchFrom (nf, cp) && (Error == null)) { +var fcp = majorsyms.matchedFrom (); +var schar; +switch (schar = nf.charAt (fcp)) { +case '(': +if (ascending) { +Error = this.ErrorStringrange (Error, "Unexpected '('", 7, fcp, nf); +continue; +};d++; +if (c.right () == null) { +c.setRight ( new jalview.datamodel.SequenceNode (null, c, null, DefDistance, DefBootstrap, false)); +c = c.right (); +} else { +if (c.left () != null) { +var tmpn = new jalview.datamodel.SequenceNode (null, c, null, 0, 0, true); +tmpn.SetChildren (c.left (), c.right ()); +c.setRight (tmpn); +}c.setLeft ( new jalview.datamodel.SequenceNode (null, c, null, DefDistance, DefBootstrap, false)); +c = c.left (); +}if (realroot == null) { +realroot = c; +}nodename = null; +distance = DefDistance; +bootstrap = DefBootstrap; +cp = fcp + 1; +break; +case '\'': +var qnodename = jalview.jsdev.RegExp.newRegex (["'([^']|'')+'"]); +if (qnodename.searchFrom (nf, fcp)) { +var nl = qnodename.stringMatched ().length; +nodename = String.instantialize (qnodename.stringMatched ().substring (1, nl - 1)); +var xpandquotes = jalview.jsdev.RegExp.perlCode ("s/''/'/"); +var widernodename = xpandquotes.replaceAll (nodename); +nodename = widernodename; +nextcp = fcp + nl + 1; +parsednodename = true; +} else { +Error = this.ErrorStringrange (Error, "Unterminated quotes for nodename", 7, fcp, nf); +}break; +default: +if (schar == ';') { +if (d != -1) { +Error = this.ErrorStringrange (Error, "Wayward semicolon (depth=" + d + ")", 7, fcp, nf); +}}if (schar == '[') { +var comment = jalview.jsdev.RegExp.newRegex (["]"]); +if (comment.searchFrom (nf, fcp)) { +nextcp = comment.matchedFrom () + 1; +this.warningMessage = "Tree file contained comments which may confuse input algorithm."; +break; +} else { +Error = this.ErrorStringrange (Error, "Unterminated comment", 3, fcp, nf); +};}var fstring = nf.substring (ncp, fcp); +while (fstring.indexOf (']') > -1) { +var cstart = fstring.indexOf ('['); +var cend = fstring.indexOf (']'); +commentString2 = fstring.substring (cstart + 1, cend); +fstring = fstring.substring (0, cstart) + fstring.substring (cend + 1); +} +var uqnodename = jalview.jsdev.RegExp.newRegex (["\\b([^' :;\\](),]+)"]); +var nbootstrap = jalview.jsdev.RegExp.newRegex (["\\s*([0-9+]+)\\s*:"]); +var ndist = jalview.jsdev.RegExp.newRegex ([":([-0-9Ee.+]+)"]); +if (!parsednodename && uqnodename.search (fstring) && ((uqnodename.matchedFromI (1) == 0) || (fstring.charAt (uqnodename.matchedFromI (1) - 1) != ':'))) { +if (nodename == null) { +if (this.ReplaceUnderscores) { +nodename = uqnodename.stringMatchedI (1).$replace ('_', ' '); +} else { +nodename = uqnodename.stringMatchedI (1); +}} else { +Error = this.ErrorStringrange (Error, "File has broken algorithm - overwritten nodename", 10, fcp, nf); +}}if (nbootstrap.search (fstring)) { +if (nbootstrap.stringMatchedI (1).equals (uqnodename.stringMatchedI (1))) { +nodename = null; +}if (nodename == null || nodename.length == 0 || nbootstrap.matchedFromI (1) > (uqnodename.matchedFromI (1) + uqnodename.stringMatched ().length)) { +try { +bootstrap = ( new Integer (nbootstrap.stringMatchedI (1))).intValue (); +this.$HasBootstrap = true; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +Error = this.ErrorStringrange (Error, "Can't parse bootstrap value", 4, ncp + nbootstrap.matchedFrom (), nf); +} else { +throw e; +} +} +}}var nodehasdistance = false; +if (ndist.search (fstring)) { +try { +distance = ( new Float (ndist.stringMatchedI (1))).floatValue (); +this.$HasDistances = true; +nodehasdistance = true; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +Error = this.ErrorStringrange (Error, "Can't parse node distance value", 7, ncp + ndist.matchedFrom (), nf); +} else { +throw e; +} +} +}if (ascending) { +c.setName (nodename); +c.dist = (this.$HasDistances) ? distance : DefDistance; +c.setBootstrap ((this.$HasBootstrap) ? bootstrap : DefBootstrap); +if (c === realroot) { +this.RootHasDistance = nodehasdistance; +}this.parseNHXNodeProps (c, commentString2); +commentString2 = null; +} else { +var newnode = new jalview.datamodel.SequenceNode (null, c, nodename, (this.$HasDistances) ? distance : DefDistance, (this.$HasBootstrap) ? bootstrap : DefBootstrap, false); +this.parseNHXNodeProps (c, commentString2); +commentString2 = null; +if (c.right () == null) { +c.setRight (newnode); +} else { +if (c.left () == null) { +c.setLeft (newnode); +} else { +var newdummy = new jalview.datamodel.SequenceNode (null, c, null, (this.$HasDistances ? 0 : DefDistance), 0, true); +newdummy.SetChildren (c.left (), newnode); +c.setLeft (newdummy); +}}}if (ascending) { +c = c.AscendTree (); +if ((d > -1) && (c == null)) { +Error = this.ErrorStringrange (Error, "File broke algorithm: Lost place in tree (is there an extra ')' ?)", 7, fcp, nf); +}}if (nf.charAt (fcp) == ')') { +d--; +ascending = true; +} else { +if (nf.charAt (fcp) == ',') { +if (ascending) { +ascending = false; +} else { +if ((c.left () != null) && (!c.left ().isLeaf ())) { +c = c.left (); +}}}}nodename = null; +distance = DefDistance; +bootstrap = DefBootstrap; +commentString2 = null; +parsednodename = false; +} +if (nextcp == 0) { +ncp = cp = fcp + 1; +} else { +cp = nextcp; +nextcp = 0; +}} +if (Error != null) { +throw ( new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.newfile", Clazz.newArray (-1, [Error.toString ()])))); +}if (this.root == null) { +throw ( new java.io.IOException (jalview.util.MessageManager.formatMessage ("exception.newfile", Clazz.newArray (-1, [jalview.util.MessageManager.getString ("label.no_tree_read_in")])))); +}this.root = this.root.right ().detach (); +if (!this.RootHasDistance) { +this.root.dist = (this.$HasDistances) ? 0 : DefDistance; +}}); +Clazz.defineMethod (c$, "parseNHXNodeProps", +($fz = function (c, commentString) { +if (commentString != null && commentString.startsWith ("&&NHX")) { +var st = new java.util.StringTokenizer (commentString.substring (5), ":"); +while (st.hasMoreTokens ()) { +var tok = st.nextToken (); +var colpos = tok.indexOf ("="); +if (colpos > -1) { +var code = tok.substring (0, colpos); +var value = tok.substring (colpos + 1); +try { +if (code.toLowerCase ().equals ("b")) { +var v = -1; +var iv = new Float (value); +v = iv.intValue (); +c.setBootstrap (v); +this.$HasBootstrap = true; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.err.println ("Couldn't parse code '" + code + "' = '" + value + "'"); +e.printStackTrace (System.err); +} else { +throw e; +} +} +}} +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode,~S"); +Clazz.defineMethod (c$, "getTree", +function () { +return this.root; +}); +Clazz.defineMethod (c$, "print", +function () { +{ +var tf = new StringBuffer (); +this.print (tf, this.root); +return (tf.append (";").toString ()); +}}); +Clazz.defineMethod (c$, "print", +function (withbootstraps) { +{ +var boots = this.$HasBootstrap; +this.$HasBootstrap = withbootstraps; +var rv = this.print (); +this.$HasBootstrap = boots; +return rv; +}}, "~B"); +Clazz.defineMethod (c$, "print", +function (withbootstraps, withdists) { +{ +var dists = this.$HasDistances; +this.$HasDistances = withdists; +var rv = this.print (withbootstraps); +this.$HasDistances = dists; +return rv; +}}, "~B,~B"); +Clazz.defineMethod (c$, "print", +function (withbootstraps, withdists, printRootInfo) { +{ +var rootinfo = printRootInfo; +this.printRootInfo = printRootInfo; +var rv = this.print (withbootstraps, withdists); +this.printRootInfo = rootinfo; +return rv; +}}, "~B,~B,~B"); +Clazz.defineMethod (c$, "getQuoteChar", +function () { +return this.QuoteChar; +}); +Clazz.defineMethod (c$, "setQuoteChar", +function (c) { +var old = this.QuoteChar; +this.QuoteChar = c; +return old; +}, "~S"); +Clazz.defineMethod (c$, "nodeName", +($fz = function (name) { +if (this.NodeSafeName[0].search (name)) { +return this.QuoteChar + this.NodeSafeName[1].replaceAll (name) + this.QuoteChar; +} else { +return this.NodeSafeName[2].replaceAll (name); +}}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "printNodeField", +($fz = function (c) { +return ((c.getName () == null) ? "" : this.nodeName (c.getName ())) + ((this.$HasBootstrap) ? ((c.getBootstrap () > -1) ? ((c.getName () != null ? " " : "") + c.getBootstrap ()) : "") : "") + ((this.$HasDistances) ? (":" + c.dist) : ""); +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "printRootField", +($fz = function (root) { +return (this.printRootInfo) ? (((root.getName () == null) ? "" : this.nodeName (root.getName ())) + ((this.$HasBootstrap) ? ((root.getBootstrap () > -1) ? ((root.getName () != null ? " " : "") + +root.getBootstrap ()) : "") : "") + ((this.RootHasDistance) ? (":" + root.dist) : "")) : ""; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "print", +function (tf, root) { +if (root != null) { +if (root.isLeaf () && this.printRootInfo) { +tf.append (this.printRootField (root)); +} else { +if (root.isDummy ()) { +this._print (tf, root.right ()); +this._print (tf, root.left ()); +} else { +tf.append ("("); +this._print (tf, root.right ()); +if (root.left () != null) { +tf.append (","); +}this._print (tf, root.left ()); +tf.append (")" + this.printRootField (root)); +}}}}, "StringBuffer,jalview.datamodel.SequenceNode"); +Clazz.defineMethod (c$, "_print", +function (tf, c) { +if (c != null) { +if (c.isLeaf ()) { +tf.append (this.printNodeField (c)); +} else { +if (c.isDummy ()) { +this._print (tf, c.left ()); +if (c.left () != null) { +tf.append (","); +}this._print (tf, c.right ()); +} else { +tf.append ("("); +this._print (tf, c.right ()); +if (c.left () != null) { +tf.append (","); +}this._print (tf, c.left ()); +tf.append (")" + this.printNodeField (c)); +}}}}, "StringBuffer,jalview.datamodel.SequenceNode"); +c$.main = Clazz.defineMethod (c$, "main", +function (args) { +try { +if (args == null || args.length != 1) { +System.err.println ("Takes one argument - file name of a newick tree file."); +System.exit (0); +}var fn = new java.io.File (args[0]); +var newickfile = new StringBuffer (); +var treefile = new java.io.BufferedReader ( new java.io.FileReader (fn)); +var l; +while ((l = treefile.readLine ()) != null) { +newickfile.append (l); +} +treefile.close (); +System.out.println ("Read file :\n"); +var trf = new jalview.io.NewickFile (args[0], "File"); +trf.parse (); +System.out.println ("Original file :\n"); +var nonl = jalview.jsdev.RegExp.newRegex (["\n+", ""]); +System.out.println (nonl.replaceAll (newickfile.toString ()) + "\n"); +System.out.println ("Parsed file.\n"); +System.out.println ("Default output type for original input.\n"); +System.out.println (trf.print ()); +System.out.println ("Without bootstraps.\n"); +System.out.println (trf.print (false)); +System.out.println ("Without distances.\n"); +System.out.println (trf.print (true, false)); +System.out.println ("Without bootstraps but with distanecs.\n"); +System.out.println (trf.print (false, true)); +System.out.println ("Without bootstraps or distanecs.\n"); +System.out.println (trf.print (false, false)); +System.out.println ("With bootstraps and with distances.\n"); +System.out.println (trf.print (true, true)); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +System.err.println ("Exception\n" + e); +e.printStackTrace (); +} else { +throw e; +} +} +}, "~A"); +}); diff --git a/bin/jalview/io/PIRFile.js b/bin/jalview/io/PIRFile.js index f14a6ea..fe50c34 100644 --- a/bin/jalview/io/PIRFile.js +++ b/bin/jalview/io/PIRFile.js @@ -1,101 +1,101 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile", "java.util.Vector"], "jalview.io.PIRFile", ["jalview.io.ModellerDescription", "jalview.util.Comparison", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.words = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "PIRFile", jalview.io.AlignFile); -Clazz.prepareFields (c$, function () { -this.words = new java.util.Vector (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.PIRFile, []); -}); -Clazz.overrideMethod (c$, "parse", -function () { -var sequence; -var line = null; -var md; -while ((line = this.nextLine ()) != null) { -if (line.length == 0) { -continue; -}if (line.indexOf ("C;") == 0 || line.indexOf ("#") == 0) { -continue; -}var newSeq = this.parseId (line.substring (line.indexOf (";") + 1)); -sequence = new StringBuffer (); -newSeq.setDescription (this.nextLine ()); -var starFound = false; -while (!starFound) { -line = this.nextLine (); -sequence.append (line); -if (line == null) { -break; -}if (line.indexOf ("*") > -1) { -starFound = true; -}} -if (sequence.length () > 0) { -sequence.setLength (sequence.length () - 1); -newSeq.setSequence (sequence.toString ()); -this.seqs.addElement (newSeq); -md = new jalview.io.ModellerDescription (newSeq.getDescription ()); -md.updateSequenceI (newSeq); -}} -}); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -Clazz.defineMethod (c$, "print", -function (s) { -var is_NA = jalview.util.Comparison.isNucleotide (s); -var len = 72; -var out = new StringBuffer (); -var i = 0; -var md; -while ((i < s.length) && (s[i] != null)) { -var seq = s[i].getSequenceAsString (); -seq = seq + "*"; -if (is_NA) { -out.append (">N1;" + s[i].getName ()); -out.append (this.newline); -if (s[i].getDescription () == null) { -out.append (s[i].getName () + " " + (s[i].getEnd () - s[i].getStart () + 1)); -out.append (is_NA ? " bases" : " residues"); -out.append (this.newline); -} else { -out.append (s[i].getDescription ()); -out.append (this.newline); -}} else { -if (jalview.io.PIRFile.useModellerOutput) { -out.append (">P1;" + s[i].getName ()); -out.append (this.newline); -md = new jalview.io.ModellerDescription (s[i]); -out.append (md.getDescriptionLine ()); -out.append (this.newline); -} else { -out.append (">P1;" + this.printId (s[i])); -out.append (this.newline); -if (s[i].getDescription () != null) { -out.append (s[i].getDescription ()); -out.append (this.newline); -} else { -out.append (s[i].getName () + " " + (s[i].getEnd () - s[i].getStart () + 1) + " residues"); -out.append (this.newline); -}}}var nochunks = (Clazz.doubleToInt (seq.length / len)) + 1; -for (var j = 0; j < nochunks; j++) { -var start = j * len; -var end = start + len; -if (end < seq.length) { -out.append (seq.substring (start, end)); -out.append (this.newline); -} else if (start < seq.length) { -out.append (seq.substring (start)); -out.append (this.newline); -}} -i++; -} -return out.toString (); -}, "~A"); -Clazz.defineStatics (c$, -"useModellerOutput", false); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile", "java.util.Vector"], "jalview.io.PIRFile", ["jalview.io.ModellerDescription", "jalview.util.Comparison", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.words = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "PIRFile", jalview.io.AlignFile); +Clazz.prepareFields (c$, function () { +this.words = new java.util.Vector (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.PIRFile, []); +}); +Clazz.overrideMethod (c$, "parse", +function () { +var sequence; +var line = null; +var md; +while ((line = this.nextLine ()) != null) { +if (line.length == 0) { +continue; +}if (line.indexOf ("C;") == 0 || line.indexOf ("#") == 0) { +continue; +}var newSeq = this.parseId (line.substring (line.indexOf (";") + 1)); +sequence = new StringBuffer (); +newSeq.setDescription (this.nextLine ()); +var starFound = false; +while (!starFound) { +line = this.nextLine (); +sequence.append (line); +if (line == null) { +break; +}if (line.indexOf ("*") > -1) { +starFound = true; +}} +if (sequence.length () > 0) { +sequence.setLength (sequence.length () - 1); +newSeq.setSequence (sequence.toString ()); +this.seqs.addElement (newSeq); +md = new jalview.io.ModellerDescription (newSeq.getDescription ()); +md.updateSequenceI (newSeq); +}} +}); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +Clazz.defineMethod (c$, "print", +function (s) { +var is_NA = jalview.util.Comparison.isNucleotide (s); +var len = 72; +var out = new StringBuffer (); +var i = 0; +var md; +while ((i < s.length) && (s[i] != null)) { +var seq = s[i].getSequenceAsString (); +seq = seq + "*"; +if (is_NA) { +out.append (">N1;" + s[i].getName ()); +out.append (this.newline); +if (s[i].getDescription () == null) { +out.append (s[i].getName () + " " + (s[i].getEnd () - s[i].getStart () + 1)); +out.append (is_NA ? " bases" : " residues"); +out.append (this.newline); +} else { +out.append (s[i].getDescription ()); +out.append (this.newline); +}} else { +if (jalview.io.PIRFile.useModellerOutput) { +out.append (">P1;" + s[i].getName ()); +out.append (this.newline); +md = new jalview.io.ModellerDescription (s[i]); +out.append (md.getDescriptionLine ()); +out.append (this.newline); +} else { +out.append (">P1;" + this.printId (s[i])); +out.append (this.newline); +if (s[i].getDescription () != null) { +out.append (s[i].getDescription ()); +out.append (this.newline); +} else { +out.append (s[i].getName () + " " + (s[i].getEnd () - s[i].getStart () + 1) + " residues"); +out.append (this.newline); +}}}var nochunks = (Clazz.doubleToInt (seq.length / len)) + 1; +for (var j = 0; j < nochunks; j++) { +var start = j * len; +var end = start + len; +if (end < seq.length) { +out.append (seq.substring (start, end)); +out.append (this.newline); +} else if (start < seq.length) { +out.append (seq.substring (start)); +out.append (this.newline); +}} +i++; +} +return out.toString (); +}, "~A"); +Clazz.defineStatics (c$, +"useModellerOutput", false); +}); diff --git a/bin/jalview/io/PfamFile.js b/bin/jalview/io/PfamFile.js index 47e9cc1..c094356 100644 --- a/bin/jalview/io/PfamFile.js +++ b/bin/jalview/io/PfamFile.js @@ -1,76 +1,76 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile"], "jalview.io.PfamFile", ["jalview.util.Format", "$.MessageManager", "java.io.IOException", "java.lang.StringBuffer", "java.util.Hashtable", "$.StringTokenizer", "$.Vector"], function () { -c$ = Clazz.declareType (jalview.io, "PfamFile", jalview.io.AlignFile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.PfamFile, []); -}); -Clazz.overrideMethod (c$, "parse", -function () { -var i = 0; -var line; -var seqhash = new java.util.Hashtable (); -var headers = new java.util.Vector (); -while ((line = this.nextLine ()) != null) { -if (line.indexOf (" ") != 0) { -if (line.indexOf ("#") != 0) { -var str = new java.util.StringTokenizer (line, " "); -var id = ""; -if (str.hasMoreTokens ()) { -id = str.nextToken (); -var tempseq; -if (seqhash.containsKey (id)) { -tempseq = seqhash.get (id); -} else { -tempseq = new StringBuffer (); -seqhash.put (id, tempseq); -}if (!(headers.contains (id))) { -headers.addElement (id); -}if (str.hasMoreTokens ()) { -tempseq.append (str.nextToken ()); -}}}}} -this.noSeqs = headers.size (); -if (this.noSeqs < 1) { -throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.pfam_no_sequences_found")); -}for (i = 0; i < headers.size (); i++) { -if (seqhash.get (headers.elementAt (i)) != null) { -if (this.maxLength < seqhash.get (headers.elementAt (i)).toString ().length) { -this.maxLength = seqhash.get (headers.elementAt (i)).toString ().length; -}var newSeq = this.parseId (headers.elementAt (i).toString ()); -newSeq.setSequence (seqhash.get (headers.elementAt (i).toString ()).toString ()); -this.seqs.addElement (newSeq); -} else { -System.err.println ("PFAM File reader: Can't find sequence for " + headers.elementAt (i)); -}} -}); -Clazz.defineMethod (c$, "print", -function (s) { -var out = new StringBuffer (""); -var max = 0; -var maxid = 0; -var i = 0; -while ((i < s.length) && (s[i] != null)) { -var tmp = this.printId (s[i]); -if (s[i].getSequence ().length > max) { -max = s[i].getSequence ().length; -}if (tmp.length > maxid) { -maxid = tmp.length; -}i++; -} -if (maxid < 15) { -maxid = 15; -}var j = 0; -while ((j < s.length) && (s[j] != null)) { -out.append ( new jalview.util.Format ("%-" + maxid + "s").form (this.printId (s[j]) + " ")); -out.append (s[j].getSequenceAsString ()); -out.append (this.newline); -j++; -} -out.append (this.newline); -return out.toString (); -}, "~A"); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile"], "jalview.io.PfamFile", ["jalview.util.Format", "$.MessageManager", "java.io.IOException", "java.lang.StringBuffer", "java.util.Hashtable", "$.StringTokenizer", "$.Vector"], function () { +c$ = Clazz.declareType (jalview.io, "PfamFile", jalview.io.AlignFile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.PfamFile, []); +}); +Clazz.overrideMethod (c$, "parse", +function () { +var i = 0; +var line; +var seqhash = new java.util.Hashtable (); +var headers = new java.util.Vector (); +while ((line = this.nextLine ()) != null) { +if (line.indexOf (" ") != 0) { +if (line.indexOf ("#") != 0) { +var str = new java.util.StringTokenizer (line, " "); +var id = ""; +if (str.hasMoreTokens ()) { +id = str.nextToken (); +var tempseq; +if (seqhash.containsKey (id)) { +tempseq = seqhash.get (id); +} else { +tempseq = new StringBuffer (); +seqhash.put (id, tempseq); +}if (!(headers.contains (id))) { +headers.addElement (id); +}if (str.hasMoreTokens ()) { +tempseq.append (str.nextToken ()); +}}}}} +this.noSeqs = headers.size (); +if (this.noSeqs < 1) { +throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.pfam_no_sequences_found")); +}for (i = 0; i < headers.size (); i++) { +if (seqhash.get (headers.elementAt (i)) != null) { +if (this.maxLength < seqhash.get (headers.elementAt (i)).toString ().length) { +this.maxLength = seqhash.get (headers.elementAt (i)).toString ().length; +}var newSeq = this.parseId (headers.elementAt (i).toString ()); +newSeq.setSequence (seqhash.get (headers.elementAt (i).toString ()).toString ()); +this.seqs.addElement (newSeq); +} else { +System.err.println ("PFAM File reader: Can't find sequence for " + headers.elementAt (i)); +}} +}); +Clazz.defineMethod (c$, "print", +function (s) { +var out = new StringBuffer (""); +var max = 0; +var maxid = 0; +var i = 0; +while ((i < s.length) && (s[i] != null)) { +var tmp = this.printId (s[i]); +if (s[i].getSequence ().length > max) { +max = s[i].getSequence ().length; +}if (tmp.length > maxid) { +maxid = tmp.length; +}i++; +} +if (maxid < 15) { +maxid = 15; +}var j = 0; +while ((j < s.length) && (s[j] != null)) { +out.append ( new jalview.util.Format ("%-" + maxid + "s").form (this.printId (s[j]) + " ")); +out.append (s[j].getSequenceAsString ()); +out.append (this.newline); +j++; +} +out.append (this.newline); +return out.toString (); +}, "~A"); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +}); diff --git a/bin/jalview/io/PhylipFile.js b/bin/jalview/io/PhylipFile.js index 0cd22ea..74e851f 100644 --- a/bin/jalview/io/PhylipFile.js +++ b/bin/jalview/io/PhylipFile.js @@ -1,103 +1,103 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile"], "jalview.io.PhylipFile", ["java.io.IOException", "java.lang.StringBuffer"], function () { -c$ = Clazz.declareType (jalview.io, "PhylipFile", jalview.io.AlignFile); -Clazz.overrideMethod (c$, "parse", -function () { -try { -var line = this.nextLine (); -var lineElements = line.trim ().$plit ("\\s+"); -if (lineElements.length < 2) { -throw new java.io.IOException ("First line must contain the number of specifies and number of characters"); -}var numberSpecies = Integer.parseInt (lineElements[0]); -var numberCharacters = Integer.parseInt (lineElements[1]); -if (numberSpecies <= 0) { -return; -}var sequenceElements = new Array (numberSpecies); -var sequences = new Array (numberSpecies); -for (var i = 0; i < numberSpecies; i++) { -line = this.nextLine (); -var potentialName = line.substring (0, 10); -var tabIndex = potentialName.indexOf ('\t'); -if (tabIndex == -1) { -sequenceElements[i] = this.parseId (this.validateName (potentialName)); -sequences[i] = new StringBuffer (this.removeWhitespace (line.substring (10))); -} else { -sequenceElements[i] = this.parseId (this.validateName (potentialName.substring (0, tabIndex))); -sequences[i] = new StringBuffer (this.removeWhitespace (line.substring (tabIndex))); -}} -if ((sequences[0]).length () != numberCharacters) { -var i = 0; -for (line = this.nextLine (); line != null; line = this.nextLine ()) { -if (line.length > 0) { -sequences[i++].append (this.removeWhitespace (line)); -}if (i == sequences.length) { -i = 0; -}} -}for (var i = 0; i < numberSpecies; i++) { -if (sequences[i].length () != numberCharacters) { -throw new java.io.IOException (sequenceElements[i].getName () + " sequence is incorrect length - should be " + numberCharacters + " but is " + sequences[i].length ()); -}sequenceElements[i].setSequence (sequences[i].toString ()); -this.seqs.add (sequenceElements[i]); -} -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -System.err.println ("Exception parsing PHYLIP file " + e); -e.printStackTrace (System.err); -throw e; -} else { -throw e; -} -} -}); -Clazz.defineMethod (c$, "removeWhitespace", -($fz = function (txt) { -return txt.replaceAll ("\\s*", ""); -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "validateName", -($fz = function (name) { -var invalidCharacters = Clazz.newCharArray (-1, ['(', ')', '[', ']', ':', ';', ',']); -for (var c, $c = 0, $$c = invalidCharacters; $c < $$c.length && ((c = $$c[$c]) || true); $c++) { -if (name.indexOf (c) > -1) { -throw new java.io.IOException ("Species name contains illegal character " + c); -}} -return name; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.overrideMethod (c$, "print", -function () { -var sb = new StringBuffer (Integer.toString (this.seqs.size ())); -sb.append (" "); -sb.append ((this.seqs.size () > 0) ? Integer.toString (this.seqs.get (0).getSequence ().length) : "0").append (this.newline); -var sequential = false; -var numInterleavedColumns = 60; -var sequenceLength = 0; -for (var s, $s = this.seqs.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { -var name = s.getName (); -if (name.length > 10) { -name = name.substring (0, 10); -} else { -name = String.format ("%1$-10s", [s.getName ()]); -}sb.append (name); -if (sequential) { -sb.append (s.getSequence ()); -} else { -sequenceLength = s.getSequence ().length; -sb.append (s.getSequence (0, Math.min (numInterleavedColumns, sequenceLength))); -}sb.append (this.newline); -} -if (!sequential && sequenceLength > numInterleavedColumns) { -var numMatrics = Clazz.doubleToInt (sequenceLength / numInterleavedColumns); -if ((sequenceLength % numInterleavedColumns) > 0) { -numMatrics++; -}for (var i = 1; i < numMatrics; i++) { -sb.append (this.newline); -var start = i * numInterleavedColumns; -for (var s, $s = this.seqs.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { -sb.append (s.getSequence (start, Math.min (start + numInterleavedColumns, sequenceLength))).append (this.newline); -} -} -}return sb.toString (); -}); -Clazz.defineStatics (c$, -"FILE_EXT", "phy", -"FILE_DESC", "PHYLIP"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile"], "jalview.io.PhylipFile", ["java.io.IOException", "java.lang.StringBuffer"], function () { +c$ = Clazz.declareType (jalview.io, "PhylipFile", jalview.io.AlignFile); +Clazz.overrideMethod (c$, "parse", +function () { +try { +var line = this.nextLine (); +var lineElements = line.trim ().$plit ("\\s+"); +if (lineElements.length < 2) { +throw new java.io.IOException ("First line must contain the number of specifies and number of characters"); +}var numberSpecies = Integer.parseInt (lineElements[0]); +var numberCharacters = Integer.parseInt (lineElements[1]); +if (numberSpecies <= 0) { +return; +}var sequenceElements = new Array (numberSpecies); +var sequences = new Array (numberSpecies); +for (var i = 0; i < numberSpecies; i++) { +line = this.nextLine (); +var potentialName = line.substring (0, 10); +var tabIndex = potentialName.indexOf ('\t'); +if (tabIndex == -1) { +sequenceElements[i] = this.parseId (this.validateName (potentialName)); +sequences[i] = new StringBuffer (this.removeWhitespace (line.substring (10))); +} else { +sequenceElements[i] = this.parseId (this.validateName (potentialName.substring (0, tabIndex))); +sequences[i] = new StringBuffer (this.removeWhitespace (line.substring (tabIndex))); +}} +if ((sequences[0]).length () != numberCharacters) { +var i = 0; +for (line = this.nextLine (); line != null; line = this.nextLine ()) { +if (line.length > 0) { +sequences[i++].append (this.removeWhitespace (line)); +}if (i == sequences.length) { +i = 0; +}} +}for (var i = 0; i < numberSpecies; i++) { +if (sequences[i].length () != numberCharacters) { +throw new java.io.IOException (sequenceElements[i].getName () + " sequence is incorrect length - should be " + numberCharacters + " but is " + sequences[i].length ()); +}sequenceElements[i].setSequence (sequences[i].toString ()); +this.seqs.add (sequenceElements[i]); +} +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +System.err.println ("Exception parsing PHYLIP file " + e); +e.printStackTrace (System.err); +throw e; +} else { +throw e; +} +} +}); +Clazz.defineMethod (c$, "removeWhitespace", +($fz = function (txt) { +return txt.replaceAll ("\\s*", ""); +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "validateName", +($fz = function (name) { +var invalidCharacters = Clazz.newCharArray (-1, ['(', ')', '[', ']', ':', ';', ',']); +for (var c, $c = 0, $$c = invalidCharacters; $c < $$c.length && ((c = $$c[$c]) || true); $c++) { +if (name.indexOf (c) > -1) { +throw new java.io.IOException ("Species name contains illegal character " + c); +}} +return name; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.overrideMethod (c$, "print", +function () { +var sb = new StringBuffer (Integer.toString (this.seqs.size ())); +sb.append (" "); +sb.append ((this.seqs.size () > 0) ? Integer.toString (this.seqs.get (0).getSequence ().length) : "0").append (this.newline); +var sequential = false; +var numInterleavedColumns = 60; +var sequenceLength = 0; +for (var s, $s = this.seqs.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { +var name = s.getName (); +if (name.length > 10) { +name = name.substring (0, 10); +} else { +name = String.format ("%1$-10s", [s.getName ()]); +}sb.append (name); +if (sequential) { +sb.append (s.getSequence ()); +} else { +sequenceLength = s.getSequence ().length; +sb.append (s.getSequence (0, Math.min (numInterleavedColumns, sequenceLength))); +}sb.append (this.newline); +} +if (!sequential && sequenceLength > numInterleavedColumns) { +var numMatrics = Clazz.doubleToInt (sequenceLength / numInterleavedColumns); +if ((sequenceLength % numInterleavedColumns) > 0) { +numMatrics++; +}for (var i = 1; i < numMatrics; i++) { +sb.append (this.newline); +var start = i * numInterleavedColumns; +for (var s, $s = this.seqs.iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { +sb.append (s.getSequence (start, Math.min (start + numInterleavedColumns, sequenceLength))).append (this.newline); +} +} +}return sb.toString (); +}); +Clazz.defineStatics (c$, +"FILE_EXT", "phy", +"FILE_DESC", "PHYLIP"); +}); diff --git a/bin/jalview/io/PileUpfile.js b/bin/jalview/io/PileUpfile.js index a6effa1..b8bb68c 100644 --- a/bin/jalview/io/PileUpfile.js +++ b/bin/jalview/io/PileUpfile.js @@ -1,82 +1,82 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.MSFfile"], "jalview.io.PileUpfile", ["jalview.util.Format", "java.lang.StringBuffer"], function () { -c$ = Clazz.declareType (jalview.io, "PileUpfile", jalview.io.MSFfile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.PileUpfile, []); -}); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -Clazz.defineMethod (c$, "print", -function (s) { -var out = new StringBuffer ("PileUp"); -out.append (this.newline); -out.append (this.newline); -var max = 0; -var maxid = 0; -var i = 0; -var bigChecksum = 0; -var checksums = Clazz.newIntArray (s.length, 0); -while (i < s.length) { -checksums[i] = this.checkSum (s[i].getSequenceAsString ()); -bigChecksum += checksums[i]; -i++; -} -out.append (" MSF: " + s[0].getSequence ().length + " Type: P Check: " + bigChecksum % 10000 + " .."); -out.append (this.newline); -out.append (this.newline); -out.append (this.newline); -i = 0; -while ((i < s.length) && (s[i] != null)) { -var seq = s[i].getSequenceAsString (); -out.append (" Name: " + this.printId (s[i]) + " oo Len: " + seq.length + " Check: " + checksums[i] + " Weight: 1.00"); -out.append (this.newline); -if (seq.length > max) { -max = seq.length; -}if (s[i].getName ().length > maxid) { -maxid = s[i].getName ().length; -}i++; -} -if (maxid < 10) { -maxid = 10; -}maxid++; -out.append (this.newline); -out.append (this.newline); -out.append ("//"); -out.append (this.newline); -out.append (this.newline); -var len = 50; -var nochunks = (Clazz.doubleToInt (max / len)) + 1; -if ((max % len) == 0) { -nochunks--; -}for (i = 0; i < nochunks; i++) { -var j = 0; -while ((j < s.length) && (s[j] != null)) { -var name = this.printId (s[j]); -out.append ( new jalview.util.Format ("%-" + maxid + "s").form (name + " ")); -for (var k = 0; k < 5; k++) { -var start = (i * 50) + (k * 10); -var end = start + 10; -if ((end < s[j].getSequence ().length) && (start < s[j].getSequence ().length)) { -out.append (s[j].getSequence (start, end)); -if (k < 4) { -out.append (" "); -} else { -out.append (this.newline); -}} else { -if (start < s[j].getSequence ().length) { -out.append (s[j].getSequenceAsString ().substring (start)); -out.append (this.newline); -} else { -if (k == 0) { -out.append (this.newline); -}}}} -j++; -} -out.append (this.newline); -} -return out.toString (); -}, "~A"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.MSFfile"], "jalview.io.PileUpfile", ["jalview.util.Format", "java.lang.StringBuffer"], function () { +c$ = Clazz.declareType (jalview.io, "PileUpfile", jalview.io.MSFfile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.PileUpfile, []); +}); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +Clazz.defineMethod (c$, "print", +function (s) { +var out = new StringBuffer ("PileUp"); +out.append (this.newline); +out.append (this.newline); +var max = 0; +var maxid = 0; +var i = 0; +var bigChecksum = 0; +var checksums = Clazz.newIntArray (s.length, 0); +while (i < s.length) { +checksums[i] = this.checkSum (s[i].getSequenceAsString ()); +bigChecksum += checksums[i]; +i++; +} +out.append (" MSF: " + s[0].getSequence ().length + " Type: P Check: " + bigChecksum % 10000 + " .."); +out.append (this.newline); +out.append (this.newline); +out.append (this.newline); +i = 0; +while ((i < s.length) && (s[i] != null)) { +var seq = s[i].getSequenceAsString (); +out.append (" Name: " + this.printId (s[i]) + " oo Len: " + seq.length + " Check: " + checksums[i] + " Weight: 1.00"); +out.append (this.newline); +if (seq.length > max) { +max = seq.length; +}if (s[i].getName ().length > maxid) { +maxid = s[i].getName ().length; +}i++; +} +if (maxid < 10) { +maxid = 10; +}maxid++; +out.append (this.newline); +out.append (this.newline); +out.append ("//"); +out.append (this.newline); +out.append (this.newline); +var len = 50; +var nochunks = (Clazz.doubleToInt (max / len)) + 1; +if ((max % len) == 0) { +nochunks--; +}for (i = 0; i < nochunks; i++) { +var j = 0; +while ((j < s.length) && (s[j] != null)) { +var name = this.printId (s[j]); +out.append ( new jalview.util.Format ("%-" + maxid + "s").form (name + " ")); +for (var k = 0; k < 5; k++) { +var start = (i * 50) + (k * 10); +var end = start + 10; +if ((end < s[j].getSequence ().length) && (start < s[j].getSequence ().length)) { +out.append (s[j].getSequence (start, end)); +if (k < 4) { +out.append (" "); +} else { +out.append (this.newline); +}} else { +if (start < s[j].getSequence ().length) { +out.append (s[j].getSequenceAsString ().substring (start)); +out.append (this.newline); +} else { +if (k == 0) { +out.append (this.newline); +}}}} +j++; +} +out.append (this.newline); +} +return out.toString (); +}, "~A"); +}); diff --git a/bin/jalview/io/SequenceAnnotationReport.js b/bin/jalview/io/SequenceAnnotationReport.js index 889211b..15fa2dd 100644 --- a/bin/jalview/io/SequenceAnnotationReport.js +++ b/bin/jalview/io/SequenceAnnotationReport.js @@ -1,181 +1,181 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.SequenceAnnotationReport", ["jalview.util.DBRefUtils", "$.UrlLink", "java.lang.Float", "java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.linkImageURL = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "SequenceAnnotationReport"); -Clazz.makeConstructor (c$, -function (linkImageURL) { -this.linkImageURL = linkImageURL; -}, "~S"); -Clazz.defineMethod (c$, "appendFeatures", -function (tooltipText2, rpos, features) { -this.appendFeatures (tooltipText2, rpos, features, null); -}, "StringBuffer,~N,java.util.List"); -Clazz.defineMethod (c$, "appendFeatures", -function (tooltipText2, rpos, features, minmax) { -var tmpString; -if (features != null) { -for (var feature, $feature = features.iterator (); $feature.hasNext () && ((feature = $feature.next ()) || true);) { -if (feature.getType ().equals ("disulfide bond")) { -if (feature.getBegin () == rpos || feature.getEnd () == rpos) { -if (tooltipText2.length () > 6) { -tooltipText2.append ("
"); -}tooltipText2.append ("disulfide bond " + feature.getBegin () + ":" + feature.getEnd ()); -}} else { -if (tooltipText2.length () > 6) { -tooltipText2.append ("
"); -}var linkOnly = feature.getValue ("linkonly") != null; -if (!linkOnly) { -tooltipText2.append (feature.getType () + " "); -if (rpos != 0) { -tooltipText2.append ("" + feature.begin); -}if (feature.begin != feature.end) { -tooltipText2.append (" " + feature.end); -}if (feature.getDescription () != null && !feature.description.equals (feature.getType ())) { -tmpString = feature.getDescription (); -var tmp2up = tmpString.toUpperCase (); -var startTag = tmp2up.indexOf (""); -if (startTag > -1) { -tmpString = tmpString.substring (startTag + 6); -tmp2up = tmp2up.substring (startTag + 6); -}var endTag = tmp2up.indexOf (""); -if (endTag > -1) { -tmpString = tmpString.substring (0, endTag); -tmp2up = tmp2up.substring (0, endTag); -}endTag = tmp2up.indexOf (""); -if (endTag > -1) { -tmpString = tmpString.substring (0, endTag); -}if (startTag > -1) { -tooltipText2.append ("; " + tmpString); -} else { -if (tmpString.indexOf ("<") > -1 || tmpString.indexOf (">") > -1) { -tmpString = tmpString.replaceAll ("<", "<"); -tmpString = tmpString.replaceAll (">", ">"); -tooltipText2.append ("; "); -tooltipText2.append (tmpString); -} else { -tooltipText2.append ("; " + tmpString); -}}}if (!Float.isNaN (feature.getScore ())) { -var rng = (minmax == null) ? null : (minmax.get (feature.getType ())); -if (rng != null && rng[0] != null && rng[0][0] != rng[0][1]) { -tooltipText2.append (" Score=" + feature.getScore ()); -}}if (feature.getValue ("status") != null) { -var status = feature.getValue ("status").toString (); -if (status.length > 0) { -tooltipText2.append ("; (" + feature.getValue ("status") + ")"); -}}}}if (feature.links != null) { -if (this.linkImageURL != null) { -tooltipText2.append (" "); -} else { -for (var urlstring, $urlstring = feature.links.iterator (); $urlstring.hasNext () && ((urlstring = $urlstring.next ()) || true);) { -try { -for (var urllink, $urllink = 0, $$urllink = this.createLinksFrom (null, urlstring); $urllink < $$urllink.length && ((urllink = $$urllink[$urllink]) || true); $urllink++) { -tooltipText2.append ("
" + (urllink[0].toLowerCase ().equals (urllink[1].toLowerCase ()) ? urllink[0] : (urllink[0] + ":" + urllink[1])) + "
"); -} -} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -System.err.println ("problem when creating links from " + urlstring); -x.printStackTrace (); -} else { -throw x; -} -} -} -}}} -}}, "StringBuffer,~N,java.util.List,java.util.Hashtable"); -Clazz.defineMethod (c$, "createLinksFrom", -function (seq, link) { -var urlSets = new java.util.ArrayList (); -var uniques = new java.util.ArrayList (); -var urlLink = new jalview.util.UrlLink (link); -if (!urlLink.isValid ()) { -System.err.println (urlLink.getInvalidMessage ()); -return null; -}var target = urlLink.getTarget (); -var label = urlLink.getLabel (); -if (seq != null && urlLink.isDynamic ()) { -var dbr = jalview.util.DBRefUtils.selectRefs (seq.getDBRef (), Clazz.newArray (-1, [target])); -var id = seq.getName (); -var descr = seq.getDescription (); -if (descr != null && descr.length < 1) { -descr = null; -}if (dbr != null) { -for (var r = 0; r < dbr.length; r++) { -if (id != null && dbr[r].getAccessionId ().equals (id)) { -id = null; -}var urls = urlLink.makeUrls (dbr[r].getAccessionId (), true); -if (urls != null) { -for (var u = 0; u < urls.length; u += 2) { -var unq = urls[u] + "|" + urls[u + 1]; -if (!uniques.contains (unq)) { -urlSets.add ( Clazz.newArray (-1, [target, label, urls[u], urls[u + 1]])); -uniques.add (unq); -}} -}} -}if (id != null) { -var urls = urlLink.makeUrls (id, true); -if (urls != null) { -for (var u = 0; u < urls.length; u += 2) { -var unq = urls[u] + "|" + urls[u + 1]; -if (!uniques.contains (unq)) { -urlSets.add ( Clazz.newArray (-1, [target, label, urls[u], urls[u + 1]])); -uniques.add (unq); -}} -}}if (descr != null && urlLink.getRegexReplace () != null) { -var urls = urlLink.makeUrls (descr, true); -if (urls != null) { -for (var u = 0; u < urls.length; u += 2) { -var unq = urls[u] + "|" + urls[u + 1]; -if (!uniques.contains (unq)) { -urlSets.add ( Clazz.newArray (-1, [target, label, urls[u], urls[u + 1]])); -uniques.add (unq); -}} -}}} else { -var unq = label + "|" + urlLink.getUrl_prefix (); -if (!uniques.contains (unq)) { -uniques.add (unq); -urlSets.add ( Clazz.newArray (-1, [target, label, null, urlLink.getUrl_prefix ()])); -}}return urlSets.toArray ( Clazz.newArray (-1, [])); -}, "jalview.datamodel.SequenceI,~S"); -Clazz.defineMethod (c$, "createSequenceAnnotationReport", -function (tip, sequence, showDbRefs, showNpFeats, minmax) { -this.createSequenceAnnotationReport (tip, sequence, showDbRefs, showNpFeats, true, minmax); -}, "StringBuffer,jalview.datamodel.SequenceI,~B,~B,java.util.Hashtable"); -Clazz.defineMethod (c$, "createSequenceAnnotationReport", -function (tip, sequence, showDbRefs, showNpFeats, tableWrap, minmax) { -var tmp; -tip.append (""); -var maxWidth = 0; -if (sequence.getDescription () != null) { -tmp = sequence.getDescription (); -tip.append ("
" + tmp); -maxWidth = Math.max (maxWidth, tmp.length); -}var ds = sequence; -while (ds.getDatasetSequence () != null) { -ds = ds.getDatasetSequence (); -} -var dbrefs = ds.getDBRef (); -if (showDbRefs && dbrefs != null) { -for (var i = 0; i < dbrefs.length; i++) { -tip.append ("
"); -tmp = dbrefs[i].getSource () + " " + dbrefs[i].getAccessionId (); -tip.append (tmp); -maxWidth = Math.max (maxWidth, tmp.length); -} -}var features = sequence.getSequenceFeatures (); -if (showNpFeats && features != null) { -for (var i = 0; i < features.length; i++) { -if (features[i].begin == 0 && features[i].end == 0) { -var sz = -tip.length (); -var tfeat = new java.util.ArrayList (); -tfeat.add (features[i]); -this.appendFeatures (tip, 0, tfeat, minmax); -sz += tip.length (); -maxWidth = Math.max (maxWidth, sz); -}} -}if (tableWrap && maxWidth > 60) { -tip.insert (0, "
"); -tip.append ("
"); -}}, "StringBuffer,jalview.datamodel.SequenceI,~B,~B,~B,java.util.Hashtable"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.SequenceAnnotationReport", ["jalview.util.DBRefUtils", "$.UrlLink", "java.lang.Float", "java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.linkImageURL = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "SequenceAnnotationReport"); +Clazz.makeConstructor (c$, +function (linkImageURL) { +this.linkImageURL = linkImageURL; +}, "~S"); +Clazz.defineMethod (c$, "appendFeatures", +function (tooltipText2, rpos, features) { +this.appendFeatures (tooltipText2, rpos, features, null); +}, "StringBuffer,~N,java.util.List"); +Clazz.defineMethod (c$, "appendFeatures", +function (tooltipText2, rpos, features, minmax) { +var tmpString; +if (features != null) { +for (var feature, $feature = features.iterator (); $feature.hasNext () && ((feature = $feature.next ()) || true);) { +if (feature.getType ().equals ("disulfide bond")) { +if (feature.getBegin () == rpos || feature.getEnd () == rpos) { +if (tooltipText2.length () > 6) { +tooltipText2.append ("
"); +}tooltipText2.append ("disulfide bond " + feature.getBegin () + ":" + feature.getEnd ()); +}} else { +if (tooltipText2.length () > 6) { +tooltipText2.append ("
"); +}var linkOnly = feature.getValue ("linkonly") != null; +if (!linkOnly) { +tooltipText2.append (feature.getType () + " "); +if (rpos != 0) { +tooltipText2.append ("" + feature.begin); +}if (feature.begin != feature.end) { +tooltipText2.append (" " + feature.end); +}if (feature.getDescription () != null && !feature.description.equals (feature.getType ())) { +tmpString = feature.getDescription (); +var tmp2up = tmpString.toUpperCase (); +var startTag = tmp2up.indexOf (""); +if (startTag > -1) { +tmpString = tmpString.substring (startTag + 6); +tmp2up = tmp2up.substring (startTag + 6); +}var endTag = tmp2up.indexOf (""); +if (endTag > -1) { +tmpString = tmpString.substring (0, endTag); +tmp2up = tmp2up.substring (0, endTag); +}endTag = tmp2up.indexOf (""); +if (endTag > -1) { +tmpString = tmpString.substring (0, endTag); +}if (startTag > -1) { +tooltipText2.append ("; " + tmpString); +} else { +if (tmpString.indexOf ("<") > -1 || tmpString.indexOf (">") > -1) { +tmpString = tmpString.replaceAll ("<", "<"); +tmpString = tmpString.replaceAll (">", ">"); +tooltipText2.append ("; "); +tooltipText2.append (tmpString); +} else { +tooltipText2.append ("; " + tmpString); +}}}if (!Float.isNaN (feature.getScore ())) { +var rng = (minmax == null) ? null : (minmax.get (feature.getType ())); +if (rng != null && rng[0] != null && rng[0][0] != rng[0][1]) { +tooltipText2.append (" Score=" + feature.getScore ()); +}}if (feature.getValue ("status") != null) { +var status = feature.getValue ("status").toString (); +if (status.length > 0) { +tooltipText2.append ("; (" + feature.getValue ("status") + ")"); +}}}}if (feature.links != null) { +if (this.linkImageURL != null) { +tooltipText2.append (" "); +} else { +for (var urlstring, $urlstring = feature.links.iterator (); $urlstring.hasNext () && ((urlstring = $urlstring.next ()) || true);) { +try { +for (var urllink, $urllink = 0, $$urllink = this.createLinksFrom (null, urlstring); $urllink < $$urllink.length && ((urllink = $$urllink[$urllink]) || true); $urllink++) { +tooltipText2.append ("
" + (urllink[0].toLowerCase ().equals (urllink[1].toLowerCase ()) ? urllink[0] : (urllink[0] + ":" + urllink[1])) + "
"); +} +} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +System.err.println ("problem when creating links from " + urlstring); +x.printStackTrace (); +} else { +throw x; +} +} +} +}}} +}}, "StringBuffer,~N,java.util.List,java.util.Hashtable"); +Clazz.defineMethod (c$, "createLinksFrom", +function (seq, link) { +var urlSets = new java.util.ArrayList (); +var uniques = new java.util.ArrayList (); +var urlLink = new jalview.util.UrlLink (link); +if (!urlLink.isValid ()) { +System.err.println (urlLink.getInvalidMessage ()); +return null; +}var target = urlLink.getTarget (); +var label = urlLink.getLabel (); +if (seq != null && urlLink.isDynamic ()) { +var dbr = jalview.util.DBRefUtils.selectRefs (seq.getDBRef (), Clazz.newArray (-1, [target])); +var id = seq.getName (); +var descr = seq.getDescription (); +if (descr != null && descr.length < 1) { +descr = null; +}if (dbr != null) { +for (var r = 0; r < dbr.length; r++) { +if (id != null && dbr[r].getAccessionId ().equals (id)) { +id = null; +}var urls = urlLink.makeUrls (dbr[r].getAccessionId (), true); +if (urls != null) { +for (var u = 0; u < urls.length; u += 2) { +var unq = urls[u] + "|" + urls[u + 1]; +if (!uniques.contains (unq)) { +urlSets.add ( Clazz.newArray (-1, [target, label, urls[u], urls[u + 1]])); +uniques.add (unq); +}} +}} +}if (id != null) { +var urls = urlLink.makeUrls (id, true); +if (urls != null) { +for (var u = 0; u < urls.length; u += 2) { +var unq = urls[u] + "|" + urls[u + 1]; +if (!uniques.contains (unq)) { +urlSets.add ( Clazz.newArray (-1, [target, label, urls[u], urls[u + 1]])); +uniques.add (unq); +}} +}}if (descr != null && urlLink.getRegexReplace () != null) { +var urls = urlLink.makeUrls (descr, true); +if (urls != null) { +for (var u = 0; u < urls.length; u += 2) { +var unq = urls[u] + "|" + urls[u + 1]; +if (!uniques.contains (unq)) { +urlSets.add ( Clazz.newArray (-1, [target, label, urls[u], urls[u + 1]])); +uniques.add (unq); +}} +}}} else { +var unq = label + "|" + urlLink.getUrl_prefix (); +if (!uniques.contains (unq)) { +uniques.add (unq); +urlSets.add ( Clazz.newArray (-1, [target, label, null, urlLink.getUrl_prefix ()])); +}}return urlSets.toArray ( Clazz.newArray (-1, [])); +}, "jalview.datamodel.SequenceI,~S"); +Clazz.defineMethod (c$, "createSequenceAnnotationReport", +function (tip, sequence, showDbRefs, showNpFeats, minmax) { +this.createSequenceAnnotationReport (tip, sequence, showDbRefs, showNpFeats, true, minmax); +}, "StringBuffer,jalview.datamodel.SequenceI,~B,~B,java.util.Hashtable"); +Clazz.defineMethod (c$, "createSequenceAnnotationReport", +function (tip, sequence, showDbRefs, showNpFeats, tableWrap, minmax) { +var tmp; +tip.append (""); +var maxWidth = 0; +if (sequence.getDescription () != null) { +tmp = sequence.getDescription (); +tip.append ("
" + tmp); +maxWidth = Math.max (maxWidth, tmp.length); +}var ds = sequence; +while (ds.getDatasetSequence () != null) { +ds = ds.getDatasetSequence (); +} +var dbrefs = ds.getDBRef (); +if (showDbRefs && dbrefs != null) { +for (var i = 0; i < dbrefs.length; i++) { +tip.append ("
"); +tmp = dbrefs[i].getSource () + " " + dbrefs[i].getAccessionId (); +tip.append (tmp); +maxWidth = Math.max (maxWidth, tmp.length); +} +}var features = sequence.getSequenceFeatures (); +if (showNpFeats && features != null) { +for (var i = 0; i < features.length; i++) { +if (features[i].begin == 0 && features[i].end == 0) { +var sz = -tip.length (); +var tfeat = new java.util.ArrayList (); +tfeat.add (features[i]); +this.appendFeatures (tip, 0, tfeat, minmax); +sz += tip.length (); +maxWidth = Math.max (maxWidth, sz); +}} +}if (tableWrap && maxWidth > 60) { +tip.insert (0, "
"); +tip.append ("
"); +}}, "StringBuffer,jalview.datamodel.SequenceI,~B,~B,~B,java.util.Hashtable"); +}); diff --git a/bin/jalview/io/TCoffeeScoreFile.js b/bin/jalview/io/TCoffeeScoreFile.js index 7f2d629..1036432 100644 --- a/bin/jalview/io/TCoffeeScoreFile.js +++ b/bin/jalview/io/TCoffeeScoreFile.js @@ -1,274 +1,274 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile", "java.awt.Color", "java.util.LinkedHashMap", "java.util.regex.Pattern"], "jalview.io.TCoffeeScoreFile", ["jalview.analysis.SequenceIdMatcher", "jalview.datamodel.Annotation", "jalview.util.Comparison", "java.lang.StringBuilder", "java.util.ArrayList", "$.HashMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.header = null; -this.scores = null; -this.fWidth = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "TCoffeeScoreFile", jalview.io.AlignFile); -Clazz.defineMethod (c$, "getHeight", -function () { -return this.scores != null && this.scores.size () > 0 ? this.scores.size () - 1 : 0; -}); -Clazz.defineMethod (c$, "getWidth", -function () { -return this.fWidth != null ? this.fWidth : 0; -}); -Clazz.defineMethod (c$, "getScoresFor", -function (id) { -return this.scores != null && this.scores.containsKey (id) ? this.scores.get (id).toString () : ""; -}, "~S"); -Clazz.defineMethod (c$, "getScoresList", -function () { -if (this.scores == null) { -return null; -}var result = new java.util.ArrayList (this.scores.size ()); -for (var it, $it = this.scores.entrySet ().iterator (); $it.hasNext () && ((it = $it.next ()) || true);) { -result.add (it.getValue ().toString ()); -} -return result; -}); -Clazz.defineMethod (c$, "getScoresArray", -function () { -if (this.scores == null) { -return null; -}var result = Clazz.newByteArray (this.scores.size (), 0); -var rowCount = 0; -for (var it, $it = this.scores.entrySet ().iterator (); $it.hasNext () && ((it = $it.next ()) || true);) { -var line = it.getValue ().toString (); -var seqValues = Clazz.newByteArray (line.length, 0); -for (var j = 0, c = line.length; j < c; j++) { -var val = (line.charCodeAt (j) - 48); -seqValues[j] = (val >= 0 && val <= 9) ? val : -1; -} -result[rowCount++] = seqValues; -} -return result; -}); -Clazz.overrideMethod (c$, "parse", -function () { -this.header = jalview.io.TCoffeeScoreFile.readHeader (this); -if (this.header == null) { -this.error = true; -return; -}this.scores = new java.util.LinkedHashMap (); -for (var entry, $entry = this.header.scores.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) { -this.scores.put (entry.getKey (), new StringBuilder ()); -} -var block; -while ((block = jalview.io.TCoffeeScoreFile.readBlock (this, this.header.scores.size ())) != null) { -for (var entry, $entry = block.items.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) { -var scoreStringBuilder = this.scores.get (entry.getKey ()); -if (scoreStringBuilder == null) { -this.error = true; -this.errormessage = String.format ("Invalid T-Coffee score file: Sequence ID '%s' is not declared in header section", [entry.getKey ()]); -return; -}scoreStringBuilder.append (entry.getValue ()); -} -} -for (var str, $str = this.scores.values ().iterator (); $str.hasNext () && ((str = $str.next ()) || true);) { -if (this.fWidth == null) { -this.fWidth = new Integer (str.length ()); -} else if ((this.fWidth).intValue () !== str.length ()) { -this.error = true; -this.errormessage = "Invalid T-Coffee score file: All the score sequences must have the same length"; -return; -}} -return; -}); -c$.parseInt = Clazz.defineMethod (c$, "parseInt", -function (str) { -try { -return Integer.parseInt (str); -} catch (e) { -if (Clazz.exceptionOf (e, NumberFormatException)) { -return 0; -} else { -throw e; -} -} -}, "~S"); -c$.readHeader = Clazz.defineMethod (c$, "readHeader", -function (reader) { -var result = null; -try { -result = new jalview.io.TCoffeeScoreFile.Header (); -result.head = reader.nextLine (); -var line; -while ((line = reader.nextLine ()) != null) { -if (line.startsWith ("SCORE=")) { -result.score = jalview.io.TCoffeeScoreFile.parseInt (line.substring (6).trim ()); -break; -}} -if ((line = reader.nextLine ()) == null || !"*".equals (line.trim ())) { -jalview.io.TCoffeeScoreFile.error (reader, "Invalid T-COFFEE score format (NO BAD/AVG/GOOD header)"); -return null; -}if ((line = reader.nextLine ()) == null || !"BAD AVG GOOD".equals (line.trim ())) { -jalview.io.TCoffeeScoreFile.error (reader, "Invalid T-COFFEE score format (NO BAD/AVG/GOOD header)"); -return null; -}if ((line = reader.nextLine ()) == null || !"*".equals (line.trim ())) { -jalview.io.TCoffeeScoreFile.error (reader, "Invalid T-COFFEE score format (NO BAD/AVG/GOOD header)"); -return null; -}while ((line = reader.nextLine ()) != null) { -if ("".equals (line)) { -break; -}var p = line.indexOf (":"); -if (p == -1) { -continue; -}var id = line.substring (0, p).trim (); -var val = jalview.io.TCoffeeScoreFile.parseInt (line.substring (p + 1).trim ()); -if ("".equals (id)) { -continue; -}result.scores.put (id, new Integer (val)); -} -if (result == null) { -jalview.io.TCoffeeScoreFile.error (reader, "T-COFFEE score file had no per-sequence scores"); -}} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -jalview.io.TCoffeeScoreFile.error (reader, "Unexpected problem parsing T-Coffee score ascii file"); -throw e; -} else { -throw e; -} -} -return result; -}, "jalview.io.FileParse"); -c$.error = Clazz.defineMethod (c$, "error", -($fz = function (reader, errm) { -reader.error = true; -if (reader.errormessage == null) { -reader.errormessage = errm; -} else { -reader.errormessage += "\n" + errm; -}}, $fz.isPrivate = true, $fz), "jalview.io.FileParse,~S"); -c$.readBlock = Clazz.defineMethod (c$, "readBlock", -function (reader, size) { -var result = new jalview.io.TCoffeeScoreFile.Block (size); -var line; -while ((line = reader.nextLine ()) != null && "".equals (line.trim ())) { -} -if (line == null) { -return null; -}do { -if ("".equals (line.trim ())) { -break; -}var p = line.indexOf (" "); -if (p == -1) { -if (reader.warningMessage == null) { -reader.warningMessage = ""; -}reader.warningMessage += "Possible parsing error - expected to find a space in line: '" + line + "'\n"; -continue; -}var id = line.substring (0, p).trim (); -var val = line.substring (p + 1).trim (); -var m = jalview.io.TCoffeeScoreFile.SCORES_WITH_RESIDUE_NUMS.matcher (val); -if (m.matches ()) { -val = m.group (1); -}result.items.put (id, val); -} while ((line = reader.nextLine ()) != null); -return result; -}, "jalview.io.FileParse,~N"); -Clazz.defineMethod (c$, "annotateAlignment", -function (al, matchids) { -if (al.getHeight () != this.getHeight () || al.getWidth () != this.getWidth ()) { -var info = String.format ("align w: %s, h: %s; score: w: %s; h: %s ", [new Integer (al.getWidth ()), new Integer (al.getHeight ()), new Integer (this.getWidth ()), new Integer (this.getHeight ())]); -this.warningMessage = "Alignment shape does not match T-Coffee score file shape -- " + info; -return false; -}var added = false; -var i = 0; -var sidmatcher = new jalview.analysis.SequenceIdMatcher (al.getSequencesArray ()); -var scoreMatrix = this.getScoresArray (); -for (var id, $id = this.scores.entrySet ().iterator (); $id.hasNext () && ((id = $id.next ()) || true);) { -var srow = scoreMatrix[i]; -var s; -if (matchids) { -s = sidmatcher.findIdMatch (id.getKey ()); -} else { -s = al.getSequenceAt (i); -}i++; -if (s == null && i != this.scores.size () && !id.getKey ().equals ("cons")) { -System.err.println ("No " + (matchids ? "match " : " sequences left ") + " for TCoffee score set : " + id.getKey ()); -continue; -}var jSize = al.getWidth () < srow.length ? al.getWidth () : srow.length; -var annotations = new Array (al.getWidth ()); -for (var j = 0; j < jSize; j++) { -var val = srow[j]; -if (s != null && jalview.util.Comparison.isGap (s.getCharAt (j))) { -annotations[j] = null; -if (val > 0) { -System.err.println ("Warning: non-zero value for positional T-COFFEE score for gap at " + j + " in sequence " + s.getName ()); -}} else { -annotations[j] = new jalview.datamodel.Annotation (s == null ? "" + val : null, s == null ? "" + val : null, '\0', val * 1, val >= 0 && val < jalview.io.TCoffeeScoreFile.colors.length ? jalview.io.TCoffeeScoreFile.colors[val] : java.awt.Color.white); -}} -var aa = al.findOrCreateAnnotation ("TCoffeeScore", "TCoffeeScore", false, s, null); -if (s != null) { -aa.label = "T-COFFEE"; -aa.description = "" + id.getKey (); -aa.annotations = annotations; -aa.visible = false; -aa.belowAlignment = false; -aa.setScore (this.header.getScoreFor (id.getKey ())); -aa.createSequenceMapping (s, s.getStart (), true); -s.addAlignmentAnnotation (aa); -aa.adjustForAlignment (); -} else { -aa.graph = 0; -aa.label = "T-COFFEE"; -aa.description = "TCoffee column reliability score"; -aa.annotations = annotations; -aa.belowAlignment = true; -aa.visible = true; -aa.setScore (this.header.getScoreAvg ()); -}aa.showAllColLabels = true; -aa.validateRangeAndDisplay (); -added = true; -} -return added; -}, "jalview.datamodel.AlignmentI,~B"); -Clazz.overrideMethod (c$, "print", -function () { -return "Not valid."; -}); -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.head = null; -this.score = 0; -this.scores = null; -Clazz.instantialize (this, arguments); -}, jalview.io.TCoffeeScoreFile, "Header"); -Clazz.prepareFields (c$, function () { -this.scores = new java.util.LinkedHashMap (); -}); -Clazz.defineMethod (c$, "getScoreAvg", -function () { -return this.score; -}); -Clazz.defineMethod (c$, "getScoreFor", -function (a) { -return this.scores.containsKey (a) ? this.scores.get (a) : -1; -}, "~S"); -c$ = Clazz.p0p (); -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.size = 0; -this.items = null; -Clazz.instantialize (this, arguments); -}, jalview.io.TCoffeeScoreFile, "Block"); -Clazz.makeConstructor (c$, -function (a) { -this.size = a; -this.items = new java.util.HashMap (a); -}, "~N"); -Clazz.defineMethod (c$, "getScoresFor", -function (a) { -return this.items.get (a); -}, "~S"); -Clazz.defineMethod (c$, "getConsensus", -function () { -return this.items.get ("cons"); -}); -c$ = Clazz.p0p (); -c$.SCORES_WITH_RESIDUE_NUMS = c$.prototype.SCORES_WITH_RESIDUE_NUMS = java.util.regex.Pattern.compile ("^\\d+\\s([^\\s]+)\\s+\\d+$"); -c$.colors = c$.prototype.colors = Clazz.newArray (-1, [ new java.awt.Color (102, 102, 255), new java.awt.Color (0, 255, 0), new java.awt.Color (102, 255, 0), new java.awt.Color (204, 255, 0), new java.awt.Color (255, 255, 0), new java.awt.Color (255, 204, 0), new java.awt.Color (255, 153, 0), new java.awt.Color (255, 102, 0), new java.awt.Color (255, 51, 0), new java.awt.Color (255, 34, 0)]); -Clazz.defineStatics (c$, -"TCOFFEE_SCORE", "TCoffeeScore"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile", "java.awt.Color", "java.util.LinkedHashMap", "java.util.regex.Pattern"], "jalview.io.TCoffeeScoreFile", ["jalview.analysis.SequenceIdMatcher", "jalview.datamodel.Annotation", "jalview.util.Comparison", "java.lang.StringBuilder", "java.util.ArrayList", "$.HashMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.header = null; +this.scores = null; +this.fWidth = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "TCoffeeScoreFile", jalview.io.AlignFile); +Clazz.defineMethod (c$, "getHeight", +function () { +return this.scores != null && this.scores.size () > 0 ? this.scores.size () - 1 : 0; +}); +Clazz.defineMethod (c$, "getWidth", +function () { +return this.fWidth != null ? this.fWidth : 0; +}); +Clazz.defineMethod (c$, "getScoresFor", +function (id) { +return this.scores != null && this.scores.containsKey (id) ? this.scores.get (id).toString () : ""; +}, "~S"); +Clazz.defineMethod (c$, "getScoresList", +function () { +if (this.scores == null) { +return null; +}var result = new java.util.ArrayList (this.scores.size ()); +for (var it, $it = this.scores.entrySet ().iterator (); $it.hasNext () && ((it = $it.next ()) || true);) { +result.add (it.getValue ().toString ()); +} +return result; +}); +Clazz.defineMethod (c$, "getScoresArray", +function () { +if (this.scores == null) { +return null; +}var result = Clazz.newByteArray (this.scores.size (), 0); +var rowCount = 0; +for (var it, $it = this.scores.entrySet ().iterator (); $it.hasNext () && ((it = $it.next ()) || true);) { +var line = it.getValue ().toString (); +var seqValues = Clazz.newByteArray (line.length, 0); +for (var j = 0, c = line.length; j < c; j++) { +var val = (line.charCodeAt (j) - 48); +seqValues[j] = (val >= 0 && val <= 9) ? val : -1; +} +result[rowCount++] = seqValues; +} +return result; +}); +Clazz.overrideMethod (c$, "parse", +function () { +this.header = jalview.io.TCoffeeScoreFile.readHeader (this); +if (this.header == null) { +this.error = true; +return; +}this.scores = new java.util.LinkedHashMap (); +for (var entry, $entry = this.header.scores.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) { +this.scores.put (entry.getKey (), new StringBuilder ()); +} +var block; +while ((block = jalview.io.TCoffeeScoreFile.readBlock (this, this.header.scores.size ())) != null) { +for (var entry, $entry = block.items.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) { +var scoreStringBuilder = this.scores.get (entry.getKey ()); +if (scoreStringBuilder == null) { +this.error = true; +this.errormessage = String.format ("Invalid T-Coffee score file: Sequence ID '%s' is not declared in header section", [entry.getKey ()]); +return; +}scoreStringBuilder.append (entry.getValue ()); +} +} +for (var str, $str = this.scores.values ().iterator (); $str.hasNext () && ((str = $str.next ()) || true);) { +if (this.fWidth == null) { +this.fWidth = new Integer (str.length ()); +} else if ((this.fWidth).intValue () !== str.length ()) { +this.error = true; +this.errormessage = "Invalid T-Coffee score file: All the score sequences must have the same length"; +return; +}} +return; +}); +c$.parseInt = Clazz.defineMethod (c$, "parseInt", +function (str) { +try { +return Integer.parseInt (str); +} catch (e) { +if (Clazz.exceptionOf (e, NumberFormatException)) { +return 0; +} else { +throw e; +} +} +}, "~S"); +c$.readHeader = Clazz.defineMethod (c$, "readHeader", +function (reader) { +var result = null; +try { +result = new jalview.io.TCoffeeScoreFile.Header (); +result.head = reader.nextLine (); +var line; +while ((line = reader.nextLine ()) != null) { +if (line.startsWith ("SCORE=")) { +result.score = jalview.io.TCoffeeScoreFile.parseInt (line.substring (6).trim ()); +break; +}} +if ((line = reader.nextLine ()) == null || !"*".equals (line.trim ())) { +jalview.io.TCoffeeScoreFile.error (reader, "Invalid T-COFFEE score format (NO BAD/AVG/GOOD header)"); +return null; +}if ((line = reader.nextLine ()) == null || !"BAD AVG GOOD".equals (line.trim ())) { +jalview.io.TCoffeeScoreFile.error (reader, "Invalid T-COFFEE score format (NO BAD/AVG/GOOD header)"); +return null; +}if ((line = reader.nextLine ()) == null || !"*".equals (line.trim ())) { +jalview.io.TCoffeeScoreFile.error (reader, "Invalid T-COFFEE score format (NO BAD/AVG/GOOD header)"); +return null; +}while ((line = reader.nextLine ()) != null) { +if ("".equals (line)) { +break; +}var p = line.indexOf (":"); +if (p == -1) { +continue; +}var id = line.substring (0, p).trim (); +var val = jalview.io.TCoffeeScoreFile.parseInt (line.substring (p + 1).trim ()); +if ("".equals (id)) { +continue; +}result.scores.put (id, new Integer (val)); +} +if (result == null) { +jalview.io.TCoffeeScoreFile.error (reader, "T-COFFEE score file had no per-sequence scores"); +}} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +jalview.io.TCoffeeScoreFile.error (reader, "Unexpected problem parsing T-Coffee score ascii file"); +throw e; +} else { +throw e; +} +} +return result; +}, "jalview.io.FileParse"); +c$.error = Clazz.defineMethod (c$, "error", +($fz = function (reader, errm) { +reader.error = true; +if (reader.errormessage == null) { +reader.errormessage = errm; +} else { +reader.errormessage += "\n" + errm; +}}, $fz.isPrivate = true, $fz), "jalview.io.FileParse,~S"); +c$.readBlock = Clazz.defineMethod (c$, "readBlock", +function (reader, size) { +var result = new jalview.io.TCoffeeScoreFile.Block (size); +var line; +while ((line = reader.nextLine ()) != null && "".equals (line.trim ())) { +} +if (line == null) { +return null; +}do { +if ("".equals (line.trim ())) { +break; +}var p = line.indexOf (" "); +if (p == -1) { +if (reader.warningMessage == null) { +reader.warningMessage = ""; +}reader.warningMessage += "Possible parsing error - expected to find a space in line: '" + line + "'\n"; +continue; +}var id = line.substring (0, p).trim (); +var val = line.substring (p + 1).trim (); +var m = jalview.io.TCoffeeScoreFile.SCORES_WITH_RESIDUE_NUMS.matcher (val); +if (m.matches ()) { +val = m.group (1); +}result.items.put (id, val); +} while ((line = reader.nextLine ()) != null); +return result; +}, "jalview.io.FileParse,~N"); +Clazz.defineMethod (c$, "annotateAlignment", +function (al, matchids) { +if (al.getHeight () != this.getHeight () || al.getWidth () != this.getWidth ()) { +var info = String.format ("align w: %s, h: %s; score: w: %s; h: %s ", [new Integer (al.getWidth ()), new Integer (al.getHeight ()), new Integer (this.getWidth ()), new Integer (this.getHeight ())]); +this.warningMessage = "Alignment shape does not match T-Coffee score file shape -- " + info; +return false; +}var added = false; +var i = 0; +var sidmatcher = new jalview.analysis.SequenceIdMatcher (al.getSequencesArray ()); +var scoreMatrix = this.getScoresArray (); +for (var id, $id = this.scores.entrySet ().iterator (); $id.hasNext () && ((id = $id.next ()) || true);) { +var srow = scoreMatrix[i]; +var s; +if (matchids) { +s = sidmatcher.findIdMatch (id.getKey ()); +} else { +s = al.getSequenceAt (i); +}i++; +if (s == null && i != this.scores.size () && !id.getKey ().equals ("cons")) { +System.err.println ("No " + (matchids ? "match " : " sequences left ") + " for TCoffee score set : " + id.getKey ()); +continue; +}var jSize = al.getWidth () < srow.length ? al.getWidth () : srow.length; +var annotations = new Array (al.getWidth ()); +for (var j = 0; j < jSize; j++) { +var val = srow[j]; +if (s != null && jalview.util.Comparison.isGap (s.getCharAt (j))) { +annotations[j] = null; +if (val > 0) { +System.err.println ("Warning: non-zero value for positional T-COFFEE score for gap at " + j + " in sequence " + s.getName ()); +}} else { +annotations[j] = new jalview.datamodel.Annotation (s == null ? "" + val : null, s == null ? "" + val : null, '\0', val * 1, val >= 0 && val < jalview.io.TCoffeeScoreFile.colors.length ? jalview.io.TCoffeeScoreFile.colors[val] : java.awt.Color.white); +}} +var aa = al.findOrCreateAnnotation ("TCoffeeScore", "TCoffeeScore", false, s, null); +if (s != null) { +aa.label = "T-COFFEE"; +aa.description = "" + id.getKey (); +aa.annotations = annotations; +aa.visible = false; +aa.belowAlignment = false; +aa.setScore (this.header.getScoreFor (id.getKey ())); +aa.createSequenceMapping (s, s.getStart (), true); +s.addAlignmentAnnotation (aa); +aa.adjustForAlignment (); +} else { +aa.graph = 0; +aa.label = "T-COFFEE"; +aa.description = "TCoffee column reliability score"; +aa.annotations = annotations; +aa.belowAlignment = true; +aa.visible = true; +aa.setScore (this.header.getScoreAvg ()); +}aa.showAllColLabels = true; +aa.validateRangeAndDisplay (); +added = true; +} +return added; +}, "jalview.datamodel.AlignmentI,~B"); +Clazz.overrideMethod (c$, "print", +function () { +return "Not valid."; +}); +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.head = null; +this.score = 0; +this.scores = null; +Clazz.instantialize (this, arguments); +}, jalview.io.TCoffeeScoreFile, "Header"); +Clazz.prepareFields (c$, function () { +this.scores = new java.util.LinkedHashMap (); +}); +Clazz.defineMethod (c$, "getScoreAvg", +function () { +return this.score; +}); +Clazz.defineMethod (c$, "getScoreFor", +function (a) { +return this.scores.containsKey (a) ? this.scores.get (a) : -1; +}, "~S"); +c$ = Clazz.p0p (); +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.size = 0; +this.items = null; +Clazz.instantialize (this, arguments); +}, jalview.io.TCoffeeScoreFile, "Block"); +Clazz.makeConstructor (c$, +function (a) { +this.size = a; +this.items = new java.util.HashMap (a); +}, "~N"); +Clazz.defineMethod (c$, "getScoresFor", +function (a) { +return this.items.get (a); +}, "~S"); +Clazz.defineMethod (c$, "getConsensus", +function () { +return this.items.get ("cons"); +}); +c$ = Clazz.p0p (); +c$.SCORES_WITH_RESIDUE_NUMS = c$.prototype.SCORES_WITH_RESIDUE_NUMS = java.util.regex.Pattern.compile ("^\\d+\\s([^\\s]+)\\s+\\d+$"); +c$.colors = c$.prototype.colors = Clazz.newArray (-1, [ new java.awt.Color (102, 102, 255), new java.awt.Color (0, 255, 0), new java.awt.Color (102, 255, 0), new java.awt.Color (204, 255, 0), new java.awt.Color (255, 255, 0), new java.awt.Color (255, 204, 0), new java.awt.Color (255, 153, 0), new java.awt.Color (255, 102, 0), new java.awt.Color (255, 51, 0), new java.awt.Color (255, 34, 0)]); +Clazz.defineStatics (c$, +"TCOFFEE_SCORE", "TCoffeeScore"); +}); diff --git a/bin/jalview/javascript/JSFunctionExec.js b/bin/jalview/javascript/JSFunctionExec.js index 43f56a2..3296c72 100644 --- a/bin/jalview/javascript/JSFunctionExec.js +++ b/bin/jalview/javascript/JSFunctionExec.js @@ -1,166 +1,166 @@ -Clazz.declarePackage ("jalview.javascript"); -Clazz.load (null, "jalview.javascript.JSFunctionExec", ["jalview.bin.JalviewLite", "java.lang.StringBuffer", "$.Thread", "java.net.MalformedURLException", "$.URL", "netscape.javascript.JSException", "$.JSObject"], function () { -c$ = Clazz.decorateAsClass (function () { -this.jvlite = null; -this.jsExecQueue = null; -this.executor = null; -Clazz.instantialize (this, arguments); -}, jalview.javascript, "JSFunctionExec", null, Runnable); -Clazz.makeConstructor (c$, -function (applet) { -this.jvlite = applet; -this.jsExecQueue = this.jvlite.getJsExecQueue (); -this.jvlite.setExecutor (this); -}, "jalview.bin.JalviewLite"); -Clazz.overrideMethod (c$, "finalize", -function () { -this.jvlite = null; -this.executor = null; -if (this.jsExecQueue != null) { -this.jsExecQueue.clear (); -}this.jsExecQueue = null; -}); -Clazz.defineMethod (c$, "stopQueue", -function () { -if (this.jsExecQueue != null) { -var q = null; -{ -q = this.jsExecQueue; -this.jsExecQueue = null; -}if (q != null) { -for (var jx, $jx = q.iterator (); $jx.hasNext () && ((jx = $jx.next ()) || true);) { -jx.jvlite = null; -} -q.removeAllElements (); -{ -q.notifyAll (); -}}}this.jvlite = null; -this.executor = null; -}); -Clazz.defineMethod (c$, "run", -function () { -while (this.jsExecQueue != null) { -if (this.jsExecQueue.size () > 0) { -var r = this.jsExecQueue.elementAt (0); -this.jsExecQueue.removeElementAt (0); -try { -r.run (); -} catch (e$$) { -if (Clazz.exceptionOf (e$$, Exception)) { -var ex = e$$; -{ -ex.printStackTrace (); -} -} else if (Clazz.exceptionOf (e$$, Error)) { -var ex = e$$; -{ -ex.printStackTrace (); -} -} else { -throw e$$; -} -} -} else { -try { -{ -this.jsExecQueue.wait (1000); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -;}} -}); -Clazz.defineMethod (c$, "executeJavascriptFunction", -function (_listener, objects) { -this.executeJavascriptFunction (false, _listener, objects); -}, "~S,~A"); -Clazz.defineMethod (c$, "executeJavascriptFunction", -function (async, _listener, $arguments) { -this.executeJavascriptFunction (async, _listener, $arguments, null); -}, "~B,~S,~A"); -Clazz.defineMethod (c$, "executeJavascriptFunction", -function (async, _listener, $arguments, dbgMsg) { -var objects = new Array ($arguments != null ? $arguments.length : 0); -if ($arguments != null) { -System.arraycopy ($arguments, 0, objects, 0, $arguments.length); -}var jsex = new Array (1); -var exec = ((Clazz.isClassDefined ("jalview.javascript.JSFunctionExec$1") ? 0 : jalview.javascript.JSFunctionExec.$JSFunctionExec$1$ ()), Clazz.innerTypeInstance (jalview.javascript.JSFunctionExec$1, this, Clazz.cloneFinals ("dbgMsg", dbgMsg, "_listener", _listener, "objects", objects, "jsex", jsex, "async", async))); -if (async) { -if (this.executor == null) { -this.executor = new Thread ( new jalview.javascript.JSFunctionExec (this.jvlite)); -this.executor.start (); -}{ -this.jsExecQueue.addElement (exec); -this.jsExecQueue.notify (); -}} else { -exec.run (); -if (jsex[0] != null) { -throw (jsex[0]); -}}}, "~B,~S,~A,~S"); -c$.$JSFunctionExec$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.javascript, "JSFunctionExec$1", null, Runnable); -Clazz.defineMethod (c$, "run", -function () { -try { -var scriptObject = null; -try { -scriptObject = netscape.javascript.JSObject.getWindow (this.b$["jalview.javascript.JSFunctionExec"].jvlite); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -;if (scriptObject != null) { -if (jalview.bin.JalviewLite.debug && this.f$.dbgMsg != null) { -System.err.println (this.f$.dbgMsg); -}scriptObject.call (this.f$._listener, this.f$.objects); -}} catch (jex) { -if (Clazz.exceptionOf (jex, Exception)) { -if (!(Clazz.instanceOf (jex, java.net.MalformedURLException))) { -if (jalview.bin.JalviewLite.debug) { -System.err.println (jex); -}if (Clazz.instanceOf (jex, netscape.javascript.JSException) && this.b$["jalview.javascript.JSFunctionExec"].jvlite.jsfallbackEnabled) { -this.f$.jsex[0] = jex; -if (jalview.bin.JalviewLite.debug) { -System.err.println ("Falling back to javascript: url call"); -}var sb = new StringBuffer ("javascript:" + this.f$._listener + "("); -for (var i = 0; this.f$.objects != null && i < this.f$.objects.length; i++) { -if (i > 0) { -sb.append (","); -}sb.append ("\""); -if (this.f$.objects[i] != null && !(this.f$.objects[i].getClass ().getName ().indexOf ("jalview") == 0)) { -sb.append (this.f$.objects[i].toString ()); -}sb.append ("\""); -} -sb.append (")"); -if (jalview.bin.JalviewLite.debug) { -System.err.println (sb.toString ()); -}var url = null; -try { -url = new java.net.URL (sb.toString ()); -this.b$["jalview.javascript.JSFunctionExec"].jvlite.getAppletContext ().showDocument (url); -jex = null; -} catch (uex) { -if (Clazz.exceptionOf (uex, Exception)) { -jex = uex; -} else { -throw uex; -} -} -}if (jex != null) { -if (this.f$.async) { -jex.printStackTrace (); -} else { -this.f$.jsex[0] = jex; -}};}} else { -throw jex; -} -} -}); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.javascript"); +Clazz.load (null, "jalview.javascript.JSFunctionExec", ["jalview.bin.JalviewLite", "java.lang.StringBuffer", "$.Thread", "java.net.MalformedURLException", "$.URL", "netscape.javascript.JSException", "$.JSObject"], function () { +c$ = Clazz.decorateAsClass (function () { +this.jvlite = null; +this.jsExecQueue = null; +this.executor = null; +Clazz.instantialize (this, arguments); +}, jalview.javascript, "JSFunctionExec", null, Runnable); +Clazz.makeConstructor (c$, +function (applet) { +this.jvlite = applet; +this.jsExecQueue = this.jvlite.getJsExecQueue (); +this.jvlite.setExecutor (this); +}, "jalview.bin.JalviewLite"); +Clazz.overrideMethod (c$, "finalize", +function () { +this.jvlite = null; +this.executor = null; +if (this.jsExecQueue != null) { +this.jsExecQueue.clear (); +}this.jsExecQueue = null; +}); +Clazz.defineMethod (c$, "stopQueue", +function () { +if (this.jsExecQueue != null) { +var q = null; +{ +q = this.jsExecQueue; +this.jsExecQueue = null; +}if (q != null) { +for (var jx, $jx = q.iterator (); $jx.hasNext () && ((jx = $jx.next ()) || true);) { +jx.jvlite = null; +} +q.removeAllElements (); +{ +q.notifyAll (); +}}}this.jvlite = null; +this.executor = null; +}); +Clazz.defineMethod (c$, "run", +function () { +while (this.jsExecQueue != null) { +if (this.jsExecQueue.size () > 0) { +var r = this.jsExecQueue.elementAt (0); +this.jsExecQueue.removeElementAt (0); +try { +r.run (); +} catch (e$$) { +if (Clazz.exceptionOf (e$$, Exception)) { +var ex = e$$; +{ +ex.printStackTrace (); +} +} else if (Clazz.exceptionOf (e$$, Error)) { +var ex = e$$; +{ +ex.printStackTrace (); +} +} else { +throw e$$; +} +} +} else { +try { +{ +this.jsExecQueue.wait (1000); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +;}} +}); +Clazz.defineMethod (c$, "executeJavascriptFunction", +function (_listener, objects) { +this.executeJavascriptFunction (false, _listener, objects); +}, "~S,~A"); +Clazz.defineMethod (c$, "executeJavascriptFunction", +function (async, _listener, $arguments) { +this.executeJavascriptFunction (async, _listener, $arguments, null); +}, "~B,~S,~A"); +Clazz.defineMethod (c$, "executeJavascriptFunction", +function (async, _listener, $arguments, dbgMsg) { +var objects = new Array ($arguments != null ? $arguments.length : 0); +if ($arguments != null) { +System.arraycopy ($arguments, 0, objects, 0, $arguments.length); +}var jsex = new Array (1); +var exec = ((Clazz.isClassDefined ("jalview.javascript.JSFunctionExec$1") ? 0 : jalview.javascript.JSFunctionExec.$JSFunctionExec$1$ ()), Clazz.innerTypeInstance (jalview.javascript.JSFunctionExec$1, this, Clazz.cloneFinals ("dbgMsg", dbgMsg, "_listener", _listener, "objects", objects, "jsex", jsex, "async", async))); +if (async) { +if (this.executor == null) { +this.executor = new Thread ( new jalview.javascript.JSFunctionExec (this.jvlite)); +this.executor.start (); +}{ +this.jsExecQueue.addElement (exec); +this.jsExecQueue.notify (); +}} else { +exec.run (); +if (jsex[0] != null) { +throw (jsex[0]); +}}}, "~B,~S,~A,~S"); +c$.$JSFunctionExec$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.javascript, "JSFunctionExec$1", null, Runnable); +Clazz.defineMethod (c$, "run", +function () { +try { +var scriptObject = null; +try { +scriptObject = netscape.javascript.JSObject.getWindow (this.b$["jalview.javascript.JSFunctionExec"].jvlite); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +;if (scriptObject != null) { +if (jalview.bin.JalviewLite.debug && this.f$.dbgMsg != null) { +System.err.println (this.f$.dbgMsg); +}scriptObject.call (this.f$._listener, this.f$.objects); +}} catch (jex) { +if (Clazz.exceptionOf (jex, Exception)) { +if (!(Clazz.instanceOf (jex, java.net.MalformedURLException))) { +if (jalview.bin.JalviewLite.debug) { +System.err.println (jex); +}if (Clazz.instanceOf (jex, netscape.javascript.JSException) && this.b$["jalview.javascript.JSFunctionExec"].jvlite.jsfallbackEnabled) { +this.f$.jsex[0] = jex; +if (jalview.bin.JalviewLite.debug) { +System.err.println ("Falling back to javascript: url call"); +}var sb = new StringBuffer ("javascript:" + this.f$._listener + "("); +for (var i = 0; this.f$.objects != null && i < this.f$.objects.length; i++) { +if (i > 0) { +sb.append (","); +}sb.append ("\""); +if (this.f$.objects[i] != null && !(this.f$.objects[i].getClass ().getName ().indexOf ("jalview") == 0)) { +sb.append (this.f$.objects[i].toString ()); +}sb.append ("\""); +} +sb.append (")"); +if (jalview.bin.JalviewLite.debug) { +System.err.println (sb.toString ()); +}var url = null; +try { +url = new java.net.URL (sb.toString ()); +this.b$["jalview.javascript.JSFunctionExec"].jvlite.getAppletContext ().showDocument (url); +jex = null; +} catch (uex) { +if (Clazz.exceptionOf (uex, Exception)) { +jex = uex; +} else { +throw uex; +} +} +}if (jex != null) { +if (this.f$.async) { +jex.printStackTrace (); +} else { +this.f$.jsex[0] = jex; +}};}} else { +throw jex; +} +} +}); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/javascript/JalviewLiteJsApi.js b/bin/jalview/javascript/JalviewLiteJsApi.js index bdd7529..ed4943e 100644 --- a/bin/jalview/javascript/JalviewLiteJsApi.js +++ b/bin/jalview/javascript/JalviewLiteJsApi.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.javascript"); -Clazz.declareInterface (jalview.javascript, "JalviewLiteJsApi"); +Clazz.declarePackage ("jalview.javascript"); +Clazz.declareInterface (jalview.javascript, "JalviewLiteJsApi"); diff --git a/bin/jalview/javascript/JsCallBack.js b/bin/jalview/javascript/JsCallBack.js index 85ac52a..1577e6b 100644 --- a/bin/jalview/javascript/JsCallBack.js +++ b/bin/jalview/javascript/JsCallBack.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.javascript"); -Clazz.declareInterface (jalview.javascript, "JsCallBack"); +Clazz.declarePackage ("jalview.javascript"); +Clazz.declareInterface (jalview.javascript, "JsCallBack"); diff --git a/bin/jalview/javascript/JsSelectionSender.js b/bin/jalview/javascript/JsSelectionSender.js index 36703c5..ad763f0 100644 --- a/bin/jalview/javascript/JsSelectionSender.js +++ b/bin/jalview/javascript/JsSelectionSender.js @@ -1,70 +1,70 @@ -Clazz.declarePackage ("jalview.javascript"); -Clazz.load (["jalview.javascript.JSFunctionExec", "$.JsCallBack", "jalview.structure.SelectionListener"], "jalview.javascript.JsSelectionSender", ["jalview.appletgui.AlignViewport", "netscape.javascript.JSException"], function () { -c$ = Clazz.decorateAsClass (function () { -this._af = null; -this._listener = null; -Clazz.instantialize (this, arguments); -}, jalview.javascript, "JsSelectionSender", jalview.javascript.JSFunctionExec, [jalview.structure.SelectionListener, jalview.javascript.JsCallBack]); -Clazz.makeConstructor (c$, -function (jvlite, af, listener) { -Clazz.superConstructor (this, jalview.javascript.JsSelectionSender, [jvlite]); -this._af = af; -this._listener = listener; -}, "jalview.bin.JalviewLite,jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "selection", -function (seqsel, colsel, source) { -try { -var setid = ""; -var viewid = ""; -var src = this._af; -if (source != null) { -if (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).applet.currentAlignFrame.viewport === source) { -src = (source).applet.currentAlignFrame; -}}var seqs = Clazz.newArray (-1, []); -var cols = Clazz.newArray (-1, []); -var strt = 0; -var end = (src == null) ? -1 : src.alignPanel.av.getAlignment ().getWidth (); -if (seqsel != null && seqsel.getSize () > 0) { -seqs = new Array (seqsel.getSize ()); -for (var i = 0; i < seqs.length; i++) { -seqs[i] = seqsel.getSequenceAt (i).getName (); -} -if (strt < seqsel.getStartRes ()) { -strt = seqsel.getStartRes (); -}if (end == -1 || end > seqsel.getEndRes ()) { -end = seqsel.getEndRes (); -}}if (colsel != null && colsel.size () > 0) { -if (end == -1) { -end = colsel.getMax () + 1; -}cols = new Array (colsel.getSelected ().size ()); -var d = 0; -var r = -1; -for (var i = 0; i < cols.length; i++) { -cols[i] = "" + (1 + colsel.getSelected ().elementAt (i).intValue ()); -} -} else { -if (seqsel != null && seqsel.getSize () > 0) { -cols = new Array (2); -cols[0] = "" + (1 + strt) + "-" + (1 + end); -};}System.err.println ("Relaying selection to jsfunction:" + this._listener); -this.executeJavascriptFunction (this._listener, Clazz.newArray (-1, [src, setid, this.jvlite.arrayToSeparatorList (seqs), this.jvlite.arrayToSeparatorList (cols)])); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Jalview Javascript exec error: Couldn't send selection message using function '" + this._listener + "'"); -ex.printStackTrace (); -if (Clazz.instanceOf (ex, netscape.javascript.JSException)) { -System.err.println ("Javascript Exception: " + (ex).getCause ().toString ()); -}} else { -throw ex; -} -} -}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); -Clazz.overrideMethod (c$, "getAlignFrame", -function () { -return this._af; -}); -Clazz.overrideMethod (c$, "getListenerFunction", -function () { -return this._listener; -}); -}); +Clazz.declarePackage ("jalview.javascript"); +Clazz.load (["jalview.javascript.JSFunctionExec", "$.JsCallBack", "jalview.structure.SelectionListener"], "jalview.javascript.JsSelectionSender", ["jalview.appletgui.AlignViewport", "netscape.javascript.JSException"], function () { +c$ = Clazz.decorateAsClass (function () { +this._af = null; +this._listener = null; +Clazz.instantialize (this, arguments); +}, jalview.javascript, "JsSelectionSender", jalview.javascript.JSFunctionExec, [jalview.structure.SelectionListener, jalview.javascript.JsCallBack]); +Clazz.makeConstructor (c$, +function (jvlite, af, listener) { +Clazz.superConstructor (this, jalview.javascript.JsSelectionSender, [jvlite]); +this._af = af; +this._listener = listener; +}, "jalview.bin.JalviewLite,jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "selection", +function (seqsel, colsel, source) { +try { +var setid = ""; +var viewid = ""; +var src = this._af; +if (source != null) { +if (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).applet.currentAlignFrame.viewport === source) { +src = (source).applet.currentAlignFrame; +}}var seqs = Clazz.newArray (-1, []); +var cols = Clazz.newArray (-1, []); +var strt = 0; +var end = (src == null) ? -1 : src.alignPanel.av.getAlignment ().getWidth (); +if (seqsel != null && seqsel.getSize () > 0) { +seqs = new Array (seqsel.getSize ()); +for (var i = 0; i < seqs.length; i++) { +seqs[i] = seqsel.getSequenceAt (i).getName (); +} +if (strt < seqsel.getStartRes ()) { +strt = seqsel.getStartRes (); +}if (end == -1 || end > seqsel.getEndRes ()) { +end = seqsel.getEndRes (); +}}if (colsel != null && colsel.size () > 0) { +if (end == -1) { +end = colsel.getMax () + 1; +}cols = new Array (colsel.getSelected ().size ()); +var d = 0; +var r = -1; +for (var i = 0; i < cols.length; i++) { +cols[i] = "" + (1 + colsel.getSelected ().elementAt (i).intValue ()); +} +} else { +if (seqsel != null && seqsel.getSize () > 0) { +cols = new Array (2); +cols[0] = "" + (1 + strt) + "-" + (1 + end); +};}System.err.println ("Relaying selection to jsfunction:" + this._listener); +this.executeJavascriptFunction (this._listener, Clazz.newArray (-1, [src, setid, this.jvlite.arrayToSeparatorList (seqs), this.jvlite.arrayToSeparatorList (cols)])); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Jalview Javascript exec error: Couldn't send selection message using function '" + this._listener + "'"); +ex.printStackTrace (); +if (Clazz.instanceOf (ex, netscape.javascript.JSException)) { +System.err.println ("Javascript Exception: " + (ex).getCause ().toString ()); +}} else { +throw ex; +} +} +}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); +Clazz.overrideMethod (c$, "getAlignFrame", +function () { +return this._af; +}); +Clazz.overrideMethod (c$, "getListenerFunction", +function () { +return this._listener; +}); +}); diff --git a/bin/jalview/javascript/MouseOverListener.js b/bin/jalview/javascript/MouseOverListener.js index de59a3e..39cb7bc 100644 --- a/bin/jalview/javascript/MouseOverListener.js +++ b/bin/jalview/javascript/MouseOverListener.js @@ -1,46 +1,46 @@ -Clazz.declarePackage ("jalview.javascript"); -Clazz.load (["jalview.javascript.JSFunctionExec", "$.JsCallBack", "jalview.structure.VamsasListener"], "jalview.javascript.MouseOverListener", ["jalview.appletgui.AlignViewport", "netscape.javascript.JSException"], function () { -c$ = Clazz.decorateAsClass (function () { -this._af = null; -this._listener = null; -this.last = null; -this.i = -1; -Clazz.instantialize (this, arguments); -}, jalview.javascript, "MouseOverListener", jalview.javascript.JSFunctionExec, [jalview.structure.VamsasListener, jalview.javascript.JsCallBack]); -Clazz.overrideMethod (c$, "mouseOverSequence", -function (seq, index, source) { -if (seq !== this.last || this.i != index) { -this.last = seq; -this.i = index; -var src = null; -try { -if (source != null) { -if (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).applet.currentAlignFrame.viewport === source) { -src = (source).applet.currentAlignFrame; -}}this.executeJavascriptFunction (this._listener, Clazz.newArray (-1, [src, seq.getDisplayId (false), "" + (1 + this.i), "" + seq.findPosition (this.i)])); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("JalviewLite javascript error: Couldn't send mouseOver with handler '" + this._listener + "'"); -if (Clazz.instanceOf (ex, netscape.javascript.JSException)) { -System.err.println ("Javascript Exception: " + (ex).getMessage ()); -}ex.printStackTrace (); -} else { -throw ex; -} -} -}}, "jalview.datamodel.SequenceI,~N,jalview.structure.VamsasSource"); -Clazz.makeConstructor (c$, -function (applet, af, listener) { -Clazz.superConstructor (this, jalview.javascript.MouseOverListener, [applet]); -this._af = af; -this._listener = listener; -}, "jalview.bin.JalviewLite,jalview.appletgui.AlignFrame,~S"); -Clazz.overrideMethod (c$, "getAlignFrame", -function () { -return this._af; -}); -Clazz.overrideMethod (c$, "getListenerFunction", -function () { -return this._listener; -}); -}); +Clazz.declarePackage ("jalview.javascript"); +Clazz.load (["jalview.javascript.JSFunctionExec", "$.JsCallBack", "jalview.structure.VamsasListener"], "jalview.javascript.MouseOverListener", ["jalview.appletgui.AlignViewport", "netscape.javascript.JSException"], function () { +c$ = Clazz.decorateAsClass (function () { +this._af = null; +this._listener = null; +this.last = null; +this.i = -1; +Clazz.instantialize (this, arguments); +}, jalview.javascript, "MouseOverListener", jalview.javascript.JSFunctionExec, [jalview.structure.VamsasListener, jalview.javascript.JsCallBack]); +Clazz.overrideMethod (c$, "mouseOverSequence", +function (seq, index, source) { +if (seq !== this.last || this.i != index) { +this.last = seq; +this.i = index; +var src = null; +try { +if (source != null) { +if (Clazz.instanceOf (source, jalview.appletgui.AlignViewport) && (source).applet.currentAlignFrame.viewport === source) { +src = (source).applet.currentAlignFrame; +}}this.executeJavascriptFunction (this._listener, Clazz.newArray (-1, [src, seq.getDisplayId (false), "" + (1 + this.i), "" + seq.findPosition (this.i)])); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("JalviewLite javascript error: Couldn't send mouseOver with handler '" + this._listener + "'"); +if (Clazz.instanceOf (ex, netscape.javascript.JSException)) { +System.err.println ("Javascript Exception: " + (ex).getMessage ()); +}ex.printStackTrace (); +} else { +throw ex; +} +} +}}, "jalview.datamodel.SequenceI,~N,jalview.structure.VamsasSource"); +Clazz.makeConstructor (c$, +function (applet, af, listener) { +Clazz.superConstructor (this, jalview.javascript.MouseOverListener, [applet]); +this._af = af; +this._listener = listener; +}, "jalview.bin.JalviewLite,jalview.appletgui.AlignFrame,~S"); +Clazz.overrideMethod (c$, "getAlignFrame", +function () { +return this._af; +}); +Clazz.overrideMethod (c$, "getListenerFunction", +function () { +return this._listener; +}); +}); diff --git a/bin/jalview/javascript/MouseOverStructureListener.js b/bin/jalview/javascript/MouseOverStructureListener.js index c897252..12d1e2f 100644 --- a/bin/jalview/javascript/MouseOverStructureListener.js +++ b/bin/jalview/javascript/MouseOverStructureListener.js @@ -1,143 +1,143 @@ -Clazz.declarePackage ("jalview.javascript"); -Clazz.load (["jalview.javascript.JSFunctionExec", "$.JsCallBack", "jalview.structure.StructureListener"], "jalview.javascript.MouseOverStructureListener", ["jalview.api.AlignmentViewPanel", "jalview.appletgui.FeatureRenderer", "jalview.ext.jmol.JmolCommands", "jalview.structure.StructureSelectionManager", "java.net.URL", "java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this._listenerfn = null; -this.modelSet = null; -Clazz.instantialize (this, arguments); -}, jalview.javascript, "MouseOverStructureListener", jalview.javascript.JSFunctionExec, [jalview.javascript.JsCallBack, jalview.structure.StructureListener]); -Clazz.makeConstructor (c$, -function (jalviewLite, listener, modelList) { -Clazz.superConstructor (this, jalview.javascript.MouseOverStructureListener, [jalviewLite]); -this._listenerfn = listener; -this.modelSet = modelList; -if (this.modelSet != null) { -for (var i = 0; i < this.modelSet.length; i++) { -try { -if ( new java.net.URL (this.modelSet[i]).openConnection () != null) { -continue; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -;try { -var db = this.jvlite.getDocumentBase ().toString (); -db = db.substring (0, db.lastIndexOf ("/")); -if ( new java.net.URL (db + "/" + this.modelSet[i]).openConnection () != null) { -this.modelSet[i] = db + "/" + this.modelSet[i]; -continue; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -;try { -if ( new java.net.URL (this.jvlite.getCodeBase () + this.modelSet[i]).openConnection () != null) { -this.modelSet[i] = this.jvlite.getCodeBase () + this.modelSet[i]; -continue; -}} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -} else { -throw x; -} -} -;} -}}, "jalview.bin.JalviewLite,~S,~A"); -Clazz.overrideMethod (c$, "getPdbFile", -function () { -return this.modelSet; -}); -Clazz.defineMethod (c$, "mouseOverStructure", -function (atomIndex, strInfo) { -}, "~N,~S"); -Clazz.overrideMethod (c$, "highlightAtoms", -function (atoms) { -for (var atom, $atom = atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { -try { -this.executeJavascriptFunction (this._listenerfn, Clazz.newArray (-1, ["mouseover", "" + atom.getPdbFile (), "" + atom.getChain (), "" + (atom.getPdbResNum ()), "" + atom.getAtomIndex ()])); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Couldn't execute callback with " + this._listenerfn + " for atomSpec: " + atom); -ex.printStackTrace (); -} else { -throw ex; -} -} -} -}, "java.util.List"); -Clazz.overrideMethod (c$, "updateColours", -function (srce) { -var source = srce; -var ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.jvlite); -if (Clazz.instanceOf (source, jalview.api.AlignmentViewPanel)) { -var sequence = new Array (this.modelSet.length); -for (var m = 0; m < this.modelSet.length; m++) { -var sm = ssm.getMapping (this.modelSet[m]); -if (sm != null && sm.length > 0) { -sequence[m] = new Array (sm.length); -for (var i = 0; i < sm.length; i++) { -sequence[m][i] = sm[i].getSequence (); -} -} else { -sequence[m] = new Array (0); -}} -var sr = (source).getSequenceRenderer (); -var fr = (source).av.isShowSequenceFeatures () ? new jalview.appletgui.FeatureRenderer ((source).av) : null; -if (fr != null) { -(fr).transferSettings ((source).getFeatureRenderer ()); -};var ccomands = new java.util.ArrayList (); -var pdbfn = new java.util.ArrayList (); -var colcommands = jalview.ext.jmol.JmolCommands.getColourBySequenceCommand (ssm, this.modelSet, sequence, sr, fr, (source).getAlignment ()); -if (colcommands == null) { -return; -}var sz = 0; -for (var ccset, $ccset = 0, $$ccset = colcommands; $ccset < $$ccset.length && ((ccset = $$ccset[$ccset]) || true); $ccset++) { -sz += ccset.commands.length; -ccomands.add (ccset.commands); -pdbfn.add (ccset.mapping); -} -var mclass; -var mhandle; -var ccomandset = new Array (sz); -sz = 0; -for (var ccset, $ccset = ccomands.iterator (); $ccset.hasNext () && ((ccset = $ccset.next ()) || true);) { -System.arraycopy (ccset, 0, ccomandset, sz, ccset.length); -sz += ccset.length; -} -if (this.jvlite.isJsMessageSetChanged (mclass = "colourstruct", mhandle = (source).av.getViewId (), ccomandset)) { -this.jvlite.setJsMessageSet (mclass, mhandle, ccomandset); -var st = Clazz.newArray (-1, ["colourstruct", "" + (source).av.getViewId (), "" + ccomandset.length, this.jvlite.arrayToSeparatorList (pdbfn.toArray ( new Array (pdbfn.size ())))]); -try { -this.executeJavascriptFunction (true, this._listenerfn, st); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.err.println ("Couldn't execute callback with " + this._listenerfn + " using args { " + st[0] + ", " + st[1] + ", " + st[2] + "," + st[3] + "}"); -ex.printStackTrace (); -} else { -throw ex; -} -} -}}}, "~O"); -Clazz.overrideMethod (c$, "getAlignFrame", -function () { -return null; -}); -Clazz.overrideMethod (c$, "getListenerFunction", -function () { -return this._listenerfn; -}); -Clazz.defineMethod (c$, "finalise", -function () { -this.jvlite = null; -Clazz.superCall (this, jalview.javascript.MouseOverStructureListener, "finalize", []); -}); -Clazz.overrideMethod (c$, "releaseReferences", -function (svl) { -}, "~O"); -Clazz.overrideMethod (c$, "isListeningFor", -function (seq) { -return true; -}, "jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.javascript"); +Clazz.load (["jalview.javascript.JSFunctionExec", "$.JsCallBack", "jalview.structure.StructureListener"], "jalview.javascript.MouseOverStructureListener", ["jalview.api.AlignmentViewPanel", "jalview.appletgui.FeatureRenderer", "jalview.ext.jmol.JmolCommands", "jalview.structure.StructureSelectionManager", "java.net.URL", "java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this._listenerfn = null; +this.modelSet = null; +Clazz.instantialize (this, arguments); +}, jalview.javascript, "MouseOverStructureListener", jalview.javascript.JSFunctionExec, [jalview.javascript.JsCallBack, jalview.structure.StructureListener]); +Clazz.makeConstructor (c$, +function (jalviewLite, listener, modelList) { +Clazz.superConstructor (this, jalview.javascript.MouseOverStructureListener, [jalviewLite]); +this._listenerfn = listener; +this.modelSet = modelList; +if (this.modelSet != null) { +for (var i = 0; i < this.modelSet.length; i++) { +try { +if ( new java.net.URL (this.modelSet[i]).openConnection () != null) { +continue; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +;try { +var db = this.jvlite.getDocumentBase ().toString (); +db = db.substring (0, db.lastIndexOf ("/")); +if ( new java.net.URL (db + "/" + this.modelSet[i]).openConnection () != null) { +this.modelSet[i] = db + "/" + this.modelSet[i]; +continue; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +;try { +if ( new java.net.URL (this.jvlite.getCodeBase () + this.modelSet[i]).openConnection () != null) { +this.modelSet[i] = this.jvlite.getCodeBase () + this.modelSet[i]; +continue; +}} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +} else { +throw x; +} +} +;} +}}, "jalview.bin.JalviewLite,~S,~A"); +Clazz.overrideMethod (c$, "getPdbFile", +function () { +return this.modelSet; +}); +Clazz.defineMethod (c$, "mouseOverStructure", +function (atomIndex, strInfo) { +}, "~N,~S"); +Clazz.overrideMethod (c$, "highlightAtoms", +function (atoms) { +for (var atom, $atom = atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { +try { +this.executeJavascriptFunction (this._listenerfn, Clazz.newArray (-1, ["mouseover", "" + atom.getPdbFile (), "" + atom.getChain (), "" + (atom.getPdbResNum ()), "" + atom.getAtomIndex ()])); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Couldn't execute callback with " + this._listenerfn + " for atomSpec: " + atom); +ex.printStackTrace (); +} else { +throw ex; +} +} +} +}, "java.util.List"); +Clazz.overrideMethod (c$, "updateColours", +function (srce) { +var source = srce; +var ssm = jalview.structure.StructureSelectionManager.getStructureSelectionManager (this.jvlite); +if (Clazz.instanceOf (source, jalview.api.AlignmentViewPanel)) { +var sequence = new Array (this.modelSet.length); +for (var m = 0; m < this.modelSet.length; m++) { +var sm = ssm.getMapping (this.modelSet[m]); +if (sm != null && sm.length > 0) { +sequence[m] = new Array (sm.length); +for (var i = 0; i < sm.length; i++) { +sequence[m][i] = sm[i].getSequence (); +} +} else { +sequence[m] = new Array (0); +}} +var sr = (source).getSequenceRenderer (); +var fr = (source).av.isShowSequenceFeatures () ? new jalview.appletgui.FeatureRenderer ((source).av) : null; +if (fr != null) { +(fr).transferSettings ((source).getFeatureRenderer ()); +};var ccomands = new java.util.ArrayList (); +var pdbfn = new java.util.ArrayList (); +var colcommands = jalview.ext.jmol.JmolCommands.getColourBySequenceCommand (ssm, this.modelSet, sequence, sr, fr, (source).getAlignment ()); +if (colcommands == null) { +return; +}var sz = 0; +for (var ccset, $ccset = 0, $$ccset = colcommands; $ccset < $$ccset.length && ((ccset = $$ccset[$ccset]) || true); $ccset++) { +sz += ccset.commands.length; +ccomands.add (ccset.commands); +pdbfn.add (ccset.mapping); +} +var mclass; +var mhandle; +var ccomandset = new Array (sz); +sz = 0; +for (var ccset, $ccset = ccomands.iterator (); $ccset.hasNext () && ((ccset = $ccset.next ()) || true);) { +System.arraycopy (ccset, 0, ccomandset, sz, ccset.length); +sz += ccset.length; +} +if (this.jvlite.isJsMessageSetChanged (mclass = "colourstruct", mhandle = (source).av.getViewId (), ccomandset)) { +this.jvlite.setJsMessageSet (mclass, mhandle, ccomandset); +var st = Clazz.newArray (-1, ["colourstruct", "" + (source).av.getViewId (), "" + ccomandset.length, this.jvlite.arrayToSeparatorList (pdbfn.toArray ( new Array (pdbfn.size ())))]); +try { +this.executeJavascriptFunction (true, this._listenerfn, st); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.err.println ("Couldn't execute callback with " + this._listenerfn + " using args { " + st[0] + ", " + st[1] + ", " + st[2] + "," + st[3] + "}"); +ex.printStackTrace (); +} else { +throw ex; +} +} +}}}, "~O"); +Clazz.overrideMethod (c$, "getAlignFrame", +function () { +return null; +}); +Clazz.overrideMethod (c$, "getListenerFunction", +function () { +return this._listenerfn; +}); +Clazz.defineMethod (c$, "finalise", +function () { +this.jvlite = null; +Clazz.superCall (this, jalview.javascript.MouseOverStructureListener, "finalize", []); +}); +Clazz.overrideMethod (c$, "releaseReferences", +function (svl) { +}, "~O"); +Clazz.overrideMethod (c$, "isListeningFor", +function (seq) { +return true; +}, "jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/jsdev/Constants.js b/bin/jalview/jsdev/Constants.js index 64acea4..9963449 100644 --- a/bin/jalview/jsdev/Constants.js +++ b/bin/jalview/jsdev/Constants.js @@ -1,13 +1,13 @@ -Clazz.declarePackage ("jalview.jsdev"); -c$ = Clazz.declareType (jalview.jsdev, "Constants"); -Clazz.defineStatics (c$, -"TCOFFEE_SCORE", "TCoffeeScore", -"Phylip_FILE", 1, -"Phylip_FILE_EXT", "phy", -"Phylip_FILE_DESC", "PHYLIP", -"JSON_FILE", 2, -"JSON_FILE_EXT", "json", -"JSON_FILE_DESC", "JSON", -"Html_FILE", 3, -"Html_FILE_EXT", "html", -"Html_FILE_DESC", "HTML"); +Clazz.declarePackage ("jalview.jsdev"); +c$ = Clazz.declareType (jalview.jsdev, "Constants"); +Clazz.defineStatics (c$, +"TCOFFEE_SCORE", "TCoffeeScore", +"Phylip_FILE", 1, +"Phylip_FILE_EXT", "phy", +"Phylip_FILE_DESC", "PHYLIP", +"JSON_FILE", 2, +"JSON_FILE_EXT", "json", +"JSON_FILE_DESC", "JSON", +"Html_FILE", 3, +"Html_FILE_EXT", "html", +"Html_FILE_DESC", "HTML"); diff --git a/bin/jalview/jsdev/GenericFileAdapter.js b/bin/jalview/jsdev/GenericFileAdapter.js index 9144c4b..60cf065 100644 --- a/bin/jalview/jsdev/GenericFileAdapter.js +++ b/bin/jalview/jsdev/GenericFileAdapter.js @@ -1,85 +1,85 @@ -Clazz.declarePackage ("jalview.jsdev"); -Clazz.load (["jalview.io.AlignFile"], "jalview.jsdev.GenericFileAdapter", ["jalview.datamodel.AlignmentI", "jalview.io.FileParse", "java.io.BufferedReader", "$.InputStreamReader", "java.net.URL"], function () { -c$ = Clazz.declareType (jalview.jsdev, "GenericFileAdapter", jalview.io.AlignFile); -c$.getFile = Clazz.defineMethod (c$, "getFile", -function (fileType, params) { -var cl = null; -try { -cl = Class.forName ("jalview.io." + fileType); -} catch (e) { -if (Clazz.exceptionOf (e, ClassNotFoundException)) { -System.err.println ("did not find file jalview.io." + fileType); -return null; -} else { -throw e; -} -} -var m; -var ex = null; -try { -switch (params.length) { -case 0: -return cl.newInstance (); -case 1: -m = (Clazz.instanceOf (params[0], jalview.io.FileParse) ? cl.getConstructor ([jalview.io.FileParse]) : cl.getConstructor ([jalview.datamodel.AlignmentI])); -break; -case 2: -m = cl.getConstructor ([String, String]); -break; -default: -return null; -} -return m.newInstance (params); -} catch (e$$) { -if (Clazz.exceptionOf (e$$, InstantiationException)) { -var e = e$$; -{ -ex = e; -} -} else if (Clazz.exceptionOf (e$$, IllegalAccessException)) { -var e = e$$; -{ -ex = e; -} -} else if (Clazz.exceptionOf (e$$, NoSuchMethodException)) { -var e = e$$; -{ -ex = e; -} -} else if (Clazz.exceptionOf (e$$, SecurityException)) { -var e = e$$; -{ -ex = e; -} -} else if (Clazz.exceptionOf (e$$, IllegalArgumentException)) { -var e = e$$; -{ -ex = e; -} -} else if (Clazz.exceptionOf (e$$, java.lang.reflect.InvocationTargetException)) { -var e = e$$; -{ -ex = e; -} -} else { -throw e$$; -} -} -if (ex != null) { -System.err.println ("Error in GenericFileAdapter: " + ex); -{ -alert(ex) -}}return null; -}, "~S,~A"); -c$.isJS = Clazz.defineMethod (c$, "isJS", -function () { -{ -return true; -}}); -c$.getReader = Clazz.defineMethod (c$, "getReader", -function (fileName, forceURL) { -if (!forceURL && !jalview.jsdev.GenericFileAdapter.isJS ()) return new java.io.BufferedReader ( new java.io.FileReader (fileName)); -if (fileName.indexOf ("//") < 0) fileName = "file://" + fileName; -return new java.io.BufferedReader ( new java.io.InputStreamReader ( new java.net.URL (fileName).openStream ())); -}, "~S,~B"); -}); +Clazz.declarePackage ("jalview.jsdev"); +Clazz.load (["jalview.io.AlignFile"], "jalview.jsdev.GenericFileAdapter", ["jalview.datamodel.AlignmentI", "jalview.io.FileParse", "java.io.BufferedReader", "$.InputStreamReader", "java.net.URL"], function () { +c$ = Clazz.declareType (jalview.jsdev, "GenericFileAdapter", jalview.io.AlignFile); +c$.getFile = Clazz.defineMethod (c$, "getFile", +function (fileType, params) { +var cl = null; +try { +cl = Class.forName ("jalview.io." + fileType); +} catch (e) { +if (Clazz.exceptionOf (e, ClassNotFoundException)) { +System.err.println ("did not find file jalview.io." + fileType); +return null; +} else { +throw e; +} +} +var m; +var ex = null; +try { +switch (params.length) { +case 0: +return cl.newInstance (); +case 1: +m = (Clazz.instanceOf (params[0], jalview.io.FileParse) ? cl.getConstructor ([jalview.io.FileParse]) : cl.getConstructor ([jalview.datamodel.AlignmentI])); +break; +case 2: +m = cl.getConstructor ([String, String]); +break; +default: +return null; +} +return m.newInstance (params); +} catch (e$$) { +if (Clazz.exceptionOf (e$$, InstantiationException)) { +var e = e$$; +{ +ex = e; +} +} else if (Clazz.exceptionOf (e$$, IllegalAccessException)) { +var e = e$$; +{ +ex = e; +} +} else if (Clazz.exceptionOf (e$$, NoSuchMethodException)) { +var e = e$$; +{ +ex = e; +} +} else if (Clazz.exceptionOf (e$$, SecurityException)) { +var e = e$$; +{ +ex = e; +} +} else if (Clazz.exceptionOf (e$$, IllegalArgumentException)) { +var e = e$$; +{ +ex = e; +} +} else if (Clazz.exceptionOf (e$$, java.lang.reflect.InvocationTargetException)) { +var e = e$$; +{ +ex = e; +} +} else { +throw e$$; +} +} +if (ex != null) { +System.err.println ("Error in GenericFileAdapter: " + ex); +{ +alert(ex) +}}return null; +}, "~S,~A"); +c$.isJS = Clazz.defineMethod (c$, "isJS", +function () { +{ +return true; +}}); +c$.getReader = Clazz.defineMethod (c$, "getReader", +function (fileName, forceURL) { +if (!forceURL && !jalview.jsdev.GenericFileAdapter.isJS ()) return new java.io.BufferedReader ( new java.io.FileReader (fileName)); +if (fileName.indexOf ("//") < 0) fileName = "file://" + fileName; +return new java.io.BufferedReader ( new java.io.InputStreamReader ( new java.net.URL (fileName).openStream ())); +}, "~S,~B"); +}); diff --git a/bin/jalview/jsdev/JSRegex.js b/bin/jalview/jsdev/JSRegex.js index 08e9c64..4dcc13e 100644 --- a/bin/jalview/jsdev/JSRegex.js +++ b/bin/jalview/jsdev/JSRegex.js @@ -1,55 +1,55 @@ -Clazz.declarePackage ("jalview.jsdev"); -Clazz.load (["jalview.jsdev.api.RegExpInterface"], "jalview.jsdev.JSRegex", null, function () { -c$ = Clazz.declareType (jalview.jsdev, "JSRegex", null, jalview.jsdev.api.RegExpInterface); -Clazz.overrideMethod (c$, "charsMatched", -function () { -return 0; -}); -Clazz.overrideMethod (c$, "left", -function () { -return null; -}); -Clazz.overrideMethod (c$, "matchedFrom", -function () { -return 0; -}); -Clazz.overrideMethod (c$, "matchedFromI", -function (pos) { -return 0; -}, "~N"); -Clazz.overrideMethod (c$, "matchedTo", -function () { -return 0; -}); -Clazz.overrideMethod (c$, "matchedToI", -function (pos) { -return 0; -}, "~N"); -Clazz.overrideMethod (c$, "numSubs", -function () { -return 0; -}); -Clazz.overrideMethod (c$, "replaceAll", -function (string) { -return null; -}, "~S"); -Clazz.overrideMethod (c$, "search", -function (str) { -return false; -}, "~S"); -Clazz.overrideMethod (c$, "searchFrom", -function (string, rematchat) { -return false; -}, "~S,~N"); -Clazz.overrideMethod (c$, "setIgnoreCase", -function (b) { -}, "~B"); -Clazz.overrideMethod (c$, "stringMatched", -function () { -return null; -}); -Clazz.overrideMethod (c$, "stringMatchedI", -function (i) { -return null; -}, "~N"); -}); +Clazz.declarePackage ("jalview.jsdev"); +Clazz.load (["jalview.jsdev.api.RegExpInterface"], "jalview.jsdev.JSRegex", null, function () { +c$ = Clazz.declareType (jalview.jsdev, "JSRegex", null, jalview.jsdev.api.RegExpInterface); +Clazz.overrideMethod (c$, "charsMatched", +function () { +return 0; +}); +Clazz.overrideMethod (c$, "left", +function () { +return null; +}); +Clazz.overrideMethod (c$, "matchedFrom", +function () { +return 0; +}); +Clazz.overrideMethod (c$, "matchedFromI", +function (pos) { +return 0; +}, "~N"); +Clazz.overrideMethod (c$, "matchedTo", +function () { +return 0; +}); +Clazz.overrideMethod (c$, "matchedToI", +function (pos) { +return 0; +}, "~N"); +Clazz.overrideMethod (c$, "numSubs", +function () { +return 0; +}); +Clazz.overrideMethod (c$, "replaceAll", +function (string) { +return null; +}, "~S"); +Clazz.overrideMethod (c$, "search", +function (str) { +return false; +}, "~S"); +Clazz.overrideMethod (c$, "searchFrom", +function (string, rematchat) { +return false; +}, "~S,~N"); +Clazz.overrideMethod (c$, "setIgnoreCase", +function (b) { +}, "~B"); +Clazz.overrideMethod (c$, "stringMatched", +function () { +return null; +}); +Clazz.overrideMethod (c$, "stringMatchedI", +function (i) { +return null; +}, "~N"); +}); diff --git a/bin/jalview/jsdev/JavaScriptRegExp.js b/bin/jalview/jsdev/JavaScriptRegExp.js index 5d67e59..735a4b6 100644 --- a/bin/jalview/jsdev/JavaScriptRegExp.js +++ b/bin/jalview/jsdev/JavaScriptRegExp.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.jsdev"); -Clazz.declareInterface (jalview.jsdev, "JavaScriptRegExp"); +Clazz.declarePackage ("jalview.jsdev"); +Clazz.declareInterface (jalview.jsdev, "JavaScriptRegExp"); diff --git a/bin/jalview/jsdev/RegExp.js b/bin/jalview/jsdev/RegExp.js index 8b2e026..ffb883f 100644 --- a/bin/jalview/jsdev/RegExp.js +++ b/bin/jalview/jsdev/RegExp.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("jalview.jsdev"); -Clazz.load (null, "jalview.jsdev.RegExp", ["com.stevesoft.pat.Regex"], function () { -c$ = Clazz.decorateAsClass (function () { -this.rg = null; -Clazz.instantialize (this, arguments); -}, jalview.jsdev, "RegExp"); -c$.newRegex = Clazz.defineMethod (c$, "newRegex", -function (params) { -return new com.stevesoft.pat.Regex (params.length < 1 ? null : params[0], params.length < 2 ? "" : params[1]); -}, "~A"); -c$.perlCode = Clazz.defineMethod (c$, "perlCode", -function (s) { -return com.stevesoft.pat.Regex.perlCode (s); -}, "~S"); -}); +Clazz.declarePackage ("jalview.jsdev"); +Clazz.load (null, "jalview.jsdev.RegExp", ["com.stevesoft.pat.Regex"], function () { +c$ = Clazz.decorateAsClass (function () { +this.rg = null; +Clazz.instantialize (this, arguments); +}, jalview.jsdev, "RegExp"); +c$.newRegex = Clazz.defineMethod (c$, "newRegex", +function (params) { +return new com.stevesoft.pat.Regex (params.length < 1 ? null : params[0], params.length < 2 ? "" : params[1]); +}, "~A"); +c$.perlCode = Clazz.defineMethod (c$, "perlCode", +function (s) { +return com.stevesoft.pat.Regex.perlCode (s); +}, "~S"); +}); diff --git a/bin/jalview/jsdev/api/RegExpInterface.js b/bin/jalview/jsdev/api/RegExpInterface.js index 48bb568..5dfe0cd 100644 --- a/bin/jalview/jsdev/api/RegExpInterface.js +++ b/bin/jalview/jsdev/api/RegExpInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.jsdev.api"); -Clazz.declareInterface (jalview.jsdev.api, "RegExpInterface"); +Clazz.declarePackage ("jalview.jsdev.api"); +Clazz.declareInterface (jalview.jsdev.api, "RegExpInterface"); diff --git a/bin/jalview/jsdev/api/VarnaRNA.js b/bin/jalview/jsdev/api/VarnaRNA.js index 1fa65f5..c2ec8a3 100644 --- a/bin/jalview/jsdev/api/VarnaRNA.js +++ b/bin/jalview/jsdev/api/VarnaRNA.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.jsdev.api"); -Clazz.declareInterface (jalview.jsdev.api, "VarnaRNA"); +Clazz.declarePackage ("jalview.jsdev.api"); +Clazz.declareInterface (jalview.jsdev.api, "VarnaRNA"); diff --git a/bin/jalview/math/AlignmentDimension.js b/bin/jalview/math/AlignmentDimension.js index 2a23983..178fe61 100644 --- a/bin/jalview/math/AlignmentDimension.js +++ b/bin/jalview/math/AlignmentDimension.js @@ -1,27 +1,27 @@ -Clazz.declarePackage ("jalview.math"); -c$ = Clazz.decorateAsClass (function () { -this.width = 0; -this.height = 0; -Clazz.instantialize (this, arguments); -}, jalview.math, "AlignmentDimension"); -Clazz.makeConstructor (c$, -function (width, height) { -this.width = width; -this.height = height; -}, "~N,~N"); -Clazz.defineMethod (c$, "getWidth", -function () { -return this.width; -}); -Clazz.defineMethod (c$, "setWidth", -function (width) { -this.width = width; -}, "~N"); -Clazz.defineMethod (c$, "getHeight", -function () { -return this.height; -}); -Clazz.defineMethod (c$, "setHeight", -function (height) { -this.height = height; -}, "~N"); +Clazz.declarePackage ("jalview.math"); +c$ = Clazz.decorateAsClass (function () { +this.width = 0; +this.height = 0; +Clazz.instantialize (this, arguments); +}, jalview.math, "AlignmentDimension"); +Clazz.makeConstructor (c$, +function (width, height) { +this.width = width; +this.height = height; +}, "~N,~N"); +Clazz.defineMethod (c$, "getWidth", +function () { +return this.width; +}); +Clazz.defineMethod (c$, "setWidth", +function (width) { +this.width = width; +}, "~N"); +Clazz.defineMethod (c$, "getHeight", +function () { +return this.height; +}); +Clazz.defineMethod (c$, "setHeight", +function (height) { +this.height = height; +}, "~N"); diff --git a/bin/jalview/math/Matrix.js b/bin/jalview/math/Matrix.js index 22cb59d..e260277 100644 --- a/bin/jalview/math/Matrix.js +++ b/bin/jalview/math/Matrix.js @@ -1,423 +1,423 @@ -Clazz.declarePackage ("jalview.math"); -Clazz.load (null, "jalview.math.Matrix", ["jalview.util.Format", "$.MessageManager", "java.lang.Exception"], function () { -c$ = Clazz.decorateAsClass (function () { -this.value = null; -this.rows = 0; -this.cols = 0; -this.d = null; -this.e = null; -this.maxIter = 45; -Clazz.instantialize (this, arguments); -}, jalview.math, "Matrix"); -Clazz.makeConstructor (c$, -function (value, rows, cols) { -this.rows = rows; -this.cols = cols; -this.value = value; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "transpose", -function () { -var out = Clazz.newDoubleArray (this.cols, this.rows, 0); -for (var i = 0; i < this.cols; i++) { -for (var j = 0; j < this.rows; j++) { -out[i][j] = this.value[j][i]; -} -} -return new jalview.math.Matrix (out, this.cols, this.rows); -}); -Clazz.defineMethod (c$, "print", -function (ps) { -for (var i = 0; i < this.rows; i++) { -for (var j = 0; j < this.cols; j++) { -jalview.util.Format.printDouble (ps, "%8.2f", this.value[i][j]); -} -ps.println (); -} -}, "java.io.PrintStream"); -Clazz.defineMethod (c$, "preMultiply", -function ($in) { -var tmp = Clazz.newDoubleArray ($in.rows, this.cols, 0); -for (var i = 0; i < $in.rows; i++) { -for (var j = 0; j < this.cols; j++) { -tmp[i][j] = 0.0; -for (var k = 0; k < $in.cols; k++) { -tmp[i][j] += ($in.value[i][k] * this.value[k][j]); -} -} -} -return new jalview.math.Matrix (tmp, $in.rows, this.cols); -}, "jalview.math.Matrix"); -Clazz.defineMethod (c$, "vectorPostMultiply", -function ($in) { -var out = Clazz.newDoubleArray ($in.length, 0); -for (var i = 0; i < $in.length; i++) { -out[i] = 0.0; -for (var k = 0; k < $in.length; k++) { -out[i] += (this.value[i][k] * $in[k]); -} -} -return out; -}, "~A"); -Clazz.defineMethod (c$, "postMultiply", -function ($in) { -var out = Clazz.newDoubleArray (this.rows, $in.cols, 0); -for (var i = 0; i < this.rows; i++) { -for (var j = 0; j < $in.cols; j++) { -out[i][j] = 0.0; -for (var k = 0; k < this.rows; k++) { -out[i][j] = out[i][j] + (this.value[i][k] * $in.value[k][j]); -} -} -} -return new jalview.math.Matrix (out, this.cols, $in.rows); -}, "jalview.math.Matrix"); -Clazz.defineMethod (c$, "copy", -function () { -var newmat = Clazz.newDoubleArray (this.rows, this.cols, 0); -for (var i = 0; i < this.rows; i++) { -for (var j = 0; j < this.cols; j++) { -newmat[i][j] = this.value[i][j]; -} -} -return new jalview.math.Matrix (newmat, this.rows, this.cols); -}); -Clazz.defineMethod (c$, "tred", -function () { -var n = this.rows; -var l; -var k; -var j; -var i; -var scale; -var hh; -var h; -var g; -var f; -this.d = Clazz.newDoubleArray (this.rows, 0); -this.e = Clazz.newDoubleArray (this.rows, 0); -for (i = n; i >= 2; i--) { -l = i - 1; -h = 0.0; -scale = 0.0; -if (l > 1) { -for (k = 1; k <= l; k++) { -scale += Math.abs (this.value[i - 1][k - 1]); -} -if (scale == 0.0) { -this.e[i - 1] = this.value[i - 1][l - 1]; -} else { -for (k = 1; k <= l; k++) { -this.value[i - 1][k - 1] /= scale; -h += (this.value[i - 1][k - 1] * this.value[i - 1][k - 1]); -} -f = this.value[i - 1][l - 1]; -if (f > 0) { -g = -1.0 * Math.sqrt (h); -} else { -g = Math.sqrt (h); -}this.e[i - 1] = scale * g; -h -= (f * g); -this.value[i - 1][l - 1] = f - g; -f = 0.0; -for (j = 1; j <= l; j++) { -this.value[j - 1][i - 1] = this.value[i - 1][j - 1] / h; -g = 0.0; -for (k = 1; k <= j; k++) { -g += (this.value[j - 1][k - 1] * this.value[i - 1][k - 1]); -} -for (k = j + 1; k <= l; k++) { -g += (this.value[k - 1][j - 1] * this.value[i - 1][k - 1]); -} -this.e[j - 1] = g / h; -f += (this.e[j - 1] * this.value[i - 1][j - 1]); -} -hh = f / (h + h); -for (j = 1; j <= l; j++) { -f = this.value[i - 1][j - 1]; -g = this.e[j - 1] - (hh * f); -this.e[j - 1] = g; -for (k = 1; k <= j; k++) { -this.value[j - 1][k - 1] -= ((f * this.e[k - 1]) + (g * this.value[i - 1][k - 1])); -} -} -}} else { -this.e[i - 1] = this.value[i - 1][l - 1]; -}this.d[i - 1] = h; -} -this.d[0] = 0.0; -this.e[0] = 0.0; -for (i = 1; i <= n; i++) { -l = i - 1; -if (this.d[i - 1] != 0.0) { -for (j = 1; j <= l; j++) { -g = 0.0; -for (k = 1; k <= l; k++) { -g += (this.value[i - 1][k - 1] * this.value[k - 1][j - 1]); -} -for (k = 1; k <= l; k++) { -this.value[k - 1][j - 1] -= (g * this.value[k - 1][i - 1]); -} -} -}this.d[i - 1] = this.value[i - 1][i - 1]; -this.value[i - 1][i - 1] = 1.0; -for (j = 1; j <= l; j++) { -this.value[j - 1][i - 1] = 0.0; -this.value[i - 1][j - 1] = 0.0; -} -} -}); -Clazz.defineMethod (c$, "tqli", -function () { -var n = this.rows; -var m; -var l; -var iter; -var i; -var k; -var s; -var r; -var p; -;var g; -var f; -var dd; -var c; -var b; -for (i = 2; i <= n; i++) { -this.e[i - 2] = this.e[i - 1]; -} -this.e[n - 1] = 0.0; -for (l = 1; l <= n; l++) { -iter = 0; -do { -for (m = l; m <= (n - 1); m++) { -dd = Math.abs (this.d[m - 1]) + Math.abs (this.d[m]); -if ((Math.abs (this.e[m - 1]) + dd) == dd) { -break; -}} -if (m != l) { -iter++; -if (iter == this.maxIter) { -throw new Exception (jalview.util.MessageManager.formatMessage ("exception.matrix_too_many_iteration", Clazz.newArray (-1, ["tqli", Integer.$valueOf (this.maxIter).toString ()]))); -} else { -}g = (this.d[l] - this.d[l - 1]) / (2.0 * this.e[l - 1]); -r = Math.sqrt ((g * g) + 1.0); -g = this.d[m - 1] - this.d[l - 1] + (this.e[l - 1] / (g + this.sign (r, g))); -c = 1.0; -s = c; -p = 0.0; -for (i = m - 1; i >= l; i--) { -f = s * this.e[i - 1]; -b = c * this.e[i - 1]; -if (Math.abs (f) >= Math.abs (g)) { -c = g / f; -r = Math.sqrt ((c * c) + 1.0); -this.e[i] = f * r; -s = 1.0 / r; -c *= s; -} else { -s = f / g; -r = Math.sqrt ((s * s) + 1.0); -this.e[i] = g * r; -c = 1.0 / r; -s *= c; -}g = this.d[i] - p; -r = ((this.d[i - 1] - g) * s) + (2.0 * c * b); -p = s * r; -this.d[i] = g + p; -g = (c * r) - b; -for (k = 1; k <= n; k++) { -f = this.value[k - 1][i]; -this.value[k - 1][i] = (s * this.value[k - 1][i - 1]) + (c * f); -this.value[k - 1][i - 1] = (c * this.value[k - 1][i - 1]) - (s * f); -} -} -this.d[l - 1] = this.d[l - 1] - p; -this.e[l - 1] = g; -this.e[m - 1] = 0.0; -}} while (m != l); -} -}); -Clazz.defineMethod (c$, "tred2", -function () { -var n = this.rows; -var l; -var k; -var j; -var i; -var scale; -var hh; -var h; -var g; -var f; -this.d = Clazz.newDoubleArray (this.rows, 0); -this.e = Clazz.newDoubleArray (this.rows, 0); -for (i = n - 1; i >= 1; i--) { -l = i - 1; -h = 0.0; -scale = 0.0; -if (l > 0) { -for (k = 0; k < l; k++) { -scale += Math.abs (this.value[i][k]); -} -if (scale == 0.0) { -this.e[i] = this.value[i][l]; -} else { -for (k = 0; k < l; k++) { -this.value[i][k] /= scale; -h += (this.value[i][k] * this.value[i][k]); -} -f = this.value[i][l]; -if (f > 0) { -g = -1.0 * Math.sqrt (h); -} else { -g = Math.sqrt (h); -}this.e[i] = scale * g; -h -= (f * g); -this.value[i][l] = f - g; -f = 0.0; -for (j = 0; j < l; j++) { -this.value[j][i] = this.value[i][j] / h; -g = 0.0; -for (k = 0; k < j; k++) { -g += (this.value[j][k] * this.value[i][k]); -} -for (k = j; k < l; k++) { -g += (this.value[k][j] * this.value[i][k]); -} -this.e[j] = g / h; -f += (this.e[j] * this.value[i][j]); -} -hh = f / (h + h); -for (j = 0; j < l; j++) { -f = this.value[i][j]; -g = this.e[j] - (hh * f); -this.e[j] = g; -for (k = 0; k < j; k++) { -this.value[j][k] -= ((f * this.e[k]) + (g * this.value[i][k])); -} -} -}} else { -this.e[i] = this.value[i][l]; -}this.d[i] = h; -} -this.d[0] = 0.0; -this.e[0] = 0.0; -for (i = 0; i < n; i++) { -l = i - 1; -if (this.d[i] != 0.0) { -for (j = 0; j < l; j++) { -g = 0.0; -for (k = 0; k < l; k++) { -g += (this.value[i][k] * this.value[k][j]); -} -for (k = 0; k < l; k++) { -this.value[k][j] -= (g * this.value[k][i]); -} -} -}this.d[i] = this.value[i][i]; -this.value[i][i] = 1.0; -for (j = 0; j < l; j++) { -this.value[j][i] = 0.0; -this.value[i][j] = 0.0; -} -} -}); -Clazz.defineMethod (c$, "tqli2", -function () { -var n = this.rows; -var m; -var l; -var iter; -var i; -var k; -var s; -var r; -var p; -;var g; -var f; -var dd; -var c; -var b; -for (i = 2; i <= n; i++) { -this.e[i - 2] = this.e[i - 1]; -} -this.e[n - 1] = 0.0; -for (l = 1; l <= n; l++) { -iter = 0; -do { -for (m = l; m <= (n - 1); m++) { -dd = Math.abs (this.d[m - 1]) + Math.abs (this.d[m]); -if ((Math.abs (this.e[m - 1]) + dd) == dd) { -break; -}} -if (m != l) { -iter++; -if (iter == this.maxIter) { -throw new Exception (jalview.util.MessageManager.formatMessage ("exception.matrix_too_many_iteration", Clazz.newArray (-1, ["tqli2", Integer.$valueOf (this.maxIter).toString ()]))); -} else { -}g = (this.d[l] - this.d[l - 1]) / (2.0 * this.e[l - 1]); -r = Math.sqrt ((g * g) + 1.0); -g = this.d[m - 1] - this.d[l - 1] + (this.e[l - 1] / (g + this.sign (r, g))); -c = 1.0; -s = c; -p = 0.0; -for (i = m - 1; i >= l; i--) { -f = s * this.e[i - 1]; -b = c * this.e[i - 1]; -if (Math.abs (f) >= Math.abs (g)) { -c = g / f; -r = Math.sqrt ((c * c) + 1.0); -this.e[i] = f * r; -s = 1.0 / r; -c *= s; -} else { -s = f / g; -r = Math.sqrt ((s * s) + 1.0); -this.e[i] = g * r; -c = 1.0 / r; -s *= c; -}g = this.d[i] - p; -r = ((this.d[i - 1] - g) * s) + (2.0 * c * b); -p = s * r; -this.d[i] = g + p; -g = (c * r) - b; -for (k = 1; k <= n; k++) { -f = this.value[k - 1][i]; -this.value[k - 1][i] = (s * this.value[k - 1][i - 1]) + (c * f); -this.value[k - 1][i - 1] = (c * this.value[k - 1][i - 1]) - (s * f); -} -} -this.d[l - 1] = this.d[l - 1] - p; -this.e[l - 1] = g; -this.e[m - 1] = 0.0; -}} while (m != l); -} -}); -Clazz.defineMethod (c$, "sign", -function (a, b) { -if (b < 0) { -return -Math.abs (a); -} else { -return Math.abs (a); -}}, "~N,~N"); -Clazz.defineMethod (c$, "getColumn", -function (n) { -var out = Clazz.newDoubleArray (this.rows, 0); -for (var i = 0; i < this.rows; i++) { -out[i] = this.value[i][n]; -} -return out; -}, "~N"); -Clazz.defineMethod (c$, "printD", -function (ps) { -for (var j = 0; j < this.rows; j++) { -jalview.util.Format.printDouble (ps, "%15.4e", this.d[j]); -} -}, "java.io.PrintStream"); -Clazz.defineMethod (c$, "printE", -function (ps) { -for (var j = 0; j < this.rows; j++) { -jalview.util.Format.printDouble (ps, "%15.4e", this.e[j]); -} -}, "java.io.PrintStream"); -}); +Clazz.declarePackage ("jalview.math"); +Clazz.load (null, "jalview.math.Matrix", ["jalview.util.Format", "$.MessageManager", "java.lang.Exception"], function () { +c$ = Clazz.decorateAsClass (function () { +this.value = null; +this.rows = 0; +this.cols = 0; +this.d = null; +this.e = null; +this.maxIter = 45; +Clazz.instantialize (this, arguments); +}, jalview.math, "Matrix"); +Clazz.makeConstructor (c$, +function (value, rows, cols) { +this.rows = rows; +this.cols = cols; +this.value = value; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "transpose", +function () { +var out = Clazz.newDoubleArray (this.cols, this.rows, 0); +for (var i = 0; i < this.cols; i++) { +for (var j = 0; j < this.rows; j++) { +out[i][j] = this.value[j][i]; +} +} +return new jalview.math.Matrix (out, this.cols, this.rows); +}); +Clazz.defineMethod (c$, "print", +function (ps) { +for (var i = 0; i < this.rows; i++) { +for (var j = 0; j < this.cols; j++) { +jalview.util.Format.printDouble (ps, "%8.2f", this.value[i][j]); +} +ps.println (); +} +}, "java.io.PrintStream"); +Clazz.defineMethod (c$, "preMultiply", +function ($in) { +var tmp = Clazz.newDoubleArray ($in.rows, this.cols, 0); +for (var i = 0; i < $in.rows; i++) { +for (var j = 0; j < this.cols; j++) { +tmp[i][j] = 0.0; +for (var k = 0; k < $in.cols; k++) { +tmp[i][j] += ($in.value[i][k] * this.value[k][j]); +} +} +} +return new jalview.math.Matrix (tmp, $in.rows, this.cols); +}, "jalview.math.Matrix"); +Clazz.defineMethod (c$, "vectorPostMultiply", +function ($in) { +var out = Clazz.newDoubleArray ($in.length, 0); +for (var i = 0; i < $in.length; i++) { +out[i] = 0.0; +for (var k = 0; k < $in.length; k++) { +out[i] += (this.value[i][k] * $in[k]); +} +} +return out; +}, "~A"); +Clazz.defineMethod (c$, "postMultiply", +function ($in) { +var out = Clazz.newDoubleArray (this.rows, $in.cols, 0); +for (var i = 0; i < this.rows; i++) { +for (var j = 0; j < $in.cols; j++) { +out[i][j] = 0.0; +for (var k = 0; k < this.rows; k++) { +out[i][j] = out[i][j] + (this.value[i][k] * $in.value[k][j]); +} +} +} +return new jalview.math.Matrix (out, this.cols, $in.rows); +}, "jalview.math.Matrix"); +Clazz.defineMethod (c$, "copy", +function () { +var newmat = Clazz.newDoubleArray (this.rows, this.cols, 0); +for (var i = 0; i < this.rows; i++) { +for (var j = 0; j < this.cols; j++) { +newmat[i][j] = this.value[i][j]; +} +} +return new jalview.math.Matrix (newmat, this.rows, this.cols); +}); +Clazz.defineMethod (c$, "tred", +function () { +var n = this.rows; +var l; +var k; +var j; +var i; +var scale; +var hh; +var h; +var g; +var f; +this.d = Clazz.newDoubleArray (this.rows, 0); +this.e = Clazz.newDoubleArray (this.rows, 0); +for (i = n; i >= 2; i--) { +l = i - 1; +h = 0.0; +scale = 0.0; +if (l > 1) { +for (k = 1; k <= l; k++) { +scale += Math.abs (this.value[i - 1][k - 1]); +} +if (scale == 0.0) { +this.e[i - 1] = this.value[i - 1][l - 1]; +} else { +for (k = 1; k <= l; k++) { +this.value[i - 1][k - 1] /= scale; +h += (this.value[i - 1][k - 1] * this.value[i - 1][k - 1]); +} +f = this.value[i - 1][l - 1]; +if (f > 0) { +g = -1.0 * Math.sqrt (h); +} else { +g = Math.sqrt (h); +}this.e[i - 1] = scale * g; +h -= (f * g); +this.value[i - 1][l - 1] = f - g; +f = 0.0; +for (j = 1; j <= l; j++) { +this.value[j - 1][i - 1] = this.value[i - 1][j - 1] / h; +g = 0.0; +for (k = 1; k <= j; k++) { +g += (this.value[j - 1][k - 1] * this.value[i - 1][k - 1]); +} +for (k = j + 1; k <= l; k++) { +g += (this.value[k - 1][j - 1] * this.value[i - 1][k - 1]); +} +this.e[j - 1] = g / h; +f += (this.e[j - 1] * this.value[i - 1][j - 1]); +} +hh = f / (h + h); +for (j = 1; j <= l; j++) { +f = this.value[i - 1][j - 1]; +g = this.e[j - 1] - (hh * f); +this.e[j - 1] = g; +for (k = 1; k <= j; k++) { +this.value[j - 1][k - 1] -= ((f * this.e[k - 1]) + (g * this.value[i - 1][k - 1])); +} +} +}} else { +this.e[i - 1] = this.value[i - 1][l - 1]; +}this.d[i - 1] = h; +} +this.d[0] = 0.0; +this.e[0] = 0.0; +for (i = 1; i <= n; i++) { +l = i - 1; +if (this.d[i - 1] != 0.0) { +for (j = 1; j <= l; j++) { +g = 0.0; +for (k = 1; k <= l; k++) { +g += (this.value[i - 1][k - 1] * this.value[k - 1][j - 1]); +} +for (k = 1; k <= l; k++) { +this.value[k - 1][j - 1] -= (g * this.value[k - 1][i - 1]); +} +} +}this.d[i - 1] = this.value[i - 1][i - 1]; +this.value[i - 1][i - 1] = 1.0; +for (j = 1; j <= l; j++) { +this.value[j - 1][i - 1] = 0.0; +this.value[i - 1][j - 1] = 0.0; +} +} +}); +Clazz.defineMethod (c$, "tqli", +function () { +var n = this.rows; +var m; +var l; +var iter; +var i; +var k; +var s; +var r; +var p; +;var g; +var f; +var dd; +var c; +var b; +for (i = 2; i <= n; i++) { +this.e[i - 2] = this.e[i - 1]; +} +this.e[n - 1] = 0.0; +for (l = 1; l <= n; l++) { +iter = 0; +do { +for (m = l; m <= (n - 1); m++) { +dd = Math.abs (this.d[m - 1]) + Math.abs (this.d[m]); +if ((Math.abs (this.e[m - 1]) + dd) == dd) { +break; +}} +if (m != l) { +iter++; +if (iter == this.maxIter) { +throw new Exception (jalview.util.MessageManager.formatMessage ("exception.matrix_too_many_iteration", Clazz.newArray (-1, ["tqli", Integer.$valueOf (this.maxIter).toString ()]))); +} else { +}g = (this.d[l] - this.d[l - 1]) / (2.0 * this.e[l - 1]); +r = Math.sqrt ((g * g) + 1.0); +g = this.d[m - 1] - this.d[l - 1] + (this.e[l - 1] / (g + this.sign (r, g))); +c = 1.0; +s = c; +p = 0.0; +for (i = m - 1; i >= l; i--) { +f = s * this.e[i - 1]; +b = c * this.e[i - 1]; +if (Math.abs (f) >= Math.abs (g)) { +c = g / f; +r = Math.sqrt ((c * c) + 1.0); +this.e[i] = f * r; +s = 1.0 / r; +c *= s; +} else { +s = f / g; +r = Math.sqrt ((s * s) + 1.0); +this.e[i] = g * r; +c = 1.0 / r; +s *= c; +}g = this.d[i] - p; +r = ((this.d[i - 1] - g) * s) + (2.0 * c * b); +p = s * r; +this.d[i] = g + p; +g = (c * r) - b; +for (k = 1; k <= n; k++) { +f = this.value[k - 1][i]; +this.value[k - 1][i] = (s * this.value[k - 1][i - 1]) + (c * f); +this.value[k - 1][i - 1] = (c * this.value[k - 1][i - 1]) - (s * f); +} +} +this.d[l - 1] = this.d[l - 1] - p; +this.e[l - 1] = g; +this.e[m - 1] = 0.0; +}} while (m != l); +} +}); +Clazz.defineMethod (c$, "tred2", +function () { +var n = this.rows; +var l; +var k; +var j; +var i; +var scale; +var hh; +var h; +var g; +var f; +this.d = Clazz.newDoubleArray (this.rows, 0); +this.e = Clazz.newDoubleArray (this.rows, 0); +for (i = n - 1; i >= 1; i--) { +l = i - 1; +h = 0.0; +scale = 0.0; +if (l > 0) { +for (k = 0; k < l; k++) { +scale += Math.abs (this.value[i][k]); +} +if (scale == 0.0) { +this.e[i] = this.value[i][l]; +} else { +for (k = 0; k < l; k++) { +this.value[i][k] /= scale; +h += (this.value[i][k] * this.value[i][k]); +} +f = this.value[i][l]; +if (f > 0) { +g = -1.0 * Math.sqrt (h); +} else { +g = Math.sqrt (h); +}this.e[i] = scale * g; +h -= (f * g); +this.value[i][l] = f - g; +f = 0.0; +for (j = 0; j < l; j++) { +this.value[j][i] = this.value[i][j] / h; +g = 0.0; +for (k = 0; k < j; k++) { +g += (this.value[j][k] * this.value[i][k]); +} +for (k = j; k < l; k++) { +g += (this.value[k][j] * this.value[i][k]); +} +this.e[j] = g / h; +f += (this.e[j] * this.value[i][j]); +} +hh = f / (h + h); +for (j = 0; j < l; j++) { +f = this.value[i][j]; +g = this.e[j] - (hh * f); +this.e[j] = g; +for (k = 0; k < j; k++) { +this.value[j][k] -= ((f * this.e[k]) + (g * this.value[i][k])); +} +} +}} else { +this.e[i] = this.value[i][l]; +}this.d[i] = h; +} +this.d[0] = 0.0; +this.e[0] = 0.0; +for (i = 0; i < n; i++) { +l = i - 1; +if (this.d[i] != 0.0) { +for (j = 0; j < l; j++) { +g = 0.0; +for (k = 0; k < l; k++) { +g += (this.value[i][k] * this.value[k][j]); +} +for (k = 0; k < l; k++) { +this.value[k][j] -= (g * this.value[k][i]); +} +} +}this.d[i] = this.value[i][i]; +this.value[i][i] = 1.0; +for (j = 0; j < l; j++) { +this.value[j][i] = 0.0; +this.value[i][j] = 0.0; +} +} +}); +Clazz.defineMethod (c$, "tqli2", +function () { +var n = this.rows; +var m; +var l; +var iter; +var i; +var k; +var s; +var r; +var p; +;var g; +var f; +var dd; +var c; +var b; +for (i = 2; i <= n; i++) { +this.e[i - 2] = this.e[i - 1]; +} +this.e[n - 1] = 0.0; +for (l = 1; l <= n; l++) { +iter = 0; +do { +for (m = l; m <= (n - 1); m++) { +dd = Math.abs (this.d[m - 1]) + Math.abs (this.d[m]); +if ((Math.abs (this.e[m - 1]) + dd) == dd) { +break; +}} +if (m != l) { +iter++; +if (iter == this.maxIter) { +throw new Exception (jalview.util.MessageManager.formatMessage ("exception.matrix_too_many_iteration", Clazz.newArray (-1, ["tqli2", Integer.$valueOf (this.maxIter).toString ()]))); +} else { +}g = (this.d[l] - this.d[l - 1]) / (2.0 * this.e[l - 1]); +r = Math.sqrt ((g * g) + 1.0); +g = this.d[m - 1] - this.d[l - 1] + (this.e[l - 1] / (g + this.sign (r, g))); +c = 1.0; +s = c; +p = 0.0; +for (i = m - 1; i >= l; i--) { +f = s * this.e[i - 1]; +b = c * this.e[i - 1]; +if (Math.abs (f) >= Math.abs (g)) { +c = g / f; +r = Math.sqrt ((c * c) + 1.0); +this.e[i] = f * r; +s = 1.0 / r; +c *= s; +} else { +s = f / g; +r = Math.sqrt ((s * s) + 1.0); +this.e[i] = g * r; +c = 1.0 / r; +s *= c; +}g = this.d[i] - p; +r = ((this.d[i - 1] - g) * s) + (2.0 * c * b); +p = s * r; +this.d[i] = g + p; +g = (c * r) - b; +for (k = 1; k <= n; k++) { +f = this.value[k - 1][i]; +this.value[k - 1][i] = (s * this.value[k - 1][i - 1]) + (c * f); +this.value[k - 1][i - 1] = (c * this.value[k - 1][i - 1]) - (s * f); +} +} +this.d[l - 1] = this.d[l - 1] - p; +this.e[l - 1] = g; +this.e[m - 1] = 0.0; +}} while (m != l); +} +}); +Clazz.defineMethod (c$, "sign", +function (a, b) { +if (b < 0) { +return -Math.abs (a); +} else { +return Math.abs (a); +}}, "~N,~N"); +Clazz.defineMethod (c$, "getColumn", +function (n) { +var out = Clazz.newDoubleArray (this.rows, 0); +for (var i = 0; i < this.rows; i++) { +out[i] = this.value[i][n]; +} +return out; +}, "~N"); +Clazz.defineMethod (c$, "printD", +function (ps) { +for (var j = 0; j < this.rows; j++) { +jalview.util.Format.printDouble (ps, "%15.4e", this.d[j]); +} +}, "java.io.PrintStream"); +Clazz.defineMethod (c$, "printE", +function (ps) { +for (var j = 0; j < this.rows; j++) { +jalview.util.Format.printDouble (ps, "%15.4e", this.e[j]); +} +}, "java.io.PrintStream"); +}); diff --git a/bin/jalview/math/RotatableMatrix.js b/bin/jalview/math/RotatableMatrix.js index bec7c23..12195ca 100644 --- a/bin/jalview/math/RotatableMatrix.js +++ b/bin/jalview/math/RotatableMatrix.js @@ -1,114 +1,114 @@ -Clazz.declarePackage ("jalview.math"); -c$ = Clazz.decorateAsClass (function () { -this.matrix = null; -this.temp = null; -this.rot = null; -Clazz.instantialize (this, arguments); -}, jalview.math, "RotatableMatrix"); -Clazz.makeConstructor (c$, -function (rows, cols) { -this.matrix = Clazz.newFloatArray (rows, cols, 0); -this.temp = Clazz.newFloatArray (3, 0); -this.rot = Clazz.newFloatArray (3, 3, 0); -}, "~N,~N"); -Clazz.defineMethod (c$, "addElement", -function (i, j, value) { -this.matrix[i][j] = value; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "print", -function () { -System.out.println (this.matrix[0][0] + " " + this.matrix[0][1] + " " + this.matrix[0][2]); -System.out.println (this.matrix[1][0] + " " + this.matrix[1][1] + " " + this.matrix[1][2]); -System.out.println (this.matrix[2][0] + " " + this.matrix[2][1] + " " + this.matrix[2][2]); -}); -Clazz.defineMethod (c$, "rotate", -function (degrees, axis) { -var costheta = Math.cos ((degrees * 3.141592653589793) / 180.0); -var sintheta = Math.sin ((degrees * 3.141592653589793) / 180.0); -if (axis == 'z') { -this.rot[0][0] = costheta; -this.rot[0][1] = -sintheta; -this.rot[0][2] = 0.0; -this.rot[1][0] = sintheta; -this.rot[1][1] = costheta; -this.rot[1][2] = 0.0; -this.rot[2][0] = 0.0; -this.rot[2][1] = 0.0; -this.rot[2][2] = 1.0; -this.preMultiply (this.rot); -}if (axis == 'x') { -this.rot[0][0] = 1.0; -this.rot[0][1] = 0.0; -this.rot[0][2] = 0.0; -this.rot[1][0] = 0.0; -this.rot[1][1] = costheta; -this.rot[1][2] = sintheta; -this.rot[2][0] = 0.0; -this.rot[2][1] = -sintheta; -this.rot[2][2] = costheta; -this.preMultiply (this.rot); -}if (axis == 'y') { -this.rot[0][0] = costheta; -this.rot[0][1] = 0.0; -this.rot[0][2] = -sintheta; -this.rot[1][0] = 0.0; -this.rot[1][1] = 1.0; -this.rot[1][2] = 0.0; -this.rot[2][0] = sintheta; -this.rot[2][1] = 0.0; -this.rot[2][2] = costheta; -this.preMultiply (this.rot); -}}, "~N,~S"); -Clazz.defineMethod (c$, "vectorMultiply", -function (vect) { -this.temp[0] = vect[0]; -this.temp[1] = vect[1]; -this.temp[2] = vect[2]; -for (var i = 0; i < 3; i++) { -this.temp[i] = (this.matrix[i][0] * vect[0]) + (this.matrix[i][1] * vect[1]) + (this.matrix[i][2] * vect[2]); -} -vect[0] = this.temp[0]; -vect[1] = this.temp[1]; -vect[2] = this.temp[2]; -return vect; -}, "~A"); -Clazz.defineMethod (c$, "preMultiply", -function (mat) { -var tmp = Clazz.newFloatArray (3, 3, 0); -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -tmp[i][j] = (mat[i][0] * this.matrix[0][j]) + (mat[i][1] * this.matrix[1][j]) + (mat[i][2] * this.matrix[2][j]); -} -} -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -this.matrix[i][j] = tmp[i][j]; -} -} -}, "~A"); -Clazz.defineMethod (c$, "postMultiply", -function (mat) { -var tmp = Clazz.newFloatArray (3, 3, 0); -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -tmp[i][j] = (this.matrix[i][0] * mat[0][j]) + (this.matrix[i][1] * mat[1][j]) + (this.matrix[i][2] * mat[2][j]); -} -} -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -this.matrix[i][j] = tmp[i][j]; -} -} -}, "~A"); -Clazz.defineMethod (c$, "setIdentity", -function () { -this.matrix[0][0] = 1.0; -this.matrix[1][1] = 1.0; -this.matrix[2][2] = 1.0; -this.matrix[0][1] = 0.0; -this.matrix[0][2] = 0.0; -this.matrix[1][0] = 0.0; -this.matrix[1][2] = 0.0; -this.matrix[2][0] = 0.0; -this.matrix[2][1] = 0.0; -}); +Clazz.declarePackage ("jalview.math"); +c$ = Clazz.decorateAsClass (function () { +this.matrix = null; +this.temp = null; +this.rot = null; +Clazz.instantialize (this, arguments); +}, jalview.math, "RotatableMatrix"); +Clazz.makeConstructor (c$, +function (rows, cols) { +this.matrix = Clazz.newFloatArray (rows, cols, 0); +this.temp = Clazz.newFloatArray (3, 0); +this.rot = Clazz.newFloatArray (3, 3, 0); +}, "~N,~N"); +Clazz.defineMethod (c$, "addElement", +function (i, j, value) { +this.matrix[i][j] = value; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "print", +function () { +System.out.println (this.matrix[0][0] + " " + this.matrix[0][1] + " " + this.matrix[0][2]); +System.out.println (this.matrix[1][0] + " " + this.matrix[1][1] + " " + this.matrix[1][2]); +System.out.println (this.matrix[2][0] + " " + this.matrix[2][1] + " " + this.matrix[2][2]); +}); +Clazz.defineMethod (c$, "rotate", +function (degrees, axis) { +var costheta = Math.cos ((degrees * 3.141592653589793) / 180.0); +var sintheta = Math.sin ((degrees * 3.141592653589793) / 180.0); +if (axis == 'z') { +this.rot[0][0] = costheta; +this.rot[0][1] = -sintheta; +this.rot[0][2] = 0.0; +this.rot[1][0] = sintheta; +this.rot[1][1] = costheta; +this.rot[1][2] = 0.0; +this.rot[2][0] = 0.0; +this.rot[2][1] = 0.0; +this.rot[2][2] = 1.0; +this.preMultiply (this.rot); +}if (axis == 'x') { +this.rot[0][0] = 1.0; +this.rot[0][1] = 0.0; +this.rot[0][2] = 0.0; +this.rot[1][0] = 0.0; +this.rot[1][1] = costheta; +this.rot[1][2] = sintheta; +this.rot[2][0] = 0.0; +this.rot[2][1] = -sintheta; +this.rot[2][2] = costheta; +this.preMultiply (this.rot); +}if (axis == 'y') { +this.rot[0][0] = costheta; +this.rot[0][1] = 0.0; +this.rot[0][2] = -sintheta; +this.rot[1][0] = 0.0; +this.rot[1][1] = 1.0; +this.rot[1][2] = 0.0; +this.rot[2][0] = sintheta; +this.rot[2][1] = 0.0; +this.rot[2][2] = costheta; +this.preMultiply (this.rot); +}}, "~N,~S"); +Clazz.defineMethod (c$, "vectorMultiply", +function (vect) { +this.temp[0] = vect[0]; +this.temp[1] = vect[1]; +this.temp[2] = vect[2]; +for (var i = 0; i < 3; i++) { +this.temp[i] = (this.matrix[i][0] * vect[0]) + (this.matrix[i][1] * vect[1]) + (this.matrix[i][2] * vect[2]); +} +vect[0] = this.temp[0]; +vect[1] = this.temp[1]; +vect[2] = this.temp[2]; +return vect; +}, "~A"); +Clazz.defineMethod (c$, "preMultiply", +function (mat) { +var tmp = Clazz.newFloatArray (3, 3, 0); +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +tmp[i][j] = (mat[i][0] * this.matrix[0][j]) + (mat[i][1] * this.matrix[1][j]) + (mat[i][2] * this.matrix[2][j]); +} +} +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +this.matrix[i][j] = tmp[i][j]; +} +} +}, "~A"); +Clazz.defineMethod (c$, "postMultiply", +function (mat) { +var tmp = Clazz.newFloatArray (3, 3, 0); +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +tmp[i][j] = (this.matrix[i][0] * mat[0][j]) + (this.matrix[i][1] * mat[1][j]) + (this.matrix[i][2] * mat[2][j]); +} +} +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +this.matrix[i][j] = tmp[i][j]; +} +} +}, "~A"); +Clazz.defineMethod (c$, "setIdentity", +function () { +this.matrix[0][0] = 1.0; +this.matrix[1][1] = 1.0; +this.matrix[2][2] = 1.0; +this.matrix[0][1] = 0.0; +this.matrix[0][2] = 0.0; +this.matrix[1][0] = 0.0; +this.matrix[1][2] = 0.0; +this.matrix[2][0] = 0.0; +this.matrix[2][1] = 0.0; +}); diff --git a/bin/jalview/renderer/AnnotationRenderer.js b/bin/jalview/renderer/AnnotationRenderer.js index 221e5d3..00d98e4 100644 --- a/bin/jalview/renderer/AnnotationRenderer.js +++ b/bin/jalview/renderer/AnnotationRenderer.js @@ -1,805 +1,805 @@ -Clazz.declarePackage ("jalview.renderer"); -Clazz.load (["jalview.util.Platform", "java.awt.Color"], "jalview.renderer.AnnotationRenderer", ["jalview.analysis.AAFrequency", "$.CodingUtils", "$.StructureFrequency", "jalview.jsdev.RegExp", "jalview.schemes.NucleotideColourScheme", "$.ResidueProperties", "$.ZappoColourScheme", "java.awt.BasicStroke", "java.awt.geom.AffineTransform", "java.util.BitSet"], function () { -c$ = Clazz.decorateAsClass (function () { -this.debugRedraw = false; -this.charWidth = 0; -this.endRes = 0; -this.charHeight = 0; -this.validCharWidth = false; -this.hasHiddenColumns = false; -this.fm = null; -this.MAC = false; -this.av_renderHistogram = true; -this.av_renderProfile = true; -this.av_normaliseProfile = false; -this.profcolour = null; -this.columnSelection = null; -this.hconsensus = null; -this.complementConsensus = null; -this.hStrucConsensus = null; -this.av_ignoreGapsConsensus = false; -this.fadedImage = null; -this.annotationPanel = null; -this.imgWidth = 0; -this.sOffset = 0; -this.visHeight = 0; -this.useClip = true; -this.canClip = false; -this.rna = false; -this.sdNOTCANONICAL_COLOUR = null; -Clazz.instantialize (this, arguments); -}, jalview.renderer, "AnnotationRenderer"); -Clazz.prepareFields (c$, function () { -this.MAC = jalview.util.Platform.isAMac (); -}); -Clazz.makeConstructor (c$, -function () { -this.construct (false); -}); -Clazz.makeConstructor (c$, -function (debugRedraw) { -this.debugRedraw = debugRedraw; -}, "~B"); -Clazz.defineMethod (c$, "drawStemAnnot", -function (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.STEM_COLOUR); -var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; -var x1 = lastSSX; -var x2 = (x * this.charWidth); -var closeparen = jalview.jsdev.RegExp.newRegex (["(\\))"]); -var dc = (column == 0 || row_annotations[column - 1] == null) ? ' ' : row_annotations[column - 1].secondaryStructure; -var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || dc != row_annotations[sCol - 1].secondaryStructure; -var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || dc != row_annotations[column].secondaryStructure; -if (column > 0 && jalview.schemes.ResidueProperties.isCloseParenRNA (dc)) { -if (diffupstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x1 += 5; -}if (diffdownstream) { -x2 -= 1; -}} else { -if (diffdownstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x2 -= 5; -}if (diffupstream) { -x1 += 1; -}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); -}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawNotCanonicalAnnot", -function (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (nonCanColor); -var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; -var x1 = lastSSX; -var x2 = (x * this.charWidth); -var closeparen = jalview.jsdev.RegExp.newRegex (["}|]|<|[a-z]"]); -var dc = (column == 0 || row_annotations[column - 1] == null) ? "" : row_annotations[column - 1].displayCharacter; -var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || !dc.equals (row_annotations[sCol - 1].displayCharacter); -var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || !dc.equals (row_annotations[column].displayCharacter); -if (column > 0 && closeparen.search (dc)) { -if (diffupstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x1 += 5; -}if (diffdownstream) { -x2 -= 1; -}} else { -if (diffdownstream) { -g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); -x2 -= 5; -}if (diffupstream) { -x1 += 1; -}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); -}, "java.awt.Graphics,java.awt.Color,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "updateFromAwtRenderPanel", -function (annotPanel, av) { -this.fm = annotPanel.getFontMetrics (); -this.annotationPanel = annotPanel; -this.fadedImage = annotPanel.getFadedImage (); -this.imgWidth = annotPanel.getFadedImageWidth (); -var bounds = annotPanel.getVisibleVRange (); -if (bounds != null) { -this.sOffset = bounds[0]; -this.visHeight = bounds[1]; -if (this.visHeight == 0) { -this.useClip = false; -} else { -this.useClip = this.canClip; -}} else { -this.useClip = false; -}this.updateFromAlignViewport (av); -}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI"); -Clazz.defineMethod (c$, "updateFromAlignViewport", -function (av) { -this.charWidth = av.getCharWidth (); -this.endRes = av.getEndRes (); -this.charHeight = av.getCharHeight (); -this.hasHiddenColumns = av.hasHiddenColumns (); -this.validCharWidth = av.isValidCharWidth (); -this.av_renderHistogram = av.isShowConsensusHistogram (); -this.av_renderProfile = av.isShowSequenceLogo (); -this.av_normaliseProfile = av.isNormaliseSequenceLogo (); -this.profcolour = av.getGlobalColourScheme (); -if (this.profcolour == null) { -this.profcolour = av.getAlignment ().isNucleotide () ? new jalview.schemes.NucleotideColourScheme () : new jalview.schemes.ZappoColourScheme (); -}this.columnSelection = av.getColumnSelection (); -this.hconsensus = av.getSequenceConsensusHash (); -this.complementConsensus = av.getComplementConsensusHash (); -this.hStrucConsensus = av.getRnaStructureConsensusHash (); -this.av_ignoreGapsConsensus = av.isIgnoreGapsConsensus (); -}, "jalview.api.AlignViewportI"); -Clazz.defineMethod (c$, "getProfileFor", -function (aa, column) { -if (aa.autoCalculated && (aa.label.startsWith ("Consensus") || aa.label.startsWith ("cDNA Consensus"))) { -var forComplement = aa.label.startsWith ("cDNA Consensus"); -if (aa.groupRef != null && aa.groupRef.consensusData != null && aa.groupRef.isShowSequenceLogo ()) { -return jalview.analysis.AAFrequency.extractProfile (aa.groupRef.consensusData[column], aa.groupRef.getIgnoreGapsConsensus ()); -}if (aa.groupRef == null && aa.sequenceRef == null) { -if (forComplement) { -return jalview.analysis.AAFrequency.extractCdnaProfile (this.complementConsensus[column], this.av_ignoreGapsConsensus); -} else { -return jalview.analysis.AAFrequency.extractProfile (this.hconsensus[column], this.av_ignoreGapsConsensus); -}}} else { -if (aa.autoCalculated && aa.label.startsWith ("StrucConsensus")) { -if (aa.groupRef == null && aa.sequenceRef == null && this.hStrucConsensus != null && this.hStrucConsensus.length > column) { -return jalview.analysis.StructureFrequency.extractProfile (this.hStrucConsensus[column], this.av_ignoreGapsConsensus); -}}}return null; -}, "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.defineMethod (c$, "drawComponent", -function (annotPanel, av, g, activeRow, startRes, endRes) { -var stime = System.currentTimeMillis (); -var usedFaded = false; -this.updateFromAwtRenderPanel (annotPanel, av); -this.fm = g.getFontMetrics (); -var aa = av.getAlignment ().getAlignmentAnnotation (); -var temp = 0; -if (aa == null) { -return false; -}var x = 0; -var y = 0; -var column = 0; -var lastSS; -var lastSSX; -var iconOffset = 0; -var validRes = false; -var validEnd = false; -var labelAllCols = false; -var centreColLabels; -var centreColLabelsDef = av.isCentreColumnLabels (); -var scaleColLabel = false; -var consensusAnnot = av.getAlignmentConsensusAnnotation (); -var structConsensusAnnot = av.getAlignmentStrucConsensusAnnotation (); -var complementConsensusAnnot = av.getComplementConsensusAnnotation (); -var renderHistogram = true; -var renderProfile = true; -var normaliseProfile = false; -var isRNA = this.rna; -var graphGroupDrawn = new java.util.BitSet (); -var charOffset = 0; -var fmWidth; -var fmScaling = 1; -var ofont = g.getFont (); -var yfrom = 0; -var f_i = 0; -var yto = 0; -var f_to = 0; -var clipst = false; -var clipend = false; -for (var i = 0; i < aa.length; i++) { -var row = aa[i]; -isRNA = row.isRNA (); -{ -if (row.groupRef != null && row === row.groupRef.getConsensus ()) { -renderHistogram = row.groupRef.isShowConsensusHistogram (); -renderProfile = row.groupRef.isShowSequenceLogo (); -normaliseProfile = row.groupRef.isNormaliseSequenceLogo (); -} else if (row === consensusAnnot || row === structConsensusAnnot || row === complementConsensusAnnot) { -renderHistogram = this.av_renderHistogram; -renderProfile = this.av_renderProfile; -normaliseProfile = this.av_normaliseProfile; -} else { -renderHistogram = true; -}}var row_annotations = row.annotations; -if (!row.visible) { -continue; -}centreColLabels = row.centreColLabels || centreColLabelsDef; -labelAllCols = row.showAllColLabels; -scaleColLabel = row.scaleColLabel; -lastSS = ' '; -lastSSX = 0; -if (!this.useClip || ((y - this.charHeight) < this.visHeight && (y + row.height + this.charHeight * 2) >= this.sOffset)) { -if (!clipst) { -clipst = true; -yfrom = y; -f_i = i; -}yto = y; -f_to = i; -if (row.graph > 0) { -if (row.graphGroup > -1 && graphGroupDrawn.get (row.graphGroup)) { -continue; -}y += row.height; -if (row.hasText) { -iconOffset = this.charHeight - this.fm.getDescent (); -y -= this.charHeight; -}} else if (row.hasText) { -iconOffset = this.charHeight - this.fm.getDescent (); -} else { -iconOffset = 0; -}if (row.autoCalculated && av.isCalculationInProgress (row)) { -y += this.charHeight; -usedFaded = true; -g.drawImage (this.fadedImage, 0, y - row.height, this.imgWidth, y, 0, y - row.height, this.imgWidth, y, this.annotationPanel); -g.setColor (java.awt.Color.black); -continue; -}x = (startRes == 0) ? 0 : -1; -while (x < endRes - startRes) { -if (this.hasHiddenColumns) { -column = this.columnSelection.adjustForHiddenColumns (startRes + x); -if (column > row_annotations.length - 1) { -break; -}} else { -column = startRes + x; -}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { -validRes = false; -} else { -validRes = true; -}var displayChar = validRes ? row_annotations[column].displayCharacter : null; -if (x > -1) { -if (activeRow == i) { -g.setColor (java.awt.Color.red); -if (this.columnSelection != null) { -for (var n = 0; n < this.columnSelection.size (); n++) { -var v = this.columnSelection.columnAt (n); -if (v == column) { -g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); -}} -}}if (row.getInvalidStrucPos () > x) { -g.setColor (java.awt.Color.orange); -g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); -} else if (row.getInvalidStrucPos () == x) { -g.setColor (java.awt.Color.orange.darker ()); -g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); -}if (this.validCharWidth && validRes && displayChar != null && (displayChar.length > 0)) { -fmWidth = this.fm.charsWidth (displayChar.toCharArray (), 0, displayChar.length); -if (scaleColLabel) { -if (fmWidth > this.charWidth) { -fmScaling = this.charWidth; -fmScaling /= fmWidth; -g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (fmScaling, 1.0))); -fmWidth = this.charWidth; -}}charOffset = Clazz.floatToInt ((this.charWidth - fmWidth) / 2); -if (row_annotations[column].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (row_annotations[column].colour); -}if (column == 0 || row.graph > 0) { -g.drawString (displayChar, (x * this.charWidth) + charOffset, y + iconOffset); -} else if (row_annotations[column - 1] == null || (labelAllCols || !displayChar.equals (row_annotations[column - 1].displayCharacter) || (displayChar.length < 2 && row_annotations[column].secondaryStructure == ' '))) { -g.drawString (displayChar, x * this.charWidth + charOffset, y + iconOffset); -}g.setFont (ofont); -}}if (row.hasIcons) { -var ss = validRes ? row_annotations[column].secondaryStructure : '-'; -if (ss == '(') { -if (displayChar.indexOf (')') > -1) { -ss = ')'; -}}if (ss == '[') { -if ((displayChar.indexOf (']') > -1)) { -ss = ']'; -}}if (ss == '{') { -if (displayChar.indexOf ('}') > -1) { -ss = '}'; -}}if (ss == '<') { -if (displayChar.indexOf ('<') > -1) { -ss = '>'; -}}if (ss.charCodeAt (0) >= 65) { -if (displayChar.indexOf (ss.charCodeAt (0) + 32) > -1) { -ss = String.fromCharCode (ss.charCodeAt (0) + 32); -}}if (!validRes || (ss != lastSS)) { -if (x > -1) { -var nb_annot = x - temp; -switch (lastSS) { -case '(': -case ')': -this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -temp = x; -break; -case 'H': -if (!isRNA) { -this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case 'E': -if (!isRNA) { -this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case '{': -case '}': -case '[': -case ']': -case '>': -case '<': -case 'A': -case 'a': -case 'B': -case 'b': -case 'C': -case 'c': -case 'D': -case 'd': -case 'e': -case 'F': -case 'f': -case 'G': -case 'g': -case 'h': -case 'I': -case 'i': -case 'J': -case 'j': -case 'K': -case 'k': -case 'L': -case 'l': -case 'M': -case 'm': -case 'N': -case 'n': -case 'O': -case 'o': -case 'P': -case 'p': -case 'Q': -case 'q': -case 'R': -case 'r': -case 'S': -case 's': -case 'T': -case 't': -case 'U': -case 'u': -case 'V': -case 'v': -case 'W': -case 'w': -case 'X': -case 'x': -case 'Y': -case 'y': -case 'Z': -case 'z': -var nonCanColor = this.getNotCanonicalColor (lastSS); -this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -temp = x; -break; -default: -g.setColor (java.awt.Color.gray); -g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); -temp = x; -break; -} -}if (validRes) { -lastSS = ss; -} else { -lastSS = ' '; -}if (x > -1) { -lastSSX = (x * this.charWidth); -}}}column++; -x++; -} -if (column >= row_annotations.length) { -column = row_annotations.length - 1; -validEnd = false; -} else { -validEnd = true; -}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { -validRes = false; -} else { -validRes = true; -}if (row.hasIcons) { -switch (lastSS) { -case 'H': -if (!isRNA) { -this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case 'E': -if (!isRNA) { -this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -}case '(': -case ')': -this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -case '{': -case '}': -case '[': -case ']': -case '>': -case '<': -case 'A': -case 'a': -case 'B': -case 'b': -case 'C': -case 'c': -case 'D': -case 'd': -case 'e': -case 'F': -case 'f': -case 'G': -case 'g': -case 'h': -case 'I': -case 'i': -case 'J': -case 'j': -case 'K': -case 'k': -case 'L': -case 'l': -case 'M': -case 'm': -case 'N': -case 'n': -case 'O': -case 'o': -case 'P': -case 'p': -case 'Q': -case 'q': -case 'R': -case 'r': -case 'T': -case 't': -case 'U': -case 'u': -case 'V': -case 'v': -case 'W': -case 'w': -case 'X': -case 'x': -case 'Y': -case 'y': -case 'Z': -case 'z': -var nonCanColor = this.getNotCanonicalColor (lastSS); -this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -default: -this.drawGlyphLine (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); -break; -} -}if (row.graph > 0 && row.graphHeight > 0) { -if (row.graph == 2) { -if (row.graphGroup > -1 && !graphGroupDrawn.get (row.graphGroup)) { -var groupmax = -999999; -var groupmin = 9999999; -for (var gg = 0; gg < aa.length; gg++) { -if (aa[gg].graphGroup != row.graphGroup) { -continue; -}if (aa[gg] !== row) { -aa[gg].visible = false; -}if (aa[gg].graphMax > groupmax) { -groupmax = aa[gg].graphMax; -}if (aa[gg].graphMin < groupmin) { -groupmin = aa[gg].graphMin; -}} -for (var gg = 0; gg < aa.length; gg++) { -if (aa[gg].graphGroup == row.graphGroup) { -this.drawLineGraph (g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin, groupmax, row.graphHeight); -}} -graphGroupDrawn.set (row.graphGroup); -} else { -this.drawLineGraph (g, row, row_annotations, startRes, endRes, y, row.graphMin, row.graphMax, row.graphHeight); -}} else if (row.graph == 1) { -this.drawBarGraph (g, row, row_annotations, startRes, endRes, row.graphMin, row.graphMax, y, renderHistogram, renderProfile, normaliseProfile); -}}} else { -if (clipst && !clipend) { -clipend = true; -}}if (row.graph > 0 && row.hasText) { -y += this.charHeight; -}if (row.graph == 0) { -y += aa[i].height; -}} -if (this.debugRedraw) { -if (this.canClip) { -if (clipst) { -System.err.println ("Start clip at : " + yfrom + " (index " + f_i + ")"); -}if (clipend) { -System.err.println ("End clip at : " + yto + " (index " + f_to + ")"); -}};System.err.println ("Annotation Rendering time:" + (System.currentTimeMillis () - stime)); -};return !usedFaded; -}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI,java.awt.Graphics,~N,~N,~N"); -Clazz.defineMethod (c$, "drawGlyphLine", -function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.GLYPHLINE_COLOR); -g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); -}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawSheetAnnot", -function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.SHEET_COLOUR); -if (!validEnd || !validRes || row == null || row[column] == null || row[column].secondaryStructure != 'E') { -g.fillRect (lastSSX, y + 4 + iconOffset, (x * this.charWidth) - lastSSX - 4, 7); -g.fillPolygon ( Clazz.newIntArray (-1, [(x * this.charWidth) - 4, (x * this.charWidth) - 4, (x * this.charWidth)]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset]), 3); -} else { -g.fillRect (lastSSX, y + 4 + iconOffset, (x + 1) * this.charWidth - lastSSX, 7); -}}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawHelixAnnot", -function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { -g.setColor (jalview.renderer.AnnotationRenderer.HELIX_COLOUR); -var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; -var x1 = lastSSX; -var x2 = (x * this.charWidth); -if (this.MAC) { -var ofs = Clazz.doubleToInt (this.charWidth / 2); -g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8); -if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { -} else { -g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); -}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { -} else { -g.fillRoundRect (lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); -}return; -}if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { -g.fillArc (lastSSX, y + 4 + iconOffset, this.charWidth, 8, 90, 180); -x1 += Clazz.doubleToInt (this.charWidth / 2); -}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { -g.fillArc ((x * this.charWidth) - this.charWidth, y + 4 + iconOffset, this.charWidth, 8, 270, 180); -x2 -= Clazz.doubleToInt (this.charWidth / 2); -}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 8); -}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); -Clazz.defineMethod (c$, "drawLineGraph", -function (g, _aa, aa_annotations, sRes, eRes, y, min, max, graphHeight) { -if (sRes > aa_annotations.length) { -return; -}var x = 0; -if (eRes < this.endRes) { -eRes++; -}eRes = Math.min (eRes, aa_annotations.length); -if (sRes == 0) { -x++; -}var y1 = y; -var y2 = y; -var range = max - min; -if (min < 0) { -y2 = y - Clazz.floatToInt ((0 - min / range) * graphHeight); -}g.setColor (java.awt.Color.gray); -g.drawLine (x - this.charWidth, y2, (eRes - sRes + 1) * this.charWidth, y2); -eRes = Math.min (eRes, aa_annotations.length); -var column; -var aaMax = aa_annotations.length - 1; -while (x < eRes - sRes) { -column = sRes + x; -if (this.hasHiddenColumns) { -column = this.columnSelection.adjustForHiddenColumns (column); -}if (column > aaMax) { -break; -}if (aa_annotations[column] == null || aa_annotations[column - 1] == null) { -x++; -continue; -}if (aa_annotations[column].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (aa_annotations[column].colour); -}y1 = y - Clazz.floatToInt (((aa_annotations[column - 1].value - min) / range) * graphHeight); -y2 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / range) * graphHeight); -g.drawLine (x * this.charWidth - Clazz.doubleToInt (this.charWidth / 2), y1, x * this.charWidth + Clazz.doubleToInt (this.charWidth / 2), y2); -x++; -} -if (_aa.threshold != null) { -g.setColor (_aa.threshold.colour); -var g2 = g; -g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); -y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * graphHeight); -g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); -g2.setStroke ( new java.awt.BasicStroke ()); -}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "drawBarGraph", -function (g, _aa, aa_annotations, sRes, eRes, min, max, y, renderHistogram, renderProfile, normaliseProfile) { -if (sRes > aa_annotations.length) { -return; -}var ofont = g.getFont (); -eRes = Math.min (eRes, aa_annotations.length); -var x = 0; -var y1 = y; -var y2 = y; -var range = max - min; -if (min < 0) { -y2 = y - Clazz.floatToInt ((0 - min / (range)) * _aa.graphHeight); -}g.setColor (java.awt.Color.gray); -g.drawLine (x, y2, (eRes - sRes) * this.charWidth, y2); -var column; -var aaMax = aa_annotations.length - 1; -while (x < eRes - sRes) { -column = sRes + x; -if (this.hasHiddenColumns) { -column = this.columnSelection.adjustForHiddenColumns (column); -}if (column > aaMax) { -break; -}if (aa_annotations[column] == null) { -x++; -continue; -}if (aa_annotations[column].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (aa_annotations[column].colour); -}y1 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight); -if (renderHistogram) { -if (y1 - y2 > 0) { -g.fillRect (x * this.charWidth, y2, this.charWidth, y1 - y2); -} else { -g.fillRect (x * this.charWidth, y1, this.charWidth, y2 - y1); -}}if (renderProfile) { -var profl = this.getProfileFor (_aa, column); -if (profl != null && profl[2] != 0) { -var isStructureProfile = profl[0] == 1; -var isCdnaProfile = profl[0] == 2; -var ht = normaliseProfile ? y - _aa.graphHeight : y1; -var htn = normaliseProfile ? _aa.graphHeight : (y2 - y1); -var hght; -var wdth; -var ht2 = 0; -var dc; -dc = Clazz.newCharArray (isStructureProfile ? 2 : (isCdnaProfile ? 3 : 1), '\0'); -var lm = g.getFontMetrics (ofont).getLineMetrics ("Q", g); -var scale = 1 / (normaliseProfile ? profl[2] : 100); -var ofontHeight = 1 / lm.getAscent (); -var scl = 0.0; -var c = 3; -var valuesProcessed = 0; -while (valuesProcessed < profl[1]) { -if (isStructureProfile) { -dc[0] = String.fromCharCode (profl[c++]); -dc[1] = String.fromCharCode (profl[c++]); -} else if (isCdnaProfile) { -dc = jalview.analysis.CodingUtils.decodeCodon (profl[c++]); -} else { -dc[0] = String.fromCharCode (profl[c++]); -}wdth = this.charWidth; -wdth /= this.fm.charsWidth (dc, 0, dc.length); -ht += scl; -scl = htn * scale * profl[c++]; -lm = ofont.getLineMetrics (dc, 0, 1, g.getFontMetrics ().getFontRenderContext ()); -g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (wdth, scl / lm.getAscent ()))); -lm = g.getFontMetrics ().getLineMetrics (dc, 0, 1, g); -var colour = null; -if (isCdnaProfile) { -var codonTranslation = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (dc)); -colour = this.profcolour.findColour (codonTranslation.charAt (0), column, null); -} else { -colour = this.profcolour.findColour (dc[0], column, null); -}g.setColor (colour === java.awt.Color.white ? java.awt.Color.lightGray : colour); -hght = (ht + (scl - lm.getDescent () - lm.getBaselineOffsets ()[lm.getBaselineIndex ()])); -g.drawChars (dc, 0, dc.length, x * this.charWidth, Clazz.doubleToInt (hght)); -valuesProcessed++; -} -g.setFont (ofont); -}}x++; -} -if (_aa.threshold != null) { -g.setColor (_aa.threshold.colour); -var g2 = g; -g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); -y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight); -g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); -g2.setStroke ( new java.awt.BasicStroke ()); -}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~B,~B,~B"); -Clazz.defineMethod (c$, "drawGraph", -function (g, _aa, aa_annotations, width, y, sRes, eRes) { -eRes = Math.min (eRes, aa_annotations.length); -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, width, y); -g.setColor ( new java.awt.Color (0, 0, 180)); -var x = 0; -var height; -for (var j = sRes; j < eRes; j++) { -if (aa_annotations[j] != null) { -if (aa_annotations[j].colour == null) { -g.setColor (java.awt.Color.black); -} else { -g.setColor (aa_annotations[j].colour); -}height = Clazz.floatToInt ((aa_annotations[j].value / _aa.graphMax) * y); -if (height > y) { -height = y; -}g.fillRect (x, y - height, this.charWidth, height); -}x += this.charWidth; -} -}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "getNotCanonicalColor", -function (lastss) { -switch (lastss) { -case '{': -case '}': -return new java.awt.Color (255, 125, 5); -case '[': -case ']': -return new java.awt.Color (245, 115, 10); -case '>': -case '<': -return new java.awt.Color (235, 135, 15); -case 'A': -case 'a': -return new java.awt.Color (225, 105, 20); -case 'B': -case 'b': -return new java.awt.Color (215, 145, 30); -case 'C': -case 'c': -return new java.awt.Color (205, 95, 35); -case 'D': -case 'd': -return new java.awt.Color (195, 155, 45); -case 'E': -case 'e': -return new java.awt.Color (185, 85, 55); -case 'F': -case 'f': -return new java.awt.Color (175, 165, 65); -case 'G': -case 'g': -return new java.awt.Color (170, 75, 75); -case 'H': -case 'h': -return new java.awt.Color (160, 175, 85); -case 'I': -case 'i': -return new java.awt.Color (150, 65, 95); -case 'J': -case 'j': -return new java.awt.Color (140, 185, 105); -case 'K': -case 'k': -return new java.awt.Color (130, 55, 110); -case 'L': -case 'l': -return new java.awt.Color (120, 195, 120); -case 'M': -case 'm': -return new java.awt.Color (110, 45, 130); -case 'N': -case 'n': -return new java.awt.Color (100, 205, 140); -case 'O': -case 'o': -return new java.awt.Color (90, 35, 150); -case 'P': -case 'p': -return new java.awt.Color (85, 215, 160); -case 'Q': -case 'q': -return new java.awt.Color (75, 25, 170); -case 'R': -case 'r': -return new java.awt.Color (65, 225, 180); -case 'S': -case 's': -return new java.awt.Color (55, 15, 185); -case 'T': -case 't': -return new java.awt.Color (45, 235, 195); -case 'U': -case 'u': -return new java.awt.Color (35, 5, 205); -case 'V': -case 'v': -return new java.awt.Color (25, 245, 215); -case 'W': -case 'w': -return new java.awt.Color (15, 0, 225); -case 'X': -case 'x': -return new java.awt.Color (10, 255, 235); -case 'Y': -case 'y': -return new java.awt.Color (5, 150, 245); -case 'Z': -case 'z': -return new java.awt.Color (0, 80, 255); -default: -System.out.println ("This is not a interaction : " + lastss); -return null; -} -}, "~S"); -c$.GLYPHLINE_COLOR = c$.prototype.GLYPHLINE_COLOR = java.awt.Color.gray; -c$.SHEET_COLOUR = c$.prototype.SHEET_COLOUR = java.awt.Color.green; -c$.HELIX_COLOUR = c$.prototype.HELIX_COLOUR = java.awt.Color.red; -c$.STEM_COLOUR = c$.prototype.STEM_COLOUR = java.awt.Color.blue; -}); +Clazz.declarePackage ("jalview.renderer"); +Clazz.load (["jalview.util.Platform", "java.awt.Color"], "jalview.renderer.AnnotationRenderer", ["jalview.analysis.AAFrequency", "$.CodingUtils", "$.StructureFrequency", "jalview.jsdev.RegExp", "jalview.schemes.NucleotideColourScheme", "$.ResidueProperties", "$.ZappoColourScheme", "java.awt.BasicStroke", "java.awt.geom.AffineTransform", "java.util.BitSet"], function () { +c$ = Clazz.decorateAsClass (function () { +this.debugRedraw = false; +this.charWidth = 0; +this.endRes = 0; +this.charHeight = 0; +this.validCharWidth = false; +this.hasHiddenColumns = false; +this.fm = null; +this.MAC = false; +this.av_renderHistogram = true; +this.av_renderProfile = true; +this.av_normaliseProfile = false; +this.profcolour = null; +this.columnSelection = null; +this.hconsensus = null; +this.complementConsensus = null; +this.hStrucConsensus = null; +this.av_ignoreGapsConsensus = false; +this.fadedImage = null; +this.annotationPanel = null; +this.imgWidth = 0; +this.sOffset = 0; +this.visHeight = 0; +this.useClip = true; +this.canClip = false; +this.rna = false; +this.sdNOTCANONICAL_COLOUR = null; +Clazz.instantialize (this, arguments); +}, jalview.renderer, "AnnotationRenderer"); +Clazz.prepareFields (c$, function () { +this.MAC = jalview.util.Platform.isAMac (); +}); +Clazz.makeConstructor (c$, +function () { +this.construct (false); +}); +Clazz.makeConstructor (c$, +function (debugRedraw) { +this.debugRedraw = debugRedraw; +}, "~B"); +Clazz.defineMethod (c$, "drawStemAnnot", +function (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.STEM_COLOUR); +var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; +var x1 = lastSSX; +var x2 = (x * this.charWidth); +var closeparen = jalview.jsdev.RegExp.newRegex (["(\\))"]); +var dc = (column == 0 || row_annotations[column - 1] == null) ? ' ' : row_annotations[column - 1].secondaryStructure; +var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || dc != row_annotations[sCol - 1].secondaryStructure; +var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || dc != row_annotations[column].secondaryStructure; +if (column > 0 && jalview.schemes.ResidueProperties.isCloseParenRNA (dc)) { +if (diffupstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x1 += 5; +}if (diffdownstream) { +x2 -= 1; +}} else { +if (diffdownstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x2 -= 5; +}if (diffupstream) { +x1 += 1; +}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); +}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawNotCanonicalAnnot", +function (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (nonCanColor); +var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; +var x1 = lastSSX; +var x2 = (x * this.charWidth); +var closeparen = jalview.jsdev.RegExp.newRegex (["}|]|<|[a-z]"]); +var dc = (column == 0 || row_annotations[column - 1] == null) ? "" : row_annotations[column - 1].displayCharacter; +var diffupstream = sCol == 0 || row_annotations[sCol - 1] == null || !dc.equals (row_annotations[sCol - 1].displayCharacter); +var diffdownstream = !validRes || !validEnd || row_annotations[column] == null || !dc.equals (row_annotations[column].displayCharacter); +if (column > 0 && closeparen.search (dc)) { +if (diffupstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [lastSSX + 5, lastSSX + 5, lastSSX]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x1 += 5; +}if (diffdownstream) { +x2 -= 1; +}} else { +if (diffdownstream) { +g.fillPolygon ( Clazz.newIntArray (-1, [x2 - 5, x2 - 5, x2]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset]), 3); +x2 -= 5; +}if (diffupstream) { +x1 += 1; +}}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 7); +}, "java.awt.Graphics,java.awt.Color,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "updateFromAwtRenderPanel", +function (annotPanel, av) { +this.fm = annotPanel.getFontMetrics (); +this.annotationPanel = annotPanel; +this.fadedImage = annotPanel.getFadedImage (); +this.imgWidth = annotPanel.getFadedImageWidth (); +var bounds = annotPanel.getVisibleVRange (); +if (bounds != null) { +this.sOffset = bounds[0]; +this.visHeight = bounds[1]; +if (this.visHeight == 0) { +this.useClip = false; +} else { +this.useClip = this.canClip; +}} else { +this.useClip = false; +}this.updateFromAlignViewport (av); +}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI"); +Clazz.defineMethod (c$, "updateFromAlignViewport", +function (av) { +this.charWidth = av.getCharWidth (); +this.endRes = av.getEndRes (); +this.charHeight = av.getCharHeight (); +this.hasHiddenColumns = av.hasHiddenColumns (); +this.validCharWidth = av.isValidCharWidth (); +this.av_renderHistogram = av.isShowConsensusHistogram (); +this.av_renderProfile = av.isShowSequenceLogo (); +this.av_normaliseProfile = av.isNormaliseSequenceLogo (); +this.profcolour = av.getGlobalColourScheme (); +if (this.profcolour == null) { +this.profcolour = av.getAlignment ().isNucleotide () ? new jalview.schemes.NucleotideColourScheme () : new jalview.schemes.ZappoColourScheme (); +}this.columnSelection = av.getColumnSelection (); +this.hconsensus = av.getSequenceConsensusHash (); +this.complementConsensus = av.getComplementConsensusHash (); +this.hStrucConsensus = av.getRnaStructureConsensusHash (); +this.av_ignoreGapsConsensus = av.isIgnoreGapsConsensus (); +}, "jalview.api.AlignViewportI"); +Clazz.defineMethod (c$, "getProfileFor", +function (aa, column) { +if (aa.autoCalculated && (aa.label.startsWith ("Consensus") || aa.label.startsWith ("cDNA Consensus"))) { +var forComplement = aa.label.startsWith ("cDNA Consensus"); +if (aa.groupRef != null && aa.groupRef.consensusData != null && aa.groupRef.isShowSequenceLogo ()) { +return jalview.analysis.AAFrequency.extractProfile (aa.groupRef.consensusData[column], aa.groupRef.getIgnoreGapsConsensus ()); +}if (aa.groupRef == null && aa.sequenceRef == null) { +if (forComplement) { +return jalview.analysis.AAFrequency.extractCdnaProfile (this.complementConsensus[column], this.av_ignoreGapsConsensus); +} else { +return jalview.analysis.AAFrequency.extractProfile (this.hconsensus[column], this.av_ignoreGapsConsensus); +}}} else { +if (aa.autoCalculated && aa.label.startsWith ("StrucConsensus")) { +if (aa.groupRef == null && aa.sequenceRef == null && this.hStrucConsensus != null && this.hStrucConsensus.length > column) { +return jalview.analysis.StructureFrequency.extractProfile (this.hStrucConsensus[column], this.av_ignoreGapsConsensus); +}}}return null; +}, "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.defineMethod (c$, "drawComponent", +function (annotPanel, av, g, activeRow, startRes, endRes) { +var stime = System.currentTimeMillis (); +var usedFaded = false; +this.updateFromAwtRenderPanel (annotPanel, av); +this.fm = g.getFontMetrics (); +var aa = av.getAlignment ().getAlignmentAnnotation (); +var temp = 0; +if (aa == null) { +return false; +}var x = 0; +var y = 0; +var column = 0; +var lastSS; +var lastSSX; +var iconOffset = 0; +var validRes = false; +var validEnd = false; +var labelAllCols = false; +var centreColLabels; +var centreColLabelsDef = av.isCentreColumnLabels (); +var scaleColLabel = false; +var consensusAnnot = av.getAlignmentConsensusAnnotation (); +var structConsensusAnnot = av.getAlignmentStrucConsensusAnnotation (); +var complementConsensusAnnot = av.getComplementConsensusAnnotation (); +var renderHistogram = true; +var renderProfile = true; +var normaliseProfile = false; +var isRNA = this.rna; +var graphGroupDrawn = new java.util.BitSet (); +var charOffset = 0; +var fmWidth; +var fmScaling = 1; +var ofont = g.getFont (); +var yfrom = 0; +var f_i = 0; +var yto = 0; +var f_to = 0; +var clipst = false; +var clipend = false; +for (var i = 0; i < aa.length; i++) { +var row = aa[i]; +isRNA = row.isRNA (); +{ +if (row.groupRef != null && row === row.groupRef.getConsensus ()) { +renderHistogram = row.groupRef.isShowConsensusHistogram (); +renderProfile = row.groupRef.isShowSequenceLogo (); +normaliseProfile = row.groupRef.isNormaliseSequenceLogo (); +} else if (row === consensusAnnot || row === structConsensusAnnot || row === complementConsensusAnnot) { +renderHistogram = this.av_renderHistogram; +renderProfile = this.av_renderProfile; +normaliseProfile = this.av_normaliseProfile; +} else { +renderHistogram = true; +}}var row_annotations = row.annotations; +if (!row.visible) { +continue; +}centreColLabels = row.centreColLabels || centreColLabelsDef; +labelAllCols = row.showAllColLabels; +scaleColLabel = row.scaleColLabel; +lastSS = ' '; +lastSSX = 0; +if (!this.useClip || ((y - this.charHeight) < this.visHeight && (y + row.height + this.charHeight * 2) >= this.sOffset)) { +if (!clipst) { +clipst = true; +yfrom = y; +f_i = i; +}yto = y; +f_to = i; +if (row.graph > 0) { +if (row.graphGroup > -1 && graphGroupDrawn.get (row.graphGroup)) { +continue; +}y += row.height; +if (row.hasText) { +iconOffset = this.charHeight - this.fm.getDescent (); +y -= this.charHeight; +}} else if (row.hasText) { +iconOffset = this.charHeight - this.fm.getDescent (); +} else { +iconOffset = 0; +}if (row.autoCalculated && av.isCalculationInProgress (row)) { +y += this.charHeight; +usedFaded = true; +g.drawImage (this.fadedImage, 0, y - row.height, this.imgWidth, y, 0, y - row.height, this.imgWidth, y, this.annotationPanel); +g.setColor (java.awt.Color.black); +continue; +}x = (startRes == 0) ? 0 : -1; +while (x < endRes - startRes) { +if (this.hasHiddenColumns) { +column = this.columnSelection.adjustForHiddenColumns (startRes + x); +if (column > row_annotations.length - 1) { +break; +}} else { +column = startRes + x; +}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { +validRes = false; +} else { +validRes = true; +}var displayChar = validRes ? row_annotations[column].displayCharacter : null; +if (x > -1) { +if (activeRow == i) { +g.setColor (java.awt.Color.red); +if (this.columnSelection != null) { +for (var n = 0; n < this.columnSelection.size (); n++) { +var v = this.columnSelection.columnAt (n); +if (v == column) { +g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); +}} +}}if (row.getInvalidStrucPos () > x) { +g.setColor (java.awt.Color.orange); +g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); +} else if (row.getInvalidStrucPos () == x) { +g.setColor (java.awt.Color.orange.darker ()); +g.fillRect (x * this.charWidth, y, this.charWidth, this.charHeight); +}if (this.validCharWidth && validRes && displayChar != null && (displayChar.length > 0)) { +fmWidth = this.fm.charsWidth (displayChar.toCharArray (), 0, displayChar.length); +if (scaleColLabel) { +if (fmWidth > this.charWidth) { +fmScaling = this.charWidth; +fmScaling /= fmWidth; +g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (fmScaling, 1.0))); +fmWidth = this.charWidth; +}}charOffset = Clazz.floatToInt ((this.charWidth - fmWidth) / 2); +if (row_annotations[column].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (row_annotations[column].colour); +}if (column == 0 || row.graph > 0) { +g.drawString (displayChar, (x * this.charWidth) + charOffset, y + iconOffset); +} else if (row_annotations[column - 1] == null || (labelAllCols || !displayChar.equals (row_annotations[column - 1].displayCharacter) || (displayChar.length < 2 && row_annotations[column].secondaryStructure == ' '))) { +g.drawString (displayChar, x * this.charWidth + charOffset, y + iconOffset); +}g.setFont (ofont); +}}if (row.hasIcons) { +var ss = validRes ? row_annotations[column].secondaryStructure : '-'; +if (ss == '(') { +if (displayChar.indexOf (')') > -1) { +ss = ')'; +}}if (ss == '[') { +if ((displayChar.indexOf (']') > -1)) { +ss = ']'; +}}if (ss == '{') { +if (displayChar.indexOf ('}') > -1) { +ss = '}'; +}}if (ss == '<') { +if (displayChar.indexOf ('<') > -1) { +ss = '>'; +}}if (ss.charCodeAt (0) >= 65) { +if (displayChar.indexOf (ss.charCodeAt (0) + 32) > -1) { +ss = String.fromCharCode (ss.charCodeAt (0) + 32); +}}if (!validRes || (ss != lastSS)) { +if (x > -1) { +var nb_annot = x - temp; +switch (lastSS) { +case '(': +case ')': +this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +temp = x; +break; +case 'H': +if (!isRNA) { +this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case 'E': +if (!isRNA) { +this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case '{': +case '}': +case '[': +case ']': +case '>': +case '<': +case 'A': +case 'a': +case 'B': +case 'b': +case 'C': +case 'c': +case 'D': +case 'd': +case 'e': +case 'F': +case 'f': +case 'G': +case 'g': +case 'h': +case 'I': +case 'i': +case 'J': +case 'j': +case 'K': +case 'k': +case 'L': +case 'l': +case 'M': +case 'm': +case 'N': +case 'n': +case 'O': +case 'o': +case 'P': +case 'p': +case 'Q': +case 'q': +case 'R': +case 'r': +case 'S': +case 's': +case 'T': +case 't': +case 'U': +case 'u': +case 'V': +case 'v': +case 'W': +case 'w': +case 'X': +case 'x': +case 'Y': +case 'y': +case 'Z': +case 'z': +var nonCanColor = this.getNotCanonicalColor (lastSS); +this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +temp = x; +break; +default: +g.setColor (java.awt.Color.gray); +g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); +temp = x; +break; +} +}if (validRes) { +lastSS = ss; +} else { +lastSS = ' '; +}if (x > -1) { +lastSSX = (x * this.charWidth); +}}}column++; +x++; +} +if (column >= row_annotations.length) { +column = row_annotations.length - 1; +validEnd = false; +} else { +validEnd = true; +}if ((row_annotations == null) || (row_annotations.length <= column) || (row_annotations[column] == null)) { +validRes = false; +} else { +validRes = true; +}if (row.hasIcons) { +switch (lastSS) { +case 'H': +if (!isRNA) { +this.drawHelixAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case 'E': +if (!isRNA) { +this.drawSheetAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +}case '(': +case ')': +this.drawStemAnnot (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +case '{': +case '}': +case '[': +case ']': +case '>': +case '<': +case 'A': +case 'a': +case 'B': +case 'b': +case 'C': +case 'c': +case 'D': +case 'd': +case 'e': +case 'F': +case 'f': +case 'G': +case 'g': +case 'h': +case 'I': +case 'i': +case 'J': +case 'j': +case 'K': +case 'k': +case 'L': +case 'l': +case 'M': +case 'm': +case 'N': +case 'n': +case 'O': +case 'o': +case 'P': +case 'p': +case 'Q': +case 'q': +case 'R': +case 'r': +case 'T': +case 't': +case 'U': +case 'u': +case 'V': +case 'v': +case 'W': +case 'w': +case 'X': +case 'x': +case 'Y': +case 'y': +case 'Z': +case 'z': +var nonCanColor = this.getNotCanonicalColor (lastSS); +this.drawNotCanonicalAnnot (g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +default: +this.drawGlyphLine (g, row_annotations, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd); +break; +} +}if (row.graph > 0 && row.graphHeight > 0) { +if (row.graph == 2) { +if (row.graphGroup > -1 && !graphGroupDrawn.get (row.graphGroup)) { +var groupmax = -999999; +var groupmin = 9999999; +for (var gg = 0; gg < aa.length; gg++) { +if (aa[gg].graphGroup != row.graphGroup) { +continue; +}if (aa[gg] !== row) { +aa[gg].visible = false; +}if (aa[gg].graphMax > groupmax) { +groupmax = aa[gg].graphMax; +}if (aa[gg].graphMin < groupmin) { +groupmin = aa[gg].graphMin; +}} +for (var gg = 0; gg < aa.length; gg++) { +if (aa[gg].graphGroup == row.graphGroup) { +this.drawLineGraph (g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin, groupmax, row.graphHeight); +}} +graphGroupDrawn.set (row.graphGroup); +} else { +this.drawLineGraph (g, row, row_annotations, startRes, endRes, y, row.graphMin, row.graphMax, row.graphHeight); +}} else if (row.graph == 1) { +this.drawBarGraph (g, row, row_annotations, startRes, endRes, row.graphMin, row.graphMax, y, renderHistogram, renderProfile, normaliseProfile); +}}} else { +if (clipst && !clipend) { +clipend = true; +}}if (row.graph > 0 && row.hasText) { +y += this.charHeight; +}if (row.graph == 0) { +y += aa[i].height; +}} +if (this.debugRedraw) { +if (this.canClip) { +if (clipst) { +System.err.println ("Start clip at : " + yfrom + " (index " + f_i + ")"); +}if (clipend) { +System.err.println ("End clip at : " + yto + " (index " + f_to + ")"); +}};System.err.println ("Annotation Rendering time:" + (System.currentTimeMillis () - stime)); +};return !usedFaded; +}, "jalview.renderer.AwtRenderPanelI,jalview.api.AlignViewportI,java.awt.Graphics,~N,~N,~N"); +Clazz.defineMethod (c$, "drawGlyphLine", +function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.GLYPHLINE_COLOR); +g.fillRect (lastSSX, y + 6 + iconOffset, (x * this.charWidth) - lastSSX, 2); +}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawSheetAnnot", +function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.SHEET_COLOUR); +if (!validEnd || !validRes || row == null || row[column] == null || row[column].secondaryStructure != 'E') { +g.fillRect (lastSSX, y + 4 + iconOffset, (x * this.charWidth) - lastSSX - 4, 7); +g.fillPolygon ( Clazz.newIntArray (-1, [(x * this.charWidth) - 4, (x * this.charWidth) - 4, (x * this.charWidth)]), Clazz.newIntArray (-1, [y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset]), 3); +} else { +g.fillRect (lastSSX, y + 4 + iconOffset, (x + 1) * this.charWidth - lastSSX, 7); +}}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawHelixAnnot", +function (g, row, lastSSX, x, y, iconOffset, startRes, column, validRes, validEnd) { +g.setColor (jalview.renderer.AnnotationRenderer.HELIX_COLOUR); +var sCol = (Clazz.doubleToInt (lastSSX / this.charWidth)) + startRes; +var x1 = lastSSX; +var x2 = (x * this.charWidth); +if (this.MAC) { +var ofs = Clazz.doubleToInt (this.charWidth / 2); +g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1, 8, 8, 8); +if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { +} else { +g.fillRoundRect (lastSSX, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); +}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { +} else { +g.fillRoundRect (lastSSX + ofs, y + 4 + iconOffset, x2 - x1 - ofs + 1, 8, 0, 0); +}return; +}if (sCol == 0 || row[sCol - 1] == null || row[sCol - 1].secondaryStructure != 'H') { +g.fillArc (lastSSX, y + 4 + iconOffset, this.charWidth, 8, 90, 180); +x1 += Clazz.doubleToInt (this.charWidth / 2); +}if (!validRes || row[column] == null || row[column].secondaryStructure != 'H') { +g.fillArc ((x * this.charWidth) - this.charWidth, y + 4 + iconOffset, this.charWidth, 8, 270, 180); +x2 -= Clazz.doubleToInt (this.charWidth / 2); +}g.fillRect (x1, y + 4 + iconOffset, x2 - x1, 8); +}, "java.awt.Graphics,~A,~N,~N,~N,~N,~N,~N,~B,~B"); +Clazz.defineMethod (c$, "drawLineGraph", +function (g, _aa, aa_annotations, sRes, eRes, y, min, max, graphHeight) { +if (sRes > aa_annotations.length) { +return; +}var x = 0; +if (eRes < this.endRes) { +eRes++; +}eRes = Math.min (eRes, aa_annotations.length); +if (sRes == 0) { +x++; +}var y1 = y; +var y2 = y; +var range = max - min; +if (min < 0) { +y2 = y - Clazz.floatToInt ((0 - min / range) * graphHeight); +}g.setColor (java.awt.Color.gray); +g.drawLine (x - this.charWidth, y2, (eRes - sRes + 1) * this.charWidth, y2); +eRes = Math.min (eRes, aa_annotations.length); +var column; +var aaMax = aa_annotations.length - 1; +while (x < eRes - sRes) { +column = sRes + x; +if (this.hasHiddenColumns) { +column = this.columnSelection.adjustForHiddenColumns (column); +}if (column > aaMax) { +break; +}if (aa_annotations[column] == null || aa_annotations[column - 1] == null) { +x++; +continue; +}if (aa_annotations[column].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (aa_annotations[column].colour); +}y1 = y - Clazz.floatToInt (((aa_annotations[column - 1].value - min) / range) * graphHeight); +y2 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / range) * graphHeight); +g.drawLine (x * this.charWidth - Clazz.doubleToInt (this.charWidth / 2), y1, x * this.charWidth + Clazz.doubleToInt (this.charWidth / 2), y2); +x++; +} +if (_aa.threshold != null) { +g.setColor (_aa.threshold.colour); +var g2 = g; +g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); +y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * graphHeight); +g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); +g2.setStroke ( new java.awt.BasicStroke ()); +}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "drawBarGraph", +function (g, _aa, aa_annotations, sRes, eRes, min, max, y, renderHistogram, renderProfile, normaliseProfile) { +if (sRes > aa_annotations.length) { +return; +}var ofont = g.getFont (); +eRes = Math.min (eRes, aa_annotations.length); +var x = 0; +var y1 = y; +var y2 = y; +var range = max - min; +if (min < 0) { +y2 = y - Clazz.floatToInt ((0 - min / (range)) * _aa.graphHeight); +}g.setColor (java.awt.Color.gray); +g.drawLine (x, y2, (eRes - sRes) * this.charWidth, y2); +var column; +var aaMax = aa_annotations.length - 1; +while (x < eRes - sRes) { +column = sRes + x; +if (this.hasHiddenColumns) { +column = this.columnSelection.adjustForHiddenColumns (column); +}if (column > aaMax) { +break; +}if (aa_annotations[column] == null) { +x++; +continue; +}if (aa_annotations[column].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (aa_annotations[column].colour); +}y1 = y - Clazz.floatToInt (((aa_annotations[column].value - min) / (range)) * _aa.graphHeight); +if (renderHistogram) { +if (y1 - y2 > 0) { +g.fillRect (x * this.charWidth, y2, this.charWidth, y1 - y2); +} else { +g.fillRect (x * this.charWidth, y1, this.charWidth, y2 - y1); +}}if (renderProfile) { +var profl = this.getProfileFor (_aa, column); +if (profl != null && profl[2] != 0) { +var isStructureProfile = profl[0] == 1; +var isCdnaProfile = profl[0] == 2; +var ht = normaliseProfile ? y - _aa.graphHeight : y1; +var htn = normaliseProfile ? _aa.graphHeight : (y2 - y1); +var hght; +var wdth; +var ht2 = 0; +var dc; +dc = Clazz.newCharArray (isStructureProfile ? 2 : (isCdnaProfile ? 3 : 1), '\0'); +var lm = g.getFontMetrics (ofont).getLineMetrics ("Q", g); +var scale = 1 / (normaliseProfile ? profl[2] : 100); +var ofontHeight = 1 / lm.getAscent (); +var scl = 0.0; +var c = 3; +var valuesProcessed = 0; +while (valuesProcessed < profl[1]) { +if (isStructureProfile) { +dc[0] = String.fromCharCode (profl[c++]); +dc[1] = String.fromCharCode (profl[c++]); +} else if (isCdnaProfile) { +dc = jalview.analysis.CodingUtils.decodeCodon (profl[c++]); +} else { +dc[0] = String.fromCharCode (profl[c++]); +}wdth = this.charWidth; +wdth /= this.fm.charsWidth (dc, 0, dc.length); +ht += scl; +scl = htn * scale * profl[c++]; +lm = ofont.getLineMetrics (dc, 0, 1, g.getFontMetrics ().getFontRenderContext ()); +g.setFont (ofont.deriveFont (java.awt.geom.AffineTransform.getScaleInstance (wdth, scl / lm.getAscent ()))); +lm = g.getFontMetrics ().getLineMetrics (dc, 0, 1, g); +var colour = null; +if (isCdnaProfile) { +var codonTranslation = jalview.schemes.ResidueProperties.codonTranslate ( String.instantialize (dc)); +colour = this.profcolour.findColour (codonTranslation.charAt (0), column, null); +} else { +colour = this.profcolour.findColour (dc[0], column, null); +}g.setColor (colour === java.awt.Color.white ? java.awt.Color.lightGray : colour); +hght = (ht + (scl - lm.getDescent () - lm.getBaselineOffsets ()[lm.getBaselineIndex ()])); +g.drawChars (dc, 0, dc.length, x * this.charWidth, Clazz.doubleToInt (hght)); +valuesProcessed++; +} +g.setFont (ofont); +}}x++; +} +if (_aa.threshold != null) { +g.setColor (_aa.threshold.colour); +var g2 = g; +g2.setStroke ( new java.awt.BasicStroke (1, 2, 1, 3, Clazz.newFloatArray (-1, [5, 3]), 0)); +y2 = Clazz.floatToInt (y - ((_aa.threshold.value - min) / range) * _aa.graphHeight); +g.drawLine (0, y2, (eRes - sRes) * this.charWidth, y2); +g2.setStroke ( new java.awt.BasicStroke ()); +}}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N,~N,~B,~B,~B"); +Clazz.defineMethod (c$, "drawGraph", +function (g, _aa, aa_annotations, width, y, sRes, eRes) { +eRes = Math.min (eRes, aa_annotations.length); +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, width, y); +g.setColor ( new java.awt.Color (0, 0, 180)); +var x = 0; +var height; +for (var j = sRes; j < eRes; j++) { +if (aa_annotations[j] != null) { +if (aa_annotations[j].colour == null) { +g.setColor (java.awt.Color.black); +} else { +g.setColor (aa_annotations[j].colour); +}height = Clazz.floatToInt ((aa_annotations[j].value / _aa.graphMax) * y); +if (height > y) { +height = y; +}g.fillRect (x, y - height, this.charWidth, height); +}x += this.charWidth; +} +}, "java.awt.Graphics,jalview.datamodel.AlignmentAnnotation,~A,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "getNotCanonicalColor", +function (lastss) { +switch (lastss) { +case '{': +case '}': +return new java.awt.Color (255, 125, 5); +case '[': +case ']': +return new java.awt.Color (245, 115, 10); +case '>': +case '<': +return new java.awt.Color (235, 135, 15); +case 'A': +case 'a': +return new java.awt.Color (225, 105, 20); +case 'B': +case 'b': +return new java.awt.Color (215, 145, 30); +case 'C': +case 'c': +return new java.awt.Color (205, 95, 35); +case 'D': +case 'd': +return new java.awt.Color (195, 155, 45); +case 'E': +case 'e': +return new java.awt.Color (185, 85, 55); +case 'F': +case 'f': +return new java.awt.Color (175, 165, 65); +case 'G': +case 'g': +return new java.awt.Color (170, 75, 75); +case 'H': +case 'h': +return new java.awt.Color (160, 175, 85); +case 'I': +case 'i': +return new java.awt.Color (150, 65, 95); +case 'J': +case 'j': +return new java.awt.Color (140, 185, 105); +case 'K': +case 'k': +return new java.awt.Color (130, 55, 110); +case 'L': +case 'l': +return new java.awt.Color (120, 195, 120); +case 'M': +case 'm': +return new java.awt.Color (110, 45, 130); +case 'N': +case 'n': +return new java.awt.Color (100, 205, 140); +case 'O': +case 'o': +return new java.awt.Color (90, 35, 150); +case 'P': +case 'p': +return new java.awt.Color (85, 215, 160); +case 'Q': +case 'q': +return new java.awt.Color (75, 25, 170); +case 'R': +case 'r': +return new java.awt.Color (65, 225, 180); +case 'S': +case 's': +return new java.awt.Color (55, 15, 185); +case 'T': +case 't': +return new java.awt.Color (45, 235, 195); +case 'U': +case 'u': +return new java.awt.Color (35, 5, 205); +case 'V': +case 'v': +return new java.awt.Color (25, 245, 215); +case 'W': +case 'w': +return new java.awt.Color (15, 0, 225); +case 'X': +case 'x': +return new java.awt.Color (10, 255, 235); +case 'Y': +case 'y': +return new java.awt.Color (5, 150, 245); +case 'Z': +case 'z': +return new java.awt.Color (0, 80, 255); +default: +System.out.println ("This is not a interaction : " + lastss); +return null; +} +}, "~S"); +c$.GLYPHLINE_COLOR = c$.prototype.GLYPHLINE_COLOR = java.awt.Color.gray; +c$.SHEET_COLOUR = c$.prototype.SHEET_COLOUR = java.awt.Color.green; +c$.HELIX_COLOUR = c$.prototype.HELIX_COLOUR = java.awt.Color.red; +c$.STEM_COLOUR = c$.prototype.STEM_COLOUR = java.awt.Color.blue; +}); diff --git a/bin/jalview/renderer/AwtRenderPanelI.js b/bin/jalview/renderer/AwtRenderPanelI.js index 42dbcc3..e3aa6c9 100644 --- a/bin/jalview/renderer/AwtRenderPanelI.js +++ b/bin/jalview/renderer/AwtRenderPanelI.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.renderer"); -Clazz.load (["java.awt.image.ImageObserver"], "jalview.renderer.AwtRenderPanelI", null, function () { -Clazz.declareInterface (jalview.renderer, "AwtRenderPanelI", java.awt.image.ImageObserver); -}); +Clazz.declarePackage ("jalview.renderer"); +Clazz.load (["java.awt.image.ImageObserver"], "jalview.renderer.AwtRenderPanelI", null, function () { +Clazz.declareInterface (jalview.renderer, "AwtRenderPanelI", java.awt.image.ImageObserver); +}); diff --git a/bin/jalview/renderer/seqfeatures/FeatureRenderer.js b/bin/jalview/renderer/seqfeatures/FeatureRenderer.js index 7dc84b1..019d218 100644 --- a/bin/jalview/renderer/seqfeatures/FeatureRenderer.js +++ b/bin/jalview/renderer/seqfeatures/FeatureRenderer.js @@ -1,187 +1,187 @@ -Clazz.declarePackage ("jalview.renderer.seqfeatures"); -Clazz.load (["jalview.viewmodel.seqfeatures.FeatureRendererModel"], "jalview.renderer.seqfeatures.FeatureRenderer", ["jalview.util.Comparison", "java.awt.AlphaComposite", "$.Color", "java.awt.image.BufferedImage", "java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fm = null; -this.charOffset = 0; -this.offscreenRender = false; -this.lastSeq = null; -this.s = '\0'; -this.i = 0; -this.av_charHeight = 0; -this.av_charWidth = 0; -this.av_validCharWidth = false; -this.av_isShowSeqFeatureHeight = false; -this.offscreenImage = null; -this.lastSequenceFeatures = null; -this.sfSize = 0; -this.sfindex = 0; -this.spos = 0; -this.epos = 0; -this.transparencyAvailable = true; -Clazz.instantialize (this, arguments); -}, jalview.renderer.seqfeatures, "FeatureRenderer", jalview.viewmodel.seqfeatures.FeatureRendererModel); -Clazz.defineMethod (c$, "updateAvConfig", -function () { -this.av_charHeight = this.av.getCharHeight (); -this.av_charWidth = this.av.getCharWidth (); -this.av_validCharWidth = this.av.isValidCharWidth (); -this.av_isShowSeqFeatureHeight = this.av.isShowSequenceFeaturesHeight (); -}); -Clazz.defineMethod (c$, "renderFeature", -function (g, seq, fstart, fend, featureColour, start, end, y1) { -this.updateAvConfig (); -if (((fstart <= end) && (fend >= start))) { -if (fstart < start) { -fstart = start; -}if (fend >= end) { -fend = end; -}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); -for (this.i = fstart; this.i <= fend; this.i++) { -this.s = seq.getCharAt (this.i); -if (jalview.util.Comparison.isGap (this.s)) { -continue; -}g.setColor (featureColour); -g.fillRect ((this.i - start) * this.av_charWidth, y1, this.av_charWidth, this.av_charHeight); -if (this.offscreenRender || !this.av_validCharWidth) { -continue; -}g.setColor (java.awt.Color.white); -this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); -g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); -} -}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N"); -Clazz.defineMethod (c$, "renderScoreFeature", -function (g, seq, fstart, fend, featureColour, start, end, y1, bs) { -this.updateAvConfig (); -if (((fstart <= end) && (fend >= start))) { -if (fstart < start) { -fstart = start; -}if (fend >= end) { -fend = end; -}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); -var ystrt = 0; -var yend = this.av_charHeight; -if (bs[0] != 0) { -if (bs[1] < 128) { -yend = Clazz.doubleToInt (this.av_charHeight * (128 - bs[1]) / 512); -ystrt = this.av_charHeight - Clazz.doubleToInt (yend / 2); -} else { -ystrt = Clazz.doubleToInt (this.av_charHeight / 2); -yend = Clazz.doubleToInt (this.av_charHeight * (bs[1] - 128) / 512); -}} else { -yend = Clazz.doubleToInt (this.av_charHeight * bs[1] / 255); -ystrt = this.av_charHeight - yend; -}for (this.i = fstart; this.i <= fend; this.i++) { -this.s = seq.getCharAt (this.i); -if (jalview.util.Comparison.isGap (this.s)) { -continue; -}g.setColor (featureColour); -var x = (this.i - start) * this.av_charWidth; -g.drawRect (x, y1, this.av_charWidth, this.av_charHeight); -g.fillRect (x, y1 + ystrt, this.av_charWidth, yend); -if (this.offscreenRender || !this.av_validCharWidth) { -continue; -}g.setColor (java.awt.Color.black); -this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); -g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); -} -}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N,~A"); -Clazz.defineMethod (c$, "findFeatureColour", -function (initialCol, seq, res) { -return new java.awt.Color (this.findFeatureColour (initialCol.getRGB (), seq, res)); -}, "java.awt.Color,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "findFeatureColour", -function (initialCol, seq, column) { -if (!this.av.isShowSequenceFeatures ()) { -return initialCol; -}var sequenceFeatures = seq.getSequenceFeatures (); -if (seq !== this.lastSeq) { -this.lastSeq = seq; -this.lastSequenceFeatures = sequenceFeatures; -if (this.lastSequenceFeatures != null) { -this.sfSize = this.lastSequenceFeatures.length; -}} else { -if (this.lastSequenceFeatures !== sequenceFeatures) { -this.lastSequenceFeatures = sequenceFeatures; -if (this.lastSequenceFeatures != null) { -this.sfSize = this.lastSequenceFeatures.length; -}}}if (this.lastSequenceFeatures == null || this.sfSize == 0) { -return initialCol; -}if (jalview.util.Comparison.isGap (this.lastSeq.getCharAt (column))) { -return java.awt.Color.white.getRGB (); -}if (this.transparency != 1.0 && this.offscreenImage == null) { -this.offscreenImage = new java.awt.image.BufferedImage (1, 1, 2); -}this.currentColour = null; -this.offscreenRender = true; -if (this.offscreenImage != null) { -this.offscreenImage.setRGB (0, 0, initialCol); -this.drawSequence (this.offscreenImage.getGraphics (), this.lastSeq, column, column, 0); -return this.offscreenImage.getRGB (0, 0); -} else { -this.drawSequence (null, this.lastSeq, this.lastSeq.findPosition (column), -1, -1); -if (this.currentColour == null) { -return initialCol; -} else { -return (this.currentColour).intValue (); -}}}, "~N,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "drawSequence", -function (g, seq, start, end, y1) { -var sequenceFeatures = seq.getSequenceFeatures (); -if (sequenceFeatures == null || sequenceFeatures.length == 0) { -return; -}if (g != null) { -this.fm = g.getFontMetrics (); -}this.updateFeatures (); -if (this.lastSeq == null || seq !== this.lastSeq || sequenceFeatures !== this.lastSequenceFeatures) { -this.lastSeq = seq; -this.lastSequenceFeatures = sequenceFeatures; -}if (this.transparency != 1 && g != null) { -var g2 = g; -g2.setComposite (java.awt.AlphaComposite.getInstance (3, this.transparency)); -}if (!this.offscreenRender) { -this.spos = this.lastSeq.findPosition (start); -this.epos = this.lastSeq.findPosition (end); -}this.sfSize = this.lastSequenceFeatures.length; -var type; -for (var renderIndex = 0; renderIndex < this.renderOrder.length; renderIndex++) { -type = this.renderOrder[renderIndex]; -if (type == null || !this.showFeatureOfType (type)) { -continue; -}for (this.sfindex = 0; this.sfindex < this.sfSize; this.sfindex++) { -var sequenceFeature = this.lastSequenceFeatures[this.sfindex]; -if (!sequenceFeature.type.equals (type)) { -continue; -}if (this.featureGroups != null && sequenceFeature.featureGroup != null && sequenceFeature.featureGroup.length != 0 && this.featureGroups.containsKey (sequenceFeature.featureGroup) && !this.featureGroups.get (sequenceFeature.featureGroup).booleanValue ()) { -continue; -}if (!this.offscreenRender && (sequenceFeature.getBegin () > this.epos || sequenceFeature.getEnd () < this.spos)) { -continue; -}if (this.offscreenRender && this.offscreenImage == null) { -if (sequenceFeature.begin <= start && sequenceFeature.end >= start) { -this.currentColour = new Integer (this.getColour (sequenceFeature).getRGB ()); -}} else if (sequenceFeature.type.equals ("disulfide bond")) { -this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.begin) - 1, this.getColour (sequenceFeature), start, end, y1); -this.renderFeature (g, seq, seq.findIndex (sequenceFeature.end) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); -} else if (this.showFeature (sequenceFeature)) { -if (this.av_isShowSeqFeatureHeight && !Float.isNaN (sequenceFeature.score)) { -this.renderScoreFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1, this.normaliseScore (sequenceFeature)); -} else { -this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); -}}} -} -if (this.transparency != 1.0 && g != null && this.transparencyAvailable) { -var g2 = g; -g2.setComposite (java.awt.AlphaComposite.getInstance (3, 1.0)); -}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,~N"); -Clazz.defineMethod (c$, "setTransparencyAvailable", -function (isTransparencyAvailable) { -this.transparencyAvailable = isTransparencyAvailable; -}, "~B"); -Clazz.overrideMethod (c$, "isTransparencyAvailable", -function () { -return this.transparencyAvailable; -}); -Clazz.overrideMethod (c$, "featuresAdded", -function () { -this.lastSeq = null; -this.findAllFeatures (); -}); -}); +Clazz.declarePackage ("jalview.renderer.seqfeatures"); +Clazz.load (["jalview.viewmodel.seqfeatures.FeatureRendererModel"], "jalview.renderer.seqfeatures.FeatureRenderer", ["jalview.util.Comparison", "java.awt.AlphaComposite", "$.Color", "java.awt.image.BufferedImage", "java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fm = null; +this.charOffset = 0; +this.offscreenRender = false; +this.lastSeq = null; +this.s = '\0'; +this.i = 0; +this.av_charHeight = 0; +this.av_charWidth = 0; +this.av_validCharWidth = false; +this.av_isShowSeqFeatureHeight = false; +this.offscreenImage = null; +this.lastSequenceFeatures = null; +this.sfSize = 0; +this.sfindex = 0; +this.spos = 0; +this.epos = 0; +this.transparencyAvailable = true; +Clazz.instantialize (this, arguments); +}, jalview.renderer.seqfeatures, "FeatureRenderer", jalview.viewmodel.seqfeatures.FeatureRendererModel); +Clazz.defineMethod (c$, "updateAvConfig", +function () { +this.av_charHeight = this.av.getCharHeight (); +this.av_charWidth = this.av.getCharWidth (); +this.av_validCharWidth = this.av.isValidCharWidth (); +this.av_isShowSeqFeatureHeight = this.av.isShowSequenceFeaturesHeight (); +}); +Clazz.defineMethod (c$, "renderFeature", +function (g, seq, fstart, fend, featureColour, start, end, y1) { +this.updateAvConfig (); +if (((fstart <= end) && (fend >= start))) { +if (fstart < start) { +fstart = start; +}if (fend >= end) { +fend = end; +}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); +for (this.i = fstart; this.i <= fend; this.i++) { +this.s = seq.getCharAt (this.i); +if (jalview.util.Comparison.isGap (this.s)) { +continue; +}g.setColor (featureColour); +g.fillRect ((this.i - start) * this.av_charWidth, y1, this.av_charWidth, this.av_charHeight); +if (this.offscreenRender || !this.av_validCharWidth) { +continue; +}g.setColor (java.awt.Color.white); +this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); +g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); +} +}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N"); +Clazz.defineMethod (c$, "renderScoreFeature", +function (g, seq, fstart, fend, featureColour, start, end, y1, bs) { +this.updateAvConfig (); +if (((fstart <= end) && (fend >= start))) { +if (fstart < start) { +fstart = start; +}if (fend >= end) { +fend = end; +}var pady = (y1 + this.av_charHeight) - Clazz.doubleToInt (this.av_charHeight / 5); +var ystrt = 0; +var yend = this.av_charHeight; +if (bs[0] != 0) { +if (bs[1] < 128) { +yend = Clazz.doubleToInt (this.av_charHeight * (128 - bs[1]) / 512); +ystrt = this.av_charHeight - Clazz.doubleToInt (yend / 2); +} else { +ystrt = Clazz.doubleToInt (this.av_charHeight / 2); +yend = Clazz.doubleToInt (this.av_charHeight * (bs[1] - 128) / 512); +}} else { +yend = Clazz.doubleToInt (this.av_charHeight * bs[1] / 255); +ystrt = this.av_charHeight - yend; +}for (this.i = fstart; this.i <= fend; this.i++) { +this.s = seq.getCharAt (this.i); +if (jalview.util.Comparison.isGap (this.s)) { +continue; +}g.setColor (featureColour); +var x = (this.i - start) * this.av_charWidth; +g.drawRect (x, y1, this.av_charWidth, this.av_charHeight); +g.fillRect (x, y1 + ystrt, this.av_charWidth, yend); +if (this.offscreenRender || !this.av_validCharWidth) { +continue; +}g.setColor (java.awt.Color.black); +this.charOffset = Clazz.doubleToInt ((this.av_charWidth - this.fm.charWidth (this.s)) / 2); +g.drawString (String.valueOf (this.s), this.charOffset + (this.av_charWidth * (this.i - start)), pady); +} +}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,java.awt.Color,~N,~N,~N,~A"); +Clazz.defineMethod (c$, "findFeatureColour", +function (initialCol, seq, res) { +return new java.awt.Color (this.findFeatureColour (initialCol.getRGB (), seq, res)); +}, "java.awt.Color,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "findFeatureColour", +function (initialCol, seq, column) { +if (!this.av.isShowSequenceFeatures ()) { +return initialCol; +}var sequenceFeatures = seq.getSequenceFeatures (); +if (seq !== this.lastSeq) { +this.lastSeq = seq; +this.lastSequenceFeatures = sequenceFeatures; +if (this.lastSequenceFeatures != null) { +this.sfSize = this.lastSequenceFeatures.length; +}} else { +if (this.lastSequenceFeatures !== sequenceFeatures) { +this.lastSequenceFeatures = sequenceFeatures; +if (this.lastSequenceFeatures != null) { +this.sfSize = this.lastSequenceFeatures.length; +}}}if (this.lastSequenceFeatures == null || this.sfSize == 0) { +return initialCol; +}if (jalview.util.Comparison.isGap (this.lastSeq.getCharAt (column))) { +return java.awt.Color.white.getRGB (); +}if (this.transparency != 1.0 && this.offscreenImage == null) { +this.offscreenImage = new java.awt.image.BufferedImage (1, 1, 2); +}this.currentColour = null; +this.offscreenRender = true; +if (this.offscreenImage != null) { +this.offscreenImage.setRGB (0, 0, initialCol); +this.drawSequence (this.offscreenImage.getGraphics (), this.lastSeq, column, column, 0); +return this.offscreenImage.getRGB (0, 0); +} else { +this.drawSequence (null, this.lastSeq, this.lastSeq.findPosition (column), -1, -1); +if (this.currentColour == null) { +return initialCol; +} else { +return (this.currentColour).intValue (); +}}}, "~N,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "drawSequence", +function (g, seq, start, end, y1) { +var sequenceFeatures = seq.getSequenceFeatures (); +if (sequenceFeatures == null || sequenceFeatures.length == 0) { +return; +}if (g != null) { +this.fm = g.getFontMetrics (); +}this.updateFeatures (); +if (this.lastSeq == null || seq !== this.lastSeq || sequenceFeatures !== this.lastSequenceFeatures) { +this.lastSeq = seq; +this.lastSequenceFeatures = sequenceFeatures; +}if (this.transparency != 1 && g != null) { +var g2 = g; +g2.setComposite (java.awt.AlphaComposite.getInstance (3, this.transparency)); +}if (!this.offscreenRender) { +this.spos = this.lastSeq.findPosition (start); +this.epos = this.lastSeq.findPosition (end); +}this.sfSize = this.lastSequenceFeatures.length; +var type; +for (var renderIndex = 0; renderIndex < this.renderOrder.length; renderIndex++) { +type = this.renderOrder[renderIndex]; +if (type == null || !this.showFeatureOfType (type)) { +continue; +}for (this.sfindex = 0; this.sfindex < this.sfSize; this.sfindex++) { +var sequenceFeature = this.lastSequenceFeatures[this.sfindex]; +if (!sequenceFeature.type.equals (type)) { +continue; +}if (this.featureGroups != null && sequenceFeature.featureGroup != null && sequenceFeature.featureGroup.length != 0 && this.featureGroups.containsKey (sequenceFeature.featureGroup) && !this.featureGroups.get (sequenceFeature.featureGroup).booleanValue ()) { +continue; +}if (!this.offscreenRender && (sequenceFeature.getBegin () > this.epos || sequenceFeature.getEnd () < this.spos)) { +continue; +}if (this.offscreenRender && this.offscreenImage == null) { +if (sequenceFeature.begin <= start && sequenceFeature.end >= start) { +this.currentColour = new Integer (this.getColour (sequenceFeature).getRGB ()); +}} else if (sequenceFeature.type.equals ("disulfide bond")) { +this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.begin) - 1, this.getColour (sequenceFeature), start, end, y1); +this.renderFeature (g, seq, seq.findIndex (sequenceFeature.end) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); +} else if (this.showFeature (sequenceFeature)) { +if (this.av_isShowSeqFeatureHeight && !Float.isNaN (sequenceFeature.score)) { +this.renderScoreFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1, this.normaliseScore (sequenceFeature)); +} else { +this.renderFeature (g, seq, seq.findIndex (sequenceFeature.begin) - 1, seq.findIndex (sequenceFeature.end) - 1, this.getColour (sequenceFeature), start, end, y1); +}}} +} +if (this.transparency != 1.0 && g != null && this.transparencyAvailable) { +var g2 = g; +g2.setComposite (java.awt.AlphaComposite.getInstance (3, 1.0)); +}}, "java.awt.Graphics,jalview.datamodel.SequenceI,~N,~N,~N"); +Clazz.defineMethod (c$, "setTransparencyAvailable", +function (isTransparencyAvailable) { +this.transparencyAvailable = isTransparencyAvailable; +}, "~B"); +Clazz.overrideMethod (c$, "isTransparencyAvailable", +function () { +return this.transparencyAvailable; +}); +Clazz.overrideMethod (c$, "featuresAdded", +function () { +this.lastSeq = null; +this.findAllFeatures (); +}); +}); diff --git a/bin/jalview/schemes/AnnotationColourGradient.js b/bin/jalview/schemes/AnnotationColourGradient.js index 0f29e11..40ed8eb 100644 --- a/bin/jalview/schemes/AnnotationColourGradient.js +++ b/bin/jalview/schemes/AnnotationColourGradient.js @@ -1,200 +1,200 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.FollowerColourScheme"], "jalview.schemes.AnnotationColourGradient", ["jalview.datamodel.AlignmentI", "$.GraphLine", "jalview.renderer.AnnotationRenderer", "jalview.schemes.ColourSchemeProperty", "jalview.util.Comparison", "java.awt.Color", "java.util.IdentityHashMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.annotation = null; -this.aboveAnnotationThreshold = -1; -this.thresholdIsMinMax = false; -this.annotationThreshold = null; -this.r1 = 0; -this.g1 = 0; -this.b1 = 0; -this.rr = 0; -this.gg = 0; -this.bb = 0; -this.predefinedColours = false; -this.seqAssociated = false; -this.noGradient = false; -this.seqannot = null; -this.aamin = 0; -this.aamax = 0; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "AnnotationColourGradient", jalview.schemes.FollowerColourScheme); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -var acg = new jalview.schemes.AnnotationColourGradient (this.annotation, this.colourScheme, this.aboveAnnotationThreshold); -acg.thresholdIsMinMax = this.thresholdIsMinMax; -acg.annotationThreshold = (this.annotationThreshold == null) ? null : new jalview.datamodel.GraphLine (this.annotationThreshold); -acg.r1 = this.r1; -acg.g1 = this.g1; -acg.b1 = this.b1; -acg.rr = this.rr; -acg.gg = this.gg; -acg.bb = this.bb; -acg.predefinedColours = this.predefinedColours; -acg.seqAssociated = this.seqAssociated; -acg.noGradient = this.noGradient; -return acg; -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.makeConstructor (c$, -function (annotation, originalColour, aboveThreshold) { -Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); -if (Clazz.instanceOf (originalColour, jalview.schemes.AnnotationColourGradient)) { -this.colourScheme = (originalColour).colourScheme; -} else { -this.colourScheme = originalColour; -}this.annotation = annotation; -this.aboveAnnotationThreshold = aboveThreshold; -if (aboveThreshold != -1 && annotation.threshold != null) { -this.annotationThreshold = annotation.threshold; -}this.r1 = 254; -this.g1 = 254; -this.b1 = 254; -this.rr = 0; -this.gg = 0; -this.bb = 0; -this.noGradient = true; -}, "jalview.datamodel.AlignmentAnnotation,jalview.schemes.ColourSchemeI,~N"); -Clazz.makeConstructor (c$, -function (annotation, minColour, maxColour, aboveThreshold) { -Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); -this.annotation = annotation; -this.aboveAnnotationThreshold = aboveThreshold; -if (aboveThreshold != -1 && annotation.threshold != null) { -this.annotationThreshold = annotation.threshold; -}this.r1 = minColour.getRed (); -this.g1 = minColour.getGreen (); -this.b1 = minColour.getBlue (); -this.rr = maxColour.getRed () - this.r1; -this.gg = maxColour.getGreen () - this.g1; -this.bb = maxColour.getBlue () - this.b1; -this.noGradient = false; -this.aamax = annotation.graphMax; -this.aamin = annotation.graphMin; -if (annotation.isRNA ()) { -jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); -}}, "jalview.datamodel.AlignmentAnnotation,java.awt.Color,java.awt.Color,~N"); -Clazz.defineMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -Clazz.superCall (this, jalview.schemes.AnnotationColourGradient, "alignmentChanged", [alignment, hiddenReps]); -if (this.seqAssociated && this.annotation.getCalcId () != null) { -if (this.seqannot != null) { -this.seqannot.clear (); -} else { -this.seqannot = new java.util.IdentityHashMap (); -}var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext (); -var f = true; -var rna = false; -for (var alan, $alan = alcontext.findAnnotation (this.annotation.getCalcId ()).iterator (); $alan.hasNext () && ((alan = $alan.next ()) || true);) { -if (alan.sequenceRef != null && (alan.label != null && this.annotation != null && alan.label.equals (this.annotation.label))) { -if (!rna && alan.isRNA ()) { -rna = true; -}this.seqannot.put (alan.sequenceRef, alan); -if (f || alan.graphMax > this.aamax) { -this.aamax = alan.graphMax; -}if (f || alan.graphMin < this.aamin) { -this.aamin = alan.graphMin; -}f = false; -}} -if (rna) { -jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); -}}}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.defineMethod (c$, "getAnnotation", -function () { -return this.annotation.label; -}); -Clazz.defineMethod (c$, "getAboveThreshold", -function () { -return this.aboveAnnotationThreshold; -}); -Clazz.defineMethod (c$, "getAnnotationThreshold", -function () { -if (this.annotationThreshold == null) { -return 0; -} else { -return this.annotationThreshold.value; -}}); -Clazz.defineMethod (c$, "getMinColour", -function () { -return new java.awt.Color (Clazz.floatToInt (this.r1), Clazz.floatToInt (this.g1), Clazz.floatToInt (this.b1)); -}); -Clazz.defineMethod (c$, "getMaxColour", -function () { -return new java.awt.Color (Clazz.floatToInt (this.r1 + this.rr), Clazz.floatToInt (this.g1 + this.gg), Clazz.floatToInt (this.b1 + this.bb)); -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return java.awt.Color.red; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour = java.awt.Color.white; -var annotation = (this.seqAssociated && this.seqannot != null ? this.seqannot.get (seq) : this.annotation); -if (annotation == null) { -return currentColour; -}if ((this.threshold == 0) || this.aboveThreshold (c, j)) { -if (annotation.annotations != null && j < annotation.annotations.length && annotation.annotations[j] != null && !jalview.util.Comparison.isGap (c)) { -var aj = annotation.annotations[j]; -if (this.aboveAnnotationThreshold == -1 || (this.annotationThreshold != null && (this.aboveAnnotationThreshold == 1 ? aj.value >= this.annotationThreshold.value : aj.value <= this.annotationThreshold.value))) { -if (this.predefinedColours && aj.colour != null && !aj.colour.equals (java.awt.Color.black)) { -currentColour = aj.colour; -} else if (annotation.hasIcons && annotation.graph == 0) { -if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.' && aj.secondaryStructure != '-') { -if (this.colourScheme != null) { -currentColour = this.colourScheme.findColour (c, j, seq); -} else { -if (annotation.isRNA ()) { -currentColour = jalview.schemes.ColourSchemeProperty.rnaHelices[Clazz.floatToInt (aj.value)]; -} else { -currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR : jalview.renderer.AnnotationRenderer.STEM_COLOUR; -}}} else { -return java.awt.Color.white; -}} else if (this.noGradient) { -if (this.colourScheme != null) { -currentColour = this.colourScheme.findColour (c, j, seq); -} else { -if (aj.colour != null) { -currentColour = aj.colour; -}}} else { -currentColour = this.shadeCalculation (annotation, j); -}}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}}}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "shadeCalculation", -($fz = function (annotation, j) { -var range = 1; -if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 1 && annotation.annotations[j].value >= annotation.threshold.value) { -range = (annotation.annotations[j].value - annotation.threshold.value) / (annotation.graphMax - annotation.threshold.value); -} else if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 0 && annotation.annotations[j].value >= annotation.graphMin) { -range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.threshold.value - annotation.graphMin); -} else { -if (annotation.graphMax != annotation.graphMin) { -range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.graphMax - annotation.graphMin); -} else { -range = 0; -}}var dr = Clazz.floatToInt (this.rr * range + this.r1); -var dg = Clazz.floatToInt (this.gg * range + this.g1); -var db = Clazz.floatToInt (this.bb * range + this.b1); -return new java.awt.Color (dr, dg, db); -}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,~N"); -Clazz.defineMethod (c$, "isPredefinedColours", -function () { -return this.predefinedColours; -}); -Clazz.defineMethod (c$, "setPredefinedColours", -function (predefinedColours) { -this.predefinedColours = predefinedColours; -}, "~B"); -Clazz.defineMethod (c$, "isSeqAssociated", -function () { -return this.seqAssociated; -}); -Clazz.defineMethod (c$, "setSeqAssociated", -function (sassoc) { -this.seqAssociated = sassoc; -}, "~B"); -Clazz.defineStatics (c$, -"NO_THRESHOLD", -1, -"BELOW_THRESHOLD", 0, -"ABOVE_THRESHOLD", 1); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.FollowerColourScheme"], "jalview.schemes.AnnotationColourGradient", ["jalview.datamodel.AlignmentI", "$.GraphLine", "jalview.renderer.AnnotationRenderer", "jalview.schemes.ColourSchemeProperty", "jalview.util.Comparison", "java.awt.Color", "java.util.IdentityHashMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.annotation = null; +this.aboveAnnotationThreshold = -1; +this.thresholdIsMinMax = false; +this.annotationThreshold = null; +this.r1 = 0; +this.g1 = 0; +this.b1 = 0; +this.rr = 0; +this.gg = 0; +this.bb = 0; +this.predefinedColours = false; +this.seqAssociated = false; +this.noGradient = false; +this.seqannot = null; +this.aamin = 0; +this.aamax = 0; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "AnnotationColourGradient", jalview.schemes.FollowerColourScheme); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +var acg = new jalview.schemes.AnnotationColourGradient (this.annotation, this.colourScheme, this.aboveAnnotationThreshold); +acg.thresholdIsMinMax = this.thresholdIsMinMax; +acg.annotationThreshold = (this.annotationThreshold == null) ? null : new jalview.datamodel.GraphLine (this.annotationThreshold); +acg.r1 = this.r1; +acg.g1 = this.g1; +acg.b1 = this.b1; +acg.rr = this.rr; +acg.gg = this.gg; +acg.bb = this.bb; +acg.predefinedColours = this.predefinedColours; +acg.seqAssociated = this.seqAssociated; +acg.noGradient = this.noGradient; +return acg; +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.makeConstructor (c$, +function (annotation, originalColour, aboveThreshold) { +Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); +if (Clazz.instanceOf (originalColour, jalview.schemes.AnnotationColourGradient)) { +this.colourScheme = (originalColour).colourScheme; +} else { +this.colourScheme = originalColour; +}this.annotation = annotation; +this.aboveAnnotationThreshold = aboveThreshold; +if (aboveThreshold != -1 && annotation.threshold != null) { +this.annotationThreshold = annotation.threshold; +}this.r1 = 254; +this.g1 = 254; +this.b1 = 254; +this.rr = 0; +this.gg = 0; +this.bb = 0; +this.noGradient = true; +}, "jalview.datamodel.AlignmentAnnotation,jalview.schemes.ColourSchemeI,~N"); +Clazz.makeConstructor (c$, +function (annotation, minColour, maxColour, aboveThreshold) { +Clazz.superConstructor (this, jalview.schemes.AnnotationColourGradient, []); +this.annotation = annotation; +this.aboveAnnotationThreshold = aboveThreshold; +if (aboveThreshold != -1 && annotation.threshold != null) { +this.annotationThreshold = annotation.threshold; +}this.r1 = minColour.getRed (); +this.g1 = minColour.getGreen (); +this.b1 = minColour.getBlue (); +this.rr = maxColour.getRed () - this.r1; +this.gg = maxColour.getGreen () - this.g1; +this.bb = maxColour.getBlue () - this.b1; +this.noGradient = false; +this.aamax = annotation.graphMax; +this.aamin = annotation.graphMin; +if (annotation.isRNA ()) { +jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); +}}, "jalview.datamodel.AlignmentAnnotation,java.awt.Color,java.awt.Color,~N"); +Clazz.defineMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +Clazz.superCall (this, jalview.schemes.AnnotationColourGradient, "alignmentChanged", [alignment, hiddenReps]); +if (this.seqAssociated && this.annotation.getCalcId () != null) { +if (this.seqannot != null) { +this.seqannot.clear (); +} else { +this.seqannot = new java.util.IdentityHashMap (); +}var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext (); +var f = true; +var rna = false; +for (var alan, $alan = alcontext.findAnnotation (this.annotation.getCalcId ()).iterator (); $alan.hasNext () && ((alan = $alan.next ()) || true);) { +if (alan.sequenceRef != null && (alan.label != null && this.annotation != null && alan.label.equals (this.annotation.label))) { +if (!rna && alan.isRNA ()) { +rna = true; +}this.seqannot.put (alan.sequenceRef, alan); +if (f || alan.graphMax > this.aamax) { +this.aamax = alan.graphMax; +}if (f || alan.graphMin < this.aamin) { +this.aamin = alan.graphMin; +}f = false; +}} +if (rna) { +jalview.schemes.ColourSchemeProperty.initRnaHelicesShading (1 + Clazz.floatToInt (this.aamax)); +}}}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.defineMethod (c$, "getAnnotation", +function () { +return this.annotation.label; +}); +Clazz.defineMethod (c$, "getAboveThreshold", +function () { +return this.aboveAnnotationThreshold; +}); +Clazz.defineMethod (c$, "getAnnotationThreshold", +function () { +if (this.annotationThreshold == null) { +return 0; +} else { +return this.annotationThreshold.value; +}}); +Clazz.defineMethod (c$, "getMinColour", +function () { +return new java.awt.Color (Clazz.floatToInt (this.r1), Clazz.floatToInt (this.g1), Clazz.floatToInt (this.b1)); +}); +Clazz.defineMethod (c$, "getMaxColour", +function () { +return new java.awt.Color (Clazz.floatToInt (this.r1 + this.rr), Clazz.floatToInt (this.g1 + this.gg), Clazz.floatToInt (this.b1 + this.bb)); +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return java.awt.Color.red; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour = java.awt.Color.white; +var annotation = (this.seqAssociated && this.seqannot != null ? this.seqannot.get (seq) : this.annotation); +if (annotation == null) { +return currentColour; +}if ((this.threshold == 0) || this.aboveThreshold (c, j)) { +if (annotation.annotations != null && j < annotation.annotations.length && annotation.annotations[j] != null && !jalview.util.Comparison.isGap (c)) { +var aj = annotation.annotations[j]; +if (this.aboveAnnotationThreshold == -1 || (this.annotationThreshold != null && (this.aboveAnnotationThreshold == 1 ? aj.value >= this.annotationThreshold.value : aj.value <= this.annotationThreshold.value))) { +if (this.predefinedColours && aj.colour != null && !aj.colour.equals (java.awt.Color.black)) { +currentColour = aj.colour; +} else if (annotation.hasIcons && annotation.graph == 0) { +if (aj.secondaryStructure > ' ' && aj.secondaryStructure != '.' && aj.secondaryStructure != '-') { +if (this.colourScheme != null) { +currentColour = this.colourScheme.findColour (c, j, seq); +} else { +if (annotation.isRNA ()) { +currentColour = jalview.schemes.ColourSchemeProperty.rnaHelices[Clazz.floatToInt (aj.value)]; +} else { +currentColour = annotation.annotations[j].secondaryStructure == 'H' ? jalview.renderer.AnnotationRenderer.HELIX_COLOUR : annotation.annotations[j].secondaryStructure == 'E' ? jalview.renderer.AnnotationRenderer.SHEET_COLOUR : jalview.renderer.AnnotationRenderer.STEM_COLOUR; +}}} else { +return java.awt.Color.white; +}} else if (this.noGradient) { +if (this.colourScheme != null) { +currentColour = this.colourScheme.findColour (c, j, seq); +} else { +if (aj.colour != null) { +currentColour = aj.colour; +}}} else { +currentColour = this.shadeCalculation (annotation, j); +}}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}}}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "shadeCalculation", +($fz = function (annotation, j) { +var range = 1; +if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 1 && annotation.annotations[j].value >= annotation.threshold.value) { +range = (annotation.annotations[j].value - annotation.threshold.value) / (annotation.graphMax - annotation.threshold.value); +} else if (this.thresholdIsMinMax && annotation.threshold != null && this.aboveAnnotationThreshold == 0 && annotation.annotations[j].value >= annotation.graphMin) { +range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.threshold.value - annotation.graphMin); +} else { +if (annotation.graphMax != annotation.graphMin) { +range = (annotation.annotations[j].value - annotation.graphMin) / (annotation.graphMax - annotation.graphMin); +} else { +range = 0; +}}var dr = Clazz.floatToInt (this.rr * range + this.r1); +var dg = Clazz.floatToInt (this.gg * range + this.g1); +var db = Clazz.floatToInt (this.bb * range + this.b1); +return new java.awt.Color (dr, dg, db); +}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,~N"); +Clazz.defineMethod (c$, "isPredefinedColours", +function () { +return this.predefinedColours; +}); +Clazz.defineMethod (c$, "setPredefinedColours", +function (predefinedColours) { +this.predefinedColours = predefinedColours; +}, "~B"); +Clazz.defineMethod (c$, "isSeqAssociated", +function () { +return this.seqAssociated; +}); +Clazz.defineMethod (c$, "setSeqAssociated", +function (sassoc) { +this.seqAssociated = sassoc; +}, "~B"); +Clazz.defineStatics (c$, +"NO_THRESHOLD", -1, +"BELOW_THRESHOLD", 0, +"ABOVE_THRESHOLD", 1); +}); diff --git a/bin/jalview/schemes/Blosum62ColourScheme.js b/bin/jalview/schemes/Blosum62ColourScheme.js index 87c4a51..3268bc7 100644 --- a/bin/jalview/schemes/Blosum62ColourScheme.js +++ b/bin/jalview/schemes/Blosum62ColourScheme.js @@ -1,37 +1,37 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.Blosum62ColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "Blosum62ColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.defineMethod (c$, "findColour", -function (res, j, seq) { -if ('a' <= res && res <= 'z') { -res = String.fromCharCode (res.charCodeAt (0) - (32)); -}if (this.consensus == null || j >= this.consensus.length || this.consensus[j] == null || (this.threshold != 0 && !this.aboveThreshold (res, j))) { -return java.awt.Color.white; -}var currentColour; -if (!jalview.util.Comparison.isGap (res)) { -var max = this.consensus[j].get ("R"); -if (max.indexOf (res) > -1) { -currentColour = new java.awt.Color (154, 154, 255); -} else { -var c = 0; -var max_aa = 0; -var n = max.length; -do { -c += jalview.schemes.ResidueProperties.getBLOSUM62 (max.charAt (max_aa), res); -} while (++max_aa < n); -if (c > 0) { -currentColour = new java.awt.Color (204, 204, 255); -} else { -currentColour = java.awt.Color.white; -}}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}} else { -return java.awt.Color.white; -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -var newcs = Clazz.superCall (this, jalview.schemes.Blosum62ColourScheme, "applyTo", [sg, hiddenRepSequences]); -return newcs; -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.Blosum62ColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "Blosum62ColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.defineMethod (c$, "findColour", +function (res, j, seq) { +if ('a' <= res && res <= 'z') { +res = String.fromCharCode (res.charCodeAt (0) - (32)); +}if (this.consensus == null || j >= this.consensus.length || this.consensus[j] == null || (this.threshold != 0 && !this.aboveThreshold (res, j))) { +return java.awt.Color.white; +}var currentColour; +if (!jalview.util.Comparison.isGap (res)) { +var max = this.consensus[j].get ("R"); +if (max.indexOf (res) > -1) { +currentColour = new java.awt.Color (154, 154, 255); +} else { +var c = 0; +var max_aa = 0; +var n = max.length; +do { +c += jalview.schemes.ResidueProperties.getBLOSUM62 (max.charAt (max_aa), res); +} while (++max_aa < n); +if (c > 0) { +currentColour = new java.awt.Color (204, 204, 255); +} else { +currentColour = java.awt.Color.white; +}}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}} else { +return java.awt.Color.white; +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +var newcs = Clazz.superCall (this, jalview.schemes.Blosum62ColourScheme, "applyTo", [sg, hiddenRepSequences]); +return newcs; +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +}); diff --git a/bin/jalview/schemes/BuriedColourScheme.js b/bin/jalview/schemes/BuriedColourScheme.js index 0ca91cd..fa820e3 100644 --- a/bin/jalview/schemes/BuriedColourScheme.js +++ b/bin/jalview/schemes/BuriedColourScheme.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.BuriedColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "BuriedColourScheme", jalview.schemes.ScoreColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.BuriedColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.buried, 0.05, 4.6]); -}); -Clazz.overrideMethod (c$, "makeColour", -function (c) { -return new java.awt.Color (0, (1.0 - c), c); -}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.BuriedColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "BuriedColourScheme", jalview.schemes.ScoreColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.BuriedColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.buried, 0.05, 4.6]); +}); +Clazz.overrideMethod (c$, "makeColour", +function (c) { +return new java.awt.Color (0, (1.0 - c), c); +}, "~N"); +}); diff --git a/bin/jalview/schemes/ClustalxColourScheme.js b/bin/jalview/schemes/ClustalxColourScheme.js index 0556777..3897463 100644 --- a/bin/jalview/schemes/ClustalxColourScheme.js +++ b/bin/jalview/schemes/ClustalxColourScheme.js @@ -1,237 +1,237 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.HashMap"], ["jalview.schemes.ConsensusColour", "$.ClustalxColourScheme"], ["jalview.schemes.Consensus", "$.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.decorateAsClass (function () { -this.cons2 = null; -this.colours = null; -this.residueColour = null; -this.size = 0; -this.conses = null; -this.includeGaps = true; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "ClustalxColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.prepareFields (c$, function () { -this.conses = new Array (32); -}); -Clazz.makeConstructor (c$, -function (alignment, hiddenReps) { -Clazz.superConstructor (this, jalview.schemes.ClustalxColourScheme, []); -this.alignmentChanged (alignment, hiddenReps); -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.overrideMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -var maxWidth = alignment.getWidth (); -var seqs = alignment.getSequences (hiddenReps); -this.cons2 = Clazz.newIntArray (maxWidth, 24, 0); -this.includeGaps = this.isIncludeGaps (); -var start = 0; -for (var j = 0; j < 24; j++) { -for (var i = 0; i < maxWidth; i++) { -this.cons2[i][j] = 0; -} -} -var res; -var i; -var j = 0; -var seq; -for (var sq, $sq = seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { -seq = sq.getSequence (); -var end_j = seq.length - 1; -for (i = start; i <= end_j; i++) { -if ((seq.length - 1) < i) { -res = 23; -} else { -res = jalview.schemes.ResidueProperties.aaIndex[seq[i].charCodeAt (0)]; -}this.cons2[i][res]++; -} -j++; -} -this.size = seqs.size (); -this.makeColours (); -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.defineMethod (c$, "makeColours", -function () { -this.conses[0] = new jalview.schemes.Consensus ("WLVIMAFCYHP", 60); -this.conses[1] = new jalview.schemes.Consensus ("WLVIMAFCYHP", 80); -this.conses[2] = new jalview.schemes.Consensus ("ED", 50); -this.conses[3] = new jalview.schemes.Consensus ("KR", 60); -this.conses[4] = new jalview.schemes.Consensus ("G", 50); -this.conses[5] = new jalview.schemes.Consensus ("N", 50); -this.conses[6] = new jalview.schemes.Consensus ("QE", 50); -this.conses[7] = new jalview.schemes.Consensus ("P", 50); -this.conses[8] = new jalview.schemes.Consensus ("TS", 50); -this.conses[26] = new jalview.schemes.Consensus ("A", 85); -this.conses[27] = new jalview.schemes.Consensus ("C", 85); -this.conses[10] = new jalview.schemes.Consensus ("E", 85); -this.conses[11] = new jalview.schemes.Consensus ("F", 85); -this.conses[12] = new jalview.schemes.Consensus ("G", 85); -this.conses[13] = new jalview.schemes.Consensus ("H", 85); -this.conses[14] = new jalview.schemes.Consensus ("I", 85); -this.conses[15] = new jalview.schemes.Consensus ("L", 85); -this.conses[16] = new jalview.schemes.Consensus ("M", 85); -this.conses[17] = new jalview.schemes.Consensus ("N", 85); -this.conses[18] = new jalview.schemes.Consensus ("P", 85); -this.conses[19] = new jalview.schemes.Consensus ("Q", 85); -this.conses[20] = new jalview.schemes.Consensus ("R", 85); -this.conses[21] = new jalview.schemes.Consensus ("S", 85); -this.conses[22] = new jalview.schemes.Consensus ("T", 85); -this.conses[23] = new jalview.schemes.Consensus ("V", 85); -this.conses[24] = new jalview.schemes.Consensus ("W", 85); -this.conses[25] = new jalview.schemes.Consensus ("Y", 85); -this.conses[28] = new jalview.schemes.Consensus ("K", 85); -this.conses[29] = new jalview.schemes.Consensus ("D", 85); -this.conses[30] = new jalview.schemes.Consensus ("G", 0); -this.conses[31] = new jalview.schemes.Consensus ("P", 0); -this.colours = new Array (11); -var tmp8 = new Array (1); -tmp8[0] = this.conses[30]; -this.colours[7] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.ORANGE), tmp8); -var tmp9 = new Array (1); -tmp9[0] = this.conses[31]; -this.colours[8] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.YELLOW), tmp9); -var tmp10 = new Array (1); -tmp10[0] = this.conses[27]; -this.colours[9] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.PINK), tmp8); -var tmp1 = new Array (14); -tmp1[0] = this.conses[0]; -tmp1[1] = this.conses[1]; -tmp1[2] = this.conses[26]; -tmp1[3] = this.conses[27]; -tmp1[4] = this.conses[11]; -tmp1[5] = this.conses[13]; -tmp1[6] = this.conses[14]; -tmp1[7] = this.conses[15]; -tmp1[8] = this.conses[16]; -tmp1[9] = this.conses[23]; -tmp1[10] = this.conses[24]; -tmp1[11] = this.conses[25]; -tmp1[12] = this.conses[18]; -tmp1[13] = this.conses[19]; -this.colours[0] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.BLUE), tmp1); -this.colours[10] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.CYAN), tmp1); -var tmp2 = new Array (5); -tmp2[0] = this.conses[8]; -tmp2[1] = this.conses[21]; -tmp2[2] = this.conses[22]; -tmp2[3] = this.conses[0]; -tmp2[4] = this.conses[1]; -this.colours[1] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp2); -var tmp3 = new Array (3); -tmp3[0] = this.conses[17]; -tmp3[1] = this.conses[29]; -tmp3[2] = this.conses[5]; -this.colours[2] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp3); -var tmp4 = new Array (6); -tmp4[0] = this.conses[6]; -tmp4[1] = this.conses[19]; -tmp4[2] = this.conses[22]; -tmp4[3] = this.conses[3]; -tmp4[4] = this.conses[28]; -tmp4[5] = this.conses[20]; -this.colours[3] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp4); -var tmp5 = new Array (4); -tmp5[0] = this.conses[3]; -tmp5[1] = this.conses[28]; -tmp5[2] = this.conses[20]; -tmp5[3] = this.conses[19]; -this.colours[4] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.RED), tmp5); -var tmp6 = new Array (6); -tmp6[0] = this.conses[3]; -tmp6[1] = this.conses[29]; -tmp6[2] = this.conses[10]; -tmp6[3] = this.conses[6]; -tmp6[4] = this.conses[19]; -tmp6[5] = this.conses[2]; -this.colours[5] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.MAGENTA), tmp6); -var tmp7 = new Array (5); -tmp7[0] = this.conses[3]; -tmp7[1] = this.conses[29]; -tmp7[2] = this.conses[10]; -tmp7[3] = this.conses[17]; -tmp7[4] = this.conses[2]; -this.colours[6] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.MAGENTA), tmp7); -this.residueColour = new Array (20); -this.residueColour[0] = this.colours[0]; -this.residueColour[1] = this.colours[4]; -this.residueColour[2] = this.colours[2]; -this.residueColour[3] = this.colours[6]; -this.residueColour[4] = this.colours[0]; -this.residueColour[5] = this.colours[3]; -this.residueColour[6] = this.colours[5]; -this.residueColour[7] = this.colours[7]; -this.residueColour[8] = this.colours[10]; -this.residueColour[9] = this.colours[0]; -this.residueColour[10] = this.colours[0]; -this.residueColour[11] = this.colours[4]; -this.residueColour[12] = this.colours[0]; -this.residueColour[13] = this.colours[0]; -this.residueColour[14] = this.colours[8]; -this.residueColour[15] = this.colours[1]; -this.residueColour[16] = this.colours[1]; -this.residueColour[17] = this.colours[0]; -this.residueColour[18] = this.colours[10]; -this.residueColour[19] = this.colours[0]; -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return java.awt.Color.pink; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour; -if (this.cons2.length <= j || (this.includeGaps && this.threshold != 0 && !this.aboveThreshold (c, j))) { -return java.awt.Color.white; -}var i = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]; -currentColour = java.awt.Color.white; -if (i > 19) { -return currentColour; -}for (var k = 0; k < this.residueColour[i].conses.length; k++) { -if (this.residueColour[i].conses[k].isConserved (this.cons2, j, this.size, this.includeGaps)) { -currentColour = this.residueColour[i].c; -}} -if (i == 4) { -if (this.conses[27].isConserved (this.cons2, j, this.size, this.includeGaps)) { -currentColour = jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.PINK); -}}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "isIncludeGaps", -function () { -return this.includeGaps; -}); -Clazz.defineMethod (c$, "setIncludeGaps", -function (includeGaps) { -this.includeGaps = includeGaps; -}, "~B"); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -var css = new jalview.schemes.ClustalxColourScheme (sg, hiddenRepSequences); -css.includeGaps = this.includeGaps; -return css; -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.defineStatics (c$, -"EIGHTY_FIVE", 85, -"FIFTY", 50, -"EIGHTY", 80, -"SIXTY", 60); -c$.colhash = c$.prototype.colhash = new java.util.HashMap (); -{ -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.RED, new java.awt.Color (0.9, 0.2, 0.1)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.BLUE, new java.awt.Color (0.5, 0.7, 0.9)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.GREEN, new java.awt.Color (0.1, 0.8, 0.1)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.ORANGE, new java.awt.Color (0.9, 0.6, 0.3)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.CYAN, new java.awt.Color (0.1, 0.7, 0.7)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.PINK, new java.awt.Color (0.9, 0.5, 0.5)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.MAGENTA, new java.awt.Color (0.8, 0.3, 0.8)); -jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.YELLOW, new java.awt.Color (0.8, 0.8, 0.0)); -}c$ = Clazz.decorateAsClass (function () { -this.conses = null; -this.c = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "ConsensusColour"); -Clazz.makeConstructor (c$, -function (c, conses) { -this.conses = conses; -this.c = c; -}, "java.awt.Color,~A"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.HashMap"], ["jalview.schemes.ConsensusColour", "$.ClustalxColourScheme"], ["jalview.schemes.Consensus", "$.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.decorateAsClass (function () { +this.cons2 = null; +this.colours = null; +this.residueColour = null; +this.size = 0; +this.conses = null; +this.includeGaps = true; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "ClustalxColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.prepareFields (c$, function () { +this.conses = new Array (32); +}); +Clazz.makeConstructor (c$, +function (alignment, hiddenReps) { +Clazz.superConstructor (this, jalview.schemes.ClustalxColourScheme, []); +this.alignmentChanged (alignment, hiddenReps); +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.overrideMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +var maxWidth = alignment.getWidth (); +var seqs = alignment.getSequences (hiddenReps); +this.cons2 = Clazz.newIntArray (maxWidth, 24, 0); +this.includeGaps = this.isIncludeGaps (); +var start = 0; +for (var j = 0; j < 24; j++) { +for (var i = 0; i < maxWidth; i++) { +this.cons2[i][j] = 0; +} +} +var res; +var i; +var j = 0; +var seq; +for (var sq, $sq = seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) { +seq = sq.getSequence (); +var end_j = seq.length - 1; +for (i = start; i <= end_j; i++) { +if ((seq.length - 1) < i) { +res = 23; +} else { +res = jalview.schemes.ResidueProperties.aaIndex[seq[i].charCodeAt (0)]; +}this.cons2[i][res]++; +} +j++; +} +this.size = seqs.size (); +this.makeColours (); +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.defineMethod (c$, "makeColours", +function () { +this.conses[0] = new jalview.schemes.Consensus ("WLVIMAFCYHP", 60); +this.conses[1] = new jalview.schemes.Consensus ("WLVIMAFCYHP", 80); +this.conses[2] = new jalview.schemes.Consensus ("ED", 50); +this.conses[3] = new jalview.schemes.Consensus ("KR", 60); +this.conses[4] = new jalview.schemes.Consensus ("G", 50); +this.conses[5] = new jalview.schemes.Consensus ("N", 50); +this.conses[6] = new jalview.schemes.Consensus ("QE", 50); +this.conses[7] = new jalview.schemes.Consensus ("P", 50); +this.conses[8] = new jalview.schemes.Consensus ("TS", 50); +this.conses[26] = new jalview.schemes.Consensus ("A", 85); +this.conses[27] = new jalview.schemes.Consensus ("C", 85); +this.conses[10] = new jalview.schemes.Consensus ("E", 85); +this.conses[11] = new jalview.schemes.Consensus ("F", 85); +this.conses[12] = new jalview.schemes.Consensus ("G", 85); +this.conses[13] = new jalview.schemes.Consensus ("H", 85); +this.conses[14] = new jalview.schemes.Consensus ("I", 85); +this.conses[15] = new jalview.schemes.Consensus ("L", 85); +this.conses[16] = new jalview.schemes.Consensus ("M", 85); +this.conses[17] = new jalview.schemes.Consensus ("N", 85); +this.conses[18] = new jalview.schemes.Consensus ("P", 85); +this.conses[19] = new jalview.schemes.Consensus ("Q", 85); +this.conses[20] = new jalview.schemes.Consensus ("R", 85); +this.conses[21] = new jalview.schemes.Consensus ("S", 85); +this.conses[22] = new jalview.schemes.Consensus ("T", 85); +this.conses[23] = new jalview.schemes.Consensus ("V", 85); +this.conses[24] = new jalview.schemes.Consensus ("W", 85); +this.conses[25] = new jalview.schemes.Consensus ("Y", 85); +this.conses[28] = new jalview.schemes.Consensus ("K", 85); +this.conses[29] = new jalview.schemes.Consensus ("D", 85); +this.conses[30] = new jalview.schemes.Consensus ("G", 0); +this.conses[31] = new jalview.schemes.Consensus ("P", 0); +this.colours = new Array (11); +var tmp8 = new Array (1); +tmp8[0] = this.conses[30]; +this.colours[7] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.ORANGE), tmp8); +var tmp9 = new Array (1); +tmp9[0] = this.conses[31]; +this.colours[8] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.YELLOW), tmp9); +var tmp10 = new Array (1); +tmp10[0] = this.conses[27]; +this.colours[9] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.PINK), tmp8); +var tmp1 = new Array (14); +tmp1[0] = this.conses[0]; +tmp1[1] = this.conses[1]; +tmp1[2] = this.conses[26]; +tmp1[3] = this.conses[27]; +tmp1[4] = this.conses[11]; +tmp1[5] = this.conses[13]; +tmp1[6] = this.conses[14]; +tmp1[7] = this.conses[15]; +tmp1[8] = this.conses[16]; +tmp1[9] = this.conses[23]; +tmp1[10] = this.conses[24]; +tmp1[11] = this.conses[25]; +tmp1[12] = this.conses[18]; +tmp1[13] = this.conses[19]; +this.colours[0] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.BLUE), tmp1); +this.colours[10] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.CYAN), tmp1); +var tmp2 = new Array (5); +tmp2[0] = this.conses[8]; +tmp2[1] = this.conses[21]; +tmp2[2] = this.conses[22]; +tmp2[3] = this.conses[0]; +tmp2[4] = this.conses[1]; +this.colours[1] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp2); +var tmp3 = new Array (3); +tmp3[0] = this.conses[17]; +tmp3[1] = this.conses[29]; +tmp3[2] = this.conses[5]; +this.colours[2] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp3); +var tmp4 = new Array (6); +tmp4[0] = this.conses[6]; +tmp4[1] = this.conses[19]; +tmp4[2] = this.conses[22]; +tmp4[3] = this.conses[3]; +tmp4[4] = this.conses[28]; +tmp4[5] = this.conses[20]; +this.colours[3] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp4); +var tmp5 = new Array (4); +tmp5[0] = this.conses[3]; +tmp5[1] = this.conses[28]; +tmp5[2] = this.conses[20]; +tmp5[3] = this.conses[19]; +this.colours[4] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.RED), tmp5); +var tmp6 = new Array (6); +tmp6[0] = this.conses[3]; +tmp6[1] = this.conses[29]; +tmp6[2] = this.conses[10]; +tmp6[3] = this.conses[6]; +tmp6[4] = this.conses[19]; +tmp6[5] = this.conses[2]; +this.colours[5] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.MAGENTA), tmp6); +var tmp7 = new Array (5); +tmp7[0] = this.conses[3]; +tmp7[1] = this.conses[29]; +tmp7[2] = this.conses[10]; +tmp7[3] = this.conses[17]; +tmp7[4] = this.conses[2]; +this.colours[6] = new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.MAGENTA), tmp7); +this.residueColour = new Array (20); +this.residueColour[0] = this.colours[0]; +this.residueColour[1] = this.colours[4]; +this.residueColour[2] = this.colours[2]; +this.residueColour[3] = this.colours[6]; +this.residueColour[4] = this.colours[0]; +this.residueColour[5] = this.colours[3]; +this.residueColour[6] = this.colours[5]; +this.residueColour[7] = this.colours[7]; +this.residueColour[8] = this.colours[10]; +this.residueColour[9] = this.colours[0]; +this.residueColour[10] = this.colours[0]; +this.residueColour[11] = this.colours[4]; +this.residueColour[12] = this.colours[0]; +this.residueColour[13] = this.colours[0]; +this.residueColour[14] = this.colours[8]; +this.residueColour[15] = this.colours[1]; +this.residueColour[16] = this.colours[1]; +this.residueColour[17] = this.colours[0]; +this.residueColour[18] = this.colours[10]; +this.residueColour[19] = this.colours[0]; +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return java.awt.Color.pink; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour; +if (this.cons2.length <= j || (this.includeGaps && this.threshold != 0 && !this.aboveThreshold (c, j))) { +return java.awt.Color.white; +}var i = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]; +currentColour = java.awt.Color.white; +if (i > 19) { +return currentColour; +}for (var k = 0; k < this.residueColour[i].conses.length; k++) { +if (this.residueColour[i].conses[k].isConserved (this.cons2, j, this.size, this.includeGaps)) { +currentColour = this.residueColour[i].c; +}} +if (i == 4) { +if (this.conses[27].isConserved (this.cons2, j, this.size, this.includeGaps)) { +currentColour = jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.PINK); +}}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "isIncludeGaps", +function () { +return this.includeGaps; +}); +Clazz.defineMethod (c$, "setIncludeGaps", +function (includeGaps) { +this.includeGaps = includeGaps; +}, "~B"); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +var css = new jalview.schemes.ClustalxColourScheme (sg, hiddenRepSequences); +css.includeGaps = this.includeGaps; +return css; +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.defineStatics (c$, +"EIGHTY_FIVE", 85, +"FIFTY", 50, +"EIGHTY", 80, +"SIXTY", 60); +c$.colhash = c$.prototype.colhash = new java.util.HashMap (); +{ +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.RED, new java.awt.Color (0.9, 0.2, 0.1)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.BLUE, new java.awt.Color (0.5, 0.7, 0.9)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.GREEN, new java.awt.Color (0.1, 0.8, 0.1)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.ORANGE, new java.awt.Color (0.9, 0.6, 0.3)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.CYAN, new java.awt.Color (0.1, 0.7, 0.7)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.PINK, new java.awt.Color (0.9, 0.5, 0.5)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.MAGENTA, new java.awt.Color (0.8, 0.3, 0.8)); +jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.YELLOW, new java.awt.Color (0.8, 0.8, 0.0)); +}c$ = Clazz.decorateAsClass (function () { +this.conses = null; +this.c = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "ConsensusColour"); +Clazz.makeConstructor (c$, +function (c, conses) { +this.conses = conses; +this.c = c; +}, "java.awt.Color,~A"); +}); diff --git a/bin/jalview/schemes/ColourSchemeI.js b/bin/jalview/schemes/ColourSchemeI.js index b82090d..9777117 100644 --- a/bin/jalview/schemes/ColourSchemeI.js +++ b/bin/jalview/schemes/ColourSchemeI.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.declareInterface (jalview.schemes, "ColourSchemeI"); +Clazz.declarePackage ("jalview.schemes"); +Clazz.declareInterface (jalview.schemes, "ColourSchemeI"); diff --git a/bin/jalview/schemes/ColourSchemeProperty.js b/bin/jalview/schemes/ColourSchemeProperty.js index eb55454..352a373 100644 --- a/bin/jalview/schemes/ColourSchemeProperty.js +++ b/bin/jalview/schemes/ColourSchemeProperty.js @@ -1,292 +1,292 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (null, "jalview.schemes.ColourSchemeProperty", ["jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.PurinePyrimidineColourScheme", "$.RNAHelicesColour", "$.StrandColourScheme", "$.TCoffeeColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.UserColourScheme", "$.ZappoColourScheme", "jalview.util.ColorUtils", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "ColourSchemeProperty"); -c$.getColourIndexFromName = Clazz.defineMethod (c$, "getColourIndexFromName", -function (name) { -var ret = -1; -if (name.equalsIgnoreCase ("Clustal")) { -ret = 2; -} else if (name.equalsIgnoreCase ("Blosum62")) { -ret = 3; -} else if (name.equalsIgnoreCase ("% Identity")) { -ret = 4; -} else if (name.equalsIgnoreCase ("Zappo")) { -ret = 5; -} else if (name.equalsIgnoreCase ("Taylor")) { -ret = 6; -} else if (name.equalsIgnoreCase ("Hydrophobic")) { -ret = 7; -} else if (name.equalsIgnoreCase ("Helix Propensity")) { -ret = 8; -} else if (name.equalsIgnoreCase ("Strand Propensity")) { -ret = 9; -} else if (name.equalsIgnoreCase ("Turn Propensity")) { -ret = 10; -} else if (name.equalsIgnoreCase ("Buried Index")) { -ret = 11; -} else if (name.equalsIgnoreCase ("Nucleotide")) { -ret = 12; -} else if (name.equalsIgnoreCase ("T-Coffee Scores")) { -ret = 15; -} else if (name.equalsIgnoreCase ("User Defined")) { -ret = 0; -} else if (name.equalsIgnoreCase ("None")) { -ret = 1; -} else if (name.equalsIgnoreCase ("Purine/Pyrimidine")) { -ret = 13; -} else if (name.equalsIgnoreCase ("RNA Interaction type")) { -ret = 17; -} else if (name.equalsIgnoreCase ("RNA Helices")) { -ret = 16; -}return ret; -}, "~S"); -c$.getColourName = Clazz.defineMethod (c$, "getColourName", -function (cs) { -var index = 1; -if (Clazz.instanceOf (cs, jalview.schemes.ClustalxColourScheme)) { -index = 2; -} else if (Clazz.instanceOf (cs, jalview.schemes.Blosum62ColourScheme)) { -index = 3; -} else if (Clazz.instanceOf (cs, jalview.schemes.PIDColourScheme)) { -index = 4; -} else if (Clazz.instanceOf (cs, jalview.schemes.ZappoColourScheme)) { -index = 5; -} else if (Clazz.instanceOf (cs, jalview.schemes.TaylorColourScheme)) { -index = 6; -} else if (Clazz.instanceOf (cs, jalview.schemes.HydrophobicColourScheme)) { -index = 7; -} else if (Clazz.instanceOf (cs, jalview.schemes.HelixColourScheme)) { -index = 8; -} else if (Clazz.instanceOf (cs, jalview.schemes.StrandColourScheme)) { -index = 9; -} else if (Clazz.instanceOf (cs, jalview.schemes.TurnColourScheme)) { -index = 10; -} else if (Clazz.instanceOf (cs, jalview.schemes.BuriedColourScheme)) { -index = 11; -} else if (Clazz.instanceOf (cs, jalview.schemes.NucleotideColourScheme)) { -index = 12; -} else if (Clazz.instanceOf (cs, jalview.schemes.PurinePyrimidineColourScheme)) { -index = 13; -} else if (Clazz.instanceOf (cs, jalview.schemes.TCoffeeColourScheme)) { -index = 15; -} else if (Clazz.instanceOf (cs, jalview.schemes.RNAHelicesColour)) { -index = 16; -} else if (Clazz.instanceOf (cs, jalview.schemes.UserColourScheme)) { -if (((cs).getName () != null) && ((cs).getName ().length > 0)) { -return (cs).getName (); -}index = 0; -}return jalview.schemes.ColourSchemeProperty.getColourName (index); -}, "jalview.schemes.ColourSchemeI"); -c$.getColourName = Clazz.defineMethod (c$, "getColourName", -function (index) { -var ret = null; -switch (index) { -case 2: -ret = "Clustal"; -break; -case 3: -ret = "Blosum62"; -break; -case 4: -ret = "% Identity"; -break; -case 5: -ret = "Zappo"; -break; -case 6: -ret = "Taylor"; -break; -case 7: -ret = "Hydrophobic"; -break; -case 8: -ret = "Helix Propensity"; -break; -case 9: -ret = "Strand Propensity"; -break; -case 10: -ret = "Turn Propensity"; -break; -case 11: -ret = "Buried Index"; -break; -case 12: -ret = "Nucleotide"; -break; -case 13: -ret = "Purine/Pyrimidine"; -break; -case 15: -ret = "T-Coffee Scores"; -break; -case 17: -ret = "RNA Interaction type"; -break; -case 16: -ret = "RNA Helices"; -break; -case 0: -ret = "User Defined"; -break; -default: -ret = "None"; -break; -} -return ret; -}, "~N"); -c$.getColour = Clazz.defineMethod (c$, "getColour", -function (alignment, name) { -var colindex = jalview.schemes.ColourSchemeProperty.getColourIndexFromName (name); -if (colindex == -1) { -if (name.indexOf ('=') == -1) { -try { -return new jalview.schemes.UserColourScheme (name); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -} else { -try { -var ucs = new jalview.schemes.UserColourScheme ("white"); -ucs.parseAppletParameter (name); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -}}return jalview.schemes.ColourSchemeProperty.getColour (alignment, jalview.schemes.ColourSchemeProperty.getColourIndexFromName (name)); -}, "jalview.datamodel.AnnotatedCollectionI,~S"); -c$.getColour = Clazz.defineMethod (c$, "getColour", -function (coll, index) { -var cs = null; -switch (index) { -case 2: -cs = new jalview.schemes.ClustalxColourScheme (coll, null); -break; -case 3: -cs = new jalview.schemes.Blosum62ColourScheme (); -break; -case 4: -cs = new jalview.schemes.PIDColourScheme (); -break; -case 5: -cs = new jalview.schemes.ZappoColourScheme (); -break; -case 6: -cs = new jalview.schemes.TaylorColourScheme (); -break; -case 7: -cs = new jalview.schemes.HydrophobicColourScheme (); -break; -case 8: -cs = new jalview.schemes.HelixColourScheme (); -break; -case 9: -cs = new jalview.schemes.StrandColourScheme (); -break; -case 10: -cs = new jalview.schemes.TurnColourScheme (); -break; -case 11: -cs = new jalview.schemes.BuriedColourScheme (); -break; -case 12: -cs = new jalview.schemes.NucleotideColourScheme (); -break; -case 13: -cs = new jalview.schemes.PurinePyrimidineColourScheme (); -break; -case 15: -cs = new jalview.schemes.TCoffeeColourScheme (coll); -break; -case 16: -cs = new jalview.schemes.RNAHelicesColour (coll); -break; -case 0: -var col = new Array (24); -for (var i = 0; i < 24; i++) { -col[i] = java.awt.Color.white; -} -cs = new jalview.schemes.UserColourScheme (col); -break; -default: -break; -} -return cs; -}, "jalview.datamodel.AnnotatedCollectionI,~N"); -c$.getAWTColorFromName = Clazz.defineMethod (c$, "getAWTColorFromName", -function (name) { -var col = null; -name = name.toLowerCase (); -if (name.equals ("black")) { -col = java.awt.Color.black; -} else if (name.equals ("blue")) { -col = java.awt.Color.blue; -} else if (name.equals ("cyan")) { -col = java.awt.Color.cyan; -} else if (name.equals ("darkGray")) { -col = java.awt.Color.darkGray; -} else if (name.equals ("gray")) { -col = java.awt.Color.gray; -} else if (name.equals ("green")) { -col = java.awt.Color.green; -} else if (name.equals ("lightGray")) { -col = java.awt.Color.lightGray; -} else if (name.equals ("magenta")) { -col = java.awt.Color.magenta; -} else if (name.equals ("orange")) { -col = java.awt.Color.orange; -} else if (name.equals ("pink")) { -col = java.awt.Color.pink; -} else if (name.equals ("red")) { -col = java.awt.Color.red; -} else if (name.equals ("white")) { -col = java.awt.Color.white; -} else if (name.equals ("yellow")) { -col = java.awt.Color.yellow; -}return col; -}, "~S"); -c$.initRnaHelicesShading = Clazz.defineMethod (c$, "initRnaHelicesShading", -function (n) { -var j = 0; -if (jalview.schemes.ColourSchemeProperty.rnaHelices == null) { -jalview.schemes.ColourSchemeProperty.rnaHelices = new Array (n + 1); -} else if (jalview.schemes.ColourSchemeProperty.rnaHelices != null && jalview.schemes.ColourSchemeProperty.rnaHelices.length <= n) { -var t = new Array (n + 1); -System.arraycopy (jalview.schemes.ColourSchemeProperty.rnaHelices, 0, t, 0, jalview.schemes.ColourSchemeProperty.rnaHelices.length); -j = jalview.schemes.ColourSchemeProperty.rnaHelices.length; -jalview.schemes.ColourSchemeProperty.rnaHelices = t; -} else { -return; -}for (; j <= n; j++) { -jalview.schemes.ColourSchemeProperty.rnaHelices[j] = jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white); -} -}, "~N"); -Clazz.defineStatics (c$, -"UNDEFINED", -1, -"USER_DEFINED", 0, -"NONE", 1, -"CLUSTAL", 2, -"BLOSUM", 3, -"PID", 4, -"ZAPPO", 5, -"TAYLOR", 6, -"HYDROPHOBIC", 7, -"HELIX", 8, -"STRAND", 9, -"TURN", 10, -"BURIED", 11, -"NUCLEOTIDE", 12, -"PURINEPYRIMIDINE", 13, -"COVARIATION", 14, -"TCOFFEE", 15, -"RNAHELIX", 16, -"RNAINTERACTION", 17, -"FIRST_COLOUR", 1, -"LAST_COLOUR", 17, -"rnaHelices", null); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (null, "jalview.schemes.ColourSchemeProperty", ["jalview.schemes.Blosum62ColourScheme", "$.BuriedColourScheme", "$.ClustalxColourScheme", "$.HelixColourScheme", "$.HydrophobicColourScheme", "$.NucleotideColourScheme", "$.PIDColourScheme", "$.PurinePyrimidineColourScheme", "$.RNAHelicesColour", "$.StrandColourScheme", "$.TCoffeeColourScheme", "$.TaylorColourScheme", "$.TurnColourScheme", "$.UserColourScheme", "$.ZappoColourScheme", "jalview.util.ColorUtils", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "ColourSchemeProperty"); +c$.getColourIndexFromName = Clazz.defineMethod (c$, "getColourIndexFromName", +function (name) { +var ret = -1; +if (name.equalsIgnoreCase ("Clustal")) { +ret = 2; +} else if (name.equalsIgnoreCase ("Blosum62")) { +ret = 3; +} else if (name.equalsIgnoreCase ("% Identity")) { +ret = 4; +} else if (name.equalsIgnoreCase ("Zappo")) { +ret = 5; +} else if (name.equalsIgnoreCase ("Taylor")) { +ret = 6; +} else if (name.equalsIgnoreCase ("Hydrophobic")) { +ret = 7; +} else if (name.equalsIgnoreCase ("Helix Propensity")) { +ret = 8; +} else if (name.equalsIgnoreCase ("Strand Propensity")) { +ret = 9; +} else if (name.equalsIgnoreCase ("Turn Propensity")) { +ret = 10; +} else if (name.equalsIgnoreCase ("Buried Index")) { +ret = 11; +} else if (name.equalsIgnoreCase ("Nucleotide")) { +ret = 12; +} else if (name.equalsIgnoreCase ("T-Coffee Scores")) { +ret = 15; +} else if (name.equalsIgnoreCase ("User Defined")) { +ret = 0; +} else if (name.equalsIgnoreCase ("None")) { +ret = 1; +} else if (name.equalsIgnoreCase ("Purine/Pyrimidine")) { +ret = 13; +} else if (name.equalsIgnoreCase ("RNA Interaction type")) { +ret = 17; +} else if (name.equalsIgnoreCase ("RNA Helices")) { +ret = 16; +}return ret; +}, "~S"); +c$.getColourName = Clazz.defineMethod (c$, "getColourName", +function (cs) { +var index = 1; +if (Clazz.instanceOf (cs, jalview.schemes.ClustalxColourScheme)) { +index = 2; +} else if (Clazz.instanceOf (cs, jalview.schemes.Blosum62ColourScheme)) { +index = 3; +} else if (Clazz.instanceOf (cs, jalview.schemes.PIDColourScheme)) { +index = 4; +} else if (Clazz.instanceOf (cs, jalview.schemes.ZappoColourScheme)) { +index = 5; +} else if (Clazz.instanceOf (cs, jalview.schemes.TaylorColourScheme)) { +index = 6; +} else if (Clazz.instanceOf (cs, jalview.schemes.HydrophobicColourScheme)) { +index = 7; +} else if (Clazz.instanceOf (cs, jalview.schemes.HelixColourScheme)) { +index = 8; +} else if (Clazz.instanceOf (cs, jalview.schemes.StrandColourScheme)) { +index = 9; +} else if (Clazz.instanceOf (cs, jalview.schemes.TurnColourScheme)) { +index = 10; +} else if (Clazz.instanceOf (cs, jalview.schemes.BuriedColourScheme)) { +index = 11; +} else if (Clazz.instanceOf (cs, jalview.schemes.NucleotideColourScheme)) { +index = 12; +} else if (Clazz.instanceOf (cs, jalview.schemes.PurinePyrimidineColourScheme)) { +index = 13; +} else if (Clazz.instanceOf (cs, jalview.schemes.TCoffeeColourScheme)) { +index = 15; +} else if (Clazz.instanceOf (cs, jalview.schemes.RNAHelicesColour)) { +index = 16; +} else if (Clazz.instanceOf (cs, jalview.schemes.UserColourScheme)) { +if (((cs).getName () != null) && ((cs).getName ().length > 0)) { +return (cs).getName (); +}index = 0; +}return jalview.schemes.ColourSchemeProperty.getColourName (index); +}, "jalview.schemes.ColourSchemeI"); +c$.getColourName = Clazz.defineMethod (c$, "getColourName", +function (index) { +var ret = null; +switch (index) { +case 2: +ret = "Clustal"; +break; +case 3: +ret = "Blosum62"; +break; +case 4: +ret = "% Identity"; +break; +case 5: +ret = "Zappo"; +break; +case 6: +ret = "Taylor"; +break; +case 7: +ret = "Hydrophobic"; +break; +case 8: +ret = "Helix Propensity"; +break; +case 9: +ret = "Strand Propensity"; +break; +case 10: +ret = "Turn Propensity"; +break; +case 11: +ret = "Buried Index"; +break; +case 12: +ret = "Nucleotide"; +break; +case 13: +ret = "Purine/Pyrimidine"; +break; +case 15: +ret = "T-Coffee Scores"; +break; +case 17: +ret = "RNA Interaction type"; +break; +case 16: +ret = "RNA Helices"; +break; +case 0: +ret = "User Defined"; +break; +default: +ret = "None"; +break; +} +return ret; +}, "~N"); +c$.getColour = Clazz.defineMethod (c$, "getColour", +function (alignment, name) { +var colindex = jalview.schemes.ColourSchemeProperty.getColourIndexFromName (name); +if (colindex == -1) { +if (name.indexOf ('=') == -1) { +try { +return new jalview.schemes.UserColourScheme (name); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +} else { +try { +var ucs = new jalview.schemes.UserColourScheme ("white"); +ucs.parseAppletParameter (name); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +}}return jalview.schemes.ColourSchemeProperty.getColour (alignment, jalview.schemes.ColourSchemeProperty.getColourIndexFromName (name)); +}, "jalview.datamodel.AnnotatedCollectionI,~S"); +c$.getColour = Clazz.defineMethod (c$, "getColour", +function (coll, index) { +var cs = null; +switch (index) { +case 2: +cs = new jalview.schemes.ClustalxColourScheme (coll, null); +break; +case 3: +cs = new jalview.schemes.Blosum62ColourScheme (); +break; +case 4: +cs = new jalview.schemes.PIDColourScheme (); +break; +case 5: +cs = new jalview.schemes.ZappoColourScheme (); +break; +case 6: +cs = new jalview.schemes.TaylorColourScheme (); +break; +case 7: +cs = new jalview.schemes.HydrophobicColourScheme (); +break; +case 8: +cs = new jalview.schemes.HelixColourScheme (); +break; +case 9: +cs = new jalview.schemes.StrandColourScheme (); +break; +case 10: +cs = new jalview.schemes.TurnColourScheme (); +break; +case 11: +cs = new jalview.schemes.BuriedColourScheme (); +break; +case 12: +cs = new jalview.schemes.NucleotideColourScheme (); +break; +case 13: +cs = new jalview.schemes.PurinePyrimidineColourScheme (); +break; +case 15: +cs = new jalview.schemes.TCoffeeColourScheme (coll); +break; +case 16: +cs = new jalview.schemes.RNAHelicesColour (coll); +break; +case 0: +var col = new Array (24); +for (var i = 0; i < 24; i++) { +col[i] = java.awt.Color.white; +} +cs = new jalview.schemes.UserColourScheme (col); +break; +default: +break; +} +return cs; +}, "jalview.datamodel.AnnotatedCollectionI,~N"); +c$.getAWTColorFromName = Clazz.defineMethod (c$, "getAWTColorFromName", +function (name) { +var col = null; +name = name.toLowerCase (); +if (name.equals ("black")) { +col = java.awt.Color.black; +} else if (name.equals ("blue")) { +col = java.awt.Color.blue; +} else if (name.equals ("cyan")) { +col = java.awt.Color.cyan; +} else if (name.equals ("darkGray")) { +col = java.awt.Color.darkGray; +} else if (name.equals ("gray")) { +col = java.awt.Color.gray; +} else if (name.equals ("green")) { +col = java.awt.Color.green; +} else if (name.equals ("lightGray")) { +col = java.awt.Color.lightGray; +} else if (name.equals ("magenta")) { +col = java.awt.Color.magenta; +} else if (name.equals ("orange")) { +col = java.awt.Color.orange; +} else if (name.equals ("pink")) { +col = java.awt.Color.pink; +} else if (name.equals ("red")) { +col = java.awt.Color.red; +} else if (name.equals ("white")) { +col = java.awt.Color.white; +} else if (name.equals ("yellow")) { +col = java.awt.Color.yellow; +}return col; +}, "~S"); +c$.initRnaHelicesShading = Clazz.defineMethod (c$, "initRnaHelicesShading", +function (n) { +var j = 0; +if (jalview.schemes.ColourSchemeProperty.rnaHelices == null) { +jalview.schemes.ColourSchemeProperty.rnaHelices = new Array (n + 1); +} else if (jalview.schemes.ColourSchemeProperty.rnaHelices != null && jalview.schemes.ColourSchemeProperty.rnaHelices.length <= n) { +var t = new Array (n + 1); +System.arraycopy (jalview.schemes.ColourSchemeProperty.rnaHelices, 0, t, 0, jalview.schemes.ColourSchemeProperty.rnaHelices.length); +j = jalview.schemes.ColourSchemeProperty.rnaHelices.length; +jalview.schemes.ColourSchemeProperty.rnaHelices = t; +} else { +return; +}for (; j <= n; j++) { +jalview.schemes.ColourSchemeProperty.rnaHelices[j] = jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white); +} +}, "~N"); +Clazz.defineStatics (c$, +"UNDEFINED", -1, +"USER_DEFINED", 0, +"NONE", 1, +"CLUSTAL", 2, +"BLOSUM", 3, +"PID", 4, +"ZAPPO", 5, +"TAYLOR", 6, +"HYDROPHOBIC", 7, +"HELIX", 8, +"STRAND", 9, +"TURN", 10, +"BURIED", 11, +"NUCLEOTIDE", 12, +"PURINEPYRIMIDINE", 13, +"COVARIATION", 14, +"TCOFFEE", 15, +"RNAHELIX", 16, +"RNAINTERACTION", 17, +"FIRST_COLOUR", 1, +"LAST_COLOUR", 17, +"rnaHelices", null); +}); diff --git a/bin/jalview/schemes/Consensus.js b/bin/jalview/schemes/Consensus.js index 45c3c6a..39d8ac9 100644 --- a/bin/jalview/schemes/Consensus.js +++ b/bin/jalview/schemes/Consensus.js @@ -1,45 +1,45 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (null, "jalview.schemes.Consensus", ["jalview.schemes.ResidueProperties"], function () { -c$ = Clazz.decorateAsClass (function () { -this.mask = null; -this.threshold = 0; -this.maskstr = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "Consensus"); -Clazz.makeConstructor (c$, -function (mask, threshold) { -this.maskstr = mask; -this.setMask (mask); -this.threshold = threshold; -}, "~S,~N"); -Clazz.defineMethod (c$, "setMask", -function (s) { -this.mask = this.setNums (s); -}, "~S"); -Clazz.defineMethod (c$, "isConserved", -function (cons2, col, size) { -return this.isConserved (cons2, col, size, true); -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "isConserved", -function (cons2, col, size, includeGaps) { -var tot = 0; -if (!includeGaps) { -size -= cons2[col][cons2[col].length - 1]; -}for (var i = 0; i < this.mask.length; i++) { -tot += cons2[col][this.mask[i]]; -} -if (tot > ((this.threshold * size) / 100)) { -return true; -}return false; -}, "~A,~N,~N,~B"); -Clazz.defineMethod (c$, "setNums", -function (s) { -var out = Clazz.newIntArray (s.length, 0); -var i = 0; -while (i < s.length) { -out[i] = jalview.schemes.ResidueProperties.aaIndex[s.charCodeAt (i)]; -i++; -} -return out; -}, "~S"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (null, "jalview.schemes.Consensus", ["jalview.schemes.ResidueProperties"], function () { +c$ = Clazz.decorateAsClass (function () { +this.mask = null; +this.threshold = 0; +this.maskstr = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "Consensus"); +Clazz.makeConstructor (c$, +function (mask, threshold) { +this.maskstr = mask; +this.setMask (mask); +this.threshold = threshold; +}, "~S,~N"); +Clazz.defineMethod (c$, "setMask", +function (s) { +this.mask = this.setNums (s); +}, "~S"); +Clazz.defineMethod (c$, "isConserved", +function (cons2, col, size) { +return this.isConserved (cons2, col, size, true); +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "isConserved", +function (cons2, col, size, includeGaps) { +var tot = 0; +if (!includeGaps) { +size -= cons2[col][cons2[col].length - 1]; +}for (var i = 0; i < this.mask.length; i++) { +tot += cons2[col][this.mask[i]]; +} +if (tot > ((this.threshold * size) / 100)) { +return true; +}return false; +}, "~A,~N,~N,~B"); +Clazz.defineMethod (c$, "setNums", +function (s) { +var out = Clazz.newIntArray (s.length, 0); +var i = 0; +while (i < s.length) { +out[i] = jalview.schemes.ResidueProperties.aaIndex[s.charCodeAt (i)]; +i++; +} +return out; +}, "~S"); +}); diff --git a/bin/jalview/schemes/CovariationColourScheme.js b/bin/jalview/schemes/CovariationColourScheme.js index 68c8f15..3d75e42 100644 --- a/bin/jalview/schemes/CovariationColourScheme.js +++ b/bin/jalview/schemes/CovariationColourScheme.js @@ -1,41 +1,41 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.Hashtable"], "jalview.schemes.CovariationColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.ColorUtils", "java.awt.Color"], function () { -c$ = Clazz.decorateAsClass (function () { -this.helixcolorhash = null; -this.positionsToHelix = null; -this.numHelix = 0; -this.annotation = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "CovariationColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.prepareFields (c$, function () { -this.helixcolorhash = new java.util.Hashtable (); -this.positionsToHelix = new java.util.Hashtable (); -}); -Clazz.makeConstructor (c$, -function (annotation) { -Clazz.superConstructor (this, jalview.schemes.CovariationColourScheme, []); -this.annotation = annotation; -for (var x = 0; x < this.annotation._rnasecstr.length; x++) { -this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getBegin ()), this.annotation._rnasecstr[x].getFeatureGroup ()); -this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getEnd ()), this.annotation._rnasecstr[x].getFeatureGroup ()); -if (Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()) > this.numHelix) { -this.numHelix = Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()); -}} -for (var j = 0; j <= this.numHelix; j++) { -this.helixcolorhash.put (Integer.toString (j), jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white)); -} -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "findColour", -function (c) { -return jalview.schemes.ResidueProperties.purinepyrimidine[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j) { -var currentColour = java.awt.Color.white; -var currentHelix = null; -currentHelix = this.positionsToHelix.get (new Integer (j)); -if (currentHelix != null) { -currentColour = this.helixcolorhash.get (currentHelix); -}return currentColour; -}, "~S,~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.Hashtable"], "jalview.schemes.CovariationColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.ColorUtils", "java.awt.Color"], function () { +c$ = Clazz.decorateAsClass (function () { +this.helixcolorhash = null; +this.positionsToHelix = null; +this.numHelix = 0; +this.annotation = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "CovariationColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.prepareFields (c$, function () { +this.helixcolorhash = new java.util.Hashtable (); +this.positionsToHelix = new java.util.Hashtable (); +}); +Clazz.makeConstructor (c$, +function (annotation) { +Clazz.superConstructor (this, jalview.schemes.CovariationColourScheme, []); +this.annotation = annotation; +for (var x = 0; x < this.annotation._rnasecstr.length; x++) { +this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getBegin ()), this.annotation._rnasecstr[x].getFeatureGroup ()); +this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getEnd ()), this.annotation._rnasecstr[x].getFeatureGroup ()); +if (Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()) > this.numHelix) { +this.numHelix = Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()); +}} +for (var j = 0; j <= this.numHelix; j++) { +this.helixcolorhash.put (Integer.toString (j), jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white)); +} +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "findColour", +function (c) { +return jalview.schemes.ResidueProperties.purinepyrimidine[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j) { +var currentColour = java.awt.Color.white; +var currentHelix = null; +currentHelix = this.positionsToHelix.get (new Integer (j)); +if (currentHelix != null) { +currentColour = this.helixcolorhash.get (currentHelix); +}return currentColour; +}, "~S,~N"); +}); diff --git a/bin/jalview/schemes/FollowerColourScheme.js b/bin/jalview/schemes/FollowerColourScheme.js index e71f907..e73b3d9 100644 --- a/bin/jalview/schemes/FollowerColourScheme.js +++ b/bin/jalview/schemes/FollowerColourScheme.js @@ -1,26 +1,26 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.FollowerColourScheme", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.colourScheme = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "FollowerColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.defineMethod (c$, "getBaseColour", -function () { -return this.colourScheme; -}); -Clazz.overrideMethod (c$, "setConsensus", -function (consensus) { -if (this.colourScheme != null) { -this.colourScheme.setConsensus (consensus); -}}, "~A"); -Clazz.overrideMethod (c$, "setConservation", -function (cons) { -if (this.colourScheme != null) { -this.colourScheme.setConservation (cons); -}}, "jalview.analysis.Conservation"); -Clazz.overrideMethod (c$, "setConservationInc", -function (i) { -if (this.colourScheme != null) { -this.colourScheme.setConservationInc (i); -}}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.FollowerColourScheme", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.colourScheme = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "FollowerColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.defineMethod (c$, "getBaseColour", +function () { +return this.colourScheme; +}); +Clazz.overrideMethod (c$, "setConsensus", +function (consensus) { +if (this.colourScheme != null) { +this.colourScheme.setConsensus (consensus); +}}, "~A"); +Clazz.overrideMethod (c$, "setConservation", +function (cons) { +if (this.colourScheme != null) { +this.colourScheme.setConservation (cons); +}}, "jalview.analysis.Conservation"); +Clazz.overrideMethod (c$, "setConservationInc", +function (i) { +if (this.colourScheme != null) { +this.colourScheme.setConservationInc (i); +}}, "~N"); +}); diff --git a/bin/jalview/schemes/GraduatedColor.js b/bin/jalview/schemes/GraduatedColor.js index e9998a1..5daa0fb 100644 --- a/bin/jalview/schemes/GraduatedColor.js +++ b/bin/jalview/schemes/GraduatedColor.js @@ -1,160 +1,160 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (null, "jalview.schemes.GraduatedColor", ["jalview.schemes.UserColourScheme", "java.awt.Color", "java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.thresholdState = -1; -this.lr = 0; -this.lg = 0; -this.lb = 0; -this.dr = 0; -this.dg = 0; -this.db = 0; -this.base = 0; -this.range = 0; -this.thrsh = 0; -this.tolow = false; -this.autoScale = true; -this.ucs = null; -this.colourByLabel = false; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "GraduatedColor"); -Clazz.makeConstructor (c$, -function (low, high, min, max) { -this.thrsh = NaN; -this.tolow = min >= max; -this.lr = low.getRed () / 255; -this.lg = low.getGreen () / 255; -this.lb = low.getBlue () / 255; -this.dr = (high.getRed () / 255) - this.lr; -this.dg = (high.getGreen () / 255) - this.lg; -this.db = (high.getBlue () / 255) - this.lb; -if (this.tolow) { -this.base = max; -this.range = min - max; -} else { -this.base = min; -this.range = max - min; -}}, "java.awt.Color,java.awt.Color,~N,~N"); -Clazz.makeConstructor (c$, -function (oldcs) { -this.lr = oldcs.lr; -this.lg = oldcs.lg; -this.lb = oldcs.lb; -this.dr = oldcs.dr; -this.dg = oldcs.dg; -this.db = oldcs.db; -this.base = oldcs.base; -this.range = oldcs.range; -this.tolow = oldcs.tolow; -this.thresholdState = oldcs.thresholdState; -this.thrsh = oldcs.thrsh; -this.autoScale = oldcs.autoScale; -this.colourByLabel = oldcs.colourByLabel; -}, "jalview.schemes.GraduatedColor"); -Clazz.makeConstructor (c$, -function (oldcs, min, max) { -this.construct (oldcs); -this.updateBounds (min, max); -}, "jalview.schemes.GraduatedColor,~N,~N"); -Clazz.defineMethod (c$, "getMinColor", -function () { -return new java.awt.Color (this.lr, this.lg, this.lb); -}); -Clazz.defineMethod (c$, "getMaxColor", -function () { -return new java.awt.Color (this.lr + this.dr, this.lg + this.dg, this.lb + this.db); -}); -Clazz.defineMethod (c$, "getTolow", -function () { -return this.tolow; -}); -Clazz.defineMethod (c$, "setTolow", -function (tolower) { -this.tolow = tolower; -}, "~B"); -Clazz.defineMethod (c$, "isColored", -function (feature) { -var val = feature.getScore (); -if (Float.isNaN (val)) { -return true; -}if (this.thresholdState == -1) { -return true; -}if (Float.isNaN (this.thrsh)) { -return true; -}var rtn = this.thresholdState == 1; -if (val <= this.thrsh) { -return !rtn; -} else { -return rtn; -}}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "isColourByLabel", -function () { -return this.colourByLabel; -}); -Clazz.defineMethod (c$, "setColourByLabel", -function (colourByLabel) { -this.colourByLabel = colourByLabel; -}, "~B"); -Clazz.defineMethod (c$, "findColor", -function (feature) { -if (this.colourByLabel) { -if (this.ucs == null) { -this.ucs = new jalview.schemes.UserColourScheme (); -}return this.ucs.createColourFromName (feature.getDescription ()); -}if (this.range == 0.0) { -return this.getMaxColor (); -}var scr = feature.getScore (); -if (Float.isNaN (scr)) { -return this.getMinColor (); -}var scl = (scr - this.base) / this.range; -if (this.tolow) { -scl = -scl; -}if (scl < 0) { -scl = 0; -}if (scl > 1) { -scl = 1; -}return new java.awt.Color (this.lr + scl * this.dr, this.lg + scl * this.dg, this.lb + scl * this.db); -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "setThresh", -function (value) { -this.thrsh = value; -}, "~N"); -Clazz.defineMethod (c$, "getThresh", -function () { -return this.thrsh; -}); -Clazz.defineMethod (c$, "setThreshType", -function (aboveThreshold) { -this.thresholdState = aboveThreshold; -}, "~N"); -Clazz.defineMethod (c$, "getThreshType", -function () { -return this.thresholdState; -}); -Clazz.defineMethod (c$, "getMax", -function () { -return (this.tolow) ? this.base : (this.base + this.range); -}); -Clazz.defineMethod (c$, "getMin", -function () { -return (this.tolow) ? (this.base + this.range) : this.base; -}); -Clazz.defineMethod (c$, "isAutoScale", -function () { -return this.autoScale; -}); -Clazz.defineMethod (c$, "setAutoScaled", -function (autoscale) { -this.autoScale = autoscale; -}, "~B"); -Clazz.defineMethod (c$, "updateBounds", -function (min, max) { -if (max < min) { -this.base = max; -this.range = min - max; -this.tolow = true; -} else { -this.base = min; -this.range = max - min; -this.tolow = false; -}}, "~N,~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (null, "jalview.schemes.GraduatedColor", ["jalview.schemes.UserColourScheme", "java.awt.Color", "java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.thresholdState = -1; +this.lr = 0; +this.lg = 0; +this.lb = 0; +this.dr = 0; +this.dg = 0; +this.db = 0; +this.base = 0; +this.range = 0; +this.thrsh = 0; +this.tolow = false; +this.autoScale = true; +this.ucs = null; +this.colourByLabel = false; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "GraduatedColor"); +Clazz.makeConstructor (c$, +function (low, high, min, max) { +this.thrsh = NaN; +this.tolow = min >= max; +this.lr = low.getRed () / 255; +this.lg = low.getGreen () / 255; +this.lb = low.getBlue () / 255; +this.dr = (high.getRed () / 255) - this.lr; +this.dg = (high.getGreen () / 255) - this.lg; +this.db = (high.getBlue () / 255) - this.lb; +if (this.tolow) { +this.base = max; +this.range = min - max; +} else { +this.base = min; +this.range = max - min; +}}, "java.awt.Color,java.awt.Color,~N,~N"); +Clazz.makeConstructor (c$, +function (oldcs) { +this.lr = oldcs.lr; +this.lg = oldcs.lg; +this.lb = oldcs.lb; +this.dr = oldcs.dr; +this.dg = oldcs.dg; +this.db = oldcs.db; +this.base = oldcs.base; +this.range = oldcs.range; +this.tolow = oldcs.tolow; +this.thresholdState = oldcs.thresholdState; +this.thrsh = oldcs.thrsh; +this.autoScale = oldcs.autoScale; +this.colourByLabel = oldcs.colourByLabel; +}, "jalview.schemes.GraduatedColor"); +Clazz.makeConstructor (c$, +function (oldcs, min, max) { +this.construct (oldcs); +this.updateBounds (min, max); +}, "jalview.schemes.GraduatedColor,~N,~N"); +Clazz.defineMethod (c$, "getMinColor", +function () { +return new java.awt.Color (this.lr, this.lg, this.lb); +}); +Clazz.defineMethod (c$, "getMaxColor", +function () { +return new java.awt.Color (this.lr + this.dr, this.lg + this.dg, this.lb + this.db); +}); +Clazz.defineMethod (c$, "getTolow", +function () { +return this.tolow; +}); +Clazz.defineMethod (c$, "setTolow", +function (tolower) { +this.tolow = tolower; +}, "~B"); +Clazz.defineMethod (c$, "isColored", +function (feature) { +var val = feature.getScore (); +if (Float.isNaN (val)) { +return true; +}if (this.thresholdState == -1) { +return true; +}if (Float.isNaN (this.thrsh)) { +return true; +}var rtn = this.thresholdState == 1; +if (val <= this.thrsh) { +return !rtn; +} else { +return rtn; +}}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "isColourByLabel", +function () { +return this.colourByLabel; +}); +Clazz.defineMethod (c$, "setColourByLabel", +function (colourByLabel) { +this.colourByLabel = colourByLabel; +}, "~B"); +Clazz.defineMethod (c$, "findColor", +function (feature) { +if (this.colourByLabel) { +if (this.ucs == null) { +this.ucs = new jalview.schemes.UserColourScheme (); +}return this.ucs.createColourFromName (feature.getDescription ()); +}if (this.range == 0.0) { +return this.getMaxColor (); +}var scr = feature.getScore (); +if (Float.isNaN (scr)) { +return this.getMinColor (); +}var scl = (scr - this.base) / this.range; +if (this.tolow) { +scl = -scl; +}if (scl < 0) { +scl = 0; +}if (scl > 1) { +scl = 1; +}return new java.awt.Color (this.lr + scl * this.dr, this.lg + scl * this.dg, this.lb + scl * this.db); +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "setThresh", +function (value) { +this.thrsh = value; +}, "~N"); +Clazz.defineMethod (c$, "getThresh", +function () { +return this.thrsh; +}); +Clazz.defineMethod (c$, "setThreshType", +function (aboveThreshold) { +this.thresholdState = aboveThreshold; +}, "~N"); +Clazz.defineMethod (c$, "getThreshType", +function () { +return this.thresholdState; +}); +Clazz.defineMethod (c$, "getMax", +function () { +return (this.tolow) ? this.base : (this.base + this.range); +}); +Clazz.defineMethod (c$, "getMin", +function () { +return (this.tolow) ? (this.base + this.range) : this.base; +}); +Clazz.defineMethod (c$, "isAutoScale", +function () { +return this.autoScale; +}); +Clazz.defineMethod (c$, "setAutoScaled", +function (autoscale) { +this.autoScale = autoscale; +}, "~B"); +Clazz.defineMethod (c$, "updateBounds", +function (min, max) { +if (max < min) { +this.base = max; +this.range = min - max; +this.tolow = true; +} else { +this.base = min; +this.range = max - min; +this.tolow = false; +}}, "~N,~N"); +}); diff --git a/bin/jalview/schemes/HelixColourScheme.js b/bin/jalview/schemes/HelixColourScheme.js index 64e88e9..4768a33 100644 --- a/bin/jalview/schemes/HelixColourScheme.js +++ b/bin/jalview/schemes/HelixColourScheme.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.HelixColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "HelixColourScheme", jalview.schemes.ScoreColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.HelixColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.helix, 0.57, 1.51]); -}); -Clazz.overrideMethod (c$, "makeColour", -function (c) { -return new java.awt.Color (c, 1.0 - c, c); -}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.HelixColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "HelixColourScheme", jalview.schemes.ScoreColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.HelixColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.helix, 0.57, 1.51]); +}); +Clazz.overrideMethod (c$, "makeColour", +function (c) { +return new java.awt.Color (c, 1.0 - c, c); +}, "~N"); +}); diff --git a/bin/jalview/schemes/HydrophobicColourScheme.js b/bin/jalview/schemes/HydrophobicColourScheme.js index 224f202..02e1bbd 100644 --- a/bin/jalview/schemes/HydrophobicColourScheme.js +++ b/bin/jalview/schemes/HydrophobicColourScheme.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.HydrophobicColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "HydrophobicColourScheme", jalview.schemes.ScoreColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.HydrophobicColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.hyd, -3.9, 4.5]); -}); -Clazz.overrideMethod (c$, "makeColour", -function (c) { -return new java.awt.Color (c, 0.0, 1.0 - c); -}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.HydrophobicColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "HydrophobicColourScheme", jalview.schemes.ScoreColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.HydrophobicColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.hyd, -3.9, 4.5]); +}); +Clazz.overrideMethod (c$, "makeColour", +function (c) { +return new java.awt.Color (c, 0.0, 1.0 - c); +}, "~N"); +}); diff --git a/bin/jalview/schemes/NucleotideColourScheme.js b/bin/jalview/schemes/NucleotideColourScheme.js index abdfb5e..1345bc6 100644 --- a/bin/jalview/schemes/NucleotideColourScheme.js +++ b/bin/jalview/schemes/NucleotideColourScheme.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.NucleotideColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "NucleotideColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.NucleotideColourScheme, [jalview.schemes.ResidueProperties.nucleotideIndex, jalview.schemes.ResidueProperties.nucleotide, 0]); -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour; -if ((this.threshold == 0) || this.aboveThreshold (c, j)) { -try { -currentColour = this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -return java.awt.Color.white; -} else { -throw ex; -} -} -} else { -return java.awt.Color.white; -}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.NucleotideColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "NucleotideColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.NucleotideColourScheme, [jalview.schemes.ResidueProperties.nucleotideIndex, jalview.schemes.ResidueProperties.nucleotide, 0]); +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour; +if ((this.threshold == 0) || this.aboveThreshold (c, j)) { +try { +currentColour = this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +return java.awt.Color.white; +} else { +throw ex; +} +} +} else { +return java.awt.Color.white; +}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/schemes/PIDColourScheme.js b/bin/jalview/schemes/PIDColourScheme.js index bdf6f24..093328c 100644 --- a/bin/jalview/schemes/PIDColourScheme.js +++ b/bin/jalview/schemes/PIDColourScheme.js @@ -1,39 +1,39 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.PIDColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () { -c$ = Clazz.decorateAsClass (function () { -this.pidColours = null; -this.thresholds = null; -this.group = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "PIDColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.PIDColourScheme, []); -this.pidColours = jalview.schemes.ResidueProperties.pidColours; -this.thresholds = jalview.schemes.ResidueProperties.pidThresholds; -}); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -if ('a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - (32)); -}if (this.consensus == null || j >= this.consensus.length || this.consensus[j] == null) { -return java.awt.Color.white; -}if ((this.threshold != 0) && !this.aboveThreshold (c, j)) { -return java.awt.Color.white; -}var currentColour = java.awt.Color.white; -var sc = 0; -if (this.consensus.length <= j) { -return java.awt.Color.white; -}if ((Integer.parseInt (this.consensus[j].get ("C").toString ()) != -1) && this.consensus[j].contains (String.valueOf (c))) { -sc = (this.consensus[j].get (this.ignoreGaps)).floatValue (); -if (!jalview.util.Comparison.isGap (c)) { -for (var i = 0; i < this.thresholds.length; i++) { -if (sc > this.thresholds[i]) { -currentColour = this.pidColours[i]; -break; -}} -}}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.PIDColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () { +c$ = Clazz.decorateAsClass (function () { +this.pidColours = null; +this.thresholds = null; +this.group = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "PIDColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.PIDColourScheme, []); +this.pidColours = jalview.schemes.ResidueProperties.pidColours; +this.thresholds = jalview.schemes.ResidueProperties.pidThresholds; +}); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +if ('a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - (32)); +}if (this.consensus == null || j >= this.consensus.length || this.consensus[j] == null) { +return java.awt.Color.white; +}if ((this.threshold != 0) && !this.aboveThreshold (c, j)) { +return java.awt.Color.white; +}var currentColour = java.awt.Color.white; +var sc = 0; +if (this.consensus.length <= j) { +return java.awt.Color.white; +}if ((Integer.parseInt (this.consensus[j].get ("C").toString ()) != -1) && this.consensus[j].contains (String.valueOf (c))) { +sc = (this.consensus[j].get (this.ignoreGaps)).floatValue (); +if (!jalview.util.Comparison.isGap (c)) { +for (var i = 0; i < this.thresholds.length; i++) { +if (sc > this.thresholds[i]) { +currentColour = this.pidColours[i]; +break; +}} +}}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/schemes/PurinePyrimidineColourScheme.js b/bin/jalview/schemes/PurinePyrimidineColourScheme.js index 514d31b..be4e523 100644 --- a/bin/jalview/schemes/PurinePyrimidineColourScheme.js +++ b/bin/jalview/schemes/PurinePyrimidineColourScheme.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.PurinePyrimidineColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "PurinePyrimidineColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.PurinePyrimidineColourScheme, [jalview.schemes.ResidueProperties.purinepyrimidineIndex, jalview.schemes.ResidueProperties.purinepyrimidine, 0]); -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return this.colors[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j) { -var currentColour; -if ((this.threshold == 0) || this.aboveThreshold (c, j)) { -try { -currentColour = this.colors[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -return java.awt.Color.white; -} else { -throw ex; -} -} -} else { -return java.awt.Color.white; -}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.PurinePyrimidineColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "PurinePyrimidineColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.PurinePyrimidineColourScheme, [jalview.schemes.ResidueProperties.purinepyrimidineIndex, jalview.schemes.ResidueProperties.purinepyrimidine, 0]); +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return this.colors[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j) { +var currentColour; +if ((this.threshold == 0) || this.aboveThreshold (c, j)) { +try { +currentColour = this.colors[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +return java.awt.Color.white; +} else { +throw ex; +} +} +} else { +return java.awt.Color.white; +}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N"); +}); diff --git a/bin/jalview/schemes/RNAHelicesColour.js b/bin/jalview/schemes/RNAHelicesColour.js index c7d3af2..5023c90 100644 --- a/bin/jalview/schemes/RNAHelicesColour.js +++ b/bin/jalview/schemes/RNAHelicesColour.js @@ -1,68 +1,68 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.Hashtable"], "jalview.schemes.RNAHelicesColour", ["jalview.schemes.ResidueProperties", "jalview.util.ColorUtils", "java.awt.Color"], function () { -c$ = Clazz.decorateAsClass (function () { -this.helixcolorhash = null; -this.positionsToHelix = null; -this.numHelix = 0; -this.annotation = null; -this.lastrefresh = -1; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "RNAHelicesColour", jalview.schemes.ResidueColourScheme); -Clazz.prepareFields (c$, function () { -this.helixcolorhash = new java.util.Hashtable (); -this.positionsToHelix = new java.util.Hashtable (); -}); -Clazz.makeConstructor (c$, -function (annotation) { -Clazz.superConstructor (this, jalview.schemes.RNAHelicesColour, [jalview.schemes.ResidueProperties.nucleotideIndex]); -this.annotation = annotation; -this.refresh (); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.makeConstructor (c$, -function (alignment) { -Clazz.superConstructor (this, jalview.schemes.RNAHelicesColour, [jalview.schemes.ResidueProperties.nucleotideIndex]); -this.alignmentChanged (alignment, null); -}, "jalview.datamodel.AnnotatedCollectionI"); -Clazz.overrideMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -var annotations = alignment.getAlignmentAnnotation (); -for (var i = 0; i < annotations.length; i++) { -if (annotations[i].getRNAStruc () != null) { -this.annotation = annotations[i]; -break; -}} -this.refresh (); -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.defineMethod (c$, "refresh", -function () { -if (this.annotation != null && ((this.annotation._rnasecstr == null || this.lastrefresh != this.annotation._rnasecstr.hashCode ()) && this.annotation.isValidStruc ())) { -this.annotation.getRNAStruc (); -this.lastrefresh = this.annotation._rnasecstr.hashCode (); -this.numHelix = 0; -this.positionsToHelix = new java.util.Hashtable (); -for (var x = 0; x < this.annotation._rnasecstr.length; x++) { -this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getBegin ()), this.annotation._rnasecstr[x].getFeatureGroup ()); -this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getEnd ()), this.annotation._rnasecstr[x].getFeatureGroup ()); -if (Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()) > this.numHelix) { -this.numHelix = Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()); -}} -for (var j = 0; j <= this.numHelix; j++) { -if (!this.helixcolorhash.containsKey (Integer.toString (j))) { -this.helixcolorhash.put (Integer.toString (j), jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white)); -}} -}}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return jalview.schemes.ResidueProperties.purinepyrimidine[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -this.refresh (); -var currentColour = java.awt.Color.white; -var currentHelix = null; -currentHelix = this.positionsToHelix.get (new Integer (j)); -if (currentHelix != null) { -currentColour = this.helixcolorhash.get (currentHelix); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.Hashtable"], "jalview.schemes.RNAHelicesColour", ["jalview.schemes.ResidueProperties", "jalview.util.ColorUtils", "java.awt.Color"], function () { +c$ = Clazz.decorateAsClass (function () { +this.helixcolorhash = null; +this.positionsToHelix = null; +this.numHelix = 0; +this.annotation = null; +this.lastrefresh = -1; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "RNAHelicesColour", jalview.schemes.ResidueColourScheme); +Clazz.prepareFields (c$, function () { +this.helixcolorhash = new java.util.Hashtable (); +this.positionsToHelix = new java.util.Hashtable (); +}); +Clazz.makeConstructor (c$, +function (annotation) { +Clazz.superConstructor (this, jalview.schemes.RNAHelicesColour, [jalview.schemes.ResidueProperties.nucleotideIndex]); +this.annotation = annotation; +this.refresh (); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.makeConstructor (c$, +function (alignment) { +Clazz.superConstructor (this, jalview.schemes.RNAHelicesColour, [jalview.schemes.ResidueProperties.nucleotideIndex]); +this.alignmentChanged (alignment, null); +}, "jalview.datamodel.AnnotatedCollectionI"); +Clazz.overrideMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +var annotations = alignment.getAlignmentAnnotation (); +for (var i = 0; i < annotations.length; i++) { +if (annotations[i].getRNAStruc () != null) { +this.annotation = annotations[i]; +break; +}} +this.refresh (); +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.defineMethod (c$, "refresh", +function () { +if (this.annotation != null && ((this.annotation._rnasecstr == null || this.lastrefresh != this.annotation._rnasecstr.hashCode ()) && this.annotation.isValidStruc ())) { +this.annotation.getRNAStruc (); +this.lastrefresh = this.annotation._rnasecstr.hashCode (); +this.numHelix = 0; +this.positionsToHelix = new java.util.Hashtable (); +for (var x = 0; x < this.annotation._rnasecstr.length; x++) { +this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getBegin ()), this.annotation._rnasecstr[x].getFeatureGroup ()); +this.positionsToHelix.put (new Integer (this.annotation._rnasecstr[x].getEnd ()), this.annotation._rnasecstr[x].getFeatureGroup ()); +if (Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()) > this.numHelix) { +this.numHelix = Integer.parseInt (this.annotation._rnasecstr[x].getFeatureGroup ()); +}} +for (var j = 0; j <= this.numHelix; j++) { +if (!this.helixcolorhash.containsKey (Integer.toString (j))) { +this.helixcolorhash.put (Integer.toString (j), jalview.util.ColorUtils.generateRandomColor (java.awt.Color.white)); +}} +}}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return jalview.schemes.ResidueProperties.purinepyrimidine[jalview.schemes.ResidueProperties.purinepyrimidineIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +this.refresh (); +var currentColour = java.awt.Color.white; +var currentHelix = null; +currentHelix = this.positionsToHelix.get (new Integer (j)); +if (currentHelix != null) { +currentColour = this.helixcolorhash.get (currentHelix); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/schemes/RNAHelicesColourChooser.js b/bin/jalview/schemes/RNAHelicesColourChooser.js index 0d9cf26..27a0f25 100644 --- a/bin/jalview/schemes/RNAHelicesColourChooser.js +++ b/bin/jalview/schemes/RNAHelicesColourChooser.js @@ -1,63 +1,63 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (null, "jalview.schemes.RNAHelicesColourChooser", ["jalview.schemes.RNAHelicesColour", "java.util.Hashtable", "$.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.ap = null; -this.oldcs = null; -this.oldgroupColours = null; -this.currentAnnotation = null; -this.adjusting = false; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "RNAHelicesColourChooser"); -Clazz.makeConstructor (c$, -function (av, ap) { -this.oldcs = av.getGlobalColourScheme (); -if (av.getAlignment ().getGroups () != null) { -this.oldgroupColours = new java.util.Hashtable (); -for (var sg, $sg = ap.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs != null) { -this.oldgroupColours.put (sg, sg.cs); -}} -}this.av = av; -this.ap = ap; -if (Clazz.instanceOf (this.oldcs, jalview.schemes.RNAHelicesColour)) { -var rhc = this.oldcs; -}this.adjusting = true; -var list = new java.util.Vector (); -var index = 1; -for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { -var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; -if (!list.contains (label)) list.addElement (label); - else list.addElement (label + "_" + (index++)); -} -this.adjusting = false; -this.changeColour (); -}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "changeColour", -function () { -if (this.adjusting) { -return; -}var rhc = null; -rhc = new jalview.schemes.RNAHelicesColour (this.av.getAlignment ()); -this.av.setGlobalColourScheme (rhc); -if (this.av.getAlignment ().getGroups () != null) { -for (var sg, $sg = this.ap.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs == null) { -continue; -}sg.cs = new jalview.schemes.RNAHelicesColour (sg); -} -}this.ap.paintAlignment (false); -}); -Clazz.defineMethod (c$, "reset", -function () { -this.av.setGlobalColourScheme (this.oldcs); -if (this.av.getAlignment ().getGroups () != null) { -for (var sg, $sg = this.ap.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -sg.cs = this.oldgroupColours.get (sg); -} -}}); -Clazz.defineMethod (c$, "annotations_actionPerformed", -function (e) { -this.changeColour (); -}, "java.awt.event.ActionEvent"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (null, "jalview.schemes.RNAHelicesColourChooser", ["jalview.schemes.RNAHelicesColour", "java.util.Hashtable", "$.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.ap = null; +this.oldcs = null; +this.oldgroupColours = null; +this.currentAnnotation = null; +this.adjusting = false; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "RNAHelicesColourChooser"); +Clazz.makeConstructor (c$, +function (av, ap) { +this.oldcs = av.getGlobalColourScheme (); +if (av.getAlignment ().getGroups () != null) { +this.oldgroupColours = new java.util.Hashtable (); +for (var sg, $sg = ap.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs != null) { +this.oldgroupColours.put (sg, sg.cs); +}} +}this.av = av; +this.ap = ap; +if (Clazz.instanceOf (this.oldcs, jalview.schemes.RNAHelicesColour)) { +var rhc = this.oldcs; +}this.adjusting = true; +var list = new java.util.Vector (); +var index = 1; +for (var i = 0; i < av.getAlignment ().getAlignmentAnnotation ().length; i++) { +var label = av.getAlignment ().getAlignmentAnnotation ()[i].label; +if (!list.contains (label)) list.addElement (label); + else list.addElement (label + "_" + (index++)); +} +this.adjusting = false; +this.changeColour (); +}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "changeColour", +function () { +if (this.adjusting) { +return; +}var rhc = null; +rhc = new jalview.schemes.RNAHelicesColour (this.av.getAlignment ()); +this.av.setGlobalColourScheme (rhc); +if (this.av.getAlignment ().getGroups () != null) { +for (var sg, $sg = this.ap.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs == null) { +continue; +}sg.cs = new jalview.schemes.RNAHelicesColour (sg); +} +}this.ap.paintAlignment (false); +}); +Clazz.defineMethod (c$, "reset", +function () { +this.av.setGlobalColourScheme (this.oldcs); +if (this.av.getAlignment ().getGroups () != null) { +for (var sg, $sg = this.ap.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +sg.cs = this.oldgroupColours.get (sg); +} +}}); +Clazz.defineMethod (c$, "annotations_actionPerformed", +function (e) { +this.changeColour (); +}, "java.awt.event.ActionEvent"); +}); diff --git a/bin/jalview/schemes/RNAInteractionColourScheme.js b/bin/jalview/schemes/RNAInteractionColourScheme.js index 6935253..9c2e946 100644 --- a/bin/jalview/schemes/RNAInteractionColourScheme.js +++ b/bin/jalview/schemes/RNAInteractionColourScheme.js @@ -1,27 +1,27 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.RNAInteractionColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "RNAInteractionColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.defineMethod (c$, "findColour", -function (c) { -return this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour; -if ((this.threshold == 0) || this.aboveThreshold (c, j)) { -try { -currentColour = this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -return java.awt.Color.white; -} else { -throw ex; -} -} -} else { -return java.awt.Color.white; -}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.RNAInteractionColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "RNAInteractionColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.defineMethod (c$, "findColour", +function (c) { +return this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour; +if ((this.threshold == 0) || this.aboveThreshold (c, j)) { +try { +currentColour = this.colors[jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]]; +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +return java.awt.Color.white; +} else { +throw ex; +} +} +} else { +return java.awt.Color.white; +}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +}); diff --git a/bin/jalview/schemes/ResidueColourScheme.js b/bin/jalview/schemes/ResidueColourScheme.js index 9b2382f..aaf6ef5 100644 --- a/bin/jalview/schemes/ResidueColourScheme.js +++ b/bin/jalview/schemes/ResidueColourScheme.js @@ -1,146 +1,146 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ColourSchemeI"], "jalview.schemes.ResidueColourScheme", ["jalview.util.Comparison", "$.MessageManager", "java.awt.Color", "java.lang.Error"], function () { -c$ = Clazz.decorateAsClass (function () { -this.symbolIndex = null; -this.conservationColouring = false; -this.colors = null; -this.threshold = 0; -this.ignoreGaps = "G"; -this.consensus = null; -this.conservation = null; -this.conservationLength = 0; -this.inc = 30; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "ResidueColourScheme", null, jalview.schemes.ColourSchemeI); -Clazz.makeConstructor (c$, -function (aaOrnaIndex, colours, threshold) { -this.symbolIndex = aaOrnaIndex; -this.colors = colours; -this.threshold = threshold; -}, "~A,~A,~N"); -Clazz.makeConstructor (c$, -function (aaOrNaIndex) { -this.symbolIndex = aaOrNaIndex; -}, "~A"); -Clazz.makeConstructor (c$, -function () { -this.symbolIndex = null; -}); -Clazz.defineMethod (c$, "findColour", -function (c) { -return this.colors == null ? java.awt.Color.white : this.colors[this.symbolIndex[c.charCodeAt (0)]]; -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour; -if (this.colors != null && this.symbolIndex != null && (this.threshold == 0) || this.aboveThreshold (c, j)) { -currentColour = this.colors[this.symbolIndex[c.charCodeAt (0)]]; -} else { -currentColour = java.awt.Color.white; -}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "getThreshold", -function () { -return this.threshold; -}); -Clazz.overrideMethod (c$, "setThreshold", -function (ct, ignoreGaps) { -this.threshold = ct; -if (ignoreGaps) { -this.ignoreGaps = "N"; -} else { -this.ignoreGaps = "G"; -}}, "~N,~B"); -Clazz.defineMethod (c$, "aboveThreshold", -function (c, j) { -if ('a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - (32)); -}if (this.consensus == null || this.consensus.length < j || this.consensus[j] == null) { -return false; -}if (((this.consensus[j].get ("C")).intValue () != -1) && this.consensus[j].contains (String.valueOf (c))) { -if ((this.consensus[j].get (this.ignoreGaps)).floatValue () >= this.threshold) { -return true; -}}return false; -}, "~S,~N"); -Clazz.overrideMethod (c$, "conservationApplied", -function () { -return this.conservationColouring; -}); -Clazz.overrideMethod (c$, "setConservationApplied", -function (conservationApplied) { -this.conservationColouring = conservationApplied; -}, "~B"); -Clazz.overrideMethod (c$, "setConservationInc", -function (i) { -this.inc = i; -}, "~N"); -Clazz.overrideMethod (c$, "getConservationInc", -function () { -return this.inc; -}); -Clazz.overrideMethod (c$, "setConsensus", -function (consensus) { -if (consensus == null) { -return; -}this.consensus = consensus; -}, "~A"); -Clazz.overrideMethod (c$, "setConservation", -function (cons) { -if (cons == null) { -this.conservationColouring = false; -this.conservation = null; -} else { -this.conservationColouring = true; -var i; -var iSize = cons.getConsSequence ().getLength (); -this.conservation = Clazz.newCharArray (iSize, '\0'); -for (i = 0; i < iSize; i++) { -this.conservation[i] = cons.getConsSequence ().getCharAt (i); -} -this.conservationLength = this.conservation.length; -}}, "jalview.analysis.Conservation"); -Clazz.defineMethod (c$, "applyConservation", -function (currentColour, i) { -if ((this.conservationLength > i) && (this.conservation[i] != '*') && (this.conservation[i] != '+')) { -if (jalview.util.Comparison.isGap (this.conservation[i])) { -currentColour = java.awt.Color.white; -} else { -var t = 11 - ((this.conservation[i]).charCodeAt (0) - 48); -if (t == 0) { -return java.awt.Color.white; -}var red = currentColour.getRed (); -var green = currentColour.getGreen (); -var blue = currentColour.getBlue (); -var dr = 255 - red; -var dg = 255 - green; -var db = 255 - blue; -dr *= t / 10; -dg *= t / 10; -db *= t / 10; -red += (this.inc / 20) * dr; -green += (this.inc / 20) * dg; -blue += (this.inc / 20) * db; -if (red > 255 || green > 255 || blue > 255) { -currentColour = java.awt.Color.white; -} else { -currentColour = new java.awt.Color (red, green, blue); -}}}return currentColour; -}, "java.awt.Color,~N"); -Clazz.overrideMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -try { -return this.getClass ().newInstance (); -} catch (q) { -if (Clazz.exceptionOf (q, Exception)) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cannot_duplicate_colour_scheme", Clazz.newArray (-1, [this.getClass ().getName ()])), q); -} else { -throw q; -} -} -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ColourSchemeI"], "jalview.schemes.ResidueColourScheme", ["jalview.util.Comparison", "$.MessageManager", "java.awt.Color", "java.lang.Error"], function () { +c$ = Clazz.decorateAsClass (function () { +this.symbolIndex = null; +this.conservationColouring = false; +this.colors = null; +this.threshold = 0; +this.ignoreGaps = "G"; +this.consensus = null; +this.conservation = null; +this.conservationLength = 0; +this.inc = 30; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "ResidueColourScheme", null, jalview.schemes.ColourSchemeI); +Clazz.makeConstructor (c$, +function (aaOrnaIndex, colours, threshold) { +this.symbolIndex = aaOrnaIndex; +this.colors = colours; +this.threshold = threshold; +}, "~A,~A,~N"); +Clazz.makeConstructor (c$, +function (aaOrNaIndex) { +this.symbolIndex = aaOrNaIndex; +}, "~A"); +Clazz.makeConstructor (c$, +function () { +this.symbolIndex = null; +}); +Clazz.defineMethod (c$, "findColour", +function (c) { +return this.colors == null ? java.awt.Color.white : this.colors[this.symbolIndex[c.charCodeAt (0)]]; +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour; +if (this.colors != null && this.symbolIndex != null && (this.threshold == 0) || this.aboveThreshold (c, j)) { +currentColour = this.colors[this.symbolIndex[c.charCodeAt (0)]]; +} else { +currentColour = java.awt.Color.white; +}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "getThreshold", +function () { +return this.threshold; +}); +Clazz.overrideMethod (c$, "setThreshold", +function (ct, ignoreGaps) { +this.threshold = ct; +if (ignoreGaps) { +this.ignoreGaps = "N"; +} else { +this.ignoreGaps = "G"; +}}, "~N,~B"); +Clazz.defineMethod (c$, "aboveThreshold", +function (c, j) { +if ('a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - (32)); +}if (this.consensus == null || this.consensus.length < j || this.consensus[j] == null) { +return false; +}if (((this.consensus[j].get ("C")).intValue () != -1) && this.consensus[j].contains (String.valueOf (c))) { +if ((this.consensus[j].get (this.ignoreGaps)).floatValue () >= this.threshold) { +return true; +}}return false; +}, "~S,~N"); +Clazz.overrideMethod (c$, "conservationApplied", +function () { +return this.conservationColouring; +}); +Clazz.overrideMethod (c$, "setConservationApplied", +function (conservationApplied) { +this.conservationColouring = conservationApplied; +}, "~B"); +Clazz.overrideMethod (c$, "setConservationInc", +function (i) { +this.inc = i; +}, "~N"); +Clazz.overrideMethod (c$, "getConservationInc", +function () { +return this.inc; +}); +Clazz.overrideMethod (c$, "setConsensus", +function (consensus) { +if (consensus == null) { +return; +}this.consensus = consensus; +}, "~A"); +Clazz.overrideMethod (c$, "setConservation", +function (cons) { +if (cons == null) { +this.conservationColouring = false; +this.conservation = null; +} else { +this.conservationColouring = true; +var i; +var iSize = cons.getConsSequence ().getLength (); +this.conservation = Clazz.newCharArray (iSize, '\0'); +for (i = 0; i < iSize; i++) { +this.conservation[i] = cons.getConsSequence ().getCharAt (i); +} +this.conservationLength = this.conservation.length; +}}, "jalview.analysis.Conservation"); +Clazz.defineMethod (c$, "applyConservation", +function (currentColour, i) { +if ((this.conservationLength > i) && (this.conservation[i] != '*') && (this.conservation[i] != '+')) { +if (jalview.util.Comparison.isGap (this.conservation[i])) { +currentColour = java.awt.Color.white; +} else { +var t = 11 - ((this.conservation[i]).charCodeAt (0) - 48); +if (t == 0) { +return java.awt.Color.white; +}var red = currentColour.getRed (); +var green = currentColour.getGreen (); +var blue = currentColour.getBlue (); +var dr = 255 - red; +var dg = 255 - green; +var db = 255 - blue; +dr *= t / 10; +dg *= t / 10; +db *= t / 10; +red += (this.inc / 20) * dr; +green += (this.inc / 20) * dg; +blue += (this.inc / 20) * db; +if (red > 255 || green > 255 || blue > 255) { +currentColour = java.awt.Color.white; +} else { +currentColour = new java.awt.Color (red, green, blue); +}}}return currentColour; +}, "java.awt.Color,~N"); +Clazz.overrideMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +try { +return this.getClass ().newInstance (); +} catch (q) { +if (Clazz.exceptionOf (q, Exception)) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cannot_duplicate_colour_scheme", Clazz.newArray (-1, [this.getClass ().getName ()])), q); +} else { +throw q; +} +} +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +}); diff --git a/bin/jalview/schemes/ResidueProperties.js b/bin/jalview/schemes/ResidueProperties.js index 2a81845..612edb4 100644 --- a/bin/jalview/schemes/ResidueProperties.js +++ b/bin/jalview/schemes/ResidueProperties.js @@ -1,1090 +1,1090 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.analysis.scoremodels.FeatureScoreModel", "$.PIDScoreModel", "jalview.schemes.ScoreMatrix", "java.awt.Color", "java.util.ArrayList", "$.HashMap", "$.Hashtable", "$.Vector"], "jalview.schemes.ResidueProperties", ["java.lang.StringBuffer"], function () { -c$ = Clazz.declareType (jalview.schemes, "ResidueProperties"); -c$.buildAmbiguityCodonSet = Clazz.defineMethod (c$, "buildAmbiguityCodonSet", -function () { -if (jalview.schemes.ResidueProperties._ambiguityCodes.size () > 0) { -System.err.println ("Ignoring multiple calls to buildAmbiguityCodonSet"); -return; -}for (var acode, $acode = jalview.schemes.ResidueProperties.ambiguityCodes.entrySet ().iterator (); $acode.hasNext () && ((acode = $acode.next ()) || true);) { -for (var r, $r = 0, $$r = acode.getValue (); $r < $$r.length && ((r = $$r[$r]) || true); $r++) { -var codesfor = jalview.schemes.ResidueProperties._ambiguityCodes.get (r); -if (codesfor == null) { -jalview.schemes.ResidueProperties._ambiguityCodes.put (r, codesfor = new java.util.ArrayList ()); -}if (!codesfor.contains (acode.getKey ())) { -codesfor.add (acode.getKey ()); -} else { -System.err.println ("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for " + acode.getKey () + " in residue " + r); -}} -} -var unambcodons = jalview.schemes.ResidueProperties.codonHash2.keySet ().toArray ( new Array (jalview.schemes.ResidueProperties.codonHash2.size ())); -for (var codon, $codon = 0, $$codon = unambcodons; $codon < $$codon.length && ((codon = $$codon[$codon]) || true); $codon++) { -var residue = jalview.schemes.ResidueProperties.codonHash2.get (codon); -var acodon = new Array (codon.length); -for (var i = 0, iSize = codon.length; i < iSize; i++) { -var _ac = "" + codon.charAt (i); -var acodes = jalview.schemes.ResidueProperties._ambiguityCodes.get (_ac); -if (acodes != null) { -acodon[i] = acodes.toArray ( new Array (acodes.size ())); -} else { -acodon[i] = Clazz.newArray (-1, []); -}} -var tpos = Clazz.newIntArray (codon.length, 0); -var cpos = Clazz.newIntArray (codon.length, 0); -for (var i = 0; i < tpos.length; i++) { -tpos[i] = -1; -} -tpos[acodon.length - 1] = 0; -var ipos; -var j; -while (tpos[0] < acodon[0].length) { -var allres = Clazz.newCharArray (tpos.length, '\0'); -var _acodon = ""; -var _anuc; -for (ipos = 0; ipos < tpos.length; ipos++) { -if (acodon[ipos].length == 0 || tpos[ipos] < 0) { -_acodon += codon.charAt (ipos); -allres[ipos] = Clazz.newCharArray (-1, [codon.charAt (ipos)]); -} else { -_acodon += acodon[ipos][tpos[ipos]]; -var altbase = jalview.schemes.ResidueProperties.ambiguityCodes.get (acodon[ipos][tpos[ipos]]); -allres[ipos] = Clazz.newCharArray (altbase.length, '\0'); -j = 0; -for (var ab, $ab = 0, $$ab = altbase; $ab < $$ab.length && ((ab = $$ab[$ab]) || true); $ab++) { -allres[ipos][j++] = ab.charAt (0); -} -}} -for (ipos = 0; ipos < cpos.length; ipos++) { -cpos[ipos] = 0; -} -var valid = true; -do { -var _codon = ""; -for (j = 0; j < cpos.length; j++) { -_codon += allres[j][cpos[j]]; -} -var tr = jalview.schemes.ResidueProperties.codonHash2.get (_codon); -if (valid = (tr != null && tr.equals (residue))) { -ipos = acodon.length - 1; -while (++cpos[ipos] >= allres[ipos].length && ipos > 0) { -cpos[ipos] = 0; -ipos--; -} -}} while (valid && cpos[0] < allres[0].length); -if (valid) { -jalview.schemes.ResidueProperties.codonHash2.put (_acodon, residue); -} else { -}ipos = acodon.length - 1; -while (++tpos[ipos] >= acodon[ipos].length && ipos > 0) { -tpos[ipos] = -1; -ipos--; -} -} -} -}); -c$.getHydmax = Clazz.defineMethod (c$, "getHydmax", -function () { -return 4.5; -}); -c$.getHydmin = Clazz.defineMethod (c$, "getHydmin", -function () { -return -3.9; -}); -c$.getHyd = Clazz.defineMethod (c$, "getHyd", -function () { -return jalview.schemes.ResidueProperties.hyd; -}); -c$.getAA3Hash = Clazz.defineMethod (c$, "getAA3Hash", -function () { -return jalview.schemes.ResidueProperties.aa3Hash; -}); -c$.getDNA = Clazz.defineMethod (c$, "getDNA", -function () { -return jalview.schemes.ResidueProperties.DNA; -}); -c$.getBLOSUM62 = Clazz.defineMethod (c$, "getBLOSUM62", -function () { -return jalview.schemes.ResidueProperties.BLOSUM62; -}); -c$.getPAM250 = Clazz.defineMethod (c$, "getPAM250", -function (A1, A2) { -return jalview.schemes.ResidueProperties.getPAM250 (A1.charAt (0), A2.charAt (0)); -}, "~S,~S"); -c$.getBLOSUM62 = Clazz.defineMethod (c$, "getBLOSUM62", -function (c1, c2) { -var pog = 0; -try { -var a = jalview.schemes.ResidueProperties.aaIndex[c1.charCodeAt (0)]; -var b = jalview.schemes.ResidueProperties.aaIndex[c2.charCodeAt (0)]; -pog = jalview.schemes.ResidueProperties.BLOSUM62[a][b]; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -return pog; -}, "~S,~S"); -c$.getCodons = Clazz.defineMethod (c$, "getCodons", -function (res) { -if (jalview.schemes.ResidueProperties.codonHash.containsKey (res)) { -return jalview.schemes.ResidueProperties.codonHash.get (res); -}return null; -}, "~S"); -c$.codonTranslate = Clazz.defineMethod (c$, "codonTranslate", -function (lccodon) { -if (false) { -return jalview.schemes.ResidueProperties._codonTranslate (lccodon); -}var cdn = jalview.schemes.ResidueProperties.codonHash2.get (lccodon.toUpperCase ()); -if (cdn != null && cdn.equals ("*")) { -return "STOP"; -}return cdn; -}, "~S"); -c$._codonTranslate = Clazz.defineMethod (c$, "_codonTranslate", -function (lccodon) { -var codon = lccodon.toUpperCase (); -if (codon.indexOf ('X') > -1 || codon.indexOf ('N') > -1) { -return "X"; -}for (var key, $key = jalview.schemes.ResidueProperties.codonHash.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { -if (jalview.schemes.ResidueProperties.codonHash.get (key).contains (codon)) { -return key; -}} -return null; -}, "~S"); -c$.getDefaultPeptideMatrix = Clazz.defineMethod (c$, "getDefaultPeptideMatrix", -function () { -return jalview.schemes.ResidueProperties.getBLOSUM62 (); -}); -c$.getDefaultDnaMatrix = Clazz.defineMethod (c$, "getDefaultDnaMatrix", -function () { -return jalview.schemes.ResidueProperties.getDNA (); -}); -c$.getScoreMatrix = Clazz.defineMethod (c$, "getScoreMatrix", -function (pwtype) { -var val = jalview.schemes.ResidueProperties.scoreMatrices.get (pwtype); -if (val != null && Clazz.instanceOf (val, jalview.schemes.ScoreMatrix)) { -return val; -}return null; -}, "~S"); -c$.getScoreModel = Clazz.defineMethod (c$, "getScoreModel", -function (pwtype) { -return jalview.schemes.ResidueProperties.scoreMatrices.get (pwtype); -}, "~S"); -c$.getPAM250 = Clazz.defineMethod (c$, "getPAM250", -function (c, d) { -var a = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]; -var b = jalview.schemes.ResidueProperties.aaIndex[d.charCodeAt (0)]; -var pog = jalview.schemes.ResidueProperties.PAM250[a][b]; -return pog; -}, "~S,~S"); -c$.getDssp3state = Clazz.defineMethod (c$, "getDssp3state", -function (ssstring) { -if (ssstring == null) { -return null; -}var ss = new StringBuffer (); -for (var i = 0; i < ssstring.length; i++) { -var ssc = ssstring.substring (i, i + 1); -if (jalview.schemes.ResidueProperties.toDssp3State.containsKey (ssc)) { -ss.append (jalview.schemes.ResidueProperties.toDssp3State.get (ssc)); -} else { -ss.append (" "); -}} -return ss.toString (); -}, "~S"); -c$.getRNASecStrucState = Clazz.defineMethod (c$, "getRNASecStrucState", -function (ssstring) { -if (ssstring == null) { -return null; -}var ss = new StringBuffer (); -for (var i = 0; i < ssstring.length; i++) { -var ssc = ssstring.substring (i, i + 1); -if (jalview.schemes.ResidueProperties.toRNAssState.containsKey (ssc)) { -ss.append (ssc); -} else { -ss.append (" "); -}} -return ss.toString (); -}, "~S"); -c$.isCloseParenRNA = Clazz.defineMethod (c$, "isCloseParenRNA", -function (dc) { -return jalview.schemes.ResidueProperties.RNAcloseParen[dc.charCodeAt (0)]; -}, "~S"); -c$.getResidues = Clazz.defineMethod (c$, "getResidues", -function (nucleotide, includeAmbiguous) { -var result = new java.util.ArrayList (); -if (nucleotide) { -for (var nuc, $nuc = jalview.schemes.ResidueProperties.nucleotideName.keySet ().iterator (); $nuc.hasNext () && ((nuc = $nuc.next ()) || true);) { -var val = jalview.schemes.ResidueProperties.nucleotideIndex[nuc.charCodeAt (0)]; -if ((!includeAmbiguous && val > 4) || (val >= 10)) { -continue; -}nuc = nuc.toUpperCase (); -if (!result.contains (nuc)) { -result.add (nuc); -}} -} else { -for (var res, $res = jalview.schemes.ResidueProperties.aa3Hash.keySet ().iterator (); $res.hasNext () && ((res = $res.next ()) || true);) { -var index = jalview.schemes.ResidueProperties.aa3Hash.get (res).intValue (); -if ((!includeAmbiguous && index >= 20) || index >= 23) { -continue; -}res = res.toUpperCase (); -if (!result.contains (res)) { -result.add (res); -}} -}return result; -}, "~B,~B"); -c$.scoreMatrices = c$.prototype.scoreMatrices = new java.util.Hashtable (); -Clazz.defineStatics (c$, -"aaIndex", null, -"nucleotideIndex", null, -"purinepyrimidineIndex", null); -c$.aa3Hash = c$.prototype.aa3Hash = new java.util.HashMap (); -c$.aa2Triplet = c$.prototype.aa2Triplet = new java.util.HashMap (); -c$.nucleotideName = c$.prototype.nucleotideName = new java.util.HashMap (); -{ -jalview.schemes.ResidueProperties.aaIndex = Clazz.newIntArray (255, 0); -for (var i = 0; i < 255; i++) { -jalview.schemes.ResidueProperties.aaIndex[i] = 23; -} -jalview.schemes.ResidueProperties.aaIndex['A'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.aaIndex['R'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.aaIndex['N'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.aaIndex['D'.charCodeAt (0)] = 3; -jalview.schemes.ResidueProperties.aaIndex['C'.charCodeAt (0)] = 4; -jalview.schemes.ResidueProperties.aaIndex['Q'.charCodeAt (0)] = 5; -jalview.schemes.ResidueProperties.aaIndex['E'.charCodeAt (0)] = 6; -jalview.schemes.ResidueProperties.aaIndex['G'.charCodeAt (0)] = 7; -jalview.schemes.ResidueProperties.aaIndex['H'.charCodeAt (0)] = 8; -jalview.schemes.ResidueProperties.aaIndex['I'.charCodeAt (0)] = 9; -jalview.schemes.ResidueProperties.aaIndex['L'.charCodeAt (0)] = 10; -jalview.schemes.ResidueProperties.aaIndex['K'.charCodeAt (0)] = 11; -jalview.schemes.ResidueProperties.aaIndex['M'.charCodeAt (0)] = 12; -jalview.schemes.ResidueProperties.aaIndex['F'.charCodeAt (0)] = 13; -jalview.schemes.ResidueProperties.aaIndex['P'.charCodeAt (0)] = 14; -jalview.schemes.ResidueProperties.aaIndex['S'.charCodeAt (0)] = 15; -jalview.schemes.ResidueProperties.aaIndex['T'.charCodeAt (0)] = 16; -jalview.schemes.ResidueProperties.aaIndex['W'.charCodeAt (0)] = 17; -jalview.schemes.ResidueProperties.aaIndex['Y'.charCodeAt (0)] = 18; -jalview.schemes.ResidueProperties.aaIndex['V'.charCodeAt (0)] = 19; -jalview.schemes.ResidueProperties.aaIndex['B'.charCodeAt (0)] = 20; -jalview.schemes.ResidueProperties.aaIndex['Z'.charCodeAt (0)] = 21; -jalview.schemes.ResidueProperties.aaIndex['X'.charCodeAt (0)] = 22; -jalview.schemes.ResidueProperties.aaIndex['U'.charCodeAt (0)] = 22; -jalview.schemes.ResidueProperties.aaIndex['a'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.aaIndex['r'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.aaIndex['n'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.aaIndex['d'.charCodeAt (0)] = 3; -jalview.schemes.ResidueProperties.aaIndex['c'.charCodeAt (0)] = 4; -jalview.schemes.ResidueProperties.aaIndex['q'.charCodeAt (0)] = 5; -jalview.schemes.ResidueProperties.aaIndex['e'.charCodeAt (0)] = 6; -jalview.schemes.ResidueProperties.aaIndex['g'.charCodeAt (0)] = 7; -jalview.schemes.ResidueProperties.aaIndex['h'.charCodeAt (0)] = 8; -jalview.schemes.ResidueProperties.aaIndex['i'.charCodeAt (0)] = 9; -jalview.schemes.ResidueProperties.aaIndex['l'.charCodeAt (0)] = 10; -jalview.schemes.ResidueProperties.aaIndex['k'.charCodeAt (0)] = 11; -jalview.schemes.ResidueProperties.aaIndex['m'.charCodeAt (0)] = 12; -jalview.schemes.ResidueProperties.aaIndex['f'.charCodeAt (0)] = 13; -jalview.schemes.ResidueProperties.aaIndex['p'.charCodeAt (0)] = 14; -jalview.schemes.ResidueProperties.aaIndex['s'.charCodeAt (0)] = 15; -jalview.schemes.ResidueProperties.aaIndex['t'.charCodeAt (0)] = 16; -jalview.schemes.ResidueProperties.aaIndex['w'.charCodeAt (0)] = 17; -jalview.schemes.ResidueProperties.aaIndex['y'.charCodeAt (0)] = 18; -jalview.schemes.ResidueProperties.aaIndex['v'.charCodeAt (0)] = 19; -jalview.schemes.ResidueProperties.aaIndex['b'.charCodeAt (0)] = 20; -jalview.schemes.ResidueProperties.aaIndex['z'.charCodeAt (0)] = 21; -jalview.schemes.ResidueProperties.aaIndex['x'.charCodeAt (0)] = 22; -jalview.schemes.ResidueProperties.aaIndex['u'.charCodeAt (0)] = 22; -}Clazz.defineStatics (c$, -"maxProteinIndex", 23, -"maxNucleotideIndex", 10); -{ -jalview.schemes.ResidueProperties.nucleotideIndex = Clazz.newIntArray (255, 0); -for (var i = 0; i < 255; i++) { -jalview.schemes.ResidueProperties.nucleotideIndex[i] = 10; -} -jalview.schemes.ResidueProperties.nucleotideIndex['A'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.nucleotideIndex['a'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.nucleotideIndex['C'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.nucleotideIndex['c'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.nucleotideIndex['G'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.nucleotideIndex['g'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.nucleotideIndex['T'.charCodeAt (0)] = 3; -jalview.schemes.ResidueProperties.nucleotideIndex['t'.charCodeAt (0)] = 3; -jalview.schemes.ResidueProperties.nucleotideIndex['U'.charCodeAt (0)] = 4; -jalview.schemes.ResidueProperties.nucleotideIndex['u'.charCodeAt (0)] = 4; -jalview.schemes.ResidueProperties.nucleotideIndex['I'.charCodeAt (0)] = 5; -jalview.schemes.ResidueProperties.nucleotideIndex['i'.charCodeAt (0)] = 5; -jalview.schemes.ResidueProperties.nucleotideIndex['X'.charCodeAt (0)] = 6; -jalview.schemes.ResidueProperties.nucleotideIndex['x'.charCodeAt (0)] = 6; -jalview.schemes.ResidueProperties.nucleotideIndex['R'.charCodeAt (0)] = 7; -jalview.schemes.ResidueProperties.nucleotideIndex['r'.charCodeAt (0)] = 7; -jalview.schemes.ResidueProperties.nucleotideIndex['Y'.charCodeAt (0)] = 8; -jalview.schemes.ResidueProperties.nucleotideIndex['y'.charCodeAt (0)] = 8; -jalview.schemes.ResidueProperties.nucleotideIndex['N'.charCodeAt (0)] = 9; -jalview.schemes.ResidueProperties.nucleotideIndex['n'.charCodeAt (0)] = 9; -jalview.schemes.ResidueProperties.nucleotideName.put ("A", "Adenine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("a", "Adenine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("G", "Guanine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("g", "Guanine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("C", "Cytosine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("c", "Cytosine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("T", "Thymine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("t", "Thymine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("U", "Uracil"); -jalview.schemes.ResidueProperties.nucleotideName.put ("u", "Uracil"); -jalview.schemes.ResidueProperties.nucleotideName.put ("I", "Inosine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("i", "Inosine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("X", "Xanthine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("x", "Xanthine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("R", "Unknown Purine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("r", "Unknown Purine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("Y", "Unknown Pyrimidine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("y", "Unknown Pyrimidine"); -jalview.schemes.ResidueProperties.nucleotideName.put ("N", "Unknown"); -jalview.schemes.ResidueProperties.nucleotideName.put ("n", "Unknown"); -jalview.schemes.ResidueProperties.nucleotideName.put ("W", "Weak nucleotide (A or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("w", "Weak nucleotide (A or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("S", "Strong nucleotide (G or C)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("s", "Strong nucleotide (G or C)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("M", "Amino (A or C)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("m", "Amino (A or C)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("K", "Keto (G or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("k", "Keto (G or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("B", "Not A (G or C or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("b", "Not A (G or C or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("H", "Not G (A or C or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("h", "Not G (A or C or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("D", "Not C (A or G or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("d", "Not C (A or G or T)"); -jalview.schemes.ResidueProperties.nucleotideName.put ("V", "Not T (A or G or C"); -jalview.schemes.ResidueProperties.nucleotideName.put ("v", "Not T (A or G or C"); -}{ -jalview.schemes.ResidueProperties.purinepyrimidineIndex = Clazz.newIntArray (255, 0); -for (var i = 0; i < 255; i++) { -jalview.schemes.ResidueProperties.purinepyrimidineIndex[i] = 3; -} -jalview.schemes.ResidueProperties.purinepyrimidineIndex['A'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['a'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['C'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['c'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['G'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['g'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['T'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['t'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['U'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['u'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['I'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['i'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['X'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['x'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['R'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['r'.charCodeAt (0)] = 0; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['Y'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['y'.charCodeAt (0)] = 1; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['N'.charCodeAt (0)] = 2; -jalview.schemes.ResidueProperties.purinepyrimidineIndex['n'.charCodeAt (0)] = 2; -}{ -jalview.schemes.ResidueProperties.aa3Hash.put ("ALA", new Integer (0)); -jalview.schemes.ResidueProperties.aa3Hash.put ("ARG", new Integer (1)); -jalview.schemes.ResidueProperties.aa3Hash.put ("ASN", new Integer (2)); -jalview.schemes.ResidueProperties.aa3Hash.put ("ASP", new Integer (3)); -jalview.schemes.ResidueProperties.aa3Hash.put ("CYS", new Integer (4)); -jalview.schemes.ResidueProperties.aa3Hash.put ("GLN", new Integer (5)); -jalview.schemes.ResidueProperties.aa3Hash.put ("GLU", new Integer (6)); -jalview.schemes.ResidueProperties.aa3Hash.put ("GLY", new Integer (7)); -jalview.schemes.ResidueProperties.aa3Hash.put ("HIS", new Integer (8)); -jalview.schemes.ResidueProperties.aa3Hash.put ("ILE", new Integer (9)); -jalview.schemes.ResidueProperties.aa3Hash.put ("LEU", new Integer (10)); -jalview.schemes.ResidueProperties.aa3Hash.put ("LYS", new Integer (11)); -jalview.schemes.ResidueProperties.aa3Hash.put ("MET", new Integer (12)); -jalview.schemes.ResidueProperties.aa3Hash.put ("PHE", new Integer (13)); -jalview.schemes.ResidueProperties.aa3Hash.put ("PRO", new Integer (14)); -jalview.schemes.ResidueProperties.aa3Hash.put ("SER", new Integer (15)); -jalview.schemes.ResidueProperties.aa3Hash.put ("THR", new Integer (16)); -jalview.schemes.ResidueProperties.aa3Hash.put ("TRP", new Integer (17)); -jalview.schemes.ResidueProperties.aa3Hash.put ("TYR", new Integer (18)); -jalview.schemes.ResidueProperties.aa3Hash.put ("VAL", new Integer (19)); -jalview.schemes.ResidueProperties.aa3Hash.put ("ASX", new Integer (20)); -jalview.schemes.ResidueProperties.aa3Hash.put ("GLX", new Integer (21)); -jalview.schemes.ResidueProperties.aa3Hash.put ("XAA", new Integer (22)); -jalview.schemes.ResidueProperties.aa3Hash.put ("-", new Integer (23)); -jalview.schemes.ResidueProperties.aa3Hash.put ("*", new Integer (23)); -jalview.schemes.ResidueProperties.aa3Hash.put (".", new Integer (23)); -jalview.schemes.ResidueProperties.aa3Hash.put (" ", new Integer (23)); -jalview.schemes.ResidueProperties.aa3Hash.put ("Gap", new Integer (23)); -}{ -jalview.schemes.ResidueProperties.aa2Triplet.put ("A", "ALA"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("a", "ALA"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("R", "ARG"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("r", "ARG"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("N", "ASN"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("n", "ASN"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("D", "ASP"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("d", "ASP"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("C", "CYS"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("c", "CYS"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("Q", "GLN"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("q", "GLN"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("E", "GLU"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("e", "GLU"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("G", "GLY"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("g", "GLY"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("H", "HIS"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("h", "HIS"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("I", "ILE"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("i", "ILE"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("L", "LEU"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("l", "LEU"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("K", "LYS"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("k", "LYS"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("M", "MET"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("m", "MET"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("F", "PHE"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("f", "PHE"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("P", "PRO"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("p", "PRO"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("S", "SER"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("s", "SER"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("T", "THR"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("t", "THR"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("W", "TRP"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("w", "TRP"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("Y", "TYR"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("y", "TYR"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("V", "VAL"); -jalview.schemes.ResidueProperties.aa2Triplet.put ("v", "VAL"); -}Clazz.defineStatics (c$, -"aa", Clazz.newArray (-1, ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " "])); -c$.midBlue = c$.prototype.midBlue = new java.awt.Color (100, 100, 255); -c$.scaleColours = c$.prototype.scaleColours = new java.util.Vector (); -{ -jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (114, 0, 147)); -jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (156, 0, 98)); -jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (190, 0, 0)); -jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.red); -jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (255, 125, 0)); -jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.orange); -jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (255, 194, 85)); -jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.yellow); -jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (255, 255, 181)); -jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.white); -}c$.taylor = c$.prototype.taylor = Clazz.newArray (-1, [ new java.awt.Color (204, 255, 0), new java.awt.Color (0, 0, 255), new java.awt.Color (204, 0, 255), new java.awt.Color (255, 0, 0), new java.awt.Color (255, 255, 0), new java.awt.Color (255, 0, 204), new java.awt.Color (255, 0, 102), new java.awt.Color (255, 153, 0), new java.awt.Color (0, 102, 255), new java.awt.Color (102, 255, 0), new java.awt.Color (51, 255, 0), new java.awt.Color (102, 0, 255), new java.awt.Color (0, 255, 0), new java.awt.Color (0, 255, 102), new java.awt.Color (255, 204, 0), new java.awt.Color (255, 51, 0), new java.awt.Color (255, 102, 0), new java.awt.Color (0, 204, 255), new java.awt.Color (0, 255, 204), new java.awt.Color (153, 255, 0), java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white]); -c$.nucleotide = c$.prototype.nucleotide = Clazz.newArray (-1, [ new java.awt.Color (100, 247, 63), new java.awt.Color (255, 179, 64), new java.awt.Color (235, 65, 60), new java.awt.Color (60, 136, 238), new java.awt.Color (60, 136, 238), java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white]); -c$.purinepyrimidine = c$.prototype.purinepyrimidine = Clazz.newArray (-1, [ new java.awt.Color (255, 131, 250), new java.awt.Color (64, 224, 208), java.awt.Color.white, java.awt.Color.white]); -c$.zappo = c$.prototype.zappo = Clazz.newArray (-1, [java.awt.Color.pink, jalview.schemes.ResidueProperties.midBlue, java.awt.Color.green, java.awt.Color.red, java.awt.Color.yellow, java.awt.Color.green, java.awt.Color.red, java.awt.Color.magenta, jalview.schemes.ResidueProperties.midBlue, java.awt.Color.pink, java.awt.Color.pink, jalview.schemes.ResidueProperties.midBlue, java.awt.Color.pink, java.awt.Color.orange, java.awt.Color.magenta, java.awt.Color.green, java.awt.Color.green, java.awt.Color.orange, java.awt.Color.orange, java.awt.Color.pink, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white]); -Clazz.defineStatics (c$, -"hyd2", Clazz.newDoubleArray (-1, [0.62, 0.29, -0.9, -0.74, 1.19, 0.48, -0.4, 1.38, -1.5, 1.06, 0.64, -0.78, 0.12, -0.85, -2.53, -0.18, -0.05, 1.08, 0.81, 0.0, 0.26, 0.0, 0.0]), -"helix", Clazz.newDoubleArray (-1, [1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0]), -"helixmin", 0.57, -"helixmax", 1.51, -"strand", Clazz.newDoubleArray (-1, [0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0]), -"strandmin", 0.37, -"strandmax", 1.7, -"turn", Clazz.newDoubleArray (-1, [0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01, 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0]), -"turnmin", 0.47, -"turnmax", 1.56, -"buried", Clazz.newDoubleArray (-1, [1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2, 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00]), -"buriedmin", 0.05, -"buriedmax", 4.6, -"hyd", Clazz.newDoubleArray (-1, [1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0]), -"hydmax", 4.5, -"hydmin", -3.9, -"BLOSUM62", Clazz.newArray (-1, [ Clazz.newIntArray (-1, [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0, -4]), Clazz.newIntArray (-1, [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1, -4]), Clazz.newIntArray (-1, [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1, -4]), Clazz.newIntArray (-1, [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1, -4]), Clazz.newIntArray (-1, [0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2, -4]), Clazz.newIntArray (-1, [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1, -4]), Clazz.newIntArray (-1, [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1, -4]), Clazz.newIntArray (-1, [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1, -4]), Clazz.newIntArray (-1, [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1, -4]), Clazz.newIntArray (-1, [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1, -4]), Clazz.newIntArray (-1, [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1, -4]), Clazz.newIntArray (-1, [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1, -4]), Clazz.newIntArray (-1, [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1, -4]), Clazz.newIntArray (-1, [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1, -4]), Clazz.newIntArray (-1, [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2, -4]), Clazz.newIntArray (-1, [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0, -4]), Clazz.newIntArray (-1, [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0, -4]), Clazz.newIntArray (-1, [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2, -4]), Clazz.newIntArray (-1, [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1, -4]), Clazz.newIntArray (-1, [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1, -4]), Clazz.newIntArray (-1, [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1, -4]), Clazz.newIntArray (-1, [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1, -4]), Clazz.newIntArray (-1, [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1, -4]), Clazz.newIntArray (-1, [-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 1])]), -"PAM250", Clazz.newArray (-1, [ Clazz.newIntArray (-1, [2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3, 0, 0, 0, 0, -8]), Clazz.newIntArray (-1, [-2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4, -2, -1, 0, -1, -8]), Clazz.newIntArray (-1, [0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2, 2, 1, 0, -8]), Clazz.newIntArray (-1, [0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4, -2, 3, 3, -1, -8]), Clazz.newIntArray (-1, [-2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2, -8, 0, -2, -4, -5, -3, -8]), Clazz.newIntArray (-1, [0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4, -2, 1, 3, -1, -8]), Clazz.newIntArray (-1, [0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4, -2, 3, 3, -1, -8]), Clazz.newIntArray (-1, [1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5, -1, 0, 0, -1, -8]), Clazz.newIntArray (-1, [-1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0, -2, 1, 2, -1, -8]), Clazz.newIntArray (-1, [-1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5, -1, 4, -2, -2, -1, -8]), Clazz.newIntArray (-1, [-2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2, -1, 2, -3, -3, -1, -8]), Clazz.newIntArray (-1, [-1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4, -2, 1, 0, -1, -8]), Clazz.newIntArray (-1, [-1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4, -2, 2, -2, -2, -1, -8]), Clazz.newIntArray (-1, [-3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0, 7, -1, -4, -5, -2, -8]), Clazz.newIntArray (-1, [1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5, -1, -1, 0, -1, -8]), Clazz.newIntArray (-1, [1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3, -1, 0, 0, 0, -8]), Clazz.newIntArray (-1, [1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3, 0, 0, -1, 0, -8]), Clazz.newIntArray (-1, [-6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5, 17, 0, -6, -5, -6, -4, -8]), Clazz.newIntArray (-1, [-3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0, 10, -2, -3, -4, -2, -8]), Clazz.newIntArray (-1, [0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6, -2, 4, -2, -2, -1, -8]), Clazz.newIntArray (-1, [0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3, -2, 3, 2, -1, -8]), Clazz.newIntArray (-1, [0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4, -2, 2, 3, -1, -8]), Clazz.newIntArray (-1, [0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4, -2, -1, -1, -1, -1, -8]), Clazz.newIntArray (-1, [-8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 1])])); -c$.ssHash = c$.prototype.ssHash = new java.util.Hashtable (); -{ -jalview.schemes.ResidueProperties.ssHash.put ("H", java.awt.Color.magenta); -jalview.schemes.ResidueProperties.ssHash.put ("E", java.awt.Color.yellow); -jalview.schemes.ResidueProperties.ssHash.put ("-", java.awt.Color.white); -jalview.schemes.ResidueProperties.ssHash.put (".", java.awt.Color.white); -jalview.schemes.ResidueProperties.ssHash.put ("S", java.awt.Color.cyan); -jalview.schemes.ResidueProperties.ssHash.put ("T", java.awt.Color.blue); -jalview.schemes.ResidueProperties.ssHash.put ("G", java.awt.Color.pink); -jalview.schemes.ResidueProperties.ssHash.put ("I", java.awt.Color.pink); -jalview.schemes.ResidueProperties.ssHash.put ("B", java.awt.Color.yellow); -}Clazz.defineStatics (c$, -"DNA", Clazz.newArray (-1, [ Clazz.newIntArray (-1, [10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1]), Clazz.newIntArray (-1, [-8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1]), Clazz.newIntArray (-1, [-8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1]), Clazz.newIntArray (-1, [-8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1]), Clazz.newIntArray (-1, [-8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1]), Clazz.newIntArray (-1, [1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1]), Clazz.newIntArray (-1, [-8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])])); -{ -jalview.schemes.ResidueProperties.scoreMatrices.put ("BLOSUM62", new jalview.schemes.ScoreMatrix ("BLOSUM62", jalview.schemes.ResidueProperties.BLOSUM62, 0)); -jalview.schemes.ResidueProperties.scoreMatrices.put ("PAM250", new jalview.schemes.ScoreMatrix ("PAM250", jalview.schemes.ResidueProperties.PAM250, 0)); -jalview.schemes.ResidueProperties.scoreMatrices.put ("DNA", new jalview.schemes.ScoreMatrix ("DNA", jalview.schemes.ResidueProperties.DNA, 1)); -}c$.pidColours = c$.prototype.pidColours = Clazz.newArray (-1, [jalview.schemes.ResidueProperties.midBlue, new java.awt.Color (153, 153, 255), new java.awt.Color (204, 204, 255)]); -Clazz.defineStatics (c$, -"pidThresholds", Clazz.newFloatArray (-1, [80, 60, 40])); -c$.codonHash = c$.prototype.codonHash = new java.util.HashMap (); -c$.Lys = c$.prototype.Lys = new java.util.ArrayList (); -c$.Asn = c$.prototype.Asn = new java.util.ArrayList (); -c$.Gln = c$.prototype.Gln = new java.util.ArrayList (); -c$.His = c$.prototype.His = new java.util.ArrayList (); -c$.Glu = c$.prototype.Glu = new java.util.ArrayList (); -c$.Asp = c$.prototype.Asp = new java.util.ArrayList (); -c$.Tyr = c$.prototype.Tyr = new java.util.ArrayList (); -c$.Thr = c$.prototype.Thr = new java.util.ArrayList (); -c$.Pro = c$.prototype.Pro = new java.util.ArrayList (); -c$.Ala = c$.prototype.Ala = new java.util.ArrayList (); -c$.Ser = c$.prototype.Ser = new java.util.ArrayList (); -c$.Arg = c$.prototype.Arg = new java.util.ArrayList (); -c$.Gly = c$.prototype.Gly = new java.util.ArrayList (); -c$.Trp = c$.prototype.Trp = new java.util.ArrayList (); -c$.Cys = c$.prototype.Cys = new java.util.ArrayList (); -c$.Ile = c$.prototype.Ile = new java.util.ArrayList (); -c$.Met = c$.prototype.Met = new java.util.ArrayList (); -c$.Leu = c$.prototype.Leu = new java.util.ArrayList (); -c$.Val = c$.prototype.Val = new java.util.ArrayList (); -c$.Phe = c$.prototype.Phe = new java.util.ArrayList (); -c$.STOP = c$.prototype.STOP = new java.util.ArrayList (); -Clazz.defineStatics (c$, -"START", "ATG"); -{ -jalview.schemes.ResidueProperties.codonHash.put ("K", jalview.schemes.ResidueProperties.Lys); -jalview.schemes.ResidueProperties.codonHash.put ("N", jalview.schemes.ResidueProperties.Asn); -jalview.schemes.ResidueProperties.codonHash.put ("Q", jalview.schemes.ResidueProperties.Gln); -jalview.schemes.ResidueProperties.codonHash.put ("H", jalview.schemes.ResidueProperties.His); -jalview.schemes.ResidueProperties.codonHash.put ("E", jalview.schemes.ResidueProperties.Glu); -jalview.schemes.ResidueProperties.codonHash.put ("D", jalview.schemes.ResidueProperties.Asp); -jalview.schemes.ResidueProperties.codonHash.put ("Y", jalview.schemes.ResidueProperties.Tyr); -jalview.schemes.ResidueProperties.codonHash.put ("T", jalview.schemes.ResidueProperties.Thr); -jalview.schemes.ResidueProperties.codonHash.put ("P", jalview.schemes.ResidueProperties.Pro); -jalview.schemes.ResidueProperties.codonHash.put ("A", jalview.schemes.ResidueProperties.Ala); -jalview.schemes.ResidueProperties.codonHash.put ("S", jalview.schemes.ResidueProperties.Ser); -jalview.schemes.ResidueProperties.codonHash.put ("R", jalview.schemes.ResidueProperties.Arg); -jalview.schemes.ResidueProperties.codonHash.put ("G", jalview.schemes.ResidueProperties.Gly); -jalview.schemes.ResidueProperties.codonHash.put ("W", jalview.schemes.ResidueProperties.Trp); -jalview.schemes.ResidueProperties.codonHash.put ("C", jalview.schemes.ResidueProperties.Cys); -jalview.schemes.ResidueProperties.codonHash.put ("I", jalview.schemes.ResidueProperties.Ile); -jalview.schemes.ResidueProperties.codonHash.put ("M", jalview.schemes.ResidueProperties.Met); -jalview.schemes.ResidueProperties.codonHash.put ("L", jalview.schemes.ResidueProperties.Leu); -jalview.schemes.ResidueProperties.codonHash.put ("V", jalview.schemes.ResidueProperties.Val); -jalview.schemes.ResidueProperties.codonHash.put ("F", jalview.schemes.ResidueProperties.Phe); -jalview.schemes.ResidueProperties.codonHash.put ("STOP", jalview.schemes.ResidueProperties.STOP); -}c$.ambiguityCodes = c$.prototype.ambiguityCodes = new java.util.Hashtable (); -c$.codonHash2 = c$.prototype.codonHash2 = new java.util.Hashtable (); -c$._ambiguityCodes = c$.prototype._ambiguityCodes = new java.util.Hashtable (); -{ -jalview.schemes.ResidueProperties.ambiguityCodes.put ("R", Clazz.newArray (-1, ["A", "G"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("Y", Clazz.newArray (-1, ["T", "C"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("W", Clazz.newArray (-1, ["A", "T"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("S", Clazz.newArray (-1, ["G", "C"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("M", Clazz.newArray (-1, ["A", "C"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("K", Clazz.newArray (-1, ["G", "T"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("H", Clazz.newArray (-1, ["A", "T", "C"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("B", Clazz.newArray (-1, ["G", "T", "C"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("V", Clazz.newArray (-1, ["G", "A", "C"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("D", Clazz.newArray (-1, ["G", "A", "T"])); -jalview.schemes.ResidueProperties.ambiguityCodes.put ("N", Clazz.newArray (-1, ["G", "A", "T", "C"])); -jalview.schemes.ResidueProperties.codonHash2.put ("AAA", "K"); -jalview.schemes.ResidueProperties.codonHash2.put ("AAG", "K"); -jalview.schemes.ResidueProperties.codonHash2.put ("AAC", "N"); -jalview.schemes.ResidueProperties.codonHash2.put ("AAT", "N"); -jalview.schemes.ResidueProperties.codonHash2.put ("CAA", "Q"); -jalview.schemes.ResidueProperties.codonHash2.put ("CAG", "Q"); -jalview.schemes.ResidueProperties.codonHash2.put ("CAC", "H"); -jalview.schemes.ResidueProperties.codonHash2.put ("CAT", "H"); -jalview.schemes.ResidueProperties.codonHash2.put ("GAA", "E"); -jalview.schemes.ResidueProperties.codonHash2.put ("GAG", "E"); -jalview.schemes.ResidueProperties.codonHash2.put ("GAC", "D"); -jalview.schemes.ResidueProperties.codonHash2.put ("GAT", "D"); -jalview.schemes.ResidueProperties.codonHash2.put ("TAC", "Y"); -jalview.schemes.ResidueProperties.codonHash2.put ("TAT", "Y"); -jalview.schemes.ResidueProperties.codonHash2.put ("ACA", "T"); -jalview.schemes.ResidueProperties.codonHash2.put ("ACC", "T"); -jalview.schemes.ResidueProperties.codonHash2.put ("ACT", "T"); -jalview.schemes.ResidueProperties.codonHash2.put ("ACG", "T"); -jalview.schemes.ResidueProperties.codonHash2.put ("CCA", "P"); -jalview.schemes.ResidueProperties.codonHash2.put ("CCG", "P"); -jalview.schemes.ResidueProperties.codonHash2.put ("CCC", "P"); -jalview.schemes.ResidueProperties.codonHash2.put ("CCT", "P"); -jalview.schemes.ResidueProperties.codonHash2.put ("GCA", "A"); -jalview.schemes.ResidueProperties.codonHash2.put ("GCG", "A"); -jalview.schemes.ResidueProperties.codonHash2.put ("GCC", "A"); -jalview.schemes.ResidueProperties.codonHash2.put ("GCT", "A"); -jalview.schemes.ResidueProperties.codonHash2.put ("TCA", "S"); -jalview.schemes.ResidueProperties.codonHash2.put ("TCG", "S"); -jalview.schemes.ResidueProperties.codonHash2.put ("TCC", "S"); -jalview.schemes.ResidueProperties.codonHash2.put ("TCT", "S"); -jalview.schemes.ResidueProperties.codonHash2.put ("AGC", "S"); -jalview.schemes.ResidueProperties.codonHash2.put ("AGT", "S"); -jalview.schemes.ResidueProperties.codonHash2.put ("AGA", "R"); -jalview.schemes.ResidueProperties.codonHash2.put ("AGG", "R"); -jalview.schemes.ResidueProperties.codonHash2.put ("CGA", "R"); -jalview.schemes.ResidueProperties.codonHash2.put ("CGG", "R"); -jalview.schemes.ResidueProperties.codonHash2.put ("CGC", "R"); -jalview.schemes.ResidueProperties.codonHash2.put ("CGT", "R"); -jalview.schemes.ResidueProperties.codonHash2.put ("GGA", "G"); -jalview.schemes.ResidueProperties.codonHash2.put ("GGG", "G"); -jalview.schemes.ResidueProperties.codonHash2.put ("GGC", "G"); -jalview.schemes.ResidueProperties.codonHash2.put ("GGT", "G"); -jalview.schemes.ResidueProperties.codonHash2.put ("TGA", "*"); -jalview.schemes.ResidueProperties.codonHash2.put ("TAA", "*"); -jalview.schemes.ResidueProperties.codonHash2.put ("TAG", "*"); -jalview.schemes.ResidueProperties.codonHash2.put ("TGG", "W"); -jalview.schemes.ResidueProperties.codonHash2.put ("TGC", "C"); -jalview.schemes.ResidueProperties.codonHash2.put ("TGT", "C"); -jalview.schemes.ResidueProperties.codonHash2.put ("ATA", "I"); -jalview.schemes.ResidueProperties.codonHash2.put ("ATC", "I"); -jalview.schemes.ResidueProperties.codonHash2.put ("ATT", "I"); -jalview.schemes.ResidueProperties.codonHash2.put ("ATG", "M"); -jalview.schemes.ResidueProperties.codonHash2.put ("CTA", "L"); -jalview.schemes.ResidueProperties.codonHash2.put ("CTG", "L"); -jalview.schemes.ResidueProperties.codonHash2.put ("CTC", "L"); -jalview.schemes.ResidueProperties.codonHash2.put ("CTT", "L"); -jalview.schemes.ResidueProperties.codonHash2.put ("TTA", "L"); -jalview.schemes.ResidueProperties.codonHash2.put ("TTG", "L"); -jalview.schemes.ResidueProperties.codonHash2.put ("GTA", "V"); -jalview.schemes.ResidueProperties.codonHash2.put ("GTG", "V"); -jalview.schemes.ResidueProperties.codonHash2.put ("GTC", "V"); -jalview.schemes.ResidueProperties.codonHash2.put ("GTT", "V"); -jalview.schemes.ResidueProperties.codonHash2.put ("TTC", "F"); -jalview.schemes.ResidueProperties.codonHash2.put ("TTT", "F"); -jalview.schemes.ResidueProperties.buildAmbiguityCodonSet (); -}{ -jalview.schemes.ResidueProperties.Lys.add ("AAA"); -jalview.schemes.ResidueProperties.Lys.add ("AAG"); -jalview.schemes.ResidueProperties.Asn.add ("AAC"); -jalview.schemes.ResidueProperties.Asn.add ("AAT"); -jalview.schemes.ResidueProperties.Gln.add ("CAA"); -jalview.schemes.ResidueProperties.Gln.add ("CAG"); -jalview.schemes.ResidueProperties.His.add ("CAC"); -jalview.schemes.ResidueProperties.His.add ("CAT"); -jalview.schemes.ResidueProperties.Glu.add ("GAA"); -jalview.schemes.ResidueProperties.Glu.add ("GAG"); -jalview.schemes.ResidueProperties.Asp.add ("GAC"); -jalview.schemes.ResidueProperties.Asp.add ("GAT"); -jalview.schemes.ResidueProperties.Tyr.add ("TAC"); -jalview.schemes.ResidueProperties.Tyr.add ("TAT"); -jalview.schemes.ResidueProperties.Thr.add ("ACA"); -jalview.schemes.ResidueProperties.Thr.add ("ACG"); -jalview.schemes.ResidueProperties.Thr.add ("ACC"); -jalview.schemes.ResidueProperties.Thr.add ("ACT"); -jalview.schemes.ResidueProperties.Pro.add ("CCA"); -jalview.schemes.ResidueProperties.Pro.add ("CCG"); -jalview.schemes.ResidueProperties.Pro.add ("CCC"); -jalview.schemes.ResidueProperties.Pro.add ("CCT"); -jalview.schemes.ResidueProperties.Ala.add ("GCA"); -jalview.schemes.ResidueProperties.Ala.add ("GCG"); -jalview.schemes.ResidueProperties.Ala.add ("GCC"); -jalview.schemes.ResidueProperties.Ala.add ("GCT"); -jalview.schemes.ResidueProperties.Ser.add ("TCA"); -jalview.schemes.ResidueProperties.Ser.add ("TCG"); -jalview.schemes.ResidueProperties.Ser.add ("TCC"); -jalview.schemes.ResidueProperties.Ser.add ("TCT"); -jalview.schemes.ResidueProperties.Ser.add ("AGC"); -jalview.schemes.ResidueProperties.Ser.add ("AGT"); -jalview.schemes.ResidueProperties.Arg.add ("AGA"); -jalview.schemes.ResidueProperties.Arg.add ("AGG"); -jalview.schemes.ResidueProperties.Arg.add ("CGA"); -jalview.schemes.ResidueProperties.Arg.add ("CGG"); -jalview.schemes.ResidueProperties.Arg.add ("CGC"); -jalview.schemes.ResidueProperties.Arg.add ("CGT"); -jalview.schemes.ResidueProperties.Gly.add ("GGA"); -jalview.schemes.ResidueProperties.Gly.add ("GGG"); -jalview.schemes.ResidueProperties.Gly.add ("GGC"); -jalview.schemes.ResidueProperties.Gly.add ("GGT"); -jalview.schemes.ResidueProperties.STOP.add ("TGA"); -jalview.schemes.ResidueProperties.STOP.add ("TAA"); -jalview.schemes.ResidueProperties.STOP.add ("TAG"); -jalview.schemes.ResidueProperties.Trp.add ("TGG"); -jalview.schemes.ResidueProperties.Cys.add ("TGC"); -jalview.schemes.ResidueProperties.Cys.add ("TGT"); -jalview.schemes.ResidueProperties.Ile.add ("ATA"); -jalview.schemes.ResidueProperties.Ile.add ("ATC"); -jalview.schemes.ResidueProperties.Ile.add ("ATT"); -jalview.schemes.ResidueProperties.Met.add ("ATG"); -jalview.schemes.ResidueProperties.Leu.add ("CTA"); -jalview.schemes.ResidueProperties.Leu.add ("CTG"); -jalview.schemes.ResidueProperties.Leu.add ("CTC"); -jalview.schemes.ResidueProperties.Leu.add ("CTT"); -jalview.schemes.ResidueProperties.Leu.add ("TTA"); -jalview.schemes.ResidueProperties.Leu.add ("TTG"); -jalview.schemes.ResidueProperties.Val.add ("GTA"); -jalview.schemes.ResidueProperties.Val.add ("GTG"); -jalview.schemes.ResidueProperties.Val.add ("GTC"); -jalview.schemes.ResidueProperties.Val.add ("GTT"); -jalview.schemes.ResidueProperties.Phe.add ("TTC"); -jalview.schemes.ResidueProperties.Phe.add ("TTT"); -}c$.propHash = c$.prototype.propHash = new java.util.Hashtable (); -c$.hydrophobic = c$.prototype.hydrophobic = new java.util.Hashtable (); -c$.polar = c$.prototype.polar = new java.util.Hashtable (); -c$.small = c$.prototype.small = new java.util.Hashtable (); -c$.positive = c$.prototype.positive = new java.util.Hashtable (); -c$.negative = c$.prototype.negative = new java.util.Hashtable (); -c$.charged = c$.prototype.charged = new java.util.Hashtable (); -c$.aromatic = c$.prototype.aromatic = new java.util.Hashtable (); -c$.aliphatic = c$.prototype.aliphatic = new java.util.Hashtable (); -c$.tiny = c$.prototype.tiny = new java.util.Hashtable (); -c$.proline = c$.prototype.proline = new java.util.Hashtable (); -{ -jalview.schemes.ResidueProperties.hydrophobic.put ("I", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("L", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("V", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("C", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("A", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("G", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("M", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("F", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("Y", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("W", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("H", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("K", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("X", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("*", new Integer (1)); -jalview.schemes.ResidueProperties.hydrophobic.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("D", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.hydrophobic.put ("P", new Integer (0)); -}{ -jalview.schemes.ResidueProperties.polar.put ("Y", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("W", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("H", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("K", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("R", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("E", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("Q", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("D", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("N", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("S", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("T", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("X", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("*", new Integer (1)); -jalview.schemes.ResidueProperties.polar.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.polar.put ("P", new Integer (0)); -}{ -jalview.schemes.ResidueProperties.small.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("V", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("C", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("A", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("G", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("H", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("K", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.small.put ("D", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("N", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("S", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("T", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("P", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.small.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.positive.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("H", new Integer (1)); -jalview.schemes.ResidueProperties.positive.put ("K", new Integer (1)); -jalview.schemes.ResidueProperties.positive.put ("R", new Integer (1)); -jalview.schemes.ResidueProperties.positive.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("D", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("P", new Integer (0)); -jalview.schemes.ResidueProperties.positive.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.positive.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.negative.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("H", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("K", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("E", new Integer (1)); -jalview.schemes.ResidueProperties.negative.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("D", new Integer (1)); -jalview.schemes.ResidueProperties.negative.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("P", new Integer (0)); -jalview.schemes.ResidueProperties.negative.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.negative.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.charged.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("H", new Integer (1)); -jalview.schemes.ResidueProperties.charged.put ("K", new Integer (1)); -jalview.schemes.ResidueProperties.charged.put ("R", new Integer (1)); -jalview.schemes.ResidueProperties.charged.put ("E", new Integer (1)); -jalview.schemes.ResidueProperties.charged.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("D", new Integer (1)); -jalview.schemes.ResidueProperties.charged.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("P", new Integer (0)); -jalview.schemes.ResidueProperties.charged.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.charged.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.aromatic.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("F", new Integer (1)); -jalview.schemes.ResidueProperties.aromatic.put ("Y", new Integer (1)); -jalview.schemes.ResidueProperties.aromatic.put ("W", new Integer (1)); -jalview.schemes.ResidueProperties.aromatic.put ("H", new Integer (1)); -jalview.schemes.ResidueProperties.aromatic.put ("K", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("D", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("P", new Integer (0)); -jalview.schemes.ResidueProperties.aromatic.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.aromatic.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.aliphatic.put ("I", new Integer (1)); -jalview.schemes.ResidueProperties.aliphatic.put ("L", new Integer (1)); -jalview.schemes.ResidueProperties.aliphatic.put ("V", new Integer (1)); -jalview.schemes.ResidueProperties.aliphatic.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("H", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("K", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("D", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("P", new Integer (0)); -jalview.schemes.ResidueProperties.aliphatic.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.aliphatic.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.tiny.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("A", new Integer (1)); -jalview.schemes.ResidueProperties.tiny.put ("G", new Integer (1)); -jalview.schemes.ResidueProperties.tiny.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("H", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("K", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("D", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("S", new Integer (1)); -jalview.schemes.ResidueProperties.tiny.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("P", new Integer (0)); -jalview.schemes.ResidueProperties.tiny.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.tiny.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.proline.put ("I", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("L", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("V", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("C", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("A", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("G", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("M", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("F", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("Y", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("W", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("H", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("K", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("R", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("E", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("Q", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("D", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("N", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("S", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("T", new Integer (0)); -jalview.schemes.ResidueProperties.proline.put ("P", new Integer (1)); -jalview.schemes.ResidueProperties.proline.put ("-", new Integer (1)); -jalview.schemes.ResidueProperties.proline.put ("*", new Integer (1)); -}{ -jalview.schemes.ResidueProperties.propHash.put ("hydrophobic", jalview.schemes.ResidueProperties.hydrophobic); -jalview.schemes.ResidueProperties.propHash.put ("small", jalview.schemes.ResidueProperties.small); -jalview.schemes.ResidueProperties.propHash.put ("positive", jalview.schemes.ResidueProperties.positive); -jalview.schemes.ResidueProperties.propHash.put ("negative", jalview.schemes.ResidueProperties.negative); -jalview.schemes.ResidueProperties.propHash.put ("charged", jalview.schemes.ResidueProperties.charged); -jalview.schemes.ResidueProperties.propHash.put ("aromatic", jalview.schemes.ResidueProperties.aromatic); -jalview.schemes.ResidueProperties.propHash.put ("aliphatic", jalview.schemes.ResidueProperties.aliphatic); -jalview.schemes.ResidueProperties.propHash.put ("tiny", jalview.schemes.ResidueProperties.tiny); -jalview.schemes.ResidueProperties.propHash.put ("proline", jalview.schemes.ResidueProperties.proline); -jalview.schemes.ResidueProperties.propHash.put ("polar", jalview.schemes.ResidueProperties.polar); -}{ -var propMatrixF = Clazz.newIntArray (23, 23, 0); -var propMatrixPos = Clazz.newIntArray (23, 23, 0); -var propMatrixEpos = Clazz.newIntArray (23, 23, 0); -for (var i = 0; i < 23; i++) { -var maxF = 0; -var maxP = 0; -var maxEP = 0; -var ic = ""; -if (jalview.schemes.ResidueProperties.aa.length > i) { -ic += jalview.schemes.ResidueProperties.aa[i]; -} else { -ic = "-"; -}for (var j = i + 1; j < 23; j++) { -var jc = ""; -if (jalview.schemes.ResidueProperties.aa.length > j) { -jc += jalview.schemes.ResidueProperties.aa[j]; -} else { -jc = "-"; -}propMatrixF[i][j] = 0; -propMatrixPos[i][j] = 0; -propMatrixEpos[i][j] = 0; -for (var en = jalview.schemes.ResidueProperties.propHash.keys (); en.hasMoreElements (); ) { -var ph = en.nextElement (); -var pph = jalview.schemes.ResidueProperties.propHash.get (ph); -if (pph.get (ic) != null && pph.get (jc) != null) { -var icp = pph.get (ic).intValue (); -var jcp = pph.get (jc).intValue (); -propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0; -propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0; -propMatrixF[i][j] += icp == jcp ? 2 : 0; -propMatrixF[j][i] += icp == jcp ? 2 : 0; -propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0; -propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0; -}} -if (maxF < propMatrixF[i][j]) { -maxF = propMatrixF[i][j]; -}if (maxP < propMatrixPos[i][j]) { -maxP = propMatrixPos[i][j]; -}if (maxEP < propMatrixEpos[i][j]) { -maxEP = propMatrixEpos[i][j]; -}} -propMatrixF[i][i] = maxF; -propMatrixPos[i][i] = maxP; -propMatrixEpos[i][i] = maxEP; -} -jalview.schemes.ResidueProperties.scoreMatrices.put ("PID", new jalview.analysis.scoremodels.PIDScoreModel ()); -jalview.schemes.ResidueProperties.scoreMatrices.put ("Displayed Features", new jalview.analysis.scoremodels.FeatureScoreModel ()); -}Clazz.defineStatics (c$, -"toDssp3State", null); -{ -jalview.schemes.ResidueProperties.toDssp3State = new java.util.Hashtable (); -jalview.schemes.ResidueProperties.toDssp3State.put ("H", "H"); -jalview.schemes.ResidueProperties.toDssp3State.put ("E", "E"); -jalview.schemes.ResidueProperties.toDssp3State.put ("C", " "); -jalview.schemes.ResidueProperties.toDssp3State.put (" ", " "); -jalview.schemes.ResidueProperties.toDssp3State.put ("T", " "); -jalview.schemes.ResidueProperties.toDssp3State.put ("B", "E"); -jalview.schemes.ResidueProperties.toDssp3State.put ("G", "H"); -jalview.schemes.ResidueProperties.toDssp3State.put ("I", "H"); -jalview.schemes.ResidueProperties.toDssp3State.put ("X", " "); -}Clazz.defineStatics (c$, -"toRNAssState", null, -"RNAcloseParen", Clazz.newBooleanArray (255, false)); -{ -jalview.schemes.ResidueProperties.toRNAssState = new java.util.Hashtable (); -jalview.schemes.ResidueProperties.toRNAssState.put (")", "("); -jalview.schemes.ResidueProperties.toRNAssState.put ("(", "("); -jalview.schemes.ResidueProperties.toRNAssState.put ("]", "["); -jalview.schemes.ResidueProperties.toRNAssState.put ("[", "["); -jalview.schemes.ResidueProperties.toRNAssState.put ("{", "{"); -jalview.schemes.ResidueProperties.toRNAssState.put ("}", "{"); -jalview.schemes.ResidueProperties.toRNAssState.put (">", ">"); -jalview.schemes.ResidueProperties.toRNAssState.put ("<", ">"); -jalview.schemes.ResidueProperties.toRNAssState.put ("A", "A"); -jalview.schemes.ResidueProperties.toRNAssState.put ("a", "A"); -jalview.schemes.ResidueProperties.toRNAssState.put ("B", "B"); -jalview.schemes.ResidueProperties.toRNAssState.put ("b", "B"); -jalview.schemes.ResidueProperties.toRNAssState.put ("C", "C"); -jalview.schemes.ResidueProperties.toRNAssState.put ("c", "C"); -jalview.schemes.ResidueProperties.toRNAssState.put ("D", "D"); -jalview.schemes.ResidueProperties.toRNAssState.put ("d", "D"); -jalview.schemes.ResidueProperties.toRNAssState.put ("E", "E"); -jalview.schemes.ResidueProperties.toRNAssState.put ("e", "E"); -jalview.schemes.ResidueProperties.toRNAssState.put ("F", "F"); -jalview.schemes.ResidueProperties.toRNAssState.put ("f", "F"); -jalview.schemes.ResidueProperties.toRNAssState.put ("G", "G"); -jalview.schemes.ResidueProperties.toRNAssState.put ("g", "G"); -jalview.schemes.ResidueProperties.toRNAssState.put ("H", "H"); -jalview.schemes.ResidueProperties.toRNAssState.put ("h", "H"); -jalview.schemes.ResidueProperties.toRNAssState.put ("I", "I"); -jalview.schemes.ResidueProperties.toRNAssState.put ("i", "I"); -jalview.schemes.ResidueProperties.toRNAssState.put ("J", "J"); -jalview.schemes.ResidueProperties.toRNAssState.put ("j", "J"); -jalview.schemes.ResidueProperties.toRNAssState.put ("K", "K"); -jalview.schemes.ResidueProperties.toRNAssState.put ("k", "K"); -jalview.schemes.ResidueProperties.toRNAssState.put ("L", "L"); -jalview.schemes.ResidueProperties.toRNAssState.put ("l", "L"); -jalview.schemes.ResidueProperties.toRNAssState.put ("M", "M"); -jalview.schemes.ResidueProperties.toRNAssState.put ("m", "M"); -jalview.schemes.ResidueProperties.toRNAssState.put ("N", "N"); -jalview.schemes.ResidueProperties.toRNAssState.put ("n", "N"); -jalview.schemes.ResidueProperties.toRNAssState.put ("O", "O"); -jalview.schemes.ResidueProperties.toRNAssState.put ("o", "O"); -jalview.schemes.ResidueProperties.toRNAssState.put ("P", "P"); -jalview.schemes.ResidueProperties.toRNAssState.put ("p", "P"); -jalview.schemes.ResidueProperties.toRNAssState.put ("Q", "Q"); -jalview.schemes.ResidueProperties.toRNAssState.put ("q", "Q"); -jalview.schemes.ResidueProperties.toRNAssState.put ("R", "R"); -jalview.schemes.ResidueProperties.toRNAssState.put ("r", "R"); -jalview.schemes.ResidueProperties.toRNAssState.put ("S", "S"); -jalview.schemes.ResidueProperties.toRNAssState.put ("s", "S"); -jalview.schemes.ResidueProperties.toRNAssState.put ("T", "T"); -jalview.schemes.ResidueProperties.toRNAssState.put ("t", "T"); -jalview.schemes.ResidueProperties.toRNAssState.put ("U", "U"); -jalview.schemes.ResidueProperties.toRNAssState.put ("u", "U"); -jalview.schemes.ResidueProperties.toRNAssState.put ("V", "V"); -jalview.schemes.ResidueProperties.toRNAssState.put ("v", "V"); -jalview.schemes.ResidueProperties.toRNAssState.put ("W", "W"); -jalview.schemes.ResidueProperties.toRNAssState.put ("w", "W"); -jalview.schemes.ResidueProperties.toRNAssState.put ("X", "X"); -jalview.schemes.ResidueProperties.toRNAssState.put ("x", "X"); -jalview.schemes.ResidueProperties.toRNAssState.put ("Y", "Y"); -jalview.schemes.ResidueProperties.toRNAssState.put ("y", "Y"); -jalview.schemes.ResidueProperties.toRNAssState.put ("Z", "Z"); -jalview.schemes.ResidueProperties.toRNAssState.put ("z", "Z"); -for (var p = 0; p < jalview.schemes.ResidueProperties.RNAcloseParen.length; p++) { -jalview.schemes.ResidueProperties.RNAcloseParen[p] = false; -} -for (var k, $k = jalview.schemes.ResidueProperties.toRNAssState.keySet ().iterator (); $k.hasNext () && ((k = $k.next ()) || true);) { -jalview.schemes.ResidueProperties.RNAcloseParen[k.charCodeAt (0)] = k.charAt (0) != jalview.schemes.ResidueProperties.toRNAssState.get (k).charAt (0); -} -}}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.analysis.scoremodels.FeatureScoreModel", "$.PIDScoreModel", "jalview.schemes.ScoreMatrix", "java.awt.Color", "java.util.ArrayList", "$.HashMap", "$.Hashtable", "$.Vector"], "jalview.schemes.ResidueProperties", ["java.lang.StringBuffer"], function () { +c$ = Clazz.declareType (jalview.schemes, "ResidueProperties"); +c$.buildAmbiguityCodonSet = Clazz.defineMethod (c$, "buildAmbiguityCodonSet", +function () { +if (jalview.schemes.ResidueProperties._ambiguityCodes.size () > 0) { +System.err.println ("Ignoring multiple calls to buildAmbiguityCodonSet"); +return; +}for (var acode, $acode = jalview.schemes.ResidueProperties.ambiguityCodes.entrySet ().iterator (); $acode.hasNext () && ((acode = $acode.next ()) || true);) { +for (var r, $r = 0, $$r = acode.getValue (); $r < $$r.length && ((r = $$r[$r]) || true); $r++) { +var codesfor = jalview.schemes.ResidueProperties._ambiguityCodes.get (r); +if (codesfor == null) { +jalview.schemes.ResidueProperties._ambiguityCodes.put (r, codesfor = new java.util.ArrayList ()); +}if (!codesfor.contains (acode.getKey ())) { +codesfor.add (acode.getKey ()); +} else { +System.err.println ("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for " + acode.getKey () + " in residue " + r); +}} +} +var unambcodons = jalview.schemes.ResidueProperties.codonHash2.keySet ().toArray ( new Array (jalview.schemes.ResidueProperties.codonHash2.size ())); +for (var codon, $codon = 0, $$codon = unambcodons; $codon < $$codon.length && ((codon = $$codon[$codon]) || true); $codon++) { +var residue = jalview.schemes.ResidueProperties.codonHash2.get (codon); +var acodon = new Array (codon.length); +for (var i = 0, iSize = codon.length; i < iSize; i++) { +var _ac = "" + codon.charAt (i); +var acodes = jalview.schemes.ResidueProperties._ambiguityCodes.get (_ac); +if (acodes != null) { +acodon[i] = acodes.toArray ( new Array (acodes.size ())); +} else { +acodon[i] = Clazz.newArray (-1, []); +}} +var tpos = Clazz.newIntArray (codon.length, 0); +var cpos = Clazz.newIntArray (codon.length, 0); +for (var i = 0; i < tpos.length; i++) { +tpos[i] = -1; +} +tpos[acodon.length - 1] = 0; +var ipos; +var j; +while (tpos[0] < acodon[0].length) { +var allres = Clazz.newCharArray (tpos.length, '\0'); +var _acodon = ""; +var _anuc; +for (ipos = 0; ipos < tpos.length; ipos++) { +if (acodon[ipos].length == 0 || tpos[ipos] < 0) { +_acodon += codon.charAt (ipos); +allres[ipos] = Clazz.newCharArray (-1, [codon.charAt (ipos)]); +} else { +_acodon += acodon[ipos][tpos[ipos]]; +var altbase = jalview.schemes.ResidueProperties.ambiguityCodes.get (acodon[ipos][tpos[ipos]]); +allres[ipos] = Clazz.newCharArray (altbase.length, '\0'); +j = 0; +for (var ab, $ab = 0, $$ab = altbase; $ab < $$ab.length && ((ab = $$ab[$ab]) || true); $ab++) { +allres[ipos][j++] = ab.charAt (0); +} +}} +for (ipos = 0; ipos < cpos.length; ipos++) { +cpos[ipos] = 0; +} +var valid = true; +do { +var _codon = ""; +for (j = 0; j < cpos.length; j++) { +_codon += allres[j][cpos[j]]; +} +var tr = jalview.schemes.ResidueProperties.codonHash2.get (_codon); +if (valid = (tr != null && tr.equals (residue))) { +ipos = acodon.length - 1; +while (++cpos[ipos] >= allres[ipos].length && ipos > 0) { +cpos[ipos] = 0; +ipos--; +} +}} while (valid && cpos[0] < allres[0].length); +if (valid) { +jalview.schemes.ResidueProperties.codonHash2.put (_acodon, residue); +} else { +}ipos = acodon.length - 1; +while (++tpos[ipos] >= acodon[ipos].length && ipos > 0) { +tpos[ipos] = -1; +ipos--; +} +} +} +}); +c$.getHydmax = Clazz.defineMethod (c$, "getHydmax", +function () { +return 4.5; +}); +c$.getHydmin = Clazz.defineMethod (c$, "getHydmin", +function () { +return -3.9; +}); +c$.getHyd = Clazz.defineMethod (c$, "getHyd", +function () { +return jalview.schemes.ResidueProperties.hyd; +}); +c$.getAA3Hash = Clazz.defineMethod (c$, "getAA3Hash", +function () { +return jalview.schemes.ResidueProperties.aa3Hash; +}); +c$.getDNA = Clazz.defineMethod (c$, "getDNA", +function () { +return jalview.schemes.ResidueProperties.DNA; +}); +c$.getBLOSUM62 = Clazz.defineMethod (c$, "getBLOSUM62", +function () { +return jalview.schemes.ResidueProperties.BLOSUM62; +}); +c$.getPAM250 = Clazz.defineMethod (c$, "getPAM250", +function (A1, A2) { +return jalview.schemes.ResidueProperties.getPAM250 (A1.charAt (0), A2.charAt (0)); +}, "~S,~S"); +c$.getBLOSUM62 = Clazz.defineMethod (c$, "getBLOSUM62", +function (c1, c2) { +var pog = 0; +try { +var a = jalview.schemes.ResidueProperties.aaIndex[c1.charCodeAt (0)]; +var b = jalview.schemes.ResidueProperties.aaIndex[c2.charCodeAt (0)]; +pog = jalview.schemes.ResidueProperties.BLOSUM62[a][b]; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +return pog; +}, "~S,~S"); +c$.getCodons = Clazz.defineMethod (c$, "getCodons", +function (res) { +if (jalview.schemes.ResidueProperties.codonHash.containsKey (res)) { +return jalview.schemes.ResidueProperties.codonHash.get (res); +}return null; +}, "~S"); +c$.codonTranslate = Clazz.defineMethod (c$, "codonTranslate", +function (lccodon) { +if (false) { +return jalview.schemes.ResidueProperties._codonTranslate (lccodon); +}var cdn = jalview.schemes.ResidueProperties.codonHash2.get (lccodon.toUpperCase ()); +if (cdn != null && cdn.equals ("*")) { +return "STOP"; +}return cdn; +}, "~S"); +c$._codonTranslate = Clazz.defineMethod (c$, "_codonTranslate", +function (lccodon) { +var codon = lccodon.toUpperCase (); +if (codon.indexOf ('X') > -1 || codon.indexOf ('N') > -1) { +return "X"; +}for (var key, $key = jalview.schemes.ResidueProperties.codonHash.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { +if (jalview.schemes.ResidueProperties.codonHash.get (key).contains (codon)) { +return key; +}} +return null; +}, "~S"); +c$.getDefaultPeptideMatrix = Clazz.defineMethod (c$, "getDefaultPeptideMatrix", +function () { +return jalview.schemes.ResidueProperties.getBLOSUM62 (); +}); +c$.getDefaultDnaMatrix = Clazz.defineMethod (c$, "getDefaultDnaMatrix", +function () { +return jalview.schemes.ResidueProperties.getDNA (); +}); +c$.getScoreMatrix = Clazz.defineMethod (c$, "getScoreMatrix", +function (pwtype) { +var val = jalview.schemes.ResidueProperties.scoreMatrices.get (pwtype); +if (val != null && Clazz.instanceOf (val, jalview.schemes.ScoreMatrix)) { +return val; +}return null; +}, "~S"); +c$.getScoreModel = Clazz.defineMethod (c$, "getScoreModel", +function (pwtype) { +return jalview.schemes.ResidueProperties.scoreMatrices.get (pwtype); +}, "~S"); +c$.getPAM250 = Clazz.defineMethod (c$, "getPAM250", +function (c, d) { +var a = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]; +var b = jalview.schemes.ResidueProperties.aaIndex[d.charCodeAt (0)]; +var pog = jalview.schemes.ResidueProperties.PAM250[a][b]; +return pog; +}, "~S,~S"); +c$.getDssp3state = Clazz.defineMethod (c$, "getDssp3state", +function (ssstring) { +if (ssstring == null) { +return null; +}var ss = new StringBuffer (); +for (var i = 0; i < ssstring.length; i++) { +var ssc = ssstring.substring (i, i + 1); +if (jalview.schemes.ResidueProperties.toDssp3State.containsKey (ssc)) { +ss.append (jalview.schemes.ResidueProperties.toDssp3State.get (ssc)); +} else { +ss.append (" "); +}} +return ss.toString (); +}, "~S"); +c$.getRNASecStrucState = Clazz.defineMethod (c$, "getRNASecStrucState", +function (ssstring) { +if (ssstring == null) { +return null; +}var ss = new StringBuffer (); +for (var i = 0; i < ssstring.length; i++) { +var ssc = ssstring.substring (i, i + 1); +if (jalview.schemes.ResidueProperties.toRNAssState.containsKey (ssc)) { +ss.append (ssc); +} else { +ss.append (" "); +}} +return ss.toString (); +}, "~S"); +c$.isCloseParenRNA = Clazz.defineMethod (c$, "isCloseParenRNA", +function (dc) { +return jalview.schemes.ResidueProperties.RNAcloseParen[dc.charCodeAt (0)]; +}, "~S"); +c$.getResidues = Clazz.defineMethod (c$, "getResidues", +function (nucleotide, includeAmbiguous) { +var result = new java.util.ArrayList (); +if (nucleotide) { +for (var nuc, $nuc = jalview.schemes.ResidueProperties.nucleotideName.keySet ().iterator (); $nuc.hasNext () && ((nuc = $nuc.next ()) || true);) { +var val = jalview.schemes.ResidueProperties.nucleotideIndex[nuc.charCodeAt (0)]; +if ((!includeAmbiguous && val > 4) || (val >= 10)) { +continue; +}nuc = nuc.toUpperCase (); +if (!result.contains (nuc)) { +result.add (nuc); +}} +} else { +for (var res, $res = jalview.schemes.ResidueProperties.aa3Hash.keySet ().iterator (); $res.hasNext () && ((res = $res.next ()) || true);) { +var index = jalview.schemes.ResidueProperties.aa3Hash.get (res).intValue (); +if ((!includeAmbiguous && index >= 20) || index >= 23) { +continue; +}res = res.toUpperCase (); +if (!result.contains (res)) { +result.add (res); +}} +}return result; +}, "~B,~B"); +c$.scoreMatrices = c$.prototype.scoreMatrices = new java.util.Hashtable (); +Clazz.defineStatics (c$, +"aaIndex", null, +"nucleotideIndex", null, +"purinepyrimidineIndex", null); +c$.aa3Hash = c$.prototype.aa3Hash = new java.util.HashMap (); +c$.aa2Triplet = c$.prototype.aa2Triplet = new java.util.HashMap (); +c$.nucleotideName = c$.prototype.nucleotideName = new java.util.HashMap (); +{ +jalview.schemes.ResidueProperties.aaIndex = Clazz.newIntArray (255, 0); +for (var i = 0; i < 255; i++) { +jalview.schemes.ResidueProperties.aaIndex[i] = 23; +} +jalview.schemes.ResidueProperties.aaIndex['A'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.aaIndex['R'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.aaIndex['N'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.aaIndex['D'.charCodeAt (0)] = 3; +jalview.schemes.ResidueProperties.aaIndex['C'.charCodeAt (0)] = 4; +jalview.schemes.ResidueProperties.aaIndex['Q'.charCodeAt (0)] = 5; +jalview.schemes.ResidueProperties.aaIndex['E'.charCodeAt (0)] = 6; +jalview.schemes.ResidueProperties.aaIndex['G'.charCodeAt (0)] = 7; +jalview.schemes.ResidueProperties.aaIndex['H'.charCodeAt (0)] = 8; +jalview.schemes.ResidueProperties.aaIndex['I'.charCodeAt (0)] = 9; +jalview.schemes.ResidueProperties.aaIndex['L'.charCodeAt (0)] = 10; +jalview.schemes.ResidueProperties.aaIndex['K'.charCodeAt (0)] = 11; +jalview.schemes.ResidueProperties.aaIndex['M'.charCodeAt (0)] = 12; +jalview.schemes.ResidueProperties.aaIndex['F'.charCodeAt (0)] = 13; +jalview.schemes.ResidueProperties.aaIndex['P'.charCodeAt (0)] = 14; +jalview.schemes.ResidueProperties.aaIndex['S'.charCodeAt (0)] = 15; +jalview.schemes.ResidueProperties.aaIndex['T'.charCodeAt (0)] = 16; +jalview.schemes.ResidueProperties.aaIndex['W'.charCodeAt (0)] = 17; +jalview.schemes.ResidueProperties.aaIndex['Y'.charCodeAt (0)] = 18; +jalview.schemes.ResidueProperties.aaIndex['V'.charCodeAt (0)] = 19; +jalview.schemes.ResidueProperties.aaIndex['B'.charCodeAt (0)] = 20; +jalview.schemes.ResidueProperties.aaIndex['Z'.charCodeAt (0)] = 21; +jalview.schemes.ResidueProperties.aaIndex['X'.charCodeAt (0)] = 22; +jalview.schemes.ResidueProperties.aaIndex['U'.charCodeAt (0)] = 22; +jalview.schemes.ResidueProperties.aaIndex['a'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.aaIndex['r'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.aaIndex['n'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.aaIndex['d'.charCodeAt (0)] = 3; +jalview.schemes.ResidueProperties.aaIndex['c'.charCodeAt (0)] = 4; +jalview.schemes.ResidueProperties.aaIndex['q'.charCodeAt (0)] = 5; +jalview.schemes.ResidueProperties.aaIndex['e'.charCodeAt (0)] = 6; +jalview.schemes.ResidueProperties.aaIndex['g'.charCodeAt (0)] = 7; +jalview.schemes.ResidueProperties.aaIndex['h'.charCodeAt (0)] = 8; +jalview.schemes.ResidueProperties.aaIndex['i'.charCodeAt (0)] = 9; +jalview.schemes.ResidueProperties.aaIndex['l'.charCodeAt (0)] = 10; +jalview.schemes.ResidueProperties.aaIndex['k'.charCodeAt (0)] = 11; +jalview.schemes.ResidueProperties.aaIndex['m'.charCodeAt (0)] = 12; +jalview.schemes.ResidueProperties.aaIndex['f'.charCodeAt (0)] = 13; +jalview.schemes.ResidueProperties.aaIndex['p'.charCodeAt (0)] = 14; +jalview.schemes.ResidueProperties.aaIndex['s'.charCodeAt (0)] = 15; +jalview.schemes.ResidueProperties.aaIndex['t'.charCodeAt (0)] = 16; +jalview.schemes.ResidueProperties.aaIndex['w'.charCodeAt (0)] = 17; +jalview.schemes.ResidueProperties.aaIndex['y'.charCodeAt (0)] = 18; +jalview.schemes.ResidueProperties.aaIndex['v'.charCodeAt (0)] = 19; +jalview.schemes.ResidueProperties.aaIndex['b'.charCodeAt (0)] = 20; +jalview.schemes.ResidueProperties.aaIndex['z'.charCodeAt (0)] = 21; +jalview.schemes.ResidueProperties.aaIndex['x'.charCodeAt (0)] = 22; +jalview.schemes.ResidueProperties.aaIndex['u'.charCodeAt (0)] = 22; +}Clazz.defineStatics (c$, +"maxProteinIndex", 23, +"maxNucleotideIndex", 10); +{ +jalview.schemes.ResidueProperties.nucleotideIndex = Clazz.newIntArray (255, 0); +for (var i = 0; i < 255; i++) { +jalview.schemes.ResidueProperties.nucleotideIndex[i] = 10; +} +jalview.schemes.ResidueProperties.nucleotideIndex['A'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.nucleotideIndex['a'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.nucleotideIndex['C'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.nucleotideIndex['c'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.nucleotideIndex['G'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.nucleotideIndex['g'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.nucleotideIndex['T'.charCodeAt (0)] = 3; +jalview.schemes.ResidueProperties.nucleotideIndex['t'.charCodeAt (0)] = 3; +jalview.schemes.ResidueProperties.nucleotideIndex['U'.charCodeAt (0)] = 4; +jalview.schemes.ResidueProperties.nucleotideIndex['u'.charCodeAt (0)] = 4; +jalview.schemes.ResidueProperties.nucleotideIndex['I'.charCodeAt (0)] = 5; +jalview.schemes.ResidueProperties.nucleotideIndex['i'.charCodeAt (0)] = 5; +jalview.schemes.ResidueProperties.nucleotideIndex['X'.charCodeAt (0)] = 6; +jalview.schemes.ResidueProperties.nucleotideIndex['x'.charCodeAt (0)] = 6; +jalview.schemes.ResidueProperties.nucleotideIndex['R'.charCodeAt (0)] = 7; +jalview.schemes.ResidueProperties.nucleotideIndex['r'.charCodeAt (0)] = 7; +jalview.schemes.ResidueProperties.nucleotideIndex['Y'.charCodeAt (0)] = 8; +jalview.schemes.ResidueProperties.nucleotideIndex['y'.charCodeAt (0)] = 8; +jalview.schemes.ResidueProperties.nucleotideIndex['N'.charCodeAt (0)] = 9; +jalview.schemes.ResidueProperties.nucleotideIndex['n'.charCodeAt (0)] = 9; +jalview.schemes.ResidueProperties.nucleotideName.put ("A", "Adenine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("a", "Adenine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("G", "Guanine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("g", "Guanine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("C", "Cytosine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("c", "Cytosine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("T", "Thymine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("t", "Thymine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("U", "Uracil"); +jalview.schemes.ResidueProperties.nucleotideName.put ("u", "Uracil"); +jalview.schemes.ResidueProperties.nucleotideName.put ("I", "Inosine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("i", "Inosine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("X", "Xanthine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("x", "Xanthine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("R", "Unknown Purine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("r", "Unknown Purine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("Y", "Unknown Pyrimidine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("y", "Unknown Pyrimidine"); +jalview.schemes.ResidueProperties.nucleotideName.put ("N", "Unknown"); +jalview.schemes.ResidueProperties.nucleotideName.put ("n", "Unknown"); +jalview.schemes.ResidueProperties.nucleotideName.put ("W", "Weak nucleotide (A or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("w", "Weak nucleotide (A or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("S", "Strong nucleotide (G or C)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("s", "Strong nucleotide (G or C)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("M", "Amino (A or C)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("m", "Amino (A or C)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("K", "Keto (G or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("k", "Keto (G or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("B", "Not A (G or C or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("b", "Not A (G or C or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("H", "Not G (A or C or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("h", "Not G (A or C or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("D", "Not C (A or G or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("d", "Not C (A or G or T)"); +jalview.schemes.ResidueProperties.nucleotideName.put ("V", "Not T (A or G or C"); +jalview.schemes.ResidueProperties.nucleotideName.put ("v", "Not T (A or G or C"); +}{ +jalview.schemes.ResidueProperties.purinepyrimidineIndex = Clazz.newIntArray (255, 0); +for (var i = 0; i < 255; i++) { +jalview.schemes.ResidueProperties.purinepyrimidineIndex[i] = 3; +} +jalview.schemes.ResidueProperties.purinepyrimidineIndex['A'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['a'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['C'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['c'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['G'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['g'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['T'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['t'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['U'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['u'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['I'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['i'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['X'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['x'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['R'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['r'.charCodeAt (0)] = 0; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['Y'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['y'.charCodeAt (0)] = 1; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['N'.charCodeAt (0)] = 2; +jalview.schemes.ResidueProperties.purinepyrimidineIndex['n'.charCodeAt (0)] = 2; +}{ +jalview.schemes.ResidueProperties.aa3Hash.put ("ALA", new Integer (0)); +jalview.schemes.ResidueProperties.aa3Hash.put ("ARG", new Integer (1)); +jalview.schemes.ResidueProperties.aa3Hash.put ("ASN", new Integer (2)); +jalview.schemes.ResidueProperties.aa3Hash.put ("ASP", new Integer (3)); +jalview.schemes.ResidueProperties.aa3Hash.put ("CYS", new Integer (4)); +jalview.schemes.ResidueProperties.aa3Hash.put ("GLN", new Integer (5)); +jalview.schemes.ResidueProperties.aa3Hash.put ("GLU", new Integer (6)); +jalview.schemes.ResidueProperties.aa3Hash.put ("GLY", new Integer (7)); +jalview.schemes.ResidueProperties.aa3Hash.put ("HIS", new Integer (8)); +jalview.schemes.ResidueProperties.aa3Hash.put ("ILE", new Integer (9)); +jalview.schemes.ResidueProperties.aa3Hash.put ("LEU", new Integer (10)); +jalview.schemes.ResidueProperties.aa3Hash.put ("LYS", new Integer (11)); +jalview.schemes.ResidueProperties.aa3Hash.put ("MET", new Integer (12)); +jalview.schemes.ResidueProperties.aa3Hash.put ("PHE", new Integer (13)); +jalview.schemes.ResidueProperties.aa3Hash.put ("PRO", new Integer (14)); +jalview.schemes.ResidueProperties.aa3Hash.put ("SER", new Integer (15)); +jalview.schemes.ResidueProperties.aa3Hash.put ("THR", new Integer (16)); +jalview.schemes.ResidueProperties.aa3Hash.put ("TRP", new Integer (17)); +jalview.schemes.ResidueProperties.aa3Hash.put ("TYR", new Integer (18)); +jalview.schemes.ResidueProperties.aa3Hash.put ("VAL", new Integer (19)); +jalview.schemes.ResidueProperties.aa3Hash.put ("ASX", new Integer (20)); +jalview.schemes.ResidueProperties.aa3Hash.put ("GLX", new Integer (21)); +jalview.schemes.ResidueProperties.aa3Hash.put ("XAA", new Integer (22)); +jalview.schemes.ResidueProperties.aa3Hash.put ("-", new Integer (23)); +jalview.schemes.ResidueProperties.aa3Hash.put ("*", new Integer (23)); +jalview.schemes.ResidueProperties.aa3Hash.put (".", new Integer (23)); +jalview.schemes.ResidueProperties.aa3Hash.put (" ", new Integer (23)); +jalview.schemes.ResidueProperties.aa3Hash.put ("Gap", new Integer (23)); +}{ +jalview.schemes.ResidueProperties.aa2Triplet.put ("A", "ALA"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("a", "ALA"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("R", "ARG"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("r", "ARG"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("N", "ASN"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("n", "ASN"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("D", "ASP"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("d", "ASP"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("C", "CYS"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("c", "CYS"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("Q", "GLN"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("q", "GLN"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("E", "GLU"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("e", "GLU"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("G", "GLY"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("g", "GLY"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("H", "HIS"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("h", "HIS"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("I", "ILE"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("i", "ILE"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("L", "LEU"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("l", "LEU"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("K", "LYS"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("k", "LYS"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("M", "MET"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("m", "MET"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("F", "PHE"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("f", "PHE"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("P", "PRO"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("p", "PRO"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("S", "SER"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("s", "SER"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("T", "THR"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("t", "THR"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("W", "TRP"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("w", "TRP"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("Y", "TYR"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("y", "TYR"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("V", "VAL"); +jalview.schemes.ResidueProperties.aa2Triplet.put ("v", "VAL"); +}Clazz.defineStatics (c$, +"aa", Clazz.newArray (-1, ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " "])); +c$.midBlue = c$.prototype.midBlue = new java.awt.Color (100, 100, 255); +c$.scaleColours = c$.prototype.scaleColours = new java.util.Vector (); +{ +jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (114, 0, 147)); +jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (156, 0, 98)); +jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (190, 0, 0)); +jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.red); +jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (255, 125, 0)); +jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.orange); +jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (255, 194, 85)); +jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.yellow); +jalview.schemes.ResidueProperties.scaleColours.addElement ( new java.awt.Color (255, 255, 181)); +jalview.schemes.ResidueProperties.scaleColours.addElement (java.awt.Color.white); +}c$.taylor = c$.prototype.taylor = Clazz.newArray (-1, [ new java.awt.Color (204, 255, 0), new java.awt.Color (0, 0, 255), new java.awt.Color (204, 0, 255), new java.awt.Color (255, 0, 0), new java.awt.Color (255, 255, 0), new java.awt.Color (255, 0, 204), new java.awt.Color (255, 0, 102), new java.awt.Color (255, 153, 0), new java.awt.Color (0, 102, 255), new java.awt.Color (102, 255, 0), new java.awt.Color (51, 255, 0), new java.awt.Color (102, 0, 255), new java.awt.Color (0, 255, 0), new java.awt.Color (0, 255, 102), new java.awt.Color (255, 204, 0), new java.awt.Color (255, 51, 0), new java.awt.Color (255, 102, 0), new java.awt.Color (0, 204, 255), new java.awt.Color (0, 255, 204), new java.awt.Color (153, 255, 0), java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white]); +c$.nucleotide = c$.prototype.nucleotide = Clazz.newArray (-1, [ new java.awt.Color (100, 247, 63), new java.awt.Color (255, 179, 64), new java.awt.Color (235, 65, 60), new java.awt.Color (60, 136, 238), new java.awt.Color (60, 136, 238), java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white]); +c$.purinepyrimidine = c$.prototype.purinepyrimidine = Clazz.newArray (-1, [ new java.awt.Color (255, 131, 250), new java.awt.Color (64, 224, 208), java.awt.Color.white, java.awt.Color.white]); +c$.zappo = c$.prototype.zappo = Clazz.newArray (-1, [java.awt.Color.pink, jalview.schemes.ResidueProperties.midBlue, java.awt.Color.green, java.awt.Color.red, java.awt.Color.yellow, java.awt.Color.green, java.awt.Color.red, java.awt.Color.magenta, jalview.schemes.ResidueProperties.midBlue, java.awt.Color.pink, java.awt.Color.pink, jalview.schemes.ResidueProperties.midBlue, java.awt.Color.pink, java.awt.Color.orange, java.awt.Color.magenta, java.awt.Color.green, java.awt.Color.green, java.awt.Color.orange, java.awt.Color.orange, java.awt.Color.pink, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white, java.awt.Color.white]); +Clazz.defineStatics (c$, +"hyd2", Clazz.newDoubleArray (-1, [0.62, 0.29, -0.9, -0.74, 1.19, 0.48, -0.4, 1.38, -1.5, 1.06, 0.64, -0.78, 0.12, -0.85, -2.53, -0.18, -0.05, 1.08, 0.81, 0.0, 0.26, 0.0, 0.0]), +"helix", Clazz.newDoubleArray (-1, [1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0]), +"helixmin", 0.57, +"helixmax", 1.51, +"strand", Clazz.newDoubleArray (-1, [0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0]), +"strandmin", 0.37, +"strandmax", 1.7, +"turn", Clazz.newDoubleArray (-1, [0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01, 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0]), +"turnmin", 0.47, +"turnmax", 1.56, +"buried", Clazz.newDoubleArray (-1, [1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2, 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00]), +"buriedmin", 0.05, +"buriedmax", 4.6, +"hyd", Clazz.newDoubleArray (-1, [1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0]), +"hydmax", 4.5, +"hydmin", -3.9, +"BLOSUM62", Clazz.newArray (-1, [ Clazz.newIntArray (-1, [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0, -4]), Clazz.newIntArray (-1, [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1, -4]), Clazz.newIntArray (-1, [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1, -4]), Clazz.newIntArray (-1, [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1, -4]), Clazz.newIntArray (-1, [0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2, -4]), Clazz.newIntArray (-1, [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1, -4]), Clazz.newIntArray (-1, [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1, -4]), Clazz.newIntArray (-1, [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1, -4]), Clazz.newIntArray (-1, [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1, -4]), Clazz.newIntArray (-1, [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1, -4]), Clazz.newIntArray (-1, [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1, -4]), Clazz.newIntArray (-1, [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1, -4]), Clazz.newIntArray (-1, [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1, -4]), Clazz.newIntArray (-1, [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1, -4]), Clazz.newIntArray (-1, [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2, -4]), Clazz.newIntArray (-1, [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0, -4]), Clazz.newIntArray (-1, [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0, -4]), Clazz.newIntArray (-1, [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2, -4]), Clazz.newIntArray (-1, [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1, -4]), Clazz.newIntArray (-1, [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1, -4]), Clazz.newIntArray (-1, [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1, -4]), Clazz.newIntArray (-1, [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1, -4]), Clazz.newIntArray (-1, [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1, -4]), Clazz.newIntArray (-1, [-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 1])]), +"PAM250", Clazz.newArray (-1, [ Clazz.newIntArray (-1, [2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3, 0, 0, 0, 0, -8]), Clazz.newIntArray (-1, [-2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4, -2, -1, 0, -1, -8]), Clazz.newIntArray (-1, [0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2, 2, 1, 0, -8]), Clazz.newIntArray (-1, [0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4, -2, 3, 3, -1, -8]), Clazz.newIntArray (-1, [-2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2, -8, 0, -2, -4, -5, -3, -8]), Clazz.newIntArray (-1, [0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4, -2, 1, 3, -1, -8]), Clazz.newIntArray (-1, [0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4, -2, 3, 3, -1, -8]), Clazz.newIntArray (-1, [1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5, -1, 0, 0, -1, -8]), Clazz.newIntArray (-1, [-1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0, -2, 1, 2, -1, -8]), Clazz.newIntArray (-1, [-1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5, -1, 4, -2, -2, -1, -8]), Clazz.newIntArray (-1, [-2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2, -1, 2, -3, -3, -1, -8]), Clazz.newIntArray (-1, [-1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4, -2, 1, 0, -1, -8]), Clazz.newIntArray (-1, [-1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4, -2, 2, -2, -2, -1, -8]), Clazz.newIntArray (-1, [-3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0, 7, -1, -4, -5, -2, -8]), Clazz.newIntArray (-1, [1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5, -1, -1, 0, -1, -8]), Clazz.newIntArray (-1, [1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3, -1, 0, 0, 0, -8]), Clazz.newIntArray (-1, [1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3, 0, 0, -1, 0, -8]), Clazz.newIntArray (-1, [-6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5, 17, 0, -6, -5, -6, -4, -8]), Clazz.newIntArray (-1, [-3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0, 10, -2, -3, -4, -2, -8]), Clazz.newIntArray (-1, [0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6, -2, 4, -2, -2, -1, -8]), Clazz.newIntArray (-1, [0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3, -2, 3, 2, -1, -8]), Clazz.newIntArray (-1, [0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4, -2, 2, 3, -1, -8]), Clazz.newIntArray (-1, [0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4, -2, -1, -1, -1, -1, -8]), Clazz.newIntArray (-1, [-8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 1])])); +c$.ssHash = c$.prototype.ssHash = new java.util.Hashtable (); +{ +jalview.schemes.ResidueProperties.ssHash.put ("H", java.awt.Color.magenta); +jalview.schemes.ResidueProperties.ssHash.put ("E", java.awt.Color.yellow); +jalview.schemes.ResidueProperties.ssHash.put ("-", java.awt.Color.white); +jalview.schemes.ResidueProperties.ssHash.put (".", java.awt.Color.white); +jalview.schemes.ResidueProperties.ssHash.put ("S", java.awt.Color.cyan); +jalview.schemes.ResidueProperties.ssHash.put ("T", java.awt.Color.blue); +jalview.schemes.ResidueProperties.ssHash.put ("G", java.awt.Color.pink); +jalview.schemes.ResidueProperties.ssHash.put ("I", java.awt.Color.pink); +jalview.schemes.ResidueProperties.ssHash.put ("B", java.awt.Color.yellow); +}Clazz.defineStatics (c$, +"DNA", Clazz.newArray (-1, [ Clazz.newIntArray (-1, [10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1]), Clazz.newIntArray (-1, [-8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1]), Clazz.newIntArray (-1, [-8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1]), Clazz.newIntArray (-1, [-8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1]), Clazz.newIntArray (-1, [-8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1]), Clazz.newIntArray (-1, [1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1]), Clazz.newIntArray (-1, [-8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1]), Clazz.newIntArray (-1, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])])); +{ +jalview.schemes.ResidueProperties.scoreMatrices.put ("BLOSUM62", new jalview.schemes.ScoreMatrix ("BLOSUM62", jalview.schemes.ResidueProperties.BLOSUM62, 0)); +jalview.schemes.ResidueProperties.scoreMatrices.put ("PAM250", new jalview.schemes.ScoreMatrix ("PAM250", jalview.schemes.ResidueProperties.PAM250, 0)); +jalview.schemes.ResidueProperties.scoreMatrices.put ("DNA", new jalview.schemes.ScoreMatrix ("DNA", jalview.schemes.ResidueProperties.DNA, 1)); +}c$.pidColours = c$.prototype.pidColours = Clazz.newArray (-1, [jalview.schemes.ResidueProperties.midBlue, new java.awt.Color (153, 153, 255), new java.awt.Color (204, 204, 255)]); +Clazz.defineStatics (c$, +"pidThresholds", Clazz.newFloatArray (-1, [80, 60, 40])); +c$.codonHash = c$.prototype.codonHash = new java.util.HashMap (); +c$.Lys = c$.prototype.Lys = new java.util.ArrayList (); +c$.Asn = c$.prototype.Asn = new java.util.ArrayList (); +c$.Gln = c$.prototype.Gln = new java.util.ArrayList (); +c$.His = c$.prototype.His = new java.util.ArrayList (); +c$.Glu = c$.prototype.Glu = new java.util.ArrayList (); +c$.Asp = c$.prototype.Asp = new java.util.ArrayList (); +c$.Tyr = c$.prototype.Tyr = new java.util.ArrayList (); +c$.Thr = c$.prototype.Thr = new java.util.ArrayList (); +c$.Pro = c$.prototype.Pro = new java.util.ArrayList (); +c$.Ala = c$.prototype.Ala = new java.util.ArrayList (); +c$.Ser = c$.prototype.Ser = new java.util.ArrayList (); +c$.Arg = c$.prototype.Arg = new java.util.ArrayList (); +c$.Gly = c$.prototype.Gly = new java.util.ArrayList (); +c$.Trp = c$.prototype.Trp = new java.util.ArrayList (); +c$.Cys = c$.prototype.Cys = new java.util.ArrayList (); +c$.Ile = c$.prototype.Ile = new java.util.ArrayList (); +c$.Met = c$.prototype.Met = new java.util.ArrayList (); +c$.Leu = c$.prototype.Leu = new java.util.ArrayList (); +c$.Val = c$.prototype.Val = new java.util.ArrayList (); +c$.Phe = c$.prototype.Phe = new java.util.ArrayList (); +c$.STOP = c$.prototype.STOP = new java.util.ArrayList (); +Clazz.defineStatics (c$, +"START", "ATG"); +{ +jalview.schemes.ResidueProperties.codonHash.put ("K", jalview.schemes.ResidueProperties.Lys); +jalview.schemes.ResidueProperties.codonHash.put ("N", jalview.schemes.ResidueProperties.Asn); +jalview.schemes.ResidueProperties.codonHash.put ("Q", jalview.schemes.ResidueProperties.Gln); +jalview.schemes.ResidueProperties.codonHash.put ("H", jalview.schemes.ResidueProperties.His); +jalview.schemes.ResidueProperties.codonHash.put ("E", jalview.schemes.ResidueProperties.Glu); +jalview.schemes.ResidueProperties.codonHash.put ("D", jalview.schemes.ResidueProperties.Asp); +jalview.schemes.ResidueProperties.codonHash.put ("Y", jalview.schemes.ResidueProperties.Tyr); +jalview.schemes.ResidueProperties.codonHash.put ("T", jalview.schemes.ResidueProperties.Thr); +jalview.schemes.ResidueProperties.codonHash.put ("P", jalview.schemes.ResidueProperties.Pro); +jalview.schemes.ResidueProperties.codonHash.put ("A", jalview.schemes.ResidueProperties.Ala); +jalview.schemes.ResidueProperties.codonHash.put ("S", jalview.schemes.ResidueProperties.Ser); +jalview.schemes.ResidueProperties.codonHash.put ("R", jalview.schemes.ResidueProperties.Arg); +jalview.schemes.ResidueProperties.codonHash.put ("G", jalview.schemes.ResidueProperties.Gly); +jalview.schemes.ResidueProperties.codonHash.put ("W", jalview.schemes.ResidueProperties.Trp); +jalview.schemes.ResidueProperties.codonHash.put ("C", jalview.schemes.ResidueProperties.Cys); +jalview.schemes.ResidueProperties.codonHash.put ("I", jalview.schemes.ResidueProperties.Ile); +jalview.schemes.ResidueProperties.codonHash.put ("M", jalview.schemes.ResidueProperties.Met); +jalview.schemes.ResidueProperties.codonHash.put ("L", jalview.schemes.ResidueProperties.Leu); +jalview.schemes.ResidueProperties.codonHash.put ("V", jalview.schemes.ResidueProperties.Val); +jalview.schemes.ResidueProperties.codonHash.put ("F", jalview.schemes.ResidueProperties.Phe); +jalview.schemes.ResidueProperties.codonHash.put ("STOP", jalview.schemes.ResidueProperties.STOP); +}c$.ambiguityCodes = c$.prototype.ambiguityCodes = new java.util.Hashtable (); +c$.codonHash2 = c$.prototype.codonHash2 = new java.util.Hashtable (); +c$._ambiguityCodes = c$.prototype._ambiguityCodes = new java.util.Hashtable (); +{ +jalview.schemes.ResidueProperties.ambiguityCodes.put ("R", Clazz.newArray (-1, ["A", "G"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("Y", Clazz.newArray (-1, ["T", "C"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("W", Clazz.newArray (-1, ["A", "T"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("S", Clazz.newArray (-1, ["G", "C"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("M", Clazz.newArray (-1, ["A", "C"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("K", Clazz.newArray (-1, ["G", "T"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("H", Clazz.newArray (-1, ["A", "T", "C"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("B", Clazz.newArray (-1, ["G", "T", "C"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("V", Clazz.newArray (-1, ["G", "A", "C"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("D", Clazz.newArray (-1, ["G", "A", "T"])); +jalview.schemes.ResidueProperties.ambiguityCodes.put ("N", Clazz.newArray (-1, ["G", "A", "T", "C"])); +jalview.schemes.ResidueProperties.codonHash2.put ("AAA", "K"); +jalview.schemes.ResidueProperties.codonHash2.put ("AAG", "K"); +jalview.schemes.ResidueProperties.codonHash2.put ("AAC", "N"); +jalview.schemes.ResidueProperties.codonHash2.put ("AAT", "N"); +jalview.schemes.ResidueProperties.codonHash2.put ("CAA", "Q"); +jalview.schemes.ResidueProperties.codonHash2.put ("CAG", "Q"); +jalview.schemes.ResidueProperties.codonHash2.put ("CAC", "H"); +jalview.schemes.ResidueProperties.codonHash2.put ("CAT", "H"); +jalview.schemes.ResidueProperties.codonHash2.put ("GAA", "E"); +jalview.schemes.ResidueProperties.codonHash2.put ("GAG", "E"); +jalview.schemes.ResidueProperties.codonHash2.put ("GAC", "D"); +jalview.schemes.ResidueProperties.codonHash2.put ("GAT", "D"); +jalview.schemes.ResidueProperties.codonHash2.put ("TAC", "Y"); +jalview.schemes.ResidueProperties.codonHash2.put ("TAT", "Y"); +jalview.schemes.ResidueProperties.codonHash2.put ("ACA", "T"); +jalview.schemes.ResidueProperties.codonHash2.put ("ACC", "T"); +jalview.schemes.ResidueProperties.codonHash2.put ("ACT", "T"); +jalview.schemes.ResidueProperties.codonHash2.put ("ACG", "T"); +jalview.schemes.ResidueProperties.codonHash2.put ("CCA", "P"); +jalview.schemes.ResidueProperties.codonHash2.put ("CCG", "P"); +jalview.schemes.ResidueProperties.codonHash2.put ("CCC", "P"); +jalview.schemes.ResidueProperties.codonHash2.put ("CCT", "P"); +jalview.schemes.ResidueProperties.codonHash2.put ("GCA", "A"); +jalview.schemes.ResidueProperties.codonHash2.put ("GCG", "A"); +jalview.schemes.ResidueProperties.codonHash2.put ("GCC", "A"); +jalview.schemes.ResidueProperties.codonHash2.put ("GCT", "A"); +jalview.schemes.ResidueProperties.codonHash2.put ("TCA", "S"); +jalview.schemes.ResidueProperties.codonHash2.put ("TCG", "S"); +jalview.schemes.ResidueProperties.codonHash2.put ("TCC", "S"); +jalview.schemes.ResidueProperties.codonHash2.put ("TCT", "S"); +jalview.schemes.ResidueProperties.codonHash2.put ("AGC", "S"); +jalview.schemes.ResidueProperties.codonHash2.put ("AGT", "S"); +jalview.schemes.ResidueProperties.codonHash2.put ("AGA", "R"); +jalview.schemes.ResidueProperties.codonHash2.put ("AGG", "R"); +jalview.schemes.ResidueProperties.codonHash2.put ("CGA", "R"); +jalview.schemes.ResidueProperties.codonHash2.put ("CGG", "R"); +jalview.schemes.ResidueProperties.codonHash2.put ("CGC", "R"); +jalview.schemes.ResidueProperties.codonHash2.put ("CGT", "R"); +jalview.schemes.ResidueProperties.codonHash2.put ("GGA", "G"); +jalview.schemes.ResidueProperties.codonHash2.put ("GGG", "G"); +jalview.schemes.ResidueProperties.codonHash2.put ("GGC", "G"); +jalview.schemes.ResidueProperties.codonHash2.put ("GGT", "G"); +jalview.schemes.ResidueProperties.codonHash2.put ("TGA", "*"); +jalview.schemes.ResidueProperties.codonHash2.put ("TAA", "*"); +jalview.schemes.ResidueProperties.codonHash2.put ("TAG", "*"); +jalview.schemes.ResidueProperties.codonHash2.put ("TGG", "W"); +jalview.schemes.ResidueProperties.codonHash2.put ("TGC", "C"); +jalview.schemes.ResidueProperties.codonHash2.put ("TGT", "C"); +jalview.schemes.ResidueProperties.codonHash2.put ("ATA", "I"); +jalview.schemes.ResidueProperties.codonHash2.put ("ATC", "I"); +jalview.schemes.ResidueProperties.codonHash2.put ("ATT", "I"); +jalview.schemes.ResidueProperties.codonHash2.put ("ATG", "M"); +jalview.schemes.ResidueProperties.codonHash2.put ("CTA", "L"); +jalview.schemes.ResidueProperties.codonHash2.put ("CTG", "L"); +jalview.schemes.ResidueProperties.codonHash2.put ("CTC", "L"); +jalview.schemes.ResidueProperties.codonHash2.put ("CTT", "L"); +jalview.schemes.ResidueProperties.codonHash2.put ("TTA", "L"); +jalview.schemes.ResidueProperties.codonHash2.put ("TTG", "L"); +jalview.schemes.ResidueProperties.codonHash2.put ("GTA", "V"); +jalview.schemes.ResidueProperties.codonHash2.put ("GTG", "V"); +jalview.schemes.ResidueProperties.codonHash2.put ("GTC", "V"); +jalview.schemes.ResidueProperties.codonHash2.put ("GTT", "V"); +jalview.schemes.ResidueProperties.codonHash2.put ("TTC", "F"); +jalview.schemes.ResidueProperties.codonHash2.put ("TTT", "F"); +jalview.schemes.ResidueProperties.buildAmbiguityCodonSet (); +}{ +jalview.schemes.ResidueProperties.Lys.add ("AAA"); +jalview.schemes.ResidueProperties.Lys.add ("AAG"); +jalview.schemes.ResidueProperties.Asn.add ("AAC"); +jalview.schemes.ResidueProperties.Asn.add ("AAT"); +jalview.schemes.ResidueProperties.Gln.add ("CAA"); +jalview.schemes.ResidueProperties.Gln.add ("CAG"); +jalview.schemes.ResidueProperties.His.add ("CAC"); +jalview.schemes.ResidueProperties.His.add ("CAT"); +jalview.schemes.ResidueProperties.Glu.add ("GAA"); +jalview.schemes.ResidueProperties.Glu.add ("GAG"); +jalview.schemes.ResidueProperties.Asp.add ("GAC"); +jalview.schemes.ResidueProperties.Asp.add ("GAT"); +jalview.schemes.ResidueProperties.Tyr.add ("TAC"); +jalview.schemes.ResidueProperties.Tyr.add ("TAT"); +jalview.schemes.ResidueProperties.Thr.add ("ACA"); +jalview.schemes.ResidueProperties.Thr.add ("ACG"); +jalview.schemes.ResidueProperties.Thr.add ("ACC"); +jalview.schemes.ResidueProperties.Thr.add ("ACT"); +jalview.schemes.ResidueProperties.Pro.add ("CCA"); +jalview.schemes.ResidueProperties.Pro.add ("CCG"); +jalview.schemes.ResidueProperties.Pro.add ("CCC"); +jalview.schemes.ResidueProperties.Pro.add ("CCT"); +jalview.schemes.ResidueProperties.Ala.add ("GCA"); +jalview.schemes.ResidueProperties.Ala.add ("GCG"); +jalview.schemes.ResidueProperties.Ala.add ("GCC"); +jalview.schemes.ResidueProperties.Ala.add ("GCT"); +jalview.schemes.ResidueProperties.Ser.add ("TCA"); +jalview.schemes.ResidueProperties.Ser.add ("TCG"); +jalview.schemes.ResidueProperties.Ser.add ("TCC"); +jalview.schemes.ResidueProperties.Ser.add ("TCT"); +jalview.schemes.ResidueProperties.Ser.add ("AGC"); +jalview.schemes.ResidueProperties.Ser.add ("AGT"); +jalview.schemes.ResidueProperties.Arg.add ("AGA"); +jalview.schemes.ResidueProperties.Arg.add ("AGG"); +jalview.schemes.ResidueProperties.Arg.add ("CGA"); +jalview.schemes.ResidueProperties.Arg.add ("CGG"); +jalview.schemes.ResidueProperties.Arg.add ("CGC"); +jalview.schemes.ResidueProperties.Arg.add ("CGT"); +jalview.schemes.ResidueProperties.Gly.add ("GGA"); +jalview.schemes.ResidueProperties.Gly.add ("GGG"); +jalview.schemes.ResidueProperties.Gly.add ("GGC"); +jalview.schemes.ResidueProperties.Gly.add ("GGT"); +jalview.schemes.ResidueProperties.STOP.add ("TGA"); +jalview.schemes.ResidueProperties.STOP.add ("TAA"); +jalview.schemes.ResidueProperties.STOP.add ("TAG"); +jalview.schemes.ResidueProperties.Trp.add ("TGG"); +jalview.schemes.ResidueProperties.Cys.add ("TGC"); +jalview.schemes.ResidueProperties.Cys.add ("TGT"); +jalview.schemes.ResidueProperties.Ile.add ("ATA"); +jalview.schemes.ResidueProperties.Ile.add ("ATC"); +jalview.schemes.ResidueProperties.Ile.add ("ATT"); +jalview.schemes.ResidueProperties.Met.add ("ATG"); +jalview.schemes.ResidueProperties.Leu.add ("CTA"); +jalview.schemes.ResidueProperties.Leu.add ("CTG"); +jalview.schemes.ResidueProperties.Leu.add ("CTC"); +jalview.schemes.ResidueProperties.Leu.add ("CTT"); +jalview.schemes.ResidueProperties.Leu.add ("TTA"); +jalview.schemes.ResidueProperties.Leu.add ("TTG"); +jalview.schemes.ResidueProperties.Val.add ("GTA"); +jalview.schemes.ResidueProperties.Val.add ("GTG"); +jalview.schemes.ResidueProperties.Val.add ("GTC"); +jalview.schemes.ResidueProperties.Val.add ("GTT"); +jalview.schemes.ResidueProperties.Phe.add ("TTC"); +jalview.schemes.ResidueProperties.Phe.add ("TTT"); +}c$.propHash = c$.prototype.propHash = new java.util.Hashtable (); +c$.hydrophobic = c$.prototype.hydrophobic = new java.util.Hashtable (); +c$.polar = c$.prototype.polar = new java.util.Hashtable (); +c$.small = c$.prototype.small = new java.util.Hashtable (); +c$.positive = c$.prototype.positive = new java.util.Hashtable (); +c$.negative = c$.prototype.negative = new java.util.Hashtable (); +c$.charged = c$.prototype.charged = new java.util.Hashtable (); +c$.aromatic = c$.prototype.aromatic = new java.util.Hashtable (); +c$.aliphatic = c$.prototype.aliphatic = new java.util.Hashtable (); +c$.tiny = c$.prototype.tiny = new java.util.Hashtable (); +c$.proline = c$.prototype.proline = new java.util.Hashtable (); +{ +jalview.schemes.ResidueProperties.hydrophobic.put ("I", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("L", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("V", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("C", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("A", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("G", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("M", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("F", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("Y", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("W", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("H", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("K", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("X", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("*", new Integer (1)); +jalview.schemes.ResidueProperties.hydrophobic.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("D", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.hydrophobic.put ("P", new Integer (0)); +}{ +jalview.schemes.ResidueProperties.polar.put ("Y", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("W", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("H", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("K", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("R", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("E", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("Q", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("D", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("N", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("S", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("T", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("X", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("*", new Integer (1)); +jalview.schemes.ResidueProperties.polar.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.polar.put ("P", new Integer (0)); +}{ +jalview.schemes.ResidueProperties.small.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("V", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("C", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("A", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("G", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("H", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("K", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.small.put ("D", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("N", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("S", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("T", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("P", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.small.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.positive.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("H", new Integer (1)); +jalview.schemes.ResidueProperties.positive.put ("K", new Integer (1)); +jalview.schemes.ResidueProperties.positive.put ("R", new Integer (1)); +jalview.schemes.ResidueProperties.positive.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("D", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("P", new Integer (0)); +jalview.schemes.ResidueProperties.positive.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.positive.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.negative.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("H", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("K", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("E", new Integer (1)); +jalview.schemes.ResidueProperties.negative.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("D", new Integer (1)); +jalview.schemes.ResidueProperties.negative.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("P", new Integer (0)); +jalview.schemes.ResidueProperties.negative.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.negative.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.charged.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("H", new Integer (1)); +jalview.schemes.ResidueProperties.charged.put ("K", new Integer (1)); +jalview.schemes.ResidueProperties.charged.put ("R", new Integer (1)); +jalview.schemes.ResidueProperties.charged.put ("E", new Integer (1)); +jalview.schemes.ResidueProperties.charged.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("D", new Integer (1)); +jalview.schemes.ResidueProperties.charged.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("P", new Integer (0)); +jalview.schemes.ResidueProperties.charged.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.charged.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.aromatic.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("F", new Integer (1)); +jalview.schemes.ResidueProperties.aromatic.put ("Y", new Integer (1)); +jalview.schemes.ResidueProperties.aromatic.put ("W", new Integer (1)); +jalview.schemes.ResidueProperties.aromatic.put ("H", new Integer (1)); +jalview.schemes.ResidueProperties.aromatic.put ("K", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("D", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("P", new Integer (0)); +jalview.schemes.ResidueProperties.aromatic.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.aromatic.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.aliphatic.put ("I", new Integer (1)); +jalview.schemes.ResidueProperties.aliphatic.put ("L", new Integer (1)); +jalview.schemes.ResidueProperties.aliphatic.put ("V", new Integer (1)); +jalview.schemes.ResidueProperties.aliphatic.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("H", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("K", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("D", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("P", new Integer (0)); +jalview.schemes.ResidueProperties.aliphatic.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.aliphatic.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.tiny.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("A", new Integer (1)); +jalview.schemes.ResidueProperties.tiny.put ("G", new Integer (1)); +jalview.schemes.ResidueProperties.tiny.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("H", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("K", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("D", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("S", new Integer (1)); +jalview.schemes.ResidueProperties.tiny.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("P", new Integer (0)); +jalview.schemes.ResidueProperties.tiny.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.tiny.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.proline.put ("I", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("L", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("V", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("C", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("A", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("G", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("M", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("F", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("Y", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("W", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("H", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("K", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("R", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("E", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("Q", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("D", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("N", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("S", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("T", new Integer (0)); +jalview.schemes.ResidueProperties.proline.put ("P", new Integer (1)); +jalview.schemes.ResidueProperties.proline.put ("-", new Integer (1)); +jalview.schemes.ResidueProperties.proline.put ("*", new Integer (1)); +}{ +jalview.schemes.ResidueProperties.propHash.put ("hydrophobic", jalview.schemes.ResidueProperties.hydrophobic); +jalview.schemes.ResidueProperties.propHash.put ("small", jalview.schemes.ResidueProperties.small); +jalview.schemes.ResidueProperties.propHash.put ("positive", jalview.schemes.ResidueProperties.positive); +jalview.schemes.ResidueProperties.propHash.put ("negative", jalview.schemes.ResidueProperties.negative); +jalview.schemes.ResidueProperties.propHash.put ("charged", jalview.schemes.ResidueProperties.charged); +jalview.schemes.ResidueProperties.propHash.put ("aromatic", jalview.schemes.ResidueProperties.aromatic); +jalview.schemes.ResidueProperties.propHash.put ("aliphatic", jalview.schemes.ResidueProperties.aliphatic); +jalview.schemes.ResidueProperties.propHash.put ("tiny", jalview.schemes.ResidueProperties.tiny); +jalview.schemes.ResidueProperties.propHash.put ("proline", jalview.schemes.ResidueProperties.proline); +jalview.schemes.ResidueProperties.propHash.put ("polar", jalview.schemes.ResidueProperties.polar); +}{ +var propMatrixF = Clazz.newIntArray (23, 23, 0); +var propMatrixPos = Clazz.newIntArray (23, 23, 0); +var propMatrixEpos = Clazz.newIntArray (23, 23, 0); +for (var i = 0; i < 23; i++) { +var maxF = 0; +var maxP = 0; +var maxEP = 0; +var ic = ""; +if (jalview.schemes.ResidueProperties.aa.length > i) { +ic += jalview.schemes.ResidueProperties.aa[i]; +} else { +ic = "-"; +}for (var j = i + 1; j < 23; j++) { +var jc = ""; +if (jalview.schemes.ResidueProperties.aa.length > j) { +jc += jalview.schemes.ResidueProperties.aa[j]; +} else { +jc = "-"; +}propMatrixF[i][j] = 0; +propMatrixPos[i][j] = 0; +propMatrixEpos[i][j] = 0; +for (var en = jalview.schemes.ResidueProperties.propHash.keys (); en.hasMoreElements (); ) { +var ph = en.nextElement (); +var pph = jalview.schemes.ResidueProperties.propHash.get (ph); +if (pph.get (ic) != null && pph.get (jc) != null) { +var icp = pph.get (ic).intValue (); +var jcp = pph.get (jc).intValue (); +propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0; +propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0; +propMatrixF[i][j] += icp == jcp ? 2 : 0; +propMatrixF[j][i] += icp == jcp ? 2 : 0; +propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0; +propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0; +}} +if (maxF < propMatrixF[i][j]) { +maxF = propMatrixF[i][j]; +}if (maxP < propMatrixPos[i][j]) { +maxP = propMatrixPos[i][j]; +}if (maxEP < propMatrixEpos[i][j]) { +maxEP = propMatrixEpos[i][j]; +}} +propMatrixF[i][i] = maxF; +propMatrixPos[i][i] = maxP; +propMatrixEpos[i][i] = maxEP; +} +jalview.schemes.ResidueProperties.scoreMatrices.put ("PID", new jalview.analysis.scoremodels.PIDScoreModel ()); +jalview.schemes.ResidueProperties.scoreMatrices.put ("Displayed Features", new jalview.analysis.scoremodels.FeatureScoreModel ()); +}Clazz.defineStatics (c$, +"toDssp3State", null); +{ +jalview.schemes.ResidueProperties.toDssp3State = new java.util.Hashtable (); +jalview.schemes.ResidueProperties.toDssp3State.put ("H", "H"); +jalview.schemes.ResidueProperties.toDssp3State.put ("E", "E"); +jalview.schemes.ResidueProperties.toDssp3State.put ("C", " "); +jalview.schemes.ResidueProperties.toDssp3State.put (" ", " "); +jalview.schemes.ResidueProperties.toDssp3State.put ("T", " "); +jalview.schemes.ResidueProperties.toDssp3State.put ("B", "E"); +jalview.schemes.ResidueProperties.toDssp3State.put ("G", "H"); +jalview.schemes.ResidueProperties.toDssp3State.put ("I", "H"); +jalview.schemes.ResidueProperties.toDssp3State.put ("X", " "); +}Clazz.defineStatics (c$, +"toRNAssState", null, +"RNAcloseParen", Clazz.newBooleanArray (255, false)); +{ +jalview.schemes.ResidueProperties.toRNAssState = new java.util.Hashtable (); +jalview.schemes.ResidueProperties.toRNAssState.put (")", "("); +jalview.schemes.ResidueProperties.toRNAssState.put ("(", "("); +jalview.schemes.ResidueProperties.toRNAssState.put ("]", "["); +jalview.schemes.ResidueProperties.toRNAssState.put ("[", "["); +jalview.schemes.ResidueProperties.toRNAssState.put ("{", "{"); +jalview.schemes.ResidueProperties.toRNAssState.put ("}", "{"); +jalview.schemes.ResidueProperties.toRNAssState.put (">", ">"); +jalview.schemes.ResidueProperties.toRNAssState.put ("<", ">"); +jalview.schemes.ResidueProperties.toRNAssState.put ("A", "A"); +jalview.schemes.ResidueProperties.toRNAssState.put ("a", "A"); +jalview.schemes.ResidueProperties.toRNAssState.put ("B", "B"); +jalview.schemes.ResidueProperties.toRNAssState.put ("b", "B"); +jalview.schemes.ResidueProperties.toRNAssState.put ("C", "C"); +jalview.schemes.ResidueProperties.toRNAssState.put ("c", "C"); +jalview.schemes.ResidueProperties.toRNAssState.put ("D", "D"); +jalview.schemes.ResidueProperties.toRNAssState.put ("d", "D"); +jalview.schemes.ResidueProperties.toRNAssState.put ("E", "E"); +jalview.schemes.ResidueProperties.toRNAssState.put ("e", "E"); +jalview.schemes.ResidueProperties.toRNAssState.put ("F", "F"); +jalview.schemes.ResidueProperties.toRNAssState.put ("f", "F"); +jalview.schemes.ResidueProperties.toRNAssState.put ("G", "G"); +jalview.schemes.ResidueProperties.toRNAssState.put ("g", "G"); +jalview.schemes.ResidueProperties.toRNAssState.put ("H", "H"); +jalview.schemes.ResidueProperties.toRNAssState.put ("h", "H"); +jalview.schemes.ResidueProperties.toRNAssState.put ("I", "I"); +jalview.schemes.ResidueProperties.toRNAssState.put ("i", "I"); +jalview.schemes.ResidueProperties.toRNAssState.put ("J", "J"); +jalview.schemes.ResidueProperties.toRNAssState.put ("j", "J"); +jalview.schemes.ResidueProperties.toRNAssState.put ("K", "K"); +jalview.schemes.ResidueProperties.toRNAssState.put ("k", "K"); +jalview.schemes.ResidueProperties.toRNAssState.put ("L", "L"); +jalview.schemes.ResidueProperties.toRNAssState.put ("l", "L"); +jalview.schemes.ResidueProperties.toRNAssState.put ("M", "M"); +jalview.schemes.ResidueProperties.toRNAssState.put ("m", "M"); +jalview.schemes.ResidueProperties.toRNAssState.put ("N", "N"); +jalview.schemes.ResidueProperties.toRNAssState.put ("n", "N"); +jalview.schemes.ResidueProperties.toRNAssState.put ("O", "O"); +jalview.schemes.ResidueProperties.toRNAssState.put ("o", "O"); +jalview.schemes.ResidueProperties.toRNAssState.put ("P", "P"); +jalview.schemes.ResidueProperties.toRNAssState.put ("p", "P"); +jalview.schemes.ResidueProperties.toRNAssState.put ("Q", "Q"); +jalview.schemes.ResidueProperties.toRNAssState.put ("q", "Q"); +jalview.schemes.ResidueProperties.toRNAssState.put ("R", "R"); +jalview.schemes.ResidueProperties.toRNAssState.put ("r", "R"); +jalview.schemes.ResidueProperties.toRNAssState.put ("S", "S"); +jalview.schemes.ResidueProperties.toRNAssState.put ("s", "S"); +jalview.schemes.ResidueProperties.toRNAssState.put ("T", "T"); +jalview.schemes.ResidueProperties.toRNAssState.put ("t", "T"); +jalview.schemes.ResidueProperties.toRNAssState.put ("U", "U"); +jalview.schemes.ResidueProperties.toRNAssState.put ("u", "U"); +jalview.schemes.ResidueProperties.toRNAssState.put ("V", "V"); +jalview.schemes.ResidueProperties.toRNAssState.put ("v", "V"); +jalview.schemes.ResidueProperties.toRNAssState.put ("W", "W"); +jalview.schemes.ResidueProperties.toRNAssState.put ("w", "W"); +jalview.schemes.ResidueProperties.toRNAssState.put ("X", "X"); +jalview.schemes.ResidueProperties.toRNAssState.put ("x", "X"); +jalview.schemes.ResidueProperties.toRNAssState.put ("Y", "Y"); +jalview.schemes.ResidueProperties.toRNAssState.put ("y", "Y"); +jalview.schemes.ResidueProperties.toRNAssState.put ("Z", "Z"); +jalview.schemes.ResidueProperties.toRNAssState.put ("z", "Z"); +for (var p = 0; p < jalview.schemes.ResidueProperties.RNAcloseParen.length; p++) { +jalview.schemes.ResidueProperties.RNAcloseParen[p] = false; +} +for (var k, $k = jalview.schemes.ResidueProperties.toRNAssState.keySet ().iterator (); $k.hasNext () && ((k = $k.next ()) || true);) { +jalview.schemes.ResidueProperties.RNAcloseParen[k.charCodeAt (0)] = k.charAt (0) != jalview.schemes.ResidueProperties.toRNAssState.get (k).charAt (0); +} +}}); diff --git a/bin/jalview/schemes/ScoreColourScheme.js b/bin/jalview/schemes/ScoreColourScheme.js index f097a40..5027bdf 100644 --- a/bin/jalview/schemes/ScoreColourScheme.js +++ b/bin/jalview/schemes/ScoreColourScheme.js @@ -1,43 +1,43 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.ScoreColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () { -c$ = Clazz.decorateAsClass (function () { -this.min = 0; -this.max = 0; -this.scores = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "ScoreColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function (symbolIndex, scores, min, max) { -Clazz.superConstructor (this, jalview.schemes.ScoreColourScheme, [symbolIndex]); -this.scores = scores; -this.min = min; -this.max = max; -var i; -var iSize = scores.length; -this.colors = new Array (scores.length); -for (i = 0; i < iSize; i++) { -var red = (scores[i] - min) / (max - min); -if (red > 1.0) { -red = 1.0; -}if (red < 0.0) { -red = 0.0; -}this.colors[i] = this.makeColour (red); -} -}, "~A,~A,~N,~N"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -if (this.threshold > 0) { -if (!this.aboveThreshold (c, j)) { -return java.awt.Color.white; -}}if (jalview.util.Comparison.isGap (c)) { -return java.awt.Color.white; -}var currentColour = this.colors[jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]]; -if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "makeColour", -function (c) { -return new java.awt.Color (c, 0.0, 1.0 - c); -}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.ScoreColourScheme", ["jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.awt.Color"], function () { +c$ = Clazz.decorateAsClass (function () { +this.min = 0; +this.max = 0; +this.scores = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "ScoreColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function (symbolIndex, scores, min, max) { +Clazz.superConstructor (this, jalview.schemes.ScoreColourScheme, [symbolIndex]); +this.scores = scores; +this.min = min; +this.max = max; +var i; +var iSize = scores.length; +this.colors = new Array (scores.length); +for (i = 0; i < iSize; i++) { +var red = (scores[i] - min) / (max - min); +if (red > 1.0) { +red = 1.0; +}if (red < 0.0) { +red = 0.0; +}this.colors[i] = this.makeColour (red); +} +}, "~A,~A,~N,~N"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +if (this.threshold > 0) { +if (!this.aboveThreshold (c, j)) { +return java.awt.Color.white; +}}if (jalview.util.Comparison.isGap (c)) { +return java.awt.Color.white; +}var currentColour = this.colors[jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]]; +if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "makeColour", +function (c) { +return new java.awt.Color (c, 0.0, 1.0 - c); +}, "~N"); +}); diff --git a/bin/jalview/schemes/ScoreMatrix.js b/bin/jalview/schemes/ScoreMatrix.js index 401ab41..a12c842 100644 --- a/bin/jalview/schemes/ScoreMatrix.js +++ b/bin/jalview/schemes/ScoreMatrix.js @@ -1,86 +1,86 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.analysis.scoremodels.PairwiseSeqScoreModel", "jalview.api.analysis.ScoreModelI"], "jalview.schemes.ScoreMatrix", ["jalview.schemes.ResidueProperties", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.name = null; -this.matrix = null; -this.type = 0; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "ScoreMatrix", jalview.analysis.scoremodels.PairwiseSeqScoreModel, jalview.api.analysis.ScoreModelI); -Clazz.overrideMethod (c$, "getName", -function () { -return this.name; -}); -Clazz.makeConstructor (c$, -function (name, matrix, type) { -Clazz.superConstructor (this, jalview.schemes.ScoreMatrix, []); -this.matrix = matrix; -this.type = type; -this.name = name; -}, "~S,~A,~N"); -Clazz.overrideMethod (c$, "isDNA", -function () { -return this.type == 1; -}); -Clazz.overrideMethod (c$, "isProtein", -function () { -return this.type == 0; -}); -Clazz.overrideMethod (c$, "getMatrix", -function () { -return this.matrix; -}); -Clazz.defineMethod (c$, "getPairwiseScore", -function (A1, A2) { -return this.getPairwiseScore (A1.charAt (0), A2.charAt (0)); -}, "~S,~S"); -Clazz.defineMethod (c$, "getPairwiseScore", -function (c, d) { -var pog = 0; -try { -var a = (this.type == 0) ? jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)] : jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]; -var b = (this.type == 0) ? jalview.schemes.ResidueProperties.aaIndex[d.charCodeAt (0)] : jalview.schemes.ResidueProperties.nucleotideIndex[d.charCodeAt (0)]; -pog = this.matrix[a][b]; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -return pog; -}, "~S,~S"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.outputMatrix (false); -}); -Clazz.defineMethod (c$, "outputMatrix", -function (html) { -var sb = new StringBuffer (); -var symbols = (this.type == 0) ? jalview.schemes.ResidueProperties.aaIndex : jalview.schemes.ResidueProperties.nucleotideIndex; -var symMax = (this.type == 0) ? 23 : 10; -var header = true; -if (html) { -sb.append (""); -}for (var sym = 'A'; sym <= 'Z'; sym = String.fromCharCode (sym.charCodeAt (0) + 1)) { -if (symbols[sym.charCodeAt (0)] >= 0 && symbols[sym.charCodeAt (0)] < symMax) { -if (header) { -sb.append (html ? "" : ""); -for (var sym2 = 'A'; sym2 <= 'Z'; sym2 = String.fromCharCode (sym2.charCodeAt (0) + 1)) { -if (symbols[sym2.charCodeAt (0)] >= 0 && symbols[sym2.charCodeAt (0)] < symMax) { -sb.append ((html ? "" : "")); -}} -header = false; -sb.append (html ? "\n" : "\n"); -}if (html) { -sb.append (""); -}sb.append ((html ? "" : "")); -for (var sym2 = 'A'; sym2 <= 'Z'; sym2 = String.fromCharCode (sym2.charCodeAt (0) + 1)) { -if (symbols[sym2.charCodeAt (0)] >= 0 && symbols[sym2.charCodeAt (0)] < symMax) { -sb.append ((html ? "" : "")); -}} -sb.append (html ? "\n" : "\n"); -}} -if (html) { -sb.append ("
 " : "\t") + sym2 + (html ? " 
" : "") + sym + (html ? "" : "\t") + this.matrix[symbols[sym.charCodeAt (0)]][symbols[sym2.charCodeAt (0)]] + (html ? "
"); -}return sb.toString (); -}, "~B"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.analysis.scoremodels.PairwiseSeqScoreModel", "jalview.api.analysis.ScoreModelI"], "jalview.schemes.ScoreMatrix", ["jalview.schemes.ResidueProperties", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.name = null; +this.matrix = null; +this.type = 0; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "ScoreMatrix", jalview.analysis.scoremodels.PairwiseSeqScoreModel, jalview.api.analysis.ScoreModelI); +Clazz.overrideMethod (c$, "getName", +function () { +return this.name; +}); +Clazz.makeConstructor (c$, +function (name, matrix, type) { +Clazz.superConstructor (this, jalview.schemes.ScoreMatrix, []); +this.matrix = matrix; +this.type = type; +this.name = name; +}, "~S,~A,~N"); +Clazz.overrideMethod (c$, "isDNA", +function () { +return this.type == 1; +}); +Clazz.overrideMethod (c$, "isProtein", +function () { +return this.type == 0; +}); +Clazz.overrideMethod (c$, "getMatrix", +function () { +return this.matrix; +}); +Clazz.defineMethod (c$, "getPairwiseScore", +function (A1, A2) { +return this.getPairwiseScore (A1.charAt (0), A2.charAt (0)); +}, "~S,~S"); +Clazz.defineMethod (c$, "getPairwiseScore", +function (c, d) { +var pog = 0; +try { +var a = (this.type == 0) ? jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)] : jalview.schemes.ResidueProperties.nucleotideIndex[c.charCodeAt (0)]; +var b = (this.type == 0) ? jalview.schemes.ResidueProperties.aaIndex[d.charCodeAt (0)] : jalview.schemes.ResidueProperties.nucleotideIndex[d.charCodeAt (0)]; +pog = this.matrix[a][b]; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +return pog; +}, "~S,~S"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.outputMatrix (false); +}); +Clazz.defineMethod (c$, "outputMatrix", +function (html) { +var sb = new StringBuffer (); +var symbols = (this.type == 0) ? jalview.schemes.ResidueProperties.aaIndex : jalview.schemes.ResidueProperties.nucleotideIndex; +var symMax = (this.type == 0) ? 23 : 10; +var header = true; +if (html) { +sb.append (""); +}for (var sym = 'A'; sym <= 'Z'; sym = String.fromCharCode (sym.charCodeAt (0) + 1)) { +if (symbols[sym.charCodeAt (0)] >= 0 && symbols[sym.charCodeAt (0)] < symMax) { +if (header) { +sb.append (html ? "" : ""); +for (var sym2 = 'A'; sym2 <= 'Z'; sym2 = String.fromCharCode (sym2.charCodeAt (0) + 1)) { +if (symbols[sym2.charCodeAt (0)] >= 0 && symbols[sym2.charCodeAt (0)] < symMax) { +sb.append ((html ? "" : "")); +}} +header = false; +sb.append (html ? "\n" : "\n"); +}if (html) { +sb.append (""); +}sb.append ((html ? "" : "")); +for (var sym2 = 'A'; sym2 <= 'Z'; sym2 = String.fromCharCode (sym2.charCodeAt (0) + 1)) { +if (symbols[sym2.charCodeAt (0)] >= 0 && symbols[sym2.charCodeAt (0)] < symMax) { +sb.append ((html ? "" : "")); +}} +sb.append (html ? "\n" : "\n"); +}} +if (html) { +sb.append ("
 " : "\t") + sym2 + (html ? " 
" : "") + sym + (html ? "" : "\t") + this.matrix[symbols[sym.charCodeAt (0)]][symbols[sym2.charCodeAt (0)]] + (html ? "
"); +}return sb.toString (); +}, "~B"); +}); diff --git a/bin/jalview/schemes/StrandColourScheme.js b/bin/jalview/schemes/StrandColourScheme.js index 7ccf062..cf2f6bf 100644 --- a/bin/jalview/schemes/StrandColourScheme.js +++ b/bin/jalview/schemes/StrandColourScheme.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.StrandColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "StrandColourScheme", jalview.schemes.ScoreColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.StrandColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.strand, 0.37, 1.7]); -}); -Clazz.overrideMethod (c$, "makeColour", -function (c) { -return new java.awt.Color (c, c, 1.0 - c); -}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.StrandColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "StrandColourScheme", jalview.schemes.ScoreColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.StrandColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.strand, 0.37, 1.7]); +}); +Clazz.overrideMethod (c$, "makeColour", +function (c) { +return new java.awt.Color (c, c, 1.0 - c); +}, "~N"); +}); diff --git a/bin/jalview/schemes/TCoffeeColourScheme.js b/bin/jalview/schemes/TCoffeeColourScheme.js index 6350ad9..0952425 100644 --- a/bin/jalview/schemes/TCoffeeColourScheme.js +++ b/bin/jalview/schemes/TCoffeeColourScheme.js @@ -1,45 +1,45 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme", "java.awt.Color"], "jalview.schemes.TCoffeeColourScheme", ["jalview.datamodel.AlignmentI", "java.util.ArrayList", "$.IdentityHashMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.seqMap = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "TCoffeeColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function (alignment) { -Clazz.superConstructor (this, jalview.schemes.TCoffeeColourScheme, []); -this.alignmentChanged (alignment, null); -}, "jalview.datamodel.AnnotatedCollectionI"); -Clazz.overrideMethod (c$, "alignmentChanged", -function (alignment, hiddenReps) { -var annots = new java.util.ArrayList (); -this.seqMap = new java.util.IdentityHashMap (); -var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext (); -var w = 0; -for (var al, $al = alcontext.findAnnotation ("TCoffeeScore").iterator (); $al.hasNext () && ((al = $al.next ()) || true);) { -if (al.sequenceRef != null && !al.belowAlignment) { -annots.add (al); -if (w < al.annotations.length) { -w = al.annotations.length; -}var scores = new Array (al.annotations.length); -var i = 0; -for (var an, $an = 0, $$an = al.annotations; $an < $$an.length && ((an = $$an[$an]) || true); $an++) { -scores[i++] = (an != null) ? an.colour : java.awt.Color.white; -} -this.seqMap.put (al.sequenceRef, scores); -}} -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var cols; -if (this.seqMap == null || (cols = this.seqMap.get (seq)) == null) { -return java.awt.Color.white; -}if (j < 0 || j >= cols.length) { -return java.awt.Color.white; -}return cols[j]; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -return new jalview.schemes.TCoffeeColourScheme (sg); -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -c$.$colors = c$.prototype.$colors = Clazz.newArray (-1, [ new java.awt.Color (102, 102, 255), new java.awt.Color (0, 255, 0), new java.awt.Color (102, 255, 0), new java.awt.Color (204, 255, 0), new java.awt.Color (255, 255, 0), new java.awt.Color (255, 204, 0), new java.awt.Color (255, 153, 0), new java.awt.Color (255, 102, 0), new java.awt.Color (255, 51, 0), new java.awt.Color (255, 34, 0)]); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme", "java.awt.Color"], "jalview.schemes.TCoffeeColourScheme", ["jalview.datamodel.AlignmentI", "java.util.ArrayList", "$.IdentityHashMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.seqMap = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "TCoffeeColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function (alignment) { +Clazz.superConstructor (this, jalview.schemes.TCoffeeColourScheme, []); +this.alignmentChanged (alignment, null); +}, "jalview.datamodel.AnnotatedCollectionI"); +Clazz.overrideMethod (c$, "alignmentChanged", +function (alignment, hiddenReps) { +var annots = new java.util.ArrayList (); +this.seqMap = new java.util.IdentityHashMap (); +var alcontext = Clazz.instanceOf (alignment, jalview.datamodel.AlignmentI) ? alignment : alignment.getContext (); +var w = 0; +for (var al, $al = alcontext.findAnnotation ("TCoffeeScore").iterator (); $al.hasNext () && ((al = $al.next ()) || true);) { +if (al.sequenceRef != null && !al.belowAlignment) { +annots.add (al); +if (w < al.annotations.length) { +w = al.annotations.length; +}var scores = new Array (al.annotations.length); +var i = 0; +for (var an, $an = 0, $$an = al.annotations; $an < $$an.length && ((an = $$an[$an]) || true); $an++) { +scores[i++] = (an != null) ? an.colour : java.awt.Color.white; +} +this.seqMap.put (al.sequenceRef, scores); +}} +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var cols; +if (this.seqMap == null || (cols = this.seqMap.get (seq)) == null) { +return java.awt.Color.white; +}if (j < 0 || j >= cols.length) { +return java.awt.Color.white; +}return cols[j]; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +return new jalview.schemes.TCoffeeColourScheme (sg); +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +c$.$colors = c$.prototype.$colors = Clazz.newArray (-1, [ new java.awt.Color (102, 102, 255), new java.awt.Color (0, 255, 0), new java.awt.Color (102, 255, 0), new java.awt.Color (204, 255, 0), new java.awt.Color (255, 255, 0), new java.awt.Color (255, 204, 0), new java.awt.Color (255, 153, 0), new java.awt.Color (255, 102, 0), new java.awt.Color (255, 51, 0), new java.awt.Color (255, 34, 0)]); +}); diff --git a/bin/jalview/schemes/TaylorColourScheme.js b/bin/jalview/schemes/TaylorColourScheme.js index 65bba75..156c6fc 100644 --- a/bin/jalview/schemes/TaylorColourScheme.js +++ b/bin/jalview/schemes/TaylorColourScheme.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.TaylorColourScheme", ["jalview.schemes.ResidueProperties"], function () { -c$ = Clazz.declareType (jalview.schemes, "TaylorColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.TaylorColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.taylor, 0]); -}); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.TaylorColourScheme", ["jalview.schemes.ResidueProperties"], function () { +c$ = Clazz.declareType (jalview.schemes, "TaylorColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.TaylorColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.taylor, 0]); +}); +}); diff --git a/bin/jalview/schemes/TurnColourScheme.js b/bin/jalview/schemes/TurnColourScheme.js index 7e440d8..74fe374 100644 --- a/bin/jalview/schemes/TurnColourScheme.js +++ b/bin/jalview/schemes/TurnColourScheme.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.TurnColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { -c$ = Clazz.declareType (jalview.schemes, "TurnColourScheme", jalview.schemes.ScoreColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.TurnColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.turn, 0.47, 1.56]); -}); -Clazz.overrideMethod (c$, "makeColour", -function (c) { -return new java.awt.Color (c, 1 - c, 1 - c); -}, "~N"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ScoreColourScheme"], "jalview.schemes.TurnColourScheme", ["jalview.schemes.ResidueProperties", "java.awt.Color"], function () { +c$ = Clazz.declareType (jalview.schemes, "TurnColourScheme", jalview.schemes.ScoreColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.TurnColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.turn, 0.47, 1.56]); +}); +Clazz.overrideMethod (c$, "makeColour", +function (c) { +return new java.awt.Color (c, 1 - c, 1 - c); +}, "~N"); +}); diff --git a/bin/jalview/schemes/UserColourScheme.js b/bin/jalview/schemes/UserColourScheme.js index ee83987..dcf5f86 100644 --- a/bin/jalview/schemes/UserColourScheme.js +++ b/bin/jalview/schemes/UserColourScheme.js @@ -1,165 +1,165 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.UserColourScheme", ["jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "java.awt.Color", "java.util.StringTokenizer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.lowerCaseColours = null; -this.schemeName = null; -Clazz.instantialize (this, arguments); -}, jalview.schemes, "UserColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]); -}); -Clazz.makeConstructor (c$, -function (newColors) { -Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]); -this.colors = newColors; -}, "~A"); -Clazz.overrideMethod (c$, "applyTo", -function (sg, hiddenRepSequences) { -var usc = new jalview.schemes.UserColourScheme (this.colors); -if (this.lowerCaseColours != null) { -usc.schemeName = String.instantialize (this.schemeName); -usc.lowerCaseColours = new Array (this.lowerCaseColours.length); -System.arraycopy (this.lowerCaseColours, 0, usc.lowerCaseColours, 0, this.lowerCaseColours.length); -}return usc; -}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); -Clazz.makeConstructor (c$, -function (colour) { -Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]); -var col = this.getColourFromString (colour); -if (col == null) { -System.out.println ("Unknown colour!! " + colour); -col = this.createColourFromName (colour); -}this.colors = new Array (24); -for (var i = 0; i < 24; i++) { -this.colors[i] = col; -} -this.schemeName = colour; -}, "~S"); -Clazz.defineMethod (c$, "getColours", -function () { -return this.colors; -}); -Clazz.defineMethod (c$, "getLowerCaseColours", -function () { -return this.lowerCaseColours; -}); -Clazz.defineMethod (c$, "setName", -function (name) { -this.schemeName = name; -}, "~S"); -Clazz.defineMethod (c$, "getName", -function () { -return this.schemeName; -}); -Clazz.defineMethod (c$, "getColourFromString", -function (colour) { -colour = colour.trim (); -var col = null; -try { -var value = Integer.parseInt (colour, 16); -col = new java.awt.Color (value); -} catch (ex) { -if (Clazz.exceptionOf (ex, NumberFormatException)) { -} else { -throw ex; -} -} -if (col == null) { -col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName (colour); -}if (col == null) { -try { -var st = new java.util.StringTokenizer (colour, ","); -var r = Integer.parseInt (st.nextToken ()); -var g = Integer.parseInt (st.nextToken ()); -var b = Integer.parseInt (st.nextToken ()); -col = new java.awt.Color (r, g, b); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -} else { -throw ex; -} -} -}return col; -}, "~S"); -Clazz.defineMethod (c$, "createColourFromName", -function (name) { -var r; -var g; -var b; -var lsize = name.length; -var start = 0; -var end = Clazz.doubleToInt (lsize / 3); -var rgbOffset = Math.abs (name.hashCode () % 10) * 15; -r = Math.abs (name.substring (start, end).hashCode () + rgbOffset) % 210 + 20; -start = end; -end += Clazz.doubleToInt (lsize / 3); -if (end > lsize) { -end = lsize; -}g = Math.abs (name.substring (start, end).hashCode () + rgbOffset) % 210 + 20; -b = Math.abs (name.substring (end).hashCode () + rgbOffset) % 210 + 20; -var color = new java.awt.Color (r, g, b); -return color; -}, "~S"); -Clazz.defineMethod (c$, "parseAppletParameter", -function (paramValue) { -var st = new java.util.StringTokenizer (paramValue, ";"); -var st2; -var token = null; -var colour; -var residues; -try { -while (st.hasMoreElements ()) { -token = st.nextToken ().trim (); -residues = token.substring (0, token.indexOf ("=")); -colour = token.substring (token.indexOf ("=") + 1); -st2 = new java.util.StringTokenizer (residues, " ,"); -while (st2.hasMoreTokens ()) { -token = st2.nextToken (); -if (jalview.schemes.ResidueProperties.aaIndex[token.charCodeAt (0)] == -1) { -continue; -}var colIndex = jalview.schemes.ResidueProperties.aaIndex[token.charCodeAt (0)]; -if (token.equalsIgnoreCase ("lowerCase")) { -if (this.lowerCaseColours == null) { -this.lowerCaseColours = new Array (23); -}for (var i = 0; i < 23; i++) { -if (this.lowerCaseColours[i] == null) { -this.lowerCaseColours[i] = this.getColourFromString (colour); -}} -continue; -}if (token.equals (token.toLowerCase ())) { -if (this.lowerCaseColours == null) { -this.lowerCaseColours = new Array (23); -}this.lowerCaseColours[colIndex] = this.getColourFromString (colour); -} else { -this.colors[colIndex] = this.getColourFromString (colour); -}} -} -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -System.out.println ("Error parsing userDefinedColours:\n" + token + "\n" + ex); -} else { -throw ex; -} -} -}, "~S"); -Clazz.defineMethod (c$, "findColour", -function (c, j, seq) { -var currentColour; -var index = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]; -if ((this.threshold == 0) || this.aboveThreshold (c, j)) { -if (this.lowerCaseColours != null && 'a' <= c && c <= 'z') { -currentColour = this.lowerCaseColours[index]; -} else { -currentColour = this.colors[index]; -}} else { -currentColour = java.awt.Color.white; -}if (this.conservationColouring) { -currentColour = this.applyConservation (currentColour, j); -}return currentColour; -}, "~S,~N,jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "setLowerCaseColours", -function (lcolours) { -this.lowerCaseColours = lcolours; -}, "~A"); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.UserColourScheme", ["jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "java.awt.Color", "java.util.StringTokenizer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.lowerCaseColours = null; +this.schemeName = null; +Clazz.instantialize (this, arguments); +}, jalview.schemes, "UserColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]); +}); +Clazz.makeConstructor (c$, +function (newColors) { +Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]); +this.colors = newColors; +}, "~A"); +Clazz.overrideMethod (c$, "applyTo", +function (sg, hiddenRepSequences) { +var usc = new jalview.schemes.UserColourScheme (this.colors); +if (this.lowerCaseColours != null) { +usc.schemeName = String.instantialize (this.schemeName); +usc.lowerCaseColours = new Array (this.lowerCaseColours.length); +System.arraycopy (this.lowerCaseColours, 0, usc.lowerCaseColours, 0, this.lowerCaseColours.length); +}return usc; +}, "jalview.datamodel.AnnotatedCollectionI,java.util.Map"); +Clazz.makeConstructor (c$, +function (colour) { +Clazz.superConstructor (this, jalview.schemes.UserColourScheme, [jalview.schemes.ResidueProperties.aaIndex]); +var col = this.getColourFromString (colour); +if (col == null) { +System.out.println ("Unknown colour!! " + colour); +col = this.createColourFromName (colour); +}this.colors = new Array (24); +for (var i = 0; i < 24; i++) { +this.colors[i] = col; +} +this.schemeName = colour; +}, "~S"); +Clazz.defineMethod (c$, "getColours", +function () { +return this.colors; +}); +Clazz.defineMethod (c$, "getLowerCaseColours", +function () { +return this.lowerCaseColours; +}); +Clazz.defineMethod (c$, "setName", +function (name) { +this.schemeName = name; +}, "~S"); +Clazz.defineMethod (c$, "getName", +function () { +return this.schemeName; +}); +Clazz.defineMethod (c$, "getColourFromString", +function (colour) { +colour = colour.trim (); +var col = null; +try { +var value = Integer.parseInt (colour, 16); +col = new java.awt.Color (value); +} catch (ex) { +if (Clazz.exceptionOf (ex, NumberFormatException)) { +} else { +throw ex; +} +} +if (col == null) { +col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName (colour); +}if (col == null) { +try { +var st = new java.util.StringTokenizer (colour, ","); +var r = Integer.parseInt (st.nextToken ()); +var g = Integer.parseInt (st.nextToken ()); +var b = Integer.parseInt (st.nextToken ()); +col = new java.awt.Color (r, g, b); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +} else { +throw ex; +} +} +}return col; +}, "~S"); +Clazz.defineMethod (c$, "createColourFromName", +function (name) { +var r; +var g; +var b; +var lsize = name.length; +var start = 0; +var end = Clazz.doubleToInt (lsize / 3); +var rgbOffset = Math.abs (name.hashCode () % 10) * 15; +r = Math.abs (name.substring (start, end).hashCode () + rgbOffset) % 210 + 20; +start = end; +end += Clazz.doubleToInt (lsize / 3); +if (end > lsize) { +end = lsize; +}g = Math.abs (name.substring (start, end).hashCode () + rgbOffset) % 210 + 20; +b = Math.abs (name.substring (end).hashCode () + rgbOffset) % 210 + 20; +var color = new java.awt.Color (r, g, b); +return color; +}, "~S"); +Clazz.defineMethod (c$, "parseAppletParameter", +function (paramValue) { +var st = new java.util.StringTokenizer (paramValue, ";"); +var st2; +var token = null; +var colour; +var residues; +try { +while (st.hasMoreElements ()) { +token = st.nextToken ().trim (); +residues = token.substring (0, token.indexOf ("=")); +colour = token.substring (token.indexOf ("=") + 1); +st2 = new java.util.StringTokenizer (residues, " ,"); +while (st2.hasMoreTokens ()) { +token = st2.nextToken (); +if (jalview.schemes.ResidueProperties.aaIndex[token.charCodeAt (0)] == -1) { +continue; +}var colIndex = jalview.schemes.ResidueProperties.aaIndex[token.charCodeAt (0)]; +if (token.equalsIgnoreCase ("lowerCase")) { +if (this.lowerCaseColours == null) { +this.lowerCaseColours = new Array (23); +}for (var i = 0; i < 23; i++) { +if (this.lowerCaseColours[i] == null) { +this.lowerCaseColours[i] = this.getColourFromString (colour); +}} +continue; +}if (token.equals (token.toLowerCase ())) { +if (this.lowerCaseColours == null) { +this.lowerCaseColours = new Array (23); +}this.lowerCaseColours[colIndex] = this.getColourFromString (colour); +} else { +this.colors[colIndex] = this.getColourFromString (colour); +}} +} +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +System.out.println ("Error parsing userDefinedColours:\n" + token + "\n" + ex); +} else { +throw ex; +} +} +}, "~S"); +Clazz.defineMethod (c$, "findColour", +function (c, j, seq) { +var currentColour; +var index = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)]; +if ((this.threshold == 0) || this.aboveThreshold (c, j)) { +if (this.lowerCaseColours != null && 'a' <= c && c <= 'z') { +currentColour = this.lowerCaseColours[index]; +} else { +currentColour = this.colors[index]; +}} else { +currentColour = java.awt.Color.white; +}if (this.conservationColouring) { +currentColour = this.applyConservation (currentColour, j); +}return currentColour; +}, "~S,~N,jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "setLowerCaseColours", +function (lcolours) { +this.lowerCaseColours = lcolours; +}, "~A"); +}); diff --git a/bin/jalview/schemes/ZappoColourScheme.js b/bin/jalview/schemes/ZappoColourScheme.js index b63064e..fc253d3 100644 --- a/bin/jalview/schemes/ZappoColourScheme.js +++ b/bin/jalview/schemes/ZappoColourScheme.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("jalview.schemes"); -Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.ZappoColourScheme", ["jalview.schemes.ResidueProperties"], function () { -c$ = Clazz.declareType (jalview.schemes, "ZappoColourScheme", jalview.schemes.ResidueColourScheme); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.schemes.ZappoColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.zappo, 0]); -}); -}); +Clazz.declarePackage ("jalview.schemes"); +Clazz.load (["jalview.schemes.ResidueColourScheme"], "jalview.schemes.ZappoColourScheme", ["jalview.schemes.ResidueProperties"], function () { +c$ = Clazz.declareType (jalview.schemes, "ZappoColourScheme", jalview.schemes.ResidueColourScheme); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.schemes.ZappoColourScheme, [jalview.schemes.ResidueProperties.aaIndex, jalview.schemes.ResidueProperties.zappo, 0]); +}); +}); diff --git a/bin/jalview/schemes/package.js b/bin/jalview/schemes/package.js index 5891eb2..045573a 100644 --- a/bin/jalview/schemes/package.js +++ b/bin/jalview/schemes/package.js @@ -1,5 +1,5 @@ -var path = ClazzLoader.getClasspathFor ("jalview.schemes.package"); -path = path.substring (0, path.lastIndexOf ("package.js")); -ClazzLoader.jarClasspath (path + "ClustalxColourScheme.js", [ -"jalview.schemes.ConsensusColour", -"$.ClustalxColourScheme"]); +var path = ClazzLoader.getClasspathFor ("jalview.schemes.package"); +path = path.substring (0, path.lastIndexOf ("package.js")); +ClazzLoader.jarClasspath (path + "ClustalxColourScheme.js", [ +"jalview.schemes.ConsensusColour", +"$.ClustalxColourScheme"]); diff --git a/bin/jalview/structure/AlignmentViewPanelListener.js b/bin/jalview/structure/AlignmentViewPanelListener.js index d293108..979d03f 100644 --- a/bin/jalview/structure/AlignmentViewPanelListener.js +++ b/bin/jalview/structure/AlignmentViewPanelListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "AlignmentViewPanelListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "AlignmentViewPanelListener"); diff --git a/bin/jalview/structure/AtomSpec.js b/bin/jalview/structure/AtomSpec.js index 0023fdc..3e50bc2 100644 --- a/bin/jalview/structure/AtomSpec.js +++ b/bin/jalview/structure/AtomSpec.js @@ -1,35 +1,35 @@ -Clazz.declarePackage ("jalview.structure"); -c$ = Clazz.decorateAsClass (function () { -this.pdbFile = null; -this.chain = null; -this.pdbResNum = 0; -this.atomIndex = 0; -Clazz.instantialize (this, arguments); -}, jalview.structure, "AtomSpec"); -Clazz.makeConstructor (c$, -function (pdbFile, chain, resNo, atomNo) { -this.pdbFile = pdbFile; -this.chain = chain; -this.pdbResNum = resNo; -this.atomIndex = atomNo; -}, "~S,~S,~N,~N"); -Clazz.defineMethod (c$, "getPdbFile", -function () { -return this.pdbFile; -}); -Clazz.defineMethod (c$, "getChain", -function () { -return this.chain; -}); -Clazz.defineMethod (c$, "getPdbResNum", -function () { -return this.pdbResNum; -}); -Clazz.defineMethod (c$, "getAtomIndex", -function () { -return this.atomIndex; -}); -Clazz.overrideMethod (c$, "toString", -function () { -return "pdbFile: " + this.pdbFile + ", chain: " + this.chain + ", res: " + this.pdbResNum + ", atom: " + this.atomIndex; -}); +Clazz.declarePackage ("jalview.structure"); +c$ = Clazz.decorateAsClass (function () { +this.pdbFile = null; +this.chain = null; +this.pdbResNum = 0; +this.atomIndex = 0; +Clazz.instantialize (this, arguments); +}, jalview.structure, "AtomSpec"); +Clazz.makeConstructor (c$, +function (pdbFile, chain, resNo, atomNo) { +this.pdbFile = pdbFile; +this.chain = chain; +this.pdbResNum = resNo; +this.atomIndex = atomNo; +}, "~S,~S,~N,~N"); +Clazz.defineMethod (c$, "getPdbFile", +function () { +return this.pdbFile; +}); +Clazz.defineMethod (c$, "getChain", +function () { +return this.chain; +}); +Clazz.defineMethod (c$, "getPdbResNum", +function () { +return this.pdbResNum; +}); +Clazz.defineMethod (c$, "getAtomIndex", +function () { +return this.atomIndex; +}); +Clazz.overrideMethod (c$, "toString", +function () { +return "pdbFile: " + this.pdbFile + ", chain: " + this.chain + ", res: " + this.pdbResNum + ", atom: " + this.atomIndex; +}); diff --git a/bin/jalview/structure/CommandListener.js b/bin/jalview/structure/CommandListener.js index 8901ca3..5f0c290 100644 --- a/bin/jalview/structure/CommandListener.js +++ b/bin/jalview/structure/CommandListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "CommandListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "CommandListener"); diff --git a/bin/jalview/structure/SecondaryStructureListener.js b/bin/jalview/structure/SecondaryStructureListener.js index b16a9bc..d9e73f4 100644 --- a/bin/jalview/structure/SecondaryStructureListener.js +++ b/bin/jalview/structure/SecondaryStructureListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "SecondaryStructureListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "SecondaryStructureListener"); diff --git a/bin/jalview/structure/SelectionListener.js b/bin/jalview/structure/SelectionListener.js index 6dc17bd..f7ce6dc 100644 --- a/bin/jalview/structure/SelectionListener.js +++ b/bin/jalview/structure/SelectionListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "SelectionListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "SelectionListener"); diff --git a/bin/jalview/structure/SelectionSource.js b/bin/jalview/structure/SelectionSource.js index 7bb91f3..995ec35 100644 --- a/bin/jalview/structure/SelectionSource.js +++ b/bin/jalview/structure/SelectionSource.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "SelectionSource"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "SelectionSource"); diff --git a/bin/jalview/structure/SequenceListener.js b/bin/jalview/structure/SequenceListener.js index 6ff05ae..026c9c1 100644 --- a/bin/jalview/structure/SequenceListener.js +++ b/bin/jalview/structure/SequenceListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "SequenceListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "SequenceListener"); diff --git a/bin/jalview/structure/StructureListener.js b/bin/jalview/structure/StructureListener.js index e5ea9ef..47bde4f 100644 --- a/bin/jalview/structure/StructureListener.js +++ b/bin/jalview/structure/StructureListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "StructureListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "StructureListener"); diff --git a/bin/jalview/structure/StructureMapping.js b/bin/jalview/structure/StructureMapping.js index 40c774f..8cf2f33 100644 --- a/bin/jalview/structure/StructureMapping.js +++ b/bin/jalview/structure/StructureMapping.js @@ -1,69 +1,69 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.load (null, "jalview.structure.StructureMapping", ["jalview.datamodel.AlignmentAnnotation"], function () { -c$ = Clazz.decorateAsClass (function () { -this.mappingDetails = null; -this.sequence = null; -this.pdbfile = null; -this.pdbid = null; -this.pdbchain = null; -this.mapping = null; -Clazz.instantialize (this, arguments); -}, jalview.structure, "StructureMapping"); -Clazz.makeConstructor (c$, -function (seq, pdbfile, pdbid, chain, mapping, mappingDetails) { -this.sequence = seq; -this.pdbfile = pdbfile; -this.pdbid = pdbid; -this.pdbchain = chain; -this.mapping = mapping; -this.mappingDetails = mappingDetails; -}, "jalview.datamodel.SequenceI,~S,~S,~S,~A,~S"); -Clazz.defineMethod (c$, "getSequence", -function () { -return this.sequence; -}); -Clazz.defineMethod (c$, "getChain", -function () { -return this.pdbchain; -}); -Clazz.defineMethod (c$, "getPdbId", -function () { -return this.pdbid; -}); -Clazz.defineMethod (c$, "getAtomNum", -function (seqpos) { -if (this.mapping.length > seqpos) { -return this.mapping[seqpos][1]; -} else { -return 0; -}}, "~N"); -Clazz.defineMethod (c$, "getPDBResNum", -function (seqpos) { -if (this.mapping.length > seqpos) { -return this.mapping[seqpos][0]; -} else { -return 0; -}}, "~N"); -Clazz.defineMethod (c$, "getSeqPos", -function (pdbResNum) { -for (var i = 0; i < this.mapping.length; i++) { -if (this.mapping[i][0] == pdbResNum) { -return i; -}} -return -1; -}, "~N"); -Clazz.defineMethod (c$, "transfer", -function (ana) { -var ala_copy = new jalview.datamodel.AlignmentAnnotation (ana); -var ds = this.sequence; -while (ds.getDatasetSequence () != null) { -ds = ds.getDatasetSequence (); -} -ala_copy.remap (ds, this.mapping, -1, -1, 0); -ds.addAlignmentAnnotation (ala_copy); -if (ds !== this.sequence) { -ala_copy = new jalview.datamodel.AlignmentAnnotation (ala_copy); -this.sequence.addAlignmentAnnotation (ala_copy); -}return ala_copy; -}, "jalview.datamodel.AlignmentAnnotation"); -}); +Clazz.declarePackage ("jalview.structure"); +Clazz.load (null, "jalview.structure.StructureMapping", ["jalview.datamodel.AlignmentAnnotation"], function () { +c$ = Clazz.decorateAsClass (function () { +this.mappingDetails = null; +this.sequence = null; +this.pdbfile = null; +this.pdbid = null; +this.pdbchain = null; +this.mapping = null; +Clazz.instantialize (this, arguments); +}, jalview.structure, "StructureMapping"); +Clazz.makeConstructor (c$, +function (seq, pdbfile, pdbid, chain, mapping, mappingDetails) { +this.sequence = seq; +this.pdbfile = pdbfile; +this.pdbid = pdbid; +this.pdbchain = chain; +this.mapping = mapping; +this.mappingDetails = mappingDetails; +}, "jalview.datamodel.SequenceI,~S,~S,~S,~A,~S"); +Clazz.defineMethod (c$, "getSequence", +function () { +return this.sequence; +}); +Clazz.defineMethod (c$, "getChain", +function () { +return this.pdbchain; +}); +Clazz.defineMethod (c$, "getPdbId", +function () { +return this.pdbid; +}); +Clazz.defineMethod (c$, "getAtomNum", +function (seqpos) { +if (this.mapping.length > seqpos) { +return this.mapping[seqpos][1]; +} else { +return 0; +}}, "~N"); +Clazz.defineMethod (c$, "getPDBResNum", +function (seqpos) { +if (this.mapping.length > seqpos) { +return this.mapping[seqpos][0]; +} else { +return 0; +}}, "~N"); +Clazz.defineMethod (c$, "getSeqPos", +function (pdbResNum) { +for (var i = 0; i < this.mapping.length; i++) { +if (this.mapping[i][0] == pdbResNum) { +return i; +}} +return -1; +}, "~N"); +Clazz.defineMethod (c$, "transfer", +function (ana) { +var ala_copy = new jalview.datamodel.AlignmentAnnotation (ana); +var ds = this.sequence; +while (ds.getDatasetSequence () != null) { +ds = ds.getDatasetSequence (); +} +ala_copy.remap (ds, this.mapping, -1, -1, 0); +ds.addAlignmentAnnotation (ala_copy); +if (ds !== this.sequence) { +ala_copy = new jalview.datamodel.AlignmentAnnotation (ala_copy); +this.sequence.addAlignmentAnnotation (ala_copy); +}return ala_copy; +}, "jalview.datamodel.AlignmentAnnotation"); +}); diff --git a/bin/jalview/structure/StructureMappingcommandSet.js b/bin/jalview/structure/StructureMappingcommandSet.js index 97ef9f5..2f615c6 100644 --- a/bin/jalview/structure/StructureMappingcommandSet.js +++ b/bin/jalview/structure/StructureMappingcommandSet.js @@ -1,13 +1,13 @@ -Clazz.declarePackage ("jalview.structure"); -c$ = Clazz.decorateAsClass (function () { -this.mapping = null; -this.commands = null; -this.handledBy = null; -Clazz.instantialize (this, arguments); -}, jalview.structure, "StructureMappingcommandSet"); -Clazz.makeConstructor (c$, -function (handledBy, files, commands) { -this.mapping = files; -this.handledBy = handledBy; -this.commands = commands; -}, "~O,~S,~A"); +Clazz.declarePackage ("jalview.structure"); +c$ = Clazz.decorateAsClass (function () { +this.mapping = null; +this.commands = null; +this.handledBy = null; +Clazz.instantialize (this, arguments); +}, jalview.structure, "StructureMappingcommandSet"); +Clazz.makeConstructor (c$, +function (handledBy, files, commands) { +this.mapping = files; +this.handledBy = handledBy; +this.commands = commands; +}, "~O,~S,~A"); diff --git a/bin/jalview/structure/StructureSelectionManager.js b/bin/jalview/structure/StructureSelectionManager.js index cdbab51..681a2a7 100644 --- a/bin/jalview/structure/StructureSelectionManager.js +++ b/bin/jalview/structure/StructureSelectionManager.js @@ -1,511 +1,511 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.load (["java.util.ArrayList", "$.HashMap", "$.LinkedHashSet", "$.Vector"], "jalview.structure.StructureSelectionManager", ["MCview.PDBfile", "jalview.analysis.AlignSeq", "jalview.commands.EditCommand", "$.OrderCommand", "jalview.datamodel.Mapping", "$.SearchResults", "jalview.io.AppletFormatAdapter", "jalview.structure.AtomSpec", "$.SecondaryStructureListener", "$.SequenceListener", "$.StructureListener", "$.StructureMapping", "$.VamsasListener", "jalview.util.MappingUtils", "$.MessageManager", "java.lang.Error", "$.NullPointerException", "$.StringBuilder", "java.util.Arrays", "$.Collections", "$.IdentityHashMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.mappings = null; -this.processSecondaryStructure = false; -this.secStructServices = false; -this.addTempFacAnnot = false; -this.seqmappings = null; -this.seqMappingRefCounts = null; -this.commandListeners = null; -this.sel_listeners = null; -this.pdbIdFileName = null; -this.pdbFileNameId = null; -this.relaySeqMappings = true; -this.listeners = null; -this.handlingVamsasMo = false; -this.lastmsg = 0; -this.view_listeners = null; -Clazz.instantialize (this, arguments); -}, jalview.structure, "StructureSelectionManager"); -Clazz.prepareFields (c$, function () { -this.mappings = new java.util.ArrayList (); -this.seqmappings = new java.util.LinkedHashSet (); -this.seqMappingRefCounts = new java.util.HashMap (); -this.commandListeners = new java.util.ArrayList (); -this.sel_listeners = new java.util.ArrayList (); -this.pdbIdFileName = new java.util.HashMap (); -this.pdbFileNameId = new java.util.HashMap (); -this.listeners = new java.util.Vector (); -this.view_listeners = new java.util.Vector (); -}); -Clazz.defineMethod (c$, "isSecStructServices", -function () { -return this.secStructServices; -}); -Clazz.defineMethod (c$, "setSecStructServices", -function (secStructServices) { -this.secStructServices = secStructServices; -}, "~B"); -Clazz.defineMethod (c$, "isAddTempFacAnnot", -function () { -return this.addTempFacAnnot; -}); -Clazz.defineMethod (c$, "setAddTempFacAnnot", -function (addTempFacAnnot) { -this.addTempFacAnnot = addTempFacAnnot; -}, "~B"); -Clazz.defineMethod (c$, "isProcessSecondaryStructure", -function () { -return this.processSecondaryStructure; -}); -Clazz.defineMethod (c$, "setProcessSecondaryStructure", -function (enable) { -this.processSecondaryStructure = enable; -}, "~B"); -Clazz.defineMethod (c$, "reportMapping", -function () { -if (this.mappings.isEmpty ()) { -System.err.println ("reportMapping: No PDB/Sequence mappings."); -} else { -System.err.println ("reportMapping: There are " + this.mappings.size () + " mappings."); -var i = 0; -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -System.err.println ("mapping " + i++ + " : " + sm.pdbfile); -} -}}); -Clazz.defineMethod (c$, "registerPDBFile", -function (idForFile, absoluteFile) { -this.pdbIdFileName.put (idForFile, absoluteFile); -this.pdbFileNameId.put (absoluteFile, idForFile); -}, "~S,~S"); -Clazz.defineMethod (c$, "findIdForPDBFile", -function (idOrFile) { -var id = this.pdbFileNameId.get (idOrFile); -return id; -}, "~S"); -Clazz.defineMethod (c$, "findFileForPDBId", -function (idOrFile) { -var id = this.pdbIdFileName.get (idOrFile); -return id; -}, "~S"); -Clazz.defineMethod (c$, "isPDBFileRegistered", -function (idOrFile) { -return this.pdbFileNameId.containsKey (idOrFile) || this.pdbIdFileName.containsKey (idOrFile); -}, "~S"); -c$.getStructureSelectionManager = Clazz.defineMethod (c$, "getStructureSelectionManager", -function (context) { -if (context == null) { -if (jalview.structure.StructureSelectionManager.nullProvider == null) { -if (jalview.structure.StructureSelectionManager.instances != null) { -throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_structure_selection_manager_null"), new NullPointerException (jalview.util.MessageManager.getString ("exception.ssm_context_is_null"))); -} else { -jalview.structure.StructureSelectionManager.nullProvider = new jalview.structure.StructureSelectionManager (); -}return jalview.structure.StructureSelectionManager.nullProvider; -}}if (jalview.structure.StructureSelectionManager.instances == null) { -jalview.structure.StructureSelectionManager.instances = new java.util.IdentityHashMap (); -}var instance = jalview.structure.StructureSelectionManager.instances.get (context); -if (instance == null) { -if (jalview.structure.StructureSelectionManager.nullProvider != null) { -instance = jalview.structure.StructureSelectionManager.nullProvider; -} else { -instance = new jalview.structure.StructureSelectionManager (); -}jalview.structure.StructureSelectionManager.instances.put (context, instance); -}return instance; -}, "jalview.api.StructureSelectionManagerProvider"); -Clazz.defineMethod (c$, "setRelaySeqMappings", -function (relay) { -this.relaySeqMappings = relay; -}, "~B"); -Clazz.defineMethod (c$, "isRelaySeqMappingsEnabled", -function () { -return this.relaySeqMappings; -}); -Clazz.defineMethod (c$, "addStructureViewerListener", -function (svl) { -if (!this.listeners.contains (svl)) { -this.listeners.addElement (svl); -}}, "~O"); -Clazz.defineMethod (c$, "alreadyMappedToFile", -function (pdbid) { -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -if (sm.getPdbId ().equals (pdbid)) { -return sm.pdbfile; -}} -return null; -}, "~S"); -Clazz.defineMethod (c$, "setMapping", -function (sequence, targetChains, pdbFile, protocol) { -return this.setMapping (true, sequence, targetChains, pdbFile, protocol); -}, "~A,~A,~S,~S"); -Clazz.defineMethod (c$, "setMapping", -function (forStructureView, sequence, targetChains, pdbFile, protocol) { -var parseSecStr = this.processSecondaryStructure; -if (this.isPDBFileRegistered (pdbFile)) { -for (var sq, $sq = 0, $$sq = sequence; $sq < $$sq.length && ((sq = $$sq[$sq]) || true); $sq++) { -var ds = sq; -while (ds.getDatasetSequence () != null) { -ds = ds.getDatasetSequence (); -} -;if (ds.getAnnotation () != null) { -for (var ala, $ala = 0, $$ala = ds.getAnnotation (); $ala < $$ala.length && ((ala = $$ala[$ala]) || true); $ala++) { -if (MCview.PDBfile.isCalcIdForFile (ala, this.findIdForPDBFile (pdbFile))) { -parseSecStr = false; -}} -}} -}var pdb = null; -try { -pdb = new MCview.PDBfile (this.addTempFacAnnot, parseSecStr, this.secStructServices, pdbFile, protocol); -if (pdb.id != null && pdb.id.trim ().length > 0 && jalview.io.AppletFormatAdapter.FILE.equals (protocol)) { -this.registerPDBFile (pdb.id.trim (), pdbFile); -}} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -return null; -} else { -throw ex; -} -} -var targetChain; -for (var s = 0; s < sequence.length; s++) { -var infChain = true; -var seq = sequence[s]; -if (targetChains != null && targetChains[s] != null) { -infChain = false; -targetChain = targetChains[s]; -} else if (seq.getName ().indexOf ("|") > -1) { -targetChain = seq.getName ().substring (seq.getName ().lastIndexOf ("|") + 1); -if (targetChain.length > 1) { -if (targetChain.trim ().length == 0) { -targetChain = " "; -} else { -targetChain = ""; -}}} else { -targetChain = ""; -}var max = -10; -var maxAlignseq = null; -var maxChainId = " "; -var maxChain = null; -var first = true; -for (var chain, $chain = pdb.chains.iterator (); $chain.hasNext () && ((chain = $chain.next ()) || true);) { -if (targetChain.length > 0 && !targetChain.equals (chain.id) && !infChain) { -continue; -}var type = chain.isNa ? "dna" : "pep"; -var as = jalview.analysis.AlignSeq.doGlobalNWAlignment (seq, chain.sequence, type); -if (first || as.maxscore > max || (as.maxscore == max && chain.id.equals (targetChain))) { -first = false; -maxChain = chain; -max = as.maxscore; -maxAlignseq = as; -maxChainId = chain.id; -}} -if (maxChain == null) { -continue; -}var mappingDetails = new StringBuilder (128); -mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("PDB Sequence is :").append (jalview.structure.StructureSelectionManager.NEWLINE).append ("Sequence = ").append (maxChain.sequence.getSequenceAsString ()); -mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("No of residues = ").append (maxChain.residues.size ()).append (jalview.structure.StructureSelectionManager.NEWLINE).append (jalview.structure.StructureSelectionManager.NEWLINE); -var ps = ((Clazz.isClassDefined ("jalview.structure.StructureSelectionManager$1") ? 0 : jalview.structure.StructureSelectionManager.$StructureSelectionManager$1$ ()), Clazz.innerTypeInstance (jalview.structure.StructureSelectionManager$1, this, Clazz.cloneFinals ("mappingDetails", mappingDetails), System.out)); -maxAlignseq.printAlignment (ps); -mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("PDB start/end "); -mappingDetails.append (String.valueOf (maxAlignseq.seq2start)).append (" "); -mappingDetails.append (String.valueOf (maxAlignseq.seq2end)); -mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("SEQ start/end "); -mappingDetails.append (String.valueOf (maxAlignseq.seq1start + seq.getStart () - 1)).append (" "); -mappingDetails.append (String.valueOf (maxAlignseq.seq1end + seq.getEnd () - 1)); -maxChain.makeExactMapping (maxAlignseq, seq); -var sqmpping = maxAlignseq.getMappingFromS1 (false); -var omap = new jalview.datamodel.Mapping (sqmpping.getMap ().getInverse ()); -maxChain.transferRESNUMFeatures (seq, null); -var mapping = Clazz.newIntArray (seq.findPosition (seq.getLength ()) + 2, 2, 0); -var resNum = -10000; -var index = 0; -do { -var tmp = maxChain.atoms.elementAt (index); -if (resNum != tmp.resNumber && tmp.alignmentMapping != -1) { -resNum = tmp.resNumber; -mapping[tmp.alignmentMapping + 1][0] = tmp.resNumber; -mapping[tmp.alignmentMapping + 1][1] = tmp.atomIndex; -}index++; -} while (index < maxChain.atoms.size ()); -if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) { -pdbFile = "INLINE" + pdb.id; -}var newMapping = new jalview.structure.StructureMapping (seq, pdbFile, pdb.id, maxChainId, mapping, mappingDetails.toString ()); -if (forStructureView) { -this.mappings.add (newMapping); -}maxChain.transferResidueAnnotation (newMapping, sqmpping); -} -return pdb; -}, "~B,~A,~A,~S,~S"); -Clazz.defineMethod (c$, "removeStructureViewerListener", -function (svl, pdbfiles) { -this.listeners.removeElement (svl); -if (Clazz.instanceOf (svl, jalview.structure.SequenceListener)) { -for (var i = 0; i < this.listeners.size (); i++) { -if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.StructureListener)) { -(this.listeners.elementAt (i)).releaseReferences (svl); -}} -}if (pdbfiles == null) { -return; -}var pdbs = new java.util.ArrayList (java.util.Arrays.asList (pdbfiles)); -var sl; -for (var i = 0; i < this.listeners.size (); i++) { -if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.StructureListener)) { -sl = this.listeners.elementAt (i); -for (var pdbfile, $pdbfile = 0, $$pdbfile = sl.getPdbFile (); $pdbfile < $$pdbfile.length && ((pdbfile = $$pdbfile[$pdbfile]) || true); $pdbfile++) { -pdbs.remove (pdbfile); -} -}} -if (pdbs.size () > 0) { -var tmp = new java.util.ArrayList (); -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -if (!pdbs.contains (sm.pdbfile)) { -tmp.add (sm); -}} -this.mappings = tmp; -}}, "~O,~A"); -Clazz.defineMethod (c$, "mouseOverStructure", -function (pdbResNum, chain, pdbfile) { -var atomSpec = new jalview.structure.AtomSpec (pdbfile, chain, pdbResNum, 0); -var atoms = java.util.Collections.singletonList (atomSpec); -this.mouseOverStructure (atoms); -}, "~N,~S,~S"); -Clazz.defineMethod (c$, "mouseOverStructure", -function (atoms) { -if (this.listeners == null) { -return; -}var hasSequenceListener = false; -for (var i = 0; i < this.listeners.size (); i++) { -if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.SequenceListener)) { -hasSequenceListener = true; -}} -if (!hasSequenceListener) { -return; -}var results = new jalview.datamodel.SearchResults (); -for (var atom, $atom = atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { -var lastseq = null; -var lastipos = -1; -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -if (sm.pdbfile.equals (atom.getPdbFile ()) && sm.pdbchain.equals (atom.getChain ())) { -var indexpos = sm.getSeqPos (atom.getPdbResNum ()); -if (lastipos != indexpos && lastseq !== sm.sequence) { -results.addResult (sm.sequence, indexpos, indexpos); -lastipos = indexpos; -lastseq = sm.sequence; -for (var acf, $acf = this.seqmappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -acf.markMappedRegion (sm.sequence, indexpos, results); -} -}}} -} -for (var li, $li = this.listeners.iterator (); $li.hasNext () && ((li = $li.next ()) || true);) { -if (Clazz.instanceOf (li, jalview.structure.SequenceListener)) { -(li).highlightSequence (results); -}} -}, "java.util.List"); -Clazz.defineMethod (c$, "mouseOverSequence", -function (seq, indexpos, index, source) { -var hasSequenceListeners = this.handlingVamsasMo || !this.seqmappings.isEmpty (); -var results = null; -if (index == -1) { -index = seq.findPosition (indexpos); -}for (var i = 0; i < this.listeners.size (); i++) { -var listener = this.listeners.elementAt (i); -if (listener === source) { -continue; -}if (Clazz.instanceOf (listener, jalview.structure.StructureListener)) { -this.highlightStructure (listener, seq, index); -} else { -if (Clazz.instanceOf (listener, jalview.structure.SequenceListener)) { -var seqListener = listener; -if (hasSequenceListeners && seqListener.getVamsasSource () !== source) { -if (this.relaySeqMappings) { -if (results == null) { -results = jalview.util.MappingUtils.buildSearchResults (seq, index, this.seqmappings); -}if (this.handlingVamsasMo) { -results.addResult (seq, index, index); -}seqListener.highlightSequence (results); -}}} else if (Clazz.instanceOf (listener, jalview.structure.VamsasListener) && !this.handlingVamsasMo) { -(listener).mouseOverSequence (seq, indexpos, source); -} else if (Clazz.instanceOf (listener, jalview.structure.SecondaryStructureListener)) { -(listener).mouseOverSequence (seq, indexpos, index); -}}} -}, "jalview.datamodel.SequenceI,~N,~N,jalview.structure.VamsasSource"); -Clazz.defineMethod (c$, "highlightStructure", -function (sl, seq, index) { -if (!sl.isListeningFor (seq)) { -return; -}var atomNo; -var atoms = new java.util.ArrayList (); -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -if (sm.sequence === seq || sm.sequence === seq.getDatasetSequence ()) { -atomNo = sm.getAtomNum (index); -if (atomNo > 0) { -atoms.add ( new jalview.structure.AtomSpec (sm.pdbfile, sm.pdbchain, sm.getPDBResNum (index), atomNo)); -}}} -sl.highlightAtoms (atoms); -}, "jalview.structure.StructureListener,jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "mouseOverVamsasSequence", -function (sequenceI, position, source) { -this.handlingVamsasMo = true; -var msg = sequenceI.hashCode () * (1 + position); -if (this.lastmsg != msg) { -this.lastmsg = msg; -this.mouseOverSequence (sequenceI, position, -1, source); -}this.handlingVamsasMo = false; -}, "jalview.datamodel.SequenceI,~N,jalview.structure.VamsasSource"); -Clazz.defineMethod (c$, "colourSequenceFromStructure", -function (seq, pdbid) { -return null; -}, "jalview.datamodel.SequenceI,~S"); -Clazz.defineMethod (c$, "structureSelectionChanged", -function () { -}); -Clazz.defineMethod (c$, "sequenceSelectionChanged", -function () { -}); -Clazz.defineMethod (c$, "sequenceColoursChanged", -function (source) { -var sl; -for (var i = 0; i < this.listeners.size (); i++) { -if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.StructureListener)) { -sl = this.listeners.elementAt (i); -sl.updateColours (source); -}} -}, "~O"); -Clazz.defineMethod (c$, "getMapping", -function (pdbfile) { -var tmp = new java.util.ArrayList (); -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -if (sm.pdbfile.equals (pdbfile)) { -tmp.add (sm); -}} -return tmp.toArray ( new Array (tmp.size ())); -}, "~S"); -Clazz.defineMethod (c$, "printMappings", -function (pdbfile, seqs) { -if (pdbfile == null || seqs == null || seqs.isEmpty ()) { -return ""; -}var sb = new StringBuilder (64); -for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { -if (sm.pdbfile.equals (pdbfile) && seqs.contains (sm.sequence)) { -sb.append (sm.mappingDetails); -sb.append (jalview.structure.StructureSelectionManager.NEWLINE); -sb.append ("====================="); -sb.append (jalview.structure.StructureSelectionManager.NEWLINE); -}} -sb.append (jalview.structure.StructureSelectionManager.NEWLINE); -return sb.toString (); -}, "~S,java.util.List"); -Clazz.defineMethod (c$, "removeMappings", -function (set) { -if (set != null) { -for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -this.removeMapping (acf); -} -}}, "java.util.Set"); -Clazz.defineMethod (c$, "removeMapping", -function (acf) { -if (acf != null && this.seqmappings.contains (acf)) { -var count = (this.seqMappingRefCounts.get (acf)).intValue (); -count--; -if (count > 0) { -this.seqMappingRefCounts.put (acf, new Integer (count)); -} else { -this.seqmappings.remove (acf); -this.seqMappingRefCounts.remove (acf); -}}}, "jalview.datamodel.AlignedCodonFrame"); -Clazz.defineMethod (c$, "addMappings", -function (set) { -if (set != null) { -for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -this.addMapping (acf); -} -}}, "java.util.Set"); -Clazz.defineMethod (c$, "addMapping", -function (acf) { -if (acf != null) { -if (this.seqmappings.contains (acf)) { -this.seqMappingRefCounts.put (acf, new Integer ((this.seqMappingRefCounts.get (acf)).intValue () + 1)); -} else { -this.seqmappings.add (acf); -this.seqMappingRefCounts.put (acf, new Integer (1)); -}}}, "jalview.datamodel.AlignedCodonFrame"); -Clazz.defineMethod (c$, "addSelectionListener", -function (selecter) { -if (!this.sel_listeners.contains (selecter)) { -this.sel_listeners.add (selecter); -}}, "jalview.structure.SelectionListener"); -Clazz.defineMethod (c$, "removeSelectionListener", -function (toremove) { -if (this.sel_listeners.contains (toremove)) { -this.sel_listeners.remove (toremove); -}}, "jalview.structure.SelectionListener"); -Clazz.defineMethod (c$, "sendSelection", -function (selection, colsel, source) { -for (var slis, $slis = this.sel_listeners.iterator (); $slis.hasNext () && ((slis = $slis.next ()) || true);) { -if (slis !== source) { -slis.selection (selection, colsel, source); -}} -}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); -Clazz.defineMethod (c$, "sendViewPosition", -function (source, startRes, endRes, startSeq, endSeq) { -if (this.view_listeners != null && this.view_listeners.size () > 0) { -var listeners = this.view_listeners.elements (); -while (listeners.hasMoreElements ()) { -var slis = listeners.nextElement (); -if (slis !== source) { -slis.viewPosition (startRes, endRes, startSeq, endSeq, source); -};} -}}, "jalview.api.AlignmentViewPanel,~N,~N,~N,~N"); -c$.release = Clazz.defineMethod (c$, "release", -function (jalviewLite) { -{ -if (jalview.structure.StructureSelectionManager.instances == null) { -return; -}var mnger = (jalview.structure.StructureSelectionManager.instances.get (jalviewLite)); -if (mnger != null) { -jalview.structure.StructureSelectionManager.instances.remove (jalviewLite); -try { -mnger.finalize (); -} catch (x) { -} -}}}, "jalview.api.StructureSelectionManagerProvider"); -Clazz.defineMethod (c$, "registerPDBEntry", -function (pdbentry) { -if (pdbentry.getFile () != null && pdbentry.getFile ().trim ().length > 0) { -this.registerPDBFile (pdbentry.getId (), pdbentry.getFile ()); -}}, "jalview.datamodel.PDBEntry"); -Clazz.defineMethod (c$, "addCommandListener", -function (cl) { -if (!this.commandListeners.contains (cl)) { -this.commandListeners.add (cl); -}}, "jalview.structure.CommandListener"); -Clazz.defineMethod (c$, "hasCommandListener", -function (cl) { -return this.commandListeners.contains (cl); -}, "jalview.structure.CommandListener"); -Clazz.defineMethod (c$, "removeCommandListener", -function (l) { -return this.commandListeners.remove (l); -}, "jalview.structure.CommandListener"); -Clazz.defineMethod (c$, "commandPerformed", -function (command, undo, source) { -for (var listener, $listener = this.commandListeners.iterator (); $listener.hasNext () && ((listener = $listener.next ()) || true);) { -listener.mirrorCommand (command, undo, this, source); -} -}, "jalview.commands.CommandI,~B,jalview.structure.VamsasSource"); -Clazz.defineMethod (c$, "mapCommand", -function (command, undo, mapTo, gapChar) { -if (Clazz.instanceOf (command, jalview.commands.EditCommand)) { -return jalview.util.MappingUtils.mapEditCommand (command, undo, mapTo, gapChar, this.seqmappings); -} else if (Clazz.instanceOf (command, jalview.commands.OrderCommand)) { -return jalview.util.MappingUtils.mapOrderCommand (command, undo, mapTo, this.seqmappings); -}return null; -}, "jalview.commands.CommandI,~B,jalview.datamodel.AlignmentI,~S"); -c$.$StructureSelectionManager$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.structure, "StructureSelectionManager$1", java.io.PrintStream); -Clazz.defineMethod (c$, "print", -function (x) { -this.f$.mappingDetails.append (x); -}, "~S"); -Clazz.defineMethod (c$, "println", -function () { -this.f$.mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE); -}); -c$ = Clazz.p0p (); -}; -c$.NEWLINE = c$.prototype.NEWLINE = System.lineSeparator (); -Clazz.defineStatics (c$, -"instances", null, -"nullProvider", null); -}); +Clazz.declarePackage ("jalview.structure"); +Clazz.load (["java.util.ArrayList", "$.HashMap", "$.LinkedHashSet", "$.Vector"], "jalview.structure.StructureSelectionManager", ["MCview.PDBfile", "jalview.analysis.AlignSeq", "jalview.commands.EditCommand", "$.OrderCommand", "jalview.datamodel.Mapping", "$.SearchResults", "jalview.io.AppletFormatAdapter", "jalview.structure.AtomSpec", "$.SecondaryStructureListener", "$.SequenceListener", "$.StructureListener", "$.StructureMapping", "$.VamsasListener", "jalview.util.MappingUtils", "$.MessageManager", "java.lang.Error", "$.NullPointerException", "$.StringBuilder", "java.util.Arrays", "$.Collections", "$.IdentityHashMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.mappings = null; +this.processSecondaryStructure = false; +this.secStructServices = false; +this.addTempFacAnnot = false; +this.seqmappings = null; +this.seqMappingRefCounts = null; +this.commandListeners = null; +this.sel_listeners = null; +this.pdbIdFileName = null; +this.pdbFileNameId = null; +this.relaySeqMappings = true; +this.listeners = null; +this.handlingVamsasMo = false; +this.lastmsg = 0; +this.view_listeners = null; +Clazz.instantialize (this, arguments); +}, jalview.structure, "StructureSelectionManager"); +Clazz.prepareFields (c$, function () { +this.mappings = new java.util.ArrayList (); +this.seqmappings = new java.util.LinkedHashSet (); +this.seqMappingRefCounts = new java.util.HashMap (); +this.commandListeners = new java.util.ArrayList (); +this.sel_listeners = new java.util.ArrayList (); +this.pdbIdFileName = new java.util.HashMap (); +this.pdbFileNameId = new java.util.HashMap (); +this.listeners = new java.util.Vector (); +this.view_listeners = new java.util.Vector (); +}); +Clazz.defineMethod (c$, "isSecStructServices", +function () { +return this.secStructServices; +}); +Clazz.defineMethod (c$, "setSecStructServices", +function (secStructServices) { +this.secStructServices = secStructServices; +}, "~B"); +Clazz.defineMethod (c$, "isAddTempFacAnnot", +function () { +return this.addTempFacAnnot; +}); +Clazz.defineMethod (c$, "setAddTempFacAnnot", +function (addTempFacAnnot) { +this.addTempFacAnnot = addTempFacAnnot; +}, "~B"); +Clazz.defineMethod (c$, "isProcessSecondaryStructure", +function () { +return this.processSecondaryStructure; +}); +Clazz.defineMethod (c$, "setProcessSecondaryStructure", +function (enable) { +this.processSecondaryStructure = enable; +}, "~B"); +Clazz.defineMethod (c$, "reportMapping", +function () { +if (this.mappings.isEmpty ()) { +System.err.println ("reportMapping: No PDB/Sequence mappings."); +} else { +System.err.println ("reportMapping: There are " + this.mappings.size () + " mappings."); +var i = 0; +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +System.err.println ("mapping " + i++ + " : " + sm.pdbfile); +} +}}); +Clazz.defineMethod (c$, "registerPDBFile", +function (idForFile, absoluteFile) { +this.pdbIdFileName.put (idForFile, absoluteFile); +this.pdbFileNameId.put (absoluteFile, idForFile); +}, "~S,~S"); +Clazz.defineMethod (c$, "findIdForPDBFile", +function (idOrFile) { +var id = this.pdbFileNameId.get (idOrFile); +return id; +}, "~S"); +Clazz.defineMethod (c$, "findFileForPDBId", +function (idOrFile) { +var id = this.pdbIdFileName.get (idOrFile); +return id; +}, "~S"); +Clazz.defineMethod (c$, "isPDBFileRegistered", +function (idOrFile) { +return this.pdbFileNameId.containsKey (idOrFile) || this.pdbIdFileName.containsKey (idOrFile); +}, "~S"); +c$.getStructureSelectionManager = Clazz.defineMethod (c$, "getStructureSelectionManager", +function (context) { +if (context == null) { +if (jalview.structure.StructureSelectionManager.nullProvider == null) { +if (jalview.structure.StructureSelectionManager.instances != null) { +throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_structure_selection_manager_null"), new NullPointerException (jalview.util.MessageManager.getString ("exception.ssm_context_is_null"))); +} else { +jalview.structure.StructureSelectionManager.nullProvider = new jalview.structure.StructureSelectionManager (); +}return jalview.structure.StructureSelectionManager.nullProvider; +}}if (jalview.structure.StructureSelectionManager.instances == null) { +jalview.structure.StructureSelectionManager.instances = new java.util.IdentityHashMap (); +}var instance = jalview.structure.StructureSelectionManager.instances.get (context); +if (instance == null) { +if (jalview.structure.StructureSelectionManager.nullProvider != null) { +instance = jalview.structure.StructureSelectionManager.nullProvider; +} else { +instance = new jalview.structure.StructureSelectionManager (); +}jalview.structure.StructureSelectionManager.instances.put (context, instance); +}return instance; +}, "jalview.api.StructureSelectionManagerProvider"); +Clazz.defineMethod (c$, "setRelaySeqMappings", +function (relay) { +this.relaySeqMappings = relay; +}, "~B"); +Clazz.defineMethod (c$, "isRelaySeqMappingsEnabled", +function () { +return this.relaySeqMappings; +}); +Clazz.defineMethod (c$, "addStructureViewerListener", +function (svl) { +if (!this.listeners.contains (svl)) { +this.listeners.addElement (svl); +}}, "~O"); +Clazz.defineMethod (c$, "alreadyMappedToFile", +function (pdbid) { +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +if (sm.getPdbId ().equals (pdbid)) { +return sm.pdbfile; +}} +return null; +}, "~S"); +Clazz.defineMethod (c$, "setMapping", +function (sequence, targetChains, pdbFile, protocol) { +return this.setMapping (true, sequence, targetChains, pdbFile, protocol); +}, "~A,~A,~S,~S"); +Clazz.defineMethod (c$, "setMapping", +function (forStructureView, sequence, targetChains, pdbFile, protocol) { +var parseSecStr = this.processSecondaryStructure; +if (this.isPDBFileRegistered (pdbFile)) { +for (var sq, $sq = 0, $$sq = sequence; $sq < $$sq.length && ((sq = $$sq[$sq]) || true); $sq++) { +var ds = sq; +while (ds.getDatasetSequence () != null) { +ds = ds.getDatasetSequence (); +} +;if (ds.getAnnotation () != null) { +for (var ala, $ala = 0, $$ala = ds.getAnnotation (); $ala < $$ala.length && ((ala = $$ala[$ala]) || true); $ala++) { +if (MCview.PDBfile.isCalcIdForFile (ala, this.findIdForPDBFile (pdbFile))) { +parseSecStr = false; +}} +}} +}var pdb = null; +try { +pdb = new MCview.PDBfile (this.addTempFacAnnot, parseSecStr, this.secStructServices, pdbFile, protocol); +if (pdb.id != null && pdb.id.trim ().length > 0 && jalview.io.AppletFormatAdapter.FILE.equals (protocol)) { +this.registerPDBFile (pdb.id.trim (), pdbFile); +}} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +return null; +} else { +throw ex; +} +} +var targetChain; +for (var s = 0; s < sequence.length; s++) { +var infChain = true; +var seq = sequence[s]; +if (targetChains != null && targetChains[s] != null) { +infChain = false; +targetChain = targetChains[s]; +} else if (seq.getName ().indexOf ("|") > -1) { +targetChain = seq.getName ().substring (seq.getName ().lastIndexOf ("|") + 1); +if (targetChain.length > 1) { +if (targetChain.trim ().length == 0) { +targetChain = " "; +} else { +targetChain = ""; +}}} else { +targetChain = ""; +}var max = -10; +var maxAlignseq = null; +var maxChainId = " "; +var maxChain = null; +var first = true; +for (var chain, $chain = pdb.chains.iterator (); $chain.hasNext () && ((chain = $chain.next ()) || true);) { +if (targetChain.length > 0 && !targetChain.equals (chain.id) && !infChain) { +continue; +}var type = chain.isNa ? "dna" : "pep"; +var as = jalview.analysis.AlignSeq.doGlobalNWAlignment (seq, chain.sequence, type); +if (first || as.maxscore > max || (as.maxscore == max && chain.id.equals (targetChain))) { +first = false; +maxChain = chain; +max = as.maxscore; +maxAlignseq = as; +maxChainId = chain.id; +}} +if (maxChain == null) { +continue; +}var mappingDetails = new StringBuilder (128); +mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("PDB Sequence is :").append (jalview.structure.StructureSelectionManager.NEWLINE).append ("Sequence = ").append (maxChain.sequence.getSequenceAsString ()); +mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("No of residues = ").append (maxChain.residues.size ()).append (jalview.structure.StructureSelectionManager.NEWLINE).append (jalview.structure.StructureSelectionManager.NEWLINE); +var ps = ((Clazz.isClassDefined ("jalview.structure.StructureSelectionManager$1") ? 0 : jalview.structure.StructureSelectionManager.$StructureSelectionManager$1$ ()), Clazz.innerTypeInstance (jalview.structure.StructureSelectionManager$1, this, Clazz.cloneFinals ("mappingDetails", mappingDetails), System.out)); +maxAlignseq.printAlignment (ps); +mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("PDB start/end "); +mappingDetails.append (String.valueOf (maxAlignseq.seq2start)).append (" "); +mappingDetails.append (String.valueOf (maxAlignseq.seq2end)); +mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE).append ("SEQ start/end "); +mappingDetails.append (String.valueOf (maxAlignseq.seq1start + seq.getStart () - 1)).append (" "); +mappingDetails.append (String.valueOf (maxAlignseq.seq1end + seq.getEnd () - 1)); +maxChain.makeExactMapping (maxAlignseq, seq); +var sqmpping = maxAlignseq.getMappingFromS1 (false); +var omap = new jalview.datamodel.Mapping (sqmpping.getMap ().getInverse ()); +maxChain.transferRESNUMFeatures (seq, null); +var mapping = Clazz.newIntArray (seq.findPosition (seq.getLength ()) + 2, 2, 0); +var resNum = -10000; +var index = 0; +do { +var tmp = maxChain.atoms.elementAt (index); +if (resNum != tmp.resNumber && tmp.alignmentMapping != -1) { +resNum = tmp.resNumber; +mapping[tmp.alignmentMapping + 1][0] = tmp.resNumber; +mapping[tmp.alignmentMapping + 1][1] = tmp.atomIndex; +}index++; +} while (index < maxChain.atoms.size ()); +if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) { +pdbFile = "INLINE" + pdb.id; +}var newMapping = new jalview.structure.StructureMapping (seq, pdbFile, pdb.id, maxChainId, mapping, mappingDetails.toString ()); +if (forStructureView) { +this.mappings.add (newMapping); +}maxChain.transferResidueAnnotation (newMapping, sqmpping); +} +return pdb; +}, "~B,~A,~A,~S,~S"); +Clazz.defineMethod (c$, "removeStructureViewerListener", +function (svl, pdbfiles) { +this.listeners.removeElement (svl); +if (Clazz.instanceOf (svl, jalview.structure.SequenceListener)) { +for (var i = 0; i < this.listeners.size (); i++) { +if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.StructureListener)) { +(this.listeners.elementAt (i)).releaseReferences (svl); +}} +}if (pdbfiles == null) { +return; +}var pdbs = new java.util.ArrayList (java.util.Arrays.asList (pdbfiles)); +var sl; +for (var i = 0; i < this.listeners.size (); i++) { +if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.StructureListener)) { +sl = this.listeners.elementAt (i); +for (var pdbfile, $pdbfile = 0, $$pdbfile = sl.getPdbFile (); $pdbfile < $$pdbfile.length && ((pdbfile = $$pdbfile[$pdbfile]) || true); $pdbfile++) { +pdbs.remove (pdbfile); +} +}} +if (pdbs.size () > 0) { +var tmp = new java.util.ArrayList (); +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +if (!pdbs.contains (sm.pdbfile)) { +tmp.add (sm); +}} +this.mappings = tmp; +}}, "~O,~A"); +Clazz.defineMethod (c$, "mouseOverStructure", +function (pdbResNum, chain, pdbfile) { +var atomSpec = new jalview.structure.AtomSpec (pdbfile, chain, pdbResNum, 0); +var atoms = java.util.Collections.singletonList (atomSpec); +this.mouseOverStructure (atoms); +}, "~N,~S,~S"); +Clazz.defineMethod (c$, "mouseOverStructure", +function (atoms) { +if (this.listeners == null) { +return; +}var hasSequenceListener = false; +for (var i = 0; i < this.listeners.size (); i++) { +if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.SequenceListener)) { +hasSequenceListener = true; +}} +if (!hasSequenceListener) { +return; +}var results = new jalview.datamodel.SearchResults (); +for (var atom, $atom = atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) { +var lastseq = null; +var lastipos = -1; +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +if (sm.pdbfile.equals (atom.getPdbFile ()) && sm.pdbchain.equals (atom.getChain ())) { +var indexpos = sm.getSeqPos (atom.getPdbResNum ()); +if (lastipos != indexpos && lastseq !== sm.sequence) { +results.addResult (sm.sequence, indexpos, indexpos); +lastipos = indexpos; +lastseq = sm.sequence; +for (var acf, $acf = this.seqmappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +acf.markMappedRegion (sm.sequence, indexpos, results); +} +}}} +} +for (var li, $li = this.listeners.iterator (); $li.hasNext () && ((li = $li.next ()) || true);) { +if (Clazz.instanceOf (li, jalview.structure.SequenceListener)) { +(li).highlightSequence (results); +}} +}, "java.util.List"); +Clazz.defineMethod (c$, "mouseOverSequence", +function (seq, indexpos, index, source) { +var hasSequenceListeners = this.handlingVamsasMo || !this.seqmappings.isEmpty (); +var results = null; +if (index == -1) { +index = seq.findPosition (indexpos); +}for (var i = 0; i < this.listeners.size (); i++) { +var listener = this.listeners.elementAt (i); +if (listener === source) { +continue; +}if (Clazz.instanceOf (listener, jalview.structure.StructureListener)) { +this.highlightStructure (listener, seq, index); +} else { +if (Clazz.instanceOf (listener, jalview.structure.SequenceListener)) { +var seqListener = listener; +if (hasSequenceListeners && seqListener.getVamsasSource () !== source) { +if (this.relaySeqMappings) { +if (results == null) { +results = jalview.util.MappingUtils.buildSearchResults (seq, index, this.seqmappings); +}if (this.handlingVamsasMo) { +results.addResult (seq, index, index); +}seqListener.highlightSequence (results); +}}} else if (Clazz.instanceOf (listener, jalview.structure.VamsasListener) && !this.handlingVamsasMo) { +(listener).mouseOverSequence (seq, indexpos, source); +} else if (Clazz.instanceOf (listener, jalview.structure.SecondaryStructureListener)) { +(listener).mouseOverSequence (seq, indexpos, index); +}}} +}, "jalview.datamodel.SequenceI,~N,~N,jalview.structure.VamsasSource"); +Clazz.defineMethod (c$, "highlightStructure", +function (sl, seq, index) { +if (!sl.isListeningFor (seq)) { +return; +}var atomNo; +var atoms = new java.util.ArrayList (); +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +if (sm.sequence === seq || sm.sequence === seq.getDatasetSequence ()) { +atomNo = sm.getAtomNum (index); +if (atomNo > 0) { +atoms.add ( new jalview.structure.AtomSpec (sm.pdbfile, sm.pdbchain, sm.getPDBResNum (index), atomNo)); +}}} +sl.highlightAtoms (atoms); +}, "jalview.structure.StructureListener,jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "mouseOverVamsasSequence", +function (sequenceI, position, source) { +this.handlingVamsasMo = true; +var msg = sequenceI.hashCode () * (1 + position); +if (this.lastmsg != msg) { +this.lastmsg = msg; +this.mouseOverSequence (sequenceI, position, -1, source); +}this.handlingVamsasMo = false; +}, "jalview.datamodel.SequenceI,~N,jalview.structure.VamsasSource"); +Clazz.defineMethod (c$, "colourSequenceFromStructure", +function (seq, pdbid) { +return null; +}, "jalview.datamodel.SequenceI,~S"); +Clazz.defineMethod (c$, "structureSelectionChanged", +function () { +}); +Clazz.defineMethod (c$, "sequenceSelectionChanged", +function () { +}); +Clazz.defineMethod (c$, "sequenceColoursChanged", +function (source) { +var sl; +for (var i = 0; i < this.listeners.size (); i++) { +if (Clazz.instanceOf (this.listeners.elementAt (i), jalview.structure.StructureListener)) { +sl = this.listeners.elementAt (i); +sl.updateColours (source); +}} +}, "~O"); +Clazz.defineMethod (c$, "getMapping", +function (pdbfile) { +var tmp = new java.util.ArrayList (); +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +if (sm.pdbfile.equals (pdbfile)) { +tmp.add (sm); +}} +return tmp.toArray ( new Array (tmp.size ())); +}, "~S"); +Clazz.defineMethod (c$, "printMappings", +function (pdbfile, seqs) { +if (pdbfile == null || seqs == null || seqs.isEmpty ()) { +return ""; +}var sb = new StringBuilder (64); +for (var sm, $sm = this.mappings.iterator (); $sm.hasNext () && ((sm = $sm.next ()) || true);) { +if (sm.pdbfile.equals (pdbfile) && seqs.contains (sm.sequence)) { +sb.append (sm.mappingDetails); +sb.append (jalview.structure.StructureSelectionManager.NEWLINE); +sb.append ("====================="); +sb.append (jalview.structure.StructureSelectionManager.NEWLINE); +}} +sb.append (jalview.structure.StructureSelectionManager.NEWLINE); +return sb.toString (); +}, "~S,java.util.List"); +Clazz.defineMethod (c$, "removeMappings", +function (set) { +if (set != null) { +for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +this.removeMapping (acf); +} +}}, "java.util.Set"); +Clazz.defineMethod (c$, "removeMapping", +function (acf) { +if (acf != null && this.seqmappings.contains (acf)) { +var count = (this.seqMappingRefCounts.get (acf)).intValue (); +count--; +if (count > 0) { +this.seqMappingRefCounts.put (acf, new Integer (count)); +} else { +this.seqmappings.remove (acf); +this.seqMappingRefCounts.remove (acf); +}}}, "jalview.datamodel.AlignedCodonFrame"); +Clazz.defineMethod (c$, "addMappings", +function (set) { +if (set != null) { +for (var acf, $acf = set.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +this.addMapping (acf); +} +}}, "java.util.Set"); +Clazz.defineMethod (c$, "addMapping", +function (acf) { +if (acf != null) { +if (this.seqmappings.contains (acf)) { +this.seqMappingRefCounts.put (acf, new Integer ((this.seqMappingRefCounts.get (acf)).intValue () + 1)); +} else { +this.seqmappings.add (acf); +this.seqMappingRefCounts.put (acf, new Integer (1)); +}}}, "jalview.datamodel.AlignedCodonFrame"); +Clazz.defineMethod (c$, "addSelectionListener", +function (selecter) { +if (!this.sel_listeners.contains (selecter)) { +this.sel_listeners.add (selecter); +}}, "jalview.structure.SelectionListener"); +Clazz.defineMethod (c$, "removeSelectionListener", +function (toremove) { +if (this.sel_listeners.contains (toremove)) { +this.sel_listeners.remove (toremove); +}}, "jalview.structure.SelectionListener"); +Clazz.defineMethod (c$, "sendSelection", +function (selection, colsel, source) { +for (var slis, $slis = this.sel_listeners.iterator (); $slis.hasNext () && ((slis = $slis.next ()) || true);) { +if (slis !== source) { +slis.selection (selection, colsel, source); +}} +}, "jalview.datamodel.SequenceGroup,jalview.datamodel.ColumnSelection,jalview.structure.SelectionSource"); +Clazz.defineMethod (c$, "sendViewPosition", +function (source, startRes, endRes, startSeq, endSeq) { +if (this.view_listeners != null && this.view_listeners.size () > 0) { +var listeners = this.view_listeners.elements (); +while (listeners.hasMoreElements ()) { +var slis = listeners.nextElement (); +if (slis !== source) { +slis.viewPosition (startRes, endRes, startSeq, endSeq, source); +};} +}}, "jalview.api.AlignmentViewPanel,~N,~N,~N,~N"); +c$.release = Clazz.defineMethod (c$, "release", +function (jalviewLite) { +{ +if (jalview.structure.StructureSelectionManager.instances == null) { +return; +}var mnger = (jalview.structure.StructureSelectionManager.instances.get (jalviewLite)); +if (mnger != null) { +jalview.structure.StructureSelectionManager.instances.remove (jalviewLite); +try { +mnger.finalize (); +} catch (x) { +} +}}}, "jalview.api.StructureSelectionManagerProvider"); +Clazz.defineMethod (c$, "registerPDBEntry", +function (pdbentry) { +if (pdbentry.getFile () != null && pdbentry.getFile ().trim ().length > 0) { +this.registerPDBFile (pdbentry.getId (), pdbentry.getFile ()); +}}, "jalview.datamodel.PDBEntry"); +Clazz.defineMethod (c$, "addCommandListener", +function (cl) { +if (!this.commandListeners.contains (cl)) { +this.commandListeners.add (cl); +}}, "jalview.structure.CommandListener"); +Clazz.defineMethod (c$, "hasCommandListener", +function (cl) { +return this.commandListeners.contains (cl); +}, "jalview.structure.CommandListener"); +Clazz.defineMethod (c$, "removeCommandListener", +function (l) { +return this.commandListeners.remove (l); +}, "jalview.structure.CommandListener"); +Clazz.defineMethod (c$, "commandPerformed", +function (command, undo, source) { +for (var listener, $listener = this.commandListeners.iterator (); $listener.hasNext () && ((listener = $listener.next ()) || true);) { +listener.mirrorCommand (command, undo, this, source); +} +}, "jalview.commands.CommandI,~B,jalview.structure.VamsasSource"); +Clazz.defineMethod (c$, "mapCommand", +function (command, undo, mapTo, gapChar) { +if (Clazz.instanceOf (command, jalview.commands.EditCommand)) { +return jalview.util.MappingUtils.mapEditCommand (command, undo, mapTo, gapChar, this.seqmappings); +} else if (Clazz.instanceOf (command, jalview.commands.OrderCommand)) { +return jalview.util.MappingUtils.mapOrderCommand (command, undo, mapTo, this.seqmappings); +}return null; +}, "jalview.commands.CommandI,~B,jalview.datamodel.AlignmentI,~S"); +c$.$StructureSelectionManager$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.structure, "StructureSelectionManager$1", java.io.PrintStream); +Clazz.defineMethod (c$, "print", +function (x) { +this.f$.mappingDetails.append (x); +}, "~S"); +Clazz.defineMethod (c$, "println", +function () { +this.f$.mappingDetails.append (jalview.structure.StructureSelectionManager.NEWLINE); +}); +c$ = Clazz.p0p (); +}; +c$.NEWLINE = c$.prototype.NEWLINE = System.lineSeparator (); +Clazz.defineStatics (c$, +"instances", null, +"nullProvider", null); +}); diff --git a/bin/jalview/structure/VamsasListener.js b/bin/jalview/structure/VamsasListener.js index 3e2c764..4d4fcbc 100644 --- a/bin/jalview/structure/VamsasListener.js +++ b/bin/jalview/structure/VamsasListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "VamsasListener"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "VamsasListener"); diff --git a/bin/jalview/structure/VamsasSource.js b/bin/jalview/structure/VamsasSource.js index 6654402..a910ac7 100644 --- a/bin/jalview/structure/VamsasSource.js +++ b/bin/jalview/structure/VamsasSource.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("jalview.structure"); -Clazz.declareInterface (jalview.structure, "VamsasSource"); +Clazz.declarePackage ("jalview.structure"); +Clazz.declareInterface (jalview.structure, "VamsasSource"); diff --git a/bin/jalview/structures/models/AAStructureBindingModel.js b/bin/jalview/structures/models/AAStructureBindingModel.js index a66cb14..f64bb34 100644 --- a/bin/jalview/structures/models/AAStructureBindingModel.js +++ b/bin/jalview/structures/models/AAStructureBindingModel.js @@ -1,306 +1,306 @@ -Clazz.declarePackage ("jalview.structures.models"); -Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.structure.StructureListener", "jalview.structures.models.SequenceStructureBindingModel"], "jalview.structures.models.AAStructureBindingModel", ["jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ssm = null; -this.pdbEntry = null; -this.sequence = null; -this.chains = null; -this.protocol = null; -this.colourBySequence = true; -this.nucleotide = false; -if (!Clazz.isClassDefined ("jalview.structures.models.AAStructureBindingModel.SuperposeData")) { -jalview.structures.models.AAStructureBindingModel.$AAStructureBindingModel$SuperposeData$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.structures.models, "AAStructureBindingModel", jalview.structures.models.SequenceStructureBindingModel, [jalview.structure.StructureListener, jalview.api.StructureSelectionManagerProvider]); -Clazz.makeConstructor (c$, -function (ssm, seqs) { -Clazz.superConstructor (this, jalview.structures.models.AAStructureBindingModel, []); -this.ssm = ssm; -this.sequence = seqs; -}, "jalview.structure.StructureSelectionManager,~A"); -Clazz.makeConstructor (c$, -function (ssm, pdbentry, sequenceIs, chains, protocol) { -Clazz.superConstructor (this, jalview.structures.models.AAStructureBindingModel, []); -this.ssm = ssm; -this.sequence = sequenceIs; -this.nucleotide = jalview.util.Comparison.isNucleotide2 (sequenceIs); -this.chains = chains; -this.pdbEntry = pdbentry; -this.protocol = protocol; -if (chains == null) { -this.chains = new Array (pdbentry.length); -}}, "jalview.structure.StructureSelectionManager,~A,~A,~A,~S"); -Clazz.defineMethod (c$, "getSsm", -function () { -return this.ssm; -}); -Clazz.defineMethod (c$, "getPdbEntry", -function (i) { -return (this.pdbEntry != null && this.pdbEntry.length > i) ? this.pdbEntry[i] : null; -}, "~N"); -Clazz.defineMethod (c$, "hasPdbId", -function (pdbId) { -if (this.pdbEntry != null) { -for (var pdb, $pdb = 0, $$pdb = this.pdbEntry; $pdb < $$pdb.length && ((pdb = $$pdb[$pdb]) || true); $pdb++) { -if (pdb.getId ().equals (pdbId)) { -return true; -}} -}return false; -}, "~S"); -Clazz.defineMethod (c$, "getPdbCount", -function () { -return this.pdbEntry == null ? 0 : this.pdbEntry.length; -}); -Clazz.defineMethod (c$, "getSequence", -function () { -return this.sequence; -}); -Clazz.defineMethod (c$, "getChains", -function () { -return this.chains; -}); -Clazz.defineMethod (c$, "getProtocol", -function () { -return this.protocol; -}); -Clazz.defineMethod (c$, "setPdbentry", -function (pdbentry) { -this.pdbEntry = pdbentry; -}, "~A"); -Clazz.defineMethod (c$, "setSequence", -function (sequence) { -this.sequence = sequence; -}, "~A"); -Clazz.defineMethod (c$, "setChains", -function (chains) { -this.chains = chains; -}, "~A"); -Clazz.defineMethod (c$, "getViewerTitle", -function (viewerName, verbose) { -if (this.getSequence () == null || this.getSequence ().length < 1 || this.getPdbCount () < 1 || this.getSequence ()[0].length < 1) { -return ("Jalview " + viewerName + " Window"); -}var title = new StringBuilder (64); -var pdbEntry = this.getPdbEntry (0); -title.append (viewerName + " view for " + this.getSequence ()[0][0].getName () + ":" + pdbEntry.getId ()); -if (verbose) { -if (pdbEntry.getProperty () != null) { -if (pdbEntry.getProperty ().get ("method") != null) { -title.append (" Method: "); -title.append (pdbEntry.getProperty ().get ("method")); -}if (pdbEntry.getProperty ().get ("chains") != null) { -title.append (" Chain:"); -title.append (pdbEntry.getProperty ().get ("chains")); -}}}return title.toString (); -}, "~S,~B"); -Clazz.defineMethod (c$, "releaseUIResources", -function () { -}); -Clazz.defineMethod (c$, "isColourBySequence", -function () { -return this.colourBySequence; -}); -Clazz.defineMethod (c$, "setColourBySequence", -function (colourBySequence) { -this.colourBySequence = colourBySequence; -}, "~B"); -Clazz.defineMethod (c$, "addSequenceAndChain", -function (pe, seq, tchain) { -if (pe < 0 || pe >= this.getPdbCount ()) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_no_pdbentry_from_index", Clazz.newArray (-1, [Integer.$valueOf (pe).toString ()]))); -}var nullChain = "TheNullChain"; -var s = new java.util.ArrayList (); -var c = new java.util.ArrayList (); -if (this.getChains () == null) { -this.setChains ( new Array (this.getPdbCount ())); -}if (this.getSequence ()[pe] != null) { -for (var i = 0; i < this.getSequence ()[pe].length; i++) { -s.add (this.getSequence ()[pe][i]); -if (this.getChains ()[pe] != null) { -if (i < this.getChains ()[pe].length) { -c.add (this.getChains ()[pe][i]); -} else { -c.add ("TheNullChain"); -}} else { -if (tchain != null && tchain.length > 0) { -c.add ("TheNullChain"); -}}} -}for (var i = 0; i < seq.length; i++) { -if (!s.contains (seq[i])) { -s.add (seq[i]); -if (tchain != null && i < tchain.length) { -c.add (tchain[i] == null ? "TheNullChain" : tchain[i]); -}}} -var tmp = s.toArray ( new Array (s.size ())); -this.getSequence ()[pe] = tmp; -if (c.size () > 0) { -var tch = c.toArray ( new Array (c.size ())); -for (var i = 0; i < tch.length; i++) { -if (tch[i] === "TheNullChain") { -tch[i] = null; -}} -this.getChains ()[pe] = tch; -} else { -this.getChains ()[pe] = null; -}}, "~N,~A,~A"); -Clazz.defineMethod (c$, "addSequenceAndChain", -function (pdbe, seq, chns) { -var v = new java.util.ArrayList (); -var rtn = new java.util.ArrayList (); -for (var i = 0; i < this.getPdbCount (); i++) { -v.add (this.getPdbEntry (i)); -} -for (var i = 0; i < pdbe.length; i++) { -var r = v.indexOf (pdbe[i]); -if (r == -1 || r >= this.getPdbCount ()) { -rtn.add ( Clazz.newIntArray (-1, [v.size (), i])); -v.add (pdbe[i]); -} else { -this.addSequenceAndChain (r, seq[i], chns[i]); -}} -pdbe = v.toArray ( new Array (v.size ())); -this.setPdbentry (pdbe); -if (rtn.size () > 0) { -var sqs = new Array (this.getPdbCount ()); -var sch = new Array (this.getPdbCount ()); -System.arraycopy (this.getSequence (), 0, sqs, 0, this.getSequence ().length); -System.arraycopy (this.getChains (), 0, sch, 0, this.getChains ().length); -this.setSequence (sqs); -this.setChains (sch); -pdbe = new Array (rtn.size ()); -for (var r = 0; r < pdbe.length; r++) { -var stri = (rtn.get (r)); -pdbe[r] = this.getPdbEntry (stri[0]); -this.addSequenceAndChain (stri[0], seq[stri[1]], chns[stri[1]]); -} -} else { -pdbe = null; -}return pdbe; -}, "~A,~A,~A"); -Clazz.defineMethod (c$, "addSequence", -function (pe, seq) { -this.addSequenceAndChain (pe, seq, null); -}, "~N,~A"); -Clazz.defineMethod (c$, "addSequenceForStructFile", -function (pdbFile, seq) { -for (var pe = 0; pe < this.getPdbCount (); pe++) { -if (this.getPdbEntry (pe).getFile ().equals (pdbFile)) { -this.addSequence (pe, seq); -}} -}, "~S,~A"); -Clazz.defineMethod (c$, "isNucleotide", -function () { -return this.nucleotide; -}); -Clazz.defineMethod (c$, "printMappings", -function () { -if (this.pdbEntry == null) { -return ""; -}var sb = new StringBuilder (128); -for (var pdbe = 0; pdbe < this.getPdbCount (); pdbe++) { -var pdbfile = this.getPdbEntry (pdbe).getFile (); -var seqs = java.util.Arrays.asList (this.getSequence ()[pdbe]); -sb.append (this.getSsm ().printMappings (pdbfile, seqs)); -} -return sb.toString (); -}); -Clazz.defineMethod (c$, "getMappedPosition", -function (seq, alignedPos, mapping) { -if (alignedPos >= seq.getLength ()) { -return -1; -}if (jalview.util.Comparison.isGap (seq.getCharAt (alignedPos))) { -return -1; -}var seqPos = seq.findPosition (alignedPos); -var pos = mapping.getPDBResNum (seqPos); -return pos; -}, "jalview.datamodel.SequenceI,~N,jalview.structure.StructureMapping"); -Clazz.defineMethod (c$, "findSuperposableResidues", -function (alignment, matched, structures) { -var refStructure = -1; -var files = this.getPdbFile (); -for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { -var mappings = this.getSsm ().getMapping (files[pdbfnum]); -var lastPos = -1; -var seqCountForPdbFile = this.getSequence ()[pdbfnum].length; -for (var s = 0; s < seqCountForPdbFile; s++) { -for (var mapping, $mapping = 0, $$mapping = mappings; $mapping < $$mapping.length && ((mapping = $$mapping[$mapping]) || true); $mapping++) { -var theSequence = this.getSequence ()[pdbfnum][s]; -if (mapping.getSequence () === theSequence && alignment.findIndex (theSequence) > -1) { -if (refStructure < 0) { -refStructure = pdbfnum; -}for (var r = 0; r < matched.length; r++) { -if (!matched[r]) { -continue; -}var pos = this.getMappedPosition (theSequence, r, mapping); -if (pos < 1 || pos == lastPos) { -matched[r] = false; -continue; -}lastPos = pos; -structures[pdbfnum].pdbResNo[r] = pos; -} -var chain = mapping.getChain (); -if (chain != null && chain.trim ().length > 0) { -structures[pdbfnum].chain = chain; -}structures[pdbfnum].pdbId = mapping.getPdbId (); -structures[pdbfnum].isRna = theSequence.getRNA () != null; -s = seqCountForPdbFile; -break; -}} -} -} -return refStructure; -}, "jalview.datamodel.AlignmentI,~A,~A"); -Clazz.defineMethod (c$, "waitForFileLoad", -function (files) { -var starttime = System.currentTimeMillis (); -var endTime = 10000 + 1000 * files.length + starttime; -var notLoaded = null; -var waiting = true; -while (waiting && System.currentTimeMillis () < endTime) { -waiting = false; -for (var file, $file = 0, $$file = files; $file < $$file.length && ((file = $$file[$file]) || true); $file++) { -notLoaded = file; -try { -var sm = this.getSsm ().getMapping (file); -if (sm == null || sm.length == 0) { -waiting = true; -}} catch (x) { -waiting = true; -} -} -} -if (waiting) { -System.err.println ("Timed out waiting for structure viewer to load file " + notLoaded); -return false; -}return true; -}, "~A"); -Clazz.overrideMethod (c$, "isListeningFor", -function (seq) { -if (this.sequence != null) { -for (var seqs, $seqs = 0, $$seqs = this.sequence; $seqs < $$seqs.length && ((seqs = $$seqs[$seqs]) || true); $seqs++) { -if (seqs != null) { -for (var s, $s = 0, $$s = seqs; $s < $$s.length && ((s = $$s[$s]) || true); $s++) { -if (s === seq) { -return true; -}} -}} -}return false; -}, "jalview.datamodel.SequenceI"); -c$.$AAStructureBindingModel$SuperposeData$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.filename = null; -this.pdbId = null; -this.chain = ""; -this.isRna = false; -this.pdbResNo = null; -Clazz.instantialize (this, arguments); -}, jalview.structures.models.AAStructureBindingModel, "SuperposeData"); -Clazz.makeConstructor (c$, -function (a) { -this.pdbResNo = Clazz.newIntArray (a, 0); -}, "~N"); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.structures.models"); +Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.structure.StructureListener", "jalview.structures.models.SequenceStructureBindingModel"], "jalview.structures.models.AAStructureBindingModel", ["jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ssm = null; +this.pdbEntry = null; +this.sequence = null; +this.chains = null; +this.protocol = null; +this.colourBySequence = true; +this.nucleotide = false; +if (!Clazz.isClassDefined ("jalview.structures.models.AAStructureBindingModel.SuperposeData")) { +jalview.structures.models.AAStructureBindingModel.$AAStructureBindingModel$SuperposeData$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.structures.models, "AAStructureBindingModel", jalview.structures.models.SequenceStructureBindingModel, [jalview.structure.StructureListener, jalview.api.StructureSelectionManagerProvider]); +Clazz.makeConstructor (c$, +function (ssm, seqs) { +Clazz.superConstructor (this, jalview.structures.models.AAStructureBindingModel, []); +this.ssm = ssm; +this.sequence = seqs; +}, "jalview.structure.StructureSelectionManager,~A"); +Clazz.makeConstructor (c$, +function (ssm, pdbentry, sequenceIs, chains, protocol) { +Clazz.superConstructor (this, jalview.structures.models.AAStructureBindingModel, []); +this.ssm = ssm; +this.sequence = sequenceIs; +this.nucleotide = jalview.util.Comparison.isNucleotide2 (sequenceIs); +this.chains = chains; +this.pdbEntry = pdbentry; +this.protocol = protocol; +if (chains == null) { +this.chains = new Array (pdbentry.length); +}}, "jalview.structure.StructureSelectionManager,~A,~A,~A,~S"); +Clazz.defineMethod (c$, "getSsm", +function () { +return this.ssm; +}); +Clazz.defineMethod (c$, "getPdbEntry", +function (i) { +return (this.pdbEntry != null && this.pdbEntry.length > i) ? this.pdbEntry[i] : null; +}, "~N"); +Clazz.defineMethod (c$, "hasPdbId", +function (pdbId) { +if (this.pdbEntry != null) { +for (var pdb, $pdb = 0, $$pdb = this.pdbEntry; $pdb < $$pdb.length && ((pdb = $$pdb[$pdb]) || true); $pdb++) { +if (pdb.getId ().equals (pdbId)) { +return true; +}} +}return false; +}, "~S"); +Clazz.defineMethod (c$, "getPdbCount", +function () { +return this.pdbEntry == null ? 0 : this.pdbEntry.length; +}); +Clazz.defineMethod (c$, "getSequence", +function () { +return this.sequence; +}); +Clazz.defineMethod (c$, "getChains", +function () { +return this.chains; +}); +Clazz.defineMethod (c$, "getProtocol", +function () { +return this.protocol; +}); +Clazz.defineMethod (c$, "setPdbentry", +function (pdbentry) { +this.pdbEntry = pdbentry; +}, "~A"); +Clazz.defineMethod (c$, "setSequence", +function (sequence) { +this.sequence = sequence; +}, "~A"); +Clazz.defineMethod (c$, "setChains", +function (chains) { +this.chains = chains; +}, "~A"); +Clazz.defineMethod (c$, "getViewerTitle", +function (viewerName, verbose) { +if (this.getSequence () == null || this.getSequence ().length < 1 || this.getPdbCount () < 1 || this.getSequence ()[0].length < 1) { +return ("Jalview " + viewerName + " Window"); +}var title = new StringBuilder (64); +var pdbEntry = this.getPdbEntry (0); +title.append (viewerName + " view for " + this.getSequence ()[0][0].getName () + ":" + pdbEntry.getId ()); +if (verbose) { +if (pdbEntry.getProperty () != null) { +if (pdbEntry.getProperty ().get ("method") != null) { +title.append (" Method: "); +title.append (pdbEntry.getProperty ().get ("method")); +}if (pdbEntry.getProperty ().get ("chains") != null) { +title.append (" Chain:"); +title.append (pdbEntry.getProperty ().get ("chains")); +}}}return title.toString (); +}, "~S,~B"); +Clazz.defineMethod (c$, "releaseUIResources", +function () { +}); +Clazz.defineMethod (c$, "isColourBySequence", +function () { +return this.colourBySequence; +}); +Clazz.defineMethod (c$, "setColourBySequence", +function (colourBySequence) { +this.colourBySequence = colourBySequence; +}, "~B"); +Clazz.defineMethod (c$, "addSequenceAndChain", +function (pe, seq, tchain) { +if (pe < 0 || pe >= this.getPdbCount ()) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_no_pdbentry_from_index", Clazz.newArray (-1, [Integer.$valueOf (pe).toString ()]))); +}var nullChain = "TheNullChain"; +var s = new java.util.ArrayList (); +var c = new java.util.ArrayList (); +if (this.getChains () == null) { +this.setChains ( new Array (this.getPdbCount ())); +}if (this.getSequence ()[pe] != null) { +for (var i = 0; i < this.getSequence ()[pe].length; i++) { +s.add (this.getSequence ()[pe][i]); +if (this.getChains ()[pe] != null) { +if (i < this.getChains ()[pe].length) { +c.add (this.getChains ()[pe][i]); +} else { +c.add ("TheNullChain"); +}} else { +if (tchain != null && tchain.length > 0) { +c.add ("TheNullChain"); +}}} +}for (var i = 0; i < seq.length; i++) { +if (!s.contains (seq[i])) { +s.add (seq[i]); +if (tchain != null && i < tchain.length) { +c.add (tchain[i] == null ? "TheNullChain" : tchain[i]); +}}} +var tmp = s.toArray ( new Array (s.size ())); +this.getSequence ()[pe] = tmp; +if (c.size () > 0) { +var tch = c.toArray ( new Array (c.size ())); +for (var i = 0; i < tch.length; i++) { +if (tch[i] === "TheNullChain") { +tch[i] = null; +}} +this.getChains ()[pe] = tch; +} else { +this.getChains ()[pe] = null; +}}, "~N,~A,~A"); +Clazz.defineMethod (c$, "addSequenceAndChain", +function (pdbe, seq, chns) { +var v = new java.util.ArrayList (); +var rtn = new java.util.ArrayList (); +for (var i = 0; i < this.getPdbCount (); i++) { +v.add (this.getPdbEntry (i)); +} +for (var i = 0; i < pdbe.length; i++) { +var r = v.indexOf (pdbe[i]); +if (r == -1 || r >= this.getPdbCount ()) { +rtn.add ( Clazz.newIntArray (-1, [v.size (), i])); +v.add (pdbe[i]); +} else { +this.addSequenceAndChain (r, seq[i], chns[i]); +}} +pdbe = v.toArray ( new Array (v.size ())); +this.setPdbentry (pdbe); +if (rtn.size () > 0) { +var sqs = new Array (this.getPdbCount ()); +var sch = new Array (this.getPdbCount ()); +System.arraycopy (this.getSequence (), 0, sqs, 0, this.getSequence ().length); +System.arraycopy (this.getChains (), 0, sch, 0, this.getChains ().length); +this.setSequence (sqs); +this.setChains (sch); +pdbe = new Array (rtn.size ()); +for (var r = 0; r < pdbe.length; r++) { +var stri = (rtn.get (r)); +pdbe[r] = this.getPdbEntry (stri[0]); +this.addSequenceAndChain (stri[0], seq[stri[1]], chns[stri[1]]); +} +} else { +pdbe = null; +}return pdbe; +}, "~A,~A,~A"); +Clazz.defineMethod (c$, "addSequence", +function (pe, seq) { +this.addSequenceAndChain (pe, seq, null); +}, "~N,~A"); +Clazz.defineMethod (c$, "addSequenceForStructFile", +function (pdbFile, seq) { +for (var pe = 0; pe < this.getPdbCount (); pe++) { +if (this.getPdbEntry (pe).getFile ().equals (pdbFile)) { +this.addSequence (pe, seq); +}} +}, "~S,~A"); +Clazz.defineMethod (c$, "isNucleotide", +function () { +return this.nucleotide; +}); +Clazz.defineMethod (c$, "printMappings", +function () { +if (this.pdbEntry == null) { +return ""; +}var sb = new StringBuilder (128); +for (var pdbe = 0; pdbe < this.getPdbCount (); pdbe++) { +var pdbfile = this.getPdbEntry (pdbe).getFile (); +var seqs = java.util.Arrays.asList (this.getSequence ()[pdbe]); +sb.append (this.getSsm ().printMappings (pdbfile, seqs)); +} +return sb.toString (); +}); +Clazz.defineMethod (c$, "getMappedPosition", +function (seq, alignedPos, mapping) { +if (alignedPos >= seq.getLength ()) { +return -1; +}if (jalview.util.Comparison.isGap (seq.getCharAt (alignedPos))) { +return -1; +}var seqPos = seq.findPosition (alignedPos); +var pos = mapping.getPDBResNum (seqPos); +return pos; +}, "jalview.datamodel.SequenceI,~N,jalview.structure.StructureMapping"); +Clazz.defineMethod (c$, "findSuperposableResidues", +function (alignment, matched, structures) { +var refStructure = -1; +var files = this.getPdbFile (); +for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { +var mappings = this.getSsm ().getMapping (files[pdbfnum]); +var lastPos = -1; +var seqCountForPdbFile = this.getSequence ()[pdbfnum].length; +for (var s = 0; s < seqCountForPdbFile; s++) { +for (var mapping, $mapping = 0, $$mapping = mappings; $mapping < $$mapping.length && ((mapping = $$mapping[$mapping]) || true); $mapping++) { +var theSequence = this.getSequence ()[pdbfnum][s]; +if (mapping.getSequence () === theSequence && alignment.findIndex (theSequence) > -1) { +if (refStructure < 0) { +refStructure = pdbfnum; +}for (var r = 0; r < matched.length; r++) { +if (!matched[r]) { +continue; +}var pos = this.getMappedPosition (theSequence, r, mapping); +if (pos < 1 || pos == lastPos) { +matched[r] = false; +continue; +}lastPos = pos; +structures[pdbfnum].pdbResNo[r] = pos; +} +var chain = mapping.getChain (); +if (chain != null && chain.trim ().length > 0) { +structures[pdbfnum].chain = chain; +}structures[pdbfnum].pdbId = mapping.getPdbId (); +structures[pdbfnum].isRna = theSequence.getRNA () != null; +s = seqCountForPdbFile; +break; +}} +} +} +return refStructure; +}, "jalview.datamodel.AlignmentI,~A,~A"); +Clazz.defineMethod (c$, "waitForFileLoad", +function (files) { +var starttime = System.currentTimeMillis (); +var endTime = 10000 + 1000 * files.length + starttime; +var notLoaded = null; +var waiting = true; +while (waiting && System.currentTimeMillis () < endTime) { +waiting = false; +for (var file, $file = 0, $$file = files; $file < $$file.length && ((file = $$file[$file]) || true); $file++) { +notLoaded = file; +try { +var sm = this.getSsm ().getMapping (file); +if (sm == null || sm.length == 0) { +waiting = true; +}} catch (x) { +waiting = true; +} +} +} +if (waiting) { +System.err.println ("Timed out waiting for structure viewer to load file " + notLoaded); +return false; +}return true; +}, "~A"); +Clazz.overrideMethod (c$, "isListeningFor", +function (seq) { +if (this.sequence != null) { +for (var seqs, $seqs = 0, $$seqs = this.sequence; $seqs < $$seqs.length && ((seqs = $$seqs[$seqs]) || true); $seqs++) { +if (seqs != null) { +for (var s, $s = 0, $$s = seqs; $s < $$s.length && ((s = $$s[$s]) || true); $s++) { +if (s === seq) { +return true; +}} +}} +}return false; +}, "jalview.datamodel.SequenceI"); +c$.$AAStructureBindingModel$SuperposeData$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.filename = null; +this.pdbId = null; +this.chain = ""; +this.isRna = false; +this.pdbResNo = null; +Clazz.instantialize (this, arguments); +}, jalview.structures.models.AAStructureBindingModel, "SuperposeData"); +Clazz.makeConstructor (c$, +function (a) { +this.pdbResNo = Clazz.newIntArray (a, 0); +}, "~N"); +c$ = Clazz.p0p (); +}; +}); diff --git a/bin/jalview/structures/models/SequenceStructureBindingModel.js b/bin/jalview/structures/models/SequenceStructureBindingModel.js index f9d2e7a..98e8875 100644 --- a/bin/jalview/structures/models/SequenceStructureBindingModel.js +++ b/bin/jalview/structures/models/SequenceStructureBindingModel.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("jalview.structures.models"); -Clazz.load (["jalview.api.SequenceStructureBinding"], "jalview.structures.models.SequenceStructureBindingModel", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.loadingFromArchive = false; -this.loadingFinished = true; -Clazz.instantialize (this, arguments); -}, jalview.structures.models, "SequenceStructureBindingModel", null, jalview.api.SequenceStructureBinding); -Clazz.overrideMethod (c$, "setLoadingFromArchive", -function (loadingFromArchive) { -this.loadingFromArchive = loadingFromArchive; -}, "~B"); -Clazz.overrideMethod (c$, "isLoadingFromArchive", -function () { -return this.loadingFromArchive && !this.loadingFinished; -}); -Clazz.overrideMethod (c$, "isLoadingFinished", -function () { -return this.loadingFinished; -}); -Clazz.overrideMethod (c$, "setFinishedLoadingFromArchive", -function (finishedLoading) { -this.loadingFinished = finishedLoading; -}, "~B"); -}); +Clazz.declarePackage ("jalview.structures.models"); +Clazz.load (["jalview.api.SequenceStructureBinding"], "jalview.structures.models.SequenceStructureBindingModel", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.loadingFromArchive = false; +this.loadingFinished = true; +Clazz.instantialize (this, arguments); +}, jalview.structures.models, "SequenceStructureBindingModel", null, jalview.api.SequenceStructureBinding); +Clazz.overrideMethod (c$, "setLoadingFromArchive", +function (loadingFromArchive) { +this.loadingFromArchive = loadingFromArchive; +}, "~B"); +Clazz.overrideMethod (c$, "isLoadingFromArchive", +function () { +return this.loadingFromArchive && !this.loadingFinished; +}); +Clazz.overrideMethod (c$, "isLoadingFinished", +function () { +return this.loadingFinished; +}); +Clazz.overrideMethod (c$, "setFinishedLoadingFromArchive", +function (finishedLoading) { +this.loadingFinished = finishedLoading; +}, "~B"); +}); diff --git a/bin/jalview/util/ColorUtils.js b/bin/jalview/util/ColorUtils.js index ed016da..129c265 100644 --- a/bin/jalview/util/ColorUtils.js +++ b/bin/jalview/util/ColorUtils.js @@ -1,30 +1,30 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.ColorUtils", ["java.awt.Color", "java.util.Random"], function () { -c$ = Clazz.declareType (jalview.util, "ColorUtils"); -c$.generateRandomColor = Clazz.defineMethod (c$, "generateRandomColor", -function (mix) { -var random = new java.util.Random (); -var red = random.nextInt (256); -var green = random.nextInt (256); -var blue = random.nextInt (256); -if (mix != null) { -red = Clazz.doubleToInt ((red + mix.getRed ()) / 2); -green = Clazz.doubleToInt ((green + mix.getGreen ()) / 2); -blue = Clazz.doubleToInt ((blue + mix.getBlue ()) / 2); -}var color = new java.awt.Color (red, green, blue); -return color; -}, "java.awt.Color"); -c$.toTkCode = Clazz.defineMethod (c$, "toTkCode", -function (colour) { -var colstring = "#" + ((colour.getRed () < 16) ? "0" : "") + Integer.toHexString (colour.getRed ()) + ((colour.getGreen () < 16) ? "0" : "") + Integer.toHexString (colour.getGreen ()) + ((colour.getBlue () < 16) ? "0" : "") + Integer.toHexString (colour.getBlue ()); -return colstring; -}, "java.awt.Color"); -c$.darkerThan = Clazz.defineMethod (c$, "darkerThan", -function (col) { -return col == null ? null : col.darker ().darker ().darker (); -}, "java.awt.Color"); -c$.brighterThan = Clazz.defineMethod (c$, "brighterThan", -function (col) { -return col == null ? null : col.brighter ().brighter ().brighter (); -}, "java.awt.Color"); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.ColorUtils", ["java.awt.Color", "java.util.Random"], function () { +c$ = Clazz.declareType (jalview.util, "ColorUtils"); +c$.generateRandomColor = Clazz.defineMethod (c$, "generateRandomColor", +function (mix) { +var random = new java.util.Random (); +var red = random.nextInt (256); +var green = random.nextInt (256); +var blue = random.nextInt (256); +if (mix != null) { +red = Clazz.doubleToInt ((red + mix.getRed ()) / 2); +green = Clazz.doubleToInt ((green + mix.getGreen ()) / 2); +blue = Clazz.doubleToInt ((blue + mix.getBlue ()) / 2); +}var color = new java.awt.Color (red, green, blue); +return color; +}, "java.awt.Color"); +c$.toTkCode = Clazz.defineMethod (c$, "toTkCode", +function (colour) { +var colstring = "#" + ((colour.getRed () < 16) ? "0" : "") + Integer.toHexString (colour.getRed ()) + ((colour.getGreen () < 16) ? "0" : "") + Integer.toHexString (colour.getGreen ()) + ((colour.getBlue () < 16) ? "0" : "") + Integer.toHexString (colour.getBlue ()); +return colstring; +}, "java.awt.Color"); +c$.darkerThan = Clazz.defineMethod (c$, "darkerThan", +function (col) { +return col == null ? null : col.darker ().darker ().darker (); +}, "java.awt.Color"); +c$.brighterThan = Clazz.defineMethod (c$, "brighterThan", +function (col) { +return col == null ? null : col.brighter ().brighter ().brighter (); +}, "java.awt.Color"); +}); diff --git a/bin/jalview/util/Comparison.js b/bin/jalview/util/Comparison.js index 29499bb..e46a616 100644 --- a/bin/jalview/util/Comparison.js +++ b/bin/jalview/util/Comparison.js @@ -1,131 +1,131 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.Comparison", ["java.util.ArrayList"], function () { -c$ = Clazz.declareType (jalview.util, "Comparison"); -c$.compare = Clazz.defineMethod (c$, "compare", -function (ii, jj) { -return jalview.util.Comparison.compare (ii, jj, 0, ii.getLength () - 1); -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); -c$.compare = Clazz.defineMethod (c$, "compare", -function (ii, jj, start, end) { -var si = ii.getSequenceAsString (); -var sj = jj.getSequenceAsString (); -var ilen = si.length - 1; -var jlen = sj.length - 1; -while (jalview.util.Comparison.isGap (si.charAt (start + ilen))) { -ilen--; -} -while (jalview.util.Comparison.isGap (sj.charAt (start + jlen))) { -jlen--; -} -var count = 0; -var match = 0; -var pid = -1; -if (ilen > jlen) { -for (var j = 0; j < jlen; j++) { -if (si.substring (start + j, start + j + 1).equals (sj.substring (start + j, start + j + 1))) { -match++; -}count++; -} -pid = match / ilen * 100; -} else { -for (var j = 0; j < jlen; j++) { -if (si.substring (start + j, start + j + 1).equals (sj.substring (start + j, start + j + 1))) { -match++; -}count++; -} -pid = match / jlen * 100; -}return pid; -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N,~N"); -c$.PID = Clazz.defineMethod (c$, "PID", -function (seq1, seq2) { -return jalview.util.Comparison.PID (seq1, seq2, 0, seq1.length); -}, "~S,~S"); -c$.PID = Clazz.defineMethod (c$, "PID", -function (seq1, seq2, start, end) { -return jalview.util.Comparison.PID (seq1, seq2, start, end, true, false); -}, "~S,~S,~N,~N"); -c$.PID = Clazz.defineMethod (c$, "PID", -function (seq1, seq2, start, end, wcGaps, ungappedOnly) { -var s1len = seq1.length; -var s2len = seq2.length; -var len = Math.min (s1len, s2len); -if (end < len) { -len = end; -}if (len < start) { -start = len - 1; -}var elen = len - start; -var bad = 0; -var chr1; -var chr2; -var agap; -for (var i = start; i < len; i++) { -chr1 = seq1.charAt (i); -chr2 = seq2.charAt (i); -agap = jalview.util.Comparison.isGap (chr1) || jalview.util.Comparison.isGap (chr2); -if ('a' <= chr1 && chr1 <= 'z') { -chr1 = String.fromCharCode (chr1.charCodeAt (0) - 32); -}if ('a' <= chr2 && chr2 <= 'z') { -chr2 = String.fromCharCode (chr2.charCodeAt (0) - 32); -}if (chr1 != chr2) { -if (agap) { -if (ungappedOnly) { -elen--; -} else if (!wcGaps) { -bad++; -}} else { -bad++; -}}} -if (elen < 1) { -return 0; -}return (100 * (elen - bad)) / elen; -}, "~S,~S,~N,~N,~B,~B"); -c$.isGap = Clazz.defineMethod (c$, "isGap", -function (c) { -return (c == '-' || c == '.' || c == ' ') ? true : false; -}, "~S"); -c$.isNucleotide = Clazz.defineMethod (c$, "isNucleotide", -function (seqs) { -if (seqs == null) { -return false; -}var ntCount = 0; -var aaCount = 0; -for (var seq, $seq = 0, $$seq = seqs; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { -if (seq == null) { -continue; -}for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) { -if ('a' <= c && c <= 'z') { -c = String.fromCharCode (c.charCodeAt (0) - 32); -}if (c == 'A' || c == 'G' || c == 'C' || c == 'T' || c == 'U') { -ntCount++; -} else if (!jalview.util.Comparison.isGap (c)) { -aaCount++; -}} -} -if (ntCount * 100 > 85 * (ntCount + aaCount)) { -return true; -} else { -return false; -}}, "~A"); -c$.isNucleotide2 = Clazz.defineMethod (c$, "isNucleotide2", -function (seqs) { -if (seqs == null) { -return false; -}var flattened = new java.util.ArrayList (); -for (var ss, $ss = 0, $$ss = seqs; $ss < $$ss.length && ((ss = $$ss[$ss]) || true); $ss++) { -for (var s, $s = 0, $$s = ss; $s < $$s.length && ((s = $$s[$s]) || true); $s++) { -flattened.add (s); -} -} -var oneDArray = flattened.toArray ( new Array (flattened.size ())); -return jalview.util.Comparison.isNucleotide (oneDArray); -}, "~A"); -Clazz.defineStatics (c$, -"EIGHTY_FIVE", 85, -"TO_UPPER_CASE", 32, -"GAP_SPACE", ' ', -"GAP_DOT", '.', -"GAP_DASH", '-'); -c$.GapChars = c$.prototype.GapChars = String.instantialize ( Clazz.newCharArray (-1, [' ', '.', '-'])); -Clazz.defineStatics (c$, -"caseShift", 32); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.Comparison", ["java.util.ArrayList"], function () { +c$ = Clazz.declareType (jalview.util, "Comparison"); +c$.compare = Clazz.defineMethod (c$, "compare", +function (ii, jj) { +return jalview.util.Comparison.compare (ii, jj, 0, ii.getLength () - 1); +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI"); +c$.compare = Clazz.defineMethod (c$, "compare", +function (ii, jj, start, end) { +var si = ii.getSequenceAsString (); +var sj = jj.getSequenceAsString (); +var ilen = si.length - 1; +var jlen = sj.length - 1; +while (jalview.util.Comparison.isGap (si.charAt (start + ilen))) { +ilen--; +} +while (jalview.util.Comparison.isGap (sj.charAt (start + jlen))) { +jlen--; +} +var count = 0; +var match = 0; +var pid = -1; +if (ilen > jlen) { +for (var j = 0; j < jlen; j++) { +if (si.substring (start + j, start + j + 1).equals (sj.substring (start + j, start + j + 1))) { +match++; +}count++; +} +pid = match / ilen * 100; +} else { +for (var j = 0; j < jlen; j++) { +if (si.substring (start + j, start + j + 1).equals (sj.substring (start + j, start + j + 1))) { +match++; +}count++; +} +pid = match / jlen * 100; +}return pid; +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI,~N,~N"); +c$.PID = Clazz.defineMethod (c$, "PID", +function (seq1, seq2) { +return jalview.util.Comparison.PID (seq1, seq2, 0, seq1.length); +}, "~S,~S"); +c$.PID = Clazz.defineMethod (c$, "PID", +function (seq1, seq2, start, end) { +return jalview.util.Comparison.PID (seq1, seq2, start, end, true, false); +}, "~S,~S,~N,~N"); +c$.PID = Clazz.defineMethod (c$, "PID", +function (seq1, seq2, start, end, wcGaps, ungappedOnly) { +var s1len = seq1.length; +var s2len = seq2.length; +var len = Math.min (s1len, s2len); +if (end < len) { +len = end; +}if (len < start) { +start = len - 1; +}var elen = len - start; +var bad = 0; +var chr1; +var chr2; +var agap; +for (var i = start; i < len; i++) { +chr1 = seq1.charAt (i); +chr2 = seq2.charAt (i); +agap = jalview.util.Comparison.isGap (chr1) || jalview.util.Comparison.isGap (chr2); +if ('a' <= chr1 && chr1 <= 'z') { +chr1 = String.fromCharCode (chr1.charCodeAt (0) - 32); +}if ('a' <= chr2 && chr2 <= 'z') { +chr2 = String.fromCharCode (chr2.charCodeAt (0) - 32); +}if (chr1 != chr2) { +if (agap) { +if (ungappedOnly) { +elen--; +} else if (!wcGaps) { +bad++; +}} else { +bad++; +}}} +if (elen < 1) { +return 0; +}return (100 * (elen - bad)) / elen; +}, "~S,~S,~N,~N,~B,~B"); +c$.isGap = Clazz.defineMethod (c$, "isGap", +function (c) { +return (c == '-' || c == '.' || c == ' ') ? true : false; +}, "~S"); +c$.isNucleotide = Clazz.defineMethod (c$, "isNucleotide", +function (seqs) { +if (seqs == null) { +return false; +}var ntCount = 0; +var aaCount = 0; +for (var seq, $seq = 0, $$seq = seqs; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { +if (seq == null) { +continue; +}for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) { +if ('a' <= c && c <= 'z') { +c = String.fromCharCode (c.charCodeAt (0) - 32); +}if (c == 'A' || c == 'G' || c == 'C' || c == 'T' || c == 'U') { +ntCount++; +} else if (!jalview.util.Comparison.isGap (c)) { +aaCount++; +}} +} +if (ntCount * 100 > 85 * (ntCount + aaCount)) { +return true; +} else { +return false; +}}, "~A"); +c$.isNucleotide2 = Clazz.defineMethod (c$, "isNucleotide2", +function (seqs) { +if (seqs == null) { +return false; +}var flattened = new java.util.ArrayList (); +for (var ss, $ss = 0, $$ss = seqs; $ss < $$ss.length && ((ss = $$ss[$ss]) || true); $ss++) { +for (var s, $s = 0, $$s = ss; $s < $$s.length && ((s = $$s[$s]) || true); $s++) { +flattened.add (s); +} +} +var oneDArray = flattened.toArray ( new Array (flattened.size ())); +return jalview.util.Comparison.isNucleotide (oneDArray); +}, "~A"); +Clazz.defineStatics (c$, +"EIGHTY_FIVE", 85, +"TO_UPPER_CASE", 32, +"GAP_SPACE", ' ', +"GAP_DOT", '.', +"GAP_DASH", '-'); +c$.GapChars = c$.prototype.GapChars = String.instantialize ( Clazz.newCharArray (-1, [' ', '.', '-'])); +Clazz.defineStatics (c$, +"caseShift", 32); +}); diff --git a/bin/jalview/util/DBRefUtils.js b/bin/jalview/util/DBRefUtils.js index b27f196..051cde7 100644 --- a/bin/jalview/util/DBRefUtils.js +++ b/bin/jalview/util/DBRefUtils.js @@ -1,184 +1,184 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.util.HashMap"], "jalview.util.DBRefUtils", ["jalview.datamodel.DBRefEntry", "$.DBRefSource", "$.PDBEntry", "jalview.jsdev.RegExp", "java.util.ArrayList", "$.Hashtable"], function () { -c$ = Clazz.declareType (jalview.util, "DBRefUtils"); -c$.selectRefs = Clazz.defineMethod (c$, "selectRefs", -function (dbrefs, sources) { -if (dbrefs == null) { -return null; -}if (sources == null) { -return dbrefs; -}var srcs = new java.util.HashMap (); -var res = new java.util.ArrayList (); -for (var i = 0; i < sources.length; i++) { -srcs.put ( String.instantialize (sources[i]), new Integer (i)); -} -for (var i = 0, j = dbrefs.length; i < j; i++) { -if (srcs.containsKey (dbrefs[i].getSource ())) { -res.add (dbrefs[i]); -}} -if (res.size () > 0) { -var reply = new Array (res.size ()); -return res.toArray (reply); -}res = null; -return null; -}, "~A,~A"); -c$.isDasCoordinateSystem = Clazz.defineMethod (c$, "isDasCoordinateSystem", -function (string, dBRefEntry) { -if (string == null || dBRefEntry == null) { -return false; -}var coordsys = jalview.util.DBRefUtils.dasCoordinateSystemsLookup.get (string.toLowerCase ()); -return coordsys == null ? false : coordsys.equals (dBRefEntry.getSource ()); -}, "~S,jalview.datamodel.DBRefEntry"); -c$.getCanonicalName = Clazz.defineMethod (c$, "getCanonicalName", -function (source) { -if (source == null) { -return null; -}var canonical = jalview.util.DBRefUtils.canonicalSourceNameLookup.get (source.toLowerCase ()); -return canonical == null ? source : canonical; -}, "~S"); -c$.searchRefs = Clazz.defineMethod (c$, "searchRefs", -function (ref, entry) { -return jalview.util.DBRefUtils.searchRefs (ref, entry, jalview.util.DBRefUtils.matchDbAndIdAndEitherMapOrEquivalentMapList); -}, "~A,jalview.datamodel.DBRefEntry"); -c$.searchRefs = Clazz.defineMethod (c$, "searchRefs", -function (refs, entry, comparator) { -if (refs == null || entry == null) { -return null; -}var rfs = new java.util.ArrayList (); -for (var i = 0; i < refs.length; i++) { -if (comparator.matches (entry, refs[i])) { -rfs.add (refs[i]); -}} -return rfs.size () == 0 ? null : rfs.toArray ( new Array (rfs.size ())); -}, "~A,jalview.datamodel.DBRefEntry,jalview.util.DBRefUtils.DbRefComp"); -c$.parseToDbRef = Clazz.defineMethod (c$, "parseToDbRef", -function (seq, dbname, version, acn) { -var ref = null; -if (dbname != null) { -var locsrc = jalview.util.DBRefUtils.getCanonicalName (dbname); -if (locsrc.equals (jalview.datamodel.DBRefSource.PDB)) { -var r = jalview.jsdev.RegExp.newRegex (["([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)"]); -if (r.search (acn.trim ())) { -var pdbid = r.stringMatchedI (1); -var chaincode = r.stringMatchedI (2); -if (chaincode == null) { -chaincode = " "; -}if (chaincode.equals (" ")) { -chaincode = "_"; -}ref = new jalview.datamodel.DBRefEntry (locsrc, version, pdbid + chaincode); -var pdbr = new jalview.datamodel.PDBEntry (); -pdbr.setId (pdbid); -pdbr.setType (jalview.datamodel.PDBEntry.Type.PDB); -pdbr.setProperty ( new java.util.Hashtable ()); -pdbr.setChainCode (chaincode); -seq.addPDBId (pdbr); -} else { -System.err.println ("Malformed PDB DR line:" + acn); -}} else { -ref = new jalview.datamodel.DBRefEntry (locsrc, version, acn); -}}if (ref != null) { -seq.addDBRef (ref); -}return ref; -}, "jalview.datamodel.SequenceI,~S,~S,~S"); -c$.$DBRefUtils$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$1", null, jalview.util.DBRefUtils.DbRefComp); -Clazz.defineMethod (c$, "matches", -function (refa, refb) { -if (refa.getSource () == null || refb.getSource ().equals (refa.getSource ())) { -if (refa.getVersion () == null || refb.getVersion ().equals (refa.getVersion ())) { -if (refa.getAccessionId () == null || refb.getAccessionId ().equals (refa.getAccessionId ())) { -if (refa.getMap () == null || (refb.getMap () != null && refb.getMap ().equals (refa.getMap ()))) { -return true; -}}}}return false; -}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); -c$ = Clazz.p0p (); -}; -c$.$DBRefUtils$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$2", null, jalview.util.DBRefUtils.DbRefComp); -Clazz.defineMethod (c$, "matches", -function (refa, refb) { -if ((refa.getSource () == null || refb.getSource () == null) || refb.getSource ().equals (refa.getSource ())) { -if ((refa.getVersion () == null || refb.getVersion () == null) || refb.getVersion ().equals (refa.getVersion ())) { -if ((refa.getAccessionId () == null || refb.getAccessionId () == null) || refb.getAccessionId ().equals (refa.getAccessionId ())) { -if ((refa.getMap () == null || refb.getMap () == null) || (refb.getMap () != null && refb.getMap ().equals (refa.getMap ()))) { -return true; -}}}}return false; -}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); -c$ = Clazz.p0p (); -}; -c$.$DBRefUtils$3$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$3", null, jalview.util.DBRefUtils.DbRefComp); -Clazz.defineMethod (c$, "matches", -function (refa, refb) { -if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { -if (refa.getAccessionId () != null && refb.getAccessionId () != null || refb.getAccessionId ().equals (refa.getAccessionId ())) { -if ((refa.getMap () == null || refb.getMap () == null) || (refa.getMap () != null && refb.getMap () != null && refb.getMap ().equals (refa.getMap ()))) { -return true; -}}}return false; -}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); -c$ = Clazz.p0p (); -}; -c$.$DBRefUtils$4$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$4", null, jalview.util.DBRefUtils.DbRefComp); -Clazz.defineMethod (c$, "matches", -function (refa, refb) { -if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { -if (refa.getAccessionId () != null && refb.getAccessionId () != null || refb.getAccessionId ().equals (refa.getAccessionId ())) { -if ((refa.getMap () == null && refb.getMap () == null) || (refa.getMap () != null && refb.getMap () != null)) { -if ((refb.getMap ().getMap () == null && refa.getMap ().getMap () == null) || (refb.getMap ().getMap () != null && refa.getMap ().getMap () != null && refb.getMap ().getMap ().getInverse ().equals (refa.getMap ().getMap ()))) { -return true; -}}}}return false; -}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); -c$ = Clazz.p0p (); -}; -c$.$DBRefUtils$5$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$5", null, jalview.util.DBRefUtils.DbRefComp); -Clazz.defineMethod (c$, "matches", -function (refa, refb) { -if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { -if (refa.getAccessionId () != null && refb.getAccessionId () != null || refb.getAccessionId ().equals (refa.getAccessionId ())) { -if (refa.getMap () == null && refb.getMap () == null) { -return true; -}if (refa.getMap () != null && refb.getMap () != null && ((refb.getMap ().getMap () == null && refa.getMap ().getMap () == null) || (refb.getMap ().getMap () != null && refa.getMap ().getMap () != null && refb.getMap ().getMap ().equals (refa.getMap ().getMap ())))) { -return true; -}}}return false; -}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); -c$ = Clazz.p0p (); -}; -c$.$DBRefUtils$6$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$6", null, jalview.util.DBRefUtils.DbRefComp); -Clazz.defineMethod (c$, "matches", -function (refa, refb) { -if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { -if (refa.getAccessionId () != null && refb.getAccessionId () != null && refb.getAccessionId ().equals (refa.getAccessionId ())) { -if (refa.getMap () == null || refb.getMap () == null) { -return true; -}if ((refa.getMap () != null && refb.getMap () != null) && (refb.getMap ().getMap () == null && refa.getMap ().getMap () == null) || (refb.getMap ().getMap () != null && refa.getMap ().getMap () != null && (refb.getMap ().getMap ().equals (refa.getMap ().getMap ())))) { -return true; -}}}return false; -}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); -c$ = Clazz.p0p (); -}; -Clazz.declareInterface (jalview.util.DBRefUtils, "DbRefComp"); -c$.canonicalSourceNameLookup = c$.prototype.canonicalSourceNameLookup = new java.util.HashMap (); -c$.dasCoordinateSystemsLookup = c$.prototype.dasCoordinateSystemsLookup = new java.util.HashMap (); -{ -jalview.util.DBRefUtils.canonicalSourceNameLookup.put ("uniprotkb/swiss-prot", jalview.datamodel.DBRefSource.UNIPROT); -jalview.util.DBRefUtils.canonicalSourceNameLookup.put ("uniprotkb/trembl", jalview.datamodel.DBRefSource.UNIPROT); -jalview.util.DBRefUtils.canonicalSourceNameLookup.put ("pdb", jalview.datamodel.DBRefSource.PDB); -jalview.util.DBRefUtils.dasCoordinateSystemsLookup.put ("pdbresnum", jalview.datamodel.DBRefSource.PDB); -jalview.util.DBRefUtils.dasCoordinateSystemsLookup.put ("uniprot", jalview.datamodel.DBRefSource.UNIPROT); -jalview.util.DBRefUtils.dasCoordinateSystemsLookup.put ("embl", jalview.datamodel.DBRefSource.EMBL); -}c$.matchNonNullonA = c$.prototype.matchNonNullonA = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$1") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$1$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$1, this, null)); -c$.matchEitherNonNull = c$.prototype.matchEitherNonNull = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$2") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$2$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$2, this, null)); -c$.matchDbAndIdAndEitherMap = c$.prototype.matchDbAndIdAndEitherMap = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$3") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$3$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$3, this, null)); -c$.matchDbAndIdAndComplementaryMapList = c$.prototype.matchDbAndIdAndComplementaryMapList = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$4") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$4$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$4, this, null)); -c$.matchDbAndIdAndEquivalentMapList = c$.prototype.matchDbAndIdAndEquivalentMapList = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$5") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$5$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$5, this, null)); -c$.matchDbAndIdAndEitherMapOrEquivalentMapList = c$.prototype.matchDbAndIdAndEitherMapOrEquivalentMapList = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$6") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$6$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$6, this, null)); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.util.HashMap"], "jalview.util.DBRefUtils", ["jalview.datamodel.DBRefEntry", "$.DBRefSource", "$.PDBEntry", "jalview.jsdev.RegExp", "java.util.ArrayList", "$.Hashtable"], function () { +c$ = Clazz.declareType (jalview.util, "DBRefUtils"); +c$.selectRefs = Clazz.defineMethod (c$, "selectRefs", +function (dbrefs, sources) { +if (dbrefs == null) { +return null; +}if (sources == null) { +return dbrefs; +}var srcs = new java.util.HashMap (); +var res = new java.util.ArrayList (); +for (var i = 0; i < sources.length; i++) { +srcs.put ( String.instantialize (sources[i]), new Integer (i)); +} +for (var i = 0, j = dbrefs.length; i < j; i++) { +if (srcs.containsKey (dbrefs[i].getSource ())) { +res.add (dbrefs[i]); +}} +if (res.size () > 0) { +var reply = new Array (res.size ()); +return res.toArray (reply); +}res = null; +return null; +}, "~A,~A"); +c$.isDasCoordinateSystem = Clazz.defineMethod (c$, "isDasCoordinateSystem", +function (string, dBRefEntry) { +if (string == null || dBRefEntry == null) { +return false; +}var coordsys = jalview.util.DBRefUtils.dasCoordinateSystemsLookup.get (string.toLowerCase ()); +return coordsys == null ? false : coordsys.equals (dBRefEntry.getSource ()); +}, "~S,jalview.datamodel.DBRefEntry"); +c$.getCanonicalName = Clazz.defineMethod (c$, "getCanonicalName", +function (source) { +if (source == null) { +return null; +}var canonical = jalview.util.DBRefUtils.canonicalSourceNameLookup.get (source.toLowerCase ()); +return canonical == null ? source : canonical; +}, "~S"); +c$.searchRefs = Clazz.defineMethod (c$, "searchRefs", +function (ref, entry) { +return jalview.util.DBRefUtils.searchRefs (ref, entry, jalview.util.DBRefUtils.matchDbAndIdAndEitherMapOrEquivalentMapList); +}, "~A,jalview.datamodel.DBRefEntry"); +c$.searchRefs = Clazz.defineMethod (c$, "searchRefs", +function (refs, entry, comparator) { +if (refs == null || entry == null) { +return null; +}var rfs = new java.util.ArrayList (); +for (var i = 0; i < refs.length; i++) { +if (comparator.matches (entry, refs[i])) { +rfs.add (refs[i]); +}} +return rfs.size () == 0 ? null : rfs.toArray ( new Array (rfs.size ())); +}, "~A,jalview.datamodel.DBRefEntry,jalview.util.DBRefUtils.DbRefComp"); +c$.parseToDbRef = Clazz.defineMethod (c$, "parseToDbRef", +function (seq, dbname, version, acn) { +var ref = null; +if (dbname != null) { +var locsrc = jalview.util.DBRefUtils.getCanonicalName (dbname); +if (locsrc.equals (jalview.datamodel.DBRefSource.PDB)) { +var r = jalview.jsdev.RegExp.newRegex (["([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)"]); +if (r.search (acn.trim ())) { +var pdbid = r.stringMatchedI (1); +var chaincode = r.stringMatchedI (2); +if (chaincode == null) { +chaincode = " "; +}if (chaincode.equals (" ")) { +chaincode = "_"; +}ref = new jalview.datamodel.DBRefEntry (locsrc, version, pdbid + chaincode); +var pdbr = new jalview.datamodel.PDBEntry (); +pdbr.setId (pdbid); +pdbr.setType (jalview.datamodel.PDBEntry.Type.PDB); +pdbr.setProperty ( new java.util.Hashtable ()); +pdbr.setChainCode (chaincode); +seq.addPDBId (pdbr); +} else { +System.err.println ("Malformed PDB DR line:" + acn); +}} else { +ref = new jalview.datamodel.DBRefEntry (locsrc, version, acn); +}}if (ref != null) { +seq.addDBRef (ref); +}return ref; +}, "jalview.datamodel.SequenceI,~S,~S,~S"); +c$.$DBRefUtils$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$1", null, jalview.util.DBRefUtils.DbRefComp); +Clazz.defineMethod (c$, "matches", +function (refa, refb) { +if (refa.getSource () == null || refb.getSource ().equals (refa.getSource ())) { +if (refa.getVersion () == null || refb.getVersion ().equals (refa.getVersion ())) { +if (refa.getAccessionId () == null || refb.getAccessionId ().equals (refa.getAccessionId ())) { +if (refa.getMap () == null || (refb.getMap () != null && refb.getMap ().equals (refa.getMap ()))) { +return true; +}}}}return false; +}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); +c$ = Clazz.p0p (); +}; +c$.$DBRefUtils$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$2", null, jalview.util.DBRefUtils.DbRefComp); +Clazz.defineMethod (c$, "matches", +function (refa, refb) { +if ((refa.getSource () == null || refb.getSource () == null) || refb.getSource ().equals (refa.getSource ())) { +if ((refa.getVersion () == null || refb.getVersion () == null) || refb.getVersion ().equals (refa.getVersion ())) { +if ((refa.getAccessionId () == null || refb.getAccessionId () == null) || refb.getAccessionId ().equals (refa.getAccessionId ())) { +if ((refa.getMap () == null || refb.getMap () == null) || (refb.getMap () != null && refb.getMap ().equals (refa.getMap ()))) { +return true; +}}}}return false; +}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); +c$ = Clazz.p0p (); +}; +c$.$DBRefUtils$3$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$3", null, jalview.util.DBRefUtils.DbRefComp); +Clazz.defineMethod (c$, "matches", +function (refa, refb) { +if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { +if (refa.getAccessionId () != null && refb.getAccessionId () != null || refb.getAccessionId ().equals (refa.getAccessionId ())) { +if ((refa.getMap () == null || refb.getMap () == null) || (refa.getMap () != null && refb.getMap () != null && refb.getMap ().equals (refa.getMap ()))) { +return true; +}}}return false; +}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); +c$ = Clazz.p0p (); +}; +c$.$DBRefUtils$4$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$4", null, jalview.util.DBRefUtils.DbRefComp); +Clazz.defineMethod (c$, "matches", +function (refa, refb) { +if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { +if (refa.getAccessionId () != null && refb.getAccessionId () != null || refb.getAccessionId ().equals (refa.getAccessionId ())) { +if ((refa.getMap () == null && refb.getMap () == null) || (refa.getMap () != null && refb.getMap () != null)) { +if ((refb.getMap ().getMap () == null && refa.getMap ().getMap () == null) || (refb.getMap ().getMap () != null && refa.getMap ().getMap () != null && refb.getMap ().getMap ().getInverse ().equals (refa.getMap ().getMap ()))) { +return true; +}}}}return false; +}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); +c$ = Clazz.p0p (); +}; +c$.$DBRefUtils$5$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$5", null, jalview.util.DBRefUtils.DbRefComp); +Clazz.defineMethod (c$, "matches", +function (refa, refb) { +if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { +if (refa.getAccessionId () != null && refb.getAccessionId () != null || refb.getAccessionId ().equals (refa.getAccessionId ())) { +if (refa.getMap () == null && refb.getMap () == null) { +return true; +}if (refa.getMap () != null && refb.getMap () != null && ((refb.getMap ().getMap () == null && refa.getMap ().getMap () == null) || (refb.getMap ().getMap () != null && refa.getMap ().getMap () != null && refb.getMap ().getMap ().equals (refa.getMap ().getMap ())))) { +return true; +}}}return false; +}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); +c$ = Clazz.p0p (); +}; +c$.$DBRefUtils$6$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "DBRefUtils$6", null, jalview.util.DBRefUtils.DbRefComp); +Clazz.defineMethod (c$, "matches", +function (refa, refb) { +if (refa.getSource () != null && refb.getSource () != null && refb.getSource ().equals (refa.getSource ())) { +if (refa.getAccessionId () != null && refb.getAccessionId () != null && refb.getAccessionId ().equals (refa.getAccessionId ())) { +if (refa.getMap () == null || refb.getMap () == null) { +return true; +}if ((refa.getMap () != null && refb.getMap () != null) && (refb.getMap ().getMap () == null && refa.getMap ().getMap () == null) || (refb.getMap ().getMap () != null && refa.getMap ().getMap () != null && (refb.getMap ().getMap ().equals (refa.getMap ().getMap ())))) { +return true; +}}}return false; +}, "jalview.datamodel.DBRefEntry,jalview.datamodel.DBRefEntry"); +c$ = Clazz.p0p (); +}; +Clazz.declareInterface (jalview.util.DBRefUtils, "DbRefComp"); +c$.canonicalSourceNameLookup = c$.prototype.canonicalSourceNameLookup = new java.util.HashMap (); +c$.dasCoordinateSystemsLookup = c$.prototype.dasCoordinateSystemsLookup = new java.util.HashMap (); +{ +jalview.util.DBRefUtils.canonicalSourceNameLookup.put ("uniprotkb/swiss-prot", jalview.datamodel.DBRefSource.UNIPROT); +jalview.util.DBRefUtils.canonicalSourceNameLookup.put ("uniprotkb/trembl", jalview.datamodel.DBRefSource.UNIPROT); +jalview.util.DBRefUtils.canonicalSourceNameLookup.put ("pdb", jalview.datamodel.DBRefSource.PDB); +jalview.util.DBRefUtils.dasCoordinateSystemsLookup.put ("pdbresnum", jalview.datamodel.DBRefSource.PDB); +jalview.util.DBRefUtils.dasCoordinateSystemsLookup.put ("uniprot", jalview.datamodel.DBRefSource.UNIPROT); +jalview.util.DBRefUtils.dasCoordinateSystemsLookup.put ("embl", jalview.datamodel.DBRefSource.EMBL); +}c$.matchNonNullonA = c$.prototype.matchNonNullonA = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$1") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$1$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$1, this, null)); +c$.matchEitherNonNull = c$.prototype.matchEitherNonNull = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$2") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$2$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$2, this, null)); +c$.matchDbAndIdAndEitherMap = c$.prototype.matchDbAndIdAndEitherMap = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$3") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$3$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$3, this, null)); +c$.matchDbAndIdAndComplementaryMapList = c$.prototype.matchDbAndIdAndComplementaryMapList = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$4") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$4$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$4, this, null)); +c$.matchDbAndIdAndEquivalentMapList = c$.prototype.matchDbAndIdAndEquivalentMapList = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$5") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$5$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$5, this, null)); +c$.matchDbAndIdAndEitherMapOrEquivalentMapList = c$.prototype.matchDbAndIdAndEitherMapOrEquivalentMapList = ((Clazz.isClassDefined ("jalview.util.DBRefUtils$6") ? 0 : jalview.util.DBRefUtils.$DBRefUtils$6$ ()), Clazz.innerTypeInstance (jalview.util.DBRefUtils$6, this, null)); +}); diff --git a/bin/jalview/util/Format.js b/bin/jalview/util/Format.js index 95a3560..739add8 100644 --- a/bin/jalview/util/Format.js +++ b/bin/jalview/util/Format.js @@ -1,389 +1,389 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.Format", ["java.lang.Character", "$.IllegalArgumentException", "$.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.width = 0; -this.precision = 0; -this.pre = null; -this.post = null; -this.leading_zeroes = false; -this.show_plus = false; -this.alternate = false; -this.show_space = false; -this.left_align = false; -this.fmt = '\0'; -this.formatString = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "Format"); -Clazz.makeConstructor (c$, -function (s) { -this.formatString = s; -this.width = 0; -this.precision = -1; -this.pre = ""; -this.post = ""; -this.leading_zeroes = false; -this.show_plus = false; -this.alternate = false; -this.show_space = false; -this.left_align = false; -this.fmt = ' '; -var length = s.length; -var parse_state = 0; -var i = 0; -while (parse_state == 0) { -if (i >= length) { -parse_state = 5; -} else if (s.charAt (i) == '%') { -if (i < (length - 1)) { -if (s.charAt (i + 1) == '%') { -this.pre = this.pre + '%'; -i++; -} else { -parse_state = 1; -}} else { -throw new IllegalArgumentException (); -}} else { -this.pre = this.pre + s.charAt (i); -}i++; -} -while (parse_state == 1) { -if (i >= length) { -parse_state = 5; -} else if (s.charAt (i) == ' ') { -this.show_space = true; -} else if (s.charAt (i) == '-') { -this.left_align = true; -} else if (s.charAt (i) == '+') { -this.show_plus = true; -} else if (s.charAt (i) == '0') { -this.leading_zeroes = true; -} else if (s.charAt (i) == '#') { -this.alternate = true; -} else { -parse_state = 2; -i--; -}i++; -} -while (parse_state == 2) { -if (i >= length) { -parse_state = 5; -} else if (('0' <= s.charAt (i)) && (s.charAt (i) <= '9')) { -this.width = ((this.width * 10) + s.charCodeAt (i)) - 48; -i++; -} else if (s.charAt (i) == '.') { -parse_state = 3; -this.precision = 0; -i++; -} else { -parse_state = 4; -}} -while (parse_state == 3) { -if (i >= length) { -parse_state = 5; -} else if (('0' <= s.charAt (i)) && (s.charAt (i) <= '9')) { -this.precision = ((this.precision * 10) + s.charCodeAt (i)) - 48; -i++; -} else { -parse_state = 4; -}} -if (parse_state == 4) { -if (i >= length) { -parse_state = 5; -} else { -this.fmt = s.charAt (i); -}i++; -}if (i < length) { -this.post = s.substring (i, length); -}}, "~S"); -c$.getHexString = Clazz.defineMethod (c$, "getHexString", -function (color) { -var r; -var g; -var b; -r = Integer.toHexString (color.getRed ()); -if (r.length < 2) { -r = "0" + r; -}g = Integer.toHexString (color.getGreen ()); -if (g.length < 2) { -g = "0" + g; -}b = Integer.toHexString (color.getBlue ()); -if (b.length < 2) { -b = "0" + b; -}return r + g + b; -}, "java.awt.Color"); -c$.printDouble = Clazz.defineMethod (c$, "printDouble", -function (s, fmt, x) { -s.print ( new jalview.util.Format (fmt).formDouble (x)); -}, "java.io.PrintStream,~S,~N"); -c$.printLong = Clazz.defineMethod (c$, "printLong", -function (s, fmt, x) { -s.print ( new jalview.util.Format (fmt).formLong (x)); -}, "java.io.PrintStream,~S,~N"); -c$.printChar = Clazz.defineMethod (c$, "printChar", -function (s, fmt, x) { -s.print ( new jalview.util.Format (fmt).formChar (x)); -}, "java.io.PrintStream,~S,~S"); -c$.print = Clazz.defineMethod (c$, "print", -function (s, fmt, x) { -s.print ( new jalview.util.Format (fmt).form (x)); -}, "java.io.PrintStream,~S,~S"); -c$.atoi = Clazz.defineMethod (c$, "atoi", -function (s) { -return jalview.util.Format.atol (s); -}, "~S"); -c$.atol = Clazz.defineMethod (c$, "atol", -function (s) { -var i = 0; -while ((i < s.length) && Character.isWhitespace (s.charAt (i))) { -i++; -} -if ((i < s.length) && (s.charAt (i) == '0')) { -if (((i + 1) < s.length) && ((s.charAt (i + 1) == 'x') || (s.charAt (i + 1) == 'X'))) { -return jalview.util.Format.parseLong (s.substring (i + 2), 16); -} else { -return jalview.util.Format.parseLong (s, 8); -}} else { -return jalview.util.Format.parseLong (s, 10); -}}, "~S"); -c$.parseLong = Clazz.defineMethod (c$, "parseLong", -($fz = function (s, base) { -var i = 0; -var sign = 1; -var r = 0; -while ((i < s.length) && Character.isWhitespace (s.charAt (i))) { -i++; -} -if ((i < s.length) && (s.charAt (i) == '-')) { -sign = -1; -i++; -} else if ((i < s.length) && (s.charAt (i) == '+')) { -i++; -}while (i < s.length) { -var ch = s.charAt (i); -if (('0' <= ch) && (ch.charCodeAt (0) < (48 + base))) { -r = ((r * base) + ch.charCodeAt (0)) - 48; -} else if (('A' <= ch) && (ch.charCodeAt (0) < ((65 + base) - 10))) { -r = ((r * base) + ch.charCodeAt (0)) - 65 + 10; -} else if (('a' <= ch) && (ch.charCodeAt (0) < ((97 + base) - 10))) { -r = ((r * base) + ch.charCodeAt (0)) - 97 + 10; -} else { -return r * sign; -}i++; -} -return r * sign; -}, $fz.isPrivate = true, $fz), "~S,~N"); -c$.atof = Clazz.defineMethod (c$, "atof", -function (s) { -var i = 0; -var sign = 1; -var r = 0; -var p = 1; -var state = 0; -while ((i < s.length) && Character.isWhitespace (s.charAt (i))) { -i++; -} -if ((i < s.length) && (s.charAt (i) == '-')) { -sign = -1; -i++; -} else if ((i < s.length) && (s.charAt (i) == '+')) { -i++; -}while (i < s.length) { -var ch = s.charAt (i); -if (('0' <= ch) && (ch <= '9')) { -if (state == 0) { -r = ((r * 10) + ch.charCodeAt (0)) - 48; -} else if (state == 1) { -p = p / 10; -r = r + (p * (ch.charCodeAt (0) - 48)); -}} else if (ch == '.') { -if (state == 0) { -state = 1; -} else { -return sign * r; -}} else if ((ch == 'e') || (ch == 'E')) { -var e = jalview.util.Format.parseLong (s.substring (i + 1), 10); -return sign * r * Math.pow (10, e); -} else { -return sign * r; -}i++; -} -return sign * r; -}, "~S"); -Clazz.defineMethod (c$, "formDouble", -function (x) { -var r; -if (this.precision < 0) { -this.precision = 6; -}var s = 1; -if (x < 0) { -x = -x; -s = -1; -}if (this.fmt == 'f') { -r = this.fixed_format (x); -} else if ((this.fmt == 'e') || (this.fmt == 'E') || (this.fmt == 'g') || (this.fmt == 'G')) { -r = this.exp_format (x); -} else { -throw new IllegalArgumentException (); -}return this.pad (this.sign (s, r)); -}, "~N"); -Clazz.defineMethod (c$, "formLong", -function (x) { -var r; -var s = 0; -if ((this.fmt == 'd') || (this.fmt == 'i')) { -if (x < 0) { -r = ("" + x).substring (1); -s = -1; -} else { -r = "" + x; -s = 1; -}} else if (this.fmt == 'o') { -r = jalview.util.Format.convert (x, 3, 7, "01234567"); -} else if (this.fmt == 'x') { -r = jalview.util.Format.convert (x, 4, 15, "0123456789abcdef"); -} else if (this.fmt == 'X') { -r = jalview.util.Format.convert (x, 4, 15, "0123456789ABCDEF"); -} else { -throw new IllegalArgumentException (); -}return this.pad (this.sign (s, r)); -}, "~N"); -Clazz.defineMethod (c$, "formChar", -function (c) { -if (this.fmt != 'c') { -throw new IllegalArgumentException (); -}var r = "" + c; -return this.pad (r); -}, "~S"); -Clazz.defineMethod (c$, "form", -function (s) { -if (this.fmt != 's') { -throw new IllegalArgumentException (); -}if (this.precision >= 0) { -s = s.substring (0, this.precision); -}return this.pad (s); -}, "~S"); -c$.repeat = Clazz.defineMethod (c$, "repeat", -($fz = function (c, n) { -if (n <= 0) { -return ""; -}var s = new StringBuffer (n); -for (var i = 0; i < n; i++) { -s.append (c); -} -return s.toString (); -}, $fz.isPrivate = true, $fz), "~S,~N"); -c$.convert = Clazz.defineMethod (c$, "convert", -($fz = function (x, n, m, d) { -if (x == 0) { -return "0"; -}var r = ""; -while (x != 0) { -r = d.charAt ((x & m)) + r; -x = x >>> n; -} -return r; -}, $fz.isPrivate = true, $fz), "~N,~N,~N,~S"); -Clazz.defineMethod (c$, "pad", -($fz = function (r) { -var p = jalview.util.Format.repeat (' ', this.width - r.length); -if (this.left_align) { -return this.pre + r + p + this.post; -} else { -return this.pre + p + r + this.post; -}}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "sign", -($fz = function (s, r) { -var p = ""; -if (s < 0) { -p = "-"; -} else if (s > 0) { -if (this.show_plus) { -p = "+"; -} else if (this.show_space) { -p = " "; -}} else { -if ((this.fmt == 'o') && this.alternate && (r.length > 0) && (r.charAt (0) != '0')) { -p = "0"; -} else if ((this.fmt == 'x') && this.alternate) { -p = "0x"; -} else if ((this.fmt == 'X') && this.alternate) { -p = "0X"; -}}var w = 0; -if (this.leading_zeroes) { -w = this.width; -} else if (((this.fmt == 'd') || (this.fmt == 'i') || (this.fmt == 'x') || (this.fmt == 'X') || (this.fmt == 'o')) && (this.precision > 0)) { -w = this.precision; -}return p + jalview.util.Format.repeat ('0', w - p.length - r.length) + r; -}, $fz.isPrivate = true, $fz), "~N,~S"); -Clazz.defineMethod (c$, "fixed_format", -($fz = function (d) { -var removeTrailing = ((this.fmt == 'G') || (this.fmt == 'g')) && !this.alternate; -if (d > 0x7FFFFFFFFFFFFFFF) { -return this.exp_format (d); -}if (this.precision == 0) { -return Clazz.doubleToLong (d + 0.5) + (removeTrailing ? "" : "."); -}var whole = Clazz.doubleToLong (d); -var fr = d - whole; -if ((fr >= 1) || (fr < 0)) { -return this.exp_format (d); -}var factor = 1; -var leading_zeroes = ""; -for (var i = 1; (i <= this.precision) && (factor <= 0x7FFFFFFFFFFFFFFF); i++) { -factor *= 10; -leading_zeroes = leading_zeroes + "0"; -} -var l = Clazz.doubleToLong ((factor * fr) + 0.5); -if (l >= factor) { -l = 0; -whole++; -}var z = leading_zeroes + l; -z = "." + z.substring (z.length - this.precision, z.length); -if (removeTrailing) { -var t = z.length - 1; -while ((t >= 0) && (z.charAt (t) == '0')) { -t--; -} -if ((t >= 0) && (z.charAt (t) == '.')) { -t--; -}z = z.substring (0, t + 1); -}return whole + z; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "exp_format", -($fz = function (d) { -var f = ""; -var e = 0; -var dd = d; -var factor = 1; -if (d != 0) { -while (dd > 10) { -e++; -factor /= 10; -dd = dd / 10; -} -while (dd < 1) { -e--; -factor *= 10; -dd = dd * 10; -} -}if (((this.fmt == 'g') || (this.fmt == 'G')) && (e >= -4) && (e < this.precision)) { -return this.fixed_format (d); -}d = d * factor; -f = f + this.fixed_format (d); -if ((this.fmt == 'e') || (this.fmt == 'g')) { -f = f + "e"; -} else { -f = f + "E"; -}var p = "000"; -if (e >= 0) { -f = f + "+"; -p = p + e; -} else { -f = f + "-"; -p = p + (-e); -}return f + p.substring (p.length - 3, p.length); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.formatString; -}); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.Format", ["java.lang.Character", "$.IllegalArgumentException", "$.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.width = 0; +this.precision = 0; +this.pre = null; +this.post = null; +this.leading_zeroes = false; +this.show_plus = false; +this.alternate = false; +this.show_space = false; +this.left_align = false; +this.fmt = '\0'; +this.formatString = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "Format"); +Clazz.makeConstructor (c$, +function (s) { +this.formatString = s; +this.width = 0; +this.precision = -1; +this.pre = ""; +this.post = ""; +this.leading_zeroes = false; +this.show_plus = false; +this.alternate = false; +this.show_space = false; +this.left_align = false; +this.fmt = ' '; +var length = s.length; +var parse_state = 0; +var i = 0; +while (parse_state == 0) { +if (i >= length) { +parse_state = 5; +} else if (s.charAt (i) == '%') { +if (i < (length - 1)) { +if (s.charAt (i + 1) == '%') { +this.pre = this.pre + '%'; +i++; +} else { +parse_state = 1; +}} else { +throw new IllegalArgumentException (); +}} else { +this.pre = this.pre + s.charAt (i); +}i++; +} +while (parse_state == 1) { +if (i >= length) { +parse_state = 5; +} else if (s.charAt (i) == ' ') { +this.show_space = true; +} else if (s.charAt (i) == '-') { +this.left_align = true; +} else if (s.charAt (i) == '+') { +this.show_plus = true; +} else if (s.charAt (i) == '0') { +this.leading_zeroes = true; +} else if (s.charAt (i) == '#') { +this.alternate = true; +} else { +parse_state = 2; +i--; +}i++; +} +while (parse_state == 2) { +if (i >= length) { +parse_state = 5; +} else if (('0' <= s.charAt (i)) && (s.charAt (i) <= '9')) { +this.width = ((this.width * 10) + s.charCodeAt (i)) - 48; +i++; +} else if (s.charAt (i) == '.') { +parse_state = 3; +this.precision = 0; +i++; +} else { +parse_state = 4; +}} +while (parse_state == 3) { +if (i >= length) { +parse_state = 5; +} else if (('0' <= s.charAt (i)) && (s.charAt (i) <= '9')) { +this.precision = ((this.precision * 10) + s.charCodeAt (i)) - 48; +i++; +} else { +parse_state = 4; +}} +if (parse_state == 4) { +if (i >= length) { +parse_state = 5; +} else { +this.fmt = s.charAt (i); +}i++; +}if (i < length) { +this.post = s.substring (i, length); +}}, "~S"); +c$.getHexString = Clazz.defineMethod (c$, "getHexString", +function (color) { +var r; +var g; +var b; +r = Integer.toHexString (color.getRed ()); +if (r.length < 2) { +r = "0" + r; +}g = Integer.toHexString (color.getGreen ()); +if (g.length < 2) { +g = "0" + g; +}b = Integer.toHexString (color.getBlue ()); +if (b.length < 2) { +b = "0" + b; +}return r + g + b; +}, "java.awt.Color"); +c$.printDouble = Clazz.defineMethod (c$, "printDouble", +function (s, fmt, x) { +s.print ( new jalview.util.Format (fmt).formDouble (x)); +}, "java.io.PrintStream,~S,~N"); +c$.printLong = Clazz.defineMethod (c$, "printLong", +function (s, fmt, x) { +s.print ( new jalview.util.Format (fmt).formLong (x)); +}, "java.io.PrintStream,~S,~N"); +c$.printChar = Clazz.defineMethod (c$, "printChar", +function (s, fmt, x) { +s.print ( new jalview.util.Format (fmt).formChar (x)); +}, "java.io.PrintStream,~S,~S"); +c$.print = Clazz.defineMethod (c$, "print", +function (s, fmt, x) { +s.print ( new jalview.util.Format (fmt).form (x)); +}, "java.io.PrintStream,~S,~S"); +c$.atoi = Clazz.defineMethod (c$, "atoi", +function (s) { +return jalview.util.Format.atol (s); +}, "~S"); +c$.atol = Clazz.defineMethod (c$, "atol", +function (s) { +var i = 0; +while ((i < s.length) && Character.isWhitespace (s.charAt (i))) { +i++; +} +if ((i < s.length) && (s.charAt (i) == '0')) { +if (((i + 1) < s.length) && ((s.charAt (i + 1) == 'x') || (s.charAt (i + 1) == 'X'))) { +return jalview.util.Format.parseLong (s.substring (i + 2), 16); +} else { +return jalview.util.Format.parseLong (s, 8); +}} else { +return jalview.util.Format.parseLong (s, 10); +}}, "~S"); +c$.parseLong = Clazz.defineMethod (c$, "parseLong", +($fz = function (s, base) { +var i = 0; +var sign = 1; +var r = 0; +while ((i < s.length) && Character.isWhitespace (s.charAt (i))) { +i++; +} +if ((i < s.length) && (s.charAt (i) == '-')) { +sign = -1; +i++; +} else if ((i < s.length) && (s.charAt (i) == '+')) { +i++; +}while (i < s.length) { +var ch = s.charAt (i); +if (('0' <= ch) && (ch.charCodeAt (0) < (48 + base))) { +r = ((r * base) + ch.charCodeAt (0)) - 48; +} else if (('A' <= ch) && (ch.charCodeAt (0) < ((65 + base) - 10))) { +r = ((r * base) + ch.charCodeAt (0)) - 65 + 10; +} else if (('a' <= ch) && (ch.charCodeAt (0) < ((97 + base) - 10))) { +r = ((r * base) + ch.charCodeAt (0)) - 97 + 10; +} else { +return r * sign; +}i++; +} +return r * sign; +}, $fz.isPrivate = true, $fz), "~S,~N"); +c$.atof = Clazz.defineMethod (c$, "atof", +function (s) { +var i = 0; +var sign = 1; +var r = 0; +var p = 1; +var state = 0; +while ((i < s.length) && Character.isWhitespace (s.charAt (i))) { +i++; +} +if ((i < s.length) && (s.charAt (i) == '-')) { +sign = -1; +i++; +} else if ((i < s.length) && (s.charAt (i) == '+')) { +i++; +}while (i < s.length) { +var ch = s.charAt (i); +if (('0' <= ch) && (ch <= '9')) { +if (state == 0) { +r = ((r * 10) + ch.charCodeAt (0)) - 48; +} else if (state == 1) { +p = p / 10; +r = r + (p * (ch.charCodeAt (0) - 48)); +}} else if (ch == '.') { +if (state == 0) { +state = 1; +} else { +return sign * r; +}} else if ((ch == 'e') || (ch == 'E')) { +var e = jalview.util.Format.parseLong (s.substring (i + 1), 10); +return sign * r * Math.pow (10, e); +} else { +return sign * r; +}i++; +} +return sign * r; +}, "~S"); +Clazz.defineMethod (c$, "formDouble", +function (x) { +var r; +if (this.precision < 0) { +this.precision = 6; +}var s = 1; +if (x < 0) { +x = -x; +s = -1; +}if (this.fmt == 'f') { +r = this.fixed_format (x); +} else if ((this.fmt == 'e') || (this.fmt == 'E') || (this.fmt == 'g') || (this.fmt == 'G')) { +r = this.exp_format (x); +} else { +throw new IllegalArgumentException (); +}return this.pad (this.sign (s, r)); +}, "~N"); +Clazz.defineMethod (c$, "formLong", +function (x) { +var r; +var s = 0; +if ((this.fmt == 'd') || (this.fmt == 'i')) { +if (x < 0) { +r = ("" + x).substring (1); +s = -1; +} else { +r = "" + x; +s = 1; +}} else if (this.fmt == 'o') { +r = jalview.util.Format.convert (x, 3, 7, "01234567"); +} else if (this.fmt == 'x') { +r = jalview.util.Format.convert (x, 4, 15, "0123456789abcdef"); +} else if (this.fmt == 'X') { +r = jalview.util.Format.convert (x, 4, 15, "0123456789ABCDEF"); +} else { +throw new IllegalArgumentException (); +}return this.pad (this.sign (s, r)); +}, "~N"); +Clazz.defineMethod (c$, "formChar", +function (c) { +if (this.fmt != 'c') { +throw new IllegalArgumentException (); +}var r = "" + c; +return this.pad (r); +}, "~S"); +Clazz.defineMethod (c$, "form", +function (s) { +if (this.fmt != 's') { +throw new IllegalArgumentException (); +}if (this.precision >= 0) { +s = s.substring (0, this.precision); +}return this.pad (s); +}, "~S"); +c$.repeat = Clazz.defineMethod (c$, "repeat", +($fz = function (c, n) { +if (n <= 0) { +return ""; +}var s = new StringBuffer (n); +for (var i = 0; i < n; i++) { +s.append (c); +} +return s.toString (); +}, $fz.isPrivate = true, $fz), "~S,~N"); +c$.convert = Clazz.defineMethod (c$, "convert", +($fz = function (x, n, m, d) { +if (x == 0) { +return "0"; +}var r = ""; +while (x != 0) { +r = d.charAt ((x & m)) + r; +x = x >>> n; +} +return r; +}, $fz.isPrivate = true, $fz), "~N,~N,~N,~S"); +Clazz.defineMethod (c$, "pad", +($fz = function (r) { +var p = jalview.util.Format.repeat (' ', this.width - r.length); +if (this.left_align) { +return this.pre + r + p + this.post; +} else { +return this.pre + p + r + this.post; +}}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "sign", +($fz = function (s, r) { +var p = ""; +if (s < 0) { +p = "-"; +} else if (s > 0) { +if (this.show_plus) { +p = "+"; +} else if (this.show_space) { +p = " "; +}} else { +if ((this.fmt == 'o') && this.alternate && (r.length > 0) && (r.charAt (0) != '0')) { +p = "0"; +} else if ((this.fmt == 'x') && this.alternate) { +p = "0x"; +} else if ((this.fmt == 'X') && this.alternate) { +p = "0X"; +}}var w = 0; +if (this.leading_zeroes) { +w = this.width; +} else if (((this.fmt == 'd') || (this.fmt == 'i') || (this.fmt == 'x') || (this.fmt == 'X') || (this.fmt == 'o')) && (this.precision > 0)) { +w = this.precision; +}return p + jalview.util.Format.repeat ('0', w - p.length - r.length) + r; +}, $fz.isPrivate = true, $fz), "~N,~S"); +Clazz.defineMethod (c$, "fixed_format", +($fz = function (d) { +var removeTrailing = ((this.fmt == 'G') || (this.fmt == 'g')) && !this.alternate; +if (d > 0x7FFFFFFFFFFFFFFF) { +return this.exp_format (d); +}if (this.precision == 0) { +return Clazz.doubleToLong (d + 0.5) + (removeTrailing ? "" : "."); +}var whole = Clazz.doubleToLong (d); +var fr = d - whole; +if ((fr >= 1) || (fr < 0)) { +return this.exp_format (d); +}var factor = 1; +var leading_zeroes = ""; +for (var i = 1; (i <= this.precision) && (factor <= 0x7FFFFFFFFFFFFFFF); i++) { +factor *= 10; +leading_zeroes = leading_zeroes + "0"; +} +var l = Clazz.doubleToLong ((factor * fr) + 0.5); +if (l >= factor) { +l = 0; +whole++; +}var z = leading_zeroes + l; +z = "." + z.substring (z.length - this.precision, z.length); +if (removeTrailing) { +var t = z.length - 1; +while ((t >= 0) && (z.charAt (t) == '0')) { +t--; +} +if ((t >= 0) && (z.charAt (t) == '.')) { +t--; +}z = z.substring (0, t + 1); +}return whole + z; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "exp_format", +($fz = function (d) { +var f = ""; +var e = 0; +var dd = d; +var factor = 1; +if (d != 0) { +while (dd > 10) { +e++; +factor /= 10; +dd = dd / 10; +} +while (dd < 1) { +e--; +factor *= 10; +dd = dd * 10; +} +}if (((this.fmt == 'g') || (this.fmt == 'G')) && (e >= -4) && (e < this.precision)) { +return this.fixed_format (d); +}d = d * factor; +f = f + this.fixed_format (d); +if ((this.fmt == 'e') || (this.fmt == 'g')) { +f = f + "e"; +} else { +f = f + "E"; +}var p = "000"; +if (e >= 0) { +f = f + "+"; +p = p + e; +} else { +f = f + "-"; +p = p + (-e); +}return f + p.substring (p.length - 3, p.length); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.formatString; +}); +}); diff --git a/bin/jalview/util/GroupUrlLink.js b/bin/jalview/util/GroupUrlLink.js index 5535c1f..c6f0e7e 100644 --- a/bin/jalview/util/GroupUrlLink.js +++ b/bin/jalview/util/GroupUrlLink.js @@ -1,363 +1,363 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.lang.Exception"], "jalview.util.GroupUrlLink", ["jalview.jsdev.RegExp", "jalview.util.MessageManager", "$.Platform", "$.QuickSort", "java.lang.Error", "$.StringBuffer", "java.util.Hashtable"], function () { -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.util.GroupUrlLink.UrlStringTooLongException")) { -jalview.util.GroupUrlLink.$GroupUrlLink$UrlStringTooLongException$ (); -} -this.url_prefix = null; -this.target = null; -this.label = null; -this.url_suffix = null; -this.separators = null; -this.regexReplace = null; -this.invalidMessage = null; -this.segs = null; -this.mtch = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "GroupUrlLink"); -Clazz.makeConstructor (c$, -function (link) { -var sep = link.indexOf ("|"); -this.segs = Clazz.newIntArray (jalview.util.GroupUrlLink.tokens.length, 0); -var ntoks = 0; -for (var i = 0; i < this.segs.length; i++) { -if ((this.segs[i] = link.indexOf ("$" + jalview.util.GroupUrlLink.tokens[i])) > -1) { -ntoks++; -}} -if (ntoks == 0) { -this.invalidMessage = "Group URL string must contain at least one of "; -for (var i = 0; i < this.segs.length; i++) { -this.invalidMessage += " '$" + jalview.util.GroupUrlLink.tokens[i] + "[=/regex=/]$'"; -} -return; -}var ptok = Clazz.newIntArray (ntoks + 1, 0); -var tmtch = new Array (ntoks + 1); -this.mtch = new Array (ntoks); -for (var i = 0, t = 0; i < this.segs.length; i++) { -if (this.segs[i] > -1) { -ptok[t] = this.segs[i]; -tmtch[t++] = jalview.util.GroupUrlLink.tokens[i]; -}} -ptok[ntoks] = link.length; -tmtch[ntoks] = "$$$$$$$$$"; -jalview.util.QuickSort.sortInt (ptok, tmtch); -for (var i = 0; i < ntoks; i++) { -this.mtch[i] = tmtch[i]; -} -var p = sep; -do { -sep = p; -p = link.indexOf ("|", sep + 1); -} while (p > sep && p < ptok[0]); -this.label = link.substring (0, sep); -if (this.label.indexOf ("|") > -1) { -this.target = this.label.substring (0, this.label.indexOf ("|")); -} else if (this.label.indexOf (" ") > 2) { -this.target = this.label.substring (0, this.label.indexOf (" ")); -} else { -this.target = this.label; -}this.url_prefix = link.substring (sep + 1, ptok[0]); -this.url_suffix = new Array (this.mtch.length); -this.regexReplace = new Array (this.mtch.length); -for (var pass = 0; pass < this.mtch.length; pass++) { -var mlength = 3 + this.mtch[pass].length; -if (link.indexOf ("$" + this.mtch[pass] + "=/") == ptok[pass] && (p = link.indexOf ("/=$", ptok[pass] + mlength)) > ptok[pass] + mlength) { -if (ptok[pass + 1] < p + 3) { -this.invalidMessage = "Token regexes cannot contain other regexes (did you terminate the $" + this.mtch[pass] + " regex with a '/=$' ?"; -return; -}this.url_suffix[pass] = link.substring (p + 3, ptok[pass + 1]); -this.regexReplace[pass] = link.substring (ptok[pass] + mlength, p); -try { -var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); -if (rg == null) { -this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; -} else { -throw e; -} -} -} else { -this.regexReplace[pass] = null; -if ((p = link.indexOf ("$" + this.mtch[pass] + "$")) == ptok[pass]) { -this.url_suffix[pass] = link.substring (p + this.mtch[pass].length + 2, ptok[pass + 1]); -} else { -this.invalidMessage = "Warning: invalid regex structure (after '" + this.mtch[0] + "') for URL link : " + link; -}}} -var pass = 0; -this.separators = new Array (this.url_suffix.length); -var suffices = this.url_suffix[this.url_suffix.length - 1]; -var lastsep = ","; -while ((p = suffices.indexOf ('|')) > -1) { -this.separators[pass] = suffices.substring (p + 1); -if (pass == 0) { -this.url_suffix[this.url_suffix.length - 1] = suffices.substring (0, p); -} else { -lastsep = (this.separators[pass - 1] = this.separators[pass - 1].substring (0, p)); -}suffices = this.separators[pass]; -pass++; -} -if (pass > 0) { -lastsep = this.separators[pass - 1]; -}while (pass < this.separators.length) { -this.separators[pass++] = lastsep; -} -}, "~S"); -Clazz.defineMethod (c$, "getUrl_suffix", -function () { -return this.url_suffix[this.url_suffix.length - 1]; -}); -Clazz.defineMethod (c$, "getUrl_prefix", -function () { -return this.url_prefix; -}); -Clazz.defineMethod (c$, "getTarget", -function () { -return this.target; -}); -Clazz.defineMethod (c$, "getLabel", -function () { -return this.label; -}); -Clazz.defineMethod (c$, "getIDRegexReplace", -function () { -return this._replaceFor (jalview.util.GroupUrlLink.tokens[0]); -}); -Clazz.defineMethod (c$, "_replaceFor", -($fz = function (token) { -for (var i = 0; i < this.mtch.length; i++) { -if (this.segs[i] > -1 && this.mtch[i].equals (token)) { -return this.regexReplace[i]; -}} -return null; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "getSeqRegexReplace", -function () { -return this._replaceFor (jalview.util.GroupUrlLink.tokens[1]); -}); -Clazz.defineMethod (c$, "getInvalidMessage", -function () { -return this.invalidMessage; -}); -Clazz.defineMethod (c$, "isValid", -function () { -return this.invalidMessage == null; -}); -Clazz.defineMethod (c$, "makeUrls", -function (idstrings, seqstrings, dsstring, onlyIfMatches) { -var rstrings = this.replacementArgs (idstrings, seqstrings, dsstring); -return this.makeUrls (rstrings, onlyIfMatches); -}, "~A,~A,~S,~B"); -Clazz.defineMethod (c$, "replacementArgs", -($fz = function (idstrings, seqstrings, dsstring) { -var rstrings = new java.util.Hashtable (); -rstrings.put (jalview.util.GroupUrlLink.tokens[0], idstrings); -rstrings.put (jalview.util.GroupUrlLink.tokens[1], seqstrings); -rstrings.put (jalview.util.GroupUrlLink.tokens[2], Clazz.newArray (-1, [dsstring])); -if (idstrings.length != seqstrings.length) { -throw new Error (jalview.util.MessageManager.getString ("error.idstring_seqstrings_only_one_per_sequence")); -}return rstrings; -}, $fz.isPrivate = true, $fz), "~A,~A,~S"); -Clazz.defineMethod (c$, "makeUrls", -function (repstrings, onlyIfMatches) { -return this.makeUrlsIf (true, repstrings, onlyIfMatches); -}, "java.util.Hashtable,~B"); -Clazz.defineMethod (c$, "makeUrlStubs", -function (ids, seqstr, string, b) { -var rstrings = this.replacementArgs (ids, seqstr, string); -var stubs = this.makeUrlsIf (false, rstrings, b); -if (stubs != null) { -return Clazz.newArray (-1, [stubs[0], stubs[1], rstrings, Clazz.newBooleanArray (-1, [b])]); -}return null; -}, "~A,~A,~S,~B"); -Clazz.defineMethod (c$, "constructFrom", -function (stubs) { -var results = this.makeUrlsIf (true, stubs[2], (stubs[3])[0]); -return (results[3])[0]; -}, "~A"); -Clazz.defineMethod (c$, "makeUrlsIf", -function (createFullUrl, repstrings, onlyIfMatches) { -var pass = 0; -var idseq = new Array (this.mtch.length); -var mins = 0; -var maxs = 0; -for (var i = 0; i < this.mtch.length; i++) { -idseq[i] = repstrings.get (this.mtch[i]); -if (idseq[i].length >= 1) { -if (mins == 0 && idseq[i].length == 1) { -mins = 1; -}if (maxs < 2) { -maxs = idseq[i].length; -} else { -if (maxs != idseq[i].length) { -throw new Error (jalview.util.MessageManager.formatMessage ("error.cannot_have_mixed_length_replacement_vectors", Clazz.newArray (-1, [(this.mtch[i]), Integer.$valueOf (idseq[i].length).toString (), Integer.$valueOf (maxs).toString ()]))); -}}} else { -throw new Error (jalview.util.MessageManager.getString ("error.cannot_have_zero_length_vector_replacement_strings")); -}} -var matched = new Array (idseq.length); -var rgxs = new Array (matched.length); -for (pass = 0; pass < matched.length; pass++) { -matched[pass] = new StringBuffer (); -if (this.regexReplace[pass] != null) { -rgxs[pass] = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); -} else { -rgxs[pass] = null; -}} -var urllength = this.url_prefix.length; -for (pass = 0; pass < matched.length; pass++) { -urllength += this.url_suffix[pass].length; -} -var thismatched = Clazz.newBooleanArray (maxs, false); -var seqsmatched = 0; -for (var sq = 0; sq < maxs; sq++) { -thismatched[sq] = false; -var thematches = new Array (rgxs.length); -for (pass = 0; pass < rgxs.length; pass++) { -thematches[pass] = new StringBuffer (); -if (idseq[pass].length <= sq) { -continue; -}if (rgxs[pass] != null) { -var rg = rgxs[pass]; -var rematchat = 0; -while (rg.searchFrom (idseq[pass][sq], rematchat)) { -rematchat = rg.matchedTo (); -thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); -urllength += rg.charsMatched (); -if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { -throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); -}if (!createFullUrl) { -continue; -}var ns = rg.numSubs (); -if (ns == 0) { -thematches[pass].append (rg.stringMatched ()); -} else { -var subs = new StringBuffer (); -var s = 0; -while (s <= ns) { -if (s + 1 <= ns && rg.matchedToI (s) > -1 && rg.matchedToI (s + 1) > -1 && rg.matchedToI (s + 1) < rg.matchedToI (s)) { -var r = s + 1; -var rmtch = new StringBuffer (); -while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) { -if (rg.matchedFromI (r) > -1) { -rmtch.append (rg.stringMatchedI (r)); -}r++; -} -if (rmtch.length () > 0) { -subs.append (rmtch); -}s = r; -} else { -if (rg.matchedFromI (s) > -1) { -subs.append (rg.stringMatchedI (s)); -}s++; -}} -thematches[pass].append (subs); -}} -} else { -if (!onlyIfMatches) { -thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); -urllength += idseq[pass][sq].length; -if (createFullUrl) { -thematches[pass] = new StringBuffer (idseq[pass][sq]); -}}}} -if (thismatched[sq]) { -if (createFullUrl) { -for (pass = 0; pass < matched.length; pass++) { -if (idseq[pass].length > 1 && matched[pass].length () > 0) { -matched[pass].append (this.separators[pass]); -}matched[pass].append (thematches[pass]); -} -}seqsmatched++; -}} -if (seqsmatched == 0 || (createFullUrl && matched[0].length () == 0)) { -return null; -}if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { -throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); -}if (!createFullUrl) { -return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched]); -}var submiturl = new StringBuffer (); -submiturl.append (this.url_prefix); -for (pass = 0; pass < matched.length; pass++) { -submiturl.append (matched[pass]); -if (this.url_suffix[pass] != null) { -submiturl.append (this.url_suffix[pass]); -}} -return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched, matched, Clazz.newArray (-1, [submiturl.toString ()])]); -}, "~B,java.util.Hashtable,~B"); -Clazz.defineMethod (c$, "getNumberInvolved", -function (urlstub) { -return (urlstub[0])[0]; -}, "~A"); -Clazz.defineMethod (c$, "getGroupURLType", -function () { -var r = 0; -for (var pass = 0; pass < jalview.util.GroupUrlLink.tokens.length; pass++) { -for (var i = 0; i < this.mtch.length; i++) { -if (this.mtch[i].equals (jalview.util.GroupUrlLink.tokens[pass])) { -r += 1 << pass; -}} -} -return r; -}); -Clazz.overrideMethod (c$, "toString", -function () { -var result = new StringBuffer (); -result.append (this.label + "|" + this.url_prefix); -var r; -for (r = 0; r < this.url_suffix.length; r++) { -result.append ("$"); -result.append (this.mtch[r]); -if (this.regexReplace[r] != null) { -result.append ("=/"); -result.append (this.regexReplace[r]); -result.append ("/="); -}result.append ("$"); -result.append (this.url_suffix[r]); -} -for (r = 0; r < this.separators.length; r++) { -result.append ("|"); -result.append (this.separators[r]); -} -return result.toString (); -}); -c$.formStrings = Clazz.defineMethod (c$, "formStrings", -function (seqs) { -var idset = Clazz.newArray (2, seqs.length, null); -for (var i = 0; i < seqs.length; i++) { -idset[0][i] = seqs[i].getName (); -idset[1][i] = seqs[i].getSequenceAsString (); -} -return idset; -}, "~A"); -Clazz.defineMethod (c$, "setLabel", -function (newlabel) { -this.label = newlabel; -}, "~S"); -c$.$GroupUrlLink$UrlStringTooLongException$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.urlLength = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.GroupUrlLink, "UrlStringTooLongException", Exception); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, jalview.util.GroupUrlLink.UrlStringTooLongException, []); -this.urlLength = a; -}, "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return "Generated url is estimated to be too long (" + this.urlLength + ")"; -}); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"tokens", null); -{ -if (jalview.util.GroupUrlLink.tokens == null) { -jalview.util.GroupUrlLink.tokens = Clazz.newArray (-1, ["SEQUENCEIDS", "SEQUENCES", "DATASETID"]); -}}Clazz.defineStatics (c$, -"SEQUENCEIDS", 1, -"SEQUENCES", 2, -"DATASETID", 4); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.lang.Exception"], "jalview.util.GroupUrlLink", ["jalview.jsdev.RegExp", "jalview.util.MessageManager", "$.Platform", "$.QuickSort", "java.lang.Error", "$.StringBuffer", "java.util.Hashtable"], function () { +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.util.GroupUrlLink.UrlStringTooLongException")) { +jalview.util.GroupUrlLink.$GroupUrlLink$UrlStringTooLongException$ (); +} +this.url_prefix = null; +this.target = null; +this.label = null; +this.url_suffix = null; +this.separators = null; +this.regexReplace = null; +this.invalidMessage = null; +this.segs = null; +this.mtch = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "GroupUrlLink"); +Clazz.makeConstructor (c$, +function (link) { +var sep = link.indexOf ("|"); +this.segs = Clazz.newIntArray (jalview.util.GroupUrlLink.tokens.length, 0); +var ntoks = 0; +for (var i = 0; i < this.segs.length; i++) { +if ((this.segs[i] = link.indexOf ("$" + jalview.util.GroupUrlLink.tokens[i])) > -1) { +ntoks++; +}} +if (ntoks == 0) { +this.invalidMessage = "Group URL string must contain at least one of "; +for (var i = 0; i < this.segs.length; i++) { +this.invalidMessage += " '$" + jalview.util.GroupUrlLink.tokens[i] + "[=/regex=/]$'"; +} +return; +}var ptok = Clazz.newIntArray (ntoks + 1, 0); +var tmtch = new Array (ntoks + 1); +this.mtch = new Array (ntoks); +for (var i = 0, t = 0; i < this.segs.length; i++) { +if (this.segs[i] > -1) { +ptok[t] = this.segs[i]; +tmtch[t++] = jalview.util.GroupUrlLink.tokens[i]; +}} +ptok[ntoks] = link.length; +tmtch[ntoks] = "$$$$$$$$$"; +jalview.util.QuickSort.sortInt (ptok, tmtch); +for (var i = 0; i < ntoks; i++) { +this.mtch[i] = tmtch[i]; +} +var p = sep; +do { +sep = p; +p = link.indexOf ("|", sep + 1); +} while (p > sep && p < ptok[0]); +this.label = link.substring (0, sep); +if (this.label.indexOf ("|") > -1) { +this.target = this.label.substring (0, this.label.indexOf ("|")); +} else if (this.label.indexOf (" ") > 2) { +this.target = this.label.substring (0, this.label.indexOf (" ")); +} else { +this.target = this.label; +}this.url_prefix = link.substring (sep + 1, ptok[0]); +this.url_suffix = new Array (this.mtch.length); +this.regexReplace = new Array (this.mtch.length); +for (var pass = 0; pass < this.mtch.length; pass++) { +var mlength = 3 + this.mtch[pass].length; +if (link.indexOf ("$" + this.mtch[pass] + "=/") == ptok[pass] && (p = link.indexOf ("/=$", ptok[pass] + mlength)) > ptok[pass] + mlength) { +if (ptok[pass + 1] < p + 3) { +this.invalidMessage = "Token regexes cannot contain other regexes (did you terminate the $" + this.mtch[pass] + " regex with a '/=$' ?"; +return; +}this.url_suffix[pass] = link.substring (p + 3, ptok[pass + 1]); +this.regexReplace[pass] = link.substring (ptok[pass] + mlength, p); +try { +var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); +if (rg == null) { +this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace[pass] + "'\n"; +} else { +throw e; +} +} +} else { +this.regexReplace[pass] = null; +if ((p = link.indexOf ("$" + this.mtch[pass] + "$")) == ptok[pass]) { +this.url_suffix[pass] = link.substring (p + this.mtch[pass].length + 2, ptok[pass + 1]); +} else { +this.invalidMessage = "Warning: invalid regex structure (after '" + this.mtch[0] + "') for URL link : " + link; +}}} +var pass = 0; +this.separators = new Array (this.url_suffix.length); +var suffices = this.url_suffix[this.url_suffix.length - 1]; +var lastsep = ","; +while ((p = suffices.indexOf ('|')) > -1) { +this.separators[pass] = suffices.substring (p + 1); +if (pass == 0) { +this.url_suffix[this.url_suffix.length - 1] = suffices.substring (0, p); +} else { +lastsep = (this.separators[pass - 1] = this.separators[pass - 1].substring (0, p)); +}suffices = this.separators[pass]; +pass++; +} +if (pass > 0) { +lastsep = this.separators[pass - 1]; +}while (pass < this.separators.length) { +this.separators[pass++] = lastsep; +} +}, "~S"); +Clazz.defineMethod (c$, "getUrl_suffix", +function () { +return this.url_suffix[this.url_suffix.length - 1]; +}); +Clazz.defineMethod (c$, "getUrl_prefix", +function () { +return this.url_prefix; +}); +Clazz.defineMethod (c$, "getTarget", +function () { +return this.target; +}); +Clazz.defineMethod (c$, "getLabel", +function () { +return this.label; +}); +Clazz.defineMethod (c$, "getIDRegexReplace", +function () { +return this._replaceFor (jalview.util.GroupUrlLink.tokens[0]); +}); +Clazz.defineMethod (c$, "_replaceFor", +($fz = function (token) { +for (var i = 0; i < this.mtch.length; i++) { +if (this.segs[i] > -1 && this.mtch[i].equals (token)) { +return this.regexReplace[i]; +}} +return null; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "getSeqRegexReplace", +function () { +return this._replaceFor (jalview.util.GroupUrlLink.tokens[1]); +}); +Clazz.defineMethod (c$, "getInvalidMessage", +function () { +return this.invalidMessage; +}); +Clazz.defineMethod (c$, "isValid", +function () { +return this.invalidMessage == null; +}); +Clazz.defineMethod (c$, "makeUrls", +function (idstrings, seqstrings, dsstring, onlyIfMatches) { +var rstrings = this.replacementArgs (idstrings, seqstrings, dsstring); +return this.makeUrls (rstrings, onlyIfMatches); +}, "~A,~A,~S,~B"); +Clazz.defineMethod (c$, "replacementArgs", +($fz = function (idstrings, seqstrings, dsstring) { +var rstrings = new java.util.Hashtable (); +rstrings.put (jalview.util.GroupUrlLink.tokens[0], idstrings); +rstrings.put (jalview.util.GroupUrlLink.tokens[1], seqstrings); +rstrings.put (jalview.util.GroupUrlLink.tokens[2], Clazz.newArray (-1, [dsstring])); +if (idstrings.length != seqstrings.length) { +throw new Error (jalview.util.MessageManager.getString ("error.idstring_seqstrings_only_one_per_sequence")); +}return rstrings; +}, $fz.isPrivate = true, $fz), "~A,~A,~S"); +Clazz.defineMethod (c$, "makeUrls", +function (repstrings, onlyIfMatches) { +return this.makeUrlsIf (true, repstrings, onlyIfMatches); +}, "java.util.Hashtable,~B"); +Clazz.defineMethod (c$, "makeUrlStubs", +function (ids, seqstr, string, b) { +var rstrings = this.replacementArgs (ids, seqstr, string); +var stubs = this.makeUrlsIf (false, rstrings, b); +if (stubs != null) { +return Clazz.newArray (-1, [stubs[0], stubs[1], rstrings, Clazz.newBooleanArray (-1, [b])]); +}return null; +}, "~A,~A,~S,~B"); +Clazz.defineMethod (c$, "constructFrom", +function (stubs) { +var results = this.makeUrlsIf (true, stubs[2], (stubs[3])[0]); +return (results[3])[0]; +}, "~A"); +Clazz.defineMethod (c$, "makeUrlsIf", +function (createFullUrl, repstrings, onlyIfMatches) { +var pass = 0; +var idseq = new Array (this.mtch.length); +var mins = 0; +var maxs = 0; +for (var i = 0; i < this.mtch.length; i++) { +idseq[i] = repstrings.get (this.mtch[i]); +if (idseq[i].length >= 1) { +if (mins == 0 && idseq[i].length == 1) { +mins = 1; +}if (maxs < 2) { +maxs = idseq[i].length; +} else { +if (maxs != idseq[i].length) { +throw new Error (jalview.util.MessageManager.formatMessage ("error.cannot_have_mixed_length_replacement_vectors", Clazz.newArray (-1, [(this.mtch[i]), Integer.$valueOf (idseq[i].length).toString (), Integer.$valueOf (maxs).toString ()]))); +}}} else { +throw new Error (jalview.util.MessageManager.getString ("error.cannot_have_zero_length_vector_replacement_strings")); +}} +var matched = new Array (idseq.length); +var rgxs = new Array (matched.length); +for (pass = 0; pass < matched.length; pass++) { +matched[pass] = new StringBuffer (); +if (this.regexReplace[pass] != null) { +rgxs[pass] = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace[pass] + "/"); +} else { +rgxs[pass] = null; +}} +var urllength = this.url_prefix.length; +for (pass = 0; pass < matched.length; pass++) { +urllength += this.url_suffix[pass].length; +} +var thismatched = Clazz.newBooleanArray (maxs, false); +var seqsmatched = 0; +for (var sq = 0; sq < maxs; sq++) { +thismatched[sq] = false; +var thematches = new Array (rgxs.length); +for (pass = 0; pass < rgxs.length; pass++) { +thematches[pass] = new StringBuffer (); +if (idseq[pass].length <= sq) { +continue; +}if (rgxs[pass] != null) { +var rg = rgxs[pass]; +var rematchat = 0; +while (rg.searchFrom (idseq[pass][sq], rematchat)) { +rematchat = rg.matchedTo (); +thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); +urllength += rg.charsMatched (); +if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { +throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); +}if (!createFullUrl) { +continue; +}var ns = rg.numSubs (); +if (ns == 0) { +thematches[pass].append (rg.stringMatched ()); +} else { +var subs = new StringBuffer (); +var s = 0; +while (s <= ns) { +if (s + 1 <= ns && rg.matchedToI (s) > -1 && rg.matchedToI (s + 1) > -1 && rg.matchedToI (s + 1) < rg.matchedToI (s)) { +var r = s + 1; +var rmtch = new StringBuffer (); +while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) { +if (rg.matchedFromI (r) > -1) { +rmtch.append (rg.stringMatchedI (r)); +}r++; +} +if (rmtch.length () > 0) { +subs.append (rmtch); +}s = r; +} else { +if (rg.matchedFromI (s) > -1) { +subs.append (rg.stringMatchedI (s)); +}s++; +}} +thematches[pass].append (subs); +}} +} else { +if (!onlyIfMatches) { +thismatched[sq] = new Boolean (thismatched[sq] | true).valueOf (); +urllength += idseq[pass][sq].length; +if (createFullUrl) { +thematches[pass] = new StringBuffer (idseq[pass][sq]); +}}}} +if (thismatched[sq]) { +if (createFullUrl) { +for (pass = 0; pass < matched.length; pass++) { +if (idseq[pass].length > 1 && matched[pass].length () > 0) { +matched[pass].append (this.separators[pass]); +}matched[pass].append (thematches[pass]); +} +}seqsmatched++; +}} +if (seqsmatched == 0 || (createFullUrl && matched[0].length () == 0)) { +return null; +}if ((urllength + 32) > jalview.util.Platform.getMaxCommandLineLength ()) { +throw Clazz.innerTypeInstance (jalview.util.GroupUrlLink.UrlStringTooLongException, this, null, urllength); +}if (!createFullUrl) { +return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched]); +}var submiturl = new StringBuffer (); +submiturl.append (this.url_prefix); +for (pass = 0; pass < matched.length; pass++) { +submiturl.append (matched[pass]); +if (this.url_suffix[pass] != null) { +submiturl.append (this.url_suffix[pass]); +}} +return Clazz.newArray (-1, [ Clazz.newIntArray (-1, [seqsmatched]), thismatched, matched, Clazz.newArray (-1, [submiturl.toString ()])]); +}, "~B,java.util.Hashtable,~B"); +Clazz.defineMethod (c$, "getNumberInvolved", +function (urlstub) { +return (urlstub[0])[0]; +}, "~A"); +Clazz.defineMethod (c$, "getGroupURLType", +function () { +var r = 0; +for (var pass = 0; pass < jalview.util.GroupUrlLink.tokens.length; pass++) { +for (var i = 0; i < this.mtch.length; i++) { +if (this.mtch[i].equals (jalview.util.GroupUrlLink.tokens[pass])) { +r += 1 << pass; +}} +} +return r; +}); +Clazz.overrideMethod (c$, "toString", +function () { +var result = new StringBuffer (); +result.append (this.label + "|" + this.url_prefix); +var r; +for (r = 0; r < this.url_suffix.length; r++) { +result.append ("$"); +result.append (this.mtch[r]); +if (this.regexReplace[r] != null) { +result.append ("=/"); +result.append (this.regexReplace[r]); +result.append ("/="); +}result.append ("$"); +result.append (this.url_suffix[r]); +} +for (r = 0; r < this.separators.length; r++) { +result.append ("|"); +result.append (this.separators[r]); +} +return result.toString (); +}); +c$.formStrings = Clazz.defineMethod (c$, "formStrings", +function (seqs) { +var idset = Clazz.newArray (2, seqs.length, null); +for (var i = 0; i < seqs.length; i++) { +idset[0][i] = seqs[i].getName (); +idset[1][i] = seqs[i].getSequenceAsString (); +} +return idset; +}, "~A"); +Clazz.defineMethod (c$, "setLabel", +function (newlabel) { +this.label = newlabel; +}, "~S"); +c$.$GroupUrlLink$UrlStringTooLongException$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.urlLength = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.GroupUrlLink, "UrlStringTooLongException", Exception); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, jalview.util.GroupUrlLink.UrlStringTooLongException, []); +this.urlLength = a; +}, "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return "Generated url is estimated to be too long (" + this.urlLength + ")"; +}); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"tokens", null); +{ +if (jalview.util.GroupUrlLink.tokens == null) { +jalview.util.GroupUrlLink.tokens = Clazz.newArray (-1, ["SEQUENCEIDS", "SEQUENCES", "DATASETID"]); +}}Clazz.defineStatics (c$, +"SEQUENCEIDS", 1, +"SEQUENCES", 2, +"DATASETID", 4); +}); diff --git a/bin/jalview/util/MapList.js b/bin/jalview/util/MapList.js index e7281ac..ff777cc 100644 --- a/bin/jalview/util/MapList.js +++ b/bin/jalview/util/MapList.js @@ -1,409 +1,409 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.util.ArrayList"], "jalview.util.MapList", ["java.lang.StringBuilder", "java.util.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fromShifts = null; -this.toShifts = null; -this.fromRatio = 0; -this.toRatio = 0; -this.fromLowest = 0; -this.fromHighest = 0; -this.toLowest = 0; -this.toHighest = 0; -Clazz.instantialize (this, arguments); -}, jalview.util, "MapList"); -Clazz.prepareFields (c$, function () { -this.fromShifts = new java.util.ArrayList (); -this.toShifts = new java.util.ArrayList (); -}); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (o == null || !(Clazz.instanceOf (o, jalview.util.MapList))) { -return false; -}var obj = o; -if (obj === this) { -return true; -}if (obj.fromRatio != this.fromRatio || obj.toRatio != this.toRatio || obj.fromShifts == null || obj.toShifts == null) { -return false; -}return java.util.Arrays.deepEquals (this.fromShifts.toArray (), obj.fromShifts.toArray ()) && java.util.Arrays.deepEquals (this.toShifts.toArray (), obj.toShifts.toArray ()); -}, "~O"); -Clazz.defineMethod (c$, "getFromRanges", -function () { -return this.fromShifts; -}); -Clazz.defineMethod (c$, "getToRanges", -function () { -return this.toShifts; -}); -c$.getRanges = Clazz.defineMethod (c$, "getRanges", -function (shifts) { -var rnges = Clazz.newIntArray (2 * shifts.size (), 0); -var i = 0; -for (var r, $r = shifts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { -rnges[i++] = r[0]; -rnges[i++] = r[1]; -} -return rnges; -}, "java.util.List"); -Clazz.defineMethod (c$, "getFromRatio", -function () { -return this.fromRatio; -}); -Clazz.defineMethod (c$, "getToRatio", -function () { -return this.toRatio; -}); -Clazz.defineMethod (c$, "getFromLowest", -function () { -return this.fromLowest; -}); -Clazz.defineMethod (c$, "getFromHighest", -function () { -return this.fromHighest; -}); -Clazz.defineMethod (c$, "getToLowest", -function () { -return this.toLowest; -}); -Clazz.defineMethod (c$, "getToHighest", -function () { -return this.toHighest; -}); -Clazz.makeConstructor (c$, -function (from, to, fromRatio, toRatio) { -this.fromRatio = fromRatio; -this.toRatio = toRatio; -this.fromLowest = from[0]; -this.fromHighest = from[1]; -for (var i = 0; i < from.length; i += 2) { -this.fromLowest = Math.min (this.fromLowest, from[i]); -this.fromHighest = Math.max (this.fromHighest, from[i + 1]); -this.fromShifts.add ( Clazz.newIntArray (-1, [from[i], from[i + 1]])); -} -this.toLowest = to[0]; -this.toHighest = to[1]; -for (var i = 0; i < to.length; i += 2) { -this.toLowest = Math.min (this.toLowest, to[i]); -this.toHighest = Math.max (this.toHighest, to[i + 1]); -this.toShifts.add ( Clazz.newIntArray (-1, [to[i], to[i + 1]])); -} -}, "~A,~A,~N,~N"); -Clazz.makeConstructor (c$, -function (map) { -this.fromLowest = map.fromLowest; -this.fromHighest = map.fromHighest; -this.toLowest = map.toLowest; -this.toHighest = map.toHighest; -this.fromRatio = map.fromRatio; -this.toRatio = map.toRatio; -if (map.fromShifts != null) { -for (var r, $r = map.fromShifts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { -this.fromShifts.add ( Clazz.newIntArray (-1, [r[0], r[1]])); -} -}if (map.toShifts != null) { -for (var r, $r = map.toShifts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { -this.toShifts.add ( Clazz.newIntArray (-1, [r[0], r[1]])); -} -}}, "jalview.util.MapList"); -Clazz.makeConstructor (c$, -function (fromRange, toRange, fromRatio, toRatio) { -this.fromShifts = fromRange; -this.toShifts = toRange; -this.fromRatio = fromRatio; -this.toRatio = toRatio; -this.fromLowest = 2147483647; -this.fromHighest = 0; -for (var range, $range = fromRange.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { -this.fromLowest = Math.min (this.fromLowest, range[0]); -this.fromHighest = Math.max (this.fromHighest, range[1]); -} -this.toLowest = 2147483647; -this.toHighest = 0; -for (var range, $range = toRange.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { -this.toLowest = Math.min (this.toLowest, range[0]); -this.toHighest = Math.max (this.toHighest, range[1]); -} -}, "java.util.List,java.util.List,~N,~N"); -Clazz.defineMethod (c$, "makeFromMap", -function () { -return this.posMap (this.fromShifts, this.fromRatio, this.toShifts, this.toRatio); -}); -Clazz.defineMethod (c$, "makeToMap", -function () { -return this.posMap (this.toShifts, this.toRatio, this.fromShifts, this.fromRatio); -}); -Clazz.defineMethod (c$, "posMap", -($fz = function (shiftTo, ratio, shiftFrom, toRatio) { -var iv = 0; -var ivSize = shiftTo.size (); -if (iv >= ivSize) { -return null; -}var intv = shiftTo.get (iv++); -var from = intv[0]; -var to = intv[1]; -if (from > to) { -from = intv[1]; -to = intv[0]; -}while (iv < ivSize) { -intv = shiftTo.get (iv++); -if (intv[0] < from) { -from = intv[0]; -}if (intv[1] < from) { -from = intv[1]; -}if (intv[0] > to) { -to = intv[0]; -}if (intv[1] > to) { -to = intv[1]; -}} -var tF = 0; -var tT = 0; -var mp = Clazz.newIntArray (to - from + 2, 0); -for (var i = 0; i < mp.length; i++) { -var m = jalview.util.MapList.shift (i + from, shiftTo, ratio, shiftFrom, toRatio); -if (m != null) { -if (i == 0) { -tF = tT = m[0]; -} else { -if (m[0] < tF) { -tF = m[0]; -}if (m[0] > tT) { -tT = m[0]; -}}}mp[i] = m; -} -var map = Clazz.newArray (-1, [ Clazz.newIntArray (-1, [from, to, tF, tT]), Clazz.newIntArray (to - from + 2, 0)]); -map[0][2] = tF; -map[0][3] = tT; -for (var i = 0; i < mp.length; i++) { -if (mp[i] != null) { -map[1][i] = mp[i][0] - tF; -} else { -map[1][i] = -1; -}} -return map; -}, $fz.isPrivate = true, $fz), "java.util.List,~N,java.util.List,~N"); -Clazz.defineMethod (c$, "shiftFrom", -function (pos) { -return jalview.util.MapList.shift (pos, this.fromShifts, this.fromRatio, this.toShifts, this.toRatio); -}, "~N"); -Clazz.defineMethod (c$, "shiftTo", -function (pos) { -return jalview.util.MapList.shift (pos, this.toShifts, this.toRatio, this.fromShifts, this.fromRatio); -}, "~N"); -c$.shift = Clazz.defineMethod (c$, "shift", -function (pos, shiftTo, fromRatio, shiftFrom, toRatio) { -var fromCount = jalview.util.MapList.countPos (shiftTo, pos); -if (fromCount == null) { -return null; -}var fromRemainder = (fromCount[0] - 1) % fromRatio; -var toCount = 1 + ((Clazz.doubleToInt ((fromCount[0] - 1) / fromRatio)) * toRatio); -var toPos = jalview.util.MapList.countToPos (shiftFrom, toCount); -if (toPos == null) { -return null; -}return Clazz.newIntArray (-1, [toPos[0], fromRemainder, toPos[1]]); -}, "~N,java.util.List,~N,java.util.List,~N"); -c$.countPos = Clazz.defineMethod (c$, "countPos", -function (shiftTo, pos) { -var count = 0; -var intv; -var iv = 0; -var ivSize = shiftTo.size (); -while (iv < ivSize) { -intv = shiftTo.get (iv++); -if (intv[0] <= intv[1]) { -if (pos >= intv[0] && pos <= intv[1]) { -return Clazz.newIntArray (-1, [count + pos - intv[0] + 1, 1]); -} else { -count += intv[1] - intv[0] + 1; -}} else { -if (pos >= intv[1] && pos <= intv[0]) { -return Clazz.newIntArray (-1, [count + intv[0] - pos + 1, -1]); -} else { -count += intv[0] - intv[1] + 1; -}}} -return null; -}, "java.util.List,~N"); -c$.countToPos = Clazz.defineMethod (c$, "countToPos", -function (shiftFrom, pos) { -var count = 0; -var diff = 0; -var iv = 0; -var ivSize = shiftFrom.size (); -var intv = Clazz.newIntArray (-1, [0, 0]); -while (iv < ivSize) { -intv = shiftFrom.get (iv++); -diff = intv[1] - intv[0]; -if (diff >= 0) { -if (pos <= count + 1 + diff) { -return Clazz.newIntArray (-1, [pos - count - 1 + intv[0], 1]); -} else { -count += 1 + diff; -}} else { -if (pos <= count + 1 - diff) { -return Clazz.newIntArray (-1, [intv[0] - (pos - count - 1), -1]); -} else { -count += 1 - diff; -}}} -return null; -}, "java.util.List,~N"); -Clazz.defineMethod (c$, "locateInFrom", -function (start, end) { -var fromStart = this.shiftTo (start); -var fromEnd = this.shiftTo (end); -return jalview.util.MapList.getIntervals (this.fromShifts, fromStart, fromEnd, this.fromRatio); -}, "~N,~N"); -Clazz.defineMethod (c$, "locateInTo", -function (start, end) { -var toStart = this.shiftFrom (start); -var toEnd = this.shiftFrom (end); -return jalview.util.MapList.getIntervals (this.toShifts, toStart, toEnd, this.toRatio); -}, "~N,~N"); -c$.getIntervals = Clazz.defineMethod (c$, "getIntervals", -function (shiftFrom, fromStart, fromEnd, fromRatio2) { -if (fromStart == null || fromEnd == null) { -return null; -}var startpos; -var endpos; -startpos = fromStart[0]; -endpos = fromEnd[0]; -var endindx = (fromRatio2 - 1); -var intv = 0; -var intvSize = shiftFrom.size (); -var iv; -var i = 0; -var fs = -1; -var fe_s = -1; -var fe = -1; -while (intv < intvSize && (fs == -1 || fe == -1)) { -iv = shiftFrom.get (intv++); -if (fe_s > -1) { -endpos = iv[0]; -endindx--; -}if (iv[0] <= iv[1]) { -if (fs == -1 && startpos >= iv[0] && startpos <= iv[1]) { -fs = i; -}if (endpos >= iv[0] && endpos <= iv[1]) { -if (fe_s == -1) { -fe_s = i; -}if (fe_s != -1) { -if (endpos + endindx <= iv[1]) { -fe = i; -endpos = endpos + endindx; -} else { -endindx -= iv[1] - endpos; -}}}} else { -if (fs == -1 && startpos <= iv[0] && startpos >= iv[1]) { -fs = i; -}if (endpos <= iv[0] && endpos >= iv[1]) { -if (fe_s == -1) { -fe_s = i; -}if (fe_s != -1) { -if (endpos - endindx >= iv[1]) { -fe = i; -endpos = endpos - endindx; -} else { -endindx -= endpos - iv[1]; -}}}}i++; -} -if (fs == fe && fe == -1) { -return null; -}var ranges = new java.util.ArrayList (); -if (fs <= fe) { -intv = fs; -i = fs; -iv = shiftFrom.get (intv++); -iv = Clazz.newIntArray (-1, [iv[0], iv[1]]); -if (i == fs) { -iv[0] = startpos; -}while (i != fe) { -ranges.add (iv); -iv = shiftFrom.get (intv++); -iv = Clazz.newIntArray (-1, [iv[0], iv[1]]); -i++; -} -if (i == fe) { -iv[1] = endpos; -}ranges.add (iv); -} else { -i = shiftFrom.size () - 1; -while (i > fs) { -i--; -} -iv = shiftFrom.get (i); -iv = Clazz.newIntArray (-1, [iv[1], iv[0]]); -if (i == fs) { -iv[0] = startpos; -}while (--i != fe) { -ranges.add (iv); -iv = shiftFrom.get (i); -iv = Clazz.newIntArray (-1, [iv[1], iv[0]]); -} -if (i == fe) { -iv[1] = endpos; -}ranges.add (iv); -}var range = null; -if (ranges != null && ranges.size () > 0) { -range = Clazz.newIntArray (ranges.size () * 2, 0); -intv = 0; -intvSize = ranges.size (); -i = 0; -while (intv < intvSize) { -iv = ranges.get (intv); -range[i++] = iv[0]; -range[i++] = iv[1]; -ranges.set (intv++, null); -} -}return range; -}, "java.util.List,~A,~A,~N"); -Clazz.defineMethod (c$, "getToPosition", -function (mpos) { -var mp = this.shiftTo (mpos); -if (mp != null) { -return mp[0]; -}return mpos; -}, "~N"); -Clazz.defineMethod (c$, "getToWord", -function (mpos) { -var mp = this.shiftTo (mpos); -if (mp != null) { -return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.getFromRatio () - 1)]); -}return null; -}, "~N"); -Clazz.defineMethod (c$, "getMappedPosition", -function (pos) { -var mp = this.shiftFrom (pos); -if (mp != null) { -return mp[0]; -}return pos; -}, "~N"); -Clazz.defineMethod (c$, "getMappedWord", -function (pos) { -var mp = this.shiftFrom (pos); -if (mp != null) { -return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.getToRatio () - 1)]); -}return null; -}, "~N"); -Clazz.defineMethod (c$, "getInverse", -function () { -return new jalview.util.MapList (this.getToRanges (), this.getFromRanges (), this.getToRatio (), this.getFromRatio ()); -}); -Clazz.defineMethod (c$, "containsEither", -function (local, map) { -if (local) { -return ((this.getFromLowest () >= map.getFromLowest () && this.getFromHighest () <= map.getFromHighest ()) || (this.getFromLowest () <= map.getFromLowest () && this.getFromHighest () >= map.getFromHighest ())); -} else { -return ((this.getToLowest () >= map.getToLowest () && this.getToHighest () <= map.getToHighest ()) || (this.getToLowest () <= map.getToLowest () && this.getToHighest () >= map.getToHighest ())); -}}, "~B,jalview.util.MapList"); -Clazz.overrideMethod (c$, "toString", -function () { -var sb = new StringBuilder (64); -sb.append ("From (").append (this.fromRatio).append (":").append (this.toRatio).append (") ["); -for (var shift, $shift = this.fromShifts.iterator (); $shift.hasNext () && ((shift = $shift.next ()) || true);) { -sb.append (" ").append (java.util.Arrays.toString (shift)); -} -sb.append (" ] To ["); -for (var shift, $shift = this.toShifts.iterator (); $shift.hasNext () && ((shift = $shift.next ()) || true);) { -sb.append (" ").append (java.util.Arrays.toString (shift)); -} -sb.append (" ]"); -return sb.toString (); -}); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.util.ArrayList"], "jalview.util.MapList", ["java.lang.StringBuilder", "java.util.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fromShifts = null; +this.toShifts = null; +this.fromRatio = 0; +this.toRatio = 0; +this.fromLowest = 0; +this.fromHighest = 0; +this.toLowest = 0; +this.toHighest = 0; +Clazz.instantialize (this, arguments); +}, jalview.util, "MapList"); +Clazz.prepareFields (c$, function () { +this.fromShifts = new java.util.ArrayList (); +this.toShifts = new java.util.ArrayList (); +}); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (o == null || !(Clazz.instanceOf (o, jalview.util.MapList))) { +return false; +}var obj = o; +if (obj === this) { +return true; +}if (obj.fromRatio != this.fromRatio || obj.toRatio != this.toRatio || obj.fromShifts == null || obj.toShifts == null) { +return false; +}return java.util.Arrays.deepEquals (this.fromShifts.toArray (), obj.fromShifts.toArray ()) && java.util.Arrays.deepEquals (this.toShifts.toArray (), obj.toShifts.toArray ()); +}, "~O"); +Clazz.defineMethod (c$, "getFromRanges", +function () { +return this.fromShifts; +}); +Clazz.defineMethod (c$, "getToRanges", +function () { +return this.toShifts; +}); +c$.getRanges = Clazz.defineMethod (c$, "getRanges", +function (shifts) { +var rnges = Clazz.newIntArray (2 * shifts.size (), 0); +var i = 0; +for (var r, $r = shifts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { +rnges[i++] = r[0]; +rnges[i++] = r[1]; +} +return rnges; +}, "java.util.List"); +Clazz.defineMethod (c$, "getFromRatio", +function () { +return this.fromRatio; +}); +Clazz.defineMethod (c$, "getToRatio", +function () { +return this.toRatio; +}); +Clazz.defineMethod (c$, "getFromLowest", +function () { +return this.fromLowest; +}); +Clazz.defineMethod (c$, "getFromHighest", +function () { +return this.fromHighest; +}); +Clazz.defineMethod (c$, "getToLowest", +function () { +return this.toLowest; +}); +Clazz.defineMethod (c$, "getToHighest", +function () { +return this.toHighest; +}); +Clazz.makeConstructor (c$, +function (from, to, fromRatio, toRatio) { +this.fromRatio = fromRatio; +this.toRatio = toRatio; +this.fromLowest = from[0]; +this.fromHighest = from[1]; +for (var i = 0; i < from.length; i += 2) { +this.fromLowest = Math.min (this.fromLowest, from[i]); +this.fromHighest = Math.max (this.fromHighest, from[i + 1]); +this.fromShifts.add ( Clazz.newIntArray (-1, [from[i], from[i + 1]])); +} +this.toLowest = to[0]; +this.toHighest = to[1]; +for (var i = 0; i < to.length; i += 2) { +this.toLowest = Math.min (this.toLowest, to[i]); +this.toHighest = Math.max (this.toHighest, to[i + 1]); +this.toShifts.add ( Clazz.newIntArray (-1, [to[i], to[i + 1]])); +} +}, "~A,~A,~N,~N"); +Clazz.makeConstructor (c$, +function (map) { +this.fromLowest = map.fromLowest; +this.fromHighest = map.fromHighest; +this.toLowest = map.toLowest; +this.toHighest = map.toHighest; +this.fromRatio = map.fromRatio; +this.toRatio = map.toRatio; +if (map.fromShifts != null) { +for (var r, $r = map.fromShifts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { +this.fromShifts.add ( Clazz.newIntArray (-1, [r[0], r[1]])); +} +}if (map.toShifts != null) { +for (var r, $r = map.toShifts.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) { +this.toShifts.add ( Clazz.newIntArray (-1, [r[0], r[1]])); +} +}}, "jalview.util.MapList"); +Clazz.makeConstructor (c$, +function (fromRange, toRange, fromRatio, toRatio) { +this.fromShifts = fromRange; +this.toShifts = toRange; +this.fromRatio = fromRatio; +this.toRatio = toRatio; +this.fromLowest = 2147483647; +this.fromHighest = 0; +for (var range, $range = fromRange.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { +this.fromLowest = Math.min (this.fromLowest, range[0]); +this.fromHighest = Math.max (this.fromHighest, range[1]); +} +this.toLowest = 2147483647; +this.toHighest = 0; +for (var range, $range = toRange.iterator (); $range.hasNext () && ((range = $range.next ()) || true);) { +this.toLowest = Math.min (this.toLowest, range[0]); +this.toHighest = Math.max (this.toHighest, range[1]); +} +}, "java.util.List,java.util.List,~N,~N"); +Clazz.defineMethod (c$, "makeFromMap", +function () { +return this.posMap (this.fromShifts, this.fromRatio, this.toShifts, this.toRatio); +}); +Clazz.defineMethod (c$, "makeToMap", +function () { +return this.posMap (this.toShifts, this.toRatio, this.fromShifts, this.fromRatio); +}); +Clazz.defineMethod (c$, "posMap", +($fz = function (shiftTo, ratio, shiftFrom, toRatio) { +var iv = 0; +var ivSize = shiftTo.size (); +if (iv >= ivSize) { +return null; +}var intv = shiftTo.get (iv++); +var from = intv[0]; +var to = intv[1]; +if (from > to) { +from = intv[1]; +to = intv[0]; +}while (iv < ivSize) { +intv = shiftTo.get (iv++); +if (intv[0] < from) { +from = intv[0]; +}if (intv[1] < from) { +from = intv[1]; +}if (intv[0] > to) { +to = intv[0]; +}if (intv[1] > to) { +to = intv[1]; +}} +var tF = 0; +var tT = 0; +var mp = Clazz.newIntArray (to - from + 2, 0); +for (var i = 0; i < mp.length; i++) { +var m = jalview.util.MapList.shift (i + from, shiftTo, ratio, shiftFrom, toRatio); +if (m != null) { +if (i == 0) { +tF = tT = m[0]; +} else { +if (m[0] < tF) { +tF = m[0]; +}if (m[0] > tT) { +tT = m[0]; +}}}mp[i] = m; +} +var map = Clazz.newArray (-1, [ Clazz.newIntArray (-1, [from, to, tF, tT]), Clazz.newIntArray (to - from + 2, 0)]); +map[0][2] = tF; +map[0][3] = tT; +for (var i = 0; i < mp.length; i++) { +if (mp[i] != null) { +map[1][i] = mp[i][0] - tF; +} else { +map[1][i] = -1; +}} +return map; +}, $fz.isPrivate = true, $fz), "java.util.List,~N,java.util.List,~N"); +Clazz.defineMethod (c$, "shiftFrom", +function (pos) { +return jalview.util.MapList.shift (pos, this.fromShifts, this.fromRatio, this.toShifts, this.toRatio); +}, "~N"); +Clazz.defineMethod (c$, "shiftTo", +function (pos) { +return jalview.util.MapList.shift (pos, this.toShifts, this.toRatio, this.fromShifts, this.fromRatio); +}, "~N"); +c$.shift = Clazz.defineMethod (c$, "shift", +function (pos, shiftTo, fromRatio, shiftFrom, toRatio) { +var fromCount = jalview.util.MapList.countPos (shiftTo, pos); +if (fromCount == null) { +return null; +}var fromRemainder = (fromCount[0] - 1) % fromRatio; +var toCount = 1 + ((Clazz.doubleToInt ((fromCount[0] - 1) / fromRatio)) * toRatio); +var toPos = jalview.util.MapList.countToPos (shiftFrom, toCount); +if (toPos == null) { +return null; +}return Clazz.newIntArray (-1, [toPos[0], fromRemainder, toPos[1]]); +}, "~N,java.util.List,~N,java.util.List,~N"); +c$.countPos = Clazz.defineMethod (c$, "countPos", +function (shiftTo, pos) { +var count = 0; +var intv; +var iv = 0; +var ivSize = shiftTo.size (); +while (iv < ivSize) { +intv = shiftTo.get (iv++); +if (intv[0] <= intv[1]) { +if (pos >= intv[0] && pos <= intv[1]) { +return Clazz.newIntArray (-1, [count + pos - intv[0] + 1, 1]); +} else { +count += intv[1] - intv[0] + 1; +}} else { +if (pos >= intv[1] && pos <= intv[0]) { +return Clazz.newIntArray (-1, [count + intv[0] - pos + 1, -1]); +} else { +count += intv[0] - intv[1] + 1; +}}} +return null; +}, "java.util.List,~N"); +c$.countToPos = Clazz.defineMethod (c$, "countToPos", +function (shiftFrom, pos) { +var count = 0; +var diff = 0; +var iv = 0; +var ivSize = shiftFrom.size (); +var intv = Clazz.newIntArray (-1, [0, 0]); +while (iv < ivSize) { +intv = shiftFrom.get (iv++); +diff = intv[1] - intv[0]; +if (diff >= 0) { +if (pos <= count + 1 + diff) { +return Clazz.newIntArray (-1, [pos - count - 1 + intv[0], 1]); +} else { +count += 1 + diff; +}} else { +if (pos <= count + 1 - diff) { +return Clazz.newIntArray (-1, [intv[0] - (pos - count - 1), -1]); +} else { +count += 1 - diff; +}}} +return null; +}, "java.util.List,~N"); +Clazz.defineMethod (c$, "locateInFrom", +function (start, end) { +var fromStart = this.shiftTo (start); +var fromEnd = this.shiftTo (end); +return jalview.util.MapList.getIntervals (this.fromShifts, fromStart, fromEnd, this.fromRatio); +}, "~N,~N"); +Clazz.defineMethod (c$, "locateInTo", +function (start, end) { +var toStart = this.shiftFrom (start); +var toEnd = this.shiftFrom (end); +return jalview.util.MapList.getIntervals (this.toShifts, toStart, toEnd, this.toRatio); +}, "~N,~N"); +c$.getIntervals = Clazz.defineMethod (c$, "getIntervals", +function (shiftFrom, fromStart, fromEnd, fromRatio2) { +if (fromStart == null || fromEnd == null) { +return null; +}var startpos; +var endpos; +startpos = fromStart[0]; +endpos = fromEnd[0]; +var endindx = (fromRatio2 - 1); +var intv = 0; +var intvSize = shiftFrom.size (); +var iv; +var i = 0; +var fs = -1; +var fe_s = -1; +var fe = -1; +while (intv < intvSize && (fs == -1 || fe == -1)) { +iv = shiftFrom.get (intv++); +if (fe_s > -1) { +endpos = iv[0]; +endindx--; +}if (iv[0] <= iv[1]) { +if (fs == -1 && startpos >= iv[0] && startpos <= iv[1]) { +fs = i; +}if (endpos >= iv[0] && endpos <= iv[1]) { +if (fe_s == -1) { +fe_s = i; +}if (fe_s != -1) { +if (endpos + endindx <= iv[1]) { +fe = i; +endpos = endpos + endindx; +} else { +endindx -= iv[1] - endpos; +}}}} else { +if (fs == -1 && startpos <= iv[0] && startpos >= iv[1]) { +fs = i; +}if (endpos <= iv[0] && endpos >= iv[1]) { +if (fe_s == -1) { +fe_s = i; +}if (fe_s != -1) { +if (endpos - endindx >= iv[1]) { +fe = i; +endpos = endpos - endindx; +} else { +endindx -= endpos - iv[1]; +}}}}i++; +} +if (fs == fe && fe == -1) { +return null; +}var ranges = new java.util.ArrayList (); +if (fs <= fe) { +intv = fs; +i = fs; +iv = shiftFrom.get (intv++); +iv = Clazz.newIntArray (-1, [iv[0], iv[1]]); +if (i == fs) { +iv[0] = startpos; +}while (i != fe) { +ranges.add (iv); +iv = shiftFrom.get (intv++); +iv = Clazz.newIntArray (-1, [iv[0], iv[1]]); +i++; +} +if (i == fe) { +iv[1] = endpos; +}ranges.add (iv); +} else { +i = shiftFrom.size () - 1; +while (i > fs) { +i--; +} +iv = shiftFrom.get (i); +iv = Clazz.newIntArray (-1, [iv[1], iv[0]]); +if (i == fs) { +iv[0] = startpos; +}while (--i != fe) { +ranges.add (iv); +iv = shiftFrom.get (i); +iv = Clazz.newIntArray (-1, [iv[1], iv[0]]); +} +if (i == fe) { +iv[1] = endpos; +}ranges.add (iv); +}var range = null; +if (ranges != null && ranges.size () > 0) { +range = Clazz.newIntArray (ranges.size () * 2, 0); +intv = 0; +intvSize = ranges.size (); +i = 0; +while (intv < intvSize) { +iv = ranges.get (intv); +range[i++] = iv[0]; +range[i++] = iv[1]; +ranges.set (intv++, null); +} +}return range; +}, "java.util.List,~A,~A,~N"); +Clazz.defineMethod (c$, "getToPosition", +function (mpos) { +var mp = this.shiftTo (mpos); +if (mp != null) { +return mp[0]; +}return mpos; +}, "~N"); +Clazz.defineMethod (c$, "getToWord", +function (mpos) { +var mp = this.shiftTo (mpos); +if (mp != null) { +return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.getFromRatio () - 1)]); +}return null; +}, "~N"); +Clazz.defineMethod (c$, "getMappedPosition", +function (pos) { +var mp = this.shiftFrom (pos); +if (mp != null) { +return mp[0]; +}return pos; +}, "~N"); +Clazz.defineMethod (c$, "getMappedWord", +function (pos) { +var mp = this.shiftFrom (pos); +if (mp != null) { +return Clazz.newIntArray (-1, [mp[0], mp[0] + mp[2] * (this.getToRatio () - 1)]); +}return null; +}, "~N"); +Clazz.defineMethod (c$, "getInverse", +function () { +return new jalview.util.MapList (this.getToRanges (), this.getFromRanges (), this.getToRatio (), this.getFromRatio ()); +}); +Clazz.defineMethod (c$, "containsEither", +function (local, map) { +if (local) { +return ((this.getFromLowest () >= map.getFromLowest () && this.getFromHighest () <= map.getFromHighest ()) || (this.getFromLowest () <= map.getFromLowest () && this.getFromHighest () >= map.getFromHighest ())); +} else { +return ((this.getToLowest () >= map.getToLowest () && this.getToHighest () <= map.getToHighest ()) || (this.getToLowest () <= map.getToLowest () && this.getToHighest () >= map.getToHighest ())); +}}, "~B,jalview.util.MapList"); +Clazz.overrideMethod (c$, "toString", +function () { +var sb = new StringBuilder (64); +sb.append ("From (").append (this.fromRatio).append (":").append (this.toRatio).append (") ["); +for (var shift, $shift = this.fromShifts.iterator (); $shift.hasNext () && ((shift = $shift.next ()) || true);) { +sb.append (" ").append (java.util.Arrays.toString (shift)); +} +sb.append (" ] To ["); +for (var shift, $shift = this.toShifts.iterator (); $shift.hasNext () && ((shift = $shift.next ()) || true);) { +sb.append (" ").append (java.util.Arrays.toString (shift)); +} +sb.append (" ]"); +return sb.toString (); +}); +}); diff --git a/bin/jalview/util/MappingUtils.js b/bin/jalview/util/MappingUtils.js index 487e30d..e5f76b9 100644 --- a/bin/jalview/util/MappingUtils.js +++ b/bin/jalview/util/MappingUtils.js @@ -1,245 +1,245 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.MappingUtils", ["jalview.analysis.AlignmentSorter", "jalview.commands.EditCommand", "$.OrderCommand", "jalview.datamodel.AlignmentOrder", "$.ColumnSelection", "$.SearchResults", "$.Sequence", "$.SequenceGroup", "jalview.util.Comparison", "$.StringUtils", "java.util.ArrayList", "$.Collections", "$.HashMap"], function () { -c$ = Clazz.declareType (jalview.util, "MappingUtils"); -c$.mapCutOrPaste = Clazz.defineMethod (c$, "mapCutOrPaste", -function (edit, undo, targetSeqs, result, mappings) { -var action = edit.getAction (); -if (undo) { -action = action.getUndoAction (); -}System.err.println ("MappingUtils.mapCutOrPaste not yet implemented"); -}, "jalview.commands.EditCommand.Edit,~B,java.util.List,jalview.commands.EditCommand,java.util.Set"); -c$.mapEditCommand = Clazz.defineMethod (c$, "mapEditCommand", -function (command, undo, mapTo, gapChar, mappings) { -if (!mapTo.isNucleotide ()) { -return null; -}var targetCopies = new java.util.HashMap (); -for (var seq, $seq = mapTo.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -var ds = seq.getDatasetSequence (); -if (ds != null) { -var copy = new jalview.datamodel.Sequence (seq); -copy.setDatasetSequence (ds); -targetCopies.put (ds, copy); -}} -var originalSequences = command.priorState (undo); -var result = new jalview.commands.EditCommand (); -var edits = command.getEditIterator (!undo); -while (edits.hasNext ()) { -var edit = edits.next (); -if (edit.getAction () === jalview.commands.EditCommand.Action.CUT || edit.getAction () === jalview.commands.EditCommand.Action.PASTE) { -jalview.util.MappingUtils.mapCutOrPaste (edit, undo, mapTo.getSequences (), result, mappings); -} else if (edit.getAction () === jalview.commands.EditCommand.Action.INSERT_GAP || edit.getAction () === jalview.commands.EditCommand.Action.DELETE_GAP) { -jalview.util.MappingUtils.mapInsertOrDelete (edit, undo, originalSequences, mapTo.getSequences (), targetCopies, gapChar, result, mappings); -}} -return result.getSize () > 0 ? result : null; -}, "jalview.commands.EditCommand,~B,jalview.datamodel.AlignmentI,~S,java.util.Set"); -c$.mapInsertOrDelete = Clazz.defineMethod (c$, "mapInsertOrDelete", -function (edit, undo, originalSequences, targetSeqs, targetCopies, gapChar, result, mappings) { -var action = edit.getAction (); -if (undo) { -action = action.getUndoAction (); -}var count = edit.getNumber (); -var editPos = edit.getPosition (); -for (var seq, $seq = 0, $$seq = edit.getSequences (); $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { -var ds = seq.getDatasetSequence (); -if (ds == null) { -continue; -}var actedOn = originalSequences.get (ds); -var seqpos = actedOn.findPosition (editPos); -var sr = jalview.util.MappingUtils.buildSearchResults (seq, seqpos, mappings); -if (!sr.isEmpty ()) { -for (var targetSeq, $targetSeq = targetSeqs.iterator (); $targetSeq.hasNext () && ((targetSeq = $targetSeq.next ()) || true);) { -ds = targetSeq.getDatasetSequence (); -if (ds == null) { -continue; -}var copyTarget = targetCopies.get (ds); -var match = sr.getResults (copyTarget, 0, copyTarget.getLength ()); -if (match != null) { -var ratio = 3; -var mappedCount = count * 3; -var mappedEditPos = action === jalview.commands.EditCommand.Action.DELETE_GAP ? match[0] - mappedCount : match[0]; -var e = resultClazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, action, Clazz.newArray (-1, [targetSeq]), mappedEditPos, mappedCount, gapChar); -result.addEdit (e); -if (action === jalview.commands.EditCommand.Action.INSERT_GAP) { -copyTarget.setSequence ( String.instantialize (jalview.util.StringUtils.insertCharAt (copyTarget.getSequence (), mappedEditPos, mappedCount, gapChar))); -} else if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { -copyTarget.setSequence ( String.instantialize (jalview.util.StringUtils.deleteChars (copyTarget.getSequence (), mappedEditPos, mappedEditPos + mappedCount))); -}}} -}if (action === jalview.commands.EditCommand.Action.INSERT_GAP) { -actedOn.setSequence ( String.instantialize (jalview.util.StringUtils.insertCharAt (actedOn.getSequence (), editPos, count, gapChar))); -} else if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { -actedOn.setSequence ( String.instantialize (jalview.util.StringUtils.deleteChars (actedOn.getSequence (), editPos, editPos + count))); -}} -}, "jalview.commands.EditCommand.Edit,~B,java.util.Map,java.util.List,java.util.Map,~S,jalview.commands.EditCommand,java.util.Set"); -c$.buildSearchResults = Clazz.defineMethod (c$, "buildSearchResults", -function (seq, index, seqmappings) { -var results = new jalview.datamodel.SearchResults (); -jalview.util.MappingUtils.addSearchResults (results, seq, index, seqmappings); -return results; -}, "jalview.datamodel.SequenceI,~N,java.util.Set"); -c$.addSearchResults = Clazz.defineMethod (c$, "addSearchResults", -function (results, seq, index, seqmappings) { -if (index >= seq.getStart () && index <= seq.getEnd ()) { -for (var acf, $acf = seqmappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -acf.markMappedRegion (seq, index, results); -} -}}, "jalview.datamodel.SearchResults,jalview.datamodel.SequenceI,~N,java.util.Set"); -c$.mapSequenceGroup = Clazz.defineMethod (c$, "mapSequenceGroup", -function (sg, mapFrom, mapTo) { -var targetIsNucleotide = mapTo.isNucleotide (); -var protein = targetIsNucleotide ? mapFrom : mapTo; -var codonFrames = protein.getAlignment ().getCodonFrames (); -var mappedGroup = new jalview.datamodel.SequenceGroup (sg); -mappedGroup.cs = mapTo.getGlobalColourScheme (); -mappedGroup.clear (); -var minStartCol = -1; -var maxEndCol = -1; -var selectionStartRes = sg.getStartRes (); -var selectionEndRes = sg.getEndRes (); -for (var selected, $selected = sg.getSequences ().iterator (); $selected.hasNext () && ((selected = $selected.next ()) || true);) { -var firstUngappedPos = selectionStartRes; -while (firstUngappedPos <= selectionEndRes && jalview.util.Comparison.isGap (selected.getCharAt (firstUngappedPos))) { -firstUngappedPos++; -} -if (firstUngappedPos > selectionEndRes) { -continue; -}var lastUngappedPos = selectionEndRes; -while (lastUngappedPos >= selectionStartRes && jalview.util.Comparison.isGap (selected.getCharAt (lastUngappedPos))) { -lastUngappedPos--; -} -var startResiduePos = selected.findPosition (firstUngappedPos); -var endResiduePos = selected.findPosition (lastUngappedPos); -for (var acf, $acf = codonFrames.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -var mappedSequence = targetIsNucleotide ? acf.getDnaForAaSeq (selected) : acf.getAaForDnaSeq (selected); -if (mappedSequence != null) { -for (var seq, $seq = mapTo.getAlignment ().getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -var mappedStartResidue = 0; -var mappedEndResidue = 0; -if (seq.getDatasetSequence () === mappedSequence) { -var sr = jalview.util.MappingUtils.buildSearchResults (selected, startResiduePos, java.util.Collections.singleton (acf)); -for (var m, $m = sr.getResults ().iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -mappedStartResidue = m.getStart (); -mappedEndResidue = m.getEnd (); -} -sr = jalview.util.MappingUtils.buildSearchResults (selected, endResiduePos, java.util.Collections.singleton (acf)); -for (var m, $m = sr.getResults ().iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -mappedStartResidue = Math.min (mappedStartResidue, m.getStart ()); -mappedEndResidue = Math.max (mappedEndResidue, m.getEnd ()); -} -var mappedStartCol = seq.findIndex (mappedStartResidue) - 1; -minStartCol = minStartCol == -1 ? mappedStartCol : Math.min (minStartCol, mappedStartCol); -var mappedEndCol = seq.findIndex (mappedEndResidue) - 1; -maxEndCol = maxEndCol == -1 ? mappedEndCol : Math.max (maxEndCol, mappedEndCol); -mappedGroup.addSequence (seq, false); -break; -}} -}} -} -mappedGroup.setStartRes (minStartCol < 0 ? 0 : minStartCol); -mappedGroup.setEndRes (maxEndCol < 0 ? 0 : maxEndCol); -return mappedGroup; -}, "jalview.datamodel.SequenceGroup,jalview.api.AlignViewportI,jalview.api.AlignViewportI"); -c$.mapOrderCommand = Clazz.defineMethod (c$, "mapOrderCommand", -function (command, undo, mapTo, mappings) { -var sortOrder = command.getSequenceOrder (undo); -var mappedOrder = new java.util.ArrayList (); -var j = 0; -var mappingToNucleotide = mapTo.isNucleotide (); -for (var seq, $seq = 0, $$seq = sortOrder; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { -for (var acf, $acf = mappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { -var mappedSeq = mappingToNucleotide ? acf.getDnaForAaSeq (seq) : acf.getAaForDnaSeq (seq); -if (mappedSeq != null) { -for (var seq2, $seq2 = mapTo.getSequences ().iterator (); $seq2.hasNext () && ((seq2 = $seq2.next ()) || true);) { -if (seq2.getDatasetSequence () === mappedSeq) { -mappedOrder.add (seq2); -j++; -break; -}} -}} -} -if (j == 0) { -return null; -}if (j < mapTo.getHeight ()) { -for (var seq, $seq = mapTo.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -if (!mappedOrder.contains (seq)) { -mappedOrder.add (seq); -}} -}var mappedOrderArray = mappedOrder.toArray ( new Array (mappedOrder.size ())); -var oldOrder = mapTo.getSequencesArray (); -jalview.analysis.AlignmentSorter.sortBy (mapTo, new jalview.datamodel.AlignmentOrder (mappedOrderArray)); -var result = new jalview.commands.OrderCommand (command.getDescription (), oldOrder, mapTo); -return result; -}, "jalview.commands.OrderCommand,~B,jalview.datamodel.AlignmentI,java.util.Set"); -c$.mapColumnSelection = Clazz.defineMethod (c$, "mapColumnSelection", -function (colsel, mapFrom, mapTo) { -var targetIsNucleotide = mapTo.isNucleotide (); -var protein = targetIsNucleotide ? mapFrom : mapTo; -var codonFrames = protein.getAlignment ().getCodonFrames (); -var mappedColumns = new jalview.datamodel.ColumnSelection (); -if (colsel == null) { -return mappedColumns; -}var fromGapChar = mapFrom.getAlignment ().getGapCharacter (); -for (var obj, $obj = colsel.getSelected ().iterator (); $obj.hasNext () && ((obj = $obj.next ()) || true);) { -var col = (obj).intValue (); -var mappedToMin = 2147483647; -var mappedToMax = -2147483648; -for (var fromSeq, $fromSeq = mapFrom.getAlignment ().getSequences ().iterator (); $fromSeq.hasNext () && ((fromSeq = $fromSeq.next ()) || true);) { -if (fromSeq.getCharAt (col) == fromGapChar) { -continue; -}var residuePos = fromSeq.findPosition (col); -var sr = jalview.util.MappingUtils.buildSearchResults (fromSeq, residuePos, codonFrames); -for (var m, $m = sr.getResults ().iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { -var mappedStartResidue = m.getStart (); -var mappedEndResidue = m.getEnd (); -var mappedSeq = m.getSequence (); -for (var toSeq, $toSeq = mapTo.getAlignment ().getSequences ().iterator (); $toSeq.hasNext () && ((toSeq = $toSeq.next ()) || true);) { -if (toSeq.getDatasetSequence () === mappedSeq) { -var mappedStartCol = toSeq.findIndex (mappedStartResidue); -var mappedEndCol = toSeq.findIndex (mappedEndResidue); -mappedToMin = Math.min (mappedToMin, mappedStartCol); -mappedToMax = Math.max (mappedToMax, mappedEndCol); -break; -}} -} -} -for (var i = mappedToMin; i <= mappedToMax; i++) { -mappedColumns.addElement (i - 1); -} -} -return mappedColumns; -}, "jalview.datamodel.ColumnSelection,jalview.api.AlignViewportI,jalview.api.AlignViewportI"); -c$.findCodonFor = Clazz.defineMethod (c$, "findCodonFor", -function (seq, col, mappings) { -var dsPos = seq.findPosition (col); -for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { -if (mapping.involvesSequence (seq)) { -return mapping.getMappedCodon (seq.getDatasetSequence (), dsPos); -}} -return null; -}, "jalview.datamodel.SequenceI,~N,java.util.Set"); -c$.flattenRanges = Clazz.defineMethod (c$, "flattenRanges", -function (ranges) { -var count = 0; -for (var i = 0; i < ranges.length - 1; i += 2) { -count += ranges[i + 1] - ranges[i] + 1; -} -var result = Clazz.newIntArray (count, 0); -var k = 0; -for (var i = 0; i < ranges.length - 1; i += 2) { -for (var j = ranges[i]; j <= ranges[i + 1]; j++) { -result[k++] = j; -} -} -return result; -}, "~A"); -c$.findMappingsForSequence = Clazz.defineMethod (c$, "findMappingsForSequence", -function (sequence, mappings) { -var result = new java.util.ArrayList (); -if (sequence == null || mappings == null) { -return result; -}for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { -if (mapping.involvesSequence (sequence)) { -result.add (mapping); -}} -return result; -}, "jalview.datamodel.SequenceI,java.util.Set"); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.MappingUtils", ["jalview.analysis.AlignmentSorter", "jalview.commands.EditCommand", "$.OrderCommand", "jalview.datamodel.AlignmentOrder", "$.ColumnSelection", "$.SearchResults", "$.Sequence", "$.SequenceGroup", "jalview.util.Comparison", "$.StringUtils", "java.util.ArrayList", "$.Collections", "$.HashMap"], function () { +c$ = Clazz.declareType (jalview.util, "MappingUtils"); +c$.mapCutOrPaste = Clazz.defineMethod (c$, "mapCutOrPaste", +function (edit, undo, targetSeqs, result, mappings) { +var action = edit.getAction (); +if (undo) { +action = action.getUndoAction (); +}System.err.println ("MappingUtils.mapCutOrPaste not yet implemented"); +}, "jalview.commands.EditCommand.Edit,~B,java.util.List,jalview.commands.EditCommand,java.util.Set"); +c$.mapEditCommand = Clazz.defineMethod (c$, "mapEditCommand", +function (command, undo, mapTo, gapChar, mappings) { +if (!mapTo.isNucleotide ()) { +return null; +}var targetCopies = new java.util.HashMap (); +for (var seq, $seq = mapTo.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +var ds = seq.getDatasetSequence (); +if (ds != null) { +var copy = new jalview.datamodel.Sequence (seq); +copy.setDatasetSequence (ds); +targetCopies.put (ds, copy); +}} +var originalSequences = command.priorState (undo); +var result = new jalview.commands.EditCommand (); +var edits = command.getEditIterator (!undo); +while (edits.hasNext ()) { +var edit = edits.next (); +if (edit.getAction () === jalview.commands.EditCommand.Action.CUT || edit.getAction () === jalview.commands.EditCommand.Action.PASTE) { +jalview.util.MappingUtils.mapCutOrPaste (edit, undo, mapTo.getSequences (), result, mappings); +} else if (edit.getAction () === jalview.commands.EditCommand.Action.INSERT_GAP || edit.getAction () === jalview.commands.EditCommand.Action.DELETE_GAP) { +jalview.util.MappingUtils.mapInsertOrDelete (edit, undo, originalSequences, mapTo.getSequences (), targetCopies, gapChar, result, mappings); +}} +return result.getSize () > 0 ? result : null; +}, "jalview.commands.EditCommand,~B,jalview.datamodel.AlignmentI,~S,java.util.Set"); +c$.mapInsertOrDelete = Clazz.defineMethod (c$, "mapInsertOrDelete", +function (edit, undo, originalSequences, targetSeqs, targetCopies, gapChar, result, mappings) { +var action = edit.getAction (); +if (undo) { +action = action.getUndoAction (); +}var count = edit.getNumber (); +var editPos = edit.getPosition (); +for (var seq, $seq = 0, $$seq = edit.getSequences (); $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { +var ds = seq.getDatasetSequence (); +if (ds == null) { +continue; +}var actedOn = originalSequences.get (ds); +var seqpos = actedOn.findPosition (editPos); +var sr = jalview.util.MappingUtils.buildSearchResults (seq, seqpos, mappings); +if (!sr.isEmpty ()) { +for (var targetSeq, $targetSeq = targetSeqs.iterator (); $targetSeq.hasNext () && ((targetSeq = $targetSeq.next ()) || true);) { +ds = targetSeq.getDatasetSequence (); +if (ds == null) { +continue; +}var copyTarget = targetCopies.get (ds); +var match = sr.getResults (copyTarget, 0, copyTarget.getLength ()); +if (match != null) { +var ratio = 3; +var mappedCount = count * 3; +var mappedEditPos = action === jalview.commands.EditCommand.Action.DELETE_GAP ? match[0] - mappedCount : match[0]; +var e = resultClazz.innerTypeInstance (jalview.commands.EditCommand.Edit, this, null, action, Clazz.newArray (-1, [targetSeq]), mappedEditPos, mappedCount, gapChar); +result.addEdit (e); +if (action === jalview.commands.EditCommand.Action.INSERT_GAP) { +copyTarget.setSequence ( String.instantialize (jalview.util.StringUtils.insertCharAt (copyTarget.getSequence (), mappedEditPos, mappedCount, gapChar))); +} else if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { +copyTarget.setSequence ( String.instantialize (jalview.util.StringUtils.deleteChars (copyTarget.getSequence (), mappedEditPos, mappedEditPos + mappedCount))); +}}} +}if (action === jalview.commands.EditCommand.Action.INSERT_GAP) { +actedOn.setSequence ( String.instantialize (jalview.util.StringUtils.insertCharAt (actedOn.getSequence (), editPos, count, gapChar))); +} else if (action === jalview.commands.EditCommand.Action.DELETE_GAP) { +actedOn.setSequence ( String.instantialize (jalview.util.StringUtils.deleteChars (actedOn.getSequence (), editPos, editPos + count))); +}} +}, "jalview.commands.EditCommand.Edit,~B,java.util.Map,java.util.List,java.util.Map,~S,jalview.commands.EditCommand,java.util.Set"); +c$.buildSearchResults = Clazz.defineMethod (c$, "buildSearchResults", +function (seq, index, seqmappings) { +var results = new jalview.datamodel.SearchResults (); +jalview.util.MappingUtils.addSearchResults (results, seq, index, seqmappings); +return results; +}, "jalview.datamodel.SequenceI,~N,java.util.Set"); +c$.addSearchResults = Clazz.defineMethod (c$, "addSearchResults", +function (results, seq, index, seqmappings) { +if (index >= seq.getStart () && index <= seq.getEnd ()) { +for (var acf, $acf = seqmappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +acf.markMappedRegion (seq, index, results); +} +}}, "jalview.datamodel.SearchResults,jalview.datamodel.SequenceI,~N,java.util.Set"); +c$.mapSequenceGroup = Clazz.defineMethod (c$, "mapSequenceGroup", +function (sg, mapFrom, mapTo) { +var targetIsNucleotide = mapTo.isNucleotide (); +var protein = targetIsNucleotide ? mapFrom : mapTo; +var codonFrames = protein.getAlignment ().getCodonFrames (); +var mappedGroup = new jalview.datamodel.SequenceGroup (sg); +mappedGroup.cs = mapTo.getGlobalColourScheme (); +mappedGroup.clear (); +var minStartCol = -1; +var maxEndCol = -1; +var selectionStartRes = sg.getStartRes (); +var selectionEndRes = sg.getEndRes (); +for (var selected, $selected = sg.getSequences ().iterator (); $selected.hasNext () && ((selected = $selected.next ()) || true);) { +var firstUngappedPos = selectionStartRes; +while (firstUngappedPos <= selectionEndRes && jalview.util.Comparison.isGap (selected.getCharAt (firstUngappedPos))) { +firstUngappedPos++; +} +if (firstUngappedPos > selectionEndRes) { +continue; +}var lastUngappedPos = selectionEndRes; +while (lastUngappedPos >= selectionStartRes && jalview.util.Comparison.isGap (selected.getCharAt (lastUngappedPos))) { +lastUngappedPos--; +} +var startResiduePos = selected.findPosition (firstUngappedPos); +var endResiduePos = selected.findPosition (lastUngappedPos); +for (var acf, $acf = codonFrames.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +var mappedSequence = targetIsNucleotide ? acf.getDnaForAaSeq (selected) : acf.getAaForDnaSeq (selected); +if (mappedSequence != null) { +for (var seq, $seq = mapTo.getAlignment ().getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +var mappedStartResidue = 0; +var mappedEndResidue = 0; +if (seq.getDatasetSequence () === mappedSequence) { +var sr = jalview.util.MappingUtils.buildSearchResults (selected, startResiduePos, java.util.Collections.singleton (acf)); +for (var m, $m = sr.getResults ().iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +mappedStartResidue = m.getStart (); +mappedEndResidue = m.getEnd (); +} +sr = jalview.util.MappingUtils.buildSearchResults (selected, endResiduePos, java.util.Collections.singleton (acf)); +for (var m, $m = sr.getResults ().iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +mappedStartResidue = Math.min (mappedStartResidue, m.getStart ()); +mappedEndResidue = Math.max (mappedEndResidue, m.getEnd ()); +} +var mappedStartCol = seq.findIndex (mappedStartResidue) - 1; +minStartCol = minStartCol == -1 ? mappedStartCol : Math.min (minStartCol, mappedStartCol); +var mappedEndCol = seq.findIndex (mappedEndResidue) - 1; +maxEndCol = maxEndCol == -1 ? mappedEndCol : Math.max (maxEndCol, mappedEndCol); +mappedGroup.addSequence (seq, false); +break; +}} +}} +} +mappedGroup.setStartRes (minStartCol < 0 ? 0 : minStartCol); +mappedGroup.setEndRes (maxEndCol < 0 ? 0 : maxEndCol); +return mappedGroup; +}, "jalview.datamodel.SequenceGroup,jalview.api.AlignViewportI,jalview.api.AlignViewportI"); +c$.mapOrderCommand = Clazz.defineMethod (c$, "mapOrderCommand", +function (command, undo, mapTo, mappings) { +var sortOrder = command.getSequenceOrder (undo); +var mappedOrder = new java.util.ArrayList (); +var j = 0; +var mappingToNucleotide = mapTo.isNucleotide (); +for (var seq, $seq = 0, $$seq = sortOrder; $seq < $$seq.length && ((seq = $$seq[$seq]) || true); $seq++) { +for (var acf, $acf = mappings.iterator (); $acf.hasNext () && ((acf = $acf.next ()) || true);) { +var mappedSeq = mappingToNucleotide ? acf.getDnaForAaSeq (seq) : acf.getAaForDnaSeq (seq); +if (mappedSeq != null) { +for (var seq2, $seq2 = mapTo.getSequences ().iterator (); $seq2.hasNext () && ((seq2 = $seq2.next ()) || true);) { +if (seq2.getDatasetSequence () === mappedSeq) { +mappedOrder.add (seq2); +j++; +break; +}} +}} +} +if (j == 0) { +return null; +}if (j < mapTo.getHeight ()) { +for (var seq, $seq = mapTo.getSequences ().iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +if (!mappedOrder.contains (seq)) { +mappedOrder.add (seq); +}} +}var mappedOrderArray = mappedOrder.toArray ( new Array (mappedOrder.size ())); +var oldOrder = mapTo.getSequencesArray (); +jalview.analysis.AlignmentSorter.sortBy (mapTo, new jalview.datamodel.AlignmentOrder (mappedOrderArray)); +var result = new jalview.commands.OrderCommand (command.getDescription (), oldOrder, mapTo); +return result; +}, "jalview.commands.OrderCommand,~B,jalview.datamodel.AlignmentI,java.util.Set"); +c$.mapColumnSelection = Clazz.defineMethod (c$, "mapColumnSelection", +function (colsel, mapFrom, mapTo) { +var targetIsNucleotide = mapTo.isNucleotide (); +var protein = targetIsNucleotide ? mapFrom : mapTo; +var codonFrames = protein.getAlignment ().getCodonFrames (); +var mappedColumns = new jalview.datamodel.ColumnSelection (); +if (colsel == null) { +return mappedColumns; +}var fromGapChar = mapFrom.getAlignment ().getGapCharacter (); +for (var obj, $obj = colsel.getSelected ().iterator (); $obj.hasNext () && ((obj = $obj.next ()) || true);) { +var col = (obj).intValue (); +var mappedToMin = 2147483647; +var mappedToMax = -2147483648; +for (var fromSeq, $fromSeq = mapFrom.getAlignment ().getSequences ().iterator (); $fromSeq.hasNext () && ((fromSeq = $fromSeq.next ()) || true);) { +if (fromSeq.getCharAt (col) == fromGapChar) { +continue; +}var residuePos = fromSeq.findPosition (col); +var sr = jalview.util.MappingUtils.buildSearchResults (fromSeq, residuePos, codonFrames); +for (var m, $m = sr.getResults ().iterator (); $m.hasNext () && ((m = $m.next ()) || true);) { +var mappedStartResidue = m.getStart (); +var mappedEndResidue = m.getEnd (); +var mappedSeq = m.getSequence (); +for (var toSeq, $toSeq = mapTo.getAlignment ().getSequences ().iterator (); $toSeq.hasNext () && ((toSeq = $toSeq.next ()) || true);) { +if (toSeq.getDatasetSequence () === mappedSeq) { +var mappedStartCol = toSeq.findIndex (mappedStartResidue); +var mappedEndCol = toSeq.findIndex (mappedEndResidue); +mappedToMin = Math.min (mappedToMin, mappedStartCol); +mappedToMax = Math.max (mappedToMax, mappedEndCol); +break; +}} +} +} +for (var i = mappedToMin; i <= mappedToMax; i++) { +mappedColumns.addElement (i - 1); +} +} +return mappedColumns; +}, "jalview.datamodel.ColumnSelection,jalview.api.AlignViewportI,jalview.api.AlignViewportI"); +c$.findCodonFor = Clazz.defineMethod (c$, "findCodonFor", +function (seq, col, mappings) { +var dsPos = seq.findPosition (col); +for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { +if (mapping.involvesSequence (seq)) { +return mapping.getMappedCodon (seq.getDatasetSequence (), dsPos); +}} +return null; +}, "jalview.datamodel.SequenceI,~N,java.util.Set"); +c$.flattenRanges = Clazz.defineMethod (c$, "flattenRanges", +function (ranges) { +var count = 0; +for (var i = 0; i < ranges.length - 1; i += 2) { +count += ranges[i + 1] - ranges[i] + 1; +} +var result = Clazz.newIntArray (count, 0); +var k = 0; +for (var i = 0; i < ranges.length - 1; i += 2) { +for (var j = ranges[i]; j <= ranges[i + 1]; j++) { +result[k++] = j; +} +} +return result; +}, "~A"); +c$.findMappingsForSequence = Clazz.defineMethod (c$, "findMappingsForSequence", +function (sequence, mappings) { +var result = new java.util.ArrayList (); +if (sequence == null || mappings == null) { +return result; +}for (var mapping, $mapping = mappings.iterator (); $mapping.hasNext () && ((mapping = $mapping.next ()) || true);) { +if (mapping.involvesSequence (sequence)) { +result.add (mapping); +}} +return result; +}, "jalview.datamodel.SequenceI,java.util.Set"); +}); diff --git a/bin/jalview/util/MessageManager.js b/bin/jalview/util/MessageManager.js index 4283582..44350e0 100644 --- a/bin/jalview/util/MessageManager.js +++ b/bin/jalview/util/MessageManager.js @@ -1,73 +1,73 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.text.MessageFormat", "java.util.logging.Logger"], "jalview.util.MessageManager", ["java.util.Locale", "$.ResourceBundle", "java.util.logging.Level"], function () { -c$ = Clazz.declareType (jalview.util, "MessageManager"); -c$.getString = Clazz.defineMethod (c$, "getString", -function (key) { -var value = "[missing key] " + key; -try { -value = jalview.util.MessageManager.rb.getString (key); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -jalview.util.MessageManager.log.warning ("I18N missing: " + jalview.util.MessageManager.loc + "\t" + key); -} else { -throw e; -} -} -return value; -}, "~S"); -c$.getLocale = Clazz.defineMethod (c$, "getLocale", -function () { -return jalview.util.MessageManager.loc; -}); -c$.formatMessage = Clazz.defineMethod (c$, "formatMessage", -function (key, params) { -return java.text.MessageFormat.format (jalview.util.MessageManager.getString (key), params); -}, "~S,~A"); -c$.formatMessage = Clazz.defineMethod (c$, "formatMessage", -function (key, params) { -return java.text.MessageFormat.format (jalview.util.MessageManager.getString (key), params); -}, "~S,~A"); -c$.getStringOrReturn = Clazz.defineMethod (c$, "getStringOrReturn", -function (keyroot, name) { -var smkey = keyroot + name.toLowerCase ().replaceAll (" ", ""); -try { -name = jalview.util.MessageManager.rb.getString (smkey); -} catch (x) { -if (Clazz.exceptionOf (x, Exception)) { -jalview.util.MessageManager.log.finest ("I18N missing key with root " + keyroot + ": " + jalview.util.MessageManager.loc + "\t" + smkey); -} else { -throw x; -} -} -return name; -}, "~S,~S"); -Clazz.defineStatics (c$, -"rb", null); -c$.log = c$.prototype.log = java.util.logging.Logger.getLogger (jalview.util.MessageManager.getCanonicalName ()); -Clazz.defineStatics (c$, -"loc", null); -{ -try { -jalview.util.MessageManager.loc = java.util.Locale.getDefault (); -jalview.util.MessageManager.log.info ("Getting messages for lang: " + jalview.util.MessageManager.loc); -jalview.util.MessageManager.rb = java.util.ResourceBundle.getBundle ("lang.Messages", jalview.util.MessageManager.loc); -if (jalview.util.MessageManager.rb == null || jalview.util.MessageManager.log.isLoggable (java.util.logging.Level.FINEST)) { -jalview.util.MessageManager.log.finest ("Language keys: " + jalview.util.MessageManager.rb.keySet ()); -}} catch (e$$) { -if (Clazz.exceptionOf (e$$, Exception)) { -var q = e$$; -{ -jalview.util.MessageManager.log.warning ("Exception when initting Locale for i18n messages\n" + q.getMessage ()); -q.printStackTrace (); -} -} else if (Clazz.exceptionOf (e$$, Error)) { -var v = e$$; -{ -jalview.util.MessageManager.log.warning ("Error when initting Locale for i18n messages\n" + v.getMessage ()); -v.printStackTrace (); -} -} else { -throw e$$; -} -} -}}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.text.MessageFormat", "java.util.logging.Logger"], "jalview.util.MessageManager", ["java.util.Locale", "$.ResourceBundle", "java.util.logging.Level"], function () { +c$ = Clazz.declareType (jalview.util, "MessageManager"); +c$.getString = Clazz.defineMethod (c$, "getString", +function (key) { +var value = "[missing key] " + key; +try { +value = jalview.util.MessageManager.rb.getString (key); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +jalview.util.MessageManager.log.warning ("I18N missing: " + jalview.util.MessageManager.loc + "\t" + key); +} else { +throw e; +} +} +return value; +}, "~S"); +c$.getLocale = Clazz.defineMethod (c$, "getLocale", +function () { +return jalview.util.MessageManager.loc; +}); +c$.formatMessage = Clazz.defineMethod (c$, "formatMessage", +function (key, params) { +return java.text.MessageFormat.format (jalview.util.MessageManager.getString (key), params); +}, "~S,~A"); +c$.formatMessage = Clazz.defineMethod (c$, "formatMessage", +function (key, params) { +return java.text.MessageFormat.format (jalview.util.MessageManager.getString (key), params); +}, "~S,~A"); +c$.getStringOrReturn = Clazz.defineMethod (c$, "getStringOrReturn", +function (keyroot, name) { +var smkey = keyroot + name.toLowerCase ().replaceAll (" ", ""); +try { +name = jalview.util.MessageManager.rb.getString (smkey); +} catch (x) { +if (Clazz.exceptionOf (x, Exception)) { +jalview.util.MessageManager.log.finest ("I18N missing key with root " + keyroot + ": " + jalview.util.MessageManager.loc + "\t" + smkey); +} else { +throw x; +} +} +return name; +}, "~S,~S"); +Clazz.defineStatics (c$, +"rb", null); +c$.log = c$.prototype.log = java.util.logging.Logger.getLogger (jalview.util.MessageManager.getCanonicalName ()); +Clazz.defineStatics (c$, +"loc", null); +{ +try { +jalview.util.MessageManager.loc = java.util.Locale.getDefault (); +jalview.util.MessageManager.log.info ("Getting messages for lang: " + jalview.util.MessageManager.loc); +jalview.util.MessageManager.rb = java.util.ResourceBundle.getBundle ("lang.Messages", jalview.util.MessageManager.loc); +if (jalview.util.MessageManager.rb == null || jalview.util.MessageManager.log.isLoggable (java.util.logging.Level.FINEST)) { +jalview.util.MessageManager.log.finest ("Language keys: " + jalview.util.MessageManager.rb.keySet ()); +}} catch (e$$) { +if (Clazz.exceptionOf (e$$, Exception)) { +var q = e$$; +{ +jalview.util.MessageManager.log.warning ("Exception when initting Locale for i18n messages\n" + q.getMessage ()); +q.printStackTrace (); +} +} else if (Clazz.exceptionOf (e$$, Error)) { +var v = e$$; +{ +jalview.util.MessageManager.log.warning ("Error when initting Locale for i18n messages\n" + v.getMessage ()); +v.printStackTrace (); +} +} else { +throw e$$; +} +} +}}); diff --git a/bin/jalview/util/ParseHtmlBodyAndLinks.js b/bin/jalview/util/ParseHtmlBodyAndLinks.js index 8e41548..bf67f6a 100644 --- a/bin/jalview/util/ParseHtmlBodyAndLinks.js +++ b/bin/jalview/util/ParseHtmlBodyAndLinks.js @@ -1,78 +1,78 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.lang.StringBuffer", "java.util.ArrayList", "java.util.regex.Pattern"], "jalview.util.ParseHtmlBodyAndLinks", ["java.util.StringTokenizer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.orig = null; -this.htmlContent = true; -this.links = null; -this.sb = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "ParseHtmlBodyAndLinks"); -Clazz.prepareFields (c$, function () { -this.links = new java.util.ArrayList (); -this.sb = new StringBuffer (); -}); -Clazz.defineMethod (c$, "getOrig", -function () { -return this.orig; -}); -Clazz.defineMethod (c$, "isHtmlContent", -function () { -return this.htmlContent; -}); -Clazz.defineMethod (c$, "getContent", -function () { -return this.sb.toString (); -}); -Clazz.defineMethod (c$, "getLinks", -function () { -return this.links; -}); -Clazz.makeConstructor (c$, -function (description, removeHTML, newline) { -if (description == null || description.length == 0) { -this.htmlContent = false; -return; -}if (description.toUpperCase ().indexOf ("") == -1) { -this.htmlContent = false; -}this.orig = description; -var st = new java.util.StringTokenizer (description, "<"); -var token; -var link; -var startTag; -var tag = null; -while (st.hasMoreElements ()) { -token = st.nextToken ("&>"); -if (token.equalsIgnoreCase ("html") || token.startsWith ("/")) { -continue; -}tag = null; -startTag = token.indexOf ("<"); -if (startTag > -1) { -tag = token.substring (startTag + 1); -token = token.substring (0, startTag); -}if (tag != null && tag.toUpperCase ().startsWith ("A HREF=")) { -if (token.length > 0) { -this.sb.append (token); -}link = tag.substring (tag.indexOf ("\"") + 1, tag.length - 1); -var label = st.nextToken ("<>"); -this.links.add (label + "|" + link); -this.sb.append (label + "%LINK%"); -} else if (tag != null && tag.equalsIgnoreCase ("br")) { -this.sb.append (newline); -} else if (token.startsWith ("lt;")) { -this.sb.append ("<" + token.substring (3)); -} else if (token.startsWith ("gt;")) { -this.sb.append (">" + token.substring (3)); -} else if (token.startsWith ("amp;")) { -this.sb.append ("&" + token.substring (4)); -} else { -this.sb.append (token); -}} -if (removeHTML && !this.htmlContent) { -this.sb = new StringBuffer (jalview.util.ParseHtmlBodyAndLinks.LEFT_ANGLE_BRACKET_PATTERN.matcher (description).replaceAll ("<")); -}}, "~S,~B,~S"); -Clazz.defineMethod (c$, "getNonHtmlContent", -function () { -return this.isHtmlContent () ? this.sb.toString () : this.orig; -}); -c$.LEFT_ANGLE_BRACKET_PATTERN = c$.prototype.LEFT_ANGLE_BRACKET_PATTERN = java.util.regex.Pattern.compile ("<"); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.lang.StringBuffer", "java.util.ArrayList", "java.util.regex.Pattern"], "jalview.util.ParseHtmlBodyAndLinks", ["java.util.StringTokenizer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.orig = null; +this.htmlContent = true; +this.links = null; +this.sb = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "ParseHtmlBodyAndLinks"); +Clazz.prepareFields (c$, function () { +this.links = new java.util.ArrayList (); +this.sb = new StringBuffer (); +}); +Clazz.defineMethod (c$, "getOrig", +function () { +return this.orig; +}); +Clazz.defineMethod (c$, "isHtmlContent", +function () { +return this.htmlContent; +}); +Clazz.defineMethod (c$, "getContent", +function () { +return this.sb.toString (); +}); +Clazz.defineMethod (c$, "getLinks", +function () { +return this.links; +}); +Clazz.makeConstructor (c$, +function (description, removeHTML, newline) { +if (description == null || description.length == 0) { +this.htmlContent = false; +return; +}if (description.toUpperCase ().indexOf ("") == -1) { +this.htmlContent = false; +}this.orig = description; +var st = new java.util.StringTokenizer (description, "<"); +var token; +var link; +var startTag; +var tag = null; +while (st.hasMoreElements ()) { +token = st.nextToken ("&>"); +if (token.equalsIgnoreCase ("html") || token.startsWith ("/")) { +continue; +}tag = null; +startTag = token.indexOf ("<"); +if (startTag > -1) { +tag = token.substring (startTag + 1); +token = token.substring (0, startTag); +}if (tag != null && tag.toUpperCase ().startsWith ("A HREF=")) { +if (token.length > 0) { +this.sb.append (token); +}link = tag.substring (tag.indexOf ("\"") + 1, tag.length - 1); +var label = st.nextToken ("<>"); +this.links.add (label + "|" + link); +this.sb.append (label + "%LINK%"); +} else if (tag != null && tag.equalsIgnoreCase ("br")) { +this.sb.append (newline); +} else if (token.startsWith ("lt;")) { +this.sb.append ("<" + token.substring (3)); +} else if (token.startsWith ("gt;")) { +this.sb.append (">" + token.substring (3)); +} else if (token.startsWith ("amp;")) { +this.sb.append ("&" + token.substring (4)); +} else { +this.sb.append (token); +}} +if (removeHTML && !this.htmlContent) { +this.sb = new StringBuffer (jalview.util.ParseHtmlBodyAndLinks.LEFT_ANGLE_BRACKET_PATTERN.matcher (description).replaceAll ("<")); +}}, "~S,~B,~S"); +Clazz.defineMethod (c$, "getNonHtmlContent", +function () { +return this.isHtmlContent () ? this.sb.toString () : this.orig; +}); +c$.LEFT_ANGLE_BRACKET_PATTERN = c$.prototype.LEFT_ANGLE_BRACKET_PATTERN = java.util.regex.Pattern.compile ("<"); +}); diff --git a/bin/jalview/util/Platform.js b/bin/jalview/util/Platform.js index e599669..d349bdb 100644 --- a/bin/jalview/util/Platform.js +++ b/bin/jalview/util/Platform.js @@ -1,30 +1,30 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.Platform", ["java.lang.StringBuffer"], function () { -c$ = Clazz.declareType (jalview.util, "Platform"); -c$.isAMac = Clazz.defineMethod (c$, "isAMac", -function () { -return java.lang.System.getProperty ("os.name").indexOf ("Mac") > -1; -}); -c$.isHeadless = Clazz.defineMethod (c$, "isHeadless", -function () { -var hdls = java.lang.System.getProperty ("java.awt.headless"); -return hdls != null && hdls.equals ("true"); -}); -c$.getMaxCommandLineLength = Clazz.defineMethod (c$, "getMaxCommandLineLength", -function () { -return 2046; -}); -c$.escapeString = Clazz.defineMethod (c$, "escapeString", -function (file) { -var f = new StringBuffer (); -var p = 0; -var lastp = 0; -while ((p = file.indexOf ('\\', lastp)) > -1) { -f.append (file.subSequence (lastp, p)); -f.append ("\\\\"); -lastp = p + 1; -} -f.append (file.substring (lastp)); -return f.toString (); -}, "~S"); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.Platform", ["java.lang.StringBuffer"], function () { +c$ = Clazz.declareType (jalview.util, "Platform"); +c$.isAMac = Clazz.defineMethod (c$, "isAMac", +function () { +return java.lang.System.getProperty ("os.name").indexOf ("Mac") > -1; +}); +c$.isHeadless = Clazz.defineMethod (c$, "isHeadless", +function () { +var hdls = java.lang.System.getProperty ("java.awt.headless"); +return hdls != null && hdls.equals ("true"); +}); +c$.getMaxCommandLineLength = Clazz.defineMethod (c$, "getMaxCommandLineLength", +function () { +return 2046; +}); +c$.escapeString = Clazz.defineMethod (c$, "escapeString", +function (file) { +var f = new StringBuffer (); +var p = 0; +var lastp = 0; +while ((p = file.indexOf ('\\', lastp)) > -1) { +f.append (file.subSequence (lastp, p)); +f.append ("\\\\"); +lastp = p + 1; +} +f.append (file.substring (lastp)); +return f.toString (); +}, "~S"); +}); diff --git a/bin/jalview/util/QuickSort.js b/bin/jalview/util/QuickSort.js index f8fb52f..a0960b5 100644 --- a/bin/jalview/util/QuickSort.js +++ b/bin/jalview/util/QuickSort.js @@ -1,231 +1,231 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.QuickSort", ["java.lang.Float", "java.util.Arrays"], function () { -c$ = Clazz.declareType (jalview.util, "QuickSort"); -c$.sortInt = Clazz.defineMethod (c$, "sortInt", -function (arr, s) { -jalview.util.QuickSort.sortInt (arr, 0, arr.length - 1, s); -}, "~A,~A"); -c$.sortFloatObject = Clazz.defineMethod (c$, "sortFloatObject", -function (arr, s) { -jalview.util.QuickSort.sortFloat (arr, 0, arr.length - 1, s); -}, "~A,~A"); -c$.sortDouble = Clazz.defineMethod (c$, "sortDouble", -function (arr, s) { -jalview.util.QuickSort.sortDouble (arr, 0, arr.length - 1, s); -}, "~A,~A"); -c$.sort = Clazz.defineMethod (c$, "sort", -function (arr, s) { -jalview.util.QuickSort.stringSort (arr, 0, arr.length - 1, s); -}, "~A,~A"); -c$.stringSort = Clazz.defineMethod (c$, "stringSort", -($fz = function (arr, p, r, s) { -var q; -if (p < r) { -q = jalview.util.QuickSort.stringPartition (arr, p, r, s); -jalview.util.QuickSort.stringSort (arr, p, q, s); -jalview.util.QuickSort.stringSort (arr, q + 1, r, s); -}}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); -c$.sortFloat = Clazz.defineMethod (c$, "sortFloat", -($fz = function (arr, p, r, s) { -var q; -if (p < r) { -q = jalview.util.QuickSort.partitionFloat (arr, p, r, s); -jalview.util.QuickSort.sortFloat (arr, p, q, s); -jalview.util.QuickSort.sortFloat (arr, q + 1, r, s); -}}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); -c$.sortInt = Clazz.defineMethod (c$, "sortInt", -($fz = function (arr, p, r, s) { -var q; -if (p < r) { -q = jalview.util.QuickSort.partitionInt (arr, p, r, s); -jalview.util.QuickSort.sortInt (arr, p, q, s); -jalview.util.QuickSort.sortInt (arr, q + 1, r, s); -}}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); -c$.partitionFloat = Clazz.defineMethod (c$, "partitionFloat", -($fz = function (arr, p, r, s) { -var x = arr[p]; -var i = p - 1; -var j = r + 1; -while (true) { -do { -j = j - 1; -} while (arr[j] > x); -do { -i = i + 1; -} while (arr[i] < x); -if (i < j) { -var tmp = arr[i]; -arr[i] = arr[j]; -arr[j] = tmp; -var tmp2 = s[i]; -s[i] = s[j]; -s[j] = tmp2; -} else { -return j; -}} -}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); -c$.partitionInt = Clazz.defineMethod (c$, "partitionInt", -($fz = function (arr, p, r, s) { -var x = arr[p]; -var i = p - 1; -var j = r + 1; -while (true) { -do { -j = j - 1; -} while (arr[j] > x); -do { -i = i + 1; -} while (arr[i] < x); -if (i < j) { -var tmp = arr[i]; -arr[i] = arr[j]; -arr[j] = tmp; -var tmp2 = s[i]; -s[i] = s[j]; -s[j] = tmp2; -} else { -return j; -}} -}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); -c$.stringPartition = Clazz.defineMethod (c$, "stringPartition", -($fz = function (arr, p, r, s) { -var x = arr[p]; -var i = p - 1; -var j = r + 1; -while (true) { -do { -j = j - 1; -} while (arr[j].compareTo (x) < 0); -do { -i = i + 1; -} while (arr[i].compareTo (x) > 0); -if (i < j) { -var tmp = arr[i]; -arr[i] = arr[j]; -arr[j] = tmp; -var tmp2 = s[i]; -s[i] = s[j]; -s[j] = tmp2; -} else { -return j; -}} -}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); -c$.sortFloatChar = Clazz.defineMethod (c$, "sortFloatChar", -function (arr, s) { -var f1 = Clazz.newFloatArray (arr.length, 0); -var s1 = Clazz.newCharArray (s.length, '\0'); -var nextZeroValue = 0; -var nextNonZeroValue = arr.length - 1; -for (var i = 0; i < arr.length; i++) { -var val = arr[i]; -if (val > 0) { -f1[nextNonZeroValue] = val; -s1[nextNonZeroValue] = s[i]; -nextNonZeroValue--; -} else { -f1[nextZeroValue] = val; -s1[nextZeroValue] = s[i]; -nextZeroValue++; -}} -System.arraycopy (f1, 0, arr, 0, nextZeroValue); -System.arraycopy (s1, 0, s, 0, nextZeroValue); -if (nextZeroValue == arr.length) { -return; -}var nonZeroFloats = java.util.Arrays.copyOfRange (f1, nextZeroValue, f1.length); -var nonZeroChars = java.util.Arrays.copyOfRange (s1, nextZeroValue, s1.length); -jalview.util.QuickSort.externalSortFloat (nonZeroFloats, nonZeroChars); -System.arraycopy (nonZeroFloats, 0, arr, nextZeroValue, nonZeroFloats.length); -System.arraycopy (nonZeroChars, 0, s, nextZeroValue, nonZeroChars.length); -}, "~A,~A"); -c$.externalSortFloat = Clazz.defineMethod (c$, "externalSortFloat", -($fz = function (arr, s) { -var length = arr.length; -var indices = jalview.util.QuickSort.makeIndexArray (length); -java.util.Arrays.sort (indices, new jalview.util.QuickSort.FloatComparator (arr)); -var sortedFloats = Clazz.newFloatArray (length, 0); -var sortedChars = Clazz.newCharArray (s.length, '\0'); -for (var i = 0; i < length; i++) { -sortedFloats[i] = arr[indices[i]]; -sortedChars[i] = s[indices[i]]; -} -System.arraycopy (sortedFloats, 0, arr, 0, length); -System.arraycopy (sortedChars, 0, s, 0, s.length); -}, $fz.isPrivate = true, $fz), "~A,~A"); -c$.makeIndexArray = Clazz.defineMethod (c$, "makeIndexArray", -($fz = function (length) { -var indices = new Array (length); -for (var i = 0; i < length; i++) { -indices[i] = new Integer (i); -} -return indices; -}, $fz.isPrivate = true, $fz), "~N"); -c$.sortIntChar = Clazz.defineMethod (c$, "sortIntChar", -function (arr, s) { -var f1 = Clazz.newIntArray (arr.length, 0); -var s1 = Clazz.newCharArray (s.length, '\0'); -var nextZeroValue = 0; -var nextNonZeroValue = arr.length - 1; -for (var i = 0; i < arr.length; i++) { -var val = arr[i]; -if (val > 0) { -f1[nextNonZeroValue] = val; -s1[nextNonZeroValue] = s[i]; -nextNonZeroValue--; -} else { -f1[nextZeroValue] = val; -s1[nextZeroValue] = s[i]; -nextZeroValue++; -}} -System.arraycopy (f1, 0, arr, 0, nextZeroValue); -System.arraycopy (s1, 0, s, 0, nextZeroValue); -if (nextZeroValue == arr.length) { -return; -}var nonZeroInts = java.util.Arrays.copyOfRange (f1, nextZeroValue, f1.length); -var nonZeroChars = java.util.Arrays.copyOfRange (s1, nextZeroValue, s1.length); -jalview.util.QuickSort.externalSortInt (nonZeroInts, nonZeroChars); -System.arraycopy (nonZeroInts, 0, arr, nextZeroValue, nonZeroInts.length); -System.arraycopy (nonZeroChars, 0, s, nextZeroValue, nonZeroChars.length); -}, "~A,~A"); -c$.externalSortInt = Clazz.defineMethod (c$, "externalSortInt", -($fz = function (arr, s) { -var length = arr.length; -var indices = jalview.util.QuickSort.makeIndexArray (length); -java.util.Arrays.sort (indices, new jalview.util.QuickSort.IntComparator (arr)); -var sortedInts = Clazz.newIntArray (length, 0); -var sortedChars = Clazz.newCharArray (s.length, '\0'); -for (var i = 0; i < length; i++) { -sortedInts[i] = arr[indices[i]]; -sortedChars[i] = s[indices[i]]; -} -System.arraycopy (sortedInts, 0, arr, 0, length); -System.arraycopy (sortedChars, 0, s, 0, s.length); -}, $fz.isPrivate = true, $fz), "~A,~A"); -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.values = null; -Clazz.instantialize (this, arguments); -}, jalview.util.QuickSort, "FloatComparator", null, java.util.Comparator); -Clazz.makeConstructor (c$, -function (a) { -this.values = a; -}, "~A"); -Clazz.overrideMethod (c$, "compare", -function (a, b) { -return Float.compare (this.values[a.intValue ()], this.values[b]); -}, "Integer,Integer"); -c$ = Clazz.p0p (); -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.values = null; -Clazz.instantialize (this, arguments); -}, jalview.util.QuickSort, "IntComparator", null, java.util.Comparator); -Clazz.makeConstructor (c$, -function (a) { -this.values = a; -}, "~A"); -Clazz.overrideMethod (c$, "compare", -function (a, b) { -return Integer.compare (this.values[a], this.values[b]); -}, "Integer,Integer"); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.QuickSort", ["java.lang.Float", "java.util.Arrays"], function () { +c$ = Clazz.declareType (jalview.util, "QuickSort"); +c$.sortInt = Clazz.defineMethod (c$, "sortInt", +function (arr, s) { +jalview.util.QuickSort.sortInt (arr, 0, arr.length - 1, s); +}, "~A,~A"); +c$.sortFloatObject = Clazz.defineMethod (c$, "sortFloatObject", +function (arr, s) { +jalview.util.QuickSort.sortFloat (arr, 0, arr.length - 1, s); +}, "~A,~A"); +c$.sortDouble = Clazz.defineMethod (c$, "sortDouble", +function (arr, s) { +jalview.util.QuickSort.sortDouble (arr, 0, arr.length - 1, s); +}, "~A,~A"); +c$.sort = Clazz.defineMethod (c$, "sort", +function (arr, s) { +jalview.util.QuickSort.stringSort (arr, 0, arr.length - 1, s); +}, "~A,~A"); +c$.stringSort = Clazz.defineMethod (c$, "stringSort", +($fz = function (arr, p, r, s) { +var q; +if (p < r) { +q = jalview.util.QuickSort.stringPartition (arr, p, r, s); +jalview.util.QuickSort.stringSort (arr, p, q, s); +jalview.util.QuickSort.stringSort (arr, q + 1, r, s); +}}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); +c$.sortFloat = Clazz.defineMethod (c$, "sortFloat", +($fz = function (arr, p, r, s) { +var q; +if (p < r) { +q = jalview.util.QuickSort.partitionFloat (arr, p, r, s); +jalview.util.QuickSort.sortFloat (arr, p, q, s); +jalview.util.QuickSort.sortFloat (arr, q + 1, r, s); +}}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); +c$.sortInt = Clazz.defineMethod (c$, "sortInt", +($fz = function (arr, p, r, s) { +var q; +if (p < r) { +q = jalview.util.QuickSort.partitionInt (arr, p, r, s); +jalview.util.QuickSort.sortInt (arr, p, q, s); +jalview.util.QuickSort.sortInt (arr, q + 1, r, s); +}}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); +c$.partitionFloat = Clazz.defineMethod (c$, "partitionFloat", +($fz = function (arr, p, r, s) { +var x = arr[p]; +var i = p - 1; +var j = r + 1; +while (true) { +do { +j = j - 1; +} while (arr[j] > x); +do { +i = i + 1; +} while (arr[i] < x); +if (i < j) { +var tmp = arr[i]; +arr[i] = arr[j]; +arr[j] = tmp; +var tmp2 = s[i]; +s[i] = s[j]; +s[j] = tmp2; +} else { +return j; +}} +}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); +c$.partitionInt = Clazz.defineMethod (c$, "partitionInt", +($fz = function (arr, p, r, s) { +var x = arr[p]; +var i = p - 1; +var j = r + 1; +while (true) { +do { +j = j - 1; +} while (arr[j] > x); +do { +i = i + 1; +} while (arr[i] < x); +if (i < j) { +var tmp = arr[i]; +arr[i] = arr[j]; +arr[j] = tmp; +var tmp2 = s[i]; +s[i] = s[j]; +s[j] = tmp2; +} else { +return j; +}} +}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); +c$.stringPartition = Clazz.defineMethod (c$, "stringPartition", +($fz = function (arr, p, r, s) { +var x = arr[p]; +var i = p - 1; +var j = r + 1; +while (true) { +do { +j = j - 1; +} while (arr[j].compareTo (x) < 0); +do { +i = i + 1; +} while (arr[i].compareTo (x) > 0); +if (i < j) { +var tmp = arr[i]; +arr[i] = arr[j]; +arr[j] = tmp; +var tmp2 = s[i]; +s[i] = s[j]; +s[j] = tmp2; +} else { +return j; +}} +}, $fz.isPrivate = true, $fz), "~A,~N,~N,~A"); +c$.sortFloatChar = Clazz.defineMethod (c$, "sortFloatChar", +function (arr, s) { +var f1 = Clazz.newFloatArray (arr.length, 0); +var s1 = Clazz.newCharArray (s.length, '\0'); +var nextZeroValue = 0; +var nextNonZeroValue = arr.length - 1; +for (var i = 0; i < arr.length; i++) { +var val = arr[i]; +if (val > 0) { +f1[nextNonZeroValue] = val; +s1[nextNonZeroValue] = s[i]; +nextNonZeroValue--; +} else { +f1[nextZeroValue] = val; +s1[nextZeroValue] = s[i]; +nextZeroValue++; +}} +System.arraycopy (f1, 0, arr, 0, nextZeroValue); +System.arraycopy (s1, 0, s, 0, nextZeroValue); +if (nextZeroValue == arr.length) { +return; +}var nonZeroFloats = java.util.Arrays.copyOfRange (f1, nextZeroValue, f1.length); +var nonZeroChars = java.util.Arrays.copyOfRange (s1, nextZeroValue, s1.length); +jalview.util.QuickSort.externalSortFloat (nonZeroFloats, nonZeroChars); +System.arraycopy (nonZeroFloats, 0, arr, nextZeroValue, nonZeroFloats.length); +System.arraycopy (nonZeroChars, 0, s, nextZeroValue, nonZeroChars.length); +}, "~A,~A"); +c$.externalSortFloat = Clazz.defineMethod (c$, "externalSortFloat", +($fz = function (arr, s) { +var length = arr.length; +var indices = jalview.util.QuickSort.makeIndexArray (length); +java.util.Arrays.sort (indices, new jalview.util.QuickSort.FloatComparator (arr)); +var sortedFloats = Clazz.newFloatArray (length, 0); +var sortedChars = Clazz.newCharArray (s.length, '\0'); +for (var i = 0; i < length; i++) { +sortedFloats[i] = arr[indices[i]]; +sortedChars[i] = s[indices[i]]; +} +System.arraycopy (sortedFloats, 0, arr, 0, length); +System.arraycopy (sortedChars, 0, s, 0, s.length); +}, $fz.isPrivate = true, $fz), "~A,~A"); +c$.makeIndexArray = Clazz.defineMethod (c$, "makeIndexArray", +($fz = function (length) { +var indices = new Array (length); +for (var i = 0; i < length; i++) { +indices[i] = new Integer (i); +} +return indices; +}, $fz.isPrivate = true, $fz), "~N"); +c$.sortIntChar = Clazz.defineMethod (c$, "sortIntChar", +function (arr, s) { +var f1 = Clazz.newIntArray (arr.length, 0); +var s1 = Clazz.newCharArray (s.length, '\0'); +var nextZeroValue = 0; +var nextNonZeroValue = arr.length - 1; +for (var i = 0; i < arr.length; i++) { +var val = arr[i]; +if (val > 0) { +f1[nextNonZeroValue] = val; +s1[nextNonZeroValue] = s[i]; +nextNonZeroValue--; +} else { +f1[nextZeroValue] = val; +s1[nextZeroValue] = s[i]; +nextZeroValue++; +}} +System.arraycopy (f1, 0, arr, 0, nextZeroValue); +System.arraycopy (s1, 0, s, 0, nextZeroValue); +if (nextZeroValue == arr.length) { +return; +}var nonZeroInts = java.util.Arrays.copyOfRange (f1, nextZeroValue, f1.length); +var nonZeroChars = java.util.Arrays.copyOfRange (s1, nextZeroValue, s1.length); +jalview.util.QuickSort.externalSortInt (nonZeroInts, nonZeroChars); +System.arraycopy (nonZeroInts, 0, arr, nextZeroValue, nonZeroInts.length); +System.arraycopy (nonZeroChars, 0, s, nextZeroValue, nonZeroChars.length); +}, "~A,~A"); +c$.externalSortInt = Clazz.defineMethod (c$, "externalSortInt", +($fz = function (arr, s) { +var length = arr.length; +var indices = jalview.util.QuickSort.makeIndexArray (length); +java.util.Arrays.sort (indices, new jalview.util.QuickSort.IntComparator (arr)); +var sortedInts = Clazz.newIntArray (length, 0); +var sortedChars = Clazz.newCharArray (s.length, '\0'); +for (var i = 0; i < length; i++) { +sortedInts[i] = arr[indices[i]]; +sortedChars[i] = s[indices[i]]; +} +System.arraycopy (sortedInts, 0, arr, 0, length); +System.arraycopy (sortedChars, 0, s, 0, s.length); +}, $fz.isPrivate = true, $fz), "~A,~A"); +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.values = null; +Clazz.instantialize (this, arguments); +}, jalview.util.QuickSort, "FloatComparator", null, java.util.Comparator); +Clazz.makeConstructor (c$, +function (a) { +this.values = a; +}, "~A"); +Clazz.overrideMethod (c$, "compare", +function (a, b) { +return Float.compare (this.values[a.intValue ()], this.values[b]); +}, "Integer,Integer"); +c$ = Clazz.p0p (); +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.values = null; +Clazz.instantialize (this, arguments); +}, jalview.util.QuickSort, "IntComparator", null, java.util.Comparator); +Clazz.makeConstructor (c$, +function (a) { +this.values = a; +}, "~A"); +Clazz.overrideMethod (c$, "compare", +function (a, b) { +return Integer.compare (this.values[a], this.values[b]); +}, "Integer,Integer"); +c$ = Clazz.p0p (); +}); diff --git a/bin/jalview/util/ReverseListIterator.js b/bin/jalview/util/ReverseListIterator.js index 66e861f..f9edbc8 100644 --- a/bin/jalview/util/ReverseListIterator.js +++ b/bin/jalview/util/ReverseListIterator.js @@ -1,23 +1,23 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.util.Iterator"], "jalview.util.ReverseListIterator", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.iterator = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "ReverseListIterator", null, java.util.Iterator); -Clazz.makeConstructor (c$, -function (stuff) { -this.iterator = stuff.listIterator (stuff.size ()); -}, "java.util.List"); -Clazz.overrideMethod (c$, "hasNext", -function () { -return this.iterator.hasPrevious (); -}); -Clazz.overrideMethod (c$, "next", -function () { -return this.iterator.previous (); -}); -Clazz.overrideMethod (c$, "remove", -function () { -this.iterator.remove (); -}); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.util.Iterator"], "jalview.util.ReverseListIterator", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.iterator = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "ReverseListIterator", null, java.util.Iterator); +Clazz.makeConstructor (c$, +function (stuff) { +this.iterator = stuff.listIterator (stuff.size ()); +}, "java.util.List"); +Clazz.overrideMethod (c$, "hasNext", +function () { +return this.iterator.hasPrevious (); +}); +Clazz.overrideMethod (c$, "next", +function () { +return this.iterator.previous (); +}); +Clazz.overrideMethod (c$, "remove", +function () { +this.iterator.remove (); +}); +}); diff --git a/bin/jalview/util/ShiftList.js b/bin/jalview/util/ShiftList.js index 258fe14..29a9645 100644 --- a/bin/jalview/util/ShiftList.js +++ b/bin/jalview/util/ShiftList.js @@ -1,67 +1,67 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.ShiftList", ["java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.shifts = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "ShiftList"); -Clazz.makeConstructor (c$, -function () { -this.shifts = new java.util.ArrayList (); -}); -Clazz.defineMethod (c$, "addShift", -function (pos, shift) { -{ -var sidx = 0; -var rshift = null; -while (sidx < this.shifts.size () && (rshift = this.shifts.get (sidx))[0] < pos) { -sidx++; -} -if (sidx == this.shifts.size ()) { -this.shifts.add (sidx, Clazz.newIntArray (-1, [pos, shift])); -} else { -rshift[1] += shift; -}}}, "~N,~N"); -Clazz.defineMethod (c$, "shift", -function (pos) { -if (this.shifts.size () == 0) { -return pos; -}var shifted = pos; -var sidx = 0; -var rshift; -while (sidx < this.shifts.size () && (rshift = (this.shifts.get (sidx++)))[0] <= pos) { -shifted += rshift[1]; -} -return shifted; -}, "~N"); -Clazz.defineMethod (c$, "clear", -function () { -this.shifts.clear (); -}); -Clazz.defineMethod (c$, "getInverse", -function () { -var inverse = new jalview.util.ShiftList (); -{ -if (this.shifts != null) { -for (var sh, $sh = this.shifts.iterator (); $sh.hasNext () && ((sh = $sh.next ()) || true);) { -if (sh != null) { -inverse.shifts.add ( Clazz.newIntArray (-1, [sh[0], -sh[1]])); -}} -}}return inverse; -}); -c$.parseMap = Clazz.defineMethod (c$, "parseMap", -function (gapMap) { -var shiftList = null; -if (gapMap != null && gapMap.length > 0) { -shiftList = new jalview.util.ShiftList (); -for (var i = 0, p = 0; i < gapMap.length; p++, i++) { -if (p != gapMap[i]) { -shiftList.addShift (p, gapMap[i] - p); -p = gapMap[i]; -}} -}return shiftList; -}, "~A"); -Clazz.defineMethod (c$, "getShifts", -function () { -return this.shifts; -}); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.ShiftList", ["java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.shifts = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "ShiftList"); +Clazz.makeConstructor (c$, +function () { +this.shifts = new java.util.ArrayList (); +}); +Clazz.defineMethod (c$, "addShift", +function (pos, shift) { +{ +var sidx = 0; +var rshift = null; +while (sidx < this.shifts.size () && (rshift = this.shifts.get (sidx))[0] < pos) { +sidx++; +} +if (sidx == this.shifts.size ()) { +this.shifts.add (sidx, Clazz.newIntArray (-1, [pos, shift])); +} else { +rshift[1] += shift; +}}}, "~N,~N"); +Clazz.defineMethod (c$, "shift", +function (pos) { +if (this.shifts.size () == 0) { +return pos; +}var shifted = pos; +var sidx = 0; +var rshift; +while (sidx < this.shifts.size () && (rshift = (this.shifts.get (sidx++)))[0] <= pos) { +shifted += rshift[1]; +} +return shifted; +}, "~N"); +Clazz.defineMethod (c$, "clear", +function () { +this.shifts.clear (); +}); +Clazz.defineMethod (c$, "getInverse", +function () { +var inverse = new jalview.util.ShiftList (); +{ +if (this.shifts != null) { +for (var sh, $sh = this.shifts.iterator (); $sh.hasNext () && ((sh = $sh.next ()) || true);) { +if (sh != null) { +inverse.shifts.add ( Clazz.newIntArray (-1, [sh[0], -sh[1]])); +}} +}}return inverse; +}); +c$.parseMap = Clazz.defineMethod (c$, "parseMap", +function (gapMap) { +var shiftList = null; +if (gapMap != null && gapMap.length > 0) { +shiftList = new jalview.util.ShiftList (); +for (var i = 0, p = 0; i < gapMap.length; p++, i++) { +if (p != gapMap[i]) { +shiftList.addShift (p, gapMap[i] - p); +p = gapMap[i]; +}} +}return shiftList; +}, "~A"); +Clazz.defineMethod (c$, "getShifts", +function () { +return this.shifts; +}); +}); diff --git a/bin/jalview/util/StringUtils.js b/bin/jalview/util/StringUtils.js index 0b21437..fd878bf 100644 --- a/bin/jalview/util/StringUtils.js +++ b/bin/jalview/util/StringUtils.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.util.regex.Pattern"], "jalview.util.StringUtils", ["java.lang.StringBuffer", "java.util.ArrayList"], function () { -c$ = Clazz.declareType (jalview.util, "StringUtils"); -c$.insertCharAt = Clazz.defineMethod (c$, "insertCharAt", -function ($in, position, count, ch) { -var tmp = Clazz.newCharArray ($in.length + count, '\0'); -if (position >= $in.length) { -System.arraycopy ($in, 0, tmp, 0, $in.length); -position = $in.length; -} else { -System.arraycopy ($in, 0, tmp, 0, position); -}var index = position; -while (count > 0) { -tmp[index++] = ch; -count--; -} -if (position < $in.length) { -System.arraycopy ($in, position, tmp, index, $in.length - position); -}return tmp; -}, "~A,~N,~N,~S"); -c$.deleteChars = Clazz.defineMethod (c$, "deleteChars", -function ($in, from, to) { -if (from >= $in.length || from < 0) { -return $in; -}var tmp; -if (to >= $in.length) { -tmp = Clazz.newCharArray (from, '\0'); -System.arraycopy ($in, 0, tmp, 0, from); -to = $in.length; -} else { -tmp = Clazz.newCharArray ($in.length - to + from, '\0'); -System.arraycopy ($in, 0, tmp, 0, from); -System.arraycopy ($in, to, tmp, from, $in.length - to); -}return tmp; -}, "~A,~N,~N"); -c$.getLastToken = Clazz.defineMethod (c$, "getLastToken", -function (input, token) { -if (input == null) { -return null; -}if (token == null) { -return input; -}var st = input.$plit (token); -return st[st.length - 1]; -}, "~S,~S"); -c$.separatorListToArray = Clazz.defineMethod (c$, "separatorListToArray", -function (input, delimiter) { -var seplen = delimiter.length; -if (input == null || input.equals ("") || input.equals (delimiter)) { -return null; -}var jv = new java.util.ArrayList (); -var cp = 0; -var pos; -var escape; -var wasescaped = false; -var wasquoted = false; -var lstitem = null; -while ((pos = input.indexOf (delimiter, cp)) >= cp) { -escape = (pos > 0 && input.charAt (pos - 1) == '\\') ? -1 : 0; -if (wasescaped || wasquoted) { -jv.set (jv.size () - 1, lstitem = lstitem + delimiter + input.substring (cp, pos + escape)); -} else { -jv.add (lstitem = input.substring (cp, pos + escape)); -}cp = pos + seplen; -wasescaped = escape == -1; -wasquoted = jalview.util.StringUtils.DELIMITERS_PATTERN.matcher (lstitem).matches (); -} -if (cp < input.length) { -var c = input.substring (cp); -if (wasescaped || wasquoted) { -jv.set (jv.size () - 1, lstitem + delimiter + c); -} else { -if (!c.equals (delimiter)) { -jv.add (c); -}}}if (jv.size () > 0) { -var v = jv.toArray ( new Array (jv.size ())); -jv.clear (); -if (false) { -System.err.println ("Array from '" + delimiter + "' separated List:\n" + v.length); -for (var i = 0; i < v.length; i++) { -System.err.println ("item " + i + " '" + v[i] + "'"); -} -}return v; -}if (false) { -System.err.println ("Empty Array from '" + delimiter + "' separated List"); -}return null; -}, "~S,~S"); -c$.arrayToSeparatorList = Clazz.defineMethod (c$, "arrayToSeparatorList", -function (list, separator) { -var v = new StringBuffer (); -if (list != null && list.length > 0) { -for (var i = 0, iSize = list.length; i < iSize; i++) { -if (list[i] != null) { -if (v.length () > 0) { -v.append (separator); -}v.append (list[i]); -}} -if (false) { -System.err.println ("Returning '" + separator + "' separated List:\n"); -System.err.println (v); -}return v.toString (); -}if (false) { -System.err.println ("Returning empty '" + separator + "' separated List\n"); -}return "" + separator; -}, "~A,~S"); -c$.DELIMITERS_PATTERN = c$.prototype.DELIMITERS_PATTERN = java.util.regex.Pattern.compile (".*='[^']*(?!')"); -Clazz.defineStatics (c$, -"DEBUG", false); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.util.regex.Pattern"], "jalview.util.StringUtils", ["java.lang.StringBuffer", "java.util.ArrayList"], function () { +c$ = Clazz.declareType (jalview.util, "StringUtils"); +c$.insertCharAt = Clazz.defineMethod (c$, "insertCharAt", +function ($in, position, count, ch) { +var tmp = Clazz.newCharArray ($in.length + count, '\0'); +if (position >= $in.length) { +System.arraycopy ($in, 0, tmp, 0, $in.length); +position = $in.length; +} else { +System.arraycopy ($in, 0, tmp, 0, position); +}var index = position; +while (count > 0) { +tmp[index++] = ch; +count--; +} +if (position < $in.length) { +System.arraycopy ($in, position, tmp, index, $in.length - position); +}return tmp; +}, "~A,~N,~N,~S"); +c$.deleteChars = Clazz.defineMethod (c$, "deleteChars", +function ($in, from, to) { +if (from >= $in.length || from < 0) { +return $in; +}var tmp; +if (to >= $in.length) { +tmp = Clazz.newCharArray (from, '\0'); +System.arraycopy ($in, 0, tmp, 0, from); +to = $in.length; +} else { +tmp = Clazz.newCharArray ($in.length - to + from, '\0'); +System.arraycopy ($in, 0, tmp, 0, from); +System.arraycopy ($in, to, tmp, from, $in.length - to); +}return tmp; +}, "~A,~N,~N"); +c$.getLastToken = Clazz.defineMethod (c$, "getLastToken", +function (input, token) { +if (input == null) { +return null; +}if (token == null) { +return input; +}var st = input.$plit (token); +return st[st.length - 1]; +}, "~S,~S"); +c$.separatorListToArray = Clazz.defineMethod (c$, "separatorListToArray", +function (input, delimiter) { +var seplen = delimiter.length; +if (input == null || input.equals ("") || input.equals (delimiter)) { +return null; +}var jv = new java.util.ArrayList (); +var cp = 0; +var pos; +var escape; +var wasescaped = false; +var wasquoted = false; +var lstitem = null; +while ((pos = input.indexOf (delimiter, cp)) >= cp) { +escape = (pos > 0 && input.charAt (pos - 1) == '\\') ? -1 : 0; +if (wasescaped || wasquoted) { +jv.set (jv.size () - 1, lstitem = lstitem + delimiter + input.substring (cp, pos + escape)); +} else { +jv.add (lstitem = input.substring (cp, pos + escape)); +}cp = pos + seplen; +wasescaped = escape == -1; +wasquoted = jalview.util.StringUtils.DELIMITERS_PATTERN.matcher (lstitem).matches (); +} +if (cp < input.length) { +var c = input.substring (cp); +if (wasescaped || wasquoted) { +jv.set (jv.size () - 1, lstitem + delimiter + c); +} else { +if (!c.equals (delimiter)) { +jv.add (c); +}}}if (jv.size () > 0) { +var v = jv.toArray ( new Array (jv.size ())); +jv.clear (); +if (false) { +System.err.println ("Array from '" + delimiter + "' separated List:\n" + v.length); +for (var i = 0; i < v.length; i++) { +System.err.println ("item " + i + " '" + v[i] + "'"); +} +}return v; +}if (false) { +System.err.println ("Empty Array from '" + delimiter + "' separated List"); +}return null; +}, "~S,~S"); +c$.arrayToSeparatorList = Clazz.defineMethod (c$, "arrayToSeparatorList", +function (list, separator) { +var v = new StringBuffer (); +if (list != null && list.length > 0) { +for (var i = 0, iSize = list.length; i < iSize; i++) { +if (list[i] != null) { +if (v.length () > 0) { +v.append (separator); +}v.append (list[i]); +}} +if (false) { +System.err.println ("Returning '" + separator + "' separated List:\n"); +System.err.println (v); +}return v.toString (); +}if (false) { +System.err.println ("Returning empty '" + separator + "' separated List\n"); +}return "" + separator; +}, "~A,~S"); +c$.DELIMITERS_PATTERN = c$.prototype.DELIMITERS_PATTERN = java.util.regex.Pattern.compile (".*='[^']*(?!')"); +Clazz.defineStatics (c$, +"DEBUG", false); +}); diff --git a/bin/jalview/util/TableSorter.js b/bin/jalview/util/TableSorter.js index dcc7fea..44ff978 100644 --- a/bin/jalview/util/TableSorter.js +++ b/bin/jalview/util/TableSorter.js @@ -1,387 +1,387 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (["java.awt.event.MouseAdapter", "javax.swing.Icon", "javax.swing.event.TableModelListener", "javax.swing.table.AbstractTableModel", "$.TableCellRenderer", "java.util.ArrayList", "$.HashMap"], "jalview.util.TableSorter", ["java.awt.Color", "java.util.Arrays", "javax.swing.JLabel", "javax.swing.event.TableModelEvent"], function () { -c$ = Clazz.decorateAsClass (function () { -this.tableModel = null; -this.viewToModel = null; -this.modelToView = null; -this.tableHeader = null; -this.mouseListener = null; -this.tableModelListener = null; -this.columnComparators = null; -this.sortingColumns = null; -if (!Clazz.isClassDefined ("jalview.util.TableSorter.Row")) { -jalview.util.TableSorter.$TableSorter$Row$ (); -} -if (!Clazz.isClassDefined ("jalview.util.TableSorter.TableModelHandler")) { -jalview.util.TableSorter.$TableSorter$TableModelHandler$ (); -} -if (!Clazz.isClassDefined ("jalview.util.TableSorter.MouseHandler")) { -jalview.util.TableSorter.$TableSorter$MouseHandler$ (); -} -if (!Clazz.isClassDefined ("jalview.util.TableSorter.SortableHeaderRenderer")) { -jalview.util.TableSorter.$TableSorter$SortableHeaderRenderer$ (); -} -Clazz.instantialize (this, arguments); -}, jalview.util, "TableSorter", javax.swing.table.AbstractTableModel); -Clazz.prepareFields (c$, function () { -this.columnComparators = new java.util.HashMap (); -this.sortingColumns = new java.util.ArrayList (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.util.TableSorter, []); -this.mouseListener = Clazz.innerTypeInstance (jalview.util.TableSorter.MouseHandler, this, null); -this.tableModelListener = Clazz.innerTypeInstance (jalview.util.TableSorter.TableModelHandler, this, null); -}); -Clazz.makeConstructor (c$, -function (tableModel) { -this.construct (); -this.setTableModel (tableModel); -}, "javax.swing.table.TableModel"); -Clazz.makeConstructor (c$, -function (tableModel, tableHeader) { -this.construct (); -this.setTableHeader (tableHeader); -this.setTableModel (tableModel); -}, "javax.swing.table.TableModel,javax.swing.table.JTableHeader"); -Clazz.defineMethod (c$, "clearSortingState", -($fz = function () { -this.viewToModel = null; -this.modelToView = null; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getTableModel", -function () { -return this.tableModel; -}); -Clazz.defineMethod (c$, "setTableModel", -function (tableModel) { -if (this.tableModel != null) { -this.tableModel.removeTableModelListener (this.tableModelListener); -}this.tableModel = tableModel; -if (this.tableModel != null) { -this.tableModel.addTableModelListener (this.tableModelListener); -}this.clearSortingState (); -this.fireTableStructureChanged (); -}, "javax.swing.table.TableModel"); -Clazz.defineMethod (c$, "getTableHeader", -function () { -return this.tableHeader; -}); -Clazz.defineMethod (c$, "setTableHeader", -function (tableHeader) { -if (this.tableHeader != null) { -this.tableHeader.removeMouseListener (this.mouseListener); -var defaultRenderer = this.tableHeader.getDefaultRenderer (); -if (Clazz.instanceOf (defaultRenderer, jalview.util.TableSorter.SortableHeaderRenderer)) { -this.tableHeader.setDefaultRenderer ((defaultRenderer).tableCellRenderer); -}}this.tableHeader = tableHeader; -if (this.tableHeader != null) { -this.tableHeader.addMouseListener (this.mouseListener); -this.tableHeader.setDefaultRenderer (Clazz.innerTypeInstance (jalview.util.TableSorter.SortableHeaderRenderer, this, null, this.tableHeader.getDefaultRenderer ())); -}}, "javax.swing.table.JTableHeader"); -Clazz.defineMethod (c$, "isSorting", -function () { -return this.sortingColumns.size () != 0; -}); -Clazz.defineMethod (c$, "getDirective", -($fz = function (column) { -for (var i = 0; i < this.sortingColumns.size (); i++) { -var directive = this.sortingColumns.get (i); -if (directive.column == column) { -return directive; -}} -return jalview.util.TableSorter.EMPTY_DIRECTIVE; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "getSortingStatus", -function (column) { -return this.getDirective (column).direction; -}, "~N"); -Clazz.defineMethod (c$, "sortingStatusChanged", -($fz = function () { -this.clearSortingState (); -this.fireTableDataChanged (); -if (this.tableHeader != null) { -this.tableHeader.repaint (); -}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "setSortingStatus", -function (column, status) { -var directive = this.getDirective (column); -if (directive !== jalview.util.TableSorter.EMPTY_DIRECTIVE) { -this.sortingColumns.remove (directive); -}if (status != 0) { -this.sortingColumns.add ( new jalview.util.TableSorter.Directive (column, status)); -}this.sortingStatusChanged (); -}, "~N,~N"); -Clazz.defineMethod (c$, "getHeaderRendererIcon", -function (column, size) { -var directive = this.getDirective (column); -if (directive === jalview.util.TableSorter.EMPTY_DIRECTIVE) { -return null; -}return new jalview.util.TableSorter.Arrow (directive.direction == -1, size, this.sortingColumns.indexOf (directive)); -}, "~N,~N"); -Clazz.defineMethod (c$, "cancelSorting", -($fz = function () { -this.sortingColumns.clear (); -this.sortingStatusChanged (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "setColumnComparator", -function (type, comparator) { -if (comparator == null) { -this.columnComparators.remove (type); -} else { -this.columnComparators.put (type, comparator); -}}, "Class,java.util.Comparator"); -Clazz.defineMethod (c$, "getComparator", -function (column) { -var columnType = this.tableModel.getColumnClass (column); -var comparator = this.columnComparators.get (columnType); -if (comparator != null) { -return comparator; -}if (Comparable.isAssignableFrom (columnType)) { -return jalview.util.TableSorter.COMPARABLE_COMAPRATOR; -}return jalview.util.TableSorter.LEXICAL_COMPARATOR; -}, "~N"); -Clazz.defineMethod (c$, "getViewToModel", -($fz = function () { -if (this.viewToModel == null) { -var tableModelRowCount = this.tableModel.getRowCount (); -this.viewToModel = new Array (tableModelRowCount); -for (var row = 0; row < tableModelRowCount; row++) { -this.viewToModel[row] = Clazz.innerTypeInstance (jalview.util.TableSorter.Row, this, null, row); -} -if (this.isSorting ()) { -java.util.Arrays.sort (this.viewToModel); -}}return this.viewToModel; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "modelIndex", -function (viewIndex) { -return this.getViewToModel ()[viewIndex].modelIndex; -}, "~N"); -Clazz.defineMethod (c$, "getModelToView", -($fz = function () { -if (this.modelToView == null) { -var n = this.getViewToModel ().length; -this.modelToView = Clazz.newIntArray (n, 0); -for (var i = 0; i < n; i++) { -this.modelToView[this.modelIndex (i)] = i; -} -}return this.modelToView; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getRowCount", -function () { -return (this.tableModel == null) ? 0 : this.tableModel.getRowCount (); -}); -Clazz.defineMethod (c$, "getColumnCount", -function () { -return (this.tableModel == null) ? 0 : this.tableModel.getColumnCount (); -}); -Clazz.overrideMethod (c$, "getColumnName", -function (column) { -return this.tableModel.getColumnName (column); -}, "~N"); -Clazz.overrideMethod (c$, "getColumnClass", -function (column) { -return this.tableModel.getColumnClass (column); -}, "~N"); -Clazz.overrideMethod (c$, "isCellEditable", -function (row, column) { -return this.tableModel.isCellEditable (this.modelIndex (row), column); -}, "~N,~N"); -Clazz.defineMethod (c$, "getValueAt", -function (row, column) { -return this.tableModel.getValueAt (this.modelIndex (row), column); -}, "~N,~N"); -Clazz.overrideMethod (c$, "setValueAt", -function (aValue, row, column) { -this.tableModel.setValueAt (aValue, this.modelIndex (row), column); -}, "~O,~N,~N"); -c$.$TableSorter$Row$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.modelIndex = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "Row", null, Comparable); -Clazz.makeConstructor (c$, -function (a) { -this.modelIndex = a; -}, "~N"); -Clazz.overrideMethod (c$, "compareTo", -function (a) { -var b = this.modelIndex; -var c = (a).modelIndex; -for (var d = this.b$["jalview.util.TableSorter"].sortingColumns.iterator (); d.hasNext (); ) { -var e = d.next (); -var f = e.column; -var g = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (b, f); -var h = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (c, f); -var i = 0; -if (g == null && h == null) { -i = 0; -} else if (g == null) { -i = -1; -} else if (h == null) { -i = 1; -} else { -i = this.b$["jalview.util.TableSorter"].getComparator (f).compare (g, h); -}if (i != 0) { -return e.direction == -1 ? -i : i; -}} -return 0; -}, "~O"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$TableModelHandler$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "TableModelHandler", null, javax.swing.event.TableModelListener); -Clazz.overrideMethod (c$, "tableChanged", -function (a) { -if (!this.b$["jalview.util.TableSorter"].isSorting ()) { -this.b$["jalview.util.TableSorter"].clearSortingState (); -this.b$["jalview.util.TableSorter"].fireTableChanged (a); -return; -}if (a.getFirstRow () == -1) { -this.b$["jalview.util.TableSorter"].cancelSorting (); -this.b$["jalview.util.TableSorter"].fireTableChanged (a); -return; -}var b = a.getColumn (); -if (a.getFirstRow () == a.getLastRow () && b != -1 && this.b$["jalview.util.TableSorter"].getSortingStatus (b) == 0 && this.b$["jalview.util.TableSorter"].modelToView != null) { -var c = this.b$["jalview.util.TableSorter"].getModelToView ()[a.getFirstRow ()]; -this.b$["jalview.util.TableSorter"].fireTableChanged ( new javax.swing.event.TableModelEvent (this.b$["jalview.util.TableSorter"], c, c, b, a.getType ())); -return; -}this.b$["jalview.util.TableSorter"].clearSortingState (); -this.b$["jalview.util.TableSorter"].fireTableDataChanged (); -return; -}, "javax.swing.event.TableModelEvent"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$MouseHandler$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "MouseHandler", java.awt.event.MouseAdapter); -Clazz.overrideMethod (c$, "mouseClicked", -function (a) { -var b = a.getSource (); -var c = b.getColumnModel (); -var d = c.getColumnIndexAtX (a.getX ()); -var e = c.getColumn (d).getModelIndex (); -if (e != -1) { -var f = this.b$["jalview.util.TableSorter"].getSortingStatus (e); -if (!a.isControlDown ()) { -this.b$["jalview.util.TableSorter"].cancelSorting (); -}f = f + (a.isShiftDown () ? -1 : 1); -f = (f + 4) % 3 - 1; -this.b$["jalview.util.TableSorter"].setSortingStatus (e, f); -}}, "java.awt.event.MouseEvent"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$SortableHeaderRenderer$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.tableCellRenderer = null; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "SortableHeaderRenderer", null, javax.swing.table.TableCellRenderer); -Clazz.makeConstructor (c$, -function (a) { -this.tableCellRenderer = a; -}, "javax.swing.table.TableCellRenderer"); -Clazz.defineMethod (c$, "getTableCellRendererComponent", -function (a, b, c, d, e, f) { -var g = this.tableCellRenderer.getTableCellRendererComponent (a, b, c, d, e, f); -if (Clazz.instanceOf (g, javax.swing.JLabel)) { -var h = g; -h.setHorizontalTextPosition (2); -var i = a.convertColumnIndexToModel (f); -h.setIcon (this.b$["jalview.util.TableSorter"].getHeaderRendererIcon (i, h.getFont ().getSize ())); -}return g; -}, "javax.swing.JTable,~O,~B,~B,~N,~N"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$1", null, java.util.Comparator); -Clazz.defineMethod (c$, "compare", -function (o1, o2) { -return (o1).compareTo (o2); -}, "~O,~O"); -c$ = Clazz.p0p (); -}; -c$.$TableSorter$2$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$2", null, java.util.Comparator); -Clazz.defineMethod (c$, "compare", -function (o1, o2) { -return o1.toString ().compareTo (o2.toString ()); -}, "~O,~O"); -c$ = Clazz.p0p (); -}; -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.descending = false; -this.size = 0; -this.priority = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "Arrow", null, javax.swing.Icon); -Clazz.makeConstructor (c$, -function (a, b, c) { -this.descending = a; -this.size = b; -this.priority = c; -}, "~B,~N,~N"); -Clazz.overrideMethod (c$, "paintIcon", -function (a, b, c, d) { -var e = a == null ? java.awt.Color.GRAY : a.getBackground (); -var f = Clazz.doubleToInt (Clazz.doubleToInt (this.size / 2) * Math.pow (0.8, this.priority)); -var g = this.descending ? f : -f; -d = d + Clazz.doubleToInt (5 * this.size / 6) + (this.descending ? -g : 0); -var h = this.descending ? 1 : -1; -b.translate (c, d); -b.setColor (e.darker ()); -b.drawLine (Clazz.doubleToInt (f / 2), g, 0, 0); -b.drawLine (Clazz.doubleToInt (f / 2), g + h, 0, h); -b.setColor (e.brighter ()); -b.drawLine (Clazz.doubleToInt (f / 2), g, f, 0); -b.drawLine (Clazz.doubleToInt (f / 2), g + h, f, h); -if (this.descending) { -b.setColor (e.darker ().darker ()); -} else { -b.setColor (e.brighter ().brighter ()); -}b.drawLine (f, 0, 0, 0); -b.setColor (e); -b.translate (-c, -d); -}, "java.awt.Component,java.awt.Graphics,~N,~N"); -Clazz.overrideMethod (c$, "getIconWidth", -function () { -return this.size; -}); -Clazz.overrideMethod (c$, "getIconHeight", -function () { -return this.size; -}); -c$ = Clazz.p0p (); -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -this.column = 0; -this.direction = 0; -Clazz.instantialize (this, arguments); -}, jalview.util.TableSorter, "Directive"); -Clazz.makeConstructor (c$, -function (a, b) { -this.column = a; -this.direction = b; -}, "~N,~N"); -c$ = Clazz.p0p (); -Clazz.defineStatics (c$, -"DESCENDING", -1, -"NOT_SORTED", 0, -"ASCENDING", 1); -c$.EMPTY_DIRECTIVE = c$.prototype.EMPTY_DIRECTIVE = new jalview.util.TableSorter.Directive (-1, 0); -c$.COMPARABLE_COMAPRATOR = c$.prototype.COMPARABLE_COMAPRATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$1") ? 0 : jalview.util.TableSorter.$TableSorter$1$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$1, this, null)); -c$.LEXICAL_COMPARATOR = c$.prototype.LEXICAL_COMPARATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$2") ? 0 : jalview.util.TableSorter.$TableSorter$2$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$2, this, null)); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (["java.awt.event.MouseAdapter", "javax.swing.Icon", "javax.swing.event.TableModelListener", "javax.swing.table.AbstractTableModel", "$.TableCellRenderer", "java.util.ArrayList", "$.HashMap"], "jalview.util.TableSorter", ["java.awt.Color", "java.util.Arrays", "javax.swing.JLabel", "javax.swing.event.TableModelEvent"], function () { +c$ = Clazz.decorateAsClass (function () { +this.tableModel = null; +this.viewToModel = null; +this.modelToView = null; +this.tableHeader = null; +this.mouseListener = null; +this.tableModelListener = null; +this.columnComparators = null; +this.sortingColumns = null; +if (!Clazz.isClassDefined ("jalview.util.TableSorter.Row")) { +jalview.util.TableSorter.$TableSorter$Row$ (); +} +if (!Clazz.isClassDefined ("jalview.util.TableSorter.TableModelHandler")) { +jalview.util.TableSorter.$TableSorter$TableModelHandler$ (); +} +if (!Clazz.isClassDefined ("jalview.util.TableSorter.MouseHandler")) { +jalview.util.TableSorter.$TableSorter$MouseHandler$ (); +} +if (!Clazz.isClassDefined ("jalview.util.TableSorter.SortableHeaderRenderer")) { +jalview.util.TableSorter.$TableSorter$SortableHeaderRenderer$ (); +} +Clazz.instantialize (this, arguments); +}, jalview.util, "TableSorter", javax.swing.table.AbstractTableModel); +Clazz.prepareFields (c$, function () { +this.columnComparators = new java.util.HashMap (); +this.sortingColumns = new java.util.ArrayList (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.util.TableSorter, []); +this.mouseListener = Clazz.innerTypeInstance (jalview.util.TableSorter.MouseHandler, this, null); +this.tableModelListener = Clazz.innerTypeInstance (jalview.util.TableSorter.TableModelHandler, this, null); +}); +Clazz.makeConstructor (c$, +function (tableModel) { +this.construct (); +this.setTableModel (tableModel); +}, "javax.swing.table.TableModel"); +Clazz.makeConstructor (c$, +function (tableModel, tableHeader) { +this.construct (); +this.setTableHeader (tableHeader); +this.setTableModel (tableModel); +}, "javax.swing.table.TableModel,javax.swing.table.JTableHeader"); +Clazz.defineMethod (c$, "clearSortingState", +($fz = function () { +this.viewToModel = null; +this.modelToView = null; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getTableModel", +function () { +return this.tableModel; +}); +Clazz.defineMethod (c$, "setTableModel", +function (tableModel) { +if (this.tableModel != null) { +this.tableModel.removeTableModelListener (this.tableModelListener); +}this.tableModel = tableModel; +if (this.tableModel != null) { +this.tableModel.addTableModelListener (this.tableModelListener); +}this.clearSortingState (); +this.fireTableStructureChanged (); +}, "javax.swing.table.TableModel"); +Clazz.defineMethod (c$, "getTableHeader", +function () { +return this.tableHeader; +}); +Clazz.defineMethod (c$, "setTableHeader", +function (tableHeader) { +if (this.tableHeader != null) { +this.tableHeader.removeMouseListener (this.mouseListener); +var defaultRenderer = this.tableHeader.getDefaultRenderer (); +if (Clazz.instanceOf (defaultRenderer, jalview.util.TableSorter.SortableHeaderRenderer)) { +this.tableHeader.setDefaultRenderer ((defaultRenderer).tableCellRenderer); +}}this.tableHeader = tableHeader; +if (this.tableHeader != null) { +this.tableHeader.addMouseListener (this.mouseListener); +this.tableHeader.setDefaultRenderer (Clazz.innerTypeInstance (jalview.util.TableSorter.SortableHeaderRenderer, this, null, this.tableHeader.getDefaultRenderer ())); +}}, "javax.swing.table.JTableHeader"); +Clazz.defineMethod (c$, "isSorting", +function () { +return this.sortingColumns.size () != 0; +}); +Clazz.defineMethod (c$, "getDirective", +($fz = function (column) { +for (var i = 0; i < this.sortingColumns.size (); i++) { +var directive = this.sortingColumns.get (i); +if (directive.column == column) { +return directive; +}} +return jalview.util.TableSorter.EMPTY_DIRECTIVE; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "getSortingStatus", +function (column) { +return this.getDirective (column).direction; +}, "~N"); +Clazz.defineMethod (c$, "sortingStatusChanged", +($fz = function () { +this.clearSortingState (); +this.fireTableDataChanged (); +if (this.tableHeader != null) { +this.tableHeader.repaint (); +}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "setSortingStatus", +function (column, status) { +var directive = this.getDirective (column); +if (directive !== jalview.util.TableSorter.EMPTY_DIRECTIVE) { +this.sortingColumns.remove (directive); +}if (status != 0) { +this.sortingColumns.add ( new jalview.util.TableSorter.Directive (column, status)); +}this.sortingStatusChanged (); +}, "~N,~N"); +Clazz.defineMethod (c$, "getHeaderRendererIcon", +function (column, size) { +var directive = this.getDirective (column); +if (directive === jalview.util.TableSorter.EMPTY_DIRECTIVE) { +return null; +}return new jalview.util.TableSorter.Arrow (directive.direction == -1, size, this.sortingColumns.indexOf (directive)); +}, "~N,~N"); +Clazz.defineMethod (c$, "cancelSorting", +($fz = function () { +this.sortingColumns.clear (); +this.sortingStatusChanged (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "setColumnComparator", +function (type, comparator) { +if (comparator == null) { +this.columnComparators.remove (type); +} else { +this.columnComparators.put (type, comparator); +}}, "Class,java.util.Comparator"); +Clazz.defineMethod (c$, "getComparator", +function (column) { +var columnType = this.tableModel.getColumnClass (column); +var comparator = this.columnComparators.get (columnType); +if (comparator != null) { +return comparator; +}if (Comparable.isAssignableFrom (columnType)) { +return jalview.util.TableSorter.COMPARABLE_COMAPRATOR; +}return jalview.util.TableSorter.LEXICAL_COMPARATOR; +}, "~N"); +Clazz.defineMethod (c$, "getViewToModel", +($fz = function () { +if (this.viewToModel == null) { +var tableModelRowCount = this.tableModel.getRowCount (); +this.viewToModel = new Array (tableModelRowCount); +for (var row = 0; row < tableModelRowCount; row++) { +this.viewToModel[row] = Clazz.innerTypeInstance (jalview.util.TableSorter.Row, this, null, row); +} +if (this.isSorting ()) { +java.util.Arrays.sort (this.viewToModel); +}}return this.viewToModel; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "modelIndex", +function (viewIndex) { +return this.getViewToModel ()[viewIndex].modelIndex; +}, "~N"); +Clazz.defineMethod (c$, "getModelToView", +($fz = function () { +if (this.modelToView == null) { +var n = this.getViewToModel ().length; +this.modelToView = Clazz.newIntArray (n, 0); +for (var i = 0; i < n; i++) { +this.modelToView[this.modelIndex (i)] = i; +} +}return this.modelToView; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getRowCount", +function () { +return (this.tableModel == null) ? 0 : this.tableModel.getRowCount (); +}); +Clazz.defineMethod (c$, "getColumnCount", +function () { +return (this.tableModel == null) ? 0 : this.tableModel.getColumnCount (); +}); +Clazz.overrideMethod (c$, "getColumnName", +function (column) { +return this.tableModel.getColumnName (column); +}, "~N"); +Clazz.overrideMethod (c$, "getColumnClass", +function (column) { +return this.tableModel.getColumnClass (column); +}, "~N"); +Clazz.overrideMethod (c$, "isCellEditable", +function (row, column) { +return this.tableModel.isCellEditable (this.modelIndex (row), column); +}, "~N,~N"); +Clazz.defineMethod (c$, "getValueAt", +function (row, column) { +return this.tableModel.getValueAt (this.modelIndex (row), column); +}, "~N,~N"); +Clazz.overrideMethod (c$, "setValueAt", +function (aValue, row, column) { +this.tableModel.setValueAt (aValue, this.modelIndex (row), column); +}, "~O,~N,~N"); +c$.$TableSorter$Row$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.modelIndex = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "Row", null, Comparable); +Clazz.makeConstructor (c$, +function (a) { +this.modelIndex = a; +}, "~N"); +Clazz.overrideMethod (c$, "compareTo", +function (a) { +var b = this.modelIndex; +var c = (a).modelIndex; +for (var d = this.b$["jalview.util.TableSorter"].sortingColumns.iterator (); d.hasNext (); ) { +var e = d.next (); +var f = e.column; +var g = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (b, f); +var h = this.b$["jalview.util.TableSorter"].tableModel.getValueAt (c, f); +var i = 0; +if (g == null && h == null) { +i = 0; +} else if (g == null) { +i = -1; +} else if (h == null) { +i = 1; +} else { +i = this.b$["jalview.util.TableSorter"].getComparator (f).compare (g, h); +}if (i != 0) { +return e.direction == -1 ? -i : i; +}} +return 0; +}, "~O"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$TableModelHandler$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "TableModelHandler", null, javax.swing.event.TableModelListener); +Clazz.overrideMethod (c$, "tableChanged", +function (a) { +if (!this.b$["jalview.util.TableSorter"].isSorting ()) { +this.b$["jalview.util.TableSorter"].clearSortingState (); +this.b$["jalview.util.TableSorter"].fireTableChanged (a); +return; +}if (a.getFirstRow () == -1) { +this.b$["jalview.util.TableSorter"].cancelSorting (); +this.b$["jalview.util.TableSorter"].fireTableChanged (a); +return; +}var b = a.getColumn (); +if (a.getFirstRow () == a.getLastRow () && b != -1 && this.b$["jalview.util.TableSorter"].getSortingStatus (b) == 0 && this.b$["jalview.util.TableSorter"].modelToView != null) { +var c = this.b$["jalview.util.TableSorter"].getModelToView ()[a.getFirstRow ()]; +this.b$["jalview.util.TableSorter"].fireTableChanged ( new javax.swing.event.TableModelEvent (this.b$["jalview.util.TableSorter"], c, c, b, a.getType ())); +return; +}this.b$["jalview.util.TableSorter"].clearSortingState (); +this.b$["jalview.util.TableSorter"].fireTableDataChanged (); +return; +}, "javax.swing.event.TableModelEvent"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$MouseHandler$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "MouseHandler", java.awt.event.MouseAdapter); +Clazz.overrideMethod (c$, "mouseClicked", +function (a) { +var b = a.getSource (); +var c = b.getColumnModel (); +var d = c.getColumnIndexAtX (a.getX ()); +var e = c.getColumn (d).getModelIndex (); +if (e != -1) { +var f = this.b$["jalview.util.TableSorter"].getSortingStatus (e); +if (!a.isControlDown ()) { +this.b$["jalview.util.TableSorter"].cancelSorting (); +}f = f + (a.isShiftDown () ? -1 : 1); +f = (f + 4) % 3 - 1; +this.b$["jalview.util.TableSorter"].setSortingStatus (e, f); +}}, "java.awt.event.MouseEvent"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$SortableHeaderRenderer$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.tableCellRenderer = null; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "SortableHeaderRenderer", null, javax.swing.table.TableCellRenderer); +Clazz.makeConstructor (c$, +function (a) { +this.tableCellRenderer = a; +}, "javax.swing.table.TableCellRenderer"); +Clazz.defineMethod (c$, "getTableCellRendererComponent", +function (a, b, c, d, e, f) { +var g = this.tableCellRenderer.getTableCellRendererComponent (a, b, c, d, e, f); +if (Clazz.instanceOf (g, javax.swing.JLabel)) { +var h = g; +h.setHorizontalTextPosition (2); +var i = a.convertColumnIndexToModel (f); +h.setIcon (this.b$["jalview.util.TableSorter"].getHeaderRendererIcon (i, h.getFont ().getSize ())); +}return g; +}, "javax.swing.JTable,~O,~B,~B,~N,~N"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$1", null, java.util.Comparator); +Clazz.defineMethod (c$, "compare", +function (o1, o2) { +return (o1).compareTo (o2); +}, "~O,~O"); +c$ = Clazz.p0p (); +}; +c$.$TableSorter$2$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (jalview.util, "TableSorter$2", null, java.util.Comparator); +Clazz.defineMethod (c$, "compare", +function (o1, o2) { +return o1.toString ().compareTo (o2.toString ()); +}, "~O,~O"); +c$ = Clazz.p0p (); +}; +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.descending = false; +this.size = 0; +this.priority = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "Arrow", null, javax.swing.Icon); +Clazz.makeConstructor (c$, +function (a, b, c) { +this.descending = a; +this.size = b; +this.priority = c; +}, "~B,~N,~N"); +Clazz.overrideMethod (c$, "paintIcon", +function (a, b, c, d) { +var e = a == null ? java.awt.Color.GRAY : a.getBackground (); +var f = Clazz.doubleToInt (Clazz.doubleToInt (this.size / 2) * Math.pow (0.8, this.priority)); +var g = this.descending ? f : -f; +d = d + Clazz.doubleToInt (5 * this.size / 6) + (this.descending ? -g : 0); +var h = this.descending ? 1 : -1; +b.translate (c, d); +b.setColor (e.darker ()); +b.drawLine (Clazz.doubleToInt (f / 2), g, 0, 0); +b.drawLine (Clazz.doubleToInt (f / 2), g + h, 0, h); +b.setColor (e.brighter ()); +b.drawLine (Clazz.doubleToInt (f / 2), g, f, 0); +b.drawLine (Clazz.doubleToInt (f / 2), g + h, f, h); +if (this.descending) { +b.setColor (e.darker ().darker ()); +} else { +b.setColor (e.brighter ().brighter ()); +}b.drawLine (f, 0, 0, 0); +b.setColor (e); +b.translate (-c, -d); +}, "java.awt.Component,java.awt.Graphics,~N,~N"); +Clazz.overrideMethod (c$, "getIconWidth", +function () { +return this.size; +}); +Clazz.overrideMethod (c$, "getIconHeight", +function () { +return this.size; +}); +c$ = Clazz.p0p (); +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +this.column = 0; +this.direction = 0; +Clazz.instantialize (this, arguments); +}, jalview.util.TableSorter, "Directive"); +Clazz.makeConstructor (c$, +function (a, b) { +this.column = a; +this.direction = b; +}, "~N,~N"); +c$ = Clazz.p0p (); +Clazz.defineStatics (c$, +"DESCENDING", -1, +"NOT_SORTED", 0, +"ASCENDING", 1); +c$.EMPTY_DIRECTIVE = c$.prototype.EMPTY_DIRECTIVE = new jalview.util.TableSorter.Directive (-1, 0); +c$.COMPARABLE_COMAPRATOR = c$.prototype.COMPARABLE_COMAPRATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$1") ? 0 : jalview.util.TableSorter.$TableSorter$1$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$1, this, null)); +c$.LEXICAL_COMPARATOR = c$.prototype.LEXICAL_COMPARATOR = ((Clazz.isClassDefined ("jalview.util.TableSorter$2") ? 0 : jalview.util.TableSorter.$TableSorter$2$ ()), Clazz.innerTypeInstance (jalview.util.TableSorter$2, this, null)); +}); diff --git a/bin/jalview/util/UrlLink.js b/bin/jalview/util/UrlLink.js index a28894b..c50c6ae 100644 --- a/bin/jalview/util/UrlLink.js +++ b/bin/jalview/util/UrlLink.js @@ -1,148 +1,148 @@ -Clazz.declarePackage ("jalview.util"); -Clazz.load (null, "jalview.util.UrlLink", ["jalview.jsdev.RegExp", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.url_suffix = null; -this.url_prefix = null; -this.target = null; -this.label = null; -this.regexReplace = null; -this.dynamic = false; -this.invalidMessage = null; -Clazz.instantialize (this, arguments); -}, jalview.util, "UrlLink"); -Clazz.makeConstructor (c$, -function (link) { -var sep = link.indexOf ("|"); -var psqid = link.indexOf ("$SEQUENCE_ID"); -if (psqid > -1) { -this.dynamic = true; -var p = sep; -do { -sep = p; -p = link.indexOf ("|", sep + 1); -} while (p > sep && p < psqid); -this.label = link.substring (0, sep); -if (this.label.indexOf ("|") > -1) { -this.target = this.label.substring (0, this.label.indexOf ("|")); -} else if (this.label.indexOf (" ") > 2) { -this.target = this.label.substring (0, this.label.indexOf (" ")); -} else { -this.target = this.label; -}this.url_prefix = link.substring (sep + 1, psqid); -if (link.indexOf ("$SEQUENCE_ID=/") == psqid && (p = link.indexOf ("/=$", psqid + 14)) > psqid + 14) { -this.url_suffix = link.substring (p + 3); -this.regexReplace = link.substring (psqid + 14, p); -try { -var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/"); -if (rg == null) { -this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n"; -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n"; -} else { -throw e; -} -} -} else { -this.regexReplace = null; -if (link.indexOf ("$SEQUENCE_ID$") == psqid) { -this.url_suffix = link.substring (psqid + 13); -this.regexReplace = null; -} else { -this.invalidMessage = "Warning: invalid regex structure for URL link : " + link; -}}} else { -this.target = link.substring (0, sep); -this.label = link.substring (0, sep = link.lastIndexOf ("|")); -this.url_prefix = link.substring (sep + 1); -this.regexReplace = null; -this.url_suffix = null; -}}, "~S"); -Clazz.defineMethod (c$, "getUrl_suffix", -function () { -return this.url_suffix; -}); -Clazz.defineMethod (c$, "getUrl_prefix", -function () { -return this.url_prefix; -}); -Clazz.defineMethod (c$, "getTarget", -function () { -return this.target; -}); -Clazz.defineMethod (c$, "getLabel", -function () { -return this.label; -}); -Clazz.defineMethod (c$, "getRegexReplace", -function () { -return this.regexReplace; -}); -Clazz.defineMethod (c$, "getInvalidMessage", -function () { -return this.invalidMessage; -}); -Clazz.defineMethod (c$, "isValid", -function () { -return this.invalidMessage == null; -}); -Clazz.defineMethod (c$, "makeUrls", -function (idstring, onlyIfMatches) { -if (this.dynamic) { -if (this.regexReplace != null) { -var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/"); -if (rg.search (idstring)) { -var ns = rg.numSubs (); -if (ns == 0) { -return Clazz.newArray (-1, [rg.stringMatchedI (ns), this.url_prefix + rg.stringMatched () + this.url_suffix]); -} else { -for (var s = 0; s <= rg.numSubs (); s++) { -System.err.println ("Sub " + s + " : " + rg.matchedFromI (s) + " : " + rg.matchedToI (s) + " : '" + rg.stringMatchedI (s) + "'"); -} -var subs = new java.util.Vector (); -var s = 0; -while (s <= ns) { -if (s + 1 <= ns && rg.matchedToI (s) > -1 && rg.matchedToI (s + 1) > -1 && rg.matchedToI (s + 1) < rg.matchedToI (s)) { -var r = s + 1; -var mtch = ""; -while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) { -if (rg.matchedFromI (r) > -1) { -mtch += rg.stringMatchedI (r); -}r++; -} -if (mtch.length > 0) { -subs.addElement (mtch); -subs.addElement (this.url_prefix + mtch + this.url_suffix); -}s = r; -} else { -if (rg.matchedFromI (s) > -1) { -subs.addElement (rg.stringMatchedI (s)); -subs.addElement (this.url_prefix + rg.stringMatchedI (s) + this.url_suffix); -}s++; -}} -var res = new Array (subs.size ()); -for (var r = 0, rs = subs.size (); r < rs; r++) { -res[r] = subs.elementAt (r); -} -subs.removeAllElements (); -return res; -}}if (onlyIfMatches) { -return null; -}}if (idstring.indexOf ("|") > -1) { -idstring = idstring.substring (idstring.lastIndexOf ("|") + 1); -}return Clazz.newArray (-1, [idstring, this.url_prefix + idstring + this.url_suffix]); -} else { -return Clazz.newArray (-1, ["", this.url_prefix]); -}}, "~S,~B"); -Clazz.overrideMethod (c$, "toString", -function () { -return this.label + "|" + this.url_prefix + (this.dynamic ? ("$SEQUENCE_ID" + ((this.regexReplace != null) ? "=" + this.regexReplace + "=$" : "$")) : "") + ((this.url_suffix == null) ? "" : this.url_suffix); -}); -Clazz.defineMethod (c$, "isDynamic", -function () { -return this.dynamic; -}); -Clazz.defineMethod (c$, "setLabel", -function (newlabel) { -this.label = newlabel; -}, "~S"); -}); +Clazz.declarePackage ("jalview.util"); +Clazz.load (null, "jalview.util.UrlLink", ["jalview.jsdev.RegExp", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.url_suffix = null; +this.url_prefix = null; +this.target = null; +this.label = null; +this.regexReplace = null; +this.dynamic = false; +this.invalidMessage = null; +Clazz.instantialize (this, arguments); +}, jalview.util, "UrlLink"); +Clazz.makeConstructor (c$, +function (link) { +var sep = link.indexOf ("|"); +var psqid = link.indexOf ("$SEQUENCE_ID"); +if (psqid > -1) { +this.dynamic = true; +var p = sep; +do { +sep = p; +p = link.indexOf ("|", sep + 1); +} while (p > sep && p < psqid); +this.label = link.substring (0, sep); +if (this.label.indexOf ("|") > -1) { +this.target = this.label.substring (0, this.label.indexOf ("|")); +} else if (this.label.indexOf (" ") > 2) { +this.target = this.label.substring (0, this.label.indexOf (" ")); +} else { +this.target = this.label; +}this.url_prefix = link.substring (sep + 1, psqid); +if (link.indexOf ("$SEQUENCE_ID=/") == psqid && (p = link.indexOf ("/=$", psqid + 14)) > psqid + 14) { +this.url_suffix = link.substring (p + 3); +this.regexReplace = link.substring (psqid + 14, p); +try { +var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/"); +if (rg == null) { +this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n"; +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +this.invalidMessage = "Invalid Regular Expression : '" + this.regexReplace + "'\n"; +} else { +throw e; +} +} +} else { +this.regexReplace = null; +if (link.indexOf ("$SEQUENCE_ID$") == psqid) { +this.url_suffix = link.substring (psqid + 13); +this.regexReplace = null; +} else { +this.invalidMessage = "Warning: invalid regex structure for URL link : " + link; +}}} else { +this.target = link.substring (0, sep); +this.label = link.substring (0, sep = link.lastIndexOf ("|")); +this.url_prefix = link.substring (sep + 1); +this.regexReplace = null; +this.url_suffix = null; +}}, "~S"); +Clazz.defineMethod (c$, "getUrl_suffix", +function () { +return this.url_suffix; +}); +Clazz.defineMethod (c$, "getUrl_prefix", +function () { +return this.url_prefix; +}); +Clazz.defineMethod (c$, "getTarget", +function () { +return this.target; +}); +Clazz.defineMethod (c$, "getLabel", +function () { +return this.label; +}); +Clazz.defineMethod (c$, "getRegexReplace", +function () { +return this.regexReplace; +}); +Clazz.defineMethod (c$, "getInvalidMessage", +function () { +return this.invalidMessage; +}); +Clazz.defineMethod (c$, "isValid", +function () { +return this.invalidMessage == null; +}); +Clazz.defineMethod (c$, "makeUrls", +function (idstring, onlyIfMatches) { +if (this.dynamic) { +if (this.regexReplace != null) { +var rg = jalview.jsdev.RegExp.perlCode ("/" + this.regexReplace + "/"); +if (rg.search (idstring)) { +var ns = rg.numSubs (); +if (ns == 0) { +return Clazz.newArray (-1, [rg.stringMatchedI (ns), this.url_prefix + rg.stringMatched () + this.url_suffix]); +} else { +for (var s = 0; s <= rg.numSubs (); s++) { +System.err.println ("Sub " + s + " : " + rg.matchedFromI (s) + " : " + rg.matchedToI (s) + " : '" + rg.stringMatchedI (s) + "'"); +} +var subs = new java.util.Vector (); +var s = 0; +while (s <= ns) { +if (s + 1 <= ns && rg.matchedToI (s) > -1 && rg.matchedToI (s + 1) > -1 && rg.matchedToI (s + 1) < rg.matchedToI (s)) { +var r = s + 1; +var mtch = ""; +while (r <= ns && rg.matchedToI (r) <= rg.matchedToI (s)) { +if (rg.matchedFromI (r) > -1) { +mtch += rg.stringMatchedI (r); +}r++; +} +if (mtch.length > 0) { +subs.addElement (mtch); +subs.addElement (this.url_prefix + mtch + this.url_suffix); +}s = r; +} else { +if (rg.matchedFromI (s) > -1) { +subs.addElement (rg.stringMatchedI (s)); +subs.addElement (this.url_prefix + rg.stringMatchedI (s) + this.url_suffix); +}s++; +}} +var res = new Array (subs.size ()); +for (var r = 0, rs = subs.size (); r < rs; r++) { +res[r] = subs.elementAt (r); +} +subs.removeAllElements (); +return res; +}}if (onlyIfMatches) { +return null; +}}if (idstring.indexOf ("|") > -1) { +idstring = idstring.substring (idstring.lastIndexOf ("|") + 1); +}return Clazz.newArray (-1, [idstring, this.url_prefix + idstring + this.url_suffix]); +} else { +return Clazz.newArray (-1, ["", this.url_prefix]); +}}, "~S,~B"); +Clazz.overrideMethod (c$, "toString", +function () { +return this.label + "|" + this.url_prefix + (this.dynamic ? ("$SEQUENCE_ID" + ((this.regexReplace != null) ? "=" + this.regexReplace + "=$" : "$")) : "") + ((this.url_suffix == null) ? "" : this.url_suffix); +}); +Clazz.defineMethod (c$, "isDynamic", +function () { +return this.dynamic; +}); +Clazz.defineMethod (c$, "setLabel", +function (newlabel) { +this.label = newlabel; +}, "~S"); +}); diff --git a/bin/jalview/viewmodel/AlignmentViewport.js b/bin/jalview/viewmodel/AlignmentViewport.js index cdbd489..6f07731 100644 --- a/bin/jalview/viewmodel/AlignmentViewport.js +++ b/bin/jalview/viewmodel/AlignmentViewport.js @@ -1,1254 +1,1254 @@ -Clazz.declarePackage ("jalview.viewmodel"); -Clazz.load (["jalview.api.AlignViewportI", "jalview.structure.CommandListener", "$.VamsasSource", "jalview.datamodel.ColumnSelection", "jalview.viewmodel.styles.ViewStyle", "jalview.workers.AlignCalcManager", "java.beans.PropertyChangeSupport", "java.util.ArrayDeque", "$.HashMap"], "jalview.viewmodel.AlignmentViewport", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.AlignmentView", "$.CigarArray", "$.Sequence", "$.SequenceGroup", "jalview.schemes.Blosum62ColourScheme", "$.PIDColourScheme", "$.ResidueProperties", "jalview.util.Comparison", "$.MappingUtils", "jalview.workers.ComplementConsensusThread", "$.ConsensusThread", "$.ConservationThread", "$.StrucConsensusThread", "java.awt.Color", "java.util.ArrayList", "$.BitSet", "$.Hashtable"], function () { -c$ = Clazz.decorateAsClass (function () { -this.viewStyle = null; -this.codingComplement = null; -this.featuresDisplayed = null; -this.historyList = null; -this.redoList = null; -this.alignment = null; -this.sequenceSetID = null; -this.$isDataset = false; -this.hiddenRepSequences = null; -this.colSel = null; -this.autoCalculateConsensus = true; -this.autoCalculateStrucConsensus = true; -this.ignoreGapsInConsensusCalculation = false; -this.globalColourScheme = null; -this.consensus = null; -this.complementConsensus = null; -this.strucConsensus = null; -this.conservation = null; -this.quality = null; -this.groupConsensus = null; -this.groupConservation = null; -this.hconsensus = null; -this.hcomplementConsensus = null; -this.hStrucConsensus = null; -this.hconservation = null; -this.ConsPercGaps = 25; -this.calculator = null; -this.showGroupConservation = false; -this.showGroupConsensus = false; -this.showSequenceLogo = false; -this.normaliseSequenceLogo = false; -this.showConsensusHistogram = true; -this.padGaps = false; -this.sortByTree = false; -this.selectionGroup = null; -this.viewId = null; -this.sgrouphash = -1; -this.colselhash = -1; -this.changeSupport = null; -this.showConservation = true; -this.showQuality = true; -this.showConsensus = true; -this.sequenceColours = null; -this.sortAnnotationsBy = null; -this.showAutocalculatedAbove = false; -this.followHighlight = true; -this.startRes = 0; -this.endRes = 0; -this.startSeq = 0; -this.endSeq = 0; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel, "AlignmentViewport", null, [jalview.api.AlignViewportI, jalview.structure.CommandListener, jalview.structure.VamsasSource]); -Clazz.prepareFields (c$, function () { -this.viewStyle = new jalview.viewmodel.styles.ViewStyle (); -this.historyList = new java.util.ArrayDeque (); -this.redoList = new java.util.ArrayDeque (); -this.colSel = new jalview.datamodel.ColumnSelection (); -this.calculator = new jalview.workers.AlignCalcManager (); -this.changeSupport = new java.beans.PropertyChangeSupport (this); -this.sequenceColours = new java.util.HashMap (); -}); -Clazz.defineMethod (c$, "setFontName", -function (name) { -this.viewStyle.setFontName (name); -}, "~S"); -Clazz.defineMethod (c$, "setFontStyle", -function (style) { -this.viewStyle.setFontStyle (style); -}, "~N"); -Clazz.defineMethod (c$, "setFontSize", -function (size) { -this.viewStyle.setFontSize (size); -}, "~N"); -Clazz.defineMethod (c$, "getFontStyle", -function () { -return this.viewStyle.getFontStyle (); -}); -Clazz.defineMethod (c$, "getFontName", -function () { -return this.viewStyle.getFontName (); -}); -Clazz.defineMethod (c$, "getFontSize", -function () { -return this.viewStyle.getFontSize (); -}); -Clazz.defineMethod (c$, "setUpperCasebold", -function (upperCasebold) { -this.viewStyle.setUpperCasebold (upperCasebold); -}, "~B"); -Clazz.defineMethod (c$, "isUpperCasebold", -function () { -return this.viewStyle.isUpperCasebold (); -}); -Clazz.defineMethod (c$, "isSeqNameItalics", -function () { -return this.viewStyle.isSeqNameItalics (); -}); -Clazz.defineMethod (c$, "setColourByReferenceSeq", -function (colourByReferenceSeq) { -this.viewStyle.setColourByReferenceSeq (colourByReferenceSeq); -}, "~B"); -Clazz.defineMethod (c$, "setColourAppliesToAllGroups", -function (b) { -this.viewStyle.setColourAppliesToAllGroups (b); -}, "~B"); -Clazz.defineMethod (c$, "getColourAppliesToAllGroups", -function () { -return this.viewStyle.getColourAppliesToAllGroups (); -}); -Clazz.defineMethod (c$, "getAbovePIDThreshold", -function () { -return this.viewStyle.getAbovePIDThreshold (); -}); -Clazz.defineMethod (c$, "setIncrement", -function (inc) { -this.viewStyle.setIncrement (inc); -}, "~N"); -Clazz.defineMethod (c$, "getIncrement", -function () { -return this.viewStyle.getIncrement (); -}); -Clazz.defineMethod (c$, "setConservationSelected", -function (b) { -this.viewStyle.setConservationSelected (b); -}, "~B"); -Clazz.defineMethod (c$, "setShowHiddenMarkers", -function (show) { -this.viewStyle.setShowHiddenMarkers (show); -}, "~B"); -Clazz.defineMethod (c$, "getShowHiddenMarkers", -function () { -return this.viewStyle.getShowHiddenMarkers (); -}); -Clazz.defineMethod (c$, "setScaleRightWrapped", -function (b) { -this.viewStyle.setScaleRightWrapped (b); -}, "~B"); -Clazz.defineMethod (c$, "setScaleLeftWrapped", -function (b) { -this.viewStyle.setScaleLeftWrapped (b); -}, "~B"); -Clazz.defineMethod (c$, "setScaleAboveWrapped", -function (b) { -this.viewStyle.setScaleAboveWrapped (b); -}, "~B"); -Clazz.defineMethod (c$, "getScaleLeftWrapped", -function () { -return this.viewStyle.getScaleLeftWrapped (); -}); -Clazz.defineMethod (c$, "getScaleAboveWrapped", -function () { -return this.viewStyle.getScaleAboveWrapped (); -}); -Clazz.defineMethod (c$, "getScaleRightWrapped", -function () { -return this.viewStyle.getScaleRightWrapped (); -}); -Clazz.defineMethod (c$, "setAbovePIDThreshold", -function (b) { -this.viewStyle.setAbovePIDThreshold (b); -}, "~B"); -Clazz.defineMethod (c$, "setThreshold", -function (thresh) { -this.viewStyle.setThreshold (thresh); -}, "~N"); -Clazz.defineMethod (c$, "getThreshold", -function () { -return this.viewStyle.getThreshold (); -}); -Clazz.defineMethod (c$, "getShowJVSuffix", -function () { -return this.viewStyle.getShowJVSuffix (); -}); -Clazz.defineMethod (c$, "setShowJVSuffix", -function (b) { -this.viewStyle.setShowJVSuffix (b); -}, "~B"); -Clazz.defineMethod (c$, "setWrapAlignment", -function (state) { -this.viewStyle.setWrapAlignment (state); -}, "~B"); -Clazz.defineMethod (c$, "setShowText", -function (state) { -this.viewStyle.setShowText (state); -}, "~B"); -Clazz.defineMethod (c$, "setRenderGaps", -function (state) { -this.viewStyle.setRenderGaps (state); -}, "~B"); -Clazz.defineMethod (c$, "getColourText", -function () { -return this.viewStyle.getColourText (); -}); -Clazz.defineMethod (c$, "setColourText", -function (state) { -this.viewStyle.setColourText (state); -}, "~B"); -Clazz.defineMethod (c$, "getWrapAlignment", -function () { -return this.viewStyle.getWrapAlignment (); -}); -Clazz.defineMethod (c$, "getShowText", -function () { -return this.viewStyle.getShowText (); -}); -Clazz.defineMethod (c$, "getWrappedWidth", -function () { -return this.viewStyle.getWrappedWidth (); -}); -Clazz.defineMethod (c$, "setWrappedWidth", -function (w) { -this.viewStyle.setWrappedWidth (w); -}, "~N"); -Clazz.defineMethod (c$, "getCharHeight", -function () { -return this.viewStyle.getCharHeight (); -}); -Clazz.defineMethod (c$, "setCharHeight", -function (h) { -this.viewStyle.setCharHeight (h); -}, "~N"); -Clazz.defineMethod (c$, "getCharWidth", -function () { -return this.viewStyle.getCharWidth (); -}); -Clazz.defineMethod (c$, "setCharWidth", -function (w) { -this.viewStyle.setCharWidth (w); -}, "~N"); -Clazz.defineMethod (c$, "getShowBoxes", -function () { -return this.viewStyle.getShowBoxes (); -}); -Clazz.defineMethod (c$, "getShowUnconserved", -function () { -return this.viewStyle.getShowUnconserved (); -}); -Clazz.defineMethod (c$, "setShowUnconserved", -function (showunconserved) { -this.viewStyle.setShowUnconserved (showunconserved); -}, "~B"); -Clazz.defineMethod (c$, "setSeqNameItalics", -function (default1) { -this.viewStyle.setSeqNameItalics (default1); -}, "~B"); -Clazz.defineMethod (c$, "getAlignment", -function () { -return this.alignment; -}); -Clazz.overrideMethod (c$, "getGapCharacter", -function () { -return this.alignment.getGapCharacter (); -}); -Clazz.defineMethod (c$, "setDataset", -function (b) { -this.$isDataset = b; -}, "~B"); -Clazz.defineMethod (c$, "isDataset", -function () { -return this.$isDataset; -}); -Clazz.overrideMethod (c$, "setGlobalColourScheme", -function (cs) { -this.globalColourScheme = cs; -var recalc = false; -if (cs != null) { -cs.setConservationApplied (recalc = this.getConservationSelected ()); -if (this.getAbovePIDThreshold () || Clazz.instanceOf (cs, jalview.schemes.PIDColourScheme) || Clazz.instanceOf (cs, jalview.schemes.Blosum62ColourScheme)) { -recalc = true; -cs.setThreshold (this.viewStyle.getThreshold (), this.ignoreGapsInConsensusCalculation); -} else { -cs.setThreshold (0, this.ignoreGapsInConsensusCalculation); -}if (recalc) { -cs.setConsensus (this.hconsensus); -cs.setConservation (this.hconservation); -}cs.alignmentChanged (this.alignment, this.hiddenRepSequences); -}if (this.getColourAppliesToAllGroups ()) { -for (var sg, $sg = this.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (cs == null) { -sg.cs = null; -continue; -}sg.cs = cs.applyTo (sg, this.getHiddenRepSequences ()); -sg.setConsPercGaps (this.ConsPercGaps); -if (this.getAbovePIDThreshold () || Clazz.instanceOf (cs, jalview.schemes.PIDColourScheme) || Clazz.instanceOf (cs, jalview.schemes.Blosum62ColourScheme)) { -sg.cs.setThreshold (this.viewStyle.getThreshold (), this.isIgnoreGapsConsensus ()); -recalc = true; -} else { -sg.cs.setThreshold (0, this.isIgnoreGapsConsensus ()); -}if (this.getConservationSelected ()) { -sg.cs.setConservationApplied (true); -recalc = true; -} else { -sg.cs.setConservation (null); -}if (recalc) { -sg.recalcConservation (); -} else { -sg.cs.alignmentChanged (sg, this.hiddenRepSequences); -}} -}}, "jalview.schemes.ColourSchemeI"); -Clazz.overrideMethod (c$, "getGlobalColourScheme", -function () { -return this.globalColourScheme; -}); -Clazz.overrideMethod (c$, "setConservation", -function (cons) { -this.hconservation = cons; -}, "jalview.analysis.Conservation"); -Clazz.overrideMethod (c$, "getConsPercGaps", -function () { -return this.ConsPercGaps; -}); -Clazz.overrideMethod (c$, "setSequenceConsensusHash", -function (hconsensus) { -this.hconsensus = hconsensus; -}, "~A"); -Clazz.overrideMethod (c$, "setComplementConsensusHash", -function (hconsensus) { -this.hcomplementConsensus = hconsensus; -}, "~A"); -Clazz.overrideMethod (c$, "getSequenceConsensusHash", -function () { -return this.hconsensus; -}); -Clazz.overrideMethod (c$, "getComplementConsensusHash", -function () { -return this.hcomplementConsensus; -}); -Clazz.overrideMethod (c$, "getRnaStructureConsensusHash", -function () { -return this.hStrucConsensus; -}); -Clazz.overrideMethod (c$, "setRnaStructureConsensusHash", -function (hStrucConsensus) { -this.hStrucConsensus = hStrucConsensus; -}, "~A"); -Clazz.overrideMethod (c$, "getAlignmentQualityAnnot", -function () { -return this.quality; -}); -Clazz.overrideMethod (c$, "getAlignmentConservationAnnotation", -function () { -return this.conservation; -}); -Clazz.overrideMethod (c$, "getAlignmentConsensusAnnotation", -function () { -return this.consensus; -}); -Clazz.overrideMethod (c$, "getComplementConsensusAnnotation", -function () { -return this.complementConsensus; -}); -Clazz.overrideMethod (c$, "getAlignmentStrucConsensusAnnotation", -function () { -return this.strucConsensus; -}); -Clazz.defineMethod (c$, "updateConservation", -function (ap) { -if (this.alignment.isNucleotide () || this.conservation == null || !this.autoCalculateConsensus) { -return; -}if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.ConservationThread) == null) { -this.calculator.registerWorker ( new jalview.workers.ConservationThread (this, ap)); -}}, "jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "updateConsensus", -function (ap) { -if (this.consensus == null || !this.autoCalculateConsensus) { -return; -}if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.ConsensusThread) == null) { -this.calculator.registerWorker ( new jalview.workers.ConsensusThread (this, ap)); -}var al = this.getAlignment (); -if (!al.isNucleotide () && al.getCodonFrames () != null && !al.getCodonFrames ().isEmpty ()) { -if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.ComplementConsensusThread) == null) { -this.calculator.registerWorker ( new jalview.workers.ComplementConsensusThread (this, ap)); -}}}, "jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "updateStrucConsensus", -function (ap) { -if (this.autoCalculateStrucConsensus && this.strucConsensus == null && this.alignment.isNucleotide () && this.alignment.hasRNAStructure ()) { -this.initRNAStructure (); -}if (this.strucConsensus == null || !this.autoCalculateStrucConsensus) { -return; -}if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.StrucConsensusThread) == null) { -this.calculator.registerWorker ( new jalview.workers.StrucConsensusThread (this, ap)); -}}, "jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "isCalcInProgress", -function () { -return this.calculator.isWorking (); -}); -Clazz.overrideMethod (c$, "isCalculationInProgress", -function (alignmentAnnotation) { -if (!alignmentAnnotation.autoCalculated) { -return false; -}if (this.calculator.workingInvolvedWith (alignmentAnnotation)) { -return true; -}return false; -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "isClosed", -function () { -return this.alignment == null; -}); -Clazz.overrideMethod (c$, "getCalcManager", -function () { -return this.calculator; -}); -Clazz.overrideMethod (c$, "isShowSequenceLogo", -function () { -return this.showSequenceLogo; -}); -Clazz.defineMethod (c$, "setShowSequenceLogo", -function (showSequenceLogo) { -if (showSequenceLogo != this.showSequenceLogo) { -this.showSequenceLogo = showSequenceLogo; -this.calculator.updateAnnotationFor (jalview.workers.ConsensusThread); -this.calculator.updateAnnotationFor (jalview.workers.ComplementConsensusThread); -this.calculator.updateAnnotationFor (jalview.workers.StrucConsensusThread); -}this.showSequenceLogo = showSequenceLogo; -}, "~B"); -Clazz.defineMethod (c$, "setShowConsensusHistogram", -function (showConsensusHistogram) { -this.showConsensusHistogram = showConsensusHistogram; -}, "~B"); -Clazz.defineMethod (c$, "isShowGroupConservation", -function () { -return this.showGroupConservation; -}); -Clazz.defineMethod (c$, "setShowGroupConservation", -function (showGroupConservation) { -this.showGroupConservation = showGroupConservation; -}, "~B"); -Clazz.defineMethod (c$, "isShowGroupConsensus", -function () { -return this.showGroupConsensus; -}); -Clazz.defineMethod (c$, "setShowGroupConsensus", -function (showGroupConsensus) { -this.showGroupConsensus = showGroupConsensus; -}, "~B"); -Clazz.overrideMethod (c$, "isShowConsensusHistogram", -function () { -return this.showConsensusHistogram; -}); -Clazz.overrideMethod (c$, "getSelectionGroup", -function () { -return this.selectionGroup; -}); -Clazz.overrideMethod (c$, "setSelectionGroup", -function (sg) { -this.selectionGroup = sg; -}, "jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "setHiddenColumns", -function (colsel) { -this.colSel = colsel; -}, "jalview.datamodel.ColumnSelection"); -Clazz.overrideMethod (c$, "getColumnSelection", -function () { -return this.colSel; -}); -Clazz.overrideMethod (c$, "setColumnSelection", -function (colSel) { -this.colSel = colSel; -if (colSel != null) { -this.updateHiddenColumns (); -}}, "jalview.datamodel.ColumnSelection"); -Clazz.overrideMethod (c$, "getHiddenRepSequences", -function () { -return this.hiddenRepSequences; -}); -Clazz.overrideMethod (c$, "setHiddenRepSequences", -function (hiddenRepSequences) { -this.hiddenRepSequences = hiddenRepSequences; -}, "java.util.Map"); -Clazz.overrideMethod (c$, "hasHiddenColumns", -function () { -return this.colSel != null && this.colSel.hasHiddenColumns (); -}); -Clazz.defineMethod (c$, "updateHiddenColumns", -function () { -}); -Clazz.overrideMethod (c$, "hasHiddenRows", -function () { -return this.alignment.getHiddenSequences ().getSize () > 0; -}); -Clazz.defineMethod (c$, "setSequenceSetId", -function (newid) { -if (this.sequenceSetID != null) { -System.err.println ("Warning - overwriting a sequenceSetId for a viewport!"); -}this.sequenceSetID = String.instantialize (newid); -}, "~S"); -Clazz.overrideMethod (c$, "getSequenceSetId", -function () { -if (this.sequenceSetID == null) { -this.sequenceSetID = this.alignment.hashCode () + ""; -}return this.sequenceSetID; -}); -Clazz.overrideMethod (c$, "getViewId", -function () { -if (this.viewId == null) { -this.viewId = this.getSequenceSetId () + "." + this.hashCode () + ""; -}return this.viewId; -}); -Clazz.defineMethod (c$, "setIgnoreGapsConsensus", -function (b, ap) { -this.ignoreGapsInConsensusCalculation = b; -if (ap != null) { -this.updateConsensus (ap); -if (this.globalColourScheme != null) { -this.globalColourScheme.setThreshold (this.globalColourScheme.getThreshold (), this.ignoreGapsInConsensusCalculation); -}}}, "~B,jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "isSelectionGroupChanged", -function (b) { -var hc = (this.selectionGroup == null || this.selectionGroup.getSize () == 0) ? -1 : this.selectionGroup.hashCode (); -if (hc != -1 && hc != this.sgrouphash) { -if (b) { -this.sgrouphash = hc; -}return true; -}return false; -}, "~B"); -Clazz.defineMethod (c$, "isColSelChanged", -function (b) { -var hc = (this.colSel == null || this.colSel.size () == 0) ? -1 : this.colSel.hashCode (); -if (hc != -1 && hc != this.colselhash) { -if (b) { -this.colselhash = hc; -}return true; -}return false; -}, "~B"); -Clazz.overrideMethod (c$, "isIgnoreGapsConsensus", -function () { -return this.ignoreGapsInConsensusCalculation; -}); -Clazz.defineMethod (c$, "addPropertyChangeListener", -function (listener) { -this.changeSupport.addPropertyChangeListener (listener); -}, "java.beans.PropertyChangeListener"); -Clazz.defineMethod (c$, "removePropertyChangeListener", -function (listener) { -this.changeSupport.removePropertyChangeListener (listener); -}, "java.beans.PropertyChangeListener"); -Clazz.defineMethod (c$, "firePropertyChange", -function (prop, oldvalue, newvalue) { -this.changeSupport.firePropertyChange (prop, oldvalue, newvalue); -}, "~S,~O,~O"); -Clazz.defineMethod (c$, "hideSelectedColumns", -function () { -if (this.colSel.size () < 1) { -return; -}this.colSel.hideSelectedColumns (); -this.setSelectionGroup (null); -}); -Clazz.defineMethod (c$, "hideColumns", -function (start, end) { -if (start == end) { -this.colSel.hideColumns (start); -} else { -this.colSel.hideColumns (start, end); -}}, "~N,~N"); -Clazz.defineMethod (c$, "showColumn", -function (col) { -this.colSel.revealHiddenColumns (col); -}, "~N"); -Clazz.defineMethod (c$, "showAllHiddenColumns", -function () { -this.colSel.revealAllHiddenColumns (); -}); -Clazz.defineMethod (c$, "showAllHiddenSeqs", -function () { -if (this.alignment.getHiddenSequences ().getSize () > 0) { -if (this.selectionGroup == null) { -this.selectionGroup = new jalview.datamodel.SequenceGroup (); -this.selectionGroup.setEndRes (this.alignment.getWidth () - 1); -}var tmp = this.alignment.getHiddenSequences ().showAll (this.hiddenRepSequences); -for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -this.selectionGroup.addSequence (seq, false); -this.setSequenceAnnotationsVisible (seq, true); -} -this.hiddenRepSequences = null; -this.firePropertyChange ("alignment", null, this.alignment.getSequences ()); -this.sendSelection (); -}}); -Clazz.defineMethod (c$, "showSequence", -function (index) { -var tmp = this.alignment.getHiddenSequences ().showSequence (index, this.hiddenRepSequences); -if (tmp.size () > 0) { -if (this.selectionGroup == null) { -this.selectionGroup = new jalview.datamodel.SequenceGroup (); -this.selectionGroup.setEndRes (this.alignment.getWidth () - 1); -}for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { -this.selectionGroup.addSequence (seq, false); -this.setSequenceAnnotationsVisible (seq, true); -} -this.firePropertyChange ("alignment", null, this.alignment.getSequences ()); -this.sendSelection (); -}}, "~N"); -Clazz.defineMethod (c$, "hideAllSelectedSeqs", -function () { -if (this.selectionGroup == null || this.selectionGroup.getSize () < 1) { -return; -}var seqs = this.selectionGroup.getSequencesInOrder (this.alignment); -this.hideSequence (seqs); -this.setSelectionGroup (null); -}); -Clazz.defineMethod (c$, "hideSequence", -function (seq) { -if (seq != null) { -for (var i = 0; i < seq.length; i++) { -this.alignment.getHiddenSequences ().hideSequence (seq[i]); -this.setSequenceAnnotationsVisible (seq[i], false); -} -this.firePropertyChange ("alignment", null, this.alignment.getSequences ()); -}}, "~A"); -Clazz.defineMethod (c$, "setSequenceAnnotationsVisible", -function (sequenceI, visible) { -for (var ann, $ann = 0, $$ann = this.alignment.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { -if (ann.sequenceRef === sequenceI) { -ann.visible = visible; -}} -}, "jalview.datamodel.SequenceI,~B"); -Clazz.defineMethod (c$, "hideRepSequences", -function (repSequence, sg) { -var sSize = sg.getSize (); -if (sSize < 2) { -return; -}if (this.hiddenRepSequences == null) { -this.hiddenRepSequences = new java.util.Hashtable (); -}this.hiddenRepSequences.put (repSequence, sg); -var seqs = new Array (sSize - 1); -var index = 0; -for (var i = 0; i < sSize; i++) { -if (sg.getSequenceAt (i) !== repSequence) { -if (index == sSize - 1) { -return; -}seqs[index++] = sg.getSequenceAt (i); -}} -sg.setSeqrep (repSequence); -sg.setHidereps (true); -this.hideSequence (seqs); -}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); -Clazz.defineMethod (c$, "isHiddenRepSequence", -function (seq) { -return this.alignment.getSeqrep () === seq || (this.hiddenRepSequences != null && this.hiddenRepSequences.containsKey (seq)); -}, "jalview.datamodel.SequenceI"); -Clazz.defineMethod (c$, "getRepresentedSequences", -function (seq) { -return (this.hiddenRepSequences == null ? null : this.hiddenRepSequences.get (seq)); -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "adjustForHiddenSeqs", -function (alignmentIndex) { -return this.alignment.getHiddenSequences ().adjustForHiddenSeqs (alignmentIndex); -}, "~N"); -Clazz.overrideMethod (c$, "invertColumnSelection", -function () { -this.colSel.invertColumnSelection (0, this.alignment.getWidth ()); -}); -Clazz.overrideMethod (c$, "getSelectionAsNewSequence", -function () { -var sequences; -if (this.selectionGroup == null || this.selectionGroup.getSize () == 0) { -sequences = this.alignment.getSequencesArray (); -var annots = this.alignment.getAlignmentAnnotation (); -for (var i = 0; i < sequences.length; i++) { -sequences[i] = new jalview.datamodel.Sequence (sequences[i], annots); -} -} else { -sequences = this.selectionGroup.getSelectionAsNewSequences (this.alignment); -}return sequences; -}); -Clazz.overrideMethod (c$, "getSequenceSelection", -function () { -var sequences = null; -if (this.selectionGroup != null) { -sequences = this.selectionGroup.getSequencesInOrder (this.alignment); -}if (sequences == null) { -sequences = this.alignment.getSequencesArray (); -}return sequences; -}); -Clazz.overrideMethod (c$, "getViewAsCigars", -function (selectedRegionOnly) { -return new jalview.datamodel.CigarArray (this.alignment, this.colSel, (selectedRegionOnly ? this.selectionGroup : null)); -}, "~B"); -Clazz.defineMethod (c$, "getAlignmentView", -function (selectedOnly) { -return this.getAlignmentView (selectedOnly, false); -}, "~B"); -Clazz.defineMethod (c$, "getAlignmentView", -function (selectedOnly, markGroups) { -return new jalview.datamodel.AlignmentView (this.alignment, this.colSel, this.selectionGroup, this.colSel != null && this.colSel.hasHiddenColumns (), selectedOnly, markGroups); -}, "~B,~B"); -Clazz.overrideMethod (c$, "getViewAsString", -function (selectedRegionOnly) { -var selection = null; -var seqs = null; -var i; -var iSize; -var start = 0; -var end = 0; -if (selectedRegionOnly && this.selectionGroup != null) { -iSize = this.selectionGroup.getSize (); -seqs = this.selectionGroup.getSequencesInOrder (this.alignment); -start = this.selectionGroup.getStartRes (); -end = this.selectionGroup.getEndRes () + 1; -} else { -iSize = this.alignment.getHeight (); -seqs = this.alignment.getSequencesArray (); -end = this.alignment.getWidth (); -}selection = new Array (iSize); -if (this.colSel != null && this.colSel.hasHiddenColumns ()) { -selection = this.colSel.getVisibleSequenceStrings (start, end, seqs); -} else { -for (i = 0; i < iSize; i++) { -selection[i] = seqs[i].getSequenceAsString (start, end); -} -}return selection; -}, "~B"); -Clazz.overrideMethod (c$, "getVisibleRegionBoundaries", -function (min, max) { -var regions = new java.util.ArrayList (); -var start = min; -var end = max; -do { -if (this.colSel != null && this.colSel.hasHiddenColumns ()) { -if (start == 0) { -start = this.colSel.adjustForHiddenColumns (start); -}end = this.colSel.getHiddenBoundaryRight (start); -if (start == end) { -end = max; -}if (end > max) { -end = max; -}}regions.add ( Clazz.newIntArray (-1, [start, end])); -if (this.colSel != null && this.colSel.hasHiddenColumns ()) { -start = this.colSel.adjustForHiddenColumns (end); -start = this.colSel.getHiddenBoundaryLeft (start) + 1; -}} while (end < max); -var startEnd = Clazz.newIntArray (regions.size (), 2, 0); -return regions; -}, "~N,~N"); -Clazz.overrideMethod (c$, "getVisibleAlignmentAnnotation", -function (selectedOnly) { -var ala = new java.util.ArrayList (); -var aa; -if ((aa = this.alignment.getAlignmentAnnotation ()) != null) { -for (var annot, $annot = 0, $$annot = aa; $annot < $$annot.length && ((annot = $$annot[$annot]) || true); $annot++) { -var clone = new jalview.datamodel.AlignmentAnnotation (annot); -if (selectedOnly && this.selectionGroup != null) { -this.colSel.makeVisibleAnnotation (this.selectionGroup.getStartRes (), this.selectionGroup.getEndRes (), clone); -} else { -this.colSel.makeVisibleAnnotation (clone); -}ala.add (clone); -} -}return ala; -}, "~B"); -Clazz.overrideMethod (c$, "isPadGaps", -function () { -return this.padGaps; -}); -Clazz.overrideMethod (c$, "setPadGaps", -function (padGaps) { -this.padGaps = padGaps; -}, "~B"); -Clazz.overrideMethod (c$, "alignmentChanged", -function (ap) { -if (this.isPadGaps ()) { -this.alignment.padGaps (); -}if (this.autoCalculateConsensus) { -this.updateConsensus (ap); -}if (this.hconsensus != null && this.autoCalculateConsensus) { -this.updateConservation (ap); -}if (this.autoCalculateStrucConsensus) { -this.updateStrucConsensus (ap); -}var alWidth = this.alignment.getWidth (); -var groups = this.alignment.getGroups (); -if (groups != null) { -for (var sg, $sg = groups.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.getEndRes () > alWidth) { -sg.setEndRes (alWidth - 1); -}} -}if (this.selectionGroup != null && this.selectionGroup.getEndRes () > alWidth) { -this.selectionGroup.setEndRes (alWidth - 1); -}this.resetAllColourSchemes (); -this.calculator.restartWorkers (); -}, "jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "resetAllColourSchemes", -function () { -var cs = this.globalColourScheme; -if (cs != null) { -cs.alignmentChanged (this.alignment, this.hiddenRepSequences); -cs.setConsensus (this.hconsensus); -if (cs.conservationApplied ()) { -cs.setConservation (jalview.analysis.Conservation.calculateConservation ("All", jalview.schemes.ResidueProperties.propHash, 3, this.alignment.getSequences (), 0, this.alignment.getWidth (), false, this.getConsPercGaps (), false)); -}}for (var sg, $sg = this.alignment.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.cs != null) { -sg.cs.alignmentChanged (sg, this.hiddenRepSequences); -}sg.recalcConservation (); -} -}); -Clazz.defineMethod (c$, "initAutoAnnotation", -function () { -if (this.hconsensus == null && !this.$isDataset) { -if (!this.alignment.isNucleotide ()) { -this.initConservation (); -this.initQuality (); -} else { -this.initRNAStructure (); -}this.consensus = new jalview.datamodel.AlignmentAnnotation ("Consensus", "PID", new Array (1), 0, 100, 1); -this.initConsensus (this.consensus); -this.initComplementConsensus (); -}}); -Clazz.defineMethod (c$, "initComplementConsensus", -function () { -if (!this.alignment.isNucleotide ()) { -var codonMappings = this.alignment.getCodonFrames (); -if (codonMappings != null && !codonMappings.isEmpty ()) { -this.complementConsensus = new jalview.datamodel.AlignmentAnnotation ("cDNA Consensus", "PID for cDNA", new Array (1), 0, 100, 1); -this.initConsensus (this.complementConsensus); -}}}); -Clazz.defineMethod (c$, "initConsensus", -($fz = function (aa) { -aa.hasText = true; -aa.autoCalculated = true; -if (this.showConsensus) { -this.alignment.addAnnotation (aa); -}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation"); -Clazz.defineMethod (c$, "initConservation", -($fz = function () { -if (this.showConservation) { -if (this.conservation == null) { -this.conservation = new jalview.datamodel.AlignmentAnnotation ("Conservation", "Conservation of total alignment less than " + this.getConsPercGaps () + "% gaps", new Array (1), 0, 11, 1); -this.conservation.hasText = true; -this.conservation.autoCalculated = true; -this.alignment.addAnnotation (this.conservation); -}}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "initQuality", -($fz = function () { -if (this.showQuality) { -if (this.quality == null) { -this.quality = new jalview.datamodel.AlignmentAnnotation ("Quality", "Alignment Quality based on Blosum62 scores", new Array (1), 0, 11, 1); -this.quality.hasText = true; -this.quality.autoCalculated = true; -this.alignment.addAnnotation (this.quality); -}}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "initRNAStructure", -($fz = function () { -if (this.alignment.hasRNAStructure () && this.strucConsensus == null) { -this.strucConsensus = new jalview.datamodel.AlignmentAnnotation ("StrucConsensus", "PID", new Array (1), 0, 100, 1); -this.strucConsensus.hasText = true; -this.strucConsensus.autoCalculated = true; -if (this.showConsensus) { -this.alignment.addAnnotation (this.strucConsensus); -}}}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "calcPanelHeight", -function () { -var anns = this.getAlignment ().getAlignmentAnnotation (); -var height = 0; -var charHeight = this.getCharHeight (); -if (anns != null) { -var graphgrp = new java.util.BitSet (); -for (var aa, $aa = 0, $$aa = anns; $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { -if (aa == null) { -System.err.println ("Null annotation row: ignoring."); -continue; -}if (!aa.visible) { -continue; -}if (aa.graphGroup > -1) { -if (graphgrp.get (aa.graphGroup)) { -continue; -} else { -graphgrp.set (aa.graphGroup); -}}aa.height = 0; -if (aa.hasText) { -aa.height += charHeight; -}if (aa.hasIcons) { -aa.height += 16; -}if (aa.graph > 0) { -aa.height += aa.graphHeight; -}if (aa.height == 0) { -aa.height = 20; -}height += aa.height; -} -}if (height == 0) { -height = 20; -}return height; -}); -Clazz.overrideMethod (c$, "updateGroupAnnotationSettings", -function (applyGlobalSettings, preserveNewGroupSettings) { -var updateCalcs = false; -var conv = this.isShowGroupConservation (); -var cons = this.isShowGroupConsensus (); -var showprf = this.isShowSequenceLogo (); -var showConsHist = this.isShowConsensusHistogram (); -var normLogo = this.isNormaliseSequenceLogo (); -var sortg = true; -var aan = this.alignment.getAlignmentAnnotation (); -var oldrfs = new java.util.ArrayList (); -if (aan != null) { -for (var an = 0; an < aan.length; an++) { -if (aan[an].autoCalculated && aan[an].groupRef != null) { -oldrfs.add (aan[an].groupRef); -this.alignment.deleteAnnotation (aan[an], false); -}} -}if (this.alignment.getGroups () != null) { -for (var sg, $sg = this.alignment.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -updateCalcs = false; -if (applyGlobalSettings || (!preserveNewGroupSettings && !oldrfs.contains (sg))) { -sg.setshowSequenceLogo (showprf); -sg.setShowConsensusHistogram (showConsHist); -sg.setNormaliseSequenceLogo (normLogo); -}if (conv) { -updateCalcs = true; -this.alignment.addAnnotation (sg.getConservationRow (), 0); -}if (cons) { -updateCalcs = true; -this.alignment.addAnnotation (sg.getConsensus (), 0); -}if (updateCalcs) { -sg.recalcConservation (); -}} -}oldrfs.clear (); -}, "~B,~B"); -Clazz.defineMethod (c$, "isDisplayReferenceSeq", -function () { -return this.alignment.hasSeqrep () && this.viewStyle.isDisplayReferenceSeq (); -}); -Clazz.defineMethod (c$, "setDisplayReferenceSeq", -function (displayReferenceSeq) { -this.viewStyle.setDisplayReferenceSeq (displayReferenceSeq); -}, "~B"); -Clazz.defineMethod (c$, "isColourByReferenceSeq", -function () { -return this.alignment.hasSeqrep () && this.viewStyle.isColourByReferenceSeq (); -}); -Clazz.overrideMethod (c$, "getSequenceColour", -function (seq) { -var sqc = this.sequenceColours.get (seq); -return (sqc == null ? java.awt.Color.white : sqc); -}, "jalview.datamodel.SequenceI"); -Clazz.overrideMethod (c$, "setSequenceColour", -function (seq, col) { -if (col == null) { -this.sequenceColours.remove (seq); -} else { -this.sequenceColours.put (seq, col); -}}, "jalview.datamodel.SequenceI,java.awt.Color"); -Clazz.overrideMethod (c$, "updateSequenceIdColours", -function () { -for (var sg, $sg = this.alignment.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { -if (sg.idColour != null) { -for (var s, $s = sg.getSequences (this.getHiddenRepSequences ()).iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { -this.sequenceColours.put (s, sg.idColour); -} -}} -}); -Clazz.overrideMethod (c$, "clearSequenceColours", -function () { -this.sequenceColours.clear (); -}); -Clazz.defineMethod (c$, "getCodingComplement", -function () { -return this.codingComplement; -}); -Clazz.defineMethod (c$, "setCodingComplement", -function (av) { -if (this === av) { -System.err.println ("Ignoring recursive setCodingComplement request"); -} else { -this.codingComplement = av; -if (av.getCodingComplement () !== this) { -av.setCodingComplement (this); -}}}, "jalview.api.AlignViewportI"); -Clazz.overrideMethod (c$, "isNucleotide", -function () { -return this.getAlignment () == null ? false : this.getAlignment ().isNucleotide (); -}); -Clazz.overrideMethod (c$, "getFeaturesDisplayed", -function () { -return this.featuresDisplayed; -}); -Clazz.overrideMethod (c$, "setFeaturesDisplayed", -function (featuresDisplayedI) { -this.featuresDisplayed = featuresDisplayedI; -}, "jalview.api.FeaturesDisplayedI"); -Clazz.overrideMethod (c$, "areFeaturesDisplayed", -function () { -return this.featuresDisplayed != null && this.featuresDisplayed.getRegisterdFeaturesCount () > 0; -}); -Clazz.defineMethod (c$, "setShowSequenceFeatures", -function (b) { -this.viewStyle.setShowSequenceFeatures (b); -}, "~B"); -Clazz.defineMethod (c$, "isShowSequenceFeatures", -function () { -return this.viewStyle.isShowSequenceFeatures (); -}); -Clazz.defineMethod (c$, "setShowSequenceFeaturesHeight", -function (selected) { -this.viewStyle.setShowSequenceFeaturesHeight (selected); -}, "~B"); -Clazz.defineMethod (c$, "isShowSequenceFeaturesHeight", -function () { -return this.viewStyle.isShowSequenceFeaturesHeight (); -}); -Clazz.defineMethod (c$, "setShowAnnotation", -function (b) { -this.viewStyle.setShowAnnotation (b); -}, "~B"); -Clazz.defineMethod (c$, "isShowAnnotation", -function () { -return this.viewStyle.isShowAnnotation (); -}); -Clazz.defineMethod (c$, "isRightAlignIds", -function () { -return this.viewStyle.isRightAlignIds (); -}); -Clazz.defineMethod (c$, "setRightAlignIds", -function (rightAlignIds) { -this.viewStyle.setRightAlignIds (rightAlignIds); -}, "~B"); -Clazz.defineMethod (c$, "getConservationSelected", -function () { -return this.viewStyle.getConservationSelected (); -}); -Clazz.defineMethod (c$, "setShowBoxes", -function (state) { -this.viewStyle.setShowBoxes (state); -}, "~B"); -Clazz.defineMethod (c$, "getTextColour", -function () { -return this.viewStyle.getTextColour (); -}); -Clazz.defineMethod (c$, "getTextColour2", -function () { -return this.viewStyle.getTextColour2 (); -}); -Clazz.defineMethod (c$, "getThresholdTextColour", -function () { -return this.viewStyle.getThresholdTextColour (); -}); -Clazz.defineMethod (c$, "isConservationColourSelected", -function () { -return this.viewStyle.isConservationColourSelected (); -}); -Clazz.defineMethod (c$, "isRenderGaps", -function () { -return this.viewStyle.isRenderGaps (); -}); -Clazz.defineMethod (c$, "isShowColourText", -function () { -return this.viewStyle.isShowColourText (); -}); -Clazz.defineMethod (c$, "setConservationColourSelected", -function (conservationColourSelected) { -this.viewStyle.setConservationColourSelected (conservationColourSelected); -}, "~B"); -Clazz.defineMethod (c$, "setShowColourText", -function (showColourText) { -this.viewStyle.setShowColourText (showColourText); -}, "~B"); -Clazz.defineMethod (c$, "setTextColour", -function (textColour) { -this.viewStyle.setTextColour (textColour); -}, "java.awt.Color"); -Clazz.defineMethod (c$, "setThresholdTextColour", -function (thresholdTextColour) { -this.viewStyle.setThresholdTextColour (thresholdTextColour); -}, "~N"); -Clazz.defineMethod (c$, "setTextColour2", -function (textColour2) { -this.viewStyle.setTextColour2 (textColour2); -}, "java.awt.Color"); -Clazz.overrideMethod (c$, "getViewStyle", -function () { -return new jalview.viewmodel.styles.ViewStyle (this.viewStyle); -}); -Clazz.overrideMethod (c$, "setViewStyle", -function (settingsForView) { -this.viewStyle = new jalview.viewmodel.styles.ViewStyle (settingsForView); -}, "jalview.api.ViewStyleI"); -Clazz.defineMethod (c$, "sameStyle", -function (them) { -return this.viewStyle.sameStyle (them); -}, "jalview.api.ViewStyleI"); -Clazz.defineMethod (c$, "getIdWidth", -function () { -return this.viewStyle.getIdWidth (); -}); -Clazz.defineMethod (c$, "setIdWidth", -function (i) { -this.viewStyle.setIdWidth (i); -}, "~N"); -Clazz.defineMethod (c$, "isCentreColumnLabels", -function () { -return this.viewStyle.isCentreColumnLabels (); -}); -Clazz.defineMethod (c$, "setCentreColumnLabels", -function (centreColumnLabels) { -this.viewStyle.setCentreColumnLabels (centreColumnLabels); -}, "~B"); -Clazz.defineMethod (c$, "setShowDBRefs", -function (showdbrefs) { -this.viewStyle.setShowDBRefs (showdbrefs); -}, "~B"); -Clazz.defineMethod (c$, "isShowDBRefs", -function () { -return this.viewStyle.isShowDBRefs (); -}); -Clazz.defineMethod (c$, "isShowNPFeats", -function () { -return this.viewStyle.isShowNPFeats (); -}); -Clazz.defineMethod (c$, "setShowNPFeats", -function (shownpfeats) { -this.viewStyle.setShowNPFeats (shownpfeats); -}, "~B"); -Clazz.defineMethod (c$, "addToHistoryList", -function (command) { -if (this.historyList != null) { -this.historyList.push (command); -this.broadcastCommand (command, false); -}}, "jalview.commands.CommandI"); -Clazz.defineMethod (c$, "broadcastCommand", -function (command, undo) { -this.getStructureSelectionManager ().commandPerformed (command, undo, this.getVamsasSource ()); -}, "jalview.commands.CommandI,~B"); -Clazz.defineMethod (c$, "addToRedoList", -function (command) { -if (this.redoList != null) { -this.redoList.push (command); -}this.broadcastCommand (command, true); -}, "jalview.commands.CommandI"); -Clazz.defineMethod (c$, "clearRedoList", -function () { -if (this.redoList != null) { -this.redoList.clear (); -}}); -Clazz.defineMethod (c$, "setHistoryList", -function (list) { -this.historyList = list; -}, "java.util.Deque"); -Clazz.defineMethod (c$, "getHistoryList", -function () { -return this.historyList; -}); -Clazz.defineMethod (c$, "setRedoList", -function (list) { -this.redoList = list; -}, "java.util.Deque"); -Clazz.defineMethod (c$, "getRedoList", -function () { -return this.redoList; -}); -Clazz.overrideMethod (c$, "getVamsasSource", -function () { -return this; -}); -Clazz.defineMethod (c$, "getSortAnnotationsBy", -function () { -return this.sortAnnotationsBy; -}); -Clazz.defineMethod (c$, "setSortAnnotationsBy", -function (sortAnnotationsBy) { -this.sortAnnotationsBy = sortAnnotationsBy; -}, "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); -Clazz.defineMethod (c$, "isShowAutocalculatedAbove", -function () { -return this.showAutocalculatedAbove; -}); -Clazz.defineMethod (c$, "setShowAutocalculatedAbove", -function (showAutocalculatedAbove) { -this.showAutocalculatedAbove = showAutocalculatedAbove; -}, "~B"); -Clazz.defineMethod (c$, "isScaleProteinAsCdna", -function () { -return this.viewStyle.isScaleProteinAsCdna (); -}); -Clazz.defineMethod (c$, "setScaleProteinAsCdna", -function (b) { -this.viewStyle.setScaleProteinAsCdna (b); -}, "~B"); -Clazz.defineMethod (c$, "isFollowHighlight", -function () { -return this.followHighlight; -}); -Clazz.overrideMethod (c$, "setFollowHighlight", -function (b) { -this.followHighlight = b; -}, "~B"); -Clazz.defineMethod (c$, "getStartRes", -function () { -return this.startRes; -}); -Clazz.overrideMethod (c$, "getEndRes", -function () { -return this.endRes; -}); -Clazz.defineMethod (c$, "getStartSeq", -function () { -return this.startSeq; -}); -Clazz.defineMethod (c$, "setStartRes", -function (res) { -this.startRes = res; -}, "~N"); -Clazz.defineMethod (c$, "setStartSeq", -function (seq) { -this.startSeq = seq; -}, "~N"); -Clazz.defineMethod (c$, "setEndRes", -function (res) { -if (res > this.alignment.getWidth () - 1) { -res = this.alignment.getWidth () - 1; -}if (res < 0) { -res = 0; -}this.endRes = res; -}, "~N"); -Clazz.defineMethod (c$, "setEndSeq", -function (seq) { -if (seq > this.alignment.getHeight ()) { -seq = this.alignment.getHeight (); -}if (seq < 0) { -seq = 0; -}this.endSeq = seq; -}, "~N"); -Clazz.defineMethod (c$, "getEndSeq", -function () { -return this.endSeq; -}); -Clazz.defineMethod (c$, "findComplementScrollTarget", -function (sr) { -var complement = this.getCodingComplement (); -if (complement == null || !complement.isFollowHighlight ()) { -return 0; -}var iAmProtein = !this.getAlignment ().isNucleotide (); -var proteinAlignment = iAmProtein ? this.getAlignment () : complement.getAlignment (); -if (proteinAlignment == null) { -return 0; -}var mappings = proteinAlignment.getCodonFrames (); -var seqOffset = 0; -var sequence = null; -var middleColumn = this.getStartRes () + Clazz.doubleToInt ((this.getEndRes () - this.getStartRes ()) / 2); -var hiddenSequences = this.getAlignment ().getHiddenSequences (); -for (var seqNo = this.getStartSeq (); seqNo < this.getEndSeq (); seqNo++, seqOffset++) { -sequence = this.getAlignment ().getSequenceAt (seqNo); -if (hiddenSequences != null && hiddenSequences.isHidden (sequence)) { -continue; -}if (jalview.util.Comparison.isGap (sequence.getCharAt (middleColumn))) { -continue; -}var seqMappings = jalview.util.MappingUtils.findMappingsForSequence (sequence, mappings); -if (!seqMappings.isEmpty ()) { -break; -}} -if (sequence == null) { -return 0; -}jalview.util.MappingUtils.addSearchResults (sr, sequence, sequence.findPosition (middleColumn), mappings); -return seqOffset; -}, "jalview.datamodel.SearchResults"); -}); +Clazz.declarePackage ("jalview.viewmodel"); +Clazz.load (["jalview.api.AlignViewportI", "jalview.structure.CommandListener", "$.VamsasSource", "jalview.datamodel.ColumnSelection", "jalview.viewmodel.styles.ViewStyle", "jalview.workers.AlignCalcManager", "java.beans.PropertyChangeSupport", "java.util.ArrayDeque", "$.HashMap"], "jalview.viewmodel.AlignmentViewport", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.AlignmentView", "$.CigarArray", "$.Sequence", "$.SequenceGroup", "jalview.schemes.Blosum62ColourScheme", "$.PIDColourScheme", "$.ResidueProperties", "jalview.util.Comparison", "$.MappingUtils", "jalview.workers.ComplementConsensusThread", "$.ConsensusThread", "$.ConservationThread", "$.StrucConsensusThread", "java.awt.Color", "java.util.ArrayList", "$.BitSet", "$.Hashtable"], function () { +c$ = Clazz.decorateAsClass (function () { +this.viewStyle = null; +this.codingComplement = null; +this.featuresDisplayed = null; +this.historyList = null; +this.redoList = null; +this.alignment = null; +this.sequenceSetID = null; +this.$isDataset = false; +this.hiddenRepSequences = null; +this.colSel = null; +this.autoCalculateConsensus = true; +this.autoCalculateStrucConsensus = true; +this.ignoreGapsInConsensusCalculation = false; +this.globalColourScheme = null; +this.consensus = null; +this.complementConsensus = null; +this.strucConsensus = null; +this.conservation = null; +this.quality = null; +this.groupConsensus = null; +this.groupConservation = null; +this.hconsensus = null; +this.hcomplementConsensus = null; +this.hStrucConsensus = null; +this.hconservation = null; +this.ConsPercGaps = 25; +this.calculator = null; +this.showGroupConservation = false; +this.showGroupConsensus = false; +this.showSequenceLogo = false; +this.normaliseSequenceLogo = false; +this.showConsensusHistogram = true; +this.padGaps = false; +this.sortByTree = false; +this.selectionGroup = null; +this.viewId = null; +this.sgrouphash = -1; +this.colselhash = -1; +this.changeSupport = null; +this.showConservation = true; +this.showQuality = true; +this.showConsensus = true; +this.sequenceColours = null; +this.sortAnnotationsBy = null; +this.showAutocalculatedAbove = false; +this.followHighlight = true; +this.startRes = 0; +this.endRes = 0; +this.startSeq = 0; +this.endSeq = 0; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel, "AlignmentViewport", null, [jalview.api.AlignViewportI, jalview.structure.CommandListener, jalview.structure.VamsasSource]); +Clazz.prepareFields (c$, function () { +this.viewStyle = new jalview.viewmodel.styles.ViewStyle (); +this.historyList = new java.util.ArrayDeque (); +this.redoList = new java.util.ArrayDeque (); +this.colSel = new jalview.datamodel.ColumnSelection (); +this.calculator = new jalview.workers.AlignCalcManager (); +this.changeSupport = new java.beans.PropertyChangeSupport (this); +this.sequenceColours = new java.util.HashMap (); +}); +Clazz.defineMethod (c$, "setFontName", +function (name) { +this.viewStyle.setFontName (name); +}, "~S"); +Clazz.defineMethod (c$, "setFontStyle", +function (style) { +this.viewStyle.setFontStyle (style); +}, "~N"); +Clazz.defineMethod (c$, "setFontSize", +function (size) { +this.viewStyle.setFontSize (size); +}, "~N"); +Clazz.defineMethod (c$, "getFontStyle", +function () { +return this.viewStyle.getFontStyle (); +}); +Clazz.defineMethod (c$, "getFontName", +function () { +return this.viewStyle.getFontName (); +}); +Clazz.defineMethod (c$, "getFontSize", +function () { +return this.viewStyle.getFontSize (); +}); +Clazz.defineMethod (c$, "setUpperCasebold", +function (upperCasebold) { +this.viewStyle.setUpperCasebold (upperCasebold); +}, "~B"); +Clazz.defineMethod (c$, "isUpperCasebold", +function () { +return this.viewStyle.isUpperCasebold (); +}); +Clazz.defineMethod (c$, "isSeqNameItalics", +function () { +return this.viewStyle.isSeqNameItalics (); +}); +Clazz.defineMethod (c$, "setColourByReferenceSeq", +function (colourByReferenceSeq) { +this.viewStyle.setColourByReferenceSeq (colourByReferenceSeq); +}, "~B"); +Clazz.defineMethod (c$, "setColourAppliesToAllGroups", +function (b) { +this.viewStyle.setColourAppliesToAllGroups (b); +}, "~B"); +Clazz.defineMethod (c$, "getColourAppliesToAllGroups", +function () { +return this.viewStyle.getColourAppliesToAllGroups (); +}); +Clazz.defineMethod (c$, "getAbovePIDThreshold", +function () { +return this.viewStyle.getAbovePIDThreshold (); +}); +Clazz.defineMethod (c$, "setIncrement", +function (inc) { +this.viewStyle.setIncrement (inc); +}, "~N"); +Clazz.defineMethod (c$, "getIncrement", +function () { +return this.viewStyle.getIncrement (); +}); +Clazz.defineMethod (c$, "setConservationSelected", +function (b) { +this.viewStyle.setConservationSelected (b); +}, "~B"); +Clazz.defineMethod (c$, "setShowHiddenMarkers", +function (show) { +this.viewStyle.setShowHiddenMarkers (show); +}, "~B"); +Clazz.defineMethod (c$, "getShowHiddenMarkers", +function () { +return this.viewStyle.getShowHiddenMarkers (); +}); +Clazz.defineMethod (c$, "setScaleRightWrapped", +function (b) { +this.viewStyle.setScaleRightWrapped (b); +}, "~B"); +Clazz.defineMethod (c$, "setScaleLeftWrapped", +function (b) { +this.viewStyle.setScaleLeftWrapped (b); +}, "~B"); +Clazz.defineMethod (c$, "setScaleAboveWrapped", +function (b) { +this.viewStyle.setScaleAboveWrapped (b); +}, "~B"); +Clazz.defineMethod (c$, "getScaleLeftWrapped", +function () { +return this.viewStyle.getScaleLeftWrapped (); +}); +Clazz.defineMethod (c$, "getScaleAboveWrapped", +function () { +return this.viewStyle.getScaleAboveWrapped (); +}); +Clazz.defineMethod (c$, "getScaleRightWrapped", +function () { +return this.viewStyle.getScaleRightWrapped (); +}); +Clazz.defineMethod (c$, "setAbovePIDThreshold", +function (b) { +this.viewStyle.setAbovePIDThreshold (b); +}, "~B"); +Clazz.defineMethod (c$, "setThreshold", +function (thresh) { +this.viewStyle.setThreshold (thresh); +}, "~N"); +Clazz.defineMethod (c$, "getThreshold", +function () { +return this.viewStyle.getThreshold (); +}); +Clazz.defineMethod (c$, "getShowJVSuffix", +function () { +return this.viewStyle.getShowJVSuffix (); +}); +Clazz.defineMethod (c$, "setShowJVSuffix", +function (b) { +this.viewStyle.setShowJVSuffix (b); +}, "~B"); +Clazz.defineMethod (c$, "setWrapAlignment", +function (state) { +this.viewStyle.setWrapAlignment (state); +}, "~B"); +Clazz.defineMethod (c$, "setShowText", +function (state) { +this.viewStyle.setShowText (state); +}, "~B"); +Clazz.defineMethod (c$, "setRenderGaps", +function (state) { +this.viewStyle.setRenderGaps (state); +}, "~B"); +Clazz.defineMethod (c$, "getColourText", +function () { +return this.viewStyle.getColourText (); +}); +Clazz.defineMethod (c$, "setColourText", +function (state) { +this.viewStyle.setColourText (state); +}, "~B"); +Clazz.defineMethod (c$, "getWrapAlignment", +function () { +return this.viewStyle.getWrapAlignment (); +}); +Clazz.defineMethod (c$, "getShowText", +function () { +return this.viewStyle.getShowText (); +}); +Clazz.defineMethod (c$, "getWrappedWidth", +function () { +return this.viewStyle.getWrappedWidth (); +}); +Clazz.defineMethod (c$, "setWrappedWidth", +function (w) { +this.viewStyle.setWrappedWidth (w); +}, "~N"); +Clazz.defineMethod (c$, "getCharHeight", +function () { +return this.viewStyle.getCharHeight (); +}); +Clazz.defineMethod (c$, "setCharHeight", +function (h) { +this.viewStyle.setCharHeight (h); +}, "~N"); +Clazz.defineMethod (c$, "getCharWidth", +function () { +return this.viewStyle.getCharWidth (); +}); +Clazz.defineMethod (c$, "setCharWidth", +function (w) { +this.viewStyle.setCharWidth (w); +}, "~N"); +Clazz.defineMethod (c$, "getShowBoxes", +function () { +return this.viewStyle.getShowBoxes (); +}); +Clazz.defineMethod (c$, "getShowUnconserved", +function () { +return this.viewStyle.getShowUnconserved (); +}); +Clazz.defineMethod (c$, "setShowUnconserved", +function (showunconserved) { +this.viewStyle.setShowUnconserved (showunconserved); +}, "~B"); +Clazz.defineMethod (c$, "setSeqNameItalics", +function (default1) { +this.viewStyle.setSeqNameItalics (default1); +}, "~B"); +Clazz.defineMethod (c$, "getAlignment", +function () { +return this.alignment; +}); +Clazz.overrideMethod (c$, "getGapCharacter", +function () { +return this.alignment.getGapCharacter (); +}); +Clazz.defineMethod (c$, "setDataset", +function (b) { +this.$isDataset = b; +}, "~B"); +Clazz.defineMethod (c$, "isDataset", +function () { +return this.$isDataset; +}); +Clazz.overrideMethod (c$, "setGlobalColourScheme", +function (cs) { +this.globalColourScheme = cs; +var recalc = false; +if (cs != null) { +cs.setConservationApplied (recalc = this.getConservationSelected ()); +if (this.getAbovePIDThreshold () || Clazz.instanceOf (cs, jalview.schemes.PIDColourScheme) || Clazz.instanceOf (cs, jalview.schemes.Blosum62ColourScheme)) { +recalc = true; +cs.setThreshold (this.viewStyle.getThreshold (), this.ignoreGapsInConsensusCalculation); +} else { +cs.setThreshold (0, this.ignoreGapsInConsensusCalculation); +}if (recalc) { +cs.setConsensus (this.hconsensus); +cs.setConservation (this.hconservation); +}cs.alignmentChanged (this.alignment, this.hiddenRepSequences); +}if (this.getColourAppliesToAllGroups ()) { +for (var sg, $sg = this.getAlignment ().getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (cs == null) { +sg.cs = null; +continue; +}sg.cs = cs.applyTo (sg, this.getHiddenRepSequences ()); +sg.setConsPercGaps (this.ConsPercGaps); +if (this.getAbovePIDThreshold () || Clazz.instanceOf (cs, jalview.schemes.PIDColourScheme) || Clazz.instanceOf (cs, jalview.schemes.Blosum62ColourScheme)) { +sg.cs.setThreshold (this.viewStyle.getThreshold (), this.isIgnoreGapsConsensus ()); +recalc = true; +} else { +sg.cs.setThreshold (0, this.isIgnoreGapsConsensus ()); +}if (this.getConservationSelected ()) { +sg.cs.setConservationApplied (true); +recalc = true; +} else { +sg.cs.setConservation (null); +}if (recalc) { +sg.recalcConservation (); +} else { +sg.cs.alignmentChanged (sg, this.hiddenRepSequences); +}} +}}, "jalview.schemes.ColourSchemeI"); +Clazz.overrideMethod (c$, "getGlobalColourScheme", +function () { +return this.globalColourScheme; +}); +Clazz.overrideMethod (c$, "setConservation", +function (cons) { +this.hconservation = cons; +}, "jalview.analysis.Conservation"); +Clazz.overrideMethod (c$, "getConsPercGaps", +function () { +return this.ConsPercGaps; +}); +Clazz.overrideMethod (c$, "setSequenceConsensusHash", +function (hconsensus) { +this.hconsensus = hconsensus; +}, "~A"); +Clazz.overrideMethod (c$, "setComplementConsensusHash", +function (hconsensus) { +this.hcomplementConsensus = hconsensus; +}, "~A"); +Clazz.overrideMethod (c$, "getSequenceConsensusHash", +function () { +return this.hconsensus; +}); +Clazz.overrideMethod (c$, "getComplementConsensusHash", +function () { +return this.hcomplementConsensus; +}); +Clazz.overrideMethod (c$, "getRnaStructureConsensusHash", +function () { +return this.hStrucConsensus; +}); +Clazz.overrideMethod (c$, "setRnaStructureConsensusHash", +function (hStrucConsensus) { +this.hStrucConsensus = hStrucConsensus; +}, "~A"); +Clazz.overrideMethod (c$, "getAlignmentQualityAnnot", +function () { +return this.quality; +}); +Clazz.overrideMethod (c$, "getAlignmentConservationAnnotation", +function () { +return this.conservation; +}); +Clazz.overrideMethod (c$, "getAlignmentConsensusAnnotation", +function () { +return this.consensus; +}); +Clazz.overrideMethod (c$, "getComplementConsensusAnnotation", +function () { +return this.complementConsensus; +}); +Clazz.overrideMethod (c$, "getAlignmentStrucConsensusAnnotation", +function () { +return this.strucConsensus; +}); +Clazz.defineMethod (c$, "updateConservation", +function (ap) { +if (this.alignment.isNucleotide () || this.conservation == null || !this.autoCalculateConsensus) { +return; +}if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.ConservationThread) == null) { +this.calculator.registerWorker ( new jalview.workers.ConservationThread (this, ap)); +}}, "jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "updateConsensus", +function (ap) { +if (this.consensus == null || !this.autoCalculateConsensus) { +return; +}if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.ConsensusThread) == null) { +this.calculator.registerWorker ( new jalview.workers.ConsensusThread (this, ap)); +}var al = this.getAlignment (); +if (!al.isNucleotide () && al.getCodonFrames () != null && !al.getCodonFrames ().isEmpty ()) { +if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.ComplementConsensusThread) == null) { +this.calculator.registerWorker ( new jalview.workers.ComplementConsensusThread (this, ap)); +}}}, "jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "updateStrucConsensus", +function (ap) { +if (this.autoCalculateStrucConsensus && this.strucConsensus == null && this.alignment.isNucleotide () && this.alignment.hasRNAStructure ()) { +this.initRNAStructure (); +}if (this.strucConsensus == null || !this.autoCalculateStrucConsensus) { +return; +}if (this.calculator.getRegisteredWorkersOfClass (jalview.workers.StrucConsensusThread) == null) { +this.calculator.registerWorker ( new jalview.workers.StrucConsensusThread (this, ap)); +}}, "jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "isCalcInProgress", +function () { +return this.calculator.isWorking (); +}); +Clazz.overrideMethod (c$, "isCalculationInProgress", +function (alignmentAnnotation) { +if (!alignmentAnnotation.autoCalculated) { +return false; +}if (this.calculator.workingInvolvedWith (alignmentAnnotation)) { +return true; +}return false; +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "isClosed", +function () { +return this.alignment == null; +}); +Clazz.overrideMethod (c$, "getCalcManager", +function () { +return this.calculator; +}); +Clazz.overrideMethod (c$, "isShowSequenceLogo", +function () { +return this.showSequenceLogo; +}); +Clazz.defineMethod (c$, "setShowSequenceLogo", +function (showSequenceLogo) { +if (showSequenceLogo != this.showSequenceLogo) { +this.showSequenceLogo = showSequenceLogo; +this.calculator.updateAnnotationFor (jalview.workers.ConsensusThread); +this.calculator.updateAnnotationFor (jalview.workers.ComplementConsensusThread); +this.calculator.updateAnnotationFor (jalview.workers.StrucConsensusThread); +}this.showSequenceLogo = showSequenceLogo; +}, "~B"); +Clazz.defineMethod (c$, "setShowConsensusHistogram", +function (showConsensusHistogram) { +this.showConsensusHistogram = showConsensusHistogram; +}, "~B"); +Clazz.defineMethod (c$, "isShowGroupConservation", +function () { +return this.showGroupConservation; +}); +Clazz.defineMethod (c$, "setShowGroupConservation", +function (showGroupConservation) { +this.showGroupConservation = showGroupConservation; +}, "~B"); +Clazz.defineMethod (c$, "isShowGroupConsensus", +function () { +return this.showGroupConsensus; +}); +Clazz.defineMethod (c$, "setShowGroupConsensus", +function (showGroupConsensus) { +this.showGroupConsensus = showGroupConsensus; +}, "~B"); +Clazz.overrideMethod (c$, "isShowConsensusHistogram", +function () { +return this.showConsensusHistogram; +}); +Clazz.overrideMethod (c$, "getSelectionGroup", +function () { +return this.selectionGroup; +}); +Clazz.overrideMethod (c$, "setSelectionGroup", +function (sg) { +this.selectionGroup = sg; +}, "jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "setHiddenColumns", +function (colsel) { +this.colSel = colsel; +}, "jalview.datamodel.ColumnSelection"); +Clazz.overrideMethod (c$, "getColumnSelection", +function () { +return this.colSel; +}); +Clazz.overrideMethod (c$, "setColumnSelection", +function (colSel) { +this.colSel = colSel; +if (colSel != null) { +this.updateHiddenColumns (); +}}, "jalview.datamodel.ColumnSelection"); +Clazz.overrideMethod (c$, "getHiddenRepSequences", +function () { +return this.hiddenRepSequences; +}); +Clazz.overrideMethod (c$, "setHiddenRepSequences", +function (hiddenRepSequences) { +this.hiddenRepSequences = hiddenRepSequences; +}, "java.util.Map"); +Clazz.overrideMethod (c$, "hasHiddenColumns", +function () { +return this.colSel != null && this.colSel.hasHiddenColumns (); +}); +Clazz.defineMethod (c$, "updateHiddenColumns", +function () { +}); +Clazz.overrideMethod (c$, "hasHiddenRows", +function () { +return this.alignment.getHiddenSequences ().getSize () > 0; +}); +Clazz.defineMethod (c$, "setSequenceSetId", +function (newid) { +if (this.sequenceSetID != null) { +System.err.println ("Warning - overwriting a sequenceSetId for a viewport!"); +}this.sequenceSetID = String.instantialize (newid); +}, "~S"); +Clazz.overrideMethod (c$, "getSequenceSetId", +function () { +if (this.sequenceSetID == null) { +this.sequenceSetID = this.alignment.hashCode () + ""; +}return this.sequenceSetID; +}); +Clazz.overrideMethod (c$, "getViewId", +function () { +if (this.viewId == null) { +this.viewId = this.getSequenceSetId () + "." + this.hashCode () + ""; +}return this.viewId; +}); +Clazz.defineMethod (c$, "setIgnoreGapsConsensus", +function (b, ap) { +this.ignoreGapsInConsensusCalculation = b; +if (ap != null) { +this.updateConsensus (ap); +if (this.globalColourScheme != null) { +this.globalColourScheme.setThreshold (this.globalColourScheme.getThreshold (), this.ignoreGapsInConsensusCalculation); +}}}, "~B,jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "isSelectionGroupChanged", +function (b) { +var hc = (this.selectionGroup == null || this.selectionGroup.getSize () == 0) ? -1 : this.selectionGroup.hashCode (); +if (hc != -1 && hc != this.sgrouphash) { +if (b) { +this.sgrouphash = hc; +}return true; +}return false; +}, "~B"); +Clazz.defineMethod (c$, "isColSelChanged", +function (b) { +var hc = (this.colSel == null || this.colSel.size () == 0) ? -1 : this.colSel.hashCode (); +if (hc != -1 && hc != this.colselhash) { +if (b) { +this.colselhash = hc; +}return true; +}return false; +}, "~B"); +Clazz.overrideMethod (c$, "isIgnoreGapsConsensus", +function () { +return this.ignoreGapsInConsensusCalculation; +}); +Clazz.defineMethod (c$, "addPropertyChangeListener", +function (listener) { +this.changeSupport.addPropertyChangeListener (listener); +}, "java.beans.PropertyChangeListener"); +Clazz.defineMethod (c$, "removePropertyChangeListener", +function (listener) { +this.changeSupport.removePropertyChangeListener (listener); +}, "java.beans.PropertyChangeListener"); +Clazz.defineMethod (c$, "firePropertyChange", +function (prop, oldvalue, newvalue) { +this.changeSupport.firePropertyChange (prop, oldvalue, newvalue); +}, "~S,~O,~O"); +Clazz.defineMethod (c$, "hideSelectedColumns", +function () { +if (this.colSel.size () < 1) { +return; +}this.colSel.hideSelectedColumns (); +this.setSelectionGroup (null); +}); +Clazz.defineMethod (c$, "hideColumns", +function (start, end) { +if (start == end) { +this.colSel.hideColumns (start); +} else { +this.colSel.hideColumns (start, end); +}}, "~N,~N"); +Clazz.defineMethod (c$, "showColumn", +function (col) { +this.colSel.revealHiddenColumns (col); +}, "~N"); +Clazz.defineMethod (c$, "showAllHiddenColumns", +function () { +this.colSel.revealAllHiddenColumns (); +}); +Clazz.defineMethod (c$, "showAllHiddenSeqs", +function () { +if (this.alignment.getHiddenSequences ().getSize () > 0) { +if (this.selectionGroup == null) { +this.selectionGroup = new jalview.datamodel.SequenceGroup (); +this.selectionGroup.setEndRes (this.alignment.getWidth () - 1); +}var tmp = this.alignment.getHiddenSequences ().showAll (this.hiddenRepSequences); +for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +this.selectionGroup.addSequence (seq, false); +this.setSequenceAnnotationsVisible (seq, true); +} +this.hiddenRepSequences = null; +this.firePropertyChange ("alignment", null, this.alignment.getSequences ()); +this.sendSelection (); +}}); +Clazz.defineMethod (c$, "showSequence", +function (index) { +var tmp = this.alignment.getHiddenSequences ().showSequence (index, this.hiddenRepSequences); +if (tmp.size () > 0) { +if (this.selectionGroup == null) { +this.selectionGroup = new jalview.datamodel.SequenceGroup (); +this.selectionGroup.setEndRes (this.alignment.getWidth () - 1); +}for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) { +this.selectionGroup.addSequence (seq, false); +this.setSequenceAnnotationsVisible (seq, true); +} +this.firePropertyChange ("alignment", null, this.alignment.getSequences ()); +this.sendSelection (); +}}, "~N"); +Clazz.defineMethod (c$, "hideAllSelectedSeqs", +function () { +if (this.selectionGroup == null || this.selectionGroup.getSize () < 1) { +return; +}var seqs = this.selectionGroup.getSequencesInOrder (this.alignment); +this.hideSequence (seqs); +this.setSelectionGroup (null); +}); +Clazz.defineMethod (c$, "hideSequence", +function (seq) { +if (seq != null) { +for (var i = 0; i < seq.length; i++) { +this.alignment.getHiddenSequences ().hideSequence (seq[i]); +this.setSequenceAnnotationsVisible (seq[i], false); +} +this.firePropertyChange ("alignment", null, this.alignment.getSequences ()); +}}, "~A"); +Clazz.defineMethod (c$, "setSequenceAnnotationsVisible", +function (sequenceI, visible) { +for (var ann, $ann = 0, $$ann = this.alignment.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) { +if (ann.sequenceRef === sequenceI) { +ann.visible = visible; +}} +}, "jalview.datamodel.SequenceI,~B"); +Clazz.defineMethod (c$, "hideRepSequences", +function (repSequence, sg) { +var sSize = sg.getSize (); +if (sSize < 2) { +return; +}if (this.hiddenRepSequences == null) { +this.hiddenRepSequences = new java.util.Hashtable (); +}this.hiddenRepSequences.put (repSequence, sg); +var seqs = new Array (sSize - 1); +var index = 0; +for (var i = 0; i < sSize; i++) { +if (sg.getSequenceAt (i) !== repSequence) { +if (index == sSize - 1) { +return; +}seqs[index++] = sg.getSequenceAt (i); +}} +sg.setSeqrep (repSequence); +sg.setHidereps (true); +this.hideSequence (seqs); +}, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup"); +Clazz.defineMethod (c$, "isHiddenRepSequence", +function (seq) { +return this.alignment.getSeqrep () === seq || (this.hiddenRepSequences != null && this.hiddenRepSequences.containsKey (seq)); +}, "jalview.datamodel.SequenceI"); +Clazz.defineMethod (c$, "getRepresentedSequences", +function (seq) { +return (this.hiddenRepSequences == null ? null : this.hiddenRepSequences.get (seq)); +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "adjustForHiddenSeqs", +function (alignmentIndex) { +return this.alignment.getHiddenSequences ().adjustForHiddenSeqs (alignmentIndex); +}, "~N"); +Clazz.overrideMethod (c$, "invertColumnSelection", +function () { +this.colSel.invertColumnSelection (0, this.alignment.getWidth ()); +}); +Clazz.overrideMethod (c$, "getSelectionAsNewSequence", +function () { +var sequences; +if (this.selectionGroup == null || this.selectionGroup.getSize () == 0) { +sequences = this.alignment.getSequencesArray (); +var annots = this.alignment.getAlignmentAnnotation (); +for (var i = 0; i < sequences.length; i++) { +sequences[i] = new jalview.datamodel.Sequence (sequences[i], annots); +} +} else { +sequences = this.selectionGroup.getSelectionAsNewSequences (this.alignment); +}return sequences; +}); +Clazz.overrideMethod (c$, "getSequenceSelection", +function () { +var sequences = null; +if (this.selectionGroup != null) { +sequences = this.selectionGroup.getSequencesInOrder (this.alignment); +}if (sequences == null) { +sequences = this.alignment.getSequencesArray (); +}return sequences; +}); +Clazz.overrideMethod (c$, "getViewAsCigars", +function (selectedRegionOnly) { +return new jalview.datamodel.CigarArray (this.alignment, this.colSel, (selectedRegionOnly ? this.selectionGroup : null)); +}, "~B"); +Clazz.defineMethod (c$, "getAlignmentView", +function (selectedOnly) { +return this.getAlignmentView (selectedOnly, false); +}, "~B"); +Clazz.defineMethod (c$, "getAlignmentView", +function (selectedOnly, markGroups) { +return new jalview.datamodel.AlignmentView (this.alignment, this.colSel, this.selectionGroup, this.colSel != null && this.colSel.hasHiddenColumns (), selectedOnly, markGroups); +}, "~B,~B"); +Clazz.overrideMethod (c$, "getViewAsString", +function (selectedRegionOnly) { +var selection = null; +var seqs = null; +var i; +var iSize; +var start = 0; +var end = 0; +if (selectedRegionOnly && this.selectionGroup != null) { +iSize = this.selectionGroup.getSize (); +seqs = this.selectionGroup.getSequencesInOrder (this.alignment); +start = this.selectionGroup.getStartRes (); +end = this.selectionGroup.getEndRes () + 1; +} else { +iSize = this.alignment.getHeight (); +seqs = this.alignment.getSequencesArray (); +end = this.alignment.getWidth (); +}selection = new Array (iSize); +if (this.colSel != null && this.colSel.hasHiddenColumns ()) { +selection = this.colSel.getVisibleSequenceStrings (start, end, seqs); +} else { +for (i = 0; i < iSize; i++) { +selection[i] = seqs[i].getSequenceAsString (start, end); +} +}return selection; +}, "~B"); +Clazz.overrideMethod (c$, "getVisibleRegionBoundaries", +function (min, max) { +var regions = new java.util.ArrayList (); +var start = min; +var end = max; +do { +if (this.colSel != null && this.colSel.hasHiddenColumns ()) { +if (start == 0) { +start = this.colSel.adjustForHiddenColumns (start); +}end = this.colSel.getHiddenBoundaryRight (start); +if (start == end) { +end = max; +}if (end > max) { +end = max; +}}regions.add ( Clazz.newIntArray (-1, [start, end])); +if (this.colSel != null && this.colSel.hasHiddenColumns ()) { +start = this.colSel.adjustForHiddenColumns (end); +start = this.colSel.getHiddenBoundaryLeft (start) + 1; +}} while (end < max); +var startEnd = Clazz.newIntArray (regions.size (), 2, 0); +return regions; +}, "~N,~N"); +Clazz.overrideMethod (c$, "getVisibleAlignmentAnnotation", +function (selectedOnly) { +var ala = new java.util.ArrayList (); +var aa; +if ((aa = this.alignment.getAlignmentAnnotation ()) != null) { +for (var annot, $annot = 0, $$annot = aa; $annot < $$annot.length && ((annot = $$annot[$annot]) || true); $annot++) { +var clone = new jalview.datamodel.AlignmentAnnotation (annot); +if (selectedOnly && this.selectionGroup != null) { +this.colSel.makeVisibleAnnotation (this.selectionGroup.getStartRes (), this.selectionGroup.getEndRes (), clone); +} else { +this.colSel.makeVisibleAnnotation (clone); +}ala.add (clone); +} +}return ala; +}, "~B"); +Clazz.overrideMethod (c$, "isPadGaps", +function () { +return this.padGaps; +}); +Clazz.overrideMethod (c$, "setPadGaps", +function (padGaps) { +this.padGaps = padGaps; +}, "~B"); +Clazz.overrideMethod (c$, "alignmentChanged", +function (ap) { +if (this.isPadGaps ()) { +this.alignment.padGaps (); +}if (this.autoCalculateConsensus) { +this.updateConsensus (ap); +}if (this.hconsensus != null && this.autoCalculateConsensus) { +this.updateConservation (ap); +}if (this.autoCalculateStrucConsensus) { +this.updateStrucConsensus (ap); +}var alWidth = this.alignment.getWidth (); +var groups = this.alignment.getGroups (); +if (groups != null) { +for (var sg, $sg = groups.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.getEndRes () > alWidth) { +sg.setEndRes (alWidth - 1); +}} +}if (this.selectionGroup != null && this.selectionGroup.getEndRes () > alWidth) { +this.selectionGroup.setEndRes (alWidth - 1); +}this.resetAllColourSchemes (); +this.calculator.restartWorkers (); +}, "jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "resetAllColourSchemes", +function () { +var cs = this.globalColourScheme; +if (cs != null) { +cs.alignmentChanged (this.alignment, this.hiddenRepSequences); +cs.setConsensus (this.hconsensus); +if (cs.conservationApplied ()) { +cs.setConservation (jalview.analysis.Conservation.calculateConservation ("All", jalview.schemes.ResidueProperties.propHash, 3, this.alignment.getSequences (), 0, this.alignment.getWidth (), false, this.getConsPercGaps (), false)); +}}for (var sg, $sg = this.alignment.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.cs != null) { +sg.cs.alignmentChanged (sg, this.hiddenRepSequences); +}sg.recalcConservation (); +} +}); +Clazz.defineMethod (c$, "initAutoAnnotation", +function () { +if (this.hconsensus == null && !this.$isDataset) { +if (!this.alignment.isNucleotide ()) { +this.initConservation (); +this.initQuality (); +} else { +this.initRNAStructure (); +}this.consensus = new jalview.datamodel.AlignmentAnnotation ("Consensus", "PID", new Array (1), 0, 100, 1); +this.initConsensus (this.consensus); +this.initComplementConsensus (); +}}); +Clazz.defineMethod (c$, "initComplementConsensus", +function () { +if (!this.alignment.isNucleotide ()) { +var codonMappings = this.alignment.getCodonFrames (); +if (codonMappings != null && !codonMappings.isEmpty ()) { +this.complementConsensus = new jalview.datamodel.AlignmentAnnotation ("cDNA Consensus", "PID for cDNA", new Array (1), 0, 100, 1); +this.initConsensus (this.complementConsensus); +}}}); +Clazz.defineMethod (c$, "initConsensus", +($fz = function (aa) { +aa.hasText = true; +aa.autoCalculated = true; +if (this.showConsensus) { +this.alignment.addAnnotation (aa); +}}, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation"); +Clazz.defineMethod (c$, "initConservation", +($fz = function () { +if (this.showConservation) { +if (this.conservation == null) { +this.conservation = new jalview.datamodel.AlignmentAnnotation ("Conservation", "Conservation of total alignment less than " + this.getConsPercGaps () + "% gaps", new Array (1), 0, 11, 1); +this.conservation.hasText = true; +this.conservation.autoCalculated = true; +this.alignment.addAnnotation (this.conservation); +}}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "initQuality", +($fz = function () { +if (this.showQuality) { +if (this.quality == null) { +this.quality = new jalview.datamodel.AlignmentAnnotation ("Quality", "Alignment Quality based on Blosum62 scores", new Array (1), 0, 11, 1); +this.quality.hasText = true; +this.quality.autoCalculated = true; +this.alignment.addAnnotation (this.quality); +}}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "initRNAStructure", +($fz = function () { +if (this.alignment.hasRNAStructure () && this.strucConsensus == null) { +this.strucConsensus = new jalview.datamodel.AlignmentAnnotation ("StrucConsensus", "PID", new Array (1), 0, 100, 1); +this.strucConsensus.hasText = true; +this.strucConsensus.autoCalculated = true; +if (this.showConsensus) { +this.alignment.addAnnotation (this.strucConsensus); +}}}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "calcPanelHeight", +function () { +var anns = this.getAlignment ().getAlignmentAnnotation (); +var height = 0; +var charHeight = this.getCharHeight (); +if (anns != null) { +var graphgrp = new java.util.BitSet (); +for (var aa, $aa = 0, $$aa = anns; $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) { +if (aa == null) { +System.err.println ("Null annotation row: ignoring."); +continue; +}if (!aa.visible) { +continue; +}if (aa.graphGroup > -1) { +if (graphgrp.get (aa.graphGroup)) { +continue; +} else { +graphgrp.set (aa.graphGroup); +}}aa.height = 0; +if (aa.hasText) { +aa.height += charHeight; +}if (aa.hasIcons) { +aa.height += 16; +}if (aa.graph > 0) { +aa.height += aa.graphHeight; +}if (aa.height == 0) { +aa.height = 20; +}height += aa.height; +} +}if (height == 0) { +height = 20; +}return height; +}); +Clazz.overrideMethod (c$, "updateGroupAnnotationSettings", +function (applyGlobalSettings, preserveNewGroupSettings) { +var updateCalcs = false; +var conv = this.isShowGroupConservation (); +var cons = this.isShowGroupConsensus (); +var showprf = this.isShowSequenceLogo (); +var showConsHist = this.isShowConsensusHistogram (); +var normLogo = this.isNormaliseSequenceLogo (); +var sortg = true; +var aan = this.alignment.getAlignmentAnnotation (); +var oldrfs = new java.util.ArrayList (); +if (aan != null) { +for (var an = 0; an < aan.length; an++) { +if (aan[an].autoCalculated && aan[an].groupRef != null) { +oldrfs.add (aan[an].groupRef); +this.alignment.deleteAnnotation (aan[an], false); +}} +}if (this.alignment.getGroups () != null) { +for (var sg, $sg = this.alignment.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +updateCalcs = false; +if (applyGlobalSettings || (!preserveNewGroupSettings && !oldrfs.contains (sg))) { +sg.setshowSequenceLogo (showprf); +sg.setShowConsensusHistogram (showConsHist); +sg.setNormaliseSequenceLogo (normLogo); +}if (conv) { +updateCalcs = true; +this.alignment.addAnnotation (sg.getConservationRow (), 0); +}if (cons) { +updateCalcs = true; +this.alignment.addAnnotation (sg.getConsensus (), 0); +}if (updateCalcs) { +sg.recalcConservation (); +}} +}oldrfs.clear (); +}, "~B,~B"); +Clazz.defineMethod (c$, "isDisplayReferenceSeq", +function () { +return this.alignment.hasSeqrep () && this.viewStyle.isDisplayReferenceSeq (); +}); +Clazz.defineMethod (c$, "setDisplayReferenceSeq", +function (displayReferenceSeq) { +this.viewStyle.setDisplayReferenceSeq (displayReferenceSeq); +}, "~B"); +Clazz.defineMethod (c$, "isColourByReferenceSeq", +function () { +return this.alignment.hasSeqrep () && this.viewStyle.isColourByReferenceSeq (); +}); +Clazz.overrideMethod (c$, "getSequenceColour", +function (seq) { +var sqc = this.sequenceColours.get (seq); +return (sqc == null ? java.awt.Color.white : sqc); +}, "jalview.datamodel.SequenceI"); +Clazz.overrideMethod (c$, "setSequenceColour", +function (seq, col) { +if (col == null) { +this.sequenceColours.remove (seq); +} else { +this.sequenceColours.put (seq, col); +}}, "jalview.datamodel.SequenceI,java.awt.Color"); +Clazz.overrideMethod (c$, "updateSequenceIdColours", +function () { +for (var sg, $sg = this.alignment.getGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) { +if (sg.idColour != null) { +for (var s, $s = sg.getSequences (this.getHiddenRepSequences ()).iterator (); $s.hasNext () && ((s = $s.next ()) || true);) { +this.sequenceColours.put (s, sg.idColour); +} +}} +}); +Clazz.overrideMethod (c$, "clearSequenceColours", +function () { +this.sequenceColours.clear (); +}); +Clazz.defineMethod (c$, "getCodingComplement", +function () { +return this.codingComplement; +}); +Clazz.defineMethod (c$, "setCodingComplement", +function (av) { +if (this === av) { +System.err.println ("Ignoring recursive setCodingComplement request"); +} else { +this.codingComplement = av; +if (av.getCodingComplement () !== this) { +av.setCodingComplement (this); +}}}, "jalview.api.AlignViewportI"); +Clazz.overrideMethod (c$, "isNucleotide", +function () { +return this.getAlignment () == null ? false : this.getAlignment ().isNucleotide (); +}); +Clazz.overrideMethod (c$, "getFeaturesDisplayed", +function () { +return this.featuresDisplayed; +}); +Clazz.overrideMethod (c$, "setFeaturesDisplayed", +function (featuresDisplayedI) { +this.featuresDisplayed = featuresDisplayedI; +}, "jalview.api.FeaturesDisplayedI"); +Clazz.overrideMethod (c$, "areFeaturesDisplayed", +function () { +return this.featuresDisplayed != null && this.featuresDisplayed.getRegisterdFeaturesCount () > 0; +}); +Clazz.defineMethod (c$, "setShowSequenceFeatures", +function (b) { +this.viewStyle.setShowSequenceFeatures (b); +}, "~B"); +Clazz.defineMethod (c$, "isShowSequenceFeatures", +function () { +return this.viewStyle.isShowSequenceFeatures (); +}); +Clazz.defineMethod (c$, "setShowSequenceFeaturesHeight", +function (selected) { +this.viewStyle.setShowSequenceFeaturesHeight (selected); +}, "~B"); +Clazz.defineMethod (c$, "isShowSequenceFeaturesHeight", +function () { +return this.viewStyle.isShowSequenceFeaturesHeight (); +}); +Clazz.defineMethod (c$, "setShowAnnotation", +function (b) { +this.viewStyle.setShowAnnotation (b); +}, "~B"); +Clazz.defineMethod (c$, "isShowAnnotation", +function () { +return this.viewStyle.isShowAnnotation (); +}); +Clazz.defineMethod (c$, "isRightAlignIds", +function () { +return this.viewStyle.isRightAlignIds (); +}); +Clazz.defineMethod (c$, "setRightAlignIds", +function (rightAlignIds) { +this.viewStyle.setRightAlignIds (rightAlignIds); +}, "~B"); +Clazz.defineMethod (c$, "getConservationSelected", +function () { +return this.viewStyle.getConservationSelected (); +}); +Clazz.defineMethod (c$, "setShowBoxes", +function (state) { +this.viewStyle.setShowBoxes (state); +}, "~B"); +Clazz.defineMethod (c$, "getTextColour", +function () { +return this.viewStyle.getTextColour (); +}); +Clazz.defineMethod (c$, "getTextColour2", +function () { +return this.viewStyle.getTextColour2 (); +}); +Clazz.defineMethod (c$, "getThresholdTextColour", +function () { +return this.viewStyle.getThresholdTextColour (); +}); +Clazz.defineMethod (c$, "isConservationColourSelected", +function () { +return this.viewStyle.isConservationColourSelected (); +}); +Clazz.defineMethod (c$, "isRenderGaps", +function () { +return this.viewStyle.isRenderGaps (); +}); +Clazz.defineMethod (c$, "isShowColourText", +function () { +return this.viewStyle.isShowColourText (); +}); +Clazz.defineMethod (c$, "setConservationColourSelected", +function (conservationColourSelected) { +this.viewStyle.setConservationColourSelected (conservationColourSelected); +}, "~B"); +Clazz.defineMethod (c$, "setShowColourText", +function (showColourText) { +this.viewStyle.setShowColourText (showColourText); +}, "~B"); +Clazz.defineMethod (c$, "setTextColour", +function (textColour) { +this.viewStyle.setTextColour (textColour); +}, "java.awt.Color"); +Clazz.defineMethod (c$, "setThresholdTextColour", +function (thresholdTextColour) { +this.viewStyle.setThresholdTextColour (thresholdTextColour); +}, "~N"); +Clazz.defineMethod (c$, "setTextColour2", +function (textColour2) { +this.viewStyle.setTextColour2 (textColour2); +}, "java.awt.Color"); +Clazz.overrideMethod (c$, "getViewStyle", +function () { +return new jalview.viewmodel.styles.ViewStyle (this.viewStyle); +}); +Clazz.overrideMethod (c$, "setViewStyle", +function (settingsForView) { +this.viewStyle = new jalview.viewmodel.styles.ViewStyle (settingsForView); +}, "jalview.api.ViewStyleI"); +Clazz.defineMethod (c$, "sameStyle", +function (them) { +return this.viewStyle.sameStyle (them); +}, "jalview.api.ViewStyleI"); +Clazz.defineMethod (c$, "getIdWidth", +function () { +return this.viewStyle.getIdWidth (); +}); +Clazz.defineMethod (c$, "setIdWidth", +function (i) { +this.viewStyle.setIdWidth (i); +}, "~N"); +Clazz.defineMethod (c$, "isCentreColumnLabels", +function () { +return this.viewStyle.isCentreColumnLabels (); +}); +Clazz.defineMethod (c$, "setCentreColumnLabels", +function (centreColumnLabels) { +this.viewStyle.setCentreColumnLabels (centreColumnLabels); +}, "~B"); +Clazz.defineMethod (c$, "setShowDBRefs", +function (showdbrefs) { +this.viewStyle.setShowDBRefs (showdbrefs); +}, "~B"); +Clazz.defineMethod (c$, "isShowDBRefs", +function () { +return this.viewStyle.isShowDBRefs (); +}); +Clazz.defineMethod (c$, "isShowNPFeats", +function () { +return this.viewStyle.isShowNPFeats (); +}); +Clazz.defineMethod (c$, "setShowNPFeats", +function (shownpfeats) { +this.viewStyle.setShowNPFeats (shownpfeats); +}, "~B"); +Clazz.defineMethod (c$, "addToHistoryList", +function (command) { +if (this.historyList != null) { +this.historyList.push (command); +this.broadcastCommand (command, false); +}}, "jalview.commands.CommandI"); +Clazz.defineMethod (c$, "broadcastCommand", +function (command, undo) { +this.getStructureSelectionManager ().commandPerformed (command, undo, this.getVamsasSource ()); +}, "jalview.commands.CommandI,~B"); +Clazz.defineMethod (c$, "addToRedoList", +function (command) { +if (this.redoList != null) { +this.redoList.push (command); +}this.broadcastCommand (command, true); +}, "jalview.commands.CommandI"); +Clazz.defineMethod (c$, "clearRedoList", +function () { +if (this.redoList != null) { +this.redoList.clear (); +}}); +Clazz.defineMethod (c$, "setHistoryList", +function (list) { +this.historyList = list; +}, "java.util.Deque"); +Clazz.defineMethod (c$, "getHistoryList", +function () { +return this.historyList; +}); +Clazz.defineMethod (c$, "setRedoList", +function (list) { +this.redoList = list; +}, "java.util.Deque"); +Clazz.defineMethod (c$, "getRedoList", +function () { +return this.redoList; +}); +Clazz.overrideMethod (c$, "getVamsasSource", +function () { +return this; +}); +Clazz.defineMethod (c$, "getSortAnnotationsBy", +function () { +return this.sortAnnotationsBy; +}); +Clazz.defineMethod (c$, "setSortAnnotationsBy", +function (sortAnnotationsBy) { +this.sortAnnotationsBy = sortAnnotationsBy; +}, "jalview.analysis.AnnotationSorter.SequenceAnnotationOrder"); +Clazz.defineMethod (c$, "isShowAutocalculatedAbove", +function () { +return this.showAutocalculatedAbove; +}); +Clazz.defineMethod (c$, "setShowAutocalculatedAbove", +function (showAutocalculatedAbove) { +this.showAutocalculatedAbove = showAutocalculatedAbove; +}, "~B"); +Clazz.defineMethod (c$, "isScaleProteinAsCdna", +function () { +return this.viewStyle.isScaleProteinAsCdna (); +}); +Clazz.defineMethod (c$, "setScaleProteinAsCdna", +function (b) { +this.viewStyle.setScaleProteinAsCdna (b); +}, "~B"); +Clazz.defineMethod (c$, "isFollowHighlight", +function () { +return this.followHighlight; +}); +Clazz.overrideMethod (c$, "setFollowHighlight", +function (b) { +this.followHighlight = b; +}, "~B"); +Clazz.defineMethod (c$, "getStartRes", +function () { +return this.startRes; +}); +Clazz.overrideMethod (c$, "getEndRes", +function () { +return this.endRes; +}); +Clazz.defineMethod (c$, "getStartSeq", +function () { +return this.startSeq; +}); +Clazz.defineMethod (c$, "setStartRes", +function (res) { +this.startRes = res; +}, "~N"); +Clazz.defineMethod (c$, "setStartSeq", +function (seq) { +this.startSeq = seq; +}, "~N"); +Clazz.defineMethod (c$, "setEndRes", +function (res) { +if (res > this.alignment.getWidth () - 1) { +res = this.alignment.getWidth () - 1; +}if (res < 0) { +res = 0; +}this.endRes = res; +}, "~N"); +Clazz.defineMethod (c$, "setEndSeq", +function (seq) { +if (seq > this.alignment.getHeight ()) { +seq = this.alignment.getHeight (); +}if (seq < 0) { +seq = 0; +}this.endSeq = seq; +}, "~N"); +Clazz.defineMethod (c$, "getEndSeq", +function () { +return this.endSeq; +}); +Clazz.defineMethod (c$, "findComplementScrollTarget", +function (sr) { +var complement = this.getCodingComplement (); +if (complement == null || !complement.isFollowHighlight ()) { +return 0; +}var iAmProtein = !this.getAlignment ().isNucleotide (); +var proteinAlignment = iAmProtein ? this.getAlignment () : complement.getAlignment (); +if (proteinAlignment == null) { +return 0; +}var mappings = proteinAlignment.getCodonFrames (); +var seqOffset = 0; +var sequence = null; +var middleColumn = this.getStartRes () + Clazz.doubleToInt ((this.getEndRes () - this.getStartRes ()) / 2); +var hiddenSequences = this.getAlignment ().getHiddenSequences (); +for (var seqNo = this.getStartSeq (); seqNo < this.getEndSeq (); seqNo++, seqOffset++) { +sequence = this.getAlignment ().getSequenceAt (seqNo); +if (hiddenSequences != null && hiddenSequences.isHidden (sequence)) { +continue; +}if (jalview.util.Comparison.isGap (sequence.getCharAt (middleColumn))) { +continue; +}var seqMappings = jalview.util.MappingUtils.findMappingsForSequence (sequence, mappings); +if (!seqMappings.isEmpty ()) { +break; +}} +if (sequence == null) { +return 0; +}jalview.util.MappingUtils.addSearchResults (sr, sequence, sequence.findPosition (middleColumn), mappings); +return seqOffset; +}, "jalview.datamodel.SearchResults"); +}); diff --git a/bin/jalview/viewmodel/PCAModel.js b/bin/jalview/viewmodel/PCAModel.js index 7527935..83a1162 100644 --- a/bin/jalview/viewmodel/PCAModel.js +++ b/bin/jalview/viewmodel/PCAModel.js @@ -1,134 +1,134 @@ -Clazz.declarePackage ("jalview.viewmodel"); -Clazz.load (null, "jalview.viewmodel.PCAModel", ["jalview.analysis.PCA", "jalview.datamodel.SequencePoint", "java.lang.StringBuffer", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.pca = null; -this.top = 0; -this.seqstrings = null; -this.seqs = null; -this.score_matrix = null; -this.nucleotide = false; -this.points = null; -this.jvCalcMode = true; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel, "PCAModel"); -Clazz.makeConstructor (c$, -function (seqstrings2, seqs2, nucleotide2) { -this.seqstrings = seqstrings2; -this.seqs = seqs2; -this.nucleotide = nucleotide2; -this.score_matrix = nucleotide2 ? "PID" : "BLOSUM62"; -}, "jalview.datamodel.AlignmentView,~A,~B"); -Clazz.defineMethod (c$, "isJvCalcMode", -function () { -return this.jvCalcMode; -}); -Clazz.defineMethod (c$, "run", -function () { -this.pca = new jalview.analysis.PCA (this.seqstrings.getSequenceStrings (' '), this.nucleotide, this.score_matrix); -this.pca.setJvCalcMode (this.jvCalcMode); -this.pca.run (); -var ii = 0; -while ((ii < this.seqs.length) && (this.seqs[ii] != null)) { -ii++; -} -var comps = Clazz.newDoubleArray (ii, ii, 0); -for (var i = 0; i < ii; i++) { -if (this.pca.getEigenvalue (i) > 1e-4) { -comps[i] = this.pca.component (i); -}} -this.top = this.pca.getM ().rows - 1; -this.points = new java.util.Vector (); -var scores = this.pca.getComponents (this.top - 1, this.top - 2, this.top - 3, 100); -for (var i = 0; i < this.pca.getM ().rows; i++) { -var sp = new jalview.datamodel.SequencePoint (this.seqs[i], scores[i]); -this.points.addElement (sp); -} -}); -Clazz.defineMethod (c$, "updateRc", -function (rc) { -rc.setPoints (this.points, this.pca.getM ().rows); -}, "jalview.api.RotatableCanvasI"); -Clazz.defineMethod (c$, "isNucleotide", -function () { -return this.nucleotide; -}); -Clazz.defineMethod (c$, "setNucleotide", -function (nucleotide) { -this.nucleotide = nucleotide; -}, "~B"); -Clazz.defineMethod (c$, "getTop", -function () { -return this.top; -}); -Clazz.defineMethod (c$, "updateRcView", -function (dim1, dim2, dim3) { -var scores = this.pca.getComponents (dim1 - 1, dim2 - 1, dim3 - 1, 100); -for (var i = 0; i < this.pca.getM ().rows; i++) { -(this.points.elementAt (i)).coord = scores[i]; -} -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "getDetails", -function () { -return this.pca.getDetails (); -}); -Clazz.defineMethod (c$, "getSeqtrings", -function () { -return this.seqstrings; -}); -Clazz.defineMethod (c$, "getPointsasCsv", -function (transformed, xdim, ydim, zdim) { -var csv = new StringBuffer (); -csv.append ("\"Sequence\""); -if (transformed) { -csv.append (","); -csv.append ("" + xdim); -csv.append (","); -csv.append ("" + ydim); -csv.append (","); -csv.append ("" + zdim); -} else { -for (var d = 1, dmax = this.pca.component (1).length; d <= dmax; d++) { -csv.append ("," + d); -} -}csv.append ("\n"); -for (var s = 0; s < this.seqs.length; s++) { -csv.append ("\"" + this.seqs[s].getName () + "\""); -var fl; -if (!transformed) { -fl = this.pca.component (s); -for (var d = fl.length - 1; d >= 0; d--) { -csv.append (","); -csv.append (fl[d]); -} -} else { -fl = this.getPointPosition (s); -for (var d = 0; d < fl.length; d++) { -csv.append (","); -csv.append (fl[d]); -} -}csv.append ("\n"); -} -return csv.toString (); -}, "~B,~N,~N,~N"); -Clazz.defineMethod (c$, "getPointPosition", -function (s) { -var pts = Clazz.newDoubleArray (3, 0); -var p = this.points.elementAt (s).coord; -pts[0] = p[0]; -pts[1] = p[1]; -pts[2] = p[2]; -return pts; -}, "~N"); -Clazz.defineMethod (c$, "setJvCalcMode", -function (state) { -this.jvCalcMode = state; -}, "~B"); -Clazz.defineMethod (c$, "getScore_matrix", -function () { -return this.score_matrix; -}); -Clazz.defineMethod (c$, "setScore_matrix", -function (score_matrix) { -this.score_matrix = score_matrix; -}, "~S"); -}); +Clazz.declarePackage ("jalview.viewmodel"); +Clazz.load (null, "jalview.viewmodel.PCAModel", ["jalview.analysis.PCA", "jalview.datamodel.SequencePoint", "java.lang.StringBuffer", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.pca = null; +this.top = 0; +this.seqstrings = null; +this.seqs = null; +this.score_matrix = null; +this.nucleotide = false; +this.points = null; +this.jvCalcMode = true; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel, "PCAModel"); +Clazz.makeConstructor (c$, +function (seqstrings2, seqs2, nucleotide2) { +this.seqstrings = seqstrings2; +this.seqs = seqs2; +this.nucleotide = nucleotide2; +this.score_matrix = nucleotide2 ? "PID" : "BLOSUM62"; +}, "jalview.datamodel.AlignmentView,~A,~B"); +Clazz.defineMethod (c$, "isJvCalcMode", +function () { +return this.jvCalcMode; +}); +Clazz.defineMethod (c$, "run", +function () { +this.pca = new jalview.analysis.PCA (this.seqstrings.getSequenceStrings (' '), this.nucleotide, this.score_matrix); +this.pca.setJvCalcMode (this.jvCalcMode); +this.pca.run (); +var ii = 0; +while ((ii < this.seqs.length) && (this.seqs[ii] != null)) { +ii++; +} +var comps = Clazz.newDoubleArray (ii, ii, 0); +for (var i = 0; i < ii; i++) { +if (this.pca.getEigenvalue (i) > 1e-4) { +comps[i] = this.pca.component (i); +}} +this.top = this.pca.getM ().rows - 1; +this.points = new java.util.Vector (); +var scores = this.pca.getComponents (this.top - 1, this.top - 2, this.top - 3, 100); +for (var i = 0; i < this.pca.getM ().rows; i++) { +var sp = new jalview.datamodel.SequencePoint (this.seqs[i], scores[i]); +this.points.addElement (sp); +} +}); +Clazz.defineMethod (c$, "updateRc", +function (rc) { +rc.setPoints (this.points, this.pca.getM ().rows); +}, "jalview.api.RotatableCanvasI"); +Clazz.defineMethod (c$, "isNucleotide", +function () { +return this.nucleotide; +}); +Clazz.defineMethod (c$, "setNucleotide", +function (nucleotide) { +this.nucleotide = nucleotide; +}, "~B"); +Clazz.defineMethod (c$, "getTop", +function () { +return this.top; +}); +Clazz.defineMethod (c$, "updateRcView", +function (dim1, dim2, dim3) { +var scores = this.pca.getComponents (dim1 - 1, dim2 - 1, dim3 - 1, 100); +for (var i = 0; i < this.pca.getM ().rows; i++) { +(this.points.elementAt (i)).coord = scores[i]; +} +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "getDetails", +function () { +return this.pca.getDetails (); +}); +Clazz.defineMethod (c$, "getSeqtrings", +function () { +return this.seqstrings; +}); +Clazz.defineMethod (c$, "getPointsasCsv", +function (transformed, xdim, ydim, zdim) { +var csv = new StringBuffer (); +csv.append ("\"Sequence\""); +if (transformed) { +csv.append (","); +csv.append ("" + xdim); +csv.append (","); +csv.append ("" + ydim); +csv.append (","); +csv.append ("" + zdim); +} else { +for (var d = 1, dmax = this.pca.component (1).length; d <= dmax; d++) { +csv.append ("," + d); +} +}csv.append ("\n"); +for (var s = 0; s < this.seqs.length; s++) { +csv.append ("\"" + this.seqs[s].getName () + "\""); +var fl; +if (!transformed) { +fl = this.pca.component (s); +for (var d = fl.length - 1; d >= 0; d--) { +csv.append (","); +csv.append (fl[d]); +} +} else { +fl = this.getPointPosition (s); +for (var d = 0; d < fl.length; d++) { +csv.append (","); +csv.append (fl[d]); +} +}csv.append ("\n"); +} +return csv.toString (); +}, "~B,~N,~N,~N"); +Clazz.defineMethod (c$, "getPointPosition", +function (s) { +var pts = Clazz.newDoubleArray (3, 0); +var p = this.points.elementAt (s).coord; +pts[0] = p[0]; +pts[1] = p[1]; +pts[2] = p[2]; +return pts; +}, "~N"); +Clazz.defineMethod (c$, "setJvCalcMode", +function (state) { +this.jvCalcMode = state; +}, "~B"); +Clazz.defineMethod (c$, "getScore_matrix", +function () { +return this.score_matrix; +}); +Clazz.defineMethod (c$, "setScore_matrix", +function (score_matrix) { +this.score_matrix = score_matrix; +}, "~S"); +}); diff --git a/bin/jalview/viewmodel/annotationfilter/AnnotationFilterParameter.js b/bin/jalview/viewmodel/annotationfilter/AnnotationFilterParameter.js index 5fd34a4..7daaad4 100644 --- a/bin/jalview/viewmodel/annotationfilter/AnnotationFilterParameter.js +++ b/bin/jalview/viewmodel/annotationfilter/AnnotationFilterParameter.js @@ -1,83 +1,83 @@ -Clazz.declarePackage ("jalview.viewmodel.annotationfilter"); -Clazz.load (["java.lang.Enum", "java.util.ArrayList"], "jalview.viewmodel.annotationfilter.AnnotationFilterParameter", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.thresholdType = null; -this.thresholdValue = 0; -this.filterAlphaHelix = false; -this.filterBetaSheet = false; -this.filterTurn = false; -this.regexString = null; -this.regexSearchFields = null; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel.annotationfilter, "AnnotationFilterParameter"); -Clazz.prepareFields (c$, function () { -this.regexSearchFields = new java.util.ArrayList (); -}); -Clazz.defineMethod (c$, "getThresholdType", -function () { -return this.thresholdType; -}); -Clazz.defineMethod (c$, "setThresholdType", -function (thresholdType) { -this.thresholdType = thresholdType; -}, "jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType"); -Clazz.defineMethod (c$, "getThresholdValue", -function () { -return this.thresholdValue; -}); -Clazz.defineMethod (c$, "setThresholdValue", -function (thresholdValue) { -this.thresholdValue = thresholdValue; -}, "~N"); -Clazz.defineMethod (c$, "getRegexString", -function () { -return this.regexString; -}); -Clazz.defineMethod (c$, "setRegexString", -function (regexString) { -this.regexString = regexString; -}, "~S"); -Clazz.defineMethod (c$, "getRegexSearchFields", -function () { -return this.regexSearchFields; -}); -Clazz.defineMethod (c$, "addRegexSearchField", -function (regexSearchField) { -this.regexSearchFields.add (regexSearchField); -}, "jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField"); -Clazz.defineMethod (c$, "isFilterAlphaHelix", -function () { -return this.filterAlphaHelix; -}); -Clazz.defineMethod (c$, "setFilterAlphaHelix", -function (alphaHelix) { -this.filterAlphaHelix = alphaHelix; -}, "~B"); -Clazz.defineMethod (c$, "isFilterBetaSheet", -function () { -return this.filterBetaSheet; -}); -Clazz.defineMethod (c$, "setFilterBetaSheet", -function (betaSheet) { -this.filterBetaSheet = betaSheet; -}, "~B"); -Clazz.defineMethod (c$, "isFilterTurn", -function () { -return this.filterTurn; -}); -Clazz.defineMethod (c$, "setFilterTurn", -function (turn) { -this.filterTurn = turn; -}, "~B"); -Clazz.pu$h (); -c$ = Clazz.declareType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter, "ThresholdType", Enum); -Clazz.defineEnumConstant (c$, "NO_THRESHOLD", 0, []); -Clazz.defineEnumConstant (c$, "BELOW_THRESHOLD", 1, []); -Clazz.defineEnumConstant (c$, "ABOVE_THRESHOLD", 2, []); -c$ = Clazz.p0p (); -Clazz.pu$h (); -c$ = Clazz.declareType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter, "SearchableAnnotationField", Enum); -Clazz.defineEnumConstant (c$, "DISPLAY_STRING", 0, []); -Clazz.defineEnumConstant (c$, "DESCRIPTION", 1, []); -c$ = Clazz.p0p (); -}); +Clazz.declarePackage ("jalview.viewmodel.annotationfilter"); +Clazz.load (["java.lang.Enum", "java.util.ArrayList"], "jalview.viewmodel.annotationfilter.AnnotationFilterParameter", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.thresholdType = null; +this.thresholdValue = 0; +this.filterAlphaHelix = false; +this.filterBetaSheet = false; +this.filterTurn = false; +this.regexString = null; +this.regexSearchFields = null; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel.annotationfilter, "AnnotationFilterParameter"); +Clazz.prepareFields (c$, function () { +this.regexSearchFields = new java.util.ArrayList (); +}); +Clazz.defineMethod (c$, "getThresholdType", +function () { +return this.thresholdType; +}); +Clazz.defineMethod (c$, "setThresholdType", +function (thresholdType) { +this.thresholdType = thresholdType; +}, "jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType"); +Clazz.defineMethod (c$, "getThresholdValue", +function () { +return this.thresholdValue; +}); +Clazz.defineMethod (c$, "setThresholdValue", +function (thresholdValue) { +this.thresholdValue = thresholdValue; +}, "~N"); +Clazz.defineMethod (c$, "getRegexString", +function () { +return this.regexString; +}); +Clazz.defineMethod (c$, "setRegexString", +function (regexString) { +this.regexString = regexString; +}, "~S"); +Clazz.defineMethod (c$, "getRegexSearchFields", +function () { +return this.regexSearchFields; +}); +Clazz.defineMethod (c$, "addRegexSearchField", +function (regexSearchField) { +this.regexSearchFields.add (regexSearchField); +}, "jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField"); +Clazz.defineMethod (c$, "isFilterAlphaHelix", +function () { +return this.filterAlphaHelix; +}); +Clazz.defineMethod (c$, "setFilterAlphaHelix", +function (alphaHelix) { +this.filterAlphaHelix = alphaHelix; +}, "~B"); +Clazz.defineMethod (c$, "isFilterBetaSheet", +function () { +return this.filterBetaSheet; +}); +Clazz.defineMethod (c$, "setFilterBetaSheet", +function (betaSheet) { +this.filterBetaSheet = betaSheet; +}, "~B"); +Clazz.defineMethod (c$, "isFilterTurn", +function () { +return this.filterTurn; +}); +Clazz.defineMethod (c$, "setFilterTurn", +function (turn) { +this.filterTurn = turn; +}, "~B"); +Clazz.pu$h (); +c$ = Clazz.declareType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter, "ThresholdType", Enum); +Clazz.defineEnumConstant (c$, "NO_THRESHOLD", 0, []); +Clazz.defineEnumConstant (c$, "BELOW_THRESHOLD", 1, []); +Clazz.defineEnumConstant (c$, "ABOVE_THRESHOLD", 2, []); +c$ = Clazz.p0p (); +Clazz.pu$h (); +c$ = Clazz.declareType (jalview.viewmodel.annotationfilter.AnnotationFilterParameter, "SearchableAnnotationField", Enum); +Clazz.defineEnumConstant (c$, "DISPLAY_STRING", 0, []); +Clazz.defineEnumConstant (c$, "DESCRIPTION", 1, []); +c$ = Clazz.p0p (); +}); diff --git a/bin/jalview/viewmodel/seqfeatures/FeatureRendererModel.js b/bin/jalview/viewmodel/seqfeatures/FeatureRendererModel.js index 985bdda..cd53bbe 100644 --- a/bin/jalview/viewmodel/seqfeatures/FeatureRendererModel.js +++ b/bin/jalview/viewmodel/seqfeatures/FeatureRendererModel.js @@ -1,481 +1,481 @@ -Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); -Clazz.load (["jalview.api.FeatureRenderer", "java.beans.PropertyChangeSupport", "java.lang.Boolean", "java.util.Hashtable", "java.util.concurrent.ConcurrentHashMap"], "jalview.viewmodel.seqfeatures.FeatureRendererModel", ["jalview.schemes.GraduatedColor", "$.UserColourScheme", "jalview.util.QuickSort", "jalview.viewmodel.seqfeatures.FeatureRendererSettings", "$.FeaturesDisplayed", "java.awt.Color", "java.lang.Error", "$.Float", "java.util.ArrayList", "$.Arrays"], function () { -c$ = Clazz.decorateAsClass (function () { -this.transparency = 1.0; -this.featureColours = null; -this.featureGroups = null; -this.currentColour = null; -this.renderOrder = null; -this.changeSupport = null; -this.av = null; -this.minmax = null; -this.newFeatureAdded = false; -this.findingFeatures = false; -this.firing = null; -this.featureOrder = null; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel.seqfeatures, "FeatureRendererModel", null, jalview.api.FeatureRenderer); -Clazz.prepareFields (c$, function () { -this.featureColours = new java.util.concurrent.ConcurrentHashMap (); -this.featureGroups = new java.util.concurrent.ConcurrentHashMap (); -this.changeSupport = new java.beans.PropertyChangeSupport (this); -this.minmax = new java.util.Hashtable (); -this.firing = Boolean.FALSE; -}); -Clazz.overrideMethod (c$, "getViewport", -function () { -return this.av; -}); -Clazz.defineMethod (c$, "getSettings", -function () { -return new jalview.viewmodel.seqfeatures.FeatureRendererSettings (this); -}); -Clazz.defineMethod (c$, "transferSettings", -function (fr) { -this.renderOrder = fr.renderOrder; -this.featureGroups = fr.featureGroups; -this.featureColours = fr.featureColours; -this.transparency = fr.transparency; -this.featureOrder = fr.featureOrder; -}, "jalview.viewmodel.seqfeatures.FeatureRendererSettings"); -Clazz.defineMethod (c$, "transferSettings", -function (_fr) { -var fr = _fr; -var frs = new jalview.viewmodel.seqfeatures.FeatureRendererSettings (fr); -this.renderOrder = frs.renderOrder; -this.featureGroups = frs.featureGroups; -this.featureColours = frs.featureColours; -this.transparency = frs.transparency; -this.featureOrder = frs.featureOrder; -if (this.av != null && this.av !== fr.getViewport ()) { -if (_fr.getFeaturesDisplayed () != null) { -var fd = this.getFeaturesDisplayed (); -if (fd == null) { -this.setFeaturesDisplayedFrom (_fr.getFeaturesDisplayed ()); -} else { -{ -fd.clear (); -var fdisp = _fr.getFeaturesDisplayed ().getVisibleFeatures (); -while (fdisp.hasNext ()) { -fd.setVisible (fdisp.next ()); -} -}}}}}, "jalview.api.FeatureRenderer"); -Clazz.defineMethod (c$, "setFeaturesDisplayedFrom", -function (featuresDisplayed) { -this.av.setFeaturesDisplayed ( new jalview.viewmodel.seqfeatures.FeaturesDisplayed (featuresDisplayed)); -}, "jalview.api.FeaturesDisplayedI"); -Clazz.overrideMethod (c$, "setVisible", -function (featureType) { -var fdi = this.av.getFeaturesDisplayed (); -if (fdi == null) { -this.av.setFeaturesDisplayed (fdi = new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); -}if (!fdi.isRegistered (featureType)) { -this.pushFeatureType (java.util.Arrays.asList ( Clazz.newArray (-1, [featureType]))); -}fdi.setVisible (featureType); -}, "~S"); -Clazz.overrideMethod (c$, "setAllVisible", -function (featureTypes) { -var fdi = this.av.getFeaturesDisplayed (); -if (fdi == null) { -this.av.setFeaturesDisplayed (fdi = new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); -}var nft = new java.util.ArrayList (); -for (var featureType, $featureType = featureTypes.iterator (); $featureType.hasNext () && ((featureType = $featureType.next ()) || true);) { -if (!fdi.isRegistered (featureType)) { -nft.add (featureType); -}} -if (nft.size () > 0) { -this.pushFeatureType (nft); -}fdi.setAllVisible (featureTypes); -}, "java.util.List"); -Clazz.defineMethod (c$, "pushFeatureType", -($fz = function (types) { -var ts = types.size (); -var neworder = new Array ((this.renderOrder == null ? 0 : this.renderOrder.length) + ts); -types.toArray (neworder); -if (this.renderOrder != null) { -System.arraycopy (neworder, 0, neworder, this.renderOrder.length, ts); -System.arraycopy (this.renderOrder, 0, neworder, 0, this.renderOrder.length); -}this.renderOrder = neworder; -}, $fz.isPrivate = true, $fz), "java.util.List"); -Clazz.defineMethod (c$, "getMinMax", -function () { -return this.minmax; -}); -Clazz.defineMethod (c$, "normaliseScore", -function (sequenceFeature) { -var mm = (this.minmax.get (sequenceFeature.type))[0]; -var r = Clazz.newByteArray (-1, [0, 255]); -if (mm != null) { -if (r[0] != 0 || mm[0] < 0.0) { -r[0] = 1; -r[1] = Clazz.doubleToByte (Clazz.doubleToInt (128.0) + 127.0 * (sequenceFeature.score / mm[1])); -} else { -r[1] = Clazz.floatToByte (Clazz.doubleToInt (255.0) * (sequenceFeature.score / mm[1])); -}}return r; -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "updateFeatures", -function () { -if (this.av.getFeaturesDisplayed () == null || this.renderOrder == null || this.newFeatureAdded) { -this.findAllFeatures (); -if (this.av.getFeaturesDisplayed ().getVisibleFeatureCount () < 1) { -return false; -}}return true; -}); -Clazz.defineMethod (c$, "findAllFeatures", -function () { -{ -if (this.firing.equals (Boolean.FALSE)) { -this.firing = Boolean.TRUE; -this.findAllFeatures (true); -this.changeSupport.firePropertyChange ("changeSupport", null, null); -this.firing = Boolean.FALSE; -}}}); -Clazz.overrideMethod (c$, "findFeaturesAtRes", -function (sequence, res) { -var tmp = new java.util.ArrayList (); -var features = sequence.getSequenceFeatures (); -if (features != null) { -for (var i = 0; i < features.length; i++) { -if (!this.av.areFeaturesDisplayed () || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) { -continue; -}if (features[i].featureGroup != null && this.featureGroups != null && this.featureGroups.containsKey (features[i].featureGroup) && !this.featureGroups.get (features[i].featureGroup).booleanValue ()) { -continue; -}if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) { -tmp.add (features[i]); -}} -}return tmp; -}, "jalview.datamodel.SequenceI,~N"); -Clazz.defineMethod (c$, "findAllFeatures", -function (newMadeVisible) { -this.newFeatureAdded = false; -if (this.findingFeatures) { -this.newFeatureAdded = true; -return; -}this.findingFeatures = true; -if (this.av.getFeaturesDisplayed () == null) { -this.av.setFeaturesDisplayed ( new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); -}var featuresDisplayed = this.av.getFeaturesDisplayed (); -var allfeatures = new java.util.ArrayList (); -var oldfeatures = new java.util.ArrayList (); -if (this.renderOrder != null) { -for (var i = 0; i < this.renderOrder.length; i++) { -if (this.renderOrder[i] != null) { -oldfeatures.add (this.renderOrder[i]); -}} -}if (this.minmax == null) { -this.minmax = new java.util.Hashtable (); -}var alignment = this.av.getAlignment (); -for (var i = 0; i < alignment.getHeight (); i++) { -var asq = alignment.getSequenceAt (i); -var features = asq.getSequenceFeatures (); -if (features == null) { -continue; -}var index = 0; -while (index < features.length) { -if (!featuresDisplayed.isRegistered (features[index].getType ())) { -var fgrp = features[index].getFeatureGroup (); -if (fgrp != null) { -var groupDisplayed = this.featureGroups.get (fgrp); -if (groupDisplayed == null) { -groupDisplayed = Boolean.$valueOf (newMadeVisible); -this.featureGroups.put (fgrp, groupDisplayed); -}if (!groupDisplayed.booleanValue ()) { -index++; -continue; -}}if (!(features[index].begin == 0 && features[index].end == 0)) { -if (newMadeVisible && !oldfeatures.contains (features[index].getType ())) { -featuresDisplayed.setVisible (features[index].getType ()); -this.setOrder (features[index].getType (), 0); -}}}if (!allfeatures.contains (features[index].getType ())) { -allfeatures.add (features[index].getType ()); -}if (!Float.isNaN (features[index].score)) { -var nonpos = features[index].getBegin () >= 1 ? 0 : 1; -var mm = this.minmax.get (features[index].getType ()); -if (mm == null) { -mm = Clazz.newArray (-1, [null, null]); -this.minmax.put (features[index].getType (), mm); -}if (mm[nonpos] == null) { -mm[nonpos] = Clazz.newFloatArray (-1, [features[index].score, features[index].score]); -} else { -if (mm[nonpos][0] > features[index].score) { -mm[nonpos][0] = features[index].score; -}if (mm[nonpos][1] < features[index].score) { -mm[nonpos][1] = features[index].score; -}}}index++; -} -} -this.updateRenderOrder (allfeatures); -this.findingFeatures = false; -}, "~B"); -Clazz.defineMethod (c$, "updateRenderOrder", -($fz = function (allFeatures) { -var allfeatures = new java.util.ArrayList (allFeatures); -var oldRender = this.renderOrder; -this.renderOrder = new Array (allfeatures.size ()); -var mmrange; -var fc = null; -var initOrders = (this.featureOrder == null); -var opos = 0; -if (oldRender != null && oldRender.length > 0) { -for (var j = 0; j < oldRender.length; j++) { -if (oldRender[j] != null) { -if (initOrders) { -this.setOrder (oldRender[j], (1 - (1 + j) / oldRender.length)); -}if (allfeatures.contains (oldRender[j])) { -this.renderOrder[opos++] = oldRender[j]; -allfeatures.remove (oldRender[j]); -if (this.minmax != null) { -mmrange = this.minmax.get (oldRender[j]); -if (mmrange != null) { -fc = this.featureColours.get (oldRender[j]); -if (fc != null && Clazz.instanceOf (fc, jalview.schemes.GraduatedColor) && (fc).isAutoScale ()) { -(fc).updateBounds ((mmrange)[0][0], (mmrange)[0][1]); -}}}}}} -}if (allfeatures.size () == 0) { -return; -}var i = allfeatures.size () - 1; -var iSize = i; -var sort = false; -var newf = new Array (allfeatures.size ()); -var sortOrder = Clazz.newFloatArray (allfeatures.size (), 0); -for (var newfeat, $newfeat = allfeatures.iterator (); $newfeat.hasNext () && ((newfeat = $newfeat.next ()) || true);) { -newf[i] = newfeat; -if (this.minmax != null) { -mmrange = this.minmax.get (newf[i]); -if (mmrange != null) { -fc = this.featureColours.get (newf[i]); -if (fc != null && Clazz.instanceOf (fc, jalview.schemes.GraduatedColor) && (fc).isAutoScale ()) { -(fc).updateBounds ((mmrange)[0][0], (mmrange)[0][1]); -}}}if (initOrders || !this.featureOrder.containsKey (newf[i])) { -var denom = initOrders ? allfeatures.size () : this.featureOrder.size (); -this.setOrder (newf[i], i / denom); -}sortOrder[i] = 2 - (this.featureOrder.get (newf[i])).floatValue (); -if (i < iSize) { -sort = sort || sortOrder[i] > sortOrder[i + 1]; -}i--; -} -if (iSize > 1 && sort) { -jalview.util.QuickSort.sortFloatObject (sortOrder, newf); -}sortOrder = null; -System.arraycopy (newf, 0, this.renderOrder, opos, newf.length); -}, $fz.isPrivate = true, $fz), "java.util.List"); -Clazz.overrideMethod (c$, "getFeatureStyle", -function (featureType) { -var fc = this.featureColours.get (featureType); -if (fc == null) { -var ucs = new jalview.schemes.UserColourScheme (); -var col = ucs.createColourFromName (featureType); -this.featureColours.put (featureType, fc = col); -}return fc; -}, "~S"); -Clazz.defineMethod (c$, "getColour", -function (featureType) { -var fc = this.getFeatureStyle (featureType); -if (Clazz.instanceOf (fc, java.awt.Color)) { -return fc; -} else { -if (Clazz.instanceOf (fc, jalview.schemes.GraduatedColor)) { -return (fc).getMaxColor (); -}}throw new Error ("Implementation Error: Unrecognised render object " + fc.getClass () + " for features of type " + featureType); -}, "~S"); -Clazz.defineMethod (c$, "getColour", -function (feature) { -var fc = this.getFeatureStyle (feature.getType ()); -if (Clazz.instanceOf (fc, java.awt.Color)) { -return fc; -} else { -if (Clazz.instanceOf (fc, jalview.schemes.GraduatedColor)) { -return (fc).findColor (feature); -}}throw new Error ("Implementation Error: Unrecognised render object " + fc.getClass () + " for features of type " + feature.getType ()); -}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "showFeature", -function (sequenceFeature) { -var fc = this.getFeatureStyle (sequenceFeature.type); -if (Clazz.instanceOf (fc, jalview.schemes.GraduatedColor)) { -return (fc).isColored (sequenceFeature); -} else { -return true; -}}, "jalview.datamodel.SequenceFeature"); -Clazz.defineMethod (c$, "showFeatureOfType", -function (type) { -return this.av.getFeaturesDisplayed ().isVisible (type); -}, "~S"); -Clazz.overrideMethod (c$, "setColour", -function (featureType, col) { -{ -this.featureColours.put (featureType, col); -}}, "~S,~O"); -Clazz.defineMethod (c$, "setTransparency", -function (value) { -this.transparency = value; -}, "~N"); -Clazz.defineMethod (c$, "getTransparency", -function () { -return this.transparency; -}); -Clazz.defineMethod (c$, "setOrder", -function (type, position) { -if (this.featureOrder == null) { -this.featureOrder = new java.util.Hashtable (); -}this.featureOrder.put (type, new Float (position)); -return position; -}, "~S,~N"); -Clazz.defineMethod (c$, "getOrder", -function (type) { -if (this.featureOrder != null) { -if (this.featureOrder.containsKey (type)) { -return (this.featureOrder.get (type)).floatValue (); -}}return -1; -}, "~S"); -Clazz.overrideMethod (c$, "getFeatureColours", -function () { -return new java.util.concurrent.ConcurrentHashMap (this.featureColours); -}); -Clazz.defineMethod (c$, "setFeaturePriority", -function (data) { -this.setFeaturePriority (data, true); -}, "~A"); -Clazz.defineMethod (c$, "setFeaturePriority", -function (data, visibleNew) { -var av_featuresdisplayed = null; -if (visibleNew) { -if ((av_featuresdisplayed = this.av.getFeaturesDisplayed ()) != null) { -this.av.getFeaturesDisplayed ().clear (); -} else { -this.av.setFeaturesDisplayed (av_featuresdisplayed = new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); -}} else { -av_featuresdisplayed = this.av.getFeaturesDisplayed (); -}if (data == null) { -return; -}this.renderOrder = new Array (data.length); -if (data.length > 0) { -for (var i = 0; i < data.length; i++) { -var type = data[i][0].toString (); -this.setColour (type, data[i][1]); -if ((data[i][2]).booleanValue ()) { -av_featuresdisplayed.setVisible (type); -}this.renderOrder[data.length - i - 1] = type; -} -}}, "~A,~B"); -Clazz.defineMethod (c$, "addPropertyChangeListener", -function (listener) { -this.changeSupport.addPropertyChangeListener (listener); -}, "java.beans.PropertyChangeListener"); -Clazz.defineMethod (c$, "removePropertyChangeListener", -function (listener) { -this.changeSupport.removePropertyChangeListener (listener); -}, "java.beans.PropertyChangeListener"); -Clazz.defineMethod (c$, "getAllFeatureColours", -function () { -return this.featureColours.keySet (); -}); -Clazz.defineMethod (c$, "clearRenderOrder", -function () { -this.renderOrder = null; -}); -Clazz.defineMethod (c$, "hasRenderOrder", -function () { -return this.renderOrder != null; -}); -Clazz.defineMethod (c$, "getRenderOrder", -function () { -if (this.renderOrder == null) { -return java.util.Arrays.asList ( Clazz.newArray (-1, [])); -}return java.util.Arrays.asList (this.renderOrder); -}); -Clazz.defineMethod (c$, "getFeatureGroupsSize", -function () { -return this.featureGroups != null ? 0 : this.featureGroups.size (); -}); -Clazz.overrideMethod (c$, "getFeatureGroups", -function () { -return (this.featureGroups == null) ? java.util.Arrays.asList ( new Array (0)) : java.util.Arrays.asList (this.featureGroups.keySet ().toArray ( new Array (0))); -}); -Clazz.defineMethod (c$, "checkGroupVisibility", -function (group, newGroupsVisible) { -if (this.featureGroups == null) { -}if (this.featureGroups.containsKey (group)) { -return this.featureGroups.get (group).booleanValue (); -}if (newGroupsVisible) { -this.featureGroups.put (group, new Boolean (true)); -return true; -}return false; -}, "~S,~B"); -Clazz.overrideMethod (c$, "getGroups", -function (visible) { -if (this.featureGroups != null) { -var gp = new java.util.ArrayList (); -for (var grp, $grp = this.featureGroups.keySet ().iterator (); $grp.hasNext () && ((grp = $grp.next ()) || true);) { -var state = this.featureGroups.get (grp); -if (state.booleanValue () == visible) { -gp.add (grp); -}} -return gp; -}return null; -}, "~B"); -Clazz.defineMethod (c$, "setGroupVisibility", -function (group, visible) { -this.featureGroups.put (group, new Boolean (visible)); -}, "~S,~B"); -Clazz.defineMethod (c$, "setGroupVisibility", -function (toset, visible) { -if (toset != null && toset.size () > 0 && this.featureGroups != null) { -var rdrw = false; -for (var gst, $gst = toset.iterator (); $gst.hasNext () && ((gst = $gst.next ()) || true);) { -var st = this.featureGroups.get (gst); -this.featureGroups.put (gst, new Boolean (visible)); -if (st != null) { -rdrw = rdrw || (visible != st.booleanValue ()); -}} -if (rdrw) { -}}}, "java.util.List,~B"); -Clazz.overrideMethod (c$, "getDisplayedFeatureCols", -function () { -var fcols = new java.util.Hashtable (); -if (this.getViewport ().getFeaturesDisplayed () == null) { -return fcols; -}var en = this.getViewport ().getFeaturesDisplayed ().getVisibleFeatures (); -while (en.hasNext ()) { -var col = en.next (); -fcols.put (col, this.getColour (col)); -} -return fcols; -}); -Clazz.defineMethod (c$, "getFeaturesDisplayed", -function () { -return this.av.getFeaturesDisplayed (); -}); -Clazz.overrideMethod (c$, "getDisplayedFeatureTypes", -function () { -var typ = null; -typ = this.getRenderOrder ().toArray ( new Array (0)); -var feature_disp = this.av.getFeaturesDisplayed (); -if (feature_disp != null) { -{ -for (var i = 0; i < typ.length; i++) { -if (!feature_disp.isVisible (typ[i])) { -typ[i] = null; -}} -}}return typ; -}); -Clazz.overrideMethod (c$, "getDisplayedFeatureGroups", -function () { -var gps = null; -var _gps = new java.util.ArrayList (); -var en = this.getFeatureGroups ().iterator (); -var g = 0; -var valid = false; -while (en.hasNext ()) { -var gp = en.next (); -if (this.checkGroupVisibility (gp, false)) { -valid = true; -_gps.add (gp); -}if (!valid) { -return null; -} else { -gps = new Array (_gps.size ()); -_gps.toArray (gps); -}} -return gps; -}); -}); +Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); +Clazz.load (["jalview.api.FeatureRenderer", "java.beans.PropertyChangeSupport", "java.lang.Boolean", "java.util.Hashtable", "java.util.concurrent.ConcurrentHashMap"], "jalview.viewmodel.seqfeatures.FeatureRendererModel", ["jalview.schemes.GraduatedColor", "$.UserColourScheme", "jalview.util.QuickSort", "jalview.viewmodel.seqfeatures.FeatureRendererSettings", "$.FeaturesDisplayed", "java.awt.Color", "java.lang.Error", "$.Float", "java.util.ArrayList", "$.Arrays"], function () { +c$ = Clazz.decorateAsClass (function () { +this.transparency = 1.0; +this.featureColours = null; +this.featureGroups = null; +this.currentColour = null; +this.renderOrder = null; +this.changeSupport = null; +this.av = null; +this.minmax = null; +this.newFeatureAdded = false; +this.findingFeatures = false; +this.firing = null; +this.featureOrder = null; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel.seqfeatures, "FeatureRendererModel", null, jalview.api.FeatureRenderer); +Clazz.prepareFields (c$, function () { +this.featureColours = new java.util.concurrent.ConcurrentHashMap (); +this.featureGroups = new java.util.concurrent.ConcurrentHashMap (); +this.changeSupport = new java.beans.PropertyChangeSupport (this); +this.minmax = new java.util.Hashtable (); +this.firing = Boolean.FALSE; +}); +Clazz.overrideMethod (c$, "getViewport", +function () { +return this.av; +}); +Clazz.defineMethod (c$, "getSettings", +function () { +return new jalview.viewmodel.seqfeatures.FeatureRendererSettings (this); +}); +Clazz.defineMethod (c$, "transferSettings", +function (fr) { +this.renderOrder = fr.renderOrder; +this.featureGroups = fr.featureGroups; +this.featureColours = fr.featureColours; +this.transparency = fr.transparency; +this.featureOrder = fr.featureOrder; +}, "jalview.viewmodel.seqfeatures.FeatureRendererSettings"); +Clazz.defineMethod (c$, "transferSettings", +function (_fr) { +var fr = _fr; +var frs = new jalview.viewmodel.seqfeatures.FeatureRendererSettings (fr); +this.renderOrder = frs.renderOrder; +this.featureGroups = frs.featureGroups; +this.featureColours = frs.featureColours; +this.transparency = frs.transparency; +this.featureOrder = frs.featureOrder; +if (this.av != null && this.av !== fr.getViewport ()) { +if (_fr.getFeaturesDisplayed () != null) { +var fd = this.getFeaturesDisplayed (); +if (fd == null) { +this.setFeaturesDisplayedFrom (_fr.getFeaturesDisplayed ()); +} else { +{ +fd.clear (); +var fdisp = _fr.getFeaturesDisplayed ().getVisibleFeatures (); +while (fdisp.hasNext ()) { +fd.setVisible (fdisp.next ()); +} +}}}}}, "jalview.api.FeatureRenderer"); +Clazz.defineMethod (c$, "setFeaturesDisplayedFrom", +function (featuresDisplayed) { +this.av.setFeaturesDisplayed ( new jalview.viewmodel.seqfeatures.FeaturesDisplayed (featuresDisplayed)); +}, "jalview.api.FeaturesDisplayedI"); +Clazz.overrideMethod (c$, "setVisible", +function (featureType) { +var fdi = this.av.getFeaturesDisplayed (); +if (fdi == null) { +this.av.setFeaturesDisplayed (fdi = new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); +}if (!fdi.isRegistered (featureType)) { +this.pushFeatureType (java.util.Arrays.asList ( Clazz.newArray (-1, [featureType]))); +}fdi.setVisible (featureType); +}, "~S"); +Clazz.overrideMethod (c$, "setAllVisible", +function (featureTypes) { +var fdi = this.av.getFeaturesDisplayed (); +if (fdi == null) { +this.av.setFeaturesDisplayed (fdi = new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); +}var nft = new java.util.ArrayList (); +for (var featureType, $featureType = featureTypes.iterator (); $featureType.hasNext () && ((featureType = $featureType.next ()) || true);) { +if (!fdi.isRegistered (featureType)) { +nft.add (featureType); +}} +if (nft.size () > 0) { +this.pushFeatureType (nft); +}fdi.setAllVisible (featureTypes); +}, "java.util.List"); +Clazz.defineMethod (c$, "pushFeatureType", +($fz = function (types) { +var ts = types.size (); +var neworder = new Array ((this.renderOrder == null ? 0 : this.renderOrder.length) + ts); +types.toArray (neworder); +if (this.renderOrder != null) { +System.arraycopy (neworder, 0, neworder, this.renderOrder.length, ts); +System.arraycopy (this.renderOrder, 0, neworder, 0, this.renderOrder.length); +}this.renderOrder = neworder; +}, $fz.isPrivate = true, $fz), "java.util.List"); +Clazz.defineMethod (c$, "getMinMax", +function () { +return this.minmax; +}); +Clazz.defineMethod (c$, "normaliseScore", +function (sequenceFeature) { +var mm = (this.minmax.get (sequenceFeature.type))[0]; +var r = Clazz.newByteArray (-1, [0, 255]); +if (mm != null) { +if (r[0] != 0 || mm[0] < 0.0) { +r[0] = 1; +r[1] = Clazz.doubleToByte (Clazz.doubleToInt (128.0) + 127.0 * (sequenceFeature.score / mm[1])); +} else { +r[1] = Clazz.floatToByte (Clazz.doubleToInt (255.0) * (sequenceFeature.score / mm[1])); +}}return r; +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "updateFeatures", +function () { +if (this.av.getFeaturesDisplayed () == null || this.renderOrder == null || this.newFeatureAdded) { +this.findAllFeatures (); +if (this.av.getFeaturesDisplayed ().getVisibleFeatureCount () < 1) { +return false; +}}return true; +}); +Clazz.defineMethod (c$, "findAllFeatures", +function () { +{ +if (this.firing.equals (Boolean.FALSE)) { +this.firing = Boolean.TRUE; +this.findAllFeatures (true); +this.changeSupport.firePropertyChange ("changeSupport", null, null); +this.firing = Boolean.FALSE; +}}}); +Clazz.overrideMethod (c$, "findFeaturesAtRes", +function (sequence, res) { +var tmp = new java.util.ArrayList (); +var features = sequence.getSequenceFeatures (); +if (features != null) { +for (var i = 0; i < features.length; i++) { +if (!this.av.areFeaturesDisplayed () || !this.av.getFeaturesDisplayed ().isVisible (features[i].getType ())) { +continue; +}if (features[i].featureGroup != null && this.featureGroups != null && this.featureGroups.containsKey (features[i].featureGroup) && !this.featureGroups.get (features[i].featureGroup).booleanValue ()) { +continue; +}if ((features[i].getBegin () <= res) && (features[i].getEnd () >= res)) { +tmp.add (features[i]); +}} +}return tmp; +}, "jalview.datamodel.SequenceI,~N"); +Clazz.defineMethod (c$, "findAllFeatures", +function (newMadeVisible) { +this.newFeatureAdded = false; +if (this.findingFeatures) { +this.newFeatureAdded = true; +return; +}this.findingFeatures = true; +if (this.av.getFeaturesDisplayed () == null) { +this.av.setFeaturesDisplayed ( new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); +}var featuresDisplayed = this.av.getFeaturesDisplayed (); +var allfeatures = new java.util.ArrayList (); +var oldfeatures = new java.util.ArrayList (); +if (this.renderOrder != null) { +for (var i = 0; i < this.renderOrder.length; i++) { +if (this.renderOrder[i] != null) { +oldfeatures.add (this.renderOrder[i]); +}} +}if (this.minmax == null) { +this.minmax = new java.util.Hashtable (); +}var alignment = this.av.getAlignment (); +for (var i = 0; i < alignment.getHeight (); i++) { +var asq = alignment.getSequenceAt (i); +var features = asq.getSequenceFeatures (); +if (features == null) { +continue; +}var index = 0; +while (index < features.length) { +if (!featuresDisplayed.isRegistered (features[index].getType ())) { +var fgrp = features[index].getFeatureGroup (); +if (fgrp != null) { +var groupDisplayed = this.featureGroups.get (fgrp); +if (groupDisplayed == null) { +groupDisplayed = Boolean.$valueOf (newMadeVisible); +this.featureGroups.put (fgrp, groupDisplayed); +}if (!groupDisplayed.booleanValue ()) { +index++; +continue; +}}if (!(features[index].begin == 0 && features[index].end == 0)) { +if (newMadeVisible && !oldfeatures.contains (features[index].getType ())) { +featuresDisplayed.setVisible (features[index].getType ()); +this.setOrder (features[index].getType (), 0); +}}}if (!allfeatures.contains (features[index].getType ())) { +allfeatures.add (features[index].getType ()); +}if (!Float.isNaN (features[index].score)) { +var nonpos = features[index].getBegin () >= 1 ? 0 : 1; +var mm = this.minmax.get (features[index].getType ()); +if (mm == null) { +mm = Clazz.newArray (-1, [null, null]); +this.minmax.put (features[index].getType (), mm); +}if (mm[nonpos] == null) { +mm[nonpos] = Clazz.newFloatArray (-1, [features[index].score, features[index].score]); +} else { +if (mm[nonpos][0] > features[index].score) { +mm[nonpos][0] = features[index].score; +}if (mm[nonpos][1] < features[index].score) { +mm[nonpos][1] = features[index].score; +}}}index++; +} +} +this.updateRenderOrder (allfeatures); +this.findingFeatures = false; +}, "~B"); +Clazz.defineMethod (c$, "updateRenderOrder", +($fz = function (allFeatures) { +var allfeatures = new java.util.ArrayList (allFeatures); +var oldRender = this.renderOrder; +this.renderOrder = new Array (allfeatures.size ()); +var mmrange; +var fc = null; +var initOrders = (this.featureOrder == null); +var opos = 0; +if (oldRender != null && oldRender.length > 0) { +for (var j = 0; j < oldRender.length; j++) { +if (oldRender[j] != null) { +if (initOrders) { +this.setOrder (oldRender[j], (1 - (1 + j) / oldRender.length)); +}if (allfeatures.contains (oldRender[j])) { +this.renderOrder[opos++] = oldRender[j]; +allfeatures.remove (oldRender[j]); +if (this.minmax != null) { +mmrange = this.minmax.get (oldRender[j]); +if (mmrange != null) { +fc = this.featureColours.get (oldRender[j]); +if (fc != null && Clazz.instanceOf (fc, jalview.schemes.GraduatedColor) && (fc).isAutoScale ()) { +(fc).updateBounds ((mmrange)[0][0], (mmrange)[0][1]); +}}}}}} +}if (allfeatures.size () == 0) { +return; +}var i = allfeatures.size () - 1; +var iSize = i; +var sort = false; +var newf = new Array (allfeatures.size ()); +var sortOrder = Clazz.newFloatArray (allfeatures.size (), 0); +for (var newfeat, $newfeat = allfeatures.iterator (); $newfeat.hasNext () && ((newfeat = $newfeat.next ()) || true);) { +newf[i] = newfeat; +if (this.minmax != null) { +mmrange = this.minmax.get (newf[i]); +if (mmrange != null) { +fc = this.featureColours.get (newf[i]); +if (fc != null && Clazz.instanceOf (fc, jalview.schemes.GraduatedColor) && (fc).isAutoScale ()) { +(fc).updateBounds ((mmrange)[0][0], (mmrange)[0][1]); +}}}if (initOrders || !this.featureOrder.containsKey (newf[i])) { +var denom = initOrders ? allfeatures.size () : this.featureOrder.size (); +this.setOrder (newf[i], i / denom); +}sortOrder[i] = 2 - (this.featureOrder.get (newf[i])).floatValue (); +if (i < iSize) { +sort = sort || sortOrder[i] > sortOrder[i + 1]; +}i--; +} +if (iSize > 1 && sort) { +jalview.util.QuickSort.sortFloatObject (sortOrder, newf); +}sortOrder = null; +System.arraycopy (newf, 0, this.renderOrder, opos, newf.length); +}, $fz.isPrivate = true, $fz), "java.util.List"); +Clazz.overrideMethod (c$, "getFeatureStyle", +function (featureType) { +var fc = this.featureColours.get (featureType); +if (fc == null) { +var ucs = new jalview.schemes.UserColourScheme (); +var col = ucs.createColourFromName (featureType); +this.featureColours.put (featureType, fc = col); +}return fc; +}, "~S"); +Clazz.defineMethod (c$, "getColour", +function (featureType) { +var fc = this.getFeatureStyle (featureType); +if (Clazz.instanceOf (fc, java.awt.Color)) { +return fc; +} else { +if (Clazz.instanceOf (fc, jalview.schemes.GraduatedColor)) { +return (fc).getMaxColor (); +}}throw new Error ("Implementation Error: Unrecognised render object " + fc.getClass () + " for features of type " + featureType); +}, "~S"); +Clazz.defineMethod (c$, "getColour", +function (feature) { +var fc = this.getFeatureStyle (feature.getType ()); +if (Clazz.instanceOf (fc, java.awt.Color)) { +return fc; +} else { +if (Clazz.instanceOf (fc, jalview.schemes.GraduatedColor)) { +return (fc).findColor (feature); +}}throw new Error ("Implementation Error: Unrecognised render object " + fc.getClass () + " for features of type " + feature.getType ()); +}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "showFeature", +function (sequenceFeature) { +var fc = this.getFeatureStyle (sequenceFeature.type); +if (Clazz.instanceOf (fc, jalview.schemes.GraduatedColor)) { +return (fc).isColored (sequenceFeature); +} else { +return true; +}}, "jalview.datamodel.SequenceFeature"); +Clazz.defineMethod (c$, "showFeatureOfType", +function (type) { +return this.av.getFeaturesDisplayed ().isVisible (type); +}, "~S"); +Clazz.overrideMethod (c$, "setColour", +function (featureType, col) { +{ +this.featureColours.put (featureType, col); +}}, "~S,~O"); +Clazz.defineMethod (c$, "setTransparency", +function (value) { +this.transparency = value; +}, "~N"); +Clazz.defineMethod (c$, "getTransparency", +function () { +return this.transparency; +}); +Clazz.defineMethod (c$, "setOrder", +function (type, position) { +if (this.featureOrder == null) { +this.featureOrder = new java.util.Hashtable (); +}this.featureOrder.put (type, new Float (position)); +return position; +}, "~S,~N"); +Clazz.defineMethod (c$, "getOrder", +function (type) { +if (this.featureOrder != null) { +if (this.featureOrder.containsKey (type)) { +return (this.featureOrder.get (type)).floatValue (); +}}return -1; +}, "~S"); +Clazz.overrideMethod (c$, "getFeatureColours", +function () { +return new java.util.concurrent.ConcurrentHashMap (this.featureColours); +}); +Clazz.defineMethod (c$, "setFeaturePriority", +function (data) { +this.setFeaturePriority (data, true); +}, "~A"); +Clazz.defineMethod (c$, "setFeaturePriority", +function (data, visibleNew) { +var av_featuresdisplayed = null; +if (visibleNew) { +if ((av_featuresdisplayed = this.av.getFeaturesDisplayed ()) != null) { +this.av.getFeaturesDisplayed ().clear (); +} else { +this.av.setFeaturesDisplayed (av_featuresdisplayed = new jalview.viewmodel.seqfeatures.FeaturesDisplayed ()); +}} else { +av_featuresdisplayed = this.av.getFeaturesDisplayed (); +}if (data == null) { +return; +}this.renderOrder = new Array (data.length); +if (data.length > 0) { +for (var i = 0; i < data.length; i++) { +var type = data[i][0].toString (); +this.setColour (type, data[i][1]); +if ((data[i][2]).booleanValue ()) { +av_featuresdisplayed.setVisible (type); +}this.renderOrder[data.length - i - 1] = type; +} +}}, "~A,~B"); +Clazz.defineMethod (c$, "addPropertyChangeListener", +function (listener) { +this.changeSupport.addPropertyChangeListener (listener); +}, "java.beans.PropertyChangeListener"); +Clazz.defineMethod (c$, "removePropertyChangeListener", +function (listener) { +this.changeSupport.removePropertyChangeListener (listener); +}, "java.beans.PropertyChangeListener"); +Clazz.defineMethod (c$, "getAllFeatureColours", +function () { +return this.featureColours.keySet (); +}); +Clazz.defineMethod (c$, "clearRenderOrder", +function () { +this.renderOrder = null; +}); +Clazz.defineMethod (c$, "hasRenderOrder", +function () { +return this.renderOrder != null; +}); +Clazz.defineMethod (c$, "getRenderOrder", +function () { +if (this.renderOrder == null) { +return java.util.Arrays.asList ( Clazz.newArray (-1, [])); +}return java.util.Arrays.asList (this.renderOrder); +}); +Clazz.defineMethod (c$, "getFeatureGroupsSize", +function () { +return this.featureGroups != null ? 0 : this.featureGroups.size (); +}); +Clazz.overrideMethod (c$, "getFeatureGroups", +function () { +return (this.featureGroups == null) ? java.util.Arrays.asList ( new Array (0)) : java.util.Arrays.asList (this.featureGroups.keySet ().toArray ( new Array (0))); +}); +Clazz.defineMethod (c$, "checkGroupVisibility", +function (group, newGroupsVisible) { +if (this.featureGroups == null) { +}if (this.featureGroups.containsKey (group)) { +return this.featureGroups.get (group).booleanValue (); +}if (newGroupsVisible) { +this.featureGroups.put (group, new Boolean (true)); +return true; +}return false; +}, "~S,~B"); +Clazz.overrideMethod (c$, "getGroups", +function (visible) { +if (this.featureGroups != null) { +var gp = new java.util.ArrayList (); +for (var grp, $grp = this.featureGroups.keySet ().iterator (); $grp.hasNext () && ((grp = $grp.next ()) || true);) { +var state = this.featureGroups.get (grp); +if (state.booleanValue () == visible) { +gp.add (grp); +}} +return gp; +}return null; +}, "~B"); +Clazz.defineMethod (c$, "setGroupVisibility", +function (group, visible) { +this.featureGroups.put (group, new Boolean (visible)); +}, "~S,~B"); +Clazz.defineMethod (c$, "setGroupVisibility", +function (toset, visible) { +if (toset != null && toset.size () > 0 && this.featureGroups != null) { +var rdrw = false; +for (var gst, $gst = toset.iterator (); $gst.hasNext () && ((gst = $gst.next ()) || true);) { +var st = this.featureGroups.get (gst); +this.featureGroups.put (gst, new Boolean (visible)); +if (st != null) { +rdrw = rdrw || (visible != st.booleanValue ()); +}} +if (rdrw) { +}}}, "java.util.List,~B"); +Clazz.overrideMethod (c$, "getDisplayedFeatureCols", +function () { +var fcols = new java.util.Hashtable (); +if (this.getViewport ().getFeaturesDisplayed () == null) { +return fcols; +}var en = this.getViewport ().getFeaturesDisplayed ().getVisibleFeatures (); +while (en.hasNext ()) { +var col = en.next (); +fcols.put (col, this.getColour (col)); +} +return fcols; +}); +Clazz.defineMethod (c$, "getFeaturesDisplayed", +function () { +return this.av.getFeaturesDisplayed (); +}); +Clazz.overrideMethod (c$, "getDisplayedFeatureTypes", +function () { +var typ = null; +typ = this.getRenderOrder ().toArray ( new Array (0)); +var feature_disp = this.av.getFeaturesDisplayed (); +if (feature_disp != null) { +{ +for (var i = 0; i < typ.length; i++) { +if (!feature_disp.isVisible (typ[i])) { +typ[i] = null; +}} +}}return typ; +}); +Clazz.overrideMethod (c$, "getDisplayedFeatureGroups", +function () { +var gps = null; +var _gps = new java.util.ArrayList (); +var en = this.getFeatureGroups ().iterator (); +var g = 0; +var valid = false; +while (en.hasNext ()) { +var gp = en.next (); +if (this.checkGroupVisibility (gp, false)) { +valid = true; +_gps.add (gp); +}if (!valid) { +return null; +} else { +gps = new Array (_gps.size ()); +_gps.toArray (gps); +}} +return gps; +}); +}); diff --git a/bin/jalview/viewmodel/seqfeatures/FeatureRendererSettings.js b/bin/jalview/viewmodel/seqfeatures/FeatureRendererSettings.js index 187a380..f166a1b 100644 --- a/bin/jalview/viewmodel/seqfeatures/FeatureRendererSettings.js +++ b/bin/jalview/viewmodel/seqfeatures/FeatureRendererSettings.js @@ -1,43 +1,43 @@ -Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); -Clazz.load (null, "jalview.viewmodel.seqfeatures.FeatureRendererSettings", ["jalview.schemes.GraduatedColor", "java.util.Arrays", "java.util.concurrent.ConcurrentHashMap"], function () { -c$ = Clazz.decorateAsClass (function () { -this.renderOrder = null; -this.featureGroups = null; -this.featureColours = null; -this.transparency = 0; -this.featureOrder = null; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel.seqfeatures, "FeatureRendererSettings", null, Cloneable); -Clazz.makeConstructor (c$, -function (renderOrder, featureGroups, featureColours, transparency, featureOrder) { -this.renderOrder = java.util.Arrays.copyOf (renderOrder, renderOrder.length); -this.featureGroups = new java.util.concurrent.ConcurrentHashMap (featureGroups); -this.featureColours = new java.util.concurrent.ConcurrentHashMap (featureColours); -this.transparency = transparency; -this.featureOrder = new java.util.concurrent.ConcurrentHashMap (featureOrder); -}, "~A,java.util.Hashtable,java.util.Hashtable,~N,java.util.Hashtable"); -Clazz.makeConstructor (c$, -function (fr) { -this.renderOrder = null; -this.featureGroups = new java.util.concurrent.ConcurrentHashMap (); -this.featureColours = new java.util.concurrent.ConcurrentHashMap (); -this.featureOrder = new java.util.concurrent.ConcurrentHashMap (); -if (fr.renderOrder != null) { -this.renderOrder = new Array (fr.renderOrder.length); -System.arraycopy (fr.renderOrder, 0, this.renderOrder, 0, fr.renderOrder.length); -}if (fr.featureGroups != null) { -this.featureGroups = new java.util.concurrent.ConcurrentHashMap (fr.featureGroups); -}if (fr.featureColours != null) { -this.featureColours = new java.util.concurrent.ConcurrentHashMap (fr.featureColours); -}var en = fr.featureColours.keySet ().iterator (); -while (en.hasNext ()) { -var next = en.next (); -var val = this.featureColours.get (next); -if (Clazz.instanceOf (val, jalview.schemes.GraduatedColor)) { -this.featureColours.put (next, new jalview.schemes.GraduatedColor (val)); -}} -this.transparency = fr.transparency; -if (fr.featureOrder != null) { -this.featureOrder = new java.util.concurrent.ConcurrentHashMap (fr.featureOrder); -}}, "jalview.viewmodel.seqfeatures.FeatureRendererModel"); -}); +Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); +Clazz.load (null, "jalview.viewmodel.seqfeatures.FeatureRendererSettings", ["jalview.schemes.GraduatedColor", "java.util.Arrays", "java.util.concurrent.ConcurrentHashMap"], function () { +c$ = Clazz.decorateAsClass (function () { +this.renderOrder = null; +this.featureGroups = null; +this.featureColours = null; +this.transparency = 0; +this.featureOrder = null; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel.seqfeatures, "FeatureRendererSettings", null, Cloneable); +Clazz.makeConstructor (c$, +function (renderOrder, featureGroups, featureColours, transparency, featureOrder) { +this.renderOrder = java.util.Arrays.copyOf (renderOrder, renderOrder.length); +this.featureGroups = new java.util.concurrent.ConcurrentHashMap (featureGroups); +this.featureColours = new java.util.concurrent.ConcurrentHashMap (featureColours); +this.transparency = transparency; +this.featureOrder = new java.util.concurrent.ConcurrentHashMap (featureOrder); +}, "~A,java.util.Hashtable,java.util.Hashtable,~N,java.util.Hashtable"); +Clazz.makeConstructor (c$, +function (fr) { +this.renderOrder = null; +this.featureGroups = new java.util.concurrent.ConcurrentHashMap (); +this.featureColours = new java.util.concurrent.ConcurrentHashMap (); +this.featureOrder = new java.util.concurrent.ConcurrentHashMap (); +if (fr.renderOrder != null) { +this.renderOrder = new Array (fr.renderOrder.length); +System.arraycopy (fr.renderOrder, 0, this.renderOrder, 0, fr.renderOrder.length); +}if (fr.featureGroups != null) { +this.featureGroups = new java.util.concurrent.ConcurrentHashMap (fr.featureGroups); +}if (fr.featureColours != null) { +this.featureColours = new java.util.concurrent.ConcurrentHashMap (fr.featureColours); +}var en = fr.featureColours.keySet ().iterator (); +while (en.hasNext ()) { +var next = en.next (); +var val = this.featureColours.get (next); +if (Clazz.instanceOf (val, jalview.schemes.GraduatedColor)) { +this.featureColours.put (next, new jalview.schemes.GraduatedColor (val)); +}} +this.transparency = fr.transparency; +if (fr.featureOrder != null) { +this.featureOrder = new java.util.concurrent.ConcurrentHashMap (fr.featureOrder); +}}, "jalview.viewmodel.seqfeatures.FeatureRendererModel"); +}); diff --git a/bin/jalview/viewmodel/seqfeatures/FeatureSettingsModel.js b/bin/jalview/viewmodel/seqfeatures/FeatureSettingsModel.js index 6623fc4..72b72b5 100644 --- a/bin/jalview/viewmodel/seqfeatures/FeatureSettingsModel.js +++ b/bin/jalview/viewmodel/seqfeatures/FeatureSettingsModel.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); -Clazz.load (["jalview.api.FeatureSettingsModelI"], "jalview.viewmodel.seqfeatures.FeatureSettingsModel", null, function () { -c$ = Clazz.declareType (jalview.viewmodel.seqfeatures, "FeatureSettingsModel", null, jalview.api.FeatureSettingsModelI); -}); +Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); +Clazz.load (["jalview.api.FeatureSettingsModelI"], "jalview.viewmodel.seqfeatures.FeatureSettingsModel", null, function () { +c$ = Clazz.declareType (jalview.viewmodel.seqfeatures, "FeatureSettingsModel", null, jalview.api.FeatureSettingsModelI); +}); diff --git a/bin/jalview/viewmodel/seqfeatures/FeaturesDisplayed.js b/bin/jalview/viewmodel/seqfeatures/FeaturesDisplayed.js index 32ddafc..8f0de99 100644 --- a/bin/jalview/viewmodel/seqfeatures/FeaturesDisplayed.js +++ b/bin/jalview/viewmodel/seqfeatures/FeaturesDisplayed.js @@ -1,68 +1,68 @@ -Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); -Clazz.load (["jalview.api.FeaturesDisplayedI", "java.util.HashSet"], "jalview.viewmodel.seqfeatures.FeaturesDisplayed", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.featuresDisplayed = null; -this.featuresRegistered = null; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel.seqfeatures, "FeaturesDisplayed", null, jalview.api.FeaturesDisplayedI); -Clazz.prepareFields (c$, function () { -this.featuresDisplayed = new java.util.HashSet (); -this.featuresRegistered = new java.util.HashSet (); -}); -Clazz.makeConstructor (c$, -function (featuresDisplayed2) { -var fdisp = featuresDisplayed2.getVisibleFeatures (); -var ftype; -while (fdisp.hasNext ()) { -ftype = fdisp.next (); -this.featuresDisplayed.add (ftype); -this.featuresRegistered.add (ftype); -} -}, "jalview.api.FeaturesDisplayedI"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "getVisibleFeatures", -function () { -return this.featuresDisplayed.iterator (); -}); -Clazz.overrideMethod (c$, "isVisible", -function (featureType) { -return this.featuresDisplayed.contains (featureType); -}, "~S"); -Clazz.overrideMethod (c$, "areVisible", -function (featureTypes) { -return this.featuresDisplayed.containsAll (featureTypes); -}, "java.util.Collection"); -Clazz.overrideMethod (c$, "clear", -function () { -this.featuresDisplayed.clear (); -this.featuresRegistered.clear (); -}); -Clazz.overrideMethod (c$, "setAllVisible", -function (makeVisible) { -this.featuresDisplayed.addAll (makeVisible); -this.featuresRegistered.addAll (makeVisible); -}, "java.util.Collection"); -Clazz.overrideMethod (c$, "setAllRegisteredVisible", -function () { -this.featuresDisplayed.addAll (this.featuresRegistered); -}); -Clazz.overrideMethod (c$, "setVisible", -function (featureType) { -this.featuresDisplayed.add (featureType); -this.featuresRegistered.add (featureType); -}, "~S"); -Clazz.overrideMethod (c$, "isRegistered", -function (type) { -return this.featuresRegistered.contains (type); -}, "~S"); -Clazz.overrideMethod (c$, "getVisibleFeatureCount", -function () { -return this.featuresDisplayed.size (); -}); -Clazz.overrideMethod (c$, "getRegisterdFeaturesCount", -function () { -return this.featuresRegistered.size (); -}); -}); +Clazz.declarePackage ("jalview.viewmodel.seqfeatures"); +Clazz.load (["jalview.api.FeaturesDisplayedI", "java.util.HashSet"], "jalview.viewmodel.seqfeatures.FeaturesDisplayed", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.featuresDisplayed = null; +this.featuresRegistered = null; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel.seqfeatures, "FeaturesDisplayed", null, jalview.api.FeaturesDisplayedI); +Clazz.prepareFields (c$, function () { +this.featuresDisplayed = new java.util.HashSet (); +this.featuresRegistered = new java.util.HashSet (); +}); +Clazz.makeConstructor (c$, +function (featuresDisplayed2) { +var fdisp = featuresDisplayed2.getVisibleFeatures (); +var ftype; +while (fdisp.hasNext ()) { +ftype = fdisp.next (); +this.featuresDisplayed.add (ftype); +this.featuresRegistered.add (ftype); +} +}, "jalview.api.FeaturesDisplayedI"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "getVisibleFeatures", +function () { +return this.featuresDisplayed.iterator (); +}); +Clazz.overrideMethod (c$, "isVisible", +function (featureType) { +return this.featuresDisplayed.contains (featureType); +}, "~S"); +Clazz.overrideMethod (c$, "areVisible", +function (featureTypes) { +return this.featuresDisplayed.containsAll (featureTypes); +}, "java.util.Collection"); +Clazz.overrideMethod (c$, "clear", +function () { +this.featuresDisplayed.clear (); +this.featuresRegistered.clear (); +}); +Clazz.overrideMethod (c$, "setAllVisible", +function (makeVisible) { +this.featuresDisplayed.addAll (makeVisible); +this.featuresRegistered.addAll (makeVisible); +}, "java.util.Collection"); +Clazz.overrideMethod (c$, "setAllRegisteredVisible", +function () { +this.featuresDisplayed.addAll (this.featuresRegistered); +}); +Clazz.overrideMethod (c$, "setVisible", +function (featureType) { +this.featuresDisplayed.add (featureType); +this.featuresRegistered.add (featureType); +}, "~S"); +Clazz.overrideMethod (c$, "isRegistered", +function (type) { +return this.featuresRegistered.contains (type); +}, "~S"); +Clazz.overrideMethod (c$, "getVisibleFeatureCount", +function () { +return this.featuresDisplayed.size (); +}); +Clazz.overrideMethod (c$, "getRegisterdFeaturesCount", +function () { +return this.featuresRegistered.size (); +}); +}); diff --git a/bin/jalview/viewmodel/styles/ViewStyle.js b/bin/jalview/viewmodel/styles/ViewStyle.js index 8ec10fa..f41fe5d 100644 --- a/bin/jalview/viewmodel/styles/ViewStyle.js +++ b/bin/jalview/viewmodel/styles/ViewStyle.js @@ -1,457 +1,457 @@ -Clazz.declarePackage ("jalview.viewmodel.styles"); -Clazz.load (["jalview.api.ViewStyleI", "java.awt.Color"], "jalview.viewmodel.styles.ViewStyle", ["java.lang.Boolean"], function () { -c$ = Clazz.decorateAsClass (function () { -this.abovePIDThreshold = false; -this.charHeight = 0; -this.charWidth = 0; -this.idWidth = -1; -this.colourAppliesToAllGroups = false; -this.centreColumnLabels = false; -this.showdbrefs = false; -this.shownpfeats = false; -this.colourByReferenceSeq = false; -this.conservationColourSelected = false; -this.displayReferenceSeq = false; -this.increment = 0; -this.renderGaps = true; -this.rightAlignIds = false; -this.scaleAboveWrapped = false; -this.scaleLeftWrapped = true; -this.scaleRightWrapped = true; -this.seqNameItalics = false; -this.showAnnotation = true; -this.showBoxes = true; -this.showColourText = false; -this.showHiddenMarkers = true; -this.showJVSuffix = true; -this.showSeqFeaturesHeight = false; -this.showSequenceFeatures = false; -this.showText = true; -this.showUnconserved = false; -this.textColour = null; -this.textColour2 = null; -this.threshold = 0; -this.thresholdTextColour = 0; -this.upperCasebold = false; -this.fontName = null; -this.fontSize = 0; -this.scaleProteinAsCdna = true; -this.wrapAlignment = false; -this.wrappedWidth = 0; -this.fontStyle = 0; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel.styles, "ViewStyle", null, jalview.api.ViewStyleI); -Clazz.prepareFields (c$, function () { -this.textColour = java.awt.Color.black; -this.textColour2 = java.awt.Color.white; -}); -Clazz.makeConstructor (c$, -function (vs) { -this.setAbovePIDThreshold (vs.getAbovePIDThreshold ()); -this.setCentreColumnLabels (vs.isCentreColumnLabels ()); -this.setCharHeight (vs.getCharHeight ()); -this.setCharWidth (vs.getCharWidth ()); -this.setColourAppliesToAllGroups (vs.getColourAppliesToAllGroups ()); -this.setColourByReferenceSeq (vs.isColourByReferenceSeq ()); -this.setColourText (vs.getColourText ()); -this.setConservationColourSelected (vs.isConservationColourSelected ()); -this.setConservationSelected (vs.getConservationSelected ()); -this.setDisplayReferenceSeq (vs.isDisplayReferenceSeq ()); -this.setFontName (vs.getFontName ()); -this.setFontSize (vs.getFontSize ()); -this.setFontStyle (vs.getFontStyle ()); -this.setIdWidth (vs.getIdWidth ()); -this.setIncrement (vs.getIncrement ()); -this.setRenderGaps (vs.isRenderGaps ()); -this.setRightAlignIds (vs.isRightAlignIds ()); -this.setScaleAboveWrapped (vs.getScaleAboveWrapped ()); -this.setScaleLeftWrapped (vs.getScaleLeftWrapped ()); -this.setScaleProteinAsCdna (vs.isScaleProteinAsCdna ()); -this.setScaleRightWrapped (vs.getScaleRightWrapped ()); -this.setSeqNameItalics (vs.isSeqNameItalics ()); -this.setShowAnnotation (vs.isShowAnnotation ()); -this.setShowBoxes (vs.getShowBoxes ()); -this.setShowColourText (vs.isShowColourText ()); -this.setShowDBRefs (vs.isShowDBRefs ()); -this.setShowHiddenMarkers (vs.getShowHiddenMarkers ()); -this.setShowJVSuffix (vs.getShowJVSuffix ()); -this.setShowNPFeats (vs.isShowNPFeats ()); -this.setShowSequenceFeaturesHeight (vs.isShowSequenceFeaturesHeight ()); -this.setShowSequenceFeatures (vs.isShowSequenceFeatures ()); -this.setShowText (vs.getShowText ()); -this.setShowUnconserved (vs.getShowUnconserved ()); -this.setTextColour (vs.getTextColour ()); -this.setTextColour2 (vs.getTextColour2 ()); -this.setThreshold (vs.getThreshold ()); -this.setThresholdTextColour (vs.getThresholdTextColour ()); -this.setUpperCasebold (vs.isUpperCasebold ()); -this.setWrapAlignment (vs.getWrapAlignment ()); -this.setWrappedWidth (vs.getWrappedWidth ()); -}, "jalview.api.ViewStyleI"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.overrideMethod (c$, "equals", -function (other) { -if (other == null || !(Clazz.instanceOf (other, jalview.viewmodel.styles.ViewStyle))) { -return false; -}var vs = other; -var match = (this.getAbovePIDThreshold () == vs.getAbovePIDThreshold () && this.isCentreColumnLabels () == vs.isCentreColumnLabels () && this.getCharHeight () == vs.getCharHeight () && this.getCharWidth () == vs.getCharWidth () && this.getColourAppliesToAllGroups () == vs.getColourAppliesToAllGroups () && this.isColourByReferenceSeq () == vs.isColourByReferenceSeq () && this.getColourText () == vs.getColourText () && this.isConservationColourSelected () == vs.isConservationColourSelected () && this.getConservationSelected () == vs.getConservationSelected () && this.isDisplayReferenceSeq () == vs.isDisplayReferenceSeq () && this.getFontSize () == vs.getFontSize () && this.getFontStyle () == vs.getFontStyle () && this.getIdWidth () == vs.getIdWidth () && this.getIncrement () == vs.getIncrement () && this.isRenderGaps () == vs.isRenderGaps () && this.isRightAlignIds () == vs.isRightAlignIds () && this.getScaleAboveWrapped () == vs.getScaleAboveWrapped () && this.getScaleLeftWrapped () == vs.getScaleLeftWrapped () && this.isScaleProteinAsCdna () == vs.isScaleProteinAsCdna () && this.getScaleRightWrapped () == vs.getScaleRightWrapped () && this.isSeqNameItalics () == vs.isSeqNameItalics () && this.isShowAnnotation () == vs.isShowAnnotation () && this.getShowBoxes () == vs.getShowBoxes () && this.isShowColourText () == vs.isShowColourText () && this.isShowDBRefs () == vs.isShowDBRefs () && this.getShowHiddenMarkers () == vs.getShowHiddenMarkers () && this.getShowJVSuffix () == vs.getShowJVSuffix () && this.isShowNPFeats () == vs.isShowNPFeats () && this.isShowSequenceFeaturesHeight () == vs.isShowSequenceFeaturesHeight () && this.isShowSequenceFeatures () == vs.isShowSequenceFeatures () && this.getShowText () == vs.getShowText () && this.getShowUnconserved () == vs.getShowUnconserved () && this.getThreshold () == vs.getThreshold () && this.getThresholdTextColour () == vs.getThresholdTextColour () && this.isUpperCasebold () == vs.isUpperCasebold () && this.getWrapAlignment () == vs.getWrapAlignment () && this.getWrappedWidth () == vs.getWrappedWidth ()); -match = match && String.valueOf (this.getFontName ()).equals (String.valueOf (vs.getFontName ())); -match = match && String.valueOf (this.getTextColour ()).equals (String.valueOf (vs.getTextColour ())); -match = match && String.valueOf (this.getTextColour2 ()).equals (String.valueOf (vs.getTextColour2 ())); -return match; -}, "~O"); -Clazz.overrideMethod (c$, "hashCode", -function () { -var hash = 0; -var m = 1; -hash += m++ * Boolean.$valueOf (this.abovePIDThreshold).hashCode (); -hash += m++ * Boolean.$valueOf (this.centreColumnLabels).hashCode (); -hash += m++ * Boolean.$valueOf (this.colourAppliesToAllGroups).hashCode (); -hash += m++ * Boolean.$valueOf (this.displayReferenceSeq).hashCode (); -hash += m++ * Boolean.$valueOf (this.renderGaps).hashCode (); -hash += m++ * Boolean.$valueOf (this.rightAlignIds).hashCode (); -hash += m++ * Boolean.$valueOf (this.scaleProteinAsCdna).hashCode (); -hash += m++ * Boolean.$valueOf (this.scaleRightWrapped).hashCode (); -hash += m++ * Boolean.$valueOf (this.seqNameItalics).hashCode (); -hash += m++ * Boolean.$valueOf (this.showAnnotation).hashCode (); -hash += m++ * Boolean.$valueOf (this.showBoxes).hashCode (); -hash += m++ * Boolean.$valueOf (this.showdbrefs).hashCode (); -hash += m++ * Boolean.$valueOf (this.showJVSuffix).hashCode (); -hash += m++ * Boolean.$valueOf (this.showSequenceFeatures).hashCode (); -hash += m++ * Boolean.$valueOf (this.showUnconserved).hashCode (); -hash += m++ * Boolean.$valueOf (this.wrapAlignment).hashCode (); -hash += m++ * this.charHeight; -hash += m++ * this.charWidth; -hash += m++ * this.fontSize; -hash += m++ * this.fontStyle; -hash += m++ * this.idWidth; -hash += String.valueOf (this.fontName).hashCode (); -return hash; -}); -Clazz.defineMethod (c$, "isUpperCasebold", -function () { -return this.upperCasebold; -}); -Clazz.overrideMethod (c$, "setUpperCasebold", -function (upperCasebold) { -this.upperCasebold = upperCasebold; -}, "~B"); -Clazz.defineMethod (c$, "getAbovePIDThreshold", -function () { -return this.abovePIDThreshold; -}); -Clazz.defineMethod (c$, "getCharHeight", -function () { -return this.charHeight; -}); -Clazz.defineMethod (c$, "getCharWidth", -function () { -return this.charWidth; -}); -Clazz.defineMethod (c$, "getColourAppliesToAllGroups", -function () { -return this.colourAppliesToAllGroups; -}); -Clazz.defineMethod (c$, "getColourText", -function () { -return this.showColourText; -}); -Clazz.defineMethod (c$, "getConservationSelected", -function () { -return this.conservationColourSelected; -}); -Clazz.defineMethod (c$, "getIncrement", -function () { -return this.increment; -}); -Clazz.defineMethod (c$, "getScaleAboveWrapped", -function () { -return this.scaleAboveWrapped; -}); -Clazz.defineMethod (c$, "getScaleLeftWrapped", -function () { -return this.scaleLeftWrapped; -}); -Clazz.defineMethod (c$, "getScaleRightWrapped", -function () { -return this.scaleRightWrapped; -}); -Clazz.defineMethod (c$, "getShowBoxes", -function () { -return this.showBoxes; -}); -Clazz.defineMethod (c$, "getShowHiddenMarkers", -function () { -return this.showHiddenMarkers; -}); -Clazz.defineMethod (c$, "getShowJVSuffix", -function () { -return this.showJVSuffix; -}); -Clazz.defineMethod (c$, "getShowText", -function () { -return this.showText; -}); -Clazz.defineMethod (c$, "getShowUnconserved", -function () { -return this.showUnconserved; -}); -Clazz.defineMethod (c$, "getTextColour", -function () { -return this.textColour; -}); -Clazz.defineMethod (c$, "getTextColour2", -function () { -return this.textColour2; -}); -Clazz.defineMethod (c$, "getThreshold", -function () { -return this.threshold; -}); -Clazz.defineMethod (c$, "getThresholdTextColour", -function () { -return this.thresholdTextColour; -}); -Clazz.defineMethod (c$, "getWrapAlignment", -function () { -return this.wrapAlignment; -}); -Clazz.defineMethod (c$, "getWrappedWidth", -function () { -return this.wrappedWidth; -}); -Clazz.defineMethod (c$, "isColourByReferenceSeq", -function () { -return this.colourByReferenceSeq; -}); -Clazz.defineMethod (c$, "isConservationColourSelected", -function () { -return this.conservationColourSelected; -}); -Clazz.defineMethod (c$, "isDisplayReferenceSeq", -function () { -return this.displayReferenceSeq; -}); -Clazz.defineMethod (c$, "isRenderGaps", -function () { -return this.renderGaps; -}); -Clazz.defineMethod (c$, "isRightAlignIds", -function () { -return this.rightAlignIds; -}); -Clazz.defineMethod (c$, "isSeqNameItalics", -function () { -return this.seqNameItalics; -}); -Clazz.defineMethod (c$, "isShowAnnotation", -function () { -return this.showAnnotation; -}); -Clazz.defineMethod (c$, "isShowColourText", -function () { -return this.showColourText; -}); -Clazz.defineMethod (c$, "isShowSequenceFeaturesHeight", -function () { -return this.showSeqFeaturesHeight; -}); -Clazz.defineMethod (c$, "isShowSequenceFeatures", -function () { -return this.showSequenceFeatures; -}); -Clazz.overrideMethod (c$, "setAbovePIDThreshold", -function (b) { -this.abovePIDThreshold = b; -}, "~B"); -Clazz.overrideMethod (c$, "setCharHeight", -function (h) { -this.charHeight = h; -}, "~N"); -Clazz.overrideMethod (c$, "setCharWidth", -function (w) { -this.charWidth = w; -}, "~N"); -Clazz.overrideMethod (c$, "setColourAppliesToAllGroups", -function (b) { -this.colourAppliesToAllGroups = b; -}, "~B"); -Clazz.overrideMethod (c$, "setColourByReferenceSeq", -function (colourByReferenceSeq) { -this.colourByReferenceSeq = colourByReferenceSeq; -}, "~B"); -Clazz.overrideMethod (c$, "setColourText", -function (state) { -this.showColourText = state; -}, "~B"); -Clazz.overrideMethod (c$, "setConservationColourSelected", -function (conservationColourSelected) { -this.conservationColourSelected = conservationColourSelected; -}, "~B"); -Clazz.overrideMethod (c$, "setConservationSelected", -function (b) { -this.conservationColourSelected = b; -}, "~B"); -Clazz.overrideMethod (c$, "setDisplayReferenceSeq", -function (displayReferenceSeq) { -this.displayReferenceSeq = displayReferenceSeq; -}, "~B"); -Clazz.overrideMethod (c$, "setIncrement", -function (inc) { -this.increment = inc; -}, "~N"); -Clazz.overrideMethod (c$, "setRenderGaps", -function (state) { -this.renderGaps = state; -}, "~B"); -Clazz.overrideMethod (c$, "setRightAlignIds", -function (rightAlignIds) { -this.rightAlignIds = rightAlignIds; -}, "~B"); -Clazz.overrideMethod (c$, "setScaleAboveWrapped", -function (b) { -this.scaleAboveWrapped = b; -}, "~B"); -Clazz.overrideMethod (c$, "setScaleLeftWrapped", -function (b) { -this.scaleLeftWrapped = b; -}, "~B"); -Clazz.overrideMethod (c$, "setScaleRightWrapped", -function (b) { -this.scaleRightWrapped = b; -}, "~B"); -Clazz.overrideMethod (c$, "setSeqNameItalics", -function (italics) { -this.seqNameItalics = italics; -}, "~B"); -Clazz.overrideMethod (c$, "setShowAnnotation", -function (b) { -this.showAnnotation = b; -}, "~B"); -Clazz.overrideMethod (c$, "setShowBoxes", -function (state) { -this.showBoxes = state; -}, "~B"); -Clazz.overrideMethod (c$, "setShowColourText", -function (showColourText) { -this.showColourText = showColourText; -}, "~B"); -Clazz.overrideMethod (c$, "setShowHiddenMarkers", -function (show) { -this.showHiddenMarkers = show; -}, "~B"); -Clazz.overrideMethod (c$, "setShowJVSuffix", -function (b) { -this.showJVSuffix = b; -}, "~B"); -Clazz.overrideMethod (c$, "setShowSequenceFeaturesHeight", -function (selected) { -this.showSeqFeaturesHeight = selected; -}, "~B"); -Clazz.overrideMethod (c$, "setShowSequenceFeatures", -function (b) { -this.showSequenceFeatures = b; -}, "~B"); -Clazz.overrideMethod (c$, "setShowText", -function (state) { -this.showText = state; -}, "~B"); -Clazz.overrideMethod (c$, "setShowUnconserved", -function (showunconserved) { -this.showUnconserved = showunconserved; -}, "~B"); -Clazz.overrideMethod (c$, "setTextColour", -function (textColour) { -this.textColour = textColour; -}, "java.awt.Color"); -Clazz.overrideMethod (c$, "setTextColour2", -function (textColour2) { -this.textColour2 = textColour2; -}, "java.awt.Color"); -Clazz.overrideMethod (c$, "setThreshold", -function (thresh) { -this.threshold = thresh; -}, "~N"); -Clazz.overrideMethod (c$, "setThresholdTextColour", -function (thresholdTextColour) { -this.thresholdTextColour = thresholdTextColour; -}, "~N"); -Clazz.overrideMethod (c$, "setWrapAlignment", -function (state) { -this.wrapAlignment = state; -}, "~B"); -Clazz.overrideMethod (c$, "setWrappedWidth", -function (w) { -this.wrappedWidth = w; -}, "~N"); -Clazz.overrideMethod (c$, "sameStyle", -function (that) { -return this.equals (that); -}, "jalview.api.ViewStyleI"); -Clazz.defineMethod (c$, "getFontName", -function () { -return this.fontName; -}); -Clazz.defineMethod (c$, "getFontSize", -function () { -return this.fontSize; -}); -Clazz.defineMethod (c$, "getFontStyle", -function () { -return this.fontStyle; -}); -Clazz.overrideMethod (c$, "setFontName", -function (name) { -this.fontName = name; -}, "~S"); -Clazz.overrideMethod (c$, "setFontSize", -function (size) { -this.fontSize = size; -}, "~N"); -Clazz.overrideMethod (c$, "setFontStyle", -function (style) { -this.fontStyle = style; -}, "~N"); -Clazz.defineMethod (c$, "getIdWidth", -function () { -return this.idWidth; -}); -Clazz.overrideMethod (c$, "setIdWidth", -function (idWidth) { -this.idWidth = idWidth; -}, "~N"); -Clazz.defineMethod (c$, "isCentreColumnLabels", -function () { -return this.centreColumnLabels; -}); -Clazz.overrideMethod (c$, "setCentreColumnLabels", -function (centreColumnLabels) { -this.centreColumnLabels = centreColumnLabels; -}, "~B"); -Clazz.defineMethod (c$, "isShowDBRefs", -function () { -return this.showdbrefs; -}); -Clazz.overrideMethod (c$, "setShowDBRefs", -function (showdbrefs) { -this.showdbrefs = showdbrefs; -}, "~B"); -Clazz.defineMethod (c$, "isShowNPFeats", -function () { -return this.shownpfeats; -}); -Clazz.overrideMethod (c$, "setShowNPFeats", -function (shownpfeats) { -this.shownpfeats = shownpfeats; -}, "~B"); -Clazz.defineMethod (c$, "isScaleProteinAsCdna", -function () { -return this.scaleProteinAsCdna; -}); -Clazz.overrideMethod (c$, "setScaleProteinAsCdna", -function (b) { -this.scaleProteinAsCdna = b; -}, "~B"); -}); +Clazz.declarePackage ("jalview.viewmodel.styles"); +Clazz.load (["jalview.api.ViewStyleI", "java.awt.Color"], "jalview.viewmodel.styles.ViewStyle", ["java.lang.Boolean"], function () { +c$ = Clazz.decorateAsClass (function () { +this.abovePIDThreshold = false; +this.charHeight = 0; +this.charWidth = 0; +this.idWidth = -1; +this.colourAppliesToAllGroups = false; +this.centreColumnLabels = false; +this.showdbrefs = false; +this.shownpfeats = false; +this.colourByReferenceSeq = false; +this.conservationColourSelected = false; +this.displayReferenceSeq = false; +this.increment = 0; +this.renderGaps = true; +this.rightAlignIds = false; +this.scaleAboveWrapped = false; +this.scaleLeftWrapped = true; +this.scaleRightWrapped = true; +this.seqNameItalics = false; +this.showAnnotation = true; +this.showBoxes = true; +this.showColourText = false; +this.showHiddenMarkers = true; +this.showJVSuffix = true; +this.showSeqFeaturesHeight = false; +this.showSequenceFeatures = false; +this.showText = true; +this.showUnconserved = false; +this.textColour = null; +this.textColour2 = null; +this.threshold = 0; +this.thresholdTextColour = 0; +this.upperCasebold = false; +this.fontName = null; +this.fontSize = 0; +this.scaleProteinAsCdna = true; +this.wrapAlignment = false; +this.wrappedWidth = 0; +this.fontStyle = 0; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel.styles, "ViewStyle", null, jalview.api.ViewStyleI); +Clazz.prepareFields (c$, function () { +this.textColour = java.awt.Color.black; +this.textColour2 = java.awt.Color.white; +}); +Clazz.makeConstructor (c$, +function (vs) { +this.setAbovePIDThreshold (vs.getAbovePIDThreshold ()); +this.setCentreColumnLabels (vs.isCentreColumnLabels ()); +this.setCharHeight (vs.getCharHeight ()); +this.setCharWidth (vs.getCharWidth ()); +this.setColourAppliesToAllGroups (vs.getColourAppliesToAllGroups ()); +this.setColourByReferenceSeq (vs.isColourByReferenceSeq ()); +this.setColourText (vs.getColourText ()); +this.setConservationColourSelected (vs.isConservationColourSelected ()); +this.setConservationSelected (vs.getConservationSelected ()); +this.setDisplayReferenceSeq (vs.isDisplayReferenceSeq ()); +this.setFontName (vs.getFontName ()); +this.setFontSize (vs.getFontSize ()); +this.setFontStyle (vs.getFontStyle ()); +this.setIdWidth (vs.getIdWidth ()); +this.setIncrement (vs.getIncrement ()); +this.setRenderGaps (vs.isRenderGaps ()); +this.setRightAlignIds (vs.isRightAlignIds ()); +this.setScaleAboveWrapped (vs.getScaleAboveWrapped ()); +this.setScaleLeftWrapped (vs.getScaleLeftWrapped ()); +this.setScaleProteinAsCdna (vs.isScaleProteinAsCdna ()); +this.setScaleRightWrapped (vs.getScaleRightWrapped ()); +this.setSeqNameItalics (vs.isSeqNameItalics ()); +this.setShowAnnotation (vs.isShowAnnotation ()); +this.setShowBoxes (vs.getShowBoxes ()); +this.setShowColourText (vs.isShowColourText ()); +this.setShowDBRefs (vs.isShowDBRefs ()); +this.setShowHiddenMarkers (vs.getShowHiddenMarkers ()); +this.setShowJVSuffix (vs.getShowJVSuffix ()); +this.setShowNPFeats (vs.isShowNPFeats ()); +this.setShowSequenceFeaturesHeight (vs.isShowSequenceFeaturesHeight ()); +this.setShowSequenceFeatures (vs.isShowSequenceFeatures ()); +this.setShowText (vs.getShowText ()); +this.setShowUnconserved (vs.getShowUnconserved ()); +this.setTextColour (vs.getTextColour ()); +this.setTextColour2 (vs.getTextColour2 ()); +this.setThreshold (vs.getThreshold ()); +this.setThresholdTextColour (vs.getThresholdTextColour ()); +this.setUpperCasebold (vs.isUpperCasebold ()); +this.setWrapAlignment (vs.getWrapAlignment ()); +this.setWrappedWidth (vs.getWrappedWidth ()); +}, "jalview.api.ViewStyleI"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.overrideMethod (c$, "equals", +function (other) { +if (other == null || !(Clazz.instanceOf (other, jalview.viewmodel.styles.ViewStyle))) { +return false; +}var vs = other; +var match = (this.getAbovePIDThreshold () == vs.getAbovePIDThreshold () && this.isCentreColumnLabels () == vs.isCentreColumnLabels () && this.getCharHeight () == vs.getCharHeight () && this.getCharWidth () == vs.getCharWidth () && this.getColourAppliesToAllGroups () == vs.getColourAppliesToAllGroups () && this.isColourByReferenceSeq () == vs.isColourByReferenceSeq () && this.getColourText () == vs.getColourText () && this.isConservationColourSelected () == vs.isConservationColourSelected () && this.getConservationSelected () == vs.getConservationSelected () && this.isDisplayReferenceSeq () == vs.isDisplayReferenceSeq () && this.getFontSize () == vs.getFontSize () && this.getFontStyle () == vs.getFontStyle () && this.getIdWidth () == vs.getIdWidth () && this.getIncrement () == vs.getIncrement () && this.isRenderGaps () == vs.isRenderGaps () && this.isRightAlignIds () == vs.isRightAlignIds () && this.getScaleAboveWrapped () == vs.getScaleAboveWrapped () && this.getScaleLeftWrapped () == vs.getScaleLeftWrapped () && this.isScaleProteinAsCdna () == vs.isScaleProteinAsCdna () && this.getScaleRightWrapped () == vs.getScaleRightWrapped () && this.isSeqNameItalics () == vs.isSeqNameItalics () && this.isShowAnnotation () == vs.isShowAnnotation () && this.getShowBoxes () == vs.getShowBoxes () && this.isShowColourText () == vs.isShowColourText () && this.isShowDBRefs () == vs.isShowDBRefs () && this.getShowHiddenMarkers () == vs.getShowHiddenMarkers () && this.getShowJVSuffix () == vs.getShowJVSuffix () && this.isShowNPFeats () == vs.isShowNPFeats () && this.isShowSequenceFeaturesHeight () == vs.isShowSequenceFeaturesHeight () && this.isShowSequenceFeatures () == vs.isShowSequenceFeatures () && this.getShowText () == vs.getShowText () && this.getShowUnconserved () == vs.getShowUnconserved () && this.getThreshold () == vs.getThreshold () && this.getThresholdTextColour () == vs.getThresholdTextColour () && this.isUpperCasebold () == vs.isUpperCasebold () && this.getWrapAlignment () == vs.getWrapAlignment () && this.getWrappedWidth () == vs.getWrappedWidth ()); +match = match && String.valueOf (this.getFontName ()).equals (String.valueOf (vs.getFontName ())); +match = match && String.valueOf (this.getTextColour ()).equals (String.valueOf (vs.getTextColour ())); +match = match && String.valueOf (this.getTextColour2 ()).equals (String.valueOf (vs.getTextColour2 ())); +return match; +}, "~O"); +Clazz.overrideMethod (c$, "hashCode", +function () { +var hash = 0; +var m = 1; +hash += m++ * Boolean.$valueOf (this.abovePIDThreshold).hashCode (); +hash += m++ * Boolean.$valueOf (this.centreColumnLabels).hashCode (); +hash += m++ * Boolean.$valueOf (this.colourAppliesToAllGroups).hashCode (); +hash += m++ * Boolean.$valueOf (this.displayReferenceSeq).hashCode (); +hash += m++ * Boolean.$valueOf (this.renderGaps).hashCode (); +hash += m++ * Boolean.$valueOf (this.rightAlignIds).hashCode (); +hash += m++ * Boolean.$valueOf (this.scaleProteinAsCdna).hashCode (); +hash += m++ * Boolean.$valueOf (this.scaleRightWrapped).hashCode (); +hash += m++ * Boolean.$valueOf (this.seqNameItalics).hashCode (); +hash += m++ * Boolean.$valueOf (this.showAnnotation).hashCode (); +hash += m++ * Boolean.$valueOf (this.showBoxes).hashCode (); +hash += m++ * Boolean.$valueOf (this.showdbrefs).hashCode (); +hash += m++ * Boolean.$valueOf (this.showJVSuffix).hashCode (); +hash += m++ * Boolean.$valueOf (this.showSequenceFeatures).hashCode (); +hash += m++ * Boolean.$valueOf (this.showUnconserved).hashCode (); +hash += m++ * Boolean.$valueOf (this.wrapAlignment).hashCode (); +hash += m++ * this.charHeight; +hash += m++ * this.charWidth; +hash += m++ * this.fontSize; +hash += m++ * this.fontStyle; +hash += m++ * this.idWidth; +hash += String.valueOf (this.fontName).hashCode (); +return hash; +}); +Clazz.defineMethod (c$, "isUpperCasebold", +function () { +return this.upperCasebold; +}); +Clazz.overrideMethod (c$, "setUpperCasebold", +function (upperCasebold) { +this.upperCasebold = upperCasebold; +}, "~B"); +Clazz.defineMethod (c$, "getAbovePIDThreshold", +function () { +return this.abovePIDThreshold; +}); +Clazz.defineMethod (c$, "getCharHeight", +function () { +return this.charHeight; +}); +Clazz.defineMethod (c$, "getCharWidth", +function () { +return this.charWidth; +}); +Clazz.defineMethod (c$, "getColourAppliesToAllGroups", +function () { +return this.colourAppliesToAllGroups; +}); +Clazz.defineMethod (c$, "getColourText", +function () { +return this.showColourText; +}); +Clazz.defineMethod (c$, "getConservationSelected", +function () { +return this.conservationColourSelected; +}); +Clazz.defineMethod (c$, "getIncrement", +function () { +return this.increment; +}); +Clazz.defineMethod (c$, "getScaleAboveWrapped", +function () { +return this.scaleAboveWrapped; +}); +Clazz.defineMethod (c$, "getScaleLeftWrapped", +function () { +return this.scaleLeftWrapped; +}); +Clazz.defineMethod (c$, "getScaleRightWrapped", +function () { +return this.scaleRightWrapped; +}); +Clazz.defineMethod (c$, "getShowBoxes", +function () { +return this.showBoxes; +}); +Clazz.defineMethod (c$, "getShowHiddenMarkers", +function () { +return this.showHiddenMarkers; +}); +Clazz.defineMethod (c$, "getShowJVSuffix", +function () { +return this.showJVSuffix; +}); +Clazz.defineMethod (c$, "getShowText", +function () { +return this.showText; +}); +Clazz.defineMethod (c$, "getShowUnconserved", +function () { +return this.showUnconserved; +}); +Clazz.defineMethod (c$, "getTextColour", +function () { +return this.textColour; +}); +Clazz.defineMethod (c$, "getTextColour2", +function () { +return this.textColour2; +}); +Clazz.defineMethod (c$, "getThreshold", +function () { +return this.threshold; +}); +Clazz.defineMethod (c$, "getThresholdTextColour", +function () { +return this.thresholdTextColour; +}); +Clazz.defineMethod (c$, "getWrapAlignment", +function () { +return this.wrapAlignment; +}); +Clazz.defineMethod (c$, "getWrappedWidth", +function () { +return this.wrappedWidth; +}); +Clazz.defineMethod (c$, "isColourByReferenceSeq", +function () { +return this.colourByReferenceSeq; +}); +Clazz.defineMethod (c$, "isConservationColourSelected", +function () { +return this.conservationColourSelected; +}); +Clazz.defineMethod (c$, "isDisplayReferenceSeq", +function () { +return this.displayReferenceSeq; +}); +Clazz.defineMethod (c$, "isRenderGaps", +function () { +return this.renderGaps; +}); +Clazz.defineMethod (c$, "isRightAlignIds", +function () { +return this.rightAlignIds; +}); +Clazz.defineMethod (c$, "isSeqNameItalics", +function () { +return this.seqNameItalics; +}); +Clazz.defineMethod (c$, "isShowAnnotation", +function () { +return this.showAnnotation; +}); +Clazz.defineMethod (c$, "isShowColourText", +function () { +return this.showColourText; +}); +Clazz.defineMethod (c$, "isShowSequenceFeaturesHeight", +function () { +return this.showSeqFeaturesHeight; +}); +Clazz.defineMethod (c$, "isShowSequenceFeatures", +function () { +return this.showSequenceFeatures; +}); +Clazz.overrideMethod (c$, "setAbovePIDThreshold", +function (b) { +this.abovePIDThreshold = b; +}, "~B"); +Clazz.overrideMethod (c$, "setCharHeight", +function (h) { +this.charHeight = h; +}, "~N"); +Clazz.overrideMethod (c$, "setCharWidth", +function (w) { +this.charWidth = w; +}, "~N"); +Clazz.overrideMethod (c$, "setColourAppliesToAllGroups", +function (b) { +this.colourAppliesToAllGroups = b; +}, "~B"); +Clazz.overrideMethod (c$, "setColourByReferenceSeq", +function (colourByReferenceSeq) { +this.colourByReferenceSeq = colourByReferenceSeq; +}, "~B"); +Clazz.overrideMethod (c$, "setColourText", +function (state) { +this.showColourText = state; +}, "~B"); +Clazz.overrideMethod (c$, "setConservationColourSelected", +function (conservationColourSelected) { +this.conservationColourSelected = conservationColourSelected; +}, "~B"); +Clazz.overrideMethod (c$, "setConservationSelected", +function (b) { +this.conservationColourSelected = b; +}, "~B"); +Clazz.overrideMethod (c$, "setDisplayReferenceSeq", +function (displayReferenceSeq) { +this.displayReferenceSeq = displayReferenceSeq; +}, "~B"); +Clazz.overrideMethod (c$, "setIncrement", +function (inc) { +this.increment = inc; +}, "~N"); +Clazz.overrideMethod (c$, "setRenderGaps", +function (state) { +this.renderGaps = state; +}, "~B"); +Clazz.overrideMethod (c$, "setRightAlignIds", +function (rightAlignIds) { +this.rightAlignIds = rightAlignIds; +}, "~B"); +Clazz.overrideMethod (c$, "setScaleAboveWrapped", +function (b) { +this.scaleAboveWrapped = b; +}, "~B"); +Clazz.overrideMethod (c$, "setScaleLeftWrapped", +function (b) { +this.scaleLeftWrapped = b; +}, "~B"); +Clazz.overrideMethod (c$, "setScaleRightWrapped", +function (b) { +this.scaleRightWrapped = b; +}, "~B"); +Clazz.overrideMethod (c$, "setSeqNameItalics", +function (italics) { +this.seqNameItalics = italics; +}, "~B"); +Clazz.overrideMethod (c$, "setShowAnnotation", +function (b) { +this.showAnnotation = b; +}, "~B"); +Clazz.overrideMethod (c$, "setShowBoxes", +function (state) { +this.showBoxes = state; +}, "~B"); +Clazz.overrideMethod (c$, "setShowColourText", +function (showColourText) { +this.showColourText = showColourText; +}, "~B"); +Clazz.overrideMethod (c$, "setShowHiddenMarkers", +function (show) { +this.showHiddenMarkers = show; +}, "~B"); +Clazz.overrideMethod (c$, "setShowJVSuffix", +function (b) { +this.showJVSuffix = b; +}, "~B"); +Clazz.overrideMethod (c$, "setShowSequenceFeaturesHeight", +function (selected) { +this.showSeqFeaturesHeight = selected; +}, "~B"); +Clazz.overrideMethod (c$, "setShowSequenceFeatures", +function (b) { +this.showSequenceFeatures = b; +}, "~B"); +Clazz.overrideMethod (c$, "setShowText", +function (state) { +this.showText = state; +}, "~B"); +Clazz.overrideMethod (c$, "setShowUnconserved", +function (showunconserved) { +this.showUnconserved = showunconserved; +}, "~B"); +Clazz.overrideMethod (c$, "setTextColour", +function (textColour) { +this.textColour = textColour; +}, "java.awt.Color"); +Clazz.overrideMethod (c$, "setTextColour2", +function (textColour2) { +this.textColour2 = textColour2; +}, "java.awt.Color"); +Clazz.overrideMethod (c$, "setThreshold", +function (thresh) { +this.threshold = thresh; +}, "~N"); +Clazz.overrideMethod (c$, "setThresholdTextColour", +function (thresholdTextColour) { +this.thresholdTextColour = thresholdTextColour; +}, "~N"); +Clazz.overrideMethod (c$, "setWrapAlignment", +function (state) { +this.wrapAlignment = state; +}, "~B"); +Clazz.overrideMethod (c$, "setWrappedWidth", +function (w) { +this.wrappedWidth = w; +}, "~N"); +Clazz.overrideMethod (c$, "sameStyle", +function (that) { +return this.equals (that); +}, "jalview.api.ViewStyleI"); +Clazz.defineMethod (c$, "getFontName", +function () { +return this.fontName; +}); +Clazz.defineMethod (c$, "getFontSize", +function () { +return this.fontSize; +}); +Clazz.defineMethod (c$, "getFontStyle", +function () { +return this.fontStyle; +}); +Clazz.overrideMethod (c$, "setFontName", +function (name) { +this.fontName = name; +}, "~S"); +Clazz.overrideMethod (c$, "setFontSize", +function (size) { +this.fontSize = size; +}, "~N"); +Clazz.overrideMethod (c$, "setFontStyle", +function (style) { +this.fontStyle = style; +}, "~N"); +Clazz.defineMethod (c$, "getIdWidth", +function () { +return this.idWidth; +}); +Clazz.overrideMethod (c$, "setIdWidth", +function (idWidth) { +this.idWidth = idWidth; +}, "~N"); +Clazz.defineMethod (c$, "isCentreColumnLabels", +function () { +return this.centreColumnLabels; +}); +Clazz.overrideMethod (c$, "setCentreColumnLabels", +function (centreColumnLabels) { +this.centreColumnLabels = centreColumnLabels; +}, "~B"); +Clazz.defineMethod (c$, "isShowDBRefs", +function () { +return this.showdbrefs; +}); +Clazz.overrideMethod (c$, "setShowDBRefs", +function (showdbrefs) { +this.showdbrefs = showdbrefs; +}, "~B"); +Clazz.defineMethod (c$, "isShowNPFeats", +function () { +return this.shownpfeats; +}); +Clazz.overrideMethod (c$, "setShowNPFeats", +function (shownpfeats) { +this.shownpfeats = shownpfeats; +}, "~B"); +Clazz.defineMethod (c$, "isScaleProteinAsCdna", +function () { +return this.scaleProteinAsCdna; +}); +Clazz.overrideMethod (c$, "setScaleProteinAsCdna", +function (b) { +this.scaleProteinAsCdna = b; +}, "~B"); +}); diff --git a/bin/jalview/workers/AlignCalcManager.js b/bin/jalview/workers/AlignCalcManager.js index 39105f8..7f25a9c 100644 --- a/bin/jalview/workers/AlignCalcManager.js +++ b/bin/jalview/workers/AlignCalcManager.js @@ -1,192 +1,192 @@ -Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.api.AlignCalcManagerI", "java.util.ArrayList", "$.Collections", "$.HashSet", "$.Hashtable"], "jalview.workers.AlignCalcManager", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.restartable = null; -this.blackList = null; -this.inProgress = null; -this.updating = null; -this.canUpdate = null; -Clazz.instantialize (this, arguments); -}, jalview.workers, "AlignCalcManager", null, jalview.api.AlignCalcManagerI); -Clazz.prepareFields (c$, function () { -this.restartable = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); -this.blackList = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); -this.inProgress = java.util.Collections.synchronizedMap ( new java.util.Hashtable ()); -this.updating = java.util.Collections.synchronizedMap ( new java.util.Hashtable ()); -this.canUpdate = new java.util.HashSet (); -}); -Clazz.overrideMethod (c$, "notifyStart", -function (worker) { -{ -var upd = this.updating.get (worker.getClass ()); -if (upd == null) { -this.updating.put (worker.getClass (), upd = java.util.Collections.synchronizedList ( new java.util.ArrayList ())); -}{ -upd.add (worker); -}}}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "alreadyDoing", -function (worker) { -{ -return this.inProgress.containsKey (worker.getClass ()); -}}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "isPending", -function (workingClass) { -var upd; -{ -upd = this.updating.get (workingClass.getClass ()); -if (upd == null) { -return false; -}{ -if (upd.size () > 1) { -return true; -}}return false; -}}, "jalview.api.AlignCalcWorkerI"); -Clazz.defineMethod (c$, "numberLive", -function (worker) { -{ -var upd = this.updating.get (worker.getClass ()); -if (upd == null) { -return 0; -};return upd.size (); -}}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "notifyWorking", -function (worker) { -{ -if (this.inProgress.get (worker.getClass ()) != null) { -if (false) { -System.err.println ("Warning: Multiple workers are running of type " + worker.getClass ()); -}return false; -}this.inProgress.put (worker.getClass (), worker); -}return true; -}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "workerComplete", -function (worker) { -{ -this.inProgress.remove (worker.getClass ()); -var upd = this.updating.get (worker.getClass ()); -if (upd != null) { -{ -upd.remove (worker); -}this.canUpdate.add (worker); -}}}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "workerCannotRun", -function (worker) { -{ -this.blackList.add (worker.getClass ()); -}}, "jalview.api.AlignCalcWorkerI"); -Clazz.defineMethod (c$, "isBlackListed", -function (workerType) { -{ -return this.blackList.contains (workerType); -}}, "Class"); -Clazz.overrideMethod (c$, "startWorker", -function (worker) { -var workerAsThread = worker; -if (workerAsThread.isAlive ()) { -workerAsThread.interrupt (); -worker = worker.getNewWorker (); -}worker.setName (worker.getClass ().getName ()); -worker.start (); -}, "jalview.api.AlignCalcWorkerI"); -Clazz.defineMethod (c$, "isWorking", -function (worker) { -{ -return worker != null && this.inProgress.get (worker.getClass ()) === worker; -}}, "jalview.api.AlignCalcWorkerI"); -Clazz.defineMethod (c$, "isWorking", -function () { -{ -return this.inProgress.size () > 0; -}}); -Clazz.overrideMethod (c$, "registerWorker", -function (worker) { -{ -if (!this.restartable.contains (worker)) { -this.restartable.add (worker); -}this.startWorker (worker); -}}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "restartWorkers", -function () { -{ -for (var worker, $worker = this.restartable.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { -this.startWorker (worker); -} -}}); -Clazz.overrideMethod (c$, "workingInvolvedWith", -function (alignmentAnnotation) { -{ -for (var worker, $worker = this.inProgress.values ().iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { -if (worker.involves (alignmentAnnotation)) { -return true; -}} -}{ -for (var workers, $workers = this.updating.values ().iterator (); $workers.hasNext () && ((workers = $workers.next ()) || true);) { -for (var worker, $worker = workers.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { -if (worker.involves (alignmentAnnotation)) { -return true; -}} -} -}return false; -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "updateAnnotationFor", -function (workerClass) { -var workers; -{ -workers = this.canUpdate.toArray ( new Array (0)); -}for (var worker, $worker = 0, $$worker = workers; $worker < $$worker.length && ((worker = $$worker[$worker]) || true); $worker++) { -if (workerClass.equals (worker.getClass ())) { -worker.updateAnnotation (); -}} -}, "Class"); -Clazz.overrideMethod (c$, "getRegisteredWorkersOfClass", -function (workerClass) { -var workingClass = new java.util.ArrayList (); -var workers; -{ -workers = this.canUpdate.toArray ( new Array (this.canUpdate.size ())); -}for (var worker, $worker = 0, $$worker = workers; $worker < $$worker.length && ((worker = $$worker[$worker]) || true); $worker++) { -if (workerClass.equals (worker.getClass ())) { -workingClass.add (worker); -}} -return (workingClass.size () == 0) ? null : workingClass; -}, "Class"); -Clazz.overrideMethod (c$, "startRegisteredWorkersOfClass", -function (workerClass) { -var workers = this.getRegisteredWorkersOfClass (workerClass); -if (workers == null) { -return false; -}for (var worker, $worker = workers.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { -if (!this.isPending (worker)) { -this.startWorker (worker); -} else { -System.err.println ("Pending exists for " + workerClass); -}} -return true; -}, "Class"); -Clazz.overrideMethod (c$, "workerMayRun", -function (worker) { -{ -if (this.blackList.contains (worker.getClass ())) { -this.blackList.remove (worker.getClass ()); -}}}, "jalview.api.AlignCalcWorkerI"); -Clazz.overrideMethod (c$, "removeRegisteredWorkersOfClass", -function (typeToRemove) { -var workers = this.getRegisteredWorkersOfClass (typeToRemove); -var removable = new java.util.ArrayList (); -var toremovannot = new java.util.HashSet (); -{ -for (var worker, $worker = this.restartable.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { -if (typeToRemove.equals (worker.getClass ())) { -removable.add (worker); -toremovannot.add (worker); -}} -this.restartable.removeAll (removable); -}{ -for (var worker, $worker = this.canUpdate.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { -if (typeToRemove.equals (worker.getClass ())) { -removable.add (worker); -toremovannot.add (worker); -}} -this.canUpdate.removeAll (removable); -}}, "Class"); -}); +Clazz.declarePackage ("jalview.workers"); +Clazz.load (["jalview.api.AlignCalcManagerI", "java.util.ArrayList", "$.Collections", "$.HashSet", "$.Hashtable"], "jalview.workers.AlignCalcManager", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.restartable = null; +this.blackList = null; +this.inProgress = null; +this.updating = null; +this.canUpdate = null; +Clazz.instantialize (this, arguments); +}, jalview.workers, "AlignCalcManager", null, jalview.api.AlignCalcManagerI); +Clazz.prepareFields (c$, function () { +this.restartable = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); +this.blackList = java.util.Collections.synchronizedList ( new java.util.ArrayList ()); +this.inProgress = java.util.Collections.synchronizedMap ( new java.util.Hashtable ()); +this.updating = java.util.Collections.synchronizedMap ( new java.util.Hashtable ()); +this.canUpdate = new java.util.HashSet (); +}); +Clazz.overrideMethod (c$, "notifyStart", +function (worker) { +{ +var upd = this.updating.get (worker.getClass ()); +if (upd == null) { +this.updating.put (worker.getClass (), upd = java.util.Collections.synchronizedList ( new java.util.ArrayList ())); +}{ +upd.add (worker); +}}}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "alreadyDoing", +function (worker) { +{ +return this.inProgress.containsKey (worker.getClass ()); +}}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "isPending", +function (workingClass) { +var upd; +{ +upd = this.updating.get (workingClass.getClass ()); +if (upd == null) { +return false; +}{ +if (upd.size () > 1) { +return true; +}}return false; +}}, "jalview.api.AlignCalcWorkerI"); +Clazz.defineMethod (c$, "numberLive", +function (worker) { +{ +var upd = this.updating.get (worker.getClass ()); +if (upd == null) { +return 0; +};return upd.size (); +}}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "notifyWorking", +function (worker) { +{ +if (this.inProgress.get (worker.getClass ()) != null) { +if (false) { +System.err.println ("Warning: Multiple workers are running of type " + worker.getClass ()); +}return false; +}this.inProgress.put (worker.getClass (), worker); +}return true; +}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "workerComplete", +function (worker) { +{ +this.inProgress.remove (worker.getClass ()); +var upd = this.updating.get (worker.getClass ()); +if (upd != null) { +{ +upd.remove (worker); +}this.canUpdate.add (worker); +}}}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "workerCannotRun", +function (worker) { +{ +this.blackList.add (worker.getClass ()); +}}, "jalview.api.AlignCalcWorkerI"); +Clazz.defineMethod (c$, "isBlackListed", +function (workerType) { +{ +return this.blackList.contains (workerType); +}}, "Class"); +Clazz.overrideMethod (c$, "startWorker", +function (worker) { +var workerAsThread = worker; +if (workerAsThread.isAlive ()) { +workerAsThread.interrupt (); +worker = worker.getNewWorker (); +}worker.setName (worker.getClass ().getName ()); +worker.start (); +}, "jalview.api.AlignCalcWorkerI"); +Clazz.defineMethod (c$, "isWorking", +function (worker) { +{ +return worker != null && this.inProgress.get (worker.getClass ()) === worker; +}}, "jalview.api.AlignCalcWorkerI"); +Clazz.defineMethod (c$, "isWorking", +function () { +{ +return this.inProgress.size () > 0; +}}); +Clazz.overrideMethod (c$, "registerWorker", +function (worker) { +{ +if (!this.restartable.contains (worker)) { +this.restartable.add (worker); +}this.startWorker (worker); +}}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "restartWorkers", +function () { +{ +for (var worker, $worker = this.restartable.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { +this.startWorker (worker); +} +}}); +Clazz.overrideMethod (c$, "workingInvolvedWith", +function (alignmentAnnotation) { +{ +for (var worker, $worker = this.inProgress.values ().iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { +if (worker.involves (alignmentAnnotation)) { +return true; +}} +}{ +for (var workers, $workers = this.updating.values ().iterator (); $workers.hasNext () && ((workers = $workers.next ()) || true);) { +for (var worker, $worker = workers.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { +if (worker.involves (alignmentAnnotation)) { +return true; +}} +} +}return false; +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "updateAnnotationFor", +function (workerClass) { +var workers; +{ +workers = this.canUpdate.toArray ( new Array (0)); +}for (var worker, $worker = 0, $$worker = workers; $worker < $$worker.length && ((worker = $$worker[$worker]) || true); $worker++) { +if (workerClass.equals (worker.getClass ())) { +worker.updateAnnotation (); +}} +}, "Class"); +Clazz.overrideMethod (c$, "getRegisteredWorkersOfClass", +function (workerClass) { +var workingClass = new java.util.ArrayList (); +var workers; +{ +workers = this.canUpdate.toArray ( new Array (this.canUpdate.size ())); +}for (var worker, $worker = 0, $$worker = workers; $worker < $$worker.length && ((worker = $$worker[$worker]) || true); $worker++) { +if (workerClass.equals (worker.getClass ())) { +workingClass.add (worker); +}} +return (workingClass.size () == 0) ? null : workingClass; +}, "Class"); +Clazz.overrideMethod (c$, "startRegisteredWorkersOfClass", +function (workerClass) { +var workers = this.getRegisteredWorkersOfClass (workerClass); +if (workers == null) { +return false; +}for (var worker, $worker = workers.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { +if (!this.isPending (worker)) { +this.startWorker (worker); +} else { +System.err.println ("Pending exists for " + workerClass); +}} +return true; +}, "Class"); +Clazz.overrideMethod (c$, "workerMayRun", +function (worker) { +{ +if (this.blackList.contains (worker.getClass ())) { +this.blackList.remove (worker.getClass ()); +}}}, "jalview.api.AlignCalcWorkerI"); +Clazz.overrideMethod (c$, "removeRegisteredWorkersOfClass", +function (typeToRemove) { +var workers = this.getRegisteredWorkersOfClass (typeToRemove); +var removable = new java.util.ArrayList (); +var toremovannot = new java.util.HashSet (); +{ +for (var worker, $worker = this.restartable.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { +if (typeToRemove.equals (worker.getClass ())) { +removable.add (worker); +toremovannot.add (worker); +}} +this.restartable.removeAll (removable); +}{ +for (var worker, $worker = this.canUpdate.iterator (); $worker.hasNext () && ((worker = $worker.next ()) || true);) { +if (typeToRemove.equals (worker.getClass ())) { +removable.add (worker); +toremovannot.add (worker); +}} +this.canUpdate.removeAll (removable); +}}, "Class"); +}); diff --git a/bin/jalview/workers/AlignCalcWorker.js b/bin/jalview/workers/AlignCalcWorker.js index 6636e6d..43b690b 100644 --- a/bin/jalview/workers/AlignCalcWorker.js +++ b/bin/jalview/workers/AlignCalcWorker.js @@ -1,54 +1,54 @@ -Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.api.AlignCalcWorkerI", "swingjs.JSThread"], "jalview.workers.AlignCalcWorker", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.iFirst = 0; -this.iLast = 0; -this.nPer = 2; -this.started = 0; -this.alignment = null; -this.aWidth = 0; -this.alignViewport = null; -this.calcMan = null; -this.ap = null; -this.ourAnnots = null; -Clazz.instantialize (this, arguments); -}, jalview.workers, "AlignCalcWorker", swingjs.JSThread, jalview.api.AlignCalcWorkerI); -Clazz.makeConstructor (c$, -function (alignViewport, alignPanel) { -Clazz.superConstructor (this, jalview.workers.AlignCalcWorker, [null, "AlignCalcWorker"]); -this.alignViewport = alignViewport; -this.calcMan = alignViewport.getCalcManager (); -this.ap = alignPanel; -}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); -Clazz.defineMethod (c$, "abortAndDestroy", -function () { -if (this.calcMan != null) { -this.calcMan.workerComplete (this); -}this.alignViewport = null; -this.calcMan = null; -this.ap = null; -}); -Clazz.overrideMethod (c$, "involves", -function (i) { -return this.ourAnnots != null && this.ourAnnots.contains (i); -}, "jalview.datamodel.AlignmentAnnotation"); -Clazz.overrideMethod (c$, "removeOurAnnotation", -function () { -if (this.ourAnnots != null && this.alignViewport != null) { -var alignment = this.alignViewport.getAlignment (); -{ -for (var aa, $aa = this.ourAnnots.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { -alignment.deleteAnnotation (aa, true); -} -}}}); -Clazz.defineMethod (c$, "notifyDone", -function () { -if (this.ap != null) { -this.ap.paintAlignment (true); -}this.calcMan.workerComplete (this); -}); -Clazz.defineStatics (c$, -"LOOP_STANDBY", 3, -"LOOP_CALCULATE", 4, -"MS_MAX", 500); -}); +Clazz.declarePackage ("jalview.workers"); +Clazz.load (["jalview.api.AlignCalcWorkerI", "swingjs.JSThread"], "jalview.workers.AlignCalcWorker", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.iFirst = 0; +this.iLast = 0; +this.nPer = 2; +this.started = 0; +this.alignment = null; +this.aWidth = 0; +this.alignViewport = null; +this.calcMan = null; +this.ap = null; +this.ourAnnots = null; +Clazz.instantialize (this, arguments); +}, jalview.workers, "AlignCalcWorker", swingjs.JSThread, jalview.api.AlignCalcWorkerI); +Clazz.makeConstructor (c$, +function (alignViewport, alignPanel) { +Clazz.superConstructor (this, jalview.workers.AlignCalcWorker, [null, "AlignCalcWorker"]); +this.alignViewport = alignViewport; +this.calcMan = alignViewport.getCalcManager (); +this.ap = alignPanel; +}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); +Clazz.defineMethod (c$, "abortAndDestroy", +function () { +if (this.calcMan != null) { +this.calcMan.workerComplete (this); +}this.alignViewport = null; +this.calcMan = null; +this.ap = null; +}); +Clazz.overrideMethod (c$, "involves", +function (i) { +return this.ourAnnots != null && this.ourAnnots.contains (i); +}, "jalview.datamodel.AlignmentAnnotation"); +Clazz.overrideMethod (c$, "removeOurAnnotation", +function () { +if (this.ourAnnots != null && this.alignViewport != null) { +var alignment = this.alignViewport.getAlignment (); +{ +for (var aa, $aa = this.ourAnnots.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) { +alignment.deleteAnnotation (aa, true); +} +}}}); +Clazz.defineMethod (c$, "notifyDone", +function () { +if (this.ap != null) { +this.ap.paintAlignment (true); +}this.calcMan.workerComplete (this); +}); +Clazz.defineStatics (c$, +"LOOP_STANDBY", 3, +"LOOP_CALCULATE", 4, +"MS_MAX", 500); +}); diff --git a/bin/jalview/workers/ComplementConsensusThread.js b/bin/jalview/workers/ComplementConsensusThread.js index 17ece7f..641c3ba 100644 --- a/bin/jalview/workers/ComplementConsensusThread.js +++ b/bin/jalview/workers/ComplementConsensusThread.js @@ -1,46 +1,46 @@ -Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.workers.ConsensusThread"], "jalview.workers.ComplementConsensusThread", ["jalview.analysis.AAFrequency"], function () { -c$ = Clazz.decorateAsClass (function () { -this.mappings = null; -Clazz.instantialize (this, arguments); -}, jalview.workers, "ComplementConsensusThread", jalview.workers.ConsensusThread); -Clazz.overrideMethod (c$, "getNewWorker", -function () { -return new jalview.workers.ComplementConsensusThread (this.alignViewport, this.ap); -}); -Clazz.overrideMethod (c$, "getConsensusAnnotation", -function () { -return this.alignViewport.getComplementConsensusAnnotation (); -}); -Clazz.overrideMethod (c$, "getViewportConsensus", -function () { -return this.alignViewport.getComplementConsensusHash (); -}); -Clazz.defineMethod (c$, "initializeCalc", -function () { -this.mappings = this.alignment.getCodonFrames (); -return (this.mappings != null && !this.mappings.isEmpty () && Clazz.superCall (this, jalview.workers.ComplementConsensusThread, "initializeCalc", [])); -}); -Clazz.overrideMethod (c$, "computeConsensus", -function () { -for (var i = 0; i < 3; i++) { -try { -jalview.analysis.AAFrequency.calculateCdna (this.alignment, this.mappings, this.hconsensus, this.iFirst, this.iLast); -break; -} catch (e) { -if (Clazz.exceptionOf (e, java.util.ConcurrentModificationException)) { -} else { -throw e; -} -} -} -}); -Clazz.overrideMethod (c$, "finalizeCalc", -function () { -this.alignViewport.setComplementConsensusHash (this.hconsensus); -}); -Clazz.overrideMethod (c$, "deriveConsensus", -function (consensusAnnotation, consensusData) { -jalview.analysis.AAFrequency.completeCdnaConsensus (consensusAnnotation, consensusData, this.alignViewport.isShowSequenceLogo (), this.getSequences ().length); -}, "jalview.datamodel.AlignmentAnnotation,~A"); -}); +Clazz.declarePackage ("jalview.workers"); +Clazz.load (["jalview.workers.ConsensusThread"], "jalview.workers.ComplementConsensusThread", ["jalview.analysis.AAFrequency"], function () { +c$ = Clazz.decorateAsClass (function () { +this.mappings = null; +Clazz.instantialize (this, arguments); +}, jalview.workers, "ComplementConsensusThread", jalview.workers.ConsensusThread); +Clazz.overrideMethod (c$, "getNewWorker", +function () { +return new jalview.workers.ComplementConsensusThread (this.alignViewport, this.ap); +}); +Clazz.overrideMethod (c$, "getConsensusAnnotation", +function () { +return this.alignViewport.getComplementConsensusAnnotation (); +}); +Clazz.overrideMethod (c$, "getViewportConsensus", +function () { +return this.alignViewport.getComplementConsensusHash (); +}); +Clazz.defineMethod (c$, "initializeCalc", +function () { +this.mappings = this.alignment.getCodonFrames (); +return (this.mappings != null && !this.mappings.isEmpty () && Clazz.superCall (this, jalview.workers.ComplementConsensusThread, "initializeCalc", [])); +}); +Clazz.overrideMethod (c$, "computeConsensus", +function () { +for (var i = 0; i < 3; i++) { +try { +jalview.analysis.AAFrequency.calculateCdna (this.alignment, this.mappings, this.hconsensus, this.iFirst, this.iLast); +break; +} catch (e) { +if (Clazz.exceptionOf (e, java.util.ConcurrentModificationException)) { +} else { +throw e; +} +} +} +}); +Clazz.overrideMethod (c$, "finalizeCalc", +function () { +this.alignViewport.setComplementConsensusHash (this.hconsensus); +}); +Clazz.overrideMethod (c$, "deriveConsensus", +function (consensusAnnotation, consensusData) { +jalview.analysis.AAFrequency.completeCdnaConsensus (consensusAnnotation, consensusData, this.alignViewport.isShowSequenceLogo (), this.getSequences ().length); +}, "jalview.datamodel.AlignmentAnnotation,~A"); +}); diff --git a/bin/jalview/workers/ConsensusThread.js b/bin/jalview/workers/ConsensusThread.js index 089a18e..3f62035 100644 --- a/bin/jalview/workers/ConsensusThread.js +++ b/bin/jalview/workers/ConsensusThread.js @@ -1,149 +1,149 @@ -Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConsensusThread", ["jalview.analysis.AAFrequency"], function () { -c$ = Clazz.decorateAsClass (function () { -this.hconsensus = null; -this.aseqs = null; -Clazz.instantialize (this, arguments); -}, jalview.workers, "ConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI); -Clazz.overrideMethod (c$, "getNewWorker", -function () { -return new jalview.workers.ConsensusThread (this.alignViewport, this.ap); -}); -Clazz.overrideMethod (c$, "run1", -function (state) { -while (!Thread.interrupted ()) { -if (this.alignViewport.isClosed ()) { -this.abortAndDestroy (); -return; -}try { -switch (state) { -case 0: -if (this.calcMan.isPending (this)) return; -this.calcMan.notifyStart (this); -var consensus = this.getConsensusAnnotation (); -if (consensus == null || this.calcMan.isPending (this)) { -this.calcMan.workerComplete (this); -return; -}state = 3; -break; -case 3: -while (!this.calcMan.notifyWorking (this)) { -if (this.ap != null) { -this.ap.paintAlignment (false); -}try { -if (this.sleepAndReturn (200, state)) return; -} catch (e) { -if (Clazz.exceptionOf (e, InterruptedException)) { -state = 2; -break; -} else { -throw e; -} -} -} -if (this.alignViewport.isClosed ()) { -this.abortAndDestroy (); -state = 2; -break; -}this.alignment = this.alignViewport.getAlignment (); -this.aWidth = -1; -if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) { -state = 2; -}this.eraseConsensus (this.aWidth); -state = (this.initializeCalc () ? 4 : 2); -break; -case 4: -this.iFirst = this.iLast; -this.iLast = Math.min (this.iLast + this.nPer, this.aWidth); -if (this.iLast == this.iFirst) { -state = 2; -} else { -this.computeConsensus (); -if (this.sleepAndReturn (0, state)) return; -}break; -case 2: -this.finalizeCalc (); -this.updateAlignment (); -this.notifyDone (); -return; -} -} catch (e$$) { -if (Clazz.exceptionOf (e$$, OutOfMemoryError)) { -var error = e$$; -{ -this.calcMan.workerCannotRun (this); -this.ap.raiseOOMWarning ("calculating consensus", error); -} -} else { -var e = e$$; -{ -System.out.println ("Error in ConsensusThread: " + e); -e.printStackTrace (); -this.calcMan.workerComplete (this); -} -} -} -} -}, "~N"); -Clazz.defineMethod (c$, "initializeCalc", -function () { -this.iLast = 0; -this.hconsensus = new Array (this.aWidth); -this.aseqs = this.getSequences (); -return true; -}); -Clazz.defineMethod (c$, "computeConsensus", -function () { -this.started = System.currentTimeMillis (); -jalview.analysis.AAFrequency.calculate (this.aseqs, this.iFirst, this.iLast, this.hconsensus, true); -if (System.currentTimeMillis () - this.started < 500) this.nPer *= 2; -}); -Clazz.defineMethod (c$, "finalizeCalc", -function () { -this.alignViewport.setSequenceConsensusHash (this.hconsensus); -}); -Clazz.defineMethod (c$, "updateAlignment", -function () { -this.setColourSchemeConsensus (this.hconsensus); -this.updateResultAnnotation (true); -}); -Clazz.defineMethod (c$, "eraseConsensus", -function (aWidth) { -var consensus = this.getConsensusAnnotation (); -consensus.annotations = new Array (aWidth); -}, "~N"); -Clazz.defineMethod (c$, "getSequences", -function () { -return this.alignViewport.getAlignment ().getSequencesArray (); -}); -Clazz.defineMethod (c$, "setColourSchemeConsensus", -function (hconsensus) { -var globalColourScheme = this.alignViewport.getGlobalColourScheme (); -if (globalColourScheme != null) { -globalColourScheme.setConsensus (hconsensus); -}}, "~A"); -Clazz.defineMethod (c$, "getConsensusAnnotation", -function () { -return this.alignViewport.getAlignmentConsensusAnnotation (); -}); -Clazz.overrideMethod (c$, "updateAnnotation", -function () { -this.updateResultAnnotation (false); -}); -Clazz.defineMethod (c$, "updateResultAnnotation", -function (immediate) { -var consensus = this.getConsensusAnnotation (); -var hconsensus = this.getViewportConsensus (); -if (immediate || !this.calcMan.isWorking (this) && consensus != null && hconsensus != null) { -this.deriveConsensus (consensus, hconsensus); -}}, "~B"); -Clazz.defineMethod (c$, "deriveConsensus", -function (consensusAnnotation, consensusData) { -var nseq = this.getSequences ().length; -jalview.analysis.AAFrequency.completeConsensus (consensusAnnotation, consensusData, 0, consensusData.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), nseq); -}, "jalview.datamodel.AlignmentAnnotation,~A"); -Clazz.defineMethod (c$, "getViewportConsensus", -function () { -return this.alignViewport.getSequenceConsensusHash (); -}); -}); +Clazz.declarePackage ("jalview.workers"); +Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConsensusThread", ["jalview.analysis.AAFrequency"], function () { +c$ = Clazz.decorateAsClass (function () { +this.hconsensus = null; +this.aseqs = null; +Clazz.instantialize (this, arguments); +}, jalview.workers, "ConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI); +Clazz.overrideMethod (c$, "getNewWorker", +function () { +return new jalview.workers.ConsensusThread (this.alignViewport, this.ap); +}); +Clazz.overrideMethod (c$, "run1", +function (state) { +while (!Thread.interrupted ()) { +if (this.alignViewport.isClosed ()) { +this.abortAndDestroy (); +return; +}try { +switch (state) { +case 0: +if (this.calcMan.isPending (this)) return; +this.calcMan.notifyStart (this); +var consensus = this.getConsensusAnnotation (); +if (consensus == null || this.calcMan.isPending (this)) { +this.calcMan.workerComplete (this); +return; +}state = 3; +break; +case 3: +while (!this.calcMan.notifyWorking (this)) { +if (this.ap != null) { +this.ap.paintAlignment (false); +}try { +if (this.sleepAndReturn (200, state)) return; +} catch (e) { +if (Clazz.exceptionOf (e, InterruptedException)) { +state = 2; +break; +} else { +throw e; +} +} +} +if (this.alignViewport.isClosed ()) { +this.abortAndDestroy (); +state = 2; +break; +}this.alignment = this.alignViewport.getAlignment (); +this.aWidth = -1; +if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) { +state = 2; +}this.eraseConsensus (this.aWidth); +state = (this.initializeCalc () ? 4 : 2); +break; +case 4: +this.iFirst = this.iLast; +this.iLast = Math.min (this.iLast + this.nPer, this.aWidth); +if (this.iLast == this.iFirst) { +state = 2; +} else { +this.computeConsensus (); +if (this.sleepAndReturn (0, state)) return; +}break; +case 2: +this.finalizeCalc (); +this.updateAlignment (); +this.notifyDone (); +return; +} +} catch (e$$) { +if (Clazz.exceptionOf (e$$, OutOfMemoryError)) { +var error = e$$; +{ +this.calcMan.workerCannotRun (this); +this.ap.raiseOOMWarning ("calculating consensus", error); +} +} else { +var e = e$$; +{ +System.out.println ("Error in ConsensusThread: " + e); +e.printStackTrace (); +this.calcMan.workerComplete (this); +} +} +} +} +}, "~N"); +Clazz.defineMethod (c$, "initializeCalc", +function () { +this.iLast = 0; +this.hconsensus = new Array (this.aWidth); +this.aseqs = this.getSequences (); +return true; +}); +Clazz.defineMethod (c$, "computeConsensus", +function () { +this.started = System.currentTimeMillis (); +jalview.analysis.AAFrequency.calculate (this.aseqs, this.iFirst, this.iLast, this.hconsensus, true); +if (System.currentTimeMillis () - this.started < 500) this.nPer *= 2; +}); +Clazz.defineMethod (c$, "finalizeCalc", +function () { +this.alignViewport.setSequenceConsensusHash (this.hconsensus); +}); +Clazz.defineMethod (c$, "updateAlignment", +function () { +this.setColourSchemeConsensus (this.hconsensus); +this.updateResultAnnotation (true); +}); +Clazz.defineMethod (c$, "eraseConsensus", +function (aWidth) { +var consensus = this.getConsensusAnnotation (); +consensus.annotations = new Array (aWidth); +}, "~N"); +Clazz.defineMethod (c$, "getSequences", +function () { +return this.alignViewport.getAlignment ().getSequencesArray (); +}); +Clazz.defineMethod (c$, "setColourSchemeConsensus", +function (hconsensus) { +var globalColourScheme = this.alignViewport.getGlobalColourScheme (); +if (globalColourScheme != null) { +globalColourScheme.setConsensus (hconsensus); +}}, "~A"); +Clazz.defineMethod (c$, "getConsensusAnnotation", +function () { +return this.alignViewport.getAlignmentConsensusAnnotation (); +}); +Clazz.overrideMethod (c$, "updateAnnotation", +function () { +this.updateResultAnnotation (false); +}); +Clazz.defineMethod (c$, "updateResultAnnotation", +function (immediate) { +var consensus = this.getConsensusAnnotation (); +var hconsensus = this.getViewportConsensus (); +if (immediate || !this.calcMan.isWorking (this) && consensus != null && hconsensus != null) { +this.deriveConsensus (consensus, hconsensus); +}}, "~B"); +Clazz.defineMethod (c$, "deriveConsensus", +function (consensusAnnotation, consensusData) { +var nseq = this.getSequences ().length; +jalview.analysis.AAFrequency.completeConsensus (consensusAnnotation, consensusData, 0, consensusData.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), nseq); +}, "jalview.datamodel.AlignmentAnnotation,~A"); +Clazz.defineMethod (c$, "getViewportConsensus", +function () { +return this.alignViewport.getSequenceConsensusHash (); +}); +}); diff --git a/bin/jalview/workers/ConservationThread.js b/bin/jalview/workers/ConservationThread.js index d790876..dc839a9 100644 --- a/bin/jalview/workers/ConservationThread.js +++ b/bin/jalview/workers/ConservationThread.js @@ -1,108 +1,108 @@ -Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConservationThread", ["jalview.analysis.Conservation", "jalview.schemes.ResidueProperties", "java.util.ArrayList"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ConsPercGaps = 25; -this.cons = null; -this.conservation = null; -this.quality = null; -Clazz.instantialize (this, arguments); -}, jalview.workers, "ConservationThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI); -Clazz.overrideMethod (c$, "getNewWorker", -function () { -return new jalview.workers.ConservationThread (this.alignViewport, this.ap); -}); -Clazz.makeConstructor (c$, -function (alignViewport, alignPanel) { -Clazz.superConstructor (this, jalview.workers.ConservationThread, [alignViewport, alignPanel]); -this.ConsPercGaps = alignViewport.getConsPercGaps (); -}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); -Clazz.overrideMethod (c$, "run1", -function (state) { -while (!Thread.interrupted ()) { -try { -switch (state) { -case 0: -if (this.calcMan.isPending (this)) return; -this.calcMan.notifyStart (this); -state = 3; -break; -case 3: -while (!this.calcMan.notifyWorking (this)) { -if (this.ap != null) { -this.ap.paintAlignment (false); -}try { -if (this.sleepAndReturn (200, state)) return; -} catch (e) { -if (Clazz.exceptionOf (e, InterruptedException)) { -state = 2; -break; -} else { -throw e; -} -} -} -if (this.alignViewport.isClosed ()) { -this.abortAndDestroy (); -state = 2; -break; -}var ourAnnot = new java.util.ArrayList (); -this.alignment = this.alignViewport.getAlignment (); -this.conservation = this.alignViewport.getAlignmentConservationAnnotation (); -this.quality = this.alignViewport.getAlignmentQualityAnnot (); -ourAnnot.add (this.conservation); -ourAnnot.add (this.quality); -this.ourAnnots = ourAnnot; -this.ConsPercGaps = this.alignViewport.getConsPercGaps (); -if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) { -this.calcMan.workerComplete (this); -return; -}state = 4; -break; -case 4: -this.iFirst = this.iLast; -this.nPer = this.aWidth + 1; -this.iLast = Math.min (this.iLast + this.nPer, this.aWidth); -if (this.iLast == this.iFirst) { -state = 2; -} else { -this.computeConsensus (); -if (this.sleepAndReturn (0, state)) return; -}break; -case 2: -this.updateResultAnnotation (true); -this.notifyDone (); -return; -} -} catch (e$$) { -if (Clazz.exceptionOf (e$$, OutOfMemoryError)) { -var error = e$$; -{ -this.calcMan.workerCannotRun (this); -this.ap.raiseOOMWarning ("calculating conservation", error); -} -} else { -var e = e$$; -{ -System.out.println ("Error in ConsensusThread: " + e); -e.printStackTrace (); -this.calcMan.workerComplete (this); -} -} -} -} -}, "~N"); -Clazz.defineMethod (c$, "computeConsensus", -($fz = function () { -this.cons = jalview.analysis.Conservation.calculateConservation ("All", jalview.schemes.ResidueProperties.propHash, 3, this.alignment.getSequences (), 0, this.aWidth - 1, false, this.ConsPercGaps, this.quality != null); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "updateResultAnnotation", -($fz = function (b) { -if (b || !this.calcMan.isWorking (this) && this.cons != null && this.conservation != null && this.quality != null) { -this.alignViewport.setConservation (this.cons); -this.cons.completeAnnotations (this.conservation, this.quality, 0, this.aWidth); -}}, $fz.isPrivate = true, $fz), "~B"); -Clazz.overrideMethod (c$, "updateAnnotation", -function () { -this.updateResultAnnotation (false); -}); -}); +Clazz.declarePackage ("jalview.workers"); +Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.ConservationThread", ["jalview.analysis.Conservation", "jalview.schemes.ResidueProperties", "java.util.ArrayList"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ConsPercGaps = 25; +this.cons = null; +this.conservation = null; +this.quality = null; +Clazz.instantialize (this, arguments); +}, jalview.workers, "ConservationThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI); +Clazz.overrideMethod (c$, "getNewWorker", +function () { +return new jalview.workers.ConservationThread (this.alignViewport, this.ap); +}); +Clazz.makeConstructor (c$, +function (alignViewport, alignPanel) { +Clazz.superConstructor (this, jalview.workers.ConservationThread, [alignViewport, alignPanel]); +this.ConsPercGaps = alignViewport.getConsPercGaps (); +}, "jalview.api.AlignViewportI,jalview.api.AlignmentViewPanel"); +Clazz.overrideMethod (c$, "run1", +function (state) { +while (!Thread.interrupted ()) { +try { +switch (state) { +case 0: +if (this.calcMan.isPending (this)) return; +this.calcMan.notifyStart (this); +state = 3; +break; +case 3: +while (!this.calcMan.notifyWorking (this)) { +if (this.ap != null) { +this.ap.paintAlignment (false); +}try { +if (this.sleepAndReturn (200, state)) return; +} catch (e) { +if (Clazz.exceptionOf (e, InterruptedException)) { +state = 2; +break; +} else { +throw e; +} +} +} +if (this.alignViewport.isClosed ()) { +this.abortAndDestroy (); +state = 2; +break; +}var ourAnnot = new java.util.ArrayList (); +this.alignment = this.alignViewport.getAlignment (); +this.conservation = this.alignViewport.getAlignmentConservationAnnotation (); +this.quality = this.alignViewport.getAlignmentQualityAnnot (); +ourAnnot.add (this.conservation); +ourAnnot.add (this.quality); +this.ourAnnots = ourAnnot; +this.ConsPercGaps = this.alignViewport.getConsPercGaps (); +if (this.alignment == null || (this.aWidth = this.alignment.getWidth ()) < 0) { +this.calcMan.workerComplete (this); +return; +}state = 4; +break; +case 4: +this.iFirst = this.iLast; +this.nPer = this.aWidth + 1; +this.iLast = Math.min (this.iLast + this.nPer, this.aWidth); +if (this.iLast == this.iFirst) { +state = 2; +} else { +this.computeConsensus (); +if (this.sleepAndReturn (0, state)) return; +}break; +case 2: +this.updateResultAnnotation (true); +this.notifyDone (); +return; +} +} catch (e$$) { +if (Clazz.exceptionOf (e$$, OutOfMemoryError)) { +var error = e$$; +{ +this.calcMan.workerCannotRun (this); +this.ap.raiseOOMWarning ("calculating conservation", error); +} +} else { +var e = e$$; +{ +System.out.println ("Error in ConsensusThread: " + e); +e.printStackTrace (); +this.calcMan.workerComplete (this); +} +} +} +} +}, "~N"); +Clazz.defineMethod (c$, "computeConsensus", +($fz = function () { +this.cons = jalview.analysis.Conservation.calculateConservation ("All", jalview.schemes.ResidueProperties.propHash, 3, this.alignment.getSequences (), 0, this.aWidth - 1, false, this.ConsPercGaps, this.quality != null); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "updateResultAnnotation", +($fz = function (b) { +if (b || !this.calcMan.isWorking (this) && this.cons != null && this.conservation != null && this.quality != null) { +this.alignViewport.setConservation (this.cons); +this.cons.completeAnnotations (this.conservation, this.quality, 0, this.aWidth); +}}, $fz.isPrivate = true, $fz), "~B"); +Clazz.overrideMethod (c$, "updateAnnotation", +function () { +this.updateResultAnnotation (false); +}); +}); diff --git a/bin/jalview/workers/StrucConsensusThread.js b/bin/jalview/workers/StrucConsensusThread.js index dbe6d50..4010f84 100644 --- a/bin/jalview/workers/StrucConsensusThread.js +++ b/bin/jalview/workers/StrucConsensusThread.js @@ -1,95 +1,95 @@ -Clazz.declarePackage ("jalview.workers"); -Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () { -c$ = Clazz.decorateAsClass (function () { -this.strucConsensus = null; -this.hStrucConsensus = null; -this.nseq = -1; -Clazz.instantialize (this, arguments); -}, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI); -Clazz.overrideMethod (c$, "getNewWorker", -function () { -return new jalview.workers.StrucConsensusThread (this.alignViewport, this.ap); -}); -Clazz.overrideMethod (c$, "run", -function () { -try { -if (this.calcMan.isPending (this)) { -return; -}this.calcMan.notifyStart (this); -while (!this.calcMan.notifyWorking (this)) { -try { -if (this.ap != null) { -}Thread.sleep (200); -} catch (ex) { -if (Clazz.exceptionOf (ex, Exception)) { -ex.printStackTrace (); -} else { -throw ex; -} -} -} -if (this.alignViewport.isClosed ()) { -this.abortAndDestroy (); -return; -}var alignment = this.alignViewport.getAlignment (); -var aWidth = -1; -if (alignment == null || (aWidth = alignment.getWidth ()) < 0) { -this.calcMan.workerComplete (this); -return; -}this.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation (); -this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash (); -this.strucConsensus.annotations = null; -this.strucConsensus.annotations = new Array (aWidth); -this.hStrucConsensus = new Array (aWidth); -var aa = this.alignViewport.getAlignment ().getAlignmentAnnotation (); -var rnaStruc = null; -for (var i = 0; i < aa.length; i++) { -if (aa[i].getRNAStruc () != null && aa[i].isValidStruc ()) { -rnaStruc = aa[i]; -break; -}} -if (rnaStruc == null || !rnaStruc.isValidStruc ()) { -this.calcMan.workerComplete (this); -return; -}try { -var arr = alignment.getSequencesArray (); -this.nseq = arr.length; -jalview.analysis.StructureFrequency.calculate (arr, 0, alignment.getWidth (), this.hStrucConsensus, true, rnaStruc); -} catch (x) { -if (Clazz.exceptionOf (x, ArrayIndexOutOfBoundsException)) { -this.calcMan.workerComplete (this); -return; -} else { -throw x; -} -} -this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus); -this.updateResultAnnotation (true); -if (this.alignViewport.getGlobalColourScheme () != null) { -this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus); -}} catch (error) { -if (Clazz.exceptionOf (error, OutOfMemoryError)) { -this.calcMan.workerCannotRun (this); -this.ap.raiseOOMWarning ("calculating RNA structure consensus", error); -} else { -throw error; -} -} finally { -this.calcMan.workerComplete (this); -if (this.ap != null) { -this.ap.paintAlignment (true); -}} -}); -Clazz.overrideMethod (c$, "updateAnnotation", -function () { -this.updateResultAnnotation (false); -}); -Clazz.defineMethod (c$, "updateResultAnnotation", -function (immediate) { -if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) { -jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq); -}}, "~B"); -Clazz.overrideMethod (c$, "run1", -function (state) { -}, "~N"); -}); +Clazz.declarePackage ("jalview.workers"); +Clazz.load (["jalview.api.AlignCalcWorkerI", "jalview.workers.AlignCalcWorker"], "jalview.workers.StrucConsensusThread", ["jalview.analysis.StructureFrequency", "java.lang.Thread"], function () { +c$ = Clazz.decorateAsClass (function () { +this.strucConsensus = null; +this.hStrucConsensus = null; +this.nseq = -1; +Clazz.instantialize (this, arguments); +}, jalview.workers, "StrucConsensusThread", jalview.workers.AlignCalcWorker, jalview.api.AlignCalcWorkerI); +Clazz.overrideMethod (c$, "getNewWorker", +function () { +return new jalview.workers.StrucConsensusThread (this.alignViewport, this.ap); +}); +Clazz.overrideMethod (c$, "run", +function () { +try { +if (this.calcMan.isPending (this)) { +return; +}this.calcMan.notifyStart (this); +while (!this.calcMan.notifyWorking (this)) { +try { +if (this.ap != null) { +}Thread.sleep (200); +} catch (ex) { +if (Clazz.exceptionOf (ex, Exception)) { +ex.printStackTrace (); +} else { +throw ex; +} +} +} +if (this.alignViewport.isClosed ()) { +this.abortAndDestroy (); +return; +}var alignment = this.alignViewport.getAlignment (); +var aWidth = -1; +if (alignment == null || (aWidth = alignment.getWidth ()) < 0) { +this.calcMan.workerComplete (this); +return; +}this.strucConsensus = this.alignViewport.getAlignmentStrucConsensusAnnotation (); +this.hStrucConsensus = this.alignViewport.getRnaStructureConsensusHash (); +this.strucConsensus.annotations = null; +this.strucConsensus.annotations = new Array (aWidth); +this.hStrucConsensus = new Array (aWidth); +var aa = this.alignViewport.getAlignment ().getAlignmentAnnotation (); +var rnaStruc = null; +for (var i = 0; i < aa.length; i++) { +if (aa[i].getRNAStruc () != null && aa[i].isValidStruc ()) { +rnaStruc = aa[i]; +break; +}} +if (rnaStruc == null || !rnaStruc.isValidStruc ()) { +this.calcMan.workerComplete (this); +return; +}try { +var arr = alignment.getSequencesArray (); +this.nseq = arr.length; +jalview.analysis.StructureFrequency.calculate (arr, 0, alignment.getWidth (), this.hStrucConsensus, true, rnaStruc); +} catch (x) { +if (Clazz.exceptionOf (x, ArrayIndexOutOfBoundsException)) { +this.calcMan.workerComplete (this); +return; +} else { +throw x; +} +} +this.alignViewport.setRnaStructureConsensusHash (this.hStrucConsensus); +this.updateResultAnnotation (true); +if (this.alignViewport.getGlobalColourScheme () != null) { +this.alignViewport.getGlobalColourScheme ().setConsensus (this.hStrucConsensus); +}} catch (error) { +if (Clazz.exceptionOf (error, OutOfMemoryError)) { +this.calcMan.workerCannotRun (this); +this.ap.raiseOOMWarning ("calculating RNA structure consensus", error); +} else { +throw error; +} +} finally { +this.calcMan.workerComplete (this); +if (this.ap != null) { +this.ap.paintAlignment (true); +}} +}); +Clazz.overrideMethod (c$, "updateAnnotation", +function () { +this.updateResultAnnotation (false); +}); +Clazz.defineMethod (c$, "updateResultAnnotation", +function (immediate) { +if (immediate || !this.calcMan.isWorking (this) && this.strucConsensus != null && this.hStrucConsensus != null) { +jalview.analysis.StructureFrequency.completeConsensus (this.strucConsensus, this.hStrucConsensus, 0, this.hStrucConsensus.length, this.alignViewport.isIgnoreGapsConsensus (), this.alignViewport.isShowSequenceLogo (), this.nseq); +}}, "~B"); +Clazz.overrideMethod (c$, "run1", +function (state) { +}, "~N"); +}); diff --git a/bin/javajs/J2SIgnoreImport.js b/bin/javajs/J2SIgnoreImport.js index bd94c0d..5b4de23 100644 --- a/bin/javajs/J2SIgnoreImport.js +++ b/bin/javajs/J2SIgnoreImport.js @@ -1 +1 @@ -Clazz.declarePackage ("javajs"); +Clazz.declarePackage ("javajs"); diff --git a/bin/javajs/J2SRequireImport.js b/bin/javajs/J2SRequireImport.js index bd94c0d..5b4de23 100644 --- a/bin/javajs/J2SRequireImport.js +++ b/bin/javajs/J2SRequireImport.js @@ -1 +1 @@ -Clazz.declarePackage ("javajs"); +Clazz.declarePackage ("javajs"); diff --git a/bin/javajs/api/BytePoster.js b/bin/javajs/api/BytePoster.js index 1fb861c..c97ddaf 100644 --- a/bin/javajs/api/BytePoster.js +++ b/bin/javajs/api/BytePoster.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "BytePoster"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "BytePoster"); diff --git a/bin/javajs/api/EigenInterface.js b/bin/javajs/api/EigenInterface.js index b6e97f1..b5d1d99 100644 --- a/bin/javajs/api/EigenInterface.js +++ b/bin/javajs/api/EigenInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "EigenInterface"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "EigenInterface"); diff --git a/bin/javajs/api/EventManager.js b/bin/javajs/api/EventManager.js index a80b250..c5a4fa9 100644 --- a/bin/javajs/api/EventManager.js +++ b/bin/javajs/api/EventManager.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "EventManager"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "EventManager"); diff --git a/bin/javajs/api/FontManager.js b/bin/javajs/api/FontManager.js index f458d89..a809538 100644 --- a/bin/javajs/api/FontManager.js +++ b/bin/javajs/api/FontManager.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "FontManager"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "FontManager"); diff --git a/bin/javajs/api/GenericBinaryDocument.js b/bin/javajs/api/GenericBinaryDocument.js index 8a2bbf9..0da5b99 100644 --- a/bin/javajs/api/GenericBinaryDocument.js +++ b/bin/javajs/api/GenericBinaryDocument.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericBinaryDocument"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericBinaryDocument"); diff --git a/bin/javajs/api/GenericCifDataParser.js b/bin/javajs/api/GenericCifDataParser.js index 6127596..2696094 100644 --- a/bin/javajs/api/GenericCifDataParser.js +++ b/bin/javajs/api/GenericCifDataParser.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.api"); -c$ = Clazz.declareInterface (javajs.api, "GenericCifDataParser"); -Clazz.defineStatics (c$, -"NONE", -1); +Clazz.declarePackage ("javajs.api"); +c$ = Clazz.declareInterface (javajs.api, "GenericCifDataParser"); +Clazz.defineStatics (c$, +"NONE", -1); diff --git a/bin/javajs/api/GenericColor.js b/bin/javajs/api/GenericColor.js index ed0a0ee..c5d0d77 100644 --- a/bin/javajs/api/GenericColor.js +++ b/bin/javajs/api/GenericColor.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericColor"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericColor"); diff --git a/bin/javajs/api/GenericFileInterface.js b/bin/javajs/api/GenericFileInterface.js index deae68e..9a09815 100644 --- a/bin/javajs/api/GenericFileInterface.js +++ b/bin/javajs/api/GenericFileInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericFileInterface"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericFileInterface"); diff --git a/bin/javajs/api/GenericImageDialog.js b/bin/javajs/api/GenericImageDialog.js index fa18c18..16c01cb 100644 --- a/bin/javajs/api/GenericImageDialog.js +++ b/bin/javajs/api/GenericImageDialog.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericImageDialog"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericImageDialog"); diff --git a/bin/javajs/api/GenericImageEncoder.js b/bin/javajs/api/GenericImageEncoder.js index a7313d0..f6a2e95 100644 --- a/bin/javajs/api/GenericImageEncoder.js +++ b/bin/javajs/api/GenericImageEncoder.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericImageEncoder"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericImageEncoder"); diff --git a/bin/javajs/api/GenericLineReader.js b/bin/javajs/api/GenericLineReader.js index 787a669..f4d2aad 100644 --- a/bin/javajs/api/GenericLineReader.js +++ b/bin/javajs/api/GenericLineReader.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericLineReader"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericLineReader"); diff --git a/bin/javajs/api/GenericMenuInterface.js b/bin/javajs/api/GenericMenuInterface.js index 8636834..d35fda0 100644 --- a/bin/javajs/api/GenericMenuInterface.js +++ b/bin/javajs/api/GenericMenuInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericMenuInterface"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericMenuInterface"); diff --git a/bin/javajs/api/GenericMouseInterface.js b/bin/javajs/api/GenericMouseInterface.js index dad99c3..d40a3a0 100644 --- a/bin/javajs/api/GenericMouseInterface.js +++ b/bin/javajs/api/GenericMouseInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericMouseInterface"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericMouseInterface"); diff --git a/bin/javajs/api/GenericPlatform.js b/bin/javajs/api/GenericPlatform.js index ae3869f..00504e7 100644 --- a/bin/javajs/api/GenericPlatform.js +++ b/bin/javajs/api/GenericPlatform.js @@ -1,11 +1,11 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.load (["javajs.api.FontManager"], "javajs.api.GenericPlatform", null, function () { -c$ = Clazz.declareInterface (javajs.api, "GenericPlatform", javajs.api.FontManager); -Clazz.defineStatics (c$, -"CURSOR_DEFAULT", 0, -"CURSOR_CROSSHAIR", 1, -"CURSOR_WAIT", 3, -"CURSOR_ZOOM", 8, -"CURSOR_HAND", 12, -"CURSOR_MOVE", 13); -}); +Clazz.declarePackage ("javajs.api"); +Clazz.load (["javajs.api.FontManager"], "javajs.api.GenericPlatform", null, function () { +c$ = Clazz.declareInterface (javajs.api, "GenericPlatform", javajs.api.FontManager); +Clazz.defineStatics (c$, +"CURSOR_DEFAULT", 0, +"CURSOR_CROSSHAIR", 1, +"CURSOR_WAIT", 3, +"CURSOR_ZOOM", 8, +"CURSOR_HAND", 12, +"CURSOR_MOVE", 13); +}); diff --git a/bin/javajs/api/GenericZipInputStream.js b/bin/javajs/api/GenericZipInputStream.js index d74cfea..9e55715 100644 --- a/bin/javajs/api/GenericZipInputStream.js +++ b/bin/javajs/api/GenericZipInputStream.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.load (["java.util.zip.ZipInputStream", "javajs.api.ZInputStream"], "javajs.api.GenericZipInputStream", null, function () { -c$ = Clazz.declareType (javajs.api, "GenericZipInputStream", java.util.zip.ZipInputStream, javajs.api.ZInputStream); -}); +Clazz.declarePackage ("javajs.api"); +Clazz.load (["java.util.zip.ZipInputStream", "javajs.api.ZInputStream"], "javajs.api.GenericZipInputStream", null, function () { +c$ = Clazz.declareType (javajs.api, "GenericZipInputStream", java.util.zip.ZipInputStream, javajs.api.ZInputStream); +}); diff --git a/bin/javajs/api/GenericZipTools.js b/bin/javajs/api/GenericZipTools.js index 902f592..00e6edf 100644 --- a/bin/javajs/api/GenericZipTools.js +++ b/bin/javajs/api/GenericZipTools.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "GenericZipTools"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "GenericZipTools"); diff --git a/bin/javajs/api/HTMLElement.js b/bin/javajs/api/HTMLElement.js index 97473c7..b305eae 100644 --- a/bin/javajs/api/HTMLElement.js +++ b/bin/javajs/api/HTMLElement.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "HTMLElement"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "HTMLElement"); diff --git a/bin/javajs/api/HTMLWindowEvent.js b/bin/javajs/api/HTMLWindowEvent.js index 538a5c1..47438ca 100644 --- a/bin/javajs/api/HTMLWindowEvent.js +++ b/bin/javajs/api/HTMLWindowEvent.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "HTMLWindowEvent"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "HTMLWindowEvent"); diff --git a/bin/javajs/api/Interface.js b/bin/javajs/api/Interface.js index 8887be8..024bf74 100644 --- a/bin/javajs/api/Interface.js +++ b/bin/javajs/api/Interface.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("javajs.api"); -c$ = Clazz.declareType (javajs.api, "Interface"); -c$.getInterface = Clazz.defineMethod (c$, "getInterface", -function (name) { -try { -var x = Class.forName (name); -return (x == null ? null : x.newInstance ()); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println ("Interface.java Error creating instance for " + name + ": \n" + e); -return null; -} else { -throw e; -} -} -}, "~S"); +Clazz.declarePackage ("javajs.api"); +c$ = Clazz.declareType (javajs.api, "Interface"); +c$.getInterface = Clazz.defineMethod (c$, "getInterface", +function (name) { +try { +var x = Class.forName (name); +return (x == null ? null : x.newInstance ()); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println ("Interface.java Error creating instance for " + name + ": \n" + e); +return null; +} else { +throw e; +} +} +}, "~S"); diff --git a/bin/javajs/api/JSInterface.js b/bin/javajs/api/JSInterface.js index ce34ecc..1086b93 100644 --- a/bin/javajs/api/JSInterface.js +++ b/bin/javajs/api/JSInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "JSInterface"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "JSInterface"); diff --git a/bin/javajs/api/JSONEncodable.js b/bin/javajs/api/JSONEncodable.js index e94f4b8..9f5778f 100644 --- a/bin/javajs/api/JSONEncodable.js +++ b/bin/javajs/api/JSONEncodable.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "JSONEncodable"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "JSONEncodable"); diff --git a/bin/javajs/api/JmolObjectInterface.js b/bin/javajs/api/JmolObjectInterface.js index 0f1e805..a499b01 100644 --- a/bin/javajs/api/JmolObjectInterface.js +++ b/bin/javajs/api/JmolObjectInterface.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "JmolObjectInterface"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "JmolObjectInterface"); diff --git a/bin/javajs/api/PlatformViewer.js b/bin/javajs/api/PlatformViewer.js index 32ed2dc..8cad055 100644 --- a/bin/javajs/api/PlatformViewer.js +++ b/bin/javajs/api/PlatformViewer.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "PlatformViewer"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "PlatformViewer"); diff --git a/bin/javajs/api/SC.js b/bin/javajs/api/SC.js index 01512cd..0edd956 100644 --- a/bin/javajs/api/SC.js +++ b/bin/javajs/api/SC.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "SC"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "SC"); diff --git a/bin/javajs/api/SwingController.js b/bin/javajs/api/SwingController.js index 277bc34..75f1f05 100644 --- a/bin/javajs/api/SwingController.js +++ b/bin/javajs/api/SwingController.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "SwingController"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "SwingController"); diff --git a/bin/javajs/api/ZInputStream.js b/bin/javajs/api/ZInputStream.js index 7a79598..abc5bb9 100644 --- a/bin/javajs/api/ZInputStream.js +++ b/bin/javajs/api/ZInputStream.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.api"); -Clazz.declareInterface (javajs.api, "ZInputStream"); +Clazz.declarePackage ("javajs.api"); +Clazz.declareInterface (javajs.api, "ZInputStream"); diff --git a/bin/javajs/awt/BorderLayout.js b/bin/javajs/awt/BorderLayout.js index 1686394..875b476 100644 --- a/bin/javajs/awt/BorderLayout.js +++ b/bin/javajs/awt/BorderLayout.js @@ -1,10 +1,10 @@ -Clazz.declarePackage ("javajs.awt"); -Clazz.load (["javajs.awt.LayoutManager"], "javajs.awt.BorderLayout", null, function () { -c$ = Clazz.declareType (javajs.awt, "BorderLayout", javajs.awt.LayoutManager); -Clazz.defineStatics (c$, -"CENTER", "Center", -"NORTH", "North", -"SOUTH", "South", -"EAST", "East", -"WEST", "West"); -}); +Clazz.declarePackage ("javajs.awt"); +Clazz.load (["javajs.awt.LayoutManager"], "javajs.awt.BorderLayout", null, function () { +c$ = Clazz.declareType (javajs.awt, "BorderLayout", javajs.awt.LayoutManager); +Clazz.defineStatics (c$, +"CENTER", "Center", +"NORTH", "North", +"SOUTH", "South", +"EAST", "East", +"WEST", "West"); +}); diff --git a/bin/javajs/awt/Color.js b/bin/javajs/awt/Color.js index 725aa31..1f168d2 100644 --- a/bin/javajs/awt/Color.js +++ b/bin/javajs/awt/Color.js @@ -1,43 +1,43 @@ -Clazz.declarePackage ("javajs.awt"); -Clazz.load (["javajs.api.GenericColor"], "javajs.awt.Color", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.argb = 0; -Clazz.instantialize (this, arguments); -}, javajs.awt, "Color", null, javajs.api.GenericColor); -Clazz.overrideMethod (c$, "getRGB", -function () { -return this.argb & 0x00FFFFFF; -}); -Clazz.overrideMethod (c$, "getOpacity255", -function () { -return ((this.argb >> 24) & 0xFF); -}); -Clazz.overrideMethod (c$, "setOpacity255", -function (a) { -this.argb = this.argb & 0xFFFFFF | ((a & 0xFF) << 24); -}, "~N"); -c$.get1 = Clazz.defineMethod (c$, "get1", -function (rgb) { -var c = new javajs.awt.Color (); -c.argb = rgb | 0xFF000000; -return c; -}, "~N"); -c$.get3 = Clazz.defineMethod (c$, "get3", -function (r, g, b) { -return new javajs.awt.Color ().set4 (r, g, b, 0xFF); -}, "~N,~N,~N"); -c$.get4 = Clazz.defineMethod (c$, "get4", -function (r, g, b, a) { -return new javajs.awt.Color ().set4 (r, g, b, a); -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "set4", -($fz = function (r, g, b, a) { -this.argb = ((a << 24) | (r << 16) | (g << 8) | b) & 0xFFFFFFFF; -return this; -}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N"); -Clazz.overrideMethod (c$, "toString", -function () { -var s = ("00000000" + Integer.toHexString (this.argb)); -return "[0x" + s.substring (s.length - 8, s.length) + "]"; -}); -}); +Clazz.declarePackage ("javajs.awt"); +Clazz.load (["javajs.api.GenericColor"], "javajs.awt.Color", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.argb = 0; +Clazz.instantialize (this, arguments); +}, javajs.awt, "Color", null, javajs.api.GenericColor); +Clazz.overrideMethod (c$, "getRGB", +function () { +return this.argb & 0x00FFFFFF; +}); +Clazz.overrideMethod (c$, "getOpacity255", +function () { +return ((this.argb >> 24) & 0xFF); +}); +Clazz.overrideMethod (c$, "setOpacity255", +function (a) { +this.argb = this.argb & 0xFFFFFF | ((a & 0xFF) << 24); +}, "~N"); +c$.get1 = Clazz.defineMethod (c$, "get1", +function (rgb) { +var c = new javajs.awt.Color (); +c.argb = rgb | 0xFF000000; +return c; +}, "~N"); +c$.get3 = Clazz.defineMethod (c$, "get3", +function (r, g, b) { +return new javajs.awt.Color ().set4 (r, g, b, 0xFF); +}, "~N,~N,~N"); +c$.get4 = Clazz.defineMethod (c$, "get4", +function (r, g, b, a) { +return new javajs.awt.Color ().set4 (r, g, b, a); +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "set4", +($fz = function (r, g, b, a) { +this.argb = ((a << 24) | (r << 16) | (g << 8) | b) & 0xFFFFFFFF; +return this; +}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N"); +Clazz.overrideMethod (c$, "toString", +function () { +var s = ("00000000" + Integer.toHexString (this.argb)); +return "[0x" + s.substring (s.length - 8, s.length) + "]"; +}); +}); diff --git a/bin/javajs/awt/Component.js b/bin/javajs/awt/Component.js index 20f1f1a..f17a3eb 100644 --- a/bin/javajs/awt/Component.js +++ b/bin/javajs/awt/Component.js @@ -1,120 +1,120 @@ -Clazz.declarePackage ("javajs.awt"); -Clazz.load (null, "javajs.awt.Component", ["javajs.util.CU"], function () { -c$ = Clazz.decorateAsClass (function () { -this.visible = false; -this.enabled = true; -this.text = null; -this.name = null; -this.width = 0; -this.height = 0; -this.id = null; -this.parent = null; -this.mouseListener = null; -this.bgcolor = null; -this.minWidth = 30; -this.minHeight = 30; -this.renderWidth = 0; -this.renderHeight = 0; -Clazz.instantialize (this, arguments); -}, javajs.awt, "Component"); -Clazz.defineMethod (c$, "setParent", -function (p) { -this.parent = p; -}, "~O"); -Clazz.makeConstructor (c$, -function (type) { -this.id = javajs.awt.Component.newID (type); -if (type == null) return; -{ -SwingController.register(this, type); -}}, "~S"); -c$.newID = Clazz.defineMethod (c$, "newID", -function (type) { -return type + ("" + Math.random ()).substring (3, 10); -}, "~S"); -Clazz.defineMethod (c$, "setBackground", -function (color) { -this.bgcolor = color; -}, "javajs.api.GenericColor"); -Clazz.defineMethod (c$, "setText", -function (text) { -this.text = text; -{ -SwingController.setText(this); -}}, "~S"); -Clazz.defineMethod (c$, "setName", -function (name) { -this.name = name; -}, "~S"); -Clazz.defineMethod (c$, "getName", -function () { -return this.name; -}); -Clazz.defineMethod (c$, "getParent", -function () { -return this.parent; -}); -Clazz.defineMethod (c$, "setPreferredSize", -function (dimension) { -this.width = dimension.width; -this.height = dimension.height; -}, "javajs.awt.Dimension"); -Clazz.defineMethod (c$, "addMouseListener", -function (listener) { -this.mouseListener = listener; -}, "~O"); -Clazz.defineMethod (c$, "getText", -function () { -return this.text; -}); -Clazz.defineMethod (c$, "isEnabled", -function () { -return this.enabled; -}); -Clazz.defineMethod (c$, "setEnabled", -function (enabled) { -this.enabled = enabled; -{ -SwingController.setEnabled(this); -}}, "~B"); -Clazz.defineMethod (c$, "isVisible", -function () { -return this.visible; -}); -Clazz.defineMethod (c$, "setVisible", -function (visible) { -this.visible = visible; -{ -SwingController.setVisible(this); -}}, "~B"); -Clazz.defineMethod (c$, "getHeight", -function () { -return this.height; -}); -Clazz.defineMethod (c$, "getWidth", -function () { -return this.width; -}); -Clazz.defineMethod (c$, "setMinimumSize", -function (d) { -this.minWidth = d.width; -this.minHeight = d.height; -}, "javajs.awt.Dimension"); -Clazz.defineMethod (c$, "getSubcomponentWidth", -function () { -return this.width; -}); -Clazz.defineMethod (c$, "getSubcomponentHeight", -function () { -return this.height; -}); -Clazz.defineMethod (c$, "getCSSstyle", -function (defaultPercentW, defaultPercentH) { -var width = (this.renderWidth > 0 ? this.renderWidth : this.getSubcomponentWidth ()); -var height = (this.renderHeight > 0 ? this.renderHeight : this.getSubcomponentHeight ()); -return (width > 0 ? "width:" + width + "px;" : defaultPercentW > 0 ? "width:" + defaultPercentW + "%;" : "") + (height > 0 ? "height:" + height + "px;" : defaultPercentH > 0 ? "height:" + defaultPercentH + "%;" : "") + (this.bgcolor == null ? "" : "background-color:" + javajs.util.CU.toCSSString (this.bgcolor) + ";"); -}, "~N,~N"); -Clazz.defineMethod (c$, "repaint", -function () { -}); -}); +Clazz.declarePackage ("javajs.awt"); +Clazz.load (null, "javajs.awt.Component", ["javajs.util.CU"], function () { +c$ = Clazz.decorateAsClass (function () { +this.visible = false; +this.enabled = true; +this.text = null; +this.name = null; +this.width = 0; +this.height = 0; +this.id = null; +this.parent = null; +this.mouseListener = null; +this.bgcolor = null; +this.minWidth = 30; +this.minHeight = 30; +this.renderWidth = 0; +this.renderHeight = 0; +Clazz.instantialize (this, arguments); +}, javajs.awt, "Component"); +Clazz.defineMethod (c$, "setParent", +function (p) { +this.parent = p; +}, "~O"); +Clazz.makeConstructor (c$, +function (type) { +this.id = javajs.awt.Component.newID (type); +if (type == null) return; +{ +SwingController.register(this, type); +}}, "~S"); +c$.newID = Clazz.defineMethod (c$, "newID", +function (type) { +return type + ("" + Math.random ()).substring (3, 10); +}, "~S"); +Clazz.defineMethod (c$, "setBackground", +function (color) { +this.bgcolor = color; +}, "javajs.api.GenericColor"); +Clazz.defineMethod (c$, "setText", +function (text) { +this.text = text; +{ +SwingController.setText(this); +}}, "~S"); +Clazz.defineMethod (c$, "setName", +function (name) { +this.name = name; +}, "~S"); +Clazz.defineMethod (c$, "getName", +function () { +return this.name; +}); +Clazz.defineMethod (c$, "getParent", +function () { +return this.parent; +}); +Clazz.defineMethod (c$, "setPreferredSize", +function (dimension) { +this.width = dimension.width; +this.height = dimension.height; +}, "javajs.awt.Dimension"); +Clazz.defineMethod (c$, "addMouseListener", +function (listener) { +this.mouseListener = listener; +}, "~O"); +Clazz.defineMethod (c$, "getText", +function () { +return this.text; +}); +Clazz.defineMethod (c$, "isEnabled", +function () { +return this.enabled; +}); +Clazz.defineMethod (c$, "setEnabled", +function (enabled) { +this.enabled = enabled; +{ +SwingController.setEnabled(this); +}}, "~B"); +Clazz.defineMethod (c$, "isVisible", +function () { +return this.visible; +}); +Clazz.defineMethod (c$, "setVisible", +function (visible) { +this.visible = visible; +{ +SwingController.setVisible(this); +}}, "~B"); +Clazz.defineMethod (c$, "getHeight", +function () { +return this.height; +}); +Clazz.defineMethod (c$, "getWidth", +function () { +return this.width; +}); +Clazz.defineMethod (c$, "setMinimumSize", +function (d) { +this.minWidth = d.width; +this.minHeight = d.height; +}, "javajs.awt.Dimension"); +Clazz.defineMethod (c$, "getSubcomponentWidth", +function () { +return this.width; +}); +Clazz.defineMethod (c$, "getSubcomponentHeight", +function () { +return this.height; +}); +Clazz.defineMethod (c$, "getCSSstyle", +function (defaultPercentW, defaultPercentH) { +var width = (this.renderWidth > 0 ? this.renderWidth : this.getSubcomponentWidth ()); +var height = (this.renderHeight > 0 ? this.renderHeight : this.getSubcomponentHeight ()); +return (width > 0 ? "width:" + width + "px;" : defaultPercentW > 0 ? "width:" + defaultPercentW + "%;" : "") + (height > 0 ? "height:" + height + "px;" : defaultPercentH > 0 ? "height:" + defaultPercentH + "%;" : "") + (this.bgcolor == null ? "" : "background-color:" + javajs.util.CU.toCSSString (this.bgcolor) + ";"); +}, "~N,~N"); +Clazz.defineMethod (c$, "repaint", +function () { +}); +}); diff --git a/bin/javajs/awt/Container.js b/bin/javajs/awt/Container.js index 5bb85ea..fe3fb75 100644 --- a/bin/javajs/awt/Container.js +++ b/bin/javajs/awt/Container.js @@ -1,65 +1,65 @@ -Clazz.declarePackage ("javajs.awt"); -Clazz.load (["javajs.awt.Component"], "javajs.awt.Container", ["javajs.util.Lst"], function () { -c$ = Clazz.decorateAsClass (function () { -this.list = null; -this.cList = null; -Clazz.instantialize (this, arguments); -}, javajs.awt, "Container", javajs.awt.Component); -Clazz.defineMethod (c$, "getComponent", -function (i) { -return this.list.get (i); -}, "~N"); -Clazz.defineMethod (c$, "getComponentCount", -function () { -return (this.list == null ? 0 : this.list.size ()); -}); -Clazz.defineMethod (c$, "getComponents", -function () { -if (this.cList == null) { -if (this.list == null) return new Array (0); -this.cList = this.list.toArray (); -}return this.cList; -}); -Clazz.defineMethod (c$, "add", -function (component) { -return this.addComponent (component); -}, "javajs.awt.Component"); -Clazz.defineMethod (c$, "addComponent", -function (component) { -if (this.list == null) this.list = new javajs.util.Lst (); -this.list.addLast (component); -this.cList = null; -component.parent = this; -return component; -}, "javajs.awt.Component"); -Clazz.defineMethod (c$, "insertComponent", -function (component, index) { -if (this.list == null) return this.addComponent (component); -this.list.add (index, component); -this.cList = null; -component.parent = this; -return component; -}, "javajs.awt.Component,~N"); -Clazz.defineMethod (c$, "remove", -function (i) { -var c = this.list.remove (i); -c.parent = null; -this.cList = null; -}, "~N"); -Clazz.defineMethod (c$, "removeAll", -function () { -if (this.list != null) { -for (var i = this.list.size (); --i >= 0; ) this.list.get (i).parent = null; - -this.list.clear (); -}this.cList = null; -}); -Clazz.defineMethod (c$, "getSubcomponentWidth", -function () { -return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentWidth () : 0); -}); -Clazz.defineMethod (c$, "getSubcomponentHeight", -function () { -return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentHeight () : 0); -}); -}); +Clazz.declarePackage ("javajs.awt"); +Clazz.load (["javajs.awt.Component"], "javajs.awt.Container", ["javajs.util.Lst"], function () { +c$ = Clazz.decorateAsClass (function () { +this.list = null; +this.cList = null; +Clazz.instantialize (this, arguments); +}, javajs.awt, "Container", javajs.awt.Component); +Clazz.defineMethod (c$, "getComponent", +function (i) { +return this.list.get (i); +}, "~N"); +Clazz.defineMethod (c$, "getComponentCount", +function () { +return (this.list == null ? 0 : this.list.size ()); +}); +Clazz.defineMethod (c$, "getComponents", +function () { +if (this.cList == null) { +if (this.list == null) return new Array (0); +this.cList = this.list.toArray (); +}return this.cList; +}); +Clazz.defineMethod (c$, "add", +function (component) { +return this.addComponent (component); +}, "javajs.awt.Component"); +Clazz.defineMethod (c$, "addComponent", +function (component) { +if (this.list == null) this.list = new javajs.util.Lst (); +this.list.addLast (component); +this.cList = null; +component.parent = this; +return component; +}, "javajs.awt.Component"); +Clazz.defineMethod (c$, "insertComponent", +function (component, index) { +if (this.list == null) return this.addComponent (component); +this.list.add (index, component); +this.cList = null; +component.parent = this; +return component; +}, "javajs.awt.Component,~N"); +Clazz.defineMethod (c$, "remove", +function (i) { +var c = this.list.remove (i); +c.parent = null; +this.cList = null; +}, "~N"); +Clazz.defineMethod (c$, "removeAll", +function () { +if (this.list != null) { +for (var i = this.list.size (); --i >= 0; ) this.list.get (i).parent = null; + +this.list.clear (); +}this.cList = null; +}); +Clazz.defineMethod (c$, "getSubcomponentWidth", +function () { +return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentWidth () : 0); +}); +Clazz.defineMethod (c$, "getSubcomponentHeight", +function () { +return (this.list != null && this.list.size () == 1 ? this.list.get (0).getSubcomponentHeight () : 0); +}); +}); diff --git a/bin/javajs/awt/Dimension.js b/bin/javajs/awt/Dimension.js index 448d107..4d21384 100644 --- a/bin/javajs/awt/Dimension.js +++ b/bin/javajs/awt/Dimension.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("javajs.awt"); -c$ = Clazz.decorateAsClass (function () { -this.width = 0; -this.height = 0; -Clazz.instantialize (this, arguments); -}, javajs.awt, "Dimension"); -Clazz.makeConstructor (c$, -function (w, h) { -this.set (w, h); -}, "~N,~N"); -Clazz.defineMethod (c$, "set", -function (w, h) { -this.width = w; -this.height = h; -return this; -}, "~N,~N"); +Clazz.declarePackage ("javajs.awt"); +c$ = Clazz.decorateAsClass (function () { +this.width = 0; +this.height = 0; +Clazz.instantialize (this, arguments); +}, javajs.awt, "Dimension"); +Clazz.makeConstructor (c$, +function (w, h) { +this.set (w, h); +}, "~N,~N"); +Clazz.defineMethod (c$, "set", +function (w, h) { +this.width = w; +this.height = h; +return this; +}, "~N,~N"); diff --git a/bin/javajs/awt/Font.js b/bin/javajs/awt/Font.js index 809c862..a5f2df9 100644 --- a/bin/javajs/awt/Font.js +++ b/bin/javajs/awt/Font.js @@ -1,105 +1,105 @@ -Clazz.declarePackage ("javajs.awt"); -Clazz.load (null, "javajs.awt.Font", ["javajs.util.AU"], function () { -c$ = Clazz.decorateAsClass (function () { -this.fid = 0; -this.fontFace = null; -this.fontStyle = null; -this.fontSizeNominal = 0; -this.idFontFace = 0; -this.idFontStyle = 0; -this.fontSize = 0; -this.font = null; -this.fontMetrics = null; -this.manager = null; -this.ascent = 0; -this.descent = 0; -this.isBold = false; -this.isItalic = false; -Clazz.instantialize (this, arguments); -}, javajs.awt, "Font"); -Clazz.makeConstructor (c$, -($fz = function (manager, fid, idFontFace, idFontStyle, fontSize, fontSizeNominal, graphics) { -this.manager = manager; -this.fid = fid; -this.fontFace = javajs.awt.Font.fontFaces[idFontFace]; -this.fontStyle = javajs.awt.Font.fontStyles[idFontStyle]; -this.idFontFace = idFontFace; -this.idFontStyle = idFontStyle; -this.fontSize = fontSize; -this.isBold = (idFontStyle & 1) == 1; -this.isItalic = (idFontStyle & 2) == 2; -this.fontSizeNominal = fontSizeNominal; -this.font = manager.newFont (javajs.awt.Font.fontFaces[idFontFace], this.isBold, this.isItalic, fontSize); -this.fontMetrics = manager.getFontMetrics (this, graphics); -this.descent = manager.getFontDescent (this.fontMetrics); -this.ascent = manager.getFontAscent (this.fontMetrics); -}, $fz.isPrivate = true, $fz), "javajs.api.FontManager,~N,~N,~N,~N,~N,~O"); -c$.getFont3D = Clazz.defineMethod (c$, "getFont3D", -function (fontID) { -return javajs.awt.Font.font3ds[fontID & 0xFF]; -}, "~N"); -c$.createFont3D = Clazz.defineMethod (c$, "createFont3D", -function (fontface, fontstyle, fontsize, fontsizeNominal, manager, graphicsForMetrics) { -if (fontsize > 0xFF) fontsize = 0xFF; -var fontsizeX16 = (Clazz.floatToInt (fontsize)) << 4; -var fontkey = ((fontface & 3) | ((fontstyle & 3) << 2) | (fontsizeX16 << 4)); -for (var i = javajs.awt.Font.fontkeyCount; --i > 0; ) if (fontkey == javajs.awt.Font.fontkeys[i] && javajs.awt.Font.font3ds[i].fontSizeNominal == fontsizeNominal) return javajs.awt.Font.font3ds[i]; - -var fontIndexNext = javajs.awt.Font.fontkeyCount++; -if (fontIndexNext == javajs.awt.Font.fontkeys.length) javajs.awt.Font.fontkeys = javajs.util.AU.arrayCopyI (javajs.awt.Font.fontkeys, fontIndexNext + 8); -javajs.awt.Font.font3ds = javajs.util.AU.arrayCopyObject (javajs.awt.Font.font3ds, fontIndexNext + 8); -var font3d = new javajs.awt.Font (manager, fontIndexNext, fontface, fontstyle, fontsize, fontsizeNominal, graphicsForMetrics); -javajs.awt.Font.font3ds[fontIndexNext] = font3d; -javajs.awt.Font.fontkeys[fontIndexNext] = fontkey; -return font3d; -}, "~N,~N,~N,~N,javajs.api.FontManager,~O"); -c$.getFontFaceID = Clazz.defineMethod (c$, "getFontFaceID", -function (fontface) { -return ("Monospaced".equalsIgnoreCase (fontface) ? 2 : "Serif".equalsIgnoreCase (fontface) ? 1 : 0); -}, "~S"); -c$.getFontStyleID = Clazz.defineMethod (c$, "getFontStyleID", -function (fontstyle) { -for (var i = 4; --i >= 0; ) if (javajs.awt.Font.fontStyles[i].equalsIgnoreCase (fontstyle)) return i; - -return -1; -}, "~S"); -Clazz.defineMethod (c$, "getAscent", -function () { -return this.ascent; -}); -Clazz.defineMethod (c$, "getDescent", -function () { -return this.descent; -}); -Clazz.defineMethod (c$, "getHeight", -function () { -return this.getAscent () + this.getDescent (); -}); -Clazz.defineMethod (c$, "getFontMetrics", -function () { -return this.fontMetrics; -}); -Clazz.defineMethod (c$, "stringWidth", -function (text) { -return this.manager.fontStringWidth (this, text); -}, "~S"); -Clazz.defineMethod (c$, "getInfo", -function () { -return this.fontSizeNominal + " " + this.fontFace + " " + this.fontStyle; -}); -Clazz.defineStatics (c$, -"FONT_ALLOCATION_UNIT", 8, -"fontkeyCount", 1, -"fontkeys", Clazz.newIntArray (8, 0)); -c$.font3ds = c$.prototype.font3ds = new Array (8); -Clazz.defineStatics (c$, -"FONT_FACE_SANS", 0, -"FONT_FACE_SERIF", 1, -"FONT_FACE_MONO", 2, -"fontFaces", Clazz.newArray (-1, ["SansSerif", "Serif", "Monospaced", ""]), -"FONT_STYLE_PLAIN", 0, -"FONT_STYLE_BOLD", 1, -"FONT_STYLE_ITALIC", 2, -"FONT_STYLE_BOLDITALIC", 3, -"fontStyles", Clazz.newArray (-1, ["Plain", "Bold", "Italic", "BoldItalic"])); -}); +Clazz.declarePackage ("javajs.awt"); +Clazz.load (null, "javajs.awt.Font", ["javajs.util.AU"], function () { +c$ = Clazz.decorateAsClass (function () { +this.fid = 0; +this.fontFace = null; +this.fontStyle = null; +this.fontSizeNominal = 0; +this.idFontFace = 0; +this.idFontStyle = 0; +this.fontSize = 0; +this.font = null; +this.fontMetrics = null; +this.manager = null; +this.ascent = 0; +this.descent = 0; +this.isBold = false; +this.isItalic = false; +Clazz.instantialize (this, arguments); +}, javajs.awt, "Font"); +Clazz.makeConstructor (c$, +($fz = function (manager, fid, idFontFace, idFontStyle, fontSize, fontSizeNominal, graphics) { +this.manager = manager; +this.fid = fid; +this.fontFace = javajs.awt.Font.fontFaces[idFontFace]; +this.fontStyle = javajs.awt.Font.fontStyles[idFontStyle]; +this.idFontFace = idFontFace; +this.idFontStyle = idFontStyle; +this.fontSize = fontSize; +this.isBold = (idFontStyle & 1) == 1; +this.isItalic = (idFontStyle & 2) == 2; +this.fontSizeNominal = fontSizeNominal; +this.font = manager.newFont (javajs.awt.Font.fontFaces[idFontFace], this.isBold, this.isItalic, fontSize); +this.fontMetrics = manager.getFontMetrics (this, graphics); +this.descent = manager.getFontDescent (this.fontMetrics); +this.ascent = manager.getFontAscent (this.fontMetrics); +}, $fz.isPrivate = true, $fz), "javajs.api.FontManager,~N,~N,~N,~N,~N,~O"); +c$.getFont3D = Clazz.defineMethod (c$, "getFont3D", +function (fontID) { +return javajs.awt.Font.font3ds[fontID & 0xFF]; +}, "~N"); +c$.createFont3D = Clazz.defineMethod (c$, "createFont3D", +function (fontface, fontstyle, fontsize, fontsizeNominal, manager, graphicsForMetrics) { +if (fontsize > 0xFF) fontsize = 0xFF; +var fontsizeX16 = (Clazz.floatToInt (fontsize)) << 4; +var fontkey = ((fontface & 3) | ((fontstyle & 3) << 2) | (fontsizeX16 << 4)); +for (var i = javajs.awt.Font.fontkeyCount; --i > 0; ) if (fontkey == javajs.awt.Font.fontkeys[i] && javajs.awt.Font.font3ds[i].fontSizeNominal == fontsizeNominal) return javajs.awt.Font.font3ds[i]; + +var fontIndexNext = javajs.awt.Font.fontkeyCount++; +if (fontIndexNext == javajs.awt.Font.fontkeys.length) javajs.awt.Font.fontkeys = javajs.util.AU.arrayCopyI (javajs.awt.Font.fontkeys, fontIndexNext + 8); +javajs.awt.Font.font3ds = javajs.util.AU.arrayCopyObject (javajs.awt.Font.font3ds, fontIndexNext + 8); +var font3d = new javajs.awt.Font (manager, fontIndexNext, fontface, fontstyle, fontsize, fontsizeNominal, graphicsForMetrics); +javajs.awt.Font.font3ds[fontIndexNext] = font3d; +javajs.awt.Font.fontkeys[fontIndexNext] = fontkey; +return font3d; +}, "~N,~N,~N,~N,javajs.api.FontManager,~O"); +c$.getFontFaceID = Clazz.defineMethod (c$, "getFontFaceID", +function (fontface) { +return ("Monospaced".equalsIgnoreCase (fontface) ? 2 : "Serif".equalsIgnoreCase (fontface) ? 1 : 0); +}, "~S"); +c$.getFontStyleID = Clazz.defineMethod (c$, "getFontStyleID", +function (fontstyle) { +for (var i = 4; --i >= 0; ) if (javajs.awt.Font.fontStyles[i].equalsIgnoreCase (fontstyle)) return i; + +return -1; +}, "~S"); +Clazz.defineMethod (c$, "getAscent", +function () { +return this.ascent; +}); +Clazz.defineMethod (c$, "getDescent", +function () { +return this.descent; +}); +Clazz.defineMethod (c$, "getHeight", +function () { +return this.getAscent () + this.getDescent (); +}); +Clazz.defineMethod (c$, "getFontMetrics", +function () { +return this.fontMetrics; +}); +Clazz.defineMethod (c$, "stringWidth", +function (text) { +return this.manager.fontStringWidth (this, text); +}, "~S"); +Clazz.defineMethod (c$, "getInfo", +function () { +return this.fontSizeNominal + " " + this.fontFace + " " + this.fontStyle; +}); +Clazz.defineStatics (c$, +"FONT_ALLOCATION_UNIT", 8, +"fontkeyCount", 1, +"fontkeys", Clazz.newIntArray (8, 0)); +c$.font3ds = c$.prototype.font3ds = new Array (8); +Clazz.defineStatics (c$, +"FONT_FACE_SANS", 0, +"FONT_FACE_SERIF", 1, +"FONT_FACE_MONO", 2, +"fontFaces", Clazz.newArray (-1, ["SansSerif", "Serif", "Monospaced", ""]), +"FONT_STYLE_PLAIN", 0, +"FONT_STYLE_BOLD", 1, +"FONT_STYLE_ITALIC", 2, +"FONT_STYLE_BOLDITALIC", 3, +"fontStyles", Clazz.newArray (-1, ["Plain", "Bold", "Italic", "BoldItalic"])); +}); diff --git a/bin/javajs/awt/LayoutManager.js b/bin/javajs/awt/LayoutManager.js index 93d4055..49c8b3a 100644 --- a/bin/javajs/awt/LayoutManager.js +++ b/bin/javajs/awt/LayoutManager.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.awt"); -c$ = Clazz.declareType (javajs.awt, "LayoutManager"); +Clazz.declarePackage ("javajs.awt"); +c$ = Clazz.declareType (javajs.awt, "LayoutManager"); diff --git a/bin/javajs/awt/event/ActionEvent.js b/bin/javajs/awt/event/ActionEvent.js index 5ff2dcc..11f0d44 100644 --- a/bin/javajs/awt/event/ActionEvent.js +++ b/bin/javajs/awt/event/ActionEvent.js @@ -1,11 +1,11 @@ -Clazz.declarePackage ("javajs.awt.event"); -Clazz.load (["javajs.awt.event.Event"], "javajs.awt.event.ActionEvent", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.actionCommand = null; -Clazz.instantialize (this, arguments); -}, javajs.awt.event, "ActionEvent", javajs.awt.event.Event); -Clazz.defineMethod (c$, "getActionCommand", -function () { -return this.actionCommand; -}); -}); +Clazz.declarePackage ("javajs.awt.event"); +Clazz.load (["javajs.awt.event.Event"], "javajs.awt.event.ActionEvent", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.actionCommand = null; +Clazz.instantialize (this, arguments); +}, javajs.awt.event, "ActionEvent", javajs.awt.event.Event); +Clazz.defineMethod (c$, "getActionCommand", +function () { +return this.actionCommand; +}); +}); diff --git a/bin/javajs/awt/event/ActionListener.js b/bin/javajs/awt/event/ActionListener.js index 09f483e..c41017a 100644 --- a/bin/javajs/awt/event/ActionListener.js +++ b/bin/javajs/awt/event/ActionListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.awt.event"); -Clazz.declareInterface (javajs.awt.event, "ActionListener"); +Clazz.declarePackage ("javajs.awt.event"); +Clazz.declareInterface (javajs.awt.event, "ActionListener"); diff --git a/bin/javajs/awt/event/Event.js b/bin/javajs/awt/event/Event.js index 522ac2f..795e48f 100644 --- a/bin/javajs/awt/event/Event.js +++ b/bin/javajs/awt/event/Event.js @@ -1,49 +1,49 @@ -Clazz.declarePackage ("javajs.awt.event"); -c$ = Clazz.decorateAsClass (function () { -this.source = null; -Clazz.instantialize (this, arguments); -}, javajs.awt.event, "Event"); -Clazz.defineMethod (c$, "getSource", -function () { -return this.source; -}); -Clazz.defineStatics (c$, -"MOUSE_LEFT", 16, -"MOUSE_MIDDLE", 8, -"MOUSE_RIGHT", 4, -"MOUSE_WHEEL", 32, -"MAC_COMMAND", 20, -"BUTTON_MASK", 28, -"MOUSE_DOWN", 501, -"MOUSE_UP", 502, -"MOUSE_MOVE", 503, -"MOUSE_ENTER", 504, -"MOUSE_EXIT", 505, -"MOUSE_DRAG", 506, -"SHIFT_MASK", 1, -"ALT_MASK", 8, -"CTRL_MASK", 2, -"CTRL_ALT", 10, -"CTRL_SHIFT", 3, -"META_MASK", 4, -"VK_SHIFT", 16, -"VK_ALT", 18, -"VK_CONTROL", 17, -"VK_META", 157, -"VK_LEFT", 37, -"VK_RIGHT", 39, -"VK_PERIOD", 46, -"VK_SPACE", 32, -"VK_DOWN", 40, -"VK_UP", 38, -"VK_ESCAPE", 27, -"VK_DELETE", 127, -"VK_BACK_SPACE", 8, -"VK_PAGE_DOWN", 34, -"VK_PAGE_UP", 33, -"MOVED", 0, -"DRAGGED", 1, -"CLICKED", 2, -"WHEELED", 3, -"PRESSED", 4, -"RELEASED", 5); +Clazz.declarePackage ("javajs.awt.event"); +c$ = Clazz.decorateAsClass (function () { +this.source = null; +Clazz.instantialize (this, arguments); +}, javajs.awt.event, "Event"); +Clazz.defineMethod (c$, "getSource", +function () { +return this.source; +}); +Clazz.defineStatics (c$, +"MOUSE_LEFT", 16, +"MOUSE_MIDDLE", 8, +"MOUSE_RIGHT", 4, +"MOUSE_WHEEL", 32, +"MAC_COMMAND", 20, +"BUTTON_MASK", 28, +"MOUSE_DOWN", 501, +"MOUSE_UP", 502, +"MOUSE_MOVE", 503, +"MOUSE_ENTER", 504, +"MOUSE_EXIT", 505, +"MOUSE_DRAG", 506, +"SHIFT_MASK", 1, +"ALT_MASK", 8, +"CTRL_MASK", 2, +"CTRL_ALT", 10, +"CTRL_SHIFT", 3, +"META_MASK", 4, +"VK_SHIFT", 16, +"VK_ALT", 18, +"VK_CONTROL", 17, +"VK_META", 157, +"VK_LEFT", 37, +"VK_RIGHT", 39, +"VK_PERIOD", 46, +"VK_SPACE", 32, +"VK_DOWN", 40, +"VK_UP", 38, +"VK_ESCAPE", 27, +"VK_DELETE", 127, +"VK_BACK_SPACE", 8, +"VK_PAGE_DOWN", 34, +"VK_PAGE_UP", 33, +"MOVED", 0, +"DRAGGED", 1, +"CLICKED", 2, +"WHEELED", 3, +"PRESSED", 4, +"RELEASED", 5); diff --git a/bin/javajs/awt/event/ItemEvent.js b/bin/javajs/awt/event/ItemEvent.js index b2722ab..8aa944f 100644 --- a/bin/javajs/awt/event/ItemEvent.js +++ b/bin/javajs/awt/event/ItemEvent.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.awt.event"); -Clazz.load (["javajs.awt.event.Event"], "javajs.awt.event.ItemEvent", null, function () { -c$ = Clazz.declareType (javajs.awt.event, "ItemEvent", javajs.awt.event.Event); -}); +Clazz.declarePackage ("javajs.awt.event"); +Clazz.load (["javajs.awt.event.Event"], "javajs.awt.event.ItemEvent", null, function () { +c$ = Clazz.declareType (javajs.awt.event, "ItemEvent", javajs.awt.event.Event); +}); diff --git a/bin/javajs/awt/event/WindowEvent.js b/bin/javajs/awt/event/WindowEvent.js index 0017c88..efa578b 100644 --- a/bin/javajs/awt/event/WindowEvent.js +++ b/bin/javajs/awt/event/WindowEvent.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.awt.event"); -Clazz.load (["javajs.awt.event.Event"], "javajs.awt.event.WindowEvent", null, function () { -c$ = Clazz.declareType (javajs.awt.event, "WindowEvent", javajs.awt.event.Event); -}); +Clazz.declarePackage ("javajs.awt.event"); +Clazz.load (["javajs.awt.event.Event"], "javajs.awt.event.WindowEvent", null, function () { +c$ = Clazz.declareType (javajs.awt.event, "WindowEvent", javajs.awt.event.Event); +}); diff --git a/bin/javajs/awt/event/WindowListener.js b/bin/javajs/awt/event/WindowListener.js index 7656d2f..bb9e9c5 100644 --- a/bin/javajs/awt/event/WindowListener.js +++ b/bin/javajs/awt/event/WindowListener.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.awt.event"); -Clazz.declareInterface (javajs.awt.event, "WindowListener"); +Clazz.declarePackage ("javajs.awt.event"); +Clazz.declareInterface (javajs.awt.event, "WindowListener"); diff --git a/bin/javajs/export/PDFCreator.js b/bin/javajs/export/PDFCreator.js index 3442530..7f5c820 100644 --- a/bin/javajs/export/PDFCreator.js +++ b/bin/javajs/export/PDFCreator.js @@ -1,300 +1,300 @@ -Clazz.declarePackage ("javajs.export"); -Clazz.load (null, "javajs.export.PDFCreator", ["java.lang.Double", "java.util.Hashtable", "javajs.export.PDFObject", "javajs.util.Lst", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.os = null; -this.indirectObjects = null; -this.root = null; -this.graphics = null; -this.pt = 0; -this.xrefPt = 0; -this.count = 0; -this.height = 0; -this.width = 0; -this.fonts = null; -this.images = null; -Clazz.instantialize (this, arguments); -}, javajs["export"], "PDFCreator"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "setOutputStream", -function (os) { -this.os = os; -}, "java.io.OutputStream"); -Clazz.defineMethod (c$, "newDocument", -function (paperWidth, paperHeight, isLandscape) { -this.width = (isLandscape ? paperHeight : paperWidth); -this.height = (isLandscape ? paperWidth : paperHeight); -System.out.println ("Creating PDF with width=" + this.width + " and height=" + this.height); -this.fonts = new java.util.Hashtable (); -this.indirectObjects = new javajs.util.Lst (); -this.root = this.newObject ("Catalog"); -var pages = this.newObject ("Pages"); -var page = this.newObject ("Page"); -var pageContents = this.newObject (null); -this.graphics = this.newObject ("XObject"); -this.root.addDef ("Pages", pages.getRef ()); -pages.addDef ("Count", "1"); -pages.addDef ("Kids", "[ " + page.getRef () + " ]"); -page.addDef ("Parent", pages.getRef ()); -page.addDef ("MediaBox", "[ 0 0 " + paperWidth + " " + paperHeight + " ]"); -if (isLandscape) page.addDef ("Rotate", "90"); -pageContents.addDef ("Length", "?"); -pageContents.append ((isLandscape ? "q 0 1 1 0 0 0 " : "q 1 0 0 -1 0 " + (paperHeight)) + " cm /" + this.graphics.getID () + " Do Q"); -page.addDef ("Contents", pageContents.getRef ()); -this.addProcSet (page); -this.addProcSet (this.graphics); -this.graphics.addDef ("Subtype", "/Form"); -this.graphics.addDef ("FormType", "1"); -this.graphics.addDef ("BBox", "[0 0 " + this.width + " " + this.height + "]"); -this.graphics.addDef ("Matrix", "[1 0 0 1 0 0]"); -this.graphics.addDef ("Length", "?"); -page.addResource ("XObject", this.graphics.getID (), this.graphics.getRef ()); -this.g ("q 1 w 1 J 1 j 10 M []0 d q "); -this.clip (0, 0, this.width, this.height); -}, "~N,~N,~B"); -Clazz.defineMethod (c$, "addProcSet", -($fz = function (o) { -o.addResource (null, "ProcSet", "[/PDF /Text /ImageB /ImageC /ImageI]"); -}, $fz.isPrivate = true, $fz), "javajs.export.PDFObject"); -Clazz.defineMethod (c$, "clip", -($fz = function (x1, y1, x2, y2) { -this.moveto (x1, y1); -this.lineto (x2, y1); -this.lineto (x2, y2); -this.lineto (x1, y2); -this.g ("h W n"); -}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "moveto", -function (x, y) { -this.g (x + " " + y + " m"); -}, "~N,~N"); -Clazz.defineMethod (c$, "lineto", -function (x, y) { -this.g (x + " " + y + " l"); -}, "~N,~N"); -Clazz.defineMethod (c$, "newObject", -($fz = function (type) { -var o = new javajs["export"].PDFObject (++this.count); -if (type != null) o.addDef ("Type", "/" + type); -this.indirectObjects.addLast (o); -return o; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "addInfo", -function (data) { -var info = new java.util.Hashtable (); -for (var e, $e = data.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) { -var value = "(" + e.getValue ().$replace (')', '_').$replace ('(', '_') + ")"; -info.put (e.getKey (), value); -} -this.root.addDef ("Info", info); -}, "java.util.Map"); -Clazz.defineMethod (c$, "addFontResource", -($fz = function (fname) { -var f = this.newObject ("Font"); -this.fonts.put (fname, f); -f.addDef ("BaseFont", fname); -f.addDef ("Encoding", "/WinAnsiEncoding"); -f.addDef ("Subtype", "/Type1"); -this.graphics.addResource ("Font", f.getID (), f.getRef ()); -return f; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "addImageResource", -function (newImage, width, height, buffer, isRGB) { -var imageObj = this.newObject ("XObject"); -if (this.images == null) this.images = new java.util.Hashtable (); -this.images.put (newImage, imageObj); -imageObj.addDef ("Subtype", "/Image"); -imageObj.addDef ("Length", "?"); -imageObj.addDef ("ColorSpace", isRGB ? "/DeviceRGB" : "/DeviceGray"); -imageObj.addDef ("BitsPerComponent", "8"); -imageObj.addDef ("Width", "" + width); -imageObj.addDef ("Height", "" + height); -this.graphics.addResource ("XObject", imageObj.getID (), imageObj.getRef ()); -var n = buffer.length; -var stream = Clazz.newByteArray (n * (isRGB ? 3 : 1), 0); -if (isRGB) { -for (var i = 0, pt = 0; i < n; i++) { -stream[pt++] = ((buffer[i] >> 16) & 0xFF); -stream[pt++] = ((buffer[i] >> 8) & 0xFF); -stream[pt++] = (buffer[i] & 0xFF); -} -} else { -for (var i = 0; i < n; i++) stream[i] = buffer[i]; - -}imageObj.setStream (stream); -this.graphics.addResource ("XObject", imageObj.getID (), imageObj.getRef ()); -}, "~O,~N,~N,~A,~B"); -Clazz.defineMethod (c$, "g", -function (cmd) { -this.graphics.append (cmd).appendC ('\n'); -}, "~S"); -Clazz.defineMethod (c$, "output", -($fz = function (s) { -var b = s.getBytes (); -this.os.write (b, 0, b.length); -this.pt += b.length; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "closeDocument", -function () { -this.g ("Q Q"); -this.outputHeader (); -this.writeObjects (); -this.writeXRefTable (); -this.writeTrailer (); -this.os.flush (); -this.os.close (); -}); -Clazz.defineMethod (c$, "outputHeader", -($fz = function () { -this.output ("%PDF-1.3\n%"); -var b = Clazz.newByteArray (-1, [-1, -1, -1, -1]); -this.os.write (b, 0, b.length); -this.pt += 4; -this.output ("\n"); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeTrailer", -($fz = function () { -var trailer = new javajs["export"].PDFObject (-2); -this.output ("trailer"); -trailer.addDef ("Size", "" + this.indirectObjects.size ()); -trailer.addDef ("Root", this.root.getRef ()); -trailer.output (this.os); -this.output ("startxref\n"); -this.output ("" + this.xrefPt + "\n"); -this.output ("%%EOF\n"); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeObjects", -($fz = function () { -var nObj = this.indirectObjects.size (); -for (var i = 0; i < nObj; i++) { -var o = this.indirectObjects.get (i); -if (!o.isFont ()) continue; -o.pt = this.pt; -this.pt += o.output (this.os); -} -for (var i = 0; i < nObj; i++) { -var o = this.indirectObjects.get (i); -if (o.isFont ()) continue; -o.pt = this.pt; -this.pt += o.output (this.os); -} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeXRefTable", -($fz = function () { -this.xrefPt = this.pt; -var nObj = this.indirectObjects.size (); -var sb = new javajs.util.SB (); -sb.append ("xref\n0 " + (nObj + 1) + "\n0000000000 65535 f\r\n"); -for (var i = 0; i < nObj; i++) { -var o = this.indirectObjects.get (i); -var s = "0000000000" + o.pt; -sb.append (s.substring (s.length - 10)); -sb.append (" 00000 n\r\n"); -} -this.output (sb.toString ()); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "canDoLineTo", -function () { -return true; -}); -Clazz.defineMethod (c$, "fill", -function () { -this.g ("f"); -}); -Clazz.defineMethod (c$, "stroke", -function () { -this.g ("S"); -}); -Clazz.defineMethod (c$, "doCircle", -function (x, y, r, doFill) { -var d = r * 4 * (Math.sqrt (2) - 1) / 3; -var dx = x; -var dy = y; -this.g ((dx + r) + " " + dy + " m"); -this.g ((dx + r) + " " + (dy + d) + " " + (dx + d) + " " + (dy + r) + " " + (dx) + " " + (dy + r) + " " + " c"); -this.g ((dx - d) + " " + (dy + r) + " " + (dx - r) + " " + (dy + d) + " " + (dx - r) + " " + (dy) + " c"); -this.g ((dx - r) + " " + (dy - d) + " " + (dx - d) + " " + (dy - r) + " " + (dx) + " " + (dy - r) + " c"); -this.g ((dx + d) + " " + (dy - r) + " " + (dx + r) + " " + (dy - d) + " " + (dx + r) + " " + (dy) + " c"); -this.g (doFill ? "f" : "s"); -}, "~N,~N,~N,~B"); -Clazz.defineMethod (c$, "doPolygon", -function (axPoints, ayPoints, nPoints, doFill) { -this.moveto (axPoints[0], ayPoints[0]); -for (var i = 1; i < nPoints; i++) this.lineto (axPoints[i], ayPoints[i]); - -this.g (doFill ? "f" : "s"); -}, "~A,~A,~N,~B"); -Clazz.defineMethod (c$, "doRect", -function (x, y, width, height, doFill) { -this.g (x + " " + y + " " + width + " " + height + " re " + (doFill ? "f" : "s")); -}, "~N,~N,~N,~N,~B"); -Clazz.defineMethod (c$, "drawImage", -function (image, destX0, destY0, destX1, destY1, srcX0, srcY0, srcX1, srcY1) { -var imageObj = this.images.get (image); -if (imageObj == null) return; -this.g ("q"); -this.clip (destX0, destY0, destX1, destY1); -var iw = Double.parseDouble (imageObj.getDef ("Width")); -var ih = Double.parseDouble (imageObj.getDef ("Height")); -var dw = (destX1 - destX0 + 1); -var dh = (destY1 - destY0 + 1); -var sw = (srcX1 - srcX0 + 1); -var sh = (srcY1 - srcY0 + 1); -var scaleX = dw / sw; -var scaleY = dh / sh; -var transX = destX0 - srcX0 * scaleX; -var transY = destY0 + (ih - srcY0) * scaleY; -this.g (scaleX * iw + " 0 0 " + -scaleY * ih + " " + transX + " " + transY + " cm"); -this.g ("/" + imageObj.getID () + " Do"); -this.g ("Q"); -}, "~O,~N,~N,~N,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "drawStringRotated", -function (s, x, y, angle) { -this.g ("q " + this.getRotation (angle) + " " + x + " " + y + " cm BT(" + s + ")Tj ET Q"); -}, "~S,~N,~N,~N"); -Clazz.defineMethod (c$, "getRotation", -function (angle) { -var cos = 0; -var sin = 0; -switch (angle) { -case 0: -cos = 1; -break; -case 90: -sin = 1; -break; -case -90: -sin = -1; -break; -case 180: -cos = -1; -break; -default: -var a = (angle / 180.0 * 3.141592653589793); -cos = Math.cos (a); -sin = Math.sin (a); -if (Math.abs (cos) < 0.0001) cos = 0; -if (Math.abs (sin) < 0.0001) sin = 0; -} -return cos + " " + sin + " " + sin + " " + -cos; -}, "~N"); -Clazz.defineMethod (c$, "setColor", -function (rgb, isFill) { -this.g (rgb[0] + " " + rgb[1] + " " + rgb[2] + (isFill ? " rg" : " RG")); -}, "~A,~B"); -Clazz.defineMethod (c$, "setFont", -function (fname, size) { -var f = this.fonts.get (fname); -if (f == null) f = this.addFontResource (fname); -this.g ("/" + f.getID () + " " + size + " Tf"); -}, "~S,~N"); -Clazz.defineMethod (c$, "setLineWidth", -function (width) { -this.g (width + " w"); -}, "~N"); -Clazz.defineMethod (c$, "translateScale", -function (x, y, scale) { -this.g (scale + " 0 0 " + scale + " " + x + " " + y + " cm"); -}, "~N,~N,~N"); -}); +Clazz.declarePackage ("javajs.export"); +Clazz.load (null, "javajs.export.PDFCreator", ["java.lang.Double", "java.util.Hashtable", "javajs.export.PDFObject", "javajs.util.Lst", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.os = null; +this.indirectObjects = null; +this.root = null; +this.graphics = null; +this.pt = 0; +this.xrefPt = 0; +this.count = 0; +this.height = 0; +this.width = 0; +this.fonts = null; +this.images = null; +Clazz.instantialize (this, arguments); +}, javajs["export"], "PDFCreator"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "setOutputStream", +function (os) { +this.os = os; +}, "java.io.OutputStream"); +Clazz.defineMethod (c$, "newDocument", +function (paperWidth, paperHeight, isLandscape) { +this.width = (isLandscape ? paperHeight : paperWidth); +this.height = (isLandscape ? paperWidth : paperHeight); +System.out.println ("Creating PDF with width=" + this.width + " and height=" + this.height); +this.fonts = new java.util.Hashtable (); +this.indirectObjects = new javajs.util.Lst (); +this.root = this.newObject ("Catalog"); +var pages = this.newObject ("Pages"); +var page = this.newObject ("Page"); +var pageContents = this.newObject (null); +this.graphics = this.newObject ("XObject"); +this.root.addDef ("Pages", pages.getRef ()); +pages.addDef ("Count", "1"); +pages.addDef ("Kids", "[ " + page.getRef () + " ]"); +page.addDef ("Parent", pages.getRef ()); +page.addDef ("MediaBox", "[ 0 0 " + paperWidth + " " + paperHeight + " ]"); +if (isLandscape) page.addDef ("Rotate", "90"); +pageContents.addDef ("Length", "?"); +pageContents.append ((isLandscape ? "q 0 1 1 0 0 0 " : "q 1 0 0 -1 0 " + (paperHeight)) + " cm /" + this.graphics.getID () + " Do Q"); +page.addDef ("Contents", pageContents.getRef ()); +this.addProcSet (page); +this.addProcSet (this.graphics); +this.graphics.addDef ("Subtype", "/Form"); +this.graphics.addDef ("FormType", "1"); +this.graphics.addDef ("BBox", "[0 0 " + this.width + " " + this.height + "]"); +this.graphics.addDef ("Matrix", "[1 0 0 1 0 0]"); +this.graphics.addDef ("Length", "?"); +page.addResource ("XObject", this.graphics.getID (), this.graphics.getRef ()); +this.g ("q 1 w 1 J 1 j 10 M []0 d q "); +this.clip (0, 0, this.width, this.height); +}, "~N,~N,~B"); +Clazz.defineMethod (c$, "addProcSet", +($fz = function (o) { +o.addResource (null, "ProcSet", "[/PDF /Text /ImageB /ImageC /ImageI]"); +}, $fz.isPrivate = true, $fz), "javajs.export.PDFObject"); +Clazz.defineMethod (c$, "clip", +($fz = function (x1, y1, x2, y2) { +this.moveto (x1, y1); +this.lineto (x2, y1); +this.lineto (x2, y2); +this.lineto (x1, y2); +this.g ("h W n"); +}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "moveto", +function (x, y) { +this.g (x + " " + y + " m"); +}, "~N,~N"); +Clazz.defineMethod (c$, "lineto", +function (x, y) { +this.g (x + " " + y + " l"); +}, "~N,~N"); +Clazz.defineMethod (c$, "newObject", +($fz = function (type) { +var o = new javajs["export"].PDFObject (++this.count); +if (type != null) o.addDef ("Type", "/" + type); +this.indirectObjects.addLast (o); +return o; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "addInfo", +function (data) { +var info = new java.util.Hashtable (); +for (var e, $e = data.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) { +var value = "(" + e.getValue ().$replace (')', '_').$replace ('(', '_') + ")"; +info.put (e.getKey (), value); +} +this.root.addDef ("Info", info); +}, "java.util.Map"); +Clazz.defineMethod (c$, "addFontResource", +($fz = function (fname) { +var f = this.newObject ("Font"); +this.fonts.put (fname, f); +f.addDef ("BaseFont", fname); +f.addDef ("Encoding", "/WinAnsiEncoding"); +f.addDef ("Subtype", "/Type1"); +this.graphics.addResource ("Font", f.getID (), f.getRef ()); +return f; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "addImageResource", +function (newImage, width, height, buffer, isRGB) { +var imageObj = this.newObject ("XObject"); +if (this.images == null) this.images = new java.util.Hashtable (); +this.images.put (newImage, imageObj); +imageObj.addDef ("Subtype", "/Image"); +imageObj.addDef ("Length", "?"); +imageObj.addDef ("ColorSpace", isRGB ? "/DeviceRGB" : "/DeviceGray"); +imageObj.addDef ("BitsPerComponent", "8"); +imageObj.addDef ("Width", "" + width); +imageObj.addDef ("Height", "" + height); +this.graphics.addResource ("XObject", imageObj.getID (), imageObj.getRef ()); +var n = buffer.length; +var stream = Clazz.newByteArray (n * (isRGB ? 3 : 1), 0); +if (isRGB) { +for (var i = 0, pt = 0; i < n; i++) { +stream[pt++] = ((buffer[i] >> 16) & 0xFF); +stream[pt++] = ((buffer[i] >> 8) & 0xFF); +stream[pt++] = (buffer[i] & 0xFF); +} +} else { +for (var i = 0; i < n; i++) stream[i] = buffer[i]; + +}imageObj.setStream (stream); +this.graphics.addResource ("XObject", imageObj.getID (), imageObj.getRef ()); +}, "~O,~N,~N,~A,~B"); +Clazz.defineMethod (c$, "g", +function (cmd) { +this.graphics.append (cmd).appendC ('\n'); +}, "~S"); +Clazz.defineMethod (c$, "output", +($fz = function (s) { +var b = s.getBytes (); +this.os.write (b, 0, b.length); +this.pt += b.length; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "closeDocument", +function () { +this.g ("Q Q"); +this.outputHeader (); +this.writeObjects (); +this.writeXRefTable (); +this.writeTrailer (); +this.os.flush (); +this.os.close (); +}); +Clazz.defineMethod (c$, "outputHeader", +($fz = function () { +this.output ("%PDF-1.3\n%"); +var b = Clazz.newByteArray (-1, [-1, -1, -1, -1]); +this.os.write (b, 0, b.length); +this.pt += 4; +this.output ("\n"); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeTrailer", +($fz = function () { +var trailer = new javajs["export"].PDFObject (-2); +this.output ("trailer"); +trailer.addDef ("Size", "" + this.indirectObjects.size ()); +trailer.addDef ("Root", this.root.getRef ()); +trailer.output (this.os); +this.output ("startxref\n"); +this.output ("" + this.xrefPt + "\n"); +this.output ("%%EOF\n"); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeObjects", +($fz = function () { +var nObj = this.indirectObjects.size (); +for (var i = 0; i < nObj; i++) { +var o = this.indirectObjects.get (i); +if (!o.isFont ()) continue; +o.pt = this.pt; +this.pt += o.output (this.os); +} +for (var i = 0; i < nObj; i++) { +var o = this.indirectObjects.get (i); +if (o.isFont ()) continue; +o.pt = this.pt; +this.pt += o.output (this.os); +} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeXRefTable", +($fz = function () { +this.xrefPt = this.pt; +var nObj = this.indirectObjects.size (); +var sb = new javajs.util.SB (); +sb.append ("xref\n0 " + (nObj + 1) + "\n0000000000 65535 f\r\n"); +for (var i = 0; i < nObj; i++) { +var o = this.indirectObjects.get (i); +var s = "0000000000" + o.pt; +sb.append (s.substring (s.length - 10)); +sb.append (" 00000 n\r\n"); +} +this.output (sb.toString ()); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "canDoLineTo", +function () { +return true; +}); +Clazz.defineMethod (c$, "fill", +function () { +this.g ("f"); +}); +Clazz.defineMethod (c$, "stroke", +function () { +this.g ("S"); +}); +Clazz.defineMethod (c$, "doCircle", +function (x, y, r, doFill) { +var d = r * 4 * (Math.sqrt (2) - 1) / 3; +var dx = x; +var dy = y; +this.g ((dx + r) + " " + dy + " m"); +this.g ((dx + r) + " " + (dy + d) + " " + (dx + d) + " " + (dy + r) + " " + (dx) + " " + (dy + r) + " " + " c"); +this.g ((dx - d) + " " + (dy + r) + " " + (dx - r) + " " + (dy + d) + " " + (dx - r) + " " + (dy) + " c"); +this.g ((dx - r) + " " + (dy - d) + " " + (dx - d) + " " + (dy - r) + " " + (dx) + " " + (dy - r) + " c"); +this.g ((dx + d) + " " + (dy - r) + " " + (dx + r) + " " + (dy - d) + " " + (dx + r) + " " + (dy) + " c"); +this.g (doFill ? "f" : "s"); +}, "~N,~N,~N,~B"); +Clazz.defineMethod (c$, "doPolygon", +function (axPoints, ayPoints, nPoints, doFill) { +this.moveto (axPoints[0], ayPoints[0]); +for (var i = 1; i < nPoints; i++) this.lineto (axPoints[i], ayPoints[i]); + +this.g (doFill ? "f" : "s"); +}, "~A,~A,~N,~B"); +Clazz.defineMethod (c$, "doRect", +function (x, y, width, height, doFill) { +this.g (x + " " + y + " " + width + " " + height + " re " + (doFill ? "f" : "s")); +}, "~N,~N,~N,~N,~B"); +Clazz.defineMethod (c$, "drawImage", +function (image, destX0, destY0, destX1, destY1, srcX0, srcY0, srcX1, srcY1) { +var imageObj = this.images.get (image); +if (imageObj == null) return; +this.g ("q"); +this.clip (destX0, destY0, destX1, destY1); +var iw = Double.parseDouble (imageObj.getDef ("Width")); +var ih = Double.parseDouble (imageObj.getDef ("Height")); +var dw = (destX1 - destX0 + 1); +var dh = (destY1 - destY0 + 1); +var sw = (srcX1 - srcX0 + 1); +var sh = (srcY1 - srcY0 + 1); +var scaleX = dw / sw; +var scaleY = dh / sh; +var transX = destX0 - srcX0 * scaleX; +var transY = destY0 + (ih - srcY0) * scaleY; +this.g (scaleX * iw + " 0 0 " + -scaleY * ih + " " + transX + " " + transY + " cm"); +this.g ("/" + imageObj.getID () + " Do"); +this.g ("Q"); +}, "~O,~N,~N,~N,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "drawStringRotated", +function (s, x, y, angle) { +this.g ("q " + this.getRotation (angle) + " " + x + " " + y + " cm BT(" + s + ")Tj ET Q"); +}, "~S,~N,~N,~N"); +Clazz.defineMethod (c$, "getRotation", +function (angle) { +var cos = 0; +var sin = 0; +switch (angle) { +case 0: +cos = 1; +break; +case 90: +sin = 1; +break; +case -90: +sin = -1; +break; +case 180: +cos = -1; +break; +default: +var a = (angle / 180.0 * 3.141592653589793); +cos = Math.cos (a); +sin = Math.sin (a); +if (Math.abs (cos) < 0.0001) cos = 0; +if (Math.abs (sin) < 0.0001) sin = 0; +} +return cos + " " + sin + " " + sin + " " + -cos; +}, "~N"); +Clazz.defineMethod (c$, "setColor", +function (rgb, isFill) { +this.g (rgb[0] + " " + rgb[1] + " " + rgb[2] + (isFill ? " rg" : " RG")); +}, "~A,~B"); +Clazz.defineMethod (c$, "setFont", +function (fname, size) { +var f = this.fonts.get (fname); +if (f == null) f = this.addFontResource (fname); +this.g ("/" + f.getID () + " " + size + " Tf"); +}, "~S,~N"); +Clazz.defineMethod (c$, "setLineWidth", +function (width) { +this.g (width + " w"); +}, "~N"); +Clazz.defineMethod (c$, "translateScale", +function (x, y, scale) { +this.g (scale + " 0 0 " + scale + " " + x + " " + y + " cm"); +}, "~N,~N,~N"); +}); diff --git a/bin/javajs/export/PDFObject.js b/bin/javajs/export/PDFObject.js index ad20c61..2752622 100644 --- a/bin/javajs/export/PDFObject.js +++ b/bin/javajs/export/PDFObject.js @@ -1,115 +1,115 @@ -Clazz.declarePackage ("javajs.export"); -Clazz.load (["javajs.util.SB"], "javajs.export.PDFObject", ["java.io.ByteArrayOutputStream", "java.util.Hashtable", "$.Map", "java.util.zip.Deflater", "$.DeflaterOutputStream"], function () { -c$ = Clazz.decorateAsClass (function () { -this.dictionary = null; -this.stream = null; -this.index = 0; -this.type = null; -this.len = 0; -this.pt = 0; -Clazz.instantialize (this, arguments); -}, javajs["export"], "PDFObject", javajs.util.SB); -Clazz.makeConstructor (c$, -function (index) { -Clazz.superConstructor (this, javajs["export"].PDFObject, []); -this.index = index; -}, "~N"); -Clazz.defineMethod (c$, "getRef", -function () { -return this.index + " 0 R"; -}); -Clazz.defineMethod (c$, "getID", -function () { -return this.type.substring (0, 1) + this.index; -}); -Clazz.defineMethod (c$, "isFont", -function () { -return "Font".equals (this.type); -}); -Clazz.defineMethod (c$, "setStream", -function (stream) { -this.stream = stream; -}, "~A"); -Clazz.defineMethod (c$, "getDef", -function (key) { -return this.dictionary.get (key); -}, "~S"); -Clazz.defineMethod (c$, "addDef", -function (key, value) { -if (this.dictionary == null) this.dictionary = new java.util.Hashtable (); -this.dictionary.put (key, value); -if (key.equals ("Type")) this.type = (value).substring (1); -}, "~S,~O"); -Clazz.defineMethod (c$, "setAsStream", -function () { -this.stream = this.toBytes (0, -1); -this.setLength (0); -}); -Clazz.defineMethod (c$, "output", -function (os) { -if (this.index > 0) { -var s = this.index + " 0 obj\n"; -this.write (os, s.getBytes (), 0); -}var streamLen = 0; -if (this.dictionary != null) { -if (this.dictionary.containsKey ("Length")) { -if (this.stream == null) this.setAsStream (); -streamLen = this.stream.length; -var doDeflate = (streamLen > 1000); -if (doDeflate) { -var deflater = new java.util.zip.Deflater (9); -var outBytes = new java.io.ByteArrayOutputStream (1024); -var compBytes = new java.util.zip.DeflaterOutputStream (outBytes, deflater); -compBytes.write (this.stream, 0, streamLen); -compBytes.finish (); -this.stream = outBytes.toByteArray (); -this.dictionary.put ("Filter", "/FlateDecode"); -streamLen = this.stream.length; -}this.dictionary.put ("Length", "" + streamLen); -}this.write (os, this.getDictionaryText (this.dictionary, "\n").getBytes (), 0); -}if (this.length () > 0) this.write (os, this.toString ().getBytes (), 0); -if (this.stream != null) { -this.write (os, "stream\r\n".getBytes (), 0); -this.write (os, this.stream, streamLen); -this.write (os, "\r\nendstream\r\n".getBytes (), 0); -}if (this.index > 0) this.write (os, "endobj\n".getBytes (), 0); -return this.len; -}, "java.io.OutputStream"); -Clazz.defineMethod (c$, "write", -($fz = function (os, bytes, nBytes) { -if (nBytes == 0) nBytes = bytes.length; -this.len += nBytes; -os.write (bytes, 0, nBytes); -}, $fz.isPrivate = true, $fz), "java.io.OutputStream,~A,~N"); -Clazz.defineMethod (c$, "getDictionaryText", -($fz = function (d, nl) { -var sb = new javajs.util.SB (); -sb.append ("<<"); -if (d.containsKey ("Type")) sb.append ("/Type").appendO (d.get ("Type")); -for (var e, $e = d.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) { -var s = e.getKey (); -if (s.equals ("Type") || s.startsWith ("!")) continue; -sb.append ("/" + s); -var o = e.getValue (); -if (Clazz.instanceOf (o, java.util.Map)) { -sb.append ((this.getDictionaryText (o, ""))); -continue; -}s = e.getValue (); -if (!s.startsWith ("/")) sb.append (" "); -sb.appendO (s); -} -return (sb.length () > 3 ? sb.append (">>").append (nl).toString () : ""); -}, $fz.isPrivate = true, $fz), "java.util.Map,~S"); -Clazz.defineMethod (c$, "createSubdict", -($fz = function (d0, dict) { -var d = d0.get (dict); -if (d == null) d0.put (dict, d = new java.util.Hashtable ()); -return d; -}, $fz.isPrivate = true, $fz), "java.util.Map,~S"); -Clazz.defineMethod (c$, "addResource", -function (type, key, value) { -var r = this.createSubdict (this.dictionary, "Resources"); -if (type != null) r = this.createSubdict (r, type); -r.put (key, value); -}, "~S,~S,~S"); -}); +Clazz.declarePackage ("javajs.export"); +Clazz.load (["javajs.util.SB"], "javajs.export.PDFObject", ["java.io.ByteArrayOutputStream", "java.util.Hashtable", "$.Map", "java.util.zip.Deflater", "$.DeflaterOutputStream"], function () { +c$ = Clazz.decorateAsClass (function () { +this.dictionary = null; +this.stream = null; +this.index = 0; +this.type = null; +this.len = 0; +this.pt = 0; +Clazz.instantialize (this, arguments); +}, javajs["export"], "PDFObject", javajs.util.SB); +Clazz.makeConstructor (c$, +function (index) { +Clazz.superConstructor (this, javajs["export"].PDFObject, []); +this.index = index; +}, "~N"); +Clazz.defineMethod (c$, "getRef", +function () { +return this.index + " 0 R"; +}); +Clazz.defineMethod (c$, "getID", +function () { +return this.type.substring (0, 1) + this.index; +}); +Clazz.defineMethod (c$, "isFont", +function () { +return "Font".equals (this.type); +}); +Clazz.defineMethod (c$, "setStream", +function (stream) { +this.stream = stream; +}, "~A"); +Clazz.defineMethod (c$, "getDef", +function (key) { +return this.dictionary.get (key); +}, "~S"); +Clazz.defineMethod (c$, "addDef", +function (key, value) { +if (this.dictionary == null) this.dictionary = new java.util.Hashtable (); +this.dictionary.put (key, value); +if (key.equals ("Type")) this.type = (value).substring (1); +}, "~S,~O"); +Clazz.defineMethod (c$, "setAsStream", +function () { +this.stream = this.toBytes (0, -1); +this.setLength (0); +}); +Clazz.defineMethod (c$, "output", +function (os) { +if (this.index > 0) { +var s = this.index + " 0 obj\n"; +this.write (os, s.getBytes (), 0); +}var streamLen = 0; +if (this.dictionary != null) { +if (this.dictionary.containsKey ("Length")) { +if (this.stream == null) this.setAsStream (); +streamLen = this.stream.length; +var doDeflate = (streamLen > 1000); +if (doDeflate) { +var deflater = new java.util.zip.Deflater (9); +var outBytes = new java.io.ByteArrayOutputStream (1024); +var compBytes = new java.util.zip.DeflaterOutputStream (outBytes, deflater); +compBytes.write (this.stream, 0, streamLen); +compBytes.finish (); +this.stream = outBytes.toByteArray (); +this.dictionary.put ("Filter", "/FlateDecode"); +streamLen = this.stream.length; +}this.dictionary.put ("Length", "" + streamLen); +}this.write (os, this.getDictionaryText (this.dictionary, "\n").getBytes (), 0); +}if (this.length () > 0) this.write (os, this.toString ().getBytes (), 0); +if (this.stream != null) { +this.write (os, "stream\r\n".getBytes (), 0); +this.write (os, this.stream, streamLen); +this.write (os, "\r\nendstream\r\n".getBytes (), 0); +}if (this.index > 0) this.write (os, "endobj\n".getBytes (), 0); +return this.len; +}, "java.io.OutputStream"); +Clazz.defineMethod (c$, "write", +($fz = function (os, bytes, nBytes) { +if (nBytes == 0) nBytes = bytes.length; +this.len += nBytes; +os.write (bytes, 0, nBytes); +}, $fz.isPrivate = true, $fz), "java.io.OutputStream,~A,~N"); +Clazz.defineMethod (c$, "getDictionaryText", +($fz = function (d, nl) { +var sb = new javajs.util.SB (); +sb.append ("<<"); +if (d.containsKey ("Type")) sb.append ("/Type").appendO (d.get ("Type")); +for (var e, $e = d.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) { +var s = e.getKey (); +if (s.equals ("Type") || s.startsWith ("!")) continue; +sb.append ("/" + s); +var o = e.getValue (); +if (Clazz.instanceOf (o, java.util.Map)) { +sb.append ((this.getDictionaryText (o, ""))); +continue; +}s = e.getValue (); +if (!s.startsWith ("/")) sb.append (" "); +sb.appendO (s); +} +return (sb.length () > 3 ? sb.append (">>").append (nl).toString () : ""); +}, $fz.isPrivate = true, $fz), "java.util.Map,~S"); +Clazz.defineMethod (c$, "createSubdict", +($fz = function (d0, dict) { +var d = d0.get (dict); +if (d == null) d0.put (dict, d = new java.util.Hashtable ()); +return d; +}, $fz.isPrivate = true, $fz), "java.util.Map,~S"); +Clazz.defineMethod (c$, "addResource", +function (type, key, value) { +var r = this.createSubdict (this.dictionary, "Resources"); +if (type != null) r = this.createSubdict (r, type); +r.put (key, value); +}, "~S,~S,~S"); +}); diff --git a/bin/javajs/img/BMPDecoder.js b/bin/javajs/img/BMPDecoder.js index c3b4dc7..b32016b 100644 --- a/bin/javajs/img/BMPDecoder.js +++ b/bin/javajs/img/BMPDecoder.js @@ -1,144 +1,144 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (null, "javajs.img.BMPDecoder", ["javajs.util.Rdr"], function () { -c$ = Clazz.decorateAsClass (function () { -this.bis = null; -this.temp = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "BMPDecoder"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "decodeWindowsBMP", -function (bytes) { -try { -this.bis = javajs.util.Rdr.getBIS (bytes); -this.temp = Clazz.newByteArray (4, 0); -if (this.readByte () != 66 || this.readByte () != 77) return null; -this.readInt (); -this.readShort (); -this.readShort (); -this.readInt (); -var imageWidth; -var imageHeight; -var bitsPerPixel; -var nColors = 0; -var imageSize = 0; -var headerSize = this.readInt (); -switch (headerSize) { -case 12: -imageWidth = this.readShort (); -imageHeight = this.readShort (); -this.readShort (); -bitsPerPixel = this.readShort (); -break; -case 40: -imageWidth = this.readInt (); -imageHeight = this.readInt (); -this.readShort (); -bitsPerPixel = this.readShort (); -var ncompression = this.readInt (); -if (ncompression != 0) { -System.out.println ("BMP Compression is :" + ncompression + " -- aborting"); -return null; -}imageSize = this.readInt (); -this.readInt (); -this.readInt (); -nColors = this.readInt (); -this.readInt (); -break; -default: -System.out.println ("BMP Header unrecognized, length=" + headerSize + " -- aborting"); -return null; -} -var isYReversed = (imageHeight < 0); -if (isYReversed) imageHeight = -imageHeight; -var nPixels = imageHeight * imageWidth; -var bytesPerPixel = Clazz.doubleToInt (bitsPerPixel / 8); -nColors = (nColors > 0 ? nColors : 1 << bitsPerPixel); -var npad = (bytesPerPixel == 4 ? 0 : imageSize == 0 ? 4 - (imageWidth % 4) : (Clazz.doubleToInt (imageSize / imageHeight)) - imageWidth * bytesPerPixel) % 4; -var palette; -var buf = Clazz.newIntArray (nPixels, 0); -var dpt = (isYReversed ? imageWidth : -imageWidth); -var pt0 = (isYReversed ? 0 : nPixels + dpt); -var pt1 = (isYReversed ? nPixels : dpt); -switch (bitsPerPixel) { -case 32: -case 24: -for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0; i < imageWidth; i++) buf[pt + i] = this.readColor (bytesPerPixel); - - -break; -case 8: -palette = Clazz.newIntArray (nColors, 0); -for (var i = 0; i < nColors; i++) palette[i] = this.readColor (4); - -for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0; i < imageWidth; i++) buf[pt + i] = palette[this.readByte ()]; - - -break; -case 4: -npad = (4 - ((Clazz.doubleToInt ((imageWidth + 1) / 2)) % 4)) % 4; -palette = Clazz.newIntArray (nColors, 0); -for (var i = 0; i < nColors; i++) palette[i] = this.readColor (4); - -var b4 = 0; -for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0, shift = 4; i < imageWidth; i++, shift = 4 - shift) buf[pt + i] = palette[((shift == 4 ? (b4 = this.readByte ()) : b4) >> shift) & 0xF]; - - -break; -case 1: -var color1 = this.readColor (3); -var color2 = this.readColor (3); -npad = (4 - ((Clazz.doubleToInt ((imageWidth + 7) / 8)) % 4)) % 4; -var b = 0; -for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0, bpt = -1; i < imageWidth; i++, bpt--) { -if (bpt < 0) { -b = this.readByte (); -bpt = 7; -}buf[pt + i] = ((b & (1 << bpt)) == 0 ? color1 : color2); -} - -break; -case 64: -case 2: -default: -System.out.println ("Not a 32-, 24-, 8-, 4-, or 1-bit Windows Bitmap, aborting..."); -return null; -} -return Clazz.newArray (-1, [buf, Integer.$valueOf (imageWidth), Integer.$valueOf (imageHeight)]); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println ("Caught exception in loadbitmap!"); -} else { -throw e; -} -} -return null; -}, "~A"); -Clazz.defineMethod (c$, "pad", -($fz = function (npad) { -for (var i = 0; i < npad; i++) this.readByte (); - -return true; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "readColor", -($fz = function (n) { -this.bis.read (this.temp, 0, n); -return -16777216 | ((this.temp[2] & 0xff) << 16) | ((this.temp[1] & 0xff) << 8) | this.temp[0] & 0xff; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "readInt", -($fz = function () { -this.bis.read (this.temp, 0, 4); -return ((this.temp[3] & 0xff) << 24) | ((this.temp[2] & 0xff) << 16) | ((this.temp[1] & 0xff) << 8) | this.temp[0] & 0xff; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "readShort", -($fz = function () { -this.bis.read (this.temp, 0, 2); -return ((this.temp[1] & 0xff) << 8) | this.temp[0] & 0xff; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "readByte", -($fz = function () { -this.bis.read (this.temp, 0, 1); -return this.temp[0] & 0xff; -}, $fz.isPrivate = true, $fz)); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (null, "javajs.img.BMPDecoder", ["javajs.util.Rdr"], function () { +c$ = Clazz.decorateAsClass (function () { +this.bis = null; +this.temp = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "BMPDecoder"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "decodeWindowsBMP", +function (bytes) { +try { +this.bis = javajs.util.Rdr.getBIS (bytes); +this.temp = Clazz.newByteArray (4, 0); +if (this.readByte () != 66 || this.readByte () != 77) return null; +this.readInt (); +this.readShort (); +this.readShort (); +this.readInt (); +var imageWidth; +var imageHeight; +var bitsPerPixel; +var nColors = 0; +var imageSize = 0; +var headerSize = this.readInt (); +switch (headerSize) { +case 12: +imageWidth = this.readShort (); +imageHeight = this.readShort (); +this.readShort (); +bitsPerPixel = this.readShort (); +break; +case 40: +imageWidth = this.readInt (); +imageHeight = this.readInt (); +this.readShort (); +bitsPerPixel = this.readShort (); +var ncompression = this.readInt (); +if (ncompression != 0) { +System.out.println ("BMP Compression is :" + ncompression + " -- aborting"); +return null; +}imageSize = this.readInt (); +this.readInt (); +this.readInt (); +nColors = this.readInt (); +this.readInt (); +break; +default: +System.out.println ("BMP Header unrecognized, length=" + headerSize + " -- aborting"); +return null; +} +var isYReversed = (imageHeight < 0); +if (isYReversed) imageHeight = -imageHeight; +var nPixels = imageHeight * imageWidth; +var bytesPerPixel = Clazz.doubleToInt (bitsPerPixel / 8); +nColors = (nColors > 0 ? nColors : 1 << bitsPerPixel); +var npad = (bytesPerPixel == 4 ? 0 : imageSize == 0 ? 4 - (imageWidth % 4) : (Clazz.doubleToInt (imageSize / imageHeight)) - imageWidth * bytesPerPixel) % 4; +var palette; +var buf = Clazz.newIntArray (nPixels, 0); +var dpt = (isYReversed ? imageWidth : -imageWidth); +var pt0 = (isYReversed ? 0 : nPixels + dpt); +var pt1 = (isYReversed ? nPixels : dpt); +switch (bitsPerPixel) { +case 32: +case 24: +for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0; i < imageWidth; i++) buf[pt + i] = this.readColor (bytesPerPixel); + + +break; +case 8: +palette = Clazz.newIntArray (nColors, 0); +for (var i = 0; i < nColors; i++) palette[i] = this.readColor (4); + +for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0; i < imageWidth; i++) buf[pt + i] = palette[this.readByte ()]; + + +break; +case 4: +npad = (4 - ((Clazz.doubleToInt ((imageWidth + 1) / 2)) % 4)) % 4; +palette = Clazz.newIntArray (nColors, 0); +for (var i = 0; i < nColors; i++) palette[i] = this.readColor (4); + +var b4 = 0; +for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0, shift = 4; i < imageWidth; i++, shift = 4 - shift) buf[pt + i] = palette[((shift == 4 ? (b4 = this.readByte ()) : b4) >> shift) & 0xF]; + + +break; +case 1: +var color1 = this.readColor (3); +var color2 = this.readColor (3); +npad = (4 - ((Clazz.doubleToInt ((imageWidth + 7) / 8)) % 4)) % 4; +var b = 0; +for (var pt = pt0; pt != pt1; pt += dpt, this.pad (npad)) for (var i = 0, bpt = -1; i < imageWidth; i++, bpt--) { +if (bpt < 0) { +b = this.readByte (); +bpt = 7; +}buf[pt + i] = ((b & (1 << bpt)) == 0 ? color1 : color2); +} + +break; +case 64: +case 2: +default: +System.out.println ("Not a 32-, 24-, 8-, 4-, or 1-bit Windows Bitmap, aborting..."); +return null; +} +return Clazz.newArray (-1, [buf, Integer.$valueOf (imageWidth), Integer.$valueOf (imageHeight)]); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println ("Caught exception in loadbitmap!"); +} else { +throw e; +} +} +return null; +}, "~A"); +Clazz.defineMethod (c$, "pad", +($fz = function (npad) { +for (var i = 0; i < npad; i++) this.readByte (); + +return true; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "readColor", +($fz = function (n) { +this.bis.read (this.temp, 0, n); +return -16777216 | ((this.temp[2] & 0xff) << 16) | ((this.temp[1] & 0xff) << 8) | this.temp[0] & 0xff; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "readInt", +($fz = function () { +this.bis.read (this.temp, 0, 4); +return ((this.temp[3] & 0xff) << 24) | ((this.temp[2] & 0xff) << 16) | ((this.temp[1] & 0xff) << 8) | this.temp[0] & 0xff; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "readShort", +($fz = function () { +this.bis.read (this.temp, 0, 2); +return ((this.temp[1] & 0xff) << 8) | this.temp[0] & 0xff; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "readByte", +($fz = function () { +this.bis.read (this.temp, 0, 1); +return this.temp[0] & 0xff; +}, $fz.isPrivate = true, $fz)); +}); diff --git a/bin/javajs/img/CRCEncoder.js b/bin/javajs/img/CRCEncoder.js index 2dca50d..3a7582e 100644 --- a/bin/javajs/img/CRCEncoder.js +++ b/bin/javajs/img/CRCEncoder.js @@ -1,74 +1,74 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.CRCEncoder", ["java.util.zip.CRC32", "javajs.util.AU"], function () { -c$ = Clazz.decorateAsClass (function () { -this.startPos = 0; -this.bytePos = 0; -this.crc = null; -this.pngBytes = null; -this.dataLen = 0; -this.int2 = null; -this.int4 = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "CRCEncoder", javajs.img.ImageEncoder); -Clazz.prepareFields (c$, function () { -this.int2 = Clazz.newByteArray (2, 0); -this.int4 = Clazz.newByteArray (4, 0); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.img.CRCEncoder, []); -this.pngBytes = Clazz.newByteArray (250, 0); -this.crc = new java.util.zip.CRC32 (); -}); -Clazz.defineMethod (c$, "setData", -function (b, pt) { -this.pngBytes = b; -this.dataLen = b.length; -this.startPos = this.bytePos = pt; -}, "~A,~N"); -Clazz.defineMethod (c$, "getBytes", -function () { -return (this.dataLen == this.pngBytes.length ? this.pngBytes : javajs.util.AU.arrayCopyByte (this.pngBytes, this.dataLen)); -}); -Clazz.defineMethod (c$, "writeCRC", -function () { -this.crc.reset (); -this.crc.update (this.pngBytes, this.startPos, this.bytePos - this.startPos); -this.writeInt4 (this.crc.getValue ()); -}); -Clazz.defineMethod (c$, "writeInt2", -function (n) { -this.int2[0] = ((n >> 8) & 0xff); -this.int2[1] = (n & 0xff); -this.writeBytes (this.int2); -}, "~N"); -Clazz.defineMethod (c$, "writeInt4", -function (n) { -javajs.img.CRCEncoder.getInt4 (n, this.int4); -this.writeBytes (this.int4); -}, "~N"); -c$.getInt4 = Clazz.defineMethod (c$, "getInt4", -function (n, int4) { -int4[0] = ((n >> 24) & 0xff); -int4[1] = ((n >> 16) & 0xff); -int4[2] = ((n >> 8) & 0xff); -int4[3] = (n & 0xff); -}, "~N,~A"); -Clazz.defineMethod (c$, "writeByte", -function (b) { -var temp = Clazz.newByteArray (-1, [b]); -this.writeBytes (temp); -}, "~N"); -Clazz.defineMethod (c$, "writeString", -function (s) { -this.writeBytes (s.getBytes ()); -}, "~S"); -Clazz.defineMethod (c$, "writeBytes", -function (data) { -var newPos = this.bytePos + data.length; -this.dataLen = Math.max (this.dataLen, newPos); -if (newPos > this.pngBytes.length) this.pngBytes = javajs.util.AU.arrayCopyByte (this.pngBytes, newPos + 16); -System.arraycopy (data, 0, this.pngBytes, this.bytePos, data.length); -this.bytePos = newPos; -}, "~A"); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.CRCEncoder", ["java.util.zip.CRC32", "javajs.util.AU"], function () { +c$ = Clazz.decorateAsClass (function () { +this.startPos = 0; +this.bytePos = 0; +this.crc = null; +this.pngBytes = null; +this.dataLen = 0; +this.int2 = null; +this.int4 = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "CRCEncoder", javajs.img.ImageEncoder); +Clazz.prepareFields (c$, function () { +this.int2 = Clazz.newByteArray (2, 0); +this.int4 = Clazz.newByteArray (4, 0); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.img.CRCEncoder, []); +this.pngBytes = Clazz.newByteArray (250, 0); +this.crc = new java.util.zip.CRC32 (); +}); +Clazz.defineMethod (c$, "setData", +function (b, pt) { +this.pngBytes = b; +this.dataLen = b.length; +this.startPos = this.bytePos = pt; +}, "~A,~N"); +Clazz.defineMethod (c$, "getBytes", +function () { +return (this.dataLen == this.pngBytes.length ? this.pngBytes : javajs.util.AU.arrayCopyByte (this.pngBytes, this.dataLen)); +}); +Clazz.defineMethod (c$, "writeCRC", +function () { +this.crc.reset (); +this.crc.update (this.pngBytes, this.startPos, this.bytePos - this.startPos); +this.writeInt4 (this.crc.getValue ()); +}); +Clazz.defineMethod (c$, "writeInt2", +function (n) { +this.int2[0] = ((n >> 8) & 0xff); +this.int2[1] = (n & 0xff); +this.writeBytes (this.int2); +}, "~N"); +Clazz.defineMethod (c$, "writeInt4", +function (n) { +javajs.img.CRCEncoder.getInt4 (n, this.int4); +this.writeBytes (this.int4); +}, "~N"); +c$.getInt4 = Clazz.defineMethod (c$, "getInt4", +function (n, int4) { +int4[0] = ((n >> 24) & 0xff); +int4[1] = ((n >> 16) & 0xff); +int4[2] = ((n >> 8) & 0xff); +int4[3] = (n & 0xff); +}, "~N,~A"); +Clazz.defineMethod (c$, "writeByte", +function (b) { +var temp = Clazz.newByteArray (-1, [b]); +this.writeBytes (temp); +}, "~N"); +Clazz.defineMethod (c$, "writeString", +function (s) { +this.writeBytes (s.getBytes ()); +}, "~S"); +Clazz.defineMethod (c$, "writeBytes", +function (data) { +var newPos = this.bytePos + data.length; +this.dataLen = Math.max (this.dataLen, newPos); +if (newPos > this.pngBytes.length) this.pngBytes = javajs.util.AU.arrayCopyByte (this.pngBytes, newPos + 16); +System.arraycopy (data, 0, this.pngBytes, this.bytePos, data.length); +this.bytePos = newPos; +}, "~A"); +}); diff --git a/bin/javajs/img/GifEncoder.js b/bin/javajs/img/GifEncoder.js index 9170951..dd22f43 100644 --- a/bin/javajs/img/GifEncoder.js +++ b/bin/javajs/img/GifEncoder.js @@ -1,627 +1,627 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.ImageEncoder", "javajs.util.Lst", "$.P3"], "javajs.img.GifEncoder", ["java.lang.Boolean", "java.util.Hashtable", "javajs.util.CU", "$.M3"], function () { -c$ = Clazz.decorateAsClass (function () { -this.params = null; -this.palette = null; -this.backgroundColor = 0; -this.interlaced = false; -this.addHeader = true; -this.addImage = true; -this.addTrailer = true; -this.isTransparent = false; -this.floydSteinberg = true; -this.capturing = false; -this.looping = false; -this.delayTime100ths = -1; -this.bitsPerPixel = 1; -this.byteCount = 0; -if (!Clazz.isClassDefined ("javajs.img.GifEncoder.ColorItem")) { -javajs.img.GifEncoder.$GifEncoder$ColorItem$ (); -} -if (!Clazz.isClassDefined ("javajs.img.GifEncoder.ColorCell")) { -javajs.img.GifEncoder.$GifEncoder$ColorCell$ (); -} -this.initCodeSize = 0; -this.curpt = 0; -this.nBits = 0; -this.maxbits = 12; -this.maxcode = 0; -this.maxmaxcode = 4096; -this.htab = null; -this.codetab = null; -this.hsize = 5003; -this.freeEnt = 0; -this.clearFlag = false; -this.clearCode = 0; -this.EOFCode = 0; -this.countDown = 0; -this.pass = 0; -this.curx = 0; -this.cury = 0; -this.curAccum = 0; -this.curBits = 0; -this.masks = null; -this.bufPt = 0; -this.buf = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "GifEncoder", javajs.img.ImageEncoder); -Clazz.prepareFields (c$, function () { -this.htab = Clazz.newIntArray (5003, 0); -this.codetab = Clazz.newIntArray (5003, 0); -this.masks = Clazz.newIntArray (-1, [0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF]); -this.buf = Clazz.newByteArray (256, 0); -}); -Clazz.overrideMethod (c$, "setParams", -function (params) { -this.params = params; -var ic = params.get ("transparentColor"); -if (ic == null) { -ic = params.get ("backgroundColor"); -if (ic != null) this.backgroundColor = ic.intValue (); -} else { -this.backgroundColor = ic.intValue (); -this.isTransparent = true; -}this.interlaced = (Boolean.TRUE === params.get ("interlaced")); -if (params.containsKey ("captureRootExt") || !params.containsKey ("captureMode")) return; -this.interlaced = false; -this.capturing = true; -try { -this.byteCount = (params.get ("captureByteCount")).intValue (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -switch ("maec".indexOf ((params.get ("captureMode")).substring (0, 1))) { -case 0: -params.put ("captureMode", "add"); -this.addImage = false; -this.addTrailer = false; -break; -case 1: -this.addHeader = false; -this.addTrailer = false; -var fps = Math.abs ((params.get ("captureFps")).intValue ()); -this.delayTime100ths = (fps == 0 ? 0 : Clazz.doubleToInt (100 / fps)); -this.looping = (Boolean.FALSE !== params.get ("captureLooping")); -break; -case 2: -this.addHeader = false; -this.addImage = false; -break; -case 3: -this.addHeader = false; -this.addImage = false; -this.out.cancel (); -break; -} -}, "java.util.Map"); -Clazz.overrideMethod (c$, "generate", -function () { -if (this.addHeader) this.writeHeader (); -this.addHeader = false; -if (this.addImage) { -this.createPalette (); -this.writeGraphicControlExtension (); -if (this.delayTime100ths >= 0 && this.looping) this.writeNetscapeLoopExtension (); -this.writeImage (); -}}); -Clazz.overrideMethod (c$, "close", -function () { -if (this.addTrailer) { -this.writeTrailer (); -} else { -this.doClose = false; -}if (this.capturing) this.params.put ("captureByteCount", Integer.$valueOf (this.byteCount)); -}); -Clazz.defineMethod (c$, "createPalette", -($fz = function () { -var tempColors = new javajs.util.Lst (); -var ciHash = new java.util.Hashtable (); -for (var i = 0, n = this.pixels.length; i < n; i++) { -var rgb = this.pixels[i]; -var key = Integer.$valueOf (rgb); -var item = ciHash.get (key); -if (item == null) { -item = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorItem, this, null, rgb, rgb == this.backgroundColor); -ciHash.put (key, item); -tempColors.addLast (item); -}} -var nColors = tempColors.size (); -System.out.println ("GIF total image colors: " + nColors); -ciHash = null; -var cells = this.quantizeColors (tempColors); -nColors = cells.size (); -System.out.println ("GIF final color count: " + nColors); -var colorMap = new java.util.Hashtable (); -this.bitsPerPixel = (nColors <= 2 ? 1 : nColors <= 4 ? 2 : nColors <= 16 ? 4 : 8); -this.palette = new Array (1 << this.bitsPerPixel); -for (var i = 0; i < nColors; i++) { -var c = cells.get (i); -colorMap.put (Integer.$valueOf (javajs.util.CU.colorPtToFFRGB (this.palette[i] = c.setColor ())), c); -} -this.pixels = this.indexPixels (cells, colorMap); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "quantizeColors", -($fz = function (tempColors) { -var n = tempColors.size (); -var cells = new javajs.util.Lst (); -var cc = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, 0); -cc.addLast (Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorItem, this, null, this.backgroundColor, true)); -cells.addLast (cc); -cc = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, 1); -if (n > 256) cells.addLast (cc); -for (var i = 0; i < n; i++) { -var c = tempColors.get (i); -if (c.isBackground) continue; -cc.addLast (c); -if (n <= 256) { -cells.addLast (cc); -cc = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, cells.size ()); -}} -tempColors.clear (); -if (n > 256) while ((n = cells.size ()) < 256) { -var maxVol = 0; -var maxCell = null; -for (var i = n; --i >= 1; ) { -var c = cells.get (i); -var v = c.getVolume (false); -if (v > maxVol) { -maxVol = v; -maxCell = c; -}} -if (maxCell == null || !maxCell.splitCell (cells)) break; -} -return cells; -}, $fz.isPrivate = true, $fz), "javajs.util.Lst"); -Clazz.defineMethod (c$, "indexPixels", -($fz = function (cells, colorMap) { -var w2 = this.width + 2; -var errors = new Array (w2); -var newPixels = Clazz.newIntArray (this.pixels.length, 0); -var err = new javajs.util.P3 (); -var lab; -var rgb; -var nearestCell = new java.util.Hashtable (); -for (var i = 0, p = 0; i < this.height; ++i) { -var notLastRow = (i != this.height - 1); -for (var j = 0; j < this.width; ++j, p++) { -if (this.pixels[p] == this.backgroundColor) { -continue; -}var pe = errors[p % w2]; -if (pe == null || pe.x == 3.4028235E38) { -lab = null; -rgb = this.pixels[p]; -} else { -lab = this.toLABnorm (this.pixels[p]); -err = pe; -err.x = this.clamp (err.x, -75, 75); -err.y = this.clamp (err.y, -75, 75); -err.z = this.clamp (err.z, -75, 75); -lab.add (err); -rgb = javajs.util.CU.colorPtToFFRGB (this.toRGB (lab)); -}var key = Integer.$valueOf (rgb); -var cell = colorMap.get (key); -if (cell == null) { -lab = this.toLABnorm (rgb); -cell = nearestCell.get (key); -if (cell == null) { -var maxerr = 3.4028235E38; -for (var ib = cells.size (); --ib >= 1; ) { -var c = cells.get (ib); -err.sub2 (lab, c.center); -var d = err.lengthSquared (); -if (d < maxerr) { -maxerr = d; -cell = c; -}} -nearestCell.put (key, cell); -}if (this.floydSteinberg) { -err.sub2 (lab, cell.center); -var notLastCol = (j < this.width - 1); -if (notLastCol) this.addError (err, 7, errors, p + 1, w2); -if (notLastRow) { -if (j > 0) this.addError (err, 3, errors, p + this.width - 1, w2); -this.addError (err, 5, errors, p + this.width, w2); -if (notLastCol) this.addError (err, 1, errors, p + this.width + 1, w2); -}}err.x = 3.4028235E38; -}newPixels[p] = cell.index; -} -} -return newPixels; -}, $fz.isPrivate = true, $fz), "javajs.util.Lst,java.util.Map"); -Clazz.defineMethod (c$, "addError", -($fz = function (err, f, errors, p, w2) { -if (this.pixels[p] == this.backgroundColor) return; -p %= w2; -var errp = errors[p]; -if (errp == null) errp = errors[p] = new javajs.util.P3 (); - else if (errp.x == 3.4028235E38) errp.set (0, 0, 0); -errp.scaleAdd2 (f / 16, err, errp); -}, $fz.isPrivate = true, $fz), "javajs.util.P3,~N,~A,~N,~N"); -Clazz.defineMethod (c$, "toLABnorm", -function (rgb) { -var lab = javajs.util.CU.colorPtFromInt (rgb, null); -this.rgbToXyz (lab, lab); -this.xyzToLab (lab, lab); -lab.y = (lab.y + 86.185) / (184.439) * 100; -lab.z = (lab.z + 107.863) / (202.345) * 100; -return lab; -}, "~N"); -Clazz.defineMethod (c$, "toRGB", -function (lab) { -var xyz = javajs.util.P3.newP (lab); -xyz.y = xyz.y / 100 * (184.439) - 86.185; -xyz.z = xyz.z / 100 * (202.345) - 107.863; -this.labToXyz (xyz, xyz); -return this.xyzToRgb (xyz, xyz); -}, "javajs.util.P3"); -Clazz.defineMethod (c$, "rgbToXyz", -function (rgb, xyz) { -if (xyz == null) xyz = new javajs.util.P3 (); -xyz.x = this.sxyz (rgb.x); -xyz.y = this.sxyz (rgb.y); -xyz.z = this.sxyz (rgb.z); -javajs.img.GifEncoder.rgb2xyz.rotate (xyz); -return xyz; -}, "javajs.util.P3,javajs.util.P3"); -Clazz.defineMethod (c$, "sxyz", -($fz = function (x) { -x /= 255; -return (x <= 0.04045 ? x / 12.92 : Math.pow (((x + 0.055) / 1.055), 2.4)) * 100; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "xyzToRgb", -function (xyz, rgb) { -if (rgb == null) rgb = new javajs.util.P3 (); -rgb.setT (xyz); -rgb.scale (0.01); -javajs.img.GifEncoder.xyz2rgb.rotate (rgb); -rgb.x = this.clamp (this.srgb (rgb.x), 0, 255); -rgb.y = this.clamp (this.srgb (rgb.y), 0, 255); -rgb.z = this.clamp (this.srgb (rgb.z), 0, 255); -return rgb; -}, "javajs.util.P3,javajs.util.P3"); -Clazz.defineMethod (c$, "srgb", -($fz = function (x) { -return (x > 0.0031308 ? (1.055 * Math.pow (x, 0.4166666666666667)) - 0.055 : x * 12.92) * 255; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "xyzToLab", -function (xyz, lab) { -if (lab == null) lab = new javajs.util.P3 (); -var x = this.flab (xyz.x / 95.0429); -var y = this.flab (xyz.y / 100); -var z = this.flab (xyz.z / 108.89); -lab.x = (116 * y) - 16; -lab.y = 500 * (x - y); -lab.z = 200 * (y - z); -return lab; -}, "javajs.util.P3,javajs.util.P3"); -Clazz.defineMethod (c$, "flab", -($fz = function (t) { -return (t > 8.85645168E-3 ? Math.pow (t, 0.333333333) : 7.78703704 * t + 0.137931034); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "labToXyz", -function (lab, xyz) { -if (xyz == null) xyz = new javajs.util.P3 (); -xyz.setT (lab); -var y = (xyz.x + 16) / 116; -var x = xyz.y / 500 + y; -var z = y - xyz.z / 200; -xyz.x = this.fxyz (x) * 95.0429; -xyz.y = this.fxyz (y) * 100; -xyz.z = this.fxyz (z) * 108.89; -return xyz; -}, "javajs.util.P3,javajs.util.P3"); -Clazz.defineMethod (c$, "fxyz", -($fz = function (t) { -return (t > 0.206896552 ? t * t * t : 0.128418549 * (t - 0.137931034)); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "clamp", -($fz = function (c, min, max) { -c = (c < min ? min : c > max ? max : c); -return (min == 0 ? Math.round (c) : c); -}, $fz.isPrivate = true, $fz), "~N,~N,~N"); -Clazz.defineMethod (c$, "writeHeader", -($fz = function () { -this.putString ("GIF89a"); -this.putWord (this.width); -this.putWord (this.height); -this.putByte (0); -this.putByte (0); -this.putByte (0); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeGraphicControlExtension", -($fz = function () { -if (this.isTransparent || this.delayTime100ths >= 0) { -this.putByte (0x21); -this.putByte (0xf9); -this.putByte (4); -this.putByte ((this.isTransparent ? 9 : 0) | (this.delayTime100ths > 0 ? 2 : 0)); -this.putWord (this.delayTime100ths > 0 ? this.delayTime100ths : 0); -this.putByte (0); -this.putByte (0); -}}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeNetscapeLoopExtension", -($fz = function () { -this.putByte (0x21); -this.putByte (0xff); -this.putByte (0x0B); -this.putString ("NETSCAPE2.0"); -this.putByte (3); -this.putByte (1); -this.putWord (0); -this.putByte (0); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeImage", -($fz = function () { -this.putByte (0x2C); -this.putWord (0); -this.putWord (0); -this.putWord (this.width); -this.putWord (this.height); -var packedFields = 0x80 | (this.interlaced ? 0x40 : 0) | (this.bitsPerPixel - 1); -this.putByte (packedFields); -var colorMapSize = 1 << this.bitsPerPixel; -var p = new javajs.util.P3 (); -for (var i = 0; i < colorMapSize; i++) { -if (this.palette[i] != null) p = this.palette[i]; -this.putByte (Clazz.floatToInt (p.x)); -this.putByte (Clazz.floatToInt (p.y)); -this.putByte (Clazz.floatToInt (p.z)); -} -this.putByte (this.initCodeSize = (this.bitsPerPixel <= 1 ? 2 : this.bitsPerPixel)); -this.compress (); -this.putByte (0); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeTrailer", -($fz = function () { -this.putByte (0x3B); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "nextPixel", -($fz = function () { -if (this.countDown-- == 0) return -1; -var colorIndex = this.pixels[this.curpt]; -++this.curx; -if (this.curx == this.width) { -this.curx = 0; -if (this.interlaced) this.updateY (javajs.img.GifEncoder.INTERLACE_PARAMS[this.pass], javajs.img.GifEncoder.INTERLACE_PARAMS[this.pass + 4]); - else ++this.cury; -}this.curpt = this.cury * this.width + this.curx; -return colorIndex & 0xff; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "updateY", -($fz = function (yNext, yNew) { -this.cury += yNext; -if (yNew >= 0 && this.cury >= this.height) { -this.cury = yNew; -++this.pass; -}}, $fz.isPrivate = true, $fz), "~N,~N"); -Clazz.defineMethod (c$, "putWord", -($fz = function (w) { -this.putByte (w); -this.putByte (w >> 8); -}, $fz.isPrivate = true, $fz), "~N"); -c$.MAXCODE = Clazz.defineMethod (c$, "MAXCODE", -($fz = function (nBits) { -return (1 << nBits) - 1; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "compress", -($fz = function () { -this.countDown = this.width * this.height; -this.pass = 0; -this.curx = 0; -this.cury = 0; -this.clearFlag = false; -this.nBits = this.initCodeSize + 1; -this.maxcode = javajs.img.GifEncoder.MAXCODE (this.nBits); -this.clearCode = 1 << this.initCodeSize; -this.EOFCode = this.clearCode + 1; -this.freeEnt = this.clearCode + 2; -this.bufPt = 0; -var ent = this.nextPixel (); -var hshift = 0; -var fcode; -for (fcode = this.hsize; fcode < 65536; fcode *= 2) ++hshift; - -hshift = 8 - hshift; -var hsizeReg = this.hsize; -this.clearHash (hsizeReg); -this.output (this.clearCode); -var c; -outer_loop : while ((c = this.nextPixel ()) != -1) { -fcode = (c << this.maxbits) + ent; -var i = (c << hshift) ^ ent; -if (this.htab[i] == fcode) { -ent = this.codetab[i]; -continue; -} else if (this.htab[i] >= 0) { -var disp = hsizeReg - i; -if (i == 0) disp = 1; -do { -if ((i -= disp) < 0) i += hsizeReg; -if (this.htab[i] == fcode) { -ent = this.codetab[i]; -continue outer_loop; -}} while (this.htab[i] >= 0); -}this.output (ent); -ent = c; -if (this.freeEnt < this.maxmaxcode) { -this.codetab[i] = this.freeEnt++; -this.htab[i] = fcode; -} else { -this.clearBlock (); -}} -this.output (ent); -this.output (this.EOFCode); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "output", -($fz = function (code) { -this.curAccum &= this.masks[this.curBits]; -if (this.curBits > 0) this.curAccum |= (code << this.curBits); - else this.curAccum = code; -this.curBits += this.nBits; -while (this.curBits >= 8) { -this.byteOut ((this.curAccum & 0xff)); -this.curAccum >>= 8; -this.curBits -= 8; -} -if (this.freeEnt > this.maxcode || this.clearFlag) { -if (this.clearFlag) { -this.maxcode = javajs.img.GifEncoder.MAXCODE (this.nBits = this.initCodeSize + 1); -this.clearFlag = false; -} else { -++this.nBits; -if (this.nBits == this.maxbits) this.maxcode = this.maxmaxcode; - else this.maxcode = javajs.img.GifEncoder.MAXCODE (this.nBits); -}}if (code == this.EOFCode) { -while (this.curBits > 0) { -this.byteOut ((this.curAccum & 0xff)); -this.curAccum >>= 8; -this.curBits -= 8; -} -this.flushBytes (); -}}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "clearBlock", -($fz = function () { -this.clearHash (this.hsize); -this.freeEnt = this.clearCode + 2; -this.clearFlag = true; -this.output (this.clearCode); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "clearHash", -($fz = function (hsize) { -for (var i = 0; i < hsize; ++i) this.htab[i] = -1; - -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "byteOut", -($fz = function (c) { -this.buf[this.bufPt++] = c; -if (this.bufPt >= 254) this.flushBytes (); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "flushBytes", -function () { -if (this.bufPt > 0) { -this.putByte (this.bufPt); -this.out.write (this.buf, 0, this.bufPt); -this.byteCount += this.bufPt; -this.bufPt = 0; -}}); -c$.$GifEncoder$ColorItem$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.isBackground = false; -Clazz.instantialize (this, arguments); -}, javajs.img.GifEncoder, "ColorItem", javajs.util.P3); -Clazz.makeConstructor (c$, -function (a, b) { -Clazz.superConstructor (this, javajs.img.GifEncoder.ColorItem, []); -this.isBackground = b; -this.setT (this.b$["javajs.img.GifEncoder"].toLABnorm (a)); -}, "~N,~B"); -c$ = Clazz.p0p (); -}; -c$.$GifEncoder$ColorCell$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.index = 0; -this.center = null; -this.volume = 0; -Clazz.instantialize (this, arguments); -}, javajs.img.GifEncoder, "ColorCell", javajs.util.Lst); -Clazz.makeConstructor (c$, -function (a) { -Clazz.superConstructor (this, javajs.img.GifEncoder.ColorCell, []); -this.index = a; -}, "~N"); -Clazz.defineMethod (c$, "getVolume", -function (a) { -if (this.volume != 0) return this.volume; -if (this.size () < 2) return -1; -var b = -2147483647; -var c = 2147483647; -var d = -2147483647; -var e = 2147483647; -var f = -2147483647; -var g = 2147483647; -var h = this.size (); -for (var i = h; --i >= 0; ) { -var j = this.get (i); -if (j.x < c) c = j.x; -if (j.y < e) e = j.y; -if (j.z < g) g = j.z; -if (j.x > b) b = j.x; -if (j.y > d) d = j.y; -if (j.z > f) f = j.z; -} -var j = (b - c); -var k = (d - e); -var l = (f - g); -return this.volume = j * j + k * k + l * l; -}, "~B"); -Clazz.defineMethod (c$, "setColor", -function () { -var a = this.size (); -this.center = new javajs.util.P3 (); -for (var b = a; --b >= 0; ) this.center.add (this.get (b)); - -this.center.scale (1 / a); -return this.b$["javajs.img.GifEncoder"].toRGB (this.center); -}); -Clazz.defineMethod (c$, "splitCell", -function (a) { -var b = this.size (); -if (b < 2) return false; -var c = a.size (); -var d = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, c); -a.addLast (d); -var e = Clazz.newFloatArray (3, 3, 0); -for (var f = 0; f < 3; f++) { -var g = 3.4028235E38; -var h = -3.4028235E38; -for (var i = b; --i >= 0; ) { -var j = this.get (i); -var k = (f == 0 ? j.x : f == 1 ? j.y : j.z); -if (g > k) g = k; -if (h < k) h = k; -} -e[0][f] = g; -e[1][f] = h; -e[2][f] = h - g; -} -var g = e[2]; -var h = (g[0] >= g[1] ? (g[0] >= g[2] ? 0 : 2) : g[1] >= g[2] ? 1 : 2); -var i = e[0][h] + e[2][h] / 2; -this.volume = 0; -switch (h) { -case 0: -for (var j = b; --j >= 0; ) if (this.get (j).x >= i) d.addLast (this.remove (j)); - -break; -case 1: -for (var k = b; --k >= 0; ) if (this.get (k).y >= i) d.addLast (this.remove (k)); - -break; -case 2: -for (var l = this.size (); --l >= 0; ) if (this.get (l).z >= i) d.addLast (this.remove (l)); - -break; -} -return true; -}, "javajs.util.Lst"); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"xyz2rgb", null, -"rgb2xyz", null); -{ -javajs.img.GifEncoder.rgb2xyz = javajs.util.M3.newA9 ( Clazz.newFloatArray (-1, [0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9505])); -javajs.img.GifEncoder.xyz2rgb = javajs.util.M3.newA9 ( Clazz.newFloatArray (-1, [3.2406, -1.5372, -0.4986, -0.9689, 1.8758, 0.0415, 0.0557, -0.204, 1.0570])); -}Clazz.defineStatics (c$, -"EOF", -1, -"INTERLACE_PARAMS", Clazz.newIntArray (-1, [8, 8, 4, 2, 4, 2, 1, 0]), -"BITS", 12, -"HSIZE", 5003); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.ImageEncoder", "javajs.util.Lst", "$.P3"], "javajs.img.GifEncoder", ["java.lang.Boolean", "java.util.Hashtable", "javajs.util.CU", "$.M3"], function () { +c$ = Clazz.decorateAsClass (function () { +this.params = null; +this.palette = null; +this.backgroundColor = 0; +this.interlaced = false; +this.addHeader = true; +this.addImage = true; +this.addTrailer = true; +this.isTransparent = false; +this.floydSteinberg = true; +this.capturing = false; +this.looping = false; +this.delayTime100ths = -1; +this.bitsPerPixel = 1; +this.byteCount = 0; +if (!Clazz.isClassDefined ("javajs.img.GifEncoder.ColorItem")) { +javajs.img.GifEncoder.$GifEncoder$ColorItem$ (); +} +if (!Clazz.isClassDefined ("javajs.img.GifEncoder.ColorCell")) { +javajs.img.GifEncoder.$GifEncoder$ColorCell$ (); +} +this.initCodeSize = 0; +this.curpt = 0; +this.nBits = 0; +this.maxbits = 12; +this.maxcode = 0; +this.maxmaxcode = 4096; +this.htab = null; +this.codetab = null; +this.hsize = 5003; +this.freeEnt = 0; +this.clearFlag = false; +this.clearCode = 0; +this.EOFCode = 0; +this.countDown = 0; +this.pass = 0; +this.curx = 0; +this.cury = 0; +this.curAccum = 0; +this.curBits = 0; +this.masks = null; +this.bufPt = 0; +this.buf = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "GifEncoder", javajs.img.ImageEncoder); +Clazz.prepareFields (c$, function () { +this.htab = Clazz.newIntArray (5003, 0); +this.codetab = Clazz.newIntArray (5003, 0); +this.masks = Clazz.newIntArray (-1, [0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF]); +this.buf = Clazz.newByteArray (256, 0); +}); +Clazz.overrideMethod (c$, "setParams", +function (params) { +this.params = params; +var ic = params.get ("transparentColor"); +if (ic == null) { +ic = params.get ("backgroundColor"); +if (ic != null) this.backgroundColor = ic.intValue (); +} else { +this.backgroundColor = ic.intValue (); +this.isTransparent = true; +}this.interlaced = (Boolean.TRUE === params.get ("interlaced")); +if (params.containsKey ("captureRootExt") || !params.containsKey ("captureMode")) return; +this.interlaced = false; +this.capturing = true; +try { +this.byteCount = (params.get ("captureByteCount")).intValue (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +switch ("maec".indexOf ((params.get ("captureMode")).substring (0, 1))) { +case 0: +params.put ("captureMode", "add"); +this.addImage = false; +this.addTrailer = false; +break; +case 1: +this.addHeader = false; +this.addTrailer = false; +var fps = Math.abs ((params.get ("captureFps")).intValue ()); +this.delayTime100ths = (fps == 0 ? 0 : Clazz.doubleToInt (100 / fps)); +this.looping = (Boolean.FALSE !== params.get ("captureLooping")); +break; +case 2: +this.addHeader = false; +this.addImage = false; +break; +case 3: +this.addHeader = false; +this.addImage = false; +this.out.cancel (); +break; +} +}, "java.util.Map"); +Clazz.overrideMethod (c$, "generate", +function () { +if (this.addHeader) this.writeHeader (); +this.addHeader = false; +if (this.addImage) { +this.createPalette (); +this.writeGraphicControlExtension (); +if (this.delayTime100ths >= 0 && this.looping) this.writeNetscapeLoopExtension (); +this.writeImage (); +}}); +Clazz.overrideMethod (c$, "close", +function () { +if (this.addTrailer) { +this.writeTrailer (); +} else { +this.doClose = false; +}if (this.capturing) this.params.put ("captureByteCount", Integer.$valueOf (this.byteCount)); +}); +Clazz.defineMethod (c$, "createPalette", +($fz = function () { +var tempColors = new javajs.util.Lst (); +var ciHash = new java.util.Hashtable (); +for (var i = 0, n = this.pixels.length; i < n; i++) { +var rgb = this.pixels[i]; +var key = Integer.$valueOf (rgb); +var item = ciHash.get (key); +if (item == null) { +item = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorItem, this, null, rgb, rgb == this.backgroundColor); +ciHash.put (key, item); +tempColors.addLast (item); +}} +var nColors = tempColors.size (); +System.out.println ("GIF total image colors: " + nColors); +ciHash = null; +var cells = this.quantizeColors (tempColors); +nColors = cells.size (); +System.out.println ("GIF final color count: " + nColors); +var colorMap = new java.util.Hashtable (); +this.bitsPerPixel = (nColors <= 2 ? 1 : nColors <= 4 ? 2 : nColors <= 16 ? 4 : 8); +this.palette = new Array (1 << this.bitsPerPixel); +for (var i = 0; i < nColors; i++) { +var c = cells.get (i); +colorMap.put (Integer.$valueOf (javajs.util.CU.colorPtToFFRGB (this.palette[i] = c.setColor ())), c); +} +this.pixels = this.indexPixels (cells, colorMap); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "quantizeColors", +($fz = function (tempColors) { +var n = tempColors.size (); +var cells = new javajs.util.Lst (); +var cc = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, 0); +cc.addLast (Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorItem, this, null, this.backgroundColor, true)); +cells.addLast (cc); +cc = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, 1); +if (n > 256) cells.addLast (cc); +for (var i = 0; i < n; i++) { +var c = tempColors.get (i); +if (c.isBackground) continue; +cc.addLast (c); +if (n <= 256) { +cells.addLast (cc); +cc = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, cells.size ()); +}} +tempColors.clear (); +if (n > 256) while ((n = cells.size ()) < 256) { +var maxVol = 0; +var maxCell = null; +for (var i = n; --i >= 1; ) { +var c = cells.get (i); +var v = c.getVolume (false); +if (v > maxVol) { +maxVol = v; +maxCell = c; +}} +if (maxCell == null || !maxCell.splitCell (cells)) break; +} +return cells; +}, $fz.isPrivate = true, $fz), "javajs.util.Lst"); +Clazz.defineMethod (c$, "indexPixels", +($fz = function (cells, colorMap) { +var w2 = this.width + 2; +var errors = new Array (w2); +var newPixels = Clazz.newIntArray (this.pixels.length, 0); +var err = new javajs.util.P3 (); +var lab; +var rgb; +var nearestCell = new java.util.Hashtable (); +for (var i = 0, p = 0; i < this.height; ++i) { +var notLastRow = (i != this.height - 1); +for (var j = 0; j < this.width; ++j, p++) { +if (this.pixels[p] == this.backgroundColor) { +continue; +}var pe = errors[p % w2]; +if (pe == null || pe.x == 3.4028235E38) { +lab = null; +rgb = this.pixels[p]; +} else { +lab = this.toLABnorm (this.pixels[p]); +err = pe; +err.x = this.clamp (err.x, -75, 75); +err.y = this.clamp (err.y, -75, 75); +err.z = this.clamp (err.z, -75, 75); +lab.add (err); +rgb = javajs.util.CU.colorPtToFFRGB (this.toRGB (lab)); +}var key = Integer.$valueOf (rgb); +var cell = colorMap.get (key); +if (cell == null) { +lab = this.toLABnorm (rgb); +cell = nearestCell.get (key); +if (cell == null) { +var maxerr = 3.4028235E38; +for (var ib = cells.size (); --ib >= 1; ) { +var c = cells.get (ib); +err.sub2 (lab, c.center); +var d = err.lengthSquared (); +if (d < maxerr) { +maxerr = d; +cell = c; +}} +nearestCell.put (key, cell); +}if (this.floydSteinberg) { +err.sub2 (lab, cell.center); +var notLastCol = (j < this.width - 1); +if (notLastCol) this.addError (err, 7, errors, p + 1, w2); +if (notLastRow) { +if (j > 0) this.addError (err, 3, errors, p + this.width - 1, w2); +this.addError (err, 5, errors, p + this.width, w2); +if (notLastCol) this.addError (err, 1, errors, p + this.width + 1, w2); +}}err.x = 3.4028235E38; +}newPixels[p] = cell.index; +} +} +return newPixels; +}, $fz.isPrivate = true, $fz), "javajs.util.Lst,java.util.Map"); +Clazz.defineMethod (c$, "addError", +($fz = function (err, f, errors, p, w2) { +if (this.pixels[p] == this.backgroundColor) return; +p %= w2; +var errp = errors[p]; +if (errp == null) errp = errors[p] = new javajs.util.P3 (); + else if (errp.x == 3.4028235E38) errp.set (0, 0, 0); +errp.scaleAdd2 (f / 16, err, errp); +}, $fz.isPrivate = true, $fz), "javajs.util.P3,~N,~A,~N,~N"); +Clazz.defineMethod (c$, "toLABnorm", +function (rgb) { +var lab = javajs.util.CU.colorPtFromInt (rgb, null); +this.rgbToXyz (lab, lab); +this.xyzToLab (lab, lab); +lab.y = (lab.y + 86.185) / (184.439) * 100; +lab.z = (lab.z + 107.863) / (202.345) * 100; +return lab; +}, "~N"); +Clazz.defineMethod (c$, "toRGB", +function (lab) { +var xyz = javajs.util.P3.newP (lab); +xyz.y = xyz.y / 100 * (184.439) - 86.185; +xyz.z = xyz.z / 100 * (202.345) - 107.863; +this.labToXyz (xyz, xyz); +return this.xyzToRgb (xyz, xyz); +}, "javajs.util.P3"); +Clazz.defineMethod (c$, "rgbToXyz", +function (rgb, xyz) { +if (xyz == null) xyz = new javajs.util.P3 (); +xyz.x = this.sxyz (rgb.x); +xyz.y = this.sxyz (rgb.y); +xyz.z = this.sxyz (rgb.z); +javajs.img.GifEncoder.rgb2xyz.rotate (xyz); +return xyz; +}, "javajs.util.P3,javajs.util.P3"); +Clazz.defineMethod (c$, "sxyz", +($fz = function (x) { +x /= 255; +return (x <= 0.04045 ? x / 12.92 : Math.pow (((x + 0.055) / 1.055), 2.4)) * 100; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "xyzToRgb", +function (xyz, rgb) { +if (rgb == null) rgb = new javajs.util.P3 (); +rgb.setT (xyz); +rgb.scale (0.01); +javajs.img.GifEncoder.xyz2rgb.rotate (rgb); +rgb.x = this.clamp (this.srgb (rgb.x), 0, 255); +rgb.y = this.clamp (this.srgb (rgb.y), 0, 255); +rgb.z = this.clamp (this.srgb (rgb.z), 0, 255); +return rgb; +}, "javajs.util.P3,javajs.util.P3"); +Clazz.defineMethod (c$, "srgb", +($fz = function (x) { +return (x > 0.0031308 ? (1.055 * Math.pow (x, 0.4166666666666667)) - 0.055 : x * 12.92) * 255; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "xyzToLab", +function (xyz, lab) { +if (lab == null) lab = new javajs.util.P3 (); +var x = this.flab (xyz.x / 95.0429); +var y = this.flab (xyz.y / 100); +var z = this.flab (xyz.z / 108.89); +lab.x = (116 * y) - 16; +lab.y = 500 * (x - y); +lab.z = 200 * (y - z); +return lab; +}, "javajs.util.P3,javajs.util.P3"); +Clazz.defineMethod (c$, "flab", +($fz = function (t) { +return (t > 8.85645168E-3 ? Math.pow (t, 0.333333333) : 7.78703704 * t + 0.137931034); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "labToXyz", +function (lab, xyz) { +if (xyz == null) xyz = new javajs.util.P3 (); +xyz.setT (lab); +var y = (xyz.x + 16) / 116; +var x = xyz.y / 500 + y; +var z = y - xyz.z / 200; +xyz.x = this.fxyz (x) * 95.0429; +xyz.y = this.fxyz (y) * 100; +xyz.z = this.fxyz (z) * 108.89; +return xyz; +}, "javajs.util.P3,javajs.util.P3"); +Clazz.defineMethod (c$, "fxyz", +($fz = function (t) { +return (t > 0.206896552 ? t * t * t : 0.128418549 * (t - 0.137931034)); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "clamp", +($fz = function (c, min, max) { +c = (c < min ? min : c > max ? max : c); +return (min == 0 ? Math.round (c) : c); +}, $fz.isPrivate = true, $fz), "~N,~N,~N"); +Clazz.defineMethod (c$, "writeHeader", +($fz = function () { +this.putString ("GIF89a"); +this.putWord (this.width); +this.putWord (this.height); +this.putByte (0); +this.putByte (0); +this.putByte (0); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeGraphicControlExtension", +($fz = function () { +if (this.isTransparent || this.delayTime100ths >= 0) { +this.putByte (0x21); +this.putByte (0xf9); +this.putByte (4); +this.putByte ((this.isTransparent ? 9 : 0) | (this.delayTime100ths > 0 ? 2 : 0)); +this.putWord (this.delayTime100ths > 0 ? this.delayTime100ths : 0); +this.putByte (0); +this.putByte (0); +}}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeNetscapeLoopExtension", +($fz = function () { +this.putByte (0x21); +this.putByte (0xff); +this.putByte (0x0B); +this.putString ("NETSCAPE2.0"); +this.putByte (3); +this.putByte (1); +this.putWord (0); +this.putByte (0); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeImage", +($fz = function () { +this.putByte (0x2C); +this.putWord (0); +this.putWord (0); +this.putWord (this.width); +this.putWord (this.height); +var packedFields = 0x80 | (this.interlaced ? 0x40 : 0) | (this.bitsPerPixel - 1); +this.putByte (packedFields); +var colorMapSize = 1 << this.bitsPerPixel; +var p = new javajs.util.P3 (); +for (var i = 0; i < colorMapSize; i++) { +if (this.palette[i] != null) p = this.palette[i]; +this.putByte (Clazz.floatToInt (p.x)); +this.putByte (Clazz.floatToInt (p.y)); +this.putByte (Clazz.floatToInt (p.z)); +} +this.putByte (this.initCodeSize = (this.bitsPerPixel <= 1 ? 2 : this.bitsPerPixel)); +this.compress (); +this.putByte (0); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeTrailer", +($fz = function () { +this.putByte (0x3B); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "nextPixel", +($fz = function () { +if (this.countDown-- == 0) return -1; +var colorIndex = this.pixels[this.curpt]; +++this.curx; +if (this.curx == this.width) { +this.curx = 0; +if (this.interlaced) this.updateY (javajs.img.GifEncoder.INTERLACE_PARAMS[this.pass], javajs.img.GifEncoder.INTERLACE_PARAMS[this.pass + 4]); + else ++this.cury; +}this.curpt = this.cury * this.width + this.curx; +return colorIndex & 0xff; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "updateY", +($fz = function (yNext, yNew) { +this.cury += yNext; +if (yNew >= 0 && this.cury >= this.height) { +this.cury = yNew; +++this.pass; +}}, $fz.isPrivate = true, $fz), "~N,~N"); +Clazz.defineMethod (c$, "putWord", +($fz = function (w) { +this.putByte (w); +this.putByte (w >> 8); +}, $fz.isPrivate = true, $fz), "~N"); +c$.MAXCODE = Clazz.defineMethod (c$, "MAXCODE", +($fz = function (nBits) { +return (1 << nBits) - 1; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "compress", +($fz = function () { +this.countDown = this.width * this.height; +this.pass = 0; +this.curx = 0; +this.cury = 0; +this.clearFlag = false; +this.nBits = this.initCodeSize + 1; +this.maxcode = javajs.img.GifEncoder.MAXCODE (this.nBits); +this.clearCode = 1 << this.initCodeSize; +this.EOFCode = this.clearCode + 1; +this.freeEnt = this.clearCode + 2; +this.bufPt = 0; +var ent = this.nextPixel (); +var hshift = 0; +var fcode; +for (fcode = this.hsize; fcode < 65536; fcode *= 2) ++hshift; + +hshift = 8 - hshift; +var hsizeReg = this.hsize; +this.clearHash (hsizeReg); +this.output (this.clearCode); +var c; +outer_loop : while ((c = this.nextPixel ()) != -1) { +fcode = (c << this.maxbits) + ent; +var i = (c << hshift) ^ ent; +if (this.htab[i] == fcode) { +ent = this.codetab[i]; +continue; +} else if (this.htab[i] >= 0) { +var disp = hsizeReg - i; +if (i == 0) disp = 1; +do { +if ((i -= disp) < 0) i += hsizeReg; +if (this.htab[i] == fcode) { +ent = this.codetab[i]; +continue outer_loop; +}} while (this.htab[i] >= 0); +}this.output (ent); +ent = c; +if (this.freeEnt < this.maxmaxcode) { +this.codetab[i] = this.freeEnt++; +this.htab[i] = fcode; +} else { +this.clearBlock (); +}} +this.output (ent); +this.output (this.EOFCode); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "output", +($fz = function (code) { +this.curAccum &= this.masks[this.curBits]; +if (this.curBits > 0) this.curAccum |= (code << this.curBits); + else this.curAccum = code; +this.curBits += this.nBits; +while (this.curBits >= 8) { +this.byteOut ((this.curAccum & 0xff)); +this.curAccum >>= 8; +this.curBits -= 8; +} +if (this.freeEnt > this.maxcode || this.clearFlag) { +if (this.clearFlag) { +this.maxcode = javajs.img.GifEncoder.MAXCODE (this.nBits = this.initCodeSize + 1); +this.clearFlag = false; +} else { +++this.nBits; +if (this.nBits == this.maxbits) this.maxcode = this.maxmaxcode; + else this.maxcode = javajs.img.GifEncoder.MAXCODE (this.nBits); +}}if (code == this.EOFCode) { +while (this.curBits > 0) { +this.byteOut ((this.curAccum & 0xff)); +this.curAccum >>= 8; +this.curBits -= 8; +} +this.flushBytes (); +}}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "clearBlock", +($fz = function () { +this.clearHash (this.hsize); +this.freeEnt = this.clearCode + 2; +this.clearFlag = true; +this.output (this.clearCode); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "clearHash", +($fz = function (hsize) { +for (var i = 0; i < hsize; ++i) this.htab[i] = -1; + +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "byteOut", +($fz = function (c) { +this.buf[this.bufPt++] = c; +if (this.bufPt >= 254) this.flushBytes (); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "flushBytes", +function () { +if (this.bufPt > 0) { +this.putByte (this.bufPt); +this.out.write (this.buf, 0, this.bufPt); +this.byteCount += this.bufPt; +this.bufPt = 0; +}}); +c$.$GifEncoder$ColorItem$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.isBackground = false; +Clazz.instantialize (this, arguments); +}, javajs.img.GifEncoder, "ColorItem", javajs.util.P3); +Clazz.makeConstructor (c$, +function (a, b) { +Clazz.superConstructor (this, javajs.img.GifEncoder.ColorItem, []); +this.isBackground = b; +this.setT (this.b$["javajs.img.GifEncoder"].toLABnorm (a)); +}, "~N,~B"); +c$ = Clazz.p0p (); +}; +c$.$GifEncoder$ColorCell$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.index = 0; +this.center = null; +this.volume = 0; +Clazz.instantialize (this, arguments); +}, javajs.img.GifEncoder, "ColorCell", javajs.util.Lst); +Clazz.makeConstructor (c$, +function (a) { +Clazz.superConstructor (this, javajs.img.GifEncoder.ColorCell, []); +this.index = a; +}, "~N"); +Clazz.defineMethod (c$, "getVolume", +function (a) { +if (this.volume != 0) return this.volume; +if (this.size () < 2) return -1; +var b = -2147483647; +var c = 2147483647; +var d = -2147483647; +var e = 2147483647; +var f = -2147483647; +var g = 2147483647; +var h = this.size (); +for (var i = h; --i >= 0; ) { +var j = this.get (i); +if (j.x < c) c = j.x; +if (j.y < e) e = j.y; +if (j.z < g) g = j.z; +if (j.x > b) b = j.x; +if (j.y > d) d = j.y; +if (j.z > f) f = j.z; +} +var j = (b - c); +var k = (d - e); +var l = (f - g); +return this.volume = j * j + k * k + l * l; +}, "~B"); +Clazz.defineMethod (c$, "setColor", +function () { +var a = this.size (); +this.center = new javajs.util.P3 (); +for (var b = a; --b >= 0; ) this.center.add (this.get (b)); + +this.center.scale (1 / a); +return this.b$["javajs.img.GifEncoder"].toRGB (this.center); +}); +Clazz.defineMethod (c$, "splitCell", +function (a) { +var b = this.size (); +if (b < 2) return false; +var c = a.size (); +var d = Clazz.innerTypeInstance (javajs.img.GifEncoder.ColorCell, this, null, c); +a.addLast (d); +var e = Clazz.newFloatArray (3, 3, 0); +for (var f = 0; f < 3; f++) { +var g = 3.4028235E38; +var h = -3.4028235E38; +for (var i = b; --i >= 0; ) { +var j = this.get (i); +var k = (f == 0 ? j.x : f == 1 ? j.y : j.z); +if (g > k) g = k; +if (h < k) h = k; +} +e[0][f] = g; +e[1][f] = h; +e[2][f] = h - g; +} +var g = e[2]; +var h = (g[0] >= g[1] ? (g[0] >= g[2] ? 0 : 2) : g[1] >= g[2] ? 1 : 2); +var i = e[0][h] + e[2][h] / 2; +this.volume = 0; +switch (h) { +case 0: +for (var j = b; --j >= 0; ) if (this.get (j).x >= i) d.addLast (this.remove (j)); + +break; +case 1: +for (var k = b; --k >= 0; ) if (this.get (k).y >= i) d.addLast (this.remove (k)); + +break; +case 2: +for (var l = this.size (); --l >= 0; ) if (this.get (l).z >= i) d.addLast (this.remove (l)); + +break; +} +return true; +}, "javajs.util.Lst"); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"xyz2rgb", null, +"rgb2xyz", null); +{ +javajs.img.GifEncoder.rgb2xyz = javajs.util.M3.newA9 ( Clazz.newFloatArray (-1, [0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9505])); +javajs.img.GifEncoder.xyz2rgb = javajs.util.M3.newA9 ( Clazz.newFloatArray (-1, [3.2406, -1.5372, -0.4986, -0.9689, 1.8758, 0.0415, 0.0557, -0.204, 1.0570])); +}Clazz.defineStatics (c$, +"EOF", -1, +"INTERLACE_PARAMS", Clazz.newIntArray (-1, [8, 8, 4, 2, 4, 2, 1, 0]), +"BITS", 12, +"HSIZE", 5003); +}); diff --git a/bin/javajs/img/ImageEncoder.js b/bin/javajs/img/ImageEncoder.js index a0fc4c0..79e2086 100644 --- a/bin/javajs/img/ImageEncoder.js +++ b/bin/javajs/img/ImageEncoder.js @@ -1,41 +1,41 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.api.GenericImageEncoder"], "javajs.img.ImageEncoder", ["java.lang.Boolean"], function () { -c$ = Clazz.decorateAsClass (function () { -this.out = null; -this.width = -1; -this.height = -1; -this.quality = -1; -this.date = null; -this.logging = false; -this.doClose = true; -this.pixels = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "ImageEncoder", null, javajs.api.GenericImageEncoder); -Clazz.overrideMethod (c$, "createImage", -function (type, out, params) { -this.out = out; -this.logging = (Boolean.TRUE === params.get ("logging")); -this.width = (params.get ("imageWidth")).intValue (); -this.height = (params.get ("imageHeight")).intValue (); -this.pixels = params.get ("imagePixels"); -this.date = params.get ("date"); -var q = params.get ("quality"); -this.quality = (q == null ? -1 : q.intValue ()); -this.setParams (params); -this.generate (); -this.close (); -return this.doClose; -}, "~S,javajs.util.OC,java.util.Map"); -Clazz.defineMethod (c$, "putString", -function (s) { -var b = s.getBytes (); -this.out.write (b, 0, b.length); -}, "~S"); -Clazz.defineMethod (c$, "putByte", -function (b) { -this.out.writeByteAsInt (b); -}, "~N"); -Clazz.defineMethod (c$, "close", -function () { -}); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.api.GenericImageEncoder"], "javajs.img.ImageEncoder", ["java.lang.Boolean"], function () { +c$ = Clazz.decorateAsClass (function () { +this.out = null; +this.width = -1; +this.height = -1; +this.quality = -1; +this.date = null; +this.logging = false; +this.doClose = true; +this.pixels = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "ImageEncoder", null, javajs.api.GenericImageEncoder); +Clazz.overrideMethod (c$, "createImage", +function (type, out, params) { +this.out = out; +this.logging = (Boolean.TRUE === params.get ("logging")); +this.width = (params.get ("imageWidth")).intValue (); +this.height = (params.get ("imageHeight")).intValue (); +this.pixels = params.get ("imagePixels"); +this.date = params.get ("date"); +var q = params.get ("quality"); +this.quality = (q == null ? -1 : q.intValue ()); +this.setParams (params); +this.generate (); +this.close (); +return this.doClose; +}, "~S,javajs.util.OC,java.util.Map"); +Clazz.defineMethod (c$, "putString", +function (s) { +var b = s.getBytes (); +this.out.write (b, 0, b.length); +}, "~S"); +Clazz.defineMethod (c$, "putByte", +function (b) { +this.out.writeByteAsInt (b); +}, "~N"); +Clazz.defineMethod (c$, "close", +function () { +}); +}); diff --git a/bin/javajs/img/Jpg64Encoder.js b/bin/javajs/img/Jpg64Encoder.js index c8eb5d1..2ef2678 100644 --- a/bin/javajs/img/Jpg64Encoder.js +++ b/bin/javajs/img/Jpg64Encoder.js @@ -1,23 +1,23 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.JpgEncoder"], "javajs.img.Jpg64Encoder", ["javajs.util.Base64"], function () { -c$ = Clazz.decorateAsClass (function () { -this.outTemp = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "Jpg64Encoder", javajs.img.JpgEncoder); -Clazz.defineMethod (c$, "setParams", -function (params) { -this.defaultQuality = 75; -this.outTemp = params.remove ("outputChannelTemp"); -Clazz.superCall (this, javajs.img.Jpg64Encoder, "setParams", [params]); -}, "java.util.Map"); -Clazz.defineMethod (c$, "generate", -function () { -var out0 = this.out; -this.out = this.outTemp; -Clazz.superCall (this, javajs.img.Jpg64Encoder, "generate", []); -var bytes = javajs.util.Base64.getBytes64 (this.out.toByteArray ()); -this.outTemp = null; -this.out = out0; -this.out.write (bytes, 0, bytes.length); -}); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.JpgEncoder"], "javajs.img.Jpg64Encoder", ["javajs.util.Base64"], function () { +c$ = Clazz.decorateAsClass (function () { +this.outTemp = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "Jpg64Encoder", javajs.img.JpgEncoder); +Clazz.defineMethod (c$, "setParams", +function (params) { +this.defaultQuality = 75; +this.outTemp = params.remove ("outputChannelTemp"); +Clazz.superCall (this, javajs.img.Jpg64Encoder, "setParams", [params]); +}, "java.util.Map"); +Clazz.defineMethod (c$, "generate", +function () { +var out0 = this.out; +this.out = this.outTemp; +Clazz.superCall (this, javajs.img.Jpg64Encoder, "generate", []); +var bytes = javajs.util.Base64.getBytes64 (this.out.toByteArray ()); +this.outTemp = null; +this.out = out0; +this.out.write (bytes, 0, bytes.length); +}); +}); diff --git a/bin/javajs/img/JpgEncoder.js b/bin/javajs/img/JpgEncoder.js index b13c26f..9edf3b2 100644 --- a/bin/javajs/img/JpgEncoder.js +++ b/bin/javajs/img/JpgEncoder.js @@ -1,753 +1,753 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.ImageEncoder", "javajs.util.AU"], ["javajs.img.DCT", "$.JpgEncoder", "$.JpegObj", "$.Huffman"], null, function () { -c$ = Clazz.decorateAsClass (function () { -this.jpegObj = null; -this.huf = null; -this.dct = null; -this.defaultQuality = 100; -this.applicationTag = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "JpgEncoder", javajs.img.ImageEncoder); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.img.JpgEncoder, []); -}); -Clazz.overrideMethod (c$, "setParams", -function (params) { -if (this.quality <= 0) this.quality = (params.containsKey ("qualityJPG") ? (params.get ("qualityJPG")).intValue () : this.defaultQuality); -this.jpegObj = new javajs.img.JpegObj (); -this.jpegObj.comment = params.get ("comment"); -this.applicationTag = params.get ("jpgAppTag"); -}, "java.util.Map"); -Clazz.overrideMethod (c$, "generate", -function () { -this.jpegObj.imageWidth = this.width; -this.jpegObj.imageHeight = this.height; -this.dct = new javajs.img.DCT (this.quality); -this.huf = new javajs.img.Huffman (this.width, this.height); -if (this.jpegObj == null) return; -this.jpegObj.getYCCArray (this.pixels); -var longState = this.writeHeaders (this.jpegObj, this.dct); -this.writeCompressedData (this.jpegObj, this.dct, this.huf); -this.writeMarker (javajs.img.JpgEncoder.eoi); -if (longState != null) { -var b = longState.getBytes (); -this.out.write (b, 0, b.length); -}}); -Clazz.defineMethod (c$, "writeCompressedData", -($fz = function (jpegObj, dct, huf) { -var i; -var j; -var r; -var c; -var a; -var b; -var comp; -var xpos; -var ypos; -var xblockoffset; -var yblockoffset; -var inputArray; -var dctArray1 = Clazz.newFloatArray (8, 8, 0); -var dctArray2 = Clazz.newDoubleArray (8, 8, 0); -var dctArray3 = Clazz.newIntArray (64, 0); -var lastDCvalue = Clazz.newIntArray (jpegObj.numberOfComponents, 0); -var minBlockWidth; -var minBlockHeight; -minBlockWidth = ((huf.imageWidth % 8 != 0) ? Clazz.doubleToInt (Math.floor (huf.imageWidth / 8.0) + 1) * 8 : huf.imageWidth); -minBlockHeight = ((huf.imageHeight % 8 != 0) ? Clazz.doubleToInt (Math.floor (huf.imageHeight / 8.0) + 1) * 8 : huf.imageHeight); -for (comp = 0; comp < jpegObj.numberOfComponents; comp++) { -minBlockWidth = Math.min (minBlockWidth, jpegObj.blockWidth[comp]); -minBlockHeight = Math.min (minBlockHeight, jpegObj.blockHeight[comp]); -} -xpos = 0; -for (r = 0; r < minBlockHeight; r++) { -for (c = 0; c < minBlockWidth; c++) { -xpos = c * 8; -ypos = r * 8; -for (comp = 0; comp < jpegObj.numberOfComponents; comp++) { -inputArray = jpegObj.components[comp]; -var vsampF = jpegObj.vsampFactor[comp]; -var hsampF = jpegObj.hsampFactor[comp]; -var qNumber = jpegObj.qtableNumber[comp]; -var dcNumber = jpegObj.dctableNumber[comp]; -var acNumber = jpegObj.actableNumber[comp]; -for (i = 0; i < vsampF; i++) { -for (j = 0; j < hsampF; j++) { -xblockoffset = j * 8; -yblockoffset = i * 8; -for (a = 0; a < 8; a++) { -for (b = 0; b < 8; b++) { -dctArray1[a][b] = inputArray[ypos + yblockoffset + a][xpos + xblockoffset + b]; -} -} -dctArray2 = javajs.img.DCT.forwardDCT (dctArray1); -dctArray3 = javajs.img.DCT.quantizeBlock (dctArray2, dct.divisors[qNumber]); -huf.HuffmanBlockEncoder (this.out, dctArray3, lastDCvalue[comp], dcNumber, acNumber); -lastDCvalue[comp] = dctArray3[0]; -} -} -} -} -} -huf.flushBuffer (this.out); -}, $fz.isPrivate = true, $fz), "javajs.img.JpegObj,javajs.img.DCT,javajs.img.Huffman"); -Clazz.defineMethod (c$, "writeHeaders", -($fz = function (jpegObj, dct) { -var i; -var j; -var index; -var offset; -var tempArray; -this.writeMarker (javajs.img.JpgEncoder.soi); -this.writeArray (javajs.img.JpgEncoder.jfif); -var comment = null; -if (jpegObj.comment.length > 0) this.writeString (jpegObj.comment, 0xE1); -this.writeString ("JPEG Encoder Copyright 1998, James R. Weeks and BioElectroMech.\n\n", 0xFE); -var dqt = Clazz.newByteArray (134, 0); -dqt[0] = 0xFF; -dqt[1] = 0xDB; -dqt[2] = 0; -dqt[3] = 132; -offset = 4; -for (i = 0; i < 2; i++) { -dqt[offset++] = ((0) + i); -tempArray = dct.quantum[i]; -for (j = 0; j < 64; j++) { -dqt[offset++] = tempArray[javajs.img.Huffman.jpegNaturalOrder[j]]; -} -} -this.writeArray (dqt); -var sof = Clazz.newByteArray (19, 0); -sof[0] = 0xFF; -sof[1] = 0xC0; -sof[2] = 0; -sof[3] = 17; -sof[4] = jpegObj.precision; -sof[5] = ((jpegObj.imageHeight >> 8) & 0xFF); -sof[6] = ((jpegObj.imageHeight) & 0xFF); -sof[7] = ((jpegObj.imageWidth >> 8) & 0xFF); -sof[8] = ((jpegObj.imageWidth) & 0xFF); -sof[9] = jpegObj.numberOfComponents; -index = 10; -for (i = 0; i < sof[9]; i++) { -sof[index++] = jpegObj.compID[i]; -sof[index++] = ((jpegObj.hsampFactor[i] << 4) + jpegObj.vsampFactor[i]); -sof[index++] = jpegObj.qtableNumber[i]; -} -this.writeArray (sof); -this.WriteDHTHeader (javajs.img.Huffman.bitsDCluminance, javajs.img.Huffman.valDCluminance); -this.WriteDHTHeader (javajs.img.Huffman.bitsACluminance, javajs.img.Huffman.valACluminance); -this.WriteDHTHeader (javajs.img.Huffman.bitsDCchrominance, javajs.img.Huffman.valDCchrominance); -this.WriteDHTHeader (javajs.img.Huffman.bitsACchrominance, javajs.img.Huffman.valACchrominance); -var sos = Clazz.newByteArray (14, 0); -sos[0] = 0xFF; -sos[1] = 0xDA; -sos[2] = 0; -sos[3] = 12; -sos[4] = jpegObj.numberOfComponents; -index = 5; -for (i = 0; i < sos[4]; i++) { -sos[index++] = jpegObj.compID[i]; -sos[index++] = ((jpegObj.dctableNumber[i] << 4) + jpegObj.actableNumber[i]); -} -sos[index++] = jpegObj.ss; -sos[index++] = jpegObj.se; -sos[index++] = ((jpegObj.ah << 4) + jpegObj.al); -this.writeArray (sos); -return comment; -}, $fz.isPrivate = true, $fz), "javajs.img.JpegObj,javajs.img.DCT"); -Clazz.defineMethod (c$, "writeString", -($fz = function (s, id) { -var len = s.length; -var i0 = 0; -var suffix = this.applicationTag; -while (i0 < len) { -var nBytes = len - i0; -if (nBytes > 65510) { -nBytes = 65500; -var pt = s.lastIndexOf ('\n', i0 + nBytes); -if (pt > i0 + 1) nBytes = pt - i0; -}if (i0 + nBytes == len) suffix = ""; -this.writeTag (nBytes + suffix.length, id); -this.writeArray (s.substring (i0, i0 + nBytes).getBytes ()); -if (suffix.length > 0) this.writeArray (suffix.getBytes ()); -i0 += nBytes; -} -}, $fz.isPrivate = true, $fz), "~S,~N"); -Clazz.defineMethod (c$, "writeTag", -($fz = function (length, id) { -length += 2; -var com = Clazz.newByteArray (4, 0); -com[0] = 0xFF; -com[1] = id; -com[2] = ((length >> 8) & 0xFF); -com[3] = (length & 0xFF); -this.writeArray (com); -}, $fz.isPrivate = true, $fz), "~N,~N"); -Clazz.defineMethod (c$, "WriteDHTHeader", -function (bits, val) { -var dht; -var bytes = 0; -for (var j = 1; j < 17; j++) bytes += bits[j]; - -dht = Clazz.newByteArray (21 + bytes, 0); -dht[0] = 0xFF; -dht[1] = 0xC4; -var index = 4; -for (var j = 0; j < 17; j++) dht[index++] = bits[j]; - -for (var j = 0; j < bytes; j++) dht[index++] = val[j]; - -dht[2] = (((index - 2) >> 8) & 0xFF); -dht[3] = ((index - 2) & 0xFF); -this.writeArray (dht); -}, "~A,~A"); -Clazz.defineMethod (c$, "writeMarker", -function (data) { -this.out.write (data, 0, 2); -}, "~A"); -Clazz.defineMethod (c$, "writeArray", -function (data) { -this.out.write (data, 0, data.length); -}, "~A"); -Clazz.defineStatics (c$, -"CONTINUE_MAX", 65500, -"CONTINUE_MAX_BUFFER", 65510, -"eoi", Clazz.newByteArray (-1, [0xFF, 0xD9]), -"jfif", Clazz.newByteArray (-1, [0xff, 0xe0, 0, 16, 0x4a, 0x46, 0x49, 0x46, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0]), -"soi", Clazz.newByteArray (-1, [0xFF, 0xD8])); -c$ = Clazz.decorateAsClass (function () { -this.quantum = null; -this.divisors = null; -this.quantum_luminance = null; -this.DivisorsLuminance = null; -this.quantum_chrominance = null; -this.DivisorsChrominance = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "DCT"); -Clazz.prepareFields (c$, function () { -this.quantum = javajs.util.AU.newInt2 (2); -this.divisors = javajs.util.AU.newDouble2 (2); -this.quantum_luminance = Clazz.newIntArray (64, 0); -this.DivisorsLuminance = Clazz.newDoubleArray (64, 0); -this.quantum_chrominance = Clazz.newIntArray (64, 0); -this.DivisorsChrominance = Clazz.newDoubleArray (64, 0); -}); -Clazz.makeConstructor (c$, -function (quality) { -this.initMatrix (quality); -}, "~N"); -Clazz.defineMethod (c$, "initMatrix", -($fz = function (quality) { -quality = (quality < 1 ? 1 : quality > 100 ? 100 : quality); -quality = (quality < 50 ? Clazz.doubleToInt (5000 / quality) : 200 - quality * 2); -this.quantum_luminance[0] = 16; -this.quantum_luminance[1] = 11; -this.quantum_luminance[2] = 10; -this.quantum_luminance[3] = 16; -this.quantum_luminance[4] = 24; -this.quantum_luminance[5] = 40; -this.quantum_luminance[6] = 51; -this.quantum_luminance[7] = 61; -this.quantum_luminance[8] = 12; -this.quantum_luminance[9] = 12; -this.quantum_luminance[10] = 14; -this.quantum_luminance[11] = 19; -this.quantum_luminance[12] = 26; -this.quantum_luminance[13] = 58; -this.quantum_luminance[14] = 60; -this.quantum_luminance[15] = 55; -this.quantum_luminance[16] = 14; -this.quantum_luminance[17] = 13; -this.quantum_luminance[18] = 16; -this.quantum_luminance[19] = 24; -this.quantum_luminance[20] = 40; -this.quantum_luminance[21] = 57; -this.quantum_luminance[22] = 69; -this.quantum_luminance[23] = 56; -this.quantum_luminance[24] = 14; -this.quantum_luminance[25] = 17; -this.quantum_luminance[26] = 22; -this.quantum_luminance[27] = 29; -this.quantum_luminance[28] = 51; -this.quantum_luminance[29] = 87; -this.quantum_luminance[30] = 80; -this.quantum_luminance[31] = 62; -this.quantum_luminance[32] = 18; -this.quantum_luminance[33] = 22; -this.quantum_luminance[34] = 37; -this.quantum_luminance[35] = 56; -this.quantum_luminance[36] = 68; -this.quantum_luminance[37] = 109; -this.quantum_luminance[38] = 103; -this.quantum_luminance[39] = 77; -this.quantum_luminance[40] = 24; -this.quantum_luminance[41] = 35; -this.quantum_luminance[42] = 55; -this.quantum_luminance[43] = 64; -this.quantum_luminance[44] = 81; -this.quantum_luminance[45] = 104; -this.quantum_luminance[46] = 113; -this.quantum_luminance[47] = 92; -this.quantum_luminance[48] = 49; -this.quantum_luminance[49] = 64; -this.quantum_luminance[50] = 78; -this.quantum_luminance[51] = 87; -this.quantum_luminance[52] = 103; -this.quantum_luminance[53] = 121; -this.quantum_luminance[54] = 120; -this.quantum_luminance[55] = 101; -this.quantum_luminance[56] = 72; -this.quantum_luminance[57] = 92; -this.quantum_luminance[58] = 95; -this.quantum_luminance[59] = 98; -this.quantum_luminance[60] = 112; -this.quantum_luminance[61] = 100; -this.quantum_luminance[62] = 103; -this.quantum_luminance[63] = 99; -javajs.img.DCT.AANscale (this.DivisorsLuminance, this.quantum_luminance, quality); -for (var i = 4; i < 64; i++) this.quantum_chrominance[i] = 99; - -this.quantum_chrominance[0] = 17; -this.quantum_chrominance[1] = 18; -this.quantum_chrominance[2] = 24; -this.quantum_chrominance[3] = 47; -this.quantum_chrominance[8] = 18; -this.quantum_chrominance[9] = 21; -this.quantum_chrominance[10] = 26; -this.quantum_chrominance[11] = 66; -this.quantum_chrominance[16] = 24; -this.quantum_chrominance[17] = 26; -this.quantum_chrominance[18] = 56; -this.quantum_chrominance[24] = 47; -this.quantum_chrominance[25] = 66; -javajs.img.DCT.AANscale (this.DivisorsChrominance, this.quantum_chrominance, quality); -this.quantum[0] = this.quantum_luminance; -this.quantum[1] = this.quantum_chrominance; -this.divisors[0] = this.DivisorsLuminance; -this.divisors[1] = this.DivisorsChrominance; -}, $fz.isPrivate = true, $fz), "~N"); -c$.AANscale = Clazz.defineMethod (c$, "AANscale", -($fz = function (divisors, values, quality) { -for (var j = 0; j < 64; j++) { -var temp = Clazz.doubleToInt ((values[j] * quality + 50) / 100); -values[j] = (temp < 1 ? 1 : temp > 255 ? 255 : temp); -} -for (var i = 0, index = 0; i < 8; i++) for (var j = 0; j < 8; j++, index++) divisors[index] = (0.125 / (values[index] * javajs.img.DCT.AANscaleFactor[i] * javajs.img.DCT.AANscaleFactor[j])); - - -}, $fz.isPrivate = true, $fz), "~A,~A,~N"); -c$.forwardDCT = Clazz.defineMethod (c$, "forwardDCT", -function (input) { -var output = Clazz.newDoubleArray (8, 8, 0); -var tmp0; -var tmp1; -var tmp2; -var tmp3; -var tmp4; -var tmp5; -var tmp6; -var tmp7; -var tmp10; -var tmp11; -var tmp12; -var tmp13; -var z1; -var z2; -var z3; -var z4; -var z5; -var z11; -var z13; -for (var i = 0; i < 8; i++) for (var j = 0; j < 8; j++) output[i][j] = (input[i][j] - 128.0); - - -for (var i = 0; i < 8; i++) { -tmp0 = output[i][0] + output[i][7]; -tmp7 = output[i][0] - output[i][7]; -tmp1 = output[i][1] + output[i][6]; -tmp6 = output[i][1] - output[i][6]; -tmp2 = output[i][2] + output[i][5]; -tmp5 = output[i][2] - output[i][5]; -tmp3 = output[i][3] + output[i][4]; -tmp4 = output[i][3] - output[i][4]; -tmp10 = tmp0 + tmp3; -tmp13 = tmp0 - tmp3; -tmp11 = tmp1 + tmp2; -tmp12 = tmp1 - tmp2; -output[i][0] = tmp10 + tmp11; -output[i][4] = tmp10 - tmp11; -z1 = (tmp12 + tmp13) * 0.707106781; -output[i][2] = tmp13 + z1; -output[i][6] = tmp13 - z1; -tmp10 = tmp4 + tmp5; -tmp11 = tmp5 + tmp6; -tmp12 = tmp6 + tmp7; -z5 = (tmp10 - tmp12) * 0.382683433; -z2 = 0.541196100 * tmp10 + z5; -z4 = 1.306562965 * tmp12 + z5; -z3 = tmp11 * 0.707106781; -z11 = tmp7 + z3; -z13 = tmp7 - z3; -output[i][5] = z13 + z2; -output[i][3] = z13 - z2; -output[i][1] = z11 + z4; -output[i][7] = z11 - z4; -} -for (var i = 0; i < 8; i++) { -tmp0 = output[0][i] + output[7][i]; -tmp7 = output[0][i] - output[7][i]; -tmp1 = output[1][i] + output[6][i]; -tmp6 = output[1][i] - output[6][i]; -tmp2 = output[2][i] + output[5][i]; -tmp5 = output[2][i] - output[5][i]; -tmp3 = output[3][i] + output[4][i]; -tmp4 = output[3][i] - output[4][i]; -tmp10 = tmp0 + tmp3; -tmp13 = tmp0 - tmp3; -tmp11 = tmp1 + tmp2; -tmp12 = tmp1 - tmp2; -output[0][i] = tmp10 + tmp11; -output[4][i] = tmp10 - tmp11; -z1 = (tmp12 + tmp13) * 0.707106781; -output[2][i] = tmp13 + z1; -output[6][i] = tmp13 - z1; -tmp10 = tmp4 + tmp5; -tmp11 = tmp5 + tmp6; -tmp12 = tmp6 + tmp7; -z5 = (tmp10 - tmp12) * 0.382683433; -z2 = 0.541196100 * tmp10 + z5; -z4 = 1.306562965 * tmp12 + z5; -z3 = tmp11 * 0.707106781; -z11 = tmp7 + z3; -z13 = tmp7 - z3; -output[5][i] = z13 + z2; -output[3][i] = z13 - z2; -output[1][i] = z11 + z4; -output[7][i] = z11 - z4; -} -return output; -}, "~A"); -c$.quantizeBlock = Clazz.defineMethod (c$, "quantizeBlock", -function (inputData, divisorsCode) { -var outputData = Clazz.newIntArray (64, 0); -for (var i = 0, index = 0; i < 8; i++) for (var j = 0; j < 8; j++, index++) outputData[index] = (Math.round (inputData[i][j] * divisorsCode[index])); - - -return outputData; -}, "~A,~A"); -Clazz.defineStatics (c$, -"N", 8, -"NN", 64, -"AANscaleFactor", Clazz.newDoubleArray (-1, [1.0, 1.387039845, 1.306562965, 1.175875602, 1.0, 0.785694958, 0.541196100, 0.275899379])); -c$ = Clazz.decorateAsClass (function () { -this.bufferPutBits = 0; -this.bufferPutBuffer = 0; -this.imageHeight = 0; -this.imageWidth = 0; -this.dc_matrix0 = null; -this.ac_matrix0 = null; -this.dc_matrix1 = null; -this.ac_matrix1 = null; -this.dc_matrix = null; -this.ac_matrix = null; -this.numOfDCTables = 0; -this.numOfACTables = 0; -Clazz.instantialize (this, arguments); -}, javajs.img, "Huffman"); -Clazz.makeConstructor (c$, -function (width, height) { -this.initHuf (); -this.imageWidth = width; -this.imageHeight = height; -}, "~N,~N"); -Clazz.defineMethod (c$, "HuffmanBlockEncoder", -function (out, zigzag, prec, dcCode, acCode) { -var temp; -var temp2; -var nbits; -var k; -var r; -var i; -this.numOfDCTables = 2; -this.numOfACTables = 2; -var matrixDC = this.dc_matrix[dcCode]; -var matrixAC = this.ac_matrix[acCode]; -temp = temp2 = zigzag[0] - prec; -if (temp < 0) { -temp = -temp; -temp2--; -}nbits = 0; -while (temp != 0) { -nbits++; -temp >>= 1; -} -this.bufferIt (out, matrixDC[nbits][0], matrixDC[nbits][1]); -if (nbits != 0) { -this.bufferIt (out, temp2, nbits); -}r = 0; -for (k = 1; k < 64; k++) { -if ((temp = zigzag[javajs.img.Huffman.jpegNaturalOrder[k]]) == 0) { -r++; -} else { -while (r > 15) { -this.bufferIt (out, matrixAC[0xF0][0], matrixAC[0xF0][1]); -r -= 16; -} -temp2 = temp; -if (temp < 0) { -temp = -temp; -temp2--; -}nbits = 1; -while ((temp >>= 1) != 0) { -nbits++; -} -i = (r << 4) + nbits; -this.bufferIt (out, matrixAC[i][0], matrixAC[i][1]); -this.bufferIt (out, temp2, nbits); -r = 0; -}} -if (r > 0) { -this.bufferIt (out, matrixAC[0][0], matrixAC[0][1]); -}}, "javajs.util.OC,~A,~N,~N,~N"); -Clazz.defineMethod (c$, "bufferIt", -function (out, code, size) { -var putBuffer = code; -var putBits = this.bufferPutBits; -putBuffer &= (1 << size) - 1; -putBits += size; -putBuffer <<= 24 - putBits; -putBuffer |= this.bufferPutBuffer; -while (putBits >= 8) { -var c = ((putBuffer >> 16) & 0xFF); -out.writeByteAsInt (c); -if (c == 0xFF) { -out.writeByteAsInt (0); -}putBuffer <<= 8; -putBits -= 8; -} -this.bufferPutBuffer = putBuffer; -this.bufferPutBits = putBits; -}, "javajs.util.OC,~N,~N"); -Clazz.defineMethod (c$, "flushBuffer", -function (out) { -var putBuffer = this.bufferPutBuffer; -var putBits = this.bufferPutBits; -while (putBits >= 8) { -var c = ((putBuffer >> 16) & 0xFF); -out.writeByteAsInt (c); -if (c == 0xFF) { -out.writeByteAsInt (0); -}putBuffer <<= 8; -putBits -= 8; -} -if (putBits > 0) { -var c = ((putBuffer >> 16) & 0xFF); -out.writeByteAsInt (c); -}}, "javajs.util.OC"); -Clazz.defineMethod (c$, "initHuf", -($fz = function () { -this.dc_matrix0 = Clazz.newIntArray (12, 2, 0); -this.dc_matrix1 = Clazz.newIntArray (12, 2, 0); -this.ac_matrix0 = Clazz.newIntArray (255, 2, 0); -this.ac_matrix1 = Clazz.newIntArray (255, 2, 0); -this.dc_matrix = javajs.util.AU.newInt3 (2, -1); -this.ac_matrix = javajs.util.AU.newInt3 (2, -1); -var p; -var l; -var i; -var lastp; -var si; -var code; -var huffsize = Clazz.newIntArray (257, 0); -var huffcode = Clazz.newIntArray (257, 0); -p = 0; -for (l = 1; l <= 16; l++) { -for (i = javajs.img.Huffman.bitsDCchrominance[l]; --i >= 0; ) { -huffsize[p++] = l; -} -} -huffsize[p] = 0; -lastp = p; -code = 0; -si = huffsize[0]; -p = 0; -while (huffsize[p] != 0) { -while (huffsize[p] == si) { -huffcode[p++] = code; -code++; -} -code <<= 1; -si++; -} -for (p = 0; p < lastp; p++) { -this.dc_matrix1[javajs.img.Huffman.valDCchrominance[p]][0] = huffcode[p]; -this.dc_matrix1[javajs.img.Huffman.valDCchrominance[p]][1] = huffsize[p]; -} -p = 0; -for (l = 1; l <= 16; l++) { -for (i = javajs.img.Huffman.bitsACchrominance[l]; --i >= 0; ) { -huffsize[p++] = l; -} -} -huffsize[p] = 0; -lastp = p; -code = 0; -si = huffsize[0]; -p = 0; -while (huffsize[p] != 0) { -while (huffsize[p] == si) { -huffcode[p++] = code; -code++; -} -code <<= 1; -si++; -} -for (p = 0; p < lastp; p++) { -this.ac_matrix1[javajs.img.Huffman.valACchrominance[p]][0] = huffcode[p]; -this.ac_matrix1[javajs.img.Huffman.valACchrominance[p]][1] = huffsize[p]; -} -p = 0; -for (l = 1; l <= 16; l++) { -for (i = javajs.img.Huffman.bitsDCluminance[l]; --i >= 0; ) { -huffsize[p++] = l; -} -} -huffsize[p] = 0; -lastp = p; -code = 0; -si = huffsize[0]; -p = 0; -while (huffsize[p] != 0) { -while (huffsize[p] == si) { -huffcode[p++] = code; -code++; -} -code <<= 1; -si++; -} -for (p = 0; p < lastp; p++) { -this.dc_matrix0[javajs.img.Huffman.valDCluminance[p]][0] = huffcode[p]; -this.dc_matrix0[javajs.img.Huffman.valDCluminance[p]][1] = huffsize[p]; -} -p = 0; -for (l = 1; l <= 16; l++) { -for (i = javajs.img.Huffman.bitsACluminance[l]; --i >= 0; ) { -huffsize[p++] = l; -} -} -huffsize[p] = 0; -lastp = p; -code = 0; -si = huffsize[0]; -p = 0; -while (huffsize[p] != 0) { -while (huffsize[p] == si) { -huffcode[p++] = code; -code++; -} -code <<= 1; -si++; -} -for (var q = 0; q < lastp; q++) { -this.ac_matrix0[javajs.img.Huffman.valACluminance[q]][0] = huffcode[q]; -this.ac_matrix0[javajs.img.Huffman.valACluminance[q]][1] = huffsize[q]; -} -this.dc_matrix[0] = this.dc_matrix0; -this.dc_matrix[1] = this.dc_matrix1; -this.ac_matrix[0] = this.ac_matrix0; -this.ac_matrix[1] = this.ac_matrix1; -}, $fz.isPrivate = true, $fz)); -Clazz.defineStatics (c$, -"bitsDCluminance", Clazz.newIntArray (-1, [0x00, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]), -"valDCluminance", Clazz.newIntArray (-1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), -"bitsDCchrominance", Clazz.newIntArray (-1, [0x01, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]), -"valDCchrominance", Clazz.newIntArray (-1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), -"bitsACluminance", Clazz.newIntArray (-1, [0x10, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d]), -"valACluminance", Clazz.newIntArray (-1, [0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa]), -"bitsACchrominance", Clazz.newIntArray (-1, [0x11, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77]), -"valACchrominance", Clazz.newIntArray (-1, [0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa]), -"jpegNaturalOrder", Clazz.newIntArray (-1, [0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63])); -c$ = Clazz.decorateAsClass (function () { -this.comment = null; -this.imageHeight = 0; -this.imageWidth = 0; -this.blockWidth = null; -this.blockHeight = null; -this.precision = 8; -this.numberOfComponents = 3; -this.components = null; -this.compID = null; -this.hsampFactor = null; -this.vsampFactor = null; -this.qtableNumber = null; -this.dctableNumber = null; -this.actableNumber = null; -this.lastColumnIsDummy = null; -this.lastRowIsDummy = null; -this.ss = 0; -this.se = 63; -this.ah = 0; -this.al = 0; -this.compWidth = null; -this.compHeight = null; -this.maxHsampFactor = 0; -this.maxVsampFactor = 0; -Clazz.instantialize (this, arguments); -}, javajs.img, "JpegObj"); -Clazz.prepareFields (c$, function () { -this.compID = Clazz.newIntArray (-1, [1, 2, 3]); -this.hsampFactor = Clazz.newIntArray (-1, [1, 1, 1]); -this.vsampFactor = Clazz.newIntArray (-1, [1, 1, 1]); -this.qtableNumber = Clazz.newIntArray (-1, [0, 1, 1]); -this.dctableNumber = Clazz.newIntArray (-1, [0, 1, 1]); -this.actableNumber = Clazz.newIntArray (-1, [0, 1, 1]); -this.lastColumnIsDummy = Clazz.newBooleanArray (-1, [false, false, false]); -this.lastRowIsDummy = Clazz.newBooleanArray (-1, [false, false, false]); -}); -Clazz.makeConstructor (c$, -function () { -this.components = javajs.util.AU.newFloat3 (this.numberOfComponents, -1); -this.compWidth = Clazz.newIntArray (this.numberOfComponents, 0); -this.compHeight = Clazz.newIntArray (this.numberOfComponents, 0); -this.blockWidth = Clazz.newIntArray (this.numberOfComponents, 0); -this.blockHeight = Clazz.newIntArray (this.numberOfComponents, 0); -}); -Clazz.defineMethod (c$, "getYCCArray", -function (pixels) { -this.maxHsampFactor = 1; -this.maxVsampFactor = 1; -for (var y = 0; y < this.numberOfComponents; y++) { -this.maxHsampFactor = Math.max (this.maxHsampFactor, this.hsampFactor[y]); -this.maxVsampFactor = Math.max (this.maxVsampFactor, this.vsampFactor[y]); -} -for (var y = 0; y < this.numberOfComponents; y++) { -this.compWidth[y] = (Clazz.doubleToInt (((this.imageWidth % 8 != 0) ? (Clazz.doubleToInt (Math.ceil (this.imageWidth / 8.0))) * 8 : this.imageWidth) / this.maxHsampFactor)) * this.hsampFactor[y]; -if (this.compWidth[y] != ((Clazz.doubleToInt (this.imageWidth / this.maxHsampFactor)) * this.hsampFactor[y])) { -this.lastColumnIsDummy[y] = true; -}this.blockWidth[y] = Clazz.doubleToInt (Math.ceil (this.compWidth[y] / 8.0)); -this.compHeight[y] = (Clazz.doubleToInt (((this.imageHeight % 8 != 0) ? (Clazz.doubleToInt (Math.ceil (this.imageHeight / 8.0))) * 8 : this.imageHeight) / this.maxVsampFactor)) * this.vsampFactor[y]; -if (this.compHeight[y] != ((Clazz.doubleToInt (this.imageHeight / this.maxVsampFactor)) * this.vsampFactor[y])) { -this.lastRowIsDummy[y] = true; -}this.blockHeight[y] = Clazz.doubleToInt (Math.ceil (this.compHeight[y] / 8.0)); -} -var Y = Clazz.newFloatArray (this.compHeight[0], this.compWidth[0], 0); -var Cr1 = Clazz.newFloatArray (this.compHeight[0], this.compWidth[0], 0); -var Cb1 = Clazz.newFloatArray (this.compHeight[0], this.compWidth[0], 0); -for (var pt = 0, y = 0; y < this.imageHeight; ++y) { -for (var x = 0; x < this.imageWidth; ++x, pt++) { -var p = pixels[pt]; -var r = ((p >> 16) & 0xff); -var g = ((p >> 8) & 0xff); -var b = (p & 0xff); -Y[y][x] = ((0.299 * r + 0.587 * g + 0.114 * b)); -Cb1[y][x] = 128 + ((-0.16874 * r - 0.33126 * g + 0.5 * b)); -Cr1[y][x] = 128 + ((0.5 * r - 0.41869 * g - 0.08131 * b)); -} -} -this.components[0] = Y; -this.components[1] = Cb1; -this.components[2] = Cr1; -}, "~A"); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.ImageEncoder", "javajs.util.AU"], ["javajs.img.DCT", "$.JpgEncoder", "$.JpegObj", "$.Huffman"], null, function () { +c$ = Clazz.decorateAsClass (function () { +this.jpegObj = null; +this.huf = null; +this.dct = null; +this.defaultQuality = 100; +this.applicationTag = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "JpgEncoder", javajs.img.ImageEncoder); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.img.JpgEncoder, []); +}); +Clazz.overrideMethod (c$, "setParams", +function (params) { +if (this.quality <= 0) this.quality = (params.containsKey ("qualityJPG") ? (params.get ("qualityJPG")).intValue () : this.defaultQuality); +this.jpegObj = new javajs.img.JpegObj (); +this.jpegObj.comment = params.get ("comment"); +this.applicationTag = params.get ("jpgAppTag"); +}, "java.util.Map"); +Clazz.overrideMethod (c$, "generate", +function () { +this.jpegObj.imageWidth = this.width; +this.jpegObj.imageHeight = this.height; +this.dct = new javajs.img.DCT (this.quality); +this.huf = new javajs.img.Huffman (this.width, this.height); +if (this.jpegObj == null) return; +this.jpegObj.getYCCArray (this.pixels); +var longState = this.writeHeaders (this.jpegObj, this.dct); +this.writeCompressedData (this.jpegObj, this.dct, this.huf); +this.writeMarker (javajs.img.JpgEncoder.eoi); +if (longState != null) { +var b = longState.getBytes (); +this.out.write (b, 0, b.length); +}}); +Clazz.defineMethod (c$, "writeCompressedData", +($fz = function (jpegObj, dct, huf) { +var i; +var j; +var r; +var c; +var a; +var b; +var comp; +var xpos; +var ypos; +var xblockoffset; +var yblockoffset; +var inputArray; +var dctArray1 = Clazz.newFloatArray (8, 8, 0); +var dctArray2 = Clazz.newDoubleArray (8, 8, 0); +var dctArray3 = Clazz.newIntArray (64, 0); +var lastDCvalue = Clazz.newIntArray (jpegObj.numberOfComponents, 0); +var minBlockWidth; +var minBlockHeight; +minBlockWidth = ((huf.imageWidth % 8 != 0) ? Clazz.doubleToInt (Math.floor (huf.imageWidth / 8.0) + 1) * 8 : huf.imageWidth); +minBlockHeight = ((huf.imageHeight % 8 != 0) ? Clazz.doubleToInt (Math.floor (huf.imageHeight / 8.0) + 1) * 8 : huf.imageHeight); +for (comp = 0; comp < jpegObj.numberOfComponents; comp++) { +minBlockWidth = Math.min (minBlockWidth, jpegObj.blockWidth[comp]); +minBlockHeight = Math.min (minBlockHeight, jpegObj.blockHeight[comp]); +} +xpos = 0; +for (r = 0; r < minBlockHeight; r++) { +for (c = 0; c < minBlockWidth; c++) { +xpos = c * 8; +ypos = r * 8; +for (comp = 0; comp < jpegObj.numberOfComponents; comp++) { +inputArray = jpegObj.components[comp]; +var vsampF = jpegObj.vsampFactor[comp]; +var hsampF = jpegObj.hsampFactor[comp]; +var qNumber = jpegObj.qtableNumber[comp]; +var dcNumber = jpegObj.dctableNumber[comp]; +var acNumber = jpegObj.actableNumber[comp]; +for (i = 0; i < vsampF; i++) { +for (j = 0; j < hsampF; j++) { +xblockoffset = j * 8; +yblockoffset = i * 8; +for (a = 0; a < 8; a++) { +for (b = 0; b < 8; b++) { +dctArray1[a][b] = inputArray[ypos + yblockoffset + a][xpos + xblockoffset + b]; +} +} +dctArray2 = javajs.img.DCT.forwardDCT (dctArray1); +dctArray3 = javajs.img.DCT.quantizeBlock (dctArray2, dct.divisors[qNumber]); +huf.HuffmanBlockEncoder (this.out, dctArray3, lastDCvalue[comp], dcNumber, acNumber); +lastDCvalue[comp] = dctArray3[0]; +} +} +} +} +} +huf.flushBuffer (this.out); +}, $fz.isPrivate = true, $fz), "javajs.img.JpegObj,javajs.img.DCT,javajs.img.Huffman"); +Clazz.defineMethod (c$, "writeHeaders", +($fz = function (jpegObj, dct) { +var i; +var j; +var index; +var offset; +var tempArray; +this.writeMarker (javajs.img.JpgEncoder.soi); +this.writeArray (javajs.img.JpgEncoder.jfif); +var comment = null; +if (jpegObj.comment.length > 0) this.writeString (jpegObj.comment, 0xE1); +this.writeString ("JPEG Encoder Copyright 1998, James R. Weeks and BioElectroMech.\n\n", 0xFE); +var dqt = Clazz.newByteArray (134, 0); +dqt[0] = 0xFF; +dqt[1] = 0xDB; +dqt[2] = 0; +dqt[3] = 132; +offset = 4; +for (i = 0; i < 2; i++) { +dqt[offset++] = ((0) + i); +tempArray = dct.quantum[i]; +for (j = 0; j < 64; j++) { +dqt[offset++] = tempArray[javajs.img.Huffman.jpegNaturalOrder[j]]; +} +} +this.writeArray (dqt); +var sof = Clazz.newByteArray (19, 0); +sof[0] = 0xFF; +sof[1] = 0xC0; +sof[2] = 0; +sof[3] = 17; +sof[4] = jpegObj.precision; +sof[5] = ((jpegObj.imageHeight >> 8) & 0xFF); +sof[6] = ((jpegObj.imageHeight) & 0xFF); +sof[7] = ((jpegObj.imageWidth >> 8) & 0xFF); +sof[8] = ((jpegObj.imageWidth) & 0xFF); +sof[9] = jpegObj.numberOfComponents; +index = 10; +for (i = 0; i < sof[9]; i++) { +sof[index++] = jpegObj.compID[i]; +sof[index++] = ((jpegObj.hsampFactor[i] << 4) + jpegObj.vsampFactor[i]); +sof[index++] = jpegObj.qtableNumber[i]; +} +this.writeArray (sof); +this.WriteDHTHeader (javajs.img.Huffman.bitsDCluminance, javajs.img.Huffman.valDCluminance); +this.WriteDHTHeader (javajs.img.Huffman.bitsACluminance, javajs.img.Huffman.valACluminance); +this.WriteDHTHeader (javajs.img.Huffman.bitsDCchrominance, javajs.img.Huffman.valDCchrominance); +this.WriteDHTHeader (javajs.img.Huffman.bitsACchrominance, javajs.img.Huffman.valACchrominance); +var sos = Clazz.newByteArray (14, 0); +sos[0] = 0xFF; +sos[1] = 0xDA; +sos[2] = 0; +sos[3] = 12; +sos[4] = jpegObj.numberOfComponents; +index = 5; +for (i = 0; i < sos[4]; i++) { +sos[index++] = jpegObj.compID[i]; +sos[index++] = ((jpegObj.dctableNumber[i] << 4) + jpegObj.actableNumber[i]); +} +sos[index++] = jpegObj.ss; +sos[index++] = jpegObj.se; +sos[index++] = ((jpegObj.ah << 4) + jpegObj.al); +this.writeArray (sos); +return comment; +}, $fz.isPrivate = true, $fz), "javajs.img.JpegObj,javajs.img.DCT"); +Clazz.defineMethod (c$, "writeString", +($fz = function (s, id) { +var len = s.length; +var i0 = 0; +var suffix = this.applicationTag; +while (i0 < len) { +var nBytes = len - i0; +if (nBytes > 65510) { +nBytes = 65500; +var pt = s.lastIndexOf ('\n', i0 + nBytes); +if (pt > i0 + 1) nBytes = pt - i0; +}if (i0 + nBytes == len) suffix = ""; +this.writeTag (nBytes + suffix.length, id); +this.writeArray (s.substring (i0, i0 + nBytes).getBytes ()); +if (suffix.length > 0) this.writeArray (suffix.getBytes ()); +i0 += nBytes; +} +}, $fz.isPrivate = true, $fz), "~S,~N"); +Clazz.defineMethod (c$, "writeTag", +($fz = function (length, id) { +length += 2; +var com = Clazz.newByteArray (4, 0); +com[0] = 0xFF; +com[1] = id; +com[2] = ((length >> 8) & 0xFF); +com[3] = (length & 0xFF); +this.writeArray (com); +}, $fz.isPrivate = true, $fz), "~N,~N"); +Clazz.defineMethod (c$, "WriteDHTHeader", +function (bits, val) { +var dht; +var bytes = 0; +for (var j = 1; j < 17; j++) bytes += bits[j]; + +dht = Clazz.newByteArray (21 + bytes, 0); +dht[0] = 0xFF; +dht[1] = 0xC4; +var index = 4; +for (var j = 0; j < 17; j++) dht[index++] = bits[j]; + +for (var j = 0; j < bytes; j++) dht[index++] = val[j]; + +dht[2] = (((index - 2) >> 8) & 0xFF); +dht[3] = ((index - 2) & 0xFF); +this.writeArray (dht); +}, "~A,~A"); +Clazz.defineMethod (c$, "writeMarker", +function (data) { +this.out.write (data, 0, 2); +}, "~A"); +Clazz.defineMethod (c$, "writeArray", +function (data) { +this.out.write (data, 0, data.length); +}, "~A"); +Clazz.defineStatics (c$, +"CONTINUE_MAX", 65500, +"CONTINUE_MAX_BUFFER", 65510, +"eoi", Clazz.newByteArray (-1, [0xFF, 0xD9]), +"jfif", Clazz.newByteArray (-1, [0xff, 0xe0, 0, 16, 0x4a, 0x46, 0x49, 0x46, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0]), +"soi", Clazz.newByteArray (-1, [0xFF, 0xD8])); +c$ = Clazz.decorateAsClass (function () { +this.quantum = null; +this.divisors = null; +this.quantum_luminance = null; +this.DivisorsLuminance = null; +this.quantum_chrominance = null; +this.DivisorsChrominance = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "DCT"); +Clazz.prepareFields (c$, function () { +this.quantum = javajs.util.AU.newInt2 (2); +this.divisors = javajs.util.AU.newDouble2 (2); +this.quantum_luminance = Clazz.newIntArray (64, 0); +this.DivisorsLuminance = Clazz.newDoubleArray (64, 0); +this.quantum_chrominance = Clazz.newIntArray (64, 0); +this.DivisorsChrominance = Clazz.newDoubleArray (64, 0); +}); +Clazz.makeConstructor (c$, +function (quality) { +this.initMatrix (quality); +}, "~N"); +Clazz.defineMethod (c$, "initMatrix", +($fz = function (quality) { +quality = (quality < 1 ? 1 : quality > 100 ? 100 : quality); +quality = (quality < 50 ? Clazz.doubleToInt (5000 / quality) : 200 - quality * 2); +this.quantum_luminance[0] = 16; +this.quantum_luminance[1] = 11; +this.quantum_luminance[2] = 10; +this.quantum_luminance[3] = 16; +this.quantum_luminance[4] = 24; +this.quantum_luminance[5] = 40; +this.quantum_luminance[6] = 51; +this.quantum_luminance[7] = 61; +this.quantum_luminance[8] = 12; +this.quantum_luminance[9] = 12; +this.quantum_luminance[10] = 14; +this.quantum_luminance[11] = 19; +this.quantum_luminance[12] = 26; +this.quantum_luminance[13] = 58; +this.quantum_luminance[14] = 60; +this.quantum_luminance[15] = 55; +this.quantum_luminance[16] = 14; +this.quantum_luminance[17] = 13; +this.quantum_luminance[18] = 16; +this.quantum_luminance[19] = 24; +this.quantum_luminance[20] = 40; +this.quantum_luminance[21] = 57; +this.quantum_luminance[22] = 69; +this.quantum_luminance[23] = 56; +this.quantum_luminance[24] = 14; +this.quantum_luminance[25] = 17; +this.quantum_luminance[26] = 22; +this.quantum_luminance[27] = 29; +this.quantum_luminance[28] = 51; +this.quantum_luminance[29] = 87; +this.quantum_luminance[30] = 80; +this.quantum_luminance[31] = 62; +this.quantum_luminance[32] = 18; +this.quantum_luminance[33] = 22; +this.quantum_luminance[34] = 37; +this.quantum_luminance[35] = 56; +this.quantum_luminance[36] = 68; +this.quantum_luminance[37] = 109; +this.quantum_luminance[38] = 103; +this.quantum_luminance[39] = 77; +this.quantum_luminance[40] = 24; +this.quantum_luminance[41] = 35; +this.quantum_luminance[42] = 55; +this.quantum_luminance[43] = 64; +this.quantum_luminance[44] = 81; +this.quantum_luminance[45] = 104; +this.quantum_luminance[46] = 113; +this.quantum_luminance[47] = 92; +this.quantum_luminance[48] = 49; +this.quantum_luminance[49] = 64; +this.quantum_luminance[50] = 78; +this.quantum_luminance[51] = 87; +this.quantum_luminance[52] = 103; +this.quantum_luminance[53] = 121; +this.quantum_luminance[54] = 120; +this.quantum_luminance[55] = 101; +this.quantum_luminance[56] = 72; +this.quantum_luminance[57] = 92; +this.quantum_luminance[58] = 95; +this.quantum_luminance[59] = 98; +this.quantum_luminance[60] = 112; +this.quantum_luminance[61] = 100; +this.quantum_luminance[62] = 103; +this.quantum_luminance[63] = 99; +javajs.img.DCT.AANscale (this.DivisorsLuminance, this.quantum_luminance, quality); +for (var i = 4; i < 64; i++) this.quantum_chrominance[i] = 99; + +this.quantum_chrominance[0] = 17; +this.quantum_chrominance[1] = 18; +this.quantum_chrominance[2] = 24; +this.quantum_chrominance[3] = 47; +this.quantum_chrominance[8] = 18; +this.quantum_chrominance[9] = 21; +this.quantum_chrominance[10] = 26; +this.quantum_chrominance[11] = 66; +this.quantum_chrominance[16] = 24; +this.quantum_chrominance[17] = 26; +this.quantum_chrominance[18] = 56; +this.quantum_chrominance[24] = 47; +this.quantum_chrominance[25] = 66; +javajs.img.DCT.AANscale (this.DivisorsChrominance, this.quantum_chrominance, quality); +this.quantum[0] = this.quantum_luminance; +this.quantum[1] = this.quantum_chrominance; +this.divisors[0] = this.DivisorsLuminance; +this.divisors[1] = this.DivisorsChrominance; +}, $fz.isPrivate = true, $fz), "~N"); +c$.AANscale = Clazz.defineMethod (c$, "AANscale", +($fz = function (divisors, values, quality) { +for (var j = 0; j < 64; j++) { +var temp = Clazz.doubleToInt ((values[j] * quality + 50) / 100); +values[j] = (temp < 1 ? 1 : temp > 255 ? 255 : temp); +} +for (var i = 0, index = 0; i < 8; i++) for (var j = 0; j < 8; j++, index++) divisors[index] = (0.125 / (values[index] * javajs.img.DCT.AANscaleFactor[i] * javajs.img.DCT.AANscaleFactor[j])); + + +}, $fz.isPrivate = true, $fz), "~A,~A,~N"); +c$.forwardDCT = Clazz.defineMethod (c$, "forwardDCT", +function (input) { +var output = Clazz.newDoubleArray (8, 8, 0); +var tmp0; +var tmp1; +var tmp2; +var tmp3; +var tmp4; +var tmp5; +var tmp6; +var tmp7; +var tmp10; +var tmp11; +var tmp12; +var tmp13; +var z1; +var z2; +var z3; +var z4; +var z5; +var z11; +var z13; +for (var i = 0; i < 8; i++) for (var j = 0; j < 8; j++) output[i][j] = (input[i][j] - 128.0); + + +for (var i = 0; i < 8; i++) { +tmp0 = output[i][0] + output[i][7]; +tmp7 = output[i][0] - output[i][7]; +tmp1 = output[i][1] + output[i][6]; +tmp6 = output[i][1] - output[i][6]; +tmp2 = output[i][2] + output[i][5]; +tmp5 = output[i][2] - output[i][5]; +tmp3 = output[i][3] + output[i][4]; +tmp4 = output[i][3] - output[i][4]; +tmp10 = tmp0 + tmp3; +tmp13 = tmp0 - tmp3; +tmp11 = tmp1 + tmp2; +tmp12 = tmp1 - tmp2; +output[i][0] = tmp10 + tmp11; +output[i][4] = tmp10 - tmp11; +z1 = (tmp12 + tmp13) * 0.707106781; +output[i][2] = tmp13 + z1; +output[i][6] = tmp13 - z1; +tmp10 = tmp4 + tmp5; +tmp11 = tmp5 + tmp6; +tmp12 = tmp6 + tmp7; +z5 = (tmp10 - tmp12) * 0.382683433; +z2 = 0.541196100 * tmp10 + z5; +z4 = 1.306562965 * tmp12 + z5; +z3 = tmp11 * 0.707106781; +z11 = tmp7 + z3; +z13 = tmp7 - z3; +output[i][5] = z13 + z2; +output[i][3] = z13 - z2; +output[i][1] = z11 + z4; +output[i][7] = z11 - z4; +} +for (var i = 0; i < 8; i++) { +tmp0 = output[0][i] + output[7][i]; +tmp7 = output[0][i] - output[7][i]; +tmp1 = output[1][i] + output[6][i]; +tmp6 = output[1][i] - output[6][i]; +tmp2 = output[2][i] + output[5][i]; +tmp5 = output[2][i] - output[5][i]; +tmp3 = output[3][i] + output[4][i]; +tmp4 = output[3][i] - output[4][i]; +tmp10 = tmp0 + tmp3; +tmp13 = tmp0 - tmp3; +tmp11 = tmp1 + tmp2; +tmp12 = tmp1 - tmp2; +output[0][i] = tmp10 + tmp11; +output[4][i] = tmp10 - tmp11; +z1 = (tmp12 + tmp13) * 0.707106781; +output[2][i] = tmp13 + z1; +output[6][i] = tmp13 - z1; +tmp10 = tmp4 + tmp5; +tmp11 = tmp5 + tmp6; +tmp12 = tmp6 + tmp7; +z5 = (tmp10 - tmp12) * 0.382683433; +z2 = 0.541196100 * tmp10 + z5; +z4 = 1.306562965 * tmp12 + z5; +z3 = tmp11 * 0.707106781; +z11 = tmp7 + z3; +z13 = tmp7 - z3; +output[5][i] = z13 + z2; +output[3][i] = z13 - z2; +output[1][i] = z11 + z4; +output[7][i] = z11 - z4; +} +return output; +}, "~A"); +c$.quantizeBlock = Clazz.defineMethod (c$, "quantizeBlock", +function (inputData, divisorsCode) { +var outputData = Clazz.newIntArray (64, 0); +for (var i = 0, index = 0; i < 8; i++) for (var j = 0; j < 8; j++, index++) outputData[index] = (Math.round (inputData[i][j] * divisorsCode[index])); + + +return outputData; +}, "~A,~A"); +Clazz.defineStatics (c$, +"N", 8, +"NN", 64, +"AANscaleFactor", Clazz.newDoubleArray (-1, [1.0, 1.387039845, 1.306562965, 1.175875602, 1.0, 0.785694958, 0.541196100, 0.275899379])); +c$ = Clazz.decorateAsClass (function () { +this.bufferPutBits = 0; +this.bufferPutBuffer = 0; +this.imageHeight = 0; +this.imageWidth = 0; +this.dc_matrix0 = null; +this.ac_matrix0 = null; +this.dc_matrix1 = null; +this.ac_matrix1 = null; +this.dc_matrix = null; +this.ac_matrix = null; +this.numOfDCTables = 0; +this.numOfACTables = 0; +Clazz.instantialize (this, arguments); +}, javajs.img, "Huffman"); +Clazz.makeConstructor (c$, +function (width, height) { +this.initHuf (); +this.imageWidth = width; +this.imageHeight = height; +}, "~N,~N"); +Clazz.defineMethod (c$, "HuffmanBlockEncoder", +function (out, zigzag, prec, dcCode, acCode) { +var temp; +var temp2; +var nbits; +var k; +var r; +var i; +this.numOfDCTables = 2; +this.numOfACTables = 2; +var matrixDC = this.dc_matrix[dcCode]; +var matrixAC = this.ac_matrix[acCode]; +temp = temp2 = zigzag[0] - prec; +if (temp < 0) { +temp = -temp; +temp2--; +}nbits = 0; +while (temp != 0) { +nbits++; +temp >>= 1; +} +this.bufferIt (out, matrixDC[nbits][0], matrixDC[nbits][1]); +if (nbits != 0) { +this.bufferIt (out, temp2, nbits); +}r = 0; +for (k = 1; k < 64; k++) { +if ((temp = zigzag[javajs.img.Huffman.jpegNaturalOrder[k]]) == 0) { +r++; +} else { +while (r > 15) { +this.bufferIt (out, matrixAC[0xF0][0], matrixAC[0xF0][1]); +r -= 16; +} +temp2 = temp; +if (temp < 0) { +temp = -temp; +temp2--; +}nbits = 1; +while ((temp >>= 1) != 0) { +nbits++; +} +i = (r << 4) + nbits; +this.bufferIt (out, matrixAC[i][0], matrixAC[i][1]); +this.bufferIt (out, temp2, nbits); +r = 0; +}} +if (r > 0) { +this.bufferIt (out, matrixAC[0][0], matrixAC[0][1]); +}}, "javajs.util.OC,~A,~N,~N,~N"); +Clazz.defineMethod (c$, "bufferIt", +function (out, code, size) { +var putBuffer = code; +var putBits = this.bufferPutBits; +putBuffer &= (1 << size) - 1; +putBits += size; +putBuffer <<= 24 - putBits; +putBuffer |= this.bufferPutBuffer; +while (putBits >= 8) { +var c = ((putBuffer >> 16) & 0xFF); +out.writeByteAsInt (c); +if (c == 0xFF) { +out.writeByteAsInt (0); +}putBuffer <<= 8; +putBits -= 8; +} +this.bufferPutBuffer = putBuffer; +this.bufferPutBits = putBits; +}, "javajs.util.OC,~N,~N"); +Clazz.defineMethod (c$, "flushBuffer", +function (out) { +var putBuffer = this.bufferPutBuffer; +var putBits = this.bufferPutBits; +while (putBits >= 8) { +var c = ((putBuffer >> 16) & 0xFF); +out.writeByteAsInt (c); +if (c == 0xFF) { +out.writeByteAsInt (0); +}putBuffer <<= 8; +putBits -= 8; +} +if (putBits > 0) { +var c = ((putBuffer >> 16) & 0xFF); +out.writeByteAsInt (c); +}}, "javajs.util.OC"); +Clazz.defineMethod (c$, "initHuf", +($fz = function () { +this.dc_matrix0 = Clazz.newIntArray (12, 2, 0); +this.dc_matrix1 = Clazz.newIntArray (12, 2, 0); +this.ac_matrix0 = Clazz.newIntArray (255, 2, 0); +this.ac_matrix1 = Clazz.newIntArray (255, 2, 0); +this.dc_matrix = javajs.util.AU.newInt3 (2, -1); +this.ac_matrix = javajs.util.AU.newInt3 (2, -1); +var p; +var l; +var i; +var lastp; +var si; +var code; +var huffsize = Clazz.newIntArray (257, 0); +var huffcode = Clazz.newIntArray (257, 0); +p = 0; +for (l = 1; l <= 16; l++) { +for (i = javajs.img.Huffman.bitsDCchrominance[l]; --i >= 0; ) { +huffsize[p++] = l; +} +} +huffsize[p] = 0; +lastp = p; +code = 0; +si = huffsize[0]; +p = 0; +while (huffsize[p] != 0) { +while (huffsize[p] == si) { +huffcode[p++] = code; +code++; +} +code <<= 1; +si++; +} +for (p = 0; p < lastp; p++) { +this.dc_matrix1[javajs.img.Huffman.valDCchrominance[p]][0] = huffcode[p]; +this.dc_matrix1[javajs.img.Huffman.valDCchrominance[p]][1] = huffsize[p]; +} +p = 0; +for (l = 1; l <= 16; l++) { +for (i = javajs.img.Huffman.bitsACchrominance[l]; --i >= 0; ) { +huffsize[p++] = l; +} +} +huffsize[p] = 0; +lastp = p; +code = 0; +si = huffsize[0]; +p = 0; +while (huffsize[p] != 0) { +while (huffsize[p] == si) { +huffcode[p++] = code; +code++; +} +code <<= 1; +si++; +} +for (p = 0; p < lastp; p++) { +this.ac_matrix1[javajs.img.Huffman.valACchrominance[p]][0] = huffcode[p]; +this.ac_matrix1[javajs.img.Huffman.valACchrominance[p]][1] = huffsize[p]; +} +p = 0; +for (l = 1; l <= 16; l++) { +for (i = javajs.img.Huffman.bitsDCluminance[l]; --i >= 0; ) { +huffsize[p++] = l; +} +} +huffsize[p] = 0; +lastp = p; +code = 0; +si = huffsize[0]; +p = 0; +while (huffsize[p] != 0) { +while (huffsize[p] == si) { +huffcode[p++] = code; +code++; +} +code <<= 1; +si++; +} +for (p = 0; p < lastp; p++) { +this.dc_matrix0[javajs.img.Huffman.valDCluminance[p]][0] = huffcode[p]; +this.dc_matrix0[javajs.img.Huffman.valDCluminance[p]][1] = huffsize[p]; +} +p = 0; +for (l = 1; l <= 16; l++) { +for (i = javajs.img.Huffman.bitsACluminance[l]; --i >= 0; ) { +huffsize[p++] = l; +} +} +huffsize[p] = 0; +lastp = p; +code = 0; +si = huffsize[0]; +p = 0; +while (huffsize[p] != 0) { +while (huffsize[p] == si) { +huffcode[p++] = code; +code++; +} +code <<= 1; +si++; +} +for (var q = 0; q < lastp; q++) { +this.ac_matrix0[javajs.img.Huffman.valACluminance[q]][0] = huffcode[q]; +this.ac_matrix0[javajs.img.Huffman.valACluminance[q]][1] = huffsize[q]; +} +this.dc_matrix[0] = this.dc_matrix0; +this.dc_matrix[1] = this.dc_matrix1; +this.ac_matrix[0] = this.ac_matrix0; +this.ac_matrix[1] = this.ac_matrix1; +}, $fz.isPrivate = true, $fz)); +Clazz.defineStatics (c$, +"bitsDCluminance", Clazz.newIntArray (-1, [0x00, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]), +"valDCluminance", Clazz.newIntArray (-1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), +"bitsDCchrominance", Clazz.newIntArray (-1, [0x01, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]), +"valDCchrominance", Clazz.newIntArray (-1, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]), +"bitsACluminance", Clazz.newIntArray (-1, [0x10, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d]), +"valACluminance", Clazz.newIntArray (-1, [0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa]), +"bitsACchrominance", Clazz.newIntArray (-1, [0x11, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77]), +"valACchrominance", Clazz.newIntArray (-1, [0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa]), +"jpegNaturalOrder", Clazz.newIntArray (-1, [0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63])); +c$ = Clazz.decorateAsClass (function () { +this.comment = null; +this.imageHeight = 0; +this.imageWidth = 0; +this.blockWidth = null; +this.blockHeight = null; +this.precision = 8; +this.numberOfComponents = 3; +this.components = null; +this.compID = null; +this.hsampFactor = null; +this.vsampFactor = null; +this.qtableNumber = null; +this.dctableNumber = null; +this.actableNumber = null; +this.lastColumnIsDummy = null; +this.lastRowIsDummy = null; +this.ss = 0; +this.se = 63; +this.ah = 0; +this.al = 0; +this.compWidth = null; +this.compHeight = null; +this.maxHsampFactor = 0; +this.maxVsampFactor = 0; +Clazz.instantialize (this, arguments); +}, javajs.img, "JpegObj"); +Clazz.prepareFields (c$, function () { +this.compID = Clazz.newIntArray (-1, [1, 2, 3]); +this.hsampFactor = Clazz.newIntArray (-1, [1, 1, 1]); +this.vsampFactor = Clazz.newIntArray (-1, [1, 1, 1]); +this.qtableNumber = Clazz.newIntArray (-1, [0, 1, 1]); +this.dctableNumber = Clazz.newIntArray (-1, [0, 1, 1]); +this.actableNumber = Clazz.newIntArray (-1, [0, 1, 1]); +this.lastColumnIsDummy = Clazz.newBooleanArray (-1, [false, false, false]); +this.lastRowIsDummy = Clazz.newBooleanArray (-1, [false, false, false]); +}); +Clazz.makeConstructor (c$, +function () { +this.components = javajs.util.AU.newFloat3 (this.numberOfComponents, -1); +this.compWidth = Clazz.newIntArray (this.numberOfComponents, 0); +this.compHeight = Clazz.newIntArray (this.numberOfComponents, 0); +this.blockWidth = Clazz.newIntArray (this.numberOfComponents, 0); +this.blockHeight = Clazz.newIntArray (this.numberOfComponents, 0); +}); +Clazz.defineMethod (c$, "getYCCArray", +function (pixels) { +this.maxHsampFactor = 1; +this.maxVsampFactor = 1; +for (var y = 0; y < this.numberOfComponents; y++) { +this.maxHsampFactor = Math.max (this.maxHsampFactor, this.hsampFactor[y]); +this.maxVsampFactor = Math.max (this.maxVsampFactor, this.vsampFactor[y]); +} +for (var y = 0; y < this.numberOfComponents; y++) { +this.compWidth[y] = (Clazz.doubleToInt (((this.imageWidth % 8 != 0) ? (Clazz.doubleToInt (Math.ceil (this.imageWidth / 8.0))) * 8 : this.imageWidth) / this.maxHsampFactor)) * this.hsampFactor[y]; +if (this.compWidth[y] != ((Clazz.doubleToInt (this.imageWidth / this.maxHsampFactor)) * this.hsampFactor[y])) { +this.lastColumnIsDummy[y] = true; +}this.blockWidth[y] = Clazz.doubleToInt (Math.ceil (this.compWidth[y] / 8.0)); +this.compHeight[y] = (Clazz.doubleToInt (((this.imageHeight % 8 != 0) ? (Clazz.doubleToInt (Math.ceil (this.imageHeight / 8.0))) * 8 : this.imageHeight) / this.maxVsampFactor)) * this.vsampFactor[y]; +if (this.compHeight[y] != ((Clazz.doubleToInt (this.imageHeight / this.maxVsampFactor)) * this.vsampFactor[y])) { +this.lastRowIsDummy[y] = true; +}this.blockHeight[y] = Clazz.doubleToInt (Math.ceil (this.compHeight[y] / 8.0)); +} +var Y = Clazz.newFloatArray (this.compHeight[0], this.compWidth[0], 0); +var Cr1 = Clazz.newFloatArray (this.compHeight[0], this.compWidth[0], 0); +var Cb1 = Clazz.newFloatArray (this.compHeight[0], this.compWidth[0], 0); +for (var pt = 0, y = 0; y < this.imageHeight; ++y) { +for (var x = 0; x < this.imageWidth; ++x, pt++) { +var p = pixels[pt]; +var r = ((p >> 16) & 0xff); +var g = ((p >> 8) & 0xff); +var b = (p & 0xff); +Y[y][x] = ((0.299 * r + 0.587 * g + 0.114 * b)); +Cb1[y][x] = 128 + ((-0.16874 * r - 0.33126 * g + 0.5 * b)); +Cr1[y][x] = 128 + ((0.5 * r - 0.41869 * g - 0.08131 * b)); +} +} +this.components[0] = Y; +this.components[1] = Cb1; +this.components[2] = Cr1; +}, "~A"); +}); diff --git a/bin/javajs/img/PdfEncoder.js b/bin/javajs/img/PdfEncoder.js index 664879f..0a468dc 100644 --- a/bin/javajs/img/PdfEncoder.js +++ b/bin/javajs/img/PdfEncoder.js @@ -1,58 +1,58 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PdfEncoder", ["java.util.Hashtable", "javajs.export.PDFCreator"], function () { -c$ = Clazz.decorateAsClass (function () { -this.isLandscape = false; -this.pdf = null; -this.comment = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "PdfEncoder", javajs.img.ImageEncoder); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.img.PdfEncoder, []); -}); -Clazz.overrideMethod (c$, "setParams", -function (params) { -this.isLandscape = (this.quality > 1); -this.comment = "Jmol " + params.get ("comment"); -}, "java.util.Map"); -Clazz.overrideMethod (c$, "generate", -function () { -this.pdf = new javajs["export"].PDFCreator (); -var pageWidth = 576; -var pageHeight = 792; -this.pdf.setOutputStream (this.out); -this.pdf.newDocument (pageWidth, pageHeight, this.isLandscape); -this.addMyImage (pageWidth, pageHeight); -var ht = new java.util.Hashtable (); -if (this.comment != null) ht.put ("Producer", this.comment); -ht.put ("Author", "JMol"); -ht.put ("CreationDate", this.date); -this.pdf.addInfo (ht); -this.pdf.closeDocument (); -}); -Clazz.defineMethod (c$, "addMyImage", -($fz = function (pageWidth, pageHeight) { -this.pdf.addImageResource ("img1", this.width, this.height, this.pixels, true); -var w = (this.isLandscape ? pageHeight : pageWidth); -var h = (this.isLandscape ? pageWidth : pageHeight); -var iw = this.width; -var ih = this.height; -if (iw > 0.9 * w) { -ih = Clazz.doubleToInt (ih * 0.9 * w / iw); -iw = Clazz.doubleToInt (w * 0.9); -}if (ih > 0.9 * h) { -iw = Clazz.doubleToInt (iw * 0.9 * h / ih); -ih = Clazz.doubleToInt (h * 0.9); -}var x = 0; -var y = 0; -var x1 = iw; -var y1 = ih; -if (w > iw) { -x = Clazz.doubleToInt ((w - iw) / 2); -x1 = iw + x; -}if (h > ih) { -y = Clazz.doubleToInt ((h - ih) / 2); -y1 = ih + y; -}this.pdf.drawImage ("img1", x, y, x1, y1, 0, 0, this.width, this.height); -}, $fz.isPrivate = true, $fz), "~N,~N"); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PdfEncoder", ["java.util.Hashtable", "javajs.export.PDFCreator"], function () { +c$ = Clazz.decorateAsClass (function () { +this.isLandscape = false; +this.pdf = null; +this.comment = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "PdfEncoder", javajs.img.ImageEncoder); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.img.PdfEncoder, []); +}); +Clazz.overrideMethod (c$, "setParams", +function (params) { +this.isLandscape = (this.quality > 1); +this.comment = "Jmol " + params.get ("comment"); +}, "java.util.Map"); +Clazz.overrideMethod (c$, "generate", +function () { +this.pdf = new javajs["export"].PDFCreator (); +var pageWidth = 576; +var pageHeight = 792; +this.pdf.setOutputStream (this.out); +this.pdf.newDocument (pageWidth, pageHeight, this.isLandscape); +this.addMyImage (pageWidth, pageHeight); +var ht = new java.util.Hashtable (); +if (this.comment != null) ht.put ("Producer", this.comment); +ht.put ("Author", "JMol"); +ht.put ("CreationDate", this.date); +this.pdf.addInfo (ht); +this.pdf.closeDocument (); +}); +Clazz.defineMethod (c$, "addMyImage", +($fz = function (pageWidth, pageHeight) { +this.pdf.addImageResource ("img1", this.width, this.height, this.pixels, true); +var w = (this.isLandscape ? pageHeight : pageWidth); +var h = (this.isLandscape ? pageWidth : pageHeight); +var iw = this.width; +var ih = this.height; +if (iw > 0.9 * w) { +ih = Clazz.doubleToInt (ih * 0.9 * w / iw); +iw = Clazz.doubleToInt (w * 0.9); +}if (ih > 0.9 * h) { +iw = Clazz.doubleToInt (iw * 0.9 * h / ih); +ih = Clazz.doubleToInt (h * 0.9); +}var x = 0; +var y = 0; +var x1 = iw; +var y1 = ih; +if (w > iw) { +x = Clazz.doubleToInt ((w - iw) / 2); +x1 = iw + x; +}if (h > ih) { +y = Clazz.doubleToInt ((h - ih) / 2); +y1 = ih + y; +}this.pdf.drawImage ("img1", x, y, x1, y1, 0, 0, this.width, this.height); +}, $fz.isPrivate = true, $fz), "~N,~N"); +}); diff --git a/bin/javajs/img/PngEncoder.js b/bin/javajs/img/PngEncoder.js index 0accd9e..8c07dbd 100644 --- a/bin/javajs/img/PngEncoder.js +++ b/bin/javajs/img/PngEncoder.js @@ -1,173 +1,173 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.CRCEncoder"], "javajs.img.PngEncoder", ["java.io.ByteArrayOutputStream", "java.util.zip.Deflater", "$.DeflaterOutputStream"], function () { -c$ = Clazz.decorateAsClass (function () { -this.encodeAlpha = false; -this.filter = 0; -this.bytesPerPixel = 0; -this.compressionLevel = 0; -this.type = null; -this.transparentColor = null; -this.appData = null; -this.appPrefix = null; -this.comment = null; -this.bytes = null; -this.scanLines = null; -this.byteWidth = 0; -Clazz.instantialize (this, arguments); -}, javajs.img, "PngEncoder", javajs.img.CRCEncoder); -Clazz.overrideMethod (c$, "setParams", -function (params) { -if (this.quality < 0) this.quality = (params.containsKey ("qualityPNG") ? (params.get ("qualityPNG")).intValue () : 2); -if (this.quality > 9) this.quality = 9; -this.encodeAlpha = false; -this.filter = 0; -this.compressionLevel = this.quality; -this.transparentColor = params.get ("transparentColor"); -this.comment = params.get ("comment"); -this.type = (params.get ("type") + "0000").substring (0, 4); -this.bytes = params.get ("pngImgData"); -this.appData = params.get ("pngAppData"); -this.appPrefix = params.get ("pngAppPrefix"); -}, "java.util.Map"); -Clazz.overrideMethod (c$, "generate", -function () { -if (this.bytes == null) { -if (!this.pngEncode ()) { -this.out.cancel (); -return; -}this.bytes = this.getBytes (); -} else { -this.dataLen = this.bytes.length; -}var len = this.dataLen; -if (this.appData != null) { -javajs.img.PngEncoder.setJmolTypeText (this.appPrefix, this.bytes, len, this.appData.length, this.type); -this.out.write (this.bytes, 0, len); -len = (this.bytes = this.appData).length; -}this.out.write (this.bytes, 0, len); -}); -Clazz.defineMethod (c$, "pngEncode", -($fz = function () { -var pngIdBytes = Clazz.newByteArray (-1, [-119, 80, 78, 71, 13, 10, 26, 10]); -this.writeBytes (pngIdBytes); -this.writeHeader (); -this.writeText (javajs.img.PngEncoder.getApplicationText (this.appPrefix, this.type, 0, 0)); -this.writeText ("Software\0Jmol " + this.comment); -this.writeText ("Creation Time\0" + this.date); -if (!this.encodeAlpha && this.transparentColor != null) this.writeTransparentColor (this.transparentColor.intValue ()); -return this.writeImageData (); -}, $fz.isPrivate = true, $fz)); -c$.setJmolTypeText = Clazz.defineMethod (c$, "setJmolTypeText", -($fz = function (prefix, b, nPNG, nState, type) { -var s = "tEXt" + javajs.img.PngEncoder.getApplicationText (prefix, type, nPNG, nState); -var encoder = new javajs.img.PngEncoder (); -var test = s.substring (0, 4 + prefix.length).getBytes (); -for (var i = test.length; --i >= 0; ) if (b[i + 37] != test[i]) { -System.out.println ("image is not of the right form; appending data, but not adding tEXt tag."); -return; -} -encoder.setData (b, 37); -encoder.writeString (s); -encoder.writeCRC (); -}, $fz.isPrivate = true, $fz), "~S,~A,~N,~N,~S"); -c$.getApplicationText = Clazz.defineMethod (c$, "getApplicationText", -($fz = function (prefix, type, nPNG, nState) { -var sPNG = "000000000" + nPNG; -sPNG = sPNG.substring (sPNG.length - 9); -var sState = "000000000" + nState; -sState = sState.substring (sState.length - 9); -return prefix + "\0" + type + (type.equals ("PNG") ? "0" : "") + sPNG + "+" + sState; -}, $fz.isPrivate = true, $fz), "~S,~S,~N,~N"); -Clazz.defineMethod (c$, "writeHeader", -($fz = function () { -this.writeInt4 (13); -this.startPos = this.bytePos; -this.writeString ("IHDR"); -this.writeInt4 (this.width); -this.writeInt4 (this.height); -this.writeByte (8); -this.writeByte (this.encodeAlpha ? 6 : 2); -this.writeByte (0); -this.writeByte (0); -this.writeByte (0); -this.writeCRC (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeText", -($fz = function (msg) { -this.writeInt4 (msg.length); -this.startPos = this.bytePos; -this.writeString ("tEXt" + msg); -this.writeCRC (); -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "writeTransparentColor", -($fz = function (icolor) { -this.writeInt4 (6); -this.startPos = this.bytePos; -this.writeString ("tRNS"); -this.writeInt2 ((icolor >> 16) & 0xFF); -this.writeInt2 ((icolor >> 8) & 0xFF); -this.writeInt2 (icolor & 0xFF); -this.writeCRC (); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "writeImageData", -($fz = function () { -this.bytesPerPixel = (this.encodeAlpha ? 4 : 3); -this.byteWidth = this.width * this.bytesPerPixel; -var scanWidth = this.byteWidth + 1; -var rowsLeft = this.height; -var nRows; -var scanPos; -var deflater = new java.util.zip.Deflater (this.compressionLevel); -var outBytes = new java.io.ByteArrayOutputStream (1024); -var compBytes = new java.util.zip.DeflaterOutputStream (outBytes, deflater); -var pt = 0; -try { -while (rowsLeft > 0) { -nRows = Math.max (1, Math.min (Clazz.doubleToInt (32767 / scanWidth), rowsLeft)); -this.scanLines = Clazz.newByteArray (scanWidth * nRows, 0); -var nPixels = this.width * nRows; -scanPos = 0; -for (var i = 0; i < nPixels; i++, pt++) { -if (i % this.width == 0) { -this.scanLines[scanPos++] = this.filter; -}this.scanLines[scanPos++] = ((this.pixels[pt] >> 16) & 0xff); -this.scanLines[scanPos++] = ((this.pixels[pt] >> 8) & 0xff); -this.scanLines[scanPos++] = ((this.pixels[pt]) & 0xff); -if (this.encodeAlpha) { -this.scanLines[scanPos++] = ((this.pixels[pt] >> 24) & 0xff); -}} -compBytes.write (this.scanLines, 0, scanPos); -rowsLeft -= nRows; -} -compBytes.close (); -var compressedLines = outBytes.toByteArray (); -this.writeInt4 (compressedLines.length); -this.startPos = this.bytePos; -this.writeString ("IDAT"); -this.writeBytes (compressedLines); -this.writeCRC (); -this.writeEnd (); -deflater.finish (); -return true; -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -System.err.println (e.toString ()); -return false; -} else { -throw e; -} -} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeEnd", -($fz = function () { -this.writeInt4 (0); -this.startPos = this.bytePos; -this.writeString ("IEND"); -this.writeCRC (); -}, $fz.isPrivate = true, $fz)); -Clazz.defineStatics (c$, -"FILTER_NONE", 0, -"FILTER_SUB", 1, -"FILTER_UP", 2, -"FILTER_LAST", 2, -"PT_FIRST_TAG", 37); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.CRCEncoder"], "javajs.img.PngEncoder", ["java.io.ByteArrayOutputStream", "java.util.zip.Deflater", "$.DeflaterOutputStream"], function () { +c$ = Clazz.decorateAsClass (function () { +this.encodeAlpha = false; +this.filter = 0; +this.bytesPerPixel = 0; +this.compressionLevel = 0; +this.type = null; +this.transparentColor = null; +this.appData = null; +this.appPrefix = null; +this.comment = null; +this.bytes = null; +this.scanLines = null; +this.byteWidth = 0; +Clazz.instantialize (this, arguments); +}, javajs.img, "PngEncoder", javajs.img.CRCEncoder); +Clazz.overrideMethod (c$, "setParams", +function (params) { +if (this.quality < 0) this.quality = (params.containsKey ("qualityPNG") ? (params.get ("qualityPNG")).intValue () : 2); +if (this.quality > 9) this.quality = 9; +this.encodeAlpha = false; +this.filter = 0; +this.compressionLevel = this.quality; +this.transparentColor = params.get ("transparentColor"); +this.comment = params.get ("comment"); +this.type = (params.get ("type") + "0000").substring (0, 4); +this.bytes = params.get ("pngImgData"); +this.appData = params.get ("pngAppData"); +this.appPrefix = params.get ("pngAppPrefix"); +}, "java.util.Map"); +Clazz.overrideMethod (c$, "generate", +function () { +if (this.bytes == null) { +if (!this.pngEncode ()) { +this.out.cancel (); +return; +}this.bytes = this.getBytes (); +} else { +this.dataLen = this.bytes.length; +}var len = this.dataLen; +if (this.appData != null) { +javajs.img.PngEncoder.setJmolTypeText (this.appPrefix, this.bytes, len, this.appData.length, this.type); +this.out.write (this.bytes, 0, len); +len = (this.bytes = this.appData).length; +}this.out.write (this.bytes, 0, len); +}); +Clazz.defineMethod (c$, "pngEncode", +($fz = function () { +var pngIdBytes = Clazz.newByteArray (-1, [-119, 80, 78, 71, 13, 10, 26, 10]); +this.writeBytes (pngIdBytes); +this.writeHeader (); +this.writeText (javajs.img.PngEncoder.getApplicationText (this.appPrefix, this.type, 0, 0)); +this.writeText ("Software\0Jmol " + this.comment); +this.writeText ("Creation Time\0" + this.date); +if (!this.encodeAlpha && this.transparentColor != null) this.writeTransparentColor (this.transparentColor.intValue ()); +return this.writeImageData (); +}, $fz.isPrivate = true, $fz)); +c$.setJmolTypeText = Clazz.defineMethod (c$, "setJmolTypeText", +($fz = function (prefix, b, nPNG, nState, type) { +var s = "tEXt" + javajs.img.PngEncoder.getApplicationText (prefix, type, nPNG, nState); +var encoder = new javajs.img.PngEncoder (); +var test = s.substring (0, 4 + prefix.length).getBytes (); +for (var i = test.length; --i >= 0; ) if (b[i + 37] != test[i]) { +System.out.println ("image is not of the right form; appending data, but not adding tEXt tag."); +return; +} +encoder.setData (b, 37); +encoder.writeString (s); +encoder.writeCRC (); +}, $fz.isPrivate = true, $fz), "~S,~A,~N,~N,~S"); +c$.getApplicationText = Clazz.defineMethod (c$, "getApplicationText", +($fz = function (prefix, type, nPNG, nState) { +var sPNG = "000000000" + nPNG; +sPNG = sPNG.substring (sPNG.length - 9); +var sState = "000000000" + nState; +sState = sState.substring (sState.length - 9); +return prefix + "\0" + type + (type.equals ("PNG") ? "0" : "") + sPNG + "+" + sState; +}, $fz.isPrivate = true, $fz), "~S,~S,~N,~N"); +Clazz.defineMethod (c$, "writeHeader", +($fz = function () { +this.writeInt4 (13); +this.startPos = this.bytePos; +this.writeString ("IHDR"); +this.writeInt4 (this.width); +this.writeInt4 (this.height); +this.writeByte (8); +this.writeByte (this.encodeAlpha ? 6 : 2); +this.writeByte (0); +this.writeByte (0); +this.writeByte (0); +this.writeCRC (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeText", +($fz = function (msg) { +this.writeInt4 (msg.length); +this.startPos = this.bytePos; +this.writeString ("tEXt" + msg); +this.writeCRC (); +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "writeTransparentColor", +($fz = function (icolor) { +this.writeInt4 (6); +this.startPos = this.bytePos; +this.writeString ("tRNS"); +this.writeInt2 ((icolor >> 16) & 0xFF); +this.writeInt2 ((icolor >> 8) & 0xFF); +this.writeInt2 (icolor & 0xFF); +this.writeCRC (); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "writeImageData", +($fz = function () { +this.bytesPerPixel = (this.encodeAlpha ? 4 : 3); +this.byteWidth = this.width * this.bytesPerPixel; +var scanWidth = this.byteWidth + 1; +var rowsLeft = this.height; +var nRows; +var scanPos; +var deflater = new java.util.zip.Deflater (this.compressionLevel); +var outBytes = new java.io.ByteArrayOutputStream (1024); +var compBytes = new java.util.zip.DeflaterOutputStream (outBytes, deflater); +var pt = 0; +try { +while (rowsLeft > 0) { +nRows = Math.max (1, Math.min (Clazz.doubleToInt (32767 / scanWidth), rowsLeft)); +this.scanLines = Clazz.newByteArray (scanWidth * nRows, 0); +var nPixels = this.width * nRows; +scanPos = 0; +for (var i = 0; i < nPixels; i++, pt++) { +if (i % this.width == 0) { +this.scanLines[scanPos++] = this.filter; +}this.scanLines[scanPos++] = ((this.pixels[pt] >> 16) & 0xff); +this.scanLines[scanPos++] = ((this.pixels[pt] >> 8) & 0xff); +this.scanLines[scanPos++] = ((this.pixels[pt]) & 0xff); +if (this.encodeAlpha) { +this.scanLines[scanPos++] = ((this.pixels[pt] >> 24) & 0xff); +}} +compBytes.write (this.scanLines, 0, scanPos); +rowsLeft -= nRows; +} +compBytes.close (); +var compressedLines = outBytes.toByteArray (); +this.writeInt4 (compressedLines.length); +this.startPos = this.bytePos; +this.writeString ("IDAT"); +this.writeBytes (compressedLines); +this.writeCRC (); +this.writeEnd (); +deflater.finish (); +return true; +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +System.err.println (e.toString ()); +return false; +} else { +throw e; +} +} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeEnd", +($fz = function () { +this.writeInt4 (0); +this.startPos = this.bytePos; +this.writeString ("IEND"); +this.writeCRC (); +}, $fz.isPrivate = true, $fz)); +Clazz.defineStatics (c$, +"FILTER_NONE", 0, +"FILTER_SUB", 1, +"FILTER_UP", 2, +"FILTER_LAST", 2, +"PT_FIRST_TAG", 37); +}); diff --git a/bin/javajs/img/PpmEncoder.js b/bin/javajs/img/PpmEncoder.js index 1769c71..7cb6943 100644 --- a/bin/javajs/img/PpmEncoder.js +++ b/bin/javajs/img/PpmEncoder.js @@ -1,23 +1,23 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PpmEncoder", null, function () { -c$ = Clazz.declareType (javajs.img, "PpmEncoder", javajs.img.ImageEncoder); -Clazz.overrideMethod (c$, "setParams", -function (params) { -}, "java.util.Map"); -Clazz.overrideMethod (c$, "generate", -function () { -this.putString ("P6\n"); -this.putString (this.width + " " + this.height + "\n"); -this.putString ("255\n"); -var ppmPixels = Clazz.newByteArray (this.width * 3, 0); -for (var pt = 0, row = 0; row < this.height; ++row) { -for (var col = 0, j = 0; col < this.width; ++col, pt++) { -var p = this.pixels[pt]; -ppmPixels[j++] = ((p >> 16) & 0xff); -ppmPixels[j++] = ((p >> 8) & 0xff); -ppmPixels[j++] = (p & 0xff); -} -this.out.write (ppmPixels, 0, ppmPixels.length); -} -}); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PpmEncoder", null, function () { +c$ = Clazz.declareType (javajs.img, "PpmEncoder", javajs.img.ImageEncoder); +Clazz.overrideMethod (c$, "setParams", +function (params) { +}, "java.util.Map"); +Clazz.overrideMethod (c$, "generate", +function () { +this.putString ("P6\n"); +this.putString (this.width + " " + this.height + "\n"); +this.putString ("255\n"); +var ppmPixels = Clazz.newByteArray (this.width * 3, 0); +for (var pt = 0, row = 0; row < this.height; ++row) { +for (var col = 0, j = 0; col < this.width; ++col, pt++) { +var p = this.pixels[pt]; +ppmPixels[j++] = ((p >> 16) & 0xff); +ppmPixels[j++] = ((p >> 8) & 0xff); +ppmPixels[j++] = (p & 0xff); +} +this.out.write (ppmPixels, 0, ppmPixels.length); +} +}); +}); diff --git a/bin/javajs/img/package.js b/bin/javajs/img/package.js index 4086dd3..0982066 100644 --- a/bin/javajs/img/package.js +++ b/bin/javajs/img/package.js @@ -1,7 +1,7 @@ -var path = ClazzLoader.getClasspathFor ("javajs.img.package"); -path = path.substring (0, path.lastIndexOf ("package.js")); -ClazzLoader.jarClasspath (path + "JpgEncoder.js", [ -"javajs.img.DCT", -"$.JpgEncoder", -"$.JpegObj", -"$.Huffman"]); +var path = ClazzLoader.getClasspathFor ("javajs.img.package"); +path = path.substring (0, path.lastIndexOf ("package.js")); +ClazzLoader.jarClasspath (path + "JpgEncoder.js", [ +"javajs.img.DCT", +"$.JpgEncoder", +"$.JpegObj", +"$.Huffman"]); diff --git a/bin/javajs/swing/AbstractButton.js b/bin/javajs/swing/AbstractButton.js index f97cb2f..7a53af7 100644 --- a/bin/javajs/swing/AbstractButton.js +++ b/bin/javajs/swing/AbstractButton.js @@ -1,82 +1,82 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.api.SC", "javajs.swing.JComponent"], "javajs.swing.AbstractButton", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.itemListener = null; -this.applet = null; -this.htmlName = null; -this.selected = false; -this.popupMenu = null; -this.icon = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "AbstractButton", javajs.swing.JComponent, javajs.api.SC); -Clazz.makeConstructor (c$, -function (type) { -Clazz.superConstructor (this, javajs.swing.AbstractButton, [type]); -this.enabled = true; -}, "~S"); -Clazz.overrideMethod (c$, "setSelected", -function (selected) { -this.selected = selected; -{ -SwingController.setSelected(this); -}}, "~B"); -Clazz.overrideMethod (c$, "isSelected", -function () { -return this.selected; -}); -Clazz.overrideMethod (c$, "addItemListener", -function (listener) { -this.itemListener = listener; -}, "~O"); -Clazz.overrideMethod (c$, "getIcon", -function () { -return this.icon; -}); -Clazz.overrideMethod (c$, "setIcon", -function (icon) { -this.icon = icon; -}, "~O"); -Clazz.overrideMethod (c$, "init", -function (text, icon, actionCommand, popupMenu) { -this.text = text; -this.icon = icon; -this.actionCommand = actionCommand; -this.popupMenu = popupMenu; -{ -SwingController.initMenuItem(this); -}}, "~S,~O,~S,javajs.api.SC"); -Clazz.defineMethod (c$, "getTopPopupMenu", -function () { -return this.popupMenu; -}); -Clazz.defineMethod (c$, "add", -function (item) { -this.addComponent (item); -}, "javajs.api.SC"); -Clazz.overrideMethod (c$, "insert", -function (subMenu, index) { -this.insertComponent (subMenu, index); -}, "javajs.api.SC,~N"); -Clazz.overrideMethod (c$, "getPopupMenu", -function () { -return null; -}); -Clazz.defineMethod (c$, "getMenuHTML", -function () { -var label = (this.icon != null ? this.icon : this.text != null ? this.text : null); -var s = (label == null ? "" : "
  • " + label + "" + this.htmlMenuOpener ("ul")); -var n = this.getComponentCount (); -if (n > 0) for (var i = 0; i < n; i++) s += this.getComponent (i).toHTML (); - -if (label != null) s += "
  • "; -return s; -}); -Clazz.defineMethod (c$, "htmlMenuOpener", -function (type) { -return "<" + type + " id=\"" + this.id + "\"" + (this.enabled ? "" : this.getHtmlDisabled ()) + ">"; -}, "~S"); -Clazz.defineMethod (c$, "getHtmlDisabled", -function () { -return " disabled=\"disabled\""; -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.api.SC", "javajs.swing.JComponent"], "javajs.swing.AbstractButton", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.itemListener = null; +this.applet = null; +this.htmlName = null; +this.selected = false; +this.popupMenu = null; +this.icon = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "AbstractButton", javajs.swing.JComponent, javajs.api.SC); +Clazz.makeConstructor (c$, +function (type) { +Clazz.superConstructor (this, javajs.swing.AbstractButton, [type]); +this.enabled = true; +}, "~S"); +Clazz.overrideMethod (c$, "setSelected", +function (selected) { +this.selected = selected; +{ +SwingController.setSelected(this); +}}, "~B"); +Clazz.overrideMethod (c$, "isSelected", +function () { +return this.selected; +}); +Clazz.overrideMethod (c$, "addItemListener", +function (listener) { +this.itemListener = listener; +}, "~O"); +Clazz.overrideMethod (c$, "getIcon", +function () { +return this.icon; +}); +Clazz.overrideMethod (c$, "setIcon", +function (icon) { +this.icon = icon; +}, "~O"); +Clazz.overrideMethod (c$, "init", +function (text, icon, actionCommand, popupMenu) { +this.text = text; +this.icon = icon; +this.actionCommand = actionCommand; +this.popupMenu = popupMenu; +{ +SwingController.initMenuItem(this); +}}, "~S,~O,~S,javajs.api.SC"); +Clazz.defineMethod (c$, "getTopPopupMenu", +function () { +return this.popupMenu; +}); +Clazz.defineMethod (c$, "add", +function (item) { +this.addComponent (item); +}, "javajs.api.SC"); +Clazz.overrideMethod (c$, "insert", +function (subMenu, index) { +this.insertComponent (subMenu, index); +}, "javajs.api.SC,~N"); +Clazz.overrideMethod (c$, "getPopupMenu", +function () { +return null; +}); +Clazz.defineMethod (c$, "getMenuHTML", +function () { +var label = (this.icon != null ? this.icon : this.text != null ? this.text : null); +var s = (label == null ? "" : "
  • " + label + "" + this.htmlMenuOpener ("ul")); +var n = this.getComponentCount (); +if (n > 0) for (var i = 0; i < n; i++) s += this.getComponent (i).toHTML (); + +if (label != null) s += "
  • "; +return s; +}); +Clazz.defineMethod (c$, "htmlMenuOpener", +function (type) { +return "<" + type + " id=\"" + this.id + "\"" + (this.enabled ? "" : this.getHtmlDisabled ()) + ">"; +}, "~S"); +Clazz.defineMethod (c$, "getHtmlDisabled", +function () { +return " disabled=\"disabled\""; +}); +}); diff --git a/bin/javajs/swing/AbstractTableModel.js b/bin/javajs/swing/AbstractTableModel.js index c17cd4a..1f7382c 100644 --- a/bin/javajs/swing/AbstractTableModel.js +++ b/bin/javajs/swing/AbstractTableModel.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.TableColumn"], "javajs.swing.AbstractTableModel", null, function () { -Clazz.declareInterface (javajs.swing, "AbstractTableModel", javajs.swing.TableColumn); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.TableColumn"], "javajs.swing.AbstractTableModel", null, function () { +Clazz.declareInterface (javajs.swing, "AbstractTableModel", javajs.swing.TableColumn); +}); diff --git a/bin/javajs/swing/ButtonGroup.js b/bin/javajs/swing/ButtonGroup.js index ebd1ca6..dbeaf88 100644 --- a/bin/javajs/swing/ButtonGroup.js +++ b/bin/javajs/swing/ButtonGroup.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (null, "javajs.swing.ButtonGroup", ["javajs.awt.Component"], function () { -c$ = Clazz.decorateAsClass (function () { -this.id = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "ButtonGroup"); -Clazz.makeConstructor (c$, -function () { -this.id = javajs.awt.Component.newID ("bg"); -}); -Clazz.defineMethod (c$, "add", -function (item) { -(item).htmlName = this.id; -}, "javajs.api.SC"); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (null, "javajs.swing.ButtonGroup", ["javajs.awt.Component"], function () { +c$ = Clazz.decorateAsClass (function () { +this.id = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "ButtonGroup"); +Clazz.makeConstructor (c$, +function () { +this.id = javajs.awt.Component.newID ("bg"); +}); +Clazz.defineMethod (c$, "add", +function (item) { +(item).htmlName = this.id; +}, "javajs.api.SC"); +}); diff --git a/bin/javajs/swing/Cell.js b/bin/javajs/swing/Cell.js index 5ac8a90..2fc85c8 100644 --- a/bin/javajs/swing/Cell.js +++ b/bin/javajs/swing/Cell.js @@ -1,21 +1,21 @@ -Clazz.declarePackage ("javajs.swing"); -c$ = Clazz.decorateAsClass (function () { -this.component = null; -this.colspan = 0; -this.rowspan = 0; -this.textAlign = 0; -this.c = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "Cell"); -Clazz.makeConstructor (c$, -function (btn, c) { -this.component = btn; -this.colspan = c.gridwidth; -this.rowspan = c.gridheight; -this.c = c; -}, "javajs.swing.JComponent,javajs.swing.GridBagConstraints"); -Clazz.defineMethod (c$, "toHTML", -function (id) { -var style = this.c.getStyle (false); -return "" + this.component.toHTML () + ""; -}, "~S"); +Clazz.declarePackage ("javajs.swing"); +c$ = Clazz.decorateAsClass (function () { +this.component = null; +this.colspan = 0; +this.rowspan = 0; +this.textAlign = 0; +this.c = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "Cell"); +Clazz.makeConstructor (c$, +function (btn, c) { +this.component = btn; +this.colspan = c.gridwidth; +this.rowspan = c.gridheight; +this.c = c; +}, "javajs.swing.JComponent,javajs.swing.GridBagConstraints"); +Clazz.defineMethod (c$, "toHTML", +function (id) { +var style = this.c.getStyle (false); +return "" + this.component.toHTML () + ""; +}, "~S"); diff --git a/bin/javajs/swing/ColumnSelectionModel.js b/bin/javajs/swing/ColumnSelectionModel.js index 4ce0290..f9395b7 100644 --- a/bin/javajs/swing/ColumnSelectionModel.js +++ b/bin/javajs/swing/ColumnSelectionModel.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.declareInterface (javajs.swing, "ColumnSelectionModel"); +Clazz.declarePackage ("javajs.swing"); +Clazz.declareInterface (javajs.swing, "ColumnSelectionModel"); diff --git a/bin/javajs/swing/Document.js b/bin/javajs/swing/Document.js index 243ba05..90cf95a 100644 --- a/bin/javajs/swing/Document.js +++ b/bin/javajs/swing/Document.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.declareInterface (javajs.swing, "Document"); +Clazz.declarePackage ("javajs.swing"); +Clazz.declareInterface (javajs.swing, "Document"); diff --git a/bin/javajs/swing/FlowLayout.js b/bin/javajs/swing/FlowLayout.js index 6ed7d37..8989304 100644 --- a/bin/javajs/swing/FlowLayout.js +++ b/bin/javajs/swing/FlowLayout.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.awt.LayoutManager"], "javajs.swing.FlowLayout", null, function () { -c$ = Clazz.declareType (javajs.swing, "FlowLayout", javajs.awt.LayoutManager); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.awt.LayoutManager"], "javajs.swing.FlowLayout", null, function () { +c$ = Clazz.declareType (javajs.swing, "FlowLayout", javajs.awt.LayoutManager); +}); diff --git a/bin/javajs/swing/Grid.js b/bin/javajs/swing/Grid.js index d0b179f..2551964 100644 --- a/bin/javajs/swing/Grid.js +++ b/bin/javajs/swing/Grid.js @@ -1,46 +1,46 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (null, "javajs.swing.Grid", ["javajs.swing.Cell", "javajs.util.AU", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.nrows = 0; -this.ncols = 0; -this.grid = null; -this.renderer = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "Grid"); -Clazz.makeConstructor (c$, -function (rows, cols) { -this.grid = Clazz.newArray (0, 0, null); -}, "~N,~N"); -Clazz.defineMethod (c$, "add", -function (btn, c) { -if (c.gridx >= this.ncols) { -this.ncols = c.gridx + 1; -for (var i = 0; i < this.nrows; i++) { -this.grid[i] = javajs.util.AU.ensureLength (this.grid[i], this.ncols * 2); -} -}if (c.gridy >= this.nrows) { -var g = new Array (c.gridy * 2 + 1); -for (var i = 0; i < this.nrows; i++) g[i] = this.grid[i]; - -for (var i = g.length; --i >= this.nrows; ) g[i] = new Array (this.ncols * 2 + 1); - -this.grid = g; -this.nrows = c.gridy + 1; -}this.grid[c.gridy][c.gridx] = new javajs.swing.Cell (btn, c); -}, "javajs.swing.JComponent,javajs.swing.GridBagConstraints"); -Clazz.defineMethod (c$, "toHTML", -function (id) { -var sb = new javajs.util.SB (); -id += "_grid"; -sb.append ("\n"); -for (var i = 0; i < this.nrows; i++) { -var rowid = id + "_" + i; -sb.append ("\n"); -for (var j = 0; j < this.ncols; j++) if (this.grid[i][j] != null) sb.append (this.grid[i][j].toHTML (rowid + "_" + j)); - -sb.append (""); -} -sb.append ("\n
    \n"); -return sb.toString (); -}, "~S"); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (null, "javajs.swing.Grid", ["javajs.swing.Cell", "javajs.util.AU", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.nrows = 0; +this.ncols = 0; +this.grid = null; +this.renderer = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "Grid"); +Clazz.makeConstructor (c$, +function (rows, cols) { +this.grid = Clazz.newArray (0, 0, null); +}, "~N,~N"); +Clazz.defineMethod (c$, "add", +function (btn, c) { +if (c.gridx >= this.ncols) { +this.ncols = c.gridx + 1; +for (var i = 0; i < this.nrows; i++) { +this.grid[i] = javajs.util.AU.ensureLength (this.grid[i], this.ncols * 2); +} +}if (c.gridy >= this.nrows) { +var g = new Array (c.gridy * 2 + 1); +for (var i = 0; i < this.nrows; i++) g[i] = this.grid[i]; + +for (var i = g.length; --i >= this.nrows; ) g[i] = new Array (this.ncols * 2 + 1); + +this.grid = g; +this.nrows = c.gridy + 1; +}this.grid[c.gridy][c.gridx] = new javajs.swing.Cell (btn, c); +}, "javajs.swing.JComponent,javajs.swing.GridBagConstraints"); +Clazz.defineMethod (c$, "toHTML", +function (id) { +var sb = new javajs.util.SB (); +id += "_grid"; +sb.append ("\n"); +for (var i = 0; i < this.nrows; i++) { +var rowid = id + "_" + i; +sb.append ("\n"); +for (var j = 0; j < this.ncols; j++) if (this.grid[i][j] != null) sb.append (this.grid[i][j].toHTML (rowid + "_" + j)); + +sb.append (""); +} +sb.append ("\n
    \n"); +return sb.toString (); +}, "~S"); +}); diff --git a/bin/javajs/swing/GridBagConstraints.js b/bin/javajs/swing/GridBagConstraints.js index f631d92..31cf45c 100644 --- a/bin/javajs/swing/GridBagConstraints.js +++ b/bin/javajs/swing/GridBagConstraints.js @@ -1,41 +1,41 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (null, "javajs.swing.GridBagConstraints", ["javajs.swing.Insets"], function () { -c$ = Clazz.decorateAsClass (function () { -this.gridx = 0; -this.gridy = 0; -this.gridwidth = 0; -this.gridheight = 0; -this.weightx = 0; -this.weighty = 0; -this.anchor = 0; -this.fill = 0; -this.insets = null; -this.ipadx = 0; -this.ipady = 0; -Clazz.instantialize (this, arguments); -}, javajs.swing, "GridBagConstraints"); -Clazz.makeConstructor (c$, -function (gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, insets, ipadx, ipady) { -this.gridx = gridx; -this.gridy = gridy; -this.gridwidth = gridwidth; -this.gridheight = gridheight; -this.weightx = weightx; -this.weighty = weighty; -this.anchor = anchor; -this.fill = fill; -if (insets == null) insets = new javajs.swing.Insets (0, 0, 0, 0); -this.insets = insets; -this.ipadx = ipadx; -this.ipady = ipady; -}, "~N,~N,~N,~N,~N,~N,~N,~N,javajs.swing.Insets,~N,~N"); -Clazz.defineMethod (c$, "getStyle", -function (margins) { -return "style='" + (margins ? "margin:" + this.insets.top + "px " + (this.ipady + this.insets.right) + "px " + this.insets.bottom + "px " + (this.ipadx + this.insets.left) + "px;" : "text-align:" + (this.anchor == 13 ? "right" : this.anchor == 17 ? "left" : "center")) + "'"; -}, "~B"); -Clazz.defineStatics (c$, -"NONE", 0, -"CENTER", 10, -"WEST", 17, -"EAST", 13); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (null, "javajs.swing.GridBagConstraints", ["javajs.swing.Insets"], function () { +c$ = Clazz.decorateAsClass (function () { +this.gridx = 0; +this.gridy = 0; +this.gridwidth = 0; +this.gridheight = 0; +this.weightx = 0; +this.weighty = 0; +this.anchor = 0; +this.fill = 0; +this.insets = null; +this.ipadx = 0; +this.ipady = 0; +Clazz.instantialize (this, arguments); +}, javajs.swing, "GridBagConstraints"); +Clazz.makeConstructor (c$, +function (gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, insets, ipadx, ipady) { +this.gridx = gridx; +this.gridy = gridy; +this.gridwidth = gridwidth; +this.gridheight = gridheight; +this.weightx = weightx; +this.weighty = weighty; +this.anchor = anchor; +this.fill = fill; +if (insets == null) insets = new javajs.swing.Insets (0, 0, 0, 0); +this.insets = insets; +this.ipadx = ipadx; +this.ipady = ipady; +}, "~N,~N,~N,~N,~N,~N,~N,~N,javajs.swing.Insets,~N,~N"); +Clazz.defineMethod (c$, "getStyle", +function (margins) { +return "style='" + (margins ? "margin:" + this.insets.top + "px " + (this.ipady + this.insets.right) + "px " + this.insets.bottom + "px " + (this.ipadx + this.insets.left) + "px;" : "text-align:" + (this.anchor == 13 ? "right" : this.anchor == 17 ? "left" : "center")) + "'"; +}, "~B"); +Clazz.defineStatics (c$, +"NONE", 0, +"CENTER", 10, +"WEST", 17, +"EAST", 13); +}); diff --git a/bin/javajs/swing/GridBagLayout.js b/bin/javajs/swing/GridBagLayout.js index f2d3d43..e2a6b72 100644 --- a/bin/javajs/swing/GridBagLayout.js +++ b/bin/javajs/swing/GridBagLayout.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.awt.LayoutManager"], "javajs.swing.GridBagLayout", null, function () { -c$ = Clazz.declareType (javajs.swing, "GridBagLayout", javajs.awt.LayoutManager); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.awt.LayoutManager"], "javajs.swing.GridBagLayout", null, function () { +c$ = Clazz.declareType (javajs.swing, "GridBagLayout", javajs.awt.LayoutManager); +}); diff --git a/bin/javajs/swing/Insets.js b/bin/javajs/swing/Insets.js index 989e644..c9338fd 100644 --- a/bin/javajs/swing/Insets.js +++ b/bin/javajs/swing/Insets.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("javajs.swing"); -c$ = Clazz.decorateAsClass (function () { -this.top = 0; -this.left = 0; -this.bottom = 0; -this.right = 0; -Clazz.instantialize (this, arguments); -}, javajs.swing, "Insets"); -Clazz.makeConstructor (c$, -function (top, left, bottom, right) { -this.top = top; -this.left = left; -this.bottom = bottom; -this.right = right; -}, "~N,~N,~N,~N"); +Clazz.declarePackage ("javajs.swing"); +c$ = Clazz.decorateAsClass (function () { +this.top = 0; +this.left = 0; +this.bottom = 0; +this.right = 0; +Clazz.instantialize (this, arguments); +}, javajs.swing, "Insets"); +Clazz.makeConstructor (c$, +function (top, left, bottom, right) { +this.top = top; +this.left = left; +this.bottom = bottom; +this.right = right; +}, "~N,~N,~N,~N"); diff --git a/bin/javajs/swing/JButton.js b/bin/javajs/swing/JButton.js index b1f5cc2..6fa242d 100644 --- a/bin/javajs/swing/JButton.js +++ b/bin/javajs/swing/JButton.js @@ -1,14 +1,14 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JButton", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JButton", javajs.swing.AbstractButton); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JButton, ["btnJB"]); -}); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append (""); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JButton", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JButton", javajs.swing.AbstractButton); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JButton, ["btnJB"]); +}); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append (""); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JCheckBox.js b/bin/javajs/swing/JCheckBox.js index bae9b88..f4697cb 100644 --- a/bin/javajs/swing/JCheckBox.js +++ b/bin/javajs/swing/JCheckBox.js @@ -1,13 +1,13 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JCheckBox", null, function () { -c$ = Clazz.declareType (javajs.swing, "JCheckBox", javajs.swing.AbstractButton); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JCheckBox, ["chkJCB"]); -}); -Clazz.overrideMethod (c$, "toHTML", -function () { -var s = ""; -return s; -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JCheckBox", null, function () { +c$ = Clazz.declareType (javajs.swing, "JCheckBox", javajs.swing.AbstractButton); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JCheckBox, ["chkJCB"]); +}); +Clazz.overrideMethod (c$, "toHTML", +function () { +var s = ""; +return s; +}); +}); diff --git a/bin/javajs/swing/JCheckBoxMenuItem.js b/bin/javajs/swing/JCheckBoxMenuItem.js index 0b6f970..7f50135 100644 --- a/bin/javajs/swing/JCheckBoxMenuItem.js +++ b/bin/javajs/swing/JCheckBoxMenuItem.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JMenuItem"], "javajs.swing.JCheckBoxMenuItem", null, function () { -c$ = Clazz.declareType (javajs.swing, "JCheckBoxMenuItem", javajs.swing.JMenuItem); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JCheckBoxMenuItem, ["chk", 2]); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JMenuItem"], "javajs.swing.JCheckBoxMenuItem", null, function () { +c$ = Clazz.declareType (javajs.swing, "JCheckBoxMenuItem", javajs.swing.JMenuItem); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JCheckBoxMenuItem, ["chk", 2]); +}); +}); diff --git a/bin/javajs/swing/JComboBox.js b/bin/javajs/swing/JComboBox.js index 088b19f..3e829b4 100644 --- a/bin/javajs/swing/JComboBox.js +++ b/bin/javajs/swing/JComboBox.js @@ -1,36 +1,36 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JComboBox", ["javajs.util.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.info = null; -this.selectedIndex = 0; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JComboBox", javajs.swing.AbstractButton); -Clazz.makeConstructor (c$, -function (info) { -Clazz.superConstructor (this, javajs.swing.JComboBox, ["cmbJCB"]); -this.info = info; -}, "~A"); -Clazz.defineMethod (c$, "setSelectedIndex", -function (i) { -this.selectedIndex = i; -{ -SwingController.setSelectedIndex(this); -}}, "~N"); -Clazz.defineMethod (c$, "getSelectedIndex", -function () { -return this.selectedIndex; -}); -Clazz.defineMethod (c$, "getSelectedItem", -function () { -return (this.selectedIndex < 0 ? null : this.info[this.selectedIndex]); -}); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append ("\n\n"); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JComboBox", ["javajs.util.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.info = null; +this.selectedIndex = 0; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JComboBox", javajs.swing.AbstractButton); +Clazz.makeConstructor (c$, +function (info) { +Clazz.superConstructor (this, javajs.swing.JComboBox, ["cmbJCB"]); +this.info = info; +}, "~A"); +Clazz.defineMethod (c$, "setSelectedIndex", +function (i) { +this.selectedIndex = i; +{ +SwingController.setSelectedIndex(this); +}}, "~N"); +Clazz.defineMethod (c$, "getSelectedIndex", +function () { +return this.selectedIndex; +}); +Clazz.defineMethod (c$, "getSelectedItem", +function () { +return (this.selectedIndex < 0 ? null : this.info[this.selectedIndex]); +}); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append ("\n\n"); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JComponent.js b/bin/javajs/swing/JComponent.js index aca8bfd..28b137e 100644 --- a/bin/javajs/swing/JComponent.js +++ b/bin/javajs/swing/JComponent.js @@ -1,25 +1,25 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.awt.Container"], "javajs.swing.JComponent", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.autoScrolls = false; -this.actionCommand = null; -this.actionListener = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JComponent", javajs.awt.Container); -Clazz.defineMethod (c$, "setAutoscrolls", -function (b) { -this.autoScrolls = b; -}, "~B"); -Clazz.defineMethod (c$, "addActionListener", -function (listener) { -this.actionListener = listener; -}, "~O"); -Clazz.defineMethod (c$, "getActionCommand", -function () { -return this.actionCommand; -}); -Clazz.defineMethod (c$, "setActionCommand", -function (actionCommand) { -this.actionCommand = actionCommand; -}, "~S"); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.awt.Container"], "javajs.swing.JComponent", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.autoScrolls = false; +this.actionCommand = null; +this.actionListener = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JComponent", javajs.awt.Container); +Clazz.defineMethod (c$, "setAutoscrolls", +function (b) { +this.autoScrolls = b; +}, "~B"); +Clazz.defineMethod (c$, "addActionListener", +function (listener) { +this.actionListener = listener; +}, "~O"); +Clazz.defineMethod (c$, "getActionCommand", +function () { +return this.actionCommand; +}); +Clazz.defineMethod (c$, "setActionCommand", +function (actionCommand) { +this.actionCommand = actionCommand; +}, "~S"); +}); diff --git a/bin/javajs/swing/JComponentImp.js b/bin/javajs/swing/JComponentImp.js index a19f4ee..2158688 100644 --- a/bin/javajs/swing/JComponentImp.js +++ b/bin/javajs/swing/JComponentImp.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JComponentImp", null, function () { -c$ = Clazz.declareType (javajs.swing, "JComponentImp", javajs.swing.JComponent); -Clazz.overrideMethod (c$, "toHTML", -function () { -return null; -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JComponentImp", null, function () { +c$ = Clazz.declareType (javajs.swing, "JComponentImp", javajs.swing.JComponent); +Clazz.overrideMethod (c$, "toHTML", +function () { +return null; +}); +}); diff --git a/bin/javajs/swing/JContentPane.js b/bin/javajs/swing/JContentPane.js index 5cd86e3..5f822fa 100644 --- a/bin/javajs/swing/JContentPane.js +++ b/bin/javajs/swing/JContentPane.js @@ -1,17 +1,17 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JContentPane", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JContentPane", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JContentPane, ["JCP"]); -}); -Clazz.defineMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append ("\n
    \n"); -if (this.list != null) for (var i = 0; i < this.list.size (); i++) sb.append (this.list.get (i).toHTML ()); - -sb.append ("\n
    \n"); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JContentPane", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JContentPane", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JContentPane, ["JCP"]); +}); +Clazz.defineMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append ("\n
    \n"); +if (this.list != null) for (var i = 0; i < this.list.size (); i++) sb.append (this.list.get (i).toHTML ()); + +sb.append ("\n
    \n"); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JDialog.js b/bin/javajs/swing/JDialog.js index 6b11856..16bacd5 100644 --- a/bin/javajs/swing/JDialog.js +++ b/bin/javajs/swing/JDialog.js @@ -1,82 +1,82 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.awt.Container"], "javajs.swing.JDialog", ["javajs.awt.Color", "javajs.swing.JContentPane", "javajs.util.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.defaultWidth = 600; -this.defaultHeight = 300; -this.contentPane = null; -this.title = null; -this.html = null; -this.zIndex = 9000; -this.loc = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JDialog", javajs.awt.Container); -Clazz.defineMethod (c$, "setZIndex", -function (zIndex) { -this.zIndex = zIndex; -}, "~N"); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JDialog, ["JD"]); -this.add (this.contentPane = new javajs.swing.JContentPane ()); -this.setBackground (javajs.awt.Color.get3 (210, 210, 240)); -this.contentPane.setBackground (javajs.awt.Color.get3 (230, 230, 230)); -}); -Clazz.defineMethod (c$, "setLocation", -function (loc) { -this.loc = loc; -}, "~A"); -Clazz.defineMethod (c$, "getContentPane", -function () { -return this.contentPane; -}); -Clazz.defineMethod (c$, "setTitle", -function (title) { -this.title = title; -}, "~S"); -Clazz.defineMethod (c$, "pack", -function () { -this.html = null; -}); -Clazz.defineMethod (c$, "validate", -function () { -this.html = null; -}); -Clazz.defineMethod (c$, "setVisible", -function (tf) { -if (tf && this.html == null) this.setDialog (); -Clazz.superCall (this, javajs.swing.JDialog, "setVisible", [tf]); -}, "~B"); -Clazz.defineMethod (c$, "dispose", -function () { -{ -{ -SwingController.dispose(this); -}}}); -Clazz.overrideMethod (c$, "repaint", -function () { -this.setDialog (); -}); -Clazz.defineMethod (c$, "setDialog", -($fz = function () { -this.html = this.toHTML (); -{ -SwingController.setDialog(this); -}}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "toHTML", -function () { -this.renderWidth = this.getSubcomponentWidth (); -if (this.renderWidth == 0) this.renderWidth = this.defaultWidth; -this.renderHeight = this.contentPane.getSubcomponentHeight (); -if (this.renderHeight == 0) this.renderHeight = this.defaultHeight; -var h = this.renderHeight - 25; -var sb = new javajs.util.SB (); -sb.append ("\n
    \n"); -sb.append ("\n
    " + "" + this.title + "" + "
    \n"); -sb.append ("\n
    \n"); -sb.append (this.contentPane.toHTML ()); -sb.append ("\n
    \n"); -return sb.toString (); -}); -Clazz.defineStatics (c$, -"headerHeight", 25); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.awt.Container"], "javajs.swing.JDialog", ["javajs.awt.Color", "javajs.swing.JContentPane", "javajs.util.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.defaultWidth = 600; +this.defaultHeight = 300; +this.contentPane = null; +this.title = null; +this.html = null; +this.zIndex = 9000; +this.loc = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JDialog", javajs.awt.Container); +Clazz.defineMethod (c$, "setZIndex", +function (zIndex) { +this.zIndex = zIndex; +}, "~N"); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JDialog, ["JD"]); +this.add (this.contentPane = new javajs.swing.JContentPane ()); +this.setBackground (javajs.awt.Color.get3 (210, 210, 240)); +this.contentPane.setBackground (javajs.awt.Color.get3 (230, 230, 230)); +}); +Clazz.defineMethod (c$, "setLocation", +function (loc) { +this.loc = loc; +}, "~A"); +Clazz.defineMethod (c$, "getContentPane", +function () { +return this.contentPane; +}); +Clazz.defineMethod (c$, "setTitle", +function (title) { +this.title = title; +}, "~S"); +Clazz.defineMethod (c$, "pack", +function () { +this.html = null; +}); +Clazz.defineMethod (c$, "validate", +function () { +this.html = null; +}); +Clazz.defineMethod (c$, "setVisible", +function (tf) { +if (tf && this.html == null) this.setDialog (); +Clazz.superCall (this, javajs.swing.JDialog, "setVisible", [tf]); +}, "~B"); +Clazz.defineMethod (c$, "dispose", +function () { +{ +{ +SwingController.dispose(this); +}}}); +Clazz.overrideMethod (c$, "repaint", +function () { +this.setDialog (); +}); +Clazz.defineMethod (c$, "setDialog", +($fz = function () { +this.html = this.toHTML (); +{ +SwingController.setDialog(this); +}}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "toHTML", +function () { +this.renderWidth = this.getSubcomponentWidth (); +if (this.renderWidth == 0) this.renderWidth = this.defaultWidth; +this.renderHeight = this.contentPane.getSubcomponentHeight (); +if (this.renderHeight == 0) this.renderHeight = this.defaultHeight; +var h = this.renderHeight - 25; +var sb = new javajs.util.SB (); +sb.append ("\n
    \n"); +sb.append ("\n
    " + "" + this.title + "" + "
    \n"); +sb.append ("\n
    \n"); +sb.append (this.contentPane.toHTML ()); +sb.append ("\n
    \n"); +return sb.toString (); +}); +Clazz.defineStatics (c$, +"headerHeight", 25); +}); diff --git a/bin/javajs/swing/JEditorPane.js b/bin/javajs/swing/JEditorPane.js index f8dcf8c..4f40aab 100644 --- a/bin/javajs/swing/JEditorPane.js +++ b/bin/javajs/swing/JEditorPane.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JEditorPane", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JEditorPane", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JEditorPane, ["txtJEP"]); -this.text = ""; -}); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append (""); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JEditorPane", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JEditorPane", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JEditorPane, ["txtJEP"]); +this.text = ""; +}); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append (""); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JLabel.js b/bin/javajs/swing/JLabel.js index 2146a5e..778976c 100644 --- a/bin/javajs/swing/JLabel.js +++ b/bin/javajs/swing/JLabel.js @@ -1,17 +1,17 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JLabel", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JLabel", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function (text) { -Clazz.superConstructor (this, javajs.swing.JLabel, ["lblJL"]); -this.text = text; -}, "~S"); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append (""); -sb.append (this.text); -sb.append (""); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JLabel", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JLabel", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function (text) { +Clazz.superConstructor (this, javajs.swing.JLabel, ["lblJL"]); +this.text = text; +}, "~S"); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append (""); +sb.append (this.text); +sb.append (""); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JMenu.js b/bin/javajs/swing/JMenu.js index 4dae0ad..f887330 100644 --- a/bin/javajs/swing/JMenu.js +++ b/bin/javajs/swing/JMenu.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JMenuItem"], "javajs.swing.JMenu", null, function () { -c$ = Clazz.declareType (javajs.swing, "JMenu", javajs.swing.JMenuItem); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JMenu, ["mnu", 4]); -}); -Clazz.defineMethod (c$, "getItemCount", -function () { -return this.getComponentCount (); -}); -Clazz.defineMethod (c$, "getItem", -function (i) { -return this.getComponent (i); -}, "~N"); -Clazz.overrideMethod (c$, "getPopupMenu", -function () { -return this; -}); -Clazz.overrideMethod (c$, "toHTML", -function () { -return this.getMenuHTML (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JMenuItem"], "javajs.swing.JMenu", null, function () { +c$ = Clazz.declareType (javajs.swing, "JMenu", javajs.swing.JMenuItem); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JMenu, ["mnu", 4]); +}); +Clazz.defineMethod (c$, "getItemCount", +function () { +return this.getComponentCount (); +}); +Clazz.defineMethod (c$, "getItem", +function (i) { +return this.getComponent (i); +}, "~N"); +Clazz.overrideMethod (c$, "getPopupMenu", +function () { +return this; +}); +Clazz.overrideMethod (c$, "toHTML", +function () { +return this.getMenuHTML (); +}); +}); diff --git a/bin/javajs/swing/JMenuItem.js b/bin/javajs/swing/JMenuItem.js index b1183cc..36e3220 100644 --- a/bin/javajs/swing/JMenuItem.js +++ b/bin/javajs/swing/JMenuItem.js @@ -1,36 +1,36 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JMenuItem", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.btnType = 0; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JMenuItem", javajs.swing.AbstractButton); -Clazz.makeConstructor (c$, -function (text) { -Clazz.superConstructor (this, javajs.swing.JMenuItem, ["btn"]); -this.setText (text); -this.btnType = (text == null ? 0 : 1); -}, "~S"); -Clazz.makeConstructor (c$, -function (type, i) { -Clazz.superConstructor (this, javajs.swing.JMenuItem, [type]); -this.btnType = i; -}, "~S,~N"); -Clazz.overrideMethod (c$, "toHTML", -function () { -return this.htmlMenuOpener ("li") + (this.text == null ? "" : "" + this.htmlLabel () + "") + ""; -}); -Clazz.overrideMethod (c$, "getHtmlDisabled", -function () { -return " class=\"ui-state-disabled\""; -}); -Clazz.defineMethod (c$, "htmlLabel", -($fz = function () { -return (this.btnType == 1 ? this.text : ""); -}, $fz.isPrivate = true, $fz)); -Clazz.defineStatics (c$, -"TYPE_SEPARATOR", 0, -"TYPE_BUTTON", 1, -"TYPE_CHECKBOX", 2, -"TYPE_RADIO", 3, -"TYPE_MENU", 4); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JMenuItem", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.btnType = 0; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JMenuItem", javajs.swing.AbstractButton); +Clazz.makeConstructor (c$, +function (text) { +Clazz.superConstructor (this, javajs.swing.JMenuItem, ["btn"]); +this.setText (text); +this.btnType = (text == null ? 0 : 1); +}, "~S"); +Clazz.makeConstructor (c$, +function (type, i) { +Clazz.superConstructor (this, javajs.swing.JMenuItem, [type]); +this.btnType = i; +}, "~S,~N"); +Clazz.overrideMethod (c$, "toHTML", +function () { +return this.htmlMenuOpener ("li") + (this.text == null ? "" : "" + this.htmlLabel () + "") + ""; +}); +Clazz.overrideMethod (c$, "getHtmlDisabled", +function () { +return " class=\"ui-state-disabled\""; +}); +Clazz.defineMethod (c$, "htmlLabel", +($fz = function () { +return (this.btnType == 1 ? this.text : ""); +}, $fz.isPrivate = true, $fz)); +Clazz.defineStatics (c$, +"TYPE_SEPARATOR", 0, +"TYPE_BUTTON", 1, +"TYPE_CHECKBOX", 2, +"TYPE_RADIO", 3, +"TYPE_MENU", 4); +}); diff --git a/bin/javajs/swing/JPanel.js b/bin/javajs/swing/JPanel.js index 76bb933..a7a7ef9 100644 --- a/bin/javajs/swing/JPanel.js +++ b/bin/javajs/swing/JPanel.js @@ -1,39 +1,39 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JPanel", ["javajs.swing.Grid", "$.GridBagConstraints", "javajs.util.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.grid = null; -this.nElements = 0; -this.last = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JPanel", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function (manager) { -Clazz.superConstructor (this, javajs.swing.JPanel, ["JP"]); -this.grid = new javajs.swing.Grid (10, 10); -}, "javajs.awt.LayoutManager"); -Clazz.defineMethod (c$, "add", -function (btn, c) { -this.last = (++this.nElements == 1 ? btn : null); -if (Clazz.instanceOf (c, String)) { -if (c.equals ("North")) c = new javajs.swing.GridBagConstraints (0, 0, 3, 1, 0, 0, 10, 0, null, 0, 0); - else if (c.equals ("South")) c = new javajs.swing.GridBagConstraints (0, 2, 3, 1, 0, 0, 10, 0, null, 0, 0); - else if (c.equals ("East")) c = new javajs.swing.GridBagConstraints (2, 1, 1, 1, 0, 0, 13, 0, null, 0, 0); - else if (c.equals ("West")) c = new javajs.swing.GridBagConstraints (0, 1, 1, 1, 0, 0, 17, 0, null, 0, 0); - else c = new javajs.swing.GridBagConstraints (1, 1, 1, 1, 0, 0, 10, 0, null, 0, 0); -}this.grid.add (btn, c); -}, "javajs.swing.JComponent,~O"); -Clazz.overrideMethod (c$, "toHTML", -function () { -if (this.last != null) { -this.grid = new javajs.swing.Grid (1, 1); -this.grid.add (this.last, new javajs.swing.GridBagConstraints (0, 0, 1, 1, 0, 0, 10, 0, null, 0, 0)); -this.last = null; -}var sb = new javajs.util.SB (); -sb.append ("\n
    \n"); -sb.append ("\n"); -sb.append (this.grid.toHTML (this.id)); -sb.append (""); -sb.append ("\n
    \n"); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JPanel", ["javajs.swing.Grid", "$.GridBagConstraints", "javajs.util.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.grid = null; +this.nElements = 0; +this.last = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JPanel", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function (manager) { +Clazz.superConstructor (this, javajs.swing.JPanel, ["JP"]); +this.grid = new javajs.swing.Grid (10, 10); +}, "javajs.awt.LayoutManager"); +Clazz.defineMethod (c$, "add", +function (btn, c) { +this.last = (++this.nElements == 1 ? btn : null); +if (Clazz.instanceOf (c, String)) { +if (c.equals ("North")) c = new javajs.swing.GridBagConstraints (0, 0, 3, 1, 0, 0, 10, 0, null, 0, 0); + else if (c.equals ("South")) c = new javajs.swing.GridBagConstraints (0, 2, 3, 1, 0, 0, 10, 0, null, 0, 0); + else if (c.equals ("East")) c = new javajs.swing.GridBagConstraints (2, 1, 1, 1, 0, 0, 13, 0, null, 0, 0); + else if (c.equals ("West")) c = new javajs.swing.GridBagConstraints (0, 1, 1, 1, 0, 0, 17, 0, null, 0, 0); + else c = new javajs.swing.GridBagConstraints (1, 1, 1, 1, 0, 0, 10, 0, null, 0, 0); +}this.grid.add (btn, c); +}, "javajs.swing.JComponent,~O"); +Clazz.overrideMethod (c$, "toHTML", +function () { +if (this.last != null) { +this.grid = new javajs.swing.Grid (1, 1); +this.grid.add (this.last, new javajs.swing.GridBagConstraints (0, 0, 1, 1, 0, 0, 10, 0, null, 0, 0)); +this.last = null; +}var sb = new javajs.util.SB (); +sb.append ("\n
    \n"); +sb.append ("\n"); +sb.append (this.grid.toHTML (this.id)); +sb.append (""); +sb.append ("\n
    \n"); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JPopupMenu.js b/bin/javajs/swing/JPopupMenu.js index 95cbc1f..855df96 100644 --- a/bin/javajs/swing/JPopupMenu.js +++ b/bin/javajs/swing/JPopupMenu.js @@ -1,37 +1,37 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JPopupMenu", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.tainted = true; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JPopupMenu", javajs.swing.AbstractButton); -Clazz.makeConstructor (c$, -function (name) { -Clazz.superConstructor (this, javajs.swing.JPopupMenu, ["mnu"]); -this.name = name; -}, "~S"); -Clazz.defineMethod (c$, "setInvoker", -function (applet) { -this.applet = applet; -{ -SwingController.setMenu(this); -}}, "~O"); -Clazz.defineMethod (c$, "show", -function (applet, x, y) { -{ -if (applet != null) -this.tainted = true; -SwingController.showMenu(this, x, y); -}}, "javajs.awt.Component,~N,~N"); -Clazz.defineMethod (c$, "disposeMenu", -function () { -{ -SwingController.disposeMenu(this); -}}); -Clazz.overrideMethod (c$, "toHTML", -function () { -return this.getMenuHTML (); -}); -{ -{ -SwingController.setDraggable(javajs.swing.JPopupMenu); -}}}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JPopupMenu", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.tainted = true; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JPopupMenu", javajs.swing.AbstractButton); +Clazz.makeConstructor (c$, +function (name) { +Clazz.superConstructor (this, javajs.swing.JPopupMenu, ["mnu"]); +this.name = name; +}, "~S"); +Clazz.defineMethod (c$, "setInvoker", +function (applet) { +this.applet = applet; +{ +SwingController.setMenu(this); +}}, "~O"); +Clazz.defineMethod (c$, "show", +function (applet, x, y) { +{ +if (applet != null) +this.tainted = true; +SwingController.showMenu(this, x, y); +}}, "javajs.awt.Component,~N,~N"); +Clazz.defineMethod (c$, "disposeMenu", +function () { +{ +SwingController.disposeMenu(this); +}}); +Clazz.overrideMethod (c$, "toHTML", +function () { +return this.getMenuHTML (); +}); +{ +{ +SwingController.setDraggable(javajs.swing.JPopupMenu); +}}}); diff --git a/bin/javajs/swing/JRadioButtonMenuItem.js b/bin/javajs/swing/JRadioButtonMenuItem.js index 8388819..1ba2401 100644 --- a/bin/javajs/swing/JRadioButtonMenuItem.js +++ b/bin/javajs/swing/JRadioButtonMenuItem.js @@ -1,11 +1,11 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JMenuItem"], "javajs.swing.JRadioButtonMenuItem", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.isRadio = true; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JRadioButtonMenuItem", javajs.swing.JMenuItem); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JRadioButtonMenuItem, ["rad", 3]); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JMenuItem"], "javajs.swing.JRadioButtonMenuItem", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.isRadio = true; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JRadioButtonMenuItem", javajs.swing.JMenuItem); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JRadioButtonMenuItem, ["rad", 3]); +}); +}); diff --git a/bin/javajs/swing/JScrollPane.js b/bin/javajs/swing/JScrollPane.js index 2ba9959..64c766a 100644 --- a/bin/javajs/swing/JScrollPane.js +++ b/bin/javajs/swing/JScrollPane.js @@ -1,22 +1,22 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JScrollPane", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JScrollPane", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function (component) { -Clazz.superConstructor (this, javajs.swing.JScrollPane, ["JScP"]); -this.add (component); -}, "javajs.swing.JComponent"); -Clazz.defineMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append ("\n
    \n"); -if (this.list != null) { -var c = this.list.get (0); -sb.append (c.toHTML ()); -}sb.append ("\n
    \n"); -return sb.toString (); -}); -Clazz.overrideMethod (c$, "setMinimumSize", -function (dimension) { -}, "javajs.awt.Dimension"); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JScrollPane", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JScrollPane", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function (component) { +Clazz.superConstructor (this, javajs.swing.JScrollPane, ["JScP"]); +this.add (component); +}, "javajs.swing.JComponent"); +Clazz.defineMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append ("\n
    \n"); +if (this.list != null) { +var c = this.list.get (0); +sb.append (c.toHTML ()); +}sb.append ("\n
    \n"); +return sb.toString (); +}); +Clazz.overrideMethod (c$, "setMinimumSize", +function (dimension) { +}, "javajs.awt.Dimension"); +}); diff --git a/bin/javajs/swing/JSplitPane.js b/bin/javajs/swing/JSplitPane.js index 08969e2..11f99e2 100644 --- a/bin/javajs/swing/JSplitPane.js +++ b/bin/javajs/swing/JSplitPane.js @@ -1,67 +1,67 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JSplitPane", ["javajs.swing.JComponentImp", "javajs.util.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.isH = true; -this.split = 1; -this.right = null; -this.left = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JSplitPane", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function (split) { -Clazz.superConstructor (this, javajs.swing.JSplitPane, ["JSpP"]); -this.split = split; -this.isH = (split == 1); -}, "~N"); -Clazz.defineMethod (c$, "setRightComponent", -function (r) { -this.right = new javajs.swing.JComponentImp (null); -this.right.add (r); -}, "javajs.swing.JComponent"); -Clazz.defineMethod (c$, "setLeftComponent", -function (l) { -this.left = new javajs.swing.JComponentImp (null); -this.left.add (l); -}, "javajs.swing.JComponent"); -Clazz.defineMethod (c$, "getSubcomponentWidth", -function () { -var w = this.width; -if (w == 0) { -var wleft = this.left.getSubcomponentWidth (); -var wright = this.right.getSubcomponentWidth (); -if (wleft > 0 && wright > 0) { -if (this.isH) w = wleft + wright; - else w = Math.max (wleft, wright); -}}return w; -}); -Clazz.defineMethod (c$, "getSubcomponentHeight", -function () { -var h = this.height; -if (h == 0) { -var hleft = this.left.getSubcomponentHeight (); -var hright = this.right.getSubcomponentHeight (); -if (hleft > 0 && hright > 0) { -if (this.isH) h = Math.max (hleft, hright); - else h = hleft + hright; -}}return h; -}); -Clazz.defineMethod (c$, "toHTML", -function () { -if (this.left == null || this.right == null) return ""; -var isH = (this.split == 1); -if (this.width == 0) this.width = this.getSubcomponentWidth (); -if (this.height == 0) this.height = this.getSubcomponentHeight (); -var sb = new javajs.util.SB (); -sb.append ("
    "); -if (isH) sb.append ("
    "); - else sb.append ("
    "); -sb.append (this.left.getComponents ()[0].toHTML ()); -if (isH) sb.append ("
    "); - else sb.append ("
    "); -sb.append (this.right.getComponents ()[0].toHTML ()); -sb.append ("
    \n"); -return sb.toString (); -}); -Clazz.defineStatics (c$, -"HORIZONTAL_SPLIT", 1); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JSplitPane", ["javajs.swing.JComponentImp", "javajs.util.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.isH = true; +this.split = 1; +this.right = null; +this.left = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JSplitPane", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function (split) { +Clazz.superConstructor (this, javajs.swing.JSplitPane, ["JSpP"]); +this.split = split; +this.isH = (split == 1); +}, "~N"); +Clazz.defineMethod (c$, "setRightComponent", +function (r) { +this.right = new javajs.swing.JComponentImp (null); +this.right.add (r); +}, "javajs.swing.JComponent"); +Clazz.defineMethod (c$, "setLeftComponent", +function (l) { +this.left = new javajs.swing.JComponentImp (null); +this.left.add (l); +}, "javajs.swing.JComponent"); +Clazz.defineMethod (c$, "getSubcomponentWidth", +function () { +var w = this.width; +if (w == 0) { +var wleft = this.left.getSubcomponentWidth (); +var wright = this.right.getSubcomponentWidth (); +if (wleft > 0 && wright > 0) { +if (this.isH) w = wleft + wright; + else w = Math.max (wleft, wright); +}}return w; +}); +Clazz.defineMethod (c$, "getSubcomponentHeight", +function () { +var h = this.height; +if (h == 0) { +var hleft = this.left.getSubcomponentHeight (); +var hright = this.right.getSubcomponentHeight (); +if (hleft > 0 && hright > 0) { +if (this.isH) h = Math.max (hleft, hright); + else h = hleft + hright; +}}return h; +}); +Clazz.defineMethod (c$, "toHTML", +function () { +if (this.left == null || this.right == null) return ""; +var isH = (this.split == 1); +if (this.width == 0) this.width = this.getSubcomponentWidth (); +if (this.height == 0) this.height = this.getSubcomponentHeight (); +var sb = new javajs.util.SB (); +sb.append ("
    "); +if (isH) sb.append ("
    "); + else sb.append ("
    "); +sb.append (this.left.getComponents ()[0].toHTML ()); +if (isH) sb.append ("
    "); + else sb.append ("
    "); +sb.append (this.right.getComponents ()[0].toHTML ()); +sb.append ("
    \n"); +return sb.toString (); +}); +Clazz.defineStatics (c$, +"HORIZONTAL_SPLIT", 1); +}); diff --git a/bin/javajs/swing/JTable.js b/bin/javajs/swing/JTable.js index b8f4499..a281668 100644 --- a/bin/javajs/swing/JTable.js +++ b/bin/javajs/swing/JTable.js @@ -1,67 +1,67 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.ColumnSelectionModel", "$.JComponent", "$.ListSelectionModel"], "javajs.swing.JTable", ["javajs.util.BS", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.tableModel = null; -this.bsSelectedCells = null; -this.bsSelectedRows = null; -this.rowSelectionAllowed = false; -this.cellSelectionEnabled = false; -this.selectionListener = null; -Clazz.instantialize (this, arguments); -}, javajs.swing, "JTable", javajs.swing.JComponent, [javajs.swing.ListSelectionModel, javajs.swing.ColumnSelectionModel]); -Clazz.makeConstructor (c$, -function (tableModel) { -Clazz.superConstructor (this, javajs.swing.JTable, ["JT"]); -this.tableModel = tableModel; -this.bsSelectedCells = new javajs.util.BS (); -this.bsSelectedRows = new javajs.util.BS (); -}, "javajs.swing.AbstractTableModel"); -Clazz.overrideMethod (c$, "getSelectionModel", -function () { -return this; -}); -Clazz.defineMethod (c$, "getColumnModel", -function () { -return this; -}); -Clazz.defineMethod (c$, "setPreferredScrollableViewportSize", -function (dimension) { -this.width = dimension.width; -this.height = dimension.height; -}, "javajs.awt.Dimension"); -Clazz.defineMethod (c$, "clearSelection", -function () { -this.bsSelectedCells.clearAll (); -this.bsSelectedRows.clearAll (); -}); -Clazz.defineMethod (c$, "setRowSelectionAllowed", -function (b) { -this.rowSelectionAllowed = b; -}, "~B"); -Clazz.defineMethod (c$, "setRowSelectionInterval", -function (i, j) { -this.bsSelectedRows.clearAll (); -this.bsSelectedRows.setBits (i, j); -this.bsSelectedCells.clearAll (); -}, "~N,~N"); -Clazz.defineMethod (c$, "setCellSelectionEnabled", -function (enabled) { -this.cellSelectionEnabled = enabled; -}, "~B"); -Clazz.overrideMethod (c$, "addListSelectionListener", -function (listener) { -this.selectionListener = listener; -}, "~O"); -Clazz.overrideMethod (c$, "getColumn", -function (i) { -return this.tableModel.getColumn (i); -}, "~N"); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append ("\n"); -this.tableModel.toHTML (sb, this.id, this.bsSelectedRows); -sb.append ("\n
    \n"); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.ColumnSelectionModel", "$.JComponent", "$.ListSelectionModel"], "javajs.swing.JTable", ["javajs.util.BS", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.tableModel = null; +this.bsSelectedCells = null; +this.bsSelectedRows = null; +this.rowSelectionAllowed = false; +this.cellSelectionEnabled = false; +this.selectionListener = null; +Clazz.instantialize (this, arguments); +}, javajs.swing, "JTable", javajs.swing.JComponent, [javajs.swing.ListSelectionModel, javajs.swing.ColumnSelectionModel]); +Clazz.makeConstructor (c$, +function (tableModel) { +Clazz.superConstructor (this, javajs.swing.JTable, ["JT"]); +this.tableModel = tableModel; +this.bsSelectedCells = new javajs.util.BS (); +this.bsSelectedRows = new javajs.util.BS (); +}, "javajs.swing.AbstractTableModel"); +Clazz.overrideMethod (c$, "getSelectionModel", +function () { +return this; +}); +Clazz.defineMethod (c$, "getColumnModel", +function () { +return this; +}); +Clazz.defineMethod (c$, "setPreferredScrollableViewportSize", +function (dimension) { +this.width = dimension.width; +this.height = dimension.height; +}, "javajs.awt.Dimension"); +Clazz.defineMethod (c$, "clearSelection", +function () { +this.bsSelectedCells.clearAll (); +this.bsSelectedRows.clearAll (); +}); +Clazz.defineMethod (c$, "setRowSelectionAllowed", +function (b) { +this.rowSelectionAllowed = b; +}, "~B"); +Clazz.defineMethod (c$, "setRowSelectionInterval", +function (i, j) { +this.bsSelectedRows.clearAll (); +this.bsSelectedRows.setBits (i, j); +this.bsSelectedCells.clearAll (); +}, "~N,~N"); +Clazz.defineMethod (c$, "setCellSelectionEnabled", +function (enabled) { +this.cellSelectionEnabled = enabled; +}, "~B"); +Clazz.overrideMethod (c$, "addListSelectionListener", +function (listener) { +this.selectionListener = listener; +}, "~O"); +Clazz.overrideMethod (c$, "getColumn", +function (i) { +return this.tableModel.getColumn (i); +}, "~N"); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append ("\n"); +this.tableModel.toHTML (sb, this.id, this.bsSelectedRows); +sb.append ("\n
    \n"); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JTextField.js b/bin/javajs/swing/JTextField.js index 88b08a6..9cc639f 100644 --- a/bin/javajs/swing/JTextField.js +++ b/bin/javajs/swing/JTextField.js @@ -1,15 +1,15 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JTextField", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JTextField", javajs.swing.JComponent); -Clazz.makeConstructor (c$, -function (value) { -Clazz.superConstructor (this, javajs.swing.JTextField, ["txtJT"]); -this.text = value; -}, "~S"); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append (""); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.JComponent"], "javajs.swing.JTextField", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JTextField", javajs.swing.JComponent); +Clazz.makeConstructor (c$, +function (value) { +Clazz.superConstructor (this, javajs.swing.JTextField, ["txtJT"]); +this.text = value; +}, "~S"); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append (""); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/JTextPane.js b/bin/javajs/swing/JTextPane.js index 25d3764..23d5a22 100644 --- a/bin/javajs/swing/JTextPane.js +++ b/bin/javajs/swing/JTextPane.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.load (["javajs.swing.Document", "$.JComponent"], "javajs.swing.JTextPane", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.swing, "JTextPane", javajs.swing.JComponent, javajs.swing.Document); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.swing.JTextPane, ["txtJTP"]); -this.text = ""; -}); -Clazz.defineMethod (c$, "getDocument", -function () { -return this; -}); -Clazz.overrideMethod (c$, "insertString", -function (i, s, object) { -i = Math.min (i, this.text.length); -this.text = this.text.substring (0, i) + s + this.text.substring (i); -}, "~N,~S,~O"); -Clazz.overrideMethod (c$, "toHTML", -function () { -var sb = new javajs.util.SB (); -sb.append (""); -return sb.toString (); -}); -}); +Clazz.declarePackage ("javajs.swing"); +Clazz.load (["javajs.swing.Document", "$.JComponent"], "javajs.swing.JTextPane", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.swing, "JTextPane", javajs.swing.JComponent, javajs.swing.Document); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.swing.JTextPane, ["txtJTP"]); +this.text = ""; +}); +Clazz.defineMethod (c$, "getDocument", +function () { +return this; +}); +Clazz.overrideMethod (c$, "insertString", +function (i, s, object) { +i = Math.min (i, this.text.length); +this.text = this.text.substring (0, i) + s + this.text.substring (i); +}, "~N,~S,~O"); +Clazz.overrideMethod (c$, "toHTML", +function () { +var sb = new javajs.util.SB (); +sb.append (""); +return sb.toString (); +}); +}); diff --git a/bin/javajs/swing/ListSelectionModel.js b/bin/javajs/swing/ListSelectionModel.js index c5fd420..5cb1d3a 100644 --- a/bin/javajs/swing/ListSelectionModel.js +++ b/bin/javajs/swing/ListSelectionModel.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.declareInterface (javajs.swing, "ListSelectionModel"); +Clazz.declarePackage ("javajs.swing"); +Clazz.declareInterface (javajs.swing, "ListSelectionModel"); diff --git a/bin/javajs/swing/SwingConstants.js b/bin/javajs/swing/SwingConstants.js index 2298d0a..f10e094 100644 --- a/bin/javajs/swing/SwingConstants.js +++ b/bin/javajs/swing/SwingConstants.js @@ -1,6 +1,6 @@ -Clazz.declarePackage ("javajs.swing"); -c$ = Clazz.declareType (javajs.swing, "SwingConstants"); -Clazz.defineStatics (c$, -"LEFT", 2, -"CENTER", 0, -"RIGHT", 4); +Clazz.declarePackage ("javajs.swing"); +c$ = Clazz.declareType (javajs.swing, "SwingConstants"); +Clazz.defineStatics (c$, +"LEFT", 2, +"CENTER", 0, +"RIGHT", 4); diff --git a/bin/javajs/swing/TableCellRenderer.js b/bin/javajs/swing/TableCellRenderer.js index 6b1942e..94b3f9f 100644 --- a/bin/javajs/swing/TableCellRenderer.js +++ b/bin/javajs/swing/TableCellRenderer.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.declareInterface (javajs.swing, "TableCellRenderer"); +Clazz.declarePackage ("javajs.swing"); +Clazz.declareInterface (javajs.swing, "TableCellRenderer"); diff --git a/bin/javajs/swing/TableColumn.js b/bin/javajs/swing/TableColumn.js index 19d5394..e2fa800 100644 --- a/bin/javajs/swing/TableColumn.js +++ b/bin/javajs/swing/TableColumn.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("javajs.swing"); -Clazz.declareInterface (javajs.swing, "TableColumn"); +Clazz.declarePackage ("javajs.swing"); +Clazz.declareInterface (javajs.swing, "TableColumn"); diff --git a/bin/javajs/util/A4.js b/bin/javajs/util/A4.js index b3f66b8..d3d3a66 100644 --- a/bin/javajs/util/A4.js +++ b/bin/javajs/util/A4.js @@ -1,89 +1,89 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.A4", ["javajs.util.T3"], function () { -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.z = 0; -this.angle = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "A4", null, [javajs.api.JSONEncodable, java.io.Serializable]); -Clazz.makeConstructor (c$, -function () { -this.z = 1.0; -}); -c$.new4 = Clazz.defineMethod (c$, "new4", -function (x, y, z, angle) { -var a = new javajs.util.A4 (); -a.set4 (x, y, z, angle); -return a; -}, "~N,~N,~N,~N"); -c$.newAA = Clazz.defineMethod (c$, "newAA", -function (a1) { -var a = new javajs.util.A4 (); -a.set4 (a1.x, a1.y, a1.z, a1.angle); -return a; -}, "javajs.util.A4"); -c$.newVA = Clazz.defineMethod (c$, "newVA", -function (axis, angle) { -var a = new javajs.util.A4 (); -a.setVA (axis, angle); -return a; -}, "javajs.util.V3,~N"); -Clazz.defineMethod (c$, "setVA", -function (axis, angle) { -this.x = axis.x; -this.y = axis.y; -this.z = axis.z; -this.angle = angle; -}, "javajs.util.V3,~N"); -Clazz.defineMethod (c$, "set4", -function (x, y, z, angle) { -this.x = x; -this.y = y; -this.z = z; -this.angle = angle; -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "setAA", -function (a) { -this.x = a.x; -this.y = a.y; -this.z = a.z; -this.angle = a.angle; -}, "javajs.util.A4"); -Clazz.defineMethod (c$, "setM", -function (m1) { -this.setFromMat (m1.m00, m1.m01, m1.m02, m1.m10, m1.m11, m1.m12, m1.m20, m1.m21, m1.m22); -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "setFromMat", -($fz = function (m00, m01, m02, m10, m11, m12, m20, m21, m22) { -var cos = (m00 + m11 + m22 - 1.0) * 0.5; -this.x = (m21 - m12); -this.y = (m02 - m20); -this.z = (m10 - m01); -var sin = 0.5 * Math.sqrt (this.x * this.x + this.y * this.y + this.z * this.z); -if (sin == 0 && cos == 1) { -this.x = this.y = 0; -this.z = 1; -this.angle = 0; -} else { -this.angle = Math.atan2 (sin, cos); -}}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return javajs.util.T3.floatToIntBits0 (this.x) ^ javajs.util.T3.floatToIntBits0 (this.y) ^ javajs.util.T3.floatToIntBits0 (this.z) ^ javajs.util.T3.floatToIntBits0 (this.angle); -}); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (!(Clazz.instanceOf (o, javajs.util.A4))) return false; -var a1 = o; -return this.x == a1.x && this.y == a1.y && this.z == a1.z && this.angle == a1.angle; -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(" + this.x + ", " + this.y + ", " + this.z + ", " + this.angle + ")"; -}); -Clazz.overrideMethod (c$, "toJSON", -function () { -return "[" + this.x + "," + this.y + "," + this.z + "," + (this.angle * 180.0 / 3.141592653589793) + "]"; -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.A4", ["javajs.util.T3"], function () { +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.z = 0; +this.angle = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "A4", null, [javajs.api.JSONEncodable, java.io.Serializable]); +Clazz.makeConstructor (c$, +function () { +this.z = 1.0; +}); +c$.new4 = Clazz.defineMethod (c$, "new4", +function (x, y, z, angle) { +var a = new javajs.util.A4 (); +a.set4 (x, y, z, angle); +return a; +}, "~N,~N,~N,~N"); +c$.newAA = Clazz.defineMethod (c$, "newAA", +function (a1) { +var a = new javajs.util.A4 (); +a.set4 (a1.x, a1.y, a1.z, a1.angle); +return a; +}, "javajs.util.A4"); +c$.newVA = Clazz.defineMethod (c$, "newVA", +function (axis, angle) { +var a = new javajs.util.A4 (); +a.setVA (axis, angle); +return a; +}, "javajs.util.V3,~N"); +Clazz.defineMethod (c$, "setVA", +function (axis, angle) { +this.x = axis.x; +this.y = axis.y; +this.z = axis.z; +this.angle = angle; +}, "javajs.util.V3,~N"); +Clazz.defineMethod (c$, "set4", +function (x, y, z, angle) { +this.x = x; +this.y = y; +this.z = z; +this.angle = angle; +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "setAA", +function (a) { +this.x = a.x; +this.y = a.y; +this.z = a.z; +this.angle = a.angle; +}, "javajs.util.A4"); +Clazz.defineMethod (c$, "setM", +function (m1) { +this.setFromMat (m1.m00, m1.m01, m1.m02, m1.m10, m1.m11, m1.m12, m1.m20, m1.m21, m1.m22); +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "setFromMat", +($fz = function (m00, m01, m02, m10, m11, m12, m20, m21, m22) { +var cos = (m00 + m11 + m22 - 1.0) * 0.5; +this.x = (m21 - m12); +this.y = (m02 - m20); +this.z = (m10 - m01); +var sin = 0.5 * Math.sqrt (this.x * this.x + this.y * this.y + this.z * this.z); +if (sin == 0 && cos == 1) { +this.x = this.y = 0; +this.z = 1; +this.angle = 0; +} else { +this.angle = Math.atan2 (sin, cos); +}}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return javajs.util.T3.floatToIntBits0 (this.x) ^ javajs.util.T3.floatToIntBits0 (this.y) ^ javajs.util.T3.floatToIntBits0 (this.z) ^ javajs.util.T3.floatToIntBits0 (this.angle); +}); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (!(Clazz.instanceOf (o, javajs.util.A4))) return false; +var a1 = o; +return this.x == a1.x && this.y == a1.y && this.z == a1.z && this.angle == a1.angle; +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(" + this.x + ", " + this.y + ", " + this.z + ", " + this.angle + ")"; +}); +Clazz.overrideMethod (c$, "toJSON", +function () { +return "[" + this.x + "," + this.y + "," + this.z + "," + (this.angle * 180.0 / 3.141592653589793) + "]"; +}); +}); diff --git a/bin/javajs/util/AU.js b/bin/javajs/util/AU.js index 080d17c..f7f0201 100644 --- a/bin/javajs/util/AU.js +++ b/bin/javajs/util/AU.js @@ -1,351 +1,351 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.AU", ["java.util.Arrays", "javajs.util.Lst"], function () { -c$ = Clazz.declareType (javajs.util, "AU"); -c$.ensureLength = Clazz.defineMethod (c$, "ensureLength", -function (array, minimumLength) { -if (array != null && javajs.util.AU.getLength (array) >= minimumLength) return array; -return javajs.util.AU.arrayCopyObject (array, minimumLength); -}, "~O,~N"); -c$.ensureLengthS = Clazz.defineMethod (c$, "ensureLengthS", -function (array, minimumLength) { -if (array != null && array.length >= minimumLength) return array; -return javajs.util.AU.arrayCopyS (array, minimumLength); -}, "~A,~N"); -c$.ensureLengthA = Clazz.defineMethod (c$, "ensureLengthA", -function (array, minimumLength) { -if (array != null && array.length >= minimumLength) return array; -return javajs.util.AU.arrayCopyF (array, minimumLength); -}, "~A,~N"); -c$.ensureLengthI = Clazz.defineMethod (c$, "ensureLengthI", -function (array, minimumLength) { -if (array != null && array.length >= minimumLength) return array; -return javajs.util.AU.arrayCopyI (array, minimumLength); -}, "~A,~N"); -c$.ensureLengthShort = Clazz.defineMethod (c$, "ensureLengthShort", -function (array, minimumLength) { -if (array != null && array.length >= minimumLength) return array; -return javajs.util.AU.arrayCopyShort (array, minimumLength); -}, "~A,~N"); -c$.ensureLengthByte = Clazz.defineMethod (c$, "ensureLengthByte", -function (array, minimumLength) { -if (array != null && array.length >= minimumLength) return array; -return javajs.util.AU.arrayCopyByte (array, minimumLength); -}, "~A,~N"); -c$.doubleLength = Clazz.defineMethod (c$, "doubleLength", -function (array) { -return javajs.util.AU.arrayCopyObject (array, (array == null ? 16 : 2 * javajs.util.AU.getLength (array))); -}, "~O"); -c$.doubleLengthS = Clazz.defineMethod (c$, "doubleLengthS", -function (array) { -return javajs.util.AU.arrayCopyS (array, (array == null ? 16 : 2 * array.length)); -}, "~A"); -c$.doubleLengthF = Clazz.defineMethod (c$, "doubleLengthF", -function (array) { -return javajs.util.AU.arrayCopyF (array, (array == null ? 16 : 2 * array.length)); -}, "~A"); -c$.doubleLengthI = Clazz.defineMethod (c$, "doubleLengthI", -function (array) { -return javajs.util.AU.arrayCopyI (array, (array == null ? 16 : 2 * array.length)); -}, "~A"); -c$.doubleLengthShort = Clazz.defineMethod (c$, "doubleLengthShort", -function (array) { -return javajs.util.AU.arrayCopyShort (array, (array == null ? 16 : 2 * array.length)); -}, "~A"); -c$.doubleLengthByte = Clazz.defineMethod (c$, "doubleLengthByte", -function (array) { -return javajs.util.AU.arrayCopyByte (array, (array == null ? 16 : 2 * array.length)); -}, "~A"); -c$.doubleLengthBool = Clazz.defineMethod (c$, "doubleLengthBool", -function (array) { -return javajs.util.AU.arrayCopyBool (array, (array == null ? 16 : 2 * array.length)); -}, "~A"); -c$.deleteElements = Clazz.defineMethod (c$, "deleteElements", -function (array, firstElement, nElements) { -if (nElements == 0 || array == null) return array; -var oldLength = javajs.util.AU.getLength (array); -if (firstElement >= oldLength) return array; -var n = oldLength - (firstElement + nElements); -if (n < 0) n = 0; -var t = javajs.util.AU.newInstanceO (array, firstElement + n); -if (firstElement > 0) System.arraycopy (array, 0, t, 0, firstElement); -if (n > 0) System.arraycopy (array, firstElement + nElements, t, firstElement, n); -return t; -}, "~O,~N,~N"); -c$.arrayCopyObject = Clazz.defineMethod (c$, "arrayCopyObject", -function (array, newLength) { -if (array == null) { -return null; -}var oldLength = javajs.util.AU.getLength (array); -if (newLength == oldLength) return array; -var t = javajs.util.AU.newInstanceO (array, newLength); -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -return t; -}, "~O,~N"); -c$.newInstanceO = Clazz.defineMethod (c$, "newInstanceO", -($fz = function (array, n) { -{ -if (!array.getClass().getComponentType) -return new Array(n); -}}, $fz.isPrivate = true, $fz), "~O,~N"); -c$.getLength = Clazz.defineMethod (c$, "getLength", -function (array) { -{ -return array.length -}}, "~O"); -c$.arrayCopyS = Clazz.defineMethod (c$, "arrayCopyS", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = new Array (newLength); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyII = Clazz.defineMethod (c$, "arrayCopyII", -function (array, newLength) { -var t = javajs.util.AU.newInt2 (newLength); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyPt = Clazz.defineMethod (c$, "arrayCopyPt", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = new Array (newLength); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyF = Clazz.defineMethod (c$, "arrayCopyF", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = Clazz.newFloatArray (newLength, 0); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyI = Clazz.defineMethod (c$, "arrayCopyI", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = Clazz.newIntArray (newLength, 0); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyRangeI = Clazz.defineMethod (c$, "arrayCopyRangeI", -function (array, i0, n) { -if (array == null) return null; -var oldLength = array.length; -if (n == -1) n = oldLength; -if (n == -2) n = Clazz.doubleToInt (oldLength / 2); -n = n - i0; -var t = Clazz.newIntArray (n, 0); -System.arraycopy (array, i0, t, 0, n); -return t; -}, "~A,~N,~N"); -c$.arrayCopyRangeRevI = Clazz.defineMethod (c$, "arrayCopyRangeRevI", -function (array, i0, n) { -if (array == null) return null; -var t = javajs.util.AU.arrayCopyRangeI (array, i0, n); -if (n < 0) n = array.length; -for (var i = Clazz.doubleToInt (n / 2); --i >= 0; ) javajs.util.AU.swapInt (t, i, n - 1 - i); - -return t; -}, "~A,~N,~N"); -c$.arrayCopyShort = Clazz.defineMethod (c$, "arrayCopyShort", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = Clazz.newShortArray (newLength, 0); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyByte = Clazz.defineMethod (c$, "arrayCopyByte", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = Clazz.newByteArray (newLength, 0); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.arrayCopyBool = Clazz.defineMethod (c$, "arrayCopyBool", -function (array, newLength) { -if (newLength < 0) newLength = array.length; -var t = Clazz.newBooleanArray (newLength, false); -if (array != null) { -var oldLength = array.length; -System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); -}return t; -}, "~A,~N"); -c$.swapInt = Clazz.defineMethod (c$, "swapInt", -function (array, indexA, indexB) { -var t = array[indexA]; -array[indexA] = array[indexB]; -array[indexB] = t; -}, "~A,~N,~N"); -c$.dumpArray = Clazz.defineMethod (c$, "dumpArray", -function (msg, A, x1, x2, y1, y2) { -var s = "dumpArray: " + msg + "\n"; -for (var x = x1; x <= x2; x++) s += "\t*" + x + "*"; - -for (var y = y2; y >= y1; y--) { -s += "\n*" + y + "*"; -for (var x = x1; x <= x2; x++) s += "\t" + (x < A.length && y < A[x].length ? A[x][y] : NaN); - -} -return s; -}, "~S,~A,~N,~N,~N,~N"); -c$.dumpIntArray = Clazz.defineMethod (c$, "dumpIntArray", -function (A, n) { -var str = ""; -for (var i = 0; i < n; i++) str += " " + A[i]; - -return str; -}, "~A,~N"); -c$.sortedItem = Clazz.defineMethod (c$, "sortedItem", -function (v, n) { -if (v.size () == 0) return null; -if (v.size () == 1) return v.get (0); -var keys = v.toArray ( new Array (v.size ())); -java.util.Arrays.sort (keys); -return keys[n % keys.length]; -}, "javajs.util.Lst,~N"); -c$.createArrayOfArrayList = Clazz.defineMethod (c$, "createArrayOfArrayList", -function (size) { -return new Array (size); -}, "~N"); -c$.createArrayOfHashtable = Clazz.defineMethod (c$, "createArrayOfHashtable", -function (size) { -return new Array (size); -}, "~N"); -c$.swap = Clazz.defineMethod (c$, "swap", -function (o, i, j) { -var oi = o[i]; -o[i] = o[j]; -o[j] = oi; -}, "~A,~N,~N"); -c$.newFloat2 = Clazz.defineMethod (c$, "newFloat2", -function (n) { -{ -return Clazz.newArray(n, null); -}}, "~N"); -c$.newInt2 = Clazz.defineMethod (c$, "newInt2", -function (n) { -{ -return Clazz.newArray(n, null); -}}, "~N"); -c$.newInt3 = Clazz.defineMethod (c$, "newInt3", -function (nx, ny) { -{ -return Clazz.newArray(nx, null); -}}, "~N,~N"); -c$.newFloat3 = Clazz.defineMethod (c$, "newFloat3", -function (nx, ny) { -{ -return Clazz.newArray(nx, null); -}}, "~N,~N"); -c$.newInt4 = Clazz.defineMethod (c$, "newInt4", -function (n) { -{ -return Clazz.newArray(n, null); -}}, "~N"); -c$.newShort2 = Clazz.defineMethod (c$, "newShort2", -function (n) { -{ -return Clazz.newArray(n, null); -}}, "~N"); -c$.newByte2 = Clazz.defineMethod (c$, "newByte2", -function (n) { -{ -return Clazz.newArray(n, null); -}}, "~N"); -c$.newDouble2 = Clazz.defineMethod (c$, "newDouble2", -function (n) { -{ -return Clazz.newArray(n, null); -}}, "~N"); -c$.removeMapKeys = Clazz.defineMethod (c$, "removeMapKeys", -function (map, root) { -var list = new javajs.util.Lst (); -for (var key, $key = map.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) if (key.startsWith (root)) list.addLast (key); - -for (var i = list.size (); --i >= 0; ) map.remove (list.get (i)); - -return list.size (); -}, "java.util.Map,~S"); -c$.isAS = Clazz.defineMethod (c$, "isAS", -function (x) { -{ -return Clazz.isAS(x); -}}, "~O"); -c$.isASS = Clazz.defineMethod (c$, "isASS", -function (x) { -{ -return Clazz.isASS(x); -}}, "~O"); -c$.isAP = Clazz.defineMethod (c$, "isAP", -function (x) { -{ -return Clazz.isAP(x); -}}, "~O"); -c$.isAF = Clazz.defineMethod (c$, "isAF", -function (x) { -{ -return Clazz.isAF(x); -}}, "~O"); -c$.isAFloat = Clazz.defineMethod (c$, "isAFloat", -function (x) { -{ -return Clazz.isAFloat(x); -}}, "~O"); -c$.isAD = Clazz.defineMethod (c$, "isAD", -function (x) { -{ -return Clazz.isAF(x); -}}, "~O"); -c$.isADD = Clazz.defineMethod (c$, "isADD", -function (x) { -{ -return Clazz.isAFF(x); -}}, "~O"); -c$.isAB = Clazz.defineMethod (c$, "isAB", -function (x) { -{ -return Clazz.isAI(x); -}}, "~O"); -c$.isAI = Clazz.defineMethod (c$, "isAI", -function (x) { -{ -return Clazz.isAI(x); -}}, "~O"); -c$.isAII = Clazz.defineMethod (c$, "isAII", -function (x) { -{ -return Clazz.isAII(x); -}}, "~O"); -c$.isAFF = Clazz.defineMethod (c$, "isAFF", -function (x) { -{ -return Clazz.isAFF(x); -}}, "~O"); -c$.isAFFF = Clazz.defineMethod (c$, "isAFFF", -function (x) { -{ -return Clazz.isAFFF(x); -}}, "~O"); -c$.ensureSignedBytes = Clazz.defineMethod (c$, "ensureSignedBytes", -function (b) { -{ -for (var i = b.length; --i >= 0;) { -var j = b[i] & 0xFF; -if (j >= 0x80) j -= 0x100; -b[i] = j; -} -}}, "~A"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.AU", ["java.util.Arrays", "javajs.util.Lst"], function () { +c$ = Clazz.declareType (javajs.util, "AU"); +c$.ensureLength = Clazz.defineMethod (c$, "ensureLength", +function (array, minimumLength) { +if (array != null && javajs.util.AU.getLength (array) >= minimumLength) return array; +return javajs.util.AU.arrayCopyObject (array, minimumLength); +}, "~O,~N"); +c$.ensureLengthS = Clazz.defineMethod (c$, "ensureLengthS", +function (array, minimumLength) { +if (array != null && array.length >= minimumLength) return array; +return javajs.util.AU.arrayCopyS (array, minimumLength); +}, "~A,~N"); +c$.ensureLengthA = Clazz.defineMethod (c$, "ensureLengthA", +function (array, minimumLength) { +if (array != null && array.length >= minimumLength) return array; +return javajs.util.AU.arrayCopyF (array, minimumLength); +}, "~A,~N"); +c$.ensureLengthI = Clazz.defineMethod (c$, "ensureLengthI", +function (array, minimumLength) { +if (array != null && array.length >= minimumLength) return array; +return javajs.util.AU.arrayCopyI (array, minimumLength); +}, "~A,~N"); +c$.ensureLengthShort = Clazz.defineMethod (c$, "ensureLengthShort", +function (array, minimumLength) { +if (array != null && array.length >= minimumLength) return array; +return javajs.util.AU.arrayCopyShort (array, minimumLength); +}, "~A,~N"); +c$.ensureLengthByte = Clazz.defineMethod (c$, "ensureLengthByte", +function (array, minimumLength) { +if (array != null && array.length >= minimumLength) return array; +return javajs.util.AU.arrayCopyByte (array, minimumLength); +}, "~A,~N"); +c$.doubleLength = Clazz.defineMethod (c$, "doubleLength", +function (array) { +return javajs.util.AU.arrayCopyObject (array, (array == null ? 16 : 2 * javajs.util.AU.getLength (array))); +}, "~O"); +c$.doubleLengthS = Clazz.defineMethod (c$, "doubleLengthS", +function (array) { +return javajs.util.AU.arrayCopyS (array, (array == null ? 16 : 2 * array.length)); +}, "~A"); +c$.doubleLengthF = Clazz.defineMethod (c$, "doubleLengthF", +function (array) { +return javajs.util.AU.arrayCopyF (array, (array == null ? 16 : 2 * array.length)); +}, "~A"); +c$.doubleLengthI = Clazz.defineMethod (c$, "doubleLengthI", +function (array) { +return javajs.util.AU.arrayCopyI (array, (array == null ? 16 : 2 * array.length)); +}, "~A"); +c$.doubleLengthShort = Clazz.defineMethod (c$, "doubleLengthShort", +function (array) { +return javajs.util.AU.arrayCopyShort (array, (array == null ? 16 : 2 * array.length)); +}, "~A"); +c$.doubleLengthByte = Clazz.defineMethod (c$, "doubleLengthByte", +function (array) { +return javajs.util.AU.arrayCopyByte (array, (array == null ? 16 : 2 * array.length)); +}, "~A"); +c$.doubleLengthBool = Clazz.defineMethod (c$, "doubleLengthBool", +function (array) { +return javajs.util.AU.arrayCopyBool (array, (array == null ? 16 : 2 * array.length)); +}, "~A"); +c$.deleteElements = Clazz.defineMethod (c$, "deleteElements", +function (array, firstElement, nElements) { +if (nElements == 0 || array == null) return array; +var oldLength = javajs.util.AU.getLength (array); +if (firstElement >= oldLength) return array; +var n = oldLength - (firstElement + nElements); +if (n < 0) n = 0; +var t = javajs.util.AU.newInstanceO (array, firstElement + n); +if (firstElement > 0) System.arraycopy (array, 0, t, 0, firstElement); +if (n > 0) System.arraycopy (array, firstElement + nElements, t, firstElement, n); +return t; +}, "~O,~N,~N"); +c$.arrayCopyObject = Clazz.defineMethod (c$, "arrayCopyObject", +function (array, newLength) { +if (array == null) { +return null; +}var oldLength = javajs.util.AU.getLength (array); +if (newLength == oldLength) return array; +var t = javajs.util.AU.newInstanceO (array, newLength); +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +return t; +}, "~O,~N"); +c$.newInstanceO = Clazz.defineMethod (c$, "newInstanceO", +($fz = function (array, n) { +{ +if (!array.getClass().getComponentType) +return new Array(n); +}}, $fz.isPrivate = true, $fz), "~O,~N"); +c$.getLength = Clazz.defineMethod (c$, "getLength", +function (array) { +{ +return array.length +}}, "~O"); +c$.arrayCopyS = Clazz.defineMethod (c$, "arrayCopyS", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = new Array (newLength); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyII = Clazz.defineMethod (c$, "arrayCopyII", +function (array, newLength) { +var t = javajs.util.AU.newInt2 (newLength); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyPt = Clazz.defineMethod (c$, "arrayCopyPt", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = new Array (newLength); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyF = Clazz.defineMethod (c$, "arrayCopyF", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = Clazz.newFloatArray (newLength, 0); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyI = Clazz.defineMethod (c$, "arrayCopyI", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = Clazz.newIntArray (newLength, 0); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyRangeI = Clazz.defineMethod (c$, "arrayCopyRangeI", +function (array, i0, n) { +if (array == null) return null; +var oldLength = array.length; +if (n == -1) n = oldLength; +if (n == -2) n = Clazz.doubleToInt (oldLength / 2); +n = n - i0; +var t = Clazz.newIntArray (n, 0); +System.arraycopy (array, i0, t, 0, n); +return t; +}, "~A,~N,~N"); +c$.arrayCopyRangeRevI = Clazz.defineMethod (c$, "arrayCopyRangeRevI", +function (array, i0, n) { +if (array == null) return null; +var t = javajs.util.AU.arrayCopyRangeI (array, i0, n); +if (n < 0) n = array.length; +for (var i = Clazz.doubleToInt (n / 2); --i >= 0; ) javajs.util.AU.swapInt (t, i, n - 1 - i); + +return t; +}, "~A,~N,~N"); +c$.arrayCopyShort = Clazz.defineMethod (c$, "arrayCopyShort", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = Clazz.newShortArray (newLength, 0); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyByte = Clazz.defineMethod (c$, "arrayCopyByte", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = Clazz.newByteArray (newLength, 0); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.arrayCopyBool = Clazz.defineMethod (c$, "arrayCopyBool", +function (array, newLength) { +if (newLength < 0) newLength = array.length; +var t = Clazz.newBooleanArray (newLength, false); +if (array != null) { +var oldLength = array.length; +System.arraycopy (array, 0, t, 0, oldLength < newLength ? oldLength : newLength); +}return t; +}, "~A,~N"); +c$.swapInt = Clazz.defineMethod (c$, "swapInt", +function (array, indexA, indexB) { +var t = array[indexA]; +array[indexA] = array[indexB]; +array[indexB] = t; +}, "~A,~N,~N"); +c$.dumpArray = Clazz.defineMethod (c$, "dumpArray", +function (msg, A, x1, x2, y1, y2) { +var s = "dumpArray: " + msg + "\n"; +for (var x = x1; x <= x2; x++) s += "\t*" + x + "*"; + +for (var y = y2; y >= y1; y--) { +s += "\n*" + y + "*"; +for (var x = x1; x <= x2; x++) s += "\t" + (x < A.length && y < A[x].length ? A[x][y] : NaN); + +} +return s; +}, "~S,~A,~N,~N,~N,~N"); +c$.dumpIntArray = Clazz.defineMethod (c$, "dumpIntArray", +function (A, n) { +var str = ""; +for (var i = 0; i < n; i++) str += " " + A[i]; + +return str; +}, "~A,~N"); +c$.sortedItem = Clazz.defineMethod (c$, "sortedItem", +function (v, n) { +if (v.size () == 0) return null; +if (v.size () == 1) return v.get (0); +var keys = v.toArray ( new Array (v.size ())); +java.util.Arrays.sort (keys); +return keys[n % keys.length]; +}, "javajs.util.Lst,~N"); +c$.createArrayOfArrayList = Clazz.defineMethod (c$, "createArrayOfArrayList", +function (size) { +return new Array (size); +}, "~N"); +c$.createArrayOfHashtable = Clazz.defineMethod (c$, "createArrayOfHashtable", +function (size) { +return new Array (size); +}, "~N"); +c$.swap = Clazz.defineMethod (c$, "swap", +function (o, i, j) { +var oi = o[i]; +o[i] = o[j]; +o[j] = oi; +}, "~A,~N,~N"); +c$.newFloat2 = Clazz.defineMethod (c$, "newFloat2", +function (n) { +{ +return Clazz.newArray(n, null); +}}, "~N"); +c$.newInt2 = Clazz.defineMethod (c$, "newInt2", +function (n) { +{ +return Clazz.newArray(n, null); +}}, "~N"); +c$.newInt3 = Clazz.defineMethod (c$, "newInt3", +function (nx, ny) { +{ +return Clazz.newArray(nx, null); +}}, "~N,~N"); +c$.newFloat3 = Clazz.defineMethod (c$, "newFloat3", +function (nx, ny) { +{ +return Clazz.newArray(nx, null); +}}, "~N,~N"); +c$.newInt4 = Clazz.defineMethod (c$, "newInt4", +function (n) { +{ +return Clazz.newArray(n, null); +}}, "~N"); +c$.newShort2 = Clazz.defineMethod (c$, "newShort2", +function (n) { +{ +return Clazz.newArray(n, null); +}}, "~N"); +c$.newByte2 = Clazz.defineMethod (c$, "newByte2", +function (n) { +{ +return Clazz.newArray(n, null); +}}, "~N"); +c$.newDouble2 = Clazz.defineMethod (c$, "newDouble2", +function (n) { +{ +return Clazz.newArray(n, null); +}}, "~N"); +c$.removeMapKeys = Clazz.defineMethod (c$, "removeMapKeys", +function (map, root) { +var list = new javajs.util.Lst (); +for (var key, $key = map.keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) if (key.startsWith (root)) list.addLast (key); + +for (var i = list.size (); --i >= 0; ) map.remove (list.get (i)); + +return list.size (); +}, "java.util.Map,~S"); +c$.isAS = Clazz.defineMethod (c$, "isAS", +function (x) { +{ +return Clazz.isAS(x); +}}, "~O"); +c$.isASS = Clazz.defineMethod (c$, "isASS", +function (x) { +{ +return Clazz.isASS(x); +}}, "~O"); +c$.isAP = Clazz.defineMethod (c$, "isAP", +function (x) { +{ +return Clazz.isAP(x); +}}, "~O"); +c$.isAF = Clazz.defineMethod (c$, "isAF", +function (x) { +{ +return Clazz.isAF(x); +}}, "~O"); +c$.isAFloat = Clazz.defineMethod (c$, "isAFloat", +function (x) { +{ +return Clazz.isAFloat(x); +}}, "~O"); +c$.isAD = Clazz.defineMethod (c$, "isAD", +function (x) { +{ +return Clazz.isAF(x); +}}, "~O"); +c$.isADD = Clazz.defineMethod (c$, "isADD", +function (x) { +{ +return Clazz.isAFF(x); +}}, "~O"); +c$.isAB = Clazz.defineMethod (c$, "isAB", +function (x) { +{ +return Clazz.isAI(x); +}}, "~O"); +c$.isAI = Clazz.defineMethod (c$, "isAI", +function (x) { +{ +return Clazz.isAI(x); +}}, "~O"); +c$.isAII = Clazz.defineMethod (c$, "isAII", +function (x) { +{ +return Clazz.isAII(x); +}}, "~O"); +c$.isAFF = Clazz.defineMethod (c$, "isAFF", +function (x) { +{ +return Clazz.isAFF(x); +}}, "~O"); +c$.isAFFF = Clazz.defineMethod (c$, "isAFFF", +function (x) { +{ +return Clazz.isAFFF(x); +}}, "~O"); +c$.ensureSignedBytes = Clazz.defineMethod (c$, "ensureSignedBytes", +function (b) { +{ +for (var i = b.length; --i >= 0;) { +var j = b[i] & 0xFF; +if (j >= 0x80) j -= 0x100; +b[i] = j; +} +}}, "~A"); +}); diff --git a/bin/javajs/util/AjaxURLConnection.js b/bin/javajs/util/AjaxURLConnection.js index 50f227d..41e35ef 100644 --- a/bin/javajs/util/AjaxURLConnection.js +++ b/bin/javajs/util/AjaxURLConnection.js @@ -1,39 +1,39 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.net.URLConnection"], "javajs.util.AjaxURLConnection", ["javajs.util.AU", "$.Rdr", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.bytesOut = null; -this.postOut = ""; -Clazz.instantialize (this, arguments); -}, javajs.util, "AjaxURLConnection", java.net.URLConnection); -Clazz.defineMethod (c$, "doAjax", -($fz = function () { -var jmol = null; -{ -jmol = Jmol; -}return jmol._doAjax (this.url, this.postOut, this.bytesOut); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "connect", -function () { -}); -Clazz.defineMethod (c$, "outputBytes", -function (bytes) { -this.bytesOut = bytes; -}, "~A"); -Clazz.defineMethod (c$, "outputString", -function (post) { -this.postOut = post; -}, "~S"); -Clazz.overrideMethod (c$, "getInputStream", -function () { -var is = null; -var o = this.doAjax (); -if (javajs.util.AU.isAB (o)) is = javajs.util.Rdr.getBIS (o); - else if (Clazz.instanceOf (o, javajs.util.SB)) is = javajs.util.Rdr.getBIS (javajs.util.Rdr.getBytesFromSB (o)); - else if (Clazz.instanceOf (o, String)) is = javajs.util.Rdr.getBIS ((o).getBytes ()); -return is; -}); -Clazz.defineMethod (c$, "getContents", -function () { -return this.doAjax (); -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.net.URLConnection"], "javajs.util.AjaxURLConnection", ["javajs.util.AU", "$.Rdr", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.bytesOut = null; +this.postOut = ""; +Clazz.instantialize (this, arguments); +}, javajs.util, "AjaxURLConnection", java.net.URLConnection); +Clazz.defineMethod (c$, "doAjax", +($fz = function () { +var jmol = null; +{ +jmol = Jmol; +}return jmol._doAjax (this.url, this.postOut, this.bytesOut); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "connect", +function () { +}); +Clazz.defineMethod (c$, "outputBytes", +function (bytes) { +this.bytesOut = bytes; +}, "~A"); +Clazz.defineMethod (c$, "outputString", +function (post) { +this.postOut = post; +}, "~S"); +Clazz.overrideMethod (c$, "getInputStream", +function () { +var is = null; +var o = this.doAjax (); +if (javajs.util.AU.isAB (o)) is = javajs.util.Rdr.getBIS (o); + else if (Clazz.instanceOf (o, javajs.util.SB)) is = javajs.util.Rdr.getBIS (javajs.util.Rdr.getBytesFromSB (o)); + else if (Clazz.instanceOf (o, String)) is = javajs.util.Rdr.getBIS ((o).getBytes ()); +return is; +}); +Clazz.defineMethod (c$, "getContents", +function () { +return this.doAjax (); +}); +}); diff --git a/bin/javajs/util/AjaxURLStreamHandler.js b/bin/javajs/util/AjaxURLStreamHandler.js index 59628d6..600c417 100644 --- a/bin/javajs/util/AjaxURLStreamHandler.js +++ b/bin/javajs/util/AjaxURLStreamHandler.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.net.URLStreamHandler"], "javajs.util.AjaxURLStreamHandler", ["javajs.util.AjaxURLConnection", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.protocol = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "AjaxURLStreamHandler", java.net.URLStreamHandler); -Clazz.makeConstructor (c$, -function (protocol) { -Clazz.superConstructor (this, javajs.util.AjaxURLStreamHandler, []); -this.protocol = protocol; -}, "~S"); -Clazz.defineMethod (c$, "openConnection", -function (url) { -return new javajs.util.AjaxURLConnection (url); -}, "java.net.URL"); -Clazz.overrideMethod (c$, "toExternalForm", -function (u) { -var result = new javajs.util.SB (); -result.append (u.getProtocol ()); -result.append (":"); -if (u.getAuthority () != null && u.getAuthority ().length > 0) { -result.append ("//"); -result.append (u.getAuthority ()); -}if (u.getPath () != null) { -result.append (u.getPath ()); -}if (u.getQuery () != null) { -result.append ("?"); -result.append (u.getQuery ()); -}if (u.getRef () != null) { -result.append ("#"); -result.append (u.getRef ()); -}return result.toString (); -}, "java.net.URL"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.net.URLStreamHandler"], "javajs.util.AjaxURLStreamHandler", ["javajs.util.AjaxURLConnection", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.protocol = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "AjaxURLStreamHandler", java.net.URLStreamHandler); +Clazz.makeConstructor (c$, +function (protocol) { +Clazz.superConstructor (this, javajs.util.AjaxURLStreamHandler, []); +this.protocol = protocol; +}, "~S"); +Clazz.defineMethod (c$, "openConnection", +function (url) { +return new javajs.util.AjaxURLConnection (url); +}, "java.net.URL"); +Clazz.overrideMethod (c$, "toExternalForm", +function (u) { +var result = new javajs.util.SB (); +result.append (u.getProtocol ()); +result.append (":"); +if (u.getAuthority () != null && u.getAuthority ().length > 0) { +result.append ("//"); +result.append (u.getAuthority ()); +}if (u.getPath () != null) { +result.append (u.getPath ()); +}if (u.getQuery () != null) { +result.append ("?"); +result.append (u.getQuery ()); +}if (u.getRef () != null) { +result.append ("#"); +result.append (u.getRef ()); +}return result.toString (); +}, "java.net.URL"); +}); diff --git a/bin/javajs/util/AjaxURLStreamHandlerFactory.js b/bin/javajs/util/AjaxURLStreamHandlerFactory.js index e51bb4e..88452ce 100644 --- a/bin/javajs/util/AjaxURLStreamHandlerFactory.js +++ b/bin/javajs/util/AjaxURLStreamHandlerFactory.js @@ -1,16 +1,16 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.net.URLStreamHandlerFactory", "java.util.Hashtable"], "javajs.util.AjaxURLStreamHandlerFactory", ["javajs.util.AjaxURLStreamHandler"], function () { -c$ = Clazz.decorateAsClass (function () { -this.htFactories = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "AjaxURLStreamHandlerFactory", null, java.net.URLStreamHandlerFactory); -Clazz.prepareFields (c$, function () { -this.htFactories = new java.util.Hashtable (); -}); -Clazz.overrideMethod (c$, "createURLStreamHandler", -function (protocol) { -var fac = this.htFactories.get (protocol); -if (fac == null) this.htFactories.put (protocol, fac = new javajs.util.AjaxURLStreamHandler (protocol)); -return (fac.protocol == null ? null : fac); -}, "~S"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.net.URLStreamHandlerFactory", "java.util.Hashtable"], "javajs.util.AjaxURLStreamHandlerFactory", ["javajs.util.AjaxURLStreamHandler"], function () { +c$ = Clazz.decorateAsClass (function () { +this.htFactories = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "AjaxURLStreamHandlerFactory", null, java.net.URLStreamHandlerFactory); +Clazz.prepareFields (c$, function () { +this.htFactories = new java.util.Hashtable (); +}); +Clazz.overrideMethod (c$, "createURLStreamHandler", +function (protocol) { +var fac = this.htFactories.get (protocol); +if (fac == null) this.htFactories.put (protocol, fac = new javajs.util.AjaxURLStreamHandler (protocol)); +return (fac.protocol == null ? null : fac); +}, "~S"); +}); diff --git a/bin/javajs/util/ArrayDataReader.js b/bin/javajs/util/ArrayDataReader.js index 532e8a9..89f64c3 100644 --- a/bin/javajs/util/ArrayDataReader.js +++ b/bin/javajs/util/ArrayDataReader.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.DataReader"], "javajs.util.ArrayDataReader", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.data = null; -this.pt = 0; -this.len = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "ArrayDataReader", javajs.util.DataReader); -Clazz.overrideMethod (c$, "setData", -function (data) { -this.data = data; -this.len = this.data.length; -return this; -}, "~O"); -Clazz.defineMethod (c$, "read", -function (buf, off, len) { -return this.readBuf (buf, off, len); -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "readLine", -function () { -return (this.pt < this.len ? this.data[this.pt++] : null); -}); -Clazz.defineMethod (c$, "mark", -function (ptr) { -this.ptMark = this.pt; -}, "~N"); -Clazz.overrideMethod (c$, "reset", -function () { -this.pt = this.ptMark; -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.DataReader"], "javajs.util.ArrayDataReader", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.data = null; +this.pt = 0; +this.len = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "ArrayDataReader", javajs.util.DataReader); +Clazz.overrideMethod (c$, "setData", +function (data) { +this.data = data; +this.len = this.data.length; +return this; +}, "~O"); +Clazz.defineMethod (c$, "read", +function (buf, off, len) { +return this.readBuf (buf, off, len); +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "readLine", +function () { +return (this.pt < this.len ? this.data[this.pt++] : null); +}); +Clazz.defineMethod (c$, "mark", +function (ptr) { +this.ptMark = this.pt; +}, "~N"); +Clazz.overrideMethod (c$, "reset", +function () { +this.pt = this.ptMark; +}); +}); diff --git a/bin/javajs/util/BArray.js b/bin/javajs/util/BArray.js index 866e432..33ba55d 100644 --- a/bin/javajs/util/BArray.js +++ b/bin/javajs/util/BArray.js @@ -1,27 +1,27 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.data = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "BArray"); -Clazz.makeConstructor (c$, -function (data) { -this.data = data; -}, "~A"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (Clazz.instanceOf (o, javajs.util.BArray)) { -var d = (o).data; -if (d.length == this.data.length) { -for (var i = 0; i < d.length; i++) if (d[i] != this.data[i]) return false; - -return true; -}}return false; -}, "~O"); -Clazz.defineMethod (c$, "hashCode", -function () { -return this.data.hashCode (); -}); -Clazz.overrideMethod (c$, "toString", -function () { -return String.instantialize (this.data); -}); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.data = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "BArray"); +Clazz.makeConstructor (c$, +function (data) { +this.data = data; +}, "~A"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (Clazz.instanceOf (o, javajs.util.BArray)) { +var d = (o).data; +if (d.length == this.data.length) { +for (var i = 0; i < d.length; i++) if (d[i] != this.data[i]) return false; + +return true; +}}return false; +}, "~O"); +Clazz.defineMethod (c$, "hashCode", +function () { +return this.data.hashCode (); +}); +Clazz.overrideMethod (c$, "toString", +function () { +return String.instantialize (this.data); +}); diff --git a/bin/javajs/util/BC.js b/bin/javajs/util/BC.js index cc5ed5a..ec20ff4 100644 --- a/bin/javajs/util/BC.js +++ b/bin/javajs/util/BC.js @@ -1,65 +1,65 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.declareType (javajs.util, "BC"); -Clazz.makeConstructor (c$, -function () { -}); -c$.bytesToFloat = Clazz.defineMethod (c$, "bytesToFloat", -function (bytes, j, isBigEndian) { -return javajs.util.BC.intToFloat (javajs.util.BC.bytesToInt (bytes, j, isBigEndian)); -}, "~A,~N,~B"); -c$.bytesToInt = Clazz.defineMethod (c$, "bytesToInt", -function (bytes, j, isBigEndian) { -var n = (isBigEndian ? (bytes[j + 3] & 0xff) | (bytes[j + 2] & 0xff) << 8 | (bytes[j + 1] & 0xff) << 16 | (bytes[j] & 0xff) << 24 : (bytes[j++] & 0xff) | (bytes[j++] & 0xff) << 8 | (bytes[j++] & 0xff) << 16 | (bytes[j++] & 0xff) << 24); -{ -return (n > 0x7FFFFFFF ? n - 0x100000000 : n); -}}, "~A,~N,~B"); -c$.intToFloat = Clazz.defineMethod (c$, "intToFloat", -function (x) { -{ -if (x == 0) return 0; -var o = javajs.util.BC; -if (o.fracIEEE == null) -o.setFracIEEE(); -var m = ((x & 0x7F800000) >> 23); -return ((x & 0x80000000) == 0 ? 1 : -1) * o.shiftIEEE((x & 0x7FFFFF) | 0x800000, m - 149); -}}, "~N"); -c$.bytesToDoubleToFloat = Clazz.defineMethod (c$, "bytesToDoubleToFloat", -function (bytes, j, isBigEndian) { -{ -if (javajs.util.BC.fracIEEE == null) javajs.util.BC.setFracIEEE (); -{ -var o = javajs.util.BC; -var b1, b2, b3, b4, b5; -if (isBigEndian) { -b1 = bytes[j] & 0xFF; -b2 = bytes[j + 1] & 0xFF; -b3 = bytes[j + 2] & 0xFF; -b4 = bytes[j + 3] & 0xFF; -b5 = bytes[j + 4] & 0xFF; -} else { -b1 = bytes[j + 7] & 0xFF; -b2 = bytes[j + 6] & 0xFF; -b3 = bytes[j + 5] & 0xFF; -b4 = bytes[j + 4] & 0xFF; -b5 = bytes[j + 3] & 0xFF; -} -var s = ((b1 & 0x80) == 0 ? 1 : -1); -var e = (((b1 & 0x7F) << 4) | (b2 >> 4)) - 1026; -b2 = (b2 & 0xF) | 0x10; -return s * (o.shiftIEEE(b2, e) + o.shiftIEEE(b3, e - 8) + o.shiftIEEE(b4, e - 16) -+ o.shiftIEEE(b5, e - 24)); -}}}, "~A,~N,~B"); -c$.setFracIEEE = Clazz.defineMethod (c$, "setFracIEEE", -($fz = function () { -javajs.util.BC.fracIEEE = Clazz.newFloatArray (270, 0); -for (var i = 0; i < 270; i++) javajs.util.BC.fracIEEE[i] = Math.pow (2, i - 141); - -}, $fz.isPrivate = true, $fz)); -c$.shiftIEEE = Clazz.defineMethod (c$, "shiftIEEE", -function (f, i) { -if (f == 0 || i < -140) return 0; -if (i > 128) return 3.4028235E38; -return f * javajs.util.BC.fracIEEE[i + 140]; -}, "~N,~N"); -Clazz.defineStatics (c$, -"fracIEEE", null); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.declareType (javajs.util, "BC"); +Clazz.makeConstructor (c$, +function () { +}); +c$.bytesToFloat = Clazz.defineMethod (c$, "bytesToFloat", +function (bytes, j, isBigEndian) { +return javajs.util.BC.intToFloat (javajs.util.BC.bytesToInt (bytes, j, isBigEndian)); +}, "~A,~N,~B"); +c$.bytesToInt = Clazz.defineMethod (c$, "bytesToInt", +function (bytes, j, isBigEndian) { +var n = (isBigEndian ? (bytes[j + 3] & 0xff) | (bytes[j + 2] & 0xff) << 8 | (bytes[j + 1] & 0xff) << 16 | (bytes[j] & 0xff) << 24 : (bytes[j++] & 0xff) | (bytes[j++] & 0xff) << 8 | (bytes[j++] & 0xff) << 16 | (bytes[j++] & 0xff) << 24); +{ +return (n > 0x7FFFFFFF ? n - 0x100000000 : n); +}}, "~A,~N,~B"); +c$.intToFloat = Clazz.defineMethod (c$, "intToFloat", +function (x) { +{ +if (x == 0) return 0; +var o = javajs.util.BC; +if (o.fracIEEE == null) +o.setFracIEEE(); +var m = ((x & 0x7F800000) >> 23); +return ((x & 0x80000000) == 0 ? 1 : -1) * o.shiftIEEE((x & 0x7FFFFF) | 0x800000, m - 149); +}}, "~N"); +c$.bytesToDoubleToFloat = Clazz.defineMethod (c$, "bytesToDoubleToFloat", +function (bytes, j, isBigEndian) { +{ +if (javajs.util.BC.fracIEEE == null) javajs.util.BC.setFracIEEE (); +{ +var o = javajs.util.BC; +var b1, b2, b3, b4, b5; +if (isBigEndian) { +b1 = bytes[j] & 0xFF; +b2 = bytes[j + 1] & 0xFF; +b3 = bytes[j + 2] & 0xFF; +b4 = bytes[j + 3] & 0xFF; +b5 = bytes[j + 4] & 0xFF; +} else { +b1 = bytes[j + 7] & 0xFF; +b2 = bytes[j + 6] & 0xFF; +b3 = bytes[j + 5] & 0xFF; +b4 = bytes[j + 4] & 0xFF; +b5 = bytes[j + 3] & 0xFF; +} +var s = ((b1 & 0x80) == 0 ? 1 : -1); +var e = (((b1 & 0x7F) << 4) | (b2 >> 4)) - 1026; +b2 = (b2 & 0xF) | 0x10; +return s * (o.shiftIEEE(b2, e) + o.shiftIEEE(b3, e - 8) + o.shiftIEEE(b4, e - 16) ++ o.shiftIEEE(b5, e - 24)); +}}}, "~A,~N,~B"); +c$.setFracIEEE = Clazz.defineMethod (c$, "setFracIEEE", +($fz = function () { +javajs.util.BC.fracIEEE = Clazz.newFloatArray (270, 0); +for (var i = 0; i < 270; i++) javajs.util.BC.fracIEEE[i] = Math.pow (2, i - 141); + +}, $fz.isPrivate = true, $fz)); +c$.shiftIEEE = Clazz.defineMethod (c$, "shiftIEEE", +function (f, i) { +if (f == 0 || i < -140) return 0; +if (i > 128) return 3.4028235E38; +return f * javajs.util.BC.fracIEEE[i + 140]; +}, "~N,~N"); +Clazz.defineStatics (c$, +"fracIEEE", null); diff --git a/bin/javajs/util/BS.js b/bin/javajs/util/BS.js index 5677631..bc34911 100644 --- a/bin/javajs/util/BS.js +++ b/bin/javajs/util/BS.js @@ -1,357 +1,357 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.BS", ["java.lang.IndexOutOfBoundsException", "$.NegativeArraySizeException", "javajs.util.PT", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.words = null; -this.wordsInUse = 0; -this.sizeIsSticky = false; -Clazz.instantialize (this, arguments); -}, javajs.util, "BS", null, [Cloneable, javajs.api.JSONEncodable]); -c$.wordIndex = Clazz.defineMethod (c$, "wordIndex", -($fz = function (bitIndex) { -return bitIndex >> 5; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "recalculateWordsInUse", -($fz = function () { -var i; -for (i = this.wordsInUse - 1; i >= 0; i--) if (this.words[i] != 0) break; - -this.wordsInUse = i + 1; -}, $fz.isPrivate = true, $fz)); -Clazz.makeConstructor (c$, -function () { -this.initWords (32); -this.sizeIsSticky = false; -}); -c$.newN = Clazz.defineMethod (c$, "newN", -function (nbits) { -var bs = new javajs.util.BS (); -bs.init (nbits); -return bs; -}, "~N"); -Clazz.defineMethod (c$, "init", -($fz = function (nbits) { -if (nbits < 0) throw new NegativeArraySizeException ("nbits < 0: " + nbits); -this.initWords (nbits); -this.sizeIsSticky = true; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "initWords", -($fz = function (nbits) { -this.words = Clazz.newIntArray (javajs.util.BS.wordIndex (nbits - 1) + 1, 0); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "ensureCapacity", -($fz = function (wordsRequired) { -if (this.words.length < wordsRequired) { -var request = Math.max (2 * this.words.length, wordsRequired); -this.setLength (request); -this.sizeIsSticky = false; -}}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "expandTo", -($fz = function (wordIndex) { -var wordsRequired = wordIndex + 1; -if (this.wordsInUse < wordsRequired) { -this.ensureCapacity (wordsRequired); -this.wordsInUse = wordsRequired; -}}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "set", -function (bitIndex) { -if (bitIndex < 0) throw new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex); -var wordIndex = javajs.util.BS.wordIndex (bitIndex); -this.expandTo (wordIndex); -this.words[wordIndex] |= (1 << bitIndex); -}, "~N"); -Clazz.defineMethod (c$, "setBitTo", -function (bitIndex, value) { -if (value) this.set (bitIndex); - else this.clear (bitIndex); -}, "~N,~B"); -Clazz.defineMethod (c$, "setBits", -function (fromIndex, toIndex) { -if (fromIndex == toIndex) return; -var startWordIndex = javajs.util.BS.wordIndex (fromIndex); -var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1); -this.expandTo (endWordIndex); -var firstWordMask = -1 << fromIndex; -var lastWordMask = -1 >>> -toIndex; -if (startWordIndex == endWordIndex) { -this.words[startWordIndex] |= (firstWordMask & lastWordMask); -} else { -this.words[startWordIndex] |= firstWordMask; -for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = -1; - -this.words[endWordIndex] |= lastWordMask; -}}, "~N,~N"); -Clazz.defineMethod (c$, "clear", -function (bitIndex) { -if (bitIndex < 0) throw new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex); -var wordIndex = javajs.util.BS.wordIndex (bitIndex); -if (wordIndex >= this.wordsInUse) return; -this.words[wordIndex] &= ~(1 << bitIndex); -this.recalculateWordsInUse (); -}, "~N"); -Clazz.defineMethod (c$, "clearBits", -function (fromIndex, toIndex) { -if (fromIndex == toIndex) return; -var startWordIndex = javajs.util.BS.wordIndex (fromIndex); -if (startWordIndex >= this.wordsInUse) return; -var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1); -if (endWordIndex >= this.wordsInUse) { -toIndex = this.length (); -endWordIndex = this.wordsInUse - 1; -}var firstWordMask = -1 << fromIndex; -var lastWordMask = -1 >>> -toIndex; -if (startWordIndex == endWordIndex) { -this.words[startWordIndex] &= ~(firstWordMask & lastWordMask); -} else { -this.words[startWordIndex] &= ~firstWordMask; -for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = 0; - -this.words[endWordIndex] &= ~lastWordMask; -}this.recalculateWordsInUse (); -}, "~N,~N"); -Clazz.defineMethod (c$, "clearAll", -function () { -while (this.wordsInUse > 0) this.words[--this.wordsInUse] = 0; - -}); -Clazz.defineMethod (c$, "get", -function (bitIndex) { -if (bitIndex < 0) throw new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex); -var wordIndex = javajs.util.BS.wordIndex (bitIndex); -return (wordIndex < this.wordsInUse) && ((this.words[wordIndex] & (1 << bitIndex)) != 0); -}, "~N"); -Clazz.defineMethod (c$, "nextSetBit", -function (fromIndex) { -if (fromIndex < 0) throw new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex); -var u = javajs.util.BS.wordIndex (fromIndex); -if (u >= this.wordsInUse) return -1; -var word = this.words[u] & (-1 << fromIndex); -while (true) { -if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word); -if (++u == this.wordsInUse) return -1; -word = this.words[u]; -} -}, "~N"); -Clazz.defineMethod (c$, "nextClearBit", -function (fromIndex) { -if (fromIndex < 0) throw new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex); -var u = javajs.util.BS.wordIndex (fromIndex); -if (u >= this.wordsInUse) return fromIndex; -var word = ~this.words[u] & (-1 << fromIndex); -while (true) { -if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word); -if (++u == this.wordsInUse) return this.wordsInUse * 32; -word = ~this.words[u]; -} -}, "~N"); -Clazz.defineMethod (c$, "length", -function () { -if (this.wordsInUse == 0) return 0; -return 32 * (this.wordsInUse - 1) + (32 - Integer.numberOfLeadingZeros (this.words[this.wordsInUse - 1])); -}); -Clazz.defineMethod (c$, "isEmpty", -function () { -return this.wordsInUse == 0; -}); -Clazz.defineMethod (c$, "intersects", -function (set) { -for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) if ((this.words[i] & set.words[i]) != 0) return true; - -return false; -}, "javajs.util.BS"); -Clazz.defineMethod (c$, "cardinality", -function () { -var sum = 0; -for (var i = 0; i < this.wordsInUse; i++) sum += Integer.bitCount (this.words[i]); - -return sum; -}); -Clazz.defineMethod (c$, "and", -function (set) { -if (this === set) return; -while (this.wordsInUse > set.wordsInUse) this.words[--this.wordsInUse] = 0; - -for (var i = 0; i < this.wordsInUse; i++) this.words[i] &= set.words[i]; - -this.recalculateWordsInUse (); -}, "javajs.util.BS"); -Clazz.defineMethod (c$, "or", -function (set) { -if (this === set) return; -var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse); -if (this.wordsInUse < set.wordsInUse) { -this.ensureCapacity (set.wordsInUse); -this.wordsInUse = set.wordsInUse; -}for (var i = 0; i < wordsInCommon; i++) this.words[i] |= set.words[i]; - -if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, this.wordsInUse - wordsInCommon); -}, "javajs.util.BS"); -Clazz.defineMethod (c$, "xor", -function (set) { -var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse); -if (this.wordsInUse < set.wordsInUse) { -this.ensureCapacity (set.wordsInUse); -this.wordsInUse = set.wordsInUse; -}for (var i = 0; i < wordsInCommon; i++) this.words[i] ^= set.words[i]; - -if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, set.wordsInUse - wordsInCommon); -this.recalculateWordsInUse (); -}, "javajs.util.BS"); -Clazz.defineMethod (c$, "andNot", -function (set) { -for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) this.words[i] &= ~set.words[i]; - -this.recalculateWordsInUse (); -}, "javajs.util.BS"); -Clazz.overrideMethod (c$, "hashCode", -function () { -var h = 1234; -for (var i = this.wordsInUse; --i >= 0; ) h ^= this.words[i] * (i + 1); - -return ((h >> 32) ^ h); -}); -Clazz.defineMethod (c$, "size", -function () { -return this.words.length * 32; -}); -Clazz.overrideMethod (c$, "equals", -function (obj) { -if (!(Clazz.instanceOf (obj, javajs.util.BS))) return false; -if (this === obj) return true; -var set = obj; -if (this.wordsInUse != set.wordsInUse) return false; -for (var i = 0; i < this.wordsInUse; i++) if (this.words[i] != set.words[i]) return false; - -return true; -}, "~O"); -Clazz.overrideMethod (c$, "clone", -function () { -if (!this.sizeIsSticky && this.wordsInUse != this.words.length) this.setLength (this.wordsInUse); -return javajs.util.BS.copy (this); -}); -Clazz.defineMethod (c$, "setLength", -($fz = function (n) { -var a = Clazz.newIntArray (n, 0); -System.arraycopy (this.words, 0, a, 0, Math.min (this.wordsInUse, n)); -this.words = a; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return javajs.util.BS.escape (this, '{', '}'); -}); -c$.copy = Clazz.defineMethod (c$, "copy", -function (bitsetToCopy) { -var bs; -{ -bs = Clazz.clone(bitsetToCopy); -}var wordCount = bitsetToCopy.wordsInUse; -if (wordCount == 0) { -bs.words = javajs.util.BS.emptyBitmap; -} else { -bs.words = Clazz.newIntArray (bs.wordsInUse = wordCount, 0); -System.arraycopy (bitsetToCopy.words, 0, bs.words, 0, wordCount); -}return bs; -}, "javajs.util.BS"); -Clazz.defineMethod (c$, "cardinalityN", -function (max) { -var n = this.cardinality (); -for (var i = this.length (); --i >= max; ) if (this.get (i)) n--; - -return n; -}, "~N"); -Clazz.overrideMethod (c$, "toJSON", -function () { -var numBits = (this.wordsInUse > 128) ? this.cardinality () : this.wordsInUse * 32; -var b = javajs.util.SB.newN (6 * numBits + 2); -b.appendC ('['); -var i = this.nextSetBit (0); -if (i != -1) { -b.appendI (i); -for (i = this.nextSetBit (i + 1); i >= 0; i = this.nextSetBit (i + 1)) { -var endOfRun = this.nextClearBit (i); -do { -b.append (", ").appendI (i); -} while (++i < endOfRun); -} -}b.appendC (']'); -return b.toString (); -}); -c$.escape = Clazz.defineMethod (c$, "escape", -function (bs, chOpen, chClose) { -if (bs == null) return chOpen + "{}" + chClose; -var s = new javajs.util.SB (); -s.append (chOpen + "{"); -var imax = bs.length (); -var iLast = -1; -var iFirst = -2; -var i = -1; -while (++i <= imax) { -var isSet = bs.get (i); -if (i == imax || iLast >= 0 && !isSet) { -if (iLast >= 0 && iFirst != iLast) s.append ((iFirst == iLast - 1 ? " " : ":") + iLast); -if (i == imax) break; -iLast = -1; -}if (bs.get (i)) { -if (iLast < 0) { -s.append ((iFirst == -2 ? "" : " ") + i); -iFirst = i; -}iLast = i; -}} -s.append ("}").appendC (chClose); -return s.toString (); -}, "javajs.util.BS,~S,~S"); -c$.unescape = Clazz.defineMethod (c$, "unescape", -function (str) { -var ch; -var len; -if (str == null || (len = (str = str.trim ()).length) < 4 || str.equalsIgnoreCase ("({null})") || (ch = str.charAt (0)) != '(' && ch != '[' || str.charAt (len - 1) != (ch == '(' ? ')' : ']') || str.charAt (1) != '{' || str.indexOf ('}') != len - 2) return null; -len -= 2; -for (var i = len; --i >= 2; ) if (!javajs.util.PT.isDigit (ch = str.charAt (i)) && ch != ' ' && ch != '\t' && ch != ':') return null; - -var lastN = len; -while (javajs.util.PT.isDigit (str.charAt (--lastN))) { -} -if (++lastN == len) lastN = 0; - else try { -lastN = Integer.parseInt (str.substring (lastN, len)); -} catch (e) { -if (Clazz.exceptionOf (e, NumberFormatException)) { -return null; -} else { -throw e; -} -} -var bs = javajs.util.BS.newN (lastN); -lastN = -1; -var iPrev = -1; -var iThis = -2; -for (var i = 2; i <= len; i++) { -switch (ch = str.charAt (i)) { -case '\t': -case ' ': -case '}': -if (iThis < 0) break; -if (iThis < lastN) return null; -lastN = iThis; -if (iPrev < 0) iPrev = iThis; -bs.setBits (iPrev, iThis + 1); -iPrev = -1; -iThis = -2; -break; -case ':': -iPrev = lastN = iThis; -iThis = -2; -break; -default: -if (javajs.util.PT.isDigit (ch)) { -if (iThis < 0) iThis = 0; -iThis = (iThis * 10) + (ch.charCodeAt (0) - 48); -}} -} -return (iPrev >= 0 ? null : bs); -}, "~S"); -Clazz.defineStatics (c$, -"ADDRESS_BITS_PER_WORD", 5, -"BITS_PER_WORD", 32, -"WORD_MASK", 0xffffffff, -"emptyBitmap", Clazz.newIntArray (0, 0)); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.BS", ["java.lang.IndexOutOfBoundsException", "$.NegativeArraySizeException", "javajs.util.PT", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.words = null; +this.wordsInUse = 0; +this.sizeIsSticky = false; +Clazz.instantialize (this, arguments); +}, javajs.util, "BS", null, [Cloneable, javajs.api.JSONEncodable]); +c$.wordIndex = Clazz.defineMethod (c$, "wordIndex", +($fz = function (bitIndex) { +return bitIndex >> 5; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "recalculateWordsInUse", +($fz = function () { +var i; +for (i = this.wordsInUse - 1; i >= 0; i--) if (this.words[i] != 0) break; + +this.wordsInUse = i + 1; +}, $fz.isPrivate = true, $fz)); +Clazz.makeConstructor (c$, +function () { +this.initWords (32); +this.sizeIsSticky = false; +}); +c$.newN = Clazz.defineMethod (c$, "newN", +function (nbits) { +var bs = new javajs.util.BS (); +bs.init (nbits); +return bs; +}, "~N"); +Clazz.defineMethod (c$, "init", +($fz = function (nbits) { +if (nbits < 0) throw new NegativeArraySizeException ("nbits < 0: " + nbits); +this.initWords (nbits); +this.sizeIsSticky = true; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "initWords", +($fz = function (nbits) { +this.words = Clazz.newIntArray (javajs.util.BS.wordIndex (nbits - 1) + 1, 0); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "ensureCapacity", +($fz = function (wordsRequired) { +if (this.words.length < wordsRequired) { +var request = Math.max (2 * this.words.length, wordsRequired); +this.setLength (request); +this.sizeIsSticky = false; +}}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "expandTo", +($fz = function (wordIndex) { +var wordsRequired = wordIndex + 1; +if (this.wordsInUse < wordsRequired) { +this.ensureCapacity (wordsRequired); +this.wordsInUse = wordsRequired; +}}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "set", +function (bitIndex) { +if (bitIndex < 0) throw new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex); +var wordIndex = javajs.util.BS.wordIndex (bitIndex); +this.expandTo (wordIndex); +this.words[wordIndex] |= (1 << bitIndex); +}, "~N"); +Clazz.defineMethod (c$, "setBitTo", +function (bitIndex, value) { +if (value) this.set (bitIndex); + else this.clear (bitIndex); +}, "~N,~B"); +Clazz.defineMethod (c$, "setBits", +function (fromIndex, toIndex) { +if (fromIndex == toIndex) return; +var startWordIndex = javajs.util.BS.wordIndex (fromIndex); +var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1); +this.expandTo (endWordIndex); +var firstWordMask = -1 << fromIndex; +var lastWordMask = -1 >>> -toIndex; +if (startWordIndex == endWordIndex) { +this.words[startWordIndex] |= (firstWordMask & lastWordMask); +} else { +this.words[startWordIndex] |= firstWordMask; +for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = -1; + +this.words[endWordIndex] |= lastWordMask; +}}, "~N,~N"); +Clazz.defineMethod (c$, "clear", +function (bitIndex) { +if (bitIndex < 0) throw new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex); +var wordIndex = javajs.util.BS.wordIndex (bitIndex); +if (wordIndex >= this.wordsInUse) return; +this.words[wordIndex] &= ~(1 << bitIndex); +this.recalculateWordsInUse (); +}, "~N"); +Clazz.defineMethod (c$, "clearBits", +function (fromIndex, toIndex) { +if (fromIndex == toIndex) return; +var startWordIndex = javajs.util.BS.wordIndex (fromIndex); +if (startWordIndex >= this.wordsInUse) return; +var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1); +if (endWordIndex >= this.wordsInUse) { +toIndex = this.length (); +endWordIndex = this.wordsInUse - 1; +}var firstWordMask = -1 << fromIndex; +var lastWordMask = -1 >>> -toIndex; +if (startWordIndex == endWordIndex) { +this.words[startWordIndex] &= ~(firstWordMask & lastWordMask); +} else { +this.words[startWordIndex] &= ~firstWordMask; +for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = 0; + +this.words[endWordIndex] &= ~lastWordMask; +}this.recalculateWordsInUse (); +}, "~N,~N"); +Clazz.defineMethod (c$, "clearAll", +function () { +while (this.wordsInUse > 0) this.words[--this.wordsInUse] = 0; + +}); +Clazz.defineMethod (c$, "get", +function (bitIndex) { +if (bitIndex < 0) throw new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex); +var wordIndex = javajs.util.BS.wordIndex (bitIndex); +return (wordIndex < this.wordsInUse) && ((this.words[wordIndex] & (1 << bitIndex)) != 0); +}, "~N"); +Clazz.defineMethod (c$, "nextSetBit", +function (fromIndex) { +if (fromIndex < 0) throw new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex); +var u = javajs.util.BS.wordIndex (fromIndex); +if (u >= this.wordsInUse) return -1; +var word = this.words[u] & (-1 << fromIndex); +while (true) { +if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word); +if (++u == this.wordsInUse) return -1; +word = this.words[u]; +} +}, "~N"); +Clazz.defineMethod (c$, "nextClearBit", +function (fromIndex) { +if (fromIndex < 0) throw new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex); +var u = javajs.util.BS.wordIndex (fromIndex); +if (u >= this.wordsInUse) return fromIndex; +var word = ~this.words[u] & (-1 << fromIndex); +while (true) { +if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word); +if (++u == this.wordsInUse) return this.wordsInUse * 32; +word = ~this.words[u]; +} +}, "~N"); +Clazz.defineMethod (c$, "length", +function () { +if (this.wordsInUse == 0) return 0; +return 32 * (this.wordsInUse - 1) + (32 - Integer.numberOfLeadingZeros (this.words[this.wordsInUse - 1])); +}); +Clazz.defineMethod (c$, "isEmpty", +function () { +return this.wordsInUse == 0; +}); +Clazz.defineMethod (c$, "intersects", +function (set) { +for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) if ((this.words[i] & set.words[i]) != 0) return true; + +return false; +}, "javajs.util.BS"); +Clazz.defineMethod (c$, "cardinality", +function () { +var sum = 0; +for (var i = 0; i < this.wordsInUse; i++) sum += Integer.bitCount (this.words[i]); + +return sum; +}); +Clazz.defineMethod (c$, "and", +function (set) { +if (this === set) return; +while (this.wordsInUse > set.wordsInUse) this.words[--this.wordsInUse] = 0; + +for (var i = 0; i < this.wordsInUse; i++) this.words[i] &= set.words[i]; + +this.recalculateWordsInUse (); +}, "javajs.util.BS"); +Clazz.defineMethod (c$, "or", +function (set) { +if (this === set) return; +var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse); +if (this.wordsInUse < set.wordsInUse) { +this.ensureCapacity (set.wordsInUse); +this.wordsInUse = set.wordsInUse; +}for (var i = 0; i < wordsInCommon; i++) this.words[i] |= set.words[i]; + +if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, this.wordsInUse - wordsInCommon); +}, "javajs.util.BS"); +Clazz.defineMethod (c$, "xor", +function (set) { +var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse); +if (this.wordsInUse < set.wordsInUse) { +this.ensureCapacity (set.wordsInUse); +this.wordsInUse = set.wordsInUse; +}for (var i = 0; i < wordsInCommon; i++) this.words[i] ^= set.words[i]; + +if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, set.wordsInUse - wordsInCommon); +this.recalculateWordsInUse (); +}, "javajs.util.BS"); +Clazz.defineMethod (c$, "andNot", +function (set) { +for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) this.words[i] &= ~set.words[i]; + +this.recalculateWordsInUse (); +}, "javajs.util.BS"); +Clazz.overrideMethod (c$, "hashCode", +function () { +var h = 1234; +for (var i = this.wordsInUse; --i >= 0; ) h ^= this.words[i] * (i + 1); + +return ((h >> 32) ^ h); +}); +Clazz.defineMethod (c$, "size", +function () { +return this.words.length * 32; +}); +Clazz.overrideMethod (c$, "equals", +function (obj) { +if (!(Clazz.instanceOf (obj, javajs.util.BS))) return false; +if (this === obj) return true; +var set = obj; +if (this.wordsInUse != set.wordsInUse) return false; +for (var i = 0; i < this.wordsInUse; i++) if (this.words[i] != set.words[i]) return false; + +return true; +}, "~O"); +Clazz.overrideMethod (c$, "clone", +function () { +if (!this.sizeIsSticky && this.wordsInUse != this.words.length) this.setLength (this.wordsInUse); +return javajs.util.BS.copy (this); +}); +Clazz.defineMethod (c$, "setLength", +($fz = function (n) { +var a = Clazz.newIntArray (n, 0); +System.arraycopy (this.words, 0, a, 0, Math.min (this.wordsInUse, n)); +this.words = a; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return javajs.util.BS.escape (this, '{', '}'); +}); +c$.copy = Clazz.defineMethod (c$, "copy", +function (bitsetToCopy) { +var bs; +{ +bs = Clazz.clone(bitsetToCopy); +}var wordCount = bitsetToCopy.wordsInUse; +if (wordCount == 0) { +bs.words = javajs.util.BS.emptyBitmap; +} else { +bs.words = Clazz.newIntArray (bs.wordsInUse = wordCount, 0); +System.arraycopy (bitsetToCopy.words, 0, bs.words, 0, wordCount); +}return bs; +}, "javajs.util.BS"); +Clazz.defineMethod (c$, "cardinalityN", +function (max) { +var n = this.cardinality (); +for (var i = this.length (); --i >= max; ) if (this.get (i)) n--; + +return n; +}, "~N"); +Clazz.overrideMethod (c$, "toJSON", +function () { +var numBits = (this.wordsInUse > 128) ? this.cardinality () : this.wordsInUse * 32; +var b = javajs.util.SB.newN (6 * numBits + 2); +b.appendC ('['); +var i = this.nextSetBit (0); +if (i != -1) { +b.appendI (i); +for (i = this.nextSetBit (i + 1); i >= 0; i = this.nextSetBit (i + 1)) { +var endOfRun = this.nextClearBit (i); +do { +b.append (", ").appendI (i); +} while (++i < endOfRun); +} +}b.appendC (']'); +return b.toString (); +}); +c$.escape = Clazz.defineMethod (c$, "escape", +function (bs, chOpen, chClose) { +if (bs == null) return chOpen + "{}" + chClose; +var s = new javajs.util.SB (); +s.append (chOpen + "{"); +var imax = bs.length (); +var iLast = -1; +var iFirst = -2; +var i = -1; +while (++i <= imax) { +var isSet = bs.get (i); +if (i == imax || iLast >= 0 && !isSet) { +if (iLast >= 0 && iFirst != iLast) s.append ((iFirst == iLast - 1 ? " " : ":") + iLast); +if (i == imax) break; +iLast = -1; +}if (bs.get (i)) { +if (iLast < 0) { +s.append ((iFirst == -2 ? "" : " ") + i); +iFirst = i; +}iLast = i; +}} +s.append ("}").appendC (chClose); +return s.toString (); +}, "javajs.util.BS,~S,~S"); +c$.unescape = Clazz.defineMethod (c$, "unescape", +function (str) { +var ch; +var len; +if (str == null || (len = (str = str.trim ()).length) < 4 || str.equalsIgnoreCase ("({null})") || (ch = str.charAt (0)) != '(' && ch != '[' || str.charAt (len - 1) != (ch == '(' ? ')' : ']') || str.charAt (1) != '{' || str.indexOf ('}') != len - 2) return null; +len -= 2; +for (var i = len; --i >= 2; ) if (!javajs.util.PT.isDigit (ch = str.charAt (i)) && ch != ' ' && ch != '\t' && ch != ':') return null; + +var lastN = len; +while (javajs.util.PT.isDigit (str.charAt (--lastN))) { +} +if (++lastN == len) lastN = 0; + else try { +lastN = Integer.parseInt (str.substring (lastN, len)); +} catch (e) { +if (Clazz.exceptionOf (e, NumberFormatException)) { +return null; +} else { +throw e; +} +} +var bs = javajs.util.BS.newN (lastN); +lastN = -1; +var iPrev = -1; +var iThis = -2; +for (var i = 2; i <= len; i++) { +switch (ch = str.charAt (i)) { +case '\t': +case ' ': +case '}': +if (iThis < 0) break; +if (iThis < lastN) return null; +lastN = iThis; +if (iPrev < 0) iPrev = iThis; +bs.setBits (iPrev, iThis + 1); +iPrev = -1; +iThis = -2; +break; +case ':': +iPrev = lastN = iThis; +iThis = -2; +break; +default: +if (javajs.util.PT.isDigit (ch)) { +if (iThis < 0) iThis = 0; +iThis = (iThis * 10) + (ch.charCodeAt (0) - 48); +}} +} +return (iPrev >= 0 ? null : bs); +}, "~S"); +Clazz.defineStatics (c$, +"ADDRESS_BITS_PER_WORD", 5, +"BITS_PER_WORD", 32, +"WORD_MASK", 0xffffffff, +"emptyBitmap", Clazz.newIntArray (0, 0)); +}); diff --git a/bin/javajs/util/Base64.js b/bin/javajs/util/Base64.js index e513e54..15f1a5f 100644 --- a/bin/javajs/util/Base64.js +++ b/bin/javajs/util/Base64.js @@ -1,54 +1,54 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.Base64", ["javajs.util.SB"], function () { -c$ = Clazz.declareType (javajs.util, "Base64"); -c$.getBytes64 = Clazz.defineMethod (c$, "getBytes64", -function (bytes) { -return javajs.util.Base64.getBase64 (bytes).toBytes (0, -1); -}, "~A"); -c$.getBase64 = Clazz.defineMethod (c$, "getBase64", -function (bytes) { -var nBytes = bytes.length; -var sout = new javajs.util.SB (); -if (nBytes == 0) return sout; -for (var i = 0, nPad = 0; i < nBytes && nPad == 0; ) { -if (i % 75 == 0 && i != 0) sout.append ("\r\n"); -nPad = (i + 2 == nBytes ? 1 : i + 1 == nBytes ? 2 : 0); -var outbytes = ((bytes[i++] << 16) & 0xFF0000) | ((nPad == 2 ? 0 : bytes[i++] << 8) & 0x00FF00) | ((nPad >= 1 ? 0 : bytes[i++]) & 0x0000FF); -sout.appendC (javajs.util.Base64.base64.charAt ((outbytes >> 18) & 0x3F)); -sout.appendC (javajs.util.Base64.base64.charAt ((outbytes >> 12) & 0x3F)); -sout.appendC (nPad == 2 ? '=' : javajs.util.Base64.base64.charAt ((outbytes >> 6) & 0x3F)); -sout.appendC (nPad >= 1 ? '=' : javajs.util.Base64.base64.charAt (outbytes & 0x3F)); -} -return sout; -}, "~A"); -c$.decodeBase64 = Clazz.defineMethod (c$, "decodeBase64", -function (strBase64) { -var nBytes = 0; -var ch; -var pt0 = strBase64.indexOf (";base64,") + 1; -if (pt0 > 0) pt0 += 7; -var chars64 = strBase64.toCharArray (); -var len64 = chars64.length; -if (len64 == 0) return Clazz.newByteArray (0, 0); -for (var i = len64; --i >= pt0; ) nBytes += ((ch = (chars64[i]).charCodeAt (0) & 0x7F) == 65 || javajs.util.Base64.decode64[ch] > 0 ? 3 : 0); - -nBytes = nBytes >> 2; -var bytes = Clazz.newByteArray (nBytes, 0); -var offset = 18; -for (var i = pt0, pt = 0, b = 0; i < len64; i++) { -if (javajs.util.Base64.decode64[ch = (chars64[i]).charCodeAt (0) & 0x7F] > 0 || ch == 65 || ch == 61) { -b |= javajs.util.Base64.decode64[ch] << offset; -offset -= 6; -if (offset < 0) { -bytes[pt++] = ((b & 0xFF0000) >> 16); -if (pt < nBytes) bytes[pt++] = ((b & 0xFF00) >> 8); -if (pt < nBytes) bytes[pt++] = (b & 0xFF); -offset = 18; -b = 0; -}}} -return bytes; -}, "~S"); -Clazz.defineStatics (c$, -"base64", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", -"decode64", Clazz.newIntArray (-1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 62, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0])); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.Base64", ["javajs.util.SB"], function () { +c$ = Clazz.declareType (javajs.util, "Base64"); +c$.getBytes64 = Clazz.defineMethod (c$, "getBytes64", +function (bytes) { +return javajs.util.Base64.getBase64 (bytes).toBytes (0, -1); +}, "~A"); +c$.getBase64 = Clazz.defineMethod (c$, "getBase64", +function (bytes) { +var nBytes = bytes.length; +var sout = new javajs.util.SB (); +if (nBytes == 0) return sout; +for (var i = 0, nPad = 0; i < nBytes && nPad == 0; ) { +if (i % 75 == 0 && i != 0) sout.append ("\r\n"); +nPad = (i + 2 == nBytes ? 1 : i + 1 == nBytes ? 2 : 0); +var outbytes = ((bytes[i++] << 16) & 0xFF0000) | ((nPad == 2 ? 0 : bytes[i++] << 8) & 0x00FF00) | ((nPad >= 1 ? 0 : bytes[i++]) & 0x0000FF); +sout.appendC (javajs.util.Base64.base64.charAt ((outbytes >> 18) & 0x3F)); +sout.appendC (javajs.util.Base64.base64.charAt ((outbytes >> 12) & 0x3F)); +sout.appendC (nPad == 2 ? '=' : javajs.util.Base64.base64.charAt ((outbytes >> 6) & 0x3F)); +sout.appendC (nPad >= 1 ? '=' : javajs.util.Base64.base64.charAt (outbytes & 0x3F)); +} +return sout; +}, "~A"); +c$.decodeBase64 = Clazz.defineMethod (c$, "decodeBase64", +function (strBase64) { +var nBytes = 0; +var ch; +var pt0 = strBase64.indexOf (";base64,") + 1; +if (pt0 > 0) pt0 += 7; +var chars64 = strBase64.toCharArray (); +var len64 = chars64.length; +if (len64 == 0) return Clazz.newByteArray (0, 0); +for (var i = len64; --i >= pt0; ) nBytes += ((ch = (chars64[i]).charCodeAt (0) & 0x7F) == 65 || javajs.util.Base64.decode64[ch] > 0 ? 3 : 0); + +nBytes = nBytes >> 2; +var bytes = Clazz.newByteArray (nBytes, 0); +var offset = 18; +for (var i = pt0, pt = 0, b = 0; i < len64; i++) { +if (javajs.util.Base64.decode64[ch = (chars64[i]).charCodeAt (0) & 0x7F] > 0 || ch == 65 || ch == 61) { +b |= javajs.util.Base64.decode64[ch] << offset; +offset -= 6; +if (offset < 0) { +bytes[pt++] = ((b & 0xFF0000) >> 16); +if (pt < nBytes) bytes[pt++] = ((b & 0xFF00) >> 8); +if (pt < nBytes) bytes[pt++] = (b & 0xFF); +offset = 18; +b = 0; +}}} +return bytes; +}, "~S"); +Clazz.defineStatics (c$, +"base64", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", +"decode64", Clazz.newIntArray (-1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 62, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0])); +}); diff --git a/bin/javajs/util/BinaryDocument.js b/bin/javajs/util/BinaryDocument.js index a0edf33..420db0b 100644 --- a/bin/javajs/util/BinaryDocument.js +++ b/bin/javajs/util/BinaryDocument.js @@ -1,218 +1,218 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.GenericBinaryDocument", "javajs.util.BC"], "javajs.util.BinaryDocument", ["java.io.DataInputStream", "java.lang.Double"], function () { -c$ = Clazz.decorateAsClass (function () { -this.stream = null; -this.isRandom = false; -this.isBigEndian = true; -this.jzt = null; -this.t8 = null; -this.nBytes = 0; -this.out = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "BinaryDocument", javajs.util.BC, javajs.api.GenericBinaryDocument); -Clazz.prepareFields (c$, function () { -this.t8 = Clazz.newByteArray (8, 0); -}); -Clazz.overrideMethod (c$, "close", -function () { -if (this.stream != null) try { -this.stream.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -if (this.out != null) this.out.closeChannel (); -}); -Clazz.overrideMethod (c$, "setStream", -function (jzt, bis, isBigEndian) { -if (jzt != null) this.jzt = jzt; -if (bis != null) this.stream = new java.io.DataInputStream (bis); -this.isBigEndian = isBigEndian; -}, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B"); -Clazz.overrideMethod (c$, "setStreamData", -function (stream, isBigEndian) { -if (stream != null) this.stream = stream; -this.isBigEndian = isBigEndian; -}, "java.io.DataInputStream,~B"); -Clazz.defineMethod (c$, "setRandom", -function (TF) { -this.isRandom = TF; -}, "~B"); -Clazz.overrideMethod (c$, "readByte", -function () { -this.nBytes++; -return this.ioReadByte (); -}); -Clazz.defineMethod (c$, "ioReadByte", -($fz = function () { -var b = this.stream.readByte (); -if (this.out != null) this.out.writeByteAsInt (b); -return b; -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "readByteArray", -function (b, off, len) { -var n = this.ioRead (b, off, len); -this.nBytes += n; -return n; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "ioRead", -($fz = function (b, off, len) { -var m = 0; -while (len > 0) { -var n = this.stream.read (b, off, len); -m += n; -if (n > 0 && this.out != null) this.writeBytes (b, off, n); -if (n >= len) break; -off += n; -len -= n; -} -return m; -}, $fz.isPrivate = true, $fz), "~A,~N,~N"); -Clazz.defineMethod (c$, "writeBytes", -function (b, off, n) { -this.out.write (b, off, n); -}, "~A,~N,~N"); -Clazz.overrideMethod (c$, "readString", -function (nChar) { -var temp = Clazz.newByteArray (nChar, 0); -var n = this.readByteArray (temp, 0, nChar); -return String.instantialize (temp, 0, n, "UTF-8"); -}, "~N"); -Clazz.overrideMethod (c$, "readShort", -function () { -this.nBytes += 2; -var n = (this.isBigEndian ? this.ioReadShort () : ((this.ioReadByte () & 0xff) | (this.ioReadByte () & 0xff) << 8)); -{ -return (n > 0x7FFF ? n - 0x10000 : n); -}}); -Clazz.defineMethod (c$, "ioReadShort", -($fz = function () { -var b = this.stream.readShort (); -if (this.out != null) this.writeShort (b); -return b; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeShort", -function (i) { -this.out.writeByteAsInt (i >> 8); -this.out.writeByteAsInt (i); -}, "~N"); -Clazz.overrideMethod (c$, "readIntLE", -function () { -this.nBytes += 4; -return this.readLEInt (); -}); -Clazz.overrideMethod (c$, "readInt", -function () { -this.nBytes += 4; -return (this.isBigEndian ? this.ioReadInt () : this.readLEInt ()); -}); -Clazz.defineMethod (c$, "ioReadInt", -($fz = function () { -var i = this.stream.readInt (); -if (this.out != null) this.writeInt (i); -return i; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeInt", -function (i) { -this.out.writeByteAsInt (i >> 24); -this.out.writeByteAsInt (i >> 16); -this.out.writeByteAsInt (i >> 8); -this.out.writeByteAsInt (i); -}, "~N"); -Clazz.overrideMethod (c$, "swapBytesI", -function (n) { -return (((n >> 24) & 0xff) | ((n >> 16) & 0xff) << 8 | ((n >> 8) & 0xff) << 16 | (n & 0xff) << 24); -}, "~N"); -Clazz.overrideMethod (c$, "swapBytesS", -function (n) { -return ((((n >> 8) & 0xff) | (n & 0xff) << 8)); -}, "~N"); -Clazz.overrideMethod (c$, "readUnsignedShort", -function () { -this.nBytes += 2; -var a = (this.ioReadByte () & 0xff); -var b = (this.ioReadByte () & 0xff); -return (this.isBigEndian ? (a << 8) + b : (b << 8) + a); -}); -Clazz.overrideMethod (c$, "readLong", -function () { -this.nBytes += 8; -return (this.isBigEndian ? this.ioReadLong () : (((this.ioReadByte ()) & 0xff) | ((this.ioReadByte ()) & 0xff) << 8 | ((this.ioReadByte ()) & 0xff) << 16 | ((this.ioReadByte ()) & 0xff) << 24 | ((this.ioReadByte ()) & 0xff) << 32 | ((this.ioReadByte ()) & 0xff) << 40 | ((this.ioReadByte ()) & 0xff) << 48 | ((this.ioReadByte ()) & 0xff) << 54)); -}); -Clazz.defineMethod (c$, "ioReadLong", -($fz = function () { -var b = this.stream.readLong (); -if (this.out != null) this.writeLong (b); -return b; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "writeLong", -function (b) { -this.writeInt (((b >> 32) & 0xFFFFFFFF)); -this.writeInt ((b & 0xFFFFFFFF)); -}, "~N"); -Clazz.defineMethod (c$, "readLEInt", -($fz = function () { -this.ioRead (this.t8, 0, 4); -return javajs.util.BC.bytesToInt (this.t8, 0, false); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "readFloat", -function () { -return javajs.util.BC.intToFloat (this.readInt ()); -}); -Clazz.overrideMethod (c$, "readDouble", -function () { -{ -this.readByteArray(this.t8, 0, 8); -return this.bytesToDoubleToFloat(this.t8, 0, this.isBigEndian); -}}); -Clazz.defineMethod (c$, "ioReadDouble", -($fz = function () { -var d = this.stream.readDouble (); -if (this.out != null) this.writeLong (Double.doubleToRawLongBits (d)); -return d; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "readLELong", -($fz = function () { -return (((this.ioReadByte ()) & 0xff) | ((this.ioReadByte ()) & 0xff) << 8 | ((this.ioReadByte ()) & 0xff) << 16 | ((this.ioReadByte ()) & 0xff) << 24 | ((this.ioReadByte ()) & 0xff) << 32 | ((this.ioReadByte ()) & 0xff) << 40 | ((this.ioReadByte ()) & 0xff) << 48 | ((this.ioReadByte ()) & 0xff) << 56); -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "seek", -function (offset) { -try { -if (offset == this.nBytes) return; -if (offset < this.nBytes) { -this.stream.reset (); -if (this.out != null && this.nBytes != 0) this.out.reset (); -this.nBytes = 0; -} else { -offset -= this.nBytes; -}if (this.out == null) { -this.stream.skipBytes (offset); -} else { -this.readByteArray ( Clazz.newByteArray (offset, 0), 0, offset); -}this.nBytes += offset; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -}, "~N"); -Clazz.overrideMethod (c$, "getPosition", -function () { -return this.nBytes; -}); -Clazz.overrideMethod (c$, "setOutputChannel", -function (out) { -this.out = out; -}, "javajs.util.OC"); -Clazz.overrideMethod (c$, "getAllDataFiles", -function (binaryFileList, firstFile) { -return null; -}, "~S,~S"); -Clazz.overrideMethod (c$, "getAllDataMapped", -function (replace, string, fileData) { -}, "~S,~S,java.util.Map"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.GenericBinaryDocument", "javajs.util.BC"], "javajs.util.BinaryDocument", ["java.io.DataInputStream", "java.lang.Double"], function () { +c$ = Clazz.decorateAsClass (function () { +this.stream = null; +this.isRandom = false; +this.isBigEndian = true; +this.jzt = null; +this.t8 = null; +this.nBytes = 0; +this.out = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "BinaryDocument", javajs.util.BC, javajs.api.GenericBinaryDocument); +Clazz.prepareFields (c$, function () { +this.t8 = Clazz.newByteArray (8, 0); +}); +Clazz.overrideMethod (c$, "close", +function () { +if (this.stream != null) try { +this.stream.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +if (this.out != null) this.out.closeChannel (); +}); +Clazz.overrideMethod (c$, "setStream", +function (jzt, bis, isBigEndian) { +if (jzt != null) this.jzt = jzt; +if (bis != null) this.stream = new java.io.DataInputStream (bis); +this.isBigEndian = isBigEndian; +}, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B"); +Clazz.overrideMethod (c$, "setStreamData", +function (stream, isBigEndian) { +if (stream != null) this.stream = stream; +this.isBigEndian = isBigEndian; +}, "java.io.DataInputStream,~B"); +Clazz.defineMethod (c$, "setRandom", +function (TF) { +this.isRandom = TF; +}, "~B"); +Clazz.overrideMethod (c$, "readByte", +function () { +this.nBytes++; +return this.ioReadByte (); +}); +Clazz.defineMethod (c$, "ioReadByte", +($fz = function () { +var b = this.stream.readByte (); +if (this.out != null) this.out.writeByteAsInt (b); +return b; +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "readByteArray", +function (b, off, len) { +var n = this.ioRead (b, off, len); +this.nBytes += n; +return n; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "ioRead", +($fz = function (b, off, len) { +var m = 0; +while (len > 0) { +var n = this.stream.read (b, off, len); +m += n; +if (n > 0 && this.out != null) this.writeBytes (b, off, n); +if (n >= len) break; +off += n; +len -= n; +} +return m; +}, $fz.isPrivate = true, $fz), "~A,~N,~N"); +Clazz.defineMethod (c$, "writeBytes", +function (b, off, n) { +this.out.write (b, off, n); +}, "~A,~N,~N"); +Clazz.overrideMethod (c$, "readString", +function (nChar) { +var temp = Clazz.newByteArray (nChar, 0); +var n = this.readByteArray (temp, 0, nChar); +return String.instantialize (temp, 0, n, "UTF-8"); +}, "~N"); +Clazz.overrideMethod (c$, "readShort", +function () { +this.nBytes += 2; +var n = (this.isBigEndian ? this.ioReadShort () : ((this.ioReadByte () & 0xff) | (this.ioReadByte () & 0xff) << 8)); +{ +return (n > 0x7FFF ? n - 0x10000 : n); +}}); +Clazz.defineMethod (c$, "ioReadShort", +($fz = function () { +var b = this.stream.readShort (); +if (this.out != null) this.writeShort (b); +return b; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeShort", +function (i) { +this.out.writeByteAsInt (i >> 8); +this.out.writeByteAsInt (i); +}, "~N"); +Clazz.overrideMethod (c$, "readIntLE", +function () { +this.nBytes += 4; +return this.readLEInt (); +}); +Clazz.overrideMethod (c$, "readInt", +function () { +this.nBytes += 4; +return (this.isBigEndian ? this.ioReadInt () : this.readLEInt ()); +}); +Clazz.defineMethod (c$, "ioReadInt", +($fz = function () { +var i = this.stream.readInt (); +if (this.out != null) this.writeInt (i); +return i; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeInt", +function (i) { +this.out.writeByteAsInt (i >> 24); +this.out.writeByteAsInt (i >> 16); +this.out.writeByteAsInt (i >> 8); +this.out.writeByteAsInt (i); +}, "~N"); +Clazz.overrideMethod (c$, "swapBytesI", +function (n) { +return (((n >> 24) & 0xff) | ((n >> 16) & 0xff) << 8 | ((n >> 8) & 0xff) << 16 | (n & 0xff) << 24); +}, "~N"); +Clazz.overrideMethod (c$, "swapBytesS", +function (n) { +return ((((n >> 8) & 0xff) | (n & 0xff) << 8)); +}, "~N"); +Clazz.overrideMethod (c$, "readUnsignedShort", +function () { +this.nBytes += 2; +var a = (this.ioReadByte () & 0xff); +var b = (this.ioReadByte () & 0xff); +return (this.isBigEndian ? (a << 8) + b : (b << 8) + a); +}); +Clazz.overrideMethod (c$, "readLong", +function () { +this.nBytes += 8; +return (this.isBigEndian ? this.ioReadLong () : (((this.ioReadByte ()) & 0xff) | ((this.ioReadByte ()) & 0xff) << 8 | ((this.ioReadByte ()) & 0xff) << 16 | ((this.ioReadByte ()) & 0xff) << 24 | ((this.ioReadByte ()) & 0xff) << 32 | ((this.ioReadByte ()) & 0xff) << 40 | ((this.ioReadByte ()) & 0xff) << 48 | ((this.ioReadByte ()) & 0xff) << 54)); +}); +Clazz.defineMethod (c$, "ioReadLong", +($fz = function () { +var b = this.stream.readLong (); +if (this.out != null) this.writeLong (b); +return b; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "writeLong", +function (b) { +this.writeInt (((b >> 32) & 0xFFFFFFFF)); +this.writeInt ((b & 0xFFFFFFFF)); +}, "~N"); +Clazz.defineMethod (c$, "readLEInt", +($fz = function () { +this.ioRead (this.t8, 0, 4); +return javajs.util.BC.bytesToInt (this.t8, 0, false); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "readFloat", +function () { +return javajs.util.BC.intToFloat (this.readInt ()); +}); +Clazz.overrideMethod (c$, "readDouble", +function () { +{ +this.readByteArray(this.t8, 0, 8); +return this.bytesToDoubleToFloat(this.t8, 0, this.isBigEndian); +}}); +Clazz.defineMethod (c$, "ioReadDouble", +($fz = function () { +var d = this.stream.readDouble (); +if (this.out != null) this.writeLong (Double.doubleToRawLongBits (d)); +return d; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "readLELong", +($fz = function () { +return (((this.ioReadByte ()) & 0xff) | ((this.ioReadByte ()) & 0xff) << 8 | ((this.ioReadByte ()) & 0xff) << 16 | ((this.ioReadByte ()) & 0xff) << 24 | ((this.ioReadByte ()) & 0xff) << 32 | ((this.ioReadByte ()) & 0xff) << 40 | ((this.ioReadByte ()) & 0xff) << 48 | ((this.ioReadByte ()) & 0xff) << 56); +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "seek", +function (offset) { +try { +if (offset == this.nBytes) return; +if (offset < this.nBytes) { +this.stream.reset (); +if (this.out != null && this.nBytes != 0) this.out.reset (); +this.nBytes = 0; +} else { +offset -= this.nBytes; +}if (this.out == null) { +this.stream.skipBytes (offset); +} else { +this.readByteArray ( Clazz.newByteArray (offset, 0), 0, offset); +}this.nBytes += offset; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +}, "~N"); +Clazz.overrideMethod (c$, "getPosition", +function () { +return this.nBytes; +}); +Clazz.overrideMethod (c$, "setOutputChannel", +function (out) { +this.out = out; +}, "javajs.util.OC"); +Clazz.overrideMethod (c$, "getAllDataFiles", +function (binaryFileList, firstFile) { +return null; +}, "~S,~S"); +Clazz.overrideMethod (c$, "getAllDataMapped", +function (replace, string, fileData) { +}, "~S,~S,java.util.Map"); +}); diff --git a/bin/javajs/util/CU.js b/bin/javajs/util/CU.js index edd8bdd..f6b3020 100644 --- a/bin/javajs/util/CU.js +++ b/bin/javajs/util/CU.js @@ -1,135 +1,135 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.util.Hashtable"], "javajs.util.CU", ["javajs.util.P3", "$.PT"], function () { -c$ = Clazz.declareType (javajs.util, "CU"); -c$.toRGBHexString = Clazz.defineMethod (c$, "toRGBHexString", -function (c) { -var rgb = c.getRGB (); -if (rgb == 0) return "000000"; -var r = "00" + Integer.toHexString ((rgb >> 16) & 0xFF); -r = r.substring (r.length - 2); -var g = "00" + Integer.toHexString ((rgb >> 8) & 0xFF); -g = g.substring (g.length - 2); -var b = "00" + Integer.toHexString (rgb & 0xFF); -b = b.substring (b.length - 2); -return r + g + b; -}, "javajs.api.GenericColor"); -c$.toCSSString = Clazz.defineMethod (c$, "toCSSString", -function (c) { -var opacity = c.getOpacity255 (); -if (opacity == 255) return "#" + javajs.util.CU.toRGBHexString (c); -var rgb = c.getRGB (); -return "rgba(" + ((rgb >> 16) & 0xFF) + "," + ((rgb >> 8) & 0xff) + "," + (rgb & 0xff) + "," + opacity / 255 + ")"; -}, "javajs.api.GenericColor"); -c$.getArgbFromString = Clazz.defineMethod (c$, "getArgbFromString", -function (strColor) { -var len = 0; -if (strColor == null || (len = strColor.length) == 0) return 0; -if (strColor.charAt (0) == '[' && strColor.charAt (len - 1) == ']') { -var check; -if (strColor.indexOf (",") >= 0) { -var tokens = javajs.util.PT.split (strColor.substring (1, strColor.length - 1), ","); -if (tokens.length != 3) return 0; -var red = javajs.util.PT.parseFloat (tokens[0]); -var grn = javajs.util.PT.parseFloat (tokens[1]); -var blu = javajs.util.PT.parseFloat (tokens[2]); -return javajs.util.CU.colorTriadToFFRGB (red, grn, blu); -}switch (len) { -case 9: -check = "x"; -break; -case 10: -check = "0x"; -break; -default: -return 0; -} -if (strColor.indexOf (check) != 1) return 0; -strColor = "#" + strColor.substring (len - 7, len - 1); -len = 7; -}if (len == 7 && strColor.charAt (0) == '#') { -try { -return javajs.util.PT.parseIntRadix (strColor.substring (1, 7), 16) | 0xFF000000; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -return 0; -} else { -throw e; -} -} -}var boxedArgb = javajs.util.CU.mapJavaScriptColors.get (strColor.toLowerCase ()); -return (boxedArgb == null ? 0 : boxedArgb.intValue ()); -}, "~S"); -c$.colorTriadToFFRGB = Clazz.defineMethod (c$, "colorTriadToFFRGB", -function (x, y, z) { -if (x <= 1 && y <= 1 && z <= 1) { -if (x > 0) x = x * 256 - 1; -if (y > 0) y = y * 256 - 1; -if (z > 0) z = z * 256 - 1; -}return javajs.util.CU.rgb (Clazz.floatToInt (x), Clazz.floatToInt (y), Clazz.floatToInt (z)); -}, "~N,~N,~N"); -c$.rgb = Clazz.defineMethod (c$, "rgb", -function (red, grn, blu) { -return 0xFF000000 | (red << 16) | (grn << 8) | blu; -}, "~N,~N,~N"); -c$.colorPtFromString = Clazz.defineMethod (c$, "colorPtFromString", -function (colorName) { -return javajs.util.CU.colorPtFromInt (javajs.util.CU.getArgbFromString (colorName), null); -}, "~S"); -c$.colorPtFromInt = Clazz.defineMethod (c$, "colorPtFromInt", -function (color, pt) { -if (pt == null) pt = new javajs.util.P3 (); -pt.set ((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF); -return pt; -}, "~N,javajs.util.P3"); -c$.colorPtToFFRGB = Clazz.defineMethod (c$, "colorPtToFFRGB", -function (pt) { -return javajs.util.CU.colorTriadToFFRGB (pt.x, pt.y, pt.z); -}, "javajs.util.T3"); -c$.toRGB3f = Clazz.defineMethod (c$, "toRGB3f", -function (c, f) { -f[0] = ((c >> 16) & 0xFF) / 255; -f[1] = ((c >> 8) & 0xFF) / 255; -f[2] = (c & 0xFF) / 255; -}, "~N,~A"); -c$.toFFGGGfromRGB = Clazz.defineMethod (c$, "toFFGGGfromRGB", -function (rgb) { -var grey = (Clazz.doubleToInt (((2989 * ((rgb >> 16) & 0xFF)) + (5870 * ((rgb >> 8) & 0xFF)) + (1140 * (rgb & 0xFF)) + 5000) / 10000)) & 0xFFFFFF; -return javajs.util.CU.rgb (grey, grey, grey); -}, "~N"); -c$.rgbToHSL = Clazz.defineMethod (c$, "rgbToHSL", -function (rgb, doRound) { -var r = rgb.x / 255; -var g = rgb.y / 255; -var b = rgb.z / 255; -var min = Math.min (r, Math.min (g, b)); -var max = Math.max (r, Math.max (g, b)); -var p = (max + min); -var q = (max - min); -var h = (60 * ((q == 0 ? 0 : max == r ? ((g - b) / q + 6) : max == g ? (b - r) / q + 2 : (r - g) / q + 4))) % 360; -var s = q / (q == 0 ? 1 : p <= 1 ? p : 2 - p); -return (doRound ? javajs.util.P3.new3 (Math.round (h * 10) / 10, Math.round (s * 1000) / 10, Math.round (p * 500) / 10) : javajs.util.P3.new3 (h, s * 100, p * 50)); -}, "javajs.util.P3,~B"); -c$.hslToRGB = Clazz.defineMethod (c$, "hslToRGB", -function (hsl) { -var h = Math.max (0, Math.min (360, hsl.x)) / 60; -var s = Math.max (0, Math.min (100, hsl.y)) / 100; -var l = Math.max (0, Math.min (100, hsl.z)) / 100; -var p = l - (l < 0.5 ? l : 1 - l) * s; -var q = 2 * (l - p); -var r = javajs.util.CU.toRGB (p, q, h + 2); -var g = javajs.util.CU.toRGB (p, q, h); -var b = javajs.util.CU.toRGB (p, q, h - 2); -return javajs.util.P3.new3 (Math.round (r * 255), Math.round (g * 255), Math.round (b * 255)); -}, "javajs.util.P3"); -c$.toRGB = Clazz.defineMethod (c$, "toRGB", -($fz = function (p, q, h) { -return ((h = (h + (h < 0 ? 6 : h > 6 ? -6 : 0))) < 1 ? p + q * h : h < 3 ? p + q : h < 4 ? p + q * (4 - h) : p); -}, $fz.isPrivate = true, $fz), "~N,~N,~N"); -Clazz.defineStatics (c$, -"colorNames", Clazz.newArray (-1, ["black", "pewhite", "pecyan", "pepurple", "pegreen", "peblue", "peviolet", "pebrown", "pepink", "peyellow", "pedarkgreen", "peorange", "pelightblue", "pedarkcyan", "pedarkgray", "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen", "bluetint", "greenblue", "greentint", "grey", "pinktint", "redorange", "yellowtint"]), -"colorArgbs", Clazz.newIntArray (-1, [0xFF000000, 0xFFffffff, 0xFF00ffff, 0xFFd020ff, 0xFF00ff00, 0xFF6060ff, 0xFFff80c0, 0xFFa42028, 0xFFffd8d8, 0xFFffff00, 0xFF00c000, 0xFFffb000, 0xFFb0b0ff, 0xFF00a0a0, 0xFF606060, 0xFFF0F8FF, 0xFFFAEBD7, 0xFF00FFFF, 0xFF7FFFD4, 0xFFF0FFFF, 0xFFF5F5DC, 0xFFFFE4C4, 0xFFFFEBCD, 0xFF0000FF, 0xFF8A2BE2, 0xFFA52A2A, 0xFFDEB887, 0xFF5F9EA0, 0xFF7FFF00, 0xFFD2691E, 0xFFFF7F50, 0xFF6495ED, 0xFFFFF8DC, 0xFFDC143C, 0xFF00FFFF, 0xFF00008B, 0xFF008B8B, 0xFFB8860B, 0xFFA9A9A9, 0xFF006400, 0xFFBDB76B, 0xFF8B008B, 0xFF556B2F, 0xFFFF8C00, 0xFF9932CC, 0xFF8B0000, 0xFFE9967A, 0xFF8FBC8F, 0xFF483D8B, 0xFF2F4F4F, 0xFF00CED1, 0xFF9400D3, 0xFFFF1493, 0xFF00BFFF, 0xFF696969, 0xFF1E90FF, 0xFFB22222, 0xFFFFFAF0, 0xFF228B22, 0xFFFF00FF, 0xFFDCDCDC, 0xFFF8F8FF, 0xFFFFD700, 0xFFDAA520, 0xFF808080, 0xFF008000, 0xFFADFF2F, 0xFFF0FFF0, 0xFFFF69B4, 0xFFCD5C5C, 0xFF4B0082, 0xFFFFFFF0, 0xFFF0E68C, 0xFFE6E6FA, 0xFFFFF0F5, 0xFF7CFC00, 0xFFFFFACD, 0xFFADD8E6, 0xFFF08080, 0xFFE0FFFF, 0xFFFAFAD2, 0xFF90EE90, 0xFFD3D3D3, 0xFFFFB6C1, 0xFFFFA07A, 0xFF20B2AA, 0xFF87CEFA, 0xFF778899, 0xFFB0C4DE, 0xFFFFFFE0, 0xFF00FF00, 0xFF32CD32, 0xFFFAF0E6, 0xFFFF00FF, 0xFF800000, 0xFF66CDAA, 0xFF0000CD, 0xFFBA55D3, 0xFF9370DB, 0xFF3CB371, 0xFF7B68EE, 0xFF00FA9A, 0xFF48D1CC, 0xFFC71585, 0xFF191970, 0xFFF5FFFA, 0xFFFFE4E1, 0xFFFFE4B5, 0xFFFFDEAD, 0xFF000080, 0xFFFDF5E6, 0xFF808000, 0xFF6B8E23, 0xFFFFA500, 0xFFFF4500, 0xFFDA70D6, 0xFFEEE8AA, 0xFF98FB98, 0xFFAFEEEE, 0xFFDB7093, 0xFFFFEFD5, 0xFFFFDAB9, 0xFFCD853F, 0xFFFFC0CB, 0xFFDDA0DD, 0xFFB0E0E6, 0xFF800080, 0xFFFF0000, 0xFFBC8F8F, 0xFF4169E1, 0xFF8B4513, 0xFFFA8072, 0xFFF4A460, 0xFF2E8B57, 0xFFFFF5EE, 0xFFA0522D, 0xFFC0C0C0, 0xFF87CEEB, 0xFF6A5ACD, 0xFF708090, 0xFFFFFAFA, 0xFF00FF7F, 0xFF4682B4, 0xFFD2B48C, 0xFF008080, 0xFFD8BFD8, 0xFFFF6347, 0xFF40E0D0, 0xFFEE82EE, 0xFFF5DEB3, 0xFFFFFFFF, 0xFFF5F5F5, 0xFFFFFF00, 0xFF9ACD32, 0xFFAFD7FF, 0xFF2E8B57, 0xFF98FFB3, 0xFF808080, 0xFFFFABBB, 0xFFFF4500, 0xFFF6F675])); -c$.mapJavaScriptColors = c$.prototype.mapJavaScriptColors = new java.util.Hashtable (); -{ -for (var i = javajs.util.CU.colorNames.length; --i >= 0; ) javajs.util.CU.mapJavaScriptColors.put (javajs.util.CU.colorNames[i], Integer.$valueOf (javajs.util.CU.colorArgbs[i])); - -}}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.util.Hashtable"], "javajs.util.CU", ["javajs.util.P3", "$.PT"], function () { +c$ = Clazz.declareType (javajs.util, "CU"); +c$.toRGBHexString = Clazz.defineMethod (c$, "toRGBHexString", +function (c) { +var rgb = c.getRGB (); +if (rgb == 0) return "000000"; +var r = "00" + Integer.toHexString ((rgb >> 16) & 0xFF); +r = r.substring (r.length - 2); +var g = "00" + Integer.toHexString ((rgb >> 8) & 0xFF); +g = g.substring (g.length - 2); +var b = "00" + Integer.toHexString (rgb & 0xFF); +b = b.substring (b.length - 2); +return r + g + b; +}, "javajs.api.GenericColor"); +c$.toCSSString = Clazz.defineMethod (c$, "toCSSString", +function (c) { +var opacity = c.getOpacity255 (); +if (opacity == 255) return "#" + javajs.util.CU.toRGBHexString (c); +var rgb = c.getRGB (); +return "rgba(" + ((rgb >> 16) & 0xFF) + "," + ((rgb >> 8) & 0xff) + "," + (rgb & 0xff) + "," + opacity / 255 + ")"; +}, "javajs.api.GenericColor"); +c$.getArgbFromString = Clazz.defineMethod (c$, "getArgbFromString", +function (strColor) { +var len = 0; +if (strColor == null || (len = strColor.length) == 0) return 0; +if (strColor.charAt (0) == '[' && strColor.charAt (len - 1) == ']') { +var check; +if (strColor.indexOf (",") >= 0) { +var tokens = javajs.util.PT.split (strColor.substring (1, strColor.length - 1), ","); +if (tokens.length != 3) return 0; +var red = javajs.util.PT.parseFloat (tokens[0]); +var grn = javajs.util.PT.parseFloat (tokens[1]); +var blu = javajs.util.PT.parseFloat (tokens[2]); +return javajs.util.CU.colorTriadToFFRGB (red, grn, blu); +}switch (len) { +case 9: +check = "x"; +break; +case 10: +check = "0x"; +break; +default: +return 0; +} +if (strColor.indexOf (check) != 1) return 0; +strColor = "#" + strColor.substring (len - 7, len - 1); +len = 7; +}if (len == 7 && strColor.charAt (0) == '#') { +try { +return javajs.util.PT.parseIntRadix (strColor.substring (1, 7), 16) | 0xFF000000; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +return 0; +} else { +throw e; +} +} +}var boxedArgb = javajs.util.CU.mapJavaScriptColors.get (strColor.toLowerCase ()); +return (boxedArgb == null ? 0 : boxedArgb.intValue ()); +}, "~S"); +c$.colorTriadToFFRGB = Clazz.defineMethod (c$, "colorTriadToFFRGB", +function (x, y, z) { +if (x <= 1 && y <= 1 && z <= 1) { +if (x > 0) x = x * 256 - 1; +if (y > 0) y = y * 256 - 1; +if (z > 0) z = z * 256 - 1; +}return javajs.util.CU.rgb (Clazz.floatToInt (x), Clazz.floatToInt (y), Clazz.floatToInt (z)); +}, "~N,~N,~N"); +c$.rgb = Clazz.defineMethod (c$, "rgb", +function (red, grn, blu) { +return 0xFF000000 | (red << 16) | (grn << 8) | blu; +}, "~N,~N,~N"); +c$.colorPtFromString = Clazz.defineMethod (c$, "colorPtFromString", +function (colorName) { +return javajs.util.CU.colorPtFromInt (javajs.util.CU.getArgbFromString (colorName), null); +}, "~S"); +c$.colorPtFromInt = Clazz.defineMethod (c$, "colorPtFromInt", +function (color, pt) { +if (pt == null) pt = new javajs.util.P3 (); +pt.set ((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF); +return pt; +}, "~N,javajs.util.P3"); +c$.colorPtToFFRGB = Clazz.defineMethod (c$, "colorPtToFFRGB", +function (pt) { +return javajs.util.CU.colorTriadToFFRGB (pt.x, pt.y, pt.z); +}, "javajs.util.T3"); +c$.toRGB3f = Clazz.defineMethod (c$, "toRGB3f", +function (c, f) { +f[0] = ((c >> 16) & 0xFF) / 255; +f[1] = ((c >> 8) & 0xFF) / 255; +f[2] = (c & 0xFF) / 255; +}, "~N,~A"); +c$.toFFGGGfromRGB = Clazz.defineMethod (c$, "toFFGGGfromRGB", +function (rgb) { +var grey = (Clazz.doubleToInt (((2989 * ((rgb >> 16) & 0xFF)) + (5870 * ((rgb >> 8) & 0xFF)) + (1140 * (rgb & 0xFF)) + 5000) / 10000)) & 0xFFFFFF; +return javajs.util.CU.rgb (grey, grey, grey); +}, "~N"); +c$.rgbToHSL = Clazz.defineMethod (c$, "rgbToHSL", +function (rgb, doRound) { +var r = rgb.x / 255; +var g = rgb.y / 255; +var b = rgb.z / 255; +var min = Math.min (r, Math.min (g, b)); +var max = Math.max (r, Math.max (g, b)); +var p = (max + min); +var q = (max - min); +var h = (60 * ((q == 0 ? 0 : max == r ? ((g - b) / q + 6) : max == g ? (b - r) / q + 2 : (r - g) / q + 4))) % 360; +var s = q / (q == 0 ? 1 : p <= 1 ? p : 2 - p); +return (doRound ? javajs.util.P3.new3 (Math.round (h * 10) / 10, Math.round (s * 1000) / 10, Math.round (p * 500) / 10) : javajs.util.P3.new3 (h, s * 100, p * 50)); +}, "javajs.util.P3,~B"); +c$.hslToRGB = Clazz.defineMethod (c$, "hslToRGB", +function (hsl) { +var h = Math.max (0, Math.min (360, hsl.x)) / 60; +var s = Math.max (0, Math.min (100, hsl.y)) / 100; +var l = Math.max (0, Math.min (100, hsl.z)) / 100; +var p = l - (l < 0.5 ? l : 1 - l) * s; +var q = 2 * (l - p); +var r = javajs.util.CU.toRGB (p, q, h + 2); +var g = javajs.util.CU.toRGB (p, q, h); +var b = javajs.util.CU.toRGB (p, q, h - 2); +return javajs.util.P3.new3 (Math.round (r * 255), Math.round (g * 255), Math.round (b * 255)); +}, "javajs.util.P3"); +c$.toRGB = Clazz.defineMethod (c$, "toRGB", +($fz = function (p, q, h) { +return ((h = (h + (h < 0 ? 6 : h > 6 ? -6 : 0))) < 1 ? p + q * h : h < 3 ? p + q : h < 4 ? p + q * (4 - h) : p); +}, $fz.isPrivate = true, $fz), "~N,~N,~N"); +Clazz.defineStatics (c$, +"colorNames", Clazz.newArray (-1, ["black", "pewhite", "pecyan", "pepurple", "pegreen", "peblue", "peviolet", "pebrown", "pepink", "peyellow", "pedarkgreen", "peorange", "pelightblue", "pedarkcyan", "pedarkgray", "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen", "bluetint", "greenblue", "greentint", "grey", "pinktint", "redorange", "yellowtint"]), +"colorArgbs", Clazz.newIntArray (-1, [0xFF000000, 0xFFffffff, 0xFF00ffff, 0xFFd020ff, 0xFF00ff00, 0xFF6060ff, 0xFFff80c0, 0xFFa42028, 0xFFffd8d8, 0xFFffff00, 0xFF00c000, 0xFFffb000, 0xFFb0b0ff, 0xFF00a0a0, 0xFF606060, 0xFFF0F8FF, 0xFFFAEBD7, 0xFF00FFFF, 0xFF7FFFD4, 0xFFF0FFFF, 0xFFF5F5DC, 0xFFFFE4C4, 0xFFFFEBCD, 0xFF0000FF, 0xFF8A2BE2, 0xFFA52A2A, 0xFFDEB887, 0xFF5F9EA0, 0xFF7FFF00, 0xFFD2691E, 0xFFFF7F50, 0xFF6495ED, 0xFFFFF8DC, 0xFFDC143C, 0xFF00FFFF, 0xFF00008B, 0xFF008B8B, 0xFFB8860B, 0xFFA9A9A9, 0xFF006400, 0xFFBDB76B, 0xFF8B008B, 0xFF556B2F, 0xFFFF8C00, 0xFF9932CC, 0xFF8B0000, 0xFFE9967A, 0xFF8FBC8F, 0xFF483D8B, 0xFF2F4F4F, 0xFF00CED1, 0xFF9400D3, 0xFFFF1493, 0xFF00BFFF, 0xFF696969, 0xFF1E90FF, 0xFFB22222, 0xFFFFFAF0, 0xFF228B22, 0xFFFF00FF, 0xFFDCDCDC, 0xFFF8F8FF, 0xFFFFD700, 0xFFDAA520, 0xFF808080, 0xFF008000, 0xFFADFF2F, 0xFFF0FFF0, 0xFFFF69B4, 0xFFCD5C5C, 0xFF4B0082, 0xFFFFFFF0, 0xFFF0E68C, 0xFFE6E6FA, 0xFFFFF0F5, 0xFF7CFC00, 0xFFFFFACD, 0xFFADD8E6, 0xFFF08080, 0xFFE0FFFF, 0xFFFAFAD2, 0xFF90EE90, 0xFFD3D3D3, 0xFFFFB6C1, 0xFFFFA07A, 0xFF20B2AA, 0xFF87CEFA, 0xFF778899, 0xFFB0C4DE, 0xFFFFFFE0, 0xFF00FF00, 0xFF32CD32, 0xFFFAF0E6, 0xFFFF00FF, 0xFF800000, 0xFF66CDAA, 0xFF0000CD, 0xFFBA55D3, 0xFF9370DB, 0xFF3CB371, 0xFF7B68EE, 0xFF00FA9A, 0xFF48D1CC, 0xFFC71585, 0xFF191970, 0xFFF5FFFA, 0xFFFFE4E1, 0xFFFFE4B5, 0xFFFFDEAD, 0xFF000080, 0xFFFDF5E6, 0xFF808000, 0xFF6B8E23, 0xFFFFA500, 0xFFFF4500, 0xFFDA70D6, 0xFFEEE8AA, 0xFF98FB98, 0xFFAFEEEE, 0xFFDB7093, 0xFFFFEFD5, 0xFFFFDAB9, 0xFFCD853F, 0xFFFFC0CB, 0xFFDDA0DD, 0xFFB0E0E6, 0xFF800080, 0xFFFF0000, 0xFFBC8F8F, 0xFF4169E1, 0xFF8B4513, 0xFFFA8072, 0xFFF4A460, 0xFF2E8B57, 0xFFFFF5EE, 0xFFA0522D, 0xFFC0C0C0, 0xFF87CEEB, 0xFF6A5ACD, 0xFF708090, 0xFFFFFAFA, 0xFF00FF7F, 0xFF4682B4, 0xFFD2B48C, 0xFF008080, 0xFFD8BFD8, 0xFFFF6347, 0xFF40E0D0, 0xFFEE82EE, 0xFFF5DEB3, 0xFFFFFFFF, 0xFFF5F5F5, 0xFFFFFF00, 0xFF9ACD32, 0xFFAFD7FF, 0xFF2E8B57, 0xFF98FFB3, 0xFF808080, 0xFFFFABBB, 0xFFFF4500, 0xFFF6F675])); +c$.mapJavaScriptColors = c$.prototype.mapJavaScriptColors = new java.util.Hashtable (); +{ +for (var i = javajs.util.CU.colorNames.length; --i >= 0; ) javajs.util.CU.mapJavaScriptColors.put (javajs.util.CU.colorNames[i], Integer.$valueOf (javajs.util.CU.colorArgbs[i])); + +}}); diff --git a/bin/javajs/util/CifDataParser.js b/bin/javajs/util/CifDataParser.js index 07e1495..c00c5e1 100644 --- a/bin/javajs/util/CifDataParser.js +++ b/bin/javajs/util/CifDataParser.js @@ -1,303 +1,303 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.GenericCifDataParser", "java.util.Hashtable", "javajs.util.SB"], "javajs.util.CifDataParser", ["javajs.util.Lst", "$.PT"], function () { -c$ = Clazz.decorateAsClass (function () { -this.reader = null; -this.br = null; -this.line = null; -this.str = null; -this.ich = 0; -this.cch = 0; -this.wasUnQuoted = false; -this.strPeeked = null; -this.ichPeeked = 0; -this.fieldCount = 0; -this.loopData = null; -this.fileHeader = null; -this.isHeader = true; -this.nullString = "\0"; -this.fields = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "CifDataParser", null, javajs.api.GenericCifDataParser); -Clazz.prepareFields (c$, function () { -this.fileHeader = new javajs.util.SB (); -}); -Clazz.defineMethod (c$, "setNullValue", -function (nullString) { -this.nullString = nullString; -}, "~S"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.overrideMethod (c$, "getLoopData", -function (i) { -return this.loopData[i]; -}, "~N"); -Clazz.overrideMethod (c$, "getFieldCount", -function () { -return this.fieldCount; -}); -Clazz.overrideMethod (c$, "getField", -function (i) { -return this.fields[i]; -}, "~N"); -Clazz.overrideMethod (c$, "set", -function (reader, br) { -this.reader = reader; -this.br = br; -return this; -}, "javajs.api.GenericLineReader,java.io.BufferedReader"); -Clazz.overrideMethod (c$, "getFileHeader", -function () { -return this.fileHeader.toString (); -}); -Clazz.overrideMethod (c$, "getAllCifData", -function () { -this.line = ""; -var key; -var data = null; -var allData = new java.util.Hashtable (); -var models = new javajs.util.Lst (); -allData.put ("models", models); -try { -while ((key = this.getNextToken ()) != null) { -if (key.startsWith ("global_") || key.startsWith ("data_")) { -models.addLast (data = new java.util.Hashtable ()); -data.put ("name", key); -continue; -}if (key.startsWith ("loop_")) { -this.getAllCifLoopData (data); -continue; -}if (key.charAt (0) != '_') { -System.out.println ("CIF ERROR ? should be an underscore: " + key); -} else { -var value = this.getNextToken (); -if (value == null) { -System.out.println ("CIF ERROR ? end of file; data missing: " + key); -} else { -data.put (this.fixKey (key), value); -}}} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -try { -if (this.br != null) this.br.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -return allData; -}); -Clazz.defineMethod (c$, "getAllCifLoopData", -($fz = function (data) { -var key; -var keyWords = new javajs.util.Lst (); -while ((key = this.peekToken ()) != null && key.charAt (0) == '_') { -key = this.fixKey (this.getTokenPeeked ()); -keyWords.addLast (key); -data.put (key, new javajs.util.Lst ()); -} -this.fieldCount = keyWords.size (); -if (this.fieldCount == 0) return; -this.loopData = new Array (this.fieldCount); -while (this.getData ()) for (var i = 0; i < this.fieldCount; i++) (data.get (keyWords.get (i))).addLast (this.loopData[i]); - - -}, $fz.isPrivate = true, $fz), "java.util.Map"); -Clazz.overrideMethod (c$, "readLine", -function () { -try { -this.line = (this.reader == null ? this.br.readLine () : this.reader.readNextLine ()); -if (this.line == null) return null; -if (this.isHeader) { -if (this.line.startsWith ("#")) this.fileHeader.append (this.line).appendC ('\n'); - else this.isHeader = false; -}return this.line; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -return null; -} else { -throw e; -} -} -}); -Clazz.overrideMethod (c$, "getData", -function () { -for (var i = 0; i < this.fieldCount; ++i) if ((this.loopData[i] = this.getNextDataToken ()) == null) return false; - -return (this.fieldCount > 0); -}); -Clazz.overrideMethod (c$, "skipLoop", -function (doReport) { -var str; -var ret = (doReport ? new javajs.util.SB () : null); -var n = 0; -while ((str = this.peekToken ()) != null && str.charAt (0) == '_') { -if (ret != null) ret.append (str).append ("\n"); -this.getTokenPeeked (); -n++; -} -var m = 0; -while ((str = this.getNextDataToken ()) != null) { -if (ret == null) continue; -ret.append (str).append (" "); -if ((++m % n) == 0) ret.append ("\n"); -} -return (ret == null ? null : ret.toString ()); -}, "~B"); -Clazz.overrideMethod (c$, "getNextToken", -function () { -while (!this.strHasMoreTokens ()) if (this.setStringNextLine () == null) return null; - -return this.nextStrToken (); -}); -Clazz.overrideMethod (c$, "getNextDataToken", -function () { -var str = this.peekToken (); -if (str == null) return null; -if (this.wasUnQuoted) if (str.charAt (0) == '_' || str.startsWith ("loop_") || str.startsWith ("data_") || str.startsWith ("stop_") || str.startsWith ("global_")) return null; -return this.getTokenPeeked (); -}); -Clazz.overrideMethod (c$, "peekToken", -function () { -while (!this.strHasMoreTokens ()) if (this.setStringNextLine () == null) return null; - -var ich = this.ich; -this.strPeeked = this.nextStrToken (); -this.ichPeeked = this.ich; -this.ich = ich; -return this.strPeeked; -}); -Clazz.overrideMethod (c$, "getTokenPeeked", -function () { -this.ich = this.ichPeeked; -return this.strPeeked; -}); -Clazz.overrideMethod (c$, "fullTrim", -function (str) { -var pt0 = -1; -var pt1 = str.length; -while (++pt0 < pt1 && javajs.util.PT.isWhitespace (str.charAt (pt0))) { -} -while (--pt1 > pt0 && javajs.util.PT.isWhitespace (str.charAt (pt1))) { -} -return str.substring (pt0, pt1 + 1); -}, "~S"); -Clazz.overrideMethod (c$, "toUnicode", -function (data) { -var pt; -try { -while ((pt = data.indexOf ('\\')) >= 0) { -var c = data.charCodeAt (pt + 1); -var ch = (c >= 65 && c <= 90 ? "ABX\u0394E\u03a6\u0393HI_K\u039bMNO\u03a0\u0398P\u03a3TY_\u03a9\u039e\u03a5Z".substring (c - 65, c - 64) : c >= 97 && c <= 122 ? "\u03b1\u03b2\u03c7\u03a4\u03a5\u03c6\u03b3\u03b7\u03b9_\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03b8\u03c1\u03c3\u03c4\u03c5_\u03c9\u03be\u03c5\u03b6".substring (c - 97, c - 96) : "_"); -data = data.substring (0, pt) + ch + data.substring (pt + 2); -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -return data; -}, "~S"); -Clazz.overrideMethod (c$, "parseLoopParameters", -function (fields, fieldOf, propertyOf) { -var propertyCount = 0; -if (fields == null) { -this.fields = new Array (100); -} else { -if (!javajs.util.CifDataParser.htFields.containsKey (fields[0])) for (var i = fields.length; --i >= 0; ) javajs.util.CifDataParser.htFields.put (fields[i], Integer.$valueOf (i)); - -for (var i = fields.length; --i >= 0; ) fieldOf[i] = -1; - -propertyCount = fields.length; -}this.fieldCount = 0; -while (true) { -var str = this.peekToken (); -if (str == null) { -this.fieldCount = 0; -break; -}if (str.charAt (0) != '_') break; -var pt = this.fieldCount++; -str = this.fixKey (this.getTokenPeeked ()); -if (fields == null) { -this.fields[propertyOf[pt] = fieldOf[pt] = pt] = str; -continue; -}var iField = javajs.util.CifDataParser.htFields.get (str); -var i = (iField == null ? -1 : iField.intValue ()); -if ((propertyOf[pt] = i) != -1) fieldOf[i] = pt; -} -if (this.fieldCount > 0) this.loopData = new Array (this.fieldCount); -return propertyCount; -}, "~A,~A,~A"); -Clazz.overrideMethod (c$, "fixKey", -function (key) { -return (javajs.util.PT.rep (key.startsWith ("_magnetic") ? key.substring (9) : key.startsWith ("_jana") ? key.substring (5) : key, ".", "_").toLowerCase ()); -}, "~S"); -Clazz.defineMethod (c$, "setString", -($fz = function (str) { -this.str = this.line = str; -this.cch = (str == null ? 0 : str.length); -this.ich = 0; -}, $fz.isPrivate = true, $fz), "~S"); -Clazz.defineMethod (c$, "setStringNextLine", -($fz = function () { -this.setString (this.readLine ()); -if (this.line == null || this.line.length == 0) return this.line; -if (this.line.charAt (0) != ';') { -if (this.str.startsWith ("###non-st#")) this.ich = 10; -return this.line; -}this.ich = 1; -var str = '\1' + this.line.substring (1) + '\n'; -while (this.readLine () != null) { -if (this.line.startsWith (";")) { -str = str.substring (0, str.length - 1) + '\1' + this.line.substring (1); -break; -}str += this.line + '\n'; -} -this.setString (str); -return str; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "strHasMoreTokens", -($fz = function () { -if (this.str == null) return false; -var ch = '#'; -while (this.ich < this.cch && ((ch = this.str.charAt (this.ich)) == ' ' || ch == '\t')) ++this.ich; - -return (this.ich < this.cch && ch != '#'); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "nextStrToken", -($fz = function () { -if (this.ich == this.cch) return null; -var ichStart = this.ich; -var ch = this.str.charAt (ichStart); -if (ch != '\'' && ch != '"' && ch != '\1') { -this.wasUnQuoted = true; -while (this.ich < this.cch && (ch = this.str.charAt (this.ich)) != ' ' && ch != '\t') ++this.ich; - -if (this.ich == ichStart + 1) if (this.nullString != null && (this.str.charAt (ichStart) == '.' || this.str.charAt (ichStart) == '?')) return this.nullString; -var s = this.str.substring (ichStart, this.ich); -return s; -}this.wasUnQuoted = false; -var chOpeningQuote = ch; -var previousCharacterWasQuote = false; -while (++this.ich < this.cch) { -ch = this.str.charAt (this.ich); -if (previousCharacterWasQuote && (ch == ' ' || ch == '\t')) break; -previousCharacterWasQuote = (ch == chOpeningQuote); -} -if (this.ich == this.cch) { -if (previousCharacterWasQuote) return this.str.substring (ichStart + 1, this.ich - 1); -return this.str.substring (ichStart, this.ich); -}++this.ich; -return this.str.substring (ichStart + 1, this.ich - 2); -}, $fz.isPrivate = true, $fz)); -c$.htFields = c$.prototype.htFields = new java.util.Hashtable (); -Clazz.defineStatics (c$, -"grABC", "ABX\u0394E\u03a6\u0393HI_K\u039bMNO\u03a0\u0398P\u03a3TY_\u03a9\u039e\u03a5Z", -"grabc", "\u03b1\u03b2\u03c7\u03a4\u03a5\u03c6\u03b3\u03b7\u03b9_\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03b8\u03c1\u03c3\u03c4\u03c5_\u03c9\u03be\u03c5\u03b6"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.GenericCifDataParser", "java.util.Hashtable", "javajs.util.SB"], "javajs.util.CifDataParser", ["javajs.util.Lst", "$.PT"], function () { +c$ = Clazz.decorateAsClass (function () { +this.reader = null; +this.br = null; +this.line = null; +this.str = null; +this.ich = 0; +this.cch = 0; +this.wasUnQuoted = false; +this.strPeeked = null; +this.ichPeeked = 0; +this.fieldCount = 0; +this.loopData = null; +this.fileHeader = null; +this.isHeader = true; +this.nullString = "\0"; +this.fields = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "CifDataParser", null, javajs.api.GenericCifDataParser); +Clazz.prepareFields (c$, function () { +this.fileHeader = new javajs.util.SB (); +}); +Clazz.defineMethod (c$, "setNullValue", +function (nullString) { +this.nullString = nullString; +}, "~S"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.overrideMethod (c$, "getLoopData", +function (i) { +return this.loopData[i]; +}, "~N"); +Clazz.overrideMethod (c$, "getFieldCount", +function () { +return this.fieldCount; +}); +Clazz.overrideMethod (c$, "getField", +function (i) { +return this.fields[i]; +}, "~N"); +Clazz.overrideMethod (c$, "set", +function (reader, br) { +this.reader = reader; +this.br = br; +return this; +}, "javajs.api.GenericLineReader,java.io.BufferedReader"); +Clazz.overrideMethod (c$, "getFileHeader", +function () { +return this.fileHeader.toString (); +}); +Clazz.overrideMethod (c$, "getAllCifData", +function () { +this.line = ""; +var key; +var data = null; +var allData = new java.util.Hashtable (); +var models = new javajs.util.Lst (); +allData.put ("models", models); +try { +while ((key = this.getNextToken ()) != null) { +if (key.startsWith ("global_") || key.startsWith ("data_")) { +models.addLast (data = new java.util.Hashtable ()); +data.put ("name", key); +continue; +}if (key.startsWith ("loop_")) { +this.getAllCifLoopData (data); +continue; +}if (key.charAt (0) != '_') { +System.out.println ("CIF ERROR ? should be an underscore: " + key); +} else { +var value = this.getNextToken (); +if (value == null) { +System.out.println ("CIF ERROR ? end of file; data missing: " + key); +} else { +data.put (this.fixKey (key), value); +}}} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +try { +if (this.br != null) this.br.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +return allData; +}); +Clazz.defineMethod (c$, "getAllCifLoopData", +($fz = function (data) { +var key; +var keyWords = new javajs.util.Lst (); +while ((key = this.peekToken ()) != null && key.charAt (0) == '_') { +key = this.fixKey (this.getTokenPeeked ()); +keyWords.addLast (key); +data.put (key, new javajs.util.Lst ()); +} +this.fieldCount = keyWords.size (); +if (this.fieldCount == 0) return; +this.loopData = new Array (this.fieldCount); +while (this.getData ()) for (var i = 0; i < this.fieldCount; i++) (data.get (keyWords.get (i))).addLast (this.loopData[i]); + + +}, $fz.isPrivate = true, $fz), "java.util.Map"); +Clazz.overrideMethod (c$, "readLine", +function () { +try { +this.line = (this.reader == null ? this.br.readLine () : this.reader.readNextLine ()); +if (this.line == null) return null; +if (this.isHeader) { +if (this.line.startsWith ("#")) this.fileHeader.append (this.line).appendC ('\n'); + else this.isHeader = false; +}return this.line; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +return null; +} else { +throw e; +} +} +}); +Clazz.overrideMethod (c$, "getData", +function () { +for (var i = 0; i < this.fieldCount; ++i) if ((this.loopData[i] = this.getNextDataToken ()) == null) return false; + +return (this.fieldCount > 0); +}); +Clazz.overrideMethod (c$, "skipLoop", +function (doReport) { +var str; +var ret = (doReport ? new javajs.util.SB () : null); +var n = 0; +while ((str = this.peekToken ()) != null && str.charAt (0) == '_') { +if (ret != null) ret.append (str).append ("\n"); +this.getTokenPeeked (); +n++; +} +var m = 0; +while ((str = this.getNextDataToken ()) != null) { +if (ret == null) continue; +ret.append (str).append (" "); +if ((++m % n) == 0) ret.append ("\n"); +} +return (ret == null ? null : ret.toString ()); +}, "~B"); +Clazz.overrideMethod (c$, "getNextToken", +function () { +while (!this.strHasMoreTokens ()) if (this.setStringNextLine () == null) return null; + +return this.nextStrToken (); +}); +Clazz.overrideMethod (c$, "getNextDataToken", +function () { +var str = this.peekToken (); +if (str == null) return null; +if (this.wasUnQuoted) if (str.charAt (0) == '_' || str.startsWith ("loop_") || str.startsWith ("data_") || str.startsWith ("stop_") || str.startsWith ("global_")) return null; +return this.getTokenPeeked (); +}); +Clazz.overrideMethod (c$, "peekToken", +function () { +while (!this.strHasMoreTokens ()) if (this.setStringNextLine () == null) return null; + +var ich = this.ich; +this.strPeeked = this.nextStrToken (); +this.ichPeeked = this.ich; +this.ich = ich; +return this.strPeeked; +}); +Clazz.overrideMethod (c$, "getTokenPeeked", +function () { +this.ich = this.ichPeeked; +return this.strPeeked; +}); +Clazz.overrideMethod (c$, "fullTrim", +function (str) { +var pt0 = -1; +var pt1 = str.length; +while (++pt0 < pt1 && javajs.util.PT.isWhitespace (str.charAt (pt0))) { +} +while (--pt1 > pt0 && javajs.util.PT.isWhitespace (str.charAt (pt1))) { +} +return str.substring (pt0, pt1 + 1); +}, "~S"); +Clazz.overrideMethod (c$, "toUnicode", +function (data) { +var pt; +try { +while ((pt = data.indexOf ('\\')) >= 0) { +var c = data.charCodeAt (pt + 1); +var ch = (c >= 65 && c <= 90 ? "ABX\u0394E\u03a6\u0393HI_K\u039bMNO\u03a0\u0398P\u03a3TY_\u03a9\u039e\u03a5Z".substring (c - 65, c - 64) : c >= 97 && c <= 122 ? "\u03b1\u03b2\u03c7\u03a4\u03a5\u03c6\u03b3\u03b7\u03b9_\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03b8\u03c1\u03c3\u03c4\u03c5_\u03c9\u03be\u03c5\u03b6".substring (c - 97, c - 96) : "_"); +data = data.substring (0, pt) + ch + data.substring (pt + 2); +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +return data; +}, "~S"); +Clazz.overrideMethod (c$, "parseLoopParameters", +function (fields, fieldOf, propertyOf) { +var propertyCount = 0; +if (fields == null) { +this.fields = new Array (100); +} else { +if (!javajs.util.CifDataParser.htFields.containsKey (fields[0])) for (var i = fields.length; --i >= 0; ) javajs.util.CifDataParser.htFields.put (fields[i], Integer.$valueOf (i)); + +for (var i = fields.length; --i >= 0; ) fieldOf[i] = -1; + +propertyCount = fields.length; +}this.fieldCount = 0; +while (true) { +var str = this.peekToken (); +if (str == null) { +this.fieldCount = 0; +break; +}if (str.charAt (0) != '_') break; +var pt = this.fieldCount++; +str = this.fixKey (this.getTokenPeeked ()); +if (fields == null) { +this.fields[propertyOf[pt] = fieldOf[pt] = pt] = str; +continue; +}var iField = javajs.util.CifDataParser.htFields.get (str); +var i = (iField == null ? -1 : iField.intValue ()); +if ((propertyOf[pt] = i) != -1) fieldOf[i] = pt; +} +if (this.fieldCount > 0) this.loopData = new Array (this.fieldCount); +return propertyCount; +}, "~A,~A,~A"); +Clazz.overrideMethod (c$, "fixKey", +function (key) { +return (javajs.util.PT.rep (key.startsWith ("_magnetic") ? key.substring (9) : key.startsWith ("_jana") ? key.substring (5) : key, ".", "_").toLowerCase ()); +}, "~S"); +Clazz.defineMethod (c$, "setString", +($fz = function (str) { +this.str = this.line = str; +this.cch = (str == null ? 0 : str.length); +this.ich = 0; +}, $fz.isPrivate = true, $fz), "~S"); +Clazz.defineMethod (c$, "setStringNextLine", +($fz = function () { +this.setString (this.readLine ()); +if (this.line == null || this.line.length == 0) return this.line; +if (this.line.charAt (0) != ';') { +if (this.str.startsWith ("###non-st#")) this.ich = 10; +return this.line; +}this.ich = 1; +var str = '\1' + this.line.substring (1) + '\n'; +while (this.readLine () != null) { +if (this.line.startsWith (";")) { +str = str.substring (0, str.length - 1) + '\1' + this.line.substring (1); +break; +}str += this.line + '\n'; +} +this.setString (str); +return str; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "strHasMoreTokens", +($fz = function () { +if (this.str == null) return false; +var ch = '#'; +while (this.ich < this.cch && ((ch = this.str.charAt (this.ich)) == ' ' || ch == '\t')) ++this.ich; + +return (this.ich < this.cch && ch != '#'); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "nextStrToken", +($fz = function () { +if (this.ich == this.cch) return null; +var ichStart = this.ich; +var ch = this.str.charAt (ichStart); +if (ch != '\'' && ch != '"' && ch != '\1') { +this.wasUnQuoted = true; +while (this.ich < this.cch && (ch = this.str.charAt (this.ich)) != ' ' && ch != '\t') ++this.ich; + +if (this.ich == ichStart + 1) if (this.nullString != null && (this.str.charAt (ichStart) == '.' || this.str.charAt (ichStart) == '?')) return this.nullString; +var s = this.str.substring (ichStart, this.ich); +return s; +}this.wasUnQuoted = false; +var chOpeningQuote = ch; +var previousCharacterWasQuote = false; +while (++this.ich < this.cch) { +ch = this.str.charAt (this.ich); +if (previousCharacterWasQuote && (ch == ' ' || ch == '\t')) break; +previousCharacterWasQuote = (ch == chOpeningQuote); +} +if (this.ich == this.cch) { +if (previousCharacterWasQuote) return this.str.substring (ichStart + 1, this.ich - 1); +return this.str.substring (ichStart, this.ich); +}++this.ich; +return this.str.substring (ichStart + 1, this.ich - 2); +}, $fz.isPrivate = true, $fz)); +c$.htFields = c$.prototype.htFields = new java.util.Hashtable (); +Clazz.defineStatics (c$, +"grABC", "ABX\u0394E\u03a6\u0393HI_K\u039bMNO\u03a0\u0398P\u03a3TY_\u03a9\u039e\u03a5Z", +"grabc", "\u03b1\u03b2\u03c7\u03a4\u03a5\u03c6\u03b3\u03b7\u03b9_\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03b8\u03c1\u03c3\u03c4\u03c5_\u03c9\u03be\u03c5\u03b6"); +}); diff --git a/bin/javajs/util/CompoundDocDirEntry.js b/bin/javajs/util/CompoundDocDirEntry.js index 5c3ab43..d792190 100644 --- a/bin/javajs/util/CompoundDocDirEntry.js +++ b/bin/javajs/util/CompoundDocDirEntry.js @@ -1,58 +1,58 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.cd = null; -this.unicodeName64 = null; -this.nBytesUnicodeName = 0; -this.entryType = 0; -this.uniqueID16 = null; -this.userflags4 = null; -this.SIDfirstSector = 0; -this.lenStream = 0; -this.unused = null; -this.entryName = null; -this.isStandard = false; -this.isEmpty = false; -Clazz.instantialize (this, arguments); -}, javajs.util, "CompoundDocDirEntry"); -Clazz.prepareFields (c$, function () { -this.unicodeName64 = Clazz.newByteArray (64, 0); -this.uniqueID16 = Clazz.newByteArray (16, 0); -this.userflags4 = Clazz.newByteArray (4, 0); -this.unused = Clazz.newByteArray (8, 0); -}); -Clazz.makeConstructor (c$, -function (compoundDocument) { -this.cd = compoundDocument; -}, "javajs.util.CompoundDocument"); -Clazz.defineMethod (c$, "readData", -function () { -try { -this.cd.readByteArray (this.unicodeName64, 0, 64); -this.nBytesUnicodeName = this.cd.readShort (); -this.entryType = this.cd.readByte (); -this.cd.readByte (); -this.cd.readInt (); -this.cd.readInt (); -this.cd.readInt (); -this.cd.readByteArray (this.uniqueID16, 0, 16); -this.cd.readByteArray (this.userflags4, 0, 4); -this.cd.readByteArray (this.unused, 0, 8); -this.cd.readByteArray (this.unused, 0, 8); -this.SIDfirstSector = this.cd.readInt (); -this.lenStream = this.cd.readInt (); -this.cd.readByteArray (this.unused, 0, 4); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -return false; -} else { -throw e; -} -} -this.entryName = ""; -for (var i = 0; i < this.nBytesUnicodeName - 2; i += 2) this.entryName += String.fromCharCode (this.unicodeName64[i]); - -this.isStandard = (this.entryType == 5 || this.lenStream >= this.cd.header.minBytesStandardStream); -this.isEmpty = (this.entryType == 0 || this.lenStream <= 0); -return true; -}); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.cd = null; +this.unicodeName64 = null; +this.nBytesUnicodeName = 0; +this.entryType = 0; +this.uniqueID16 = null; +this.userflags4 = null; +this.SIDfirstSector = 0; +this.lenStream = 0; +this.unused = null; +this.entryName = null; +this.isStandard = false; +this.isEmpty = false; +Clazz.instantialize (this, arguments); +}, javajs.util, "CompoundDocDirEntry"); +Clazz.prepareFields (c$, function () { +this.unicodeName64 = Clazz.newByteArray (64, 0); +this.uniqueID16 = Clazz.newByteArray (16, 0); +this.userflags4 = Clazz.newByteArray (4, 0); +this.unused = Clazz.newByteArray (8, 0); +}); +Clazz.makeConstructor (c$, +function (compoundDocument) { +this.cd = compoundDocument; +}, "javajs.util.CompoundDocument"); +Clazz.defineMethod (c$, "readData", +function () { +try { +this.cd.readByteArray (this.unicodeName64, 0, 64); +this.nBytesUnicodeName = this.cd.readShort (); +this.entryType = this.cd.readByte (); +this.cd.readByte (); +this.cd.readInt (); +this.cd.readInt (); +this.cd.readInt (); +this.cd.readByteArray (this.uniqueID16, 0, 16); +this.cd.readByteArray (this.userflags4, 0, 4); +this.cd.readByteArray (this.unused, 0, 8); +this.cd.readByteArray (this.unused, 0, 8); +this.SIDfirstSector = this.cd.readInt (); +this.lenStream = this.cd.readInt (); +this.cd.readByteArray (this.unused, 0, 4); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +return false; +} else { +throw e; +} +} +this.entryName = ""; +for (var i = 0; i < this.nBytesUnicodeName - 2; i += 2) this.entryName += String.fromCharCode (this.unicodeName64[i]); + +this.isStandard = (this.entryType == 5 || this.lenStream >= this.cd.header.minBytesStandardStream); +this.isEmpty = (this.entryType == 0 || this.lenStream <= 0); +return true; +}); diff --git a/bin/javajs/util/CompoundDocHeader.js b/bin/javajs/util/CompoundDocHeader.js index 30d7fd1..14d9c45 100644 --- a/bin/javajs/util/CompoundDocHeader.js +++ b/bin/javajs/util/CompoundDocHeader.js @@ -1,66 +1,66 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.cd = null; -this.magicNumbers = null; -this.uniqueID16 = null; -this.revNumber = 0; -this.verNumber = 0; -this.sectorPower = 0; -this.shortSectorPower = 0; -this.unused = null; -this.nSATsectors = 0; -this.SID_DIR_start = 0; -this.minBytesStandardStream = 0; -this.SID_SSAT_start = 0; -this.nSSATsectors = 0; -this.SID_MSAT_next = 0; -this.nAdditionalMATsectors = 0; -this.MSAT0 = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "CompoundDocHeader"); -Clazz.prepareFields (c$, function () { -this.magicNumbers = Clazz.newByteArray (8, 0); -this.uniqueID16 = Clazz.newByteArray (16, 0); -this.unused = Clazz.newByteArray (10, 0); -this.MSAT0 = Clazz.newIntArray (109, 0); -}); -Clazz.makeConstructor (c$, -function (compoundDocument) { -this.cd = compoundDocument; -}, "javajs.util.CompoundDocument"); -Clazz.defineMethod (c$, "readData", -function () { -try { -this.cd.readByteArray (this.magicNumbers, 0, 8); -if (this.magicNumbers[0] != 0xD0 || this.magicNumbers[1] != 0xCF || this.magicNumbers[2] != 0x11 || this.magicNumbers[3] != 0xE0 || this.magicNumbers[4] != 0xA1 || this.magicNumbers[5] != 0xB1 || this.magicNumbers[6] != 0x1A || this.magicNumbers[7] != 0xE1) return false; -this.cd.readByteArray (this.uniqueID16, 0, 16); -this.revNumber = this.cd.readByte (); -this.cd.readByte (); -this.verNumber = this.cd.readByte (); -this.cd.readByte (); -var b1 = this.cd.readByte (); -var b2 = this.cd.readByte (); -this.cd.isBigEndian = (b1 == -1 && b2 == -2); -this.sectorPower = this.cd.readShort (); -this.shortSectorPower = this.cd.readShort (); -this.cd.readByteArray (this.unused, 0, 10); -this.nSATsectors = this.cd.readInt (); -this.SID_DIR_start = this.cd.readInt (); -this.cd.readByteArray (this.unused, 0, 4); -this.minBytesStandardStream = this.cd.readInt (); -this.SID_SSAT_start = this.cd.readInt (); -this.nSSATsectors = this.cd.readInt (); -this.SID_MSAT_next = this.cd.readInt (); -this.nAdditionalMATsectors = this.cd.readInt (); -for (var i = 0; i < 109; i++) this.MSAT0[i] = this.cd.readInt (); - -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -return false; -} else { -throw e; -} -} -return true; -}); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.cd = null; +this.magicNumbers = null; +this.uniqueID16 = null; +this.revNumber = 0; +this.verNumber = 0; +this.sectorPower = 0; +this.shortSectorPower = 0; +this.unused = null; +this.nSATsectors = 0; +this.SID_DIR_start = 0; +this.minBytesStandardStream = 0; +this.SID_SSAT_start = 0; +this.nSSATsectors = 0; +this.SID_MSAT_next = 0; +this.nAdditionalMATsectors = 0; +this.MSAT0 = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "CompoundDocHeader"); +Clazz.prepareFields (c$, function () { +this.magicNumbers = Clazz.newByteArray (8, 0); +this.uniqueID16 = Clazz.newByteArray (16, 0); +this.unused = Clazz.newByteArray (10, 0); +this.MSAT0 = Clazz.newIntArray (109, 0); +}); +Clazz.makeConstructor (c$, +function (compoundDocument) { +this.cd = compoundDocument; +}, "javajs.util.CompoundDocument"); +Clazz.defineMethod (c$, "readData", +function () { +try { +this.cd.readByteArray (this.magicNumbers, 0, 8); +if (this.magicNumbers[0] != 0xD0 || this.magicNumbers[1] != 0xCF || this.magicNumbers[2] != 0x11 || this.magicNumbers[3] != 0xE0 || this.magicNumbers[4] != 0xA1 || this.magicNumbers[5] != 0xB1 || this.magicNumbers[6] != 0x1A || this.magicNumbers[7] != 0xE1) return false; +this.cd.readByteArray (this.uniqueID16, 0, 16); +this.revNumber = this.cd.readByte (); +this.cd.readByte (); +this.verNumber = this.cd.readByte (); +this.cd.readByte (); +var b1 = this.cd.readByte (); +var b2 = this.cd.readByte (); +this.cd.isBigEndian = (b1 == -1 && b2 == -2); +this.sectorPower = this.cd.readShort (); +this.shortSectorPower = this.cd.readShort (); +this.cd.readByteArray (this.unused, 0, 10); +this.nSATsectors = this.cd.readInt (); +this.SID_DIR_start = this.cd.readInt (); +this.cd.readByteArray (this.unused, 0, 4); +this.minBytesStandardStream = this.cd.readInt (); +this.SID_SSAT_start = this.cd.readInt (); +this.nSSATsectors = this.cd.readInt (); +this.SID_MSAT_next = this.cd.readInt (); +this.nAdditionalMATsectors = this.cd.readInt (); +for (var i = 0; i < 109; i++) this.MSAT0[i] = this.cd.readInt (); + +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +return false; +} else { +throw e; +} +} +return true; +}); diff --git a/bin/javajs/util/CompoundDocument.js b/bin/javajs/util/CompoundDocument.js index a37c69e..7e480bc 100644 --- a/bin/javajs/util/CompoundDocument.js +++ b/bin/javajs/util/CompoundDocument.js @@ -1,286 +1,286 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.BinaryDocument", "$.CompoundDocHeader", "$.Lst"], "javajs.util.CompoundDocument", ["java.io.DataInputStream", "javajs.util.CompoundDocDirEntry", "$.SB", "$.ZipData"], function () { -c$ = Clazz.decorateAsClass (function () { -this.header = null; -this.directory = null; -this.rootEntry = null; -this.SAT = null; -this.SSAT = null; -this.sectorSize = 0; -this.shortSectorSize = 0; -this.nShortSectorsPerStandardSector = 0; -this.nIntPerSector = 0; -this.nDirEntriesperSector = 0; -this.data = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "CompoundDocument", javajs.util.BinaryDocument); -Clazz.prepareFields (c$, function () { -this.header = new javajs.util.CompoundDocHeader (this); -this.directory = new javajs.util.Lst (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.util.CompoundDocument); -this.isBigEndian = true; -}); -Clazz.overrideMethod (c$, "setStream", -function (jzt, bis, isBigEndian) { -this.jzt = jzt; -if (!this.isRandom) { -this.stream = new java.io.DataInputStream (bis); -}this.stream.mark (2147483647); -if (!this.readHeader ()) return; -this.getSectorAllocationTable (); -this.getShortSectorAllocationTable (); -this.getDirectoryTable (); -}, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B"); -Clazz.defineMethod (c$, "getDirectory", -function () { -return this.directory; -}); -Clazz.defineMethod (c$, "getDirectoryListing", -function (separator) { -var str = ""; -for (var i = 0; i < this.directory.size (); i++) { -var thisEntry = this.directory.get (i); -if (!thisEntry.isEmpty) str += separator + thisEntry.entryName + "\tlen=" + thisEntry.lenStream + "\tSID=" + thisEntry.SIDfirstSector + (thisEntry.isStandard ? "\tfileOffset=" + this.getOffset (thisEntry.SIDfirstSector) : ""); -} -return str; -}, "~S"); -Clazz.defineMethod (c$, "getAllData", -function () { -return this.getAllDataFiles (null, null); -}); -Clazz.overrideMethod (c$, "getAllDataMapped", -function (prefix, binaryFileList, fileData) { -fileData.put ("#Directory_Listing", this.getDirectoryListing ("|")); -binaryFileList = "|" + binaryFileList + "|"; -for (var i = 0; i < this.directory.size (); i++) { -var thisEntry = this.directory.get (i); -if (!thisEntry.isEmpty && thisEntry.entryType != 5) { -var name = thisEntry.entryName; -System.out.println ("CompoundDocument file " + name); -var isBinary = (binaryFileList.indexOf ("|" + name + "|") >= 0); -if (isBinary) name += ":asBinaryString"; -var data = new javajs.util.SB (); -data.append ("BEGIN Directory Entry ").append (name).append ("\n"); -data.appendSB (this.getEntryAsString (thisEntry, isBinary)); -data.append ("\nEND Directory Entry ").append (name).append ("\n"); -fileData.put (prefix + "/" + name, data.toString ()); -}} -this.close (); -}, "~S,~S,java.util.Map"); -Clazz.overrideMethod (c$, "getAllDataFiles", -function (binaryFileList, firstFile) { -if (firstFile != null) { -for (var i = 0; i < this.directory.size (); i++) { -var thisEntry = this.directory.get (i); -if (thisEntry.entryName.equals (firstFile)) { -this.directory.remove (i); -this.directory.add (1, thisEntry); -break; -}} -}this.data = new javajs.util.SB (); -this.data.append ("Compound Document File Directory: "); -this.data.append (this.getDirectoryListing ("|")); -this.data.append ("\n"); -binaryFileList = "|" + binaryFileList + "|"; -for (var i = 0; i < this.directory.size (); i++) { -var thisEntry = this.directory.get (i); -if (!thisEntry.isEmpty && thisEntry.entryType != 5) { -var name = thisEntry.entryName; -if (name.endsWith (".gz")) name = name.substring (0, name.length - 3); -this.data.append ("BEGIN Directory Entry ").append (name).append ("\n"); -this.data.appendSB (this.getEntryAsString (thisEntry, binaryFileList.indexOf ("|" + thisEntry.entryName + "|") >= 0)); -this.data.append ("\n"); -this.data.append ("END Directory Entry ").append (thisEntry.entryName).append ("\n"); -}} -this.close (); -return this.data; -}, "~S,~S"); -Clazz.defineMethod (c$, "getFileAsString", -function (entryName) { -for (var i = 0; i < this.directory.size (); i++) { -var thisEntry = this.directory.get (i); -if (thisEntry.entryName.equals (entryName)) return this.getEntryAsString (thisEntry, false); -} -return new javajs.util.SB (); -}, "~S"); -Clazz.defineMethod (c$, "getOffset", -($fz = function (SID) { -return (SID + 1) * this.sectorSize; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "gotoSector", -($fz = function (SID) { -this.seek (this.getOffset (SID)); -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "readHeader", -($fz = function () { -if (!this.header.readData ()) return false; -this.sectorSize = 1 << this.header.sectorPower; -this.shortSectorSize = 1 << this.header.shortSectorPower; -this.nShortSectorsPerStandardSector = Clazz.doubleToInt (this.sectorSize / this.shortSectorSize); -this.nIntPerSector = Clazz.doubleToInt (this.sectorSize / 4); -this.nDirEntriesperSector = Clazz.doubleToInt (this.sectorSize / 128); -return true; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getSectorAllocationTable", -($fz = function () { -var nSID = 0; -var thisSID; -this.SAT = Clazz.newIntArray (this.header.nSATsectors * this.nIntPerSector + 109, 0); -try { -for (var i = 0; i < 109; i++) { -thisSID = this.header.MSAT0[i]; -if (thisSID < 0) break; -this.gotoSector (thisSID); -for (var j = 0; j < this.nIntPerSector; j++) { -this.SAT[nSID++] = this.readInt (); -} -} -var nMaster = this.header.nAdditionalMATsectors; -thisSID = this.header.SID_MSAT_next; -var MSAT = Clazz.newIntArray (this.nIntPerSector, 0); -out : while (nMaster-- > 0 && thisSID >= 0) { -this.gotoSector (thisSID); -for (var i = 0; i < this.nIntPerSector; i++) MSAT[i] = this.readInt (); - -for (var i = 0; i < this.nIntPerSector - 1; i++) { -thisSID = MSAT[i]; -if (thisSID < 0) break out; -this.gotoSector (thisSID); -for (var j = this.nIntPerSector; --j >= 0; ) this.SAT[nSID++] = this.readInt (); - -} -thisSID = MSAT[this.nIntPerSector - 1]; -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getShortSectorAllocationTable", -($fz = function () { -var nSSID = 0; -var thisSID = this.header.SID_SSAT_start; -var nMax = this.header.nSSATsectors * this.nIntPerSector; -this.SSAT = Clazz.newIntArray (nMax, 0); -try { -while (thisSID > 0 && nSSID < nMax) { -this.gotoSector (thisSID); -for (var j = 0; j < this.nIntPerSector; j++) { -this.SSAT[nSSID++] = this.readInt (); -} -thisSID = this.SAT[thisSID]; -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getDirectoryTable", -($fz = function () { -var thisSID = this.header.SID_DIR_start; -var thisEntry; -this.rootEntry = null; -try { -while (thisSID > 0) { -this.gotoSector (thisSID); -for (var j = this.nDirEntriesperSector; --j >= 0; ) { -thisEntry = new javajs.util.CompoundDocDirEntry (this); -thisEntry.readData (); -if (thisEntry.lenStream > 0) { -this.directory.addLast (thisEntry); -}if (thisEntry.entryType == 5) this.rootEntry = thisEntry; -} -thisSID = this.SAT[thisSID]; -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getEntryAsString", -($fz = function (thisEntry, asBinaryString) { -if (thisEntry.isEmpty) return new javajs.util.SB (); -return (thisEntry.isStandard ? this.getStandardStringData (thisEntry.SIDfirstSector, thisEntry.lenStream, asBinaryString) : this.getShortStringData (thisEntry.SIDfirstSector, thisEntry.lenStream, asBinaryString)); -}, $fz.isPrivate = true, $fz), "javajs.util.CompoundDocDirEntry,~B"); -Clazz.defineMethod (c$, "getStandardStringData", -($fz = function (thisSID, nBytes, asBinaryString) { -var data = new javajs.util.SB (); -var byteBuf = Clazz.newByteArray (this.sectorSize, 0); -var gzipData = new javajs.util.ZipData (nBytes); -try { -while (thisSID > 0 && nBytes > 0) { -this.gotoSector (thisSID); -nBytes = this.getSectorData (data, byteBuf, this.sectorSize, nBytes, asBinaryString, gzipData); -thisSID = this.SAT[thisSID]; -} -if (nBytes == -9999) return new javajs.util.SB (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -if (gzipData.isEnabled) gzipData.addTo (this.jzt, data); -return data; -}, $fz.isPrivate = true, $fz), "~N,~N,~B"); -Clazz.defineMethod (c$, "getSectorData", -($fz = function (data, byteBuf, nSectorBytes, nBytes, asBinaryString, gzipData) { -this.readByteArray (byteBuf, 0, byteBuf.length); -var n = gzipData.addBytes (byteBuf, nSectorBytes, nBytes); -if (n >= 0) return n; -if (asBinaryString) { -for (var i = 0; i < nSectorBytes; i++) { -data.append (Integer.toHexString (byteBuf[i] & 0xFF)).appendC (' '); -if (--nBytes < 1) break; -} -} else { -for (var i = 0; i < nSectorBytes; i++) { -if (byteBuf[i] == 0) return -9999; -data.appendC (String.fromCharCode (byteBuf[i])); -if (--nBytes < 1) break; -} -}return nBytes; -}, $fz.isPrivate = true, $fz), "javajs.util.SB,~A,~N,~N,~B,javajs.util.ZipData"); -Clazz.defineMethod (c$, "getShortStringData", -($fz = function (shortSID, nBytes, asBinaryString) { -var data = new javajs.util.SB (); -if (this.rootEntry == null) return data; -var thisSID = this.rootEntry.SIDfirstSector; -var ptShort = 0; -var byteBuf = Clazz.newByteArray (this.shortSectorSize, 0); -var gzipData = new javajs.util.ZipData (nBytes); -try { -while (thisSID >= 0 && shortSID >= 0 && nBytes > 0) { -while (shortSID - ptShort >= this.nShortSectorsPerStandardSector) { -ptShort += this.nShortSectorsPerStandardSector; -thisSID = this.SAT[thisSID]; -} -this.seek (this.getOffset (thisSID) + (shortSID - ptShort) * this.shortSectorSize); -nBytes = this.getSectorData (data, byteBuf, this.shortSectorSize, nBytes, asBinaryString, gzipData); -shortSID = this.SSAT[shortSID]; -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (data.toString ()); -System.out.println ("reader error in CompoundDocument " + e.toString ()); -} else { -throw e; -} -} -if (gzipData.isEnabled) gzipData.addTo (this.jzt, data); -return data; -}, $fz.isPrivate = true, $fz), "~N,~N,~B"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.BinaryDocument", "$.CompoundDocHeader", "$.Lst"], "javajs.util.CompoundDocument", ["java.io.DataInputStream", "javajs.util.CompoundDocDirEntry", "$.SB", "$.ZipData"], function () { +c$ = Clazz.decorateAsClass (function () { +this.header = null; +this.directory = null; +this.rootEntry = null; +this.SAT = null; +this.SSAT = null; +this.sectorSize = 0; +this.shortSectorSize = 0; +this.nShortSectorsPerStandardSector = 0; +this.nIntPerSector = 0; +this.nDirEntriesperSector = 0; +this.data = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "CompoundDocument", javajs.util.BinaryDocument); +Clazz.prepareFields (c$, function () { +this.header = new javajs.util.CompoundDocHeader (this); +this.directory = new javajs.util.Lst (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.util.CompoundDocument); +this.isBigEndian = true; +}); +Clazz.overrideMethod (c$, "setStream", +function (jzt, bis, isBigEndian) { +this.jzt = jzt; +if (!this.isRandom) { +this.stream = new java.io.DataInputStream (bis); +}this.stream.mark (2147483647); +if (!this.readHeader ()) return; +this.getSectorAllocationTable (); +this.getShortSectorAllocationTable (); +this.getDirectoryTable (); +}, "javajs.api.GenericZipTools,java.io.BufferedInputStream,~B"); +Clazz.defineMethod (c$, "getDirectory", +function () { +return this.directory; +}); +Clazz.defineMethod (c$, "getDirectoryListing", +function (separator) { +var str = ""; +for (var i = 0; i < this.directory.size (); i++) { +var thisEntry = this.directory.get (i); +if (!thisEntry.isEmpty) str += separator + thisEntry.entryName + "\tlen=" + thisEntry.lenStream + "\tSID=" + thisEntry.SIDfirstSector + (thisEntry.isStandard ? "\tfileOffset=" + this.getOffset (thisEntry.SIDfirstSector) : ""); +} +return str; +}, "~S"); +Clazz.defineMethod (c$, "getAllData", +function () { +return this.getAllDataFiles (null, null); +}); +Clazz.overrideMethod (c$, "getAllDataMapped", +function (prefix, binaryFileList, fileData) { +fileData.put ("#Directory_Listing", this.getDirectoryListing ("|")); +binaryFileList = "|" + binaryFileList + "|"; +for (var i = 0; i < this.directory.size (); i++) { +var thisEntry = this.directory.get (i); +if (!thisEntry.isEmpty && thisEntry.entryType != 5) { +var name = thisEntry.entryName; +System.out.println ("CompoundDocument file " + name); +var isBinary = (binaryFileList.indexOf ("|" + name + "|") >= 0); +if (isBinary) name += ":asBinaryString"; +var data = new javajs.util.SB (); +data.append ("BEGIN Directory Entry ").append (name).append ("\n"); +data.appendSB (this.getEntryAsString (thisEntry, isBinary)); +data.append ("\nEND Directory Entry ").append (name).append ("\n"); +fileData.put (prefix + "/" + name, data.toString ()); +}} +this.close (); +}, "~S,~S,java.util.Map"); +Clazz.overrideMethod (c$, "getAllDataFiles", +function (binaryFileList, firstFile) { +if (firstFile != null) { +for (var i = 0; i < this.directory.size (); i++) { +var thisEntry = this.directory.get (i); +if (thisEntry.entryName.equals (firstFile)) { +this.directory.remove (i); +this.directory.add (1, thisEntry); +break; +}} +}this.data = new javajs.util.SB (); +this.data.append ("Compound Document File Directory: "); +this.data.append (this.getDirectoryListing ("|")); +this.data.append ("\n"); +binaryFileList = "|" + binaryFileList + "|"; +for (var i = 0; i < this.directory.size (); i++) { +var thisEntry = this.directory.get (i); +if (!thisEntry.isEmpty && thisEntry.entryType != 5) { +var name = thisEntry.entryName; +if (name.endsWith (".gz")) name = name.substring (0, name.length - 3); +this.data.append ("BEGIN Directory Entry ").append (name).append ("\n"); +this.data.appendSB (this.getEntryAsString (thisEntry, binaryFileList.indexOf ("|" + thisEntry.entryName + "|") >= 0)); +this.data.append ("\n"); +this.data.append ("END Directory Entry ").append (thisEntry.entryName).append ("\n"); +}} +this.close (); +return this.data; +}, "~S,~S"); +Clazz.defineMethod (c$, "getFileAsString", +function (entryName) { +for (var i = 0; i < this.directory.size (); i++) { +var thisEntry = this.directory.get (i); +if (thisEntry.entryName.equals (entryName)) return this.getEntryAsString (thisEntry, false); +} +return new javajs.util.SB (); +}, "~S"); +Clazz.defineMethod (c$, "getOffset", +($fz = function (SID) { +return (SID + 1) * this.sectorSize; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "gotoSector", +($fz = function (SID) { +this.seek (this.getOffset (SID)); +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "readHeader", +($fz = function () { +if (!this.header.readData ()) return false; +this.sectorSize = 1 << this.header.sectorPower; +this.shortSectorSize = 1 << this.header.shortSectorPower; +this.nShortSectorsPerStandardSector = Clazz.doubleToInt (this.sectorSize / this.shortSectorSize); +this.nIntPerSector = Clazz.doubleToInt (this.sectorSize / 4); +this.nDirEntriesperSector = Clazz.doubleToInt (this.sectorSize / 128); +return true; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getSectorAllocationTable", +($fz = function () { +var nSID = 0; +var thisSID; +this.SAT = Clazz.newIntArray (this.header.nSATsectors * this.nIntPerSector + 109, 0); +try { +for (var i = 0; i < 109; i++) { +thisSID = this.header.MSAT0[i]; +if (thisSID < 0) break; +this.gotoSector (thisSID); +for (var j = 0; j < this.nIntPerSector; j++) { +this.SAT[nSID++] = this.readInt (); +} +} +var nMaster = this.header.nAdditionalMATsectors; +thisSID = this.header.SID_MSAT_next; +var MSAT = Clazz.newIntArray (this.nIntPerSector, 0); +out : while (nMaster-- > 0 && thisSID >= 0) { +this.gotoSector (thisSID); +for (var i = 0; i < this.nIntPerSector; i++) MSAT[i] = this.readInt (); + +for (var i = 0; i < this.nIntPerSector - 1; i++) { +thisSID = MSAT[i]; +if (thisSID < 0) break out; +this.gotoSector (thisSID); +for (var j = this.nIntPerSector; --j >= 0; ) this.SAT[nSID++] = this.readInt (); + +} +thisSID = MSAT[this.nIntPerSector - 1]; +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getShortSectorAllocationTable", +($fz = function () { +var nSSID = 0; +var thisSID = this.header.SID_SSAT_start; +var nMax = this.header.nSSATsectors * this.nIntPerSector; +this.SSAT = Clazz.newIntArray (nMax, 0); +try { +while (thisSID > 0 && nSSID < nMax) { +this.gotoSector (thisSID); +for (var j = 0; j < this.nIntPerSector; j++) { +this.SSAT[nSSID++] = this.readInt (); +} +thisSID = this.SAT[thisSID]; +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getDirectoryTable", +($fz = function () { +var thisSID = this.header.SID_DIR_start; +var thisEntry; +this.rootEntry = null; +try { +while (thisSID > 0) { +this.gotoSector (thisSID); +for (var j = this.nDirEntriesperSector; --j >= 0; ) { +thisEntry = new javajs.util.CompoundDocDirEntry (this); +thisEntry.readData (); +if (thisEntry.lenStream > 0) { +this.directory.addLast (thisEntry); +}if (thisEntry.entryType == 5) this.rootEntry = thisEntry; +} +thisSID = this.SAT[thisSID]; +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getEntryAsString", +($fz = function (thisEntry, asBinaryString) { +if (thisEntry.isEmpty) return new javajs.util.SB (); +return (thisEntry.isStandard ? this.getStandardStringData (thisEntry.SIDfirstSector, thisEntry.lenStream, asBinaryString) : this.getShortStringData (thisEntry.SIDfirstSector, thisEntry.lenStream, asBinaryString)); +}, $fz.isPrivate = true, $fz), "javajs.util.CompoundDocDirEntry,~B"); +Clazz.defineMethod (c$, "getStandardStringData", +($fz = function (thisSID, nBytes, asBinaryString) { +var data = new javajs.util.SB (); +var byteBuf = Clazz.newByteArray (this.sectorSize, 0); +var gzipData = new javajs.util.ZipData (nBytes); +try { +while (thisSID > 0 && nBytes > 0) { +this.gotoSector (thisSID); +nBytes = this.getSectorData (data, byteBuf, this.sectorSize, nBytes, asBinaryString, gzipData); +thisSID = this.SAT[thisSID]; +} +if (nBytes == -9999) return new javajs.util.SB (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +if (gzipData.isEnabled) gzipData.addTo (this.jzt, data); +return data; +}, $fz.isPrivate = true, $fz), "~N,~N,~B"); +Clazz.defineMethod (c$, "getSectorData", +($fz = function (data, byteBuf, nSectorBytes, nBytes, asBinaryString, gzipData) { +this.readByteArray (byteBuf, 0, byteBuf.length); +var n = gzipData.addBytes (byteBuf, nSectorBytes, nBytes); +if (n >= 0) return n; +if (asBinaryString) { +for (var i = 0; i < nSectorBytes; i++) { +data.append (Integer.toHexString (byteBuf[i] & 0xFF)).appendC (' '); +if (--nBytes < 1) break; +} +} else { +for (var i = 0; i < nSectorBytes; i++) { +if (byteBuf[i] == 0) return -9999; +data.appendC (String.fromCharCode (byteBuf[i])); +if (--nBytes < 1) break; +} +}return nBytes; +}, $fz.isPrivate = true, $fz), "javajs.util.SB,~A,~N,~N,~B,javajs.util.ZipData"); +Clazz.defineMethod (c$, "getShortStringData", +($fz = function (shortSID, nBytes, asBinaryString) { +var data = new javajs.util.SB (); +if (this.rootEntry == null) return data; +var thisSID = this.rootEntry.SIDfirstSector; +var ptShort = 0; +var byteBuf = Clazz.newByteArray (this.shortSectorSize, 0); +var gzipData = new javajs.util.ZipData (nBytes); +try { +while (thisSID >= 0 && shortSID >= 0 && nBytes > 0) { +while (shortSID - ptShort >= this.nShortSectorsPerStandardSector) { +ptShort += this.nShortSectorsPerStandardSector; +thisSID = this.SAT[thisSID]; +} +this.seek (this.getOffset (thisSID) + (shortSID - ptShort) * this.shortSectorSize); +nBytes = this.getSectorData (data, byteBuf, this.shortSectorSize, nBytes, asBinaryString, gzipData); +shortSID = this.SSAT[shortSID]; +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (data.toString ()); +System.out.println ("reader error in CompoundDocument " + e.toString ()); +} else { +throw e; +} +} +if (gzipData.isEnabled) gzipData.addTo (this.jzt, data); +return data; +}, $fz.isPrivate = true, $fz), "~N,~N,~B"); +}); diff --git a/bin/javajs/util/DF.js b/bin/javajs/util/DF.js index 6122352..9247146 100644 --- a/bin/javajs/util/DF.js +++ b/bin/javajs/util/DF.js @@ -1,78 +1,78 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.lang.Boolean"], "javajs.util.DF", ["java.lang.Double", "$.Float", "javajs.util.PT", "$.SB"], function () { -c$ = Clazz.declareType (javajs.util, "DF"); -c$.setUseNumberLocalization = Clazz.defineMethod (c$, "setUseNumberLocalization", -function (TF) { -javajs.util.DF.useNumberLocalization[0] = (TF ? Boolean.TRUE : Boolean.FALSE); -}, "~B"); -c$.formatDecimalDbl = Clazz.defineMethod (c$, "formatDecimalDbl", -function (value, decimalDigits) { -if (decimalDigits == 2147483647 || value == -Infinity || value == Infinity || Double.isNaN (value)) return "" + value; -return javajs.util.DF.formatDecimal (value, decimalDigits); -}, "~N,~N"); -c$.formatDecimal = Clazz.defineMethod (c$, "formatDecimal", -function (value, decimalDigits) { -if (decimalDigits == 2147483647 || value == -Infinity || value == Infinity || Float.isNaN (value)) return "" + value; -var n; -if (decimalDigits < 0) { -decimalDigits = -decimalDigits; -if (decimalDigits > javajs.util.DF.formattingStrings.length) decimalDigits = javajs.util.DF.formattingStrings.length; -if (value == 0) return javajs.util.DF.formattingStrings[decimalDigits] + "E+0"; -n = 0; -var d; -if (Math.abs (value) < 1) { -n = 10; -d = value * 1e-10; -} else { -n = -10; -d = value * 1e10; -}var s = ("" + d).toUpperCase (); -var i = s.indexOf ("E"); -n = javajs.util.PT.parseInt (s.substring (i + 1)) + n; -return (i < 0 ? "" + value : javajs.util.DF.formatDecimal (javajs.util.PT.parseFloat (s.substring (0, i)), decimalDigits - 1) + "E" + (n >= 0 ? "+" : "") + n); -}if (decimalDigits >= javajs.util.DF.formattingStrings.length) decimalDigits = javajs.util.DF.formattingStrings.length - 1; -var s1 = ("" + value).toUpperCase (); -var pt = s1.indexOf ("."); -if (pt < 0) return s1 + javajs.util.DF.formattingStrings[decimalDigits].substring (1); -var isNeg = s1.startsWith ("-"); -if (isNeg) { -s1 = s1.substring (1); -pt--; -}var pt1 = s1.indexOf ("E-"); -if (pt1 > 0) { -n = javajs.util.PT.parseInt (s1.substring (pt1 + 1)); -s1 = "0." + "0000000000000000000000000000000000000000".substring (0, -n - 1) + s1.substring (0, 1) + s1.substring (2, pt1); -pt = 1; -}pt1 = s1.indexOf ("E"); -if (pt1 > 0) { -n = javajs.util.PT.parseInt (s1.substring (pt1 + 1)); -s1 = s1.substring (0, 1) + s1.substring (2, pt1) + "0000000000000000000000000000000000000000"; -s1 = s1.substring (0, n + 1) + "." + s1.substring (n + 1); -pt = s1.indexOf ("."); -}var len = s1.length; -var pt2 = decimalDigits + pt + 1; -if (pt2 < len && s1.charAt (pt2) >= '5') { -return javajs.util.DF.formatDecimal (value + (isNeg ? -1 : 1) * javajs.util.DF.formatAdds[decimalDigits], decimalDigits); -}var sb = javajs.util.SB.newS (s1.substring (0, (decimalDigits == 0 ? pt : ++pt))); -for (var i = 0; i < decimalDigits; i++, pt++) { -if (pt < len) sb.appendC (s1.charAt (pt)); - else sb.appendC ('0'); -} -s1 = (isNeg ? "-" : "") + sb; -return (Boolean.TRUE.equals (javajs.util.DF.useNumberLocalization[0]) ? s1 : s1.$replace (',', '.')); -}, "~N,~N"); -c$.formatDecimalTrimmed = Clazz.defineMethod (c$, "formatDecimalTrimmed", -function (x, precision) { -var str = javajs.util.DF.formatDecimalDbl (x, precision); -var m = str.length - 1; -var zero = '0'; -while (m >= 0 && str.charAt (m) == zero) m--; - -return str.substring (0, m + 1); -}, "~N,~N"); -Clazz.defineStatics (c$, -"formattingStrings", Clazz.newArray (-1, ["0", "0.0", "0.00", "0.000", "0.0000", "0.00000", "0.000000", "0.0000000", "0.00000000", "0.000000000"]), -"zeros", "0000000000000000000000000000000000000000", -"formatAdds", Clazz.newFloatArray (-1, [0.5, 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005, 0.000000005, 0.0000000005])); -c$.useNumberLocalization = c$.prototype.useNumberLocalization = Clazz.newArray (-1, [Boolean.TRUE]); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.lang.Boolean"], "javajs.util.DF", ["java.lang.Double", "$.Float", "javajs.util.PT", "$.SB"], function () { +c$ = Clazz.declareType (javajs.util, "DF"); +c$.setUseNumberLocalization = Clazz.defineMethod (c$, "setUseNumberLocalization", +function (TF) { +javajs.util.DF.useNumberLocalization[0] = (TF ? Boolean.TRUE : Boolean.FALSE); +}, "~B"); +c$.formatDecimalDbl = Clazz.defineMethod (c$, "formatDecimalDbl", +function (value, decimalDigits) { +if (decimalDigits == 2147483647 || value == -Infinity || value == Infinity || Double.isNaN (value)) return "" + value; +return javajs.util.DF.formatDecimal (value, decimalDigits); +}, "~N,~N"); +c$.formatDecimal = Clazz.defineMethod (c$, "formatDecimal", +function (value, decimalDigits) { +if (decimalDigits == 2147483647 || value == -Infinity || value == Infinity || Float.isNaN (value)) return "" + value; +var n; +if (decimalDigits < 0) { +decimalDigits = -decimalDigits; +if (decimalDigits > javajs.util.DF.formattingStrings.length) decimalDigits = javajs.util.DF.formattingStrings.length; +if (value == 0) return javajs.util.DF.formattingStrings[decimalDigits] + "E+0"; +n = 0; +var d; +if (Math.abs (value) < 1) { +n = 10; +d = value * 1e-10; +} else { +n = -10; +d = value * 1e10; +}var s = ("" + d).toUpperCase (); +var i = s.indexOf ("E"); +n = javajs.util.PT.parseInt (s.substring (i + 1)) + n; +return (i < 0 ? "" + value : javajs.util.DF.formatDecimal (javajs.util.PT.parseFloat (s.substring (0, i)), decimalDigits - 1) + "E" + (n >= 0 ? "+" : "") + n); +}if (decimalDigits >= javajs.util.DF.formattingStrings.length) decimalDigits = javajs.util.DF.formattingStrings.length - 1; +var s1 = ("" + value).toUpperCase (); +var pt = s1.indexOf ("."); +if (pt < 0) return s1 + javajs.util.DF.formattingStrings[decimalDigits].substring (1); +var isNeg = s1.startsWith ("-"); +if (isNeg) { +s1 = s1.substring (1); +pt--; +}var pt1 = s1.indexOf ("E-"); +if (pt1 > 0) { +n = javajs.util.PT.parseInt (s1.substring (pt1 + 1)); +s1 = "0." + "0000000000000000000000000000000000000000".substring (0, -n - 1) + s1.substring (0, 1) + s1.substring (2, pt1); +pt = 1; +}pt1 = s1.indexOf ("E"); +if (pt1 > 0) { +n = javajs.util.PT.parseInt (s1.substring (pt1 + 1)); +s1 = s1.substring (0, 1) + s1.substring (2, pt1) + "0000000000000000000000000000000000000000"; +s1 = s1.substring (0, n + 1) + "." + s1.substring (n + 1); +pt = s1.indexOf ("."); +}var len = s1.length; +var pt2 = decimalDigits + pt + 1; +if (pt2 < len && s1.charAt (pt2) >= '5') { +return javajs.util.DF.formatDecimal (value + (isNeg ? -1 : 1) * javajs.util.DF.formatAdds[decimalDigits], decimalDigits); +}var sb = javajs.util.SB.newS (s1.substring (0, (decimalDigits == 0 ? pt : ++pt))); +for (var i = 0; i < decimalDigits; i++, pt++) { +if (pt < len) sb.appendC (s1.charAt (pt)); + else sb.appendC ('0'); +} +s1 = (isNeg ? "-" : "") + sb; +return (Boolean.TRUE.equals (javajs.util.DF.useNumberLocalization[0]) ? s1 : s1.$replace (',', '.')); +}, "~N,~N"); +c$.formatDecimalTrimmed = Clazz.defineMethod (c$, "formatDecimalTrimmed", +function (x, precision) { +var str = javajs.util.DF.formatDecimalDbl (x, precision); +var m = str.length - 1; +var zero = '0'; +while (m >= 0 && str.charAt (m) == zero) m--; + +return str.substring (0, m + 1); +}, "~N,~N"); +Clazz.defineStatics (c$, +"formattingStrings", Clazz.newArray (-1, ["0", "0.0", "0.00", "0.000", "0.0000", "0.00000", "0.000000", "0.0000000", "0.00000000", "0.000000000"]), +"zeros", "0000000000000000000000000000000000000000", +"formatAdds", Clazz.newFloatArray (-1, [0.5, 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005, 0.000000005, 0.0000000005])); +c$.useNumberLocalization = c$.prototype.useNumberLocalization = Clazz.newArray (-1, [Boolean.TRUE]); +}); diff --git a/bin/javajs/util/DataReader.js b/bin/javajs/util/DataReader.js index ea8774f..3be547c 100644 --- a/bin/javajs/util/DataReader.js +++ b/bin/javajs/util/DataReader.js @@ -1,34 +1,34 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.io.BufferedReader"], "javajs.util.DataReader", ["java.io.StringReader"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ptMark = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "DataReader", java.io.BufferedReader); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.util.DataReader, [ new java.io.StringReader ("")]); -}); -Clazz.defineMethod (c$, "getBufferedReader", -function () { -return this; -}); -Clazz.defineMethod (c$, "readBuf", -function (buf, off, len) { -var nRead = 0; -var line = this.readLine (); -if (line == null) return 0; -var linept = 0; -var linelen = line.length; -for (var i = off; i < len && linelen >= 0; i++) { -if (linept >= linelen) { -linept = 0; -buf[i] = '\n'; -line = this.readLine (); -linelen = (line == null ? -1 : line.length); -} else { -buf[i] = line.charAt (linept++); -}nRead++; -} -return nRead; -}, "~A,~N,~N"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.io.BufferedReader"], "javajs.util.DataReader", ["java.io.StringReader"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ptMark = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "DataReader", java.io.BufferedReader); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.util.DataReader, [ new java.io.StringReader ("")]); +}); +Clazz.defineMethod (c$, "getBufferedReader", +function () { +return this; +}); +Clazz.defineMethod (c$, "readBuf", +function (buf, off, len) { +var nRead = 0; +var line = this.readLine (); +if (line == null) return 0; +var linept = 0; +var linelen = line.length; +for (var i = off; i < len && linelen >= 0; i++) { +if (linept >= linelen) { +linept = 0; +buf[i] = '\n'; +line = this.readLine (); +linelen = (line == null ? -1 : line.length); +} else { +buf[i] = line.charAt (linept++); +}nRead++; +} +return nRead; +}, "~A,~N,~N"); +}); diff --git a/bin/javajs/util/Eigen.js b/bin/javajs/util/Eigen.js index 4d28a61..b08955b 100644 --- a/bin/javajs/util/Eigen.js +++ b/bin/javajs/util/Eigen.js @@ -1,254 +1,254 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.EigenInterface"], "javajs.util.Eigen", ["javajs.util.V3"], function () { -c$ = Clazz.decorateAsClass (function () { -this.n = 3; -this.d = null; -this.e = null; -this.V = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "Eigen", null, javajs.api.EigenInterface); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "set", -function (n) { -this.n = n; -this.V = Clazz.newDoubleArray (n, n, 0); -this.d = Clazz.newDoubleArray (n, 0); -this.e = Clazz.newDoubleArray (n, 0); -return this; -}, "~N"); -Clazz.overrideMethod (c$, "setM", -function (m) { -this.set (m.length); -this.calc (m); -return this; -}, "~A"); -Clazz.overrideMethod (c$, "getEigenvalues", -function () { -return this.d; -}); -Clazz.overrideMethod (c$, "fillFloatArrays", -function (eigenVectors, eigenValues) { -for (var i = 0; i < 3; i++) { -if (eigenVectors != null) { -if (eigenVectors[i] == null) eigenVectors[i] = new javajs.util.V3 (); -eigenVectors[i].set (this.V[0][i], this.V[1][i], this.V[2][i]); -}if (eigenValues != null) eigenValues[i] = this.d[i]; -} -}, "~A,~A"); -Clazz.overrideMethod (c$, "getEigenvectorsFloatTransposed", -function () { -var f = Clazz.newFloatArray (this.n, this.n, 0); -for (var i = this.n; --i >= 0; ) for (var j = this.n; --j >= 0; ) f[j][i] = this.V[i][j]; - - -return f; -}); -Clazz.defineMethod (c$, "calc", -function (A) { -for (var i = 0; i < this.n; i++) { -for (var j = 0; j < this.n; j++) { -this.V[i][j] = A[i][j]; -} -} -this.tred2 (); -this.tql2 (); -}, "~A"); -Clazz.defineMethod (c$, "getRealEigenvalues", -function () { -return this.d; -}); -Clazz.defineMethod (c$, "getImagEigenvalues", -function () { -return this.e; -}); -Clazz.defineMethod (c$, "tred2", -($fz = function () { -for (var j = 0; j < this.n; j++) { -this.d[j] = this.V[this.n - 1][j]; -} -for (var i = this.n - 1; i > 0; i--) { -var scale = 0.0; -var h = 0.0; -for (var k = 0; k < i; k++) { -scale = scale + Math.abs (this.d[k]); -} -if (scale == 0.0) { -this.e[i] = this.d[i - 1]; -for (var j = 0; j < i; j++) { -this.d[j] = this.V[i - 1][j]; -this.V[i][j] = 0.0; -this.V[j][i] = 0.0; -} -} else { -for (var k = 0; k < i; k++) { -this.d[k] /= scale; -h += this.d[k] * this.d[k]; -} -var f = this.d[i - 1]; -var g = Math.sqrt (h); -if (f > 0) { -g = -g; -}this.e[i] = scale * g; -h = h - f * g; -this.d[i - 1] = f - g; -for (var j = 0; j < i; j++) { -this.e[j] = 0.0; -} -for (var j = 0; j < i; j++) { -f = this.d[j]; -this.V[j][i] = f; -g = this.e[j] + this.V[j][j] * f; -for (var k = j + 1; k <= i - 1; k++) { -g += this.V[k][j] * this.d[k]; -this.e[k] += this.V[k][j] * f; -} -this.e[j] = g; -} -f = 0.0; -for (var j = 0; j < i; j++) { -this.e[j] /= h; -f += this.e[j] * this.d[j]; -} -var hh = f / (h + h); -for (var j = 0; j < i; j++) { -this.e[j] -= hh * this.d[j]; -} -for (var j = 0; j < i; j++) { -f = this.d[j]; -g = this.e[j]; -for (var k = j; k <= i - 1; k++) { -this.V[k][j] -= (f * this.e[k] + g * this.d[k]); -} -this.d[j] = this.V[i - 1][j]; -this.V[i][j] = 0.0; -} -}this.d[i] = h; -} -for (var i = 0; i < this.n - 1; i++) { -this.V[this.n - 1][i] = this.V[i][i]; -this.V[i][i] = 1.0; -var h = this.d[i + 1]; -if (h != 0.0) { -for (var k = 0; k <= i; k++) { -this.d[k] = this.V[k][i + 1] / h; -} -for (var j = 0; j <= i; j++) { -var g = 0.0; -for (var k = 0; k <= i; k++) { -g += this.V[k][i + 1] * this.V[k][j]; -} -for (var k = 0; k <= i; k++) { -this.V[k][j] -= g * this.d[k]; -} -} -}for (var k = 0; k <= i; k++) { -this.V[k][i + 1] = 0.0; -} -} -for (var j = 0; j < this.n; j++) { -this.d[j] = this.V[this.n - 1][j]; -this.V[this.n - 1][j] = 0.0; -} -this.V[this.n - 1][this.n - 1] = 1.0; -this.e[0] = 0.0; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "tql2", -($fz = function () { -for (var i = 1; i < this.n; i++) { -this.e[i - 1] = this.e[i]; -} -this.e[this.n - 1] = 0.0; -var f = 0.0; -var tst1 = 0.0; -var eps = Math.pow (2.0, -52.0); -for (var l = 0; l < this.n; l++) { -tst1 = Math.max (tst1, Math.abs (this.d[l]) + Math.abs (this.e[l])); -var m = l; -while (m < this.n) { -if (Math.abs (this.e[m]) <= eps * tst1) { -break; -}m++; -} -if (m > l) { -var iter = 0; -do { -iter = iter + 1; -var g = this.d[l]; -var p = (this.d[l + 1] - g) / (2.0 * this.e[l]); -var r = javajs.util.Eigen.hypot (p, 1.0); -if (p < 0) { -r = -r; -}this.d[l] = this.e[l] / (p + r); -this.d[l + 1] = this.e[l] * (p + r); -var dl1 = this.d[l + 1]; -var h = g - this.d[l]; -for (var i = l + 2; i < this.n; i++) { -this.d[i] -= h; -} -f = f + h; -p = this.d[m]; -var c = 1.0; -var c2 = c; -var c3 = c; -var el1 = this.e[l + 1]; -var s = 0.0; -var s2 = 0.0; -for (var i = m - 1; i >= l; i--) { -c3 = c2; -c2 = c; -s2 = s; -g = c * this.e[i]; -h = c * p; -r = javajs.util.Eigen.hypot (p, this.e[i]); -this.e[i + 1] = s * r; -s = this.e[i] / r; -c = p / r; -p = c * this.d[i] - s * g; -this.d[i + 1] = h + s * (c * g + s * this.d[i]); -for (var k = 0; k < this.n; k++) { -h = this.V[k][i + 1]; -this.V[k][i + 1] = s * this.V[k][i] + c * h; -this.V[k][i] = c * this.V[k][i] - s * h; -} -} -p = -s * s2 * c3 * el1 * this.e[l] / dl1; -this.e[l] = s * p; -this.d[l] = c * p; -} while (Math.abs (this.e[l]) > eps * tst1); -}this.d[l] = this.d[l] + f; -this.e[l] = 0.0; -} -for (var i = 0; i < this.n - 1; i++) { -var k = i; -var p = this.d[i]; -for (var j = i + 1; j < this.n; j++) { -if (this.d[j] < p) { -k = j; -p = this.d[j]; -}} -if (k != i) { -this.d[k] = this.d[i]; -this.d[i] = p; -for (var j = 0; j < this.n; j++) { -p = this.V[j][i]; -this.V[j][i] = this.V[j][k]; -this.V[j][k] = p; -} -}} -}, $fz.isPrivate = true, $fz)); -c$.hypot = Clazz.defineMethod (c$, "hypot", -($fz = function (a, b) { -var r; -if (Math.abs (a) > Math.abs (b)) { -r = b / a; -r = Math.abs (a) * Math.sqrt (1 + r * r); -} else if (b != 0) { -r = a / b; -r = Math.abs (b) * Math.sqrt (1 + r * r); -} else { -r = 0.0; -}return r; -}, $fz.isPrivate = true, $fz), "~N,~N"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.EigenInterface"], "javajs.util.Eigen", ["javajs.util.V3"], function () { +c$ = Clazz.decorateAsClass (function () { +this.n = 3; +this.d = null; +this.e = null; +this.V = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "Eigen", null, javajs.api.EigenInterface); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "set", +function (n) { +this.n = n; +this.V = Clazz.newDoubleArray (n, n, 0); +this.d = Clazz.newDoubleArray (n, 0); +this.e = Clazz.newDoubleArray (n, 0); +return this; +}, "~N"); +Clazz.overrideMethod (c$, "setM", +function (m) { +this.set (m.length); +this.calc (m); +return this; +}, "~A"); +Clazz.overrideMethod (c$, "getEigenvalues", +function () { +return this.d; +}); +Clazz.overrideMethod (c$, "fillFloatArrays", +function (eigenVectors, eigenValues) { +for (var i = 0; i < 3; i++) { +if (eigenVectors != null) { +if (eigenVectors[i] == null) eigenVectors[i] = new javajs.util.V3 (); +eigenVectors[i].set (this.V[0][i], this.V[1][i], this.V[2][i]); +}if (eigenValues != null) eigenValues[i] = this.d[i]; +} +}, "~A,~A"); +Clazz.overrideMethod (c$, "getEigenvectorsFloatTransposed", +function () { +var f = Clazz.newFloatArray (this.n, this.n, 0); +for (var i = this.n; --i >= 0; ) for (var j = this.n; --j >= 0; ) f[j][i] = this.V[i][j]; + + +return f; +}); +Clazz.defineMethod (c$, "calc", +function (A) { +for (var i = 0; i < this.n; i++) { +for (var j = 0; j < this.n; j++) { +this.V[i][j] = A[i][j]; +} +} +this.tred2 (); +this.tql2 (); +}, "~A"); +Clazz.defineMethod (c$, "getRealEigenvalues", +function () { +return this.d; +}); +Clazz.defineMethod (c$, "getImagEigenvalues", +function () { +return this.e; +}); +Clazz.defineMethod (c$, "tred2", +($fz = function () { +for (var j = 0; j < this.n; j++) { +this.d[j] = this.V[this.n - 1][j]; +} +for (var i = this.n - 1; i > 0; i--) { +var scale = 0.0; +var h = 0.0; +for (var k = 0; k < i; k++) { +scale = scale + Math.abs (this.d[k]); +} +if (scale == 0.0) { +this.e[i] = this.d[i - 1]; +for (var j = 0; j < i; j++) { +this.d[j] = this.V[i - 1][j]; +this.V[i][j] = 0.0; +this.V[j][i] = 0.0; +} +} else { +for (var k = 0; k < i; k++) { +this.d[k] /= scale; +h += this.d[k] * this.d[k]; +} +var f = this.d[i - 1]; +var g = Math.sqrt (h); +if (f > 0) { +g = -g; +}this.e[i] = scale * g; +h = h - f * g; +this.d[i - 1] = f - g; +for (var j = 0; j < i; j++) { +this.e[j] = 0.0; +} +for (var j = 0; j < i; j++) { +f = this.d[j]; +this.V[j][i] = f; +g = this.e[j] + this.V[j][j] * f; +for (var k = j + 1; k <= i - 1; k++) { +g += this.V[k][j] * this.d[k]; +this.e[k] += this.V[k][j] * f; +} +this.e[j] = g; +} +f = 0.0; +for (var j = 0; j < i; j++) { +this.e[j] /= h; +f += this.e[j] * this.d[j]; +} +var hh = f / (h + h); +for (var j = 0; j < i; j++) { +this.e[j] -= hh * this.d[j]; +} +for (var j = 0; j < i; j++) { +f = this.d[j]; +g = this.e[j]; +for (var k = j; k <= i - 1; k++) { +this.V[k][j] -= (f * this.e[k] + g * this.d[k]); +} +this.d[j] = this.V[i - 1][j]; +this.V[i][j] = 0.0; +} +}this.d[i] = h; +} +for (var i = 0; i < this.n - 1; i++) { +this.V[this.n - 1][i] = this.V[i][i]; +this.V[i][i] = 1.0; +var h = this.d[i + 1]; +if (h != 0.0) { +for (var k = 0; k <= i; k++) { +this.d[k] = this.V[k][i + 1] / h; +} +for (var j = 0; j <= i; j++) { +var g = 0.0; +for (var k = 0; k <= i; k++) { +g += this.V[k][i + 1] * this.V[k][j]; +} +for (var k = 0; k <= i; k++) { +this.V[k][j] -= g * this.d[k]; +} +} +}for (var k = 0; k <= i; k++) { +this.V[k][i + 1] = 0.0; +} +} +for (var j = 0; j < this.n; j++) { +this.d[j] = this.V[this.n - 1][j]; +this.V[this.n - 1][j] = 0.0; +} +this.V[this.n - 1][this.n - 1] = 1.0; +this.e[0] = 0.0; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "tql2", +($fz = function () { +for (var i = 1; i < this.n; i++) { +this.e[i - 1] = this.e[i]; +} +this.e[this.n - 1] = 0.0; +var f = 0.0; +var tst1 = 0.0; +var eps = Math.pow (2.0, -52.0); +for (var l = 0; l < this.n; l++) { +tst1 = Math.max (tst1, Math.abs (this.d[l]) + Math.abs (this.e[l])); +var m = l; +while (m < this.n) { +if (Math.abs (this.e[m]) <= eps * tst1) { +break; +}m++; +} +if (m > l) { +var iter = 0; +do { +iter = iter + 1; +var g = this.d[l]; +var p = (this.d[l + 1] - g) / (2.0 * this.e[l]); +var r = javajs.util.Eigen.hypot (p, 1.0); +if (p < 0) { +r = -r; +}this.d[l] = this.e[l] / (p + r); +this.d[l + 1] = this.e[l] * (p + r); +var dl1 = this.d[l + 1]; +var h = g - this.d[l]; +for (var i = l + 2; i < this.n; i++) { +this.d[i] -= h; +} +f = f + h; +p = this.d[m]; +var c = 1.0; +var c2 = c; +var c3 = c; +var el1 = this.e[l + 1]; +var s = 0.0; +var s2 = 0.0; +for (var i = m - 1; i >= l; i--) { +c3 = c2; +c2 = c; +s2 = s; +g = c * this.e[i]; +h = c * p; +r = javajs.util.Eigen.hypot (p, this.e[i]); +this.e[i + 1] = s * r; +s = this.e[i] / r; +c = p / r; +p = c * this.d[i] - s * g; +this.d[i + 1] = h + s * (c * g + s * this.d[i]); +for (var k = 0; k < this.n; k++) { +h = this.V[k][i + 1]; +this.V[k][i + 1] = s * this.V[k][i] + c * h; +this.V[k][i] = c * this.V[k][i] - s * h; +} +} +p = -s * s2 * c3 * el1 * this.e[l] / dl1; +this.e[l] = s * p; +this.d[l] = c * p; +} while (Math.abs (this.e[l]) > eps * tst1); +}this.d[l] = this.d[l] + f; +this.e[l] = 0.0; +} +for (var i = 0; i < this.n - 1; i++) { +var k = i; +var p = this.d[i]; +for (var j = i + 1; j < this.n; j++) { +if (this.d[j] < p) { +k = j; +p = this.d[j]; +}} +if (k != i) { +this.d[k] = this.d[i]; +this.d[i] = p; +for (var j = 0; j < this.n; j++) { +p = this.V[j][i]; +this.V[j][i] = this.V[j][k]; +this.V[j][k] = p; +} +}} +}, $fz.isPrivate = true, $fz)); +c$.hypot = Clazz.defineMethod (c$, "hypot", +($fz = function (a, b) { +var r; +if (Math.abs (a) > Math.abs (b)) { +r = b / a; +r = Math.abs (a) * Math.sqrt (1 + r * r); +} else if (b != 0) { +r = a / b; +r = Math.abs (b) * Math.sqrt (1 + r * r); +} else { +r = 0.0; +}return r; +}, $fz.isPrivate = true, $fz), "~N,~N"); +}); diff --git a/bin/javajs/util/Encoding.js b/bin/javajs/util/Encoding.js index d7abfc0..aecf019 100644 --- a/bin/javajs/util/Encoding.js +++ b/bin/javajs/util/Encoding.js @@ -1,10 +1,10 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.lang.Enum"], "javajs.util.Encoding", null, function () { -c$ = Clazz.declareType (javajs.util, "Encoding", Enum); -Clazz.defineEnumConstant (c$, "NONE", 0, []); -Clazz.defineEnumConstant (c$, "UTF8", 1, []); -Clazz.defineEnumConstant (c$, "UTF_16BE", 2, []); -Clazz.defineEnumConstant (c$, "UTF_16LE", 3, []); -Clazz.defineEnumConstant (c$, "UTF_32BE", 4, []); -Clazz.defineEnumConstant (c$, "UTF_32LE", 5, []); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.lang.Enum"], "javajs.util.Encoding", null, function () { +c$ = Clazz.declareType (javajs.util, "Encoding", Enum); +Clazz.defineEnumConstant (c$, "NONE", 0, []); +Clazz.defineEnumConstant (c$, "UTF8", 1, []); +Clazz.defineEnumConstant (c$, "UTF_16BE", 2, []); +Clazz.defineEnumConstant (c$, "UTF_16LE", 3, []); +Clazz.defineEnumConstant (c$, "UTF_32BE", 4, []); +Clazz.defineEnumConstant (c$, "UTF_32LE", 5, []); +}); diff --git a/bin/javajs/util/LimitedLineReader.js b/bin/javajs/util/LimitedLineReader.js index 95d0741..c8c7764 100644 --- a/bin/javajs/util/LimitedLineReader.js +++ b/bin/javajs/util/LimitedLineReader.js @@ -1,33 +1,33 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.buf = null; -this.cchBuf = 0; -this.ichCurrent = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "LimitedLineReader"); -Clazz.makeConstructor (c$, -function (bufferedReader, readLimit) { -bufferedReader.mark (readLimit + 1); -this.buf = Clazz.newCharArray (readLimit, '\0'); -this.cchBuf = Math.max (bufferedReader.read (this.buf, 0, readLimit), 0); -this.ichCurrent = 0; -bufferedReader.reset (); -}, "java.io.BufferedReader,~N"); -Clazz.defineMethod (c$, "getHeader", -function (n) { -return (n == 0 ? String.instantialize (this.buf) : String.instantialize (this.buf, 0, Math.min (this.cchBuf, n))); -}, "~N"); -Clazz.defineMethod (c$, "readLineWithNewline", -function () { -while (this.ichCurrent < this.cchBuf) { -var ichBeginningOfLine = this.ichCurrent; -var ch = String.fromCharCode (0); -while (this.ichCurrent < this.cchBuf && (ch = this.buf[this.ichCurrent++]) != '\r' && ch != '\n') { -} -if (ch == '\r' && this.ichCurrent < this.cchBuf && this.buf[this.ichCurrent] == '\n') ++this.ichCurrent; -var cchLine = this.ichCurrent - ichBeginningOfLine; -if (this.buf[ichBeginningOfLine] == '#') continue; -return String.instantialize (this.buf, ichBeginningOfLine, cchLine); -} -return ""; -}); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.buf = null; +this.cchBuf = 0; +this.ichCurrent = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "LimitedLineReader"); +Clazz.makeConstructor (c$, +function (bufferedReader, readLimit) { +bufferedReader.mark (readLimit + 1); +this.buf = Clazz.newCharArray (readLimit, '\0'); +this.cchBuf = Math.max (bufferedReader.read (this.buf, 0, readLimit), 0); +this.ichCurrent = 0; +bufferedReader.reset (); +}, "java.io.BufferedReader,~N"); +Clazz.defineMethod (c$, "getHeader", +function (n) { +return (n == 0 ? String.instantialize (this.buf) : String.instantialize (this.buf, 0, Math.min (this.cchBuf, n))); +}, "~N"); +Clazz.defineMethod (c$, "readLineWithNewline", +function () { +while (this.ichCurrent < this.cchBuf) { +var ichBeginningOfLine = this.ichCurrent; +var ch = String.fromCharCode (0); +while (this.ichCurrent < this.cchBuf && (ch = this.buf[this.ichCurrent++]) != '\r' && ch != '\n') { +} +if (ch == '\r' && this.ichCurrent < this.cchBuf && this.buf[this.ichCurrent] == '\n') ++this.ichCurrent; +var cchLine = this.ichCurrent - ichBeginningOfLine; +if (this.buf[ichBeginningOfLine] == '#') continue; +return String.instantialize (this.buf, ichBeginningOfLine, cchLine); +} +return ""; +}); diff --git a/bin/javajs/util/ListDataReader.js b/bin/javajs/util/ListDataReader.js index dbd859d..54d8d69 100644 --- a/bin/javajs/util/ListDataReader.js +++ b/bin/javajs/util/ListDataReader.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.DataReader"], "javajs.util.ListDataReader", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.data = null; -this.pt = 0; -this.len = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "ListDataReader", javajs.util.DataReader); -Clazz.overrideMethod (c$, "setData", -function (data) { -this.data = data; -this.len = this.data.size (); -return this; -}, "~O"); -Clazz.defineMethod (c$, "read", -function (buf, off, len) { -return this.readBuf (buf, off, len); -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "readLine", -function () { -return (this.pt < this.len ? this.data.get (this.pt++) : null); -}); -Clazz.defineMethod (c$, "mark", -function (ptr) { -this.ptMark = this.pt; -}, "~N"); -Clazz.overrideMethod (c$, "reset", -function () { -this.pt = this.ptMark; -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.DataReader"], "javajs.util.ListDataReader", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.data = null; +this.pt = 0; +this.len = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "ListDataReader", javajs.util.DataReader); +Clazz.overrideMethod (c$, "setData", +function (data) { +this.data = data; +this.len = this.data.size (); +return this; +}, "~O"); +Clazz.defineMethod (c$, "read", +function (buf, off, len) { +return this.readBuf (buf, off, len); +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "readLine", +function () { +return (this.pt < this.len ? this.data.get (this.pt++) : null); +}); +Clazz.defineMethod (c$, "mark", +function (ptr) { +this.ptMark = this.pt; +}, "~N"); +Clazz.overrideMethod (c$, "reset", +function () { +this.pt = this.ptMark; +}); +}); diff --git a/bin/javajs/util/Lst.js b/bin/javajs/util/Lst.js index f809b5a..414e59d 100644 --- a/bin/javajs/util/Lst.js +++ b/bin/javajs/util/Lst.js @@ -1,14 +1,14 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.util.ArrayList"], "javajs.util.Lst", null, function () { -c$ = Clazz.declareType (javajs.util, "Lst", java.util.ArrayList); -Clazz.defineMethod (c$, "addLast", -function (v) { -{ -return this.add1(v); -}}, "~O"); -Clazz.defineMethod (c$, "removeObj", -function (v) { -{ -return this.removeObject(v); -}}, "~O"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.util.ArrayList"], "javajs.util.Lst", null, function () { +c$ = Clazz.declareType (javajs.util, "Lst", java.util.ArrayList); +Clazz.defineMethod (c$, "addLast", +function (v) { +{ +return this.add1(v); +}}, "~O"); +Clazz.defineMethod (c$, "removeObj", +function (v) { +{ +return this.removeObject(v); +}}, "~O"); +}); diff --git a/bin/javajs/util/M3.js b/bin/javajs/util/M3.js index 8461118..a395f3f 100644 --- a/bin/javajs/util/M3.js +++ b/bin/javajs/util/M3.js @@ -1,298 +1,298 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.M34"], "javajs.util.M3", ["javajs.util.T3"], function () { -c$ = Clazz.declareType (javajs.util, "M3", javajs.util.M34, java.io.Serializable); -c$.newA9 = Clazz.defineMethod (c$, "newA9", -function (v) { -var m = new javajs.util.M3 (); -m.setA (v); -return m; -}, "~A"); -c$.newM3 = Clazz.defineMethod (c$, "newM3", -function (m1) { -var m = new javajs.util.M3 (); -if (m1 == null) { -m.setScale (1); -return m; -}m.m00 = m1.m00; -m.m01 = m1.m01; -m.m02 = m1.m02; -m.m10 = m1.m10; -m.m11 = m1.m11; -m.m12 = m1.m12; -m.m20 = m1.m20; -m.m21 = m1.m21; -m.m22 = m1.m22; -return m; -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "setScale", -function (scale) { -this.clear33 (); -this.m00 = this.m11 = this.m22 = scale; -}, "~N"); -Clazz.defineMethod (c$, "setM3", -function (m1) { -this.setM33 (m1); -}, "javajs.util.M34"); -Clazz.defineMethod (c$, "setA", -function (m) { -this.m00 = m[0]; -this.m01 = m[1]; -this.m02 = m[2]; -this.m10 = m[3]; -this.m11 = m[4]; -this.m12 = m[5]; -this.m20 = m[6]; -this.m21 = m[7]; -this.m22 = m[8]; -}, "~A"); -Clazz.defineMethod (c$, "setElement", -function (row, col, v) { -this.set33 (row, col, v); -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "getElement", -function (row, col) { -return this.get33 (row, col); -}, "~N,~N"); -Clazz.defineMethod (c$, "setRow", -function (row, x, y, z) { -switch (row) { -case 0: -this.m00 = x; -this.m01 = y; -this.m02 = z; -return; -case 1: -this.m10 = x; -this.m11 = y; -this.m12 = z; -return; -case 2: -this.m20 = x; -this.m21 = y; -this.m22 = z; -return; -default: -this.err (); -} -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "setRowV", -function (row, v) { -switch (row) { -case 0: -this.m00 = v.x; -this.m01 = v.y; -this.m02 = v.z; -return; -case 1: -this.m10 = v.x; -this.m11 = v.y; -this.m12 = v.z; -return; -case 2: -this.m20 = v.x; -this.m21 = v.y; -this.m22 = v.z; -return; -default: -this.err (); -} -}, "~N,javajs.util.T3"); -Clazz.defineMethod (c$, "setRowA", -function (row, v) { -this.setRow33 (row, v); -}, "~N,~A"); -Clazz.overrideMethod (c$, "getRow", -function (row, v) { -this.getRow33 (row, v); -}, "~N,~A"); -Clazz.defineMethod (c$, "setColumn3", -function (column, x, y, z) { -switch (column) { -case 0: -this.m00 = x; -this.m10 = y; -this.m20 = z; -break; -case 1: -this.m01 = x; -this.m11 = y; -this.m21 = z; -break; -case 2: -this.m02 = x; -this.m12 = y; -this.m22 = z; -break; -default: -this.err (); -} -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "setColumnV", -function (column, v) { -switch (column) { -case 0: -this.m00 = v.x; -this.m10 = v.y; -this.m20 = v.z; -break; -case 1: -this.m01 = v.x; -this.m11 = v.y; -this.m21 = v.z; -break; -case 2: -this.m02 = v.x; -this.m12 = v.y; -this.m22 = v.z; -break; -default: -this.err (); -} -}, "~N,javajs.util.T3"); -Clazz.defineMethod (c$, "getColumnV", -function (column, v) { -switch (column) { -case 0: -v.x = this.m00; -v.y = this.m10; -v.z = this.m20; -break; -case 1: -v.x = this.m01; -v.y = this.m11; -v.z = this.m21; -break; -case 2: -v.x = this.m02; -v.y = this.m12; -v.z = this.m22; -break; -default: -this.err (); -} -}, "~N,javajs.util.T3"); -Clazz.defineMethod (c$, "setColumnA", -function (column, v) { -this.setColumn33 (column, v); -}, "~N,~A"); -Clazz.defineMethod (c$, "getColumn", -function (column, v) { -this.getColumn33 (column, v); -}, "~N,~A"); -Clazz.defineMethod (c$, "add", -function (m1) { -this.add33 (m1); -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "sub", -function (m1) { -this.sub33 (m1); -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "transpose", -function () { -this.transpose33 (); -}); -Clazz.defineMethod (c$, "transposeM", -function (m1) { -this.setM33 (m1); -this.transpose33 (); -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "invertM", -function (m1) { -this.setM33 (m1); -this.invert (); -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "invert", -function () { -var s = this.determinant3 (); -if (s == 0.0) return; -s = 1 / s; -this.set9 (this.m11 * this.m22 - this.m12 * this.m21, this.m02 * this.m21 - this.m01 * this.m22, this.m01 * this.m12 - this.m02 * this.m11, this.m12 * this.m20 - this.m10 * this.m22, this.m00 * this.m22 - this.m02 * this.m20, this.m02 * this.m10 - this.m00 * this.m12, this.m10 * this.m21 - this.m11 * this.m20, this.m01 * this.m20 - this.m00 * this.m21, this.m00 * this.m11 - this.m01 * this.m10); -this.scale (s); -}); -Clazz.defineMethod (c$, "setAsXRotation", -function (angle) { -this.setXRot (angle); -return this; -}, "~N"); -Clazz.defineMethod (c$, "setAsYRotation", -function (angle) { -this.setYRot (angle); -return this; -}, "~N"); -Clazz.defineMethod (c$, "setAsZRotation", -function (angle) { -this.setZRot (angle); -return this; -}, "~N"); -Clazz.defineMethod (c$, "scale", -function (scalar) { -this.mul33 (scalar); -}, "~N"); -Clazz.defineMethod (c$, "mul", -function (m1) { -this.mul2 (this, m1); -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "mul2", -function (m1, m2) { -this.set9 (m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20, m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21, m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22, m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20, m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21, m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22, m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20, m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21, m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22); -}, "javajs.util.M3,javajs.util.M3"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (!(Clazz.instanceOf (o, javajs.util.M3))) return false; -var m = o; -return this.m00 == m.m00 && this.m01 == m.m01 && this.m02 == m.m02 && this.m10 == m.m10 && this.m11 == m.m11 && this.m12 == m.m12 && this.m20 == m.m20 && this.m21 == m.m21 && this.m22 == m.m22; -}, "~O"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return javajs.util.T3.floatToIntBits0 (this.m00) ^ javajs.util.T3.floatToIntBits0 (this.m01) ^ javajs.util.T3.floatToIntBits0 (this.m02) ^ javajs.util.T3.floatToIntBits0 (this.m10) ^ javajs.util.T3.floatToIntBits0 (this.m11) ^ javajs.util.T3.floatToIntBits0 (this.m12) ^ javajs.util.T3.floatToIntBits0 (this.m20) ^ javajs.util.T3.floatToIntBits0 (this.m21) ^ javajs.util.T3.floatToIntBits0 (this.m22); -}); -Clazz.defineMethod (c$, "setZero", -function () { -this.clear33 (); -}); -Clazz.defineMethod (c$, "set9", -($fz = function (m00, m01, m02, m10, m11, m12, m20, m21, m22) { -this.m00 = m00; -this.m01 = m01; -this.m02 = m02; -this.m10 = m10; -this.m11 = m11; -this.m12 = m12; -this.m20 = m20; -this.m21 = m21; -this.m22 = m22; -}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N"); -Clazz.overrideMethod (c$, "toString", -function () { -return "[\n [" + this.m00 + "\t" + this.m01 + "\t" + this.m02 + "]" + "\n [" + this.m10 + "\t" + this.m11 + "\t" + this.m12 + "]" + "\n [" + this.m20 + "\t" + this.m21 + "\t" + this.m22 + "] ]"; -}); -Clazz.defineMethod (c$, "setAA", -function (a) { -this.setAA33 (a); -return this; -}, "javajs.util.A4"); -Clazz.defineMethod (c$, "setAsBallRotation", -function (responseFactor, dx, dy) { -var r = Math.sqrt (dx * dx + dy * dy); -var th = r * responseFactor; -if (th == 0) { -this.setScale (1); -return false; -}var c = Math.cos (th); -var s = Math.sin (th); -var nx = -dy / r; -var ny = dx / r; -var c1 = c - 1; -this.m00 = 1 + c1 * nx * nx; -this.m01 = this.m10 = c1 * nx * ny; -this.m20 = -(this.m02 = s * nx); -this.m11 = 1 + c1 * ny * ny; -this.m21 = -(this.m12 = s * ny); -this.m22 = c; -return true; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "isRotation", -function () { -return (Math.abs (this.determinant3 () - 1) < 0.001); -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.M34"], "javajs.util.M3", ["javajs.util.T3"], function () { +c$ = Clazz.declareType (javajs.util, "M3", javajs.util.M34, java.io.Serializable); +c$.newA9 = Clazz.defineMethod (c$, "newA9", +function (v) { +var m = new javajs.util.M3 (); +m.setA (v); +return m; +}, "~A"); +c$.newM3 = Clazz.defineMethod (c$, "newM3", +function (m1) { +var m = new javajs.util.M3 (); +if (m1 == null) { +m.setScale (1); +return m; +}m.m00 = m1.m00; +m.m01 = m1.m01; +m.m02 = m1.m02; +m.m10 = m1.m10; +m.m11 = m1.m11; +m.m12 = m1.m12; +m.m20 = m1.m20; +m.m21 = m1.m21; +m.m22 = m1.m22; +return m; +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "setScale", +function (scale) { +this.clear33 (); +this.m00 = this.m11 = this.m22 = scale; +}, "~N"); +Clazz.defineMethod (c$, "setM3", +function (m1) { +this.setM33 (m1); +}, "javajs.util.M34"); +Clazz.defineMethod (c$, "setA", +function (m) { +this.m00 = m[0]; +this.m01 = m[1]; +this.m02 = m[2]; +this.m10 = m[3]; +this.m11 = m[4]; +this.m12 = m[5]; +this.m20 = m[6]; +this.m21 = m[7]; +this.m22 = m[8]; +}, "~A"); +Clazz.defineMethod (c$, "setElement", +function (row, col, v) { +this.set33 (row, col, v); +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "getElement", +function (row, col) { +return this.get33 (row, col); +}, "~N,~N"); +Clazz.defineMethod (c$, "setRow", +function (row, x, y, z) { +switch (row) { +case 0: +this.m00 = x; +this.m01 = y; +this.m02 = z; +return; +case 1: +this.m10 = x; +this.m11 = y; +this.m12 = z; +return; +case 2: +this.m20 = x; +this.m21 = y; +this.m22 = z; +return; +default: +this.err (); +} +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "setRowV", +function (row, v) { +switch (row) { +case 0: +this.m00 = v.x; +this.m01 = v.y; +this.m02 = v.z; +return; +case 1: +this.m10 = v.x; +this.m11 = v.y; +this.m12 = v.z; +return; +case 2: +this.m20 = v.x; +this.m21 = v.y; +this.m22 = v.z; +return; +default: +this.err (); +} +}, "~N,javajs.util.T3"); +Clazz.defineMethod (c$, "setRowA", +function (row, v) { +this.setRow33 (row, v); +}, "~N,~A"); +Clazz.overrideMethod (c$, "getRow", +function (row, v) { +this.getRow33 (row, v); +}, "~N,~A"); +Clazz.defineMethod (c$, "setColumn3", +function (column, x, y, z) { +switch (column) { +case 0: +this.m00 = x; +this.m10 = y; +this.m20 = z; +break; +case 1: +this.m01 = x; +this.m11 = y; +this.m21 = z; +break; +case 2: +this.m02 = x; +this.m12 = y; +this.m22 = z; +break; +default: +this.err (); +} +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "setColumnV", +function (column, v) { +switch (column) { +case 0: +this.m00 = v.x; +this.m10 = v.y; +this.m20 = v.z; +break; +case 1: +this.m01 = v.x; +this.m11 = v.y; +this.m21 = v.z; +break; +case 2: +this.m02 = v.x; +this.m12 = v.y; +this.m22 = v.z; +break; +default: +this.err (); +} +}, "~N,javajs.util.T3"); +Clazz.defineMethod (c$, "getColumnV", +function (column, v) { +switch (column) { +case 0: +v.x = this.m00; +v.y = this.m10; +v.z = this.m20; +break; +case 1: +v.x = this.m01; +v.y = this.m11; +v.z = this.m21; +break; +case 2: +v.x = this.m02; +v.y = this.m12; +v.z = this.m22; +break; +default: +this.err (); +} +}, "~N,javajs.util.T3"); +Clazz.defineMethod (c$, "setColumnA", +function (column, v) { +this.setColumn33 (column, v); +}, "~N,~A"); +Clazz.defineMethod (c$, "getColumn", +function (column, v) { +this.getColumn33 (column, v); +}, "~N,~A"); +Clazz.defineMethod (c$, "add", +function (m1) { +this.add33 (m1); +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "sub", +function (m1) { +this.sub33 (m1); +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "transpose", +function () { +this.transpose33 (); +}); +Clazz.defineMethod (c$, "transposeM", +function (m1) { +this.setM33 (m1); +this.transpose33 (); +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "invertM", +function (m1) { +this.setM33 (m1); +this.invert (); +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "invert", +function () { +var s = this.determinant3 (); +if (s == 0.0) return; +s = 1 / s; +this.set9 (this.m11 * this.m22 - this.m12 * this.m21, this.m02 * this.m21 - this.m01 * this.m22, this.m01 * this.m12 - this.m02 * this.m11, this.m12 * this.m20 - this.m10 * this.m22, this.m00 * this.m22 - this.m02 * this.m20, this.m02 * this.m10 - this.m00 * this.m12, this.m10 * this.m21 - this.m11 * this.m20, this.m01 * this.m20 - this.m00 * this.m21, this.m00 * this.m11 - this.m01 * this.m10); +this.scale (s); +}); +Clazz.defineMethod (c$, "setAsXRotation", +function (angle) { +this.setXRot (angle); +return this; +}, "~N"); +Clazz.defineMethod (c$, "setAsYRotation", +function (angle) { +this.setYRot (angle); +return this; +}, "~N"); +Clazz.defineMethod (c$, "setAsZRotation", +function (angle) { +this.setZRot (angle); +return this; +}, "~N"); +Clazz.defineMethod (c$, "scale", +function (scalar) { +this.mul33 (scalar); +}, "~N"); +Clazz.defineMethod (c$, "mul", +function (m1) { +this.mul2 (this, m1); +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "mul2", +function (m1, m2) { +this.set9 (m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20, m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21, m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22, m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20, m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21, m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22, m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20, m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21, m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22); +}, "javajs.util.M3,javajs.util.M3"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (!(Clazz.instanceOf (o, javajs.util.M3))) return false; +var m = o; +return this.m00 == m.m00 && this.m01 == m.m01 && this.m02 == m.m02 && this.m10 == m.m10 && this.m11 == m.m11 && this.m12 == m.m12 && this.m20 == m.m20 && this.m21 == m.m21 && this.m22 == m.m22; +}, "~O"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return javajs.util.T3.floatToIntBits0 (this.m00) ^ javajs.util.T3.floatToIntBits0 (this.m01) ^ javajs.util.T3.floatToIntBits0 (this.m02) ^ javajs.util.T3.floatToIntBits0 (this.m10) ^ javajs.util.T3.floatToIntBits0 (this.m11) ^ javajs.util.T3.floatToIntBits0 (this.m12) ^ javajs.util.T3.floatToIntBits0 (this.m20) ^ javajs.util.T3.floatToIntBits0 (this.m21) ^ javajs.util.T3.floatToIntBits0 (this.m22); +}); +Clazz.defineMethod (c$, "setZero", +function () { +this.clear33 (); +}); +Clazz.defineMethod (c$, "set9", +($fz = function (m00, m01, m02, m10, m11, m12, m20, m21, m22) { +this.m00 = m00; +this.m01 = m01; +this.m02 = m02; +this.m10 = m10; +this.m11 = m11; +this.m12 = m12; +this.m20 = m20; +this.m21 = m21; +this.m22 = m22; +}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N"); +Clazz.overrideMethod (c$, "toString", +function () { +return "[\n [" + this.m00 + "\t" + this.m01 + "\t" + this.m02 + "]" + "\n [" + this.m10 + "\t" + this.m11 + "\t" + this.m12 + "]" + "\n [" + this.m20 + "\t" + this.m21 + "\t" + this.m22 + "] ]"; +}); +Clazz.defineMethod (c$, "setAA", +function (a) { +this.setAA33 (a); +return this; +}, "javajs.util.A4"); +Clazz.defineMethod (c$, "setAsBallRotation", +function (responseFactor, dx, dy) { +var r = Math.sqrt (dx * dx + dy * dy); +var th = r * responseFactor; +if (th == 0) { +this.setScale (1); +return false; +}var c = Math.cos (th); +var s = Math.sin (th); +var nx = -dy / r; +var ny = dx / r; +var c1 = c - 1; +this.m00 = 1 + c1 * nx * nx; +this.m01 = this.m10 = c1 * nx * ny; +this.m20 = -(this.m02 = s * nx); +this.m11 = 1 + c1 * ny * ny; +this.m21 = -(this.m12 = s * ny); +this.m22 = c; +return true; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "isRotation", +function () { +return (Math.abs (this.determinant3 () - 1) < 0.001); +}); +}); diff --git a/bin/javajs/util/M34.js b/bin/javajs/util/M34.js index ae3f33d..47c6a34 100644 --- a/bin/javajs/util/M34.js +++ b/bin/javajs/util/M34.js @@ -1,336 +1,336 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.M34", ["java.lang.ArrayIndexOutOfBoundsException"], function () { -c$ = Clazz.decorateAsClass (function () { -this.m00 = 0; -this.m01 = 0; -this.m02 = 0; -this.m10 = 0; -this.m11 = 0; -this.m12 = 0; -this.m20 = 0; -this.m21 = 0; -this.m22 = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "M34"); -Clazz.defineMethod (c$, "setAA33", -function (a) { -var x = a.x; -var y = a.y; -var z = a.z; -var angle = a.angle; -var n = Math.sqrt (x * x + y * y + z * z); -n = 1 / n; -x *= n; -y *= n; -z *= n; -var c = Math.cos (angle); -var s = Math.sin (angle); -var omc = 1.0 - c; -this.m00 = (c + x * x * omc); -this.m11 = (c + y * y * omc); -this.m22 = (c + z * z * omc); -var tmp1 = x * y * omc; -var tmp2 = z * s; -this.m01 = (tmp1 - tmp2); -this.m10 = (tmp1 + tmp2); -tmp1 = x * z * omc; -tmp2 = y * s; -this.m02 = (tmp1 + tmp2); -this.m20 = (tmp1 - tmp2); -tmp1 = y * z * omc; -tmp2 = x * s; -this.m12 = (tmp1 - tmp2); -this.m21 = (tmp1 + tmp2); -}, "javajs.util.A4"); -Clazz.defineMethod (c$, "rotate", -function (t) { -this.rotate2 (t, t); -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "rotate2", -function (t, result) { -result.set (this.m00 * t.x + this.m01 * t.y + this.m02 * t.z, this.m10 * t.x + this.m11 * t.y + this.m12 * t.z, this.m20 * t.x + this.m21 * t.y + this.m22 * t.z); -}, "javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "setM33", -function (m1) { -this.m00 = m1.m00; -this.m01 = m1.m01; -this.m02 = m1.m02; -this.m10 = m1.m10; -this.m11 = m1.m11; -this.m12 = m1.m12; -this.m20 = m1.m20; -this.m21 = m1.m21; -this.m22 = m1.m22; -}, "javajs.util.M34"); -Clazz.defineMethod (c$, "clear33", -function () { -this.m00 = this.m01 = this.m02 = this.m10 = this.m11 = this.m12 = this.m20 = this.m21 = this.m22 = 0.0; -}); -Clazz.defineMethod (c$, "set33", -function (row, col, v) { -switch (row) { -case 0: -switch (col) { -case 0: -this.m00 = v; -return; -case 1: -this.m01 = v; -return; -case 2: -this.m02 = v; -return; -} -break; -case 1: -switch (col) { -case 0: -this.m10 = v; -return; -case 1: -this.m11 = v; -return; -case 2: -this.m12 = v; -return; -} -break; -case 2: -switch (col) { -case 0: -this.m20 = v; -return; -case 1: -this.m21 = v; -return; -case 2: -this.m22 = v; -return; -} -break; -} -this.err (); -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "get33", -function (row, col) { -switch (row) { -case 0: -switch (col) { -case 0: -return this.m00; -case 1: -return this.m01; -case 2: -return this.m02; -} -break; -case 1: -switch (col) { -case 0: -return this.m10; -case 1: -return this.m11; -case 2: -return this.m12; -} -break; -case 2: -switch (col) { -case 0: -return this.m20; -case 1: -return this.m21; -case 2: -return this.m22; -} -break; -} -this.err (); -return 0; -}, "~N,~N"); -Clazz.defineMethod (c$, "setRow33", -function (row, v) { -switch (row) { -case 0: -this.m00 = v[0]; -this.m01 = v[1]; -this.m02 = v[2]; -return; -case 1: -this.m10 = v[0]; -this.m11 = v[1]; -this.m12 = v[2]; -return; -case 2: -this.m20 = v[0]; -this.m21 = v[1]; -this.m22 = v[2]; -return; -default: -this.err (); -} -}, "~N,~A"); -Clazz.defineMethod (c$, "getRow33", -function (row, v) { -switch (row) { -case 0: -v[0] = this.m00; -v[1] = this.m01; -v[2] = this.m02; -return; -case 1: -v[0] = this.m10; -v[1] = this.m11; -v[2] = this.m12; -return; -case 2: -v[0] = this.m20; -v[1] = this.m21; -v[2] = this.m22; -return; -} -this.err (); -}, "~N,~A"); -Clazz.defineMethod (c$, "setColumn33", -function (column, v) { -switch (column) { -case 0: -this.m00 = v[0]; -this.m10 = v[1]; -this.m20 = v[2]; -break; -case 1: -this.m01 = v[0]; -this.m11 = v[1]; -this.m21 = v[2]; -break; -case 2: -this.m02 = v[0]; -this.m12 = v[1]; -this.m22 = v[2]; -break; -default: -this.err (); -} -}, "~N,~A"); -Clazz.defineMethod (c$, "getColumn33", -function (column, v) { -switch (column) { -case 0: -v[0] = this.m00; -v[1] = this.m10; -v[2] = this.m20; -break; -case 1: -v[0] = this.m01; -v[1] = this.m11; -v[2] = this.m21; -break; -case 2: -v[0] = this.m02; -v[1] = this.m12; -v[2] = this.m22; -break; -default: -this.err (); -} -}, "~N,~A"); -Clazz.defineMethod (c$, "add33", -function (m1) { -this.m00 += m1.m00; -this.m01 += m1.m01; -this.m02 += m1.m02; -this.m10 += m1.m10; -this.m11 += m1.m11; -this.m12 += m1.m12; -this.m20 += m1.m20; -this.m21 += m1.m21; -this.m22 += m1.m22; -}, "javajs.util.M34"); -Clazz.defineMethod (c$, "sub33", -function (m1) { -this.m00 -= m1.m00; -this.m01 -= m1.m01; -this.m02 -= m1.m02; -this.m10 -= m1.m10; -this.m11 -= m1.m11; -this.m12 -= m1.m12; -this.m20 -= m1.m20; -this.m21 -= m1.m21; -this.m22 -= m1.m22; -}, "javajs.util.M34"); -Clazz.defineMethod (c$, "mul33", -function (x) { -this.m00 *= x; -this.m01 *= x; -this.m02 *= x; -this.m10 *= x; -this.m11 *= x; -this.m12 *= x; -this.m20 *= x; -this.m21 *= x; -this.m22 *= x; -}, "~N"); -Clazz.defineMethod (c$, "transpose33", -function () { -var tmp = this.m01; -this.m01 = this.m10; -this.m10 = tmp; -tmp = this.m02; -this.m02 = this.m20; -this.m20 = tmp; -tmp = this.m12; -this.m12 = this.m21; -this.m21 = tmp; -}); -Clazz.defineMethod (c$, "setXRot", -function (angle) { -var c = Math.cos (angle); -var s = Math.sin (angle); -this.m00 = 1.0; -this.m01 = 0.0; -this.m02 = 0.0; -this.m10 = 0.0; -this.m11 = c; -this.m12 = -s; -this.m20 = 0.0; -this.m21 = s; -this.m22 = c; -}, "~N"); -Clazz.defineMethod (c$, "setYRot", -function (angle) { -var c = Math.cos (angle); -var s = Math.sin (angle); -this.m00 = c; -this.m01 = 0.0; -this.m02 = s; -this.m10 = 0.0; -this.m11 = 1.0; -this.m12 = 0.0; -this.m20 = -s; -this.m21 = 0.0; -this.m22 = c; -}, "~N"); -Clazz.defineMethod (c$, "setZRot", -function (angle) { -var c = Math.cos (angle); -var s = Math.sin (angle); -this.m00 = c; -this.m01 = -s; -this.m02 = 0.0; -this.m10 = s; -this.m11 = c; -this.m12 = 0.0; -this.m20 = 0.0; -this.m21 = 0.0; -this.m22 = 1.0; -}, "~N"); -Clazz.defineMethod (c$, "determinant3", -function () { -return this.m00 * (this.m11 * this.m22 - this.m21 * this.m12) - this.m01 * (this.m10 * this.m22 - this.m20 * this.m12) + this.m02 * (this.m10 * this.m21 - this.m20 * this.m11); -}); -Clazz.defineMethod (c$, "err", -function () { -throw new ArrayIndexOutOfBoundsException ("matrix column/row out of bounds"); -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.M34", ["java.lang.ArrayIndexOutOfBoundsException"], function () { +c$ = Clazz.decorateAsClass (function () { +this.m00 = 0; +this.m01 = 0; +this.m02 = 0; +this.m10 = 0; +this.m11 = 0; +this.m12 = 0; +this.m20 = 0; +this.m21 = 0; +this.m22 = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "M34"); +Clazz.defineMethod (c$, "setAA33", +function (a) { +var x = a.x; +var y = a.y; +var z = a.z; +var angle = a.angle; +var n = Math.sqrt (x * x + y * y + z * z); +n = 1 / n; +x *= n; +y *= n; +z *= n; +var c = Math.cos (angle); +var s = Math.sin (angle); +var omc = 1.0 - c; +this.m00 = (c + x * x * omc); +this.m11 = (c + y * y * omc); +this.m22 = (c + z * z * omc); +var tmp1 = x * y * omc; +var tmp2 = z * s; +this.m01 = (tmp1 - tmp2); +this.m10 = (tmp1 + tmp2); +tmp1 = x * z * omc; +tmp2 = y * s; +this.m02 = (tmp1 + tmp2); +this.m20 = (tmp1 - tmp2); +tmp1 = y * z * omc; +tmp2 = x * s; +this.m12 = (tmp1 - tmp2); +this.m21 = (tmp1 + tmp2); +}, "javajs.util.A4"); +Clazz.defineMethod (c$, "rotate", +function (t) { +this.rotate2 (t, t); +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "rotate2", +function (t, result) { +result.set (this.m00 * t.x + this.m01 * t.y + this.m02 * t.z, this.m10 * t.x + this.m11 * t.y + this.m12 * t.z, this.m20 * t.x + this.m21 * t.y + this.m22 * t.z); +}, "javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "setM33", +function (m1) { +this.m00 = m1.m00; +this.m01 = m1.m01; +this.m02 = m1.m02; +this.m10 = m1.m10; +this.m11 = m1.m11; +this.m12 = m1.m12; +this.m20 = m1.m20; +this.m21 = m1.m21; +this.m22 = m1.m22; +}, "javajs.util.M34"); +Clazz.defineMethod (c$, "clear33", +function () { +this.m00 = this.m01 = this.m02 = this.m10 = this.m11 = this.m12 = this.m20 = this.m21 = this.m22 = 0.0; +}); +Clazz.defineMethod (c$, "set33", +function (row, col, v) { +switch (row) { +case 0: +switch (col) { +case 0: +this.m00 = v; +return; +case 1: +this.m01 = v; +return; +case 2: +this.m02 = v; +return; +} +break; +case 1: +switch (col) { +case 0: +this.m10 = v; +return; +case 1: +this.m11 = v; +return; +case 2: +this.m12 = v; +return; +} +break; +case 2: +switch (col) { +case 0: +this.m20 = v; +return; +case 1: +this.m21 = v; +return; +case 2: +this.m22 = v; +return; +} +break; +} +this.err (); +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "get33", +function (row, col) { +switch (row) { +case 0: +switch (col) { +case 0: +return this.m00; +case 1: +return this.m01; +case 2: +return this.m02; +} +break; +case 1: +switch (col) { +case 0: +return this.m10; +case 1: +return this.m11; +case 2: +return this.m12; +} +break; +case 2: +switch (col) { +case 0: +return this.m20; +case 1: +return this.m21; +case 2: +return this.m22; +} +break; +} +this.err (); +return 0; +}, "~N,~N"); +Clazz.defineMethod (c$, "setRow33", +function (row, v) { +switch (row) { +case 0: +this.m00 = v[0]; +this.m01 = v[1]; +this.m02 = v[2]; +return; +case 1: +this.m10 = v[0]; +this.m11 = v[1]; +this.m12 = v[2]; +return; +case 2: +this.m20 = v[0]; +this.m21 = v[1]; +this.m22 = v[2]; +return; +default: +this.err (); +} +}, "~N,~A"); +Clazz.defineMethod (c$, "getRow33", +function (row, v) { +switch (row) { +case 0: +v[0] = this.m00; +v[1] = this.m01; +v[2] = this.m02; +return; +case 1: +v[0] = this.m10; +v[1] = this.m11; +v[2] = this.m12; +return; +case 2: +v[0] = this.m20; +v[1] = this.m21; +v[2] = this.m22; +return; +} +this.err (); +}, "~N,~A"); +Clazz.defineMethod (c$, "setColumn33", +function (column, v) { +switch (column) { +case 0: +this.m00 = v[0]; +this.m10 = v[1]; +this.m20 = v[2]; +break; +case 1: +this.m01 = v[0]; +this.m11 = v[1]; +this.m21 = v[2]; +break; +case 2: +this.m02 = v[0]; +this.m12 = v[1]; +this.m22 = v[2]; +break; +default: +this.err (); +} +}, "~N,~A"); +Clazz.defineMethod (c$, "getColumn33", +function (column, v) { +switch (column) { +case 0: +v[0] = this.m00; +v[1] = this.m10; +v[2] = this.m20; +break; +case 1: +v[0] = this.m01; +v[1] = this.m11; +v[2] = this.m21; +break; +case 2: +v[0] = this.m02; +v[1] = this.m12; +v[2] = this.m22; +break; +default: +this.err (); +} +}, "~N,~A"); +Clazz.defineMethod (c$, "add33", +function (m1) { +this.m00 += m1.m00; +this.m01 += m1.m01; +this.m02 += m1.m02; +this.m10 += m1.m10; +this.m11 += m1.m11; +this.m12 += m1.m12; +this.m20 += m1.m20; +this.m21 += m1.m21; +this.m22 += m1.m22; +}, "javajs.util.M34"); +Clazz.defineMethod (c$, "sub33", +function (m1) { +this.m00 -= m1.m00; +this.m01 -= m1.m01; +this.m02 -= m1.m02; +this.m10 -= m1.m10; +this.m11 -= m1.m11; +this.m12 -= m1.m12; +this.m20 -= m1.m20; +this.m21 -= m1.m21; +this.m22 -= m1.m22; +}, "javajs.util.M34"); +Clazz.defineMethod (c$, "mul33", +function (x) { +this.m00 *= x; +this.m01 *= x; +this.m02 *= x; +this.m10 *= x; +this.m11 *= x; +this.m12 *= x; +this.m20 *= x; +this.m21 *= x; +this.m22 *= x; +}, "~N"); +Clazz.defineMethod (c$, "transpose33", +function () { +var tmp = this.m01; +this.m01 = this.m10; +this.m10 = tmp; +tmp = this.m02; +this.m02 = this.m20; +this.m20 = tmp; +tmp = this.m12; +this.m12 = this.m21; +this.m21 = tmp; +}); +Clazz.defineMethod (c$, "setXRot", +function (angle) { +var c = Math.cos (angle); +var s = Math.sin (angle); +this.m00 = 1.0; +this.m01 = 0.0; +this.m02 = 0.0; +this.m10 = 0.0; +this.m11 = c; +this.m12 = -s; +this.m20 = 0.0; +this.m21 = s; +this.m22 = c; +}, "~N"); +Clazz.defineMethod (c$, "setYRot", +function (angle) { +var c = Math.cos (angle); +var s = Math.sin (angle); +this.m00 = c; +this.m01 = 0.0; +this.m02 = s; +this.m10 = 0.0; +this.m11 = 1.0; +this.m12 = 0.0; +this.m20 = -s; +this.m21 = 0.0; +this.m22 = c; +}, "~N"); +Clazz.defineMethod (c$, "setZRot", +function (angle) { +var c = Math.cos (angle); +var s = Math.sin (angle); +this.m00 = c; +this.m01 = -s; +this.m02 = 0.0; +this.m10 = s; +this.m11 = c; +this.m12 = 0.0; +this.m20 = 0.0; +this.m21 = 0.0; +this.m22 = 1.0; +}, "~N"); +Clazz.defineMethod (c$, "determinant3", +function () { +return this.m00 * (this.m11 * this.m22 - this.m21 * this.m12) - this.m01 * (this.m10 * this.m22 - this.m20 * this.m12) + this.m02 * (this.m10 * this.m21 - this.m20 * this.m11); +}); +Clazz.defineMethod (c$, "err", +function () { +throw new ArrayIndexOutOfBoundsException ("matrix column/row out of bounds"); +}); +}); diff --git a/bin/javajs/util/M4.js b/bin/javajs/util/M4.js index 59c23db..211ae5d 100644 --- a/bin/javajs/util/M4.js +++ b/bin/javajs/util/M4.js @@ -1,486 +1,486 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.M34"], "javajs.util.M4", ["javajs.util.T3"], function () { -c$ = Clazz.decorateAsClass (function () { -this.m03 = 0; -this.m13 = 0; -this.m23 = 0; -this.m30 = 0; -this.m31 = 0; -this.m32 = 0; -this.m33 = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "M4", javajs.util.M34); -c$.newA16 = Clazz.defineMethod (c$, "newA16", -function (v) { -var m = new javajs.util.M4 (); -m.m00 = v[0]; -m.m01 = v[1]; -m.m02 = v[2]; -m.m03 = v[3]; -m.m10 = v[4]; -m.m11 = v[5]; -m.m12 = v[6]; -m.m13 = v[7]; -m.m20 = v[8]; -m.m21 = v[9]; -m.m22 = v[10]; -m.m23 = v[11]; -m.m30 = v[12]; -m.m31 = v[13]; -m.m32 = v[14]; -m.m33 = v[15]; -return m; -}, "~A"); -c$.newM4 = Clazz.defineMethod (c$, "newM4", -function (m1) { -var m = new javajs.util.M4 (); -if (m1 == null) { -m.setIdentity (); -return m; -}m.setToM3 (m1); -m.m03 = m1.m03; -m.m13 = m1.m13; -m.m23 = m1.m23; -m.m30 = m1.m30; -m.m31 = m1.m31; -m.m32 = m1.m32; -m.m33 = m1.m33; -return m; -}, "javajs.util.M4"); -c$.newMV = Clazz.defineMethod (c$, "newMV", -function (m1, t) { -var m = new javajs.util.M4 (); -m.setMV (m1, t); -return m; -}, "javajs.util.M3,javajs.util.T3"); -Clazz.defineMethod (c$, "setZero", -function () { -this.clear33 (); -this.m03 = this.m13 = this.m23 = this.m30 = this.m31 = this.m32 = this.m33 = 0.0; -}); -Clazz.defineMethod (c$, "setIdentity", -function () { -this.setZero (); -this.m00 = this.m11 = this.m22 = this.m33 = 1.0; -}); -Clazz.defineMethod (c$, "setM4", -function (m1) { -this.setM33 (m1); -this.m03 = m1.m03; -this.m13 = m1.m13; -this.m23 = m1.m23; -this.m30 = m1.m30; -this.m31 = m1.m31; -this.m32 = m1.m32; -this.m33 = m1.m33; -return this; -}, "javajs.util.M4"); -Clazz.defineMethod (c$, "setMV", -function (m1, t) { -this.setM33 (m1); -this.setTranslation (t); -this.m33 = 1; -}, "javajs.util.M3,javajs.util.T3"); -Clazz.defineMethod (c$, "setToM3", -function (m1) { -this.setM33 (m1); -this.m03 = this.m13 = this.m23 = this.m30 = this.m31 = this.m32 = 0.0; -this.m33 = 1.0; -}, "javajs.util.M34"); -Clazz.defineMethod (c$, "setToAA", -function (a) { -this.setIdentity (); -this.setAA33 (a); -}, "javajs.util.A4"); -Clazz.defineMethod (c$, "setA", -function (m) { -this.m00 = m[0]; -this.m01 = m[1]; -this.m02 = m[2]; -this.m03 = m[3]; -this.m10 = m[4]; -this.m11 = m[5]; -this.m12 = m[6]; -this.m13 = m[7]; -this.m20 = m[8]; -this.m21 = m[9]; -this.m22 = m[10]; -this.m23 = m[11]; -this.m30 = m[12]; -this.m31 = m[13]; -this.m32 = m[14]; -this.m33 = m[15]; -}, "~A"); -Clazz.defineMethod (c$, "setTranslation", -function (trans) { -this.m03 = trans.x; -this.m13 = trans.y; -this.m23 = trans.z; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "setElement", -function (row, col, v) { -if (row < 3 && col < 3) { -this.set33 (row, col, v); -return; -}if (row > 3 || col > 3) this.err (); -switch (row) { -case 0: -this.m03 = v; -return; -case 1: -this.m13 = v; -return; -case 2: -this.m23 = v; -return; -} -switch (col) { -case 0: -this.m30 = v; -return; -case 1: -this.m31 = v; -return; -case 2: -this.m32 = v; -return; -case 3: -this.m33 = v; -return; -} -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "getElement", -function (row, col) { -if (row < 3 && col < 3) return this.get33 (row, col); -if (row > 3 || col > 3) { -this.err (); -return 0; -}switch (row) { -case 0: -return this.m03; -case 1: -return this.m13; -case 2: -return this.m23; -default: -switch (col) { -case 0: -return this.m30; -case 1: -return this.m31; -case 2: -return this.m32; -default: -return this.m33; -} -} -}, "~N,~N"); -Clazz.defineMethod (c$, "getTranslation", -function (trans) { -trans.x = this.m03; -trans.y = this.m13; -trans.z = this.m23; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "getRotationScale", -function (m1) { -m1.m00 = this.m00; -m1.m01 = this.m01; -m1.m02 = this.m02; -m1.m10 = this.m10; -m1.m11 = this.m11; -m1.m12 = this.m12; -m1.m20 = this.m20; -m1.m21 = this.m21; -m1.m22 = this.m22; -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "setRotationScale", -function (m1) { -this.m00 = m1.m00; -this.m01 = m1.m01; -this.m02 = m1.m02; -this.m10 = m1.m10; -this.m11 = m1.m11; -this.m12 = m1.m12; -this.m20 = m1.m20; -this.m21 = m1.m21; -this.m22 = m1.m22; -}, "javajs.util.M3"); -Clazz.defineMethod (c$, "setRowA", -function (row, v) { -if (row < 3) this.setRow33 (row, v); -switch (row) { -case 0: -this.m03 = v[3]; -return; -case 1: -this.m13 = v[3]; -return; -case 2: -this.m23 = v[3]; -return; -case 3: -this.m30 = v[0]; -this.m31 = v[1]; -this.m32 = v[2]; -this.m33 = v[3]; -return; -} -this.err (); -}, "~N,~A"); -Clazz.overrideMethod (c$, "getRow", -function (row, v) { -if (row < 3) this.getRow33 (row, v); -switch (row) { -case 0: -v[3] = this.m03; -return; -case 1: -v[3] = this.m13; -return; -case 2: -v[3] = this.m23; -return; -case 3: -v[0] = this.m30; -v[1] = this.m31; -v[2] = this.m32; -v[3] = this.m33; -return; -} -this.err (); -}, "~N,~A"); -Clazz.defineMethod (c$, "setColumn4", -function (column, x, y, z, w) { -if (column == 0) { -this.m00 = x; -this.m10 = y; -this.m20 = z; -this.m30 = w; -} else if (column == 1) { -this.m01 = x; -this.m11 = y; -this.m21 = z; -this.m31 = w; -} else if (column == 2) { -this.m02 = x; -this.m12 = y; -this.m22 = z; -this.m32 = w; -} else if (column == 3) { -this.m03 = x; -this.m13 = y; -this.m23 = z; -this.m33 = w; -} else { -this.err (); -}}, "~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "setColumnA", -function (column, v) { -if (column < 3) this.setColumn33 (column, v); -switch (column) { -case 0: -this.m30 = v[3]; -return; -case 1: -this.m31 = v[3]; -return; -case 2: -this.m32 = v[3]; -return; -case 3: -this.m03 = v[0]; -this.m13 = v[1]; -this.m23 = v[2]; -this.m33 = v[3]; -return; -default: -this.err (); -} -}, "~N,~A"); -Clazz.defineMethod (c$, "getColumn", -function (column, v) { -if (column < 3) this.getColumn33 (column, v); -switch (column) { -case 0: -v[3] = this.m30; -return; -case 1: -v[3] = this.m31; -return; -case 2: -v[3] = this.m32; -return; -case 3: -v[0] = this.m03; -v[1] = this.m13; -v[2] = this.m23; -v[3] = this.m33; -return; -default: -this.err (); -} -}, "~N,~A"); -Clazz.defineMethod (c$, "sub", -function (m1) { -this.sub33 (m1); -this.m03 -= m1.m03; -this.m13 -= m1.m13; -this.m23 -= m1.m23; -this.m30 -= m1.m30; -this.m31 -= m1.m31; -this.m32 -= m1.m32; -this.m33 -= m1.m33; -}, "javajs.util.M4"); -Clazz.defineMethod (c$, "transpose", -function () { -this.transpose33 (); -var tmp = this.m03; -this.m03 = this.m30; -this.m30 = tmp; -tmp = this.m13; -this.m13 = this.m31; -this.m31 = tmp; -tmp = this.m23; -this.m23 = this.m32; -this.m32 = tmp; -}); -Clazz.defineMethod (c$, "invert", -function () { -var s = this.determinant4 (); -if (s == 0.0) return this; -s = 1 / s; -this.set (this.m11 * (this.m22 * this.m33 - this.m23 * this.m32) + this.m12 * (this.m23 * this.m31 - this.m21 * this.m33) + this.m13 * (this.m21 * this.m32 - this.m22 * this.m31), this.m21 * (this.m02 * this.m33 - this.m03 * this.m32) + this.m22 * (this.m03 * this.m31 - this.m01 * this.m33) + this.m23 * (this.m01 * this.m32 - this.m02 * this.m31), this.m31 * (this.m02 * this.m13 - this.m03 * this.m12) + this.m32 * (this.m03 * this.m11 - this.m01 * this.m13) + this.m33 * (this.m01 * this.m12 - this.m02 * this.m11), this.m01 * (this.m13 * this.m22 - this.m12 * this.m23) + this.m02 * (this.m11 * this.m23 - this.m13 * this.m21) + this.m03 * (this.m12 * this.m21 - this.m11 * this.m22), this.m12 * (this.m20 * this.m33 - this.m23 * this.m30) + this.m13 * (this.m22 * this.m30 - this.m20 * this.m32) + this.m10 * (this.m23 * this.m32 - this.m22 * this.m33), this.m22 * (this.m00 * this.m33 - this.m03 * this.m30) + this.m23 * (this.m02 * this.m30 - this.m00 * this.m32) + this.m20 * (this.m03 * this.m32 - this.m02 * this.m33), this.m32 * (this.m00 * this.m13 - this.m03 * this.m10) + this.m33 * (this.m02 * this.m10 - this.m00 * this.m12) + this.m30 * (this.m03 * this.m12 - this.m02 * this.m13), this.m02 * (this.m13 * this.m20 - this.m10 * this.m23) + this.m03 * (this.m10 * this.m22 - this.m12 * this.m20) + this.m00 * (this.m12 * this.m23 - this.m13 * this.m22), this.m13 * (this.m20 * this.m31 - this.m21 * this.m30) + this.m10 * (this.m21 * this.m33 - this.m23 * this.m31) + this.m11 * (this.m23 * this.m30 - this.m20 * this.m33), this.m23 * (this.m00 * this.m31 - this.m01 * this.m30) + this.m20 * (this.m01 * this.m33 - this.m03 * this.m31) + this.m21 * (this.m03 * this.m30 - this.m00 * this.m33), this.m33 * (this.m00 * this.m11 - this.m01 * this.m10) + this.m30 * (this.m01 * this.m13 - this.m03 * this.m11) + this.m31 * (this.m03 * this.m10 - this.m00 * this.m13), this.m03 * (this.m11 * this.m20 - this.m10 * this.m21) + this.m00 * (this.m13 * this.m21 - this.m11 * this.m23) + this.m01 * (this.m10 * this.m23 - this.m13 * this.m20), this.m10 * (this.m22 * this.m31 - this.m21 * this.m32) + this.m11 * (this.m20 * this.m32 - this.m22 * this.m30) + this.m12 * (this.m21 * this.m30 - this.m20 * this.m31), this.m20 * (this.m02 * this.m31 - this.m01 * this.m32) + this.m21 * (this.m00 * this.m32 - this.m02 * this.m30) + this.m22 * (this.m01 * this.m30 - this.m00 * this.m31), this.m30 * (this.m02 * this.m11 - this.m01 * this.m12) + this.m31 * (this.m00 * this.m12 - this.m02 * this.m10) + this.m32 * (this.m01 * this.m10 - this.m00 * this.m11), this.m00 * (this.m11 * this.m22 - this.m12 * this.m21) + this.m01 * (this.m12 * this.m20 - this.m10 * this.m22) + this.m02 * (this.m10 * this.m21 - this.m11 * this.m20)); -this.scale (s); -return this; -}); -Clazz.defineMethod (c$, "set", -($fz = function (m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { -this.m00 = m00; -this.m01 = m01; -this.m02 = m02; -this.m03 = m03; -this.m10 = m10; -this.m11 = m11; -this.m12 = m12; -this.m13 = m13; -this.m20 = m20; -this.m21 = m21; -this.m22 = m22; -this.m23 = m23; -this.m30 = m30; -this.m31 = m31; -this.m32 = m32; -this.m33 = m33; -}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N"); -Clazz.defineMethod (c$, "determinant4", -function () { -return (this.m00 * this.m11 - this.m01 * this.m10) * (this.m22 * this.m33 - this.m23 * this.m32) - (this.m00 * this.m12 - this.m02 * this.m10) * (this.m21 * this.m33 - this.m23 * this.m31) + (this.m00 * this.m13 - this.m03 * this.m10) * (this.m21 * this.m32 - this.m22 * this.m31) + (this.m01 * this.m12 - this.m02 * this.m11) * (this.m20 * this.m33 - this.m23 * this.m30) - (this.m01 * this.m13 - this.m03 * this.m11) * (this.m20 * this.m32 - this.m22 * this.m30) + (this.m02 * this.m13 - this.m03 * this.m12) * (this.m20 * this.m31 - this.m21 * this.m30); -}); -Clazz.defineMethod (c$, "scale", -($fz = function (scalar) { -this.mul33 (scalar); -this.m03 *= scalar; -this.m13 *= scalar; -this.m23 *= scalar; -this.m30 *= scalar; -this.m31 *= scalar; -this.m32 *= scalar; -this.m33 *= scalar; -}, $fz.isPrivate = true, $fz), "~N"); -Clazz.defineMethod (c$, "mul", -function (m1) { -this.mul2 (this, m1); -}, "javajs.util.M4"); -Clazz.defineMethod (c$, "mul2", -function (m1, m2) { -this.set (m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20 + m1.m03 * m2.m30, m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21 + m1.m03 * m2.m31, m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22 + m1.m03 * m2.m32, m1.m00 * m2.m03 + m1.m01 * m2.m13 + m1.m02 * m2.m23 + m1.m03 * m2.m33, m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20 + m1.m13 * m2.m30, m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21 + m1.m13 * m2.m31, m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22 + m1.m13 * m2.m32, m1.m10 * m2.m03 + m1.m11 * m2.m13 + m1.m12 * m2.m23 + m1.m13 * m2.m33, m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20 + m1.m23 * m2.m30, m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21 + m1.m23 * m2.m31, m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22 + m1.m23 * m2.m32, m1.m20 * m2.m03 + m1.m21 * m2.m13 + m1.m22 * m2.m23 + m1.m23 * m2.m33, m1.m30 * m2.m00 + m1.m31 * m2.m10 + m1.m32 * m2.m20 + m1.m33 * m2.m30, m1.m30 * m2.m01 + m1.m31 * m2.m11 + m1.m32 * m2.m21 + m1.m33 * m2.m31, m1.m30 * m2.m02 + m1.m31 * m2.m12 + m1.m32 * m2.m22 + m1.m33 * m2.m32, m1.m30 * m2.m03 + m1.m31 * m2.m13 + m1.m32 * m2.m23 + m1.m33 * m2.m33); -}, "javajs.util.M4,javajs.util.M4"); -Clazz.defineMethod (c$, "transform", -function (vec) { -this.transform2 (vec, vec); -}, "javajs.util.T4"); -Clazz.defineMethod (c$, "transform2", -function (vec, vecOut) { -vecOut.set4 (this.m00 * vec.x + this.m01 * vec.y + this.m02 * vec.z + this.m03 * vec.w, this.m10 * vec.x + this.m11 * vec.y + this.m12 * vec.z + this.m13 * vec.w, this.m20 * vec.x + this.m21 * vec.y + this.m22 * vec.z + this.m23 * vec.w, this.m30 * vec.x + this.m31 * vec.y + this.m32 * vec.z + this.m33 * vec.w); -}, "javajs.util.T4,javajs.util.T4"); -Clazz.defineMethod (c$, "rotTrans", -function (point) { -this.rotTrans2 (point, point); -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "rotTrans2", -function (point, pointOut) { -pointOut.set (this.m00 * point.x + this.m01 * point.y + this.m02 * point.z + this.m03, this.m10 * point.x + this.m11 * point.y + this.m12 * point.z + this.m13, this.m20 * point.x + this.m21 * point.y + this.m22 * point.z + this.m23); -return pointOut; -}, "javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "setAsXYRotation", -function (angle) { -this.setIdentity (); -var c = Math.cos (angle); -var s = Math.sin (angle); -this.m22 = c; -this.m23 = -s; -this.m32 = s; -this.m33 = c; -return this; -}, "~N"); -Clazz.defineMethod (c$, "setAsYZRotation", -function (angle) { -this.setIdentity (); -var c = Math.cos (angle); -var s = Math.sin (angle); -this.m00 = c; -this.m03 = -s; -this.m30 = s; -this.m33 = c; -return this; -}, "~N"); -Clazz.defineMethod (c$, "setAsXZRotation", -function (angle) { -this.setIdentity (); -var c = Math.cos (angle); -var s = Math.sin (angle); -this.m11 = c; -this.m13 = -s; -this.m31 = s; -this.m33 = c; -return this; -}, "~N"); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (!(Clazz.instanceOf (o, javajs.util.M4))) return false; -var m = o; -return (this.m00 == m.m00 && this.m01 == m.m01 && this.m02 == m.m02 && this.m03 == m.m03 && this.m10 == m.m10 && this.m11 == m.m11 && this.m12 == m.m12 && this.m13 == m.m13 && this.m20 == m.m20 && this.m21 == m.m21 && this.m22 == m.m22 && this.m23 == m.m23 && this.m30 == m.m30 && this.m31 == m.m31 && this.m32 == m.m32 && this.m33 == m.m33); -}, "~O"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return javajs.util.T3.floatToIntBits0 (this.m00) ^ javajs.util.T3.floatToIntBits0 (this.m01) ^ javajs.util.T3.floatToIntBits0 (this.m02) ^ javajs.util.T3.floatToIntBits0 (this.m03) ^ javajs.util.T3.floatToIntBits0 (this.m10) ^ javajs.util.T3.floatToIntBits0 (this.m11) ^ javajs.util.T3.floatToIntBits0 (this.m12) ^ javajs.util.T3.floatToIntBits0 (this.m13) ^ javajs.util.T3.floatToIntBits0 (this.m20) ^ javajs.util.T3.floatToIntBits0 (this.m21) ^ javajs.util.T3.floatToIntBits0 (this.m22) ^ javajs.util.T3.floatToIntBits0 (this.m23) ^ javajs.util.T3.floatToIntBits0 (this.m30) ^ javajs.util.T3.floatToIntBits0 (this.m31) ^ javajs.util.T3.floatToIntBits0 (this.m32) ^ javajs.util.T3.floatToIntBits0 (this.m33); -}); -Clazz.overrideMethod (c$, "toString", -function () { -return "[\n [" + this.m00 + "\t" + this.m01 + "\t" + this.m02 + "\t" + this.m03 + "]" + "\n [" + this.m10 + "\t" + this.m11 + "\t" + this.m12 + "\t" + this.m13 + "]" + "\n [" + this.m20 + "\t" + this.m21 + "\t" + this.m22 + "\t" + this.m23 + "]" + "\n [" + this.m30 + "\t" + this.m31 + "\t" + this.m32 + "\t" + this.m33 + "] ]"; -}); -Clazz.defineMethod (c$, "round", -function (f) { -this.m00 = this.rnd (this.m00, f); -this.m01 = this.rnd (this.m01, f); -this.m02 = this.rnd (this.m02, f); -this.m03 = this.rnd (this.m03, f); -this.m10 = this.rnd (this.m10, f); -this.m11 = this.rnd (this.m11, f); -this.m12 = this.rnd (this.m12, f); -this.m13 = this.rnd (this.m13, f); -this.m20 = this.rnd (this.m20, f); -this.m21 = this.rnd (this.m21, f); -this.m22 = this.rnd (this.m22, f); -this.m23 = this.rnd (this.m23, f); -this.m30 = this.rnd (this.m30, f); -this.m31 = this.rnd (this.m31, f); -this.m32 = this.rnd (this.m32, f); -this.m33 = this.rnd (this.m33, f); -return this; -}, "~N"); -Clazz.defineMethod (c$, "rnd", -($fz = function (n, f) { -return (Math.abs (n) < f ? 0 : n); -}, $fz.isPrivate = true, $fz), "~N,~N"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.M34"], "javajs.util.M4", ["javajs.util.T3"], function () { +c$ = Clazz.decorateAsClass (function () { +this.m03 = 0; +this.m13 = 0; +this.m23 = 0; +this.m30 = 0; +this.m31 = 0; +this.m32 = 0; +this.m33 = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "M4", javajs.util.M34); +c$.newA16 = Clazz.defineMethod (c$, "newA16", +function (v) { +var m = new javajs.util.M4 (); +m.m00 = v[0]; +m.m01 = v[1]; +m.m02 = v[2]; +m.m03 = v[3]; +m.m10 = v[4]; +m.m11 = v[5]; +m.m12 = v[6]; +m.m13 = v[7]; +m.m20 = v[8]; +m.m21 = v[9]; +m.m22 = v[10]; +m.m23 = v[11]; +m.m30 = v[12]; +m.m31 = v[13]; +m.m32 = v[14]; +m.m33 = v[15]; +return m; +}, "~A"); +c$.newM4 = Clazz.defineMethod (c$, "newM4", +function (m1) { +var m = new javajs.util.M4 (); +if (m1 == null) { +m.setIdentity (); +return m; +}m.setToM3 (m1); +m.m03 = m1.m03; +m.m13 = m1.m13; +m.m23 = m1.m23; +m.m30 = m1.m30; +m.m31 = m1.m31; +m.m32 = m1.m32; +m.m33 = m1.m33; +return m; +}, "javajs.util.M4"); +c$.newMV = Clazz.defineMethod (c$, "newMV", +function (m1, t) { +var m = new javajs.util.M4 (); +m.setMV (m1, t); +return m; +}, "javajs.util.M3,javajs.util.T3"); +Clazz.defineMethod (c$, "setZero", +function () { +this.clear33 (); +this.m03 = this.m13 = this.m23 = this.m30 = this.m31 = this.m32 = this.m33 = 0.0; +}); +Clazz.defineMethod (c$, "setIdentity", +function () { +this.setZero (); +this.m00 = this.m11 = this.m22 = this.m33 = 1.0; +}); +Clazz.defineMethod (c$, "setM4", +function (m1) { +this.setM33 (m1); +this.m03 = m1.m03; +this.m13 = m1.m13; +this.m23 = m1.m23; +this.m30 = m1.m30; +this.m31 = m1.m31; +this.m32 = m1.m32; +this.m33 = m1.m33; +return this; +}, "javajs.util.M4"); +Clazz.defineMethod (c$, "setMV", +function (m1, t) { +this.setM33 (m1); +this.setTranslation (t); +this.m33 = 1; +}, "javajs.util.M3,javajs.util.T3"); +Clazz.defineMethod (c$, "setToM3", +function (m1) { +this.setM33 (m1); +this.m03 = this.m13 = this.m23 = this.m30 = this.m31 = this.m32 = 0.0; +this.m33 = 1.0; +}, "javajs.util.M34"); +Clazz.defineMethod (c$, "setToAA", +function (a) { +this.setIdentity (); +this.setAA33 (a); +}, "javajs.util.A4"); +Clazz.defineMethod (c$, "setA", +function (m) { +this.m00 = m[0]; +this.m01 = m[1]; +this.m02 = m[2]; +this.m03 = m[3]; +this.m10 = m[4]; +this.m11 = m[5]; +this.m12 = m[6]; +this.m13 = m[7]; +this.m20 = m[8]; +this.m21 = m[9]; +this.m22 = m[10]; +this.m23 = m[11]; +this.m30 = m[12]; +this.m31 = m[13]; +this.m32 = m[14]; +this.m33 = m[15]; +}, "~A"); +Clazz.defineMethod (c$, "setTranslation", +function (trans) { +this.m03 = trans.x; +this.m13 = trans.y; +this.m23 = trans.z; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "setElement", +function (row, col, v) { +if (row < 3 && col < 3) { +this.set33 (row, col, v); +return; +}if (row > 3 || col > 3) this.err (); +switch (row) { +case 0: +this.m03 = v; +return; +case 1: +this.m13 = v; +return; +case 2: +this.m23 = v; +return; +} +switch (col) { +case 0: +this.m30 = v; +return; +case 1: +this.m31 = v; +return; +case 2: +this.m32 = v; +return; +case 3: +this.m33 = v; +return; +} +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "getElement", +function (row, col) { +if (row < 3 && col < 3) return this.get33 (row, col); +if (row > 3 || col > 3) { +this.err (); +return 0; +}switch (row) { +case 0: +return this.m03; +case 1: +return this.m13; +case 2: +return this.m23; +default: +switch (col) { +case 0: +return this.m30; +case 1: +return this.m31; +case 2: +return this.m32; +default: +return this.m33; +} +} +}, "~N,~N"); +Clazz.defineMethod (c$, "getTranslation", +function (trans) { +trans.x = this.m03; +trans.y = this.m13; +trans.z = this.m23; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "getRotationScale", +function (m1) { +m1.m00 = this.m00; +m1.m01 = this.m01; +m1.m02 = this.m02; +m1.m10 = this.m10; +m1.m11 = this.m11; +m1.m12 = this.m12; +m1.m20 = this.m20; +m1.m21 = this.m21; +m1.m22 = this.m22; +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "setRotationScale", +function (m1) { +this.m00 = m1.m00; +this.m01 = m1.m01; +this.m02 = m1.m02; +this.m10 = m1.m10; +this.m11 = m1.m11; +this.m12 = m1.m12; +this.m20 = m1.m20; +this.m21 = m1.m21; +this.m22 = m1.m22; +}, "javajs.util.M3"); +Clazz.defineMethod (c$, "setRowA", +function (row, v) { +if (row < 3) this.setRow33 (row, v); +switch (row) { +case 0: +this.m03 = v[3]; +return; +case 1: +this.m13 = v[3]; +return; +case 2: +this.m23 = v[3]; +return; +case 3: +this.m30 = v[0]; +this.m31 = v[1]; +this.m32 = v[2]; +this.m33 = v[3]; +return; +} +this.err (); +}, "~N,~A"); +Clazz.overrideMethod (c$, "getRow", +function (row, v) { +if (row < 3) this.getRow33 (row, v); +switch (row) { +case 0: +v[3] = this.m03; +return; +case 1: +v[3] = this.m13; +return; +case 2: +v[3] = this.m23; +return; +case 3: +v[0] = this.m30; +v[1] = this.m31; +v[2] = this.m32; +v[3] = this.m33; +return; +} +this.err (); +}, "~N,~A"); +Clazz.defineMethod (c$, "setColumn4", +function (column, x, y, z, w) { +if (column == 0) { +this.m00 = x; +this.m10 = y; +this.m20 = z; +this.m30 = w; +} else if (column == 1) { +this.m01 = x; +this.m11 = y; +this.m21 = z; +this.m31 = w; +} else if (column == 2) { +this.m02 = x; +this.m12 = y; +this.m22 = z; +this.m32 = w; +} else if (column == 3) { +this.m03 = x; +this.m13 = y; +this.m23 = z; +this.m33 = w; +} else { +this.err (); +}}, "~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "setColumnA", +function (column, v) { +if (column < 3) this.setColumn33 (column, v); +switch (column) { +case 0: +this.m30 = v[3]; +return; +case 1: +this.m31 = v[3]; +return; +case 2: +this.m32 = v[3]; +return; +case 3: +this.m03 = v[0]; +this.m13 = v[1]; +this.m23 = v[2]; +this.m33 = v[3]; +return; +default: +this.err (); +} +}, "~N,~A"); +Clazz.defineMethod (c$, "getColumn", +function (column, v) { +if (column < 3) this.getColumn33 (column, v); +switch (column) { +case 0: +v[3] = this.m30; +return; +case 1: +v[3] = this.m31; +return; +case 2: +v[3] = this.m32; +return; +case 3: +v[0] = this.m03; +v[1] = this.m13; +v[2] = this.m23; +v[3] = this.m33; +return; +default: +this.err (); +} +}, "~N,~A"); +Clazz.defineMethod (c$, "sub", +function (m1) { +this.sub33 (m1); +this.m03 -= m1.m03; +this.m13 -= m1.m13; +this.m23 -= m1.m23; +this.m30 -= m1.m30; +this.m31 -= m1.m31; +this.m32 -= m1.m32; +this.m33 -= m1.m33; +}, "javajs.util.M4"); +Clazz.defineMethod (c$, "transpose", +function () { +this.transpose33 (); +var tmp = this.m03; +this.m03 = this.m30; +this.m30 = tmp; +tmp = this.m13; +this.m13 = this.m31; +this.m31 = tmp; +tmp = this.m23; +this.m23 = this.m32; +this.m32 = tmp; +}); +Clazz.defineMethod (c$, "invert", +function () { +var s = this.determinant4 (); +if (s == 0.0) return this; +s = 1 / s; +this.set (this.m11 * (this.m22 * this.m33 - this.m23 * this.m32) + this.m12 * (this.m23 * this.m31 - this.m21 * this.m33) + this.m13 * (this.m21 * this.m32 - this.m22 * this.m31), this.m21 * (this.m02 * this.m33 - this.m03 * this.m32) + this.m22 * (this.m03 * this.m31 - this.m01 * this.m33) + this.m23 * (this.m01 * this.m32 - this.m02 * this.m31), this.m31 * (this.m02 * this.m13 - this.m03 * this.m12) + this.m32 * (this.m03 * this.m11 - this.m01 * this.m13) + this.m33 * (this.m01 * this.m12 - this.m02 * this.m11), this.m01 * (this.m13 * this.m22 - this.m12 * this.m23) + this.m02 * (this.m11 * this.m23 - this.m13 * this.m21) + this.m03 * (this.m12 * this.m21 - this.m11 * this.m22), this.m12 * (this.m20 * this.m33 - this.m23 * this.m30) + this.m13 * (this.m22 * this.m30 - this.m20 * this.m32) + this.m10 * (this.m23 * this.m32 - this.m22 * this.m33), this.m22 * (this.m00 * this.m33 - this.m03 * this.m30) + this.m23 * (this.m02 * this.m30 - this.m00 * this.m32) + this.m20 * (this.m03 * this.m32 - this.m02 * this.m33), this.m32 * (this.m00 * this.m13 - this.m03 * this.m10) + this.m33 * (this.m02 * this.m10 - this.m00 * this.m12) + this.m30 * (this.m03 * this.m12 - this.m02 * this.m13), this.m02 * (this.m13 * this.m20 - this.m10 * this.m23) + this.m03 * (this.m10 * this.m22 - this.m12 * this.m20) + this.m00 * (this.m12 * this.m23 - this.m13 * this.m22), this.m13 * (this.m20 * this.m31 - this.m21 * this.m30) + this.m10 * (this.m21 * this.m33 - this.m23 * this.m31) + this.m11 * (this.m23 * this.m30 - this.m20 * this.m33), this.m23 * (this.m00 * this.m31 - this.m01 * this.m30) + this.m20 * (this.m01 * this.m33 - this.m03 * this.m31) + this.m21 * (this.m03 * this.m30 - this.m00 * this.m33), this.m33 * (this.m00 * this.m11 - this.m01 * this.m10) + this.m30 * (this.m01 * this.m13 - this.m03 * this.m11) + this.m31 * (this.m03 * this.m10 - this.m00 * this.m13), this.m03 * (this.m11 * this.m20 - this.m10 * this.m21) + this.m00 * (this.m13 * this.m21 - this.m11 * this.m23) + this.m01 * (this.m10 * this.m23 - this.m13 * this.m20), this.m10 * (this.m22 * this.m31 - this.m21 * this.m32) + this.m11 * (this.m20 * this.m32 - this.m22 * this.m30) + this.m12 * (this.m21 * this.m30 - this.m20 * this.m31), this.m20 * (this.m02 * this.m31 - this.m01 * this.m32) + this.m21 * (this.m00 * this.m32 - this.m02 * this.m30) + this.m22 * (this.m01 * this.m30 - this.m00 * this.m31), this.m30 * (this.m02 * this.m11 - this.m01 * this.m12) + this.m31 * (this.m00 * this.m12 - this.m02 * this.m10) + this.m32 * (this.m01 * this.m10 - this.m00 * this.m11), this.m00 * (this.m11 * this.m22 - this.m12 * this.m21) + this.m01 * (this.m12 * this.m20 - this.m10 * this.m22) + this.m02 * (this.m10 * this.m21 - this.m11 * this.m20)); +this.scale (s); +return this; +}); +Clazz.defineMethod (c$, "set", +($fz = function (m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { +this.m00 = m00; +this.m01 = m01; +this.m02 = m02; +this.m03 = m03; +this.m10 = m10; +this.m11 = m11; +this.m12 = m12; +this.m13 = m13; +this.m20 = m20; +this.m21 = m21; +this.m22 = m22; +this.m23 = m23; +this.m30 = m30; +this.m31 = m31; +this.m32 = m32; +this.m33 = m33; +}, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N"); +Clazz.defineMethod (c$, "determinant4", +function () { +return (this.m00 * this.m11 - this.m01 * this.m10) * (this.m22 * this.m33 - this.m23 * this.m32) - (this.m00 * this.m12 - this.m02 * this.m10) * (this.m21 * this.m33 - this.m23 * this.m31) + (this.m00 * this.m13 - this.m03 * this.m10) * (this.m21 * this.m32 - this.m22 * this.m31) + (this.m01 * this.m12 - this.m02 * this.m11) * (this.m20 * this.m33 - this.m23 * this.m30) - (this.m01 * this.m13 - this.m03 * this.m11) * (this.m20 * this.m32 - this.m22 * this.m30) + (this.m02 * this.m13 - this.m03 * this.m12) * (this.m20 * this.m31 - this.m21 * this.m30); +}); +Clazz.defineMethod (c$, "scale", +($fz = function (scalar) { +this.mul33 (scalar); +this.m03 *= scalar; +this.m13 *= scalar; +this.m23 *= scalar; +this.m30 *= scalar; +this.m31 *= scalar; +this.m32 *= scalar; +this.m33 *= scalar; +}, $fz.isPrivate = true, $fz), "~N"); +Clazz.defineMethod (c$, "mul", +function (m1) { +this.mul2 (this, m1); +}, "javajs.util.M4"); +Clazz.defineMethod (c$, "mul2", +function (m1, m2) { +this.set (m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20 + m1.m03 * m2.m30, m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21 + m1.m03 * m2.m31, m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22 + m1.m03 * m2.m32, m1.m00 * m2.m03 + m1.m01 * m2.m13 + m1.m02 * m2.m23 + m1.m03 * m2.m33, m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20 + m1.m13 * m2.m30, m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21 + m1.m13 * m2.m31, m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22 + m1.m13 * m2.m32, m1.m10 * m2.m03 + m1.m11 * m2.m13 + m1.m12 * m2.m23 + m1.m13 * m2.m33, m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20 + m1.m23 * m2.m30, m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21 + m1.m23 * m2.m31, m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22 + m1.m23 * m2.m32, m1.m20 * m2.m03 + m1.m21 * m2.m13 + m1.m22 * m2.m23 + m1.m23 * m2.m33, m1.m30 * m2.m00 + m1.m31 * m2.m10 + m1.m32 * m2.m20 + m1.m33 * m2.m30, m1.m30 * m2.m01 + m1.m31 * m2.m11 + m1.m32 * m2.m21 + m1.m33 * m2.m31, m1.m30 * m2.m02 + m1.m31 * m2.m12 + m1.m32 * m2.m22 + m1.m33 * m2.m32, m1.m30 * m2.m03 + m1.m31 * m2.m13 + m1.m32 * m2.m23 + m1.m33 * m2.m33); +}, "javajs.util.M4,javajs.util.M4"); +Clazz.defineMethod (c$, "transform", +function (vec) { +this.transform2 (vec, vec); +}, "javajs.util.T4"); +Clazz.defineMethod (c$, "transform2", +function (vec, vecOut) { +vecOut.set4 (this.m00 * vec.x + this.m01 * vec.y + this.m02 * vec.z + this.m03 * vec.w, this.m10 * vec.x + this.m11 * vec.y + this.m12 * vec.z + this.m13 * vec.w, this.m20 * vec.x + this.m21 * vec.y + this.m22 * vec.z + this.m23 * vec.w, this.m30 * vec.x + this.m31 * vec.y + this.m32 * vec.z + this.m33 * vec.w); +}, "javajs.util.T4,javajs.util.T4"); +Clazz.defineMethod (c$, "rotTrans", +function (point) { +this.rotTrans2 (point, point); +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "rotTrans2", +function (point, pointOut) { +pointOut.set (this.m00 * point.x + this.m01 * point.y + this.m02 * point.z + this.m03, this.m10 * point.x + this.m11 * point.y + this.m12 * point.z + this.m13, this.m20 * point.x + this.m21 * point.y + this.m22 * point.z + this.m23); +return pointOut; +}, "javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "setAsXYRotation", +function (angle) { +this.setIdentity (); +var c = Math.cos (angle); +var s = Math.sin (angle); +this.m22 = c; +this.m23 = -s; +this.m32 = s; +this.m33 = c; +return this; +}, "~N"); +Clazz.defineMethod (c$, "setAsYZRotation", +function (angle) { +this.setIdentity (); +var c = Math.cos (angle); +var s = Math.sin (angle); +this.m00 = c; +this.m03 = -s; +this.m30 = s; +this.m33 = c; +return this; +}, "~N"); +Clazz.defineMethod (c$, "setAsXZRotation", +function (angle) { +this.setIdentity (); +var c = Math.cos (angle); +var s = Math.sin (angle); +this.m11 = c; +this.m13 = -s; +this.m31 = s; +this.m33 = c; +return this; +}, "~N"); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (!(Clazz.instanceOf (o, javajs.util.M4))) return false; +var m = o; +return (this.m00 == m.m00 && this.m01 == m.m01 && this.m02 == m.m02 && this.m03 == m.m03 && this.m10 == m.m10 && this.m11 == m.m11 && this.m12 == m.m12 && this.m13 == m.m13 && this.m20 == m.m20 && this.m21 == m.m21 && this.m22 == m.m22 && this.m23 == m.m23 && this.m30 == m.m30 && this.m31 == m.m31 && this.m32 == m.m32 && this.m33 == m.m33); +}, "~O"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return javajs.util.T3.floatToIntBits0 (this.m00) ^ javajs.util.T3.floatToIntBits0 (this.m01) ^ javajs.util.T3.floatToIntBits0 (this.m02) ^ javajs.util.T3.floatToIntBits0 (this.m03) ^ javajs.util.T3.floatToIntBits0 (this.m10) ^ javajs.util.T3.floatToIntBits0 (this.m11) ^ javajs.util.T3.floatToIntBits0 (this.m12) ^ javajs.util.T3.floatToIntBits0 (this.m13) ^ javajs.util.T3.floatToIntBits0 (this.m20) ^ javajs.util.T3.floatToIntBits0 (this.m21) ^ javajs.util.T3.floatToIntBits0 (this.m22) ^ javajs.util.T3.floatToIntBits0 (this.m23) ^ javajs.util.T3.floatToIntBits0 (this.m30) ^ javajs.util.T3.floatToIntBits0 (this.m31) ^ javajs.util.T3.floatToIntBits0 (this.m32) ^ javajs.util.T3.floatToIntBits0 (this.m33); +}); +Clazz.overrideMethod (c$, "toString", +function () { +return "[\n [" + this.m00 + "\t" + this.m01 + "\t" + this.m02 + "\t" + this.m03 + "]" + "\n [" + this.m10 + "\t" + this.m11 + "\t" + this.m12 + "\t" + this.m13 + "]" + "\n [" + this.m20 + "\t" + this.m21 + "\t" + this.m22 + "\t" + this.m23 + "]" + "\n [" + this.m30 + "\t" + this.m31 + "\t" + this.m32 + "\t" + this.m33 + "] ]"; +}); +Clazz.defineMethod (c$, "round", +function (f) { +this.m00 = this.rnd (this.m00, f); +this.m01 = this.rnd (this.m01, f); +this.m02 = this.rnd (this.m02, f); +this.m03 = this.rnd (this.m03, f); +this.m10 = this.rnd (this.m10, f); +this.m11 = this.rnd (this.m11, f); +this.m12 = this.rnd (this.m12, f); +this.m13 = this.rnd (this.m13, f); +this.m20 = this.rnd (this.m20, f); +this.m21 = this.rnd (this.m21, f); +this.m22 = this.rnd (this.m22, f); +this.m23 = this.rnd (this.m23, f); +this.m30 = this.rnd (this.m30, f); +this.m31 = this.rnd (this.m31, f); +this.m32 = this.rnd (this.m32, f); +this.m33 = this.rnd (this.m33, f); +return this; +}, "~N"); +Clazz.defineMethod (c$, "rnd", +($fz = function (n, f) { +return (Math.abs (n) < f ? 0 : n); +}, $fz.isPrivate = true, $fz), "~N,~N"); +}); diff --git a/bin/javajs/util/Matrix.js b/bin/javajs/util/Matrix.js index cadc683..50972a4 100644 --- a/bin/javajs/util/Matrix.js +++ b/bin/javajs/util/Matrix.js @@ -1,223 +1,223 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.a = null; -this.m = 0; -this.n = 0; -if (!Clazz.isClassDefined ("javajs.util.Matrix.LUDecomp")) { -javajs.util.Matrix.$Matrix$LUDecomp$ (); -} -Clazz.instantialize (this, arguments); -}, javajs.util, "Matrix", null, Cloneable); -Clazz.makeConstructor (c$, -function (a, m, n) { -this.a = (a == null ? Clazz.newDoubleArray (m, n, 0) : a); -this.m = m; -this.n = n; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "getRowDimension", -function () { -return this.m; -}); -Clazz.defineMethod (c$, "getColumnDimension", -function () { -return this.n; -}); -Clazz.defineMethod (c$, "getArray", -function () { -return this.a; -}); -Clazz.defineMethod (c$, "getArrayCopy", -function () { -var x = Clazz.newDoubleArray (this.m, this.n, 0); -for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) x[i][j] = this.a[i][j]; - - -return x; -}); -Clazz.defineMethod (c$, "copy", -function () { -var x = new javajs.util.Matrix (null, this.m, this.n); -var c = x.a; -for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) c[i][j] = this.a[i][j]; - - -return x; -}); -Clazz.overrideMethod (c$, "clone", -function () { -return this.copy (); -}); -Clazz.defineMethod (c$, "getSubmatrix", -function (i0, j0, nrows, ncols) { -var x = new javajs.util.Matrix (null, nrows, ncols); -var xa = x.a; -for (var i = nrows; --i >= 0; ) for (var j = ncols; --j >= 0; ) xa[i][j] = this.a[i0 + i][j0 + j]; - - -return x; -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "getMatrixSelected", -function (r, n) { -var x = new javajs.util.Matrix (null, r.length, n); -var xa = x.a; -for (var i = r.length; --i >= 0; ) { -var b = this.a[r[i]]; -for (var j = n; --j >= 0; ) xa[i][j] = b[j]; - -} -return x; -}, "~A,~N"); -Clazz.defineMethod (c$, "transpose", -function () { -var x = new javajs.util.Matrix (null, this.n, this.m); -var c = x.a; -for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) c[j][i] = this.a[i][j]; - - -return x; -}); -Clazz.defineMethod (c$, "add", -function (b) { -return this.scaleAdd (b, 1); -}, "javajs.util.Matrix"); -Clazz.defineMethod (c$, "sub", -function (b) { -return this.scaleAdd (b, -1); -}, "javajs.util.Matrix"); -Clazz.defineMethod (c$, "scaleAdd", -function (b, scale) { -var x = new javajs.util.Matrix (null, this.m, this.n); -var xa = x.a; -var ba = b.a; -for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) xa[i][j] = ba[i][j] * scale + this.a[i][j]; - - -return x; -}, "javajs.util.Matrix,~N"); -Clazz.defineMethod (c$, "mul", -function (b) { -if (b.m != this.n) return null; -var x = new javajs.util.Matrix (null, this.m, b.n); -var xa = x.a; -var ba = b.a; -for (var j = b.n; --j >= 0; ) for (var i = this.m; --i >= 0; ) { -var arowi = this.a[i]; -var s = 0; -for (var k = this.n; --k >= 0; ) s += arowi[k] * ba[k][j]; - -xa[i][j] = s; -} - -return x; -}, "javajs.util.Matrix"); -Clazz.defineMethod (c$, "inverse", -function () { -return Clazz.innerTypeInstance (javajs.util.Matrix.LUDecomp, this, null, this.m, this.n).solve (javajs.util.Matrix.identity (this.m, this.m), this.n); -}); -Clazz.defineMethod (c$, "trace", -function () { -var t = 0; -for (var i = Math.min (this.m, this.n); --i >= 0; ) t += this.a[i][i]; - -return t; -}); -c$.identity = Clazz.defineMethod (c$, "identity", -function (m, n) { -var x = new javajs.util.Matrix (null, m, n); -var xa = x.a; -for (var i = Math.min (m, n); --i >= 0; ) xa[i][i] = 1; - -return x; -}, "~N,~N"); -Clazz.defineMethod (c$, "getRotation", -function () { -return this.getSubmatrix (0, 0, this.m - 1, this.n - 1); -}); -Clazz.defineMethod (c$, "getTranslation", -function () { -return this.getSubmatrix (0, this.n - 1, this.m - 1, 1); -}); -c$.newT = Clazz.defineMethod (c$, "newT", -function (r, asColumn) { -return (asColumn ? new javajs.util.Matrix ( Clazz.newArray (-1, [ Clazz.newDoubleArray (-1, [r.x]), Clazz.newDoubleArray (-1, [r.y]), Clazz.newDoubleArray (-1, [r.z])]), 3, 1) : new javajs.util.Matrix ( Clazz.newArray (-1, [ Clazz.newDoubleArray (-1, [r.x, r.y, r.z])]), 1, 3)); -}, "javajs.util.T3,~B"); -Clazz.overrideMethod (c$, "toString", -function () { -var s = "[\n"; -for (var i = 0; i < this.m; i++) { -s += " ["; -for (var j = 0; j < this.n; j++) s += " " + this.a[i][j]; - -s += "]\n"; -} -s += "]"; -return s; -}); -c$.$Matrix$LUDecomp$ = function () { -Clazz.pu$h (); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -this.LU = null; -this.piv = null; -this.pivsign = 0; -Clazz.instantialize (this, arguments); -}, javajs.util.Matrix, "LUDecomp"); -Clazz.makeConstructor (c$, -function (a, b) { -this.LU = this.b$["javajs.util.Matrix"].getArrayCopy (); -this.piv = Clazz.newIntArray (a, 0); -for (var c = a; --c >= 0; ) this.piv[c] = c; - -this.pivsign = 1; -var d; -var e = Clazz.newDoubleArray (a, 0); -for (var f = 0; f < b; f++) { -for (var g = a; --g >= 0; ) e[g] = this.LU[g][f]; - -for (var h = a; --h >= 0; ) { -d = this.LU[h]; -var i = Math.min (h, f); -var j = 0.0; -for (var k = i; --k >= 0; ) j += d[k] * e[k]; - -d[f] = e[h] -= j; -} -var i = f; -for (var j = a; --j > f; ) if (Math.abs (e[j]) > Math.abs (e[i])) i = j; - -if (i != f) { -for (var k = b; --k >= 0; ) { -var l = this.LU[i][k]; -this.LU[i][k] = this.LU[f][k]; -this.LU[f][k] = l; -} -var l = this.piv[i]; -this.piv[i] = this.piv[f]; -this.piv[f] = l; -this.pivsign = -this.pivsign; -}if ( new Boolean (f < a & this.LU[f][f] != 0.0).valueOf ()) for (var k = a; --k > f; ) this.LU[k][f] /= this.LU[f][f]; - -} -}, "~N,~N"); -Clazz.defineMethod (c$, "solve", -function (a, b) { -for (var c = 0; c < b; c++) if (this.LU[c][c] == 0) return null; - -var d = a.n; -var e = a.getMatrixSelected (this.piv, d); -var f = e.a; -for (var g = 0; g < b; g++) for (var h = g + 1; h < b; h++) for (var i = 0; i < d; i++) f[h][i] -= f[g][i] * this.LU[h][g]; - - - -for (var j = b; --j >= 0; ) { -for (var k = d; --k >= 0; ) f[j][k] /= this.LU[j][j]; - -for (var l = j; --l >= 0; ) for (var m = d; --m >= 0; ) f[l][m] -= f[j][m] * this.LU[l][j]; - - -} -return e; -}, "javajs.util.Matrix,~N"); -c$ = Clazz.p0p (); -}; +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.a = null; +this.m = 0; +this.n = 0; +if (!Clazz.isClassDefined ("javajs.util.Matrix.LUDecomp")) { +javajs.util.Matrix.$Matrix$LUDecomp$ (); +} +Clazz.instantialize (this, arguments); +}, javajs.util, "Matrix", null, Cloneable); +Clazz.makeConstructor (c$, +function (a, m, n) { +this.a = (a == null ? Clazz.newDoubleArray (m, n, 0) : a); +this.m = m; +this.n = n; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "getRowDimension", +function () { +return this.m; +}); +Clazz.defineMethod (c$, "getColumnDimension", +function () { +return this.n; +}); +Clazz.defineMethod (c$, "getArray", +function () { +return this.a; +}); +Clazz.defineMethod (c$, "getArrayCopy", +function () { +var x = Clazz.newDoubleArray (this.m, this.n, 0); +for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) x[i][j] = this.a[i][j]; + + +return x; +}); +Clazz.defineMethod (c$, "copy", +function () { +var x = new javajs.util.Matrix (null, this.m, this.n); +var c = x.a; +for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) c[i][j] = this.a[i][j]; + + +return x; +}); +Clazz.overrideMethod (c$, "clone", +function () { +return this.copy (); +}); +Clazz.defineMethod (c$, "getSubmatrix", +function (i0, j0, nrows, ncols) { +var x = new javajs.util.Matrix (null, nrows, ncols); +var xa = x.a; +for (var i = nrows; --i >= 0; ) for (var j = ncols; --j >= 0; ) xa[i][j] = this.a[i0 + i][j0 + j]; + + +return x; +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "getMatrixSelected", +function (r, n) { +var x = new javajs.util.Matrix (null, r.length, n); +var xa = x.a; +for (var i = r.length; --i >= 0; ) { +var b = this.a[r[i]]; +for (var j = n; --j >= 0; ) xa[i][j] = b[j]; + +} +return x; +}, "~A,~N"); +Clazz.defineMethod (c$, "transpose", +function () { +var x = new javajs.util.Matrix (null, this.n, this.m); +var c = x.a; +for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) c[j][i] = this.a[i][j]; + + +return x; +}); +Clazz.defineMethod (c$, "add", +function (b) { +return this.scaleAdd (b, 1); +}, "javajs.util.Matrix"); +Clazz.defineMethod (c$, "sub", +function (b) { +return this.scaleAdd (b, -1); +}, "javajs.util.Matrix"); +Clazz.defineMethod (c$, "scaleAdd", +function (b, scale) { +var x = new javajs.util.Matrix (null, this.m, this.n); +var xa = x.a; +var ba = b.a; +for (var i = this.m; --i >= 0; ) for (var j = this.n; --j >= 0; ) xa[i][j] = ba[i][j] * scale + this.a[i][j]; + + +return x; +}, "javajs.util.Matrix,~N"); +Clazz.defineMethod (c$, "mul", +function (b) { +if (b.m != this.n) return null; +var x = new javajs.util.Matrix (null, this.m, b.n); +var xa = x.a; +var ba = b.a; +for (var j = b.n; --j >= 0; ) for (var i = this.m; --i >= 0; ) { +var arowi = this.a[i]; +var s = 0; +for (var k = this.n; --k >= 0; ) s += arowi[k] * ba[k][j]; + +xa[i][j] = s; +} + +return x; +}, "javajs.util.Matrix"); +Clazz.defineMethod (c$, "inverse", +function () { +return Clazz.innerTypeInstance (javajs.util.Matrix.LUDecomp, this, null, this.m, this.n).solve (javajs.util.Matrix.identity (this.m, this.m), this.n); +}); +Clazz.defineMethod (c$, "trace", +function () { +var t = 0; +for (var i = Math.min (this.m, this.n); --i >= 0; ) t += this.a[i][i]; + +return t; +}); +c$.identity = Clazz.defineMethod (c$, "identity", +function (m, n) { +var x = new javajs.util.Matrix (null, m, n); +var xa = x.a; +for (var i = Math.min (m, n); --i >= 0; ) xa[i][i] = 1; + +return x; +}, "~N,~N"); +Clazz.defineMethod (c$, "getRotation", +function () { +return this.getSubmatrix (0, 0, this.m - 1, this.n - 1); +}); +Clazz.defineMethod (c$, "getTranslation", +function () { +return this.getSubmatrix (0, this.n - 1, this.m - 1, 1); +}); +c$.newT = Clazz.defineMethod (c$, "newT", +function (r, asColumn) { +return (asColumn ? new javajs.util.Matrix ( Clazz.newArray (-1, [ Clazz.newDoubleArray (-1, [r.x]), Clazz.newDoubleArray (-1, [r.y]), Clazz.newDoubleArray (-1, [r.z])]), 3, 1) : new javajs.util.Matrix ( Clazz.newArray (-1, [ Clazz.newDoubleArray (-1, [r.x, r.y, r.z])]), 1, 3)); +}, "javajs.util.T3,~B"); +Clazz.overrideMethod (c$, "toString", +function () { +var s = "[\n"; +for (var i = 0; i < this.m; i++) { +s += " ["; +for (var j = 0; j < this.n; j++) s += " " + this.a[i][j]; + +s += "]\n"; +} +s += "]"; +return s; +}); +c$.$Matrix$LUDecomp$ = function () { +Clazz.pu$h (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +this.LU = null; +this.piv = null; +this.pivsign = 0; +Clazz.instantialize (this, arguments); +}, javajs.util.Matrix, "LUDecomp"); +Clazz.makeConstructor (c$, +function (a, b) { +this.LU = this.b$["javajs.util.Matrix"].getArrayCopy (); +this.piv = Clazz.newIntArray (a, 0); +for (var c = a; --c >= 0; ) this.piv[c] = c; + +this.pivsign = 1; +var d; +var e = Clazz.newDoubleArray (a, 0); +for (var f = 0; f < b; f++) { +for (var g = a; --g >= 0; ) e[g] = this.LU[g][f]; + +for (var h = a; --h >= 0; ) { +d = this.LU[h]; +var i = Math.min (h, f); +var j = 0.0; +for (var k = i; --k >= 0; ) j += d[k] * e[k]; + +d[f] = e[h] -= j; +} +var i = f; +for (var j = a; --j > f; ) if (Math.abs (e[j]) > Math.abs (e[i])) i = j; + +if (i != f) { +for (var k = b; --k >= 0; ) { +var l = this.LU[i][k]; +this.LU[i][k] = this.LU[f][k]; +this.LU[f][k] = l; +} +var l = this.piv[i]; +this.piv[i] = this.piv[f]; +this.piv[f] = l; +this.pivsign = -this.pivsign; +}if ( new Boolean (f < a & this.LU[f][f] != 0.0).valueOf ()) for (var k = a; --k > f; ) this.LU[k][f] /= this.LU[f][f]; + +} +}, "~N,~N"); +Clazz.defineMethod (c$, "solve", +function (a, b) { +for (var c = 0; c < b; c++) if (this.LU[c][c] == 0) return null; + +var d = a.n; +var e = a.getMatrixSelected (this.piv, d); +var f = e.a; +for (var g = 0; g < b; g++) for (var h = g + 1; h < b; h++) for (var i = 0; i < d; i++) f[h][i] -= f[g][i] * this.LU[h][g]; + + + +for (var j = b; --j >= 0; ) { +for (var k = d; --k >= 0; ) f[j][k] /= this.LU[j][j]; + +for (var l = j; --l >= 0; ) for (var m = d; --m >= 0; ) f[l][m] -= f[j][m] * this.LU[l][j]; + + +} +return e; +}, "javajs.util.Matrix,~N"); +c$ = Clazz.p0p (); +}; diff --git a/bin/javajs/util/Measure.js b/bin/javajs/util/Measure.js index bbcd327..14e6410 100644 --- a/bin/javajs/util/Measure.js +++ b/bin/javajs/util/Measure.js @@ -1,394 +1,394 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.V3"], "javajs.util.Measure", ["java.lang.Float", "javajs.api.Interface", "javajs.util.Lst", "$.P3", "$.P4", "$.Quat"], function () { -c$ = Clazz.declareType (javajs.util, "Measure"); -c$.computeAngle = Clazz.defineMethod (c$, "computeAngle", -function (pointA, pointB, pointC, vectorBA, vectorBC, asDegrees) { -vectorBA.sub2 (pointA, pointB); -vectorBC.sub2 (pointC, pointB); -var angle = vectorBA.angle (vectorBC); -return (asDegrees ? angle / 0.017453292 : angle); -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3,~B"); -c$.computeAngleABC = Clazz.defineMethod (c$, "computeAngleABC", -function (pointA, pointB, pointC, asDegrees) { -var vectorBA = new javajs.util.V3 (); -var vectorBC = new javajs.util.V3 (); -return javajs.util.Measure.computeAngle (pointA, pointB, pointC, vectorBA, vectorBC, asDegrees); -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,~B"); -c$.computeTorsion = Clazz.defineMethod (c$, "computeTorsion", -function (p1, p2, p3, p4, asDegrees) { -var ijx = p1.x - p2.x; -var ijy = p1.y - p2.y; -var ijz = p1.z - p2.z; -var kjx = p3.x - p2.x; -var kjy = p3.y - p2.y; -var kjz = p3.z - p2.z; -var klx = p3.x - p4.x; -var kly = p3.y - p4.y; -var klz = p3.z - p4.z; -var ax = ijy * kjz - ijz * kjy; -var ay = ijz * kjx - ijx * kjz; -var az = ijx * kjy - ijy * kjx; -var cx = kjy * klz - kjz * kly; -var cy = kjz * klx - kjx * klz; -var cz = kjx * kly - kjy * klx; -var ai2 = 1 / (ax * ax + ay * ay + az * az); -var ci2 = 1 / (cx * cx + cy * cy + cz * cz); -var ai = Math.sqrt (ai2); -var ci = Math.sqrt (ci2); -var denom = ai * ci; -var cross = ax * cx + ay * cy + az * cz; -var cosang = cross * denom; -if (cosang > 1) { -cosang = 1; -}if (cosang < -1) { -cosang = -1; -}var torsion = Math.acos (cosang); -var dot = ijx * cx + ijy * cy + ijz * cz; -var absDot = Math.abs (dot); -torsion = (dot / absDot > 0) ? torsion : -torsion; -return (asDegrees ? torsion / 0.017453292 : torsion); -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.T3,~B"); -c$.computeHelicalAxis = Clazz.defineMethod (c$, "computeHelicalAxis", -function (a, b, dq) { -var vab = new javajs.util.V3 (); -vab.sub2 (b, a); -var theta = dq.getTheta (); -var n = dq.getNormal (); -var v_dot_n = vab.dot (n); -if (Math.abs (v_dot_n) < 0.0001) v_dot_n = 0; -var va_prime_d = new javajs.util.V3 (); -va_prime_d.cross (vab, n); -if (va_prime_d.dot (va_prime_d) != 0) va_prime_d.normalize (); -var vda = new javajs.util.V3 (); -var vcb = javajs.util.V3.newV (n); -if (v_dot_n == 0) v_dot_n = 1.4E-45; -vcb.scale (v_dot_n); -vda.sub2 (vcb, vab); -vda.scale (0.5); -va_prime_d.scale (theta == 0 ? 0 : (vda.length () / Math.tan (theta / 2 / 180 * 3.141592653589793))); -var r = javajs.util.V3.newV (va_prime_d); -if (theta != 0) r.add (vda); -var pt_a_prime = javajs.util.P3.newP (a); -pt_a_prime.sub (r); -if (v_dot_n != 1.4E-45) n.scale (v_dot_n); -var pt_b_prime = javajs.util.P3.newP (pt_a_prime); -pt_b_prime.add (n); -theta = javajs.util.Measure.computeTorsion (a, pt_a_prime, pt_b_prime, b, true); -if (Float.isNaN (theta) || r.length () < 0.0001) theta = dq.getThetaDirectedV (n); -var residuesPerTurn = Math.abs (theta == 0 ? 0 : 360 / theta); -var pitch = Math.abs (v_dot_n == 1.4E-45 ? 0 : n.length () * (theta == 0 ? 1 : 360 / theta)); -return Clazz.newArray (-1, [pt_a_prime, n, r, javajs.util.P3.new3 (theta, pitch, residuesPerTurn), pt_b_prime]); -}, "javajs.util.P3,javajs.util.P3,javajs.util.Quat"); -c$.getPlaneThroughPoints = Clazz.defineMethod (c$, "getPlaneThroughPoints", -function (pointA, pointB, pointC, vNorm, vAB, plane) { -var w = javajs.util.Measure.getNormalThroughPoints (pointA, pointB, pointC, vNorm, vAB); -plane.set4 (vNorm.x, vNorm.y, vNorm.z, w); -return plane; -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3,javajs.util.P4"); -c$.getPlaneThroughPoint = Clazz.defineMethod (c$, "getPlaneThroughPoint", -function (pt, normal, plane) { -plane.set4 (normal.x, normal.y, normal.z, -normal.dot (pt)); -}, "javajs.util.T3,javajs.util.V3,javajs.util.P4"); -c$.distanceToPlane = Clazz.defineMethod (c$, "distanceToPlane", -function (plane, pt) { -return (plane == null ? NaN : (plane.dot (pt) + plane.w) / Math.sqrt (plane.dot (plane))); -}, "javajs.util.P4,javajs.util.T3"); -c$.directedDistanceToPlane = Clazz.defineMethod (c$, "directedDistanceToPlane", -function (pt, plane, ptref) { -var f = plane.dot (pt) + plane.w; -var f1 = plane.dot (ptref) + plane.w; -return Math.signum (f1) * f / Math.sqrt (plane.dot (plane)); -}, "javajs.util.P3,javajs.util.P4,javajs.util.P3"); -c$.distanceToPlaneD = Clazz.defineMethod (c$, "distanceToPlaneD", -function (plane, d, pt) { -return (plane == null ? NaN : (plane.dot (pt) + plane.w) / d); -}, "javajs.util.P4,~N,javajs.util.P3"); -c$.distanceToPlaneV = Clazz.defineMethod (c$, "distanceToPlaneV", -function (norm, w, pt) { -return (norm == null ? NaN : (norm.dot (pt) + w) / Math.sqrt (norm.dot (norm))); -}, "javajs.util.V3,~N,javajs.util.P3"); -c$.calcNormalizedNormal = Clazz.defineMethod (c$, "calcNormalizedNormal", -function (pointA, pointB, pointC, vNormNorm, vAB) { -vAB.sub2 (pointB, pointA); -vNormNorm.sub2 (pointC, pointA); -vNormNorm.cross (vAB, vNormNorm); -vNormNorm.normalize (); -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3"); -c$.getDirectedNormalThroughPoints = Clazz.defineMethod (c$, "getDirectedNormalThroughPoints", -function (pointA, pointB, pointC, ptRef, vNorm, vAB) { -var nd = javajs.util.Measure.getNormalThroughPoints (pointA, pointB, pointC, vNorm, vAB); -if (ptRef != null) { -var pt0 = javajs.util.P3.newP (pointA); -pt0.add (vNorm); -var d = pt0.distance (ptRef); -pt0.sub2 (pointA, vNorm); -if (d > pt0.distance (ptRef)) { -vNorm.scale (-1); -nd = -nd; -}}return nd; -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3"); -c$.getNormalThroughPoints = Clazz.defineMethod (c$, "getNormalThroughPoints", -function (pointA, pointB, pointC, vNorm, vTemp) { -javajs.util.Measure.calcNormalizedNormal (pointA, pointB, pointC, vNorm, vTemp); -vTemp.setT (pointA); -return -vTemp.dot (vNorm); -}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3"); -c$.getPlaneProjection = Clazz.defineMethod (c$, "getPlaneProjection", -function (pt, plane, ptProj, vNorm) { -var dist = javajs.util.Measure.distanceToPlane (plane, pt); -vNorm.set (plane.x, plane.y, plane.z); -vNorm.normalize (); -vNorm.scale (-dist); -ptProj.add2 (pt, vNorm); -}, "javajs.util.P3,javajs.util.P4,javajs.util.P3,javajs.util.V3"); -c$.getNormalToLine = Clazz.defineMethod (c$, "getNormalToLine", -function (pointA, pointB, vNormNorm) { -vNormNorm.sub2 (pointA, pointB); -vNormNorm.cross (vNormNorm, javajs.util.Measure.axisY); -vNormNorm.normalize (); -if (Float.isNaN (vNormNorm.x)) vNormNorm.set (1, 0, 0); -}, "javajs.util.P3,javajs.util.P3,javajs.util.V3"); -c$.getBisectingPlane = Clazz.defineMethod (c$, "getBisectingPlane", -function (pointA, vAB, ptTemp, vTemp, plane) { -ptTemp.scaleAdd2 (0.5, vAB, pointA); -vTemp.setT (vAB); -vTemp.normalize (); -javajs.util.Measure.getPlaneThroughPoint (ptTemp, vTemp, plane); -}, "javajs.util.P3,javajs.util.V3,javajs.util.T3,javajs.util.V3,javajs.util.P4"); -c$.projectOntoAxis = Clazz.defineMethod (c$, "projectOntoAxis", -function (point, axisA, axisUnitVector, vectorProjection) { -vectorProjection.sub2 (point, axisA); -var projectedLength = vectorProjection.dot (axisUnitVector); -point.scaleAdd2 (projectedLength, axisUnitVector, axisA); -vectorProjection.sub2 (point, axisA); -}, "javajs.util.P3,javajs.util.P3,javajs.util.V3,javajs.util.V3"); -c$.calcBestAxisThroughPoints = Clazz.defineMethod (c$, "calcBestAxisThroughPoints", -function (points, axisA, axisUnitVector, vectorProjection, nTriesMax) { -var nPoints = points.length; -axisA.setT (points[0]); -axisUnitVector.sub2 (points[nPoints - 1], axisA); -axisUnitVector.normalize (); -javajs.util.Measure.calcAveragePointN (points, nPoints, axisA); -var nTries = 0; -while (nTries++ < nTriesMax && javajs.util.Measure.findAxis (points, nPoints, axisA, axisUnitVector, vectorProjection) > 0.001) { -} -var tempA = javajs.util.P3.newP (points[0]); -javajs.util.Measure.projectOntoAxis (tempA, axisA, axisUnitVector, vectorProjection); -axisA.setT (tempA); -}, "~A,javajs.util.P3,javajs.util.V3,javajs.util.V3,~N"); -c$.findAxis = Clazz.defineMethod (c$, "findAxis", -function (points, nPoints, axisA, axisUnitVector, vectorProjection) { -var sumXiYi = new javajs.util.V3 (); -var vTemp = new javajs.util.V3 (); -var pt = new javajs.util.P3 (); -var ptProj = new javajs.util.P3 (); -var a = javajs.util.V3.newV (axisUnitVector); -var sum_Xi2 = 0; -for (var i = nPoints; --i >= 0; ) { -pt.setT (points[i]); -ptProj.setT (pt); -javajs.util.Measure.projectOntoAxis (ptProj, axisA, axisUnitVector, vectorProjection); -vTemp.sub2 (pt, ptProj); -vTemp.cross (vectorProjection, vTemp); -sumXiYi.add (vTemp); -sum_Xi2 += vectorProjection.lengthSquared (); -} -var m = javajs.util.V3.newV (sumXiYi); -m.scale (1 / sum_Xi2); -vTemp.cross (m, axisUnitVector); -axisUnitVector.add (vTemp); -axisUnitVector.normalize (); -vTemp.sub2 (axisUnitVector, a); -return vTemp.length (); -}, "~A,~N,javajs.util.P3,javajs.util.V3,javajs.util.V3"); -c$.calcAveragePoint = Clazz.defineMethod (c$, "calcAveragePoint", -function (pointA, pointB, pointC) { -pointC.set ((pointA.x + pointB.x) / 2, (pointA.y + pointB.y) / 2, (pointA.z + pointB.z) / 2); -}, "javajs.util.P3,javajs.util.P3,javajs.util.P3"); -c$.calcAveragePointN = Clazz.defineMethod (c$, "calcAveragePointN", -function (points, nPoints, averagePoint) { -averagePoint.setT (points[0]); -for (var i = 1; i < nPoints; i++) averagePoint.add (points[i]); - -averagePoint.scale (1 / nPoints); -}, "~A,~N,javajs.util.P3"); -c$.transformPoints = Clazz.defineMethod (c$, "transformPoints", -function (vPts, m4, center) { -var v = new javajs.util.Lst (); -for (var i = 0; i < vPts.size (); i++) { -var pt = javajs.util.P3.newP (vPts.get (i)); -pt.sub (center); -m4.rotTrans (pt); -pt.add (center); -v.addLast (pt); -} -return v; -}, "javajs.util.Lst,javajs.util.M4,javajs.util.P3"); -c$.isInTetrahedron = Clazz.defineMethod (c$, "isInTetrahedron", -function (pt, ptA, ptB, ptC, ptD, plane, vTemp, vTemp2, fullyEnclosed) { -var b = (javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptC, ptD, ptA, vTemp, vTemp2, plane), pt) >= 0); -if (b != (javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptA, ptD, ptB, vTemp, vTemp2, plane), pt) >= 0)) return false; -if (b != (javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptB, ptD, ptC, vTemp, vTemp2, plane), pt) >= 0)) return false; -var d = javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptA, ptB, ptC, vTemp, vTemp2, plane), pt); -if (fullyEnclosed) return (b == (d >= 0)); -var d1 = javajs.util.Measure.distanceToPlane (plane, ptD); -return d1 * d <= 0 || Math.abs (d1) > Math.abs (d); -}, "javajs.util.P3,javajs.util.P3,javajs.util.P3,javajs.util.P3,javajs.util.P3,javajs.util.P4,javajs.util.V3,javajs.util.V3,~B"); -c$.getIntersectionPP = Clazz.defineMethod (c$, "getIntersectionPP", -function (plane1, plane2) { -var a1 = plane1.x; -var b1 = plane1.y; -var c1 = plane1.z; -var d1 = plane1.w; -var a2 = plane2.x; -var b2 = plane2.y; -var c2 = plane2.z; -var d2 = plane2.w; -var norm1 = javajs.util.V3.new3 (a1, b1, c1); -var norm2 = javajs.util.V3.new3 (a2, b2, c2); -var nxn = new javajs.util.V3 (); -nxn.cross (norm1, norm2); -var ax = Math.abs (nxn.x); -var ay = Math.abs (nxn.y); -var az = Math.abs (nxn.z); -var x; -var y; -var z; -var diff; -var type = (ax > ay ? (ax > az ? 1 : 3) : ay > az ? 2 : 3); -switch (type) { -case 1: -x = 0; -diff = (b1 * c2 - b2 * c1); -if (Math.abs (diff) < 0.01) return null; -y = (c1 * d2 - c2 * d1) / diff; -z = (b2 * d1 - d2 * b1) / diff; -break; -case 2: -diff = (a1 * c2 - a2 * c1); -if (Math.abs (diff) < 0.01) return null; -x = (c1 * d2 - c2 * d1) / diff; -y = 0; -z = (a2 * d1 - d2 * a1) / diff; -break; -case 3: -default: -diff = (a1 * b2 - a2 * b1); -if (Math.abs (diff) < 0.01) return null; -x = (b1 * d2 - b2 * d1) / diff; -y = (a2 * d1 - d2 * a1) / diff; -z = 0; -} -var list = new javajs.util.Lst (); -list.addLast (javajs.util.P3.new3 (x, y, z)); -nxn.normalize (); -list.addLast (nxn); -return list; -}, "javajs.util.P4,javajs.util.P4"); -c$.getIntersection = Clazz.defineMethod (c$, "getIntersection", -function (pt1, v, plane, ptRet, tempNorm, vTemp) { -javajs.util.Measure.getPlaneProjection (pt1, plane, ptRet, tempNorm); -tempNorm.set (plane.x, plane.y, plane.z); -tempNorm.normalize (); -if (v == null) v = javajs.util.V3.newV (tempNorm); -var l_dot_n = v.dot (tempNorm); -if (Math.abs (l_dot_n) < 0.01) return null; -vTemp.sub2 (ptRet, pt1); -ptRet.scaleAdd2 (vTemp.dot (tempNorm) / l_dot_n, v, pt1); -return ptRet; -}, "javajs.util.P3,javajs.util.V3,javajs.util.P4,javajs.util.P3,javajs.util.V3,javajs.util.V3"); -c$.calculateQuaternionRotation = Clazz.defineMethod (c$, "calculateQuaternionRotation", -function (centerAndPoints, retStddev) { -retStddev[1] = NaN; -var q = new javajs.util.Quat (); -if (centerAndPoints[0].length == 1 || centerAndPoints[0].length != centerAndPoints[1].length) return q; -var n = centerAndPoints[0].length - 1; -if (n < 2) return q; -var Sxx = 0; -var Sxy = 0; -var Sxz = 0; -var Syx = 0; -var Syy = 0; -var Syz = 0; -var Szx = 0; -var Szy = 0; -var Szz = 0; -var ptA = new javajs.util.P3 (); -var ptB = new javajs.util.P3 (); -for (var i = n + 1; --i >= 1; ) { -var aij = centerAndPoints[0][i]; -var bij = centerAndPoints[1][i]; -ptA.sub2 (aij, centerAndPoints[0][0]); -ptB.sub2 (bij, centerAndPoints[0][1]); -Sxx += ptA.x * ptB.x; -Sxy += ptA.x * ptB.y; -Sxz += ptA.x * ptB.z; -Syx += ptA.y * ptB.x; -Syy += ptA.y * ptB.y; -Syz += ptA.y * ptB.z; -Szx += ptA.z * ptB.x; -Szy += ptA.z * ptB.y; -Szz += ptA.z * ptB.z; -} -retStddev[0] = javajs.util.Measure.getRmsd (centerAndPoints, q); -var N = Clazz.newDoubleArray (4, 4, 0); -N[0][0] = Sxx + Syy + Szz; -N[0][1] = N[1][0] = Syz - Szy; -N[0][2] = N[2][0] = Szx - Sxz; -N[0][3] = N[3][0] = Sxy - Syx; -N[1][1] = Sxx - Syy - Szz; -N[1][2] = N[2][1] = Sxy + Syx; -N[1][3] = N[3][1] = Szx + Sxz; -N[2][2] = -Sxx + Syy - Szz; -N[2][3] = N[3][2] = Syz + Szy; -N[3][3] = -Sxx - Syy + Szz; -var v = (javajs.api.Interface.getInterface ("javajs.util.Eigen")).setM (N).getEigenvectorsFloatTransposed ()[3]; -q = javajs.util.Quat.newP4 (javajs.util.P4.new4 (v[1], v[2], v[3], v[0])); -retStddev[1] = javajs.util.Measure.getRmsd (centerAndPoints, q); -return q; -}, "~A,~A"); -c$.getTransformMatrix4 = Clazz.defineMethod (c$, "getTransformMatrix4", -function (ptsA, ptsB, m, centerA) { -var cptsA = javajs.util.Measure.getCenterAndPoints (ptsA); -var cptsB = javajs.util.Measure.getCenterAndPoints (ptsB); -var retStddev = Clazz.newFloatArray (2, 0); -var q = javajs.util.Measure.calculateQuaternionRotation ( Clazz.newArray (-1, [cptsA, cptsB]), retStddev); -var r = q.getMatrix (); -if (centerA == null) r.rotate (cptsA[0]); - else centerA.setT (cptsA[0]); -var t = javajs.util.V3.newVsub (cptsB[0], cptsA[0]); -m.setMV (r, t); -return retStddev[1]; -}, "javajs.util.Lst,javajs.util.Lst,javajs.util.M4,javajs.util.P3"); -c$.getCenterAndPoints = Clazz.defineMethod (c$, "getCenterAndPoints", -function (vPts) { -var n = vPts.size (); -var pts = new Array (n + 1); -pts[0] = new javajs.util.P3 (); -if (n > 0) { -for (var i = 0; i < n; i++) { -pts[0].add (pts[i + 1] = vPts.get (i)); -} -pts[0].scale (1 / n); -}return pts; -}, "javajs.util.Lst"); -c$.getRmsd = Clazz.defineMethod (c$, "getRmsd", -function (centerAndPoints, q) { -var sum2 = 0; -var ptsA = centerAndPoints[0]; -var ptsB = centerAndPoints[1]; -var cA = ptsA[0]; -var cB = ptsB[0]; -var n = ptsA.length - 1; -var ptAnew = new javajs.util.P3 (); -for (var i = n + 1; --i >= 1; ) { -ptAnew.sub2 (ptsA[i], cA); -q.transform2 (ptAnew, ptAnew).add (cB); -sum2 += ptAnew.distanceSquared (ptsB[i]); -} -return Math.sqrt (sum2 / n); -}, "~A,javajs.util.Quat"); -Clazz.defineStatics (c$, -"radiansPerDegree", (0.017453292519943295)); -c$.axisY = c$.prototype.axisY = javajs.util.V3.new3 (0, 1, 0); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.V3"], "javajs.util.Measure", ["java.lang.Float", "javajs.api.Interface", "javajs.util.Lst", "$.P3", "$.P4", "$.Quat"], function () { +c$ = Clazz.declareType (javajs.util, "Measure"); +c$.computeAngle = Clazz.defineMethod (c$, "computeAngle", +function (pointA, pointB, pointC, vectorBA, vectorBC, asDegrees) { +vectorBA.sub2 (pointA, pointB); +vectorBC.sub2 (pointC, pointB); +var angle = vectorBA.angle (vectorBC); +return (asDegrees ? angle / 0.017453292 : angle); +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3,~B"); +c$.computeAngleABC = Clazz.defineMethod (c$, "computeAngleABC", +function (pointA, pointB, pointC, asDegrees) { +var vectorBA = new javajs.util.V3 (); +var vectorBC = new javajs.util.V3 (); +return javajs.util.Measure.computeAngle (pointA, pointB, pointC, vectorBA, vectorBC, asDegrees); +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,~B"); +c$.computeTorsion = Clazz.defineMethod (c$, "computeTorsion", +function (p1, p2, p3, p4, asDegrees) { +var ijx = p1.x - p2.x; +var ijy = p1.y - p2.y; +var ijz = p1.z - p2.z; +var kjx = p3.x - p2.x; +var kjy = p3.y - p2.y; +var kjz = p3.z - p2.z; +var klx = p3.x - p4.x; +var kly = p3.y - p4.y; +var klz = p3.z - p4.z; +var ax = ijy * kjz - ijz * kjy; +var ay = ijz * kjx - ijx * kjz; +var az = ijx * kjy - ijy * kjx; +var cx = kjy * klz - kjz * kly; +var cy = kjz * klx - kjx * klz; +var cz = kjx * kly - kjy * klx; +var ai2 = 1 / (ax * ax + ay * ay + az * az); +var ci2 = 1 / (cx * cx + cy * cy + cz * cz); +var ai = Math.sqrt (ai2); +var ci = Math.sqrt (ci2); +var denom = ai * ci; +var cross = ax * cx + ay * cy + az * cz; +var cosang = cross * denom; +if (cosang > 1) { +cosang = 1; +}if (cosang < -1) { +cosang = -1; +}var torsion = Math.acos (cosang); +var dot = ijx * cx + ijy * cy + ijz * cz; +var absDot = Math.abs (dot); +torsion = (dot / absDot > 0) ? torsion : -torsion; +return (asDegrees ? torsion / 0.017453292 : torsion); +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.T3,~B"); +c$.computeHelicalAxis = Clazz.defineMethod (c$, "computeHelicalAxis", +function (a, b, dq) { +var vab = new javajs.util.V3 (); +vab.sub2 (b, a); +var theta = dq.getTheta (); +var n = dq.getNormal (); +var v_dot_n = vab.dot (n); +if (Math.abs (v_dot_n) < 0.0001) v_dot_n = 0; +var va_prime_d = new javajs.util.V3 (); +va_prime_d.cross (vab, n); +if (va_prime_d.dot (va_prime_d) != 0) va_prime_d.normalize (); +var vda = new javajs.util.V3 (); +var vcb = javajs.util.V3.newV (n); +if (v_dot_n == 0) v_dot_n = 1.4E-45; +vcb.scale (v_dot_n); +vda.sub2 (vcb, vab); +vda.scale (0.5); +va_prime_d.scale (theta == 0 ? 0 : (vda.length () / Math.tan (theta / 2 / 180 * 3.141592653589793))); +var r = javajs.util.V3.newV (va_prime_d); +if (theta != 0) r.add (vda); +var pt_a_prime = javajs.util.P3.newP (a); +pt_a_prime.sub (r); +if (v_dot_n != 1.4E-45) n.scale (v_dot_n); +var pt_b_prime = javajs.util.P3.newP (pt_a_prime); +pt_b_prime.add (n); +theta = javajs.util.Measure.computeTorsion (a, pt_a_prime, pt_b_prime, b, true); +if (Float.isNaN (theta) || r.length () < 0.0001) theta = dq.getThetaDirectedV (n); +var residuesPerTurn = Math.abs (theta == 0 ? 0 : 360 / theta); +var pitch = Math.abs (v_dot_n == 1.4E-45 ? 0 : n.length () * (theta == 0 ? 1 : 360 / theta)); +return Clazz.newArray (-1, [pt_a_prime, n, r, javajs.util.P3.new3 (theta, pitch, residuesPerTurn), pt_b_prime]); +}, "javajs.util.P3,javajs.util.P3,javajs.util.Quat"); +c$.getPlaneThroughPoints = Clazz.defineMethod (c$, "getPlaneThroughPoints", +function (pointA, pointB, pointC, vNorm, vAB, plane) { +var w = javajs.util.Measure.getNormalThroughPoints (pointA, pointB, pointC, vNorm, vAB); +plane.set4 (vNorm.x, vNorm.y, vNorm.z, w); +return plane; +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3,javajs.util.P4"); +c$.getPlaneThroughPoint = Clazz.defineMethod (c$, "getPlaneThroughPoint", +function (pt, normal, plane) { +plane.set4 (normal.x, normal.y, normal.z, -normal.dot (pt)); +}, "javajs.util.T3,javajs.util.V3,javajs.util.P4"); +c$.distanceToPlane = Clazz.defineMethod (c$, "distanceToPlane", +function (plane, pt) { +return (plane == null ? NaN : (plane.dot (pt) + plane.w) / Math.sqrt (plane.dot (plane))); +}, "javajs.util.P4,javajs.util.T3"); +c$.directedDistanceToPlane = Clazz.defineMethod (c$, "directedDistanceToPlane", +function (pt, plane, ptref) { +var f = plane.dot (pt) + plane.w; +var f1 = plane.dot (ptref) + plane.w; +return Math.signum (f1) * f / Math.sqrt (plane.dot (plane)); +}, "javajs.util.P3,javajs.util.P4,javajs.util.P3"); +c$.distanceToPlaneD = Clazz.defineMethod (c$, "distanceToPlaneD", +function (plane, d, pt) { +return (plane == null ? NaN : (plane.dot (pt) + plane.w) / d); +}, "javajs.util.P4,~N,javajs.util.P3"); +c$.distanceToPlaneV = Clazz.defineMethod (c$, "distanceToPlaneV", +function (norm, w, pt) { +return (norm == null ? NaN : (norm.dot (pt) + w) / Math.sqrt (norm.dot (norm))); +}, "javajs.util.V3,~N,javajs.util.P3"); +c$.calcNormalizedNormal = Clazz.defineMethod (c$, "calcNormalizedNormal", +function (pointA, pointB, pointC, vNormNorm, vAB) { +vAB.sub2 (pointB, pointA); +vNormNorm.sub2 (pointC, pointA); +vNormNorm.cross (vAB, vNormNorm); +vNormNorm.normalize (); +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3"); +c$.getDirectedNormalThroughPoints = Clazz.defineMethod (c$, "getDirectedNormalThroughPoints", +function (pointA, pointB, pointC, ptRef, vNorm, vAB) { +var nd = javajs.util.Measure.getNormalThroughPoints (pointA, pointB, pointC, vNorm, vAB); +if (ptRef != null) { +var pt0 = javajs.util.P3.newP (pointA); +pt0.add (vNorm); +var d = pt0.distance (ptRef); +pt0.sub2 (pointA, vNorm); +if (d > pt0.distance (ptRef)) { +vNorm.scale (-1); +nd = -nd; +}}return nd; +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3"); +c$.getNormalThroughPoints = Clazz.defineMethod (c$, "getNormalThroughPoints", +function (pointA, pointB, pointC, vNorm, vTemp) { +javajs.util.Measure.calcNormalizedNormal (pointA, pointB, pointC, vNorm, vTemp); +vTemp.setT (pointA); +return -vTemp.dot (vNorm); +}, "javajs.util.T3,javajs.util.T3,javajs.util.T3,javajs.util.V3,javajs.util.V3"); +c$.getPlaneProjection = Clazz.defineMethod (c$, "getPlaneProjection", +function (pt, plane, ptProj, vNorm) { +var dist = javajs.util.Measure.distanceToPlane (plane, pt); +vNorm.set (plane.x, plane.y, plane.z); +vNorm.normalize (); +vNorm.scale (-dist); +ptProj.add2 (pt, vNorm); +}, "javajs.util.P3,javajs.util.P4,javajs.util.P3,javajs.util.V3"); +c$.getNormalToLine = Clazz.defineMethod (c$, "getNormalToLine", +function (pointA, pointB, vNormNorm) { +vNormNorm.sub2 (pointA, pointB); +vNormNorm.cross (vNormNorm, javajs.util.Measure.axisY); +vNormNorm.normalize (); +if (Float.isNaN (vNormNorm.x)) vNormNorm.set (1, 0, 0); +}, "javajs.util.P3,javajs.util.P3,javajs.util.V3"); +c$.getBisectingPlane = Clazz.defineMethod (c$, "getBisectingPlane", +function (pointA, vAB, ptTemp, vTemp, plane) { +ptTemp.scaleAdd2 (0.5, vAB, pointA); +vTemp.setT (vAB); +vTemp.normalize (); +javajs.util.Measure.getPlaneThroughPoint (ptTemp, vTemp, plane); +}, "javajs.util.P3,javajs.util.V3,javajs.util.T3,javajs.util.V3,javajs.util.P4"); +c$.projectOntoAxis = Clazz.defineMethod (c$, "projectOntoAxis", +function (point, axisA, axisUnitVector, vectorProjection) { +vectorProjection.sub2 (point, axisA); +var projectedLength = vectorProjection.dot (axisUnitVector); +point.scaleAdd2 (projectedLength, axisUnitVector, axisA); +vectorProjection.sub2 (point, axisA); +}, "javajs.util.P3,javajs.util.P3,javajs.util.V3,javajs.util.V3"); +c$.calcBestAxisThroughPoints = Clazz.defineMethod (c$, "calcBestAxisThroughPoints", +function (points, axisA, axisUnitVector, vectorProjection, nTriesMax) { +var nPoints = points.length; +axisA.setT (points[0]); +axisUnitVector.sub2 (points[nPoints - 1], axisA); +axisUnitVector.normalize (); +javajs.util.Measure.calcAveragePointN (points, nPoints, axisA); +var nTries = 0; +while (nTries++ < nTriesMax && javajs.util.Measure.findAxis (points, nPoints, axisA, axisUnitVector, vectorProjection) > 0.001) { +} +var tempA = javajs.util.P3.newP (points[0]); +javajs.util.Measure.projectOntoAxis (tempA, axisA, axisUnitVector, vectorProjection); +axisA.setT (tempA); +}, "~A,javajs.util.P3,javajs.util.V3,javajs.util.V3,~N"); +c$.findAxis = Clazz.defineMethod (c$, "findAxis", +function (points, nPoints, axisA, axisUnitVector, vectorProjection) { +var sumXiYi = new javajs.util.V3 (); +var vTemp = new javajs.util.V3 (); +var pt = new javajs.util.P3 (); +var ptProj = new javajs.util.P3 (); +var a = javajs.util.V3.newV (axisUnitVector); +var sum_Xi2 = 0; +for (var i = nPoints; --i >= 0; ) { +pt.setT (points[i]); +ptProj.setT (pt); +javajs.util.Measure.projectOntoAxis (ptProj, axisA, axisUnitVector, vectorProjection); +vTemp.sub2 (pt, ptProj); +vTemp.cross (vectorProjection, vTemp); +sumXiYi.add (vTemp); +sum_Xi2 += vectorProjection.lengthSquared (); +} +var m = javajs.util.V3.newV (sumXiYi); +m.scale (1 / sum_Xi2); +vTemp.cross (m, axisUnitVector); +axisUnitVector.add (vTemp); +axisUnitVector.normalize (); +vTemp.sub2 (axisUnitVector, a); +return vTemp.length (); +}, "~A,~N,javajs.util.P3,javajs.util.V3,javajs.util.V3"); +c$.calcAveragePoint = Clazz.defineMethod (c$, "calcAveragePoint", +function (pointA, pointB, pointC) { +pointC.set ((pointA.x + pointB.x) / 2, (pointA.y + pointB.y) / 2, (pointA.z + pointB.z) / 2); +}, "javajs.util.P3,javajs.util.P3,javajs.util.P3"); +c$.calcAveragePointN = Clazz.defineMethod (c$, "calcAveragePointN", +function (points, nPoints, averagePoint) { +averagePoint.setT (points[0]); +for (var i = 1; i < nPoints; i++) averagePoint.add (points[i]); + +averagePoint.scale (1 / nPoints); +}, "~A,~N,javajs.util.P3"); +c$.transformPoints = Clazz.defineMethod (c$, "transformPoints", +function (vPts, m4, center) { +var v = new javajs.util.Lst (); +for (var i = 0; i < vPts.size (); i++) { +var pt = javajs.util.P3.newP (vPts.get (i)); +pt.sub (center); +m4.rotTrans (pt); +pt.add (center); +v.addLast (pt); +} +return v; +}, "javajs.util.Lst,javajs.util.M4,javajs.util.P3"); +c$.isInTetrahedron = Clazz.defineMethod (c$, "isInTetrahedron", +function (pt, ptA, ptB, ptC, ptD, plane, vTemp, vTemp2, fullyEnclosed) { +var b = (javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptC, ptD, ptA, vTemp, vTemp2, plane), pt) >= 0); +if (b != (javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptA, ptD, ptB, vTemp, vTemp2, plane), pt) >= 0)) return false; +if (b != (javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptB, ptD, ptC, vTemp, vTemp2, plane), pt) >= 0)) return false; +var d = javajs.util.Measure.distanceToPlane (javajs.util.Measure.getPlaneThroughPoints (ptA, ptB, ptC, vTemp, vTemp2, plane), pt); +if (fullyEnclosed) return (b == (d >= 0)); +var d1 = javajs.util.Measure.distanceToPlane (plane, ptD); +return d1 * d <= 0 || Math.abs (d1) > Math.abs (d); +}, "javajs.util.P3,javajs.util.P3,javajs.util.P3,javajs.util.P3,javajs.util.P3,javajs.util.P4,javajs.util.V3,javajs.util.V3,~B"); +c$.getIntersectionPP = Clazz.defineMethod (c$, "getIntersectionPP", +function (plane1, plane2) { +var a1 = plane1.x; +var b1 = plane1.y; +var c1 = plane1.z; +var d1 = plane1.w; +var a2 = plane2.x; +var b2 = plane2.y; +var c2 = plane2.z; +var d2 = plane2.w; +var norm1 = javajs.util.V3.new3 (a1, b1, c1); +var norm2 = javajs.util.V3.new3 (a2, b2, c2); +var nxn = new javajs.util.V3 (); +nxn.cross (norm1, norm2); +var ax = Math.abs (nxn.x); +var ay = Math.abs (nxn.y); +var az = Math.abs (nxn.z); +var x; +var y; +var z; +var diff; +var type = (ax > ay ? (ax > az ? 1 : 3) : ay > az ? 2 : 3); +switch (type) { +case 1: +x = 0; +diff = (b1 * c2 - b2 * c1); +if (Math.abs (diff) < 0.01) return null; +y = (c1 * d2 - c2 * d1) / diff; +z = (b2 * d1 - d2 * b1) / diff; +break; +case 2: +diff = (a1 * c2 - a2 * c1); +if (Math.abs (diff) < 0.01) return null; +x = (c1 * d2 - c2 * d1) / diff; +y = 0; +z = (a2 * d1 - d2 * a1) / diff; +break; +case 3: +default: +diff = (a1 * b2 - a2 * b1); +if (Math.abs (diff) < 0.01) return null; +x = (b1 * d2 - b2 * d1) / diff; +y = (a2 * d1 - d2 * a1) / diff; +z = 0; +} +var list = new javajs.util.Lst (); +list.addLast (javajs.util.P3.new3 (x, y, z)); +nxn.normalize (); +list.addLast (nxn); +return list; +}, "javajs.util.P4,javajs.util.P4"); +c$.getIntersection = Clazz.defineMethod (c$, "getIntersection", +function (pt1, v, plane, ptRet, tempNorm, vTemp) { +javajs.util.Measure.getPlaneProjection (pt1, plane, ptRet, tempNorm); +tempNorm.set (plane.x, plane.y, plane.z); +tempNorm.normalize (); +if (v == null) v = javajs.util.V3.newV (tempNorm); +var l_dot_n = v.dot (tempNorm); +if (Math.abs (l_dot_n) < 0.01) return null; +vTemp.sub2 (ptRet, pt1); +ptRet.scaleAdd2 (vTemp.dot (tempNorm) / l_dot_n, v, pt1); +return ptRet; +}, "javajs.util.P3,javajs.util.V3,javajs.util.P4,javajs.util.P3,javajs.util.V3,javajs.util.V3"); +c$.calculateQuaternionRotation = Clazz.defineMethod (c$, "calculateQuaternionRotation", +function (centerAndPoints, retStddev) { +retStddev[1] = NaN; +var q = new javajs.util.Quat (); +if (centerAndPoints[0].length == 1 || centerAndPoints[0].length != centerAndPoints[1].length) return q; +var n = centerAndPoints[0].length - 1; +if (n < 2) return q; +var Sxx = 0; +var Sxy = 0; +var Sxz = 0; +var Syx = 0; +var Syy = 0; +var Syz = 0; +var Szx = 0; +var Szy = 0; +var Szz = 0; +var ptA = new javajs.util.P3 (); +var ptB = new javajs.util.P3 (); +for (var i = n + 1; --i >= 1; ) { +var aij = centerAndPoints[0][i]; +var bij = centerAndPoints[1][i]; +ptA.sub2 (aij, centerAndPoints[0][0]); +ptB.sub2 (bij, centerAndPoints[0][1]); +Sxx += ptA.x * ptB.x; +Sxy += ptA.x * ptB.y; +Sxz += ptA.x * ptB.z; +Syx += ptA.y * ptB.x; +Syy += ptA.y * ptB.y; +Syz += ptA.y * ptB.z; +Szx += ptA.z * ptB.x; +Szy += ptA.z * ptB.y; +Szz += ptA.z * ptB.z; +} +retStddev[0] = javajs.util.Measure.getRmsd (centerAndPoints, q); +var N = Clazz.newDoubleArray (4, 4, 0); +N[0][0] = Sxx + Syy + Szz; +N[0][1] = N[1][0] = Syz - Szy; +N[0][2] = N[2][0] = Szx - Sxz; +N[0][3] = N[3][0] = Sxy - Syx; +N[1][1] = Sxx - Syy - Szz; +N[1][2] = N[2][1] = Sxy + Syx; +N[1][3] = N[3][1] = Szx + Sxz; +N[2][2] = -Sxx + Syy - Szz; +N[2][3] = N[3][2] = Syz + Szy; +N[3][3] = -Sxx - Syy + Szz; +var v = (javajs.api.Interface.getInterface ("javajs.util.Eigen")).setM (N).getEigenvectorsFloatTransposed ()[3]; +q = javajs.util.Quat.newP4 (javajs.util.P4.new4 (v[1], v[2], v[3], v[0])); +retStddev[1] = javajs.util.Measure.getRmsd (centerAndPoints, q); +return q; +}, "~A,~A"); +c$.getTransformMatrix4 = Clazz.defineMethod (c$, "getTransformMatrix4", +function (ptsA, ptsB, m, centerA) { +var cptsA = javajs.util.Measure.getCenterAndPoints (ptsA); +var cptsB = javajs.util.Measure.getCenterAndPoints (ptsB); +var retStddev = Clazz.newFloatArray (2, 0); +var q = javajs.util.Measure.calculateQuaternionRotation ( Clazz.newArray (-1, [cptsA, cptsB]), retStddev); +var r = q.getMatrix (); +if (centerA == null) r.rotate (cptsA[0]); + else centerA.setT (cptsA[0]); +var t = javajs.util.V3.newVsub (cptsB[0], cptsA[0]); +m.setMV (r, t); +return retStddev[1]; +}, "javajs.util.Lst,javajs.util.Lst,javajs.util.M4,javajs.util.P3"); +c$.getCenterAndPoints = Clazz.defineMethod (c$, "getCenterAndPoints", +function (vPts) { +var n = vPts.size (); +var pts = new Array (n + 1); +pts[0] = new javajs.util.P3 (); +if (n > 0) { +for (var i = 0; i < n; i++) { +pts[0].add (pts[i + 1] = vPts.get (i)); +} +pts[0].scale (1 / n); +}return pts; +}, "javajs.util.Lst"); +c$.getRmsd = Clazz.defineMethod (c$, "getRmsd", +function (centerAndPoints, q) { +var sum2 = 0; +var ptsA = centerAndPoints[0]; +var ptsB = centerAndPoints[1]; +var cA = ptsA[0]; +var cB = ptsB[0]; +var n = ptsA.length - 1; +var ptAnew = new javajs.util.P3 (); +for (var i = n + 1; --i >= 1; ) { +ptAnew.sub2 (ptsA[i], cA); +q.transform2 (ptAnew, ptAnew).add (cB); +sum2 += ptAnew.distanceSquared (ptsB[i]); +} +return Math.sqrt (sum2 / n); +}, "~A,javajs.util.Quat"); +Clazz.defineStatics (c$, +"radiansPerDegree", (0.017453292519943295)); +c$.axisY = c$.prototype.axisY = javajs.util.V3.new3 (0, 1, 0); +}); diff --git a/bin/javajs/util/OC.js b/bin/javajs/util/OC.js index f720165..76f148a 100644 --- a/bin/javajs/util/OC.js +++ b/bin/javajs/util/OC.js @@ -1,236 +1,236 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["java.io.OutputStream"], "javajs.util.OC", ["java.io.BufferedWriter", "$.ByteArrayOutputStream", "$.OutputStreamWriter", "javajs.util.Base64", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.bytePoster = null; -this.fileName = null; -this.bw = null; -this.isLocalFile = false; -this.byteCount = 0; -this.isCanceled = false; -this.closed = false; -this.os = null; -this.sb = null; -this.type = null; -this.$isBase64 = false; -this.os0 = null; -this.bytes = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "OC", java.io.OutputStream); -Clazz.defineMethod (c$, "setParams", -function (bytePoster, fileName, asWriter, os) { -this.bytePoster = bytePoster; -this.fileName = fileName; -this.$isBase64 = ";base64,".equals (fileName); -if (this.$isBase64) { -fileName = null; -this.os0 = os; -os = null; -}this.os = os; -this.isLocalFile = (fileName != null && !javajs.util.OC.isRemote (fileName)); -if (asWriter && !this.$isBase64 && os != null) this.bw = new java.io.BufferedWriter ( new java.io.OutputStreamWriter (os)); -return this; -}, "javajs.api.BytePoster,~S,~B,java.io.OutputStream"); -Clazz.defineMethod (c$, "setBytes", -function (b) { -this.bytes = b; -return this; -}, "~A"); -Clazz.defineMethod (c$, "getFileName", -function () { -return this.fileName; -}); -Clazz.defineMethod (c$, "getName", -function () { -return (this.fileName == null ? null : this.fileName.substring (this.fileName.lastIndexOf ("/") + 1)); -}); -Clazz.defineMethod (c$, "getByteCount", -function () { -return this.byteCount; -}); -Clazz.defineMethod (c$, "setType", -function (type) { -this.type = type; -}, "~S"); -Clazz.defineMethod (c$, "getType", -function () { -return this.type; -}); -Clazz.defineMethod (c$, "append", -function (s) { -try { -if (this.bw != null) { -this.bw.write (s); -} else if (this.os == null) { -if (this.sb == null) this.sb = new javajs.util.SB (); -this.sb.append (s); -} else { -var b = s.getBytes (); -this.os.write (b, 0, b.length); -this.byteCount += b.length; -return this; -}} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -this.byteCount += s.length; -return this; -}, "~S"); -Clazz.defineMethod (c$, "reset", -function () { -this.sb = null; -this.initOS (); -}); -Clazz.defineMethod (c$, "initOS", -($fz = function () { -if (this.sb != null) { -var s = this.sb.toString (); -this.reset (); -this.append (s); -return; -}try { -{ -this.os = null; -}if (this.os == null) this.os = new java.io.ByteArrayOutputStream (); -if (this.bw != null) { -this.bw.close (); -this.bw = new java.io.BufferedWriter ( new java.io.OutputStreamWriter (this.os)); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -this.byteCount = 0; -}, $fz.isPrivate = true, $fz)); -Clazz.overrideMethod (c$, "write", -function (buf, i, len) { -if (this.os == null) this.initOS (); -try { -this.os.write (buf, i, len); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -this.byteCount += len; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "writeByteAsInt", -function (b) { -if (this.os == null) this.initOS (); -{ -this.os.writeByteAsInt(b); -}this.byteCount++; -}, "~N"); -Clazz.defineMethod (c$, "cancel", -function () { -this.isCanceled = true; -this.closeChannel (); -}); -Clazz.defineMethod (c$, "closeChannel", -function () { -if (this.closed) return null; -try { -if (this.bw != null) { -this.bw.flush (); -this.bw.close (); -} else if (this.os != null) { -this.os.flush (); -this.os.close (); -}if (this.os0 != null && this.isCanceled) { -this.os0.flush (); -this.os0.close (); -}} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -if (this.isCanceled) { -this.closed = true; -return null; -}if (this.fileName == null) { -if (this.$isBase64) { -var s = this.getBase64 (); -if (this.os0 != null) { -this.os = this.os0; -this.append (s); -}this.sb = new javajs.util.SB (); -this.sb.append (s); -this.$isBase64 = false; -return this.closeChannel (); -}return (this.sb == null ? null : this.sb.toString ()); -}this.closed = true; -var jmol = null; -var _function = null; -{ -jmol = Jmol; _function = (typeof this.fileName == "function" ? -this.fileName : null); -}if (jmol != null) { -var data = (this.sb == null ? this.toByteArray () : this.sb.toString ()); -if (_function == null) jmol._doAjax (this.fileName, null, data); - else jmol._apply (this.fileName, data); -}return null; -}); -Clazz.defineMethod (c$, "isBase64", -function () { -return this.$isBase64; -}); -Clazz.defineMethod (c$, "getBase64", -function () { -return javajs.util.Base64.getBase64 (this.toByteArray ()).toString (); -}); -Clazz.defineMethod (c$, "toByteArray", -function () { -return (this.bytes != null ? this.bytes : Clazz.instanceOf (this.os, java.io.ByteArrayOutputStream) ? (this.os).toByteArray () : null); -}); -Clazz.defineMethod (c$, "close", -function () { -this.closeChannel (); -}); -Clazz.overrideMethod (c$, "toString", -function () { -if (this.bw != null) try { -this.bw.flush (); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -if (this.sb != null) return this.closeChannel (); -return this.byteCount + " bytes"; -}); -Clazz.defineMethod (c$, "postByteArray", -($fz = function () { -var bytes = (this.sb == null ? this.toByteArray () : this.sb.toString ().getBytes ()); -return this.bytePoster.postByteArray (this.fileName, bytes); -}, $fz.isPrivate = true, $fz)); -c$.isRemote = Clazz.defineMethod (c$, "isRemote", -function (fileName) { -if (fileName == null) return false; -var itype = javajs.util.OC.urlTypeIndex (fileName); -return (itype >= 0 && itype != 4); -}, "~S"); -c$.isLocal = Clazz.defineMethod (c$, "isLocal", -function (fileName) { -if (fileName == null) return false; -var itype = javajs.util.OC.urlTypeIndex (fileName); -return (itype < 0 || itype == 4); -}, "~S"); -c$.urlTypeIndex = Clazz.defineMethod (c$, "urlTypeIndex", -function (name) { -if (name == null) return -2; -for (var i = 0; i < javajs.util.OC.urlPrefixes.length; ++i) { -if (name.startsWith (javajs.util.OC.urlPrefixes[i])) { -return i; -}} -return -1; -}, "~S"); -Clazz.defineStatics (c$, -"urlPrefixes", Clazz.newArray (-1, ["http:", "https:", "sftp:", "ftp:", "file:"]), -"URL_LOCAL", 4); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["java.io.OutputStream"], "javajs.util.OC", ["java.io.BufferedWriter", "$.ByteArrayOutputStream", "$.OutputStreamWriter", "javajs.util.Base64", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.bytePoster = null; +this.fileName = null; +this.bw = null; +this.isLocalFile = false; +this.byteCount = 0; +this.isCanceled = false; +this.closed = false; +this.os = null; +this.sb = null; +this.type = null; +this.$isBase64 = false; +this.os0 = null; +this.bytes = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "OC", java.io.OutputStream); +Clazz.defineMethod (c$, "setParams", +function (bytePoster, fileName, asWriter, os) { +this.bytePoster = bytePoster; +this.fileName = fileName; +this.$isBase64 = ";base64,".equals (fileName); +if (this.$isBase64) { +fileName = null; +this.os0 = os; +os = null; +}this.os = os; +this.isLocalFile = (fileName != null && !javajs.util.OC.isRemote (fileName)); +if (asWriter && !this.$isBase64 && os != null) this.bw = new java.io.BufferedWriter ( new java.io.OutputStreamWriter (os)); +return this; +}, "javajs.api.BytePoster,~S,~B,java.io.OutputStream"); +Clazz.defineMethod (c$, "setBytes", +function (b) { +this.bytes = b; +return this; +}, "~A"); +Clazz.defineMethod (c$, "getFileName", +function () { +return this.fileName; +}); +Clazz.defineMethod (c$, "getName", +function () { +return (this.fileName == null ? null : this.fileName.substring (this.fileName.lastIndexOf ("/") + 1)); +}); +Clazz.defineMethod (c$, "getByteCount", +function () { +return this.byteCount; +}); +Clazz.defineMethod (c$, "setType", +function (type) { +this.type = type; +}, "~S"); +Clazz.defineMethod (c$, "getType", +function () { +return this.type; +}); +Clazz.defineMethod (c$, "append", +function (s) { +try { +if (this.bw != null) { +this.bw.write (s); +} else if (this.os == null) { +if (this.sb == null) this.sb = new javajs.util.SB (); +this.sb.append (s); +} else { +var b = s.getBytes (); +this.os.write (b, 0, b.length); +this.byteCount += b.length; +return this; +}} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +this.byteCount += s.length; +return this; +}, "~S"); +Clazz.defineMethod (c$, "reset", +function () { +this.sb = null; +this.initOS (); +}); +Clazz.defineMethod (c$, "initOS", +($fz = function () { +if (this.sb != null) { +var s = this.sb.toString (); +this.reset (); +this.append (s); +return; +}try { +{ +this.os = null; +}if (this.os == null) this.os = new java.io.ByteArrayOutputStream (); +if (this.bw != null) { +this.bw.close (); +this.bw = new java.io.BufferedWriter ( new java.io.OutputStreamWriter (this.os)); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +this.byteCount = 0; +}, $fz.isPrivate = true, $fz)); +Clazz.overrideMethod (c$, "write", +function (buf, i, len) { +if (this.os == null) this.initOS (); +try { +this.os.write (buf, i, len); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +this.byteCount += len; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "writeByteAsInt", +function (b) { +if (this.os == null) this.initOS (); +{ +this.os.writeByteAsInt(b); +}this.byteCount++; +}, "~N"); +Clazz.defineMethod (c$, "cancel", +function () { +this.isCanceled = true; +this.closeChannel (); +}); +Clazz.defineMethod (c$, "closeChannel", +function () { +if (this.closed) return null; +try { +if (this.bw != null) { +this.bw.flush (); +this.bw.close (); +} else if (this.os != null) { +this.os.flush (); +this.os.close (); +}if (this.os0 != null && this.isCanceled) { +this.os0.flush (); +this.os0.close (); +}} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +if (this.isCanceled) { +this.closed = true; +return null; +}if (this.fileName == null) { +if (this.$isBase64) { +var s = this.getBase64 (); +if (this.os0 != null) { +this.os = this.os0; +this.append (s); +}this.sb = new javajs.util.SB (); +this.sb.append (s); +this.$isBase64 = false; +return this.closeChannel (); +}return (this.sb == null ? null : this.sb.toString ()); +}this.closed = true; +var jmol = null; +var _function = null; +{ +jmol = Jmol; _function = (typeof this.fileName == "function" ? +this.fileName : null); +}if (jmol != null) { +var data = (this.sb == null ? this.toByteArray () : this.sb.toString ()); +if (_function == null) jmol._doAjax (this.fileName, null, data); + else jmol._apply (this.fileName, data); +}return null; +}); +Clazz.defineMethod (c$, "isBase64", +function () { +return this.$isBase64; +}); +Clazz.defineMethod (c$, "getBase64", +function () { +return javajs.util.Base64.getBase64 (this.toByteArray ()).toString (); +}); +Clazz.defineMethod (c$, "toByteArray", +function () { +return (this.bytes != null ? this.bytes : Clazz.instanceOf (this.os, java.io.ByteArrayOutputStream) ? (this.os).toByteArray () : null); +}); +Clazz.defineMethod (c$, "close", +function () { +this.closeChannel (); +}); +Clazz.overrideMethod (c$, "toString", +function () { +if (this.bw != null) try { +this.bw.flush (); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +if (this.sb != null) return this.closeChannel (); +return this.byteCount + " bytes"; +}); +Clazz.defineMethod (c$, "postByteArray", +($fz = function () { +var bytes = (this.sb == null ? this.toByteArray () : this.sb.toString ().getBytes ()); +return this.bytePoster.postByteArray (this.fileName, bytes); +}, $fz.isPrivate = true, $fz)); +c$.isRemote = Clazz.defineMethod (c$, "isRemote", +function (fileName) { +if (fileName == null) return false; +var itype = javajs.util.OC.urlTypeIndex (fileName); +return (itype >= 0 && itype != 4); +}, "~S"); +c$.isLocal = Clazz.defineMethod (c$, "isLocal", +function (fileName) { +if (fileName == null) return false; +var itype = javajs.util.OC.urlTypeIndex (fileName); +return (itype < 0 || itype == 4); +}, "~S"); +c$.urlTypeIndex = Clazz.defineMethod (c$, "urlTypeIndex", +function (name) { +if (name == null) return -2; +for (var i = 0; i < javajs.util.OC.urlPrefixes.length; ++i) { +if (name.startsWith (javajs.util.OC.urlPrefixes[i])) { +return i; +}} +return -1; +}, "~S"); +Clazz.defineStatics (c$, +"urlPrefixes", Clazz.newArray (-1, ["http:", "https:", "sftp:", "ftp:", "file:"]), +"URL_LOCAL", 4); +}); diff --git a/bin/javajs/util/P3.js b/bin/javajs/util/P3.js index b44211d..cc292cd 100644 --- a/bin/javajs/util/P3.js +++ b/bin/javajs/util/P3.js @@ -1,26 +1,26 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.T3"], "javajs.util.P3", null, function () { -c$ = Clazz.declareType (javajs.util, "P3", javajs.util.T3); -c$.newP = Clazz.defineMethod (c$, "newP", -function (t) { -var p = new javajs.util.P3 (); -p.x = t.x; -p.y = t.y; -p.z = t.z; -return p; -}, "javajs.util.T3"); -c$.getUnlikely = Clazz.defineMethod (c$, "getUnlikely", -function () { -return (javajs.util.P3.unlikely == null ? javajs.util.P3.unlikely = javajs.util.P3.new3 (3.141592653589793, 2.718281828459045, (8.539734222673566)) : javajs.util.P3.unlikely); -}); -c$.new3 = Clazz.defineMethod (c$, "new3", -function (x, y, z) { -var p = new javajs.util.P3 (); -p.x = x; -p.y = y; -p.z = z; -return p; -}, "~N,~N,~N"); -Clazz.defineStatics (c$, -"unlikely", null); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.T3"], "javajs.util.P3", null, function () { +c$ = Clazz.declareType (javajs.util, "P3", javajs.util.T3); +c$.newP = Clazz.defineMethod (c$, "newP", +function (t) { +var p = new javajs.util.P3 (); +p.x = t.x; +p.y = t.y; +p.z = t.z; +return p; +}, "javajs.util.T3"); +c$.getUnlikely = Clazz.defineMethod (c$, "getUnlikely", +function () { +return (javajs.util.P3.unlikely == null ? javajs.util.P3.unlikely = javajs.util.P3.new3 (3.141592653589793, 2.718281828459045, (8.539734222673566)) : javajs.util.P3.unlikely); +}); +c$.new3 = Clazz.defineMethod (c$, "new3", +function (x, y, z) { +var p = new javajs.util.P3 (); +p.x = x; +p.y = y; +p.z = z; +return p; +}, "~N,~N,~N"); +Clazz.defineStatics (c$, +"unlikely", null); +}); diff --git a/bin/javajs/util/P3i.js b/bin/javajs/util/P3i.js index e4e31b5..4888909 100644 --- a/bin/javajs/util/P3i.js +++ b/bin/javajs/util/P3i.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.T3i"], "javajs.util.P3i", null, function () { -c$ = Clazz.declareType (javajs.util, "P3i", javajs.util.T3i); -c$.new3 = Clazz.defineMethod (c$, "new3", -function (x, y, z) { -var pt = new javajs.util.P3i (); -pt.x = x; -pt.y = y; -pt.z = z; -return pt; -}, "~N,~N,~N"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.T3i"], "javajs.util.P3i", null, function () { +c$ = Clazz.declareType (javajs.util, "P3i", javajs.util.T3i); +c$.new3 = Clazz.defineMethod (c$, "new3", +function (x, y, z) { +var pt = new javajs.util.P3i (); +pt.x = x; +pt.y = y; +pt.z = z; +return pt; +}, "~N,~N,~N"); +}); diff --git a/bin/javajs/util/P4.js b/bin/javajs/util/P4.js index 2afde3c..c317cd6 100644 --- a/bin/javajs/util/P4.js +++ b/bin/javajs/util/P4.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.T4"], "javajs.util.P4", null, function () { -c$ = Clazz.declareType (javajs.util, "P4", javajs.util.T4); -c$.new4 = Clazz.defineMethod (c$, "new4", -function (x, y, z, w) { -var pt = new javajs.util.P4 (); -pt.set4 (x, y, z, w); -return pt; -}, "~N,~N,~N,~N"); -c$.newPt = Clazz.defineMethod (c$, "newPt", -function (value) { -var pt = new javajs.util.P4 (); -pt.set4 (value.x, value.y, value.z, value.w); -return pt; -}, "javajs.util.P4"); -Clazz.defineMethod (c$, "distance4", -function (p1) { -var dx = this.x - p1.x; -var dy = this.y - p1.y; -var dz = this.z - p1.z; -var dw = this.w - p1.w; -return Math.sqrt (dx * dx + dy * dy + dz * dz + dw * dw); -}, "javajs.util.P4"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.T4"], "javajs.util.P4", null, function () { +c$ = Clazz.declareType (javajs.util, "P4", javajs.util.T4); +c$.new4 = Clazz.defineMethod (c$, "new4", +function (x, y, z, w) { +var pt = new javajs.util.P4 (); +pt.set4 (x, y, z, w); +return pt; +}, "~N,~N,~N,~N"); +c$.newPt = Clazz.defineMethod (c$, "newPt", +function (value) { +var pt = new javajs.util.P4 (); +pt.set4 (value.x, value.y, value.z, value.w); +return pt; +}, "javajs.util.P4"); +Clazz.defineMethod (c$, "distance4", +function (p1) { +var dx = this.x - p1.x; +var dy = this.y - p1.y; +var dz = this.z - p1.z; +var dw = this.w - p1.w; +return Math.sqrt (dx * dx + dy * dy + dz * dz + dw * dw); +}, "javajs.util.P4"); +}); diff --git a/bin/javajs/util/PT.js b/bin/javajs/util/PT.js index 2bfe06d..b20715c 100644 --- a/bin/javajs/util/PT.js +++ b/bin/javajs/util/PT.js @@ -1,945 +1,945 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.PT", ["java.lang.Boolean", "$.Double", "$.Float", "$.Number", "java.util.Map", "javajs.api.JSONEncodable", "javajs.util.AU", "$.DF", "$.Lst", "$.M34", "$.M4", "$.SB"], function () { -c$ = Clazz.declareType (javajs.util, "PT"); -c$.parseInt = Clazz.defineMethod (c$, "parseInt", -function (str) { -return javajs.util.PT.parseIntNext (str, Clazz.newIntArray (-1, [0])); -}, "~S"); -c$.parseIntNext = Clazz.defineMethod (c$, "parseIntNext", -function (str, next) { -var cch = str.length; -if (next[0] < 0 || next[0] >= cch) return -2147483648; -return javajs.util.PT.parseIntChecked (str, cch, next); -}, "~S,~A"); -c$.parseIntChecked = Clazz.defineMethod (c$, "parseIntChecked", -function (str, ichMax, next) { -var digitSeen = false; -var value = 0; -var ich = next[0]; -if (ich < 0) return -2147483648; -var ch; -while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; - -var negative = false; -if (ich < ichMax && str.charCodeAt (ich) == 45) { -negative = true; -++ich; -}while (ich < ichMax && (ch = str.charCodeAt (ich)) >= 48 && ch <= 57) { -value = value * 10 + (ch - 48); -digitSeen = true; -++ich; -} -if (!digitSeen) value = -2147483648; - else if (negative) value = -value; -next[0] = ich; -return value; -}, "~S,~N,~A"); -c$.isWhiteSpace = Clazz.defineMethod (c$, "isWhiteSpace", -function (str, ich) { -var ch; -return (ich >= 0 && ((ch = str.charAt (ich)) == ' ' || ch == '\t' || ch == '\n')); -}, "~S,~N"); -c$.parseFloatChecked = Clazz.defineMethod (c$, "parseFloatChecked", -function (str, ichMax, next, isStrict) { -var digitSeen = false; -var ich = next[0]; -if (isStrict && str.indexOf ('\n') != str.lastIndexOf ('\n')) return NaN; -while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; - -var negative = false; -if (ich < ichMax && str.charAt (ich) == '-') { -++ich; -negative = true; -}var ch = 0; -var ival = 0; -var ival2 = 0; -while (ich < ichMax && (ch = str.charCodeAt (ich)) >= 48 && ch <= 57) { -ival = (ival * 10) + (ch - 48) * 1; -++ich; -digitSeen = true; -} -var isDecimal = false; -var iscale = 0; -var nzero = (ival == 0 ? -1 : 0); -if (ch == 46) { -isDecimal = true; -while (++ich < ichMax && (ch = str.charCodeAt (ich)) >= 48 && ch <= 57) { -digitSeen = true; -if (nzero < 0) { -if (ch == 48) { -nzero--; -continue; -}nzero = -nzero; -}if (iscale < javajs.util.PT.decimalScale.length) { -ival2 = (ival2 * 10) + (ch - 48) * 1; -iscale++; -}} -}var value; -if (!digitSeen) { -value = NaN; -} else if (ival2 > 0) { -value = ival2 * javajs.util.PT.decimalScale[iscale - 1]; -if (nzero > 1) { -if (nzero - 2 < javajs.util.PT.decimalScale.length) { -value *= javajs.util.PT.decimalScale[nzero - 2]; -} else { -value *= Math.pow (10, 1 - nzero); -}} else { -value += ival; -}} else { -value = ival; -}var isExponent = false; -if (ich < ichMax && (ch == 69 || ch == 101 || ch == 68)) { -isExponent = true; -if (++ich >= ichMax) return NaN; -ch = str.charCodeAt (ich); -if ((ch == 43) && (++ich >= ichMax)) return NaN; -next[0] = ich; -var exponent = javajs.util.PT.parseIntChecked (str, ichMax, next); -if (exponent == -2147483648) return NaN; -if (exponent > 0 && exponent <= javajs.util.PT.tensScale.length) value *= javajs.util.PT.tensScale[exponent - 1]; - else if (exponent < 0 && -exponent <= javajs.util.PT.decimalScale.length) value *= javajs.util.PT.decimalScale[-exponent - 1]; - else if (exponent != 0) value *= Math.pow (10, exponent); -} else { -next[0] = ich; -}if (negative) value = -value; -if (value == Infinity) value = 3.4028235E38; -return (!isStrict || (!isExponent || isDecimal) && javajs.util.PT.checkTrailingText (str, next[0], ichMax) ? value : NaN); -}, "~S,~N,~A,~B"); -c$.checkTrailingText = Clazz.defineMethod (c$, "checkTrailingText", -function (str, ich, ichMax) { -var ch; -while (ich < ichMax && (javajs.util.PT.isWhitespace (ch = str.charAt (ich)) || ch == ';')) ++ich; - -return (ich == ichMax); -}, "~S,~N,~N"); -c$.parseFloatArray = Clazz.defineMethod (c$, "parseFloatArray", -function (str) { -return javajs.util.PT.parseFloatArrayNext (str, Clazz.newIntArray (1, 0), null, null, null); -}, "~S"); -c$.parseFloatArrayInfested = Clazz.defineMethod (c$, "parseFloatArrayInfested", -function (tokens, data) { -var len = data.length; -var nTokens = tokens.length; -var n = 0; -var max = 0; -for (var i = 0; i >= 0 && i < len && n < nTokens; i++) { -var f; -while (Float.isNaN (f = javajs.util.PT.parseFloat (tokens[n++])) && n < nTokens) { -} -if (!Float.isNaN (f)) data[(max = i)] = f; -if (n == nTokens) break; -} -return max + 1; -}, "~A,~A"); -c$.parseFloatArrayNext = Clazz.defineMethod (c$, "parseFloatArrayNext", -function (str, next, f, strStart, strEnd) { -var n = 0; -var pt = next[0]; -if (pt >= 0) { -if (strStart != null) { -var p = str.indexOf (strStart, pt); -if (p >= 0) next[0] = p + strStart.length; -}str = str.substring (next[0]); -pt = (strEnd == null ? -1 : str.indexOf (strEnd)); -if (pt < 0) pt = str.length; - else str = str.substring (0, pt); -next[0] += pt + 1; -var tokens = javajs.util.PT.getTokens (str); -if (f == null) f = Clazz.newFloatArray (tokens.length, 0); -n = javajs.util.PT.parseFloatArrayInfested (tokens, f); -}if (f == null) return Clazz.newFloatArray (0, 0); -for (var i = n; i < f.length; i++) f[i] = NaN; - -return f; -}, "~S,~A,~A,~S,~S"); -c$.parseFloatRange = Clazz.defineMethod (c$, "parseFloatRange", -function (str, ichMax, next) { -var cch = str.length; -if (ichMax > cch) ichMax = cch; -if (next[0] < 0 || next[0] >= ichMax) return NaN; -return javajs.util.PT.parseFloatChecked (str, ichMax, next, false); -}, "~S,~N,~A"); -c$.parseFloatNext = Clazz.defineMethod (c$, "parseFloatNext", -function (str, next) { -var cch = (str == null ? -1 : str.length); -return (next[0] < 0 || next[0] >= cch ? NaN : javajs.util.PT.parseFloatChecked (str, cch, next, false)); -}, "~S,~A"); -c$.parseFloatStrict = Clazz.defineMethod (c$, "parseFloatStrict", -function (str) { -var cch = str.length; -if (cch == 0) return NaN; -return javajs.util.PT.parseFloatChecked (str, cch, Clazz.newIntArray (-1, [0]), true); -}, "~S"); -c$.parseFloat = Clazz.defineMethod (c$, "parseFloat", -function (str) { -return javajs.util.PT.parseFloatNext (str, Clazz.newIntArray (-1, [0])); -}, "~S"); -c$.parseIntRadix = Clazz.defineMethod (c$, "parseIntRadix", -function (s, i) { -{ -return Integer.parseIntRadix(s, i); -}}, "~S,~N"); -c$.getTokens = Clazz.defineMethod (c$, "getTokens", -function (line) { -return javajs.util.PT.getTokensAt (line, 0); -}, "~S"); -c$.parseToken = Clazz.defineMethod (c$, "parseToken", -function (str) { -return javajs.util.PT.parseTokenNext (str, Clazz.newIntArray (-1, [0])); -}, "~S"); -c$.parseTrimmed = Clazz.defineMethod (c$, "parseTrimmed", -function (str) { -return javajs.util.PT.parseTrimmedRange (str, 0, str.length); -}, "~S"); -c$.parseTrimmedAt = Clazz.defineMethod (c$, "parseTrimmedAt", -function (str, ichStart) { -return javajs.util.PT.parseTrimmedRange (str, ichStart, str.length); -}, "~S,~N"); -c$.parseTrimmedRange = Clazz.defineMethod (c$, "parseTrimmedRange", -function (str, ichStart, ichMax) { -var cch = str.length; -if (ichMax < cch) cch = ichMax; -if (cch < ichStart) return ""; -return javajs.util.PT.parseTrimmedChecked (str, ichStart, cch); -}, "~S,~N,~N"); -c$.getTokensAt = Clazz.defineMethod (c$, "getTokensAt", -function (line, ich) { -if (line == null) return null; -var cchLine = line.length; -if (ich < 0 || ich > cchLine) return null; -var tokenCount = javajs.util.PT.countTokens (line, ich); -var tokens = new Array (tokenCount); -var next = Clazz.newIntArray (1, 0); -next[0] = ich; -for (var i = 0; i < tokenCount; ++i) tokens[i] = javajs.util.PT.parseTokenChecked (line, cchLine, next); - -return tokens; -}, "~S,~N"); -c$.countChar = Clazz.defineMethod (c$, "countChar", -function (line, c) { -var tokenCount = 0; -var pt = -1; -while ((pt = line.indexOf (c, pt + 1)) >= 0) tokenCount++; - -return tokenCount; -}, "~S,~S"); -c$.countTokens = Clazz.defineMethod (c$, "countTokens", -function (line, ich) { -var tokenCount = 0; -if (line != null) { -var ichMax = line.length; -while (true) { -while (ich < ichMax && javajs.util.PT.isWhiteSpace (line, ich)) ++ich; - -if (ich == ichMax) break; -++tokenCount; -do { -++ich; -} while (ich < ichMax && !javajs.util.PT.isWhiteSpace (line, ich)); -} -}return tokenCount; -}, "~S,~N"); -c$.parseTokenNext = Clazz.defineMethod (c$, "parseTokenNext", -function (str, next) { -var cch = str.length; -return (next[0] < 0 || next[0] >= cch ? null : javajs.util.PT.parseTokenChecked (str, cch, next)); -}, "~S,~A"); -c$.parseTokenRange = Clazz.defineMethod (c$, "parseTokenRange", -function (str, ichMax, next) { -var cch = str.length; -if (ichMax > cch) ichMax = cch; -return (next[0] < 0 || next[0] >= ichMax ? null : javajs.util.PT.parseTokenChecked (str, ichMax, next)); -}, "~S,~N,~A"); -c$.parseTokenChecked = Clazz.defineMethod (c$, "parseTokenChecked", -function (str, ichMax, next) { -var ich = next[0]; -while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; - -var ichNonWhite = ich; -while (ich < ichMax && !javajs.util.PT.isWhiteSpace (str, ich)) ++ich; - -next[0] = ich; -return (ichNonWhite == ich ? null : str.substring (ichNonWhite, ich)); -}, "~S,~N,~A"); -c$.parseTrimmedChecked = Clazz.defineMethod (c$, "parseTrimmedChecked", -function (str, ich, ichMax) { -while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; - -var ichLast = ichMax - 1; -while (ichLast >= ich && javajs.util.PT.isWhiteSpace (str, ichLast)) --ichLast; - -return (ichLast < ich ? "" : str.substring (ich, ichLast + 1)); -}, "~S,~N,~N"); -c$.dVal = Clazz.defineMethod (c$, "dVal", -function (s) { -{ -if(s==null) -throw new NumberFormatException("null"); -var d=parseFloat(s); -if(isNaN(d)) -throw new NumberFormatException("Not a Number : "+s); -return d -}}, "~S"); -c$.fVal = Clazz.defineMethod (c$, "fVal", -function (s) { -{ -return this.dVal(s); -}}, "~S"); -c$.parseIntRange = Clazz.defineMethod (c$, "parseIntRange", -function (str, ichMax, next) { -var cch = str.length; -if (ichMax > cch) ichMax = cch; -return (next[0] < 0 || next[0] >= ichMax ? -2147483648 : javajs.util.PT.parseIntChecked (str, ichMax, next)); -}, "~S,~N,~A"); -c$.parseFloatArrayData = Clazz.defineMethod (c$, "parseFloatArrayData", -function (tokens, data) { -javajs.util.PT.parseFloatArrayDataN (tokens, data, data.length); -}, "~A,~A"); -c$.parseFloatArrayDataN = Clazz.defineMethod (c$, "parseFloatArrayDataN", -function (tokens, data, nData) { -for (var i = nData; --i >= 0; ) data[i] = (i >= tokens.length ? NaN : javajs.util.PT.parseFloat (tokens[i])); - -}, "~A,~A,~N"); -c$.split = Clazz.defineMethod (c$, "split", -function (text, run) { -if (text.length == 0) return new Array (0); -var n = 1; -var i = text.indexOf (run); -var lines; -var runLen = run.length; -if (i < 0 || runLen == 0) { -lines = new Array (1); -lines[0] = text; -return lines; -}var len = text.length - runLen; -for (; i >= 0 && i < len; n++) i = text.indexOf (run, i + runLen); - -lines = new Array (n); -i = 0; -var ipt = 0; -var pt = 0; -for (; (ipt = text.indexOf (run, i)) >= 0 && pt + 1 < n; ) { -lines[pt++] = text.substring (i, ipt); -i = ipt + runLen; -} -if (text.indexOf (run, len) != len) len += runLen; -lines[pt] = text.substring (i, len); -return lines; -}, "~S,~S"); -c$.getQuotedStringAt = Clazz.defineMethod (c$, "getQuotedStringAt", -function (line, ipt0) { -var next = Clazz.newIntArray (-1, [ipt0]); -return javajs.util.PT.getQuotedStringNext (line, next); -}, "~S,~N"); -c$.getQuotedStringNext = Clazz.defineMethod (c$, "getQuotedStringNext", -function (line, next) { -var i = next[0]; -if (i < 0 || (i = line.indexOf ("\"", i)) < 0) return ""; -var pt = i + 1; -var len = line.length; -while (++i < len && line.charAt (i) != '"') if (line.charAt (i) == '\\') i++; - -next[0] = i + 1; -return line.substring (pt, i); -}, "~S,~A"); -c$.getCSVString = Clazz.defineMethod (c$, "getCSVString", -function (line, next) { -var i = next[1]; -if (i < 0 || (i = line.indexOf ("\"", i)) < 0) return null; -var pt = next[0] = i; -var len = line.length; -var escaped = false; -var haveEscape = false; -while (++i < len && (line.charAt (i) != '"' || (escaped = (i + 1 < len && line.charAt (i + 1) == '"')))) if (escaped) { -escaped = false; -haveEscape = true; -i++; -} -if (i >= len) { -next[1] = -1; -return null; -}next[1] = i + 1; -var s = line.substring (pt + 1, i); -return (haveEscape ? javajs.util.PT.rep (javajs.util.PT.rep (s, "\"\"", "\0"), "\0", "\"") : s); -}, "~S,~A"); -c$.isOneOf = Clazz.defineMethod (c$, "isOneOf", -function (key, semiList) { -if (semiList.length == 0) return false; -if (semiList.charAt (0) != ';') semiList = ";" + semiList + ";"; -return key.indexOf (";") < 0 && semiList.indexOf (';' + key + ';') >= 0; -}, "~S,~S"); -c$.getQuotedAttribute = Clazz.defineMethod (c$, "getQuotedAttribute", -function (info, name) { -var i = info.indexOf (name + "="); -return (i < 0 ? null : javajs.util.PT.getQuotedStringAt (info, i)); -}, "~S,~S"); -c$.approx = Clazz.defineMethod (c$, "approx", -function (f, n) { -return Math.round (f * n) / n; -}, "~N,~N"); -c$.rep = Clazz.defineMethod (c$, "rep", -function (str, strFrom, strTo) { -if (str == null || strFrom.length == 0 || str.indexOf (strFrom) < 0) return str; -var isOnce = (strTo.indexOf (strFrom) >= 0); -do { -str = str.$replace (strFrom, strTo); -} while (!isOnce && str.indexOf (strFrom) >= 0); -return str; -}, "~S,~S,~S"); -c$.formatF = Clazz.defineMethod (c$, "formatF", -function (value, width, precision, alignLeft, zeroPad) { -return javajs.util.PT.formatS (javajs.util.DF.formatDecimal (value, precision), width, 0, alignLeft, zeroPad); -}, "~N,~N,~N,~B,~B"); -c$.formatD = Clazz.defineMethod (c$, "formatD", -function (value, width, precision, alignLeft, zeroPad, allowOverflow) { -return javajs.util.PT.formatS (javajs.util.DF.formatDecimal (value, -1 - precision), width, 0, alignLeft, zeroPad); -}, "~N,~N,~N,~B,~B,~B"); -c$.formatS = Clazz.defineMethod (c$, "formatS", -function (value, width, precision, alignLeft, zeroPad) { -if (value == null) return ""; -var len = value.length; -if (precision != 2147483647 && precision > 0 && precision < len) value = value.substring (0, precision); - else if (precision < 0 && len + precision >= 0) value = value.substring (len + precision + 1); -var padLength = width - value.length; -if (padLength <= 0) return value; -var isNeg = (zeroPad && !alignLeft && value.charAt (0) == '-'); -var padChar = (zeroPad ? '0' : ' '); -var padChar0 = (isNeg ? '-' : padChar); -var sb = new javajs.util.SB (); -if (alignLeft) sb.append (value); -sb.appendC (padChar0); -for (var i = padLength; --i > 0; ) sb.appendC (padChar); - -if (!alignLeft) sb.append (isNeg ? padChar + value.substring (1) : value); -return sb.toString (); -}, "~S,~N,~N,~B,~B"); -c$.replaceWithCharacter = Clazz.defineMethod (c$, "replaceWithCharacter", -function (str, strFrom, chTo) { -if (str == null) return null; -for (var i = strFrom.length; --i >= 0; ) str = str.$replace (strFrom.charAt (i), chTo); - -return str; -}, "~S,~S,~S"); -c$.replaceAllCharacters = Clazz.defineMethod (c$, "replaceAllCharacters", -function (str, strFrom, strTo) { -for (var i = strFrom.length; --i >= 0; ) { -var chFrom = strFrom.substring (i, i + 1); -str = javajs.util.PT.rep (str, chFrom, strTo); -} -return str; -}, "~S,~S,~S"); -c$.trim = Clazz.defineMethod (c$, "trim", -function (str, chars) { -if (str == null || str.length == 0) return str; -if (chars.length == 0) return str.trim (); -var len = str.length; -var k = 0; -while (k < len && chars.indexOf (str.charAt (k)) >= 0) k++; - -var m = str.length - 1; -while (m > k && chars.indexOf (str.charAt (m)) >= 0) m--; - -return str.substring (k, m + 1); -}, "~S,~S"); -c$.trimQuotes = Clazz.defineMethod (c$, "trimQuotes", -function (value) { -return (value != null && value.length > 1 && value.startsWith ("\"") && value.endsWith ("\"") ? value.substring (1, value.length - 1) : value); -}, "~S"); -c$.isNonStringPrimitive = Clazz.defineMethod (c$, "isNonStringPrimitive", -function (info) { -return Clazz.instanceOf (info, Number) || Clazz.instanceOf (info, Boolean); -}, "~O"); -c$.arrayGet = Clazz.defineMethod (c$, "arrayGet", -($fz = function (info, i) { -{ -return info[i]; -}}, $fz.isPrivate = true, $fz), "~O,~N"); -c$.toJSON = Clazz.defineMethod (c$, "toJSON", -function (infoType, info) { -if (info == null) return javajs.util.PT.packageJSON (infoType, null); -if (javajs.util.PT.isNonStringPrimitive (info)) return javajs.util.PT.packageJSON (infoType, info.toString ()); -var s = null; -var sb = null; -while (true) { -if (Clazz.instanceOf (info, String)) { -s = info; -{ -if (typeof s == "undefined") s = "null" -}if (s.indexOf ("{\"") != 0) { -s = javajs.util.PT.rep (s, "\"", "\\\""); -s = javajs.util.PT.rep (s, "\n", "\\n"); -s = "\"" + s + "\""; -}break; -}if (Clazz.instanceOf (info, javajs.api.JSONEncodable)) { -if ((s = (info).toJSON ()) == null) s = "null"; -break; -}sb = new javajs.util.SB (); -if (Clazz.instanceOf (info, java.util.Map)) { -sb.append ("{ "); -var sep = ""; -for (var key, $key = (info).keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { -sb.append (sep).append (javajs.util.PT.packageJSON (key, javajs.util.PT.toJSON (null, (info).get (key)))); -sep = ","; -} -sb.append (" }"); -break; -}if (Clazz.instanceOf (info, javajs.util.Lst)) { -sb.append ("[ "); -var n = (info).size (); -for (var i = 0; i < n; i++) { -if (i > 0) sb.appendC (','); -sb.append (javajs.util.PT.toJSON (null, (info).get (i))); -} -sb.append (" ]"); -break; -}if (Clazz.instanceOf (info, javajs.util.M34)) { -var len = (Clazz.instanceOf (info, javajs.util.M4) ? 4 : 3); -var x = Clazz.newFloatArray (len, 0); -var m = info; -sb.appendC ('['); -for (var i = 0; i < len; i++) { -if (i > 0) sb.appendC (','); -m.getRow (i, x); -sb.append (javajs.util.PT.toJSON (null, x)); -} -sb.appendC (']'); -break; -}s = javajs.util.PT.nonArrayString (info); -if (s == null) { -sb.append ("["); -var n = javajs.util.AU.getLength (info); -for (var i = 0; i < n; i++) { -if (i > 0) sb.appendC (','); -sb.append (javajs.util.PT.toJSON (null, javajs.util.PT.arrayGet (info, i))); -} -sb.append ("]"); -break; -}info = info.toString (); -} -return javajs.util.PT.packageJSON (infoType, (s == null ? sb.toString () : s)); -}, "~S,~O"); -c$.nonArrayString = Clazz.defineMethod (c$, "nonArrayString", -function (x) { -{ -var s = x.toString(); return (s.startsWith("[object") && -s.endsWith("Array]") ? null : s); -}}, "~O"); -c$.byteArrayToJSON = Clazz.defineMethod (c$, "byteArrayToJSON", -function (data) { -var sb = new javajs.util.SB (); -sb.append ("["); -var n = data.length; -for (var i = 0; i < n; i++) { -if (i > 0) sb.appendC (','); -sb.appendI (data[i] & 0xFF); -} -sb.append ("]"); -return sb.toString (); -}, "~A"); -c$.packageJSON = Clazz.defineMethod (c$, "packageJSON", -function (infoType, info) { -return (infoType == null ? info : "\"" + infoType + "\": " + info); -}, "~S,~S"); -c$.escapeUrl = Clazz.defineMethod (c$, "escapeUrl", -function (url) { -url = javajs.util.PT.rep (url, "\n", ""); -url = javajs.util.PT.rep (url, "%", "%25"); -url = javajs.util.PT.rep (url, "#", "%23"); -url = javajs.util.PT.rep (url, "[", "%5B"); -url = javajs.util.PT.rep (url, "]", "%5D"); -url = javajs.util.PT.rep (url, " ", "%20"); -return url; -}, "~S"); -c$.esc = Clazz.defineMethod (c$, "esc", -function (str) { -if (str == null || str.length == 0) return "\"\""; -var haveEscape = false; -var i = 0; -for (; i < "\\\\\tt\rr\nn\"\"".length; i += 2) if (str.indexOf ("\\\\\tt\rr\nn\"\"".charAt (i)) >= 0) { -haveEscape = true; -break; -} -if (haveEscape) while (i < "\\\\\tt\rr\nn\"\"".length) { -var pt = -1; -var ch = "\\\\\tt\rr\nn\"\"".charAt (i++); -var ch2 = "\\\\\tt\rr\nn\"\"".charAt (i++); -var sb = new javajs.util.SB (); -var pt0 = 0; -while ((pt = str.indexOf (ch, pt + 1)) >= 0) { -sb.append (str.substring (pt0, pt)).appendC ('\\').appendC (ch2); -pt0 = pt + 1; -} -sb.append (str.substring (pt0, str.length)); -str = sb.toString (); -} -return "\"" + javajs.util.PT.escUnicode (str) + "\""; -}, "~S"); -c$.escUnicode = Clazz.defineMethod (c$, "escUnicode", -function (str) { -for (var i = str.length; --i >= 0; ) if (str.charCodeAt (i) > 0x7F) { -var s = "0000" + Integer.toHexString (str.charCodeAt (i)); -str = str.substring (0, i) + "\\u" + s.substring (s.length - 4) + str.substring (i + 1); -} -return str; -}, "~S"); -c$.escF = Clazz.defineMethod (c$, "escF", -function (f) { -var sf = "" + f; -{ -if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0) -sf += ".0"; -}return sf; -}, "~N"); -c$.join = Clazz.defineMethod (c$, "join", -function (s, c, i0) { -if (s.length < i0) return null; -var sb = new javajs.util.SB (); -sb.append (s[i0++]); -for (var i = i0; i < s.length; i++) sb.appendC (c).append (s[i]); - -return sb.toString (); -}, "~A,~S,~N"); -c$.isLike = Clazz.defineMethod (c$, "isLike", -function (a, b) { -var areEqual = a.equals (b); -if (areEqual) return true; -var isStart = b.startsWith ("*"); -var isEnd = b.endsWith ("*"); -return (!isStart && !isEnd) ? areEqual : isStart && isEnd ? b.length == 1 || a.contains (b.substring (1, b.length - 1)) : isStart ? a.endsWith (b.substring (1)) : a.startsWith (b.substring (0, b.length - 1)); -}, "~S,~S"); -c$.getMapValueNoCase = Clazz.defineMethod (c$, "getMapValueNoCase", -function (h, key) { -if ("this".equals (key)) return h; -var val = h.get (key); -if (val == null) for (var e, $e = h.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) if (e.getKey ().equalsIgnoreCase (key)) return e.getValue (); - -return val; -}, "java.util.Map,~S"); -c$.clean = Clazz.defineMethod (c$, "clean", -function (s) { -return javajs.util.PT.rep (javajs.util.PT.replaceAllCharacters (s, " \t\n\r", " "), " ", " ").trim (); -}, "~S"); -c$.fdup = Clazz.defineMethod (c$, "fdup", -function (f, pt, n) { -var ch; -var count = 0; -for (var i = pt; --i >= 1; ) { -if (javajs.util.PT.isDigit (ch = f.charAt (i))) continue; -switch (ch) { -case '.': -if (count++ != 0) return f; -continue; -case '-': -if (i != 1 && f.charAt (i - 1) != '.') return f; -continue; -default: -return f; -} -} -var s = f.substring (0, pt + 1); -var sb = new javajs.util.SB (); -for (var i = 0; i < n; i++) sb.append (s); - -sb.append (f.substring (pt + 1)); -return sb.toString (); -}, "~S,~N,~N"); -c$.formatString = Clazz.defineMethod (c$, "formatString", -function (strFormat, key, strT, floatT, doubleT, doOne) { -if (strFormat == null) return null; -if ("".equals (strFormat)) return ""; -var len = key.length; -if (strFormat.indexOf ("%") < 0 || len == 0 || strFormat.indexOf (key) < 0) return strFormat; -var strLabel = ""; -var ich; -var ichPercent; -var ichKey; -for (ich = 0; (ichPercent = strFormat.indexOf ('%', ich)) >= 0 && (ichKey = strFormat.indexOf (key, ichPercent + 1)) >= 0; ) { -if (ich != ichPercent) strLabel += strFormat.substring (ich, ichPercent); -ich = ichPercent + 1; -if (ichKey > ichPercent + 6) { -strLabel += '%'; -continue; -}try { -var alignLeft = false; -if (strFormat.charAt (ich) == '-') { -alignLeft = true; -++ich; -}var zeroPad = false; -if (strFormat.charAt (ich) == '0') { -zeroPad = true; -++ich; -}var ch; -var width = 0; -while ((ch = strFormat.charAt (ich)) >= '0' && (ch <= '9')) { -width = (10 * width) + (ch.charCodeAt (0) - 48); -++ich; -} -var precision = 2147483647; -var isExponential = false; -if (strFormat.charAt (ich) == '.') { -++ich; -if ((ch = strFormat.charAt (ich)) == '-') { -isExponential = true; -++ich; -}if ((ch = strFormat.charAt (ich)) >= '0' && ch <= '9') { -precision = ch.charCodeAt (0) - 48; -++ich; -}if (isExponential) precision = -precision - (strT == null ? 1 : 0); -}var st = strFormat.substring (ich, ich + len); -if (!st.equals (key)) { -ich = ichPercent + 1; -strLabel += '%'; -continue; -}ich += len; -if (!Float.isNaN (floatT)) strLabel += javajs.util.PT.formatF (floatT, width, precision, alignLeft, zeroPad); - else if (strT != null) strLabel += javajs.util.PT.formatS (strT, width, precision, alignLeft, zeroPad); - else if (!Double.isNaN (doubleT)) strLabel += javajs.util.PT.formatD (doubleT, width, precision, alignLeft, zeroPad, true); -if (doOne) break; -} catch (ioobe) { -if (Clazz.exceptionOf (ioobe, IndexOutOfBoundsException)) { -ich = ichPercent; -break; -} else { -throw ioobe; -} -} -} -strLabel += strFormat.substring (ich); -return strLabel; -}, "~S,~S,~S,~N,~N,~B"); -c$.formatStringS = Clazz.defineMethod (c$, "formatStringS", -function (strFormat, key, strT) { -return javajs.util.PT.formatString (strFormat, key, strT, NaN, NaN, false); -}, "~S,~S,~S"); -c$.formatStringF = Clazz.defineMethod (c$, "formatStringF", -function (strFormat, key, floatT) { -return javajs.util.PT.formatString (strFormat, key, null, floatT, NaN, false); -}, "~S,~S,~N"); -c$.formatStringI = Clazz.defineMethod (c$, "formatStringI", -function (strFormat, key, intT) { -return javajs.util.PT.formatString (strFormat, key, "" + intT, NaN, NaN, false); -}, "~S,~S,~N"); -c$.sprintf = Clazz.defineMethod (c$, "sprintf", -function (strFormat, list, values) { -if (values == null) return strFormat; -var n = list.length; -if (n == values.length) try { -for (var o = 0; o < n; o++) { -if (values[o] == null) continue; -switch (list.charAt (o)) { -case 's': -strFormat = javajs.util.PT.formatString (strFormat, "s", values[o], NaN, NaN, true); -break; -case 'f': -strFormat = javajs.util.PT.formatString (strFormat, "f", null, (values[o]).floatValue (), NaN, true); -break; -case 'i': -strFormat = javajs.util.PT.formatString (strFormat, "d", "" + values[o], NaN, NaN, true); -strFormat = javajs.util.PT.formatString (strFormat, "i", "" + values[o], NaN, NaN, true); -break; -case 'd': -strFormat = javajs.util.PT.formatString (strFormat, "e", null, NaN, (values[o]).doubleValue (), true); -break; -case 'p': -var pVal = values[o]; -strFormat = javajs.util.PT.formatString (strFormat, "p", null, pVal.x, NaN, true); -strFormat = javajs.util.PT.formatString (strFormat, "p", null, pVal.y, NaN, true); -strFormat = javajs.util.PT.formatString (strFormat, "p", null, pVal.z, NaN, true); -break; -case 'q': -var qVal = values[o]; -strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.x, NaN, true); -strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.y, NaN, true); -strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.z, NaN, true); -strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.w, NaN, true); -break; -case 'S': -var sVal = values[o]; -for (var i = 0; i < sVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "s", sVal[i], NaN, NaN, true); - -break; -case 'F': -var fVal = values[o]; -for (var i = 0; i < fVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "f", null, fVal[i], NaN, true); - -break; -case 'I': -var iVal = values[o]; -for (var i = 0; i < iVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "d", "" + iVal[i], NaN, NaN, true); - -for (var i = 0; i < iVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "i", "" + iVal[i], NaN, NaN, true); - -break; -case 'D': -var dVal = values[o]; -for (var i = 0; i < dVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "e", null, NaN, dVal[i], true); - -} -} -return javajs.util.PT.rep (strFormat, "%%", "%"); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -System.out.println ("TextFormat.sprintf error " + list + " " + strFormat); -return javajs.util.PT.rep (strFormat, "%", "?"); -}, "~S,~S,~A"); -c$.formatCheck = Clazz.defineMethod (c$, "formatCheck", -function (strFormat) { -if (strFormat == null || strFormat.indexOf ('p') < 0 && strFormat.indexOf ('q') < 0) return strFormat; -strFormat = javajs.util.PT.rep (strFormat, "%%", "\1"); -strFormat = javajs.util.PT.rep (strFormat, "%p", "%6.2p"); -strFormat = javajs.util.PT.rep (strFormat, "%q", "%6.2q"); -var format = javajs.util.PT.split (strFormat, "%"); -var sb = new javajs.util.SB (); -sb.append (format[0]); -for (var i = 1; i < format.length; i++) { -var f = "%" + format[i]; -var pt; -if (f.length >= 3) { -if ((pt = f.indexOf ('p')) >= 0) f = javajs.util.PT.fdup (f, pt, 3); -if ((pt = f.indexOf ('q')) >= 0) f = javajs.util.PT.fdup (f, pt, 4); -}sb.append (f); -} -return sb.toString ().$replace ('\1', '%'); -}, "~S"); -c$.leftJustify = Clazz.defineMethod (c$, "leftJustify", -function (s, s1, s2) { -s.append (s2); -var n = s1.length - s2.length; -if (n > 0) s.append (s1.substring (0, n)); -}, "javajs.util.SB,~S,~S"); -c$.rightJustify = Clazz.defineMethod (c$, "rightJustify", -function (s, s1, s2) { -var n = s1.length - s2.length; -if (n > 0) s.append (s1.substring (0, n)); -s.append (s2); -}, "javajs.util.SB,~S,~S"); -c$.safeTruncate = Clazz.defineMethod (c$, "safeTruncate", -function (f, n) { -if (f > -0.001 && f < 0.001) f = 0; -return (f + " ").substring (0, n); -}, "~N,~N"); -c$.isWild = Clazz.defineMethod (c$, "isWild", -function (s) { -return s != null && (s.indexOf ("*") >= 0 || s.indexOf ("?") >= 0); -}, "~S"); -c$.isMatch = Clazz.defineMethod (c$, "isMatch", -function (search, match, checkStar, allowInitialStar) { -if (search.equals (match)) return true; -var mLen = match.length; -if (mLen == 0) return false; -var isStar0 = (checkStar && allowInitialStar ? match.charAt (0) == '*' : false); -if (mLen == 1 && isStar0) return true; -var isStar1 = (checkStar && match.endsWith ("*")); -var haveQ = (match.indexOf ('?') >= 0); -if (!haveQ) { -if (isStar0) return (isStar1 ? (mLen < 3 || search.indexOf (match.substring (1, mLen - 1)) >= 0) : search.endsWith (match.substring (1))); - else if (isStar1) return search.startsWith (match.substring (0, mLen - 1)); -}var sLen = search.length; -var qqqq = "????"; -var nq = 4; -while (nq < sLen) { -qqqq += qqqq; -nq += 4; -} -if (checkStar) { -if (isStar0) { -match = qqqq + match.substring (1); -mLen += nq - 1; -}if (isStar1) { -match = match.substring (0, mLen - 1) + qqqq; -mLen += nq - 1; -}}if (mLen < sLen) return false; -var ich = 0; -while (mLen > sLen) { -if (allowInitialStar && match.charAt (ich) == '?') { -++ich; -} else if (match.charAt (ich + mLen - 1) != '?') { -return false; -}--mLen; -} -for (var i = sLen; --i >= 0; ) { -var chm = match.charAt (ich + i); -if (chm == '?') continue; -var chs = search.charAt (i); -if (chm != chs && (chm != '\1' || chs != '?')) return false; -} -return true; -}, "~S,~S,~B,~B"); -c$.replaceQuotedStrings = Clazz.defineMethod (c$, "replaceQuotedStrings", -function (s, list, newList) { -var n = list.size (); -for (var i = 0; i < n; i++) { -var name = list.get (i); -var newName = newList.get (i); -if (!newName.equals (name)) s = javajs.util.PT.rep (s, "\"" + name + "\"", "\"" + newName + "\""); -} -return s; -}, "~S,javajs.util.Lst,javajs.util.Lst"); -c$.replaceStrings = Clazz.defineMethod (c$, "replaceStrings", -function (s, list, newList) { -var n = list.size (); -for (var i = 0; i < n; i++) { -var name = list.get (i); -var newName = newList.get (i); -if (!newName.equals (name)) s = javajs.util.PT.rep (s, name, newName); -} -return s; -}, "~S,javajs.util.Lst,javajs.util.Lst"); -c$.isDigit = Clazz.defineMethod (c$, "isDigit", -function (ch) { -var c = (ch).charCodeAt (0); -return (48 <= c && c <= 57); -}, "~S"); -c$.isUpperCase = Clazz.defineMethod (c$, "isUpperCase", -function (ch) { -var c = (ch).charCodeAt (0); -return (65 <= c && c <= 90); -}, "~S"); -c$.isLowerCase = Clazz.defineMethod (c$, "isLowerCase", -function (ch) { -var c = (ch).charCodeAt (0); -return (97 <= c && c <= 122); -}, "~S"); -c$.isLetter = Clazz.defineMethod (c$, "isLetter", -function (ch) { -var c = (ch).charCodeAt (0); -return (65 <= c && c <= 90 || 97 <= c && c <= 122); -}, "~S"); -c$.isLetterOrDigit = Clazz.defineMethod (c$, "isLetterOrDigit", -function (ch) { -var c = (ch).charCodeAt (0); -return (65 <= c && c <= 90 || 97 <= c && c <= 122 || 48 <= c && c <= 57); -}, "~S"); -c$.isWhitespace = Clazz.defineMethod (c$, "isWhitespace", -function (ch) { -var c = (ch).charCodeAt (0); -return (c >= 0x1c && c <= 0x20 || c >= 0x9 && c <= 0xd); -}, "~S"); -c$.fixPtFloats = Clazz.defineMethod (c$, "fixPtFloats", -function (pt, f) { -pt.x = Math.round (pt.x * f) / f; -pt.y = Math.round (pt.y * f) / f; -pt.z = Math.round (pt.z * f) / f; -}, "javajs.util.T3,~N"); -c$.fixDouble = Clazz.defineMethod (c$, "fixDouble", -function (d, f) { -return Math.round (d * f) / f; -}, "~N,~N"); -c$.parseFloatFraction = Clazz.defineMethod (c$, "parseFloatFraction", -function (s) { -var pt = s.indexOf ("/"); -return (pt < 0 ? javajs.util.PT.parseFloat (s) : javajs.util.PT.parseFloat (s.substring (0, pt)) / javajs.util.PT.parseFloat (s.substring (pt + 1))); -}, "~S"); -Clazz.defineStatics (c$, -"tensScale", Clazz.newFloatArray (-1, [10, 100, 1000, 10000, 100000, 1000000]), -"decimalScale", Clazz.newFloatArray (-1, [0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001, 0.00000001, 0.000000001]), -"FLOAT_MIN_SAFE", 2E-45, -"escapable", "\\\\\tt\rr\nn\"\"", -"FRACTIONAL_PRECISION", 100000, -"CARTESIAN_PRECISION", 10000); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.PT", ["java.lang.Boolean", "$.Double", "$.Float", "$.Number", "java.util.Map", "javajs.api.JSONEncodable", "javajs.util.AU", "$.DF", "$.Lst", "$.M34", "$.M4", "$.SB"], function () { +c$ = Clazz.declareType (javajs.util, "PT"); +c$.parseInt = Clazz.defineMethod (c$, "parseInt", +function (str) { +return javajs.util.PT.parseIntNext (str, Clazz.newIntArray (-1, [0])); +}, "~S"); +c$.parseIntNext = Clazz.defineMethod (c$, "parseIntNext", +function (str, next) { +var cch = str.length; +if (next[0] < 0 || next[0] >= cch) return -2147483648; +return javajs.util.PT.parseIntChecked (str, cch, next); +}, "~S,~A"); +c$.parseIntChecked = Clazz.defineMethod (c$, "parseIntChecked", +function (str, ichMax, next) { +var digitSeen = false; +var value = 0; +var ich = next[0]; +if (ich < 0) return -2147483648; +var ch; +while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; + +var negative = false; +if (ich < ichMax && str.charCodeAt (ich) == 45) { +negative = true; +++ich; +}while (ich < ichMax && (ch = str.charCodeAt (ich)) >= 48 && ch <= 57) { +value = value * 10 + (ch - 48); +digitSeen = true; +++ich; +} +if (!digitSeen) value = -2147483648; + else if (negative) value = -value; +next[0] = ich; +return value; +}, "~S,~N,~A"); +c$.isWhiteSpace = Clazz.defineMethod (c$, "isWhiteSpace", +function (str, ich) { +var ch; +return (ich >= 0 && ((ch = str.charAt (ich)) == ' ' || ch == '\t' || ch == '\n')); +}, "~S,~N"); +c$.parseFloatChecked = Clazz.defineMethod (c$, "parseFloatChecked", +function (str, ichMax, next, isStrict) { +var digitSeen = false; +var ich = next[0]; +if (isStrict && str.indexOf ('\n') != str.lastIndexOf ('\n')) return NaN; +while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; + +var negative = false; +if (ich < ichMax && str.charAt (ich) == '-') { +++ich; +negative = true; +}var ch = 0; +var ival = 0; +var ival2 = 0; +while (ich < ichMax && (ch = str.charCodeAt (ich)) >= 48 && ch <= 57) { +ival = (ival * 10) + (ch - 48) * 1; +++ich; +digitSeen = true; +} +var isDecimal = false; +var iscale = 0; +var nzero = (ival == 0 ? -1 : 0); +if (ch == 46) { +isDecimal = true; +while (++ich < ichMax && (ch = str.charCodeAt (ich)) >= 48 && ch <= 57) { +digitSeen = true; +if (nzero < 0) { +if (ch == 48) { +nzero--; +continue; +}nzero = -nzero; +}if (iscale < javajs.util.PT.decimalScale.length) { +ival2 = (ival2 * 10) + (ch - 48) * 1; +iscale++; +}} +}var value; +if (!digitSeen) { +value = NaN; +} else if (ival2 > 0) { +value = ival2 * javajs.util.PT.decimalScale[iscale - 1]; +if (nzero > 1) { +if (nzero - 2 < javajs.util.PT.decimalScale.length) { +value *= javajs.util.PT.decimalScale[nzero - 2]; +} else { +value *= Math.pow (10, 1 - nzero); +}} else { +value += ival; +}} else { +value = ival; +}var isExponent = false; +if (ich < ichMax && (ch == 69 || ch == 101 || ch == 68)) { +isExponent = true; +if (++ich >= ichMax) return NaN; +ch = str.charCodeAt (ich); +if ((ch == 43) && (++ich >= ichMax)) return NaN; +next[0] = ich; +var exponent = javajs.util.PT.parseIntChecked (str, ichMax, next); +if (exponent == -2147483648) return NaN; +if (exponent > 0 && exponent <= javajs.util.PT.tensScale.length) value *= javajs.util.PT.tensScale[exponent - 1]; + else if (exponent < 0 && -exponent <= javajs.util.PT.decimalScale.length) value *= javajs.util.PT.decimalScale[-exponent - 1]; + else if (exponent != 0) value *= Math.pow (10, exponent); +} else { +next[0] = ich; +}if (negative) value = -value; +if (value == Infinity) value = 3.4028235E38; +return (!isStrict || (!isExponent || isDecimal) && javajs.util.PT.checkTrailingText (str, next[0], ichMax) ? value : NaN); +}, "~S,~N,~A,~B"); +c$.checkTrailingText = Clazz.defineMethod (c$, "checkTrailingText", +function (str, ich, ichMax) { +var ch; +while (ich < ichMax && (javajs.util.PT.isWhitespace (ch = str.charAt (ich)) || ch == ';')) ++ich; + +return (ich == ichMax); +}, "~S,~N,~N"); +c$.parseFloatArray = Clazz.defineMethod (c$, "parseFloatArray", +function (str) { +return javajs.util.PT.parseFloatArrayNext (str, Clazz.newIntArray (1, 0), null, null, null); +}, "~S"); +c$.parseFloatArrayInfested = Clazz.defineMethod (c$, "parseFloatArrayInfested", +function (tokens, data) { +var len = data.length; +var nTokens = tokens.length; +var n = 0; +var max = 0; +for (var i = 0; i >= 0 && i < len && n < nTokens; i++) { +var f; +while (Float.isNaN (f = javajs.util.PT.parseFloat (tokens[n++])) && n < nTokens) { +} +if (!Float.isNaN (f)) data[(max = i)] = f; +if (n == nTokens) break; +} +return max + 1; +}, "~A,~A"); +c$.parseFloatArrayNext = Clazz.defineMethod (c$, "parseFloatArrayNext", +function (str, next, f, strStart, strEnd) { +var n = 0; +var pt = next[0]; +if (pt >= 0) { +if (strStart != null) { +var p = str.indexOf (strStart, pt); +if (p >= 0) next[0] = p + strStart.length; +}str = str.substring (next[0]); +pt = (strEnd == null ? -1 : str.indexOf (strEnd)); +if (pt < 0) pt = str.length; + else str = str.substring (0, pt); +next[0] += pt + 1; +var tokens = javajs.util.PT.getTokens (str); +if (f == null) f = Clazz.newFloatArray (tokens.length, 0); +n = javajs.util.PT.parseFloatArrayInfested (tokens, f); +}if (f == null) return Clazz.newFloatArray (0, 0); +for (var i = n; i < f.length; i++) f[i] = NaN; + +return f; +}, "~S,~A,~A,~S,~S"); +c$.parseFloatRange = Clazz.defineMethod (c$, "parseFloatRange", +function (str, ichMax, next) { +var cch = str.length; +if (ichMax > cch) ichMax = cch; +if (next[0] < 0 || next[0] >= ichMax) return NaN; +return javajs.util.PT.parseFloatChecked (str, ichMax, next, false); +}, "~S,~N,~A"); +c$.parseFloatNext = Clazz.defineMethod (c$, "parseFloatNext", +function (str, next) { +var cch = (str == null ? -1 : str.length); +return (next[0] < 0 || next[0] >= cch ? NaN : javajs.util.PT.parseFloatChecked (str, cch, next, false)); +}, "~S,~A"); +c$.parseFloatStrict = Clazz.defineMethod (c$, "parseFloatStrict", +function (str) { +var cch = str.length; +if (cch == 0) return NaN; +return javajs.util.PT.parseFloatChecked (str, cch, Clazz.newIntArray (-1, [0]), true); +}, "~S"); +c$.parseFloat = Clazz.defineMethod (c$, "parseFloat", +function (str) { +return javajs.util.PT.parseFloatNext (str, Clazz.newIntArray (-1, [0])); +}, "~S"); +c$.parseIntRadix = Clazz.defineMethod (c$, "parseIntRadix", +function (s, i) { +{ +return Integer.parseIntRadix(s, i); +}}, "~S,~N"); +c$.getTokens = Clazz.defineMethod (c$, "getTokens", +function (line) { +return javajs.util.PT.getTokensAt (line, 0); +}, "~S"); +c$.parseToken = Clazz.defineMethod (c$, "parseToken", +function (str) { +return javajs.util.PT.parseTokenNext (str, Clazz.newIntArray (-1, [0])); +}, "~S"); +c$.parseTrimmed = Clazz.defineMethod (c$, "parseTrimmed", +function (str) { +return javajs.util.PT.parseTrimmedRange (str, 0, str.length); +}, "~S"); +c$.parseTrimmedAt = Clazz.defineMethod (c$, "parseTrimmedAt", +function (str, ichStart) { +return javajs.util.PT.parseTrimmedRange (str, ichStart, str.length); +}, "~S,~N"); +c$.parseTrimmedRange = Clazz.defineMethod (c$, "parseTrimmedRange", +function (str, ichStart, ichMax) { +var cch = str.length; +if (ichMax < cch) cch = ichMax; +if (cch < ichStart) return ""; +return javajs.util.PT.parseTrimmedChecked (str, ichStart, cch); +}, "~S,~N,~N"); +c$.getTokensAt = Clazz.defineMethod (c$, "getTokensAt", +function (line, ich) { +if (line == null) return null; +var cchLine = line.length; +if (ich < 0 || ich > cchLine) return null; +var tokenCount = javajs.util.PT.countTokens (line, ich); +var tokens = new Array (tokenCount); +var next = Clazz.newIntArray (1, 0); +next[0] = ich; +for (var i = 0; i < tokenCount; ++i) tokens[i] = javajs.util.PT.parseTokenChecked (line, cchLine, next); + +return tokens; +}, "~S,~N"); +c$.countChar = Clazz.defineMethod (c$, "countChar", +function (line, c) { +var tokenCount = 0; +var pt = -1; +while ((pt = line.indexOf (c, pt + 1)) >= 0) tokenCount++; + +return tokenCount; +}, "~S,~S"); +c$.countTokens = Clazz.defineMethod (c$, "countTokens", +function (line, ich) { +var tokenCount = 0; +if (line != null) { +var ichMax = line.length; +while (true) { +while (ich < ichMax && javajs.util.PT.isWhiteSpace (line, ich)) ++ich; + +if (ich == ichMax) break; +++tokenCount; +do { +++ich; +} while (ich < ichMax && !javajs.util.PT.isWhiteSpace (line, ich)); +} +}return tokenCount; +}, "~S,~N"); +c$.parseTokenNext = Clazz.defineMethod (c$, "parseTokenNext", +function (str, next) { +var cch = str.length; +return (next[0] < 0 || next[0] >= cch ? null : javajs.util.PT.parseTokenChecked (str, cch, next)); +}, "~S,~A"); +c$.parseTokenRange = Clazz.defineMethod (c$, "parseTokenRange", +function (str, ichMax, next) { +var cch = str.length; +if (ichMax > cch) ichMax = cch; +return (next[0] < 0 || next[0] >= ichMax ? null : javajs.util.PT.parseTokenChecked (str, ichMax, next)); +}, "~S,~N,~A"); +c$.parseTokenChecked = Clazz.defineMethod (c$, "parseTokenChecked", +function (str, ichMax, next) { +var ich = next[0]; +while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; + +var ichNonWhite = ich; +while (ich < ichMax && !javajs.util.PT.isWhiteSpace (str, ich)) ++ich; + +next[0] = ich; +return (ichNonWhite == ich ? null : str.substring (ichNonWhite, ich)); +}, "~S,~N,~A"); +c$.parseTrimmedChecked = Clazz.defineMethod (c$, "parseTrimmedChecked", +function (str, ich, ichMax) { +while (ich < ichMax && javajs.util.PT.isWhiteSpace (str, ich)) ++ich; + +var ichLast = ichMax - 1; +while (ichLast >= ich && javajs.util.PT.isWhiteSpace (str, ichLast)) --ichLast; + +return (ichLast < ich ? "" : str.substring (ich, ichLast + 1)); +}, "~S,~N,~N"); +c$.dVal = Clazz.defineMethod (c$, "dVal", +function (s) { +{ +if(s==null) +throw new NumberFormatException("null"); +var d=parseFloat(s); +if(isNaN(d)) +throw new NumberFormatException("Not a Number : "+s); +return d +}}, "~S"); +c$.fVal = Clazz.defineMethod (c$, "fVal", +function (s) { +{ +return this.dVal(s); +}}, "~S"); +c$.parseIntRange = Clazz.defineMethod (c$, "parseIntRange", +function (str, ichMax, next) { +var cch = str.length; +if (ichMax > cch) ichMax = cch; +return (next[0] < 0 || next[0] >= ichMax ? -2147483648 : javajs.util.PT.parseIntChecked (str, ichMax, next)); +}, "~S,~N,~A"); +c$.parseFloatArrayData = Clazz.defineMethod (c$, "parseFloatArrayData", +function (tokens, data) { +javajs.util.PT.parseFloatArrayDataN (tokens, data, data.length); +}, "~A,~A"); +c$.parseFloatArrayDataN = Clazz.defineMethod (c$, "parseFloatArrayDataN", +function (tokens, data, nData) { +for (var i = nData; --i >= 0; ) data[i] = (i >= tokens.length ? NaN : javajs.util.PT.parseFloat (tokens[i])); + +}, "~A,~A,~N"); +c$.split = Clazz.defineMethod (c$, "split", +function (text, run) { +if (text.length == 0) return new Array (0); +var n = 1; +var i = text.indexOf (run); +var lines; +var runLen = run.length; +if (i < 0 || runLen == 0) { +lines = new Array (1); +lines[0] = text; +return lines; +}var len = text.length - runLen; +for (; i >= 0 && i < len; n++) i = text.indexOf (run, i + runLen); + +lines = new Array (n); +i = 0; +var ipt = 0; +var pt = 0; +for (; (ipt = text.indexOf (run, i)) >= 0 && pt + 1 < n; ) { +lines[pt++] = text.substring (i, ipt); +i = ipt + runLen; +} +if (text.indexOf (run, len) != len) len += runLen; +lines[pt] = text.substring (i, len); +return lines; +}, "~S,~S"); +c$.getQuotedStringAt = Clazz.defineMethod (c$, "getQuotedStringAt", +function (line, ipt0) { +var next = Clazz.newIntArray (-1, [ipt0]); +return javajs.util.PT.getQuotedStringNext (line, next); +}, "~S,~N"); +c$.getQuotedStringNext = Clazz.defineMethod (c$, "getQuotedStringNext", +function (line, next) { +var i = next[0]; +if (i < 0 || (i = line.indexOf ("\"", i)) < 0) return ""; +var pt = i + 1; +var len = line.length; +while (++i < len && line.charAt (i) != '"') if (line.charAt (i) == '\\') i++; + +next[0] = i + 1; +return line.substring (pt, i); +}, "~S,~A"); +c$.getCSVString = Clazz.defineMethod (c$, "getCSVString", +function (line, next) { +var i = next[1]; +if (i < 0 || (i = line.indexOf ("\"", i)) < 0) return null; +var pt = next[0] = i; +var len = line.length; +var escaped = false; +var haveEscape = false; +while (++i < len && (line.charAt (i) != '"' || (escaped = (i + 1 < len && line.charAt (i + 1) == '"')))) if (escaped) { +escaped = false; +haveEscape = true; +i++; +} +if (i >= len) { +next[1] = -1; +return null; +}next[1] = i + 1; +var s = line.substring (pt + 1, i); +return (haveEscape ? javajs.util.PT.rep (javajs.util.PT.rep (s, "\"\"", "\0"), "\0", "\"") : s); +}, "~S,~A"); +c$.isOneOf = Clazz.defineMethod (c$, "isOneOf", +function (key, semiList) { +if (semiList.length == 0) return false; +if (semiList.charAt (0) != ';') semiList = ";" + semiList + ";"; +return key.indexOf (";") < 0 && semiList.indexOf (';' + key + ';') >= 0; +}, "~S,~S"); +c$.getQuotedAttribute = Clazz.defineMethod (c$, "getQuotedAttribute", +function (info, name) { +var i = info.indexOf (name + "="); +return (i < 0 ? null : javajs.util.PT.getQuotedStringAt (info, i)); +}, "~S,~S"); +c$.approx = Clazz.defineMethod (c$, "approx", +function (f, n) { +return Math.round (f * n) / n; +}, "~N,~N"); +c$.rep = Clazz.defineMethod (c$, "rep", +function (str, strFrom, strTo) { +if (str == null || strFrom.length == 0 || str.indexOf (strFrom) < 0) return str; +var isOnce = (strTo.indexOf (strFrom) >= 0); +do { +str = str.$replace (strFrom, strTo); +} while (!isOnce && str.indexOf (strFrom) >= 0); +return str; +}, "~S,~S,~S"); +c$.formatF = Clazz.defineMethod (c$, "formatF", +function (value, width, precision, alignLeft, zeroPad) { +return javajs.util.PT.formatS (javajs.util.DF.formatDecimal (value, precision), width, 0, alignLeft, zeroPad); +}, "~N,~N,~N,~B,~B"); +c$.formatD = Clazz.defineMethod (c$, "formatD", +function (value, width, precision, alignLeft, zeroPad, allowOverflow) { +return javajs.util.PT.formatS (javajs.util.DF.formatDecimal (value, -1 - precision), width, 0, alignLeft, zeroPad); +}, "~N,~N,~N,~B,~B,~B"); +c$.formatS = Clazz.defineMethod (c$, "formatS", +function (value, width, precision, alignLeft, zeroPad) { +if (value == null) return ""; +var len = value.length; +if (precision != 2147483647 && precision > 0 && precision < len) value = value.substring (0, precision); + else if (precision < 0 && len + precision >= 0) value = value.substring (len + precision + 1); +var padLength = width - value.length; +if (padLength <= 0) return value; +var isNeg = (zeroPad && !alignLeft && value.charAt (0) == '-'); +var padChar = (zeroPad ? '0' : ' '); +var padChar0 = (isNeg ? '-' : padChar); +var sb = new javajs.util.SB (); +if (alignLeft) sb.append (value); +sb.appendC (padChar0); +for (var i = padLength; --i > 0; ) sb.appendC (padChar); + +if (!alignLeft) sb.append (isNeg ? padChar + value.substring (1) : value); +return sb.toString (); +}, "~S,~N,~N,~B,~B"); +c$.replaceWithCharacter = Clazz.defineMethod (c$, "replaceWithCharacter", +function (str, strFrom, chTo) { +if (str == null) return null; +for (var i = strFrom.length; --i >= 0; ) str = str.$replace (strFrom.charAt (i), chTo); + +return str; +}, "~S,~S,~S"); +c$.replaceAllCharacters = Clazz.defineMethod (c$, "replaceAllCharacters", +function (str, strFrom, strTo) { +for (var i = strFrom.length; --i >= 0; ) { +var chFrom = strFrom.substring (i, i + 1); +str = javajs.util.PT.rep (str, chFrom, strTo); +} +return str; +}, "~S,~S,~S"); +c$.trim = Clazz.defineMethod (c$, "trim", +function (str, chars) { +if (str == null || str.length == 0) return str; +if (chars.length == 0) return str.trim (); +var len = str.length; +var k = 0; +while (k < len && chars.indexOf (str.charAt (k)) >= 0) k++; + +var m = str.length - 1; +while (m > k && chars.indexOf (str.charAt (m)) >= 0) m--; + +return str.substring (k, m + 1); +}, "~S,~S"); +c$.trimQuotes = Clazz.defineMethod (c$, "trimQuotes", +function (value) { +return (value != null && value.length > 1 && value.startsWith ("\"") && value.endsWith ("\"") ? value.substring (1, value.length - 1) : value); +}, "~S"); +c$.isNonStringPrimitive = Clazz.defineMethod (c$, "isNonStringPrimitive", +function (info) { +return Clazz.instanceOf (info, Number) || Clazz.instanceOf (info, Boolean); +}, "~O"); +c$.arrayGet = Clazz.defineMethod (c$, "arrayGet", +($fz = function (info, i) { +{ +return info[i]; +}}, $fz.isPrivate = true, $fz), "~O,~N"); +c$.toJSON = Clazz.defineMethod (c$, "toJSON", +function (infoType, info) { +if (info == null) return javajs.util.PT.packageJSON (infoType, null); +if (javajs.util.PT.isNonStringPrimitive (info)) return javajs.util.PT.packageJSON (infoType, info.toString ()); +var s = null; +var sb = null; +while (true) { +if (Clazz.instanceOf (info, String)) { +s = info; +{ +if (typeof s == "undefined") s = "null" +}if (s.indexOf ("{\"") != 0) { +s = javajs.util.PT.rep (s, "\"", "\\\""); +s = javajs.util.PT.rep (s, "\n", "\\n"); +s = "\"" + s + "\""; +}break; +}if (Clazz.instanceOf (info, javajs.api.JSONEncodable)) { +if ((s = (info).toJSON ()) == null) s = "null"; +break; +}sb = new javajs.util.SB (); +if (Clazz.instanceOf (info, java.util.Map)) { +sb.append ("{ "); +var sep = ""; +for (var key, $key = (info).keySet ().iterator (); $key.hasNext () && ((key = $key.next ()) || true);) { +sb.append (sep).append (javajs.util.PT.packageJSON (key, javajs.util.PT.toJSON (null, (info).get (key)))); +sep = ","; +} +sb.append (" }"); +break; +}if (Clazz.instanceOf (info, javajs.util.Lst)) { +sb.append ("[ "); +var n = (info).size (); +for (var i = 0; i < n; i++) { +if (i > 0) sb.appendC (','); +sb.append (javajs.util.PT.toJSON (null, (info).get (i))); +} +sb.append (" ]"); +break; +}if (Clazz.instanceOf (info, javajs.util.M34)) { +var len = (Clazz.instanceOf (info, javajs.util.M4) ? 4 : 3); +var x = Clazz.newFloatArray (len, 0); +var m = info; +sb.appendC ('['); +for (var i = 0; i < len; i++) { +if (i > 0) sb.appendC (','); +m.getRow (i, x); +sb.append (javajs.util.PT.toJSON (null, x)); +} +sb.appendC (']'); +break; +}s = javajs.util.PT.nonArrayString (info); +if (s == null) { +sb.append ("["); +var n = javajs.util.AU.getLength (info); +for (var i = 0; i < n; i++) { +if (i > 0) sb.appendC (','); +sb.append (javajs.util.PT.toJSON (null, javajs.util.PT.arrayGet (info, i))); +} +sb.append ("]"); +break; +}info = info.toString (); +} +return javajs.util.PT.packageJSON (infoType, (s == null ? sb.toString () : s)); +}, "~S,~O"); +c$.nonArrayString = Clazz.defineMethod (c$, "nonArrayString", +function (x) { +{ +var s = x.toString(); return (s.startsWith("[object") && +s.endsWith("Array]") ? null : s); +}}, "~O"); +c$.byteArrayToJSON = Clazz.defineMethod (c$, "byteArrayToJSON", +function (data) { +var sb = new javajs.util.SB (); +sb.append ("["); +var n = data.length; +for (var i = 0; i < n; i++) { +if (i > 0) sb.appendC (','); +sb.appendI (data[i] & 0xFF); +} +sb.append ("]"); +return sb.toString (); +}, "~A"); +c$.packageJSON = Clazz.defineMethod (c$, "packageJSON", +function (infoType, info) { +return (infoType == null ? info : "\"" + infoType + "\": " + info); +}, "~S,~S"); +c$.escapeUrl = Clazz.defineMethod (c$, "escapeUrl", +function (url) { +url = javajs.util.PT.rep (url, "\n", ""); +url = javajs.util.PT.rep (url, "%", "%25"); +url = javajs.util.PT.rep (url, "#", "%23"); +url = javajs.util.PT.rep (url, "[", "%5B"); +url = javajs.util.PT.rep (url, "]", "%5D"); +url = javajs.util.PT.rep (url, " ", "%20"); +return url; +}, "~S"); +c$.esc = Clazz.defineMethod (c$, "esc", +function (str) { +if (str == null || str.length == 0) return "\"\""; +var haveEscape = false; +var i = 0; +for (; i < "\\\\\tt\rr\nn\"\"".length; i += 2) if (str.indexOf ("\\\\\tt\rr\nn\"\"".charAt (i)) >= 0) { +haveEscape = true; +break; +} +if (haveEscape) while (i < "\\\\\tt\rr\nn\"\"".length) { +var pt = -1; +var ch = "\\\\\tt\rr\nn\"\"".charAt (i++); +var ch2 = "\\\\\tt\rr\nn\"\"".charAt (i++); +var sb = new javajs.util.SB (); +var pt0 = 0; +while ((pt = str.indexOf (ch, pt + 1)) >= 0) { +sb.append (str.substring (pt0, pt)).appendC ('\\').appendC (ch2); +pt0 = pt + 1; +} +sb.append (str.substring (pt0, str.length)); +str = sb.toString (); +} +return "\"" + javajs.util.PT.escUnicode (str) + "\""; +}, "~S"); +c$.escUnicode = Clazz.defineMethod (c$, "escUnicode", +function (str) { +for (var i = str.length; --i >= 0; ) if (str.charCodeAt (i) > 0x7F) { +var s = "0000" + Integer.toHexString (str.charCodeAt (i)); +str = str.substring (0, i) + "\\u" + s.substring (s.length - 4) + str.substring (i + 1); +} +return str; +}, "~S"); +c$.escF = Clazz.defineMethod (c$, "escF", +function (f) { +var sf = "" + f; +{ +if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0) +sf += ".0"; +}return sf; +}, "~N"); +c$.join = Clazz.defineMethod (c$, "join", +function (s, c, i0) { +if (s.length < i0) return null; +var sb = new javajs.util.SB (); +sb.append (s[i0++]); +for (var i = i0; i < s.length; i++) sb.appendC (c).append (s[i]); + +return sb.toString (); +}, "~A,~S,~N"); +c$.isLike = Clazz.defineMethod (c$, "isLike", +function (a, b) { +var areEqual = a.equals (b); +if (areEqual) return true; +var isStart = b.startsWith ("*"); +var isEnd = b.endsWith ("*"); +return (!isStart && !isEnd) ? areEqual : isStart && isEnd ? b.length == 1 || a.contains (b.substring (1, b.length - 1)) : isStart ? a.endsWith (b.substring (1)) : a.startsWith (b.substring (0, b.length - 1)); +}, "~S,~S"); +c$.getMapValueNoCase = Clazz.defineMethod (c$, "getMapValueNoCase", +function (h, key) { +if ("this".equals (key)) return h; +var val = h.get (key); +if (val == null) for (var e, $e = h.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) if (e.getKey ().equalsIgnoreCase (key)) return e.getValue (); + +return val; +}, "java.util.Map,~S"); +c$.clean = Clazz.defineMethod (c$, "clean", +function (s) { +return javajs.util.PT.rep (javajs.util.PT.replaceAllCharacters (s, " \t\n\r", " "), " ", " ").trim (); +}, "~S"); +c$.fdup = Clazz.defineMethod (c$, "fdup", +function (f, pt, n) { +var ch; +var count = 0; +for (var i = pt; --i >= 1; ) { +if (javajs.util.PT.isDigit (ch = f.charAt (i))) continue; +switch (ch) { +case '.': +if (count++ != 0) return f; +continue; +case '-': +if (i != 1 && f.charAt (i - 1) != '.') return f; +continue; +default: +return f; +} +} +var s = f.substring (0, pt + 1); +var sb = new javajs.util.SB (); +for (var i = 0; i < n; i++) sb.append (s); + +sb.append (f.substring (pt + 1)); +return sb.toString (); +}, "~S,~N,~N"); +c$.formatString = Clazz.defineMethod (c$, "formatString", +function (strFormat, key, strT, floatT, doubleT, doOne) { +if (strFormat == null) return null; +if ("".equals (strFormat)) return ""; +var len = key.length; +if (strFormat.indexOf ("%") < 0 || len == 0 || strFormat.indexOf (key) < 0) return strFormat; +var strLabel = ""; +var ich; +var ichPercent; +var ichKey; +for (ich = 0; (ichPercent = strFormat.indexOf ('%', ich)) >= 0 && (ichKey = strFormat.indexOf (key, ichPercent + 1)) >= 0; ) { +if (ich != ichPercent) strLabel += strFormat.substring (ich, ichPercent); +ich = ichPercent + 1; +if (ichKey > ichPercent + 6) { +strLabel += '%'; +continue; +}try { +var alignLeft = false; +if (strFormat.charAt (ich) == '-') { +alignLeft = true; +++ich; +}var zeroPad = false; +if (strFormat.charAt (ich) == '0') { +zeroPad = true; +++ich; +}var ch; +var width = 0; +while ((ch = strFormat.charAt (ich)) >= '0' && (ch <= '9')) { +width = (10 * width) + (ch.charCodeAt (0) - 48); +++ich; +} +var precision = 2147483647; +var isExponential = false; +if (strFormat.charAt (ich) == '.') { +++ich; +if ((ch = strFormat.charAt (ich)) == '-') { +isExponential = true; +++ich; +}if ((ch = strFormat.charAt (ich)) >= '0' && ch <= '9') { +precision = ch.charCodeAt (0) - 48; +++ich; +}if (isExponential) precision = -precision - (strT == null ? 1 : 0); +}var st = strFormat.substring (ich, ich + len); +if (!st.equals (key)) { +ich = ichPercent + 1; +strLabel += '%'; +continue; +}ich += len; +if (!Float.isNaN (floatT)) strLabel += javajs.util.PT.formatF (floatT, width, precision, alignLeft, zeroPad); + else if (strT != null) strLabel += javajs.util.PT.formatS (strT, width, precision, alignLeft, zeroPad); + else if (!Double.isNaN (doubleT)) strLabel += javajs.util.PT.formatD (doubleT, width, precision, alignLeft, zeroPad, true); +if (doOne) break; +} catch (ioobe) { +if (Clazz.exceptionOf (ioobe, IndexOutOfBoundsException)) { +ich = ichPercent; +break; +} else { +throw ioobe; +} +} +} +strLabel += strFormat.substring (ich); +return strLabel; +}, "~S,~S,~S,~N,~N,~B"); +c$.formatStringS = Clazz.defineMethod (c$, "formatStringS", +function (strFormat, key, strT) { +return javajs.util.PT.formatString (strFormat, key, strT, NaN, NaN, false); +}, "~S,~S,~S"); +c$.formatStringF = Clazz.defineMethod (c$, "formatStringF", +function (strFormat, key, floatT) { +return javajs.util.PT.formatString (strFormat, key, null, floatT, NaN, false); +}, "~S,~S,~N"); +c$.formatStringI = Clazz.defineMethod (c$, "formatStringI", +function (strFormat, key, intT) { +return javajs.util.PT.formatString (strFormat, key, "" + intT, NaN, NaN, false); +}, "~S,~S,~N"); +c$.sprintf = Clazz.defineMethod (c$, "sprintf", +function (strFormat, list, values) { +if (values == null) return strFormat; +var n = list.length; +if (n == values.length) try { +for (var o = 0; o < n; o++) { +if (values[o] == null) continue; +switch (list.charAt (o)) { +case 's': +strFormat = javajs.util.PT.formatString (strFormat, "s", values[o], NaN, NaN, true); +break; +case 'f': +strFormat = javajs.util.PT.formatString (strFormat, "f", null, (values[o]).floatValue (), NaN, true); +break; +case 'i': +strFormat = javajs.util.PT.formatString (strFormat, "d", "" + values[o], NaN, NaN, true); +strFormat = javajs.util.PT.formatString (strFormat, "i", "" + values[o], NaN, NaN, true); +break; +case 'd': +strFormat = javajs.util.PT.formatString (strFormat, "e", null, NaN, (values[o]).doubleValue (), true); +break; +case 'p': +var pVal = values[o]; +strFormat = javajs.util.PT.formatString (strFormat, "p", null, pVal.x, NaN, true); +strFormat = javajs.util.PT.formatString (strFormat, "p", null, pVal.y, NaN, true); +strFormat = javajs.util.PT.formatString (strFormat, "p", null, pVal.z, NaN, true); +break; +case 'q': +var qVal = values[o]; +strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.x, NaN, true); +strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.y, NaN, true); +strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.z, NaN, true); +strFormat = javajs.util.PT.formatString (strFormat, "q", null, qVal.w, NaN, true); +break; +case 'S': +var sVal = values[o]; +for (var i = 0; i < sVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "s", sVal[i], NaN, NaN, true); + +break; +case 'F': +var fVal = values[o]; +for (var i = 0; i < fVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "f", null, fVal[i], NaN, true); + +break; +case 'I': +var iVal = values[o]; +for (var i = 0; i < iVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "d", "" + iVal[i], NaN, NaN, true); + +for (var i = 0; i < iVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "i", "" + iVal[i], NaN, NaN, true); + +break; +case 'D': +var dVal = values[o]; +for (var i = 0; i < dVal.length; i++) strFormat = javajs.util.PT.formatString (strFormat, "e", null, NaN, dVal[i], true); + +} +} +return javajs.util.PT.rep (strFormat, "%%", "%"); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +System.out.println ("TextFormat.sprintf error " + list + " " + strFormat); +return javajs.util.PT.rep (strFormat, "%", "?"); +}, "~S,~S,~A"); +c$.formatCheck = Clazz.defineMethod (c$, "formatCheck", +function (strFormat) { +if (strFormat == null || strFormat.indexOf ('p') < 0 && strFormat.indexOf ('q') < 0) return strFormat; +strFormat = javajs.util.PT.rep (strFormat, "%%", "\1"); +strFormat = javajs.util.PT.rep (strFormat, "%p", "%6.2p"); +strFormat = javajs.util.PT.rep (strFormat, "%q", "%6.2q"); +var format = javajs.util.PT.split (strFormat, "%"); +var sb = new javajs.util.SB (); +sb.append (format[0]); +for (var i = 1; i < format.length; i++) { +var f = "%" + format[i]; +var pt; +if (f.length >= 3) { +if ((pt = f.indexOf ('p')) >= 0) f = javajs.util.PT.fdup (f, pt, 3); +if ((pt = f.indexOf ('q')) >= 0) f = javajs.util.PT.fdup (f, pt, 4); +}sb.append (f); +} +return sb.toString ().$replace ('\1', '%'); +}, "~S"); +c$.leftJustify = Clazz.defineMethod (c$, "leftJustify", +function (s, s1, s2) { +s.append (s2); +var n = s1.length - s2.length; +if (n > 0) s.append (s1.substring (0, n)); +}, "javajs.util.SB,~S,~S"); +c$.rightJustify = Clazz.defineMethod (c$, "rightJustify", +function (s, s1, s2) { +var n = s1.length - s2.length; +if (n > 0) s.append (s1.substring (0, n)); +s.append (s2); +}, "javajs.util.SB,~S,~S"); +c$.safeTruncate = Clazz.defineMethod (c$, "safeTruncate", +function (f, n) { +if (f > -0.001 && f < 0.001) f = 0; +return (f + " ").substring (0, n); +}, "~N,~N"); +c$.isWild = Clazz.defineMethod (c$, "isWild", +function (s) { +return s != null && (s.indexOf ("*") >= 0 || s.indexOf ("?") >= 0); +}, "~S"); +c$.isMatch = Clazz.defineMethod (c$, "isMatch", +function (search, match, checkStar, allowInitialStar) { +if (search.equals (match)) return true; +var mLen = match.length; +if (mLen == 0) return false; +var isStar0 = (checkStar && allowInitialStar ? match.charAt (0) == '*' : false); +if (mLen == 1 && isStar0) return true; +var isStar1 = (checkStar && match.endsWith ("*")); +var haveQ = (match.indexOf ('?') >= 0); +if (!haveQ) { +if (isStar0) return (isStar1 ? (mLen < 3 || search.indexOf (match.substring (1, mLen - 1)) >= 0) : search.endsWith (match.substring (1))); + else if (isStar1) return search.startsWith (match.substring (0, mLen - 1)); +}var sLen = search.length; +var qqqq = "????"; +var nq = 4; +while (nq < sLen) { +qqqq += qqqq; +nq += 4; +} +if (checkStar) { +if (isStar0) { +match = qqqq + match.substring (1); +mLen += nq - 1; +}if (isStar1) { +match = match.substring (0, mLen - 1) + qqqq; +mLen += nq - 1; +}}if (mLen < sLen) return false; +var ich = 0; +while (mLen > sLen) { +if (allowInitialStar && match.charAt (ich) == '?') { +++ich; +} else if (match.charAt (ich + mLen - 1) != '?') { +return false; +}--mLen; +} +for (var i = sLen; --i >= 0; ) { +var chm = match.charAt (ich + i); +if (chm == '?') continue; +var chs = search.charAt (i); +if (chm != chs && (chm != '\1' || chs != '?')) return false; +} +return true; +}, "~S,~S,~B,~B"); +c$.replaceQuotedStrings = Clazz.defineMethod (c$, "replaceQuotedStrings", +function (s, list, newList) { +var n = list.size (); +for (var i = 0; i < n; i++) { +var name = list.get (i); +var newName = newList.get (i); +if (!newName.equals (name)) s = javajs.util.PT.rep (s, "\"" + name + "\"", "\"" + newName + "\""); +} +return s; +}, "~S,javajs.util.Lst,javajs.util.Lst"); +c$.replaceStrings = Clazz.defineMethod (c$, "replaceStrings", +function (s, list, newList) { +var n = list.size (); +for (var i = 0; i < n; i++) { +var name = list.get (i); +var newName = newList.get (i); +if (!newName.equals (name)) s = javajs.util.PT.rep (s, name, newName); +} +return s; +}, "~S,javajs.util.Lst,javajs.util.Lst"); +c$.isDigit = Clazz.defineMethod (c$, "isDigit", +function (ch) { +var c = (ch).charCodeAt (0); +return (48 <= c && c <= 57); +}, "~S"); +c$.isUpperCase = Clazz.defineMethod (c$, "isUpperCase", +function (ch) { +var c = (ch).charCodeAt (0); +return (65 <= c && c <= 90); +}, "~S"); +c$.isLowerCase = Clazz.defineMethod (c$, "isLowerCase", +function (ch) { +var c = (ch).charCodeAt (0); +return (97 <= c && c <= 122); +}, "~S"); +c$.isLetter = Clazz.defineMethod (c$, "isLetter", +function (ch) { +var c = (ch).charCodeAt (0); +return (65 <= c && c <= 90 || 97 <= c && c <= 122); +}, "~S"); +c$.isLetterOrDigit = Clazz.defineMethod (c$, "isLetterOrDigit", +function (ch) { +var c = (ch).charCodeAt (0); +return (65 <= c && c <= 90 || 97 <= c && c <= 122 || 48 <= c && c <= 57); +}, "~S"); +c$.isWhitespace = Clazz.defineMethod (c$, "isWhitespace", +function (ch) { +var c = (ch).charCodeAt (0); +return (c >= 0x1c && c <= 0x20 || c >= 0x9 && c <= 0xd); +}, "~S"); +c$.fixPtFloats = Clazz.defineMethod (c$, "fixPtFloats", +function (pt, f) { +pt.x = Math.round (pt.x * f) / f; +pt.y = Math.round (pt.y * f) / f; +pt.z = Math.round (pt.z * f) / f; +}, "javajs.util.T3,~N"); +c$.fixDouble = Clazz.defineMethod (c$, "fixDouble", +function (d, f) { +return Math.round (d * f) / f; +}, "~N,~N"); +c$.parseFloatFraction = Clazz.defineMethod (c$, "parseFloatFraction", +function (s) { +var pt = s.indexOf ("/"); +return (pt < 0 ? javajs.util.PT.parseFloat (s) : javajs.util.PT.parseFloat (s.substring (0, pt)) / javajs.util.PT.parseFloat (s.substring (pt + 1))); +}, "~S"); +Clazz.defineStatics (c$, +"tensScale", Clazz.newFloatArray (-1, [10, 100, 1000, 10000, 100000, 1000000]), +"decimalScale", Clazz.newFloatArray (-1, [0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001, 0.00000001, 0.000000001]), +"FLOAT_MIN_SAFE", 2E-45, +"escapable", "\\\\\tt\rr\nn\"\"", +"FRACTIONAL_PRECISION", 100000, +"CARTESIAN_PRECISION", 10000); +}); diff --git a/bin/javajs/util/Quat.js b/bin/javajs/util/Quat.js index bfc5444..0db2469 100644 --- a/bin/javajs/util/Quat.js +++ b/bin/javajs/util/Quat.js @@ -1,427 +1,427 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.P4"], "javajs.util.Quat", ["java.lang.Float", "javajs.util.A4", "$.M3", "$.V3"], function () { -c$ = Clazz.decorateAsClass (function () { -this.q0 = 0; -this.q1 = 0; -this.q2 = 0; -this.q3 = 0; -this.mat = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "Quat"); -Clazz.makeConstructor (c$, -function () { -this.q0 = 1; -}); -c$.newQ = Clazz.defineMethod (c$, "newQ", -function (q) { -var q1 = new javajs.util.Quat (); -q1.set (q); -return q1; -}, "javajs.util.Quat"); -c$.newVA = Clazz.defineMethod (c$, "newVA", -function (v, theta) { -var q = new javajs.util.Quat (); -q.setTA (v, theta); -return q; -}, "javajs.util.T3,~N"); -c$.newM = Clazz.defineMethod (c$, "newM", -function (mat) { -var q = new javajs.util.Quat (); -q.setM (javajs.util.M3.newM3 (mat)); -return q; -}, "javajs.util.M3"); -c$.newAA = Clazz.defineMethod (c$, "newAA", -function (a) { -var q = new javajs.util.Quat (); -q.setAA (a); -return q; -}, "javajs.util.A4"); -c$.newP4 = Clazz.defineMethod (c$, "newP4", -function (pt) { -var q = new javajs.util.Quat (); -q.setP4 (pt); -return q; -}, "javajs.util.P4"); -c$.new4 = Clazz.defineMethod (c$, "new4", -function (q1, q2, q3, q0) { -var q = new javajs.util.Quat (); -if (q0 < -1) { -q.q0 = -1; -return q; -}if (q0 > 1) { -q.q0 = 1; -return q; -}q.q0 = q0; -q.q1 = q1; -q.q2 = q2; -q.q3 = q3; -return q; -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "set", -function (q) { -this.q0 = q.q0; -this.q1 = q.q1; -this.q2 = q.q2; -this.q3 = q.q3; -}, "javajs.util.Quat"); -Clazz.defineMethod (c$, "setP4", -($fz = function (pt) { -var factor = (pt == null ? 0 : pt.distance4 (javajs.util.Quat.qZero)); -if (factor == 0) { -this.q0 = 1; -return; -}this.q0 = pt.w / factor; -this.q1 = pt.x / factor; -this.q2 = pt.y / factor; -this.q3 = pt.z / factor; -}, $fz.isPrivate = true, $fz), "javajs.util.P4"); -Clazz.defineMethod (c$, "setTA", -function (pt, theta) { -if (pt.x == 0 && pt.y == 0 && pt.z == 0) { -this.q0 = 1; -return; -}var fact = (Math.sin (theta / 2 * 0.017453292519943295) / Math.sqrt (pt.x * pt.x + pt.y * pt.y + pt.z * pt.z)); -this.q0 = (Math.cos (theta / 2 * 0.017453292519943295)); -this.q1 = (pt.x * fact); -this.q2 = (pt.y * fact); -this.q3 = (pt.z * fact); -}, "javajs.util.T3,~N"); -Clazz.defineMethod (c$, "setAA", -function (a) { -var aa = javajs.util.A4.newAA (a); -if (aa.angle == 0) aa.y = 1; -this.setM ( new javajs.util.M3 ().setAA (aa)); -}, "javajs.util.A4"); -Clazz.defineMethod (c$, "setM", -($fz = function (mat) { -this.mat = mat; -var trace = mat.m00 + mat.m11 + mat.m22; -var temp; -var w; -var x; -var y; -var z; -if (trace >= 0.5) { -w = Math.sqrt (1.0 + trace); -x = (mat.m21 - mat.m12) / w; -y = (mat.m02 - mat.m20) / w; -z = (mat.m10 - mat.m01) / w; -} else if ((temp = mat.m00 + mat.m00 - trace) >= 0.5) { -x = Math.sqrt (1.0 + temp); -w = (mat.m21 - mat.m12) / x; -y = (mat.m10 + mat.m01) / x; -z = (mat.m20 + mat.m02) / x; -} else if ((temp = mat.m11 + mat.m11 - trace) >= 0.5 || mat.m11 > mat.m22) { -y = Math.sqrt (1.0 + temp); -w = (mat.m02 - mat.m20) / y; -x = (mat.m10 + mat.m01) / y; -z = (mat.m21 + mat.m12) / y; -} else { -z = Math.sqrt (1.0 + mat.m22 + mat.m22 - trace); -w = (mat.m10 - mat.m01) / z; -x = (mat.m20 + mat.m02) / z; -y = (mat.m21 + mat.m12) / z; -}this.q0 = (w * 0.5); -this.q1 = (x * 0.5); -this.q2 = (y * 0.5); -this.q3 = (z * 0.5); -}, $fz.isPrivate = true, $fz), "javajs.util.M3"); -Clazz.defineMethod (c$, "setRef", -function (qref) { -if (qref == null) { -this.mul (this.getFixFactor ()); -return; -}if (this.dot (qref) >= 0) return; -this.q0 *= -1; -this.q1 *= -1; -this.q2 *= -1; -this.q3 *= -1; -}, "javajs.util.Quat"); -c$.getQuaternionFrame = Clazz.defineMethod (c$, "getQuaternionFrame", -function (center, x, xy) { -var vA = javajs.util.V3.newV (x); -var vB = javajs.util.V3.newV (xy); -if (center != null) { -vA.sub (center); -vB.sub (center); -}return javajs.util.Quat.getQuaternionFrameV (vA, vB, null, false); -}, "javajs.util.P3,javajs.util.T3,javajs.util.T3"); -c$.getQuaternionFrameV = Clazz.defineMethod (c$, "getQuaternionFrameV", -function (vA, vB, vC, yBased) { -if (vC == null) { -vC = new javajs.util.V3 (); -vC.cross (vA, vB); -if (yBased) vA.cross (vB, vC); -}var vBprime = new javajs.util.V3 (); -vBprime.cross (vC, vA); -vA.normalize (); -vBprime.normalize (); -vC.normalize (); -var mat = new javajs.util.M3 (); -mat.setColumnV (0, vA); -mat.setColumnV (1, vBprime); -mat.setColumnV (2, vC); -var q = javajs.util.Quat.newM (mat); -return q; -}, "javajs.util.V3,javajs.util.V3,javajs.util.V3,~B"); -Clazz.defineMethod (c$, "getMatrix", -function () { -if (this.mat == null) this.setMatrix (); -return this.mat; -}); -Clazz.defineMethod (c$, "setMatrix", -($fz = function () { -this.mat = new javajs.util.M3 (); -this.mat.m00 = this.q0 * this.q0 + this.q1 * this.q1 - this.q2 * this.q2 - this.q3 * this.q3; -this.mat.m01 = 2 * this.q1 * this.q2 - 2 * this.q0 * this.q3; -this.mat.m02 = 2 * this.q1 * this.q3 + 2 * this.q0 * this.q2; -this.mat.m10 = 2 * this.q1 * this.q2 + 2 * this.q0 * this.q3; -this.mat.m11 = this.q0 * this.q0 - this.q1 * this.q1 + this.q2 * this.q2 - this.q3 * this.q3; -this.mat.m12 = 2 * this.q2 * this.q3 - 2 * this.q0 * this.q1; -this.mat.m20 = 2 * this.q1 * this.q3 - 2 * this.q0 * this.q2; -this.mat.m21 = 2 * this.q2 * this.q3 + 2 * this.q0 * this.q1; -this.mat.m22 = this.q0 * this.q0 - this.q1 * this.q1 - this.q2 * this.q2 + this.q3 * this.q3; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "add", -function (x) { -return javajs.util.Quat.newVA (this.getNormal (), this.getTheta () + x); -}, "~N"); -Clazz.defineMethod (c$, "mul", -function (x) { -return (x == 1 ? javajs.util.Quat.new4 (this.q1, this.q2, this.q3, this.q0) : javajs.util.Quat.newVA (this.getNormal (), this.getTheta () * x)); -}, "~N"); -Clazz.defineMethod (c$, "mulQ", -function (p) { -return javajs.util.Quat.new4 (this.q0 * p.q1 + this.q1 * p.q0 + this.q2 * p.q3 - this.q3 * p.q2, this.q0 * p.q2 + this.q2 * p.q0 + this.q3 * p.q1 - this.q1 * p.q3, this.q0 * p.q3 + this.q3 * p.q0 + this.q1 * p.q2 - this.q2 * p.q1, this.q0 * p.q0 - this.q1 * p.q1 - this.q2 * p.q2 - this.q3 * p.q3); -}, "javajs.util.Quat"); -Clazz.defineMethod (c$, "div", -function (p) { -return this.mulQ (p.inv ()); -}, "javajs.util.Quat"); -Clazz.defineMethod (c$, "divLeft", -function (p) { -return this.inv ().mulQ (p); -}, "javajs.util.Quat"); -Clazz.defineMethod (c$, "dot", -function (q) { -return this.q0 * q.q0 + this.q1 * q.q1 + this.q2 * q.q2 + this.q3 * q.q3; -}, "javajs.util.Quat"); -Clazz.defineMethod (c$, "inv", -function () { -return javajs.util.Quat.new4 (-this.q1, -this.q2, -this.q3, this.q0); -}); -Clazz.defineMethod (c$, "negate", -function () { -return javajs.util.Quat.new4 (-this.q1, -this.q2, -this.q3, -this.q0); -}); -Clazz.defineMethod (c$, "getFixFactor", -($fz = function () { -return (this.q0 < 0 || this.q0 == 0 && (this.q1 < 0 || this.q1 == 0 && (this.q2 < 0 || this.q2 == 0 && this.q3 < 0)) ? -1 : 1); -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getVector", -function (i) { -return this.getVectorScaled (i, 1); -}, "~N"); -Clazz.defineMethod (c$, "getVectorScaled", -function (i, scale) { -if (i == -1) { -scale *= this.getFixFactor (); -return javajs.util.V3.new3 (this.q1 * scale, this.q2 * scale, this.q3 * scale); -}if (this.mat == null) this.setMatrix (); -var v = new javajs.util.V3 (); -this.mat.getColumnV (i, v); -if (scale != 1) v.scale (scale); -return v; -}, "~N,~N"); -Clazz.defineMethod (c$, "getNormal", -function () { -var v = javajs.util.Quat.getRawNormal (this); -v.scale (this.getFixFactor ()); -return v; -}); -c$.getRawNormal = Clazz.defineMethod (c$, "getRawNormal", -($fz = function (q) { -var v = javajs.util.V3.new3 (q.q1, q.q2, q.q3); -if (v.length () == 0) return javajs.util.V3.new3 (0, 0, 1); -v.normalize (); -return v; -}, $fz.isPrivate = true, $fz), "javajs.util.Quat"); -Clazz.defineMethod (c$, "getTheta", -function () { -return (Math.acos (Math.abs (this.q0)) * 2 * 180 / 3.141592653589793); -}); -Clazz.defineMethod (c$, "getThetaRadians", -function () { -return (Math.acos (Math.abs (this.q0)) * 2); -}); -Clazz.defineMethod (c$, "getNormalDirected", -function (v0) { -var v = this.getNormal (); -if (v.x * v0.x + v.y * v0.y + v.z * v0.z < 0) { -v.scale (-1); -}return v; -}, "javajs.util.V3"); -Clazz.defineMethod (c$, "get3dProjection", -function (v3d) { -v3d.set (this.q1, this.q2, this.q3); -return v3d; -}, "javajs.util.V3"); -Clazz.defineMethod (c$, "getThetaDirected", -function (axisAngle) { -var theta = this.getTheta (); -var v = this.getNormal (); -if (axisAngle.x * this.q1 + axisAngle.y * this.q2 + axisAngle.z * this.q3 < 0) { -v.scale (-1); -theta = -theta; -}axisAngle.set4 (v.x, v.y, v.z, theta); -return axisAngle; -}, "javajs.util.P4"); -Clazz.defineMethod (c$, "getThetaDirectedV", -function (vector) { -var theta = this.getTheta (); -var v = this.getNormal (); -if (vector.x * this.q1 + vector.y * this.q2 + vector.z * this.q3 < 0) { -v.scale (-1); -theta = -theta; -}return theta; -}, "javajs.util.V3"); -Clazz.defineMethod (c$, "toPoint4f", -function () { -return javajs.util.P4.new4 (this.q1, this.q2, this.q3, this.q0); -}); -Clazz.defineMethod (c$, "toAxisAngle4f", -function () { -var theta = 2 * Math.acos (Math.abs (this.q0)); -var sinTheta2 = Math.sin (theta / 2); -var v = this.getNormal (); -if (sinTheta2 < 0) { -v.scale (-1); -theta = 3.141592653589793 - theta; -}return javajs.util.A4.newVA (v, theta); -}); -Clazz.defineMethod (c$, "transform2", -function (pt, ptNew) { -if (this.mat == null) this.setMatrix (); -this.mat.rotate2 (pt, ptNew); -return ptNew; -}, "javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "leftDifference", -function (q2) { -var q2adjusted = (this.dot (q2) < 0 ? q2.negate () : q2); -return this.inv ().mulQ (q2adjusted); -}, "javajs.util.Quat"); -Clazz.defineMethod (c$, "rightDifference", -function (q2) { -var q2adjusted = (this.dot (q2) < 0 ? q2.negate () : q2); -return this.mulQ (q2adjusted.inv ()); -}, "javajs.util.Quat"); -Clazz.overrideMethod (c$, "toString", -function () { -return "{" + this.q1 + " " + this.q2 + " " + this.q3 + " " + this.q0 + "}"; -}); -c$.div = Clazz.defineMethod (c$, "div", -function (data1, data2, nMax, isRelative) { -var n; -if (data1 == null || data2 == null || (n = Math.min (data1.length, data2.length)) == 0) return null; -if (nMax > 0 && n > nMax) n = nMax; -var dqs = new Array (n); -for (var i = 0; i < n; i++) { -if (data1[i] == null || data2[i] == null) return null; -dqs[i] = (isRelative ? data1[i].divLeft (data2[i]) : data1[i].div (data2[i])); -} -return dqs; -}, "~A,~A,~N,~B"); -c$.sphereMean = Clazz.defineMethod (c$, "sphereMean", -function (data, retStddev, criterion) { -if (data == null || data.length == 0) return new javajs.util.Quat (); -if (retStddev == null) retStddev = Clazz.newFloatArray (1, 0); -if (data.length == 1) { -retStddev[0] = 0; -return javajs.util.Quat.newQ (data[0]); -}var diff = 3.4028235E38; -var lastStddev = 3.4028235E38; -var qMean = javajs.util.Quat.simpleAverage (data); -var maxIter = 100; -var iter = 0; -while (diff > criterion && lastStddev != 0 && iter < maxIter) { -qMean = javajs.util.Quat.newMean (data, qMean); -retStddev[0] = javajs.util.Quat.stdDev (data, qMean); -diff = Math.abs (retStddev[0] - lastStddev); -lastStddev = retStddev[0]; -} -return qMean; -}, "~A,~A,~N"); -c$.simpleAverage = Clazz.defineMethod (c$, "simpleAverage", -($fz = function (ndata) { -var mean = javajs.util.V3.new3 (0, 0, 1); -var v = ndata[0].getNormal (); -mean.add (v); -for (var i = ndata.length; --i >= 0; ) mean.add (ndata[i].getNormalDirected (mean)); - -mean.sub (v); -mean.normalize (); -var f = 0; -for (var i = ndata.length; --i >= 0; ) f += Math.abs (ndata[i].get3dProjection (v).dot (mean)); - -if (f != 0) mean.scale (f / ndata.length); -f = Math.sqrt (1 - mean.lengthSquared ()); -if (Float.isNaN (f)) f = 0; -return javajs.util.Quat.newP4 (javajs.util.P4.new4 (mean.x, mean.y, mean.z, f)); -}, $fz.isPrivate = true, $fz), "~A"); -c$.newMean = Clazz.defineMethod (c$, "newMean", -($fz = function (data, mean) { -var sum = new javajs.util.V3 (); -var v; -var q; -var dq; -for (var i = data.length; --i >= 0; ) { -q = data[i]; -dq = q.div (mean); -v = dq.getNormal (); -v.scale (dq.getTheta ()); -sum.add (v); -} -sum.scale (1 / data.length); -var dqMean = javajs.util.Quat.newVA (sum, sum.length ()); -return dqMean.mulQ (mean); -}, $fz.isPrivate = true, $fz), "~A,javajs.util.Quat"); -c$.stdDev = Clazz.defineMethod (c$, "stdDev", -($fz = function (data, mean) { -var sum2 = 0; -var n = data.length; -for (var i = n; --i >= 0; ) { -var theta = data[i].div (mean).getTheta (); -sum2 += theta * theta; -} -return Math.sqrt (sum2 / n); -}, $fz.isPrivate = true, $fz), "~A,javajs.util.Quat"); -Clazz.defineMethod (c$, "getEulerZYZ", -function () { -var rA; -var rB; -var rG; -if (this.q1 == 0 && this.q2 == 0) { -var theta = this.getTheta (); -return Clazz.newFloatArray (-1, [this.q3 < 0 ? -theta : theta, 0, 0]); -}rA = Math.atan2 (2 * (this.q2 * this.q3 + this.q0 * this.q1), 2 * (-this.q1 * this.q3 + this.q0 * this.q2)); -rB = Math.acos (this.q3 * this.q3 - this.q2 * this.q2 - this.q1 * this.q1 + this.q0 * this.q0); -rG = Math.atan2 (2 * (this.q2 * this.q3 - this.q0 * this.q1), 2 * (this.q0 * this.q2 + this.q1 * this.q3)); -return Clazz.newFloatArray (-1, [(rA / 0.017453292519943295), (rB / 0.017453292519943295), (rG / 0.017453292519943295)]); -}); -Clazz.defineMethod (c$, "getEulerZXZ", -function () { -var rA; -var rB; -var rG; -if (this.q1 == 0 && this.q2 == 0) { -var theta = this.getTheta (); -return Clazz.newFloatArray (-1, [this.q3 < 0 ? -theta : theta, 0, 0]); -}rA = Math.atan2 (2 * (this.q1 * this.q3 - this.q0 * this.q2), 2 * (this.q0 * this.q1 + this.q2 * this.q3)); -rB = Math.acos (this.q3 * this.q3 - this.q2 * this.q2 - this.q1 * this.q1 + this.q0 * this.q0); -rG = Math.atan2 (2 * (this.q1 * this.q3 + this.q0 * this.q2), 2 * (-this.q2 * this.q3 + this.q0 * this.q1)); -return Clazz.newFloatArray (-1, [(rA / 0.017453292519943295), (rB / 0.017453292519943295), (rG / 0.017453292519943295)]); -}); -c$.qZero = c$.prototype.qZero = new javajs.util.P4 (); -Clazz.defineStatics (c$, -"RAD_PER_DEG", 0.017453292519943295); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.P4"], "javajs.util.Quat", ["java.lang.Float", "javajs.util.A4", "$.M3", "$.V3"], function () { +c$ = Clazz.decorateAsClass (function () { +this.q0 = 0; +this.q1 = 0; +this.q2 = 0; +this.q3 = 0; +this.mat = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "Quat"); +Clazz.makeConstructor (c$, +function () { +this.q0 = 1; +}); +c$.newQ = Clazz.defineMethod (c$, "newQ", +function (q) { +var q1 = new javajs.util.Quat (); +q1.set (q); +return q1; +}, "javajs.util.Quat"); +c$.newVA = Clazz.defineMethod (c$, "newVA", +function (v, theta) { +var q = new javajs.util.Quat (); +q.setTA (v, theta); +return q; +}, "javajs.util.T3,~N"); +c$.newM = Clazz.defineMethod (c$, "newM", +function (mat) { +var q = new javajs.util.Quat (); +q.setM (javajs.util.M3.newM3 (mat)); +return q; +}, "javajs.util.M3"); +c$.newAA = Clazz.defineMethod (c$, "newAA", +function (a) { +var q = new javajs.util.Quat (); +q.setAA (a); +return q; +}, "javajs.util.A4"); +c$.newP4 = Clazz.defineMethod (c$, "newP4", +function (pt) { +var q = new javajs.util.Quat (); +q.setP4 (pt); +return q; +}, "javajs.util.P4"); +c$.new4 = Clazz.defineMethod (c$, "new4", +function (q1, q2, q3, q0) { +var q = new javajs.util.Quat (); +if (q0 < -1) { +q.q0 = -1; +return q; +}if (q0 > 1) { +q.q0 = 1; +return q; +}q.q0 = q0; +q.q1 = q1; +q.q2 = q2; +q.q3 = q3; +return q; +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "set", +function (q) { +this.q0 = q.q0; +this.q1 = q.q1; +this.q2 = q.q2; +this.q3 = q.q3; +}, "javajs.util.Quat"); +Clazz.defineMethod (c$, "setP4", +($fz = function (pt) { +var factor = (pt == null ? 0 : pt.distance4 (javajs.util.Quat.qZero)); +if (factor == 0) { +this.q0 = 1; +return; +}this.q0 = pt.w / factor; +this.q1 = pt.x / factor; +this.q2 = pt.y / factor; +this.q3 = pt.z / factor; +}, $fz.isPrivate = true, $fz), "javajs.util.P4"); +Clazz.defineMethod (c$, "setTA", +function (pt, theta) { +if (pt.x == 0 && pt.y == 0 && pt.z == 0) { +this.q0 = 1; +return; +}var fact = (Math.sin (theta / 2 * 0.017453292519943295) / Math.sqrt (pt.x * pt.x + pt.y * pt.y + pt.z * pt.z)); +this.q0 = (Math.cos (theta / 2 * 0.017453292519943295)); +this.q1 = (pt.x * fact); +this.q2 = (pt.y * fact); +this.q3 = (pt.z * fact); +}, "javajs.util.T3,~N"); +Clazz.defineMethod (c$, "setAA", +function (a) { +var aa = javajs.util.A4.newAA (a); +if (aa.angle == 0) aa.y = 1; +this.setM ( new javajs.util.M3 ().setAA (aa)); +}, "javajs.util.A4"); +Clazz.defineMethod (c$, "setM", +($fz = function (mat) { +this.mat = mat; +var trace = mat.m00 + mat.m11 + mat.m22; +var temp; +var w; +var x; +var y; +var z; +if (trace >= 0.5) { +w = Math.sqrt (1.0 + trace); +x = (mat.m21 - mat.m12) / w; +y = (mat.m02 - mat.m20) / w; +z = (mat.m10 - mat.m01) / w; +} else if ((temp = mat.m00 + mat.m00 - trace) >= 0.5) { +x = Math.sqrt (1.0 + temp); +w = (mat.m21 - mat.m12) / x; +y = (mat.m10 + mat.m01) / x; +z = (mat.m20 + mat.m02) / x; +} else if ((temp = mat.m11 + mat.m11 - trace) >= 0.5 || mat.m11 > mat.m22) { +y = Math.sqrt (1.0 + temp); +w = (mat.m02 - mat.m20) / y; +x = (mat.m10 + mat.m01) / y; +z = (mat.m21 + mat.m12) / y; +} else { +z = Math.sqrt (1.0 + mat.m22 + mat.m22 - trace); +w = (mat.m10 - mat.m01) / z; +x = (mat.m20 + mat.m02) / z; +y = (mat.m21 + mat.m12) / z; +}this.q0 = (w * 0.5); +this.q1 = (x * 0.5); +this.q2 = (y * 0.5); +this.q3 = (z * 0.5); +}, $fz.isPrivate = true, $fz), "javajs.util.M3"); +Clazz.defineMethod (c$, "setRef", +function (qref) { +if (qref == null) { +this.mul (this.getFixFactor ()); +return; +}if (this.dot (qref) >= 0) return; +this.q0 *= -1; +this.q1 *= -1; +this.q2 *= -1; +this.q3 *= -1; +}, "javajs.util.Quat"); +c$.getQuaternionFrame = Clazz.defineMethod (c$, "getQuaternionFrame", +function (center, x, xy) { +var vA = javajs.util.V3.newV (x); +var vB = javajs.util.V3.newV (xy); +if (center != null) { +vA.sub (center); +vB.sub (center); +}return javajs.util.Quat.getQuaternionFrameV (vA, vB, null, false); +}, "javajs.util.P3,javajs.util.T3,javajs.util.T3"); +c$.getQuaternionFrameV = Clazz.defineMethod (c$, "getQuaternionFrameV", +function (vA, vB, vC, yBased) { +if (vC == null) { +vC = new javajs.util.V3 (); +vC.cross (vA, vB); +if (yBased) vA.cross (vB, vC); +}var vBprime = new javajs.util.V3 (); +vBprime.cross (vC, vA); +vA.normalize (); +vBprime.normalize (); +vC.normalize (); +var mat = new javajs.util.M3 (); +mat.setColumnV (0, vA); +mat.setColumnV (1, vBprime); +mat.setColumnV (2, vC); +var q = javajs.util.Quat.newM (mat); +return q; +}, "javajs.util.V3,javajs.util.V3,javajs.util.V3,~B"); +Clazz.defineMethod (c$, "getMatrix", +function () { +if (this.mat == null) this.setMatrix (); +return this.mat; +}); +Clazz.defineMethod (c$, "setMatrix", +($fz = function () { +this.mat = new javajs.util.M3 (); +this.mat.m00 = this.q0 * this.q0 + this.q1 * this.q1 - this.q2 * this.q2 - this.q3 * this.q3; +this.mat.m01 = 2 * this.q1 * this.q2 - 2 * this.q0 * this.q3; +this.mat.m02 = 2 * this.q1 * this.q3 + 2 * this.q0 * this.q2; +this.mat.m10 = 2 * this.q1 * this.q2 + 2 * this.q0 * this.q3; +this.mat.m11 = this.q0 * this.q0 - this.q1 * this.q1 + this.q2 * this.q2 - this.q3 * this.q3; +this.mat.m12 = 2 * this.q2 * this.q3 - 2 * this.q0 * this.q1; +this.mat.m20 = 2 * this.q1 * this.q3 - 2 * this.q0 * this.q2; +this.mat.m21 = 2 * this.q2 * this.q3 + 2 * this.q0 * this.q1; +this.mat.m22 = this.q0 * this.q0 - this.q1 * this.q1 - this.q2 * this.q2 + this.q3 * this.q3; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "add", +function (x) { +return javajs.util.Quat.newVA (this.getNormal (), this.getTheta () + x); +}, "~N"); +Clazz.defineMethod (c$, "mul", +function (x) { +return (x == 1 ? javajs.util.Quat.new4 (this.q1, this.q2, this.q3, this.q0) : javajs.util.Quat.newVA (this.getNormal (), this.getTheta () * x)); +}, "~N"); +Clazz.defineMethod (c$, "mulQ", +function (p) { +return javajs.util.Quat.new4 (this.q0 * p.q1 + this.q1 * p.q0 + this.q2 * p.q3 - this.q3 * p.q2, this.q0 * p.q2 + this.q2 * p.q0 + this.q3 * p.q1 - this.q1 * p.q3, this.q0 * p.q3 + this.q3 * p.q0 + this.q1 * p.q2 - this.q2 * p.q1, this.q0 * p.q0 - this.q1 * p.q1 - this.q2 * p.q2 - this.q3 * p.q3); +}, "javajs.util.Quat"); +Clazz.defineMethod (c$, "div", +function (p) { +return this.mulQ (p.inv ()); +}, "javajs.util.Quat"); +Clazz.defineMethod (c$, "divLeft", +function (p) { +return this.inv ().mulQ (p); +}, "javajs.util.Quat"); +Clazz.defineMethod (c$, "dot", +function (q) { +return this.q0 * q.q0 + this.q1 * q.q1 + this.q2 * q.q2 + this.q3 * q.q3; +}, "javajs.util.Quat"); +Clazz.defineMethod (c$, "inv", +function () { +return javajs.util.Quat.new4 (-this.q1, -this.q2, -this.q3, this.q0); +}); +Clazz.defineMethod (c$, "negate", +function () { +return javajs.util.Quat.new4 (-this.q1, -this.q2, -this.q3, -this.q0); +}); +Clazz.defineMethod (c$, "getFixFactor", +($fz = function () { +return (this.q0 < 0 || this.q0 == 0 && (this.q1 < 0 || this.q1 == 0 && (this.q2 < 0 || this.q2 == 0 && this.q3 < 0)) ? -1 : 1); +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getVector", +function (i) { +return this.getVectorScaled (i, 1); +}, "~N"); +Clazz.defineMethod (c$, "getVectorScaled", +function (i, scale) { +if (i == -1) { +scale *= this.getFixFactor (); +return javajs.util.V3.new3 (this.q1 * scale, this.q2 * scale, this.q3 * scale); +}if (this.mat == null) this.setMatrix (); +var v = new javajs.util.V3 (); +this.mat.getColumnV (i, v); +if (scale != 1) v.scale (scale); +return v; +}, "~N,~N"); +Clazz.defineMethod (c$, "getNormal", +function () { +var v = javajs.util.Quat.getRawNormal (this); +v.scale (this.getFixFactor ()); +return v; +}); +c$.getRawNormal = Clazz.defineMethod (c$, "getRawNormal", +($fz = function (q) { +var v = javajs.util.V3.new3 (q.q1, q.q2, q.q3); +if (v.length () == 0) return javajs.util.V3.new3 (0, 0, 1); +v.normalize (); +return v; +}, $fz.isPrivate = true, $fz), "javajs.util.Quat"); +Clazz.defineMethod (c$, "getTheta", +function () { +return (Math.acos (Math.abs (this.q0)) * 2 * 180 / 3.141592653589793); +}); +Clazz.defineMethod (c$, "getThetaRadians", +function () { +return (Math.acos (Math.abs (this.q0)) * 2); +}); +Clazz.defineMethod (c$, "getNormalDirected", +function (v0) { +var v = this.getNormal (); +if (v.x * v0.x + v.y * v0.y + v.z * v0.z < 0) { +v.scale (-1); +}return v; +}, "javajs.util.V3"); +Clazz.defineMethod (c$, "get3dProjection", +function (v3d) { +v3d.set (this.q1, this.q2, this.q3); +return v3d; +}, "javajs.util.V3"); +Clazz.defineMethod (c$, "getThetaDirected", +function (axisAngle) { +var theta = this.getTheta (); +var v = this.getNormal (); +if (axisAngle.x * this.q1 + axisAngle.y * this.q2 + axisAngle.z * this.q3 < 0) { +v.scale (-1); +theta = -theta; +}axisAngle.set4 (v.x, v.y, v.z, theta); +return axisAngle; +}, "javajs.util.P4"); +Clazz.defineMethod (c$, "getThetaDirectedV", +function (vector) { +var theta = this.getTheta (); +var v = this.getNormal (); +if (vector.x * this.q1 + vector.y * this.q2 + vector.z * this.q3 < 0) { +v.scale (-1); +theta = -theta; +}return theta; +}, "javajs.util.V3"); +Clazz.defineMethod (c$, "toPoint4f", +function () { +return javajs.util.P4.new4 (this.q1, this.q2, this.q3, this.q0); +}); +Clazz.defineMethod (c$, "toAxisAngle4f", +function () { +var theta = 2 * Math.acos (Math.abs (this.q0)); +var sinTheta2 = Math.sin (theta / 2); +var v = this.getNormal (); +if (sinTheta2 < 0) { +v.scale (-1); +theta = 3.141592653589793 - theta; +}return javajs.util.A4.newVA (v, theta); +}); +Clazz.defineMethod (c$, "transform2", +function (pt, ptNew) { +if (this.mat == null) this.setMatrix (); +this.mat.rotate2 (pt, ptNew); +return ptNew; +}, "javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "leftDifference", +function (q2) { +var q2adjusted = (this.dot (q2) < 0 ? q2.negate () : q2); +return this.inv ().mulQ (q2adjusted); +}, "javajs.util.Quat"); +Clazz.defineMethod (c$, "rightDifference", +function (q2) { +var q2adjusted = (this.dot (q2) < 0 ? q2.negate () : q2); +return this.mulQ (q2adjusted.inv ()); +}, "javajs.util.Quat"); +Clazz.overrideMethod (c$, "toString", +function () { +return "{" + this.q1 + " " + this.q2 + " " + this.q3 + " " + this.q0 + "}"; +}); +c$.div = Clazz.defineMethod (c$, "div", +function (data1, data2, nMax, isRelative) { +var n; +if (data1 == null || data2 == null || (n = Math.min (data1.length, data2.length)) == 0) return null; +if (nMax > 0 && n > nMax) n = nMax; +var dqs = new Array (n); +for (var i = 0; i < n; i++) { +if (data1[i] == null || data2[i] == null) return null; +dqs[i] = (isRelative ? data1[i].divLeft (data2[i]) : data1[i].div (data2[i])); +} +return dqs; +}, "~A,~A,~N,~B"); +c$.sphereMean = Clazz.defineMethod (c$, "sphereMean", +function (data, retStddev, criterion) { +if (data == null || data.length == 0) return new javajs.util.Quat (); +if (retStddev == null) retStddev = Clazz.newFloatArray (1, 0); +if (data.length == 1) { +retStddev[0] = 0; +return javajs.util.Quat.newQ (data[0]); +}var diff = 3.4028235E38; +var lastStddev = 3.4028235E38; +var qMean = javajs.util.Quat.simpleAverage (data); +var maxIter = 100; +var iter = 0; +while (diff > criterion && lastStddev != 0 && iter < maxIter) { +qMean = javajs.util.Quat.newMean (data, qMean); +retStddev[0] = javajs.util.Quat.stdDev (data, qMean); +diff = Math.abs (retStddev[0] - lastStddev); +lastStddev = retStddev[0]; +} +return qMean; +}, "~A,~A,~N"); +c$.simpleAverage = Clazz.defineMethod (c$, "simpleAverage", +($fz = function (ndata) { +var mean = javajs.util.V3.new3 (0, 0, 1); +var v = ndata[0].getNormal (); +mean.add (v); +for (var i = ndata.length; --i >= 0; ) mean.add (ndata[i].getNormalDirected (mean)); + +mean.sub (v); +mean.normalize (); +var f = 0; +for (var i = ndata.length; --i >= 0; ) f += Math.abs (ndata[i].get3dProjection (v).dot (mean)); + +if (f != 0) mean.scale (f / ndata.length); +f = Math.sqrt (1 - mean.lengthSquared ()); +if (Float.isNaN (f)) f = 0; +return javajs.util.Quat.newP4 (javajs.util.P4.new4 (mean.x, mean.y, mean.z, f)); +}, $fz.isPrivate = true, $fz), "~A"); +c$.newMean = Clazz.defineMethod (c$, "newMean", +($fz = function (data, mean) { +var sum = new javajs.util.V3 (); +var v; +var q; +var dq; +for (var i = data.length; --i >= 0; ) { +q = data[i]; +dq = q.div (mean); +v = dq.getNormal (); +v.scale (dq.getTheta ()); +sum.add (v); +} +sum.scale (1 / data.length); +var dqMean = javajs.util.Quat.newVA (sum, sum.length ()); +return dqMean.mulQ (mean); +}, $fz.isPrivate = true, $fz), "~A,javajs.util.Quat"); +c$.stdDev = Clazz.defineMethod (c$, "stdDev", +($fz = function (data, mean) { +var sum2 = 0; +var n = data.length; +for (var i = n; --i >= 0; ) { +var theta = data[i].div (mean).getTheta (); +sum2 += theta * theta; +} +return Math.sqrt (sum2 / n); +}, $fz.isPrivate = true, $fz), "~A,javajs.util.Quat"); +Clazz.defineMethod (c$, "getEulerZYZ", +function () { +var rA; +var rB; +var rG; +if (this.q1 == 0 && this.q2 == 0) { +var theta = this.getTheta (); +return Clazz.newFloatArray (-1, [this.q3 < 0 ? -theta : theta, 0, 0]); +}rA = Math.atan2 (2 * (this.q2 * this.q3 + this.q0 * this.q1), 2 * (-this.q1 * this.q3 + this.q0 * this.q2)); +rB = Math.acos (this.q3 * this.q3 - this.q2 * this.q2 - this.q1 * this.q1 + this.q0 * this.q0); +rG = Math.atan2 (2 * (this.q2 * this.q3 - this.q0 * this.q1), 2 * (this.q0 * this.q2 + this.q1 * this.q3)); +return Clazz.newFloatArray (-1, [(rA / 0.017453292519943295), (rB / 0.017453292519943295), (rG / 0.017453292519943295)]); +}); +Clazz.defineMethod (c$, "getEulerZXZ", +function () { +var rA; +var rB; +var rG; +if (this.q1 == 0 && this.q2 == 0) { +var theta = this.getTheta (); +return Clazz.newFloatArray (-1, [this.q3 < 0 ? -theta : theta, 0, 0]); +}rA = Math.atan2 (2 * (this.q1 * this.q3 - this.q0 * this.q2), 2 * (this.q0 * this.q1 + this.q2 * this.q3)); +rB = Math.acos (this.q3 * this.q3 - this.q2 * this.q2 - this.q1 * this.q1 + this.q0 * this.q0); +rG = Math.atan2 (2 * (this.q1 * this.q3 + this.q0 * this.q2), 2 * (-this.q2 * this.q3 + this.q0 * this.q1)); +return Clazz.newFloatArray (-1, [(rA / 0.017453292519943295), (rB / 0.017453292519943295), (rG / 0.017453292519943295)]); +}); +c$.qZero = c$.prototype.qZero = new javajs.util.P4 (); +Clazz.defineStatics (c$, +"RAD_PER_DEG", 0.017453292519943295); +}); diff --git a/bin/javajs/util/Rdr.js b/bin/javajs/util/Rdr.js index 45a14ab..6f65dc5 100644 --- a/bin/javajs/util/Rdr.js +++ b/bin/javajs/util/Rdr.js @@ -1,311 +1,311 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.GenericLineReader"], "javajs.util.Rdr", ["java.io.BufferedInputStream", "$.BufferedReader", "$.ByteArrayInputStream", "$.InputStreamReader", "$.StringReader", "javajs.util.AU", "$.Base64", "$.Encoding", "$.SB"], function () { -c$ = Clazz.decorateAsClass (function () { -this.reader = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "Rdr", null, javajs.api.GenericLineReader); -Clazz.makeConstructor (c$, -function (reader) { -this.reader = reader; -}, "java.io.BufferedReader"); -Clazz.overrideMethod (c$, "readNextLine", -function () { -return this.reader.readLine (); -}); -c$.readCifData = Clazz.defineMethod (c$, "readCifData", -function (parser, br) { -return parser.set (null, br).getAllCifData (); -}, "javajs.api.GenericCifDataParser,java.io.BufferedReader"); -c$.fixUTF = Clazz.defineMethod (c$, "fixUTF", -function (bytes) { -var encoding = javajs.util.Rdr.getUTFEncoding (bytes); -if (encoding !== javajs.util.Encoding.NONE) try { -var s = String.instantialize (bytes, encoding.name ().$replace ('_', '-')); -switch (encoding) { -case javajs.util.Encoding.UTF8: -case javajs.util.Encoding.UTF_16BE: -case javajs.util.Encoding.UTF_16LE: -s = s.substring (1); -break; -default: -break; -} -return s; -} catch (e) { -if (Clazz.exceptionOf (e, java.io.UnsupportedEncodingException)) { -System.out.println (e); -} else { -throw e; -} -} -return String.instantialize (bytes); -}, "~A"); -c$.getUTFEncoding = Clazz.defineMethod (c$, "getUTFEncoding", -($fz = function (bytes) { -if (bytes.length >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) return javajs.util.Encoding.UTF8; -if (bytes.length >= 4 && bytes[0] == 0 && bytes[1] == 0 && bytes[2] == 0xFE && bytes[3] == 0xFF) return javajs.util.Encoding.UTF_32BE; -if (bytes.length >= 4 && bytes[0] == 0xFF && bytes[1] == 0xFE && bytes[2] == 0 && bytes[3] == 0) return javajs.util.Encoding.UTF_32LE; -if (bytes.length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE) return javajs.util.Encoding.UTF_16LE; -if (bytes.length >= 2 && bytes[0] == 0xFE && bytes[1] == 0xFF) return javajs.util.Encoding.UTF_16BE; -return javajs.util.Encoding.NONE; -}, $fz.isPrivate = true, $fz), "~A"); -c$.getUTFEncodingForStream = Clazz.defineMethod (c$, "getUTFEncodingForStream", -($fz = function (is) { -{ -is.resetStream(); -}var abMagic = Clazz.newByteArray (4, 0); -abMagic[3] = 1; -try { -is.mark (5); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -return javajs.util.Encoding.NONE; -} else { -throw e; -} -} -is.read (abMagic, 0, 4); -is.reset (); -return javajs.util.Rdr.getUTFEncoding (abMagic); -}, $fz.isPrivate = true, $fz), "java.io.BufferedInputStream"); -c$.isBase64 = Clazz.defineMethod (c$, "isBase64", -function (sb) { -return (sb.indexOf (";base64,") == 0); -}, "javajs.util.SB"); -c$.isCompoundDocumentS = Clazz.defineMethod (c$, "isCompoundDocumentS", -function (is) { -return javajs.util.Rdr.isCompoundDocumentB (javajs.util.Rdr.getMagic (is, 8)); -}, "java.io.InputStream"); -c$.isCompoundDocumentB = Clazz.defineMethod (c$, "isCompoundDocumentB", -function (bytes) { -return (bytes.length >= 8 && bytes[0] == 0xD0 && bytes[1] == 0xCF && bytes[2] == 0x11 && bytes[3] == 0xE0 && bytes[4] == 0xA1 && bytes[5] == 0xB1 && bytes[6] == 0x1A && bytes[7] == 0xE1); -}, "~A"); -c$.isGzipS = Clazz.defineMethod (c$, "isGzipS", -function (is) { -return javajs.util.Rdr.isGzipB (javajs.util.Rdr.getMagic (is, 2)); -}, "java.io.InputStream"); -c$.isGzipB = Clazz.defineMethod (c$, "isGzipB", -function (bytes) { -return (bytes != null && bytes.length >= 2 && bytes[0] == 0x1F && bytes[1] == 0x8B); -}, "~A"); -c$.isPickleS = Clazz.defineMethod (c$, "isPickleS", -function (is) { -return javajs.util.Rdr.isPickleB (javajs.util.Rdr.getMagic (is, 2)); -}, "java.io.InputStream"); -c$.isPickleB = Clazz.defineMethod (c$, "isPickleB", -function (bytes) { -return (bytes != null && bytes.length >= 2 && bytes[0] == 0x7D && bytes[1] == 0x71); -}, "~A"); -c$.isPngZipStream = Clazz.defineMethod (c$, "isPngZipStream", -function (is) { -return javajs.util.Rdr.isPngZipB (javajs.util.Rdr.getMagic (is, 55)); -}, "java.io.InputStream"); -c$.isPngZipB = Clazz.defineMethod (c$, "isPngZipB", -function (bytes) { -return (bytes[50] == 0 && bytes[51] == 0x50 && bytes[52] == 0x4E && bytes[53] == 0x47 && bytes[54] == 0x4A); -}, "~A"); -c$.isZipS = Clazz.defineMethod (c$, "isZipS", -function (is) { -return javajs.util.Rdr.isZipB (javajs.util.Rdr.getMagic (is, 4)); -}, "java.io.InputStream"); -c$.isZipB = Clazz.defineMethod (c$, "isZipB", -function (bytes) { -return (bytes.length >= 4 && bytes[0] == 0x50 && bytes[1] == 0x4B && bytes[2] == 0x03 && bytes[3] == 0x04); -}, "~A"); -c$.getMagic = Clazz.defineMethod (c$, "getMagic", -($fz = function (is, n) { -var abMagic = Clazz.newByteArray (n, 0); -{ -is.resetStream(); -}try { -is.mark (n + 1); -is.read (abMagic, 0, n); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -try { -is.reset (); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -return abMagic; -}, $fz.isPrivate = true, $fz), "java.io.InputStream,~N"); -c$.guessMimeTypeForBytes = Clazz.defineMethod (c$, "guessMimeTypeForBytes", -function (bytes) { -switch (bytes.length < 2 ? -1 : bytes[1]) { -case 0: -return "image/jpg"; -case 0x49: -return "image/gif"; -case 0x4D: -return "image/BMP"; -case 0x50: -return "image/png"; -default: -return "image/unknown"; -} -}, "~A"); -c$.getBIS = Clazz.defineMethod (c$, "getBIS", -function (bytes) { -return new java.io.BufferedInputStream ( new java.io.ByteArrayInputStream (bytes)); -}, "~A"); -c$.getBR = Clazz.defineMethod (c$, "getBR", -function (string) { -return new java.io.BufferedReader ( new java.io.StringReader (string)); -}, "~S"); -c$.getUnzippedInputStream = Clazz.defineMethod (c$, "getUnzippedInputStream", -function (jzt, bis) { -while (javajs.util.Rdr.isGzipS (bis)) bis = new java.io.BufferedInputStream (jzt.newGZIPInputStream (bis)); - -return bis; -}, "javajs.api.GenericZipTools,java.io.BufferedInputStream"); -c$.getBytesFromSB = Clazz.defineMethod (c$, "getBytesFromSB", -function (sb) { -return (javajs.util.Rdr.isBase64 (sb) ? javajs.util.Base64.decodeBase64 (sb.substring (8)) : sb.toBytes (0, -1)); -}, "javajs.util.SB"); -c$.getStreamAsBytes = Clazz.defineMethod (c$, "getStreamAsBytes", -function (bis, out) { -var buf = Clazz.newByteArray (1024, 0); -var bytes = (out == null ? Clazz.newByteArray (4096, 0) : null); -var len = 0; -var totalLen = 0; -while ((len = bis.read (buf, 0, 1024)) > 0) { -totalLen += len; -if (out == null) { -if (totalLen >= bytes.length) bytes = javajs.util.AU.ensureLengthByte (bytes, totalLen * 2); -System.arraycopy (buf, 0, bytes, totalLen - len, len); -} else { -out.write (buf, 0, len); -}} -bis.close (); -if (out == null) { -return javajs.util.AU.arrayCopyByte (bytes, totalLen); -}return totalLen + " bytes"; -}, "java.io.BufferedInputStream,javajs.util.OC"); -c$.getBufferedReader = Clazz.defineMethod (c$, "getBufferedReader", -function (bis, charSet) { -if (javajs.util.Rdr.getUTFEncodingForStream (bis) === javajs.util.Encoding.NONE) return new java.io.BufferedReader ( new java.io.InputStreamReader (bis, (charSet == null ? "UTF-8" : charSet))); -var bytes = javajs.util.Rdr.getLimitedStreamBytes (bis, -1); -bis.close (); -return javajs.util.Rdr.getBR (charSet == null ? javajs.util.Rdr.fixUTF (bytes) : String.instantialize (bytes, charSet)); -}, "java.io.BufferedInputStream,~S"); -c$.getLimitedStreamBytes = Clazz.defineMethod (c$, "getLimitedStreamBytes", -function (is, n) { -var buflen = (n > 0 && n < 1024 ? n : 1024); -var buf = Clazz.newByteArray (buflen, 0); -var bytes = Clazz.newByteArray (n < 0 ? 4096 : n, 0); -var len = 0; -var totalLen = 0; -if (n < 0) n = 2147483647; -while (totalLen < n && (len = is.read (buf, 0, buflen)) > 0) { -totalLen += len; -if (totalLen > bytes.length) bytes = javajs.util.AU.ensureLengthByte (bytes, totalLen * 2); -System.arraycopy (buf, 0, bytes, totalLen - len, len); -if (n != 2147483647 && totalLen + buflen > bytes.length) buflen = bytes.length - totalLen; -} -if (totalLen == bytes.length) return bytes; -buf = Clazz.newByteArray (totalLen, 0); -System.arraycopy (bytes, 0, buf, 0, totalLen); -return buf; -}, "java.io.InputStream,~N"); -c$.StreamToUTF8String = Clazz.defineMethod (c$, "StreamToUTF8String", -function (bis) { -var data = new Array (1); -try { -javajs.util.Rdr.readAllAsString (javajs.util.Rdr.getBufferedReader (bis, "UTF-8"), -1, true, data, 0); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -} else { -throw e; -} -} -return data[0]; -}, "java.io.BufferedInputStream"); -c$.readAllAsString = Clazz.defineMethod (c$, "readAllAsString", -function (br, nBytesMax, allowBinary, data, i) { -try { -var sb = javajs.util.SB.newN (8192); -var line; -if (nBytesMax < 0) { -line = br.readLine (); -if (allowBinary || line != null && line.indexOf ('\0') < 0 && (line.length != 4 || line.charCodeAt (0) != 65533 || line.indexOf ("PNG") != 1)) { -sb.append (line).appendC ('\n'); -while ((line = br.readLine ()) != null) sb.append (line).appendC ('\n'); - -}} else { -var n = 0; -var len; -while (n < nBytesMax && (line = br.readLine ()) != null) { -if (nBytesMax - n < (len = line.length) + 1) line = line.substring (0, nBytesMax - n - 1); -sb.append (line).appendC ('\n'); -n += len + 1; -} -}br.close (); -data[i] = sb.toString (); -return true; -} catch (ioe) { -if (Clazz.exceptionOf (ioe, Exception)) { -data[i] = ioe.toString (); -return false; -} else { -throw ioe; -} -} -}, "java.io.BufferedReader,~N,~B,~A,~N"); -c$.getPngZipPointAndCount = Clazz.defineMethod (c$, "getPngZipPointAndCount", -function (bis, pt_count) { -bis.mark (75); -try { -var data = javajs.util.Rdr.getLimitedStreamBytes (bis, 74); -bis.reset (); -var pt = 0; -for (var i = 64, f = 1; --i > 54; f *= 10) pt += (data[i] - 48) * f; - -var n = 0; -for (var i = 74, f = 1; --i > 64; f *= 10) n += (data[i] - 48) * f; - -pt_count[0] = pt; -pt_count[1] = n; -} catch (e) { -pt_count[1] = 0; -} -}, "java.io.BufferedInputStream,~A"); -c$.getPngZipStream = Clazz.defineMethod (c$, "getPngZipStream", -function (bis, asNewStream) { -if (!javajs.util.Rdr.isPngZipStream (bis)) return bis; -var data = Clazz.newByteArray (0, 0); -bis.mark (75); -try { -var pt_count = Clazz.newIntArray (2, 0); -javajs.util.Rdr.getPngZipPointAndCount (bis, pt_count); -if (pt_count[1] != 0) { -var pt = pt_count[0]; -while (pt > 0) pt -= bis.skip (pt); - -if (!asNewStream) return bis; -data = javajs.util.Rdr.getLimitedStreamBytes (bis, pt_count[1]); -}} catch (e) { -} finally { -try { -if (asNewStream) bis.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -} -return javajs.util.Rdr.getBIS (data); -}, "java.io.BufferedInputStream,~B"); -c$.getZipRoot = Clazz.defineMethod (c$, "getZipRoot", -function (fileName) { -var pt = fileName.indexOf ("|"); -return (pt < 0 ? fileName : fileName.substring (0, pt)); -}, "~S"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.GenericLineReader"], "javajs.util.Rdr", ["java.io.BufferedInputStream", "$.BufferedReader", "$.ByteArrayInputStream", "$.InputStreamReader", "$.StringReader", "javajs.util.AU", "$.Base64", "$.Encoding", "$.SB"], function () { +c$ = Clazz.decorateAsClass (function () { +this.reader = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "Rdr", null, javajs.api.GenericLineReader); +Clazz.makeConstructor (c$, +function (reader) { +this.reader = reader; +}, "java.io.BufferedReader"); +Clazz.overrideMethod (c$, "readNextLine", +function () { +return this.reader.readLine (); +}); +c$.readCifData = Clazz.defineMethod (c$, "readCifData", +function (parser, br) { +return parser.set (null, br).getAllCifData (); +}, "javajs.api.GenericCifDataParser,java.io.BufferedReader"); +c$.fixUTF = Clazz.defineMethod (c$, "fixUTF", +function (bytes) { +var encoding = javajs.util.Rdr.getUTFEncoding (bytes); +if (encoding !== javajs.util.Encoding.NONE) try { +var s = String.instantialize (bytes, encoding.name ().$replace ('_', '-')); +switch (encoding) { +case javajs.util.Encoding.UTF8: +case javajs.util.Encoding.UTF_16BE: +case javajs.util.Encoding.UTF_16LE: +s = s.substring (1); +break; +default: +break; +} +return s; +} catch (e) { +if (Clazz.exceptionOf (e, java.io.UnsupportedEncodingException)) { +System.out.println (e); +} else { +throw e; +} +} +return String.instantialize (bytes); +}, "~A"); +c$.getUTFEncoding = Clazz.defineMethod (c$, "getUTFEncoding", +($fz = function (bytes) { +if (bytes.length >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) return javajs.util.Encoding.UTF8; +if (bytes.length >= 4 && bytes[0] == 0 && bytes[1] == 0 && bytes[2] == 0xFE && bytes[3] == 0xFF) return javajs.util.Encoding.UTF_32BE; +if (bytes.length >= 4 && bytes[0] == 0xFF && bytes[1] == 0xFE && bytes[2] == 0 && bytes[3] == 0) return javajs.util.Encoding.UTF_32LE; +if (bytes.length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE) return javajs.util.Encoding.UTF_16LE; +if (bytes.length >= 2 && bytes[0] == 0xFE && bytes[1] == 0xFF) return javajs.util.Encoding.UTF_16BE; +return javajs.util.Encoding.NONE; +}, $fz.isPrivate = true, $fz), "~A"); +c$.getUTFEncodingForStream = Clazz.defineMethod (c$, "getUTFEncodingForStream", +($fz = function (is) { +{ +is.resetStream(); +}var abMagic = Clazz.newByteArray (4, 0); +abMagic[3] = 1; +try { +is.mark (5); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +return javajs.util.Encoding.NONE; +} else { +throw e; +} +} +is.read (abMagic, 0, 4); +is.reset (); +return javajs.util.Rdr.getUTFEncoding (abMagic); +}, $fz.isPrivate = true, $fz), "java.io.BufferedInputStream"); +c$.isBase64 = Clazz.defineMethod (c$, "isBase64", +function (sb) { +return (sb.indexOf (";base64,") == 0); +}, "javajs.util.SB"); +c$.isCompoundDocumentS = Clazz.defineMethod (c$, "isCompoundDocumentS", +function (is) { +return javajs.util.Rdr.isCompoundDocumentB (javajs.util.Rdr.getMagic (is, 8)); +}, "java.io.InputStream"); +c$.isCompoundDocumentB = Clazz.defineMethod (c$, "isCompoundDocumentB", +function (bytes) { +return (bytes.length >= 8 && bytes[0] == 0xD0 && bytes[1] == 0xCF && bytes[2] == 0x11 && bytes[3] == 0xE0 && bytes[4] == 0xA1 && bytes[5] == 0xB1 && bytes[6] == 0x1A && bytes[7] == 0xE1); +}, "~A"); +c$.isGzipS = Clazz.defineMethod (c$, "isGzipS", +function (is) { +return javajs.util.Rdr.isGzipB (javajs.util.Rdr.getMagic (is, 2)); +}, "java.io.InputStream"); +c$.isGzipB = Clazz.defineMethod (c$, "isGzipB", +function (bytes) { +return (bytes != null && bytes.length >= 2 && bytes[0] == 0x1F && bytes[1] == 0x8B); +}, "~A"); +c$.isPickleS = Clazz.defineMethod (c$, "isPickleS", +function (is) { +return javajs.util.Rdr.isPickleB (javajs.util.Rdr.getMagic (is, 2)); +}, "java.io.InputStream"); +c$.isPickleB = Clazz.defineMethod (c$, "isPickleB", +function (bytes) { +return (bytes != null && bytes.length >= 2 && bytes[0] == 0x7D && bytes[1] == 0x71); +}, "~A"); +c$.isPngZipStream = Clazz.defineMethod (c$, "isPngZipStream", +function (is) { +return javajs.util.Rdr.isPngZipB (javajs.util.Rdr.getMagic (is, 55)); +}, "java.io.InputStream"); +c$.isPngZipB = Clazz.defineMethod (c$, "isPngZipB", +function (bytes) { +return (bytes[50] == 0 && bytes[51] == 0x50 && bytes[52] == 0x4E && bytes[53] == 0x47 && bytes[54] == 0x4A); +}, "~A"); +c$.isZipS = Clazz.defineMethod (c$, "isZipS", +function (is) { +return javajs.util.Rdr.isZipB (javajs.util.Rdr.getMagic (is, 4)); +}, "java.io.InputStream"); +c$.isZipB = Clazz.defineMethod (c$, "isZipB", +function (bytes) { +return (bytes.length >= 4 && bytes[0] == 0x50 && bytes[1] == 0x4B && bytes[2] == 0x03 && bytes[3] == 0x04); +}, "~A"); +c$.getMagic = Clazz.defineMethod (c$, "getMagic", +($fz = function (is, n) { +var abMagic = Clazz.newByteArray (n, 0); +{ +is.resetStream(); +}try { +is.mark (n + 1); +is.read (abMagic, 0, n); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +try { +is.reset (); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +return abMagic; +}, $fz.isPrivate = true, $fz), "java.io.InputStream,~N"); +c$.guessMimeTypeForBytes = Clazz.defineMethod (c$, "guessMimeTypeForBytes", +function (bytes) { +switch (bytes.length < 2 ? -1 : bytes[1]) { +case 0: +return "image/jpg"; +case 0x49: +return "image/gif"; +case 0x4D: +return "image/BMP"; +case 0x50: +return "image/png"; +default: +return "image/unknown"; +} +}, "~A"); +c$.getBIS = Clazz.defineMethod (c$, "getBIS", +function (bytes) { +return new java.io.BufferedInputStream ( new java.io.ByteArrayInputStream (bytes)); +}, "~A"); +c$.getBR = Clazz.defineMethod (c$, "getBR", +function (string) { +return new java.io.BufferedReader ( new java.io.StringReader (string)); +}, "~S"); +c$.getUnzippedInputStream = Clazz.defineMethod (c$, "getUnzippedInputStream", +function (jzt, bis) { +while (javajs.util.Rdr.isGzipS (bis)) bis = new java.io.BufferedInputStream (jzt.newGZIPInputStream (bis)); + +return bis; +}, "javajs.api.GenericZipTools,java.io.BufferedInputStream"); +c$.getBytesFromSB = Clazz.defineMethod (c$, "getBytesFromSB", +function (sb) { +return (javajs.util.Rdr.isBase64 (sb) ? javajs.util.Base64.decodeBase64 (sb.substring (8)) : sb.toBytes (0, -1)); +}, "javajs.util.SB"); +c$.getStreamAsBytes = Clazz.defineMethod (c$, "getStreamAsBytes", +function (bis, out) { +var buf = Clazz.newByteArray (1024, 0); +var bytes = (out == null ? Clazz.newByteArray (4096, 0) : null); +var len = 0; +var totalLen = 0; +while ((len = bis.read (buf, 0, 1024)) > 0) { +totalLen += len; +if (out == null) { +if (totalLen >= bytes.length) bytes = javajs.util.AU.ensureLengthByte (bytes, totalLen * 2); +System.arraycopy (buf, 0, bytes, totalLen - len, len); +} else { +out.write (buf, 0, len); +}} +bis.close (); +if (out == null) { +return javajs.util.AU.arrayCopyByte (bytes, totalLen); +}return totalLen + " bytes"; +}, "java.io.BufferedInputStream,javajs.util.OC"); +c$.getBufferedReader = Clazz.defineMethod (c$, "getBufferedReader", +function (bis, charSet) { +if (javajs.util.Rdr.getUTFEncodingForStream (bis) === javajs.util.Encoding.NONE) return new java.io.BufferedReader ( new java.io.InputStreamReader (bis, (charSet == null ? "UTF-8" : charSet))); +var bytes = javajs.util.Rdr.getLimitedStreamBytes (bis, -1); +bis.close (); +return javajs.util.Rdr.getBR (charSet == null ? javajs.util.Rdr.fixUTF (bytes) : String.instantialize (bytes, charSet)); +}, "java.io.BufferedInputStream,~S"); +c$.getLimitedStreamBytes = Clazz.defineMethod (c$, "getLimitedStreamBytes", +function (is, n) { +var buflen = (n > 0 && n < 1024 ? n : 1024); +var buf = Clazz.newByteArray (buflen, 0); +var bytes = Clazz.newByteArray (n < 0 ? 4096 : n, 0); +var len = 0; +var totalLen = 0; +if (n < 0) n = 2147483647; +while (totalLen < n && (len = is.read (buf, 0, buflen)) > 0) { +totalLen += len; +if (totalLen > bytes.length) bytes = javajs.util.AU.ensureLengthByte (bytes, totalLen * 2); +System.arraycopy (buf, 0, bytes, totalLen - len, len); +if (n != 2147483647 && totalLen + buflen > bytes.length) buflen = bytes.length - totalLen; +} +if (totalLen == bytes.length) return bytes; +buf = Clazz.newByteArray (totalLen, 0); +System.arraycopy (bytes, 0, buf, 0, totalLen); +return buf; +}, "java.io.InputStream,~N"); +c$.StreamToUTF8String = Clazz.defineMethod (c$, "StreamToUTF8String", +function (bis) { +var data = new Array (1); +try { +javajs.util.Rdr.readAllAsString (javajs.util.Rdr.getBufferedReader (bis, "UTF-8"), -1, true, data, 0); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +} else { +throw e; +} +} +return data[0]; +}, "java.io.BufferedInputStream"); +c$.readAllAsString = Clazz.defineMethod (c$, "readAllAsString", +function (br, nBytesMax, allowBinary, data, i) { +try { +var sb = javajs.util.SB.newN (8192); +var line; +if (nBytesMax < 0) { +line = br.readLine (); +if (allowBinary || line != null && line.indexOf ('\0') < 0 && (line.length != 4 || line.charCodeAt (0) != 65533 || line.indexOf ("PNG") != 1)) { +sb.append (line).appendC ('\n'); +while ((line = br.readLine ()) != null) sb.append (line).appendC ('\n'); + +}} else { +var n = 0; +var len; +while (n < nBytesMax && (line = br.readLine ()) != null) { +if (nBytesMax - n < (len = line.length) + 1) line = line.substring (0, nBytesMax - n - 1); +sb.append (line).appendC ('\n'); +n += len + 1; +} +}br.close (); +data[i] = sb.toString (); +return true; +} catch (ioe) { +if (Clazz.exceptionOf (ioe, Exception)) { +data[i] = ioe.toString (); +return false; +} else { +throw ioe; +} +} +}, "java.io.BufferedReader,~N,~B,~A,~N"); +c$.getPngZipPointAndCount = Clazz.defineMethod (c$, "getPngZipPointAndCount", +function (bis, pt_count) { +bis.mark (75); +try { +var data = javajs.util.Rdr.getLimitedStreamBytes (bis, 74); +bis.reset (); +var pt = 0; +for (var i = 64, f = 1; --i > 54; f *= 10) pt += (data[i] - 48) * f; + +var n = 0; +for (var i = 74, f = 1; --i > 64; f *= 10) n += (data[i] - 48) * f; + +pt_count[0] = pt; +pt_count[1] = n; +} catch (e) { +pt_count[1] = 0; +} +}, "java.io.BufferedInputStream,~A"); +c$.getPngZipStream = Clazz.defineMethod (c$, "getPngZipStream", +function (bis, asNewStream) { +if (!javajs.util.Rdr.isPngZipStream (bis)) return bis; +var data = Clazz.newByteArray (0, 0); +bis.mark (75); +try { +var pt_count = Clazz.newIntArray (2, 0); +javajs.util.Rdr.getPngZipPointAndCount (bis, pt_count); +if (pt_count[1] != 0) { +var pt = pt_count[0]; +while (pt > 0) pt -= bis.skip (pt); + +if (!asNewStream) return bis; +data = javajs.util.Rdr.getLimitedStreamBytes (bis, pt_count[1]); +}} catch (e) { +} finally { +try { +if (asNewStream) bis.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +} +return javajs.util.Rdr.getBIS (data); +}, "java.io.BufferedInputStream,~B"); +c$.getZipRoot = Clazz.defineMethod (c$, "getZipRoot", +function (fileName) { +var pt = fileName.indexOf ("|"); +return (pt < 0 ? fileName : fileName.substring (0, pt)); +}, "~S"); +}); diff --git a/bin/javajs/util/SB.js b/bin/javajs/util/SB.js index b597d0f..daa1518 100644 --- a/bin/javajs/util/SB.js +++ b/bin/javajs/util/SB.js @@ -1,151 +1,151 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.sb = null; -this.s = null; -Clazz.instantialize (this, arguments); -}, javajs.util, "SB"); -Clazz.makeConstructor (c$, -function () { -{ -this.s = ""; -}}); -c$.newN = Clazz.defineMethod (c$, "newN", -function (n) { -{ -return new javajs.util.SB(); -}}, "~N"); -c$.newS = Clazz.defineMethod (c$, "newS", -function (s) { -{ -var sb = new javajs.util.SB(); -sb.s = s; -return sb; -}}, "~S"); -Clazz.defineMethod (c$, "append", -function (s) { -{ -this.s += s -}return this; -}, "~S"); -Clazz.defineMethod (c$, "appendC", -function (c) { -{ -this.s += c; -}return this; -}, "~S"); -Clazz.defineMethod (c$, "appendI", -function (i) { -{ -this.s += i -}return this; -}, "~N"); -Clazz.defineMethod (c$, "appendB", -function (b) { -{ -this.s += b -}return this; -}, "~B"); -Clazz.defineMethod (c$, "appendF", -function (f) { -{ -var sf = "" + f; -if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0) -sf += ".0" ; -this.s += sf; -}return this; -}, "~N"); -Clazz.defineMethod (c$, "appendD", -function (d) { -{ -var sf = "" + d; -if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0) -sf += ".0" ; -this.s += sf; -}return this; -}, "~N"); -Clazz.defineMethod (c$, "appendSB", -function (buf) { -{ -this.s += buf.s; -}return this; -}, "javajs.util.SB"); -Clazz.defineMethod (c$, "appendO", -function (data) { -if (data != null) { -{ -this.s += data.toString(); -}}return this; -}, "~O"); -Clazz.defineMethod (c$, "appendCB", -function (cb, off, len) { -{ -for (var i = len,j=off; --i >= 0;) -this.s += cb[j++]; -}}, "~A,~N,~N"); -Clazz.overrideMethod (c$, "toString", -function () { -{ -return this.s; -}}); -Clazz.defineMethod (c$, "length", -function () { -{ -return this.s.length; -}}); -Clazz.defineMethod (c$, "indexOf", -function (s) { -{ -return this.s.indexOf(s); -}}, "~S"); -Clazz.defineMethod (c$, "charAt", -function (i) { -{ -return this.s.charAt(i); -}}, "~N"); -Clazz.defineMethod (c$, "charCodeAt", -function (i) { -{ -return this.s.charCodeAt(i); -}}, "~N"); -Clazz.defineMethod (c$, "setLength", -function (n) { -{ -this.s = this.s.substring(0, n); -}}, "~N"); -Clazz.defineMethod (c$, "lastIndexOf", -function (s) { -{ -return this.s.lastIndexOf(s); -}}, "~S"); -Clazz.defineMethod (c$, "indexOf2", -function (s, i) { -{ -return this.s.indexOf(s, i); -}}, "~S,~N"); -Clazz.defineMethod (c$, "substring", -function (i) { -{ -return this.s.substring(i); -}}, "~N"); -Clazz.defineMethod (c$, "substring2", -function (i, j) { -{ -return this.s.substring(i, j); -}}, "~N,~N"); -Clazz.defineMethod (c$, "toBytes", -function (off, len) { -if (len < 0) len = this.length () - off; -var b = Clazz.newByteArray (len, 0); -for (var i = off + len, j = i - off; --i >= off; ) b[--j] = (this.charAt (i)).charCodeAt (0); - -return b; -}, "~N,~N"); -Clazz.defineMethod (c$, "replace", -function (start, end, str) { -{ -this.s = this.s.substring(0, start) + str + this.s.substring(end); -}}, "~N,~N,~S"); -Clazz.defineMethod (c$, "insert", -function (offset, str) { -this.replace (offset, offset, str); -}, "~N,~S"); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.sb = null; +this.s = null; +Clazz.instantialize (this, arguments); +}, javajs.util, "SB"); +Clazz.makeConstructor (c$, +function () { +{ +this.s = ""; +}}); +c$.newN = Clazz.defineMethod (c$, "newN", +function (n) { +{ +return new javajs.util.SB(); +}}, "~N"); +c$.newS = Clazz.defineMethod (c$, "newS", +function (s) { +{ +var sb = new javajs.util.SB(); +sb.s = s; +return sb; +}}, "~S"); +Clazz.defineMethod (c$, "append", +function (s) { +{ +this.s += s +}return this; +}, "~S"); +Clazz.defineMethod (c$, "appendC", +function (c) { +{ +this.s += c; +}return this; +}, "~S"); +Clazz.defineMethod (c$, "appendI", +function (i) { +{ +this.s += i +}return this; +}, "~N"); +Clazz.defineMethod (c$, "appendB", +function (b) { +{ +this.s += b +}return this; +}, "~B"); +Clazz.defineMethod (c$, "appendF", +function (f) { +{ +var sf = "" + f; +if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0) +sf += ".0" ; +this.s += sf; +}return this; +}, "~N"); +Clazz.defineMethod (c$, "appendD", +function (d) { +{ +var sf = "" + d; +if (sf.indexOf(".") < 0 && sf.indexOf("e") < 0) +sf += ".0" ; +this.s += sf; +}return this; +}, "~N"); +Clazz.defineMethod (c$, "appendSB", +function (buf) { +{ +this.s += buf.s; +}return this; +}, "javajs.util.SB"); +Clazz.defineMethod (c$, "appendO", +function (data) { +if (data != null) { +{ +this.s += data.toString(); +}}return this; +}, "~O"); +Clazz.defineMethod (c$, "appendCB", +function (cb, off, len) { +{ +for (var i = len,j=off; --i >= 0;) +this.s += cb[j++]; +}}, "~A,~N,~N"); +Clazz.overrideMethod (c$, "toString", +function () { +{ +return this.s; +}}); +Clazz.defineMethod (c$, "length", +function () { +{ +return this.s.length; +}}); +Clazz.defineMethod (c$, "indexOf", +function (s) { +{ +return this.s.indexOf(s); +}}, "~S"); +Clazz.defineMethod (c$, "charAt", +function (i) { +{ +return this.s.charAt(i); +}}, "~N"); +Clazz.defineMethod (c$, "charCodeAt", +function (i) { +{ +return this.s.charCodeAt(i); +}}, "~N"); +Clazz.defineMethod (c$, "setLength", +function (n) { +{ +this.s = this.s.substring(0, n); +}}, "~N"); +Clazz.defineMethod (c$, "lastIndexOf", +function (s) { +{ +return this.s.lastIndexOf(s); +}}, "~S"); +Clazz.defineMethod (c$, "indexOf2", +function (s, i) { +{ +return this.s.indexOf(s, i); +}}, "~S,~N"); +Clazz.defineMethod (c$, "substring", +function (i) { +{ +return this.s.substring(i); +}}, "~N"); +Clazz.defineMethod (c$, "substring2", +function (i, j) { +{ +return this.s.substring(i, j); +}}, "~N,~N"); +Clazz.defineMethod (c$, "toBytes", +function (off, len) { +if (len < 0) len = this.length () - off; +var b = Clazz.newByteArray (len, 0); +for (var i = off + len, j = i - off; --i >= off; ) b[--j] = (this.charAt (i)).charCodeAt (0); + +return b; +}, "~N,~N"); +Clazz.defineMethod (c$, "replace", +function (start, end, str) { +{ +this.s = this.s.substring(0, start) + str + this.s.substring(end); +}}, "~N,~N,~S"); +Clazz.defineMethod (c$, "insert", +function (offset, str) { +this.replace (offset, offset, str); +}, "~N,~S"); diff --git a/bin/javajs/util/StringDataReader.js b/bin/javajs/util/StringDataReader.js index 229c2ac..691fb2c 100644 --- a/bin/javajs/util/StringDataReader.js +++ b/bin/javajs/util/StringDataReader.js @@ -1,12 +1,12 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.DataReader"], "javajs.util.StringDataReader", ["java.io.StringReader"], function () { -c$ = Clazz.declareType (javajs.util, "StringDataReader", javajs.util.DataReader); -Clazz.makeConstructor (c$, -function (data) { -Clazz.superConstructor (this, javajs.util.StringDataReader, [ new java.io.StringReader (data)]); -}, "~S"); -Clazz.overrideMethod (c$, "setData", -function (data) { -return new javajs.util.StringDataReader (data); -}, "~O"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.DataReader"], "javajs.util.StringDataReader", ["java.io.StringReader"], function () { +c$ = Clazz.declareType (javajs.util, "StringDataReader", javajs.util.DataReader); +Clazz.makeConstructor (c$, +function (data) { +Clazz.superConstructor (this, javajs.util.StringDataReader, [ new java.io.StringReader (data)]); +}, "~S"); +Clazz.overrideMethod (c$, "setData", +function (data) { +return new javajs.util.StringDataReader (data); +}, "~O"); +}); diff --git a/bin/javajs/util/T3.js b/bin/javajs/util/T3.js index 81c591c..a914fe2 100644 --- a/bin/javajs/util/T3.js +++ b/bin/javajs/util/T3.js @@ -1,141 +1,141 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.T3", ["java.lang.Float"], function () { -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.z = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "T3", null, [javajs.api.JSONEncodable, java.io.Serializable]); -Clazz.defineMethod (c$, "set", -function (x, y, z) { -this.x = x; -this.y = y; -this.z = z; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "setA", -function (t) { -this.x = t[0]; -this.y = t[1]; -this.z = t[2]; -}, "~A"); -Clazz.defineMethod (c$, "setT", -function (t1) { -this.x = t1.x; -this.y = t1.y; -this.z = t1.z; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "add2", -function (t1, t2) { -this.x = t1.x + t2.x; -this.y = t1.y + t2.y; -this.z = t1.z + t2.z; -}, "javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "add", -function (t1) { -this.x += t1.x; -this.y += t1.y; -this.z += t1.z; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "distanceSquared", -function (p1) { -var dx = this.x - p1.x; -var dy = this.y - p1.y; -var dz = this.z - p1.z; -return (dx * dx + dy * dy + dz * dz); -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "distance", -function (p1) { -return Math.sqrt (this.distanceSquared (p1)); -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "sub2", -function (t1, t2) { -this.x = t1.x - t2.x; -this.y = t1.y - t2.y; -this.z = t1.z - t2.z; -}, "javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "sub", -function (t1) { -this.x -= t1.x; -this.y -= t1.y; -this.z -= t1.z; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "scale", -function (s) { -this.x *= s; -this.y *= s; -this.z *= s; -}, "~N"); -Clazz.defineMethod (c$, "add3", -function (a, b, c) { -this.x += a; -this.y += b; -this.z += c; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "scaleT", -function (p) { -this.x *= p.x; -this.y *= p.y; -this.z *= p.z; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "scaleAdd2", -function (s, t1, t2) { -this.x = s * t1.x + t2.x; -this.y = s * t1.y + t2.y; -this.z = s * t1.z + t2.z; -}, "~N,javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "ave", -function (a, b) { -this.x = (a.x + b.x) / 2; -this.y = (a.y + b.y) / 2; -this.z = (a.z + b.z) / 2; -}, "javajs.util.T3,javajs.util.T3"); -Clazz.defineMethod (c$, "dot", -function (v) { -return this.x * v.x + this.y * v.y + this.z * v.z; -}, "javajs.util.T3"); -Clazz.defineMethod (c$, "lengthSquared", -function () { -return this.x * this.x + this.y * this.y + this.z * this.z; -}); -Clazz.defineMethod (c$, "length", -function () { -return Math.sqrt (this.lengthSquared ()); -}); -Clazz.defineMethod (c$, "normalize", -function () { -var d = this.length (); -this.x /= d; -this.y /= d; -this.z /= d; -}); -Clazz.defineMethod (c$, "cross", -function (v1, v2) { -this.set (v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); -}, "javajs.util.T3,javajs.util.T3"); -Clazz.overrideMethod (c$, "hashCode", -function () { -var bits = 1; -bits = 31 * bits + javajs.util.T3.floatToIntBits0 (this.x); -bits = 31 * bits + javajs.util.T3.floatToIntBits0 (this.y); -bits = 31 * bits + javajs.util.T3.floatToIntBits0 (this.z); -return (bits ^ (bits >> 32)); -}); -c$.floatToIntBits0 = Clazz.defineMethod (c$, "floatToIntBits0", -function (f) { -return (f == 0 ? 0 : Float.floatToIntBits (f)); -}, "~N"); -Clazz.overrideMethod (c$, "equals", -function (t1) { -if (!(Clazz.instanceOf (t1, javajs.util.T3))) return false; -var t2 = t1; -return (this.x == t2.x && this.y == t2.y && this.z == t2.z); -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -return "{" + this.x + ", " + this.y + ", " + this.z + "}"; -}); -Clazz.overrideMethod (c$, "toJSON", -function () { -return "[" + this.x + "," + this.y + "," + this.z + "]"; -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.T3", ["java.lang.Float"], function () { +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.z = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "T3", null, [javajs.api.JSONEncodable, java.io.Serializable]); +Clazz.defineMethod (c$, "set", +function (x, y, z) { +this.x = x; +this.y = y; +this.z = z; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "setA", +function (t) { +this.x = t[0]; +this.y = t[1]; +this.z = t[2]; +}, "~A"); +Clazz.defineMethod (c$, "setT", +function (t1) { +this.x = t1.x; +this.y = t1.y; +this.z = t1.z; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "add2", +function (t1, t2) { +this.x = t1.x + t2.x; +this.y = t1.y + t2.y; +this.z = t1.z + t2.z; +}, "javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "add", +function (t1) { +this.x += t1.x; +this.y += t1.y; +this.z += t1.z; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "distanceSquared", +function (p1) { +var dx = this.x - p1.x; +var dy = this.y - p1.y; +var dz = this.z - p1.z; +return (dx * dx + dy * dy + dz * dz); +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "distance", +function (p1) { +return Math.sqrt (this.distanceSquared (p1)); +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "sub2", +function (t1, t2) { +this.x = t1.x - t2.x; +this.y = t1.y - t2.y; +this.z = t1.z - t2.z; +}, "javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "sub", +function (t1) { +this.x -= t1.x; +this.y -= t1.y; +this.z -= t1.z; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "scale", +function (s) { +this.x *= s; +this.y *= s; +this.z *= s; +}, "~N"); +Clazz.defineMethod (c$, "add3", +function (a, b, c) { +this.x += a; +this.y += b; +this.z += c; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "scaleT", +function (p) { +this.x *= p.x; +this.y *= p.y; +this.z *= p.z; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "scaleAdd2", +function (s, t1, t2) { +this.x = s * t1.x + t2.x; +this.y = s * t1.y + t2.y; +this.z = s * t1.z + t2.z; +}, "~N,javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "ave", +function (a, b) { +this.x = (a.x + b.x) / 2; +this.y = (a.y + b.y) / 2; +this.z = (a.z + b.z) / 2; +}, "javajs.util.T3,javajs.util.T3"); +Clazz.defineMethod (c$, "dot", +function (v) { +return this.x * v.x + this.y * v.y + this.z * v.z; +}, "javajs.util.T3"); +Clazz.defineMethod (c$, "lengthSquared", +function () { +return this.x * this.x + this.y * this.y + this.z * this.z; +}); +Clazz.defineMethod (c$, "length", +function () { +return Math.sqrt (this.lengthSquared ()); +}); +Clazz.defineMethod (c$, "normalize", +function () { +var d = this.length (); +this.x /= d; +this.y /= d; +this.z /= d; +}); +Clazz.defineMethod (c$, "cross", +function (v1, v2) { +this.set (v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); +}, "javajs.util.T3,javajs.util.T3"); +Clazz.overrideMethod (c$, "hashCode", +function () { +var bits = 1; +bits = 31 * bits + javajs.util.T3.floatToIntBits0 (this.x); +bits = 31 * bits + javajs.util.T3.floatToIntBits0 (this.y); +bits = 31 * bits + javajs.util.T3.floatToIntBits0 (this.z); +return (bits ^ (bits >> 32)); +}); +c$.floatToIntBits0 = Clazz.defineMethod (c$, "floatToIntBits0", +function (f) { +return (f == 0 ? 0 : Float.floatToIntBits (f)); +}, "~N"); +Clazz.overrideMethod (c$, "equals", +function (t1) { +if (!(Clazz.instanceOf (t1, javajs.util.T3))) return false; +var t2 = t1; +return (this.x == t2.x && this.y == t2.y && this.z == t2.z); +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +return "{" + this.x + ", " + this.y + ", " + this.z + "}"; +}); +Clazz.overrideMethod (c$, "toJSON", +function () { +return "[" + this.x + "," + this.y + "," + this.z + "]"; +}); +}); diff --git a/bin/javajs/util/T3d.js b/bin/javajs/util/T3d.js index 984370c..4040423 100644 --- a/bin/javajs/util/T3d.js +++ b/bin/javajs/util/T3d.js @@ -1,87 +1,87 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.T3d", ["java.lang.Double"], function () { -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.z = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "T3d", null, java.io.Serializable); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "set", -function (x, y, z) { -this.x = x; -this.y = y; -this.z = z; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "setA", -function (t) { -this.x = t[0]; -this.y = t[1]; -this.z = t[2]; -}, "~A"); -Clazz.defineMethod (c$, "setT", -function (t1) { -this.x = t1.x; -this.y = t1.y; -this.z = t1.z; -}, "javajs.util.T3d"); -Clazz.defineMethod (c$, "add2", -function (t1, t2) { -this.x = t1.x + t2.x; -this.y = t1.y + t2.y; -this.z = t1.z + t2.z; -}, "javajs.util.T3d,javajs.util.T3d"); -Clazz.defineMethod (c$, "add", -function (t1) { -this.x += t1.x; -this.y += t1.y; -this.z += t1.z; -}, "javajs.util.T3d"); -Clazz.defineMethod (c$, "sub2", -function (t1, t2) { -this.x = t1.x - t2.x; -this.y = t1.y - t2.y; -this.z = t1.z - t2.z; -}, "javajs.util.T3d,javajs.util.T3d"); -Clazz.defineMethod (c$, "sub", -function (t1) { -this.x -= t1.x; -this.y -= t1.y; -this.z -= t1.z; -}, "javajs.util.T3d"); -Clazz.defineMethod (c$, "scale", -function (s) { -this.x *= s; -this.y *= s; -this.z *= s; -}, "~N"); -Clazz.defineMethod (c$, "scaleAdd", -function (s, t1, t2) { -this.x = s * t1.x + t2.x; -this.y = s * t1.y + t2.y; -this.z = s * t1.z + t2.z; -}, "~N,javajs.util.T3d,javajs.util.T3d"); -Clazz.overrideMethod (c$, "hashCode", -function () { -var xbits = javajs.util.T3d.doubleToLongBits0 (this.x); -var ybits = javajs.util.T3d.doubleToLongBits0 (this.y); -var zbits = javajs.util.T3d.doubleToLongBits0 (this.z); -return (xbits ^ (xbits >> 32) ^ ybits ^ (ybits >> 32) ^ zbits ^ (zbits >> 32)); -}); -c$.doubleToLongBits0 = Clazz.defineMethod (c$, "doubleToLongBits0", -function (d) { -return (d == 0 ? 0 : Double.doubleToLongBits (d)); -}, "~N"); -Clazz.overrideMethod (c$, "equals", -function (t1) { -if (!(Clazz.instanceOf (t1, javajs.util.T3d))) return false; -var t2 = t1; -return (this.x == t2.x && this.y == t2.y && this.z == t2.z); -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -return "{" + this.x + ", " + this.y + ", " + this.z + "}"; -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.T3d", ["java.lang.Double"], function () { +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.z = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "T3d", null, java.io.Serializable); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "set", +function (x, y, z) { +this.x = x; +this.y = y; +this.z = z; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "setA", +function (t) { +this.x = t[0]; +this.y = t[1]; +this.z = t[2]; +}, "~A"); +Clazz.defineMethod (c$, "setT", +function (t1) { +this.x = t1.x; +this.y = t1.y; +this.z = t1.z; +}, "javajs.util.T3d"); +Clazz.defineMethod (c$, "add2", +function (t1, t2) { +this.x = t1.x + t2.x; +this.y = t1.y + t2.y; +this.z = t1.z + t2.z; +}, "javajs.util.T3d,javajs.util.T3d"); +Clazz.defineMethod (c$, "add", +function (t1) { +this.x += t1.x; +this.y += t1.y; +this.z += t1.z; +}, "javajs.util.T3d"); +Clazz.defineMethod (c$, "sub2", +function (t1, t2) { +this.x = t1.x - t2.x; +this.y = t1.y - t2.y; +this.z = t1.z - t2.z; +}, "javajs.util.T3d,javajs.util.T3d"); +Clazz.defineMethod (c$, "sub", +function (t1) { +this.x -= t1.x; +this.y -= t1.y; +this.z -= t1.z; +}, "javajs.util.T3d"); +Clazz.defineMethod (c$, "scale", +function (s) { +this.x *= s; +this.y *= s; +this.z *= s; +}, "~N"); +Clazz.defineMethod (c$, "scaleAdd", +function (s, t1, t2) { +this.x = s * t1.x + t2.x; +this.y = s * t1.y + t2.y; +this.z = s * t1.z + t2.z; +}, "~N,javajs.util.T3d,javajs.util.T3d"); +Clazz.overrideMethod (c$, "hashCode", +function () { +var xbits = javajs.util.T3d.doubleToLongBits0 (this.x); +var ybits = javajs.util.T3d.doubleToLongBits0 (this.y); +var zbits = javajs.util.T3d.doubleToLongBits0 (this.z); +return (xbits ^ (xbits >> 32) ^ ybits ^ (ybits >> 32) ^ zbits ^ (zbits >> 32)); +}); +c$.doubleToLongBits0 = Clazz.defineMethod (c$, "doubleToLongBits0", +function (d) { +return (d == 0 ? 0 : Double.doubleToLongBits (d)); +}, "~N"); +Clazz.overrideMethod (c$, "equals", +function (t1) { +if (!(Clazz.instanceOf (t1, javajs.util.T3d))) return false; +var t2 = t1; +return (this.x == t2.x && this.y == t2.y && this.z == t2.z); +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +return "{" + this.x + ", " + this.y + ", " + this.z + "}"; +}); +}); diff --git a/bin/javajs/util/T3i.js b/bin/javajs/util/T3i.js index 43b9910..bc24bf4 100644 --- a/bin/javajs/util/T3i.js +++ b/bin/javajs/util/T3i.js @@ -1,48 +1,48 @@ -Clazz.declarePackage ("javajs.util"); -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.z = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "T3i", null, java.io.Serializable); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "set", -function (x, y, z) { -this.x = x; -this.y = y; -this.z = z; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "setT", -function (t1) { -this.x = t1.x; -this.y = t1.y; -this.z = t1.z; -}, "javajs.util.T3i"); -Clazz.defineMethod (c$, "add", -function (t) { -this.x += t.x; -this.y += t.y; -this.z += t.z; -}, "javajs.util.T3i"); -Clazz.defineMethod (c$, "scaleAdd", -function (s, t1, t2) { -this.x = s * t1.x + t2.x; -this.y = s * t1.y + t2.y; -this.z = s * t1.z + t2.z; -}, "~N,javajs.util.T3i,javajs.util.T3i"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return this.x ^ this.y ^ this.z; -}); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (!(Clazz.instanceOf (o, javajs.util.T3i))) return false; -var t = o; -return (this.x == t.x && this.y == t.y && this.z == t.z); -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(" + this.x + ", " + this.y + ", " + this.z + ")"; -}); +Clazz.declarePackage ("javajs.util"); +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.z = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "T3i", null, java.io.Serializable); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "set", +function (x, y, z) { +this.x = x; +this.y = y; +this.z = z; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "setT", +function (t1) { +this.x = t1.x; +this.y = t1.y; +this.z = t1.z; +}, "javajs.util.T3i"); +Clazz.defineMethod (c$, "add", +function (t) { +this.x += t.x; +this.y += t.y; +this.z += t.z; +}, "javajs.util.T3i"); +Clazz.defineMethod (c$, "scaleAdd", +function (s, t1, t2) { +this.x = s * t1.x + t2.x; +this.y = s * t1.y + t2.y; +this.z = s * t1.z + t2.z; +}, "~N,javajs.util.T3i,javajs.util.T3i"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return this.x ^ this.y ^ this.z; +}); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (!(Clazz.instanceOf (o, javajs.util.T3i))) return false; +var t = o; +return (this.x == t.x && this.y == t.y && this.z == t.z); +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(" + this.x + ", " + this.y + ", " + this.z + ")"; +}); diff --git a/bin/javajs/util/T4.js b/bin/javajs/util/T4.js index d33a2c7..3ea8edd 100644 --- a/bin/javajs/util/T4.js +++ b/bin/javajs/util/T4.js @@ -1,37 +1,37 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.T3"], "javajs.util.T4", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.w = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "T4", javajs.util.T3); -Clazz.defineMethod (c$, "set4", -function (x, y, z, w) { -this.x = x; -this.y = y; -this.z = z; -this.w = w; -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "scale4", -function (s) { -this.scale (s); -this.w *= s; -}, "~N"); -Clazz.overrideMethod (c$, "hashCode", -function () { -return javajs.util.T3.floatToIntBits0 (this.x) ^ javajs.util.T3.floatToIntBits0 (this.y) ^ javajs.util.T3.floatToIntBits0 (this.z) ^ javajs.util.T3.floatToIntBits0 (this.w); -}); -Clazz.overrideMethod (c$, "equals", -function (o) { -if (!(Clazz.instanceOf (o, javajs.util.T4))) return false; -var t = o; -return (this.x == t.x && this.y == t.y && this.z == t.z && this.w == t.w); -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -return "(" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + ")"; -}); -Clazz.overrideMethod (c$, "toJSON", -function () { -return "[" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + "]"; -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.T3"], "javajs.util.T4", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.w = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "T4", javajs.util.T3); +Clazz.defineMethod (c$, "set4", +function (x, y, z, w) { +this.x = x; +this.y = y; +this.z = z; +this.w = w; +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "scale4", +function (s) { +this.scale (s); +this.w *= s; +}, "~N"); +Clazz.overrideMethod (c$, "hashCode", +function () { +return javajs.util.T3.floatToIntBits0 (this.x) ^ javajs.util.T3.floatToIntBits0 (this.y) ^ javajs.util.T3.floatToIntBits0 (this.z) ^ javajs.util.T3.floatToIntBits0 (this.w); +}); +Clazz.overrideMethod (c$, "equals", +function (o) { +if (!(Clazz.instanceOf (o, javajs.util.T4))) return false; +var t = o; +return (this.x == t.x && this.y == t.y && this.z == t.z && this.w == t.w); +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +return "(" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + ")"; +}); +Clazz.overrideMethod (c$, "toJSON", +function () { +return "[" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + "]"; +}); +}); diff --git a/bin/javajs/util/V3.js b/bin/javajs/util/V3.js index 28f7077..37591c1 100644 --- a/bin/javajs/util/V3.js +++ b/bin/javajs/util/V3.js @@ -1,31 +1,31 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.T3"], "javajs.util.V3", null, function () { -c$ = Clazz.declareType (javajs.util, "V3", javajs.util.T3); -Clazz.makeConstructor (c$, -function () { -}); -c$.newV = Clazz.defineMethod (c$, "newV", -function (t) { -return javajs.util.V3.new3 (t.x, t.y, t.z); -}, "javajs.util.T3"); -c$.newVsub = Clazz.defineMethod (c$, "newVsub", -function (t1, t2) { -return javajs.util.V3.new3 (t1.x - t2.x, t1.y - t2.y, t1.z - t2.z); -}, "javajs.util.T3,javajs.util.T3"); -c$.new3 = Clazz.defineMethod (c$, "new3", -function (x, y, z) { -var v = new javajs.util.V3 (); -v.x = x; -v.y = y; -v.z = z; -return v; -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "angle", -function (v1) { -var xx = this.y * v1.z - this.z * v1.y; -var yy = this.z * v1.x - this.x * v1.z; -var zz = this.x * v1.y - this.y * v1.x; -var cross = Math.sqrt (xx * xx + yy * yy + zz * zz); -return Math.abs (Math.atan2 (cross, this.dot (v1))); -}, "javajs.util.V3"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.T3"], "javajs.util.V3", null, function () { +c$ = Clazz.declareType (javajs.util, "V3", javajs.util.T3); +Clazz.makeConstructor (c$, +function () { +}); +c$.newV = Clazz.defineMethod (c$, "newV", +function (t) { +return javajs.util.V3.new3 (t.x, t.y, t.z); +}, "javajs.util.T3"); +c$.newVsub = Clazz.defineMethod (c$, "newVsub", +function (t1, t2) { +return javajs.util.V3.new3 (t1.x - t2.x, t1.y - t2.y, t1.z - t2.z); +}, "javajs.util.T3,javajs.util.T3"); +c$.new3 = Clazz.defineMethod (c$, "new3", +function (x, y, z) { +var v = new javajs.util.V3 (); +v.x = x; +v.y = y; +v.z = z; +return v; +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "angle", +function (v1) { +var xx = this.y * v1.z - this.z * v1.y; +var yy = this.z * v1.x - this.x * v1.z; +var zz = this.x * v1.y - this.y * v1.x; +var cross = Math.sqrt (xx * xx + yy * yy + zz * zz); +return Math.abs (Math.atan2 (cross, this.dot (v1))); +}, "javajs.util.V3"); +}); diff --git a/bin/javajs/util/V3d.js b/bin/javajs/util/V3d.js index c3a166e..729c5a3 100644 --- a/bin/javajs/util/V3d.js +++ b/bin/javajs/util/V3d.js @@ -1,27 +1,27 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.util.T3d"], "javajs.util.V3d", null, function () { -c$ = Clazz.declareType (javajs.util, "V3d", javajs.util.T3d); -Clazz.defineMethod (c$, "cross", -function (v1, v2) { -this.set (v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); -}, "javajs.util.V3d,javajs.util.V3d"); -Clazz.defineMethod (c$, "normalize", -function () { -var d = this.length (); -this.x /= d; -this.y /= d; -this.z /= d; -}); -Clazz.defineMethod (c$, "dot", -function (v) { -return this.x * v.x + this.y * v.y + this.z * v.z; -}, "javajs.util.V3d"); -Clazz.defineMethod (c$, "lengthSquared", -function () { -return this.x * this.x + this.y * this.y + this.z * this.z; -}); -Clazz.defineMethod (c$, "length", -function () { -return Math.sqrt (this.lengthSquared ()); -}); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.util.T3d"], "javajs.util.V3d", null, function () { +c$ = Clazz.declareType (javajs.util, "V3d", javajs.util.T3d); +Clazz.defineMethod (c$, "cross", +function (v1, v2) { +this.set (v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); +}, "javajs.util.V3d,javajs.util.V3d"); +Clazz.defineMethod (c$, "normalize", +function () { +var d = this.length (); +this.x /= d; +this.y /= d; +this.z /= d; +}); +Clazz.defineMethod (c$, "dot", +function (v) { +return this.x * v.x + this.y * v.y + this.z * v.z; +}, "javajs.util.V3d"); +Clazz.defineMethod (c$, "lengthSquared", +function () { +return this.x * this.x + this.y * this.y + this.z * this.z; +}); +Clazz.defineMethod (c$, "length", +function () { +return Math.sqrt (this.lengthSquared ()); +}); +}); diff --git a/bin/javajs/util/XmlUtil.js b/bin/javajs/util/XmlUtil.js index 68b0ce4..ee4fff9 100644 --- a/bin/javajs/util/XmlUtil.js +++ b/bin/javajs/util/XmlUtil.js @@ -1,73 +1,73 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.XmlUtil", ["javajs.util.PT"], function () { -c$ = Clazz.declareType (javajs.util, "XmlUtil"); -Clazz.makeConstructor (c$, -function () { -}); -c$.openDocument = Clazz.defineMethod (c$, "openDocument", -function (data) { -data.append ("\n"); -}, "javajs.util.SB"); -c$.openTag = Clazz.defineMethod (c$, "openTag", -function (sb, name) { -sb.append ("<").append (name).append (">\n"); -}, "javajs.util.SB,~S"); -c$.openTagAttr = Clazz.defineMethod (c$, "openTagAttr", -function (sb, name, attributes) { -javajs.util.XmlUtil.appendTagAll (sb, name, attributes, null, false, false); -sb.append ("\n"); -}, "javajs.util.SB,~S,~A"); -c$.closeTag = Clazz.defineMethod (c$, "closeTag", -function (sb, name) { -sb.append ("\n"); -}, "javajs.util.SB,~S"); -c$.appendTagAll = Clazz.defineMethod (c$, "appendTagAll", -function (sb, name, attributes, data, isCdata, doClose) { -var closer = ">"; -if (name.endsWith ("/")) { -name = name.substring (0, name.length - 1); -if (data == null) { -closer = "/>\n"; -doClose = false; -}}sb.append ("<").append (name); -if (attributes != null) for (var i = 0; i < attributes.length; i++) { -var o = attributes[i]; -if (o == null) continue; -if (Clazz.instanceOf (o, Array)) for (var j = 0; j < (o).length; j += 2) javajs.util.XmlUtil.appendAttrib (sb, (o)[j], (o)[j + 1]); - - else javajs.util.XmlUtil.appendAttrib (sb, o, attributes[++i]); -} -sb.append (closer); -if (data != null) { -if (isCdata) data = javajs.util.XmlUtil.wrapCdata (data); -sb.appendO (data); -}if (doClose) javajs.util.XmlUtil.closeTag (sb, name); -}, "javajs.util.SB,~S,~A,~O,~B,~B"); -c$.wrapCdata = Clazz.defineMethod (c$, "wrapCdata", -function (data) { -var s = "" + data; -return (s.indexOf ("&") < 0 && s.indexOf ("<") < 0 ? (s.startsWith ("\n") ? "" : "\n") + s : "", "]]]]>") + "]]>"); -}, "~O"); -c$.unwrapCdata = Clazz.defineMethod (c$, "unwrapCdata", -function (s) { -return (s.startsWith ("") ? javajs.util.PT.rep (s.substring (9, s.length - 3), "]]]]>", "]]>") : s); -}, "~S"); -c$.appendTagObj = Clazz.defineMethod (c$, "appendTagObj", -function (sb, name, attributes, data) { -javajs.util.XmlUtil.appendTagAll (sb, name, attributes, data, false, true); -}, "javajs.util.SB,~S,~A,~O"); -c$.appendTag = Clazz.defineMethod (c$, "appendTag", -function (sb, name, data) { -if (Clazz.instanceOf (data, Array)) javajs.util.XmlUtil.appendTagAll (sb, name, data, null, false, true); - else javajs.util.XmlUtil.appendTagAll (sb, name, null, data, false, true); -}, "javajs.util.SB,~S,~O"); -c$.appendCdata = Clazz.defineMethod (c$, "appendCdata", -function (sb, name, attributes, data) { -javajs.util.XmlUtil.appendTagAll (sb, name, attributes, data, true, true); -}, "javajs.util.SB,~S,~A,~S"); -c$.appendAttrib = Clazz.defineMethod (c$, "appendAttrib", -function (sb, name, value) { -if (value == null) return; -sb.append (" ").appendO (name).append ("=\"").appendO (value).append ("\""); -}, "javajs.util.SB,~O,~O"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.XmlUtil", ["javajs.util.PT"], function () { +c$ = Clazz.declareType (javajs.util, "XmlUtil"); +Clazz.makeConstructor (c$, +function () { +}); +c$.openDocument = Clazz.defineMethod (c$, "openDocument", +function (data) { +data.append ("\n"); +}, "javajs.util.SB"); +c$.openTag = Clazz.defineMethod (c$, "openTag", +function (sb, name) { +sb.append ("<").append (name).append (">\n"); +}, "javajs.util.SB,~S"); +c$.openTagAttr = Clazz.defineMethod (c$, "openTagAttr", +function (sb, name, attributes) { +javajs.util.XmlUtil.appendTagAll (sb, name, attributes, null, false, false); +sb.append ("\n"); +}, "javajs.util.SB,~S,~A"); +c$.closeTag = Clazz.defineMethod (c$, "closeTag", +function (sb, name) { +sb.append ("\n"); +}, "javajs.util.SB,~S"); +c$.appendTagAll = Clazz.defineMethod (c$, "appendTagAll", +function (sb, name, attributes, data, isCdata, doClose) { +var closer = ">"; +if (name.endsWith ("/")) { +name = name.substring (0, name.length - 1); +if (data == null) { +closer = "/>\n"; +doClose = false; +}}sb.append ("<").append (name); +if (attributes != null) for (var i = 0; i < attributes.length; i++) { +var o = attributes[i]; +if (o == null) continue; +if (Clazz.instanceOf (o, Array)) for (var j = 0; j < (o).length; j += 2) javajs.util.XmlUtil.appendAttrib (sb, (o)[j], (o)[j + 1]); + + else javajs.util.XmlUtil.appendAttrib (sb, o, attributes[++i]); +} +sb.append (closer); +if (data != null) { +if (isCdata) data = javajs.util.XmlUtil.wrapCdata (data); +sb.appendO (data); +}if (doClose) javajs.util.XmlUtil.closeTag (sb, name); +}, "javajs.util.SB,~S,~A,~O,~B,~B"); +c$.wrapCdata = Clazz.defineMethod (c$, "wrapCdata", +function (data) { +var s = "" + data; +return (s.indexOf ("&") < 0 && s.indexOf ("<") < 0 ? (s.startsWith ("\n") ? "" : "\n") + s : "", "]]]]>") + "]]>"); +}, "~O"); +c$.unwrapCdata = Clazz.defineMethod (c$, "unwrapCdata", +function (s) { +return (s.startsWith ("") ? javajs.util.PT.rep (s.substring (9, s.length - 3), "]]]]>", "]]>") : s); +}, "~S"); +c$.appendTagObj = Clazz.defineMethod (c$, "appendTagObj", +function (sb, name, attributes, data) { +javajs.util.XmlUtil.appendTagAll (sb, name, attributes, data, false, true); +}, "javajs.util.SB,~S,~A,~O"); +c$.appendTag = Clazz.defineMethod (c$, "appendTag", +function (sb, name, data) { +if (Clazz.instanceOf (data, Array)) javajs.util.XmlUtil.appendTagAll (sb, name, data, null, false, true); + else javajs.util.XmlUtil.appendTagAll (sb, name, null, data, false, true); +}, "javajs.util.SB,~S,~O"); +c$.appendCdata = Clazz.defineMethod (c$, "appendCdata", +function (sb, name, attributes, data) { +javajs.util.XmlUtil.appendTagAll (sb, name, attributes, data, true, true); +}, "javajs.util.SB,~S,~A,~S"); +c$.appendAttrib = Clazz.defineMethod (c$, "appendAttrib", +function (sb, name, value) { +if (value == null) return; +sb.append (" ").appendO (name).append ("=\"").appendO (value).append ("\""); +}, "javajs.util.SB,~O,~O"); +}); diff --git a/bin/javajs/util/ZipData.js b/bin/javajs/util/ZipData.js index 8d9db8e..8f318ca 100644 --- a/bin/javajs/util/ZipData.js +++ b/bin/javajs/util/ZipData.js @@ -1,45 +1,45 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (null, "javajs.util.ZipData", ["javajs.util.Rdr", "$.ZipTools"], function () { -c$ = Clazz.decorateAsClass (function () { -this.isEnabled = true; -this.buf = null; -this.pt = 0; -this.nBytes = 0; -Clazz.instantialize (this, arguments); -}, javajs.util, "ZipData"); -Clazz.makeConstructor (c$, -function (nBytes) { -this.nBytes = nBytes; -}, "~N"); -Clazz.defineMethod (c$, "addBytes", -function (byteBuf, nSectorBytes, nBytesRemaining) { -if (this.pt == 0) { -if (!javajs.util.Rdr.isGzipB (byteBuf)) { -this.isEnabled = false; -return -1; -}this.buf = Clazz.newByteArray (nBytesRemaining, 0); -}var nToAdd = Math.min (nSectorBytes, nBytesRemaining); -System.arraycopy (byteBuf, 0, this.buf, this.pt, nToAdd); -this.pt += nToAdd; -return nBytesRemaining - nToAdd; -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "addTo", -function (jzt, data) { -data.append (javajs.util.ZipData.getGzippedBytesAsString (jzt, this.buf)); -}, "javajs.api.GenericZipTools,javajs.util.SB"); -c$.getGzippedBytesAsString = Clazz.defineMethod (c$, "getGzippedBytesAsString", -function (jzt, bytes) { -try { -var bis = jzt.getUnGzippedInputStream (bytes); -var s = javajs.util.ZipTools.getStreamAsString (bis); -bis.close (); -return s; -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -return ""; -} else { -throw e; -} -} -}, "javajs.api.GenericZipTools,~A"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (null, "javajs.util.ZipData", ["javajs.util.Rdr", "$.ZipTools"], function () { +c$ = Clazz.decorateAsClass (function () { +this.isEnabled = true; +this.buf = null; +this.pt = 0; +this.nBytes = 0; +Clazz.instantialize (this, arguments); +}, javajs.util, "ZipData"); +Clazz.makeConstructor (c$, +function (nBytes) { +this.nBytes = nBytes; +}, "~N"); +Clazz.defineMethod (c$, "addBytes", +function (byteBuf, nSectorBytes, nBytesRemaining) { +if (this.pt == 0) { +if (!javajs.util.Rdr.isGzipB (byteBuf)) { +this.isEnabled = false; +return -1; +}this.buf = Clazz.newByteArray (nBytesRemaining, 0); +}var nToAdd = Math.min (nSectorBytes, nBytesRemaining); +System.arraycopy (byteBuf, 0, this.buf, this.pt, nToAdd); +this.pt += nToAdd; +return nBytesRemaining - nToAdd; +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "addTo", +function (jzt, data) { +data.append (javajs.util.ZipData.getGzippedBytesAsString (jzt, this.buf)); +}, "javajs.api.GenericZipTools,javajs.util.SB"); +c$.getGzippedBytesAsString = Clazz.defineMethod (c$, "getGzippedBytesAsString", +function (jzt, bytes) { +try { +var bis = jzt.getUnGzippedInputStream (bytes); +var s = javajs.util.ZipTools.getStreamAsString (bis); +bis.close (); +return s; +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +return ""; +} else { +throw e; +} +} +}, "javajs.api.GenericZipTools,~A"); +}); diff --git a/bin/javajs/util/ZipTools.js b/bin/javajs/util/ZipTools.js index fba24e6..5e0ad7b 100644 --- a/bin/javajs/util/ZipTools.js +++ b/bin/javajs/util/ZipTools.js @@ -1,308 +1,308 @@ -Clazz.declarePackage ("javajs.util"); -Clazz.load (["javajs.api.GenericZipTools"], "javajs.util.ZipTools", ["java.io.BufferedInputStream", "$.IOException", "java.lang.Boolean", "java.util.zip.CRC32", "$.GZIPInputStream", "$.ZipEntry", "$.ZipInputStream", "javajs.api.GenericZipInputStream", "$.ZInputStream", "javajs.util.BArray", "$.Lst", "$.PT", "$.Rdr", "$.SB"], function () { -c$ = Clazz.declareType (javajs.util, "ZipTools", null, javajs.api.GenericZipTools); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.overrideMethod (c$, "newZipInputStream", -function (is) { -return javajs.util.ZipTools.newZIS (is); -}, "java.io.InputStream"); -c$.newZIS = Clazz.defineMethod (c$, "newZIS", -($fz = function (is) { -return (Clazz.instanceOf (is, javajs.api.ZInputStream) ? is : Clazz.instanceOf (is, java.io.BufferedInputStream) ? new javajs.api.GenericZipInputStream (is) : new javajs.api.GenericZipInputStream ( new java.io.BufferedInputStream (is))); -}, $fz.isPrivate = true, $fz), "java.io.InputStream"); -Clazz.overrideMethod (c$, "getAllZipData", -function (is, subfileList, name0, binaryFileList, fileData) { -var zis = javajs.util.ZipTools.newZIS (is); -var ze; -var listing = new javajs.util.SB (); -binaryFileList = "|" + binaryFileList + "|"; -var prefix = javajs.util.PT.join (subfileList, '/', 1); -var prefixd = null; -if (prefix != null) { -prefixd = prefix.substring (0, prefix.indexOf ("/") + 1); -if (prefixd.length == 0) prefixd = null; -}try { -while ((ze = zis.getNextEntry ()) != null) { -var name = ze.getName (); -if (prefix != null && prefixd != null && !(name.equals (prefix) || name.startsWith (prefixd))) continue; -listing.append (name).appendC ('\n'); -var sname = "|" + name.substring (name.lastIndexOf ("/") + 1) + "|"; -var asBinaryString = (binaryFileList.indexOf (sname) >= 0); -var bytes = javajs.util.Rdr.getLimitedStreamBytes (zis, ze.getSize ()); -var str; -if (asBinaryString) { -str = this.getBinaryStringForBytes (bytes); -name += ":asBinaryString"; -} else { -str = javajs.util.Rdr.fixUTF (bytes); -}str = "BEGIN Directory Entry " + name + "\n" + str + "\nEND Directory Entry " + name + "\n"; -fileData.put (name0 + "|" + name, str); -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -fileData.put ("#Directory_Listing", listing.toString ()); -}, "java.io.InputStream,~A,~S,~S,java.util.Map"); -Clazz.defineMethod (c$, "getBinaryStringForBytes", -($fz = function (bytes) { -var ret = new javajs.util.SB (); -for (var i = 0; i < bytes.length; i++) ret.append (Integer.toHexString (bytes[i] & 0xFF)).appendC (' '); - -return ret.toString (); -}, $fz.isPrivate = true, $fz), "~A"); -Clazz.overrideMethod (c$, "getZipFileDirectory", -function (bis, list, listPtr, asBufferedInputStream) { -var ret; -if (list == null || listPtr >= list.length) return this.getZipDirectoryAsStringAndClose (bis); -bis = javajs.util.Rdr.getPngZipStream (bis, true); -var fileName = list[listPtr]; -var zis = new java.util.zip.ZipInputStream (bis); -var ze; -try { -var isAll = (fileName.equals (".")); -if (isAll || fileName.lastIndexOf ("/") == fileName.length - 1) { -ret = new javajs.util.SB (); -while ((ze = zis.getNextEntry ()) != null) { -var name = ze.getName (); -if (isAll || name.startsWith (fileName)) ret.append (name).appendC ('\n'); -} -var str = ret.toString (); -return (asBufferedInputStream ? javajs.util.Rdr.getBIS (str.getBytes ()) : str); -}var pt = fileName.indexOf (":asBinaryString"); -var asBinaryString = (pt > 0); -if (asBinaryString) fileName = fileName.substring (0, pt); -fileName = fileName.$replace ('\\', '/'); -while ((ze = zis.getNextEntry ()) != null && !fileName.equals (ze.getName ())) { -} -var bytes = (ze == null ? null : javajs.util.Rdr.getLimitedStreamBytes (zis, ze.getSize ())); -ze = null; -zis.close (); -if (bytes == null) return ""; -if (javajs.util.Rdr.isZipB (bytes) || javajs.util.Rdr.isPngZipB (bytes)) return this.getZipFileDirectory (javajs.util.Rdr.getBIS (bytes), list, ++listPtr, asBufferedInputStream); -if (asBufferedInputStream) return javajs.util.Rdr.getBIS (bytes); -if (asBinaryString) { -ret = new javajs.util.SB (); -for (var i = 0; i < bytes.length; i++) ret.append (Integer.toHexString (bytes[i] & 0xFF)).appendC (' '); - -return ret.toString (); -}if (javajs.util.Rdr.isGzipB (bytes)) bytes = javajs.util.Rdr.getLimitedStreamBytes (this.getUnGzippedInputStream (bytes), -1); -return javajs.util.Rdr.fixUTF (bytes); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -return ""; -} else { -throw e; -} -} -}, "java.io.BufferedInputStream,~A,~N,~B"); -Clazz.overrideMethod (c$, "getZipFileContentsAsBytes", -function (bis, list, listPtr) { -var ret = Clazz.newByteArray (0, 0); -var fileName = list[listPtr]; -if (fileName.lastIndexOf ("/") == fileName.length - 1) return ret; -try { -bis = javajs.util.Rdr.getPngZipStream (bis, true); -var zis = new java.util.zip.ZipInputStream (bis); -var ze; -while ((ze = zis.getNextEntry ()) != null) { -if (!fileName.equals (ze.getName ())) continue; -var bytes = javajs.util.Rdr.getLimitedStreamBytes (zis, ze.getSize ()); -return ((javajs.util.Rdr.isZipB (bytes) || javajs.util.Rdr.isPngZipB (bytes)) && ++listPtr < list.length ? this.getZipFileContentsAsBytes (javajs.util.Rdr.getBIS (bytes), list, listPtr) : bytes); -} -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -} else { -throw e; -} -} -return ret; -}, "java.io.BufferedInputStream,~A,~N"); -Clazz.overrideMethod (c$, "getZipDirectoryAsStringAndClose", -function (bis) { -var sb = new javajs.util.SB (); -var s = new Array (0); -try { -s = this.getZipDirectoryOrErrorAndClose (bis, null); -bis.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -for (var i = 0; i < s.length; i++) sb.append (s[i]).appendC ('\n'); - -return sb.toString (); -}, "java.io.BufferedInputStream"); -Clazz.overrideMethod (c$, "getZipDirectoryAndClose", -function (bis, manifestID) { -var s = new Array (0); -try { -s = this.getZipDirectoryOrErrorAndClose (bis, manifestID); -bis.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -System.out.println (e.toString ()); -} else { -throw e; -} -} -return s; -}, "java.io.BufferedInputStream,~S"); -Clazz.defineMethod (c$, "getZipDirectoryOrErrorAndClose", -($fz = function (bis, manifestID) { -bis = javajs.util.Rdr.getPngZipStream (bis, true); -var v = new javajs.util.Lst (); -var zis = new java.util.zip.ZipInputStream (bis); -var ze; -var manifest = null; -while ((ze = zis.getNextEntry ()) != null) { -var fileName = ze.getName (); -if (manifestID != null && fileName.startsWith (manifestID)) manifest = javajs.util.ZipTools.getStreamAsString (zis); - else if (!fileName.startsWith ("__MACOS")) v.addLast (fileName); -} -zis.close (); -if (manifestID != null) v.add (0, manifest == null ? "" : manifest + "\n############\n"); -return v.toArray ( new Array (v.size ())); -}, $fz.isPrivate = true, $fz), "java.io.BufferedInputStream,~S"); -c$.getStreamAsString = Clazz.defineMethod (c$, "getStreamAsString", -function (is) { -return javajs.util.Rdr.fixUTF (javajs.util.Rdr.getLimitedStreamBytes (is, -1)); -}, "java.io.InputStream"); -Clazz.overrideMethod (c$, "newGZIPInputStream", -function (is) { -return new java.io.BufferedInputStream ( new java.util.zip.GZIPInputStream (is, 512)); -}, "java.io.InputStream"); -Clazz.overrideMethod (c$, "getUnGzippedInputStream", -function (bytes) { -try { -return javajs.util.Rdr.getUnzippedInputStream (this, javajs.util.Rdr.getBIS (bytes)); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -return null; -} else { -throw e; -} -} -}, "~A"); -Clazz.overrideMethod (c$, "addZipEntry", -function (zos, fileName) { -(zos).putNextEntry ( new java.util.zip.ZipEntry (fileName)); -}, "~O,~S"); -Clazz.overrideMethod (c$, "closeZipEntry", -function (zos) { -(zos).closeEntry (); -}, "~O"); -Clazz.overrideMethod (c$, "getZipOutputStream", -function (bos) { -{ -return javajs.api.Interface.getInterface( -"java.util.zip.ZipOutputStream").setZOS(bos); -}}, "~O"); -Clazz.overrideMethod (c$, "getCrcValue", -function (bytes) { -var crc = new java.util.zip.CRC32 (); -crc.update (bytes, 0, bytes.length); -return crc.getValue (); -}, "~A"); -Clazz.overrideMethod (c$, "readFileAsMap", -function (bis, bdata, name) { -var pt = (name == null ? -1 : name.indexOf ("|")); -name = (pt >= 0 ? name.substring (pt + 1) : null); -try { -if (javajs.util.Rdr.isPngZipStream (bis)) { -var isImage = "_IMAGE_".equals (name); -if (name == null || isImage) bdata.put ((isImage ? "_DATA_" : "_IMAGE_"), new javajs.util.BArray (javajs.util.ZipTools.getPngImageBytes (bis))); -if (!isImage) this.cacheZipContents (bis, name, bdata, true); -} else if (javajs.util.Rdr.isZipS (bis)) { -this.cacheZipContents (bis, name, bdata, true); -} else if (name == null) { -bdata.put ("_DATA_", new javajs.util.BArray (javajs.util.Rdr.getLimitedStreamBytes (bis, -1))); -} else { -throw new java.io.IOException ("ZIP file " + name + " not found"); -}bdata.put ("$_BINARY_$", Boolean.TRUE); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -bdata.clear (); -bdata.put ("_ERROR_", e.getMessage ()); -} else { -throw e; -} -} -}, "java.io.BufferedInputStream,java.util.Map,~S"); -Clazz.overrideMethod (c$, "cacheZipContents", -function (bis, fileName, cache, asByteArray) { -var zis = javajs.util.ZipTools.newZIS (bis); -var ze; -var listing = new javajs.util.SB (); -var n = 0; -var oneFile = (asByteArray && fileName != null); -var pt = (oneFile ? fileName.indexOf ("|") : -1); -var file0 = (pt >= 0 ? fileName : null); -if (pt >= 0) fileName = fileName.substring (0, pt); -try { -while ((ze = zis.getNextEntry ()) != null) { -var name = ze.getName (); -if (fileName != null) { -if (oneFile) { -if (!name.equalsIgnoreCase (fileName)) continue; -} else { -listing.append (name).appendC ('\n'); -}}var nBytes = ze.getSize (); -var bytes = javajs.util.Rdr.getLimitedStreamBytes (zis, nBytes); -if (file0 != null) { -this.readFileAsMap (javajs.util.Rdr.getBIS (bytes), cache, file0); -return null; -}n += bytes.length; -var o = (asByteArray ? new javajs.util.BArray (bytes) : bytes); -cache.put ((oneFile ? "_DATA_" : (fileName == null ? "" : fileName + "|") + name), o); -if (oneFile) break; -} -zis.close (); -} catch (e) { -if (Clazz.exceptionOf (e, Exception)) { -try { -zis.close (); -} catch (e1) { -if (Clazz.exceptionOf (e1, java.io.IOException)) { -} else { -throw e1; -} -} -return null; -} else { -throw e; -} -} -if (n == 0 || fileName == null) return null; -System.out.println ("ZipTools cached " + n + " bytes from " + fileName); -return listing.toString (); -}, "java.io.BufferedInputStream,~S,java.util.Map,~B"); -c$.getPngImageBytes = Clazz.defineMethod (c$, "getPngImageBytes", -($fz = function (bis) { -try { -if (javajs.util.Rdr.isPngZipStream (bis)) { -var pt_count = Clazz.newIntArray (2, 0); -javajs.util.Rdr.getPngZipPointAndCount (bis, pt_count); -if (pt_count[1] != 0) return javajs.util.ZipTools.deActivatePngZipB (javajs.util.Rdr.getLimitedStreamBytes (bis, pt_count[0])); -}return javajs.util.Rdr.getLimitedStreamBytes (bis, -1); -} catch (e) { -if (Clazz.exceptionOf (e, java.io.IOException)) { -return null; -} else { -throw e; -} -} -}, $fz.isPrivate = true, $fz), "java.io.BufferedInputStream"); -c$.deActivatePngZipB = Clazz.defineMethod (c$, "deActivatePngZipB", -($fz = function (bytes) { -if (javajs.util.Rdr.isPngZipB (bytes)) bytes[51] = 32; -return bytes; -}, $fz.isPrivate = true, $fz), "~A"); -}); +Clazz.declarePackage ("javajs.util"); +Clazz.load (["javajs.api.GenericZipTools"], "javajs.util.ZipTools", ["java.io.BufferedInputStream", "$.IOException", "java.lang.Boolean", "java.util.zip.CRC32", "$.GZIPInputStream", "$.ZipEntry", "$.ZipInputStream", "javajs.api.GenericZipInputStream", "$.ZInputStream", "javajs.util.BArray", "$.Lst", "$.PT", "$.Rdr", "$.SB"], function () { +c$ = Clazz.declareType (javajs.util, "ZipTools", null, javajs.api.GenericZipTools); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.overrideMethod (c$, "newZipInputStream", +function (is) { +return javajs.util.ZipTools.newZIS (is); +}, "java.io.InputStream"); +c$.newZIS = Clazz.defineMethod (c$, "newZIS", +($fz = function (is) { +return (Clazz.instanceOf (is, javajs.api.ZInputStream) ? is : Clazz.instanceOf (is, java.io.BufferedInputStream) ? new javajs.api.GenericZipInputStream (is) : new javajs.api.GenericZipInputStream ( new java.io.BufferedInputStream (is))); +}, $fz.isPrivate = true, $fz), "java.io.InputStream"); +Clazz.overrideMethod (c$, "getAllZipData", +function (is, subfileList, name0, binaryFileList, fileData) { +var zis = javajs.util.ZipTools.newZIS (is); +var ze; +var listing = new javajs.util.SB (); +binaryFileList = "|" + binaryFileList + "|"; +var prefix = javajs.util.PT.join (subfileList, '/', 1); +var prefixd = null; +if (prefix != null) { +prefixd = prefix.substring (0, prefix.indexOf ("/") + 1); +if (prefixd.length == 0) prefixd = null; +}try { +while ((ze = zis.getNextEntry ()) != null) { +var name = ze.getName (); +if (prefix != null && prefixd != null && !(name.equals (prefix) || name.startsWith (prefixd))) continue; +listing.append (name).appendC ('\n'); +var sname = "|" + name.substring (name.lastIndexOf ("/") + 1) + "|"; +var asBinaryString = (binaryFileList.indexOf (sname) >= 0); +var bytes = javajs.util.Rdr.getLimitedStreamBytes (zis, ze.getSize ()); +var str; +if (asBinaryString) { +str = this.getBinaryStringForBytes (bytes); +name += ":asBinaryString"; +} else { +str = javajs.util.Rdr.fixUTF (bytes); +}str = "BEGIN Directory Entry " + name + "\n" + str + "\nEND Directory Entry " + name + "\n"; +fileData.put (name0 + "|" + name, str); +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +fileData.put ("#Directory_Listing", listing.toString ()); +}, "java.io.InputStream,~A,~S,~S,java.util.Map"); +Clazz.defineMethod (c$, "getBinaryStringForBytes", +($fz = function (bytes) { +var ret = new javajs.util.SB (); +for (var i = 0; i < bytes.length; i++) ret.append (Integer.toHexString (bytes[i] & 0xFF)).appendC (' '); + +return ret.toString (); +}, $fz.isPrivate = true, $fz), "~A"); +Clazz.overrideMethod (c$, "getZipFileDirectory", +function (bis, list, listPtr, asBufferedInputStream) { +var ret; +if (list == null || listPtr >= list.length) return this.getZipDirectoryAsStringAndClose (bis); +bis = javajs.util.Rdr.getPngZipStream (bis, true); +var fileName = list[listPtr]; +var zis = new java.util.zip.ZipInputStream (bis); +var ze; +try { +var isAll = (fileName.equals (".")); +if (isAll || fileName.lastIndexOf ("/") == fileName.length - 1) { +ret = new javajs.util.SB (); +while ((ze = zis.getNextEntry ()) != null) { +var name = ze.getName (); +if (isAll || name.startsWith (fileName)) ret.append (name).appendC ('\n'); +} +var str = ret.toString (); +return (asBufferedInputStream ? javajs.util.Rdr.getBIS (str.getBytes ()) : str); +}var pt = fileName.indexOf (":asBinaryString"); +var asBinaryString = (pt > 0); +if (asBinaryString) fileName = fileName.substring (0, pt); +fileName = fileName.$replace ('\\', '/'); +while ((ze = zis.getNextEntry ()) != null && !fileName.equals (ze.getName ())) { +} +var bytes = (ze == null ? null : javajs.util.Rdr.getLimitedStreamBytes (zis, ze.getSize ())); +ze = null; +zis.close (); +if (bytes == null) return ""; +if (javajs.util.Rdr.isZipB (bytes) || javajs.util.Rdr.isPngZipB (bytes)) return this.getZipFileDirectory (javajs.util.Rdr.getBIS (bytes), list, ++listPtr, asBufferedInputStream); +if (asBufferedInputStream) return javajs.util.Rdr.getBIS (bytes); +if (asBinaryString) { +ret = new javajs.util.SB (); +for (var i = 0; i < bytes.length; i++) ret.append (Integer.toHexString (bytes[i] & 0xFF)).appendC (' '); + +return ret.toString (); +}if (javajs.util.Rdr.isGzipB (bytes)) bytes = javajs.util.Rdr.getLimitedStreamBytes (this.getUnGzippedInputStream (bytes), -1); +return javajs.util.Rdr.fixUTF (bytes); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +return ""; +} else { +throw e; +} +} +}, "java.io.BufferedInputStream,~A,~N,~B"); +Clazz.overrideMethod (c$, "getZipFileContentsAsBytes", +function (bis, list, listPtr) { +var ret = Clazz.newByteArray (0, 0); +var fileName = list[listPtr]; +if (fileName.lastIndexOf ("/") == fileName.length - 1) return ret; +try { +bis = javajs.util.Rdr.getPngZipStream (bis, true); +var zis = new java.util.zip.ZipInputStream (bis); +var ze; +while ((ze = zis.getNextEntry ()) != null) { +if (!fileName.equals (ze.getName ())) continue; +var bytes = javajs.util.Rdr.getLimitedStreamBytes (zis, ze.getSize ()); +return ((javajs.util.Rdr.isZipB (bytes) || javajs.util.Rdr.isPngZipB (bytes)) && ++listPtr < list.length ? this.getZipFileContentsAsBytes (javajs.util.Rdr.getBIS (bytes), list, listPtr) : bytes); +} +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +} else { +throw e; +} +} +return ret; +}, "java.io.BufferedInputStream,~A,~N"); +Clazz.overrideMethod (c$, "getZipDirectoryAsStringAndClose", +function (bis) { +var sb = new javajs.util.SB (); +var s = new Array (0); +try { +s = this.getZipDirectoryOrErrorAndClose (bis, null); +bis.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +for (var i = 0; i < s.length; i++) sb.append (s[i]).appendC ('\n'); + +return sb.toString (); +}, "java.io.BufferedInputStream"); +Clazz.overrideMethod (c$, "getZipDirectoryAndClose", +function (bis, manifestID) { +var s = new Array (0); +try { +s = this.getZipDirectoryOrErrorAndClose (bis, manifestID); +bis.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +System.out.println (e.toString ()); +} else { +throw e; +} +} +return s; +}, "java.io.BufferedInputStream,~S"); +Clazz.defineMethod (c$, "getZipDirectoryOrErrorAndClose", +($fz = function (bis, manifestID) { +bis = javajs.util.Rdr.getPngZipStream (bis, true); +var v = new javajs.util.Lst (); +var zis = new java.util.zip.ZipInputStream (bis); +var ze; +var manifest = null; +while ((ze = zis.getNextEntry ()) != null) { +var fileName = ze.getName (); +if (manifestID != null && fileName.startsWith (manifestID)) manifest = javajs.util.ZipTools.getStreamAsString (zis); + else if (!fileName.startsWith ("__MACOS")) v.addLast (fileName); +} +zis.close (); +if (manifestID != null) v.add (0, manifest == null ? "" : manifest + "\n############\n"); +return v.toArray ( new Array (v.size ())); +}, $fz.isPrivate = true, $fz), "java.io.BufferedInputStream,~S"); +c$.getStreamAsString = Clazz.defineMethod (c$, "getStreamAsString", +function (is) { +return javajs.util.Rdr.fixUTF (javajs.util.Rdr.getLimitedStreamBytes (is, -1)); +}, "java.io.InputStream"); +Clazz.overrideMethod (c$, "newGZIPInputStream", +function (is) { +return new java.io.BufferedInputStream ( new java.util.zip.GZIPInputStream (is, 512)); +}, "java.io.InputStream"); +Clazz.overrideMethod (c$, "getUnGzippedInputStream", +function (bytes) { +try { +return javajs.util.Rdr.getUnzippedInputStream (this, javajs.util.Rdr.getBIS (bytes)); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +return null; +} else { +throw e; +} +} +}, "~A"); +Clazz.overrideMethod (c$, "addZipEntry", +function (zos, fileName) { +(zos).putNextEntry ( new java.util.zip.ZipEntry (fileName)); +}, "~O,~S"); +Clazz.overrideMethod (c$, "closeZipEntry", +function (zos) { +(zos).closeEntry (); +}, "~O"); +Clazz.overrideMethod (c$, "getZipOutputStream", +function (bos) { +{ +return javajs.api.Interface.getInterface( +"java.util.zip.ZipOutputStream").setZOS(bos); +}}, "~O"); +Clazz.overrideMethod (c$, "getCrcValue", +function (bytes) { +var crc = new java.util.zip.CRC32 (); +crc.update (bytes, 0, bytes.length); +return crc.getValue (); +}, "~A"); +Clazz.overrideMethod (c$, "readFileAsMap", +function (bis, bdata, name) { +var pt = (name == null ? -1 : name.indexOf ("|")); +name = (pt >= 0 ? name.substring (pt + 1) : null); +try { +if (javajs.util.Rdr.isPngZipStream (bis)) { +var isImage = "_IMAGE_".equals (name); +if (name == null || isImage) bdata.put ((isImage ? "_DATA_" : "_IMAGE_"), new javajs.util.BArray (javajs.util.ZipTools.getPngImageBytes (bis))); +if (!isImage) this.cacheZipContents (bis, name, bdata, true); +} else if (javajs.util.Rdr.isZipS (bis)) { +this.cacheZipContents (bis, name, bdata, true); +} else if (name == null) { +bdata.put ("_DATA_", new javajs.util.BArray (javajs.util.Rdr.getLimitedStreamBytes (bis, -1))); +} else { +throw new java.io.IOException ("ZIP file " + name + " not found"); +}bdata.put ("$_BINARY_$", Boolean.TRUE); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +bdata.clear (); +bdata.put ("_ERROR_", e.getMessage ()); +} else { +throw e; +} +} +}, "java.io.BufferedInputStream,java.util.Map,~S"); +Clazz.overrideMethod (c$, "cacheZipContents", +function (bis, fileName, cache, asByteArray) { +var zis = javajs.util.ZipTools.newZIS (bis); +var ze; +var listing = new javajs.util.SB (); +var n = 0; +var oneFile = (asByteArray && fileName != null); +var pt = (oneFile ? fileName.indexOf ("|") : -1); +var file0 = (pt >= 0 ? fileName : null); +if (pt >= 0) fileName = fileName.substring (0, pt); +try { +while ((ze = zis.getNextEntry ()) != null) { +var name = ze.getName (); +if (fileName != null) { +if (oneFile) { +if (!name.equalsIgnoreCase (fileName)) continue; +} else { +listing.append (name).appendC ('\n'); +}}var nBytes = ze.getSize (); +var bytes = javajs.util.Rdr.getLimitedStreamBytes (zis, nBytes); +if (file0 != null) { +this.readFileAsMap (javajs.util.Rdr.getBIS (bytes), cache, file0); +return null; +}n += bytes.length; +var o = (asByteArray ? new javajs.util.BArray (bytes) : bytes); +cache.put ((oneFile ? "_DATA_" : (fileName == null ? "" : fileName + "|") + name), o); +if (oneFile) break; +} +zis.close (); +} catch (e) { +if (Clazz.exceptionOf (e, Exception)) { +try { +zis.close (); +} catch (e1) { +if (Clazz.exceptionOf (e1, java.io.IOException)) { +} else { +throw e1; +} +} +return null; +} else { +throw e; +} +} +if (n == 0 || fileName == null) return null; +System.out.println ("ZipTools cached " + n + " bytes from " + fileName); +return listing.toString (); +}, "java.io.BufferedInputStream,~S,java.util.Map,~B"); +c$.getPngImageBytes = Clazz.defineMethod (c$, "getPngImageBytes", +($fz = function (bis) { +try { +if (javajs.util.Rdr.isPngZipStream (bis)) { +var pt_count = Clazz.newIntArray (2, 0); +javajs.util.Rdr.getPngZipPointAndCount (bis, pt_count); +if (pt_count[1] != 0) return javajs.util.ZipTools.deActivatePngZipB (javajs.util.Rdr.getLimitedStreamBytes (bis, pt_count[0])); +}return javajs.util.Rdr.getLimitedStreamBytes (bis, -1); +} catch (e) { +if (Clazz.exceptionOf (e, java.io.IOException)) { +return null; +} else { +throw e; +} +} +}, $fz.isPrivate = true, $fz), "java.io.BufferedInputStream"); +c$.deActivatePngZipB = Clazz.defineMethod (c$, "deActivatePngZipB", +($fz = function (bytes) { +if (javajs.util.Rdr.isPngZipB (bytes)) bytes[51] = 32; +return bytes; +}, $fz.isPrivate = true, $fz), "~A"); +}); diff --git a/bin/netscape/javascript/JSException.js b/bin/netscape/javascript/JSException.js index 8033210..41d9f27 100644 --- a/bin/netscape/javascript/JSException.js +++ b/bin/netscape/javascript/JSException.js @@ -1,4 +1,4 @@ -Clazz.declarePackage ("netscape.javascript"); -Clazz.load (["java.lang.Exception"], "netscape.javascript.JSException", null, function () { -c$ = Clazz.declareType (netscape.javascript, "JSException", Exception); -}); +Clazz.declarePackage ("netscape.javascript"); +Clazz.load (["java.lang.Exception"], "netscape.javascript.JSException", null, function () { +c$ = Clazz.declareType (netscape.javascript, "JSException", Exception); +}); diff --git a/bin/netscape/javascript/JSObject.js b/bin/netscape/javascript/JSObject.js index e43f247..661d426 100644 --- a/bin/netscape/javascript/JSObject.js +++ b/bin/netscape/javascript/JSObject.js @@ -1,19 +1,19 @@ -Clazz.declarePackage ("netscape.javascript"); -c$ = Clazz.declareType (netscape.javascript, "JSObject"); -c$.getWindow = Clazz.defineMethod (c$, "getWindow", -function (jvlite) { -{ -return window; -}}, "jalview.bin.JalviewLite"); -Clazz.defineMethod (c$, "call", -function (func, params) { -{ -alert("call " + func); -func.apply(null, params); -}}, "~S,~A"); -Clazz.defineMethod (c$, "eval", -function (string) { -{ -alert("evval " + string); -}return this.eval (string); -}, "~S"); +Clazz.declarePackage ("netscape.javascript"); +c$ = Clazz.declareType (netscape.javascript, "JSObject"); +c$.getWindow = Clazz.defineMethod (c$, "getWindow", +function (jvlite) { +{ +return window; +}}, "jalview.bin.JalviewLite"); +Clazz.defineMethod (c$, "call", +function (func, params) { +{ +alert("call " + func); +func.apply(null, params); +}}, "~S,~A"); +Clazz.defineMethod (c$, "eval", +function (string) { +{ +alert("evval " + string); +}return this.eval (string); +}, "~S"); diff --git a/bin/org/exolab/castor/mapping/Mapping.js b/bin/org/exolab/castor/mapping/Mapping.js index b4a3c0f..d15a01d 100644 --- a/bin/org/exolab/castor/mapping/Mapping.js +++ b/bin/org/exolab/castor/mapping/Mapping.js @@ -1,8 +1,8 @@ -Clazz.declarePackage ("org.exolab.castor.mapping"); -c$ = Clazz.declareType (org.exolab.castor.mapping, "Mapping"); -Clazz.makeConstructor (c$, -function (classLoader) { -}, "ClassLoader"); -Clazz.defineMethod (c$, "loadMapping", -function (url) { -}, "java.net.URL"); +Clazz.declarePackage ("org.exolab.castor.mapping"); +c$ = Clazz.declareType (org.exolab.castor.mapping, "Mapping"); +Clazz.makeConstructor (c$, +function (classLoader) { +}, "ClassLoader"); +Clazz.defineMethod (c$, "loadMapping", +function (url) { +}, "java.net.URL"); diff --git a/bin/org/exolab/castor/xml/Unmarshaller.js b/bin/org/exolab/castor/xml/Unmarshaller.js index 70aff82..09f0175 100644 --- a/bin/org/exolab/castor/xml/Unmarshaller.js +++ b/bin/org/exolab/castor/xml/Unmarshaller.js @@ -1,24 +1,24 @@ -Clazz.declarePackage ("org.exolab.castor.xml"); -c$ = Clazz.declareType (org.exolab.castor.xml, "Unmarshaller"); -Clazz.makeConstructor (c$, -function (record) { -}, "~O"); -Clazz.defineMethod (c$, "setIgnoreExtraElements", -function (b) { -}, "~B"); -Clazz.defineMethod (c$, "setIgnoreExtraAttributes", -function (b) { -}, "~B"); -Clazz.defineMethod (c$, "setMapping", -function (map) { -}, "org.exolab.castor.mapping.Mapping"); -Clazz.defineMethod (c$, "setLogWriter", -function (printWriter) { -}, "java.io.PrintWriter"); -Clazz.defineMethod (c$, "unmarshal", -function (file) { -return null; -}, "java.io.Reader"); -Clazz.defineMethod (c$, "setDebug", -function (debugEnabled) { -}, "~B"); +Clazz.declarePackage ("org.exolab.castor.xml"); +c$ = Clazz.declareType (org.exolab.castor.xml, "Unmarshaller"); +Clazz.makeConstructor (c$, +function (record) { +}, "~O"); +Clazz.defineMethod (c$, "setIgnoreExtraElements", +function (b) { +}, "~B"); +Clazz.defineMethod (c$, "setIgnoreExtraAttributes", +function (b) { +}, "~B"); +Clazz.defineMethod (c$, "setMapping", +function (map) { +}, "org.exolab.castor.mapping.Mapping"); +Clazz.defineMethod (c$, "setLogWriter", +function (printWriter) { +}, "java.io.PrintWriter"); +Clazz.defineMethod (c$, "unmarshal", +function (file) { +return null; +}, "java.io.Reader"); +Clazz.defineMethod (c$, "setDebug", +function (debugEnabled) { +}, "~B"); diff --git a/bin/org/jmol/viewer/Viewer.js b/bin/org/jmol/viewer/Viewer.js index 078e834..42c1406 100644 --- a/bin/org/jmol/viewer/Viewer.js +++ b/bin/org/jmol/viewer/Viewer.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("org.jmol.viewer"); -c$ = Clazz.declareType (org.jmol.viewer, "Viewer"); +Clazz.declarePackage ("org.jmol.viewer"); +c$ = Clazz.declareType (org.jmol.viewer, "Viewer"); diff --git a/bin/swingjs/JSThread.js b/bin/swingjs/JSThread.js index 92f41fb..5c12398 100644 --- a/bin/swingjs/JSThread.js +++ b/bin/swingjs/JSThread.js @@ -1,49 +1,49 @@ -Clazz.declarePackage ("swingjs"); -Clazz.load (["java.lang.Thread", "swingjs.api.JSFunction"], "swingjs.JSThread", null, function () { -c$ = Clazz.decorateAsClass (function () { -this.isJS = false; -Clazz.instantialize (this, arguments); -}, swingjs, "JSThread", Thread, swingjs.api.JSFunction); -Clazz.makeConstructor (c$, -function (group, name) { -Clazz.superConstructor (this, swingjs.JSThread, [group, name]); -{ -this.isJS = true; -}}, "ThreadGroup,~S"); -Clazz.overrideMethod (c$, "run", -function () { -this.run1 (0); -}); -Clazz.defineMethod (c$, "start", -function () { -{ -swingjs.JSToolkit.setTimeout(this, 1, 0); -}}); -Clazz.defineMethod (c$, "sleepAndReturn", -function (delay, state) { -if (!this.isJS) { -Thread.sleep (delay); -return false; -}var me = this; -var r = ((Clazz.isClassDefined ("swingjs.JSThread$1") ? 0 : swingjs.JSThread.$JSThread$1$ ()), Clazz.innerTypeInstance (swingjs.JSThread$1, this, Clazz.cloneFinals ("me", me, "state", state))); -{ -setTimeout( -function() {java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new java.awt.event.InvocationEvent(me, r))}, -delay -); -}return true; -}, "~N,~N"); -c$.$JSThread$1$ = function () { -Clazz.pu$h (); -c$ = Clazz.declareAnonymous (swingjs, "JSThread$1", null, Runnable); -Clazz.overrideMethod (c$, "run", -function () { -this.f$.me.run1 (this.f$.state); -}); -c$ = Clazz.p0p (); -}; -Clazz.defineStatics (c$, -"INIT", 0, -"LOOP", 1, -"DONE", 2); -}); +Clazz.declarePackage ("swingjs"); +Clazz.load (["java.lang.Thread", "swingjs.api.JSFunction"], "swingjs.JSThread", null, function () { +c$ = Clazz.decorateAsClass (function () { +this.isJS = false; +Clazz.instantialize (this, arguments); +}, swingjs, "JSThread", Thread, swingjs.api.JSFunction); +Clazz.makeConstructor (c$, +function (group, name) { +Clazz.superConstructor (this, swingjs.JSThread, [group, name]); +{ +this.isJS = true; +}}, "ThreadGroup,~S"); +Clazz.overrideMethod (c$, "run", +function () { +this.run1 (0); +}); +Clazz.defineMethod (c$, "start", +function () { +{ +swingjs.JSToolkit.setTimeout(this, 1, 0); +}}); +Clazz.defineMethod (c$, "sleepAndReturn", +function (delay, state) { +if (!this.isJS) { +Thread.sleep (delay); +return false; +}var me = this; +var r = ((Clazz.isClassDefined ("swingjs.JSThread$1") ? 0 : swingjs.JSThread.$JSThread$1$ ()), Clazz.innerTypeInstance (swingjs.JSThread$1, this, Clazz.cloneFinals ("me", me, "state", state))); +{ +setTimeout( +function() {java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new java.awt.event.InvocationEvent(me, r))}, +delay +); +}return true; +}, "~N,~N"); +c$.$JSThread$1$ = function () { +Clazz.pu$h (); +c$ = Clazz.declareAnonymous (swingjs, "JSThread$1", null, Runnable); +Clazz.overrideMethod (c$, "run", +function () { +this.f$.me.run1 (this.f$.state); +}); +c$ = Clazz.p0p (); +}; +Clazz.defineStatics (c$, +"INIT", 0, +"LOOP", 1, +"DONE", 2); +}); diff --git a/bin/swingjs/api/DOMNode.js b/bin/swingjs/api/DOMNode.js index ad28942..f518093 100644 --- a/bin/swingjs/api/DOMNode.js +++ b/bin/swingjs/api/DOMNode.js @@ -1,58 +1,58 @@ -Clazz.declarePackage ("swingjs.api"); -c$ = Clazz.declareType (swingjs.api, "DOMNode"); -c$.createElement = Clazz.defineMethod (c$, "createElement", -function (key, id) { -var obj = null; -{ -obj = document.createElement(key); -obj.id = id; -}return obj; -}, "~S,~S"); -c$.getParent = Clazz.defineMethod (c$, "getParent", -function (obj) { -{ -return obj.parentNode; -}}, "swingjs.api.DOMNode"); -c$.remove = Clazz.defineMethod (c$, "remove", -function (obj) { -{ -try { -var p = obj.parentNode; -p.removeNode(obj); -} catch(e) {}; -return p; -}}, "swingjs.api.DOMNode"); -c$.add = Clazz.defineMethod (c$, "add", -function (parent, child) { -{ -parent && parent.appendChild(child); -}}, "swingjs.api.DOMNode,swingjs.api.DOMNode"); -c$.getAttr = Clazz.defineMethod (c$, "getAttr", -function (obj, attr) { -{ -if (obj)return obj[attr]; -}}, "swingjs.api.DOMNode,~S"); -Clazz.defineMethod (c$, "getStyle", -function (style) { -{ -if (obj)return obj.style[style]; -}}, "~S"); -c$.setAttr = Clazz.defineMethod (c$, "setAttr", -function (obj, attr, val) { -{ -obj[attr] = (val == "TRUE" ? true : val); -}return obj; -}, "swingjs.api.DOMNode,~S,~O"); -c$.setStyles = Clazz.defineMethod (c$, "setStyles", -function (obj, attr) { -{ -for (var i = 0; i < attr.length;) { -//System.out.println(["DOMNode.setStyles ",attr[i],attr[i+1]]) -; -obj.style[attr[i++]] = attr[i++]; } -}return obj; -}, "swingjs.api.DOMNode,~A"); -c$.setSize = Clazz.defineMethod (c$, "setSize", -function (obj, width, height) { -return swingjs.api.DOMNode.setStyles (obj, ["width", width + "px", "height", height + "px"]); -}, "swingjs.api.DOMNode,~N,~N"); +Clazz.declarePackage ("swingjs.api"); +c$ = Clazz.declareType (swingjs.api, "DOMNode"); +c$.createElement = Clazz.defineMethod (c$, "createElement", +function (key, id) { +var obj = null; +{ +obj = document.createElement(key); +obj.id = id; +}return obj; +}, "~S,~S"); +c$.getParent = Clazz.defineMethod (c$, "getParent", +function (obj) { +{ +return obj.parentNode; +}}, "swingjs.api.DOMNode"); +c$.remove = Clazz.defineMethod (c$, "remove", +function (obj) { +{ +try { +var p = obj.parentNode; +p.removeNode(obj); +} catch(e) {}; +return p; +}}, "swingjs.api.DOMNode"); +c$.add = Clazz.defineMethod (c$, "add", +function (parent, child) { +{ +parent && parent.appendChild(child); +}}, "swingjs.api.DOMNode,swingjs.api.DOMNode"); +c$.getAttr = Clazz.defineMethod (c$, "getAttr", +function (obj, attr) { +{ +if (obj)return obj[attr]; +}}, "swingjs.api.DOMNode,~S"); +Clazz.defineMethod (c$, "getStyle", +function (style) { +{ +if (obj)return obj.style[style]; +}}, "~S"); +c$.setAttr = Clazz.defineMethod (c$, "setAttr", +function (obj, attr, val) { +{ +obj[attr] = (val == "TRUE" ? true : val); +}return obj; +}, "swingjs.api.DOMNode,~S,~O"); +c$.setStyles = Clazz.defineMethod (c$, "setStyles", +function (obj, attr) { +{ +for (var i = 0; i < attr.length;) { +//System.out.println(["DOMNode.setStyles ",attr[i],attr[i+1]]) +; +obj.style[attr[i++]] = attr[i++]; } +}return obj; +}, "swingjs.api.DOMNode,~A"); +c$.setSize = Clazz.defineMethod (c$, "setSize", +function (obj, width, height) { +return swingjs.api.DOMNode.setStyles (obj, ["width", width + "px", "height", height + "px"]); +}, "swingjs.api.DOMNode,~N,~N"); diff --git a/bin/swingjs/api/JSFunction.js b/bin/swingjs/api/JSFunction.js index 1c8077b..4923079 100644 --- a/bin/swingjs/api/JSFunction.js +++ b/bin/swingjs/api/JSFunction.js @@ -1,2 +1,2 @@ -Clazz.declarePackage ("swingjs.api"); -Clazz.declareInterface (swingjs.api, "JSFunction"); +Clazz.declarePackage ("swingjs.api"); +Clazz.declareInterface (swingjs.api, "JSFunction"); diff --git a/unused/appletgui/APopupMenu.java b/unused/appletgui/APopupMenu.java index ec13e4f..a8cbf11 100644 --- a/unused/appletgui/APopupMenu.java +++ b/unused/appletgui/APopupMenu.java @@ -1,1438 +1,1438 @@ -/* - * 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. - * - * 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 . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.appletgui; - -import jalview.analysis.AAFrequency; -import jalview.analysis.AlignmentAnnotationUtils; -import jalview.analysis.AlignmentUtils; -import jalview.analysis.Conservation; -import jalview.bin.JalviewLite; -import jalview.commands.ChangeCaseCommand; -import jalview.commands.EditCommand; -import jalview.commands.EditCommand.Action; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.DBRefEntry; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -import jalview.io.AppletFormatAdapter; -import jalview.io.SequenceAnnotationReport; -import jalview.schemes.Blosum62ColourScheme; -import jalview.schemes.BuriedColourScheme; -import jalview.schemes.ClustalxColourScheme; -import jalview.schemes.HelixColourScheme; -import jalview.schemes.HydrophobicColourScheme; -import jalview.schemes.NucleotideColourScheme; -import jalview.schemes.PIDColourScheme; -import jalview.schemes.ResidueProperties; -import jalview.schemes.StrandColourScheme; -import jalview.schemes.TaylorColourScheme; -import jalview.schemes.TurnColourScheme; -import jalview.schemes.ZappoColourScheme; -import jalview.util.DBRefUtils; -import jalview.util.MessageManager; -import jalview.util.UrlLink; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - -import javax.swing.JPopupMenu; - -public class APopupMenu extends JPopupMenu implements - ActionListener, ItemListener -{ - private static final String ALL_ANNOTATIONS = "All"; - - JMenu groupMenu = new JMenu(); - - JMenuItem editGroupName = new JMenuItem(); - - protected JMenuItem clustalColour = new JMenuItem(); - - protected JMenuItem zappoColour = new JMenuItem(); - - protected JMenuItem taylorColour = new JMenuItem(); - - protected JMenuItem hydrophobicityColour = new JMenuItem(); - - protected JMenuItem helixColour = new JMenuItem(); - - protected JMenuItem strandColour = new JMenuItem(); - - protected JMenuItem turnColour = new JMenuItem(); - - protected JMenuItem buriedColour = new JMenuItem(); - - protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); - - protected JMenuItem userDefinedColour = new JMenuItem(); - - protected JMenuItem PIDColour = new JMenuItem(); - - protected JMenuItem BLOSUM62Colour = new JMenuItem(); - - JMenuItem noColourmenuItem = new JMenuItem(); - - protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - - final AlignmentPanel ap; - - JMenuItem unGroupMenuItem = new JMenuItem(); - - JMenuItem createGroupMenuItem = new JMenuItem(); - - JMenuItem nucleotideMenuItem = new JMenuItem(); - - JMenu colourMenu = new JMenu(); - - JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem showText = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem(); - - JMenu seqShowAnnotationsMenu = new JMenu( - MessageManager.getString("label.show_annotations")); - - JMenu seqHideAnnotationsMenu = new JMenu( - MessageManager.getString("label.hide_annotations")); - - JMenuItem seqAddReferenceAnnotations = new JMenuItem( - MessageManager.getString("label.add_reference_annotations")); - - JMenu groupShowAnnotationsMenu = new JMenu( - MessageManager.getString("label.show_annotations")); - - JMenu groupHideAnnotationsMenu = new JMenu( - MessageManager.getString("label.hide_annotations")); - - JMenuItem groupAddReferenceAnnotations = new JMenuItem( - MessageManager.getString("label.add_reference_annotations")); - - JMenu editMenu = new JMenu(MessageManager.getString("action.edit")); - - JMenuItem copy = new JMenuItem(MessageManager.getString("action.copy")); - - JMenuItem cut = new JMenuItem(MessageManager.getString("action.cut")); - - JMenuItem toUpper = new JMenuItem( - MessageManager.getString("label.to_upper_case")); - - JMenuItem toLower = new JMenuItem( - MessageManager.getString("label.to_lower_case")); - - JMenuItem toggleCase = new JMenuItem( - MessageManager.getString("label.toggle_case")); - - JMenu outputmenu = new JMenu(); - - JMenu seqMenu = new JMenu(); - - JMenuItem pdb = new JMenuItem(); - - JMenuItem hideSeqs = new JMenuItem(); - - JMenuItem repGroup = new JMenuItem(); - - JMenuItem sequenceName = new JMenuItem( - MessageManager.getString("label.edit_name_description")); - - JMenuItem sequenceFeature = new JMenuItem( - MessageManager.getString("label.create_sequence_feature")); - - JMenuItem editSequence = new JMenuItem( - MessageManager.getString("label.edit_sequence")); - - JMenuItem sequenceDetails = new JMenuItem( - MessageManager.getString("label.sequence_details") + "..."); - - JMenuItem selSeqDetails = new JMenuItem( - MessageManager.getString("label.sequence_details") + "..."); - - JMenuItem makeReferenceSeq = new JMenuItem(); - - SequenceI seq; - - JMenuItem revealAll = new JMenuItem(); - - JMenuItem revealSeq = new JMenuItem(); - - /** - * index of sequence to be revealed - */ - int revealSeq_index = -1; - - JMenu menu1 = new JMenu(); - - public APopupMenu(AlignmentPanel apanel, final SequenceI seq, - Vector links) - { - // ///////////////////////////////////////////////////////// - // If this is activated from the sequence panel, the user may want to - // edit or annotate a particular residue. Therefore display the residue menu - // - // If from the IDPanel, we must display the sequence menu - // //////////////////////////////////////////////////////// - - this.ap = apanel; - this.seq = seq; - - try - { - jbInit(); - } catch (Exception e) - { - e.printStackTrace(); - } - - for (int i = 0; i < AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) - { - JMenuItem item = new JMenuItem( -AppletFormatAdapter.WRITEABLE_FORMATS[i]); - - item.addActionListener(this); - outputmenu.add(item); - } - - buildAnnotationSubmenus(); - - SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg != null && sg.getSize() > 0) - { - editGroupName.setLabel(MessageManager.formatMessage( - "label.name_param", new Object[] - { sg.getName() })); - showText.setState(sg.getDisplayText()); - showColourText.setState(sg.getColourText()); - showBoxes.setState(sg.getDisplayBoxes()); - displayNonconserved.setState(sg.getShowNonconserved()); - if (!ap.av.getAlignment().getGroups().contains(sg)) - { - menu1.setLabel(MessageManager.getString("action.edit_new_group")); - groupMenu.remove(unGroupMenuItem); - } - else - { - menu1.setLabel(MessageManager.getString("action.edit_group")); - groupMenu.remove(createGroupMenuItem); - } - - } - else - { - remove(hideSeqs); - remove(groupMenu); - } - - if (links != null && links.size() > 0) - { - JMenu linkMenu = new JMenu(MessageManager.getString("action.link")); - for (int i = 0; i < links.size(); i++) - { - String link = links.elementAt(i); - UrlLink urlLink = new UrlLink(link); - if (!urlLink.isValid()) - { - System.err.println(urlLink.getInvalidMessage()); - continue; - } - final String target = urlLink.getTarget(); // link.substring(0, - // link.indexOf("|")); - final String label = urlLink.getLabel(); - if (seq != null && urlLink.isDynamic()) - { - - // collect matching db-refs - DBRefEntry[] dbr = DBRefUtils.selectRefs( - seq.getDBRef(), new String[] - { target }); - // collect id string too - String id = seq.getName(); - String descr = seq.getDescription(); - if (descr != null && descr.length() < 1) - { - descr = null; - } - if (dbr != null) - { - for (int r = 0; r < dbr.length; r++) - { - if (id != null && dbr[r].getAccessionId().equals(id)) - { - // suppress duplicate link creation for the bare sequence ID - // string with this link - id = null; - } - // create Bare ID link for this RUL - String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(), - true); - if (urls != null) - { - for (int u = 0; u < urls.length; u += 2) - { - addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]); - } - } - } - } - if (id != null) - { - // create Bare ID link for this RUL - String[] urls = urlLink.makeUrls(id, true); - if (urls != null) - { - for (int u = 0; u < urls.length; u += 2) - { - addshowLink(linkMenu, label, urls[u + 1]); - } - } - // addshowLink(linkMenu, target, url_pref + id + url_suff); - } - // Now construct URLs from description but only try to do it for regex - // URL links - if (descr != null && urlLink.getRegexReplace() != null) - { - // create link for this URL from description only if regex matches - String[] urls = urlLink.makeUrls(descr, true); - if (urls != null) - { - for (int u = 0; u < urls.length; u += 2) - { - addshowLink(linkMenu, label, urls[u + 1]); - } - } - } - } - else - { - addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1)); - } - /* - * final String url; - * - * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID - * string and any matching database reference accessions String url_pref - * = link.substring(link.indexOf("|") + 1, - * link.indexOf("$SEQUENCE_ID$")); - * - * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13); - * // collect matching db-refs DBRefEntry[] dbr = - * DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target}); // - * collect id string too String id = seq.getName(); if (id.indexOf("|") - * > -1) { id = id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) - * { for (int r=0;r 0) - { - if (seq != null) - { - seqMenu.add(linkMenu); - } - else - { - add(linkMenu); - } - } - } - // TODO: add group link menu entry here - if (seq != null) - { - seqMenu.setLabel(seq.getName()); - if (seq == ap.av.getAlignment().getSeqrep()) - { - makeReferenceSeq.setLabel(MessageManager - .getString("action.unmark_as_reference"));// Unmark - // representative"); - } - else - { - makeReferenceSeq.setLabel(MessageManager - .getString("action.set_as_reference")); // ); - } - repGroup.setLabel(MessageManager.formatMessage( - "label.represent_group_with", new Object[] - { seq.getName() })); - } - else - { - remove(seqMenu); - } - - if (!ap.av.hasHiddenRows()) - { - remove(revealAll); - remove(revealSeq); - } - else - { - final int index = ap.av.getAlignment().findIndex(seq); - - if (ap.av.adjustForHiddenSeqs(index) - - ap.av.adjustForHiddenSeqs(index - 1) > 1) - { - revealSeq_index = index; - } - else - { - remove(revealSeq); - } - } - } - - /** - * Build menus for annotation types that may be shown or hidden, and for - * 'reference annotations' that may be added to the alignment. - */ - private void buildAnnotationSubmenus() - { - /* - * First for the currently selected sequence (if there is one): - */ - final List selectedSequence = (seq == null ? Collections - . emptyList() : Arrays.asList(seq)); - buildAnnotationTypesMenus(seqShowAnnotationsMenu, - seqHideAnnotationsMenu, selectedSequence); - configureReferenceAnnotationsMenu(seqAddReferenceAnnotations, - selectedSequence); - - /* - * and repeat for the current selection group (if there is one): - */ - final List selectedGroup = (ap.av.getSelectionGroup() == null ? Collections - . emptyList() : ap.av.getSelectionGroup() - .getSequences()); - buildAnnotationTypesMenus(groupShowAnnotationsMenu, - groupHideAnnotationsMenu, selectedGroup); - configureReferenceAnnotationsMenu(groupAddReferenceAnnotations, - selectedGroup); - } - - /** - * Determine whether or not to enable 'add reference annotations' menu item. - * It is enable if there are any annotations, on any of the selected - * sequences, which are not yet on the alignment (visible or not). - * - * @param menu - * @param forSequences - */ - private void configureReferenceAnnotationsMenu(JMenuItem menuItem, - List forSequences) - { - menuItem.setEnabled(false); - - /* - * Temporary store to hold distinct calcId / type pairs for the tooltip. - * Using TreeMap means calcIds are shown in alphabetical order. - */ - Map tipEntries = new TreeMap(); - final Map> candidates = new LinkedHashMap>(); - AlignmentI al = this.ap.av.getAlignment(); - AlignmentUtils.findAddableReferenceAnnotations(forSequences, - tipEntries, candidates, al); - if (!candidates.isEmpty()) - { - StringBuilder tooltip = new StringBuilder(64); - tooltip.append(MessageManager.getString("label.add_annotations_for")); - - /* - * Found annotations that could be added. Enable the menu item, and - * configure its action. - */ - menuItem.setEnabled(true); - - menuItem.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - addReferenceAnnotations_actionPerformed(candidates); - } - }); - } - } - - /** - * Add annotations to the sequences and to the alignment. - * - * @param candidates - * a map whose keys are sequences on the alignment, and values a list - * of annotations to add to each sequence - */ - protected void addReferenceAnnotations_actionPerformed( - Map> candidates) - { - final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup(); - final AlignmentI alignment = this.ap.getAlignment(); - AlignmentUtils.addReferenceAnnotations(candidates, alignment, - selectionGroup); - refresh(); - } - - /** - * add a show URL menu item to the given linkMenu - * - * @param linkMenu - * @param target - * - menu label string - * @param url - * - url to open - */ - private void addshowLink(JMenu linkMenu, final String target, - final String url) - { - addshowLink(linkMenu, target, target, url); - } - - /** - * add a show URL menu item to the given linkMenu - * - * @param linkMenu - * @param target - * - URL target window - * @param label - * - menu label string - * @param url - * - url to open - */ - private void addshowLink(JMenu linkMenu, final String target, - final String label, final String url) - { - JMenuItem item = new JMenuItem(label); - item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ap.alignFrame.showURL(url, target); - } - }); - linkMenu.add(item); - } - - public void itemStateChanged(ItemEvent evt) - { - if (evt.getSource() == abovePIDColour) - { - abovePIDColour_itemStateChanged(); - } - else if (evt.getSource() == showColourText) - { - showColourText_itemStateChanged(); - } - else if (evt.getSource() == showText) - { - showText_itemStateChanged(); - } - else if (evt.getSource() == showBoxes) - { - showBoxes_itemStateChanged(); - } - else if (evt.getSource() == displayNonconserved) - { - this.showNonconserved_itemStateChanged(); - } - } - - public void actionPerformed(ActionEvent evt) - { - Object source = evt.getSource(); - if (source == clustalColour) - { - clustalColour_actionPerformed(); - } - else if (source == zappoColour) - { - zappoColour_actionPerformed(); - } - else if (source == taylorColour) - { - taylorColour_actionPerformed(); - } - else if (source == hydrophobicityColour) - { - hydrophobicityColour_actionPerformed(); - } - else if (source == helixColour) - { - helixColour_actionPerformed(); - } - else if (source == strandColour) - { - strandColour_actionPerformed(); - } - else if (source == turnColour) - { - turnColour_actionPerformed(); - } - else if (source == buriedColour) - { - buriedColour_actionPerformed(); - } - else if (source == nucleotideMenuItem) - { - nucleotideMenuItem_actionPerformed(); - } - - else if (source == userDefinedColour) - { - userDefinedColour_actionPerformed(); - } - else if (source == PIDColour) - { - PIDColour_actionPerformed(); - } - else if (source == BLOSUM62Colour) - { - BLOSUM62Colour_actionPerformed(); - } - else if (source == noColourmenuItem) - { - noColourmenuItem_actionPerformed(); - } - else if (source == conservationMenuItem) - { - conservationMenuItem_itemStateChanged(); - } - else if (source == unGroupMenuItem) - { - unGroupMenuItem_actionPerformed(); - } - - else if (source == createGroupMenuItem) - { - createGroupMenuItem_actionPerformed(); - } - - else if (source == sequenceName) - { - editName(); - } - else if (source == makeReferenceSeq) - { - makeReferenceSeq_actionPerformed(); - } - else if (source == sequenceDetails) - { - showSequenceDetails(); - } - else if (source == selSeqDetails) - { - showSequenceSelectionDetails(); - } - else if (source == pdb) - { - addPDB(); - } - else if (source == hideSeqs) - { - hideSequences(false); - } - else if (source == repGroup) - { - hideSequences(true); - } - else if (source == revealSeq) - { - ap.av.showSequence(revealSeq_index); - } - else if (source == revealAll) - { - ap.av.showAllHiddenSeqs(); - } - - else if (source == editGroupName) - { - EditNameDialog dialog = new EditNameDialog(getGroup().getName(), - getGroup().getDescription(), " Group Name", - "Group Description", ap.alignFrame, - "Edit Group Name / Description", 500, 100, true); - - if (dialog.accept) - { - getGroup().setName(dialog.getName().replace(' ', '_')); - getGroup().setDescription(dialog.getDescription()); - } - - } - else if (source == copy) - { - ap.alignFrame.copy_actionPerformed(); - } - else if (source == cut) - { - ap.alignFrame.cut_actionPerformed(); - } - else if (source == editSequence) - { - SequenceGroup sg = ap.av.getSelectionGroup(); - - if (sg != null) - { - if (seq == null) - { - seq = sg.getSequenceAt(0); - } - - EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString( - sg.getStartRes(), sg.getEndRes() + 1), null, - "Edit Sequence ", null, - - ap.alignFrame, "Edit Sequence", 500, 100, true); - - if (dialog.accept) - { - EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"), - Action.REPLACE, dialog.getName().replace(' ', - ap.av.getGapCharacter()), - sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), - sg.getStartRes(), sg.getEndRes() + 1, - ap.av.getAlignment()); - - ap.alignFrame.addHistoryItem(editCommand); - - ap.av.firePropertyChange("alignment", null, ap.av.getAlignment() - .getSequences()); - } - } - } - else if (source == toUpper || source == toLower || source == toggleCase) - { - SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg != null) - { - List startEnd = ap.av.getVisibleRegionBoundaries( - sg.getStartRes(), sg.getEndRes() + 1); - - String description; - int caseChange; - - if (source == toggleCase) - { - description = "Toggle Case"; - caseChange = ChangeCaseCommand.TOGGLE_CASE; - } - else if (source == toUpper) - { - description = "To Upper Case"; - caseChange = ChangeCaseCommand.TO_UPPER; - } - else - { - description = "To Lower Case"; - caseChange = ChangeCaseCommand.TO_LOWER; - } - - ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, - sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), - startEnd, caseChange); - - ap.alignFrame.addHistoryItem(caseCommand); - - ap.av.firePropertyChange("alignment", null, ap.av.getAlignment() - .getSequences()); - - } - } - else if (source == sequenceFeature) - { - SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg == null) - { - return; - } - - int rsize = 0, gSize = sg.getSize(); - SequenceI[] rseqs, seqs = new SequenceI[gSize]; - SequenceFeature[] tfeatures, features = new SequenceFeature[gSize]; - - for (int i = 0; i < gSize; i++) - { - int start = sg.getSequenceAt(i).findPosition(sg.getStartRes()); - int end = sg.findEndRes(sg.getSequenceAt(i)); - if (start <= end) - { - seqs[rsize] = sg.getSequenceAt(i); - features[rsize] = new SequenceFeature(null, null, null, start, - end, "Jalview"); - rsize++; - } - } - rseqs = new SequenceI[rsize]; - tfeatures = new SequenceFeature[rsize]; - System.arraycopy(seqs, 0, rseqs, 0, rsize); - System.arraycopy(features, 0, tfeatures, 0, rsize); - features = tfeatures; - seqs = rseqs; - - if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, - features, true, ap)) - { - ap.alignFrame.sequenceFeatures.setState(true); - ap.av.setShowSequenceFeatures(true);; - ap.highlightSearchResults(null); - } - } - else - { - outputText(evt); - } - - } - - void outputText(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame); - - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.selection_output_command", new Object[] - { e.getActionCommand() }), 600, 500); - // JBPNote: getSelectionAsNewSequence behaviour has changed - this method - // now returns a full copy of sequence data - // TODO consider using getSequenceSelection instead here - - cap.setText(new AppletFormatAdapter().formatSequences( - e.getActionCommand(), ap.av.getShowJVSuffix(), ap, true)); - - } - - protected void showSequenceSelectionDetails() - { - createSequenceDetailsReport(ap.av.getSequenceSelection()); - } - - protected void showSequenceDetails() - { - createSequenceDetailsReport(new SequenceI[] - { seq }); - } - - public void createSequenceDetailsReport(SequenceI[] sequences) - { - - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame); - - StringBuffer contents = new StringBuffer(); - for (SequenceI seq : sequences) - { - contents.append(MessageManager.formatMessage( - "label.annotation_for_displayid", new Object[] - { seq.getDisplayId(true) })); - new SequenceAnnotationReport(null) - .createSequenceAnnotationReport( - contents, - seq, - true, - true, - false, - (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.getMinMax() - : null); - contents.append("

    "); - } - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, "Sequence Details for " - + (sequences.length == 1 ? sequences[0].getDisplayId(true) - : "Selection"), 600, 500); - cap.setText(MessageManager.formatMessage("label.html_content", - new Object[] - { contents.toString() })); - } - - void editName() - { - EditNameDialog dialog = new EditNameDialog(seq.getName(), - seq.getDescription(), " Sequence Name", - "Sequence Description", ap.alignFrame, - "Edit Sequence Name / Description", 500, 100, true); - - if (dialog.accept) - { - seq.setName(dialog.getName()); - seq.setDescription(dialog.getDescription()); - ap.paintAlignment(false); - } - } - - void addPDB() - { - if (seq.getPDBId() != null) - { - PDBEntry entry = seq.getPDBId().firstElement(); - -// if (ap.av.applet.jmolAvailable) -// { - new AppletJmol(entry, new SequenceI[] - { seq }, null, ap, AppletFormatAdapter.URL); -// } -// else -// { -// new MCview.AppletPDBViewer(entry, new SequenceI[] -// { seq }, null, ap, AppletFormatAdapter.URL); -// } - - } - else - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame); - cap.setText(MessageManager.getString("label.paste_pdb_file")); - cap.setPDBImport(seq); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.paste_pdb_file_for_sequence", new Object[] - { seq.getName() }), 400, 300); - } - } - - private void jbInit() throws Exception - { - groupMenu.setLabel(MessageManager.getString("label.selection")); - sequenceFeature.addActionListener(this); - - editGroupName.addActionListener(this); - unGroupMenuItem.setLabel(MessageManager - .getString("action.remove_group")); - unGroupMenuItem.addActionListener(this); - - createGroupMenuItem.setLabel(MessageManager - .getString("action.create_group")); - createGroupMenuItem.addActionListener(this); - - nucleotideMenuItem.setLabel(MessageManager - .getString("label.nucleotide")); - nucleotideMenuItem.addActionListener(this); - conservationMenuItem.addItemListener(this); - abovePIDColour.addItemListener(this); - colourMenu.setLabel(MessageManager.getString("label.group_colour")); - showBoxes.setLabel(MessageManager.getString("action.boxes")); - showBoxes.setState(true); - showBoxes.addItemListener(this); - sequenceName.addActionListener(this); - sequenceDetails.addActionListener(this); - selSeqDetails.addActionListener(this); - displayNonconserved.setLabel(MessageManager - .getString("label.show_non_conversed")); - displayNonconserved.setState(false); - displayNonconserved.addItemListener(this); - showText.setLabel(MessageManager.getString("action.text")); - showText.addItemListener(this); - showColourText.setLabel(MessageManager.getString("label.colour_text")); - showColourText.addItemListener(this); - outputmenu.setLabel(MessageManager.getString("label.out_to_textbox")); - seqMenu.setLabel(MessageManager.getString("label.sequence")); - pdb.setLabel(MessageManager.getString("label.view_pdb_structure")); - hideSeqs.setLabel(MessageManager.getString("action.hide_sequences")); - repGroup.setLabel(MessageManager.formatMessage( - "label.represent_group_with", new Object[] - { "" })); - revealAll.setLabel(MessageManager.getString("action.reveal_all")); - revealSeq.setLabel(MessageManager.getString("action.reveal_sequences")); - menu1.setLabel(MessageManager.getString("label.group") + ":"); - add(groupMenu); - this.add(seqMenu); - this.add(hideSeqs); - this.add(revealSeq); - this.add(revealAll); - // groupMenu.add(selSeqDetails); - groupMenu.add(groupShowAnnotationsMenu); - groupMenu.add(groupHideAnnotationsMenu); - groupMenu.add(groupAddReferenceAnnotations); - groupMenu.add(editMenu); - groupMenu.add(outputmenu); - groupMenu.add(sequenceFeature); - groupMenu.add(createGroupMenuItem); - groupMenu.add(unGroupMenuItem); - groupMenu.add(menu1); - - colourMenu.add(noColourmenuItem); - colourMenu.add(clustalColour); - colourMenu.add(BLOSUM62Colour); - colourMenu.add(PIDColour); - colourMenu.add(zappoColour); - colourMenu.add(taylorColour); - colourMenu.add(hydrophobicityColour); - colourMenu.add(helixColour); - colourMenu.add(strandColour); - colourMenu.add(turnColour); - colourMenu.add(buriedColour); - colourMenu.add(nucleotideMenuItem); - colourMenu.add(userDefinedColour); - colourMenu.addSeparator(); - colourMenu.add(abovePIDColour); - colourMenu.add(conservationMenuItem); - - noColourmenuItem.setLabel(MessageManager.getString("label.none")); - noColourmenuItem.addActionListener(this); - - clustalColour.setLabel(MessageManager.getString("label.clustalx_colours")); - clustalColour.addActionListener(this); - zappoColour.setLabel(MessageManager.getString("label.zappo")); - zappoColour.addActionListener(this); - taylorColour.setLabel(MessageManager.getString("label.taylor")); - taylorColour.addActionListener(this); - hydrophobicityColour.setLabel(MessageManager.getString("label.hydrophobicity")); - hydrophobicityColour.addActionListener(this); - helixColour.setLabel(MessageManager.getString("label.helix_propensity")); - helixColour.addActionListener(this); - strandColour.setLabel(MessageManager.getString("label.strand_propensity")); - strandColour.addActionListener(this); - turnColour.setLabel(MessageManager.getString("label.turn_propensity")); - turnColour.addActionListener(this); - buriedColour.setLabel(MessageManager.getString("label.buried_index")); - buriedColour.addActionListener(this); - abovePIDColour.setLabel(MessageManager.getString("label.above_identity_percentage")); - - userDefinedColour.setLabel(MessageManager.getString("action.user_defined")); - userDefinedColour.addActionListener(this); - PIDColour.setLabel(MessageManager.getString("action.percentage_identity")); - PIDColour.addActionListener(this); - BLOSUM62Colour.setLabel("BLOSUM62"); - BLOSUM62Colour.addActionListener(this); - conservationMenuItem.setLabel(MessageManager.getString("label.conservation")); - - editMenu.add(copy); - copy.addActionListener(this); - editMenu.add(cut); - cut.addActionListener(this); - - editMenu.add(editSequence); - editSequence.addActionListener(this); - - editMenu.add(toUpper); - toUpper.addActionListener(this); - editMenu.add(toLower); - toLower.addActionListener(this); - editMenu.add(toggleCase); - seqMenu.add(seqShowAnnotationsMenu); - seqMenu.add(seqHideAnnotationsMenu); - seqMenu.add(seqAddReferenceAnnotations); - seqMenu.add(sequenceName); - seqMenu.add(makeReferenceSeq); - // seqMenu.add(sequenceDetails); - - if (!ap.av.applet.useXtrnalSviewer) - { - seqMenu.add(pdb); - } - seqMenu.add(repGroup); - menu1.add(editGroupName); - menu1.add(colourMenu); - menu1.add(showBoxes); - menu1.add(showText); - menu1.add(showColourText); - menu1.add(displayNonconserved); - toggleCase.addActionListener(this); - pdb.addActionListener(this); - hideSeqs.addActionListener(this); - repGroup.addActionListener(this); - revealAll.addActionListener(this); - revealSeq.addActionListener(this); - makeReferenceSeq.addActionListener(this); - } - - void refresh() - { - ap.paintAlignment(true); - } - - protected void clustalColour_actionPerformed() - { - SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences()); - refresh(); - } - - protected void zappoColour_actionPerformed() - { - getGroup().cs = new ZappoColourScheme(); - refresh(); - } - - protected void taylorColour_actionPerformed() - { - getGroup().cs = new TaylorColourScheme(); - refresh(); - } - - protected void hydrophobicityColour_actionPerformed() - { - getGroup().cs = new HydrophobicColourScheme(); - refresh(); - } - - protected void helixColour_actionPerformed() - { - getGroup().cs = new HelixColourScheme(); - refresh(); - } - - protected void strandColour_actionPerformed() - { - getGroup().cs = new StrandColourScheme(); - refresh(); - } - - protected void turnColour_actionPerformed() - { - getGroup().cs = new TurnColourScheme(); - refresh(); - } - - protected void buriedColour_actionPerformed() - { - getGroup().cs = new BuriedColourScheme(); - refresh(); - } - - public void nucleotideMenuItem_actionPerformed() - { - getGroup().cs = new NucleotideColourScheme(); - refresh(); - } - - protected void abovePIDColour_itemStateChanged() - { - SequenceGroup sg = getGroup(); - if (sg.cs == null) - { - return; - } - - if (abovePIDColour.getState()) - { - sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av - .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth())); - int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup() - .getName()); - - sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus()); - - SliderPanel.showPIDSlider(); - - } - else - // remove PIDColouring - { - sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus()); - } - - refresh(); - - } - - protected void userDefinedColour_actionPerformed() - { - new UserDefinedColours(ap, getGroup()); - } - - protected void PIDColour_actionPerformed() - { - SequenceGroup sg = getGroup(); - sg.cs = new PIDColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av - .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth())); - refresh(); - } - - protected void BLOSUM62Colour_actionPerformed() - { - SequenceGroup sg = getGroup(); - - sg.cs = new Blosum62ColourScheme(); - - sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av - .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth())); - - refresh(); - } - - protected void noColourmenuItem_actionPerformed() - { - getGroup().cs = null; - refresh(); - } - - protected void conservationMenuItem_itemStateChanged() - { - SequenceGroup sg = getGroup(); - if (sg.cs == null) - { - return; - } - - if (conservationMenuItem.getState()) - { - - sg.cs.setConservation(Conservation.calculateConservation("Group", - ResidueProperties.propHash, 3, sg.getSequences(ap.av - .getHiddenRepSequences()), 0, ap.av.getAlignment() - .getWidth(), false, ap.av.getConsPercGaps(), false)); - SliderPanel.setConservationSlider(ap, sg.cs, sg.getName()); - SliderPanel.showConservationSlider(); - } - else - // remove ConservationColouring - { - sg.cs.setConservation(null); - } - - refresh(); - } - - SequenceGroup getGroup() - { - SequenceGroup sg = ap.av.getSelectionGroup(); - - // this method won't add a new group if it already exists - if (sg != null) - { - ap.av.getAlignment().addGroup(sg); - } - - return sg; - } - - void unGroupMenuItem_actionPerformed() - { - SequenceGroup sg = ap.av.getSelectionGroup(); - ap.av.getAlignment().deleteGroup(sg); - ap.av.setSelectionGroup(null); - ap.paintAlignment(true); - } - - void createGroupMenuItem_actionPerformed() - { - getGroup(); // implicitly create group - refresh(); - } - - public void showColourText_itemStateChanged() - { - getGroup().setColourText(showColourText.getState()); - refresh(); - } - - public void showText_itemStateChanged() - { - getGroup().setDisplayText(showText.getState()); - refresh(); - } - public void makeReferenceSeq_actionPerformed() - { - if (!ap.av.getAlignment().hasSeqrep()) - { - // initialise the display flags so the user sees something happen - ap.av.setDisplayReferenceSeq(true); - ap.av.setColourByReferenceSeq(true); - ap.av.getAlignment().setSeqrep(seq); - } - else - { - if (ap.av.getAlignment().getSeqrep() == seq) - { - ap.av.getAlignment().setSeqrep(null); - } - else - { - ap.av.getAlignment().setSeqrep(seq); - } - } - refresh(); - } - - public void showNonconserved_itemStateChanged() - { - getGroup().setShowNonconserved(this.displayNonconserved.getState()); - refresh(); - } - - public void showBoxes_itemStateChanged() - { - getGroup().setDisplayBoxes(showBoxes.getState()); - refresh(); - } - - void hideSequences(boolean representGroup) - { - SequenceGroup sg = ap.av.getSelectionGroup(); - if (sg == null || sg.getSize() < 1) - { - ap.av.hideSequence(new SequenceI[] - { seq }); - return; - } - - ap.av.setSelectionGroup(null); - - if (representGroup) - { - ap.av.hideRepSequences(seq, sg); - - return; - } - - int gsize = sg.getSize(); - SequenceI[] hseqs; - - hseqs = new SequenceI[gsize]; - - int index = 0; - for (int i = 0; i < gsize; i++) - { - hseqs[index++] = sg.getSequenceAt(i); - } - - ap.av.hideSequence(hseqs); - ap.av.sendSelection(); - } - - /** - * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus. - * "All" is added first, followed by a separator. Then add any annotation - * types associated with the current selection. Separate menus are built for - * the selected sequence group (if any), and the selected sequence. - *

    - * Some annotation rows are always rendered together - these can be identified - * by a common graphGroup property > -1. Only one of each group will be marked - * as visible (to avoid duplication of the display). For such groups we add a - * composite type name, e.g. - *

    - * IUPredWS (Long), IUPredWS (Short) - * - * @param seq - */ - protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu, - List forSequences) - { - showMenu.removeAll(); - hideMenu.removeAll(); - - final List all = Arrays.asList(ALL_ANNOTATIONS); - addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true); - addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true, - false); - showMenu.addSeparator(); - hideMenu.addSeparator(); - - final AlignmentAnnotation[] annotations = ap.getAlignment() - .getAlignmentAnnotation(); - - /* - * Find shown/hidden annotations types, distinguished by source (calcId), - * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in - * the insertion order, which is the order of the annotations on the - * alignment. - */ - Map>> shownTypes = new LinkedHashMap>>(); - Map>> hiddenTypes = new LinkedHashMap>>(); - AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, - hiddenTypes, - AlignmentAnnotationUtils.asList(annotations), - forSequences); - - for (String calcId : hiddenTypes.keySet()) - { - for (List type : hiddenTypes.get(calcId)) - { - addAnnotationTypeToShowHide(showMenu, forSequences, - calcId, type, false, true); - } - } - // grey out 'show annotations' if none are hidden - showMenu.setEnabled(!hiddenTypes.isEmpty()); - - for (String calcId : shownTypes.keySet()) - { - for (List type : shownTypes.get(calcId)) - { - addAnnotationTypeToShowHide(hideMenu, forSequences, - calcId, type, false, false); - } - } - // grey out 'hide annotations' if none are shown - hideMenu.setEnabled(!shownTypes.isEmpty()); - } - - /** - * Add one annotation type to the 'Show Annotations' or 'Hide Annotations' - * menus. - * - * @param showOrHideMenu - * the menu to add to - * @param forSequences - * the sequences whose annotations may be shown or hidden - * @param calcId - * @param types - * the label to add - * @param allTypes - * if true this is a special label meaning 'All' - * @param actionIsShow - * if true, the select menu item action is to show the annotation - * type, else hide - */ - protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu, - final List forSequences, String calcId, - final List types, final boolean allTypes, - final boolean actionIsShow) - { - String label = types.toString(); // [a, b, c] - label = label.substring(1, label.length() - 1); - final JMenuItem item = new JMenuItem(label); - item.addActionListener(new java.awt.event.ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(), types, - forSequences, allTypes, actionIsShow); - refresh(); - } - }); - showOrHideMenu.add(item); - } - -} +/* + * 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.appletgui; + +import jalview.analysis.AAFrequency; +import jalview.analysis.AlignmentAnnotationUtils; +import jalview.analysis.AlignmentUtils; +import jalview.analysis.Conservation; +import jalview.bin.JalviewLite; +import jalview.commands.ChangeCaseCommand; +import jalview.commands.EditCommand; +import jalview.commands.EditCommand.Action; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.DBRefEntry; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.io.AppletFormatAdapter; +import jalview.io.SequenceAnnotationReport; +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ClustalxColourScheme; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.ResidueProperties; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; +import jalview.util.DBRefUtils; +import jalview.util.MessageManager; +import jalview.util.UrlLink; + +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.Vector; + +import javax.swing.JPopupMenu; + +public class APopupMenu extends JPopupMenu implements + ActionListener, ItemListener +{ + private static final String ALL_ANNOTATIONS = "All"; + + JMenu groupMenu = new JMenu(); + + JMenuItem editGroupName = new JMenuItem(); + + protected JMenuItem clustalColour = new JMenuItem(); + + protected JMenuItem zappoColour = new JMenuItem(); + + protected JMenuItem taylorColour = new JMenuItem(); + + protected JMenuItem hydrophobicityColour = new JMenuItem(); + + protected JMenuItem helixColour = new JMenuItem(); + + protected JMenuItem strandColour = new JMenuItem(); + + protected JMenuItem turnColour = new JMenuItem(); + + protected JMenuItem buriedColour = new JMenuItem(); + + protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); + + protected JMenuItem userDefinedColour = new JMenuItem(); + + protected JMenuItem PIDColour = new JMenuItem(); + + protected JMenuItem BLOSUM62Colour = new JMenuItem(); + + JMenuItem noColourmenuItem = new JMenuItem(); + + protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); + + final AlignmentPanel ap; + + JMenuItem unGroupMenuItem = new JMenuItem(); + + JMenuItem createGroupMenuItem = new JMenuItem(); + + JMenuItem nucleotideMenuItem = new JMenuItem(); + + JMenu colourMenu = new JMenu(); + + JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem showText = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem(); + + JMenu seqShowAnnotationsMenu = new JMenu( + MessageManager.getString("label.show_annotations")); + + JMenu seqHideAnnotationsMenu = new JMenu( + MessageManager.getString("label.hide_annotations")); + + JMenuItem seqAddReferenceAnnotations = new JMenuItem( + MessageManager.getString("label.add_reference_annotations")); + + JMenu groupShowAnnotationsMenu = new JMenu( + MessageManager.getString("label.show_annotations")); + + JMenu groupHideAnnotationsMenu = new JMenu( + MessageManager.getString("label.hide_annotations")); + + JMenuItem groupAddReferenceAnnotations = new JMenuItem( + MessageManager.getString("label.add_reference_annotations")); + + JMenu editMenu = new JMenu(MessageManager.getString("action.edit")); + + JMenuItem copy = new JMenuItem(MessageManager.getString("action.copy")); + + JMenuItem cut = new JMenuItem(MessageManager.getString("action.cut")); + + JMenuItem toUpper = new JMenuItem( + MessageManager.getString("label.to_upper_case")); + + JMenuItem toLower = new JMenuItem( + MessageManager.getString("label.to_lower_case")); + + JMenuItem toggleCase = new JMenuItem( + MessageManager.getString("label.toggle_case")); + + JMenu outputmenu = new JMenu(); + + JMenu seqMenu = new JMenu(); + + JMenuItem pdb = new JMenuItem(); + + JMenuItem hideSeqs = new JMenuItem(); + + JMenuItem repGroup = new JMenuItem(); + + JMenuItem sequenceName = new JMenuItem( + MessageManager.getString("label.edit_name_description")); + + JMenuItem sequenceFeature = new JMenuItem( + MessageManager.getString("label.create_sequence_feature")); + + JMenuItem editSequence = new JMenuItem( + MessageManager.getString("label.edit_sequence")); + + JMenuItem sequenceDetails = new JMenuItem( + MessageManager.getString("label.sequence_details") + "..."); + + JMenuItem selSeqDetails = new JMenuItem( + MessageManager.getString("label.sequence_details") + "..."); + + JMenuItem makeReferenceSeq = new JMenuItem(); + + SequenceI seq; + + JMenuItem revealAll = new JMenuItem(); + + JMenuItem revealSeq = new JMenuItem(); + + /** + * index of sequence to be revealed + */ + int revealSeq_index = -1; + + JMenu menu1 = new JMenu(); + + public APopupMenu(AlignmentPanel apanel, final SequenceI seq, + Vector links) + { + // ///////////////////////////////////////////////////////// + // If this is activated from the sequence panel, the user may want to + // edit or annotate a particular residue. Therefore display the residue menu + // + // If from the IDPanel, we must display the sequence menu + // //////////////////////////////////////////////////////// + + this.ap = apanel; + this.seq = seq; + + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + + for (int i = 0; i < AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) + { + JMenuItem item = new JMenuItem( +AppletFormatAdapter.WRITEABLE_FORMATS[i]); + + item.addActionListener(this); + outputmenu.add(item); + } + + buildAnnotationSubmenus(); + + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg != null && sg.getSize() > 0) + { + editGroupName.setLabel(MessageManager.formatMessage( + "label.name_param", new Object[] + { sg.getName() })); + showText.setState(sg.getDisplayText()); + showColourText.setState(sg.getColourText()); + showBoxes.setState(sg.getDisplayBoxes()); + displayNonconserved.setState(sg.getShowNonconserved()); + if (!ap.av.getAlignment().getGroups().contains(sg)) + { + menu1.setLabel(MessageManager.getString("action.edit_new_group")); + groupMenu.remove(unGroupMenuItem); + } + else + { + menu1.setLabel(MessageManager.getString("action.edit_group")); + groupMenu.remove(createGroupMenuItem); + } + + } + else + { + remove(hideSeqs); + remove(groupMenu); + } + + if (links != null && links.size() > 0) + { + JMenu linkMenu = new JMenu(MessageManager.getString("action.link")); + for (int i = 0; i < links.size(); i++) + { + String link = links.elementAt(i); + UrlLink urlLink = new UrlLink(link); + if (!urlLink.isValid()) + { + System.err.println(urlLink.getInvalidMessage()); + continue; + } + final String target = urlLink.getTarget(); // link.substring(0, + // link.indexOf("|")); + final String label = urlLink.getLabel(); + if (seq != null && urlLink.isDynamic()) + { + + // collect matching db-refs + DBRefEntry[] dbr = DBRefUtils.selectRefs( + seq.getDBRef(), new String[] + { target }); + // collect id string too + String id = seq.getName(); + String descr = seq.getDescription(); + if (descr != null && descr.length() < 1) + { + descr = null; + } + if (dbr != null) + { + for (int r = 0; r < dbr.length; r++) + { + if (id != null && dbr[r].getAccessionId().equals(id)) + { + // suppress duplicate link creation for the bare sequence ID + // string with this link + id = null; + } + // create Bare ID link for this RUL + String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(), + true); + if (urls != null) + { + for (int u = 0; u < urls.length; u += 2) + { + addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]); + } + } + } + } + if (id != null) + { + // create Bare ID link for this RUL + String[] urls = urlLink.makeUrls(id, true); + if (urls != null) + { + for (int u = 0; u < urls.length; u += 2) + { + addshowLink(linkMenu, label, urls[u + 1]); + } + } + // addshowLink(linkMenu, target, url_pref + id + url_suff); + } + // Now construct URLs from description but only try to do it for regex + // URL links + if (descr != null && urlLink.getRegexReplace() != null) + { + // create link for this URL from description only if regex matches + String[] urls = urlLink.makeUrls(descr, true); + if (urls != null) + { + for (int u = 0; u < urls.length; u += 2) + { + addshowLink(linkMenu, label, urls[u + 1]); + } + } + } + } + else + { + addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1)); + } + /* + * final String url; + * + * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID + * string and any matching database reference accessions String url_pref + * = link.substring(link.indexOf("|") + 1, + * link.indexOf("$SEQUENCE_ID$")); + * + * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13); + * // collect matching db-refs DBRefEntry[] dbr = + * DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target}); // + * collect id string too String id = seq.getName(); if (id.indexOf("|") + * > -1) { id = id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) + * { for (int r=0;r 0) + { + if (seq != null) + { + seqMenu.add(linkMenu); + } + else + { + add(linkMenu); + } + } + } + // TODO: add group link menu entry here + if (seq != null) + { + seqMenu.setLabel(seq.getName()); + if (seq == ap.av.getAlignment().getSeqrep()) + { + makeReferenceSeq.setLabel(MessageManager + .getString("action.unmark_as_reference"));// Unmark + // representative"); + } + else + { + makeReferenceSeq.setLabel(MessageManager + .getString("action.set_as_reference")); // ); + } + repGroup.setLabel(MessageManager.formatMessage( + "label.represent_group_with", new Object[] + { seq.getName() })); + } + else + { + remove(seqMenu); + } + + if (!ap.av.hasHiddenRows()) + { + remove(revealAll); + remove(revealSeq); + } + else + { + final int index = ap.av.getAlignment().findIndex(seq); + + if (ap.av.adjustForHiddenSeqs(index) + - ap.av.adjustForHiddenSeqs(index - 1) > 1) + { + revealSeq_index = index; + } + else + { + remove(revealSeq); + } + } + } + + /** + * Build menus for annotation types that may be shown or hidden, and for + * 'reference annotations' that may be added to the alignment. + */ + private void buildAnnotationSubmenus() + { + /* + * First for the currently selected sequence (if there is one): + */ + final List selectedSequence = (seq == null ? Collections + . emptyList() : Arrays.asList(seq)); + buildAnnotationTypesMenus(seqShowAnnotationsMenu, + seqHideAnnotationsMenu, selectedSequence); + configureReferenceAnnotationsMenu(seqAddReferenceAnnotations, + selectedSequence); + + /* + * and repeat for the current selection group (if there is one): + */ + final List selectedGroup = (ap.av.getSelectionGroup() == null ? Collections + . emptyList() : ap.av.getSelectionGroup() + .getSequences()); + buildAnnotationTypesMenus(groupShowAnnotationsMenu, + groupHideAnnotationsMenu, selectedGroup); + configureReferenceAnnotationsMenu(groupAddReferenceAnnotations, + selectedGroup); + } + + /** + * Determine whether or not to enable 'add reference annotations' menu item. + * It is enable if there are any annotations, on any of the selected + * sequences, which are not yet on the alignment (visible or not). + * + * @param menu + * @param forSequences + */ + private void configureReferenceAnnotationsMenu(JMenuItem menuItem, + List forSequences) + { + menuItem.setEnabled(false); + + /* + * Temporary store to hold distinct calcId / type pairs for the tooltip. + * Using TreeMap means calcIds are shown in alphabetical order. + */ + Map tipEntries = new TreeMap(); + final Map> candidates = new LinkedHashMap>(); + AlignmentI al = this.ap.av.getAlignment(); + AlignmentUtils.findAddableReferenceAnnotations(forSequences, + tipEntries, candidates, al); + if (!candidates.isEmpty()) + { + StringBuilder tooltip = new StringBuilder(64); + tooltip.append(MessageManager.getString("label.add_annotations_for")); + + /* + * Found annotations that could be added. Enable the menu item, and + * configure its action. + */ + menuItem.setEnabled(true); + + menuItem.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + addReferenceAnnotations_actionPerformed(candidates); + } + }); + } + } + + /** + * Add annotations to the sequences and to the alignment. + * + * @param candidates + * a map whose keys are sequences on the alignment, and values a list + * of annotations to add to each sequence + */ + protected void addReferenceAnnotations_actionPerformed( + Map> candidates) + { + final SequenceGroup selectionGroup = this.ap.av.getSelectionGroup(); + final AlignmentI alignment = this.ap.getAlignment(); + AlignmentUtils.addReferenceAnnotations(candidates, alignment, + selectionGroup); + refresh(); + } + + /** + * add a show URL menu item to the given linkMenu + * + * @param linkMenu + * @param target + * - menu label string + * @param url + * - url to open + */ + private void addshowLink(JMenu linkMenu, final String target, + final String url) + { + addshowLink(linkMenu, target, target, url); + } + + /** + * add a show URL menu item to the given linkMenu + * + * @param linkMenu + * @param target + * - URL target window + * @param label + * - menu label string + * @param url + * - url to open + */ + private void addshowLink(JMenu linkMenu, final String target, + final String label, final String url) + { + JMenuItem item = new JMenuItem(label); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + ap.alignFrame.showURL(url, target); + } + }); + linkMenu.add(item); + } + + public void itemStateChanged(ItemEvent evt) + { + if (evt.getSource() == abovePIDColour) + { + abovePIDColour_itemStateChanged(); + } + else if (evt.getSource() == showColourText) + { + showColourText_itemStateChanged(); + } + else if (evt.getSource() == showText) + { + showText_itemStateChanged(); + } + else if (evt.getSource() == showBoxes) + { + showBoxes_itemStateChanged(); + } + else if (evt.getSource() == displayNonconserved) + { + this.showNonconserved_itemStateChanged(); + } + } + + public void actionPerformed(ActionEvent evt) + { + Object source = evt.getSource(); + if (source == clustalColour) + { + clustalColour_actionPerformed(); + } + else if (source == zappoColour) + { + zappoColour_actionPerformed(); + } + else if (source == taylorColour) + { + taylorColour_actionPerformed(); + } + else if (source == hydrophobicityColour) + { + hydrophobicityColour_actionPerformed(); + } + else if (source == helixColour) + { + helixColour_actionPerformed(); + } + else if (source == strandColour) + { + strandColour_actionPerformed(); + } + else if (source == turnColour) + { + turnColour_actionPerformed(); + } + else if (source == buriedColour) + { + buriedColour_actionPerformed(); + } + else if (source == nucleotideMenuItem) + { + nucleotideMenuItem_actionPerformed(); + } + + else if (source == userDefinedColour) + { + userDefinedColour_actionPerformed(); + } + else if (source == PIDColour) + { + PIDColour_actionPerformed(); + } + else if (source == BLOSUM62Colour) + { + BLOSUM62Colour_actionPerformed(); + } + else if (source == noColourmenuItem) + { + noColourmenuItem_actionPerformed(); + } + else if (source == conservationMenuItem) + { + conservationMenuItem_itemStateChanged(); + } + else if (source == unGroupMenuItem) + { + unGroupMenuItem_actionPerformed(); + } + + else if (source == createGroupMenuItem) + { + createGroupMenuItem_actionPerformed(); + } + + else if (source == sequenceName) + { + editName(); + } + else if (source == makeReferenceSeq) + { + makeReferenceSeq_actionPerformed(); + } + else if (source == sequenceDetails) + { + showSequenceDetails(); + } + else if (source == selSeqDetails) + { + showSequenceSelectionDetails(); + } + else if (source == pdb) + { + addPDB(); + } + else if (source == hideSeqs) + { + hideSequences(false); + } + else if (source == repGroup) + { + hideSequences(true); + } + else if (source == revealSeq) + { + ap.av.showSequence(revealSeq_index); + } + else if (source == revealAll) + { + ap.av.showAllHiddenSeqs(); + } + + else if (source == editGroupName) + { + EditNameDialog dialog = new EditNameDialog(getGroup().getName(), + getGroup().getDescription(), " Group Name", + "Group Description", ap.alignFrame, + "Edit Group Name / Description", 500, 100, true); + + if (dialog.accept) + { + getGroup().setName(dialog.getName().replace(' ', '_')); + getGroup().setDescription(dialog.getDescription()); + } + + } + else if (source == copy) + { + ap.alignFrame.copy_actionPerformed(); + } + else if (source == cut) + { + ap.alignFrame.cut_actionPerformed(); + } + else if (source == editSequence) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + + if (sg != null) + { + if (seq == null) + { + seq = sg.getSequenceAt(0); + } + + EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString( + sg.getStartRes(), sg.getEndRes() + 1), null, + "Edit Sequence ", null, + + ap.alignFrame, "Edit Sequence", 500, 100, true); + + if (dialog.accept) + { + EditCommand editCommand = new EditCommand(MessageManager.getString("label.edit_sequences"), + Action.REPLACE, dialog.getName().replace(' ', + ap.av.getGapCharacter()), + sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), + sg.getStartRes(), sg.getEndRes() + 1, + ap.av.getAlignment()); + + ap.alignFrame.addHistoryItem(editCommand); + + ap.av.firePropertyChange("alignment", null, ap.av.getAlignment() + .getSequences()); + } + } + } + else if (source == toUpper || source == toLower || source == toggleCase) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg != null) + { + List startEnd = ap.av.getVisibleRegionBoundaries( + sg.getStartRes(), sg.getEndRes() + 1); + + String description; + int caseChange; + + if (source == toggleCase) + { + description = "Toggle Case"; + caseChange = ChangeCaseCommand.TOGGLE_CASE; + } + else if (source == toUpper) + { + description = "To Upper Case"; + caseChange = ChangeCaseCommand.TO_UPPER; + } + else + { + description = "To Lower Case"; + caseChange = ChangeCaseCommand.TO_LOWER; + } + + ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, + sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), + startEnd, caseChange); + + ap.alignFrame.addHistoryItem(caseCommand); + + ap.av.firePropertyChange("alignment", null, ap.av.getAlignment() + .getSequences()); + + } + } + else if (source == sequenceFeature) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg == null) + { + return; + } + + int rsize = 0, gSize = sg.getSize(); + SequenceI[] rseqs, seqs = new SequenceI[gSize]; + SequenceFeature[] tfeatures, features = new SequenceFeature[gSize]; + + for (int i = 0; i < gSize; i++) + { + int start = sg.getSequenceAt(i).findPosition(sg.getStartRes()); + int end = sg.findEndRes(sg.getSequenceAt(i)); + if (start <= end) + { + seqs[rsize] = sg.getSequenceAt(i); + features[rsize] = new SequenceFeature(null, null, null, start, + end, "Jalview"); + rsize++; + } + } + rseqs = new SequenceI[rsize]; + tfeatures = new SequenceFeature[rsize]; + System.arraycopy(seqs, 0, rseqs, 0, rsize); + System.arraycopy(features, 0, tfeatures, 0, rsize); + features = tfeatures; + seqs = rseqs; + + if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, + features, true, ap)) + { + ap.alignFrame.sequenceFeatures.setState(true); + ap.av.setShowSequenceFeatures(true);; + ap.highlightSearchResults(null); + } + } + else + { + outputText(evt); + } + + } + + void outputText(ActionEvent e) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame); + + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.selection_output_command", new Object[] + { e.getActionCommand() }), 600, 500); + // JBPNote: getSelectionAsNewSequence behaviour has changed - this method + // now returns a full copy of sequence data + // TODO consider using getSequenceSelection instead here + + cap.setText(new AppletFormatAdapter().formatSequences( + e.getActionCommand(), ap.av.getShowJVSuffix(), ap, true)); + + } + + protected void showSequenceSelectionDetails() + { + createSequenceDetailsReport(ap.av.getSequenceSelection()); + } + + protected void showSequenceDetails() + { + createSequenceDetailsReport(new SequenceI[] + { seq }); + } + + public void createSequenceDetailsReport(SequenceI[] sequences) + { + + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame); + + StringBuffer contents = new StringBuffer(); + for (SequenceI seq : sequences) + { + contents.append(MessageManager.formatMessage( + "label.annotation_for_displayid", new Object[] + { seq.getDisplayId(true) })); + new SequenceAnnotationReport(null) + .createSequenceAnnotationReport( + contents, + seq, + true, + true, + false, + (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.getMinMax() + : null); + contents.append("

    "); + } + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, "Sequence Details for " + + (sequences.length == 1 ? sequences[0].getDisplayId(true) + : "Selection"), 600, 500); + cap.setText(MessageManager.formatMessage("label.html_content", + new Object[] + { contents.toString() })); + } + + void editName() + { + EditNameDialog dialog = new EditNameDialog(seq.getName(), + seq.getDescription(), " Sequence Name", + "Sequence Description", ap.alignFrame, + "Edit Sequence Name / Description", 500, 100, true); + + if (dialog.accept) + { + seq.setName(dialog.getName()); + seq.setDescription(dialog.getDescription()); + ap.paintAlignment(false); + } + } + + void addPDB() + { + if (seq.getPDBId() != null) + { + PDBEntry entry = seq.getPDBId().firstElement(); + +// if (ap.av.applet.jmolAvailable) +// { + new AppletJmol(entry, new SequenceI[] + { seq }, null, ap, AppletFormatAdapter.URL); +// } +// else +// { +// new MCview.AppletPDBViewer(entry, new SequenceI[] +// { seq }, null, ap, AppletFormatAdapter.URL); +// } + + } + else + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame); + cap.setText(MessageManager.getString("label.paste_pdb_file")); + cap.setPDBImport(seq); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.paste_pdb_file_for_sequence", new Object[] + { seq.getName() }), 400, 300); + } + } + + private void jbInit() throws Exception + { + groupMenu.setLabel(MessageManager.getString("label.selection")); + sequenceFeature.addActionListener(this); + + editGroupName.addActionListener(this); + unGroupMenuItem.setLabel(MessageManager + .getString("action.remove_group")); + unGroupMenuItem.addActionListener(this); + + createGroupMenuItem.setLabel(MessageManager + .getString("action.create_group")); + createGroupMenuItem.addActionListener(this); + + nucleotideMenuItem.setLabel(MessageManager + .getString("label.nucleotide")); + nucleotideMenuItem.addActionListener(this); + conservationMenuItem.addItemListener(this); + abovePIDColour.addItemListener(this); + colourMenu.setLabel(MessageManager.getString("label.group_colour")); + showBoxes.setLabel(MessageManager.getString("action.boxes")); + showBoxes.setState(true); + showBoxes.addItemListener(this); + sequenceName.addActionListener(this); + sequenceDetails.addActionListener(this); + selSeqDetails.addActionListener(this); + displayNonconserved.setLabel(MessageManager + .getString("label.show_non_conversed")); + displayNonconserved.setState(false); + displayNonconserved.addItemListener(this); + showText.setLabel(MessageManager.getString("action.text")); + showText.addItemListener(this); + showColourText.setLabel(MessageManager.getString("label.colour_text")); + showColourText.addItemListener(this); + outputmenu.setLabel(MessageManager.getString("label.out_to_textbox")); + seqMenu.setLabel(MessageManager.getString("label.sequence")); + pdb.setLabel(MessageManager.getString("label.view_pdb_structure")); + hideSeqs.setLabel(MessageManager.getString("action.hide_sequences")); + repGroup.setLabel(MessageManager.formatMessage( + "label.represent_group_with", new Object[] + { "" })); + revealAll.setLabel(MessageManager.getString("action.reveal_all")); + revealSeq.setLabel(MessageManager.getString("action.reveal_sequences")); + menu1.setLabel(MessageManager.getString("label.group") + ":"); + add(groupMenu); + this.add(seqMenu); + this.add(hideSeqs); + this.add(revealSeq); + this.add(revealAll); + // groupMenu.add(selSeqDetails); + groupMenu.add(groupShowAnnotationsMenu); + groupMenu.add(groupHideAnnotationsMenu); + groupMenu.add(groupAddReferenceAnnotations); + groupMenu.add(editMenu); + groupMenu.add(outputmenu); + groupMenu.add(sequenceFeature); + groupMenu.add(createGroupMenuItem); + groupMenu.add(unGroupMenuItem); + groupMenu.add(menu1); + + colourMenu.add(noColourmenuItem); + colourMenu.add(clustalColour); + colourMenu.add(BLOSUM62Colour); + colourMenu.add(PIDColour); + colourMenu.add(zappoColour); + colourMenu.add(taylorColour); + colourMenu.add(hydrophobicityColour); + colourMenu.add(helixColour); + colourMenu.add(strandColour); + colourMenu.add(turnColour); + colourMenu.add(buriedColour); + colourMenu.add(nucleotideMenuItem); + colourMenu.add(userDefinedColour); + colourMenu.addSeparator(); + colourMenu.add(abovePIDColour); + colourMenu.add(conservationMenuItem); + + noColourmenuItem.setLabel(MessageManager.getString("label.none")); + noColourmenuItem.addActionListener(this); + + clustalColour.setLabel(MessageManager.getString("label.clustalx_colours")); + clustalColour.addActionListener(this); + zappoColour.setLabel(MessageManager.getString("label.zappo")); + zappoColour.addActionListener(this); + taylorColour.setLabel(MessageManager.getString("label.taylor")); + taylorColour.addActionListener(this); + hydrophobicityColour.setLabel(MessageManager.getString("label.hydrophobicity")); + hydrophobicityColour.addActionListener(this); + helixColour.setLabel(MessageManager.getString("label.helix_propensity")); + helixColour.addActionListener(this); + strandColour.setLabel(MessageManager.getString("label.strand_propensity")); + strandColour.addActionListener(this); + turnColour.setLabel(MessageManager.getString("label.turn_propensity")); + turnColour.addActionListener(this); + buriedColour.setLabel(MessageManager.getString("label.buried_index")); + buriedColour.addActionListener(this); + abovePIDColour.setLabel(MessageManager.getString("label.above_identity_percentage")); + + userDefinedColour.setLabel(MessageManager.getString("action.user_defined")); + userDefinedColour.addActionListener(this); + PIDColour.setLabel(MessageManager.getString("action.percentage_identity")); + PIDColour.addActionListener(this); + BLOSUM62Colour.setLabel("BLOSUM62"); + BLOSUM62Colour.addActionListener(this); + conservationMenuItem.setLabel(MessageManager.getString("label.conservation")); + + editMenu.add(copy); + copy.addActionListener(this); + editMenu.add(cut); + cut.addActionListener(this); + + editMenu.add(editSequence); + editSequence.addActionListener(this); + + editMenu.add(toUpper); + toUpper.addActionListener(this); + editMenu.add(toLower); + toLower.addActionListener(this); + editMenu.add(toggleCase); + seqMenu.add(seqShowAnnotationsMenu); + seqMenu.add(seqHideAnnotationsMenu); + seqMenu.add(seqAddReferenceAnnotations); + seqMenu.add(sequenceName); + seqMenu.add(makeReferenceSeq); + // seqMenu.add(sequenceDetails); + + if (!ap.av.applet.useXtrnalSviewer) + { + seqMenu.add(pdb); + } + seqMenu.add(repGroup); + menu1.add(editGroupName); + menu1.add(colourMenu); + menu1.add(showBoxes); + menu1.add(showText); + menu1.add(showColourText); + menu1.add(displayNonconserved); + toggleCase.addActionListener(this); + pdb.addActionListener(this); + hideSeqs.addActionListener(this); + repGroup.addActionListener(this); + revealAll.addActionListener(this); + revealSeq.addActionListener(this); + makeReferenceSeq.addActionListener(this); + } + + void refresh() + { + ap.paintAlignment(true); + } + + protected void clustalColour_actionPerformed() + { + SequenceGroup sg = getGroup(); + sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences()); + refresh(); + } + + protected void zappoColour_actionPerformed() + { + getGroup().cs = new ZappoColourScheme(); + refresh(); + } + + protected void taylorColour_actionPerformed() + { + getGroup().cs = new TaylorColourScheme(); + refresh(); + } + + protected void hydrophobicityColour_actionPerformed() + { + getGroup().cs = new HydrophobicColourScheme(); + refresh(); + } + + protected void helixColour_actionPerformed() + { + getGroup().cs = new HelixColourScheme(); + refresh(); + } + + protected void strandColour_actionPerformed() + { + getGroup().cs = new StrandColourScheme(); + refresh(); + } + + protected void turnColour_actionPerformed() + { + getGroup().cs = new TurnColourScheme(); + refresh(); + } + + protected void buriedColour_actionPerformed() + { + getGroup().cs = new BuriedColourScheme(); + refresh(); + } + + public void nucleotideMenuItem_actionPerformed() + { + getGroup().cs = new NucleotideColourScheme(); + refresh(); + } + + protected void abovePIDColour_itemStateChanged() + { + SequenceGroup sg = getGroup(); + if (sg.cs == null) + { + return; + } + + if (abovePIDColour.getState()) + { + sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av + .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth())); + int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup() + .getName()); + + sg.cs.setThreshold(threshold, ap.av.isIgnoreGapsConsensus()); + + SliderPanel.showPIDSlider(); + + } + else + // remove PIDColouring + { + sg.cs.setThreshold(0, ap.av.isIgnoreGapsConsensus()); + } + + refresh(); + + } + + protected void userDefinedColour_actionPerformed() + { + new UserDefinedColours(ap, getGroup()); + } + + protected void PIDColour_actionPerformed() + { + SequenceGroup sg = getGroup(); + sg.cs = new PIDColourScheme(); + sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av + .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth())); + refresh(); + } + + protected void BLOSUM62Colour_actionPerformed() + { + SequenceGroup sg = getGroup(); + + sg.cs = new Blosum62ColourScheme(); + + sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av + .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth())); + + refresh(); + } + + protected void noColourmenuItem_actionPerformed() + { + getGroup().cs = null; + refresh(); + } + + protected void conservationMenuItem_itemStateChanged() + { + SequenceGroup sg = getGroup(); + if (sg.cs == null) + { + return; + } + + if (conservationMenuItem.getState()) + { + + sg.cs.setConservation(Conservation.calculateConservation("Group", + ResidueProperties.propHash, 3, sg.getSequences(ap.av + .getHiddenRepSequences()), 0, ap.av.getAlignment() + .getWidth(), false, ap.av.getConsPercGaps(), false)); + SliderPanel.setConservationSlider(ap, sg.cs, sg.getName()); + SliderPanel.showConservationSlider(); + } + else + // remove ConservationColouring + { + sg.cs.setConservation(null); + } + + refresh(); + } + + SequenceGroup getGroup() + { + SequenceGroup sg = ap.av.getSelectionGroup(); + + // this method won't add a new group if it already exists + if (sg != null) + { + ap.av.getAlignment().addGroup(sg); + } + + return sg; + } + + void unGroupMenuItem_actionPerformed() + { + SequenceGroup sg = ap.av.getSelectionGroup(); + ap.av.getAlignment().deleteGroup(sg); + ap.av.setSelectionGroup(null); + ap.paintAlignment(true); + } + + void createGroupMenuItem_actionPerformed() + { + getGroup(); // implicitly create group + refresh(); + } + + public void showColourText_itemStateChanged() + { + getGroup().setColourText(showColourText.getState()); + refresh(); + } + + public void showText_itemStateChanged() + { + getGroup().setDisplayText(showText.getState()); + refresh(); + } + public void makeReferenceSeq_actionPerformed() + { + if (!ap.av.getAlignment().hasSeqrep()) + { + // initialise the display flags so the user sees something happen + ap.av.setDisplayReferenceSeq(true); + ap.av.setColourByReferenceSeq(true); + ap.av.getAlignment().setSeqrep(seq); + } + else + { + if (ap.av.getAlignment().getSeqrep() == seq) + { + ap.av.getAlignment().setSeqrep(null); + } + else + { + ap.av.getAlignment().setSeqrep(seq); + } + } + refresh(); + } + + public void showNonconserved_itemStateChanged() + { + getGroup().setShowNonconserved(this.displayNonconserved.getState()); + refresh(); + } + + public void showBoxes_itemStateChanged() + { + getGroup().setDisplayBoxes(showBoxes.getState()); + refresh(); + } + + void hideSequences(boolean representGroup) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + if (sg == null || sg.getSize() < 1) + { + ap.av.hideSequence(new SequenceI[] + { seq }); + return; + } + + ap.av.setSelectionGroup(null); + + if (representGroup) + { + ap.av.hideRepSequences(seq, sg); + + return; + } + + int gsize = sg.getSize(); + SequenceI[] hseqs; + + hseqs = new SequenceI[gsize]; + + int index = 0; + for (int i = 0; i < gsize; i++) + { + hseqs[index++] = sg.getSequenceAt(i); + } + + ap.av.hideSequence(hseqs); + ap.av.sendSelection(); + } + + /** + * Add annotation types to 'Show annotations' and/or 'Hide annotations' menus. + * "All" is added first, followed by a separator. Then add any annotation + * types associated with the current selection. Separate menus are built for + * the selected sequence group (if any), and the selected sequence. + *

    + * Some annotation rows are always rendered together - these can be identified + * by a common graphGroup property > -1. Only one of each group will be marked + * as visible (to avoid duplication of the display). For such groups we add a + * composite type name, e.g. + *

    + * IUPredWS (Long), IUPredWS (Short) + * + * @param seq + */ + protected void buildAnnotationTypesMenus(JMenu showMenu, JMenu hideMenu, + List forSequences) + { + showMenu.removeAll(); + hideMenu.removeAll(); + + final List all = Arrays.asList(ALL_ANNOTATIONS); + addAnnotationTypeToShowHide(showMenu, forSequences, "", all, true, true); + addAnnotationTypeToShowHide(hideMenu, forSequences, "", all, true, + false); + showMenu.addSeparator(); + hideMenu.addSeparator(); + + final AlignmentAnnotation[] annotations = ap.getAlignment() + .getAlignmentAnnotation(); + + /* + * Find shown/hidden annotations types, distinguished by source (calcId), + * and grouped by graphGroup. Using LinkedHashMap means we will retrieve in + * the insertion order, which is the order of the annotations on the + * alignment. + */ + Map>> shownTypes = new LinkedHashMap>>(); + Map>> hiddenTypes = new LinkedHashMap>>(); + AlignmentAnnotationUtils.getShownHiddenTypes(shownTypes, + hiddenTypes, + AlignmentAnnotationUtils.asList(annotations), + forSequences); + + for (String calcId : hiddenTypes.keySet()) + { + for (List type : hiddenTypes.get(calcId)) + { + addAnnotationTypeToShowHide(showMenu, forSequences, + calcId, type, false, true); + } + } + // grey out 'show annotations' if none are hidden + showMenu.setEnabled(!hiddenTypes.isEmpty()); + + for (String calcId : shownTypes.keySet()) + { + for (List type : shownTypes.get(calcId)) + { + addAnnotationTypeToShowHide(hideMenu, forSequences, + calcId, type, false, false); + } + } + // grey out 'hide annotations' if none are shown + hideMenu.setEnabled(!shownTypes.isEmpty()); + } + + /** + * Add one annotation type to the 'Show Annotations' or 'Hide Annotations' + * menus. + * + * @param showOrHideMenu + * the menu to add to + * @param forSequences + * the sequences whose annotations may be shown or hidden + * @param calcId + * @param types + * the label to add + * @param allTypes + * if true this is a special label meaning 'All' + * @param actionIsShow + * if true, the select menu item action is to show the annotation + * type, else hide + */ + protected void addAnnotationTypeToShowHide(JMenu showOrHideMenu, + final List forSequences, String calcId, + final List types, final boolean allTypes, + final boolean actionIsShow) + { + String label = types.toString(); // [a, b, c] + label = label.substring(1, label.length() - 1); + final JMenuItem item = new JMenuItem(label); + item.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + AlignmentUtils.showOrHideSequenceAnnotations(ap.getAlignment(), types, + forSequences, allTypes, actionIsShow); + refresh(); + } + }); + showOrHideMenu.add(item); + } + +} diff --git a/unused/appletgui/AlignFrame.java b/unused/appletgui/AlignFrame.java index 2a73d08..bcc9c7b 100644 --- a/unused/appletgui/AlignFrame.java +++ b/unused/appletgui/AlignFrame.java @@ -1,4248 +1,4248 @@ -/* - * 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. - * - * 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 . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.appletgui; - -import jalview.analysis.AlignmentSorter; -import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; -import jalview.api.AlignViewControllerGuiI; -import jalview.api.AlignViewControllerI; -import jalview.api.AlignViewportI; -import jalview.api.FeatureRenderer; -import jalview.api.FeatureSettingsControllerI; -import jalview.api.SequenceStructureBinding; -import jalview.bin.JalviewLite; -import jalview.commands.CommandI; -import jalview.commands.EditCommand; -import jalview.commands.EditCommand.Action; -import jalview.commands.OrderCommand; -import jalview.commands.RemoveGapColCommand; -import jalview.commands.RemoveGapsCommand; -import jalview.commands.SlideSequencesCommand; -import jalview.commands.TrimRegionCommand; -import jalview.controller.AlignViewController; -import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.AlignmentOrder; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; - -import jalview.io.AlignFile; -import jalview.io.AlignmentProperties; -import jalview.io.AnnotationFile; -import jalview.io.AppletFormatAdapter; -import jalview.io.FeaturesFile; -import jalview.io.NewickFile; -import jalview.jsdev.GenericFileAdapter; -import jalview.schemes.Blosum62ColourScheme; -import jalview.schemes.BuriedColourScheme; -import jalview.schemes.ClustalxColourScheme; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.HelixColourScheme; -import jalview.schemes.HydrophobicColourScheme; -import jalview.schemes.NucleotideColourScheme; -import jalview.schemes.PIDColourScheme; -import jalview.schemes.PurinePyrimidineColourScheme; -import jalview.schemes.RNAHelicesColourChooser; -import jalview.schemes.RNAInteractionColourScheme; -import jalview.schemes.StrandColourScheme; -import jalview.schemes.TCoffeeColourScheme; -import jalview.schemes.TaylorColourScheme; -import jalview.schemes.TurnColourScheme; -import jalview.schemes.ZappoColourScheme; -import jalview.structure.StructureSelectionManager; -import jalview.structures.models.AAStructureBindingModel; -import jalview.util.Comparison; -import jalview.util.MappingUtils; -import jalview.util.MessageManager; -import jalview.viewmodel.AlignmentViewport; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.IOException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Arrays; -import java.util.Deque; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JPanel; - -import org.jmol.viewer.Viewer; - -public class AlignFrame extends EmbmenuFrame implements ActionListener, - ItemListener, KeyListener, AlignViewControllerGuiI -{ - public AlignViewControllerI avc; - - public AlignmentPanel alignPanel; - - public AlignViewport viewport; - - // width and height may be overridden by applet parameters - int frameWidth = 700; - - int frameHeight = 500; - - String jalviewServletURL; - - /* - * Flag for showing autocalculated consensus above or below other consensus - * rows - */ - private boolean showAutoCalculatedAbove; - - private SequenceAnnotationOrder annotationSortOrder; - - /** - * Constructor that creates the frame and adds it to the display. - * - * @param al - * @param applet - * @param title - * @param embedded - */ - public AlignFrame(AlignmentI al, JalviewLite applet, - String title, boolean embedded) - { - this(al, applet, title, embedded, true); - } - - /** - * Constructor that optionally allows the frame to be displayed or only - * created. - * - * @param al - * @param applet - * @param title - * @param embedded - * @param addToDisplay - */ - public AlignFrame(AlignmentI al, JalviewLite applet, - String title, boolean embedded, boolean addToDisplay) - { - this(al, null, null, applet, title, embedded, addToDisplay); - } - - public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, - ColumnSelection columnSelection, JalviewLite applet, - String title, boolean embedded) - { - this(al, hiddenSeqs, columnSelection, applet, title, embedded, true); - } - - public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, - ColumnSelection columnSelection, JalviewLite applet, - String title, boolean embedded, boolean addToDisplay) - { - if (applet != null) - { - jalviewServletURL = applet.getParameter("APPLICATION_URL"); - } - - try - { - jbInit(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - // need to get window geometry before we calculate alignment layout - if (applet != null) - { - String param; - try - { - param = applet.getParameter("windowWidth"); - if (param != null) - { - int width = Integer.parseInt(param); - frameWidth = width; - } - param = applet.getParameter("windowHeight"); - if (param != null) - { - int height = Integer.parseInt(param); - frameHeight = height; - } - } catch (Exception ex) - { - } - } - viewport = new AlignViewport(al, applet); - - if (hiddenSeqs != null && hiddenSeqs.length > 0) - { - viewport.hideSequence(hiddenSeqs); - } - if (columnSelection != null) - { - viewport.setColumnSelection(columnSelection); - } - - alignPanel = new AlignmentPanel(this, viewport); - avc = new AlignViewController(this, viewport, - alignPanel); - viewport.updateConservation(alignPanel); - viewport.updateConsensus(alignPanel); - - displayNonconservedMenuItem.setState(viewport.getShowUnconserved()); - followMouseOverFlag.setState(viewport.isFollowHighlight()); - showGroupConsensus.setState(viewport.isShowGroupConsensus()); - showGroupConservation.setState(viewport.isShowGroupConservation()); - showConsensusHistogram.setState(viewport.isShowConsensusHistogram()); - showSequenceLogo.setState(viewport.isShowSequenceLogo()); - normSequenceLogo.setState(viewport.isNormaliseSequenceLogo()); - applyToAllGroups.setState(viewport.getColourAppliesToAllGroups()); - annotationPanelMenuItem.setState(viewport.isShowAnnotation()); - showAlignmentAnnotations.setState(viewport.isShowAnnotation()); - showSequenceAnnotations.setState(viewport.isShowAnnotation()); - - seqLimits.setState(viewport.getShowJVSuffix()); - - if (applet != null) - { - String param = applet.getParameter("sortBy"); - if (param != null) - { - if (param.equalsIgnoreCase("Id")) - { - sortIDMenuItem_actionPerformed(); - } - else if (param.equalsIgnoreCase("Pairwise Identity")) - { - sortPairwiseMenuItem_actionPerformed(); - } - else if (param.equalsIgnoreCase("Length")) - { - sortLengthMenuItem_actionPerformed(); - } - } - - param = applet.getParameter("wrap"); - if (param != null) - { - if (param.equalsIgnoreCase("true")) - { - wrapMenuItem.setState(true); - wrapMenuItem_actionPerformed(); - } - } - param = applet.getParameter("centrecolumnlabels"); - if (param != null) - { - centreColumnLabelFlag.setState(true); - centreColumnLabelFlag_stateChanged(); - } - - } - if (viewport.getAlignment().isNucleotide()) - { - viewport.updateStrucConsensus(alignPanel); - if (viewport.getAlignment().hasRNAStructure()) - { - RNAHelixColour.setEnabled(true); - } - else - { - RNAHelixColour.setEnabled(false); - } - } - else - { - RNAHelixColour.setEnabled(false); - purinePyrimidineColour.setEnabled(false); - } - // Some JVMS send keyevents to Top frame or lowest panel, - // Havent worked out why yet. So add to both this frame and seqCanvas for - // now - this.addKeyListener(this); - alignPanel.seqPanel.seqCanvas.addKeyListener(this); - alignPanel.idPanel.idCanvas.addKeyListener(this); - alignPanel.scalePanel.addKeyListener(this); - alignPanel.annotationPanel.addKeyListener(this); - alignPanel.annotationPanelHolder.addKeyListener(this); - alignPanel.annotationSpaceFillerHolder.addKeyListener(this); - alignPanel.alabels.addKeyListener(this); - - if (addToDisplay) - { - addToDisplay(embedded); - } - } - - /** - * @param embedded - */ - public void addToDisplay(boolean embedded) - { - createAlignFrameWindow(embedded); - validate(); - alignPanel.adjustAnnotationHeight(); - alignPanel.paintAlignment(true); - } - - public AlignViewport getAlignViewport() - { - return viewport; - } - - public SeqCanvas getSeqcanvas() - { - return alignPanel.seqPanel.seqCanvas; - } - - /** - * Load a features file onto the alignment - * - * @param file - * file URL, content, or other resolvable path - * @param type - * is protocol for accessing data referred to by file - */ - - public boolean parseFeaturesFile(String file, String type) - { - return parseFeaturesFile(file, type, true); - } - - /** - * Load a features file onto the alignment - * - * @param file - * file URL, content, or other resolvable path - * @param type - * is protocol for accessing data referred to by file - * @param autoenabledisplay - * when true, display features flag will be automatically enabled if - * features are loaded - * @return true if data parsed as a features file - */ - public boolean parseFeaturesFile(String file, String type, - boolean autoenabledisplay) - { - // TODO: test if importing a features file onto an alignment which already - // has features with links overwrites the original links. - - Hashtable featureLinks = new Hashtable(); - boolean featuresFile = false; - try - { - featuresFile = new FeaturesFile(file, type) - .parse(viewport.getAlignment(), alignPanel.seqPanel.seqCanvas - .getFeatureRenderer().getFeatureColours(), featureLinks, - true, viewport.applet.getDefaultParameter( - "relaxedidmatch", false)); - } catch (Exception ex) - { - ex.printStackTrace(); - } - - if (featuresFile) - { - if (featureLinks.size() > 0) - { - alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks; - } - if (autoenabledisplay) - { - viewport.setShowSequenceFeatures(true); - sequenceFeatures.setState(true); - } - if (alignPanel.seqPanel.seqCanvas.fr != null) - { - // update the min/max ranges where necessary - alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true); - } - if (viewport.featureSettings != null) - { - viewport.featureSettings.refreshTable(); - } - alignPanel.paintAlignment(true); - statusBar.setText(MessageManager - .getString("label.successfully_added_features_alignment")); - } - return featuresFile; - } - - @Override - public void keyPressed(KeyEvent evt) - { - if (viewport.cursorMode - && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt - .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt - .getKeyCode() <= KeyEvent.VK_NUMPAD9)) - && Character.isDigit(evt.getKeyChar())) - { - alignPanel.seqPanel.numberPressed(evt.getKeyChar()); - } - - switch (evt.getKeyCode()) - { - case 27: // escape key - deselectAllSequenceMenuItem_actionPerformed(); - - alignPanel.alabels.cancelDrag(); - break; - case KeyEvent.VK_X: - if (evt.isControlDown() || evt.isMetaDown()) - { - cut_actionPerformed(); - } - break; - case KeyEvent.VK_C: - if (viewport.cursorMode && !evt.isControlDown()) - { - alignPanel.seqPanel.setCursorColumn(); - } - if (evt.isControlDown() || evt.isMetaDown()) - { - copy_actionPerformed(); - } - break; - case KeyEvent.VK_V: - if (evt.isControlDown()) - { - paste(evt.isShiftDown()); - } - break; - case KeyEvent.VK_A: - if (evt.isControlDown() || evt.isMetaDown()) - { - selectAllSequenceMenuItem_actionPerformed(); - } - break; - case KeyEvent.VK_DOWN: - if (viewport.cursorMode) - { - alignPanel.seqPanel.moveCursor(0, 1); - } - else - { - moveSelectedSequences(false); - } - break; - - case KeyEvent.VK_UP: - if (viewport.cursorMode) - { - alignPanel.seqPanel.moveCursor(0, -1); - } - else - { - moveSelectedSequences(true); - } - break; - - case KeyEvent.VK_LEFT: - if (evt.isAltDown() || !viewport.cursorMode) - { - slideSequences(false, alignPanel.seqPanel.getKeyboardNo1()); - } - else - { - alignPanel.seqPanel.moveCursor(-1, 0); - } - break; - - case KeyEvent.VK_RIGHT: - if (evt.isAltDown() || !viewport.cursorMode) - { - slideSequences(true, alignPanel.seqPanel.getKeyboardNo1()); - } - else - { - alignPanel.seqPanel.moveCursor(1, 0); - } - break; - - case KeyEvent.VK_SPACE: - if (viewport.cursorMode) - { - alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown() - || evt.isShiftDown() || evt.isAltDown()); - } - break; - - case KeyEvent.VK_DELETE: - case KeyEvent.VK_BACK_SPACE: - if (viewport.cursorMode) - { - alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown() - || evt.isShiftDown() || evt.isAltDown()); - } - else - { - cut_actionPerformed(); - alignPanel.seqPanel.seqCanvas.repaint(); - } - break; - - case KeyEvent.VK_S: - if (viewport.cursorMode) - { - alignPanel.seqPanel.setCursorRow(); - } - break; - case KeyEvent.VK_P: - if (viewport.cursorMode) - { - alignPanel.seqPanel.setCursorPosition(); - } - break; - - case KeyEvent.VK_ENTER: - case KeyEvent.VK_COMMA: - if (viewport.cursorMode) - { - alignPanel.seqPanel.setCursorRowAndColumn(); - } - break; - - case KeyEvent.VK_Q: - if (viewport.cursorMode) - { - alignPanel.seqPanel.setSelectionAreaAtCursor(true); - } - break; - case KeyEvent.VK_M: - if (viewport.cursorMode) - { - alignPanel.seqPanel.setSelectionAreaAtCursor(false); - } - break; - - case KeyEvent.VK_F2: - viewport.cursorMode = !viewport.cursorMode; - statusBar.setText(MessageManager.formatMessage( - "label.keyboard_editing_mode", new String[] - { (viewport.cursorMode ? "on" : "off") })); - if (viewport.cursorMode) - { - alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; - alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; - } - break; - - case KeyEvent.VK_F: - if (evt.isControlDown()) - { - findMenuItem_actionPerformed(); - } - break; - - case KeyEvent.VK_H: - { - boolean toggleSeqs = !evt.isControlDown(); - boolean toggleCols = !evt.isShiftDown(); - toggleHiddenRegions(toggleSeqs, toggleCols); - break; - } - - case KeyEvent.VK_PAGE_UP: - if (viewport.getWrapAlignment()) - { - alignPanel.scrollUp(true); - } - else - { - alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - - viewport.endSeq + viewport.startSeq); - } - break; - - case KeyEvent.VK_PAGE_DOWN: - if (viewport.getWrapAlignment()) - { - alignPanel.scrollUp(false); - } - else - { - alignPanel.setScrollValues(viewport.startRes, viewport.startSeq - + viewport.endSeq - viewport.startSeq); - } - break; - - case KeyEvent.VK_Z: - if (evt.isControlDown()) - { - undoMenuItem_actionPerformed(); - } - break; - - case KeyEvent.VK_Y: - if (evt.isControlDown()) - { - redoMenuItem_actionPerformed(); - } - break; - - case KeyEvent.VK_L: - if (evt.isControlDown()) - { - trimAlignment(true); - } - break; - - case KeyEvent.VK_R: - if (evt.isControlDown()) - { - trimAlignment(false); - } - break; - - case KeyEvent.VK_E: - if (evt.isControlDown()) - { - if (evt.isShiftDown()) - { - this.removeAllGapsMenuItem_actionPerformed(); - } - else - { - removeGappedColumnMenuItem_actionPerformed(); - } - } - break; - case KeyEvent.VK_I: - if (evt.isControlDown()) - { - if (evt.isAltDown()) - { - invertColSel_actionPerformed(); - } - else - { - invertSequenceMenuItem_actionPerformed(); - } - } - break; - - case KeyEvent.VK_G: - if (evt.isControlDown()) - { - if (evt.isShiftDown()) - { - this.unGroup_actionPerformed(); - } - else - { - this.createGroup_actionPerformed(); - } - } - break; - - case KeyEvent.VK_U: - if (evt.isControlDown()) - { - this.deleteGroups_actionPerformed(); - } - break; - - case KeyEvent.VK_T: - if (evt.isControlDown()) - { - newView(null); - } - break; - - } - alignPanel.paintAlignment(true); - } - - /** - * called by key handler and the hide all/show all menu items - * - * @param toggleSeqs - * @param toggleCols - */ - private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols) - { - boolean hide = false; - SequenceGroup sg = viewport.getSelectionGroup(); - if (!toggleSeqs && !toggleCols) - { - // Hide everything by the current selection - this is a hack - we do the - // invert and then hide - // first check that there will be visible columns after the invert. - if ((viewport.getColumnSelection() != null - && viewport.getColumnSelection().getSelected() != null && viewport - .getColumnSelection().getSelected().size() > 0) - || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg - .getEndRes())) - { - // now invert the sequence set, if required - empty selection implies - // that no hiding is required. - if (sg != null) - { - invertSequenceMenuItem_actionPerformed(); - sg = viewport.getSelectionGroup(); - toggleSeqs = true; - - } - viewport.expandColSelection(sg, true); - // finally invert the column selection and get the new sequence - // selection and indicate it should be hidden. - invertColSel_actionPerformed(); - toggleCols = true; - } - } - - if (toggleSeqs) - { - if (sg != null && sg.getSize() != viewport.getAlignment().getHeight()) - { - hide = true; - viewport.hideAllSelectedSeqs(); - } - else if (!(toggleCols && viewport.getColumnSelection().getSelected() - .size() > 0)) - { - viewport.showAllHiddenSeqs(); - } - } - - if (toggleCols) - { - if (viewport.getColumnSelection().getSelected().size() > 0) - { - viewport.hideSelectedColumns(); - if (!toggleSeqs) - { - viewport.setSelectionGroup(sg); - } - } - else if (!hide) - { - viewport.showAllHiddenColumns(); - } - } - } - - @Override - public void keyReleased(KeyEvent evt) - { - } - - @Override - public void keyTyped(KeyEvent evt) - { - } - - @Override - public void itemStateChanged(ItemEvent evt) - { - final Object source = evt.getSource(); - if (source == displayNonconservedMenuItem) - { - displayNonconservedMenuItem_actionPerformed(); - } - else if (source == colourTextMenuItem) - { - colourTextMenuItem_actionPerformed(); - } - else if (source == wrapMenuItem) - { - wrapMenuItem_actionPerformed(); - } - else if (source == scaleAbove) - { - viewport.setScaleAboveWrapped(scaleAbove.getState()); - } - else if (source == scaleLeft) - { - viewport.setScaleLeftWrapped(scaleLeft.getState()); - } - else if (source == scaleRight) - { - viewport.setScaleRightWrapped(scaleRight.getState()); - } - else if (source == seqLimits) - { - seqLimits_itemStateChanged(); - } - else if (source == viewBoxesMenuItem) - { - viewport.setShowBoxes(viewBoxesMenuItem.getState()); - } - else if (source == viewTextMenuItem) - { - viewport.setShowText(viewTextMenuItem.getState()); - } - else if (source == renderGapsMenuItem) - { - viewport.setRenderGaps(renderGapsMenuItem.getState()); - } - else if (source == annotationPanelMenuItem) - { - viewport.setShowAnnotation(annotationPanelMenuItem.getState()); - alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState()); - } - else if (source == sequenceFeatures) - { - viewport.setShowSequenceFeatures(sequenceFeatures.getState()); - alignPanel.seqPanel.seqCanvas.repaint(); - } - else if (source == showAlignmentAnnotations) - { - setAnnotationsVisibility(); - } - else if (source == showSequenceAnnotations) - { - setAnnotationsVisibility(); - } - else if (source == sortAnnBySequence) - { - boolean newState = sortAnnBySequence.getState(); - sortAnnByLabel.setState(false); - setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL - : SequenceAnnotationOrder.NONE); - setViewportAnnotationOrder(); - } - else if (source == sortAnnByLabel) - { - boolean newState = sortAnnByLabel.getState(); - sortAnnBySequence.setState(false); - setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE - : SequenceAnnotationOrder.NONE); - setViewportAnnotationOrder(); - } - else if (source == showAutoFirst) - { - showAutoLast.setState(!showAutoFirst.getState()); - setShowAutoCalculatedAbove(showAutoFirst.getState()); - setViewportAnnotationOrder(); - } - else if (source == showAutoLast) - { - showAutoFirst.setState(!showAutoLast.getState()); - setShowAutoCalculatedAbove(showAutoFirst.getState()); - setViewportAnnotationOrder(); - } - else if (source == conservationMenuItem) - { - conservationMenuItem_actionPerformed(); - } - else if (source == abovePIDThreshold) - { - abovePIDThreshold_actionPerformed(); - } - else if (source == applyToAllGroups) - { - viewport.setColourAppliesToAllGroups(applyToAllGroups.getState()); - } - else if (source == autoCalculate) - { - viewport.autoCalculateConsensus = autoCalculate.getState(); - } - else if (source == sortByTree) - { - viewport.sortByTree = sortByTree.getState(); - } - else if (source == this.centreColumnLabelFlag) - { - centreColumnLabelFlag_stateChanged(); - } - else if (source == this.followMouseOverFlag) - { - mouseOverFlag_stateChanged(); - } - else if (source == showGroupConsensus) - { - showGroupConsensus_actionPerformed(); - } - else if (source == showGroupConservation) - { - showGroupConservation_actionPerformed(); - } - else if (source == showSequenceLogo) - { - showSequenceLogo_actionPerformed(); - } - else if (source == normSequenceLogo) - { - normSequenceLogo_actionPerformed(); - } - else if (source == showConsensusHistogram) - { - showConsensusHistogram_actionPerformed(); - } - else if (source == applyAutoAnnotationSettings) - { - applyAutoAnnotationSettings_actionPerformed(); - } - alignPanel.paintAlignment(true); - } - - /** - * Set the visibility state of sequence-related and/or alignment-related - * annotations depending on checkbox selections. Repaint after calling. - * - * @param visible - */ - private void setAnnotationsVisibility() - { - boolean showForAlignment = showAlignmentAnnotations.getState(); - boolean showForSequences = showSequenceAnnotations.getState(); - for (AlignmentAnnotation aa : alignPanel.getAlignment() - .getAlignmentAnnotation()) - { - boolean visible = (aa.sequenceRef == null ? showForAlignment - : showForSequences); - aa.visible = visible; - } - alignPanel.validateAnnotationDimensions(true); - validate(); - repaint(); - } - - private void setAnnotationSortOrder(SequenceAnnotationOrder order) - { - this.annotationSortOrder = order; - } - - /** - * Set flags on the viewport that control annotation ordering - */ - private void setViewportAnnotationOrder() - { - this.alignPanel.av.setSortAnnotationsBy(this.annotationSortOrder); - this.alignPanel.av - .setShowAutocalculatedAbove(this.showAutoCalculatedAbove); - } - - private void setShowAutoCalculatedAbove(boolean showAbove) - { - this.showAutoCalculatedAbove = showAbove; - } - - private void mouseOverFlag_stateChanged() - { - viewport.setFollowHighlight(followMouseOverFlag.getState()); - // TODO: could kick the scrollTo mechanism to reset view for current - // searchresults. - } - - private void centreColumnLabelFlag_stateChanged() - { - viewport.centreColumnLabels = centreColumnLabelFlag.getState(); - this.alignPanel.annotationPanel.repaint(); - } - - @Override - public void actionPerformed(ActionEvent evt) - { - Object source = evt.getSource(); - - if (source == inputText) - { - inputText_actionPerformed(); - } - else if (source == loadTree) - { - loadTree_actionPerformed(); - } - else if (source == loadApplication) - { - launchFullApplication(); - } - else if (source == loadAnnotations) - { - loadAnnotations(); - } - else if (source == outputAnnotations) - { - outputAnnotations(true); - } - else if (source == outputFeatures) - { - outputFeatures(true, "Jalview"); - } - else if (source == closeMenuItem) - { - closeMenuItem_actionPerformed(); - } - else if (source == copy) - { - copy_actionPerformed(); - } - else if (source == undoMenuItem) - { - undoMenuItem_actionPerformed(); - } - else if (source == redoMenuItem) - { - redoMenuItem_actionPerformed(); - } - else if (source == inputText) - { - inputText_actionPerformed(); - } - else if (source == closeMenuItem) - { - closeMenuItem_actionPerformed(); - } - else if (source == undoMenuItem) - { - undoMenuItem_actionPerformed(); - } - else if (source == redoMenuItem) - { - redoMenuItem_actionPerformed(); - } - else if (source == copy) - { - copy_actionPerformed(); - } - else if (source == pasteNew) - { - pasteNew_actionPerformed(); - } - else if (source == pasteThis) - { - pasteThis_actionPerformed(); - } - else if (source == cut) - { - cut_actionPerformed(); - } - else if (source == delete) - { - delete_actionPerformed(); - } - else if (source == grpsFromSelection) - { - makeGrpsFromSelection_actionPerformed(); - } - else if (source == deleteGroups) - { - deleteGroups_actionPerformed(); - } - else if (source == selectAllSequenceMenuItem) - { - selectAllSequenceMenuItem_actionPerformed(); - } - else if (source == deselectAllSequenceMenuItem) - { - deselectAllSequenceMenuItem_actionPerformed(); - } - else if (source == invertSequenceMenuItem) - { - invertSequenceMenuItem_actionPerformed(); - } - else if (source == invertColSel) - { - viewport.invertColumnSelection(); - alignPanel.paintAlignment(true); - } - else if (source == remove2LeftMenuItem) - { - trimAlignment(true); - } - else if (source == remove2RightMenuItem) - { - trimAlignment(false); - } - else if (source == removeGappedColumnMenuItem) - { - removeGappedColumnMenuItem_actionPerformed(); - } - else if (source == removeAllGapsMenuItem) - { - removeAllGapsMenuItem_actionPerformed(); - } - else if (source == findMenuItem) - { - findMenuItem_actionPerformed(); - } - else if (source == font) - { - new FontChooser(alignPanel); - } - else if (source == newView) - { - newView(null); - } - else if (source == showColumns) - { - viewport.showAllHiddenColumns(); - alignPanel.paintAlignment(true); - } - else if (source == showSeqs) - { - viewport.showAllHiddenSeqs(); - alignPanel.paintAlignment(true); - } - else if (source == hideColumns) - { - viewport.hideSelectedColumns(); - alignPanel.paintAlignment(true); - } - else if (source == hideSequences - && viewport.getSelectionGroup() != null) - { - viewport.hideAllSelectedSeqs(); - alignPanel.paintAlignment(true); - } - else if (source == hideAllButSelection) - { - toggleHiddenRegions(false, false); - alignPanel.paintAlignment(true); - } - else if (source == hideAllSelection) - { - SequenceGroup sg = viewport.getSelectionGroup(); - viewport.expandColSelection(sg, false); - viewport.hideAllSelectedSeqs(); - viewport.hideSelectedColumns(); - alignPanel.paintAlignment(true); - } - else if (source == showAllHidden) - { - viewport.showAllHiddenColumns(); - viewport.showAllHiddenSeqs(); - alignPanel.paintAlignment(true); - } - else if (source == showGroupConsensus) - { - showGroupConsensus_actionPerformed(); - } - else if (source == showGroupConservation) - { - showGroupConservation_actionPerformed(); - } - else if (source == showSequenceLogo) - { - showSequenceLogo_actionPerformed(); - } - else if (source == normSequenceLogo) - { - normSequenceLogo_actionPerformed(); - } - else if (source == showConsensusHistogram) - { - showConsensusHistogram_actionPerformed(); - } - else if (source == applyAutoAnnotationSettings) - { - applyAutoAnnotationSettings_actionPerformed(); - } - else if (source == featureSettings) - { - new FeatureSettings(alignPanel); - } - else if (source == alProperties) - { - StringBuffer contents = new AlignmentProperties( - viewport.getAlignment()).formatAsString(); - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); - cap.setText(contents.toString()); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.alignment_properties", new String[] - { getTitle() }), 400, 250); - } - else if (source == overviewMenuItem) - { - overviewMenuItem_actionPerformed(); - } - else if (source == noColourmenuItem) - { - changeColour(null); - } - else if (source == clustalColour) - { - abovePIDThreshold.setState(false); - changeColour(new ClustalxColourScheme(viewport.getAlignment(), null)); - } - else if (source == zappoColour) - { - changeColour(new ZappoColourScheme()); - } - else if (source == taylorColour) - { - changeColour(new TaylorColourScheme()); - } - else if (source == hydrophobicityColour) - { - changeColour(new HydrophobicColourScheme()); - } - else if (source == helixColour) - { - changeColour(new HelixColourScheme()); - } - else if (source == strandColour) - { - changeColour(new StrandColourScheme()); - } - else if (source == turnColour) - { - changeColour(new TurnColourScheme()); - } - else if (source == buriedColour) - { - changeColour(new BuriedColourScheme()); - } - else if (source == nucleotideColour) - { - changeColour(new NucleotideColourScheme()); - } - else if (source == purinePyrimidineColour) - { - changeColour(new PurinePyrimidineColourScheme()); - } - else if (source == RNAInteractionColour) - { - changeColour(new RNAInteractionColourScheme()); - } - else if (source == RNAHelixColour) - { - new RNAHelicesColourChooser(viewport, alignPanel); - } - else if (source == modifyPID) - { - modifyPID_actionPerformed(); - } - else if (source == modifyConservation) - { - modifyConservation_actionPerformed(); - } - else if (source == userDefinedColour) - { - new UserDefinedColours(alignPanel, null); - } - else if (source == PIDColour) - { - changeColour(new PIDColourScheme()); - } - else if (source == BLOSUM62Colour) - { - changeColour(new Blosum62ColourScheme()); - } - else if (source == tcoffeeColour) - { - changeColour(new TCoffeeColourScheme(alignPanel.getAlignment())); - } - else if (source == annotationColour) - { - new AnnotationColourChooser(viewport, alignPanel); - } - else if (source == annotationColumnSelection) - { - new AnnotationColumnChooser(viewport, alignPanel); - } - else if (source == sortPairwiseMenuItem) - { - sortPairwiseMenuItem_actionPerformed(); - } - else if (source == sortIDMenuItem) - { - sortIDMenuItem_actionPerformed(); - } - else if (source == sortLengthMenuItem) - { - sortLengthMenuItem_actionPerformed(); - } - else if (source == sortGroupMenuItem) - { - sortGroupMenuItem_actionPerformed(); - } - else if (source == removeRedundancyMenuItem) - { - removeRedundancyMenuItem_actionPerformed(); - } - else if (source == pairwiseAlignmentMenuItem) - { - pairwiseAlignmentMenuItem_actionPerformed(); - } - else if (source == PCAMenuItem) - { - PCAMenuItem_actionPerformed(); - } - else if (source == averageDistanceTreeMenuItem) - { - averageDistanceTreeMenuItem_actionPerformed(); - } - else if (source == neighbourTreeMenuItem) - { - neighbourTreeMenuItem_actionPerformed(); - } - else if (source == njTreeBlosumMenuItem) - { - njTreeBlosumMenuItem_actionPerformed(); - } - else if (source == avDistanceTreeBlosumMenuItem) - { - avTreeBlosumMenuItem_actionPerformed(); - } - else if (source == documentation) - { - documentation_actionPerformed(); - } - else if (source == about) - { - about_actionPerformed(); - } - - } - - public void inputText_actionPerformed() - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, - MessageManager.getString("label.input_cut_paste"), 500, 500); - } - - protected void outputText_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.alignment_output_command", new Object[] - { e.getActionCommand() }), 600, 500); - - FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer(); - cap.setText(new AppletFormatAdapter(alignPanel).formatSequences( - e.getActionCommand(), viewport.getAlignment(), - viewport.getShowJVSuffix())); - } - - public void loadAnnotations() - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); - cap.setText(MessageManager - .getString("label.paste_features_annotations_Tcoffee_here")); - cap.setAnnotationImport(); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, - MessageManager.getString("action.paste_annotations"), 400, 300); - - } - - public String outputAnnotations(boolean displayTextbox) - { - String annotation = new AnnotationFile() - .printAnnotationsForView(viewport); - - if (displayTextbox) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, - MessageManager.getString("label.annotations"), 600, 500); - cap.setText(annotation); - } - - return annotation; - } - - private Map getDisplayedFeatureCols() - { - if (alignPanel.getFeatureRenderer() != null - && viewport.getFeaturesDisplayed()!= null) - { - return alignPanel.getFeatureRenderer().getDisplayedFeatureCols(); - - } - return null; - } - - public String outputFeatures(boolean displayTextbox, String format) - { - String features; - if (format.equalsIgnoreCase("Jalview")) - { - features = new FeaturesFile().printJalviewFormat(viewport - .getAlignment().getSequencesArray(), - getDisplayedFeatureCols()); - } - else - { - features = new FeaturesFile().printGFFFormat(viewport.getAlignment() - .getSequencesArray(), getDisplayedFeatureCols()); - } - - if (displayTextbox) - { - boolean frimport = false; - if (features == null || features.equals("No Features Visible")) - { - features = "# No features visible - paste some and import them here."; - frimport = true; - } - - CutAndPasteTransfer cap = new CutAndPasteTransfer(frimport, this); - if (frimport) - { - cap.setAnnotationImport(); - } - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, - MessageManager.getString("label.features"), 600, 500); - cap.setText(features); - } - else - { - if (features == null) - { - features = ""; - } - } - - return features; - } - - void launchFullApplication() - { - StringBuffer url = new StringBuffer(jalviewServletURL); - - // allow servlet parameters to be passed in applet parameter - String firstSep = url.lastIndexOf("?") > url.lastIndexOf("/") ? "&" - : "?"; - url.append(firstSep); - - url.append("open=" - + appendProtocol(viewport.applet.getParameter("file"))); - - if (viewport.applet.getParameter("features") != null) - { - url.append("&features="); - url.append(appendProtocol(viewport.applet.getParameter("features"))); - } - - if (viewport.applet.getParameter("annotations") != null) - { - url.append("&annotations="); - url.append(appendProtocol(viewport.applet.getParameter("annotations"))); - } - - if (viewport.applet.getParameter("jnetfile") != null) - { - url.append("&annotations="); - url.append(appendProtocol(viewport.applet.getParameter("jnetfile"))); - } - - if (viewport.applet.getParameter("defaultColour") != null) - { - url.append("&colour=" - + removeWhiteSpace(viewport.applet - .getParameter("defaultColour"))); - } - - if (viewport.applet.getParameter("userDefinedColour") != null) - { - url.append("&colour=" - + removeWhiteSpace(viewport.applet - .getParameter("userDefinedColour"))); - } - if (viewport.applet.getParameter("tree") != null) - { - url.append("&tree=" - + appendProtocol(viewport.applet.getParameter("tree"))); - } - if (viewport.applet.getParameter("treeFile") != null) - { - url.append("&tree=" - + appendProtocol(viewport.applet.getParameter("treeFile"))); - } - - showURL(url.toString(), "FULL_APP"); - } - - String removeWhiteSpace(String colour) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < colour.length(); i++) - { - if (Character.isWhitespace(colour.charAt(i))) - { - sb.append("%20"); - } - else - { - sb.append(colour.charAt(i)); - } - } - - return sb.toString(); - } - - String appendProtocol(String url) - { - try - { - new URL(url); - url = URLEncoder.encode(url); - } - /* - * When we finally deprecate 1.1 compatibility, we can start to use - * URLEncoder.encode(url,"UTF-8") and then we'll need this catch: catch - * (UnsupportedEncodingException ex) { System.err.println("WARNING - - * IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "+url); - * ex.printStackTrace(); } - */ - catch (java.net.MalformedURLException ex) - { - url = viewport.applet.getCodeBase() + url; - } - return url; - } - - public void closeMenuItem_actionPerformed() - { - PaintRefresher.RemoveComponent(alignPanel); - if (alignPanel.seqPanel != null - && alignPanel.seqPanel.seqCanvas != null) - { - PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas); - } - if (alignPanel.idPanel != null && alignPanel.idPanel.idCanvas != null) - { - PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas); - } - - if (PaintRefresher.components.size() == 0 && viewport.applet == null) - { - System.exit(0); - } - else - { - } - viewport = null; - alignPanel = null; - this.dispose(); - } - - /** - * TODO: JAL-1104 - */ - void updateEditMenuBar() - { - - if (viewport.getHistoryList().size() > 0) - { - undoMenuItem.setEnabled(true); - CommandI command = viewport.getHistoryList().peek(); - undoMenuItem.setLabel(MessageManager.formatMessage( - "label.undo_command", new Object[] - { command.getDescription() })); - } - else - { - undoMenuItem.setEnabled(false); - undoMenuItem.setLabel(MessageManager.getString("action.undo")); - } - - if (viewport.getRedoList().size() > 0) - { - redoMenuItem.setEnabled(true); - - CommandI command = viewport.getRedoList().peek(); - redoMenuItem.setLabel(MessageManager.formatMessage( - "label.redo_command", new Object[] - { command.getDescription() })); - } - else - { - redoMenuItem.setEnabled(false); - redoMenuItem.setLabel(MessageManager.getString("action.redo")); - } - } - - /** - * TODO: JAL-1104 - */ - @Override - public void addHistoryItem(CommandI command) - { - if (command.getSize() > 0) - { - viewport.addToHistoryList(command); - viewport.clearRedoList(); - updateEditMenuBar(); - viewport.updateHiddenColumns(); - } - } - - /** - * TODO: JAL-1104 DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void undoMenuItem_actionPerformed() - { - if (viewport.getHistoryList().isEmpty()) - { - return; - } - - CommandI command = viewport.getHistoryList().pop(); - viewport.addToRedoList(command); - command.undoCommand(null); - - AlignmentViewport originalSource = getOriginatingSource(command); - // JBPNote Test - if (originalSource != viewport) - { - System.err - .println("Warning: Viewport object mismatch whilst undoing"); - } - originalSource.updateHiddenColumns(); // originalSource.hasHiddenColumns = - // viewport.getColumnSelection().getHiddenColumns() - // != null; - updateEditMenuBar(); - originalSource.firePropertyChange("alignment", null, originalSource - .getAlignment().getSequences()); - } - - /** - * TODO: JAL-1104 DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void redoMenuItem_actionPerformed() - { - if (viewport.getRedoList().isEmpty()) - { - return; - } - - CommandI command = viewport.getRedoList().pop(); - viewport.addToHistoryList(command); - command.doCommand(null); - - AlignmentViewport originalSource = getOriginatingSource(command); - // JBPNote Test - if (originalSource != viewport) - { - System.err - .println("Warning: Viewport object mismatch whilst re-doing"); - } - originalSource.updateHiddenColumns(); // sethasHiddenColumns(); = - // viewport.getColumnSelection().getHiddenColumns() - // != null; - - updateEditMenuBar(); - originalSource.firePropertyChange("alignment", null, originalSource - .getAlignment().getSequences()); - } - - AlignmentViewport getOriginatingSource(CommandI command) - { - AlignmentViewport originalSource = null; - // For sequence removal and addition, we need to fire - // the property change event FROM the viewport where the - // original alignment was altered - AlignmentI al = null; - if (command instanceof EditCommand) - { - EditCommand editCommand = (EditCommand) command; - al = editCommand.getAlignment(); - Vector comps = (Vector) PaintRefresher.components.get(viewport - .getSequenceSetId()); - for (int i = 0; i < comps.size(); i++) - { - if (comps.elementAt(i) instanceof AlignmentPanel) - { - if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment()) - { - originalSource = ((AlignmentPanel) comps.elementAt(i)).av; - break; - } - } - } - } - - if (originalSource == null) - { - // The original view is closed, we must validate - // the current view against the closed view first - if (al != null) - { - PaintRefresher.validateSequences(al, viewport.getAlignment()); - } - - originalSource = viewport; - } - - return originalSource; - } - - /** - * Move the currently selected sequences up or down one position in the - * alignment - * - * @param up - */ - public void moveSelectedSequences(boolean up) - { - SequenceGroup sg = viewport.getSelectionGroup(); - if (sg == null) - { - return; - } - viewport.getAlignment().moveSelectedSequencesByOne(sg, - up ? null : viewport.getHiddenRepSequences(), up); - alignPanel.paintAlignment(true); - - /* - * Also move cDNA/protein complement sequences - */ - AlignViewportI complement = viewport.getCodingComplement(); - if (complement != null) - { - SequenceGroup mappedSelection = MappingUtils.mapSequenceGroup(sg, - viewport, complement); - complement.getAlignment().moveSelectedSequencesByOne(mappedSelection, - up ? null : complement.getHiddenRepSequences(), up); - // TODO need to trigger a repaint of the complementary panel - how? - // would prefer to handle in SplitFrame but it is not overriding key - // listener chiz - } - } - - synchronized void slideSequences(boolean right, int size) - { - List sg = new Vector(); - if (viewport.cursorMode) - { - sg.add(viewport.getAlignment().getSequenceAt( - alignPanel.seqPanel.seqCanvas.cursorY)); - } - else if (viewport.getSelectionGroup() != null - && viewport.getSelectionGroup().getSize() != viewport - .getAlignment().getHeight()) - { - sg = viewport.getSelectionGroup().getSequences( - viewport.getHiddenRepSequences()); - } - - if (sg.size() < 1) - { - return; - } - - Vector invertGroup = new Vector(); - - for (int i = 0; i < viewport.getAlignment().getHeight(); i++) - { - if (!sg.contains(viewport.getAlignment().getSequenceAt(i))) - { - invertGroup.addElement(viewport.getAlignment().getSequenceAt(i)); - } - } - - SequenceI[] seqs1 = sg.toArray(new SequenceI[sg.size()]); - - SequenceI[] seqs2 = invertGroup.toArray(new SequenceI[invertGroup - .size()]); - for (int i = 0; i < invertGroup.size(); i++) - { - seqs2[i] = invertGroup.elementAt(i); - } - - SlideSequencesCommand ssc; - if (right) - { - ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, - size, viewport.getGapCharacter()); - } - else - { - ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, - size, viewport.getGapCharacter()); - } - - int groupAdjustment = 0; - if (ssc.getGapsInsertedBegin() && right) - { - if (viewport.cursorMode) - { - alignPanel.seqPanel.moveCursor(size, 0); - } - else - { - groupAdjustment = size; - } - } - else if (!ssc.getGapsInsertedBegin() && !right) - { - if (viewport.cursorMode) - { - alignPanel.seqPanel.moveCursor(-size, 0); - } - else - { - groupAdjustment = -size; - } - } - - if (groupAdjustment != 0) - { - viewport.getSelectionGroup().setStartRes( - viewport.getSelectionGroup().getStartRes() + groupAdjustment); - viewport.getSelectionGroup().setEndRes( - viewport.getSelectionGroup().getEndRes() + groupAdjustment); - } - - boolean appendHistoryItem = false; - Deque historyList = viewport.getHistoryList(); - if (historyList != null && historyList.size() > 0 - && historyList.peek() instanceof SlideSequencesCommand) - { - appendHistoryItem = ssc - .appendSlideCommand((SlideSequencesCommand) historyList - .peek()); - } - - if (!appendHistoryItem) - { - addHistoryItem(ssc); - } - - repaint(); - } - - static StringBuffer copiedSequences; - - static Vector copiedHiddenColumns; - - protected void copy_actionPerformed() - { - if (viewport.getSelectionGroup() == null) - { - return; - } - - SequenceGroup sg = viewport.getSelectionGroup(); - copiedSequences = new StringBuffer(); - Map orderedSeqs = new HashMap(); - for (int i = 0; i < sg.getSize(); i++) - { - SequenceI seq = sg.getSequenceAt(i); - int index = viewport.getAlignment().findIndex(seq); - orderedSeqs.put(index, seq); - } - - int index = 0, startRes, endRes; - char ch; - - if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null) - { - copiedHiddenColumns = new Vector(); - int hiddenOffset = viewport.getSelectionGroup().getStartRes(); - for (int[] region : viewport.getColumnSelection().getHiddenColumns()) - { - copiedHiddenColumns.addElement(new int[] - { region[0] - hiddenOffset, region[1] - hiddenOffset }); - } - } - else - { - copiedHiddenColumns = null; - } - - for (int i = 0; i < sg.getSize(); i++) - { - SequenceI seq = null; - - while (seq == null) - { - if (orderedSeqs.containsKey(index)) - { - seq = orderedSeqs.get(index); - index++; - break; - } - else - { - index++; - } - } - - // FIND START RES - // Returns residue following index if gap - startRes = seq.findPosition(sg.getStartRes()); - - // FIND END RES - // Need to find the residue preceeding index if gap - endRes = 0; - - for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++) - { - ch = seq.getCharAt(j); - if (!Comparison.isGap((ch))) - { - endRes++; - } - } - - if (endRes > 0) - { - endRes += seq.getStart() - 1; - } - - copiedSequences.append(seq.getName() - + "\t" - + startRes - + "\t" - + endRes - + "\t" - + seq.getSequenceAsString(sg.getStartRes(), - sg.getEndRes() + 1) + "\n"); - } - - } - - protected void pasteNew_actionPerformed() - { - paste(true); - } - - protected void pasteThis_actionPerformed() - { - paste(false); - } - - void paste(boolean newAlignment) - { - try - { - - if (copiedSequences == null) - { - return; - } - - StringTokenizer st = new StringTokenizer(copiedSequences.toString()); - Vector seqs = new Vector(); - while (st.hasMoreElements()) - { - String name = st.nextToken(); - int start = Integer.parseInt(st.nextToken()); - int end = Integer.parseInt(st.nextToken()); - seqs.addElement(new Sequence(name, st.nextToken(), start, end)); - } - SequenceI[] newSeqs = new SequenceI[seqs.size()]; - for (int i = 0; i < seqs.size(); i++) - { - newSeqs[i] = (SequenceI) seqs.elementAt(i); - } - - if (newAlignment) - { - String newtitle = MessageManager.getString("label.copied_sequences"); - if (getTitle().startsWith(MessageManager.getString("label.copied_sequences"))) - { - newtitle = getTitle(); - } - else - { - newtitle = newtitle.concat(MessageManager.formatMessage("label.from_msname", new String[]{getTitle()})); - } - AlignFrame af = new AlignFrame(new Alignment(newSeqs), - viewport.applet, newtitle, false); - if (copiedHiddenColumns != null) - { - for (int i = 0; i < copiedHiddenColumns.size(); i++) - { - int[] region = (int[]) copiedHiddenColumns.elementAt(i); - af.viewport.hideColumns(region[0], region[1]); - } - } - - JalviewLite.addFrame(af, newtitle, frameWidth, - frameHeight); - } - else - { - addSequences(newSeqs); - } - - } catch (Exception ex) - { - } // could be anything being pasted in here - - } - - void addSequences(SequenceI[] seqs) - { - for (int i = 0; i < seqs.length; i++) - { - viewport.getAlignment().addSequence(seqs[i]); - } - - // !newAlignment - addHistoryItem(new EditCommand( - MessageManager.getString("label.add_sequences"), Action.PASTE, - seqs, 0, viewport.getAlignment().getWidth(), - viewport.getAlignment())); - - viewport.setEndSeq(viewport.getAlignment().getHeight()); - viewport.getAlignment().getWidth(); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); - - } - - protected void cut_actionPerformed() - { - copy_actionPerformed(); - delete_actionPerformed(); - } - - protected void delete_actionPerformed() - { - - SequenceGroup sg = viewport.getSelectionGroup(); - if (sg == null) - { - return; - } - - Vector seqs = new Vector(); - SequenceI seq; - for (int i = 0; i < sg.getSize(); i++) - { - seq = sg.getSequenceAt(i); - seqs.addElement(seq); - } - - // If the cut affects all sequences, remove highlighted columns - if (sg.getSize() == viewport.getAlignment().getHeight()) - { - viewport.getColumnSelection().removeElements(sg.getStartRes(), - sg.getEndRes() + 1); - } - - SequenceI[] cut = new SequenceI[seqs.size()]; - for (int i = 0; i < seqs.size(); i++) - { - cut[i] = (SequenceI) seqs.elementAt(i); - } - - /* - * //ADD HISTORY ITEM - */ - addHistoryItem(new EditCommand( - MessageManager.getString("label.cut_sequences"), Action.CUT, - cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1, - viewport.getAlignment())); - - viewport.setSelectionGroup(null); - viewport.getAlignment().deleteGroup(sg); - - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); - - if (viewport.getAlignment().getHeight() < 1) - { - this.setVisible(false); - } - viewport.sendSelection(); - } - - /** - * group consensus toggled - * - */ - protected void showGroupConsensus_actionPerformed() - { - viewport.setShowGroupConsensus(showGroupConsensus.getState()); - alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); - - } - - /** - * group conservation toggled. - */ - protected void showGroupConservation_actionPerformed() - { - viewport.setShowGroupConservation(showGroupConservation.getState()); - alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); - } - - /* - * (non-Javadoc) - * - * @see - * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt - * .event.ActionEvent) - */ - protected void showConsensusHistogram_actionPerformed() - { - viewport.setShowConsensusHistogram(showConsensusHistogram.getState()); - alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); - } - - /* - * (non-Javadoc) - * - * @see - * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt - * .event.ActionEvent) - */ - protected void showSequenceLogo_actionPerformed() - { - viewport.setShowSequenceLogo(showSequenceLogo.getState()); - alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); - } - - protected void normSequenceLogo_actionPerformed() - { - showSequenceLogo.setState(true); - viewport.setShowSequenceLogo(true); - viewport.setNormaliseSequenceLogo(normSequenceLogo.getState()); - alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); - } - - protected void applyAutoAnnotationSettings_actionPerformed() - { - alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); - } - - protected void makeGrpsFromSelection_actionPerformed() - { - if (avc.makeGroupsFromSelection()) - { - PaintRefresher.Refresh(this, viewport.getSequenceSetId()); - alignPanel.updateAnnotation(); - alignPanel.paintAlignment(true); - } - } - - protected void createGroup_actionPerformed() - { - avc.createGroup(); - } - - protected void unGroup_actionPerformed() - { - if (avc.unGroup()) - { - alignPanel.alignmentChanged(); - } - } - - protected void deleteGroups_actionPerformed() - { - if (avc.deleteGroups()) - { - alignPanel.alignmentChanged(); - } - } - - public void selectAllSequenceMenuItem_actionPerformed() - { - SequenceGroup sg = new SequenceGroup(); - for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) - { - sg.addSequence(viewport.getAlignment().getSequenceAt(i), false); - } - sg.setEndRes(viewport.getAlignment().getWidth() - 1); - viewport.setSelectionGroup(sg); - alignPanel.paintAlignment(true); - PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); - viewport.sendSelection(); - } - - public void deselectAllSequenceMenuItem_actionPerformed() - { - if (viewport.cursorMode) - { - alignPanel.seqPanel.keyboardNo1 = null; - alignPanel.seqPanel.keyboardNo2 = null; - } - viewport.setSelectionGroup(null); - viewport.getColumnSelection().clear(); - viewport.setSelectionGroup(null); - alignPanel.idPanel.idCanvas.searchResults = null; - alignPanel.seqPanel.seqCanvas.highlightSearchResults(null); - alignPanel.paintAlignment(true); - PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); - viewport.sendSelection(); - } - - public void invertSequenceMenuItem_actionPerformed() - { - SequenceGroup sg = viewport.getSelectionGroup(); - for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) - { - sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false); - } - - PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); - viewport.sendSelection(); - } - - public void invertColSel_actionPerformed() - { - viewport.invertColumnSelection(); - alignPanel.paintAlignment(true); - PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); - viewport.sendSelection(); - } - - void trimAlignment(boolean trimLeft) - { - ColumnSelection colSel = viewport.getColumnSelection(); - int column; - - if (colSel.size() > 0) - { - if (trimLeft) - { - column = colSel.getMin(); - } - else - { - column = colSel.getMax(); - } - - SequenceI[] seqs; - if (viewport.getSelectionGroup() != null) - { - seqs = viewport.getSelectionGroup().getSequencesAsArray( - viewport.getHiddenRepSequences()); - } - else - { - seqs = viewport.getAlignment().getSequencesArray(); - } - - TrimRegionCommand trimRegion; - if (trimLeft) - { - trimRegion = new TrimRegionCommand("Remove Left", - TrimRegionCommand.TRIM_LEFT, seqs, column, - viewport.getAlignment(), viewport.getColumnSelection(), - viewport.getSelectionGroup()); - viewport.setStartRes(0); - } - else - { - trimRegion = new TrimRegionCommand("Remove Right", - TrimRegionCommand.TRIM_RIGHT, seqs, column, - viewport.getAlignment(), viewport.getColumnSelection(), - viewport.getSelectionGroup()); - } - - statusBar.setText(MessageManager.formatMessage( - "label.removed_columns", new String[] - { Integer.valueOf(trimRegion.getSize()).toString() })); - addHistoryItem(trimRegion); - - for (SequenceGroup sg : viewport.getAlignment().getGroups()) - { - if ((trimLeft && !sg.adjustForRemoveLeft(column)) - || (!trimLeft && !sg.adjustForRemoveRight(column))) - { - viewport.getAlignment().deleteGroup(sg); - } - } - - viewport.firePropertyChange("alignment", null, viewport - .getAlignment().getSequences()); - } - } - - public void removeGappedColumnMenuItem_actionPerformed() - { - int start = 0, end = viewport.getAlignment().getWidth() - 1; - - SequenceI[] seqs; - if (viewport.getSelectionGroup() != null) - { - seqs = viewport.getSelectionGroup().getSequencesAsArray( - viewport.getHiddenRepSequences()); - start = viewport.getSelectionGroup().getStartRes(); - end = viewport.getSelectionGroup().getEndRes(); - } - else - { - seqs = viewport.getAlignment().getSequencesArray(); - } - - RemoveGapColCommand removeGapCols = new RemoveGapColCommand( - "Remove Gapped Columns", seqs, start, end, - viewport.getAlignment()); - - addHistoryItem(removeGapCols); - - statusBar.setText(MessageManager.formatMessage( - "label.removed_empty_columns", new String[] - { Integer.valueOf(removeGapCols.getSize()).toString() })); - - // This is to maintain viewport position on first residue - // of first sequence - SequenceI seq = viewport.getAlignment().getSequenceAt(0); - int startRes = seq.findPosition(viewport.startRes); - // ShiftList shifts; - // viewport.getAlignment().removeGaps(shifts=new ShiftList()); - // edit.alColumnChanges=shifts.getInverse(); - // if (viewport.hasHiddenColumns) - // viewport.getColumnSelection().compensateForEdits(shifts); - viewport.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); - - } - - public void removeAllGapsMenuItem_actionPerformed() - { - int start = 0, end = viewport.getAlignment().getWidth() - 1; - - SequenceI[] seqs; - if (viewport.getSelectionGroup() != null) - { - seqs = viewport.getSelectionGroup().getSequencesAsArray( - viewport.getHiddenRepSequences()); - start = viewport.getSelectionGroup().getStartRes(); - end = viewport.getSelectionGroup().getEndRes(); - } - else - { - seqs = viewport.getAlignment().getSequencesArray(); - } - - // This is to maintain viewport position on first residue - // of first sequence - SequenceI seq = viewport.getAlignment().getSequenceAt(0); - int startRes = seq.findPosition(viewport.startRes); - - addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end, - viewport.getAlignment())); - - viewport.setStartRes(seq.findIndex(startRes) - 1); - - viewport.firePropertyChange("alignment", null, viewport.getAlignment() - .getSequences()); - - } - - public void findMenuItem_actionPerformed() - { - new Finder(alignPanel); - } - - /** - * create a new view derived from the current view - * - * @param viewtitle - * @return frame for the new view - */ - public AlignFrame newView(String viewtitle) - { - AlignmentI newal; - if (viewport.hasHiddenRows()) - { - newal = new Alignment(viewport.getAlignment().getHiddenSequences() - .getFullAlignment().getSequencesArray()); - } - else - { - newal = new Alignment(viewport.getAlignment().getSequencesArray()); - } - - if (viewport.getAlignment().getAlignmentAnnotation() != null) - { - for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++) - { - if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated) - { - newal.addAnnotation(viewport.getAlignment() - .getAlignmentAnnotation()[i]); - } - } - } - - AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false); - - newaf.viewport.setSequenceSetId(alignPanel.av.getSequenceSetId()); - PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId()); - PaintRefresher.Register(newaf.alignPanel, - newaf.alignPanel.av.getSequenceSetId()); - - PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas, - newaf.alignPanel.av.getSequenceSetId()); - PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas, - newaf.alignPanel.av.getSequenceSetId()); - - Vector comps = (Vector) PaintRefresher.components.get(viewport - .getSequenceSetId()); - int viewSize = -1; - for (int i = 0; i < comps.size(); i++) - { - if (comps.elementAt(i) instanceof AlignmentPanel) - { - viewSize++; - } - } - - String title = new String(this.getTitle()); - if (viewtitle != null) - { - title = viewtitle + " ( " + title + ")"; - } - else - { - if (title.indexOf("(View") > -1) - { - title = title.substring(0, title.indexOf("(View")); - } - title += "(View " + viewSize + ")"; - } - - newaf.setTitle(title.toString()); - - newaf.viewport.setHistoryList(viewport.getHistoryList()); - newaf.viewport.setRedoList(viewport.getRedoList()); - return newaf; - } - - /** - * - * @return list of feature groups on the view - */ - public String[] getFeatureGroups() - { - FeatureRenderer fr = null; - if (alignPanel != null - && (fr = alignPanel.getFeatureRenderer()) != null) - { - List gps = fr.getFeatureGroups(); - String[] _gps = gps.toArray(new String[gps.size()]); - return _gps; - } - return null; - } - - /** - * get sequence feature groups that are hidden or shown - * - * @param visible - * true is visible - * @return list - */ - public String[] getFeatureGroupsOfState(boolean visible) - { - FeatureRenderer fr = null; - if (alignPanel != null - && (fr = alignPanel.getFeatureRenderer()) != null) - { - List gps = fr.getGroups(visible); - String[] _gps = gps.toArray(new String[gps.size()]); - return _gps; - } - return null; - } - - /** - * Change the display state for the given feature groups - * - * @param groups - * list of group strings - * @param state - * visible or invisible - */ - public void setFeatureGroupState(String[] groups, boolean state) - { - FeatureRenderer fr = null; - this.sequenceFeatures.setState(true); - viewport.setShowSequenceFeatures(true); - if (alignPanel != null - && (fr = alignPanel.getFeatureRenderer()) != null) - { - - fr.setGroupVisibility(Arrays.asList(groups), state); - alignPanel.seqPanel.seqCanvas.repaint(); - if (alignPanel.overviewPanel != null) - { - alignPanel.overviewPanel.updateOverviewImage(); - } - } - } - - public void seqLimits_itemStateChanged() - { - viewport.setShowJVSuffix(seqLimits.getState()); - alignPanel.fontChanged(); - alignPanel.paintAlignment(true); - } - - protected void colourTextMenuItem_actionPerformed() - { - viewport.setColourText(colourTextMenuItem.getState()); - alignPanel.paintAlignment(true); - } - - protected void displayNonconservedMenuItem_actionPerformed() - { - viewport.setShowUnconserved(displayNonconservedMenuItem.getState()); - alignPanel.paintAlignment(true); - } - - protected void wrapMenuItem_actionPerformed() - { - viewport.setWrapAlignment(wrapMenuItem.getState()); - alignPanel.setWrapAlignment(wrapMenuItem.getState()); - scaleAbove.setEnabled(wrapMenuItem.getState()); - scaleLeft.setEnabled(wrapMenuItem.getState()); - scaleRight.setEnabled(wrapMenuItem.getState()); - alignPanel.paintAlignment(true); - } - - public void overviewMenuItem_actionPerformed() - { - if (alignPanel.overviewPanel != null) - { - return; - } - - JFrame frame = new JFrame(); - OverviewPanel overview = new OverviewPanel(alignPanel); - frame.add(overview); - // +50 must allow for applet frame window - JalviewLite.addFrame(frame, MessageManager.formatMessage( - "label.overview_params", new String[] - { this.getTitle() }), overview.getPreferredSize().width, - overview.getPreferredSize().height + 50); - - frame.pack(); - final AlignmentPanel ap = alignPanel; - frame.addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - if (ap != null) - { - ap.setOverviewPanel(null); - } - }; - }); - - alignPanel.setOverviewPanel(overview); - - } - - public void changeColour(ColourSchemeI cs) - { - int threshold = 0; - - if (cs != null) - { - if (viewport.getAbovePIDThreshold()) - { - viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel, - cs, "Background")); - } - - if (viewport.getConservationSelected()) - { - cs.setConservationApplied(true); - viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel, - cs, "Background")); - } - else - { - cs.setConservationApplied(false); - } - } - viewport.setGlobalColourScheme(cs); - - if (alignPanel.getOverviewPanel() != null) - { - alignPanel.getOverviewPanel().updateOverviewImage(); - } - - StructureSelectionManager.getStructureSelectionManager(viewport.applet) - .sequenceColoursChanged(alignPanel); - - alignPanel.paintAlignment(true); - } - - protected void modifyPID_actionPerformed() - { - if (viewport.getAbovePIDThreshold() - && viewport.getGlobalColourScheme() != null) - { - SliderPanel.setPIDSliderSource(alignPanel, - viewport.getGlobalColourScheme(), "Background"); - SliderPanel.showPIDSlider(); - } - } - - protected void modifyConservation_actionPerformed() - { - if (viewport.getConservationSelected() - && viewport.getGlobalColourScheme() != null) - { - SliderPanel.setConservationSlider(alignPanel, - viewport.getGlobalColourScheme(), "Background"); - SliderPanel.showConservationSlider(); - } - } - - protected void conservationMenuItem_actionPerformed() - { - viewport.setConservationSelected(conservationMenuItem.getState()); - - viewport.setAbovePIDThreshold(false); - abovePIDThreshold.setState(false); - - changeColour(viewport.getGlobalColourScheme()); - - modifyConservation_actionPerformed(); - } - - public void abovePIDThreshold_actionPerformed() - { - viewport.setAbovePIDThreshold(abovePIDThreshold.getState()); - - conservationMenuItem.setState(false); - viewport.setConservationSelected(false); - - changeColour(viewport.getGlobalColourScheme()); - - modifyPID_actionPerformed(); - } - - public void sortPairwiseMenuItem_actionPerformed() - { - SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByPID(viewport.getAlignment(), viewport - .getAlignment().getSequenceAt(0), null); - - addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, - viewport.getAlignment())); - alignPanel.paintAlignment(true); - } - - public void sortIDMenuItem_actionPerformed() - { - SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByID(viewport.getAlignment()); - addHistoryItem(new OrderCommand("ID Sort", oldOrder, - viewport.getAlignment())); - alignPanel.paintAlignment(true); - } - - public void sortLengthMenuItem_actionPerformed() - { - SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByLength(viewport.getAlignment()); - addHistoryItem(new OrderCommand("Length Sort", oldOrder, - viewport.getAlignment())); - alignPanel.paintAlignment(true); - } - - public void sortGroupMenuItem_actionPerformed() - { - SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByGroup(viewport.getAlignment()); - addHistoryItem(new OrderCommand("Group Sort", oldOrder, - viewport.getAlignment())); - alignPanel.paintAlignment(true); - - } - - public void removeRedundancyMenuItem_actionPerformed() - { - new RedundancyPanel(alignPanel); - } - - public void pairwiseAlignmentMenuItem_actionPerformed() - { - if (viewport.getSelectionGroup() != null - && viewport.getSelectionGroup().getSize() > 1) - { - JFrame frame = new JFrame(); - frame.add(new PairwiseAlignPanel(alignPanel)); - JalviewLite.addFrame(frame, - MessageManager.getString("action.pairwise_alignment"), 600, - 500); - } - } - - public void PCAMenuItem_actionPerformed() - { - // are the sequences aligned? - if (!viewport.getAlignment().isAligned(false)) - { - SequenceI current; - int Width = viewport.getAlignment().getWidth(); - - for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) - { - current = viewport.getAlignment().getSequenceAt(i); - - if (current.getLength() < Width) - { - current.insertCharAt(Width - 1, viewport.getGapCharacter()); - } - } - alignPanel.paintAlignment(true); - } - - if ((viewport.getSelectionGroup() != null - && viewport.getSelectionGroup().getSize() < 4 && viewport - .getSelectionGroup().getSize() > 0) - || viewport.getAlignment().getHeight() < 4) - { - return; - } - - try - { - new PCAPanel(viewport); - } catch (java.lang.OutOfMemoryError ex) - { - } - - } - - public void averageDistanceTreeMenuItem_actionPerformed() - { - NewTreePanel("AV", "PID", "Average distance tree using PID"); - } - - public void neighbourTreeMenuItem_actionPerformed() - { - NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); - } - - protected void njTreeBlosumMenuItem_actionPerformed() - { - NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); - } - - protected void avTreeBlosumMenuItem_actionPerformed() - { - NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62"); - } - - void NewTreePanel(String type, String pwType, String title) - { - // are the sequences aligned? - if (!viewport.getAlignment().isAligned(false)) - { - SequenceI current; - int Width = viewport.getAlignment().getWidth(); - - for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) - { - current = viewport.getAlignment().getSequenceAt(i); - - if (current.getLength() < Width) - { - current.insertCharAt(Width - 1, viewport.getGapCharacter()); - } - } - alignPanel.paintAlignment(true); - - } - - if ((viewport.getSelectionGroup() != null && viewport - .getSelectionGroup().getSize() > 1) - || (viewport.getAlignment().getHeight() > 1)) - { - final TreePanel tp = new TreePanel(alignPanel, type, pwType); - - addTreeMenuItem(tp, title); - - JalviewLite.addFrame(tp, title, 600, 500); - } - } - - void loadTree_actionPerformed() - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); - cap.setText(MessageManager.getString("label.paste_newick_tree_file")); - cap.setTreeImport(); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, - MessageManager.getString("label.paste_newick_file"), 400, 300); - } - - public void loadTree(NewickFile tree, String treeFile) - { - TreePanel tp = new TreePanel(alignPanel, treeFile, - MessageManager.getString("label.load_tree_from_file"), tree); - JalviewLite.addFrame(tp, treeFile, 600, 500); - addTreeMenuItem(tp, treeFile); - } - - /** - * sort the alignment using the given treePanel - * - * @param treePanel - * tree used to sort view - * @param title - * string used for undo event name - */ - public void sortByTree(TreePanel treePanel, String title) - { - SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter - .sortByTree(viewport.getAlignment(), treePanel.getTree()); - // addHistoryItem(new HistoryItem("Sort", viewport.alignment, - // HistoryItem.SORT)); - addHistoryItem(new OrderCommand(MessageManager.formatMessage( - "label.order_by_params", new String[] - { title }), oldOrder, viewport.getAlignment())); - alignPanel.paintAlignment(true); - } - - /** - * Do any automatic reordering of the alignment and add the necessary bits to - * the menu structure for the new tree - * - * @param treePanel - * @param title - */ - protected void addTreeMenuItem(final TreePanel treePanel, - final String title) - { - final JMenuItem item = new JMenuItem(title); - sortByTreeMenu.add(item); - item.addActionListener(new java.awt.event.ActionListener() - { - @Override - public void actionPerformed(ActionEvent evt) - { - sortByTree(treePanel, title); // treePanel.getTitle()); - } - }); - - treePanel.addWindowListener(new WindowAdapter() - { - @Override - public void windowOpened(WindowEvent e) - { - if (viewport.sortByTree) - { - sortByTree(treePanel, title); - } - super.windowOpened(e); - } - - @Override - public void windowClosing(WindowEvent e) - { - sortByTreeMenu.remove(item); - }; - }); - } - - public boolean sortBy(AlignmentOrder alorder, String undoname) - { - SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - if (JalviewLite.debug) - { - System.err.println("Sorting " + alorder.getOrder().size() - + " in alignment '" + getTitle() + "'"); - } - AlignmentSorter.sortBy(viewport.getAlignment(), alorder); - if (undoname != null) - { - addHistoryItem(new OrderCommand(undoname, oldOrder, - viewport.getAlignment())); - } - alignPanel.paintAlignment(true); - return true; - } - - protected void documentation_actionPerformed() - { - alignPanel.av.applet.openJalviewHelpUrl(); - } - - protected void about_actionPerformed() - { - - class AboutPanel extends JPanel - { - String version; - - String builddate; - - public AboutPanel(String version, String builddate) - { - this.version = version; - this.builddate = builddate; - } - - @Override - public void paint(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getSize().width, getSize().height); - g.setFont(new Font("Helvetica", Font.PLAIN, 12)); - FontMetrics fm = g.getFontMetrics(); - int fh = fm.getHeight(); - int y = 5, x = 7; - g.setColor(Color.black); - // TODO: update this text for each release or centrally store it for - // lite and application - g.setFont(new Font("Helvetica", Font.BOLD, 14)); - g.drawString(MessageManager.formatMessage( - "label.jalviewLite_release", new String[] - { version }), x, y += fh); - g.setFont(new Font("Helvetica", Font.BOLD, 12)); - g.drawString(MessageManager.formatMessage( - "label.jaview_build_date", new String[] - { builddate }), x, y += fh); - g.setFont(new Font("Helvetica", Font.PLAIN, 12)); - g.drawString(MessageManager.getString("label.jalview_authors_1"), - x, y += fh * 1.5); - g.drawString(MessageManager.getString("label.jalview_authors_2"), - x + 50, y += fh + 8); - g.drawString( - MessageManager.getString("label.jalview_dev_managers"), x, - y += fh); - g.drawString(MessageManager - .getString("label.jalview_distribution_lists"), x, y += fh); - g.drawString(MessageManager.getString("label.jalview_please_cite"), - x, y += fh + 8); - g.drawString( - MessageManager.getString("label.jalview_cite_1_authors"), - x, y += fh); - g.drawString( - MessageManager.getString("label.jalview_cite_1_title"), x, - y += fh); - g.drawString(MessageManager.getString("label.jalview_cite_1_ref"), - x, y += fh); - } - } - - JFrame frame = new JFrame(); - frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite - .getBuildDate())); - JalviewLite.addFrame(frame, - MessageManager.getString("label.jalview"), 580, 220); - - } - - public void showURL(String url, String target) - { - if (viewport.applet == null) - { - System.out.println("Not running as applet - no browser available."); - } - else - { - viewport.applet.showURL(url, target); - } - } - - // //////////////////////////////////////////////////////////////////////////////// - // JBuilder Graphics here - - JMenuBar alignFrameMenuBar = new JMenuBar(); - - JMenu fileMenu = new JMenu(MessageManager.getString("action.file")); - - JMenuItem loadApplication = new JMenuItem( - MessageManager.getString("label.view_full_application")); - - JMenuItem loadTree = new JMenuItem( - MessageManager.getString("label.load_associated_tree")); - - JMenuItem loadAnnotations = new JMenuItem( - MessageManager.getString("label.load_features_annotations")); - - JMenuItem outputFeatures = new JMenuItem( - MessageManager.getString("label.export_features").concat("...")); - - JMenuItem outputAnnotations = new JMenuItem( - MessageManager.getString("label.export_annotations").concat("...")); - - JMenuItem closeMenuItem = new JMenuItem( - MessageManager.getString("action.close")); - - JMenuItem selectAllSequenceMenuItem = new JMenuItem( - MessageManager.getString("action.select_all")); - - JMenuItem deselectAllSequenceMenuItem = new JMenuItem( - MessageManager.getString("action.deselect_all")); - - JMenuItem invertSequenceMenuItem = new JMenuItem( - MessageManager.getString("action.invert_selection")); - - JMenuItem remove2LeftMenuItem = new JMenuItem(); - - JMenuItem remove2RightMenuItem = new JMenuItem(); - - JMenuItem removeGappedColumnMenuItem = new JMenuItem(); - - JMenuItem removeAllGapsMenuItem = new JMenuItem(); - - JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem(); - - JMenuItem sortPairwiseMenuItem = new JMenuItem(); - - JMenuItem sortIDMenuItem = new JMenuItem(); - - JMenuItem sortLengthMenuItem = new JMenuItem(); - - JMenuItem sortGroupMenuItem = new JMenuItem(); - - JMenuItem removeRedundancyMenuItem = new JMenuItem(); - - JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(); - - JMenuItem PCAMenuItem = new JMenuItem(); - - JMenuItem averageDistanceTreeMenuItem = new JMenuItem(); - - JMenuItem neighbourTreeMenuItem = new JMenuItem(); - - BorderLayout borderLayout1 = new BorderLayout(); - - public JLabel statusBar = new JLabel(); - - JMenuItem clustalColour = new JMenuItem(); - - JMenuItem zappoColour = new JMenuItem(); - - JMenuItem taylorColour = new JMenuItem(); - - JMenuItem hydrophobicityColour = new JMenuItem(); - - JMenuItem helixColour = new JMenuItem(); - - JMenuItem strandColour = new JMenuItem(); - - JMenuItem turnColour = new JMenuItem(); - - JMenuItem buriedColour = new JMenuItem(); - - JMenuItem purinePyrimidineColour = new JMenuItem(); - - JMenuItem RNAInteractionColour = new JMenuItem(); - - JMenuItem RNAHelixColour = new JMenuItem(); - - JMenuItem userDefinedColour = new JMenuItem(); - - JMenuItem PIDColour = new JMenuItem(); - - JMenuItem BLOSUM62Colour = new JMenuItem(); - - JMenuItem tcoffeeColour = new JMenuItem(); - - JMenuItem njTreeBlosumMenuItem = new JMenuItem(); - - JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(); - - JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem displayNonconservedMenuItem = new JCheckBoxMenuItem(); - - JMenuItem alProperties = new JMenuItem( - MessageManager.getString("label.alignment_props")); - - JMenuItem overviewMenuItem = new JMenuItem(); - - JMenuItem undoMenuItem = new JMenuItem(); - - JMenuItem redoMenuItem = new JMenuItem(); - - JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - - JMenuItem noColourmenuItem = new JMenuItem(); - - JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); - - JMenuItem findMenuItem = new JMenuItem(); - - JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); - - JMenuItem nucleotideColour = new JMenuItem(); - - JMenuItem deleteGroups = new JMenuItem(); - - JMenuItem grpsFromSelection = new JMenuItem(); - - JMenuItem createGroup = new JMenuItem(); - - JMenuItem unGroup = new JMenuItem(); - - JMenuItem delete = new JMenuItem(); - - JMenuItem copy = new JMenuItem(); - - JMenuItem cut = new JMenuItem(); - - JMenu pasteMenu = new JMenu(); - - JMenuItem pasteNew = new JMenuItem(); - - JMenuItem pasteThis = new JMenuItem(); - - JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); - - JMenuItem font = new JMenuItem(); - - JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem(); - - JMenuItem modifyPID = new JMenuItem(); - - JMenuItem modifyConservation = new JMenuItem(); - - JCheckBoxMenuItem autoCalculate = null; - - JCheckBoxMenuItem sortByTree = new JCheckBoxMenuItem( - "Sort Alignment With New Tree", true); - - JMenu sortByTreeMenu = new JMenu(); - - JMenuItem inputText = new JMenuItem(); - - JMenuItem documentation = new JMenuItem(); - - JMenuItem about = new JMenuItem(); - - JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem centreColumnLabelFlag = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem followMouseOverFlag = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem(); - - JCheckBoxMenuItem normSequenceLogo = new JCheckBoxMenuItem(); - - /** - * Initialise menus and other items - * - * @throws Exception - */ - private void jbInit() throws Exception - { - setJMenuBar(alignFrameMenuBar); - - /* - * Configure File menu items and actions - */ - inputText - .setLabel(MessageManager.getString("label.input_from_textbox")); - inputText.addActionListener(this); - JMenu outputTextboxMenu = new JMenu( - MessageManager.getString("label.out_to_textbox")); - for (int i = 0; i < AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) - { - - JMenuItem item = new JMenuItem(AppletFormatAdapter.WRITEABLE_FORMATS[i]); - - item.addActionListener(new java.awt.event.ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - outputText_actionPerformed(e); - } - }); - - outputTextboxMenu.add(item); - } - closeMenuItem.addActionListener(this); - loadApplication.addActionListener(this); - loadTree.addActionListener(this); - loadAnnotations.addActionListener(this); - outputFeatures.addActionListener(this); - outputAnnotations.addActionListener(this); - - /* - * Configure Edit menu items and actions - */ - undoMenuItem.setEnabled(false); - undoMenuItem.setLabel(MessageManager.getString("action.undo")); - undoMenuItem.addActionListener(this); - redoMenuItem.setEnabled(false); - redoMenuItem.setLabel(MessageManager.getString("action.redo")); - redoMenuItem.addActionListener(this); - copy.setLabel(MessageManager.getString("action.copy")); - copy.addActionListener(this); - cut.setLabel(MessageManager.getString("action.cut")); - cut.addActionListener(this); - delete.setLabel(MessageManager.getString("action.delete")); - delete.addActionListener(this); - pasteMenu.setLabel(MessageManager.getString("action.paste")); - pasteNew.setLabel(MessageManager.getString("label.to_new_alignment")); - pasteNew.addActionListener(this); - pasteThis.setLabel(MessageManager.getString("label.to_this_alignment")); - pasteThis.addActionListener(this); - remove2LeftMenuItem.setLabel(MessageManager - .getString("action.remove_left")); - remove2LeftMenuItem.addActionListener(this); - remove2RightMenuItem.setLabel(MessageManager - .getString("action.remove_right")); - remove2RightMenuItem.addActionListener(this); - removeGappedColumnMenuItem.setLabel(MessageManager - .getString("action.remove_empty_columns")); - removeGappedColumnMenuItem.addActionListener(this); - removeAllGapsMenuItem.setLabel(MessageManager - .getString("action.remove_all_gaps")); - removeAllGapsMenuItem.addActionListener(this); - removeRedundancyMenuItem.setLabel(MessageManager.getString( - "action.remove_redundancy").concat("...")); - removeRedundancyMenuItem.addActionListener(this); - - /* - * Configure Select menu items and actions - */ - findMenuItem.setLabel(MessageManager.getString("action.find")); - findMenuItem.addActionListener(this); - selectAllSequenceMenuItem.addActionListener(this); - deselectAllSequenceMenuItem.addActionListener(this); - invertSequenceMenuItem.setLabel(MessageManager - .getString("action.invert_sequence_selection")); - invertSequenceMenuItem.addActionListener(this); - invertColSel.setLabel(MessageManager - .getString("action.invert_column_selection")); - invertColSel.addActionListener(this); - deleteGroups.setLabel(MessageManager - .getString("action.undefine_groups")); - deleteGroups.addActionListener(this); - grpsFromSelection.setLabel(MessageManager - .getString("action.make_groups_selection")); - grpsFromSelection.addActionListener(this); - createGroup.setLabel(MessageManager.getString("action.create_group")); - unGroup.setLabel(MessageManager.getString("action.remove_group")); - annotationColumnSelection.setLabel("Select by Annotation"); - annotationColumnSelection.addActionListener(this); - - /* - * Configure View menu items and actions - */ - newView.setLabel(MessageManager.getString("action.new_view")); - newView.addActionListener(this); - JMenu showMenu = new JMenu(MessageManager.getString("action.show")); - showColumns.setLabel(MessageManager.getString("label.all_columns")); - showSeqs.setLabel(MessageManager.getString("label.all_sequences")); - JMenu hideMenu = new JMenu(MessageManager.getString("action.hide")); - hideColumns - .setLabel(MessageManager.getString("label.selected_columns")); - hideSequences.setLabel(MessageManager - .getString("label.selected_sequences")); - hideAllButSelection.setLabel(MessageManager - .getString("label.all_but_selected_region")); - hideAllSelection.setLabel(MessageManager - .getString("label.selected_region")); - showAllHidden.setLabel(MessageManager - .getString("label.all_sequences_columns")); - showColumns.addActionListener(this); - showSeqs.addActionListener(this); - hideColumns.addActionListener(this); - hideSequences.addActionListener(this); - hideAllButSelection.addActionListener(this); - hideAllSelection.addActionListener(this); - showAllHidden.addActionListener(this); - featureSettings.setLabel(MessageManager - .getString("label.feature_settings")); - featureSettings.addActionListener(this); - sequenceFeatures.setLabel(MessageManager - .getString("label.show_sequence_features")); - sequenceFeatures.addItemListener(this); - sequenceFeatures.setState(false); - followMouseOverFlag.setLabel(MessageManager - .getString("label.automatic_scrolling")); - followMouseOverFlag.addItemListener(this); - alProperties.addActionListener(this); - overviewMenuItem.setLabel(MessageManager - .getString("label.overview_window")); - overviewMenuItem.addActionListener(this); - - /* - * Configure Annotations menu items and actions - */ - annotationPanelMenuItem.setLabel(MessageManager - .getString("label.show_annotations")); - annotationPanelMenuItem.addItemListener(this); - showGroupConsensus.setLabel(MessageManager - .getString("label.group_consensus")); - showGroupConservation.setLabel(MessageManager - .getString("label.group_conservation")); - showConsensusHistogram.setLabel(MessageManager - .getString("label.show_consensus_histogram")); - showSequenceLogo.setLabel(MessageManager - .getString("label.show_consensus_logo")); - normSequenceLogo.setLabel(MessageManager - .getString("label.norm_consensus_logo")); - applyAutoAnnotationSettings.setLabel(MessageManager - .getString("label.apply_all_groups")); - applyAutoAnnotationSettings.setState(true); - JMenu autoAnnMenu = new JMenu( - MessageManager.getString("label.autocalculated_annotation")); - showGroupConsensus.addItemListener(this); - showGroupConservation.addItemListener(this); - showConsensusHistogram.addItemListener(this); - showSequenceLogo.addItemListener(this); - normSequenceLogo.addItemListener(this); - applyAutoAnnotationSettings.addItemListener(this); - showAlignmentAnnotations = new JCheckBoxMenuItem( - MessageManager.getString("label.show_all_al_annotations")); - showSequenceAnnotations = new JCheckBoxMenuItem( - MessageManager.getString("label.show_all_seq_annotations")); - sortAnnBySequence = new JCheckBoxMenuItem( - MessageManager.getString("label.sort_annotations_by_sequence")); - sortAnnByLabel = new JCheckBoxMenuItem( - MessageManager.getString("label.sort_annotations_by_label")); - showAutoFirst = new JCheckBoxMenuItem( - MessageManager.getString("label.show_first")); - showAutoLast = new JCheckBoxMenuItem( - MessageManager.getString("label.show_last")); - showAlignmentAnnotations.addItemListener(this); - showSequenceAnnotations.addItemListener(this); - sortAnnBySequence.addItemListener(this); - sortAnnByLabel.addItemListener(this); - showAutoFirst.addItemListener(this); - showAutoLast.addItemListener(this); - - /* - * Configure Format menu items and actions - */ - font.setLabel(MessageManager.getString("action.font")); - font.addActionListener(this); - scaleAbove.setLabel(MessageManager.getString("action.scale_above")); - scaleAbove.setState(true); - scaleAbove.setEnabled(false); - scaleAbove.addItemListener(this); - scaleLeft.setEnabled(false); - scaleLeft.setState(true); - scaleLeft.setLabel(MessageManager.getString("action.scale_left")); - scaleLeft.addItemListener(this); - scaleRight.setEnabled(false); - scaleRight.setState(true); - scaleRight.setLabel(MessageManager.getString("action.scale_right")); - scaleRight.addItemListener(this); - viewBoxesMenuItem.setLabel(MessageManager.getString("action.boxes")); - viewBoxesMenuItem.setState(true); - viewBoxesMenuItem.addItemListener(this); - viewTextMenuItem.setLabel(MessageManager.getString("action.text")); - viewTextMenuItem.setState(true); - viewTextMenuItem.addItemListener(this); - colourTextMenuItem.setLabel(MessageManager - .getString("label.colour_text")); - colourTextMenuItem.addItemListener(this); - displayNonconservedMenuItem.setLabel(MessageManager - .getString("label.show_non_conversed")); - displayNonconservedMenuItem.addItemListener(this); - wrapMenuItem.setLabel(MessageManager.getString("action.wrap")); - wrapMenuItem.addItemListener(this); - renderGapsMenuItem.setLabel(MessageManager - .getString("action.show_gaps")); - renderGapsMenuItem.setState(true); - renderGapsMenuItem.addItemListener(this); - centreColumnLabelFlag.setLabel(MessageManager - .getString("label.centre_column_labels")); - centreColumnLabelFlag.addItemListener(this); - seqLimits.setState(true); - seqLimits.setLabel(MessageManager - .getString("label.show_sequence_limits")); - seqLimits.addItemListener(this); - - /* - * Configure Colour menu items and actions - */ - applyToAllGroups.setLabel(MessageManager - .getString("label.apply_colour_to_all_groups")); - applyToAllGroups.setState(true); - applyToAllGroups.addItemListener(this); - clustalColour.setLabel(MessageManager.getString("label.clustalx")); - clustalColour.addActionListener(this); - zappoColour.setLabel(MessageManager.getString("label.zappo")); - zappoColour.addActionListener(this); - taylorColour.setLabel(MessageManager.getString("label.taylor")); - taylorColour.addActionListener(this); - hydrophobicityColour.setLabel(MessageManager - .getString("label.hydrophobicity")); - hydrophobicityColour.addActionListener(this); - helixColour - .setLabel(MessageManager.getString("label.helix_propensity")); - helixColour.addActionListener(this); - strandColour.setLabel(MessageManager - .getString("label.strand_propensity")); - strandColour.addActionListener(this); - turnColour.setLabel(MessageManager.getString("label.turn_propensity")); - turnColour.addActionListener(this); - buriedColour.setLabel(MessageManager.getString("label.buried_index")); - buriedColour.addActionListener(this); - purinePyrimidineColour.setLabel(MessageManager - .getString("label.purine_pyrimidine")); - purinePyrimidineColour.addActionListener(this); - RNAInteractionColour.setLabel(MessageManager - .getString("label.rna_interaction")); - RNAInteractionColour.addActionListener(this); - RNAHelixColour.setLabel(MessageManager - .getString("action.by_rna_helixes")); - RNAHelixColour.addActionListener(this); - userDefinedColour.setLabel(MessageManager - .getString("action.user_defined")); - userDefinedColour.addActionListener(this); - PIDColour.setLabel(MessageManager - .getString("label.percentage_identity")); - PIDColour.addActionListener(this); - BLOSUM62Colour.setLabel(MessageManager - .getString("label.blosum62_score")); - BLOSUM62Colour.addActionListener(this); - tcoffeeColour - .setLabel(MessageManager.getString("label.tcoffee_scores")); - // it will be enabled only if a score file is provided - tcoffeeColour.setEnabled(false); - tcoffeeColour.addActionListener(this); - conservationMenuItem.setLabel(MessageManager - .getString("action.by_conservation")); - conservationMenuItem.addItemListener(this); - noColourmenuItem.setLabel(MessageManager.getString("label.none")); - noColourmenuItem.addActionListener(this); - abovePIDThreshold.setLabel(MessageManager - .getString("label.above_identity_threshold")); - abovePIDThreshold.addItemListener(this); - nucleotideColour.setLabel(MessageManager.getString("label.nucleotide")); - nucleotideColour.addActionListener(this); - modifyPID.setLabel(MessageManager - .getString("label.modify_identity_thereshold")); - modifyPID.addActionListener(this); - modifyConservation.setLabel(MessageManager - .getString("label.modify_conservation_thereshold")); - modifyConservation.addActionListener(this); - annotationColour.setLabel(MessageManager - .getString("action.by_annotation")); - annotationColour.addActionListener(this); - - /* - * Configure Calculate menu items and actions - */ - sortPairwiseMenuItem.setLabel(MessageManager - .getString("action.by_pairwise_id")); - sortPairwiseMenuItem.addActionListener(this); - sortIDMenuItem.setLabel(MessageManager.getString("action.by_id")); - sortIDMenuItem.addActionListener(this); - sortLengthMenuItem.setLabel(MessageManager - .getString("action.by_length")); - sortLengthMenuItem.addActionListener(this); - sortGroupMenuItem.setLabel(MessageManager.getString("action.by_group")); - sortGroupMenuItem.addActionListener(this); - pairwiseAlignmentMenuItem.setLabel(MessageManager - .getString("action.pairwise_alignment")); - pairwiseAlignmentMenuItem.addActionListener(this); - PCAMenuItem.setLabel(MessageManager - .getString("label.principal_component_analysis")); - PCAMenuItem.addActionListener(this); - autoCalculate = new JCheckBoxMenuItem( - MessageManager.getString("label.autocalculate_consensus"), true); - averageDistanceTreeMenuItem.setLabel(MessageManager - .getString("label.average_distance_identity")); - averageDistanceTreeMenuItem.addActionListener(this); - neighbourTreeMenuItem.setLabel(MessageManager - .getString("label.neighbour_joining_identity")); - neighbourTreeMenuItem.addActionListener(this); - avDistanceTreeBlosumMenuItem.setLabel(MessageManager - .getString("label.average_distance_bloslum62")); - avDistanceTreeBlosumMenuItem.addActionListener(this); - njTreeBlosumMenuItem.setLabel(MessageManager - .getString("label.neighbour_blosum62")); - njTreeBlosumMenuItem.addActionListener(this); - sortByTreeMenu.setLabel(MessageManager - .getString("action.by_tree_order")); - JMenu sortMenu = new JMenu(MessageManager.getString("action.sort")); - JMenu calculateTreeMenu = new JMenu( - MessageManager.getString("action.calculate_tree")); - autoCalculate.addItemListener(this); - sortByTree.addItemListener(this); - - /* - * Configure Help menu items and actions - */ - JMenu helpMenu = new JMenu(MessageManager.getString("action.help")); - documentation.setLabel(MessageManager.getString("label.documentation")); - documentation.addActionListener(this); - about.setLabel(MessageManager.getString("label.about")); - about.addActionListener(this); - - /* - * Add top level menus to frame - */ - alignFrameMenuBar.add(fileMenu); - JMenu editMenu = new JMenu(MessageManager.getString("action.edit")); - alignFrameMenuBar.add(editMenu); - JMenu selectMenu = new JMenu(MessageManager.getString("action.select")); - alignFrameMenuBar.add(selectMenu); - JMenu viewMenu = new JMenu(MessageManager.getString("action.view")); - alignFrameMenuBar.add(viewMenu); - JMenu annotationsMenu = new JMenu( - MessageManager.getString("action.annotations")); - alignFrameMenuBar.add(annotationsMenu); - JMenu formatMenu = new JMenu(MessageManager.getString("action.format")); - alignFrameMenuBar.add(formatMenu); - JMenu colourMenu = new JMenu(MessageManager.getString("action.colour")); - alignFrameMenuBar.add(colourMenu); - JMenu calculateMenu = new JMenu( - MessageManager.getString("action.calculate")); - alignFrameMenuBar.add(calculateMenu); - alignFrameMenuBar.add(helpMenu); - - /* - * File menu - */ - fileMenu.add(inputText); - fileMenu.add(loadTree); - fileMenu.add(loadAnnotations); - fileMenu.addSeparator(); - fileMenu.add(outputTextboxMenu); - fileMenu.add(outputFeatures); - fileMenu.add(outputAnnotations); - if (jalviewServletURL != null) - { - fileMenu.add(loadApplication); - } - fileMenu.addSeparator(); - fileMenu.add(closeMenuItem); - - /* - * Edit menu - */ - editMenu.add(undoMenuItem); - editMenu.add(redoMenuItem); - editMenu.add(cut); - editMenu.add(copy); - pasteMenu.add(pasteNew); - pasteMenu.add(pasteThis); - editMenu.add(pasteMenu); - editMenu.add(delete); - editMenu.addSeparator(); - editMenu.add(remove2LeftMenuItem); - editMenu.add(remove2RightMenuItem); - editMenu.add(removeGappedColumnMenuItem); - editMenu.add(removeAllGapsMenuItem); - editMenu.add(removeRedundancyMenuItem); - - /* - * Select menu - */ - selectMenu.add(findMenuItem); - selectMenu.addSeparator(); - selectMenu.add(selectAllSequenceMenuItem); - selectMenu.add(deselectAllSequenceMenuItem); - selectMenu.add(invertSequenceMenuItem); - selectMenu.add(invertColSel); - selectMenu.add(createGroup); - selectMenu.add(unGroup); - selectMenu.add(grpsFromSelection); - selectMenu.add(deleteGroups); - selectMenu.add(annotationColumnSelection); - - /* - * View menu - */ - viewMenu.add(newView); - viewMenu.addSeparator(); - showMenu.add(showColumns); - showMenu.add(showSeqs); - showMenu.add(showAllHidden); - viewMenu.add(showMenu); - hideMenu.add(hideColumns); - hideMenu.add(hideSequences); - hideMenu.add(hideAllSelection); - hideMenu.add(hideAllButSelection); - viewMenu.add(hideMenu); - viewMenu.addSeparator(); - viewMenu.add(followMouseOverFlag); - viewMenu.addSeparator(); - viewMenu.add(sequenceFeatures); - viewMenu.add(featureSettings); - viewMenu.addSeparator(); - viewMenu.add(alProperties); - viewMenu.addSeparator(); - viewMenu.add(overviewMenuItem); - - /* - * Annotations menu - */ - annotationsMenu.add(annotationPanelMenuItem); - annotationsMenu.addSeparator(); - annotationsMenu.add(showAlignmentAnnotations); - annotationsMenu.add(showSequenceAnnotations); - annotationsMenu.add(sortAnnBySequence); - annotationsMenu.add(sortAnnByLabel); - annotationsMenu.addSeparator(); - autoAnnMenu.add(showAutoFirst); - autoAnnMenu.add(showAutoLast); - autoAnnMenu.addSeparator(); - autoAnnMenu.add(applyAutoAnnotationSettings); - autoAnnMenu.add(showConsensusHistogram); - autoAnnMenu.add(showSequenceLogo); - autoAnnMenu.add(normSequenceLogo); - autoAnnMenu.addSeparator(); - autoAnnMenu.add(showGroupConservation); - autoAnnMenu.add(showGroupConsensus); - annotationsMenu.add(autoAnnMenu); - - /* - * Format menu - */ - formatMenu.add(font); - formatMenu.add(seqLimits); - formatMenu.add(wrapMenuItem); - formatMenu.add(scaleAbove); - formatMenu.add(scaleLeft); - formatMenu.add(scaleRight); - formatMenu.add(viewBoxesMenuItem); - formatMenu.add(viewTextMenuItem); - formatMenu.add(colourTextMenuItem); - formatMenu.add(displayNonconservedMenuItem); - formatMenu.add(renderGapsMenuItem); - formatMenu.add(centreColumnLabelFlag); - - /* - * Colour menu - */ - colourMenu.add(applyToAllGroups); - colourMenu.addSeparator(); - colourMenu.add(noColourmenuItem); - colourMenu.add(clustalColour); - colourMenu.add(BLOSUM62Colour); - colourMenu.add(PIDColour); - colourMenu.add(zappoColour); - colourMenu.add(taylorColour); - colourMenu.add(hydrophobicityColour); - colourMenu.add(helixColour); - colourMenu.add(strandColour); - colourMenu.add(turnColour); - colourMenu.add(buriedColour); - colourMenu.add(nucleotideColour); - colourMenu.add(purinePyrimidineColour); - // colourMenu.add(RNAInteractionColour); - colourMenu.add(tcoffeeColour); - colourMenu.add(userDefinedColour); - colourMenu.addSeparator(); - colourMenu.add(conservationMenuItem); - colourMenu.add(modifyConservation); - colourMenu.add(abovePIDThreshold); - colourMenu.add(modifyPID); - colourMenu.add(annotationColour); - colourMenu.add(RNAHelixColour); - - /* - * Calculate menu - */ - sortMenu.add(sortIDMenuItem); - sortMenu.add(sortLengthMenuItem); - sortMenu.add(sortByTreeMenu); - sortMenu.add(sortGroupMenuItem); - sortMenu.add(sortPairwiseMenuItem); - calculateMenu.add(sortMenu); - calculateTreeMenu.add(averageDistanceTreeMenuItem); - calculateTreeMenu.add(neighbourTreeMenuItem); - calculateTreeMenu.add(avDistanceTreeBlosumMenuItem); - calculateTreeMenu.add(njTreeBlosumMenuItem); - calculateMenu.add(calculateTreeMenu); - calculateMenu.addSeparator(); - calculateMenu.add(pairwiseAlignmentMenuItem); - calculateMenu.add(PCAMenuItem); - calculateMenu.add(autoCalculate); - calculateMenu.add(sortByTree); - - /* - * Help menu - */ - helpMenu.add(documentation); - helpMenu.add(about); - - /* - * Status bar - */ - statusBar.setBackground(Color.white); - statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); - statusBar.setText(MessageManager.getString("label.status_bar")); - this.add(statusBar, BorderLayout.SOUTH); - } - - public void setStatus(String string) - { - statusBar.setText(string); - }; - - JMenuItem featureSettings = new JMenuItem(); - - JCheckBoxMenuItem sequenceFeatures = new JCheckBoxMenuItem(); - - JMenuItem annotationColour = new JMenuItem(); - - JMenuItem annotationColumnSelection = new JMenuItem(); - - JMenuItem invertColSel = new JMenuItem(); - - JMenuItem showColumns = new JMenuItem(); - - JMenuItem showSeqs = new JMenuItem(); - - JMenuItem hideColumns = new JMenuItem(); - - JMenuItem hideSequences = new JMenuItem(); - - JMenuItem hideAllButSelection = new JMenuItem(); - - JMenuItem hideAllSelection = new JMenuItem(); - - JMenuItem showAllHidden = new JMenuItem(); - - JMenuItem newView = new JMenuItem(); - - private JCheckBoxMenuItem showAlignmentAnnotations; - - private JCheckBoxMenuItem showSequenceAnnotations; - - private JCheckBoxMenuItem sortAnnBySequence; - - private JCheckBoxMenuItem sortAnnByLabel; - - private JCheckBoxMenuItem showAutoFirst; - - private JCheckBoxMenuItem showAutoLast; - - private SplitFrame splitFrame; - - /** - * Attach the alignFrame panels after embedding menus, if necessary. This used - * to be called setEmbedded, but is now creates the dropdown menus in a - * platform independent manner to avoid OSX/Mac menu appendage daftness. - * - * @param reallyEmbedded - * true to attach the view to the applet area on the page rather than - * in a new window - */ - public void createAlignFrameWindow(boolean reallyEmbedded) - { - if (reallyEmbedded) - { - embedAlignFrameInApplet(viewport.applet); - } - else - { - // ////// - // test and embed menu bar if necessary. - // - if (embedMenuIfNeeded(alignPanel)) - { - /* - * adjust for status bar height too. ? pointless as overridden by layout - * manager - */ - alignPanel.setSize(getSize().width, - getSize().height - statusBar.getHeight()); - } - add(statusBar, BorderLayout.SOUTH); - add(alignPanel, BorderLayout.CENTER); - // and register with the applet so it can pass external API calls to us - JalviewLite.addFrame(this, this.getTitle(), - frameWidth, - frameHeight); - } - } - - /** - * Add the components of this AlignFrame to the applet container. - * - * @param theApplet - */ - public void embedAlignFrameInApplet(final JalviewLite theApplet) - { - // //// - // Explicitly build the embedded menu panel for the on-page applet - // - // view cannot be closed if its actually on the page - fileMenu.remove(closeMenuItem); - fileMenu.remove(3); // Remove Separator - // construct embedded menu, using default font - embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, false, false); - // and actually add the components to the applet area - theApplet.setLayout(new BorderLayout()); - theApplet.add(embeddedMenu, BorderLayout.NORTH); - theApplet.add(statusBar, BorderLayout.SOUTH); - // TODO should size be left to the layout manager? - alignPanel.setSize(theApplet.getSize().width, - theApplet.getSize().height - embeddedMenu.getHeight() - - statusBar.getHeight()); - theApplet.add(alignPanel, BorderLayout.CENTER); - final AlignFrame me = this; - theApplet.addFocusListener(new FocusListener() - { - - @Override - public void focusLost(FocusEvent e) - { - if (theApplet.currentAlignFrame == me) - { - theApplet.currentAlignFrame = null; - } - } - - @Override - public void focusGained(FocusEvent e) - { - theApplet.currentAlignFrame = me; - } - }); - theApplet.validate(); - } - - /** - * create a new binding between structures in an existing jmol viewer instance - * and an alignpanel with sequences that have existing PDBFile entries. Note, - * this does not open a new Jmol window, or modify the display of the - * structures in the original jmol window. Note This method doesn't work - * without an additional javascript library to exchange messages between the - * distinct applets. See http://issues.jalview.org/browse/JAL-621 - * - * @param viewer - * JmolViewer instance - * @param sequenceIds - * - sequence Ids to search for associations - */ - public SequenceStructureBinding addStructureViewInstance( - Object jmolviewer, String[] sequenceIds) - { - Viewer viewer = null; - try - { - viewer = (Viewer) jmolviewer; - } catch (ClassCastException ex) - { - System.err.println("Unsupported viewer object :" - + jmolviewer.getClass()); - } - if (viewer == null) - { - System.err.println("Can't use this object as a structure viewer:" - + jmolviewer.getClass()); - return null; - } - SequenceI[] seqs = null; - if (sequenceIds == null || sequenceIds.length == 0) - { - seqs = viewport.getAlignment().getSequencesArray(); - } - else - { - Vector sqi = new Vector(); - AlignmentI al = viewport.getAlignment(); - for (int sid = 0; sid < sequenceIds.length; sid++) - { - SequenceI sq = al.findName(sequenceIds[sid]); - if (sq != null) - { - sqi.addElement(sq); - } - } - if (sqi.size() > 0) - { - seqs = new SequenceI[sqi.size()]; - for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++) - { - seqs[sid] = (SequenceI) sqi.elementAt(sid); - } - } - else - { - return null; - } - } - AAStructureBindingModel jmv = null; - // TODO: search for a jmv that involves viewer - if (jmv == null) - { // create a new viewer/jalview binding. - jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][] - { seqs }); - } - return jmv; - - } - - /** - * bind a pdb file to a sequence in the current view - * - * @param sequenceId - * - sequenceId within the dataset. - * @param pdbEntryString - * - the short name for the PDB file - * @param pdbFile - * - pdb file - either a URL or a valid PDB file. - * @return true if binding was as success TODO: consider making an exception - * structure for indicating when PDB parsing or sequenceId location - * fails. - */ - public boolean addPdbFile(String sequenceId, String pdbEntryString, - String pdbFile) - { - SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId); - boolean needtoadd = false; - if (toaddpdb != null) - { - Vector pdbe = toaddpdb.getPDBId(); - PDBEntry pdbentry = null; - if (pdbe != null && pdbe.size() > 0) - { - for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++) - { - pdbentry = (PDBEntry) pdbe.elementAt(pe); - if (!pdbentry.getId().equals(pdbEntryString) - && !pdbentry.getFile().equals(pdbFile)) - { - pdbentry = null; - } - else - { - continue; - } - } - } - if (pdbentry == null) - { - pdbentry = new PDBEntry(); - pdbentry.setId(pdbEntryString); - pdbentry.setFile(pdbFile); - needtoadd = true; // add this new entry to sequence. - } - // resolve data source - // TODO: this code should be a refactored to an io package - String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB"); - if (protocol == null) - { - return false; - } - if (needtoadd) - { - // make a note of the access mode and add - if (pdbentry.getProperty() == null) - { - pdbentry.setProperty(new Hashtable()); - } - pdbentry.getProperty().put("protocol", protocol); - toaddpdb.addPDBId(pdbentry); - alignPanel.getStructureSelectionManager() - .registerPDBEntry(pdbentry); - } - } - return true; - } - - private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains) - { - if (seqs != null) - { - Vector sequences = new Vector(); - for (int i = 0; i < seqs.length; i++) - { - if (seqs[i] != null) - { - sequences.addElement(new Object[] - { seqs[i], (chains != null) ? chains[i] : null }); - } - } - seqs = new SequenceI[sequences.size()]; - chains = new String[sequences.size()]; - for (int i = 0, isize = sequences.size(); i < isize; i++) - { - Object[] oj = (Object[]) sequences.elementAt(i); - - seqs[i] = (SequenceI) oj[0]; - chains[i] = (String) oj[1]; - } - } - return new Object[] - { seqs, chains }; - - } - - public void newStructureView(JalviewLite applet, PDBEntry pdb, - SequenceI[] seqs, String[] chains, String protocol) - { - // Scrub any null sequences from the array - Object[] sqch = cleanSeqChainArrays(seqs, chains); - seqs = (SequenceI[]) sqch[0]; - chains = (String[]) sqch[1]; - if (seqs == null || seqs.length == 0) - { - System.err - .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); - } - if (protocol == null || protocol.trim().length() == 0 - || protocol.equals("null")) - { - protocol = (String) pdb.getProperty().get("protocol"); - if (protocol == null) - { - System.err.println("Couldn't work out protocol to open structure: " - + pdb.getId()); - return; - } - } - if (applet.useXtrnalSviewer) - { - // register the association(s) and quit, don't create any windows. - if (StructureSelectionManager.getStructureSelectionManager(applet) - .setMapping(seqs, chains, pdb.getFile(), protocol) == null) - { - System.err.println("Failed to map " + pdb.getFile() + " (" - + protocol + ") to any sequences"); - } - return; - } - if (applet.isAlignPdbStructures() && applet.jmolAvailable) - { - // can only do alignments with Jmol - // find the last jmol window assigned to this alignment - AppletJmol ajm = null, tajm; - Vector jmols = applet -.getAppletWindow(AppletJmol.class); - for (int i = 0, iSize = jmols.size(); i < iSize; i++) - { - tajm = (AppletJmol) jmols.elementAt(i); - if (tajm.ap.alignFrame == this) - { - ajm = tajm; - break; - } - } - if (ajm != null) - { - System.err - .println("Incremental adding and aligning structure to existing Jmol view not yet implemented."); - // try and add the pdb structure - // ajm.addS - ajm = null; - } - } - // otherwise, create a new window -// if (applet.jmolAvailable) -// { - new AppletJmol(pdb, seqs, chains, alignPanel, protocol); - applet.lastFrameX += 40; - applet.lastFrameY += 40; -// } -// else -// { -// new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol); -// } - - } - - public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb, - SequenceI[][] seqs, String[][] chains, String[] protocols) - { - // TODO Auto-generated method stub - System.err.println("Aligned Structure View: Not yet implemented."); - } - - /** - * modify the current selection, providing the user has not made a selection - * already. - * - * @param sel - * - sequences from this alignment - * @param csel - * - columns to be selected on the alignment - */ - public void select(SequenceGroup sel, ColumnSelection csel) - { - alignPanel.seqPanel.selection(sel, csel, null); - } - - public void scrollTo(int row, int column) - { - alignPanel.seqPanel.scrollTo(row, column); - } - - public void scrollToRow(int row) - { - alignPanel.seqPanel.scrollToRow(row); - } - - public void scrollToColumn(int column) - { - alignPanel.seqPanel.scrollToColumn(column); - } - - /** - * @return the alignments unique ID. - */ - public String getSequenceSetId() - { - return viewport.getSequenceSetId(); - } - - /** - * Load the (T-Coffee) score file from the specified url - * - * @param source - * File/URL/T-COFFEE score file contents - * @throws IOException - * @return true if alignment was annotated with data from source - */ - public boolean loadScoreFile(String source) throws IOException - { - - AlignFile file = GenericFileAdapter.newTCoffeeScoreFile(source, - AppletFormatAdapter.checkProtocol(source)); - if (!file.isValid()) - { - // TODO: raise dialog for gui - System.err.println("Problems parsing T-Coffee scores: " - + file.getWarningMessage()); - System.err.println("Origin was:\n" + source); - return false; - } - - /* - * check that the score matrix matches the alignment dimensions - */ - AlignmentI aln; - if ((aln = viewport.getAlignment()) != null - && (aln.getHeight() != file.getHeight() || aln.getWidth() != file - .getWidth())) - { - // TODO: raise a dialog box here rather than bomb out. - System.err - .println("The scores matrix does not match the alignment dimensions"); - - } - - // TODO add parameter to indicate if matching should be done - if (file.annotateAlignment(alignPanel.getAlignment(), false)) - { - alignPanel.fontChanged(); - tcoffeeColour.setEnabled(true); - // switch to this color - changeColour(new TCoffeeColourScheme(alignPanel.getAlignment())); - return true; - } - else - { - System.err.println("Problems resolving T-Coffee scores:"); - if (file.getWarningMessage() != null) - { - System.err.println(file.getWarningMessage()); - } - } - return false; - } - - public SplitFrame getSplitFrame() - { - return this.splitFrame; - } - - public void setSplitFrame(SplitFrame sf) - { - this.splitFrame = sf; - } - - // may not need this - @Override - public void setShowSeqFeatures(boolean b) - { - // showSeqFeatures.setSelected(b); - viewport.setShowSequenceFeatures(b); - - } - - @Override - public void setMenusForViewport() - { - // setMenusFromViewport(viewport); - - } - @Override - public void refreshFeatureUI(boolean enableIfNecessary) - { - if (enableIfNecessary) - { - sequenceFeatures.setState(true); - alignPanel.av.setShowSequenceFeatures(true); - } - } - - @Override - public FeatureSettingsControllerI getFeatureSettingsUI() - { - return alignPanel.av.featureSettings; - } - -} +/* + * 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.appletgui; + +import jalview.analysis.AlignmentSorter; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; +import jalview.api.AlignViewControllerGuiI; +import jalview.api.AlignViewControllerI; +import jalview.api.AlignViewportI; +import jalview.api.FeatureRenderer; +import jalview.api.FeatureSettingsControllerI; +import jalview.api.SequenceStructureBinding; +import jalview.bin.JalviewLite; +import jalview.commands.CommandI; +import jalview.commands.EditCommand; +import jalview.commands.EditCommand.Action; +import jalview.commands.OrderCommand; +import jalview.commands.RemoveGapColCommand; +import jalview.commands.RemoveGapsCommand; +import jalview.commands.SlideSequencesCommand; +import jalview.commands.TrimRegionCommand; +import jalview.controller.AlignViewController; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.AlignmentOrder; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; + +import jalview.io.AlignFile; +import jalview.io.AlignmentProperties; +import jalview.io.AnnotationFile; +import jalview.io.AppletFormatAdapter; +import jalview.io.FeaturesFile; +import jalview.io.NewickFile; +import jalview.jsdev.GenericFileAdapter; +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ClustalxColourScheme; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.PurinePyrimidineColourScheme; +import jalview.schemes.RNAHelicesColourChooser; +import jalview.schemes.RNAInteractionColourScheme; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TCoffeeColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; +import jalview.structure.StructureSelectionManager; +import jalview.structures.models.AAStructureBindingModel; +import jalview.util.Comparison; +import jalview.util.MappingUtils; +import jalview.util.MessageManager; +import jalview.viewmodel.AlignmentViewport; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.Arrays; +import java.util.Deque; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.Vector; + +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; + +import org.jmol.viewer.Viewer; + +public class AlignFrame extends EmbmenuFrame implements ActionListener, + ItemListener, KeyListener, AlignViewControllerGuiI +{ + public AlignViewControllerI avc; + + public AlignmentPanel alignPanel; + + public AlignViewport viewport; + + // width and height may be overridden by applet parameters + int frameWidth = 700; + + int frameHeight = 500; + + String jalviewServletURL; + + /* + * Flag for showing autocalculated consensus above or below other consensus + * rows + */ + private boolean showAutoCalculatedAbove; + + private SequenceAnnotationOrder annotationSortOrder; + + /** + * Constructor that creates the frame and adds it to the display. + * + * @param al + * @param applet + * @param title + * @param embedded + */ + public AlignFrame(AlignmentI al, JalviewLite applet, + String title, boolean embedded) + { + this(al, applet, title, embedded, true); + } + + /** + * Constructor that optionally allows the frame to be displayed or only + * created. + * + * @param al + * @param applet + * @param title + * @param embedded + * @param addToDisplay + */ + public AlignFrame(AlignmentI al, JalviewLite applet, + String title, boolean embedded, boolean addToDisplay) + { + this(al, null, null, applet, title, embedded, addToDisplay); + } + + public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, + ColumnSelection columnSelection, JalviewLite applet, + String title, boolean embedded) + { + this(al, hiddenSeqs, columnSelection, applet, title, embedded, true); + } + + public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs, + ColumnSelection columnSelection, JalviewLite applet, + String title, boolean embedded, boolean addToDisplay) + { + if (applet != null) + { + jalviewServletURL = applet.getParameter("APPLICATION_URL"); + } + + try + { + jbInit(); + } catch (Exception ex) + { + ex.printStackTrace(); + } + // need to get window geometry before we calculate alignment layout + if (applet != null) + { + String param; + try + { + param = applet.getParameter("windowWidth"); + if (param != null) + { + int width = Integer.parseInt(param); + frameWidth = width; + } + param = applet.getParameter("windowHeight"); + if (param != null) + { + int height = Integer.parseInt(param); + frameHeight = height; + } + } catch (Exception ex) + { + } + } + viewport = new AlignViewport(al, applet); + + if (hiddenSeqs != null && hiddenSeqs.length > 0) + { + viewport.hideSequence(hiddenSeqs); + } + if (columnSelection != null) + { + viewport.setColumnSelection(columnSelection); + } + + alignPanel = new AlignmentPanel(this, viewport); + avc = new AlignViewController(this, viewport, + alignPanel); + viewport.updateConservation(alignPanel); + viewport.updateConsensus(alignPanel); + + displayNonconservedMenuItem.setState(viewport.getShowUnconserved()); + followMouseOverFlag.setState(viewport.isFollowHighlight()); + showGroupConsensus.setState(viewport.isShowGroupConsensus()); + showGroupConservation.setState(viewport.isShowGroupConservation()); + showConsensusHistogram.setState(viewport.isShowConsensusHistogram()); + showSequenceLogo.setState(viewport.isShowSequenceLogo()); + normSequenceLogo.setState(viewport.isNormaliseSequenceLogo()); + applyToAllGroups.setState(viewport.getColourAppliesToAllGroups()); + annotationPanelMenuItem.setState(viewport.isShowAnnotation()); + showAlignmentAnnotations.setState(viewport.isShowAnnotation()); + showSequenceAnnotations.setState(viewport.isShowAnnotation()); + + seqLimits.setState(viewport.getShowJVSuffix()); + + if (applet != null) + { + String param = applet.getParameter("sortBy"); + if (param != null) + { + if (param.equalsIgnoreCase("Id")) + { + sortIDMenuItem_actionPerformed(); + } + else if (param.equalsIgnoreCase("Pairwise Identity")) + { + sortPairwiseMenuItem_actionPerformed(); + } + else if (param.equalsIgnoreCase("Length")) + { + sortLengthMenuItem_actionPerformed(); + } + } + + param = applet.getParameter("wrap"); + if (param != null) + { + if (param.equalsIgnoreCase("true")) + { + wrapMenuItem.setState(true); + wrapMenuItem_actionPerformed(); + } + } + param = applet.getParameter("centrecolumnlabels"); + if (param != null) + { + centreColumnLabelFlag.setState(true); + centreColumnLabelFlag_stateChanged(); + } + + } + if (viewport.getAlignment().isNucleotide()) + { + viewport.updateStrucConsensus(alignPanel); + if (viewport.getAlignment().hasRNAStructure()) + { + RNAHelixColour.setEnabled(true); + } + else + { + RNAHelixColour.setEnabled(false); + } + } + else + { + RNAHelixColour.setEnabled(false); + purinePyrimidineColour.setEnabled(false); + } + // Some JVMS send keyevents to Top frame or lowest panel, + // Havent worked out why yet. So add to both this frame and seqCanvas for + // now + this.addKeyListener(this); + alignPanel.seqPanel.seqCanvas.addKeyListener(this); + alignPanel.idPanel.idCanvas.addKeyListener(this); + alignPanel.scalePanel.addKeyListener(this); + alignPanel.annotationPanel.addKeyListener(this); + alignPanel.annotationPanelHolder.addKeyListener(this); + alignPanel.annotationSpaceFillerHolder.addKeyListener(this); + alignPanel.alabels.addKeyListener(this); + + if (addToDisplay) + { + addToDisplay(embedded); + } + } + + /** + * @param embedded + */ + public void addToDisplay(boolean embedded) + { + createAlignFrameWindow(embedded); + validate(); + alignPanel.adjustAnnotationHeight(); + alignPanel.paintAlignment(true); + } + + public AlignViewport getAlignViewport() + { + return viewport; + } + + public SeqCanvas getSeqcanvas() + { + return alignPanel.seqPanel.seqCanvas; + } + + /** + * Load a features file onto the alignment + * + * @param file + * file URL, content, or other resolvable path + * @param type + * is protocol for accessing data referred to by file + */ + + public boolean parseFeaturesFile(String file, String type) + { + return parseFeaturesFile(file, type, true); + } + + /** + * Load a features file onto the alignment + * + * @param file + * file URL, content, or other resolvable path + * @param type + * is protocol for accessing data referred to by file + * @param autoenabledisplay + * when true, display features flag will be automatically enabled if + * features are loaded + * @return true if data parsed as a features file + */ + public boolean parseFeaturesFile(String file, String type, + boolean autoenabledisplay) + { + // TODO: test if importing a features file onto an alignment which already + // has features with links overwrites the original links. + + Hashtable featureLinks = new Hashtable(); + boolean featuresFile = false; + try + { + featuresFile = new FeaturesFile(file, type) + .parse(viewport.getAlignment(), alignPanel.seqPanel.seqCanvas + .getFeatureRenderer().getFeatureColours(), featureLinks, + true, viewport.applet.getDefaultParameter( + "relaxedidmatch", false)); + } catch (Exception ex) + { + ex.printStackTrace(); + } + + if (featuresFile) + { + if (featureLinks.size() > 0) + { + alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks; + } + if (autoenabledisplay) + { + viewport.setShowSequenceFeatures(true); + sequenceFeatures.setState(true); + } + if (alignPanel.seqPanel.seqCanvas.fr != null) + { + // update the min/max ranges where necessary + alignPanel.seqPanel.seqCanvas.fr.findAllFeatures(true); + } + if (viewport.featureSettings != null) + { + viewport.featureSettings.refreshTable(); + } + alignPanel.paintAlignment(true); + statusBar.setText(MessageManager + .getString("label.successfully_added_features_alignment")); + } + return featuresFile; + } + + @Override + public void keyPressed(KeyEvent evt) + { + if (viewport.cursorMode + && ((evt.getKeyCode() >= KeyEvent.VK_0 && evt.getKeyCode() <= KeyEvent.VK_9) || (evt + .getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt + .getKeyCode() <= KeyEvent.VK_NUMPAD9)) + && Character.isDigit(evt.getKeyChar())) + { + alignPanel.seqPanel.numberPressed(evt.getKeyChar()); + } + + switch (evt.getKeyCode()) + { + case 27: // escape key + deselectAllSequenceMenuItem_actionPerformed(); + + alignPanel.alabels.cancelDrag(); + break; + case KeyEvent.VK_X: + if (evt.isControlDown() || evt.isMetaDown()) + { + cut_actionPerformed(); + } + break; + case KeyEvent.VK_C: + if (viewport.cursorMode && !evt.isControlDown()) + { + alignPanel.seqPanel.setCursorColumn(); + } + if (evt.isControlDown() || evt.isMetaDown()) + { + copy_actionPerformed(); + } + break; + case KeyEvent.VK_V: + if (evt.isControlDown()) + { + paste(evt.isShiftDown()); + } + break; + case KeyEvent.VK_A: + if (evt.isControlDown() || evt.isMetaDown()) + { + selectAllSequenceMenuItem_actionPerformed(); + } + break; + case KeyEvent.VK_DOWN: + if (viewport.cursorMode) + { + alignPanel.seqPanel.moveCursor(0, 1); + } + else + { + moveSelectedSequences(false); + } + break; + + case KeyEvent.VK_UP: + if (viewport.cursorMode) + { + alignPanel.seqPanel.moveCursor(0, -1); + } + else + { + moveSelectedSequences(true); + } + break; + + case KeyEvent.VK_LEFT: + if (evt.isAltDown() || !viewport.cursorMode) + { + slideSequences(false, alignPanel.seqPanel.getKeyboardNo1()); + } + else + { + alignPanel.seqPanel.moveCursor(-1, 0); + } + break; + + case KeyEvent.VK_RIGHT: + if (evt.isAltDown() || !viewport.cursorMode) + { + slideSequences(true, alignPanel.seqPanel.getKeyboardNo1()); + } + else + { + alignPanel.seqPanel.moveCursor(1, 0); + } + break; + + case KeyEvent.VK_SPACE: + if (viewport.cursorMode) + { + alignPanel.seqPanel.insertGapAtCursor(evt.isControlDown() + || evt.isShiftDown() || evt.isAltDown()); + } + break; + + case KeyEvent.VK_DELETE: + case KeyEvent.VK_BACK_SPACE: + if (viewport.cursorMode) + { + alignPanel.seqPanel.deleteGapAtCursor(evt.isControlDown() + || evt.isShiftDown() || evt.isAltDown()); + } + else + { + cut_actionPerformed(); + alignPanel.seqPanel.seqCanvas.repaint(); + } + break; + + case KeyEvent.VK_S: + if (viewport.cursorMode) + { + alignPanel.seqPanel.setCursorRow(); + } + break; + case KeyEvent.VK_P: + if (viewport.cursorMode) + { + alignPanel.seqPanel.setCursorPosition(); + } + break; + + case KeyEvent.VK_ENTER: + case KeyEvent.VK_COMMA: + if (viewport.cursorMode) + { + alignPanel.seqPanel.setCursorRowAndColumn(); + } + break; + + case KeyEvent.VK_Q: + if (viewport.cursorMode) + { + alignPanel.seqPanel.setSelectionAreaAtCursor(true); + } + break; + case KeyEvent.VK_M: + if (viewport.cursorMode) + { + alignPanel.seqPanel.setSelectionAreaAtCursor(false); + } + break; + + case KeyEvent.VK_F2: + viewport.cursorMode = !viewport.cursorMode; + statusBar.setText(MessageManager.formatMessage( + "label.keyboard_editing_mode", new String[] + { (viewport.cursorMode ? "on" : "off") })); + if (viewport.cursorMode) + { + alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; + alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; + } + break; + + case KeyEvent.VK_F: + if (evt.isControlDown()) + { + findMenuItem_actionPerformed(); + } + break; + + case KeyEvent.VK_H: + { + boolean toggleSeqs = !evt.isControlDown(); + boolean toggleCols = !evt.isShiftDown(); + toggleHiddenRegions(toggleSeqs, toggleCols); + break; + } + + case KeyEvent.VK_PAGE_UP: + if (viewport.getWrapAlignment()) + { + alignPanel.scrollUp(true); + } + else + { + alignPanel.setScrollValues(viewport.startRes, viewport.startSeq + - viewport.endSeq + viewport.startSeq); + } + break; + + case KeyEvent.VK_PAGE_DOWN: + if (viewport.getWrapAlignment()) + { + alignPanel.scrollUp(false); + } + else + { + alignPanel.setScrollValues(viewport.startRes, viewport.startSeq + + viewport.endSeq - viewport.startSeq); + } + break; + + case KeyEvent.VK_Z: + if (evt.isControlDown()) + { + undoMenuItem_actionPerformed(); + } + break; + + case KeyEvent.VK_Y: + if (evt.isControlDown()) + { + redoMenuItem_actionPerformed(); + } + break; + + case KeyEvent.VK_L: + if (evt.isControlDown()) + { + trimAlignment(true); + } + break; + + case KeyEvent.VK_R: + if (evt.isControlDown()) + { + trimAlignment(false); + } + break; + + case KeyEvent.VK_E: + if (evt.isControlDown()) + { + if (evt.isShiftDown()) + { + this.removeAllGapsMenuItem_actionPerformed(); + } + else + { + removeGappedColumnMenuItem_actionPerformed(); + } + } + break; + case KeyEvent.VK_I: + if (evt.isControlDown()) + { + if (evt.isAltDown()) + { + invertColSel_actionPerformed(); + } + else + { + invertSequenceMenuItem_actionPerformed(); + } + } + break; + + case KeyEvent.VK_G: + if (evt.isControlDown()) + { + if (evt.isShiftDown()) + { + this.unGroup_actionPerformed(); + } + else + { + this.createGroup_actionPerformed(); + } + } + break; + + case KeyEvent.VK_U: + if (evt.isControlDown()) + { + this.deleteGroups_actionPerformed(); + } + break; + + case KeyEvent.VK_T: + if (evt.isControlDown()) + { + newView(null); + } + break; + + } + alignPanel.paintAlignment(true); + } + + /** + * called by key handler and the hide all/show all menu items + * + * @param toggleSeqs + * @param toggleCols + */ + private void toggleHiddenRegions(boolean toggleSeqs, boolean toggleCols) + { + boolean hide = false; + SequenceGroup sg = viewport.getSelectionGroup(); + if (!toggleSeqs && !toggleCols) + { + // Hide everything by the current selection - this is a hack - we do the + // invert and then hide + // first check that there will be visible columns after the invert. + if ((viewport.getColumnSelection() != null + && viewport.getColumnSelection().getSelected() != null && viewport + .getColumnSelection().getSelected().size() > 0) + || (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg + .getEndRes())) + { + // now invert the sequence set, if required - empty selection implies + // that no hiding is required. + if (sg != null) + { + invertSequenceMenuItem_actionPerformed(); + sg = viewport.getSelectionGroup(); + toggleSeqs = true; + + } + viewport.expandColSelection(sg, true); + // finally invert the column selection and get the new sequence + // selection and indicate it should be hidden. + invertColSel_actionPerformed(); + toggleCols = true; + } + } + + if (toggleSeqs) + { + if (sg != null && sg.getSize() != viewport.getAlignment().getHeight()) + { + hide = true; + viewport.hideAllSelectedSeqs(); + } + else if (!(toggleCols && viewport.getColumnSelection().getSelected() + .size() > 0)) + { + viewport.showAllHiddenSeqs(); + } + } + + if (toggleCols) + { + if (viewport.getColumnSelection().getSelected().size() > 0) + { + viewport.hideSelectedColumns(); + if (!toggleSeqs) + { + viewport.setSelectionGroup(sg); + } + } + else if (!hide) + { + viewport.showAllHiddenColumns(); + } + } + } + + @Override + public void keyReleased(KeyEvent evt) + { + } + + @Override + public void keyTyped(KeyEvent evt) + { + } + + @Override + public void itemStateChanged(ItemEvent evt) + { + final Object source = evt.getSource(); + if (source == displayNonconservedMenuItem) + { + displayNonconservedMenuItem_actionPerformed(); + } + else if (source == colourTextMenuItem) + { + colourTextMenuItem_actionPerformed(); + } + else if (source == wrapMenuItem) + { + wrapMenuItem_actionPerformed(); + } + else if (source == scaleAbove) + { + viewport.setScaleAboveWrapped(scaleAbove.getState()); + } + else if (source == scaleLeft) + { + viewport.setScaleLeftWrapped(scaleLeft.getState()); + } + else if (source == scaleRight) + { + viewport.setScaleRightWrapped(scaleRight.getState()); + } + else if (source == seqLimits) + { + seqLimits_itemStateChanged(); + } + else if (source == viewBoxesMenuItem) + { + viewport.setShowBoxes(viewBoxesMenuItem.getState()); + } + else if (source == viewTextMenuItem) + { + viewport.setShowText(viewTextMenuItem.getState()); + } + else if (source == renderGapsMenuItem) + { + viewport.setRenderGaps(renderGapsMenuItem.getState()); + } + else if (source == annotationPanelMenuItem) + { + viewport.setShowAnnotation(annotationPanelMenuItem.getState()); + alignPanel.setAnnotationVisible(annotationPanelMenuItem.getState()); + } + else if (source == sequenceFeatures) + { + viewport.setShowSequenceFeatures(sequenceFeatures.getState()); + alignPanel.seqPanel.seqCanvas.repaint(); + } + else if (source == showAlignmentAnnotations) + { + setAnnotationsVisibility(); + } + else if (source == showSequenceAnnotations) + { + setAnnotationsVisibility(); + } + else if (source == sortAnnBySequence) + { + boolean newState = sortAnnBySequence.getState(); + sortAnnByLabel.setState(false); + setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL + : SequenceAnnotationOrder.NONE); + setViewportAnnotationOrder(); + } + else if (source == sortAnnByLabel) + { + boolean newState = sortAnnByLabel.getState(); + sortAnnBySequence.setState(false); + setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE + : SequenceAnnotationOrder.NONE); + setViewportAnnotationOrder(); + } + else if (source == showAutoFirst) + { + showAutoLast.setState(!showAutoFirst.getState()); + setShowAutoCalculatedAbove(showAutoFirst.getState()); + setViewportAnnotationOrder(); + } + else if (source == showAutoLast) + { + showAutoFirst.setState(!showAutoLast.getState()); + setShowAutoCalculatedAbove(showAutoFirst.getState()); + setViewportAnnotationOrder(); + } + else if (source == conservationMenuItem) + { + conservationMenuItem_actionPerformed(); + } + else if (source == abovePIDThreshold) + { + abovePIDThreshold_actionPerformed(); + } + else if (source == applyToAllGroups) + { + viewport.setColourAppliesToAllGroups(applyToAllGroups.getState()); + } + else if (source == autoCalculate) + { + viewport.autoCalculateConsensus = autoCalculate.getState(); + } + else if (source == sortByTree) + { + viewport.sortByTree = sortByTree.getState(); + } + else if (source == this.centreColumnLabelFlag) + { + centreColumnLabelFlag_stateChanged(); + } + else if (source == this.followMouseOverFlag) + { + mouseOverFlag_stateChanged(); + } + else if (source == showGroupConsensus) + { + showGroupConsensus_actionPerformed(); + } + else if (source == showGroupConservation) + { + showGroupConservation_actionPerformed(); + } + else if (source == showSequenceLogo) + { + showSequenceLogo_actionPerformed(); + } + else if (source == normSequenceLogo) + { + normSequenceLogo_actionPerformed(); + } + else if (source == showConsensusHistogram) + { + showConsensusHistogram_actionPerformed(); + } + else if (source == applyAutoAnnotationSettings) + { + applyAutoAnnotationSettings_actionPerformed(); + } + alignPanel.paintAlignment(true); + } + + /** + * Set the visibility state of sequence-related and/or alignment-related + * annotations depending on checkbox selections. Repaint after calling. + * + * @param visible + */ + private void setAnnotationsVisibility() + { + boolean showForAlignment = showAlignmentAnnotations.getState(); + boolean showForSequences = showSequenceAnnotations.getState(); + for (AlignmentAnnotation aa : alignPanel.getAlignment() + .getAlignmentAnnotation()) + { + boolean visible = (aa.sequenceRef == null ? showForAlignment + : showForSequences); + aa.visible = visible; + } + alignPanel.validateAnnotationDimensions(true); + validate(); + repaint(); + } + + private void setAnnotationSortOrder(SequenceAnnotationOrder order) + { + this.annotationSortOrder = order; + } + + /** + * Set flags on the viewport that control annotation ordering + */ + private void setViewportAnnotationOrder() + { + this.alignPanel.av.setSortAnnotationsBy(this.annotationSortOrder); + this.alignPanel.av + .setShowAutocalculatedAbove(this.showAutoCalculatedAbove); + } + + private void setShowAutoCalculatedAbove(boolean showAbove) + { + this.showAutoCalculatedAbove = showAbove; + } + + private void mouseOverFlag_stateChanged() + { + viewport.setFollowHighlight(followMouseOverFlag.getState()); + // TODO: could kick the scrollTo mechanism to reset view for current + // searchresults. + } + + private void centreColumnLabelFlag_stateChanged() + { + viewport.centreColumnLabels = centreColumnLabelFlag.getState(); + this.alignPanel.annotationPanel.repaint(); + } + + @Override + public void actionPerformed(ActionEvent evt) + { + Object source = evt.getSource(); + + if (source == inputText) + { + inputText_actionPerformed(); + } + else if (source == loadTree) + { + loadTree_actionPerformed(); + } + else if (source == loadApplication) + { + launchFullApplication(); + } + else if (source == loadAnnotations) + { + loadAnnotations(); + } + else if (source == outputAnnotations) + { + outputAnnotations(true); + } + else if (source == outputFeatures) + { + outputFeatures(true, "Jalview"); + } + else if (source == closeMenuItem) + { + closeMenuItem_actionPerformed(); + } + else if (source == copy) + { + copy_actionPerformed(); + } + else if (source == undoMenuItem) + { + undoMenuItem_actionPerformed(); + } + else if (source == redoMenuItem) + { + redoMenuItem_actionPerformed(); + } + else if (source == inputText) + { + inputText_actionPerformed(); + } + else if (source == closeMenuItem) + { + closeMenuItem_actionPerformed(); + } + else if (source == undoMenuItem) + { + undoMenuItem_actionPerformed(); + } + else if (source == redoMenuItem) + { + redoMenuItem_actionPerformed(); + } + else if (source == copy) + { + copy_actionPerformed(); + } + else if (source == pasteNew) + { + pasteNew_actionPerformed(); + } + else if (source == pasteThis) + { + pasteThis_actionPerformed(); + } + else if (source == cut) + { + cut_actionPerformed(); + } + else if (source == delete) + { + delete_actionPerformed(); + } + else if (source == grpsFromSelection) + { + makeGrpsFromSelection_actionPerformed(); + } + else if (source == deleteGroups) + { + deleteGroups_actionPerformed(); + } + else if (source == selectAllSequenceMenuItem) + { + selectAllSequenceMenuItem_actionPerformed(); + } + else if (source == deselectAllSequenceMenuItem) + { + deselectAllSequenceMenuItem_actionPerformed(); + } + else if (source == invertSequenceMenuItem) + { + invertSequenceMenuItem_actionPerformed(); + } + else if (source == invertColSel) + { + viewport.invertColumnSelection(); + alignPanel.paintAlignment(true); + } + else if (source == remove2LeftMenuItem) + { + trimAlignment(true); + } + else if (source == remove2RightMenuItem) + { + trimAlignment(false); + } + else if (source == removeGappedColumnMenuItem) + { + removeGappedColumnMenuItem_actionPerformed(); + } + else if (source == removeAllGapsMenuItem) + { + removeAllGapsMenuItem_actionPerformed(); + } + else if (source == findMenuItem) + { + findMenuItem_actionPerformed(); + } + else if (source == font) + { + new FontChooser(alignPanel); + } + else if (source == newView) + { + newView(null); + } + else if (source == showColumns) + { + viewport.showAllHiddenColumns(); + alignPanel.paintAlignment(true); + } + else if (source == showSeqs) + { + viewport.showAllHiddenSeqs(); + alignPanel.paintAlignment(true); + } + else if (source == hideColumns) + { + viewport.hideSelectedColumns(); + alignPanel.paintAlignment(true); + } + else if (source == hideSequences + && viewport.getSelectionGroup() != null) + { + viewport.hideAllSelectedSeqs(); + alignPanel.paintAlignment(true); + } + else if (source == hideAllButSelection) + { + toggleHiddenRegions(false, false); + alignPanel.paintAlignment(true); + } + else if (source == hideAllSelection) + { + SequenceGroup sg = viewport.getSelectionGroup(); + viewport.expandColSelection(sg, false); + viewport.hideAllSelectedSeqs(); + viewport.hideSelectedColumns(); + alignPanel.paintAlignment(true); + } + else if (source == showAllHidden) + { + viewport.showAllHiddenColumns(); + viewport.showAllHiddenSeqs(); + alignPanel.paintAlignment(true); + } + else if (source == showGroupConsensus) + { + showGroupConsensus_actionPerformed(); + } + else if (source == showGroupConservation) + { + showGroupConservation_actionPerformed(); + } + else if (source == showSequenceLogo) + { + showSequenceLogo_actionPerformed(); + } + else if (source == normSequenceLogo) + { + normSequenceLogo_actionPerformed(); + } + else if (source == showConsensusHistogram) + { + showConsensusHistogram_actionPerformed(); + } + else if (source == applyAutoAnnotationSettings) + { + applyAutoAnnotationSettings_actionPerformed(); + } + else if (source == featureSettings) + { + new FeatureSettings(alignPanel); + } + else if (source == alProperties) + { + StringBuffer contents = new AlignmentProperties( + viewport.getAlignment()).formatAsString(); + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); + cap.setText(contents.toString()); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.alignment_properties", new String[] + { getTitle() }), 400, 250); + } + else if (source == overviewMenuItem) + { + overviewMenuItem_actionPerformed(); + } + else if (source == noColourmenuItem) + { + changeColour(null); + } + else if (source == clustalColour) + { + abovePIDThreshold.setState(false); + changeColour(new ClustalxColourScheme(viewport.getAlignment(), null)); + } + else if (source == zappoColour) + { + changeColour(new ZappoColourScheme()); + } + else if (source == taylorColour) + { + changeColour(new TaylorColourScheme()); + } + else if (source == hydrophobicityColour) + { + changeColour(new HydrophobicColourScheme()); + } + else if (source == helixColour) + { + changeColour(new HelixColourScheme()); + } + else if (source == strandColour) + { + changeColour(new StrandColourScheme()); + } + else if (source == turnColour) + { + changeColour(new TurnColourScheme()); + } + else if (source == buriedColour) + { + changeColour(new BuriedColourScheme()); + } + else if (source == nucleotideColour) + { + changeColour(new NucleotideColourScheme()); + } + else if (source == purinePyrimidineColour) + { + changeColour(new PurinePyrimidineColourScheme()); + } + else if (source == RNAInteractionColour) + { + changeColour(new RNAInteractionColourScheme()); + } + else if (source == RNAHelixColour) + { + new RNAHelicesColourChooser(viewport, alignPanel); + } + else if (source == modifyPID) + { + modifyPID_actionPerformed(); + } + else if (source == modifyConservation) + { + modifyConservation_actionPerformed(); + } + else if (source == userDefinedColour) + { + new UserDefinedColours(alignPanel, null); + } + else if (source == PIDColour) + { + changeColour(new PIDColourScheme()); + } + else if (source == BLOSUM62Colour) + { + changeColour(new Blosum62ColourScheme()); + } + else if (source == tcoffeeColour) + { + changeColour(new TCoffeeColourScheme(alignPanel.getAlignment())); + } + else if (source == annotationColour) + { + new AnnotationColourChooser(viewport, alignPanel); + } + else if (source == annotationColumnSelection) + { + new AnnotationColumnChooser(viewport, alignPanel); + } + else if (source == sortPairwiseMenuItem) + { + sortPairwiseMenuItem_actionPerformed(); + } + else if (source == sortIDMenuItem) + { + sortIDMenuItem_actionPerformed(); + } + else if (source == sortLengthMenuItem) + { + sortLengthMenuItem_actionPerformed(); + } + else if (source == sortGroupMenuItem) + { + sortGroupMenuItem_actionPerformed(); + } + else if (source == removeRedundancyMenuItem) + { + removeRedundancyMenuItem_actionPerformed(); + } + else if (source == pairwiseAlignmentMenuItem) + { + pairwiseAlignmentMenuItem_actionPerformed(); + } + else if (source == PCAMenuItem) + { + PCAMenuItem_actionPerformed(); + } + else if (source == averageDistanceTreeMenuItem) + { + averageDistanceTreeMenuItem_actionPerformed(); + } + else if (source == neighbourTreeMenuItem) + { + neighbourTreeMenuItem_actionPerformed(); + } + else if (source == njTreeBlosumMenuItem) + { + njTreeBlosumMenuItem_actionPerformed(); + } + else if (source == avDistanceTreeBlosumMenuItem) + { + avTreeBlosumMenuItem_actionPerformed(); + } + else if (source == documentation) + { + documentation_actionPerformed(); + } + else if (source == about) + { + about_actionPerformed(); + } + + } + + public void inputText_actionPerformed() + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, + MessageManager.getString("label.input_cut_paste"), 500, 500); + } + + protected void outputText_actionPerformed(ActionEvent e) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.alignment_output_command", new Object[] + { e.getActionCommand() }), 600, 500); + + FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer(); + cap.setText(new AppletFormatAdapter(alignPanel).formatSequences( + e.getActionCommand(), viewport.getAlignment(), + viewport.getShowJVSuffix())); + } + + public void loadAnnotations() + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); + cap.setText(MessageManager + .getString("label.paste_features_annotations_Tcoffee_here")); + cap.setAnnotationImport(); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, + MessageManager.getString("action.paste_annotations"), 400, 300); + + } + + public String outputAnnotations(boolean displayTextbox) + { + String annotation = new AnnotationFile() + .printAnnotationsForView(viewport); + + if (displayTextbox) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, + MessageManager.getString("label.annotations"), 600, 500); + cap.setText(annotation); + } + + return annotation; + } + + private Map getDisplayedFeatureCols() + { + if (alignPanel.getFeatureRenderer() != null + && viewport.getFeaturesDisplayed()!= null) + { + return alignPanel.getFeatureRenderer().getDisplayedFeatureCols(); + + } + return null; + } + + public String outputFeatures(boolean displayTextbox, String format) + { + String features; + if (format.equalsIgnoreCase("Jalview")) + { + features = new FeaturesFile().printJalviewFormat(viewport + .getAlignment().getSequencesArray(), + getDisplayedFeatureCols()); + } + else + { + features = new FeaturesFile().printGFFFormat(viewport.getAlignment() + .getSequencesArray(), getDisplayedFeatureCols()); + } + + if (displayTextbox) + { + boolean frimport = false; + if (features == null || features.equals("No Features Visible")) + { + features = "# No features visible - paste some and import them here."; + frimport = true; + } + + CutAndPasteTransfer cap = new CutAndPasteTransfer(frimport, this); + if (frimport) + { + cap.setAnnotationImport(); + } + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, + MessageManager.getString("label.features"), 600, 500); + cap.setText(features); + } + else + { + if (features == null) + { + features = ""; + } + } + + return features; + } + + void launchFullApplication() + { + StringBuffer url = new StringBuffer(jalviewServletURL); + + // allow servlet parameters to be passed in applet parameter + String firstSep = url.lastIndexOf("?") > url.lastIndexOf("/") ? "&" + : "?"; + url.append(firstSep); + + url.append("open=" + + appendProtocol(viewport.applet.getParameter("file"))); + + if (viewport.applet.getParameter("features") != null) + { + url.append("&features="); + url.append(appendProtocol(viewport.applet.getParameter("features"))); + } + + if (viewport.applet.getParameter("annotations") != null) + { + url.append("&annotations="); + url.append(appendProtocol(viewport.applet.getParameter("annotations"))); + } + + if (viewport.applet.getParameter("jnetfile") != null) + { + url.append("&annotations="); + url.append(appendProtocol(viewport.applet.getParameter("jnetfile"))); + } + + if (viewport.applet.getParameter("defaultColour") != null) + { + url.append("&colour=" + + removeWhiteSpace(viewport.applet + .getParameter("defaultColour"))); + } + + if (viewport.applet.getParameter("userDefinedColour") != null) + { + url.append("&colour=" + + removeWhiteSpace(viewport.applet + .getParameter("userDefinedColour"))); + } + if (viewport.applet.getParameter("tree") != null) + { + url.append("&tree=" + + appendProtocol(viewport.applet.getParameter("tree"))); + } + if (viewport.applet.getParameter("treeFile") != null) + { + url.append("&tree=" + + appendProtocol(viewport.applet.getParameter("treeFile"))); + } + + showURL(url.toString(), "FULL_APP"); + } + + String removeWhiteSpace(String colour) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < colour.length(); i++) + { + if (Character.isWhitespace(colour.charAt(i))) + { + sb.append("%20"); + } + else + { + sb.append(colour.charAt(i)); + } + } + + return sb.toString(); + } + + String appendProtocol(String url) + { + try + { + new URL(url); + url = URLEncoder.encode(url); + } + /* + * When we finally deprecate 1.1 compatibility, we can start to use + * URLEncoder.encode(url,"UTF-8") and then we'll need this catch: catch + * (UnsupportedEncodingException ex) { System.err.println("WARNING - + * IMPLEMENTATION ERROR - UNSUPPORTED ENCODING EXCEPTION FOR "+url); + * ex.printStackTrace(); } + */ + catch (java.net.MalformedURLException ex) + { + url = viewport.applet.getCodeBase() + url; + } + return url; + } + + public void closeMenuItem_actionPerformed() + { + PaintRefresher.RemoveComponent(alignPanel); + if (alignPanel.seqPanel != null + && alignPanel.seqPanel.seqCanvas != null) + { + PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas); + } + if (alignPanel.idPanel != null && alignPanel.idPanel.idCanvas != null) + { + PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas); + } + + if (PaintRefresher.components.size() == 0 && viewport.applet == null) + { + System.exit(0); + } + else + { + } + viewport = null; + alignPanel = null; + this.dispose(); + } + + /** + * TODO: JAL-1104 + */ + void updateEditMenuBar() + { + + if (viewport.getHistoryList().size() > 0) + { + undoMenuItem.setEnabled(true); + CommandI command = viewport.getHistoryList().peek(); + undoMenuItem.setLabel(MessageManager.formatMessage( + "label.undo_command", new Object[] + { command.getDescription() })); + } + else + { + undoMenuItem.setEnabled(false); + undoMenuItem.setLabel(MessageManager.getString("action.undo")); + } + + if (viewport.getRedoList().size() > 0) + { + redoMenuItem.setEnabled(true); + + CommandI command = viewport.getRedoList().peek(); + redoMenuItem.setLabel(MessageManager.formatMessage( + "label.redo_command", new Object[] + { command.getDescription() })); + } + else + { + redoMenuItem.setEnabled(false); + redoMenuItem.setLabel(MessageManager.getString("action.redo")); + } + } + + /** + * TODO: JAL-1104 + */ + @Override + public void addHistoryItem(CommandI command) + { + if (command.getSize() > 0) + { + viewport.addToHistoryList(command); + viewport.clearRedoList(); + updateEditMenuBar(); + viewport.updateHiddenColumns(); + } + } + + /** + * TODO: JAL-1104 DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + protected void undoMenuItem_actionPerformed() + { + if (viewport.getHistoryList().isEmpty()) + { + return; + } + + CommandI command = viewport.getHistoryList().pop(); + viewport.addToRedoList(command); + command.undoCommand(null); + + AlignmentViewport originalSource = getOriginatingSource(command); + // JBPNote Test + if (originalSource != viewport) + { + System.err + .println("Warning: Viewport object mismatch whilst undoing"); + } + originalSource.updateHiddenColumns(); // originalSource.hasHiddenColumns = + // viewport.getColumnSelection().getHiddenColumns() + // != null; + updateEditMenuBar(); + originalSource.firePropertyChange("alignment", null, originalSource + .getAlignment().getSequences()); + } + + /** + * TODO: JAL-1104 DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + protected void redoMenuItem_actionPerformed() + { + if (viewport.getRedoList().isEmpty()) + { + return; + } + + CommandI command = viewport.getRedoList().pop(); + viewport.addToHistoryList(command); + command.doCommand(null); + + AlignmentViewport originalSource = getOriginatingSource(command); + // JBPNote Test + if (originalSource != viewport) + { + System.err + .println("Warning: Viewport object mismatch whilst re-doing"); + } + originalSource.updateHiddenColumns(); // sethasHiddenColumns(); = + // viewport.getColumnSelection().getHiddenColumns() + // != null; + + updateEditMenuBar(); + originalSource.firePropertyChange("alignment", null, originalSource + .getAlignment().getSequences()); + } + + AlignmentViewport getOriginatingSource(CommandI command) + { + AlignmentViewport originalSource = null; + // For sequence removal and addition, we need to fire + // the property change event FROM the viewport where the + // original alignment was altered + AlignmentI al = null; + if (command instanceof EditCommand) + { + EditCommand editCommand = (EditCommand) command; + al = editCommand.getAlignment(); + Vector comps = (Vector) PaintRefresher.components.get(viewport + .getSequenceSetId()); + for (int i = 0; i < comps.size(); i++) + { + if (comps.elementAt(i) instanceof AlignmentPanel) + { + if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment()) + { + originalSource = ((AlignmentPanel) comps.elementAt(i)).av; + break; + } + } + } + } + + if (originalSource == null) + { + // The original view is closed, we must validate + // the current view against the closed view first + if (al != null) + { + PaintRefresher.validateSequences(al, viewport.getAlignment()); + } + + originalSource = viewport; + } + + return originalSource; + } + + /** + * Move the currently selected sequences up or down one position in the + * alignment + * + * @param up + */ + public void moveSelectedSequences(boolean up) + { + SequenceGroup sg = viewport.getSelectionGroup(); + if (sg == null) + { + return; + } + viewport.getAlignment().moveSelectedSequencesByOne(sg, + up ? null : viewport.getHiddenRepSequences(), up); + alignPanel.paintAlignment(true); + + /* + * Also move cDNA/protein complement sequences + */ + AlignViewportI complement = viewport.getCodingComplement(); + if (complement != null) + { + SequenceGroup mappedSelection = MappingUtils.mapSequenceGroup(sg, + viewport, complement); + complement.getAlignment().moveSelectedSequencesByOne(mappedSelection, + up ? null : complement.getHiddenRepSequences(), up); + // TODO need to trigger a repaint of the complementary panel - how? + // would prefer to handle in SplitFrame but it is not overriding key + // listener chiz + } + } + + synchronized void slideSequences(boolean right, int size) + { + List sg = new Vector(); + if (viewport.cursorMode) + { + sg.add(viewport.getAlignment().getSequenceAt( + alignPanel.seqPanel.seqCanvas.cursorY)); + } + else if (viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() != viewport + .getAlignment().getHeight()) + { + sg = viewport.getSelectionGroup().getSequences( + viewport.getHiddenRepSequences()); + } + + if (sg.size() < 1) + { + return; + } + + Vector invertGroup = new Vector(); + + for (int i = 0; i < viewport.getAlignment().getHeight(); i++) + { + if (!sg.contains(viewport.getAlignment().getSequenceAt(i))) + { + invertGroup.addElement(viewport.getAlignment().getSequenceAt(i)); + } + } + + SequenceI[] seqs1 = sg.toArray(new SequenceI[sg.size()]); + + SequenceI[] seqs2 = invertGroup.toArray(new SequenceI[invertGroup + .size()]); + for (int i = 0; i < invertGroup.size(); i++) + { + seqs2[i] = invertGroup.elementAt(i); + } + + SlideSequencesCommand ssc; + if (right) + { + ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, + size, viewport.getGapCharacter()); + } + else + { + ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, + size, viewport.getGapCharacter()); + } + + int groupAdjustment = 0; + if (ssc.getGapsInsertedBegin() && right) + { + if (viewport.cursorMode) + { + alignPanel.seqPanel.moveCursor(size, 0); + } + else + { + groupAdjustment = size; + } + } + else if (!ssc.getGapsInsertedBegin() && !right) + { + if (viewport.cursorMode) + { + alignPanel.seqPanel.moveCursor(-size, 0); + } + else + { + groupAdjustment = -size; + } + } + + if (groupAdjustment != 0) + { + viewport.getSelectionGroup().setStartRes( + viewport.getSelectionGroup().getStartRes() + groupAdjustment); + viewport.getSelectionGroup().setEndRes( + viewport.getSelectionGroup().getEndRes() + groupAdjustment); + } + + boolean appendHistoryItem = false; + Deque historyList = viewport.getHistoryList(); + if (historyList != null && historyList.size() > 0 + && historyList.peek() instanceof SlideSequencesCommand) + { + appendHistoryItem = ssc + .appendSlideCommand((SlideSequencesCommand) historyList + .peek()); + } + + if (!appendHistoryItem) + { + addHistoryItem(ssc); + } + + repaint(); + } + + static StringBuffer copiedSequences; + + static Vector copiedHiddenColumns; + + protected void copy_actionPerformed() + { + if (viewport.getSelectionGroup() == null) + { + return; + } + + SequenceGroup sg = viewport.getSelectionGroup(); + copiedSequences = new StringBuffer(); + Map orderedSeqs = new HashMap(); + for (int i = 0; i < sg.getSize(); i++) + { + SequenceI seq = sg.getSequenceAt(i); + int index = viewport.getAlignment().findIndex(seq); + orderedSeqs.put(index, seq); + } + + int index = 0, startRes, endRes; + char ch; + + if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null) + { + copiedHiddenColumns = new Vector(); + int hiddenOffset = viewport.getSelectionGroup().getStartRes(); + for (int[] region : viewport.getColumnSelection().getHiddenColumns()) + { + copiedHiddenColumns.addElement(new int[] + { region[0] - hiddenOffset, region[1] - hiddenOffset }); + } + } + else + { + copiedHiddenColumns = null; + } + + for (int i = 0; i < sg.getSize(); i++) + { + SequenceI seq = null; + + while (seq == null) + { + if (orderedSeqs.containsKey(index)) + { + seq = orderedSeqs.get(index); + index++; + break; + } + else + { + index++; + } + } + + // FIND START RES + // Returns residue following index if gap + startRes = seq.findPosition(sg.getStartRes()); + + // FIND END RES + // Need to find the residue preceeding index if gap + endRes = 0; + + for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++) + { + ch = seq.getCharAt(j); + if (!Comparison.isGap((ch))) + { + endRes++; + } + } + + if (endRes > 0) + { + endRes += seq.getStart() - 1; + } + + copiedSequences.append(seq.getName() + + "\t" + + startRes + + "\t" + + endRes + + "\t" + + seq.getSequenceAsString(sg.getStartRes(), + sg.getEndRes() + 1) + "\n"); + } + + } + + protected void pasteNew_actionPerformed() + { + paste(true); + } + + protected void pasteThis_actionPerformed() + { + paste(false); + } + + void paste(boolean newAlignment) + { + try + { + + if (copiedSequences == null) + { + return; + } + + StringTokenizer st = new StringTokenizer(copiedSequences.toString()); + Vector seqs = new Vector(); + while (st.hasMoreElements()) + { + String name = st.nextToken(); + int start = Integer.parseInt(st.nextToken()); + int end = Integer.parseInt(st.nextToken()); + seqs.addElement(new Sequence(name, st.nextToken(), start, end)); + } + SequenceI[] newSeqs = new SequenceI[seqs.size()]; + for (int i = 0; i < seqs.size(); i++) + { + newSeqs[i] = (SequenceI) seqs.elementAt(i); + } + + if (newAlignment) + { + String newtitle = MessageManager.getString("label.copied_sequences"); + if (getTitle().startsWith(MessageManager.getString("label.copied_sequences"))) + { + newtitle = getTitle(); + } + else + { + newtitle = newtitle.concat(MessageManager.formatMessage("label.from_msname", new String[]{getTitle()})); + } + AlignFrame af = new AlignFrame(new Alignment(newSeqs), + viewport.applet, newtitle, false); + if (copiedHiddenColumns != null) + { + for (int i = 0; i < copiedHiddenColumns.size(); i++) + { + int[] region = (int[]) copiedHiddenColumns.elementAt(i); + af.viewport.hideColumns(region[0], region[1]); + } + } + + JalviewLite.addFrame(af, newtitle, frameWidth, + frameHeight); + } + else + { + addSequences(newSeqs); + } + + } catch (Exception ex) + { + } // could be anything being pasted in here + + } + + void addSequences(SequenceI[] seqs) + { + for (int i = 0; i < seqs.length; i++) + { + viewport.getAlignment().addSequence(seqs[i]); + } + + // !newAlignment + addHistoryItem(new EditCommand( + MessageManager.getString("label.add_sequences"), Action.PASTE, + seqs, 0, viewport.getAlignment().getWidth(), + viewport.getAlignment())); + + viewport.setEndSeq(viewport.getAlignment().getHeight()); + viewport.getAlignment().getWidth(); + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); + + } + + protected void cut_actionPerformed() + { + copy_actionPerformed(); + delete_actionPerformed(); + } + + protected void delete_actionPerformed() + { + + SequenceGroup sg = viewport.getSelectionGroup(); + if (sg == null) + { + return; + } + + Vector seqs = new Vector(); + SequenceI seq; + for (int i = 0; i < sg.getSize(); i++) + { + seq = sg.getSequenceAt(i); + seqs.addElement(seq); + } + + // If the cut affects all sequences, remove highlighted columns + if (sg.getSize() == viewport.getAlignment().getHeight()) + { + viewport.getColumnSelection().removeElements(sg.getStartRes(), + sg.getEndRes() + 1); + } + + SequenceI[] cut = new SequenceI[seqs.size()]; + for (int i = 0; i < seqs.size(); i++) + { + cut[i] = (SequenceI) seqs.elementAt(i); + } + + /* + * //ADD HISTORY ITEM + */ + addHistoryItem(new EditCommand( + MessageManager.getString("label.cut_sequences"), Action.CUT, + cut, sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1, + viewport.getAlignment())); + + viewport.setSelectionGroup(null); + viewport.getAlignment().deleteGroup(sg); + + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); + + if (viewport.getAlignment().getHeight() < 1) + { + this.setVisible(false); + } + viewport.sendSelection(); + } + + /** + * group consensus toggled + * + */ + protected void showGroupConsensus_actionPerformed() + { + viewport.setShowGroupConsensus(showGroupConsensus.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + + } + + /** + * group conservation toggled. + */ + protected void showGroupConservation_actionPerformed() + { + viewport.setShowGroupConservation(showGroupConservation.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + /* + * (non-Javadoc) + * + * @see + * jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt + * .event.ActionEvent) + */ + protected void showConsensusHistogram_actionPerformed() + { + viewport.setShowConsensusHistogram(showConsensusHistogram.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + /* + * (non-Javadoc) + * + * @see + * jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt + * .event.ActionEvent) + */ + protected void showSequenceLogo_actionPerformed() + { + viewport.setShowSequenceLogo(showSequenceLogo.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + protected void normSequenceLogo_actionPerformed() + { + showSequenceLogo.setState(true); + viewport.setShowSequenceLogo(true); + viewport.setNormaliseSequenceLogo(normSequenceLogo.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + protected void applyAutoAnnotationSettings_actionPerformed() + { + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + protected void makeGrpsFromSelection_actionPerformed() + { + if (avc.makeGroupsFromSelection()) + { + PaintRefresher.Refresh(this, viewport.getSequenceSetId()); + alignPanel.updateAnnotation(); + alignPanel.paintAlignment(true); + } + } + + protected void createGroup_actionPerformed() + { + avc.createGroup(); + } + + protected void unGroup_actionPerformed() + { + if (avc.unGroup()) + { + alignPanel.alignmentChanged(); + } + } + + protected void deleteGroups_actionPerformed() + { + if (avc.deleteGroups()) + { + alignPanel.alignmentChanged(); + } + } + + public void selectAllSequenceMenuItem_actionPerformed() + { + SequenceGroup sg = new SequenceGroup(); + for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) + { + sg.addSequence(viewport.getAlignment().getSequenceAt(i), false); + } + sg.setEndRes(viewport.getAlignment().getWidth() - 1); + viewport.setSelectionGroup(sg); + alignPanel.paintAlignment(true); + PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); + viewport.sendSelection(); + } + + public void deselectAllSequenceMenuItem_actionPerformed() + { + if (viewport.cursorMode) + { + alignPanel.seqPanel.keyboardNo1 = null; + alignPanel.seqPanel.keyboardNo2 = null; + } + viewport.setSelectionGroup(null); + viewport.getColumnSelection().clear(); + viewport.setSelectionGroup(null); + alignPanel.idPanel.idCanvas.searchResults = null; + alignPanel.seqPanel.seqCanvas.highlightSearchResults(null); + alignPanel.paintAlignment(true); + PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); + viewport.sendSelection(); + } + + public void invertSequenceMenuItem_actionPerformed() + { + SequenceGroup sg = viewport.getSelectionGroup(); + for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) + { + sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false); + } + + PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); + viewport.sendSelection(); + } + + public void invertColSel_actionPerformed() + { + viewport.invertColumnSelection(); + alignPanel.paintAlignment(true); + PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); + viewport.sendSelection(); + } + + void trimAlignment(boolean trimLeft) + { + ColumnSelection colSel = viewport.getColumnSelection(); + int column; + + if (colSel.size() > 0) + { + if (trimLeft) + { + column = colSel.getMin(); + } + else + { + column = colSel.getMax(); + } + + SequenceI[] seqs; + if (viewport.getSelectionGroup() != null) + { + seqs = viewport.getSelectionGroup().getSequencesAsArray( + viewport.getHiddenRepSequences()); + } + else + { + seqs = viewport.getAlignment().getSequencesArray(); + } + + TrimRegionCommand trimRegion; + if (trimLeft) + { + trimRegion = new TrimRegionCommand("Remove Left", + TrimRegionCommand.TRIM_LEFT, seqs, column, + viewport.getAlignment(), viewport.getColumnSelection(), + viewport.getSelectionGroup()); + viewport.setStartRes(0); + } + else + { + trimRegion = new TrimRegionCommand("Remove Right", + TrimRegionCommand.TRIM_RIGHT, seqs, column, + viewport.getAlignment(), viewport.getColumnSelection(), + viewport.getSelectionGroup()); + } + + statusBar.setText(MessageManager.formatMessage( + "label.removed_columns", new String[] + { Integer.valueOf(trimRegion.getSize()).toString() })); + addHistoryItem(trimRegion); + + for (SequenceGroup sg : viewport.getAlignment().getGroups()) + { + if ((trimLeft && !sg.adjustForRemoveLeft(column)) + || (!trimLeft && !sg.adjustForRemoveRight(column))) + { + viewport.getAlignment().deleteGroup(sg); + } + } + + viewport.firePropertyChange("alignment", null, viewport + .getAlignment().getSequences()); + } + } + + public void removeGappedColumnMenuItem_actionPerformed() + { + int start = 0, end = viewport.getAlignment().getWidth() - 1; + + SequenceI[] seqs; + if (viewport.getSelectionGroup() != null) + { + seqs = viewport.getSelectionGroup().getSequencesAsArray( + viewport.getHiddenRepSequences()); + start = viewport.getSelectionGroup().getStartRes(); + end = viewport.getSelectionGroup().getEndRes(); + } + else + { + seqs = viewport.getAlignment().getSequencesArray(); + } + + RemoveGapColCommand removeGapCols = new RemoveGapColCommand( + "Remove Gapped Columns", seqs, start, end, + viewport.getAlignment()); + + addHistoryItem(removeGapCols); + + statusBar.setText(MessageManager.formatMessage( + "label.removed_empty_columns", new String[] + { Integer.valueOf(removeGapCols.getSize()).toString() })); + + // This is to maintain viewport position on first residue + // of first sequence + SequenceI seq = viewport.getAlignment().getSequenceAt(0); + int startRes = seq.findPosition(viewport.startRes); + // ShiftList shifts; + // viewport.getAlignment().removeGaps(shifts=new ShiftList()); + // edit.alColumnChanges=shifts.getInverse(); + // if (viewport.hasHiddenColumns) + // viewport.getColumnSelection().compensateForEdits(shifts); + viewport.setStartRes(seq.findIndex(startRes) - 1); + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); + + } + + public void removeAllGapsMenuItem_actionPerformed() + { + int start = 0, end = viewport.getAlignment().getWidth() - 1; + + SequenceI[] seqs; + if (viewport.getSelectionGroup() != null) + { + seqs = viewport.getSelectionGroup().getSequencesAsArray( + viewport.getHiddenRepSequences()); + start = viewport.getSelectionGroup().getStartRes(); + end = viewport.getSelectionGroup().getEndRes(); + } + else + { + seqs = viewport.getAlignment().getSequencesArray(); + } + + // This is to maintain viewport position on first residue + // of first sequence + SequenceI seq = viewport.getAlignment().getSequenceAt(0); + int startRes = seq.findPosition(viewport.startRes); + + addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end, + viewport.getAlignment())); + + viewport.setStartRes(seq.findIndex(startRes) - 1); + + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); + + } + + public void findMenuItem_actionPerformed() + { + new Finder(alignPanel); + } + + /** + * create a new view derived from the current view + * + * @param viewtitle + * @return frame for the new view + */ + public AlignFrame newView(String viewtitle) + { + AlignmentI newal; + if (viewport.hasHiddenRows()) + { + newal = new Alignment(viewport.getAlignment().getHiddenSequences() + .getFullAlignment().getSequencesArray()); + } + else + { + newal = new Alignment(viewport.getAlignment().getSequencesArray()); + } + + if (viewport.getAlignment().getAlignmentAnnotation() != null) + { + for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++) + { + if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated) + { + newal.addAnnotation(viewport.getAlignment() + .getAlignmentAnnotation()[i]); + } + } + } + + AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false); + + newaf.viewport.setSequenceSetId(alignPanel.av.getSequenceSetId()); + PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId()); + PaintRefresher.Register(newaf.alignPanel, + newaf.alignPanel.av.getSequenceSetId()); + + PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas, + newaf.alignPanel.av.getSequenceSetId()); + PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas, + newaf.alignPanel.av.getSequenceSetId()); + + Vector comps = (Vector) PaintRefresher.components.get(viewport + .getSequenceSetId()); + int viewSize = -1; + for (int i = 0; i < comps.size(); i++) + { + if (comps.elementAt(i) instanceof AlignmentPanel) + { + viewSize++; + } + } + + String title = new String(this.getTitle()); + if (viewtitle != null) + { + title = viewtitle + " ( " + title + ")"; + } + else + { + if (title.indexOf("(View") > -1) + { + title = title.substring(0, title.indexOf("(View")); + } + title += "(View " + viewSize + ")"; + } + + newaf.setTitle(title.toString()); + + newaf.viewport.setHistoryList(viewport.getHistoryList()); + newaf.viewport.setRedoList(viewport.getRedoList()); + return newaf; + } + + /** + * + * @return list of feature groups on the view + */ + public String[] getFeatureGroups() + { + FeatureRenderer fr = null; + if (alignPanel != null + && (fr = alignPanel.getFeatureRenderer()) != null) + { + List gps = fr.getFeatureGroups(); + String[] _gps = gps.toArray(new String[gps.size()]); + return _gps; + } + return null; + } + + /** + * get sequence feature groups that are hidden or shown + * + * @param visible + * true is visible + * @return list + */ + public String[] getFeatureGroupsOfState(boolean visible) + { + FeatureRenderer fr = null; + if (alignPanel != null + && (fr = alignPanel.getFeatureRenderer()) != null) + { + List gps = fr.getGroups(visible); + String[] _gps = gps.toArray(new String[gps.size()]); + return _gps; + } + return null; + } + + /** + * Change the display state for the given feature groups + * + * @param groups + * list of group strings + * @param state + * visible or invisible + */ + public void setFeatureGroupState(String[] groups, boolean state) + { + FeatureRenderer fr = null; + this.sequenceFeatures.setState(true); + viewport.setShowSequenceFeatures(true); + if (alignPanel != null + && (fr = alignPanel.getFeatureRenderer()) != null) + { + + fr.setGroupVisibility(Arrays.asList(groups), state); + alignPanel.seqPanel.seqCanvas.repaint(); + if (alignPanel.overviewPanel != null) + { + alignPanel.overviewPanel.updateOverviewImage(); + } + } + } + + public void seqLimits_itemStateChanged() + { + viewport.setShowJVSuffix(seqLimits.getState()); + alignPanel.fontChanged(); + alignPanel.paintAlignment(true); + } + + protected void colourTextMenuItem_actionPerformed() + { + viewport.setColourText(colourTextMenuItem.getState()); + alignPanel.paintAlignment(true); + } + + protected void displayNonconservedMenuItem_actionPerformed() + { + viewport.setShowUnconserved(displayNonconservedMenuItem.getState()); + alignPanel.paintAlignment(true); + } + + protected void wrapMenuItem_actionPerformed() + { + viewport.setWrapAlignment(wrapMenuItem.getState()); + alignPanel.setWrapAlignment(wrapMenuItem.getState()); + scaleAbove.setEnabled(wrapMenuItem.getState()); + scaleLeft.setEnabled(wrapMenuItem.getState()); + scaleRight.setEnabled(wrapMenuItem.getState()); + alignPanel.paintAlignment(true); + } + + public void overviewMenuItem_actionPerformed() + { + if (alignPanel.overviewPanel != null) + { + return; + } + + JFrame frame = new JFrame(); + OverviewPanel overview = new OverviewPanel(alignPanel); + frame.add(overview); + // +50 must allow for applet frame window + JalviewLite.addFrame(frame, MessageManager.formatMessage( + "label.overview_params", new String[] + { this.getTitle() }), overview.getPreferredSize().width, + overview.getPreferredSize().height + 50); + + frame.pack(); + final AlignmentPanel ap = alignPanel; + frame.addWindowListener(new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent e) + { + if (ap != null) + { + ap.setOverviewPanel(null); + } + }; + }); + + alignPanel.setOverviewPanel(overview); + + } + + public void changeColour(ColourSchemeI cs) + { + int threshold = 0; + + if (cs != null) + { + if (viewport.getAbovePIDThreshold()) + { + viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel, + cs, "Background")); + } + + if (viewport.getConservationSelected()) + { + cs.setConservationApplied(true); + viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel, + cs, "Background")); + } + else + { + cs.setConservationApplied(false); + } + } + viewport.setGlobalColourScheme(cs); + + if (alignPanel.getOverviewPanel() != null) + { + alignPanel.getOverviewPanel().updateOverviewImage(); + } + + StructureSelectionManager.getStructureSelectionManager(viewport.applet) + .sequenceColoursChanged(alignPanel); + + alignPanel.paintAlignment(true); + } + + protected void modifyPID_actionPerformed() + { + if (viewport.getAbovePIDThreshold() + && viewport.getGlobalColourScheme() != null) + { + SliderPanel.setPIDSliderSource(alignPanel, + viewport.getGlobalColourScheme(), "Background"); + SliderPanel.showPIDSlider(); + } + } + + protected void modifyConservation_actionPerformed() + { + if (viewport.getConservationSelected() + && viewport.getGlobalColourScheme() != null) + { + SliderPanel.setConservationSlider(alignPanel, + viewport.getGlobalColourScheme(), "Background"); + SliderPanel.showConservationSlider(); + } + } + + protected void conservationMenuItem_actionPerformed() + { + viewport.setConservationSelected(conservationMenuItem.getState()); + + viewport.setAbovePIDThreshold(false); + abovePIDThreshold.setState(false); + + changeColour(viewport.getGlobalColourScheme()); + + modifyConservation_actionPerformed(); + } + + public void abovePIDThreshold_actionPerformed() + { + viewport.setAbovePIDThreshold(abovePIDThreshold.getState()); + + conservationMenuItem.setState(false); + viewport.setConservationSelected(false); + + changeColour(viewport.getGlobalColourScheme()); + + modifyPID_actionPerformed(); + } + + public void sortPairwiseMenuItem_actionPerformed() + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter.sortByPID(viewport.getAlignment(), viewport + .getAlignment().getSequenceAt(0), null); + + addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, + viewport.getAlignment())); + alignPanel.paintAlignment(true); + } + + public void sortIDMenuItem_actionPerformed() + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter.sortByID(viewport.getAlignment()); + addHistoryItem(new OrderCommand("ID Sort", oldOrder, + viewport.getAlignment())); + alignPanel.paintAlignment(true); + } + + public void sortLengthMenuItem_actionPerformed() + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter.sortByLength(viewport.getAlignment()); + addHistoryItem(new OrderCommand("Length Sort", oldOrder, + viewport.getAlignment())); + alignPanel.paintAlignment(true); + } + + public void sortGroupMenuItem_actionPerformed() + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter.sortByGroup(viewport.getAlignment()); + addHistoryItem(new OrderCommand("Group Sort", oldOrder, + viewport.getAlignment())); + alignPanel.paintAlignment(true); + + } + + public void removeRedundancyMenuItem_actionPerformed() + { + new RedundancyPanel(alignPanel); + } + + public void pairwiseAlignmentMenuItem_actionPerformed() + { + if (viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() > 1) + { + JFrame frame = new JFrame(); + frame.add(new PairwiseAlignPanel(alignPanel)); + JalviewLite.addFrame(frame, + MessageManager.getString("action.pairwise_alignment"), 600, + 500); + } + } + + public void PCAMenuItem_actionPerformed() + { + // are the sequences aligned? + if (!viewport.getAlignment().isAligned(false)) + { + SequenceI current; + int Width = viewport.getAlignment().getWidth(); + + for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) + { + current = viewport.getAlignment().getSequenceAt(i); + + if (current.getLength() < Width) + { + current.insertCharAt(Width - 1, viewport.getGapCharacter()); + } + } + alignPanel.paintAlignment(true); + } + + if ((viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() < 4 && viewport + .getSelectionGroup().getSize() > 0) + || viewport.getAlignment().getHeight() < 4) + { + return; + } + + try + { + new PCAPanel(viewport); + } catch (java.lang.OutOfMemoryError ex) + { + } + + } + + public void averageDistanceTreeMenuItem_actionPerformed() + { + NewTreePanel("AV", "PID", "Average distance tree using PID"); + } + + public void neighbourTreeMenuItem_actionPerformed() + { + NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); + } + + protected void njTreeBlosumMenuItem_actionPerformed() + { + NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); + } + + protected void avTreeBlosumMenuItem_actionPerformed() + { + NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62"); + } + + void NewTreePanel(String type, String pwType, String title) + { + // are the sequences aligned? + if (!viewport.getAlignment().isAligned(false)) + { + SequenceI current; + int Width = viewport.getAlignment().getWidth(); + + for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) + { + current = viewport.getAlignment().getSequenceAt(i); + + if (current.getLength() < Width) + { + current.insertCharAt(Width - 1, viewport.getGapCharacter()); + } + } + alignPanel.paintAlignment(true); + + } + + if ((viewport.getSelectionGroup() != null && viewport + .getSelectionGroup().getSize() > 1) + || (viewport.getAlignment().getHeight() > 1)) + { + final TreePanel tp = new TreePanel(alignPanel, type, pwType); + + addTreeMenuItem(tp, title); + + JalviewLite.addFrame(tp, title, 600, 500); + } + } + + void loadTree_actionPerformed() + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); + cap.setText(MessageManager.getString("label.paste_newick_tree_file")); + cap.setTreeImport(); + JFrame frame = new JFrame(); + frame.add(cap); + JalviewLite.addFrame(frame, + MessageManager.getString("label.paste_newick_file"), 400, 300); + } + + public void loadTree(NewickFile tree, String treeFile) + { + TreePanel tp = new TreePanel(alignPanel, treeFile, + MessageManager.getString("label.load_tree_from_file"), tree); + JalviewLite.addFrame(tp, treeFile, 600, 500); + addTreeMenuItem(tp, treeFile); + } + + /** + * sort the alignment using the given treePanel + * + * @param treePanel + * tree used to sort view + * @param title + * string used for undo event name + */ + public void sortByTree(TreePanel treePanel, String title) + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter + .sortByTree(viewport.getAlignment(), treePanel.getTree()); + // addHistoryItem(new HistoryItem("Sort", viewport.alignment, + // HistoryItem.SORT)); + addHistoryItem(new OrderCommand(MessageManager.formatMessage( + "label.order_by_params", new String[] + { title }), oldOrder, viewport.getAlignment())); + alignPanel.paintAlignment(true); + } + + /** + * Do any automatic reordering of the alignment and add the necessary bits to + * the menu structure for the new tree + * + * @param treePanel + * @param title + */ + protected void addTreeMenuItem(final TreePanel treePanel, + final String title) + { + final JMenuItem item = new JMenuItem(title); + sortByTreeMenu.add(item); + item.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent evt) + { + sortByTree(treePanel, title); // treePanel.getTitle()); + } + }); + + treePanel.addWindowListener(new WindowAdapter() + { + @Override + public void windowOpened(WindowEvent e) + { + if (viewport.sortByTree) + { + sortByTree(treePanel, title); + } + super.windowOpened(e); + } + + @Override + public void windowClosing(WindowEvent e) + { + sortByTreeMenu.remove(item); + }; + }); + } + + public boolean sortBy(AlignmentOrder alorder, String undoname) + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + if (JalviewLite.debug) + { + System.err.println("Sorting " + alorder.getOrder().size() + + " in alignment '" + getTitle() + "'"); + } + AlignmentSorter.sortBy(viewport.getAlignment(), alorder); + if (undoname != null) + { + addHistoryItem(new OrderCommand(undoname, oldOrder, + viewport.getAlignment())); + } + alignPanel.paintAlignment(true); + return true; + } + + protected void documentation_actionPerformed() + { + alignPanel.av.applet.openJalviewHelpUrl(); + } + + protected void about_actionPerformed() + { + + class AboutPanel extends JPanel + { + String version; + + String builddate; + + public AboutPanel(String version, String builddate) + { + this.version = version; + this.builddate = builddate; + } + + @Override + public void paint(Graphics g) + { + g.setColor(Color.white); + g.fillRect(0, 0, getSize().width, getSize().height); + g.setFont(new Font("Helvetica", Font.PLAIN, 12)); + FontMetrics fm = g.getFontMetrics(); + int fh = fm.getHeight(); + int y = 5, x = 7; + g.setColor(Color.black); + // TODO: update this text for each release or centrally store it for + // lite and application + g.setFont(new Font("Helvetica", Font.BOLD, 14)); + g.drawString(MessageManager.formatMessage( + "label.jalviewLite_release", new String[] + { version }), x, y += fh); + g.setFont(new Font("Helvetica", Font.BOLD, 12)); + g.drawString(MessageManager.formatMessage( + "label.jaview_build_date", new String[] + { builddate }), x, y += fh); + g.setFont(new Font("Helvetica", Font.PLAIN, 12)); + g.drawString(MessageManager.getString("label.jalview_authors_1"), + x, y += fh * 1.5); + g.drawString(MessageManager.getString("label.jalview_authors_2"), + x + 50, y += fh + 8); + g.drawString( + MessageManager.getString("label.jalview_dev_managers"), x, + y += fh); + g.drawString(MessageManager + .getString("label.jalview_distribution_lists"), x, y += fh); + g.drawString(MessageManager.getString("label.jalview_please_cite"), + x, y += fh + 8); + g.drawString( + MessageManager.getString("label.jalview_cite_1_authors"), + x, y += fh); + g.drawString( + MessageManager.getString("label.jalview_cite_1_title"), x, + y += fh); + g.drawString(MessageManager.getString("label.jalview_cite_1_ref"), + x, y += fh); + } + } + + JFrame frame = new JFrame(); + frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite + .getBuildDate())); + JalviewLite.addFrame(frame, + MessageManager.getString("label.jalview"), 580, 220); + + } + + public void showURL(String url, String target) + { + if (viewport.applet == null) + { + System.out.println("Not running as applet - no browser available."); + } + else + { + viewport.applet.showURL(url, target); + } + } + + // //////////////////////////////////////////////////////////////////////////////// + // JBuilder Graphics here + + JMenuBar alignFrameMenuBar = new JMenuBar(); + + JMenu fileMenu = new JMenu(MessageManager.getString("action.file")); + + JMenuItem loadApplication = new JMenuItem( + MessageManager.getString("label.view_full_application")); + + JMenuItem loadTree = new JMenuItem( + MessageManager.getString("label.load_associated_tree")); + + JMenuItem loadAnnotations = new JMenuItem( + MessageManager.getString("label.load_features_annotations")); + + JMenuItem outputFeatures = new JMenuItem( + MessageManager.getString("label.export_features").concat("...")); + + JMenuItem outputAnnotations = new JMenuItem( + MessageManager.getString("label.export_annotations").concat("...")); + + JMenuItem closeMenuItem = new JMenuItem( + MessageManager.getString("action.close")); + + JMenuItem selectAllSequenceMenuItem = new JMenuItem( + MessageManager.getString("action.select_all")); + + JMenuItem deselectAllSequenceMenuItem = new JMenuItem( + MessageManager.getString("action.deselect_all")); + + JMenuItem invertSequenceMenuItem = new JMenuItem( + MessageManager.getString("action.invert_selection")); + + JMenuItem remove2LeftMenuItem = new JMenuItem(); + + JMenuItem remove2RightMenuItem = new JMenuItem(); + + JMenuItem removeGappedColumnMenuItem = new JMenuItem(); + + JMenuItem removeAllGapsMenuItem = new JMenuItem(); + + JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem(); + + JMenuItem sortPairwiseMenuItem = new JMenuItem(); + + JMenuItem sortIDMenuItem = new JMenuItem(); + + JMenuItem sortLengthMenuItem = new JMenuItem(); + + JMenuItem sortGroupMenuItem = new JMenuItem(); + + JMenuItem removeRedundancyMenuItem = new JMenuItem(); + + JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(); + + JMenuItem PCAMenuItem = new JMenuItem(); + + JMenuItem averageDistanceTreeMenuItem = new JMenuItem(); + + JMenuItem neighbourTreeMenuItem = new JMenuItem(); + + BorderLayout borderLayout1 = new BorderLayout(); + + public JLabel statusBar = new JLabel(); + + JMenuItem clustalColour = new JMenuItem(); + + JMenuItem zappoColour = new JMenuItem(); + + JMenuItem taylorColour = new JMenuItem(); + + JMenuItem hydrophobicityColour = new JMenuItem(); + + JMenuItem helixColour = new JMenuItem(); + + JMenuItem strandColour = new JMenuItem(); + + JMenuItem turnColour = new JMenuItem(); + + JMenuItem buriedColour = new JMenuItem(); + + JMenuItem purinePyrimidineColour = new JMenuItem(); + + JMenuItem RNAInteractionColour = new JMenuItem(); + + JMenuItem RNAHelixColour = new JMenuItem(); + + JMenuItem userDefinedColour = new JMenuItem(); + + JMenuItem PIDColour = new JMenuItem(); + + JMenuItem BLOSUM62Colour = new JMenuItem(); + + JMenuItem tcoffeeColour = new JMenuItem(); + + JMenuItem njTreeBlosumMenuItem = new JMenuItem(); + + JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(); + + JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem displayNonconservedMenuItem = new JCheckBoxMenuItem(); + + JMenuItem alProperties = new JMenuItem( + MessageManager.getString("label.alignment_props")); + + JMenuItem overviewMenuItem = new JMenuItem(); + + JMenuItem undoMenuItem = new JMenuItem(); + + JMenuItem redoMenuItem = new JMenuItem(); + + JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); + + JMenuItem noColourmenuItem = new JMenuItem(); + + JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); + + JMenuItem findMenuItem = new JMenuItem(); + + JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); + + JMenuItem nucleotideColour = new JMenuItem(); + + JMenuItem deleteGroups = new JMenuItem(); + + JMenuItem grpsFromSelection = new JMenuItem(); + + JMenuItem createGroup = new JMenuItem(); + + JMenuItem unGroup = new JMenuItem(); + + JMenuItem delete = new JMenuItem(); + + JMenuItem copy = new JMenuItem(); + + JMenuItem cut = new JMenuItem(); + + JMenu pasteMenu = new JMenu(); + + JMenuItem pasteNew = new JMenuItem(); + + JMenuItem pasteThis = new JMenuItem(); + + JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); + + JMenuItem font = new JMenuItem(); + + JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem(); + + JMenuItem modifyPID = new JMenuItem(); + + JMenuItem modifyConservation = new JMenuItem(); + + JCheckBoxMenuItem autoCalculate = null; + + JCheckBoxMenuItem sortByTree = new JCheckBoxMenuItem( + "Sort Alignment With New Tree", true); + + JMenu sortByTreeMenu = new JMenu(); + + JMenuItem inputText = new JMenuItem(); + + JMenuItem documentation = new JMenuItem(); + + JMenuItem about = new JMenuItem(); + + JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem centreColumnLabelFlag = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem followMouseOverFlag = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem(); + + JCheckBoxMenuItem normSequenceLogo = new JCheckBoxMenuItem(); + + /** + * Initialise menus and other items + * + * @throws Exception + */ + private void jbInit() throws Exception + { + setJMenuBar(alignFrameMenuBar); + + /* + * Configure File menu items and actions + */ + inputText + .setLabel(MessageManager.getString("label.input_from_textbox")); + inputText.addActionListener(this); + JMenu outputTextboxMenu = new JMenu( + MessageManager.getString("label.out_to_textbox")); + for (int i = 0; i < AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) + { + + JMenuItem item = new JMenuItem(AppletFormatAdapter.WRITEABLE_FORMATS[i]); + + item.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + outputText_actionPerformed(e); + } + }); + + outputTextboxMenu.add(item); + } + closeMenuItem.addActionListener(this); + loadApplication.addActionListener(this); + loadTree.addActionListener(this); + loadAnnotations.addActionListener(this); + outputFeatures.addActionListener(this); + outputAnnotations.addActionListener(this); + + /* + * Configure Edit menu items and actions + */ + undoMenuItem.setEnabled(false); + undoMenuItem.setLabel(MessageManager.getString("action.undo")); + undoMenuItem.addActionListener(this); + redoMenuItem.setEnabled(false); + redoMenuItem.setLabel(MessageManager.getString("action.redo")); + redoMenuItem.addActionListener(this); + copy.setLabel(MessageManager.getString("action.copy")); + copy.addActionListener(this); + cut.setLabel(MessageManager.getString("action.cut")); + cut.addActionListener(this); + delete.setLabel(MessageManager.getString("action.delete")); + delete.addActionListener(this); + pasteMenu.setLabel(MessageManager.getString("action.paste")); + pasteNew.setLabel(MessageManager.getString("label.to_new_alignment")); + pasteNew.addActionListener(this); + pasteThis.setLabel(MessageManager.getString("label.to_this_alignment")); + pasteThis.addActionListener(this); + remove2LeftMenuItem.setLabel(MessageManager + .getString("action.remove_left")); + remove2LeftMenuItem.addActionListener(this); + remove2RightMenuItem.setLabel(MessageManager + .getString("action.remove_right")); + remove2RightMenuItem.addActionListener(this); + removeGappedColumnMenuItem.setLabel(MessageManager + .getString("action.remove_empty_columns")); + removeGappedColumnMenuItem.addActionListener(this); + removeAllGapsMenuItem.setLabel(MessageManager + .getString("action.remove_all_gaps")); + removeAllGapsMenuItem.addActionListener(this); + removeRedundancyMenuItem.setLabel(MessageManager.getString( + "action.remove_redundancy").concat("...")); + removeRedundancyMenuItem.addActionListener(this); + + /* + * Configure Select menu items and actions + */ + findMenuItem.setLabel(MessageManager.getString("action.find")); + findMenuItem.addActionListener(this); + selectAllSequenceMenuItem.addActionListener(this); + deselectAllSequenceMenuItem.addActionListener(this); + invertSequenceMenuItem.setLabel(MessageManager + .getString("action.invert_sequence_selection")); + invertSequenceMenuItem.addActionListener(this); + invertColSel.setLabel(MessageManager + .getString("action.invert_column_selection")); + invertColSel.addActionListener(this); + deleteGroups.setLabel(MessageManager + .getString("action.undefine_groups")); + deleteGroups.addActionListener(this); + grpsFromSelection.setLabel(MessageManager + .getString("action.make_groups_selection")); + grpsFromSelection.addActionListener(this); + createGroup.setLabel(MessageManager.getString("action.create_group")); + unGroup.setLabel(MessageManager.getString("action.remove_group")); + annotationColumnSelection.setLabel("Select by Annotation"); + annotationColumnSelection.addActionListener(this); + + /* + * Configure View menu items and actions + */ + newView.setLabel(MessageManager.getString("action.new_view")); + newView.addActionListener(this); + JMenu showMenu = new JMenu(MessageManager.getString("action.show")); + showColumns.setLabel(MessageManager.getString("label.all_columns")); + showSeqs.setLabel(MessageManager.getString("label.all_sequences")); + JMenu hideMenu = new JMenu(MessageManager.getString("action.hide")); + hideColumns + .setLabel(MessageManager.getString("label.selected_columns")); + hideSequences.setLabel(MessageManager + .getString("label.selected_sequences")); + hideAllButSelection.setLabel(MessageManager + .getString("label.all_but_selected_region")); + hideAllSelection.setLabel(MessageManager + .getString("label.selected_region")); + showAllHidden.setLabel(MessageManager + .getString("label.all_sequences_columns")); + showColumns.addActionListener(this); + showSeqs.addActionListener(this); + hideColumns.addActionListener(this); + hideSequences.addActionListener(this); + hideAllButSelection.addActionListener(this); + hideAllSelection.addActionListener(this); + showAllHidden.addActionListener(this); + featureSettings.setLabel(MessageManager + .getString("label.feature_settings")); + featureSettings.addActionListener(this); + sequenceFeatures.setLabel(MessageManager + .getString("label.show_sequence_features")); + sequenceFeatures.addItemListener(this); + sequenceFeatures.setState(false); + followMouseOverFlag.setLabel(MessageManager + .getString("label.automatic_scrolling")); + followMouseOverFlag.addItemListener(this); + alProperties.addActionListener(this); + overviewMenuItem.setLabel(MessageManager + .getString("label.overview_window")); + overviewMenuItem.addActionListener(this); + + /* + * Configure Annotations menu items and actions + */ + annotationPanelMenuItem.setLabel(MessageManager + .getString("label.show_annotations")); + annotationPanelMenuItem.addItemListener(this); + showGroupConsensus.setLabel(MessageManager + .getString("label.group_consensus")); + showGroupConservation.setLabel(MessageManager + .getString("label.group_conservation")); + showConsensusHistogram.setLabel(MessageManager + .getString("label.show_consensus_histogram")); + showSequenceLogo.setLabel(MessageManager + .getString("label.show_consensus_logo")); + normSequenceLogo.setLabel(MessageManager + .getString("label.norm_consensus_logo")); + applyAutoAnnotationSettings.setLabel(MessageManager + .getString("label.apply_all_groups")); + applyAutoAnnotationSettings.setState(true); + JMenu autoAnnMenu = new JMenu( + MessageManager.getString("label.autocalculated_annotation")); + showGroupConsensus.addItemListener(this); + showGroupConservation.addItemListener(this); + showConsensusHistogram.addItemListener(this); + showSequenceLogo.addItemListener(this); + normSequenceLogo.addItemListener(this); + applyAutoAnnotationSettings.addItemListener(this); + showAlignmentAnnotations = new JCheckBoxMenuItem( + MessageManager.getString("label.show_all_al_annotations")); + showSequenceAnnotations = new JCheckBoxMenuItem( + MessageManager.getString("label.show_all_seq_annotations")); + sortAnnBySequence = new JCheckBoxMenuItem( + MessageManager.getString("label.sort_annotations_by_sequence")); + sortAnnByLabel = new JCheckBoxMenuItem( + MessageManager.getString("label.sort_annotations_by_label")); + showAutoFirst = new JCheckBoxMenuItem( + MessageManager.getString("label.show_first")); + showAutoLast = new JCheckBoxMenuItem( + MessageManager.getString("label.show_last")); + showAlignmentAnnotations.addItemListener(this); + showSequenceAnnotations.addItemListener(this); + sortAnnBySequence.addItemListener(this); + sortAnnByLabel.addItemListener(this); + showAutoFirst.addItemListener(this); + showAutoLast.addItemListener(this); + + /* + * Configure Format menu items and actions + */ + font.setLabel(MessageManager.getString("action.font")); + font.addActionListener(this); + scaleAbove.setLabel(MessageManager.getString("action.scale_above")); + scaleAbove.setState(true); + scaleAbove.setEnabled(false); + scaleAbove.addItemListener(this); + scaleLeft.setEnabled(false); + scaleLeft.setState(true); + scaleLeft.setLabel(MessageManager.getString("action.scale_left")); + scaleLeft.addItemListener(this); + scaleRight.setEnabled(false); + scaleRight.setState(true); + scaleRight.setLabel(MessageManager.getString("action.scale_right")); + scaleRight.addItemListener(this); + viewBoxesMenuItem.setLabel(MessageManager.getString("action.boxes")); + viewBoxesMenuItem.setState(true); + viewBoxesMenuItem.addItemListener(this); + viewTextMenuItem.setLabel(MessageManager.getString("action.text")); + viewTextMenuItem.setState(true); + viewTextMenuItem.addItemListener(this); + colourTextMenuItem.setLabel(MessageManager + .getString("label.colour_text")); + colourTextMenuItem.addItemListener(this); + displayNonconservedMenuItem.setLabel(MessageManager + .getString("label.show_non_conversed")); + displayNonconservedMenuItem.addItemListener(this); + wrapMenuItem.setLabel(MessageManager.getString("action.wrap")); + wrapMenuItem.addItemListener(this); + renderGapsMenuItem.setLabel(MessageManager + .getString("action.show_gaps")); + renderGapsMenuItem.setState(true); + renderGapsMenuItem.addItemListener(this); + centreColumnLabelFlag.setLabel(MessageManager + .getString("label.centre_column_labels")); + centreColumnLabelFlag.addItemListener(this); + seqLimits.setState(true); + seqLimits.setLabel(MessageManager + .getString("label.show_sequence_limits")); + seqLimits.addItemListener(this); + + /* + * Configure Colour menu items and actions + */ + applyToAllGroups.setLabel(MessageManager + .getString("label.apply_colour_to_all_groups")); + applyToAllGroups.setState(true); + applyToAllGroups.addItemListener(this); + clustalColour.setLabel(MessageManager.getString("label.clustalx")); + clustalColour.addActionListener(this); + zappoColour.setLabel(MessageManager.getString("label.zappo")); + zappoColour.addActionListener(this); + taylorColour.setLabel(MessageManager.getString("label.taylor")); + taylorColour.addActionListener(this); + hydrophobicityColour.setLabel(MessageManager + .getString("label.hydrophobicity")); + hydrophobicityColour.addActionListener(this); + helixColour + .setLabel(MessageManager.getString("label.helix_propensity")); + helixColour.addActionListener(this); + strandColour.setLabel(MessageManager + .getString("label.strand_propensity")); + strandColour.addActionListener(this); + turnColour.setLabel(MessageManager.getString("label.turn_propensity")); + turnColour.addActionListener(this); + buriedColour.setLabel(MessageManager.getString("label.buried_index")); + buriedColour.addActionListener(this); + purinePyrimidineColour.setLabel(MessageManager + .getString("label.purine_pyrimidine")); + purinePyrimidineColour.addActionListener(this); + RNAInteractionColour.setLabel(MessageManager + .getString("label.rna_interaction")); + RNAInteractionColour.addActionListener(this); + RNAHelixColour.setLabel(MessageManager + .getString("action.by_rna_helixes")); + RNAHelixColour.addActionListener(this); + userDefinedColour.setLabel(MessageManager + .getString("action.user_defined")); + userDefinedColour.addActionListener(this); + PIDColour.setLabel(MessageManager + .getString("label.percentage_identity")); + PIDColour.addActionListener(this); + BLOSUM62Colour.setLabel(MessageManager + .getString("label.blosum62_score")); + BLOSUM62Colour.addActionListener(this); + tcoffeeColour + .setLabel(MessageManager.getString("label.tcoffee_scores")); + // it will be enabled only if a score file is provided + tcoffeeColour.setEnabled(false); + tcoffeeColour.addActionListener(this); + conservationMenuItem.setLabel(MessageManager + .getString("action.by_conservation")); + conservationMenuItem.addItemListener(this); + noColourmenuItem.setLabel(MessageManager.getString("label.none")); + noColourmenuItem.addActionListener(this); + abovePIDThreshold.setLabel(MessageManager + .getString("label.above_identity_threshold")); + abovePIDThreshold.addItemListener(this); + nucleotideColour.setLabel(MessageManager.getString("label.nucleotide")); + nucleotideColour.addActionListener(this); + modifyPID.setLabel(MessageManager + .getString("label.modify_identity_thereshold")); + modifyPID.addActionListener(this); + modifyConservation.setLabel(MessageManager + .getString("label.modify_conservation_thereshold")); + modifyConservation.addActionListener(this); + annotationColour.setLabel(MessageManager + .getString("action.by_annotation")); + annotationColour.addActionListener(this); + + /* + * Configure Calculate menu items and actions + */ + sortPairwiseMenuItem.setLabel(MessageManager + .getString("action.by_pairwise_id")); + sortPairwiseMenuItem.addActionListener(this); + sortIDMenuItem.setLabel(MessageManager.getString("action.by_id")); + sortIDMenuItem.addActionListener(this); + sortLengthMenuItem.setLabel(MessageManager + .getString("action.by_length")); + sortLengthMenuItem.addActionListener(this); + sortGroupMenuItem.setLabel(MessageManager.getString("action.by_group")); + sortGroupMenuItem.addActionListener(this); + pairwiseAlignmentMenuItem.setLabel(MessageManager + .getString("action.pairwise_alignment")); + pairwiseAlignmentMenuItem.addActionListener(this); + PCAMenuItem.setLabel(MessageManager + .getString("label.principal_component_analysis")); + PCAMenuItem.addActionListener(this); + autoCalculate = new JCheckBoxMenuItem( + MessageManager.getString("label.autocalculate_consensus"), true); + averageDistanceTreeMenuItem.setLabel(MessageManager + .getString("label.average_distance_identity")); + averageDistanceTreeMenuItem.addActionListener(this); + neighbourTreeMenuItem.setLabel(MessageManager + .getString("label.neighbour_joining_identity")); + neighbourTreeMenuItem.addActionListener(this); + avDistanceTreeBlosumMenuItem.setLabel(MessageManager + .getString("label.average_distance_bloslum62")); + avDistanceTreeBlosumMenuItem.addActionListener(this); + njTreeBlosumMenuItem.setLabel(MessageManager + .getString("label.neighbour_blosum62")); + njTreeBlosumMenuItem.addActionListener(this); + sortByTreeMenu.setLabel(MessageManager + .getString("action.by_tree_order")); + JMenu sortMenu = new JMenu(MessageManager.getString("action.sort")); + JMenu calculateTreeMenu = new JMenu( + MessageManager.getString("action.calculate_tree")); + autoCalculate.addItemListener(this); + sortByTree.addItemListener(this); + + /* + * Configure Help menu items and actions + */ + JMenu helpMenu = new JMenu(MessageManager.getString("action.help")); + documentation.setLabel(MessageManager.getString("label.documentation")); + documentation.addActionListener(this); + about.setLabel(MessageManager.getString("label.about")); + about.addActionListener(this); + + /* + * Add top level menus to frame + */ + alignFrameMenuBar.add(fileMenu); + JMenu editMenu = new JMenu(MessageManager.getString("action.edit")); + alignFrameMenuBar.add(editMenu); + JMenu selectMenu = new JMenu(MessageManager.getString("action.select")); + alignFrameMenuBar.add(selectMenu); + JMenu viewMenu = new JMenu(MessageManager.getString("action.view")); + alignFrameMenuBar.add(viewMenu); + JMenu annotationsMenu = new JMenu( + MessageManager.getString("action.annotations")); + alignFrameMenuBar.add(annotationsMenu); + JMenu formatMenu = new JMenu(MessageManager.getString("action.format")); + alignFrameMenuBar.add(formatMenu); + JMenu colourMenu = new JMenu(MessageManager.getString("action.colour")); + alignFrameMenuBar.add(colourMenu); + JMenu calculateMenu = new JMenu( + MessageManager.getString("action.calculate")); + alignFrameMenuBar.add(calculateMenu); + alignFrameMenuBar.add(helpMenu); + + /* + * File menu + */ + fileMenu.add(inputText); + fileMenu.add(loadTree); + fileMenu.add(loadAnnotations); + fileMenu.addSeparator(); + fileMenu.add(outputTextboxMenu); + fileMenu.add(outputFeatures); + fileMenu.add(outputAnnotations); + if (jalviewServletURL != null) + { + fileMenu.add(loadApplication); + } + fileMenu.addSeparator(); + fileMenu.add(closeMenuItem); + + /* + * Edit menu + */ + editMenu.add(undoMenuItem); + editMenu.add(redoMenuItem); + editMenu.add(cut); + editMenu.add(copy); + pasteMenu.add(pasteNew); + pasteMenu.add(pasteThis); + editMenu.add(pasteMenu); + editMenu.add(delete); + editMenu.addSeparator(); + editMenu.add(remove2LeftMenuItem); + editMenu.add(remove2RightMenuItem); + editMenu.add(removeGappedColumnMenuItem); + editMenu.add(removeAllGapsMenuItem); + editMenu.add(removeRedundancyMenuItem); + + /* + * Select menu + */ + selectMenu.add(findMenuItem); + selectMenu.addSeparator(); + selectMenu.add(selectAllSequenceMenuItem); + selectMenu.add(deselectAllSequenceMenuItem); + selectMenu.add(invertSequenceMenuItem); + selectMenu.add(invertColSel); + selectMenu.add(createGroup); + selectMenu.add(unGroup); + selectMenu.add(grpsFromSelection); + selectMenu.add(deleteGroups); + selectMenu.add(annotationColumnSelection); + + /* + * View menu + */ + viewMenu.add(newView); + viewMenu.addSeparator(); + showMenu.add(showColumns); + showMenu.add(showSeqs); + showMenu.add(showAllHidden); + viewMenu.add(showMenu); + hideMenu.add(hideColumns); + hideMenu.add(hideSequences); + hideMenu.add(hideAllSelection); + hideMenu.add(hideAllButSelection); + viewMenu.add(hideMenu); + viewMenu.addSeparator(); + viewMenu.add(followMouseOverFlag); + viewMenu.addSeparator(); + viewMenu.add(sequenceFeatures); + viewMenu.add(featureSettings); + viewMenu.addSeparator(); + viewMenu.add(alProperties); + viewMenu.addSeparator(); + viewMenu.add(overviewMenuItem); + + /* + * Annotations menu + */ + annotationsMenu.add(annotationPanelMenuItem); + annotationsMenu.addSeparator(); + annotationsMenu.add(showAlignmentAnnotations); + annotationsMenu.add(showSequenceAnnotations); + annotationsMenu.add(sortAnnBySequence); + annotationsMenu.add(sortAnnByLabel); + annotationsMenu.addSeparator(); + autoAnnMenu.add(showAutoFirst); + autoAnnMenu.add(showAutoLast); + autoAnnMenu.addSeparator(); + autoAnnMenu.add(applyAutoAnnotationSettings); + autoAnnMenu.add(showConsensusHistogram); + autoAnnMenu.add(showSequenceLogo); + autoAnnMenu.add(normSequenceLogo); + autoAnnMenu.addSeparator(); + autoAnnMenu.add(showGroupConservation); + autoAnnMenu.add(showGroupConsensus); + annotationsMenu.add(autoAnnMenu); + + /* + * Format menu + */ + formatMenu.add(font); + formatMenu.add(seqLimits); + formatMenu.add(wrapMenuItem); + formatMenu.add(scaleAbove); + formatMenu.add(scaleLeft); + formatMenu.add(scaleRight); + formatMenu.add(viewBoxesMenuItem); + formatMenu.add(viewTextMenuItem); + formatMenu.add(colourTextMenuItem); + formatMenu.add(displayNonconservedMenuItem); + formatMenu.add(renderGapsMenuItem); + formatMenu.add(centreColumnLabelFlag); + + /* + * Colour menu + */ + colourMenu.add(applyToAllGroups); + colourMenu.addSeparator(); + colourMenu.add(noColourmenuItem); + colourMenu.add(clustalColour); + colourMenu.add(BLOSUM62Colour); + colourMenu.add(PIDColour); + colourMenu.add(zappoColour); + colourMenu.add(taylorColour); + colourMenu.add(hydrophobicityColour); + colourMenu.add(helixColour); + colourMenu.add(strandColour); + colourMenu.add(turnColour); + colourMenu.add(buriedColour); + colourMenu.add(nucleotideColour); + colourMenu.add(purinePyrimidineColour); + // colourMenu.add(RNAInteractionColour); + colourMenu.add(tcoffeeColour); + colourMenu.add(userDefinedColour); + colourMenu.addSeparator(); + colourMenu.add(conservationMenuItem); + colourMenu.add(modifyConservation); + colourMenu.add(abovePIDThreshold); + colourMenu.add(modifyPID); + colourMenu.add(annotationColour); + colourMenu.add(RNAHelixColour); + + /* + * Calculate menu + */ + sortMenu.add(sortIDMenuItem); + sortMenu.add(sortLengthMenuItem); + sortMenu.add(sortByTreeMenu); + sortMenu.add(sortGroupMenuItem); + sortMenu.add(sortPairwiseMenuItem); + calculateMenu.add(sortMenu); + calculateTreeMenu.add(averageDistanceTreeMenuItem); + calculateTreeMenu.add(neighbourTreeMenuItem); + calculateTreeMenu.add(avDistanceTreeBlosumMenuItem); + calculateTreeMenu.add(njTreeBlosumMenuItem); + calculateMenu.add(calculateTreeMenu); + calculateMenu.addSeparator(); + calculateMenu.add(pairwiseAlignmentMenuItem); + calculateMenu.add(PCAMenuItem); + calculateMenu.add(autoCalculate); + calculateMenu.add(sortByTree); + + /* + * Help menu + */ + helpMenu.add(documentation); + helpMenu.add(about); + + /* + * Status bar + */ + statusBar.setBackground(Color.white); + statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setText(MessageManager.getString("label.status_bar")); + this.add(statusBar, BorderLayout.SOUTH); + } + + public void setStatus(String string) + { + statusBar.setText(string); + }; + + JMenuItem featureSettings = new JMenuItem(); + + JCheckBoxMenuItem sequenceFeatures = new JCheckBoxMenuItem(); + + JMenuItem annotationColour = new JMenuItem(); + + JMenuItem annotationColumnSelection = new JMenuItem(); + + JMenuItem invertColSel = new JMenuItem(); + + JMenuItem showColumns = new JMenuItem(); + + JMenuItem showSeqs = new JMenuItem(); + + JMenuItem hideColumns = new JMenuItem(); + + JMenuItem hideSequences = new JMenuItem(); + + JMenuItem hideAllButSelection = new JMenuItem(); + + JMenuItem hideAllSelection = new JMenuItem(); + + JMenuItem showAllHidden = new JMenuItem(); + + JMenuItem newView = new JMenuItem(); + + private JCheckBoxMenuItem showAlignmentAnnotations; + + private JCheckBoxMenuItem showSequenceAnnotations; + + private JCheckBoxMenuItem sortAnnBySequence; + + private JCheckBoxMenuItem sortAnnByLabel; + + private JCheckBoxMenuItem showAutoFirst; + + private JCheckBoxMenuItem showAutoLast; + + private SplitFrame splitFrame; + + /** + * Attach the alignFrame panels after embedding menus, if necessary. This used + * to be called setEmbedded, but is now creates the dropdown menus in a + * platform independent manner to avoid OSX/Mac menu appendage daftness. + * + * @param reallyEmbedded + * true to attach the view to the applet area on the page rather than + * in a new window + */ + public void createAlignFrameWindow(boolean reallyEmbedded) + { + if (reallyEmbedded) + { + embedAlignFrameInApplet(viewport.applet); + } + else + { + // ////// + // test and embed menu bar if necessary. + // + if (embedMenuIfNeeded(alignPanel)) + { + /* + * adjust for status bar height too. ? pointless as overridden by layout + * manager + */ + alignPanel.setSize(getSize().width, + getSize().height - statusBar.getHeight()); + } + add(statusBar, BorderLayout.SOUTH); + add(alignPanel, BorderLayout.CENTER); + // and register with the applet so it can pass external API calls to us + JalviewLite.addFrame(this, this.getTitle(), + frameWidth, + frameHeight); + } + } + + /** + * Add the components of this AlignFrame to the applet container. + * + * @param theApplet + */ + public void embedAlignFrameInApplet(final JalviewLite theApplet) + { + // //// + // Explicitly build the embedded menu panel for the on-page applet + // + // view cannot be closed if its actually on the page + fileMenu.remove(closeMenuItem); + fileMenu.remove(3); // Remove Separator + // construct embedded menu, using default font + embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, false, false); + // and actually add the components to the applet area + theApplet.setLayout(new BorderLayout()); + theApplet.add(embeddedMenu, BorderLayout.NORTH); + theApplet.add(statusBar, BorderLayout.SOUTH); + // TODO should size be left to the layout manager? + alignPanel.setSize(theApplet.getSize().width, + theApplet.getSize().height - embeddedMenu.getHeight() + - statusBar.getHeight()); + theApplet.add(alignPanel, BorderLayout.CENTER); + final AlignFrame me = this; + theApplet.addFocusListener(new FocusListener() + { + + @Override + public void focusLost(FocusEvent e) + { + if (theApplet.currentAlignFrame == me) + { + theApplet.currentAlignFrame = null; + } + } + + @Override + public void focusGained(FocusEvent e) + { + theApplet.currentAlignFrame = me; + } + }); + theApplet.validate(); + } + + /** + * create a new binding between structures in an existing jmol viewer instance + * and an alignpanel with sequences that have existing PDBFile entries. Note, + * this does not open a new Jmol window, or modify the display of the + * structures in the original jmol window. Note This method doesn't work + * without an additional javascript library to exchange messages between the + * distinct applets. See http://issues.jalview.org/browse/JAL-621 + * + * @param viewer + * JmolViewer instance + * @param sequenceIds + * - sequence Ids to search for associations + */ + public SequenceStructureBinding addStructureViewInstance( + Object jmolviewer, String[] sequenceIds) + { + Viewer viewer = null; + try + { + viewer = (Viewer) jmolviewer; + } catch (ClassCastException ex) + { + System.err.println("Unsupported viewer object :" + + jmolviewer.getClass()); + } + if (viewer == null) + { + System.err.println("Can't use this object as a structure viewer:" + + jmolviewer.getClass()); + return null; + } + SequenceI[] seqs = null; + if (sequenceIds == null || sequenceIds.length == 0) + { + seqs = viewport.getAlignment().getSequencesArray(); + } + else + { + Vector sqi = new Vector(); + AlignmentI al = viewport.getAlignment(); + for (int sid = 0; sid < sequenceIds.length; sid++) + { + SequenceI sq = al.findName(sequenceIds[sid]); + if (sq != null) + { + sqi.addElement(sq); + } + } + if (sqi.size() > 0) + { + seqs = new SequenceI[sqi.size()]; + for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++) + { + seqs[sid] = (SequenceI) sqi.elementAt(sid); + } + } + else + { + return null; + } + } + AAStructureBindingModel jmv = null; + // TODO: search for a jmv that involves viewer + if (jmv == null) + { // create a new viewer/jalview binding. + jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][] + { seqs }); + } + return jmv; + + } + + /** + * bind a pdb file to a sequence in the current view + * + * @param sequenceId + * - sequenceId within the dataset. + * @param pdbEntryString + * - the short name for the PDB file + * @param pdbFile + * - pdb file - either a URL or a valid PDB file. + * @return true if binding was as success TODO: consider making an exception + * structure for indicating when PDB parsing or sequenceId location + * fails. + */ + public boolean addPdbFile(String sequenceId, String pdbEntryString, + String pdbFile) + { + SequenceI toaddpdb = viewport.getAlignment().findName(sequenceId); + boolean needtoadd = false; + if (toaddpdb != null) + { + Vector pdbe = toaddpdb.getPDBId(); + PDBEntry pdbentry = null; + if (pdbe != null && pdbe.size() > 0) + { + for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++) + { + pdbentry = (PDBEntry) pdbe.elementAt(pe); + if (!pdbentry.getId().equals(pdbEntryString) + && !pdbentry.getFile().equals(pdbFile)) + { + pdbentry = null; + } + else + { + continue; + } + } + } + if (pdbentry == null) + { + pdbentry = new PDBEntry(); + pdbentry.setId(pdbEntryString); + pdbentry.setFile(pdbFile); + needtoadd = true; // add this new entry to sequence. + } + // resolve data source + // TODO: this code should be a refactored to an io package + String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB"); + if (protocol == null) + { + return false; + } + if (needtoadd) + { + // make a note of the access mode and add + if (pdbentry.getProperty() == null) + { + pdbentry.setProperty(new Hashtable()); + } + pdbentry.getProperty().put("protocol", protocol); + toaddpdb.addPDBId(pdbentry); + alignPanel.getStructureSelectionManager() + .registerPDBEntry(pdbentry); + } + } + return true; + } + + private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains) + { + if (seqs != null) + { + Vector sequences = new Vector(); + for (int i = 0; i < seqs.length; i++) + { + if (seqs[i] != null) + { + sequences.addElement(new Object[] + { seqs[i], (chains != null) ? chains[i] : null }); + } + } + seqs = new SequenceI[sequences.size()]; + chains = new String[sequences.size()]; + for (int i = 0, isize = sequences.size(); i < isize; i++) + { + Object[] oj = (Object[]) sequences.elementAt(i); + + seqs[i] = (SequenceI) oj[0]; + chains[i] = (String) oj[1]; + } + } + return new Object[] + { seqs, chains }; + + } + + public void newStructureView(JalviewLite applet, PDBEntry pdb, + SequenceI[] seqs, String[] chains, String protocol) + { + // Scrub any null sequences from the array + Object[] sqch = cleanSeqChainArrays(seqs, chains); + seqs = (SequenceI[]) sqch[0]; + chains = (String[]) sqch[1]; + if (seqs == null || seqs.length == 0) + { + System.err + .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to."); + } + if (protocol == null || protocol.trim().length() == 0 + || protocol.equals("null")) + { + protocol = (String) pdb.getProperty().get("protocol"); + if (protocol == null) + { + System.err.println("Couldn't work out protocol to open structure: " + + pdb.getId()); + return; + } + } + if (applet.useXtrnalSviewer) + { + // register the association(s) and quit, don't create any windows. + if (StructureSelectionManager.getStructureSelectionManager(applet) + .setMapping(seqs, chains, pdb.getFile(), protocol) == null) + { + System.err.println("Failed to map " + pdb.getFile() + " (" + + protocol + ") to any sequences"); + } + return; + } + if (applet.isAlignPdbStructures() && applet.jmolAvailable) + { + // can only do alignments with Jmol + // find the last jmol window assigned to this alignment + AppletJmol ajm = null, tajm; + Vector jmols = applet +.getAppletWindow(AppletJmol.class); + for (int i = 0, iSize = jmols.size(); i < iSize; i++) + { + tajm = (AppletJmol) jmols.elementAt(i); + if (tajm.ap.alignFrame == this) + { + ajm = tajm; + break; + } + } + if (ajm != null) + { + System.err + .println("Incremental adding and aligning structure to existing Jmol view not yet implemented."); + // try and add the pdb structure + // ajm.addS + ajm = null; + } + } + // otherwise, create a new window +// if (applet.jmolAvailable) +// { + new AppletJmol(pdb, seqs, chains, alignPanel, protocol); + applet.lastFrameX += 40; + applet.lastFrameY += 40; +// } +// else +// { +// new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol); +// } + + } + + public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb, + SequenceI[][] seqs, String[][] chains, String[] protocols) + { + // TODO Auto-generated method stub + System.err.println("Aligned Structure View: Not yet implemented."); + } + + /** + * modify the current selection, providing the user has not made a selection + * already. + * + * @param sel + * - sequences from this alignment + * @param csel + * - columns to be selected on the alignment + */ + public void select(SequenceGroup sel, ColumnSelection csel) + { + alignPanel.seqPanel.selection(sel, csel, null); + } + + public void scrollTo(int row, int column) + { + alignPanel.seqPanel.scrollTo(row, column); + } + + public void scrollToRow(int row) + { + alignPanel.seqPanel.scrollToRow(row); + } + + public void scrollToColumn(int column) + { + alignPanel.seqPanel.scrollToColumn(column); + } + + /** + * @return the alignments unique ID. + */ + public String getSequenceSetId() + { + return viewport.getSequenceSetId(); + } + + /** + * Load the (T-Coffee) score file from the specified url + * + * @param source + * File/URL/T-COFFEE score file contents + * @throws IOException + * @return true if alignment was annotated with data from source + */ + public boolean loadScoreFile(String source) throws IOException + { + + AlignFile file = GenericFileAdapter.newTCoffeeScoreFile(source, + AppletFormatAdapter.checkProtocol(source)); + if (!file.isValid()) + { + // TODO: raise dialog for gui + System.err.println("Problems parsing T-Coffee scores: " + + file.getWarningMessage()); + System.err.println("Origin was:\n" + source); + return false; + } + + /* + * check that the score matrix matches the alignment dimensions + */ + AlignmentI aln; + if ((aln = viewport.getAlignment()) != null + && (aln.getHeight() != file.getHeight() || aln.getWidth() != file + .getWidth())) + { + // TODO: raise a dialog box here rather than bomb out. + System.err + .println("The scores matrix does not match the alignment dimensions"); + + } + + // TODO add parameter to indicate if matching should be done + if (file.annotateAlignment(alignPanel.getAlignment(), false)) + { + alignPanel.fontChanged(); + tcoffeeColour.setEnabled(true); + // switch to this color + changeColour(new TCoffeeColourScheme(alignPanel.getAlignment())); + return true; + } + else + { + System.err.println("Problems resolving T-Coffee scores:"); + if (file.getWarningMessage() != null) + { + System.err.println(file.getWarningMessage()); + } + } + return false; + } + + public SplitFrame getSplitFrame() + { + return this.splitFrame; + } + + public void setSplitFrame(SplitFrame sf) + { + this.splitFrame = sf; + } + + // may not need this + @Override + public void setShowSeqFeatures(boolean b) + { + // showSeqFeatures.setSelected(b); + viewport.setShowSequenceFeatures(b); + + } + + @Override + public void setMenusForViewport() + { + // setMenusFromViewport(viewport); + + } + @Override + public void refreshFeatureUI(boolean enableIfNecessary) + { + if (enableIfNecessary) + { + sequenceFeatures.setState(true); + alignPanel.av.setShowSequenceFeatures(true); + } + } + + @Override + public FeatureSettingsControllerI getFeatureSettingsUI() + { + return alignPanel.av.featureSettings; + } + +} diff --git a/unused/appletgui/AlignViewport.java b/unused/appletgui/AlignViewport.java index 68d6c90..bfd593a 100644 --- a/unused/appletgui/AlignViewport.java +++ b/unused/appletgui/AlignViewport.java @@ -1,472 +1,472 @@ -/* - * 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. - * - * 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 . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.appletgui; - -import jalview.analysis.NJTree; -import jalview.api.AlignViewportI; -import jalview.bin.JalviewLite; -import jalview.commands.CommandI; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.SearchResults; -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -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.util.Platform; -import jalview.viewmodel.AlignmentViewport; -import jalview.workers.AlignCalcManager; - -import java.awt.Font; - -public class AlignViewport extends AlignmentViewport implements - SelectionSource, VamsasSource, CommandListener -{ - boolean cursorMode = false; - - Font font = new Font("SansSerif", Font.PLAIN, 10); - - boolean validCharWidth = true; - - NJTree currentTree = null; - - public JalviewLite applet; - - boolean MAC = false; - - private AnnotationColumnChooser annotationColumnSelectionState; - - public void finalize() - { - applet = null; - quality = null; - alignment = null; - colSel = null; - } - - public AlignViewport(AlignmentI al, JalviewLite applet) - { - super(); - calculator = new AlignCalcManager(); - this.applet = applet; - alignment = al; - // 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 - String param = applet.getParameter("widthScale"); - if (param != null) - { - try - { - widthScale = new Float(param).floatValue(); - } catch (Exception e) - { - } - if (widthScale <= 1.0) - { - System.err - .println("Invalid alignment character width scaling factor (" - + widthScale + "). Ignoring."); - widthScale = 1; - } - if (JalviewLite.debug) - { - System.err - .println("Alignment character width scaling factor is now " - + widthScale); - } - } - param = applet.getParameter("heightScale"); - if (param != null) - { - try - { - heightScale = new Float(param).floatValue(); - } catch (Exception e) - { - } - if (heightScale <= 1.0) - { - System.err - .println("Invalid alignment character height scaling factor (" - + heightScale + "). Ignoring."); - heightScale = 1; - } - if (JalviewLite.debug) - { - System.err - .println("Alignment character height scaling factor is now " - + heightScale); - } - } - } - setFont(font); - - MAC = Platform.isAMac(); - - if (applet != null) - { - setShowJVSuffix(applet.getDefaultParameter("showFullId", - getShowJVSuffix())); - - setShowAnnotation(applet.getDefaultParameter("showAnnotation", - isShowAnnotation())); - - showConservation = applet.getDefaultParameter("showConservation", - showConservation); - - showQuality = applet.getDefaultParameter("showQuality", showQuality); - - showConsensus = applet.getDefaultParameter("showConsensus", - showConsensus); - - setShowUnconserved(applet.getDefaultParameter("showUnconserved", - getShowUnconserved())); - - setScaleProteinAsCdna(applet.getDefaultParameter( - "scaleProteinAsCdna", isScaleProteinAsCdna())); - - String param = applet.getParameter("upperCase"); - if (param != null) - { - if (param.equalsIgnoreCase("bold")) - { - setUpperCasebold(true); - } - } - sortByTree = applet.getDefaultParameter("sortByTree", sortByTree); - - setFollowHighlight(applet.getDefaultParameter("automaticScrolling", - isFollowHighlight())); - followSelection = isFollowHighlight(); - - showSequenceLogo = applet.getDefaultParameter("showSequenceLogo", - showSequenceLogo); - - normaliseSequenceLogo = applet.getDefaultParameter( - "normaliseSequenceLogo", applet.getDefaultParameter( - "normaliseLogo", normaliseSequenceLogo)); - - showGroupConsensus = applet.getDefaultParameter("showGroupConsensus", - showGroupConsensus); - - showGroupConservation = applet.getDefaultParameter( - "showGroupConservation", showGroupConservation); - - showConsensusHistogram = applet.getDefaultParameter( - "showConsensusHistogram", showConsensusHistogram); - - } - - if (applet != null) - { - String colour = applet.getParameter("defaultColour"); - - if (colour == null) - { - colour = applet.getParameter("userDefinedColour"); - if (colour != null) - { - colour = "User Defined"; - } - } - - if (colour != null) - { - globalColourScheme = ColourSchemeProperty.getColour(alignment, - colour); - if (globalColourScheme != null) - { - globalColourScheme.setConsensus(hconsensus); - } - } - - if (applet.getParameter("userDefinedColour") != null) - { - ((UserColourScheme) globalColourScheme).parseAppletParameter(applet - .getParameter("userDefinedColour")); - } - } - initAutoAnnotation(); - - } - - /** - * get the consensus sequence as displayed under the PID consensus annotation - * row. - * - * @return consensus sequence as a new sequence object - */ - public SequenceI getConsensusSeq() - { - if (consensus == null) - { - updateConsensus(null); - } - if (consensus == null) - { - return null; - } - StringBuilder seqs = new StringBuilder(consensus.annotations.length); - for (int i = 0; i < consensus.annotations.length; i++) - { - if (consensus.annotations[i] != null) - { - if (consensus.annotations[i].description.charAt(0) == '[') - { - seqs.append(consensus.annotations[i].description.charAt(1)); - } - else - { - seqs.append(consensus.annotations[i].displayCharacter); - } - } - } - SequenceI sq = new Sequence("Consensus", seqs.toString()); - sq.setDescription("Percentage Identity Consensus " - + ((ignoreGapsInConsensusCalculation) ? " without gaps" : "")); - return sq; - } - - java.awt.Frame nullFrame; - - protected FeatureSettings featureSettings = null; - - private float heightScale = 1, widthScale = 1; - - public void setFont(Font f) - { - font = f; - if (nullFrame == null) - { - nullFrame = new java.awt.Frame(); - nullFrame.addNotify(); - } - - java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font); - setCharHeight((int) (heightScale * fm.getHeight())); - setCharWidth((int) (widthScale * fm.charWidth('M'))); - - if (isUpperCasebold()) - { - Font f2 = new Font(f.getName(), Font.BOLD, f.getSize()); - fm = nullFrame.getGraphics().getFontMetrics(f2); - setCharWidth((int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10))); - } - } - - public Font getFont() - { - return font; - } - - - public void resetSeqLimits(int height) - { - setEndSeq(height / getCharHeight()); - } - - public void setCurrentTree(NJTree tree) - { - currentTree = tree; - } - - public NJTree getCurrentTree() - { - return currentTree; - } - - - boolean centreColumnLabels; - - public boolean getCentreColumnLabels() - { - return centreColumnLabels; - } - - public boolean followSelection = true; - - /** - * @return true if view selection should always follow the selections - * broadcast by other selection sources - */ - public boolean getFollowSelection() - { - return followSelection; - } - - public void sendSelection() - { - getStructureSelectionManager().sendSelection( - new SequenceGroup(getSelectionGroup()), - new ColumnSelection(getColumnSelection()), this); - } - - /** - * Returns an instance of the StructureSelectionManager scoped to this applet - * instance. - * - * @return - */ - @Override - public StructureSelectionManager getStructureSelectionManager() - { - return StructureSelectionManager.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); - } - } - } - - public boolean isNormaliseSequenceLogo() - { - return normaliseSequenceLogo; - } - - public void setNormaliseSequenceLogo(boolean state) - { - normaliseSequenceLogo = state; - } - - /** - * - * @return true if alignment characters should be displayed - */ - public boolean isValidCharWidth() - { - return validCharWidth; - } - - public AnnotationColumnChooser getAnnotationColumnSelectionState() - { - return annotationColumnSelectionState; - } - - public void setAnnotationColumnSelectionState( - AnnotationColumnChooser annotationColumnSelectionState) - { - this.annotationColumnSelectionState = annotationColumnSelectionState; - } - - @Override - public void mirrorCommand(CommandI command, boolean undo, - StructureSelectionManager ssm, VamsasSource source) - { - // TODO refactor so this can be pulled up to superclass or controller - /* - * Do nothing unless we are a 'complement' of the source. May replace this - * with direct calls not via SSM. - */ - if (source instanceof AlignViewportI - && ((AlignViewportI) source).getCodingComplement() == this) - { - // ok to continue; - } - else - { - return; - } - - CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(), - getGapCharacter()); - if (mappedCommand != null) - { - mappedCommand.doCommand(null); - firePropertyChange("alignment", null, getAlignment().getSequences()); - - // ap.scalePanelHolder.repaint(); - // ap.repaint(); - } - } - - @Override - public VamsasSource getVamsasSource() - { - 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. - */ - SearchResults sr = new SearchResults(); - int seqOffset = findComplementScrollTarget(sr); - if (!sr.isEmpty()) - { - complementPanel.setFollowingComplementScroll(true); - complementPanel.scrollToCentre(sr, seqOffset); - } - } - - -} +/* + * 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.appletgui; + +import jalview.analysis.NJTree; +import jalview.api.AlignViewportI; +import jalview.bin.JalviewLite; +import jalview.commands.CommandI; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SearchResults; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +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.util.Platform; +import jalview.viewmodel.AlignmentViewport; +import jalview.workers.AlignCalcManager; + +import java.awt.Font; + +public class AlignViewport extends AlignmentViewport implements + SelectionSource, VamsasSource, CommandListener +{ + boolean cursorMode = false; + + Font font = new Font("SansSerif", Font.PLAIN, 10); + + boolean validCharWidth = true; + + NJTree currentTree = null; + + public JalviewLite applet; + + boolean MAC = false; + + private AnnotationColumnChooser annotationColumnSelectionState; + + public void finalize() + { + applet = null; + quality = null; + alignment = null; + colSel = null; + } + + public AlignViewport(AlignmentI al, JalviewLite applet) + { + super(); + calculator = new AlignCalcManager(); + this.applet = applet; + alignment = al; + // 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 + String param = applet.getParameter("widthScale"); + if (param != null) + { + try + { + widthScale = new Float(param).floatValue(); + } catch (Exception e) + { + } + if (widthScale <= 1.0) + { + System.err + .println("Invalid alignment character width scaling factor (" + + widthScale + "). Ignoring."); + widthScale = 1; + } + if (JalviewLite.debug) + { + System.err + .println("Alignment character width scaling factor is now " + + widthScale); + } + } + param = applet.getParameter("heightScale"); + if (param != null) + { + try + { + heightScale = new Float(param).floatValue(); + } catch (Exception e) + { + } + if (heightScale <= 1.0) + { + System.err + .println("Invalid alignment character height scaling factor (" + + heightScale + "). Ignoring."); + heightScale = 1; + } + if (JalviewLite.debug) + { + System.err + .println("Alignment character height scaling factor is now " + + heightScale); + } + } + } + setFont(font); + + MAC = Platform.isAMac(); + + if (applet != null) + { + setShowJVSuffix(applet.getDefaultParameter("showFullId", + getShowJVSuffix())); + + setShowAnnotation(applet.getDefaultParameter("showAnnotation", + isShowAnnotation())); + + showConservation = applet.getDefaultParameter("showConservation", + showConservation); + + showQuality = applet.getDefaultParameter("showQuality", showQuality); + + showConsensus = applet.getDefaultParameter("showConsensus", + showConsensus); + + setShowUnconserved(applet.getDefaultParameter("showUnconserved", + getShowUnconserved())); + + setScaleProteinAsCdna(applet.getDefaultParameter( + "scaleProteinAsCdna", isScaleProteinAsCdna())); + + String param = applet.getParameter("upperCase"); + if (param != null) + { + if (param.equalsIgnoreCase("bold")) + { + setUpperCasebold(true); + } + } + sortByTree = applet.getDefaultParameter("sortByTree", sortByTree); + + setFollowHighlight(applet.getDefaultParameter("automaticScrolling", + isFollowHighlight())); + followSelection = isFollowHighlight(); + + showSequenceLogo = applet.getDefaultParameter("showSequenceLogo", + showSequenceLogo); + + normaliseSequenceLogo = applet.getDefaultParameter( + "normaliseSequenceLogo", applet.getDefaultParameter( + "normaliseLogo", normaliseSequenceLogo)); + + showGroupConsensus = applet.getDefaultParameter("showGroupConsensus", + showGroupConsensus); + + showGroupConservation = applet.getDefaultParameter( + "showGroupConservation", showGroupConservation); + + showConsensusHistogram = applet.getDefaultParameter( + "showConsensusHistogram", showConsensusHistogram); + + } + + if (applet != null) + { + String colour = applet.getParameter("defaultColour"); + + if (colour == null) + { + colour = applet.getParameter("userDefinedColour"); + if (colour != null) + { + colour = "User Defined"; + } + } + + if (colour != null) + { + globalColourScheme = ColourSchemeProperty.getColour(alignment, + colour); + if (globalColourScheme != null) + { + globalColourScheme.setConsensus(hconsensus); + } + } + + if (applet.getParameter("userDefinedColour") != null) + { + ((UserColourScheme) globalColourScheme).parseAppletParameter(applet + .getParameter("userDefinedColour")); + } + } + initAutoAnnotation(); + + } + + /** + * get the consensus sequence as displayed under the PID consensus annotation + * row. + * + * @return consensus sequence as a new sequence object + */ + public SequenceI getConsensusSeq() + { + if (consensus == null) + { + updateConsensus(null); + } + if (consensus == null) + { + return null; + } + StringBuilder seqs = new StringBuilder(consensus.annotations.length); + for (int i = 0; i < consensus.annotations.length; i++) + { + if (consensus.annotations[i] != null) + { + if (consensus.annotations[i].description.charAt(0) == '[') + { + seqs.append(consensus.annotations[i].description.charAt(1)); + } + else + { + seqs.append(consensus.annotations[i].displayCharacter); + } + } + } + SequenceI sq = new Sequence("Consensus", seqs.toString()); + sq.setDescription("Percentage Identity Consensus " + + ((ignoreGapsInConsensusCalculation) ? " without gaps" : "")); + return sq; + } + + java.awt.Frame nullFrame; + + protected FeatureSettings featureSettings = null; + + private float heightScale = 1, widthScale = 1; + + public void setFont(Font f) + { + font = f; + if (nullFrame == null) + { + nullFrame = new java.awt.Frame(); + nullFrame.addNotify(); + } + + java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font); + setCharHeight((int) (heightScale * fm.getHeight())); + setCharWidth((int) (widthScale * fm.charWidth('M'))); + + if (isUpperCasebold()) + { + Font f2 = new Font(f.getName(), Font.BOLD, f.getSize()); + fm = nullFrame.getGraphics().getFontMetrics(f2); + setCharWidth((int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10))); + } + } + + public Font getFont() + { + return font; + } + + + public void resetSeqLimits(int height) + { + setEndSeq(height / getCharHeight()); + } + + public void setCurrentTree(NJTree tree) + { + currentTree = tree; + } + + public NJTree getCurrentTree() + { + return currentTree; + } + + + boolean centreColumnLabels; + + public boolean getCentreColumnLabels() + { + return centreColumnLabels; + } + + public boolean followSelection = true; + + /** + * @return true if view selection should always follow the selections + * broadcast by other selection sources + */ + public boolean getFollowSelection() + { + return followSelection; + } + + public void sendSelection() + { + getStructureSelectionManager().sendSelection( + new SequenceGroup(getSelectionGroup()), + new ColumnSelection(getColumnSelection()), this); + } + + /** + * Returns an instance of the StructureSelectionManager scoped to this applet + * instance. + * + * @return + */ + @Override + public StructureSelectionManager getStructureSelectionManager() + { + return StructureSelectionManager.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); + } + } + } + + public boolean isNormaliseSequenceLogo() + { + return normaliseSequenceLogo; + } + + public void setNormaliseSequenceLogo(boolean state) + { + normaliseSequenceLogo = state; + } + + /** + * + * @return true if alignment characters should be displayed + */ + public boolean isValidCharWidth() + { + return validCharWidth; + } + + public AnnotationColumnChooser getAnnotationColumnSelectionState() + { + return annotationColumnSelectionState; + } + + public void setAnnotationColumnSelectionState( + AnnotationColumnChooser annotationColumnSelectionState) + { + this.annotationColumnSelectionState = annotationColumnSelectionState; + } + + @Override + public void mirrorCommand(CommandI command, boolean undo, + StructureSelectionManager ssm, VamsasSource source) + { + // TODO refactor so this can be pulled up to superclass or controller + /* + * Do nothing unless we are a 'complement' of the source. May replace this + * with direct calls not via SSM. + */ + if (source instanceof AlignViewportI + && ((AlignViewportI) source).getCodingComplement() == this) + { + // ok to continue; + } + else + { + return; + } + + CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(), + getGapCharacter()); + if (mappedCommand != null) + { + mappedCommand.doCommand(null); + firePropertyChange("alignment", null, getAlignment().getSequences()); + + // ap.scalePanelHolder.repaint(); + // ap.repaint(); + } + } + + @Override + public VamsasSource getVamsasSource() + { + 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. + */ + SearchResults sr = new SearchResults(); + int seqOffset = findComplementScrollTarget(sr); + if (!sr.isEmpty()) + { + complementPanel.setFollowingComplementScroll(true); + complementPanel.scrollToCentre(sr, seqOffset); + } + } + + +} diff --git a/unused/appletgui/AlignmentPanel.java b/unused/appletgui/AlignmentPanel.java index 92e6267..36c5028 100644 --- a/unused/appletgui/AlignmentPanel.java +++ b/unused/appletgui/AlignmentPanel.java @@ -1,1166 +1,1166 @@ -/* - * 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. - * - * 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 . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.appletgui; - -import jalview.analysis.AnnotationSorter; -import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.bin.JalviewLite; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.SearchResults; -import jalview.datamodel.SequenceI; -import jalview.structure.StructureSelectionManager; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.event.AdjustmentEvent; -import java.awt.event.AdjustmentListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.util.List; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JScrollBar; - -public class AlignmentPanel extends JPanel implements AdjustmentListener, - AlignmentViewPanel -{ - - public AlignViewport av; - - OverviewPanel overviewPanel; - - SeqPanel seqPanel; - - IdPanel idPanel; - - IdwidthAdjuster idwidthAdjuster; - - public AlignFrame alignFrame; - - ScalePanel scalePanel; - - AnnotationPanel annotationPanel; - - AnnotationLabels alabels; - - // this value is set false when selection area being dragged - boolean fastPaint = true; - - public void finalize() - { - alignFrame = null; - av = null; - seqPanel = null; - seqPanelHolder = null; - sequenceHolderPanel = null; - scalePanel = null; - scalePanelHolder = null; - annotationPanel = null; - annotationPanelHolder = null; - annotationSpaceFillerHolder = null; - } - - public AlignmentPanel(AlignFrame af, final AlignViewport av) - { - try - { - jbInit(); - } catch (Exception e) - { - e.printStackTrace(); - } - - alignFrame = af; - this.av = av; - seqPanel = new SeqPanel(av, this); - idPanel = new IdPanel(av, this); - scalePanel = new ScalePanel(av, this); - idwidthAdjuster = new IdwidthAdjuster(this); - annotationPanel = new AnnotationPanel(this); - annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER); - - sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH); - alabels = new AnnotationLabels(this); - - setAnnotationVisible(av.isShowAnnotation()); - - idPanelHolder.add(idPanel, BorderLayout.CENTER); - idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); - annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); - scalePanelHolder.add(scalePanel, BorderLayout.CENTER); - seqPanelHolder.add(seqPanel, BorderLayout.CENTER); - - fontChanged(); - setScrollValues(0, 0); - - apvscroll.addAdjustmentListener(this); - hscroll.addAdjustmentListener(this); - vscroll.addAdjustmentListener(this); - - addComponentListener(new ComponentAdapter() - { - public void componentResized(ComponentEvent evt) - { - setScrollValues(av.getStartRes(), av.getStartSeq()); - if (getSize().height > 0 - && annotationPanelHolder.getSize().height > 0) - { - validateAnnotationDimensions(false); - } - repaint(); - } - - }); - - Dimension d = calculateIdWidth(); - idPanel.idCanvas.setSize(d); - - hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height); - - idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); - annotationSpaceFillerHolder.setSize(d.width, - annotationPanel.getSize().height); - alabels.setSize(d.width, annotationPanel.getSize().height); - final AlignmentPanel ap = this; - av.addPropertyChangeListener(new java.beans.PropertyChangeListener() - { - public void propertyChange(java.beans.PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals("alignment")) - { - PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true); - alignmentChanged(); - } - } - }); - } - - @Override - public AlignViewportI getAlignViewport() - { - return av; - } - public SequenceRenderer getSequenceRenderer() - { - return seqPanel.seqCanvas.sr; - } - @Override - public jalview.api.FeatureRenderer getFeatureRenderer() - { - return seqPanel.seqCanvas.fr; - } - @Override - public jalview.api.FeatureRenderer cloneFeatureRenderer() - { - FeatureRenderer nfr = new FeatureRenderer(av); - nfr.transferSettings(seqPanel.seqCanvas.fr); - return nfr; - } - public void alignmentChanged() - { - av.alignmentChanged(this); - - if (overviewPanel != null) - { - overviewPanel.updateOverviewImage(); - } - - alignFrame.updateEditMenuBar(); - - repaint(); - } - - public void fontChanged() - { - // set idCanvas bufferedImage to null - // to prevent drawing old image - idPanel.idCanvas.image = null; - FontMetrics fm = getFontMetrics(av.getFont()); - - scalePanel.setSize(new Dimension(10, av.getCharHeight() - + fm.getDescent())); - idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight() - + fm.getDescent())); - av.updateSequenceIdColours(); - annotationPanel.image = null; - int ap = annotationPanel.adjustPanelHeight(false); - Dimension d = calculateIdWidth(); - d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height); - alabels.setSize(d.width + 4, ap); - - idPanel.idCanvas.setSize(d); - hscrollFillerPanel.setSize(d); - - validateAnnotationDimensions(false); - annotationPanel.repaint(); - validate(); - repaint(); - - if (overviewPanel != null) - { - overviewPanel.updateOverviewImage(); - } - } - - public void setIdWidth(int w, int h) - { - idPanel.idCanvas.setSize(w, h); - idPanelHolder.setSize(w, idPanelHolder.getSize().height); - annotationSpaceFillerHolder.setSize(w, - annotationSpaceFillerHolder.getSize().height); - alabels.setSize(w, alabels.getSize().height); - validate(); - } - - Dimension calculateIdWidth() - { - if (av.nullFrame == null) - { - av.nullFrame = new JFrame(); - av.nullFrame.addNotify(); - } - - Graphics g = av.nullFrame.getGraphics(); - - FontMetrics fm = g.getFontMetrics(av.font); - AlignmentI al = av.getAlignment(); - - int i = 0; - int idWidth = 0; - String id; - while (i < al.getHeight() && al.getSequenceAt(i) != null) - { - SequenceI s = al.getSequenceAt(i); - id = s.getDisplayId(av.getShowJVSuffix()); - - if (fm.stringWidth(id) > idWidth) - { - idWidth = fm.stringWidth(id); - } - i++; - } - - // Also check annotation label widths - i = 0; - if (al.getAlignmentAnnotation() != null) - { - fm = g.getFontMetrics(av.nullFrame.getFont()); - while (i < al.getAlignmentAnnotation().length) - { - String label = al.getAlignmentAnnotation()[i].label; - if (fm.stringWidth(label) > idWidth) - { - idWidth = fm.stringWidth(label); - } - i++; - } - } - - return new Dimension(idWidth, idPanel.idCanvas.getSize().height); - } - - /** - * Highlight the given results on the alignment. - * - */ - public void highlightSearchResults(SearchResults results) - { - scrollToPosition(results); - seqPanel.seqCanvas.highlightSearchResults(results); - } - - /** - * scroll the view to show the position of the highlighted region in results - * (if any) and redraw the overview - * - * @param results - * @return false if results were not found - */ - public boolean scrollToPosition(SearchResults results) - { - return scrollToPosition(results, true); - } - - /** - * scroll the view to show the position of the highlighted region in results - * (if any) - * - * @param results - * @param redrawOverview - * - when set, the overview will be recalculated (takes longer) - * @return false if results were not found - */ - public boolean scrollToPosition(SearchResults results, - boolean redrawOverview) - { - return scrollToPosition(results, redrawOverview, false); - } - - /** - * scroll the view to show the position of the highlighted region in results - * (if any) - * - * @param results - * @param redrawOverview - * - when set, the overview will be recalculated (takes longer) - * @return false if results were not found - */ - public boolean scrollToPosition(SearchResults results, - boolean redrawOverview, boolean centre) - { - // do we need to scroll the panel? - if (results != null && results.getSize() > 0) - { - AlignmentI alignment = av.getAlignment(); - int seqIndex = alignment.findIndex(results); - if (seqIndex == -1) - { - return false; - } - SequenceI seq = alignment.getSequenceAt(seqIndex); - int[] r = results.getResults(seq, 0, alignment.getWidth()); - if (r == null) - { - if (JalviewLite.debug) - {// DEBUG - System.out - .println("DEBUG: scroll didn't happen - results not within alignment : " - + seq.getStart() + "," + seq.getEnd()); - } - return false; - } - if (JalviewLite.debug) - { - // DEBUG - /* - * System.out.println("DEBUG: scroll: start=" + r[0] + - * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] + - * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() + - * " hextent=" + hextent); - */ - } - int start = r[0]; - int end = r[1]; - - /* - * To centre results, scroll to positions half the visible width - * left/right of the start/end positions - */ - if (centre) - { - int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1; - start = Math.max(start - offset, 0); - end = Math.min(end + offset, seq.getEnd() - 1); - } - - if (start < 0) - { - return false; - } - if (end == seq.getEnd()) - { - return false; - } - return scrollTo(start, end, seqIndex, false, redrawOverview); - } - return true; - } - - public boolean scrollTo(int ostart, int end, int seqIndex, - boolean scrollToNearest, boolean redrawOverview) - { - int startv, endv, starts, ends, width; - - int start = -1; - if (av.hasHiddenColumns()) - { - start = av.getColumnSelection().findColumnPosition(ostart); - end = av.getColumnSelection().findColumnPosition(end); - if (start == end) - { - if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart)) - { - // don't scroll - position isn't visible - return false; - } - } - } - else - { - start = ostart; - } - if (!av.getWrapAlignment()) - { - /* - * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv = - * av.getStartRes()) >= start) { spos=start-1; // seqIn // - * setScrollValues(start - 1, seqIndex); } else if ((endv = - * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end - - * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts = - * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(), - * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) { - * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); } - */ - - // below is scrolling logic up to Jalview 2.8.2 - // if ((av.getStartRes() > end) - // || (av.getEndRes() < start) - // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex))) - // { - // if (start > av.getAlignment().getWidth() - hextent) - // { - // start = av.getAlignment().getWidth() - hextent; - // if (start < 0) - // { - // start = 0; - // } - // - // } - // if (seqIndex > av.getAlignment().getHeight() - vextent) - // { - // seqIndex = av.getAlignment().getHeight() - vextent; - // if (seqIndex < 0) - // { - // seqIndex = 0; - // } - // } - // setScrollValues(start, seqIndex); - // } - // logic copied from jalview.gui.AlignmentPanel: - if ((startv = av.getStartRes()) >= start) - { - /* - * Scroll left to make start of search results visible - */ - setScrollValues(start - 1, seqIndex); - } - else if ((endv = av.getEndRes()) <= end) - { - /* - * Scroll right to make end of search results visible - */ - setScrollValues(startv + 1 + end - endv, seqIndex); - } - else if ((starts = av.getStartSeq()) > seqIndex) - { - /* - * Scroll up to make start of search results visible - */ - setScrollValues(av.getStartRes(), seqIndex); - } - else if ((ends = av.getEndSeq()) <= seqIndex) - { - /* - * Scroll down to make end of search results visible - */ - setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); - } - /* - * Else results are already visible - no need to scroll - */ - } - else - { - scrollToWrappedVisible(start); - } - if (redrawOverview && overviewPanel != null) - { - overviewPanel.setBoxPosition(); - } - paintAlignment(redrawOverview); - return true; - } - - void scrollToWrappedVisible(int res) - { - int cwidth = seqPanel.seqCanvas - .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); - if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth)) - { - vscroll.setValue(res / cwidth); - av.startRes = vscroll.getValue() * cwidth; - } - } - - public OverviewPanel getOverviewPanel() - { - return overviewPanel; - } - - public void setOverviewPanel(OverviewPanel op) - { - overviewPanel = op; - } - - public void setAnnotationVisible(boolean b) - { - if (!av.getWrapAlignment()) - { - annotationSpaceFillerHolder.setVisible(b); - annotationPanelHolder.setVisible(b); - } - else - { - annotationSpaceFillerHolder.setVisible(false); - annotationPanelHolder.setVisible(false); - } - validate(); - repaint(); - } - - /** - * automatically adjust annotation panel height for new annotation whilst - * ensuring the alignment is still visible. - */ - public void adjustAnnotationHeight() - { - // TODO: display vertical annotation scrollbar if necessary - // this is called after loading new annotation onto alignment - if (alignFrame.getSize().height == 0) - { - System.out - .println("adjustAnnotationHeight frame size zero NEEDS FIXING"); - } - fontChanged(); - validateAnnotationDimensions(true); - apvscroll.addNotify(); - hscroll.addNotify(); - validate(); - paintAlignment(true); - } - - /** - * Calculate the annotation dimensions and refresh slider values accordingly. - * Need to do repaints/notifys afterwards. - */ - protected void validateAnnotationDimensions(boolean adjustPanelHeight) - { - int rowHeight = av.getCharHeight(); - int alignmentHeight = rowHeight * av.getAlignment().getHeight(); - int annotationHeight = av.calcPanelHeight(); - - int mheight = annotationHeight; - Dimension d = sequenceHolderPanel.getSize(); - - int availableHeight = d.height - scalePanelHolder.getHeight(); - - if (adjustPanelHeight) - { - /* - * If not enough vertical space, maximize annotation height while keeping - * at least two rows of alignment visible - */ - if (annotationHeight + alignmentHeight > availableHeight) - { - annotationHeight = Math.min(annotationHeight, availableHeight - 2 - * rowHeight); - } - } - else - { - // maintain same window layout whilst updating sliders - annotationHeight = annotationPanelHolder.getSize().height; - } - - if (availableHeight - annotationHeight < 5) - { - annotationHeight = availableHeight; - } - - annotationPanel.setSize(new Dimension(d.width, annotationHeight)); - annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight)); - // seqPanelHolder.setSize(d.width, seqandannot - height); - seqPanel.seqCanvas - .setSize(d.width, seqPanel.seqCanvas.getSize().height); - - Dimension e = idPanel.getSize(); - alabels.setSize(new Dimension(e.width, annotationHeight)); - annotationSpaceFillerHolder.setSize(new Dimension(e.width, - annotationHeight)); - - int s = apvscroll.getValue(); - if (s > mheight - annotationHeight) - { - s = 0; - } - apvscroll.setValues(s, annotationHeight, 0, mheight); - annotationPanel.setScrollOffset(apvscroll.getValue(), false); - alabels.setScrollOffset(apvscroll.getValue(), false); - } - - public void setWrapAlignment(boolean wrap) - { - av.startSeq = 0; - av.startRes = 0; - scalePanelHolder.setVisible(!wrap); - - hscroll.setVisible(!wrap); - idwidthAdjuster.setVisible(!wrap); - - if (wrap) - { - annotationPanelHolder.setVisible(false); - annotationSpaceFillerHolder.setVisible(false); - } - else if (av.isShowAnnotation()) - { - annotationPanelHolder.setVisible(true); - annotationSpaceFillerHolder.setVisible(true); - } - - idSpaceFillerPanel1.setVisible(!wrap); - - fontChanged(); // This is so that the scalePanel is resized correctly - - validate(); - sequenceHolderPanel.validate(); - repaint(); - - } - - int hextent = 0; - - int vextent = 0; - - // return value is true if the scroll is valid - public boolean scrollUp(boolean up) - { - if (up) - { - if (vscroll.getValue() < 1) - { - return false; - } - setScrollValues(hscroll.getValue(), vscroll.getValue() - 1); - } - else - { - if (vextent + vscroll.getValue() >= av.getAlignment().getHeight()) - { - return false; - } - setScrollValues(hscroll.getValue(), vscroll.getValue() + 1); - } - - repaint(); - return true; - } - - public boolean scrollRight(boolean right) - { - if (!right) - { - if (hscroll.getValue() < 1) - { - return false; - } - setScrollValues(hscroll.getValue() - 1, vscroll.getValue()); - } - else - { - if (hextent + hscroll.getValue() >= av.getAlignment().getWidth()) - { - return false; - } - setScrollValues(hscroll.getValue() + 1, vscroll.getValue()); - } - - repaint(); - return true; - } - - public void setScrollValues(int x, int y) - { - int width = av.getAlignment().getWidth(); - int height = av.getAlignment().getHeight(); - - if (av.hasHiddenColumns()) - { - width = av.getColumnSelection().findColumnPosition(width); - } - if (x < 0) - { - x = 0; - } - ; - - hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth(); - vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight(); - - if (hextent > width) - { - hextent = width; - } - - if (vextent > height) - { - vextent = height; - } - - if ((hextent + x) > width) - { - System.err.println("hextent was " + hextent + " and x was " + x); - - x = width - hextent; - } - - if ((vextent + y) > height) - { - y = height - vextent; - } - - if (y < 0) - { - y = 0; - } - - if (x < 0) - { - System.err.println("x was " + x); - x = 0; - } - - av.setStartSeq(y); - - int endSeq = y + vextent; - if (endSeq > av.getAlignment().getHeight()) - { - endSeq = av.getAlignment().getHeight(); - } - - av.setEndSeq(endSeq); - av.setStartRes(x); - av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av - .getCharWidth())) - 1); - - hscroll.setValues(x, hextent, 0, width); - vscroll.setValues(y, vextent, 0, height); - - if (overviewPanel != null) - { - overviewPanel.setBoxPosition(); - } - sendViewPosition(); - - } - - public void adjustmentValueChanged(AdjustmentEvent evt) - { - int oldX = av.getStartRes(); - int oldY = av.getStartSeq(); - - if (evt == null || evt.getSource() == apvscroll) - { - annotationPanel.setScrollOffset(apvscroll.getValue(), false); - alabels.setScrollOffset(apvscroll.getValue(), false); - // annotationPanel.image=null; - // alabels.image=null; - // alabels.repaint(); - // annotationPanel.repaint(); - } - if (evt == null || evt.getSource() == hscroll) - { - int x = hscroll.getValue(); - av.setStartRes(x); - av.setEndRes(x + seqPanel.seqCanvas.getSize().width - / av.getCharWidth() - 1); - } - - if (evt == null || evt.getSource() == vscroll) - { - int offy = vscroll.getValue(); - if (av.getWrapAlignment()) - { - int rowSize = seqPanel.seqCanvas - .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); - av.setStartRes(vscroll.getValue() * rowSize); - av.setEndRes((vscroll.getValue() + 1) * rowSize); - } - else - { - av.setStartSeq(offy); - av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height - / av.getCharHeight()); - } - } - - if (overviewPanel != null) - { - overviewPanel.setBoxPosition(); - } - - int scrollX = av.startRes - oldX; - int scrollY = av.startSeq - oldY; - - if (av.getWrapAlignment() || !fastPaint || av.MAC) - { - repaint(); - } - else - { - // Make sure we're not trying to draw a panel - // larger than the visible window - if (scrollX > av.endRes - av.startRes) - { - scrollX = av.endRes - av.startRes; - } - else if (scrollX < av.startRes - av.endRes) - { - scrollX = av.startRes - av.endRes; - } - - idPanel.idCanvas.fastPaint(scrollY); - seqPanel.seqCanvas.fastPaint(scrollX, scrollY); - - scalePanel.repaint(); - if (av.isShowAnnotation()) - { - annotationPanel.fastPaint(av.getStartRes() - oldX); - } - } - sendViewPosition(); - - /* - * If there is one, scroll the (Protein/cDNA) complementary alignment to - * match, unless we are ourselves doing that. - */ - if (isFollowingComplementScroll()) - { - setFollowingComplementScroll(false); - } - else - { - AlignmentPanel ap = getComplementPanel(); - av.scrollComplementaryAlignment(ap); - } - - } - - /** - * A helper method to return the AlignmentPanel in the other (complementary) - * half of a SplitFrame view. Returns null if not in a SplitFrame. - * - * @return - */ - private AlignmentPanel getComplementPanel() - { - AlignmentPanel ap = null; - if (alignFrame != null) - { - SplitFrame sf = alignFrame.getSplitFrame(); - if (sf != null) - { - AlignFrame other = sf.getComplement(alignFrame); - if (other != null) - { - ap = other.alignPanel; - } - } - } - return ap; - } - - /** - * Follow a scrolling change in the (cDNA/Protein) complementary alignment. - * The aim is to keep the two alignments 'lined up' on their centre columns. - * - * @param sr - * holds mapped region(s) of this alignment that we are scrolling - * 'to'; may be modified for sequence offset by this method - * @param seqOffset - * the number of visible sequences to show above the mapped region - */ - protected void scrollToCentre(SearchResults sr, int seqOffset) - { - /* - * To avoid jumpy vertical scrolling (if some sequences are gapped or not - * mapped), we can make the scroll-to location a sequence above the one - * actually mapped. - */ - SequenceI mappedTo = sr.getResultSequence(0); - List seqs = av.getAlignment().getSequences(); - - /* - * This is like AlignmentI.findIndex(seq) but here we are matching the - * dataset sequence not the aligned sequence - */ - int sequenceIndex = 0; - boolean matched = false; - for (SequenceI seq : seqs) - { - if (mappedTo == seq.getDatasetSequence()) - { - matched = true; - break; - } - sequenceIndex++; - } - if (!matched) - { - return; // failsafe, shouldn't happen - } - sequenceIndex = Math.max(0, sequenceIndex - seqOffset); - sr.getResults().get(0) - .setSequence(av.getAlignment().getSequenceAt(sequenceIndex)); - - /* - * Scroll to position but centring the target residue. Also set a state flag - * to prevent adjustmentValueChanged performing this recursively. - */ - setFollowingComplementScroll(true); - scrollToPosition(sr, true, true); - } - - private void sendViewPosition() - { - StructureSelectionManager.getStructureSelectionManager(av.applet) - .sendViewPosition(this, av.startRes, av.endRes, av.startSeq, - 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) - { - StructureSelectionManager.getStructureSelectionManager(av.applet) - .sequenceColoursChanged(this); - - if (overviewPanel != null) - { - overviewPanel.updateOverviewImage(); - } - } - } - - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - invalidate(); - Dimension d = idPanel.idCanvas.getSize(); - final int canvasHeight = seqPanel.seqCanvas.getSize().height; - if (canvasHeight != d.height) - { - idPanel.idCanvas.setSize(d.width, canvasHeight); - } - - if (av.getWrapAlignment()) - { - int maxwidth = av.getAlignment().getWidth(); - - if (av.hasHiddenColumns()) - { - maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; - } - - int canvasWidth = seqPanel.seqCanvas - .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); - - if (canvasWidth > 0) - { - int max = maxwidth / canvasWidth; - vscroll.setMaximum(1 + max); - vscroll.setUnitIncrement(1); - vscroll.setVisibleAmount(1); - } - } - else - { - setScrollValues(av.getStartRes(), av.getStartSeq()); - } - - seqPanel.seqCanvas.repaint(); - idPanel.idCanvas.repaint(); - if (!av.getWrapAlignment()) - { - if (av.isShowAnnotation()) - { - alabels.repaint(); - annotationPanel.repaint(); - } - scalePanel.repaint(); - } - - } - - protected JPanel sequenceHolderPanel = new JPanel(); - - protected JScrollBar vscroll = new JScrollBar(); - - protected JScrollBar hscroll = new JScrollBar(); - - protected JPanel seqPanelHolder = new JPanel(); - - protected JPanel scalePanelHolder = new JPanel(); - - protected JPanel idPanelHolder = new JPanel(); - - protected JPanel idSpaceFillerPanel1 = new JPanel(); - - public JPanel annotationSpaceFillerHolder = new JPanel(); - - protected JPanel hscrollFillerPanel = new JPanel(); - - JPanel annotationPanelHolder = new JPanel(); - - protected JScrollBar apvscroll = new JScrollBar(); - - /* - * Flag set while scrolling to follow complementary cDNA/protein scroll. When - * true, suppresses invoking the same method recursively. - */ - private boolean followingComplementScroll; - - private void jbInit() throws Exception - { - // idPanelHolder.setPreferredSize(new Dimension(70, 10)); - this.setLayout(new BorderLayout()); - - // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); - sequenceHolderPanel.setLayout(new BorderLayout()); - seqPanelHolder.setLayout(new BorderLayout()); - scalePanelHolder.setBackground(Color.white); - - // scalePanelHolder.setPreferredSize(new Dimension(10, 30)); - scalePanelHolder.setLayout(new BorderLayout()); - idPanelHolder.setLayout(new BorderLayout()); - idSpaceFillerPanel1.setBackground(Color.white); - - // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); - idSpaceFillerPanel1.setLayout(new BorderLayout()); - annotationSpaceFillerHolder.setBackground(Color.white); - - // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); - annotationSpaceFillerHolder.setLayout(new BorderLayout()); - hscroll.setOrientation(JScrollBar.HORIZONTAL); - - JPanel hscrollHolder = new JPanel(); - hscrollHolder.setLayout(new BorderLayout()); - hscrollFillerPanel.setBackground(Color.white); - apvscroll.setOrientation(JScrollBar.VERTICAL); - apvscroll.setVisible(true); - apvscroll.addAdjustmentListener(this); - - annotationPanelHolder.setBackground(Color.white); - annotationPanelHolder.setLayout(new BorderLayout()); - annotationPanelHolder.add(apvscroll, BorderLayout.EAST); - // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); - hscrollHolder.setBackground(Color.white); - - // annotationScroller.setPreferredSize(new Dimension(10, 80)); - // this.setPreferredSize(new Dimension(220, 166)); - seqPanelHolder.setBackground(Color.white); - idPanelHolder.setBackground(Color.white); - sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); - sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); - seqPanelHolder.add(vscroll, BorderLayout.EAST); - - // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH); - this.add(idPanelHolder, BorderLayout.WEST); - idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH); - idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH); - this.add(hscrollHolder, BorderLayout.SOUTH); - hscrollHolder.add(hscroll, BorderLayout.CENTER); - hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST); - this.add(sequenceHolderPanel, BorderLayout.CENTER); - } - - /** - * hides or shows dynamic annotation rows based on groups and av state flags - */ - public void updateAnnotation() - { - updateAnnotation(false); - } - - public void updateAnnotation(boolean applyGlobalSettings) - { - updateAnnotation(applyGlobalSettings, false); - } - - public void updateAnnotation(boolean applyGlobalSettings, - boolean preserveNewGroupSettings) - { - av.updateGroupAnnotationSettings(applyGlobalSettings, - preserveNewGroupSettings); - adjustAnnotationHeight(); - } - - @Override - public AlignmentI getAlignment() - { - return av.getAlignment(); - } - - @Override - public String getViewName() - { - return getName(); - } - - @Override - public StructureSelectionManager getStructureSelectionManager() - { - return StructureSelectionManager - .getStructureSelectionManager(av.applet); - } - - @Override - public void raiseOOMWarning(String string, OutOfMemoryError error) - { - // TODO: JAL-960 - System.err.println("Out of memory whilst '" + string + "'"); - error.printStackTrace(); - } - - /** - * Set a flag to say we are scrolling to follow a (cDNA/protein) complement. - * - * @param b - */ - protected void setFollowingComplementScroll(boolean b) - { - this.followingComplementScroll = b; - } - - protected boolean isFollowingComplementScroll() - { - return this.followingComplementScroll; - } - -} +/* + * 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.appletgui; + +import jalview.analysis.AnnotationSorter; +import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; +import jalview.bin.JalviewLite; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SearchResults; +import jalview.datamodel.SequenceI; +import jalview.structure.StructureSelectionManager; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.util.List; + +import javax.swing.JPanel; +import javax.swing.JFrame; +import javax.swing.JScrollBar; + +public class AlignmentPanel extends JPanel implements AdjustmentListener, + AlignmentViewPanel +{ + + public AlignViewport av; + + OverviewPanel overviewPanel; + + SeqPanel seqPanel; + + IdPanel idPanel; + + IdwidthAdjuster idwidthAdjuster; + + public AlignFrame alignFrame; + + ScalePanel scalePanel; + + AnnotationPanel annotationPanel; + + AnnotationLabels alabels; + + // this value is set false when selection area being dragged + boolean fastPaint = true; + + public void finalize() + { + alignFrame = null; + av = null; + seqPanel = null; + seqPanelHolder = null; + sequenceHolderPanel = null; + scalePanel = null; + scalePanelHolder = null; + annotationPanel = null; + annotationPanelHolder = null; + annotationSpaceFillerHolder = null; + } + + public AlignmentPanel(AlignFrame af, final AlignViewport av) + { + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + + alignFrame = af; + this.av = av; + seqPanel = new SeqPanel(av, this); + idPanel = new IdPanel(av, this); + scalePanel = new ScalePanel(av, this); + idwidthAdjuster = new IdwidthAdjuster(this); + annotationPanel = new AnnotationPanel(this); + annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER); + + sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH); + alabels = new AnnotationLabels(this); + + setAnnotationVisible(av.isShowAnnotation()); + + idPanelHolder.add(idPanel, BorderLayout.CENTER); + idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); + annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); + scalePanelHolder.add(scalePanel, BorderLayout.CENTER); + seqPanelHolder.add(seqPanel, BorderLayout.CENTER); + + fontChanged(); + setScrollValues(0, 0); + + apvscroll.addAdjustmentListener(this); + hscroll.addAdjustmentListener(this); + vscroll.addAdjustmentListener(this); + + addComponentListener(new ComponentAdapter() + { + public void componentResized(ComponentEvent evt) + { + setScrollValues(av.getStartRes(), av.getStartSeq()); + if (getSize().height > 0 + && annotationPanelHolder.getSize().height > 0) + { + validateAnnotationDimensions(false); + } + repaint(); + } + + }); + + Dimension d = calculateIdWidth(); + idPanel.idCanvas.setSize(d); + + hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height); + + idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); + annotationSpaceFillerHolder.setSize(d.width, + annotationPanel.getSize().height); + alabels.setSize(d.width, annotationPanel.getSize().height); + final AlignmentPanel ap = this; + av.addPropertyChangeListener(new java.beans.PropertyChangeListener() + { + public void propertyChange(java.beans.PropertyChangeEvent evt) + { + if (evt.getPropertyName().equals("alignment")) + { + PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true); + alignmentChanged(); + } + } + }); + } + + @Override + public AlignViewportI getAlignViewport() + { + return av; + } + public SequenceRenderer getSequenceRenderer() + { + return seqPanel.seqCanvas.sr; + } + @Override + public jalview.api.FeatureRenderer getFeatureRenderer() + { + return seqPanel.seqCanvas.fr; + } + @Override + public jalview.api.FeatureRenderer cloneFeatureRenderer() + { + FeatureRenderer nfr = new FeatureRenderer(av); + nfr.transferSettings(seqPanel.seqCanvas.fr); + return nfr; + } + public void alignmentChanged() + { + av.alignmentChanged(this); + + if (overviewPanel != null) + { + overviewPanel.updateOverviewImage(); + } + + alignFrame.updateEditMenuBar(); + + repaint(); + } + + public void fontChanged() + { + // set idCanvas bufferedImage to null + // to prevent drawing old image + idPanel.idCanvas.image = null; + FontMetrics fm = getFontMetrics(av.getFont()); + + scalePanel.setSize(new Dimension(10, av.getCharHeight() + + fm.getDescent())); + idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight() + + fm.getDescent())); + av.updateSequenceIdColours(); + annotationPanel.image = null; + int ap = annotationPanel.adjustPanelHeight(false); + Dimension d = calculateIdWidth(); + d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height); + alabels.setSize(d.width + 4, ap); + + idPanel.idCanvas.setSize(d); + hscrollFillerPanel.setSize(d); + + validateAnnotationDimensions(false); + annotationPanel.repaint(); + validate(); + repaint(); + + if (overviewPanel != null) + { + overviewPanel.updateOverviewImage(); + } + } + + public void setIdWidth(int w, int h) + { + idPanel.idCanvas.setSize(w, h); + idPanelHolder.setSize(w, idPanelHolder.getSize().height); + annotationSpaceFillerHolder.setSize(w, + annotationSpaceFillerHolder.getSize().height); + alabels.setSize(w, alabels.getSize().height); + validate(); + } + + Dimension calculateIdWidth() + { + if (av.nullFrame == null) + { + av.nullFrame = new JFrame(); + av.nullFrame.addNotify(); + } + + Graphics g = av.nullFrame.getGraphics(); + + FontMetrics fm = g.getFontMetrics(av.font); + AlignmentI al = av.getAlignment(); + + int i = 0; + int idWidth = 0; + String id; + while (i < al.getHeight() && al.getSequenceAt(i) != null) + { + SequenceI s = al.getSequenceAt(i); + id = s.getDisplayId(av.getShowJVSuffix()); + + if (fm.stringWidth(id) > idWidth) + { + idWidth = fm.stringWidth(id); + } + i++; + } + + // Also check annotation label widths + i = 0; + if (al.getAlignmentAnnotation() != null) + { + fm = g.getFontMetrics(av.nullFrame.getFont()); + while (i < al.getAlignmentAnnotation().length) + { + String label = al.getAlignmentAnnotation()[i].label; + if (fm.stringWidth(label) > idWidth) + { + idWidth = fm.stringWidth(label); + } + i++; + } + } + + return new Dimension(idWidth, idPanel.idCanvas.getSize().height); + } + + /** + * Highlight the given results on the alignment. + * + */ + public void highlightSearchResults(SearchResults results) + { + scrollToPosition(results); + seqPanel.seqCanvas.highlightSearchResults(results); + } + + /** + * scroll the view to show the position of the highlighted region in results + * (if any) and redraw the overview + * + * @param results + * @return false if results were not found + */ + public boolean scrollToPosition(SearchResults results) + { + return scrollToPosition(results, true); + } + + /** + * scroll the view to show the position of the highlighted region in results + * (if any) + * + * @param results + * @param redrawOverview + * - when set, the overview will be recalculated (takes longer) + * @return false if results were not found + */ + public boolean scrollToPosition(SearchResults results, + boolean redrawOverview) + { + return scrollToPosition(results, redrawOverview, false); + } + + /** + * scroll the view to show the position of the highlighted region in results + * (if any) + * + * @param results + * @param redrawOverview + * - when set, the overview will be recalculated (takes longer) + * @return false if results were not found + */ + public boolean scrollToPosition(SearchResults results, + boolean redrawOverview, boolean centre) + { + // do we need to scroll the panel? + if (results != null && results.getSize() > 0) + { + AlignmentI alignment = av.getAlignment(); + int seqIndex = alignment.findIndex(results); + if (seqIndex == -1) + { + return false; + } + SequenceI seq = alignment.getSequenceAt(seqIndex); + int[] r = results.getResults(seq, 0, alignment.getWidth()); + if (r == null) + { + if (JalviewLite.debug) + {// DEBUG + System.out + .println("DEBUG: scroll didn't happen - results not within alignment : " + + seq.getStart() + "," + seq.getEnd()); + } + return false; + } + if (JalviewLite.debug) + { + // DEBUG + /* + * System.out.println("DEBUG: scroll: start=" + r[0] + + * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] + + * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() + + * " hextent=" + hextent); + */ + } + int start = r[0]; + int end = r[1]; + + /* + * To centre results, scroll to positions half the visible width + * left/right of the start/end positions + */ + if (centre) + { + int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1; + start = Math.max(start - offset, 0); + end = Math.min(end + offset, seq.getEnd() - 1); + } + + if (start < 0) + { + return false; + } + if (end == seq.getEnd()) + { + return false; + } + return scrollTo(start, end, seqIndex, false, redrawOverview); + } + return true; + } + + public boolean scrollTo(int ostart, int end, int seqIndex, + boolean scrollToNearest, boolean redrawOverview) + { + int startv, endv, starts, ends, width; + + int start = -1; + if (av.hasHiddenColumns()) + { + start = av.getColumnSelection().findColumnPosition(ostart); + end = av.getColumnSelection().findColumnPosition(end); + if (start == end) + { + if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart)) + { + // don't scroll - position isn't visible + return false; + } + } + } + else + { + start = ostart; + } + if (!av.getWrapAlignment()) + { + /* + * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv = + * av.getStartRes()) >= start) { spos=start-1; // seqIn // + * setScrollValues(start - 1, seqIndex); } else if ((endv = + * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end - + * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts = + * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(), + * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) { + * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); } + */ + + // below is scrolling logic up to Jalview 2.8.2 + // if ((av.getStartRes() > end) + // || (av.getEndRes() < start) + // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex))) + // { + // if (start > av.getAlignment().getWidth() - hextent) + // { + // start = av.getAlignment().getWidth() - hextent; + // if (start < 0) + // { + // start = 0; + // } + // + // } + // if (seqIndex > av.getAlignment().getHeight() - vextent) + // { + // seqIndex = av.getAlignment().getHeight() - vextent; + // if (seqIndex < 0) + // { + // seqIndex = 0; + // } + // } + // setScrollValues(start, seqIndex); + // } + // logic copied from jalview.gui.AlignmentPanel: + if ((startv = av.getStartRes()) >= start) + { + /* + * Scroll left to make start of search results visible + */ + setScrollValues(start - 1, seqIndex); + } + else if ((endv = av.getEndRes()) <= end) + { + /* + * Scroll right to make end of search results visible + */ + setScrollValues(startv + 1 + end - endv, seqIndex); + } + else if ((starts = av.getStartSeq()) > seqIndex) + { + /* + * Scroll up to make start of search results visible + */ + setScrollValues(av.getStartRes(), seqIndex); + } + else if ((ends = av.getEndSeq()) <= seqIndex) + { + /* + * Scroll down to make end of search results visible + */ + setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); + } + /* + * Else results are already visible - no need to scroll + */ + } + else + { + scrollToWrappedVisible(start); + } + if (redrawOverview && overviewPanel != null) + { + overviewPanel.setBoxPosition(); + } + paintAlignment(redrawOverview); + return true; + } + + void scrollToWrappedVisible(int res) + { + int cwidth = seqPanel.seqCanvas + .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); + if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth)) + { + vscroll.setValue(res / cwidth); + av.startRes = vscroll.getValue() * cwidth; + } + } + + public OverviewPanel getOverviewPanel() + { + return overviewPanel; + } + + public void setOverviewPanel(OverviewPanel op) + { + overviewPanel = op; + } + + public void setAnnotationVisible(boolean b) + { + if (!av.getWrapAlignment()) + { + annotationSpaceFillerHolder.setVisible(b); + annotationPanelHolder.setVisible(b); + } + else + { + annotationSpaceFillerHolder.setVisible(false); + annotationPanelHolder.setVisible(false); + } + validate(); + repaint(); + } + + /** + * automatically adjust annotation panel height for new annotation whilst + * ensuring the alignment is still visible. + */ + public void adjustAnnotationHeight() + { + // TODO: display vertical annotation scrollbar if necessary + // this is called after loading new annotation onto alignment + if (alignFrame.getSize().height == 0) + { + System.out + .println("adjustAnnotationHeight frame size zero NEEDS FIXING"); + } + fontChanged(); + validateAnnotationDimensions(true); + apvscroll.addNotify(); + hscroll.addNotify(); + validate(); + paintAlignment(true); + } + + /** + * Calculate the annotation dimensions and refresh slider values accordingly. + * Need to do repaints/notifys afterwards. + */ + protected void validateAnnotationDimensions(boolean adjustPanelHeight) + { + int rowHeight = av.getCharHeight(); + int alignmentHeight = rowHeight * av.getAlignment().getHeight(); + int annotationHeight = av.calcPanelHeight(); + + int mheight = annotationHeight; + Dimension d = sequenceHolderPanel.getSize(); + + int availableHeight = d.height - scalePanelHolder.getHeight(); + + if (adjustPanelHeight) + { + /* + * If not enough vertical space, maximize annotation height while keeping + * at least two rows of alignment visible + */ + if (annotationHeight + alignmentHeight > availableHeight) + { + annotationHeight = Math.min(annotationHeight, availableHeight - 2 + * rowHeight); + } + } + else + { + // maintain same window layout whilst updating sliders + annotationHeight = annotationPanelHolder.getSize().height; + } + + if (availableHeight - annotationHeight < 5) + { + annotationHeight = availableHeight; + } + + annotationPanel.setSize(new Dimension(d.width, annotationHeight)); + annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight)); + // seqPanelHolder.setSize(d.width, seqandannot - height); + seqPanel.seqCanvas + .setSize(d.width, seqPanel.seqCanvas.getSize().height); + + Dimension e = idPanel.getSize(); + alabels.setSize(new Dimension(e.width, annotationHeight)); + annotationSpaceFillerHolder.setSize(new Dimension(e.width, + annotationHeight)); + + int s = apvscroll.getValue(); + if (s > mheight - annotationHeight) + { + s = 0; + } + apvscroll.setValues(s, annotationHeight, 0, mheight); + annotationPanel.setScrollOffset(apvscroll.getValue(), false); + alabels.setScrollOffset(apvscroll.getValue(), false); + } + + public void setWrapAlignment(boolean wrap) + { + av.startSeq = 0; + av.startRes = 0; + scalePanelHolder.setVisible(!wrap); + + hscroll.setVisible(!wrap); + idwidthAdjuster.setVisible(!wrap); + + if (wrap) + { + annotationPanelHolder.setVisible(false); + annotationSpaceFillerHolder.setVisible(false); + } + else if (av.isShowAnnotation()) + { + annotationPanelHolder.setVisible(true); + annotationSpaceFillerHolder.setVisible(true); + } + + idSpaceFillerPanel1.setVisible(!wrap); + + fontChanged(); // This is so that the scalePanel is resized correctly + + validate(); + sequenceHolderPanel.validate(); + repaint(); + + } + + int hextent = 0; + + int vextent = 0; + + // return value is true if the scroll is valid + public boolean scrollUp(boolean up) + { + if (up) + { + if (vscroll.getValue() < 1) + { + return false; + } + setScrollValues(hscroll.getValue(), vscroll.getValue() - 1); + } + else + { + if (vextent + vscroll.getValue() >= av.getAlignment().getHeight()) + { + return false; + } + setScrollValues(hscroll.getValue(), vscroll.getValue() + 1); + } + + repaint(); + return true; + } + + public boolean scrollRight(boolean right) + { + if (!right) + { + if (hscroll.getValue() < 1) + { + return false; + } + setScrollValues(hscroll.getValue() - 1, vscroll.getValue()); + } + else + { + if (hextent + hscroll.getValue() >= av.getAlignment().getWidth()) + { + return false; + } + setScrollValues(hscroll.getValue() + 1, vscroll.getValue()); + } + + repaint(); + return true; + } + + public void setScrollValues(int x, int y) + { + int width = av.getAlignment().getWidth(); + int height = av.getAlignment().getHeight(); + + if (av.hasHiddenColumns()) + { + width = av.getColumnSelection().findColumnPosition(width); + } + if (x < 0) + { + x = 0; + } + ; + + hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth(); + vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight(); + + if (hextent > width) + { + hextent = width; + } + + if (vextent > height) + { + vextent = height; + } + + if ((hextent + x) > width) + { + System.err.println("hextent was " + hextent + " and x was " + x); + + x = width - hextent; + } + + if ((vextent + y) > height) + { + y = height - vextent; + } + + if (y < 0) + { + y = 0; + } + + if (x < 0) + { + System.err.println("x was " + x); + x = 0; + } + + av.setStartSeq(y); + + int endSeq = y + vextent; + if (endSeq > av.getAlignment().getHeight()) + { + endSeq = av.getAlignment().getHeight(); + } + + av.setEndSeq(endSeq); + av.setStartRes(x); + av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av + .getCharWidth())) - 1); + + hscroll.setValues(x, hextent, 0, width); + vscroll.setValues(y, vextent, 0, height); + + if (overviewPanel != null) + { + overviewPanel.setBoxPosition(); + } + sendViewPosition(); + + } + + public void adjustmentValueChanged(AdjustmentEvent evt) + { + int oldX = av.getStartRes(); + int oldY = av.getStartSeq(); + + if (evt == null || evt.getSource() == apvscroll) + { + annotationPanel.setScrollOffset(apvscroll.getValue(), false); + alabels.setScrollOffset(apvscroll.getValue(), false); + // annotationPanel.image=null; + // alabels.image=null; + // alabels.repaint(); + // annotationPanel.repaint(); + } + if (evt == null || evt.getSource() == hscroll) + { + int x = hscroll.getValue(); + av.setStartRes(x); + av.setEndRes(x + seqPanel.seqCanvas.getSize().width + / av.getCharWidth() - 1); + } + + if (evt == null || evt.getSource() == vscroll) + { + int offy = vscroll.getValue(); + if (av.getWrapAlignment()) + { + int rowSize = seqPanel.seqCanvas + .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); + av.setStartRes(vscroll.getValue() * rowSize); + av.setEndRes((vscroll.getValue() + 1) * rowSize); + } + else + { + av.setStartSeq(offy); + av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height + / av.getCharHeight()); + } + } + + if (overviewPanel != null) + { + overviewPanel.setBoxPosition(); + } + + int scrollX = av.startRes - oldX; + int scrollY = av.startSeq - oldY; + + if (av.getWrapAlignment() || !fastPaint || av.MAC) + { + repaint(); + } + else + { + // Make sure we're not trying to draw a panel + // larger than the visible window + if (scrollX > av.endRes - av.startRes) + { + scrollX = av.endRes - av.startRes; + } + else if (scrollX < av.startRes - av.endRes) + { + scrollX = av.startRes - av.endRes; + } + + idPanel.idCanvas.fastPaint(scrollY); + seqPanel.seqCanvas.fastPaint(scrollX, scrollY); + + scalePanel.repaint(); + if (av.isShowAnnotation()) + { + annotationPanel.fastPaint(av.getStartRes() - oldX); + } + } + sendViewPosition(); + + /* + * If there is one, scroll the (Protein/cDNA) complementary alignment to + * match, unless we are ourselves doing that. + */ + if (isFollowingComplementScroll()) + { + setFollowingComplementScroll(false); + } + else + { + AlignmentPanel ap = getComplementPanel(); + av.scrollComplementaryAlignment(ap); + } + + } + + /** + * A helper method to return the AlignmentPanel in the other (complementary) + * half of a SplitFrame view. Returns null if not in a SplitFrame. + * + * @return + */ + private AlignmentPanel getComplementPanel() + { + AlignmentPanel ap = null; + if (alignFrame != null) + { + SplitFrame sf = alignFrame.getSplitFrame(); + if (sf != null) + { + AlignFrame other = sf.getComplement(alignFrame); + if (other != null) + { + ap = other.alignPanel; + } + } + } + return ap; + } + + /** + * Follow a scrolling change in the (cDNA/Protein) complementary alignment. + * The aim is to keep the two alignments 'lined up' on their centre columns. + * + * @param sr + * holds mapped region(s) of this alignment that we are scrolling + * 'to'; may be modified for sequence offset by this method + * @param seqOffset + * the number of visible sequences to show above the mapped region + */ + protected void scrollToCentre(SearchResults sr, int seqOffset) + { + /* + * To avoid jumpy vertical scrolling (if some sequences are gapped or not + * mapped), we can make the scroll-to location a sequence above the one + * actually mapped. + */ + SequenceI mappedTo = sr.getResultSequence(0); + List seqs = av.getAlignment().getSequences(); + + /* + * This is like AlignmentI.findIndex(seq) but here we are matching the + * dataset sequence not the aligned sequence + */ + int sequenceIndex = 0; + boolean matched = false; + for (SequenceI seq : seqs) + { + if (mappedTo == seq.getDatasetSequence()) + { + matched = true; + break; + } + sequenceIndex++; + } + if (!matched) + { + return; // failsafe, shouldn't happen + } + sequenceIndex = Math.max(0, sequenceIndex - seqOffset); + sr.getResults().get(0) + .setSequence(av.getAlignment().getSequenceAt(sequenceIndex)); + + /* + * Scroll to position but centring the target residue. Also set a state flag + * to prevent adjustmentValueChanged performing this recursively. + */ + setFollowingComplementScroll(true); + scrollToPosition(sr, true, true); + } + + private void sendViewPosition() + { + StructureSelectionManager.getStructureSelectionManager(av.applet) + .sendViewPosition(this, av.startRes, av.endRes, av.startSeq, + 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) + { + StructureSelectionManager.getStructureSelectionManager(av.applet) + .sequenceColoursChanged(this); + + if (overviewPanel != null) + { + overviewPanel.updateOverviewImage(); + } + } + } + + public void update(Graphics g) + { + paint(g); + } + + public void paint(Graphics g) + { + invalidate(); + Dimension d = idPanel.idCanvas.getSize(); + final int canvasHeight = seqPanel.seqCanvas.getSize().height; + if (canvasHeight != d.height) + { + idPanel.idCanvas.setSize(d.width, canvasHeight); + } + + if (av.getWrapAlignment()) + { + int maxwidth = av.getAlignment().getWidth(); + + if (av.hasHiddenColumns()) + { + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + } + + int canvasWidth = seqPanel.seqCanvas + .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); + + if (canvasWidth > 0) + { + int max = maxwidth / canvasWidth; + vscroll.setMaximum(1 + max); + vscroll.setUnitIncrement(1); + vscroll.setVisibleAmount(1); + } + } + else + { + setScrollValues(av.getStartRes(), av.getStartSeq()); + } + + seqPanel.seqCanvas.repaint(); + idPanel.idCanvas.repaint(); + if (!av.getWrapAlignment()) + { + if (av.isShowAnnotation()) + { + alabels.repaint(); + annotationPanel.repaint(); + } + scalePanel.repaint(); + } + + } + + protected JPanel sequenceHolderPanel = new JPanel(); + + protected JScrollBar vscroll = new JScrollBar(); + + protected JScrollBar hscroll = new JScrollBar(); + + protected JPanel seqPanelHolder = new JPanel(); + + protected JPanel scalePanelHolder = new JPanel(); + + protected JPanel idPanelHolder = new JPanel(); + + protected JPanel idSpaceFillerPanel1 = new JPanel(); + + public JPanel annotationSpaceFillerHolder = new JPanel(); + + protected JPanel hscrollFillerPanel = new JPanel(); + + JPanel annotationPanelHolder = new JPanel(); + + protected JScrollBar apvscroll = new JScrollBar(); + + /* + * Flag set while scrolling to follow complementary cDNA/protein scroll. When + * true, suppresses invoking the same method recursively. + */ + private boolean followingComplementScroll; + + private void jbInit() throws Exception + { + // idPanelHolder.setPreferredSize(new Dimension(70, 10)); + this.setLayout(new BorderLayout()); + + // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); + sequenceHolderPanel.setLayout(new BorderLayout()); + seqPanelHolder.setLayout(new BorderLayout()); + scalePanelHolder.setBackground(Color.white); + + // scalePanelHolder.setPreferredSize(new Dimension(10, 30)); + scalePanelHolder.setLayout(new BorderLayout()); + idPanelHolder.setLayout(new BorderLayout()); + idSpaceFillerPanel1.setBackground(Color.white); + + // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); + idSpaceFillerPanel1.setLayout(new BorderLayout()); + annotationSpaceFillerHolder.setBackground(Color.white); + + // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); + annotationSpaceFillerHolder.setLayout(new BorderLayout()); + hscroll.setOrientation(JScrollBar.HORIZONTAL); + + JPanel hscrollHolder = new JPanel(); + hscrollHolder.setLayout(new BorderLayout()); + hscrollFillerPanel.setBackground(Color.white); + apvscroll.setOrientation(JScrollBar.VERTICAL); + apvscroll.setVisible(true); + apvscroll.addAdjustmentListener(this); + + annotationPanelHolder.setBackground(Color.white); + annotationPanelHolder.setLayout(new BorderLayout()); + annotationPanelHolder.add(apvscroll, BorderLayout.EAST); + // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); + hscrollHolder.setBackground(Color.white); + + // annotationScroller.setPreferredSize(new Dimension(10, 80)); + // this.setPreferredSize(new Dimension(220, 166)); + seqPanelHolder.setBackground(Color.white); + idPanelHolder.setBackground(Color.white); + sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); + sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); + seqPanelHolder.add(vscroll, BorderLayout.EAST); + + // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH); + this.add(idPanelHolder, BorderLayout.WEST); + idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH); + idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH); + this.add(hscrollHolder, BorderLayout.SOUTH); + hscrollHolder.add(hscroll, BorderLayout.CENTER); + hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST); + this.add(sequenceHolderPanel, BorderLayout.CENTER); + } + + /** + * hides or shows dynamic annotation rows based on groups and av state flags + */ + public void updateAnnotation() + { + updateAnnotation(false); + } + + public void updateAnnotation(boolean applyGlobalSettings) + { + updateAnnotation(applyGlobalSettings, false); + } + + public void updateAnnotation(boolean applyGlobalSettings, + boolean preserveNewGroupSettings) + { + av.updateGroupAnnotationSettings(applyGlobalSettings, + preserveNewGroupSettings); + adjustAnnotationHeight(); + } + + @Override + public AlignmentI getAlignment() + { + return av.getAlignment(); + } + + @Override + public String getViewName() + { + return getName(); + } + + @Override + public StructureSelectionManager getStructureSelectionManager() + { + return StructureSelectionManager + .getStructureSelectionManager(av.applet); + } + + @Override + public void raiseOOMWarning(String string, OutOfMemoryError error) + { + // TODO: JAL-960 + System.err.println("Out of memory whilst '" + string + "'"); + error.printStackTrace(); + } + + /** + * Set a flag to say we are scrolling to follow a (cDNA/protein) complement. + * + * @param b + */ + protected void setFollowingComplementScroll(boolean b) + { + this.followingComplementScroll = b; + } + + protected boolean isFollowingComplementScroll() + { + return this.followingComplementScroll; + } + +} diff --git a/unused/appletgui/AnnotationColourChooser.java b/unused/appletgui/AnnotationColourChooser.java index d98154a..ef66226 100644 --- a/unused/appletgui/AnnotationColourChooser.java +++ b/unused/appletgui/AnnotationColourChooser.java @@ -1,581 +1,581 @@ -/* - * 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. - * - * 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 . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.appletgui; - -import jalview.bin.JalviewLite; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.GraphLine; -import jalview.datamodel.SequenceGroup; -import jalview.schemes.AnnotationColourGradient; -import jalview.schemes.ColourSchemeI; -import jalview.util.MessageManager; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.AdjustmentEvent; -import java.awt.event.AdjustmentListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.Hashtable; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JScrollBar; -import javax.swing.JTextField; - -public class AnnotationColourChooser extends JPanel implements - ActionListener, AdjustmentListener, ItemListener, MouseListener -{ - JFrame frame; - - AlignViewport av; - - AlignmentPanel ap; - - ColourSchemeI oldcs; - - Hashtable oldgroupColours; - - AlignmentAnnotation currentAnnotation; - - boolean adjusting = false; - - public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap) - { - try - { - jbInit(); - } catch (Exception ex) - { - } - - oldcs = av.getGlobalColourScheme(); - if (av.getAlignment().getGroups() != null) - { - oldgroupColours = new Hashtable(); - for (SequenceGroup sg : ap.av.getAlignment().getGroups()) - { - if (sg.cs != null) - { - oldgroupColours.put(sg, sg.cs); - } - else - { - oldgroupColours.put(sg, "null"); - } - } - } - this.av = av; - this.ap = ap; - - slider.addAdjustmentListener(this); - slider.addMouseListener(this); - - if (av.getAlignment().getAlignmentAnnotation() == null) - { - return; - } - - setDefaultMinMax(); - - adjusting = true; - if (oldcs instanceof AnnotationColourGradient) - { - AnnotationColourGradient acg = (AnnotationColourGradient) oldcs; - currentColours.setSelected(acg.isPredefinedColours() - || acg.getBaseColour() != null); - if (!acg.isPredefinedColours() && acg.getBaseColour() == null) - { - minColour.setBackground(acg.getMinColour()); - maxColour.setBackground(acg.getMaxColour()); - } - // seqAssociated.setState(acg.isSeqAssociated()); - } - - Vector list = new Vector(); - int index = 1; - for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++) - { - String label = av.getAlignment().getAlignmentAnnotation()[i].label; - if (!list.contains(label)) - { - list.addElement(label); - } - else - { - list.addElement(label + "_" + (index++)); - } - } - - for (int i = 0; i < list.size(); i++) - { - annotations.addItem(list.elementAt(i).toString()); - } - - threshold.addItem(MessageManager - .getString("label.threshold_feature_no_thereshold")); - threshold.addItem(MessageManager - .getString("label.threshold_feature_above_thereshold")); - threshold.addItem(MessageManager - .getString("label.threshold_feature_below_thereshold")); - - if (oldcs instanceof AnnotationColourGradient) - { - AnnotationColourGradient acg = (AnnotationColourGradient) oldcs; - annotations.select(acg.getAnnotation()); - switch (acg.getAboveThreshold()) - { - case AnnotationColourGradient.NO_THRESHOLD: - threshold.select(0); - break; - case AnnotationColourGradient.ABOVE_THRESHOLD: - threshold.select(1); - break; - case AnnotationColourGradient.BELOW_THRESHOLD: - threshold.select(1); - break; - default: - throw new Error( - MessageManager - .getString("error.implementation_error_dont_know_thereshold_annotationcolourgradient")); - } - thresholdIsMin.setSelected(acg.thresholdIsMinMax); - thresholdValue.setText("" + acg.getAnnotationThreshold()); - } - - adjusting = false; - - changeColour(); - - frame = new JFrame(); - frame.add(this); - JalviewLite.addFrame(frame, - MessageManager.getString("label.colour_by_annotation"), 560, - 175); - validate(); - } - - private void setDefaultMinMax() - { - minColour.setBackground(av.applet.getDefaultColourParameter( - "ANNOTATIONCOLOUR_MIN", Color.orange)); - maxColour.setBackground(av.applet.getDefaultColourParameter( - "ANNOTATIONCOLOUR_MAX", Color.red)); - - } - - public AnnotationColourChooser() - { - try - { - jbInit(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private void jbInit() throws Exception - { - minColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - minColour.setLabel(MessageManager.getString("label.min_colour")); - minColour.addActionListener(this); - - maxColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - maxColour.setLabel(MessageManager.getString("label.max_colour")); - maxColour.addActionListener(this); - - thresholdIsMin.addItemListener(this); - ok.setLabel(MessageManager.getString("action.ok")); - ok.addActionListener(this); - - cancel.setLabel(MessageManager.getString("action.cancel")); - cancel.addActionListener(this); - - defColours.setLabel(MessageManager.getString("action.set_defaults")); - defColours.addActionListener(this); - - annotations.addItemListener(this); - - thresholdValue.addActionListener(this); - slider.setBackground(Color.white); - slider.setPreferredSize(new Dimension(193, 21)); - slider.setEnabled(false); - thresholdValue.setPreferredSize(new Dimension(79, 22)); - thresholdValue.setEnabled(false); - thresholdValue.setColumns(5); - currentColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - currentColours.setLabel(MessageManager - .getString("label.use_original_colours")); - currentColours.addItemListener(this); - - thresholdIsMin.setBackground(Color.white); - thresholdIsMin.setLabel(MessageManager - .getString("label.threshold_minmax")); - - this.setLayout(borderLayout1); - - jPanel1.setBackground(Color.white); - - jPanel2.setLayout(new FlowLayout()); - jPanel2.setBackground(Color.white); - threshold.addItemListener(this); - jPanel3.setLayout(new FlowLayout()); - jPanel3.setBackground(Color.white); - JPanel jPanel4 = new JPanel(); - jPanel4.setLayout(new BorderLayout()); - jPanel4.setBackground(Color.white); - - jPanel1.add(ok); - jPanel1.add(cancel); - - jPanel2.add(annotations); - jPanel2.add(currentColours); - jPanel2.add(minColour); - jPanel2.add(maxColour); - - jPanel4.add(thresholdIsMin, BorderLayout.WEST); - jPanel4.add(slider, BorderLayout.CENTER); - jPanel4.add(thresholdValue, BorderLayout.EAST); - - JPanel jPanel34 = new JPanel(); - jPanel34.setLayout(new BorderLayout()); - jPanel34.setBackground(Color.white); - jPanel34.add(jPanel2, BorderLayout.NORTH); - jPanel34.add(threshold, BorderLayout.WEST); - jPanel3.add(defColours); - jPanel34.add(jPanel3, BorderLayout.EAST); - jPanel34.add(jPanel4, BorderLayout.SOUTH); - - this.add(jPanel34, java.awt.BorderLayout.CENTER); - this.add(jPanel1, java.awt.BorderLayout.SOUTH); - - } - - Choice annotations = new Choice(); - - JButton minColour = new JButton(); - - JButton maxColour = new JButton(); - - JButton ok = new JButton(); - - JButton cancel = new JButton(); - - JButton defColours = new JButton(); - - JPanel jPanel1 = new JPanel(); - - JPanel jPanel2 = new JPanel(); - - Choice threshold = new Choice(); - - FlowLayout flowLayout1 = new FlowLayout(); - - JPanel jPanel3 = new JPanel(); - - JScrollBar slider = new JScrollBar(JScrollBar.HORIZONTAL); - - JTextField thresholdValue = new JTextField(20); - - JCheckBox currentColours = new JCheckBox(); - - BorderLayout borderLayout1 = new BorderLayout(); - - JCheckBox thresholdIsMin = new JCheckBox(); - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == thresholdValue) - { - try - { - float f = new Float(thresholdValue.getText()).floatValue(); - slider.setValue((int) (f * 1000)); - adjustmentValueChanged(null); - } catch (NumberFormatException ex) - { - } - } - else if (evt.getSource() == minColour) - { - minColour_actionPerformed(null); - } - else if (evt.getSource() == maxColour) - { - maxColour_actionPerformed(null); - } - else if (evt.getSource() == defColours) - { - defColour_actionPerformed(); - } - else if (evt.getSource() == ok) - { - changeColour(); - frame.setVisible(false); - } - else if (evt.getSource() == cancel) - { - reset(); - ap.paintAlignment(true); - frame.setVisible(false); - } - - else - { - changeColour(); - } - } - - public void itemStateChanged(ItemEvent evt) - { - if (evt.getSource() == currentColours) - { - if (currentColours.isSelected()) - { - reset(); - } - - maxColour.setEnabled(!currentColours.isSelected()); - minColour.setEnabled(!currentColours.isSelected()); - - } - - changeColour(); - } - - public void adjustmentValueChanged(AdjustmentEvent evt) - { - if (!adjusting) - { - thresholdValue.setText((slider.getValue() / 1000f) + ""); - if (currentColours.isSelected() - && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient)) - { - changeColour(); - } - - currentAnnotation.threshold.value = slider.getValue() / 1000f; - ap.paintAlignment(false); - } - } - - public void minColour_actionPerformed(Color newCol) - { - if (newCol != null) - { - minColour.setBackground(newCol); - minColour.repaint(); - changeColour(); - } - else - { - new UserDefinedColours(this, "Min Colour", minColour.getBackground()); - } - - } - - public void maxColour_actionPerformed(Color newCol) - { - if (newCol != null) - { - maxColour.setBackground(newCol); - maxColour.repaint(); - changeColour(); - } - else - { - new UserDefinedColours(this, "Max Colour", maxColour.getBackground()); - } - } - - public void defColour_actionPerformed() - { - setDefaultMinMax(); - minColour.repaint(); - maxColour.repaint(); - changeColour(); - } - - void changeColour() - { - // Check if combobox is still adjusting - if (adjusting) - { - return; - } - - currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations - .getSelectedIndex()]; - - int aboveThreshold = -1; - if (threshold.getSelectedIndex() == 1) - { - aboveThreshold = AnnotationColourGradient.ABOVE_THRESHOLD; - } - else if (threshold.getSelectedIndex() == 2) - { - aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD; - } - - slider.setEnabled(true); - thresholdValue.setEnabled(true); - thresholdIsMin.setEnabled(true); - - if (aboveThreshold == AnnotationColourGradient.NO_THRESHOLD) - { - slider.setEnabled(false); - thresholdValue.setEnabled(false); - thresholdIsMin.setEnabled(false); - thresholdValue.setText(""); - } - else if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD - && currentAnnotation.threshold == null) - { - currentAnnotation - .setThreshold(new GraphLine( - (currentAnnotation.graphMax - currentAnnotation.graphMin) / 2f, - "Threshold", Color.black)); - } - - if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD) - { - adjusting = true; - - slider.setMinimum((int) (currentAnnotation.graphMin * 1000)); - slider.setMaximum((int) (currentAnnotation.graphMax * 1000)); - slider.setValue((int) (currentAnnotation.threshold.value * 1000)); - thresholdValue.setText(currentAnnotation.threshold.value + ""); - slider.setEnabled(true); - thresholdValue.setEnabled(true); - adjusting = false; - } - - AnnotationColourGradient acg = null; - if (currentColours.isSelected()) - { - acg = new AnnotationColourGradient(currentAnnotation, - av.getGlobalColourScheme(), aboveThreshold); - } - else - { - acg = new AnnotationColourGradient(currentAnnotation, - minColour.getBackground(), maxColour.getBackground(), - aboveThreshold); - } - - if (currentAnnotation.graphMin == 0f - && currentAnnotation.graphMax == 0f) - { - acg.setPredefinedColours(true); - } - - acg.thresholdIsMinMax = thresholdIsMin.isSelected(); - - av.setGlobalColourScheme(acg); - - // TODO: per group colour propagation not always desired - if (av.getAlignment().getGroups() != null) - { - for (SequenceGroup sg : ap.av.getAlignment().getGroups()) - { - - if (sg.cs == null) - { - continue; - } - - if (currentColours.isSelected()) - { - sg.cs = new AnnotationColourGradient(currentAnnotation, sg.cs, - aboveThreshold); - } - else - { - sg.cs = new AnnotationColourGradient(currentAnnotation, - minColour.getBackground(), maxColour.getBackground(), - aboveThreshold); - } - - } - } - - // update colours in linked windows - ap.alignmentChanged(); - ap.paintAlignment(true); - } - - void reset() - { - av.setGlobalColourScheme(oldcs); - if (av.getAlignment().getGroups() != null) - { - for (SequenceGroup sg : ap.av.getAlignment().getGroups()) - { - Object cs = oldgroupColours.get(sg); - if (cs instanceof ColourSchemeI) - { - sg.cs = (ColourSchemeI) cs; - } - else - { - // probably the "null" string we set it to if it was null originally. - sg.cs = null; - } - } - } - ap.paintAlignment(true); - - } - - public void mouseClicked(MouseEvent evt) - { - } - - public void mousePressed(MouseEvent evt) - { - } - - public void mouseReleased(MouseEvent evt) - { - ap.paintAlignment(true); - } - - public void mouseEntered(MouseEvent evt) - { - } - - public void mouseExited(MouseEvent evt) - { - } - -} +/* + * 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.appletgui; + +import jalview.bin.JalviewLite; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.GraphLine; +import jalview.datamodel.SequenceGroup; +import jalview.schemes.AnnotationColourGradient; +import jalview.schemes.ColourSchemeI; +import jalview.util.MessageManager; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.Hashtable; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollBar; +import javax.swing.JTextField; + +public class AnnotationColourChooser extends JPanel implements + ActionListener, AdjustmentListener, ItemListener, MouseListener +{ + JFrame frame; + + AlignViewport av; + + AlignmentPanel ap; + + ColourSchemeI oldcs; + + Hashtable oldgroupColours; + + AlignmentAnnotation currentAnnotation; + + boolean adjusting = false; + + public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap) + { + try + { + jbInit(); + } catch (Exception ex) + { + } + + oldcs = av.getGlobalColourScheme(); + if (av.getAlignment().getGroups() != null) + { + oldgroupColours = new Hashtable(); + for (SequenceGroup sg : ap.av.getAlignment().getGroups()) + { + if (sg.cs != null) + { + oldgroupColours.put(sg, sg.cs); + } + else + { + oldgroupColours.put(sg, "null"); + } + } + } + this.av = av; + this.ap = ap; + + slider.addAdjustmentListener(this); + slider.addMouseListener(this); + + if (av.getAlignment().getAlignmentAnnotation() == null) + { + return; + } + + setDefaultMinMax(); + + adjusting = true; + if (oldcs instanceof AnnotationColourGradient) + { + AnnotationColourGradient acg = (AnnotationColourGradient) oldcs; + currentColours.setSelected(acg.isPredefinedColours() + || acg.getBaseColour() != null); + if (!acg.isPredefinedColours() && acg.getBaseColour() == null) + { + minColour.setBackground(acg.getMinColour()); + maxColour.setBackground(acg.getMaxColour()); + } + // seqAssociated.setState(acg.isSeqAssociated()); + } + + Vector list = new Vector(); + int index = 1; + for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++) + { + String label = av.getAlignment().getAlignmentAnnotation()[i].label; + if (!list.contains(label)) + { + list.addElement(label); + } + else + { + list.addElement(label + "_" + (index++)); + } + } + + for (int i = 0; i < list.size(); i++) + { + annotations.addItem(list.elementAt(i).toString()); + } + + threshold.addItem(MessageManager + .getString("label.threshold_feature_no_thereshold")); + threshold.addItem(MessageManager + .getString("label.threshold_feature_above_thereshold")); + threshold.addItem(MessageManager + .getString("label.threshold_feature_below_thereshold")); + + if (oldcs instanceof AnnotationColourGradient) + { + AnnotationColourGradient acg = (AnnotationColourGradient) oldcs; + annotations.select(acg.getAnnotation()); + switch (acg.getAboveThreshold()) + { + case AnnotationColourGradient.NO_THRESHOLD: + threshold.select(0); + break; + case AnnotationColourGradient.ABOVE_THRESHOLD: + threshold.select(1); + break; + case AnnotationColourGradient.BELOW_THRESHOLD: + threshold.select(1); + break; + default: + throw new Error( + MessageManager + .getString("error.implementation_error_dont_know_thereshold_annotationcolourgradient")); + } + thresholdIsMin.setSelected(acg.thresholdIsMinMax); + thresholdValue.setText("" + acg.getAnnotationThreshold()); + } + + adjusting = false; + + changeColour(); + + frame = new JFrame(); + frame.add(this); + JalviewLite.addFrame(frame, + MessageManager.getString("label.colour_by_annotation"), 560, + 175); + validate(); + } + + private void setDefaultMinMax() + { + minColour.setBackground(av.applet.getDefaultColourParameter( + "ANNOTATIONCOLOUR_MIN", Color.orange)); + maxColour.setBackground(av.applet.getDefaultColourParameter( + "ANNOTATIONCOLOUR_MAX", Color.red)); + + } + + public AnnotationColourChooser() + { + try + { + jbInit(); + } catch (Exception ex) + { + ex.printStackTrace(); + } + } + + private void jbInit() throws Exception + { + minColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + minColour.setLabel(MessageManager.getString("label.min_colour")); + minColour.addActionListener(this); + + maxColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + maxColour.setLabel(MessageManager.getString("label.max_colour")); + maxColour.addActionListener(this); + + thresholdIsMin.addItemListener(this); + ok.setLabel(MessageManager.getString("action.ok")); + ok.addActionListener(this); + + cancel.setLabel(MessageManager.getString("action.cancel")); + cancel.addActionListener(this); + + defColours.setLabel(MessageManager.getString("action.set_defaults")); + defColours.addActionListener(this); + + annotations.addItemListener(this); + + thresholdValue.addActionListener(this); + slider.setBackground(Color.white); + slider.setPreferredSize(new Dimension(193, 21)); + slider.setEnabled(false); + thresholdValue.setPreferredSize(new Dimension(79, 22)); + thresholdValue.setEnabled(false); + thresholdValue.setColumns(5); + currentColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + currentColours.setLabel(MessageManager + .getString("label.use_original_colours")); + currentColours.addItemListener(this); + + thresholdIsMin.setBackground(Color.white); + thresholdIsMin.setLabel(MessageManager + .getString("label.threshold_minmax")); + + this.setLayout(borderLayout1); + + jPanel1.setBackground(Color.white); + + jPanel2.setLayout(new FlowLayout()); + jPanel2.setBackground(Color.white); + threshold.addItemListener(this); + jPanel3.setLayout(new FlowLayout()); + jPanel3.setBackground(Color.white); + JPanel jPanel4 = new JPanel(); + jPanel4.setLayout(new BorderLayout()); + jPanel4.setBackground(Color.white); + + jPanel1.add(ok); + jPanel1.add(cancel); + + jPanel2.add(annotations); + jPanel2.add(currentColours); + jPanel2.add(minColour); + jPanel2.add(maxColour); + + jPanel4.add(thresholdIsMin, BorderLayout.WEST); + jPanel4.add(slider, BorderLayout.CENTER); + jPanel4.add(thresholdValue, BorderLayout.EAST); + + JPanel jPanel34 = new JPanel(); + jPanel34.setLayout(new BorderLayout()); + jPanel34.setBackground(Color.white); + jPanel34.add(jPanel2, BorderLayout.NORTH); + jPanel34.add(threshold, BorderLayout.WEST); + jPanel3.add(defColours); + jPanel34.add(jPanel3, BorderLayout.EAST); + jPanel34.add(jPanel4, BorderLayout.SOUTH); + + this.add(jPanel34, java.awt.BorderLayout.CENTER); + this.add(jPanel1, java.awt.BorderLayout.SOUTH); + + } + + Choice annotations = new Choice(); + + JButton minColour = new JButton(); + + JButton maxColour = new JButton(); + + JButton ok = new JButton(); + + JButton cancel = new JButton(); + + JButton defColours = new JButton(); + + JPanel jPanel1 = new JPanel(); + + JPanel jPanel2 = new JPanel(); + + Choice threshold = new Choice(); + + FlowLayout flowLayout1 = new FlowLayout(); + + JPanel jPanel3 = new JPanel(); + + JScrollBar slider = new JScrollBar(JScrollBar.HORIZONTAL); + + JTextField thresholdValue = new JTextField(20); + + JCheckBox currentColours = new JCheckBox(); + + BorderLayout borderLayout1 = new BorderLayout(); + + JCheckBox thresholdIsMin = new JCheckBox(); + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == thresholdValue) + { + try + { + float f = new Float(thresholdValue.getText()).floatValue(); + slider.setValue((int) (f * 1000)); + adjustmentValueChanged(null); + } catch (NumberFormatException ex) + { + } + } + else if (evt.getSource() == minColour) + { + minColour_actionPerformed(null); + } + else if (evt.getSource() == maxColour) + { + maxColour_actionPerformed(null); + } + else if (evt.getSource() == defColours) + { + defColour_actionPerformed(); + } + else if (evt.getSource() == ok) + { + changeColour(); + frame.setVisible(false); + } + else if (evt.getSource() == cancel) + { + reset(); + ap.paintAlignment(true); + frame.setVisible(false); + } + + else + { + changeColour(); + } + } + + public void itemStateChanged(ItemEvent evt) + { + if (evt.getSource() == currentColours) + { + if (currentColours.isSelected()) + { + reset(); + } + + maxColour.setEnabled(!currentColours.isSelected()); + minColour.setEnabled(!currentColours.isSelected()); + + } + + changeColour(); + } + + public void adjustmentValueChanged(AdjustmentEvent evt) + { + if (!adjusting) + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + if (currentColours.isSelected() + && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient)) + { + changeColour(); + } + + currentAnnotation.threshold.value = slider.getValue() / 1000f; + ap.paintAlignment(false); + } + } + + public void minColour_actionPerformed(Color newCol) + { + if (newCol != null) + { + minColour.setBackground(newCol); + minColour.repaint(); + changeColour(); + } + else + { + new UserDefinedColours(this, "Min Colour", minColour.getBackground()); + } + + } + + public void maxColour_actionPerformed(Color newCol) + { + if (newCol != null) + { + maxColour.setBackground(newCol); + maxColour.repaint(); + changeColour(); + } + else + { + new UserDefinedColours(this, "Max Colour", maxColour.getBackground()); + } + } + + public void defColour_actionPerformed() + { + setDefaultMinMax(); + minColour.repaint(); + maxColour.repaint(); + changeColour(); + } + + void changeColour() + { + // Check if combobox is still adjusting + if (adjusting) + { + return; + } + + currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations + .getSelectedIndex()]; + + int aboveThreshold = -1; + if (threshold.getSelectedIndex() == 1) + { + aboveThreshold = AnnotationColourGradient.ABOVE_THRESHOLD; + } + else if (threshold.getSelectedIndex() == 2) + { + aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD; + } + + slider.setEnabled(true); + thresholdValue.setEnabled(true); + thresholdIsMin.setEnabled(true); + + if (aboveThreshold == AnnotationColourGradient.NO_THRESHOLD) + { + slider.setEnabled(false); + thresholdValue.setEnabled(false); + thresholdIsMin.setEnabled(false); + thresholdValue.setText(""); + } + else if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD + && currentAnnotation.threshold == null) + { + currentAnnotation + .setThreshold(new GraphLine( + (currentAnnotation.graphMax - currentAnnotation.graphMin) / 2f, + "Threshold", Color.black)); + } + + if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD) + { + adjusting = true; + + slider.setMinimum((int) (currentAnnotation.graphMin * 1000)); + slider.setMaximum((int) (currentAnnotation.graphMax * 1000)); + slider.setValue((int) (currentAnnotation.threshold.value * 1000)); + thresholdValue.setText(currentAnnotation.threshold.value + ""); + slider.setEnabled(true); + thresholdValue.setEnabled(true); + adjusting = false; + } + + AnnotationColourGradient acg = null; + if (currentColours.isSelected()) + { + acg = new AnnotationColourGradient(currentAnnotation, + av.getGlobalColourScheme(), aboveThreshold); + } + else + { + acg = new AnnotationColourGradient(currentAnnotation, + minColour.getBackground(), maxColour.getBackground(), + aboveThreshold); + } + + if (currentAnnotation.graphMin == 0f + && currentAnnotation.graphMax == 0f) + { + acg.setPredefinedColours(true); + } + + acg.thresholdIsMinMax = thresholdIsMin.isSelected(); + + av.setGlobalColourScheme(acg); + + // TODO: per group colour propagation not always desired + if (av.getAlignment().getGroups() != null) + { + for (SequenceGroup sg : ap.av.getAlignment().getGroups()) + { + + if (sg.cs == null) + { + continue; + } + + if (currentColours.isSelected()) + { + sg.cs = new AnnotationColourGradient(currentAnnotation, sg.cs, + aboveThreshold); + } + else + { + sg.cs = new AnnotationColourGradient(currentAnnotation, + minColour.getBackground(), maxColour.getBackground(), + aboveThreshold); + } + + } + } + + // update colours in linked windows + ap.alignmentChanged(); + ap.paintAlignment(true); + } + + void reset() + { + av.setGlobalColourScheme(oldcs); + if (av.getAlignment().getGroups() != null) + { + for (SequenceGroup sg : ap.av.getAlignment().getGroups()) + { + Object cs = oldgroupColours.get(sg); + if (cs instanceof ColourSchemeI) + { + sg.cs = (ColourSchemeI) cs; + } + else + { + // probably the "null" string we set it to if it was null originally. + sg.cs = null; + } + } + } + ap.paintAlignment(true); + + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + } + + public void mouseReleased(MouseEvent evt) + { + ap.paintAlignment(true); + } + + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + +} diff --git a/unused/appletgui/AnnotationColumnChooser.java b/unused/appletgui/AnnotationColumnChooser.java index 1bba8d1..c57ca30 100644 --- a/unused/appletgui/AnnotationColumnChooser.java +++ b/unused/appletgui/AnnotationColumnChooser.java @@ -1,928 +1,928 @@ -package jalview.appletgui; - -import jalview.bin.JalviewLite; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.GraphLine; -import jalview.schemes.AnnotationColourGradient; -import jalview.util.MessageManager; -import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Checkbox; -import java.awt.Choice; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Panel; -import java.awt.TextField; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.AdjustmentEvent; -import java.awt.event.AdjustmentListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.TextEvent; -import java.awt.event.TextListener; -import java.util.Iterator; -import java.util.Vector; - -import javax.swing.JPanel; - -//import net.miginfocom.swing.MigLayout; - -public class AnnotationColumnChooser extends AnnotationRowFilter implements - ActionListener, AdjustmentListener, ItemListener, MouseListener -{ - - private Choice annotations = new Choice(); - - private Panel actionPanel = new Panel(); - - private TitledPanel thresholdPanel = new TitledPanel(); - - private Panel switchableViewsPanel = new Panel(new CardLayout()); - - private CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel - .getLayout()); - - private Panel noGraphFilterView = new Panel(); - - private Panel graphFilterView = new Panel(); - - private Panel annotationComboBoxPanel = new Panel(); - - private BorderLayout borderLayout1 = new BorderLayout(); - - private BorderLayout gBorderLayout = new BorderLayout(); - - private BorderLayout ngBorderLayout = new BorderLayout(); - - private Choice threshold = new Choice(); - - private StructureFilterPanel gStructureFilterPanel; - - private StructureFilterPanel ngStructureFilterPanel; - - private StructureFilterPanel currentStructureFilterPanel; - - private SearchPanel currentSearchPanel; - - private SearchPanel gSearchPanel; - - private SearchPanel ngSearchPanel; - - private FurtherActionPanel currentFurtherActionPanel; - - private FurtherActionPanel gFurtherActionPanel; - - private FurtherActionPanel ngFurtherActionPanel; - - public static final int ACTION_OPTION_SELECT = 1; - - public static int ACTION_OPTION_HIDE = 2; - - public static String NO_GRAPH_VIEW = "0"; - - public static String GRAPH_VIEW = "1"; - - private int actionOption = ACTION_OPTION_SELECT; - - private ColumnSelection oldColumnSelection; - - public AnnotationColumnChooser() - { - try - { - jbInit(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - - public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap) - { - super(av, ap); - frame = new JFrame(); - frame.add(this); - JalviewLite.addFrame(frame, - MessageManager.getString("label.select_by_annotation"), 520, - 215); - - slider.addAdjustmentListener(this); - slider.addMouseListener(this); - - if (av.getAlignment().getAlignmentAnnotation() == null) - { - return; - } - setOldColumnSelection(av.getColumnSelection()); - adjusting = true; - Vector list = new Vector(); - int index = 1; - for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++) - { - String label = av.getAlignment().getAlignmentAnnotation()[i].label; - if (!list.contains(label)) - { - list.addElement(label); - } - else - { - list.addElement(label + "_" + (index++)); - } - } - - for (int i = 0; i < list.size(); i++) - { - annotations.addItem(list.elementAt(i).toString()); - } - - populateThresholdComboBox(threshold); - - // restore Object state from the previous session if one exists - if (av.getAnnotationColumnSelectionState() != null) - { - currentSearchPanel = av.getAnnotationColumnSelectionState() - .getCurrentSearchPanel(); - currentStructureFilterPanel = av.getAnnotationColumnSelectionState() - .getCurrentStructureFilterPanel(); - annotations.select(av.getAnnotationColumnSelectionState() - .getAnnotations().getSelectedIndex()); - threshold.select(av.getAnnotationColumnSelectionState() - .getThreshold().getSelectedIndex()); - actionOption = av.getAnnotationColumnSelectionState() - .getActionOption(); - } - - try - { - jbInit(); - } catch (Exception ex) - { - } - adjusting = false; - - updateView(); - frame.invalidate(); - frame.pack(); - } - - private void jbInit() throws Exception - { - ok.setLabel(MessageManager.getString("action.ok")); - - cancel.setLabel(MessageManager.getString("action.cancel")); - - thresholdValue.setEnabled(false); - thresholdValue.setColumns(7); - - ok.addActionListener(this); - cancel.addActionListener(this); - annotations.addItemListener(this); - thresholdValue.addActionListener(this); - threshold.addItemListener(this); - - slider.setBackground(Color.white); - slider.setEnabled(false); - slider.setPreferredSize(new Dimension(100, 32)); - - thresholdPanel.setBackground(Color.white); - // thresholdPanel.setFont(JvSwingUtils.getLabelFont()); - // thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]")); - - actionPanel.setBackground(Color.white); - // actionPanel.setFont(JvSwingUtils.getLabelFont()); - - graphFilterView.setLayout(gBorderLayout); - graphFilterView.setBackground(Color.white); - - noGraphFilterView.setLayout(ngBorderLayout); - noGraphFilterView.setBackground(Color.white); - - annotationComboBoxPanel.setBackground(Color.white); - // annotationComboBoxPanel.setFont(JvSwingUtils.getLabelFont()); - - gSearchPanel = new SearchPanel(this); - ngSearchPanel = new SearchPanel(this); - gFurtherActionPanel = new FurtherActionPanel(this); - ngFurtherActionPanel = new FurtherActionPanel(this); - gStructureFilterPanel = new StructureFilterPanel(this); - ngStructureFilterPanel = new StructureFilterPanel(this); - - thresholdPanel.setTitle("Threshold Filter"); - thresholdPanel.add(getThreshold()); - thresholdPanel.add(slider); - thresholdPanel.add(thresholdValue); - - actionPanel.add(ok); - actionPanel.add(cancel); - - JPanel staticPanel = new JPanel(); - staticPanel.setLayout(new BorderLayout()); - staticPanel.setBackground(Color.white); - - staticPanel.add(gSearchPanel, java.awt.BorderLayout.NORTH); - staticPanel.add(gStructureFilterPanel, java.awt.BorderLayout.SOUTH); - - graphFilterView.add(staticPanel, java.awt.BorderLayout.NORTH); - graphFilterView.add(thresholdPanel, java.awt.BorderLayout.CENTER); - graphFilterView.add(gFurtherActionPanel, java.awt.BorderLayout.SOUTH); - - noGraphFilterView.add(ngSearchPanel, java.awt.BorderLayout.PAGE_START); - noGraphFilterView.add(ngStructureFilterPanel, - java.awt.BorderLayout.CENTER); - noGraphFilterView.add(ngFurtherActionPanel, - java.awt.BorderLayout.CENTER); - - annotationComboBoxPanel.add(getAnnotations()); - switchableViewsPanel.add(noGraphFilterView, - AnnotationColumnChooser.NO_GRAPH_VIEW); - switchableViewsPanel.add(graphFilterView, - AnnotationColumnChooser.GRAPH_VIEW); - - this.setLayout(borderLayout1); - this.add(annotationComboBoxPanel, java.awt.BorderLayout.PAGE_START); - this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER); - this.add(actionPanel, java.awt.BorderLayout.SOUTH); - - selectedAnnotationChanged(); - this.validate(); - } - - @SuppressWarnings("unchecked") - public void reset() - { - if (this.getOldColumnSelection() != null) - { - av.getColumnSelection().clear(); - - if (av.getAnnotationColumnSelectionState() != null) - { - ColumnSelection oldSelection = av - .getAnnotationColumnSelectionState() - .getOldColumnSelection(); - if (oldSelection != null && oldSelection.getHiddenColumns() != null - && !oldSelection.getHiddenColumns().isEmpty()) - { - for (Iterator itr = oldSelection.getHiddenColumns() - .iterator(); itr.hasNext();) - { - int positions[] = itr.next(); - av.hideColumns(positions[0], positions[1]); - } - } - av.setColumnSelection(oldSelection); - } - ap.paintAlignment(true); - } - - } - - public void adjustmentValueChanged(AdjustmentEvent evt) - { - if (!adjusting) - { - thresholdValue.setText((slider.getValue() / 1000f) + ""); - valueChanged(!sliderDragging); - } - } - - protected void addSliderMouseListeners() - { - - slider.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent e) - { - sliderDragging = true; - super.mousePressed(e); - } - - @Override - public void mouseDragged(MouseEvent e) - { - sliderDragging = true; - super.mouseDragged(e); - } - - @Override - public void mouseReleased(MouseEvent evt) - { - if (sliderDragging) - { - sliderDragging = false; - valueChanged(true); - } - ap.paintAlignment(true); - } - }); - } - - public void valueChanged(boolean updateAllAnnotation) - { - if (slider.isEnabled()) - { - getCurrentAnnotation().threshold.value = slider.getValue() / 1000f; - updateView(); - ap.paintAlignment(false); - } - } - - public Choice getThreshold() - { - return threshold; - } - - public void setThreshold(Choice threshold) - { - this.threshold = threshold; - } - - public Choice getAnnotations() - { - return annotations; - } - - public void setAnnotations(Choice annotations) - { - this.annotations = annotations; - } - - @Override - public void updateView() - { - // Check if combobox is still adjusting - if (adjusting) - { - return; - } - - AnnotationFilterParameter filterParams = new AnnotationFilterParameter(); - setCurrentAnnotation(av.getAlignment().getAlignmentAnnotation()[getAnnotations() - .getSelectedIndex()]); - - int selectedThresholdItem = getSelectedThresholdItem(getThreshold() - .getSelectedIndex()); - - slider.setEnabled(true); - thresholdValue.setEnabled(true); - - if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD) - { - slider.setEnabled(false); - thresholdValue.setEnabled(false); - thresholdValue.setText(""); - // build filter params - } - else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD) - { - if (getCurrentAnnotation().threshold == null) - { - getCurrentAnnotation() - .setThreshold( - new GraphLine( - (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin) / 2f, - "Threshold", Color.black)); - } - - adjusting = true; - float range = getCurrentAnnotation().graphMax * 1000 - - getCurrentAnnotation().graphMin * 1000; - - slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000)); - slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000)); - slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000)); - thresholdValue.setText(getCurrentAnnotation().threshold.value + ""); - // slider.setMajorTickSpacing((int) (range / 10f)); - slider.setEnabled(true); - thresholdValue.setEnabled(true); - adjusting = false; - - // build filter params - filterParams - .setThresholdType(AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); - if (getCurrentAnnotation().graph != AlignmentAnnotation.NO_GRAPH) - { - filterParams - .setThresholdValue(getCurrentAnnotation().threshold.value); - - if (selectedThresholdItem == AnnotationColourGradient.ABOVE_THRESHOLD) - { - filterParams - .setThresholdType(AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD); - } - else if (selectedThresholdItem == AnnotationColourGradient.BELOW_THRESHOLD) - { - filterParams - .setThresholdType(AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD); - } - } - } - - if (currentStructureFilterPanel != null) - { - if (currentStructureFilterPanel.alphaHelix.getState()) - { - filterParams.setFilterAlphaHelix(true); - } - if (currentStructureFilterPanel.betaStrand.getState()) - { - filterParams.setFilterBetaSheet(true); - } - if (currentStructureFilterPanel.turn.getState()) - { - filterParams.setFilterTurn(true); - } - } - - if (currentSearchPanel != null) - { - - if (!currentSearchPanel.searchBox.getText().isEmpty()) - { - currentSearchPanel.description.setEnabled(true); - currentSearchPanel.displayName.setEnabled(true); - filterParams.setRegexString(currentSearchPanel.searchBox.getText()); - if (currentSearchPanel.displayName.getState()) - { - filterParams - .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING); - } - if (currentSearchPanel.description.getState()) - { - filterParams - .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION); - } - } - else - { - currentSearchPanel.description.setEnabled(false); - currentSearchPanel.displayName.setEnabled(false); - } - } - - av.getColumnSelection().filterAnnotations( - getCurrentAnnotation().annotations, filterParams); - - av.showAllHiddenColumns(); - if (getActionOption() == ACTION_OPTION_HIDE) - { - av.hideSelectedColumns(); - } - - filterParams = null; - av.setAnnotationColumnSelectionState(this); - ap.paintAlignment(true); - } - - public ColumnSelection getOldColumnSelection() - { - return oldColumnSelection; - } - - public void setOldColumnSelection(ColumnSelection currentColumnSelection) - { - if (currentColumnSelection != null) - { - this.oldColumnSelection = new ColumnSelection(currentColumnSelection); - } - } - - public FurtherActionPanel getCurrentFutherActionPanel() - { - return currentFurtherActionPanel; - } - - public void setCurrentFutherActionPanel( - FurtherActionPanel currentFutherActionPanel) - { - this.currentFurtherActionPanel = currentFutherActionPanel; - } - - public SearchPanel getCurrentSearchPanel() - { - return currentSearchPanel; - } - - public void setCurrentSearchPanel(SearchPanel currentSearchPanel) - { - this.currentSearchPanel = currentSearchPanel; - } - - public int getActionOption() - { - return actionOption; - } - - public void setActionOption(int actionOption) - { - this.actionOption = actionOption; - } - - public StructureFilterPanel getCurrentStructureFilterPanel() - { - return currentStructureFilterPanel; - } - - public void setCurrentStructureFilterPanel( - StructureFilterPanel currentStructureFilterPanel) - { - this.currentStructureFilterPanel = currentStructureFilterPanel; - } - - @Override - public void itemStateChanged(ItemEvent e) - { - if (e.getSource() == annotations) - { - selectedAnnotationChanged(); - } - else if (e.getSource() == threshold) - { - threshold_actionPerformed(null); - } - } - - public void selectedAnnotationChanged() - { - String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW; - if (av.getAlignment().getAlignmentAnnotation()[getAnnotations() - .getSelectedIndex()].graph != AlignmentAnnotation.NO_GRAPH) - { - currentView = AnnotationColumnChooser.GRAPH_VIEW; - } - - gSearchPanel.syncState(); - gFurtherActionPanel.syncState(); - gStructureFilterPanel.syncState(); - - ngSearchPanel.syncState(); - ngFurtherActionPanel.syncState(); - ngStructureFilterPanel.syncState(); - - switchableViewsLayout.show(switchableViewsPanel, currentView); - updateView(); - } - - public class FurtherActionPanel extends Panel implements - ItemListener - { - private AnnotationColumnChooser aColChooser; - - private Choice furtherAction = new Choice(); - - public FurtherActionPanel(AnnotationColumnChooser aColChooser) - { - this.aColChooser = aColChooser; - furtherAction.addItem("Select"); - furtherAction.addItem("Hide"); - furtherAction.addItemListener(this); - syncState(); - - // this.setTitle("Filter Actions"); - // this.setFont(JvSwingUtils.getLabelFont()); - - this.add(furtherAction); - } - - public void syncState() - { - if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) - { - furtherAction.select("Hide"); - } - else - { - furtherAction.select("Select"); - } - } - - @Override - public void itemStateChanged(ItemEvent e) - { - aColChooser.setCurrentFutherActionPanel(this); - if (furtherAction.getSelectedItem().equalsIgnoreCase("Select")) - { - setActionOption(ACTION_OPTION_SELECT); - updateView(); - } - else - { - setActionOption(ACTION_OPTION_HIDE); - updateView(); - } - - } - } - - public class StructureFilterPanel extends TitledPanel implements - ItemListener - { - private AnnotationColumnChooser aColChooser; - - private Checkbox alphaHelix = new Checkbox(); - - private Checkbox betaStrand = new Checkbox(); - - private Checkbox turn = new Checkbox(); - - private Checkbox all = new Checkbox(); - - public StructureFilterPanel(AnnotationColumnChooser aColChooser) - { - this.aColChooser = aColChooser; - - alphaHelix.setLabel(MessageManager.getString("label.alpha_helix")); - alphaHelix.setBackground(Color.white); - - alphaHelix.addItemListener(this); - - betaStrand.setLabel(MessageManager.getString("label.beta_strand")); - betaStrand.setBackground(Color.white); - betaStrand.addItemListener(this); - - turn.setLabel(MessageManager.getString("label.turn")); - turn.setBackground(Color.white); - turn.addItemListener(this); - - all.setLabel(MessageManager.getString("label.select_all")); - all.setBackground(Color.white); - all.addItemListener(this); - - this.setBackground(Color.white); - this.setTitle("Structure Filter"); - // this.setFont(JvSwingUtils.getLabelFont()); - - this.add(all); - this.add(alphaHelix); - this.add(betaStrand); - this.add(turn); - } - - public void alphaHelix_actionPerformed() - { - updateSelectAllState(); - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void betaStrand_actionPerformed() - { - updateSelectAllState(); - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void turn_actionPerformed() - { - updateSelectAllState(); - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void all_actionPerformed() - { - if (all.getState()) - { - alphaHelix.setState(true); - betaStrand.setState(true); - turn.setState(true); - } - else - { - alphaHelix.setState(false); - betaStrand.setState(false); - turn.setState(false); - } - aColChooser.setCurrentStructureFilterPanel(this); - aColChooser.updateView(); - } - - public void updateSelectAllState() - { - if (alphaHelix.getState() && betaStrand.getState() && turn.getState()) - { - all.setState(true); - } - else - { - all.setState(false); - } - } - - public void syncState() - { - StructureFilterPanel sfp = aColChooser - .getCurrentStructureFilterPanel(); - if (sfp != null) - { - alphaHelix.setState(sfp.alphaHelix.getState()); - betaStrand.setState(sfp.betaStrand.getState()); - turn.setState(sfp.turn.getState()); - if (sfp.all.getState()) - { - all.setState(true); - alphaHelix.setState(true); - betaStrand.setState(true); - turn.setState(true); - } - } - - } - - @Override - public void itemStateChanged(ItemEvent e) - { - if (e.getSource() == alphaHelix) - { - alphaHelix_actionPerformed(); - } - else if (e.getSource() == betaStrand) - { - betaStrand_actionPerformed(); - } - else if (e.getSource() == turn) - { - turn_actionPerformed(); - } - else if (e.getSource() == all) - { - all_actionPerformed(); - } - } - } - - public class SearchPanel extends TitledPanel implements ItemListener - { - private AnnotationColumnChooser aColChooser; - - private Checkbox displayName = new Checkbox(); - - private Checkbox description = new Checkbox(); - - private TextField searchBox = new TextField(10); - - public SearchPanel(AnnotationColumnChooser aColChooser) - { - - this.aColChooser = aColChooser; - searchBox.addTextListener(new TextListener() - { - - @Override - public void textValueChanged(TextEvent e) - { - searchStringAction(); - - } - - }); - - displayName.setLabel(MessageManager.getString("label.display_name")); - displayName.setEnabled(false); - displayName.addItemListener(this); - - description.setLabel(MessageManager.getString("label.description")); - description.setEnabled(false); - description.addItemListener(this); - this.setTitle("Search Filter"); - // this.setFont(JvSwingUtils.getLabelFont()); - - syncState(); - this.add(searchBox); - this.add(displayName); - this.add(description); - } - - public void displayNameCheckboxAction() - { - aColChooser.setCurrentSearchPanel(this); - aColChooser.updateView(); - } - - public void discriptionCheckboxAction() - { - aColChooser.setCurrentSearchPanel(this); - aColChooser.updateView(); - } - - public void searchStringAction() - { - aColChooser.setCurrentSearchPanel(this); - aColChooser.updateView(); - } - - public void syncState() - { - SearchPanel sp = aColChooser.getCurrentSearchPanel(); - if (sp != null) - { - description.setEnabled(sp.description.isEnabled()); - description.setState(sp.description.getState()); - - displayName.setEnabled(sp.displayName.isEnabled()); - displayName.setState(sp.displayName.getState()); - - searchBox.setText(sp.searchBox.getText()); - } - } - - @Override - public void itemStateChanged(ItemEvent e) - { - if (e.getSource() == displayName) - { - displayNameCheckboxAction(); - } - else if (e.getSource() == description) - { - discriptionCheckboxAction(); - } - - } - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == thresholdValue) - { - try - { - float f = new Float(thresholdValue.getText()).floatValue(); - slider.setValue((int) (f * 1000)); - adjustmentValueChanged(null); - } catch (NumberFormatException ex) - { - } - } - - else if (evt.getSource() == ok) - { - ok_actionPerformed(null); - } - else if (evt.getSource() == cancel) - { - cancel_actionPerformed(null); - } - else if (evt.getSource() == thresholdValue) - { - thresholdValue_actionPerformed(null); - } - else - { - updateView(); - } - } - - @Override - public void mouseClicked(MouseEvent e) - { - // TODO Auto-generated method stub - - } - - @Override - public void mousePressed(MouseEvent e) - { - if (e.getSource() == slider) - { - updateView(); - } - - } - - @Override - public void mouseReleased(MouseEvent e) - { - if (e.getSource() == slider) - { - updateView(); - } - } - - @Override - public void mouseEntered(MouseEvent e) - { - if (e.getSource() == slider) - { - updateView(); - } - } - - @Override - public void mouseExited(MouseEvent e) - { - if (e.getSource() == slider) - { - updateView(); - } - } - -} +package jalview.appletgui; + +import jalview.bin.JalviewLite; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.GraphLine; +import jalview.schemes.AnnotationColourGradient; +import jalview.util.MessageManager; +import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.TextEvent; +import java.awt.event.TextListener; +import java.util.Iterator; +import java.util.Vector; + +import javax.swing.JPanel; + +//import net.miginfocom.swing.MigLayout; + +public class AnnotationColumnChooser extends AnnotationRowFilter implements + ActionListener, AdjustmentListener, ItemListener, MouseListener +{ + + private Choice annotations = new Choice(); + + private Panel actionPanel = new Panel(); + + private TitledPanel thresholdPanel = new TitledPanel(); + + private Panel switchableViewsPanel = new Panel(new CardLayout()); + + private CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel + .getLayout()); + + private Panel noGraphFilterView = new Panel(); + + private Panel graphFilterView = new Panel(); + + private Panel annotationComboBoxPanel = new Panel(); + + private BorderLayout borderLayout1 = new BorderLayout(); + + private BorderLayout gBorderLayout = new BorderLayout(); + + private BorderLayout ngBorderLayout = new BorderLayout(); + + private Choice threshold = new Choice(); + + private StructureFilterPanel gStructureFilterPanel; + + private StructureFilterPanel ngStructureFilterPanel; + + private StructureFilterPanel currentStructureFilterPanel; + + private SearchPanel currentSearchPanel; + + private SearchPanel gSearchPanel; + + private SearchPanel ngSearchPanel; + + private FurtherActionPanel currentFurtherActionPanel; + + private FurtherActionPanel gFurtherActionPanel; + + private FurtherActionPanel ngFurtherActionPanel; + + public static final int ACTION_OPTION_SELECT = 1; + + public static int ACTION_OPTION_HIDE = 2; + + public static String NO_GRAPH_VIEW = "0"; + + public static String GRAPH_VIEW = "1"; + + private int actionOption = ACTION_OPTION_SELECT; + + private ColumnSelection oldColumnSelection; + + public AnnotationColumnChooser() + { + try + { + jbInit(); + } catch (Exception ex) + { + ex.printStackTrace(); + } + } + + public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap) + { + super(av, ap); + frame = new JFrame(); + frame.add(this); + JalviewLite.addFrame(frame, + MessageManager.getString("label.select_by_annotation"), 520, + 215); + + slider.addAdjustmentListener(this); + slider.addMouseListener(this); + + if (av.getAlignment().getAlignmentAnnotation() == null) + { + return; + } + setOldColumnSelection(av.getColumnSelection()); + adjusting = true; + Vector list = new Vector(); + int index = 1; + for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++) + { + String label = av.getAlignment().getAlignmentAnnotation()[i].label; + if (!list.contains(label)) + { + list.addElement(label); + } + else + { + list.addElement(label + "_" + (index++)); + } + } + + for (int i = 0; i < list.size(); i++) + { + annotations.addItem(list.elementAt(i).toString()); + } + + populateThresholdComboBox(threshold); + + // restore Object state from the previous session if one exists + if (av.getAnnotationColumnSelectionState() != null) + { + currentSearchPanel = av.getAnnotationColumnSelectionState() + .getCurrentSearchPanel(); + currentStructureFilterPanel = av.getAnnotationColumnSelectionState() + .getCurrentStructureFilterPanel(); + annotations.select(av.getAnnotationColumnSelectionState() + .getAnnotations().getSelectedIndex()); + threshold.select(av.getAnnotationColumnSelectionState() + .getThreshold().getSelectedIndex()); + actionOption = av.getAnnotationColumnSelectionState() + .getActionOption(); + } + + try + { + jbInit(); + } catch (Exception ex) + { + } + adjusting = false; + + updateView(); + frame.invalidate(); + frame.pack(); + } + + private void jbInit() throws Exception + { + ok.setLabel(MessageManager.getString("action.ok")); + + cancel.setLabel(MessageManager.getString("action.cancel")); + + thresholdValue.setEnabled(false); + thresholdValue.setColumns(7); + + ok.addActionListener(this); + cancel.addActionListener(this); + annotations.addItemListener(this); + thresholdValue.addActionListener(this); + threshold.addItemListener(this); + + slider.setBackground(Color.white); + slider.setEnabled(false); + slider.setPreferredSize(new Dimension(100, 32)); + + thresholdPanel.setBackground(Color.white); + // thresholdPanel.setFont(JvSwingUtils.getLabelFont()); + // thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]")); + + actionPanel.setBackground(Color.white); + // actionPanel.setFont(JvSwingUtils.getLabelFont()); + + graphFilterView.setLayout(gBorderLayout); + graphFilterView.setBackground(Color.white); + + noGraphFilterView.setLayout(ngBorderLayout); + noGraphFilterView.setBackground(Color.white); + + annotationComboBoxPanel.setBackground(Color.white); + // annotationComboBoxPanel.setFont(JvSwingUtils.getLabelFont()); + + gSearchPanel = new SearchPanel(this); + ngSearchPanel = new SearchPanel(this); + gFurtherActionPanel = new FurtherActionPanel(this); + ngFurtherActionPanel = new FurtherActionPanel(this); + gStructureFilterPanel = new StructureFilterPanel(this); + ngStructureFilterPanel = new StructureFilterPanel(this); + + thresholdPanel.setTitle("Threshold Filter"); + thresholdPanel.add(getThreshold()); + thresholdPanel.add(slider); + thresholdPanel.add(thresholdValue); + + actionPanel.add(ok); + actionPanel.add(cancel); + + JPanel staticPanel = new JPanel(); + staticPanel.setLayout(new BorderLayout()); + staticPanel.setBackground(Color.white); + + staticPanel.add(gSearchPanel, java.awt.BorderLayout.NORTH); + staticPanel.add(gStructureFilterPanel, java.awt.BorderLayout.SOUTH); + + graphFilterView.add(staticPanel, java.awt.BorderLayout.NORTH); + graphFilterView.add(thresholdPanel, java.awt.BorderLayout.CENTER); + graphFilterView.add(gFurtherActionPanel, java.awt.BorderLayout.SOUTH); + + noGraphFilterView.add(ngSearchPanel, java.awt.BorderLayout.PAGE_START); + noGraphFilterView.add(ngStructureFilterPanel, + java.awt.BorderLayout.CENTER); + noGraphFilterView.add(ngFurtherActionPanel, + java.awt.BorderLayout.CENTER); + + annotationComboBoxPanel.add(getAnnotations()); + switchableViewsPanel.add(noGraphFilterView, + AnnotationColumnChooser.NO_GRAPH_VIEW); + switchableViewsPanel.add(graphFilterView, + AnnotationColumnChooser.GRAPH_VIEW); + + this.setLayout(borderLayout1); + this.add(annotationComboBoxPanel, java.awt.BorderLayout.PAGE_START); + this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER); + this.add(actionPanel, java.awt.BorderLayout.SOUTH); + + selectedAnnotationChanged(); + this.validate(); + } + + @SuppressWarnings("unchecked") + public void reset() + { + if (this.getOldColumnSelection() != null) + { + av.getColumnSelection().clear(); + + if (av.getAnnotationColumnSelectionState() != null) + { + ColumnSelection oldSelection = av + .getAnnotationColumnSelectionState() + .getOldColumnSelection(); + if (oldSelection != null && oldSelection.getHiddenColumns() != null + && !oldSelection.getHiddenColumns().isEmpty()) + { + for (Iterator itr = oldSelection.getHiddenColumns() + .iterator(); itr.hasNext();) + { + int positions[] = itr.next(); + av.hideColumns(positions[0], positions[1]); + } + } + av.setColumnSelection(oldSelection); + } + ap.paintAlignment(true); + } + + } + + public void adjustmentValueChanged(AdjustmentEvent evt) + { + if (!adjusting) + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + valueChanged(!sliderDragging); + } + } + + protected void addSliderMouseListeners() + { + + slider.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent e) + { + sliderDragging = true; + super.mousePressed(e); + } + + @Override + public void mouseDragged(MouseEvent e) + { + sliderDragging = true; + super.mouseDragged(e); + } + + @Override + public void mouseReleased(MouseEvent evt) + { + if (sliderDragging) + { + sliderDragging = false; + valueChanged(true); + } + ap.paintAlignment(true); + } + }); + } + + public void valueChanged(boolean updateAllAnnotation) + { + if (slider.isEnabled()) + { + getCurrentAnnotation().threshold.value = slider.getValue() / 1000f; + updateView(); + ap.paintAlignment(false); + } + } + + public Choice getThreshold() + { + return threshold; + } + + public void setThreshold(Choice threshold) + { + this.threshold = threshold; + } + + public Choice getAnnotations() + { + return annotations; + } + + public void setAnnotations(Choice annotations) + { + this.annotations = annotations; + } + + @Override + public void updateView() + { + // Check if combobox is still adjusting + if (adjusting) + { + return; + } + + AnnotationFilterParameter filterParams = new AnnotationFilterParameter(); + setCurrentAnnotation(av.getAlignment().getAlignmentAnnotation()[getAnnotations() + .getSelectedIndex()]); + + int selectedThresholdItem = getSelectedThresholdItem(getThreshold() + .getSelectedIndex()); + + slider.setEnabled(true); + thresholdValue.setEnabled(true); + + if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD) + { + slider.setEnabled(false); + thresholdValue.setEnabled(false); + thresholdValue.setText(""); + // build filter params + } + else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD) + { + if (getCurrentAnnotation().threshold == null) + { + getCurrentAnnotation() + .setThreshold( + new GraphLine( + (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin) / 2f, + "Threshold", Color.black)); + } + + adjusting = true; + float range = getCurrentAnnotation().graphMax * 1000 + - getCurrentAnnotation().graphMin * 1000; + + slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000)); + slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000)); + slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000)); + thresholdValue.setText(getCurrentAnnotation().threshold.value + ""); + // slider.setMajorTickSpacing((int) (range / 10f)); + slider.setEnabled(true); + thresholdValue.setEnabled(true); + adjusting = false; + + // build filter params + filterParams + .setThresholdType(AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); + if (getCurrentAnnotation().graph != AlignmentAnnotation.NO_GRAPH) + { + filterParams + .setThresholdValue(getCurrentAnnotation().threshold.value); + + if (selectedThresholdItem == AnnotationColourGradient.ABOVE_THRESHOLD) + { + filterParams + .setThresholdType(AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD); + } + else if (selectedThresholdItem == AnnotationColourGradient.BELOW_THRESHOLD) + { + filterParams + .setThresholdType(AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD); + } + } + } + + if (currentStructureFilterPanel != null) + { + if (currentStructureFilterPanel.alphaHelix.getState()) + { + filterParams.setFilterAlphaHelix(true); + } + if (currentStructureFilterPanel.betaStrand.getState()) + { + filterParams.setFilterBetaSheet(true); + } + if (currentStructureFilterPanel.turn.getState()) + { + filterParams.setFilterTurn(true); + } + } + + if (currentSearchPanel != null) + { + + if (!currentSearchPanel.searchBox.getText().isEmpty()) + { + currentSearchPanel.description.setEnabled(true); + currentSearchPanel.displayName.setEnabled(true); + filterParams.setRegexString(currentSearchPanel.searchBox.getText()); + if (currentSearchPanel.displayName.getState()) + { + filterParams + .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING); + } + if (currentSearchPanel.description.getState()) + { + filterParams + .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION); + } + } + else + { + currentSearchPanel.description.setEnabled(false); + currentSearchPanel.displayName.setEnabled(false); + } + } + + av.getColumnSelection().filterAnnotations( + getCurrentAnnotation().annotations, filterParams); + + av.showAllHiddenColumns(); + if (getActionOption() == ACTION_OPTION_HIDE) + { + av.hideSelectedColumns(); + } + + filterParams = null; + av.setAnnotationColumnSelectionState(this); + ap.paintAlignment(true); + } + + public ColumnSelection getOldColumnSelection() + { + return oldColumnSelection; + } + + public void setOldColumnSelection(ColumnSelection currentColumnSelection) + { + if (currentColumnSelection != null) + { + this.oldColumnSelection = new ColumnSelection(currentColumnSelection); + } + } + + public FurtherActionPanel getCurrentFutherActionPanel() + { + return currentFurtherActionPanel; + } + + public void setCurrentFutherActionPanel( + FurtherActionPanel currentFutherActionPanel) + { + this.currentFurtherActionPanel = currentFutherActionPanel; + } + + public SearchPanel getCurrentSearchPanel() + { + return currentSearchPanel; + } + + public void setCurrentSearchPanel(SearchPanel currentSearchPanel) + { + this.currentSearchPanel = currentSearchPanel; + } + + public int getActionOption() + { + return actionOption; + } + + public void setActionOption(int actionOption) + { + this.actionOption = actionOption; + } + + public StructureFilterPanel getCurrentStructureFilterPanel() + { + return currentStructureFilterPanel; + } + + public void setCurrentStructureFilterPanel( + StructureFilterPanel currentStructureFilterPanel) + { + this.currentStructureFilterPanel = currentStructureFilterPanel; + } + + @Override + public void itemStateChanged(ItemEvent e) + { + if (e.getSource() == annotations) + { + selectedAnnotationChanged(); + } + else if (e.getSource() == threshold) + { + threshold_actionPerformed(null); + } + } + + public void selectedAnnotationChanged() + { + String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW; + if (av.getAlignment().getAlignmentAnnotation()[getAnnotations() + .getSelectedIndex()].graph != AlignmentAnnotation.NO_GRAPH) + { + currentView = AnnotationColumnChooser.GRAPH_VIEW; + } + + gSearchPanel.syncState(); + gFurtherActionPanel.syncState(); + gStructureFilterPanel.syncState(); + + ngSearchPanel.syncState(); + ngFurtherActionPanel.syncState(); + ngStructureFilterPanel.syncState(); + + switchableViewsLayout.show(switchableViewsPanel, currentView); + updateView(); + } + + public class FurtherActionPanel extends Panel implements + ItemListener + { + private AnnotationColumnChooser aColChooser; + + private Choice furtherAction = new Choice(); + + public FurtherActionPanel(AnnotationColumnChooser aColChooser) + { + this.aColChooser = aColChooser; + furtherAction.addItem("Select"); + furtherAction.addItem("Hide"); + furtherAction.addItemListener(this); + syncState(); + + // this.setTitle("Filter Actions"); + // this.setFont(JvSwingUtils.getLabelFont()); + + this.add(furtherAction); + } + + public void syncState() + { + if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) + { + furtherAction.select("Hide"); + } + else + { + furtherAction.select("Select"); + } + } + + @Override + public void itemStateChanged(ItemEvent e) + { + aColChooser.setCurrentFutherActionPanel(this); + if (furtherAction.getSelectedItem().equalsIgnoreCase("Select")) + { + setActionOption(ACTION_OPTION_SELECT); + updateView(); + } + else + { + setActionOption(ACTION_OPTION_HIDE); + updateView(); + } + + } + } + + public class StructureFilterPanel extends TitledPanel implements + ItemListener + { + private AnnotationColumnChooser aColChooser; + + private Checkbox alphaHelix = new Checkbox(); + + private Checkbox betaStrand = new Checkbox(); + + private Checkbox turn = new Checkbox(); + + private Checkbox all = new Checkbox(); + + public StructureFilterPanel(AnnotationColumnChooser aColChooser) + { + this.aColChooser = aColChooser; + + alphaHelix.setLabel(MessageManager.getString("label.alpha_helix")); + alphaHelix.setBackground(Color.white); + + alphaHelix.addItemListener(this); + + betaStrand.setLabel(MessageManager.getString("label.beta_strand")); + betaStrand.setBackground(Color.white); + betaStrand.addItemListener(this); + + turn.setLabel(MessageManager.getString("label.turn")); + turn.setBackground(Color.white); + turn.addItemListener(this); + + all.setLabel(MessageManager.getString("label.select_all")); + all.setBackground(Color.white); + all.addItemListener(this); + + this.setBackground(Color.white); + this.setTitle("Structure Filter"); + // this.setFont(JvSwingUtils.getLabelFont()); + + this.add(all); + this.add(alphaHelix); + this.add(betaStrand); + this.add(turn); + } + + public void alphaHelix_actionPerformed() + { + updateSelectAllState(); + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void betaStrand_actionPerformed() + { + updateSelectAllState(); + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void turn_actionPerformed() + { + updateSelectAllState(); + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void all_actionPerformed() + { + if (all.getState()) + { + alphaHelix.setState(true); + betaStrand.setState(true); + turn.setState(true); + } + else + { + alphaHelix.setState(false); + betaStrand.setState(false); + turn.setState(false); + } + aColChooser.setCurrentStructureFilterPanel(this); + aColChooser.updateView(); + } + + public void updateSelectAllState() + { + if (alphaHelix.getState() && betaStrand.getState() && turn.getState()) + { + all.setState(true); + } + else + { + all.setState(false); + } + } + + public void syncState() + { + StructureFilterPanel sfp = aColChooser + .getCurrentStructureFilterPanel(); + if (sfp != null) + { + alphaHelix.setState(sfp.alphaHelix.getState()); + betaStrand.setState(sfp.betaStrand.getState()); + turn.setState(sfp.turn.getState()); + if (sfp.all.getState()) + { + all.setState(true); + alphaHelix.setState(true); + betaStrand.setState(true); + turn.setState(true); + } + } + + } + + @Override + public void itemStateChanged(ItemEvent e) + { + if (e.getSource() == alphaHelix) + { + alphaHelix_actionPerformed(); + } + else if (e.getSource() == betaStrand) + { + betaStrand_actionPerformed(); + } + else if (e.getSource() == turn) + { + turn_actionPerformed(); + } + else if (e.getSource() == all) + { + all_actionPerformed(); + } + } + } + + public class SearchPanel extends TitledPanel implements ItemListener + { + private AnnotationColumnChooser aColChooser; + + private Checkbox displayName = new Checkbox(); + + private Checkbox description = new Checkbox(); + + private TextField searchBox = new TextField(10); + + public SearchPanel(AnnotationColumnChooser aColChooser) + { + + this.aColChooser = aColChooser; + searchBox.addTextListener(new TextListener() + { + + @Override + public void textValueChanged(TextEvent e) + { + searchStringAction(); + + } + + }); + + displayName.setLabel(MessageManager.getString("label.display_name")); + displayName.setEnabled(false); + displayName.addItemListener(this); + + description.setLabel(MessageManager.getString("label.description")); + description.setEnabled(false); + description.addItemListener(this); + this.setTitle("Search Filter"); + // this.setFont(JvSwingUtils.getLabelFont()); + + syncState(); + this.add(searchBox); + this.add(displayName); + this.add(description); + } + + public void displayNameCheckboxAction() + { + aColChooser.setCurrentSearchPanel(this); + aColChooser.updateView(); + } + + public void discriptionCheckboxAction() + { + aColChooser.setCurrentSearchPanel(this); + aColChooser.updateView(); + } + + public void searchStringAction() + { + aColChooser.setCurrentSearchPanel(this); + aColChooser.updateView(); + } + + public void syncState() + { + SearchPanel sp = aColChooser.getCurrentSearchPanel(); + if (sp != null) + { + description.setEnabled(sp.description.isEnabled()); + description.setState(sp.description.getState()); + + displayName.setEnabled(sp.displayName.isEnabled()); + displayName.setState(sp.displayName.getState()); + + searchBox.setText(sp.searchBox.getText()); + } + } + + @Override + public void itemStateChanged(ItemEvent e) + { + if (e.getSource() == displayName) + { + displayNameCheckboxAction(); + } + else if (e.getSource() == description) + { + discriptionCheckboxAction(); + } + + } + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == thresholdValue) + { + try + { + float f = new Float(thresholdValue.getText()).floatValue(); + slider.setValue((int) (f * 1000)); + adjustmentValueChanged(null); + } catch (NumberFormatException ex) + { + } + } + + else if (evt.getSource() == ok) + { + ok_actionPerformed(null); + } + else if (evt.getSource() == cancel) + { + cancel_actionPerformed(null); + } + else if (evt.getSource() == thresholdValue) + { + thresholdValue_actionPerformed(null); + } + else + { + updateView(); + } + } + + @Override + public void mouseClicked(MouseEvent e) + { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) + { + if (e.getSource() == slider) + { + updateView(); + } + + } + + @Override + public void mouseReleased(MouseEvent e) + { + if (e.getSource() == slider) + { + updateView(); + } + } + + @Override + public void mouseEntered(MouseEvent e) + { + if (e.getSource() == slider) + { + updateView(); + } + } + + @Override + public void mouseExited(MouseEvent e) + { + if (e.getSource() == slider) + { + updateView(); + } + } + +} diff --git a/unused/appletgui/AnnotationLabels.java b/unused/appletgui/AnnotationLabels.java index 1d61ce4..ad798ab 100644 --- a/unused/appletgui/AnnotationLabels.java +++ b/unused/appletgui/AnnotationLabels.java @@ -1,862 +1,862 @@ -/* - * 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. - * - * 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 . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.appletgui; - -import jalview.analysis.AlignmentUtils; -import jalview.bin.JalviewLite; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.Annotation; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -import jalview.util.MessageManager; -import jalview.util.ParseHtmlBodyAndLinks; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.Arrays; -import java.util.Collections; -import java.util.Vector; - -import javax.swing.JCheckBox; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFrame; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -public class AnnotationLabels extends JPanel implements ActionListener, - MouseListener, MouseMotionListener -{ - Image image; - - boolean active = false; - - AlignmentPanel ap; - - AlignViewport av; - - boolean resizing = false; - - int oldY, mouseX; - - static String ADDNEW = "Add New Row"; - - static String EDITNAME = "Edit Label/Description"; - - static String HIDE = "Hide This Row"; - - static String SHOWALL = "Show All Hidden Rows"; - - static String OUTPUT_TEXT = "Show Values In Textbox"; - - static String COPYCONS_SEQ = "Copy Consensus Sequence"; - - int scrollOffset = 0; - - int selectedRow = -1; - - Tooltip tooltip; - - private boolean hasHiddenRows; - - public AnnotationLabels(AlignmentPanel ap) - { - this.ap = ap; - this.av = ap.av; - setLayout(null); - - /** - * this retrieves the adjustable height glyph from resources. we don't use - * it at the moment. java.net.URL url = - * getClass().getResource("/images/idwidth.gif"); Image temp = null; - * - * if (url != null) { temp = - * java.awt.Toolkit.getDefaultToolkit().createImage(url); } - * - * try { MediaTracker mt = new MediaTracker(this); mt.addImage(temp, 0); - * mt.waitForID(0); } catch (Exception ex) { } - * - * BufferedImage bi = new BufferedImage(temp.getHeight(this), - * temp.getWidth(this), BufferedImage.TYPE_INT_RGB); Graphics2D g = - * (Graphics2D) bi.getGraphics(); g.rotate(Math.toRadians(90)); - * g.drawImage(temp, 0, -bi.getWidth(this), this); image = (Image) bi; - */ - addMouseListener(this); - addMouseMotionListener(this); - } - - public AnnotationLabels(AlignViewport av) - { - this.av = av; - } - - public void setScrollOffset(int y, boolean repaint) - { - scrollOffset = y; - if (repaint) - { - repaint(); - } - } - - /** - * - * @param y - * @return -2 if no rows are visible at all, -1 if no visible rows were - * selected - */ - int getSelectedRow(int y) - { - int row = -2; - AlignmentAnnotation[] aa = ap.av.getAlignment() - .getAlignmentAnnotation(); - - if (aa == null) - { - return row; - } - int height = 0; - for (int i = 0; i < aa.length; i++) - { - row = -1; - if (!aa[i].visible) - { - continue; - } - height += aa[i].height; - if (y < height) - { - row = i; - break; - } - } - - return row; - } - - public void actionPerformed(ActionEvent evt) - { - AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation(); - - if (evt.getActionCommand().equals(ADDNEW)) - { - AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", null, - new Annotation[ap.av.getAlignment().getWidth()]); - - if (!editLabelDescription(newAnnotation)) - { - return; - } - - ap.av.getAlignment().addAnnotation(newAnnotation); - ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0); - } - else if (evt.getActionCommand().equals(EDITNAME)) - { - editLabelDescription(aa[selectedRow]); - } - else if (evt.getActionCommand().equals(HIDE)) - { - aa[selectedRow].visible = false; - } - else if (evt.getActionCommand().equals(SHOWALL)) - { - for (int i = 0; i < aa.length; i++) - { - aa[i].visible = (aa[i].annotations == null) ? false : true; - } - } - else if (evt.getActionCommand().equals(OUTPUT_TEXT)) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, - ap.alignFrame); - JFrame frame = new JFrame(); - frame.add(cap); - JalviewLite.addFrame(frame, ap.alignFrame.getTitle() - + " - " + aa[selectedRow].label, 500, 100); - cap.setText(aa[selectedRow].toString()); - } - else if (evt.getActionCommand().equals(COPYCONS_SEQ)) - { - SequenceI cons = av.getConsensusSeq(); - if (cons != null) - { - copy_annotseqtoclipboard(cons); - } - - } - refresh(); - } - - /** - * Adjust size and repaint - */ - protected void refresh() - { - ap.annotationPanel.adjustPanelHeight(); - setSize(getSize().width, ap.annotationPanel.getSize().height); - ap.validate(); - ap.paintAlignment(true); - } - - boolean editLabelDescription(AlignmentAnnotation annotation) - { - JCheckBox padGaps = new JCheckBox("Fill Empty Gaps With \"" - + ap.av.getGapCharacter() + "\"", annotation.padGaps); - - EditNameDialog dialog = new EditNameDialog(annotation.label, - annotation.description, " Annotation Label", - "Annotation Description", ap.alignFrame, - "Edit Annotation Name / Description", 500, 180, false); - - JPanel empty = new JPanel(new FlowLayout()); - empty.add(padGaps); - dialog.add(empty); - dialog.pack(); - - dialog.setVisible(true); - - if (dialog.accept) - { - annotation.label = dialog.getName(); - annotation.description = dialog.getDescription(); - annotation.setPadGaps(padGaps.isSelected(), av.getGapCharacter()); - repaint(); - return true; - } - else - { - return false; - } - - } - - boolean resizePanel = false; - - public void mouseMoved(MouseEvent evt) - { - resizePanel = evt.getY() < 10 && evt.getX() < 14; - int row = getSelectedRow(evt.getY() + scrollOffset); - - if (row > -1) - { - ParseHtmlBodyAndLinks phb = new ParseHtmlBodyAndLinks( - av.getAlignment().getAlignmentAnnotation()[row] - .getDescription(true), - true, "\n"); - if (tooltip == null) - { - tooltip = new Tooltip(phb.getNonHtmlContent(), this); - } - else - { - tooltip.setTip(phb.getNonHtmlContent()); - } - } - else if (tooltip != null) - { - tooltip.setTip(""); - } - } - - /** - * curent drag position - */ - MouseEvent dragEvent = null; - - /** - * flag to indicate drag events should be ignored - */ - private boolean dragCancelled = false; - - /** - * clear any drag events in progress - */ - public void cancelDrag() - { - dragEvent = null; - dragCancelled = true; - } - - public void mouseDragged(MouseEvent evt) - { - if (dragCancelled) - { - return; - } - ; - dragEvent = evt; - - if (resizePanel) - { - Dimension d = ap.annotationPanelHolder.getSize(), e = ap.annotationSpaceFillerHolder - .getSize(), f = ap.seqPanelHolder.getSize(); - int dif = evt.getY() - oldY; - - dif /= ap.av.getCharHeight(); - dif *= ap.av.getCharHeight(); - - if ((d.height - dif) > 20 && (f.height + dif) > 20) - { - ap.annotationPanel.setSize(d.width, d.height - dif); - setSize(new Dimension(e.width, d.height - dif)); - ap.annotationSpaceFillerHolder.setSize(new Dimension(e.width, - d.height - dif)); - ap.annotationPanelHolder.setSize(new Dimension(d.width, d.height - - dif)); - ap.apvscroll.setValues(ap.apvscroll.getValue(), d.height - dif, 0, - av.calcPanelHeight()); - f.height += dif; - ap.seqPanelHolder.setPreferredSize(f); - ap.setScrollValues(av.getStartRes(), av.getStartSeq()); - ap.validate(); - // ap.paintAlignment(true); - ap.addNotify(); - } - - } - else - { - int diff; - if ((diff = 6 - evt.getY()) > 0) - { - // nudge scroll up - ap.apvscroll.setValue(ap.apvscroll.getValue() - diff); - ap.adjustmentValueChanged(null); - - } - else if ((0 < (diff = 6 - - ap.annotationSpaceFillerHolder.getSize().height - + evt.getY()))) - { - // nudge scroll down - ap.apvscroll.setValue(ap.apvscroll.getValue() + diff); - ap.adjustmentValueChanged(null); - } - repaint(); - } - } - - public void mouseClicked(MouseEvent evt) - { - } - - public void mouseReleased(MouseEvent evt) - { - if (!resizePanel && !dragCancelled) - { - int start = selectedRow; - - int end = getSelectedRow(evt.getY() + scrollOffset); - - if (start > -1 && start != end) - { - // Swap these annotations - AlignmentAnnotation startAA = ap.av.getAlignment() - .getAlignmentAnnotation()[start]; - if (end == -1) - { - end = ap.av.getAlignment().getAlignmentAnnotation().length - 1; - } - AlignmentAnnotation endAA = ap.av.getAlignment() - .getAlignmentAnnotation()[end]; - - ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA; - ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA; - } - } - resizePanel = false; - dragEvent = null; - dragCancelled = false; - repaint(); - ap.annotationPanel.repaint(); - } - - public void mouseEntered(MouseEvent evt) - { - if (evt.getY() < 10 && evt.getX() < 14) - { - resizePanel = true; - repaint(); - } - } - - public void mouseExited(MouseEvent evt) - { - dragCancelled = false; - - if (dragEvent == null) - { - resizePanel = false; - } - else - { - if (!resizePanel) - { - dragEvent = null; - } - } - repaint(); - } - - public void mousePressed(MouseEvent evt) - { - oldY = evt.getY(); - if (resizePanel) - { - return; - } - dragCancelled = false; - // todo: move below to mouseClicked ? - selectedRow = getSelectedRow(evt.getY() + scrollOffset); - - AlignmentAnnotation[] aa = ap.av.getAlignment() - .getAlignmentAnnotation(); - - // DETECT RIGHT MOUSE BUTTON IN AWT - if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) - { - - JPopupMenu popup = new JPopupMenu( - MessageManager.getString("label.annotations")); - - JMenuItem item = new JMenuItem(ADDNEW); - item.addActionListener(this); - popup.add(item); - if (selectedRow < 0) - { - // this never happens at moment: - see comment on JAL-563 - if (hasHiddenRows) - { - item = new JMenuItem(SHOWALL); - item.addActionListener(this); - popup.add(item); - } - this.add(popup); - popup.show(this, evt.getX(), evt.getY()); - return; - } - // add the rest if there are actually rows to show - item = new JMenuItem(EDITNAME); - item.addActionListener(this); - popup.add(item); - item = new JMenuItem(HIDE); - item.addActionListener(this); - popup.add(item); - - /* - * Hide all

    - * The performance of the methods found in String and Character is better, but - * these methods work both in java 1.0 and 1.1. If it is desirable, either to - * gain a slight performance increase or to accomodate application specific - * modifications to the definitions of upper, lower, and title case then it - * should be a straightforward task to substitute your own methods for these. - */ -final public class CaseMgr -{ - final static boolean java_1_0 = false; - - /** Convert a character to upper case . */ - public static char toUpperCase(char c) - { - if (java_1_0) - { - int ret = (int) c; - switch (c) - { - case 97: - ret = 65; - break; - case 98: - ret = 66; - break; - case 99: - ret = 67; - break; - case 100: - ret = 68; - break; - case 101: - ret = 69; - break; - case 102: - ret = 70; - break; - case 103: - ret = 71; - break; - case 104: - ret = 72; - break; - case 105: - ret = 73; - break; - case 106: - ret = 74; - break; - case 107: - ret = 75; - break; - case 108: - ret = 76; - break; - case 109: - ret = 77; - break; - case 110: - ret = 78; - break; - case 111: - ret = 79; - break; - case 112: - ret = 80; - break; - case 113: - ret = 81; - break; - case 114: - ret = 82; - break; - case 115: - ret = 83; - break; - case 116: - ret = 84; - break; - case 117: - ret = 85; - break; - case 118: - ret = 86; - break; - case 119: - ret = 87; - break; - case 120: - ret = 88; - break; - case 121: - ret = 89; - break; - case 122: - ret = 90; - break; - case 224: - ret = 192; - break; - case 225: - ret = 193; - break; - case 226: - ret = 194; - break; - case 227: - ret = 195; - break; - case 228: - ret = 196; - break; - case 229: - ret = 197; - break; - case 230: - ret = 198; - break; - case 231: - ret = 199; - break; - case 232: - ret = 200; - break; - case 233: - ret = 201; - break; - case 234: - ret = 202; - break; - case 235: - ret = 203; - break; - case 236: - ret = 204; - break; - case 237: - ret = 205; - break; - case 238: - ret = 206; - break; - case 239: - ret = 207; - break; - case 240: - ret = 208; - break; - case 241: - ret = 209; - break; - case 242: - ret = 210; - break; - case 243: - ret = 211; - break; - case 244: - ret = 212; - break; - case 245: - ret = 213; - break; - case 246: - ret = 214; - break; - case 248: - ret = 216; - break; - case 249: - ret = 217; - break; - case 250: - ret = 218; - break; - case 251: - ret = 219; - break; - case 252: - ret = 220; - break; - case 253: - ret = 221; - break; - case 254: - ret = 222; - break; - case 255: - ret = 376; - break; - case 257: - ret = 256; - break; - case 259: - ret = 258; - break; - case 261: - ret = 260; - break; - case 263: - ret = 262; - break; - case 265: - ret = 264; - break; - case 267: - ret = 266; - break; - case 269: - ret = 268; - break; - case 271: - ret = 270; - break; - case 273: - ret = 272; - break; - case 275: - ret = 274; - break; - case 277: - ret = 276; - break; - case 279: - ret = 278; - break; - case 281: - ret = 280; - break; - case 283: - ret = 282; - break; - case 285: - ret = 284; - break; - case 287: - ret = 286; - break; - case 289: - ret = 288; - break; - case 291: - ret = 290; - break; - case 293: - ret = 292; - break; - case 295: - ret = 294; - break; - case 297: - ret = 296; - break; - case 299: - ret = 298; - break; - case 301: - ret = 300; - break; - case 303: - ret = 302; - break; - case 305: - ret = 73; - break; - case 307: - ret = 306; - break; - case 309: - ret = 308; - break; - case 311: - ret = 310; - break; - case 314: - ret = 313; - break; - case 316: - ret = 315; - break; - case 318: - ret = 317; - break; - case 320: - ret = 319; - break; - case 322: - ret = 321; - break; - case 324: - ret = 323; - break; - case 326: - ret = 325; - break; - case 328: - ret = 327; - break; - case 331: - ret = 330; - break; - case 333: - ret = 332; - break; - case 335: - ret = 334; - break; - case 337: - ret = 336; - break; - case 339: - ret = 338; - break; - case 341: - ret = 340; - break; - case 343: - ret = 342; - break; - case 345: - ret = 344; - break; - case 347: - ret = 346; - break; - case 349: - ret = 348; - break; - case 351: - ret = 350; - break; - case 353: - ret = 352; - break; - case 355: - ret = 354; - break; - case 357: - ret = 356; - break; - case 359: - ret = 358; - break; - case 361: - ret = 360; - break; - case 363: - ret = 362; - break; - case 365: - ret = 364; - break; - case 367: - ret = 366; - break; - case 369: - ret = 368; - break; - case 371: - ret = 370; - break; - case 373: - ret = 372; - break; - case 375: - ret = 374; - break; - case 378: - ret = 377; - break; - case 380: - ret = 379; - break; - case 382: - ret = 381; - break; - case 383: - ret = 83; - break; - case 387: - ret = 386; - break; - case 389: - ret = 388; - break; - case 392: - ret = 391; - break; - case 396: - ret = 395; - break; - case 402: - ret = 401; - break; - case 409: - ret = 408; - break; - case 417: - ret = 416; - break; - case 419: - ret = 418; - break; - case 421: - ret = 420; - break; - case 424: - ret = 423; - break; - case 429: - ret = 428; - break; - case 432: - ret = 431; - break; - case 436: - ret = 435; - break; - case 438: - ret = 437; - break; - case 441: - ret = 440; - break; - case 445: - ret = 444; - break; - case 453: - ret = 452; - break; - case 454: - ret = 452; - break; - case 456: - ret = 455; - break; - case 457: - ret = 455; - break; - case 459: - ret = 458; - break; - case 460: - ret = 458; - break; - case 462: - ret = 461; - break; - case 464: - ret = 463; - break; - case 466: - ret = 465; - break; - case 468: - ret = 467; - break; - case 470: - ret = 469; - break; - case 472: - ret = 471; - break; - case 474: - ret = 473; - break; - case 476: - ret = 475; - break; - case 479: - ret = 478; - break; - case 481: - ret = 480; - break; - case 483: - ret = 482; - break; - case 485: - ret = 484; - break; - case 487: - ret = 486; - break; - case 489: - ret = 488; - break; - case 491: - ret = 490; - break; - case 493: - ret = 492; - break; - case 495: - ret = 494; - break; - case 498: - ret = 497; - break; - case 499: - ret = 497; - break; - case 501: - ret = 500; - break; - case 507: - ret = 506; - break; - case 509: - ret = 508; - break; - case 511: - ret = 510; - break; - case 513: - ret = 512; - break; - case 515: - ret = 514; - break; - case 517: - ret = 516; - break; - case 519: - ret = 518; - break; - case 521: - ret = 520; - break; - case 523: - ret = 522; - break; - case 525: - ret = 524; - break; - case 527: - ret = 526; - break; - case 529: - ret = 528; - break; - case 531: - ret = 530; - break; - case 533: - ret = 532; - break; - case 535: - ret = 534; - break; - case 595: - ret = 385; - break; - case 596: - ret = 390; - break; - case 598: - ret = 393; - break; - case 599: - ret = 394; - break; - case 600: - ret = 398; - break; - case 601: - ret = 399; - break; - case 603: - ret = 400; - break; - case 608: - ret = 403; - break; - case 611: - ret = 404; - break; - case 616: - ret = 407; - break; - case 617: - ret = 406; - break; - case 623: - ret = 412; - break; - case 626: - ret = 413; - break; - case 643: - ret = 425; - break; - case 648: - ret = 430; - break; - case 650: - ret = 433; - break; - case 651: - ret = 434; - break; - case 658: - ret = 439; - break; - case 940: - ret = 902; - break; - case 941: - ret = 904; - break; - case 942: - ret = 905; - break; - case 943: - ret = 906; - break; - case 945: - ret = 913; - break; - case 946: - ret = 914; - break; - case 947: - ret = 915; - break; - case 948: - ret = 916; - break; - case 949: - ret = 917; - break; - case 950: - ret = 918; - break; - case 951: - ret = 919; - break; - case 952: - ret = 920; - break; - case 953: - ret = 921; - break; - case 954: - ret = 922; - break; - case 955: - ret = 923; - break; - case 956: - ret = 924; - break; - case 957: - ret = 925; - break; - case 958: - ret = 926; - break; - case 959: - ret = 927; - break; - case 960: - ret = 928; - break; - case 961: - ret = 929; - break; - case 963: - ret = 931; - break; - case 964: - ret = 932; - break; - case 965: - ret = 933; - break; - case 966: - ret = 934; - break; - case 967: - ret = 935; - break; - case 968: - ret = 936; - break; - case 969: - ret = 937; - break; - case 970: - ret = 938; - break; - case 971: - ret = 939; - break; - case 972: - ret = 908; - break; - case 973: - ret = 910; - break; - case 974: - ret = 911; - break; - case 976: - ret = 914; - break; - case 977: - ret = 920; - break; - case 981: - ret = 934; - break; - case 982: - ret = 928; - break; - case 995: - ret = 994; - break; - case 997: - ret = 996; - break; - case 999: - ret = 998; - break; - case 1001: - ret = 1000; - break; - case 1003: - ret = 1002; - break; - case 1005: - ret = 1004; - break; - case 1007: - ret = 1006; - break; - case 1008: - ret = 922; - break; - case 1009: - ret = 929; - break; - case 1072: - ret = 1040; - break; - case 1073: - ret = 1041; - break; - case 1074: - ret = 1042; - break; - case 1075: - ret = 1043; - break; - case 1076: - ret = 1044; - break; - case 1077: - ret = 1045; - break; - case 1078: - ret = 1046; - break; - case 1079: - ret = 1047; - break; - case 1080: - ret = 1048; - break; - case 1081: - ret = 1049; - break; - case 1082: - ret = 1050; - break; - case 1083: - ret = 1051; - break; - case 1084: - ret = 1052; - break; - case 1085: - ret = 1053; - break; - case 1086: - ret = 1054; - break; - case 1087: - ret = 1055; - break; - case 1088: - ret = 1056; - break; - case 1089: - ret = 1057; - break; - case 1090: - ret = 1058; - break; - case 1091: - ret = 1059; - break; - case 1092: - ret = 1060; - break; - case 1093: - ret = 1061; - break; - case 1094: - ret = 1062; - break; - case 1095: - ret = 1063; - break; - case 1096: - ret = 1064; - break; - case 1097: - ret = 1065; - break; - case 1098: - ret = 1066; - break; - case 1099: - ret = 1067; - break; - case 1100: - ret = 1068; - break; - case 1101: - ret = 1069; - break; - case 1102: - ret = 1070; - break; - case 1103: - ret = 1071; - break; - case 1105: - ret = 1025; - break; - case 1106: - ret = 1026; - break; - case 1107: - ret = 1027; - break; - case 1108: - ret = 1028; - break; - case 1109: - ret = 1029; - break; - case 1110: - ret = 1030; - break; - case 1111: - ret = 1031; - break; - case 1112: - ret = 1032; - break; - case 1113: - ret = 1033; - break; - case 1114: - ret = 1034; - break; - case 1115: - ret = 1035; - break; - case 1116: - ret = 1036; - break; - case 1118: - ret = 1038; - break; - case 1119: - ret = 1039; - break; - case 1121: - ret = 1120; - break; - case 1123: - ret = 1122; - break; - case 1125: - ret = 1124; - break; - case 1127: - ret = 1126; - break; - case 1129: - ret = 1128; - break; - case 1131: - ret = 1130; - break; - case 1133: - ret = 1132; - break; - case 1135: - ret = 1134; - break; - case 1137: - ret = 1136; - break; - case 1139: - ret = 1138; - break; - case 1141: - ret = 1140; - break; - case 1143: - ret = 1142; - break; - case 1145: - ret = 1144; - break; - case 1147: - ret = 1146; - break; - case 1149: - ret = 1148; - break; - case 1151: - ret = 1150; - break; - case 1153: - ret = 1152; - break; - case 1169: - ret = 1168; - break; - case 1171: - ret = 1170; - break; - case 1173: - ret = 1172; - break; - case 1175: - ret = 1174; - break; - case 1177: - ret = 1176; - break; - case 1179: - ret = 1178; - break; - case 1181: - ret = 1180; - break; - case 1183: - ret = 1182; - break; - case 1185: - ret = 1184; - break; - case 1187: - ret = 1186; - break; - case 1189: - ret = 1188; - break; - case 1191: - ret = 1190; - break; - case 1193: - ret = 1192; - break; - case 1195: - ret = 1194; - break; - case 1197: - ret = 1196; - break; - case 1199: - ret = 1198; - break; - case 1201: - ret = 1200; - break; - case 1203: - ret = 1202; - break; - case 1205: - ret = 1204; - break; - case 1207: - ret = 1206; - break; - case 1209: - ret = 1208; - break; - case 1211: - ret = 1210; - break; - case 1213: - ret = 1212; - break; - case 1215: - ret = 1214; - break; - case 1218: - ret = 1217; - break; - case 1220: - ret = 1219; - break; - case 1224: - ret = 1223; - break; - case 1228: - ret = 1227; - break; - case 1233: - ret = 1232; - break; - case 1235: - ret = 1234; - break; - case 1237: - ret = 1236; - break; - case 1239: - ret = 1238; - break; - case 1241: - ret = 1240; - break; - case 1243: - ret = 1242; - break; - case 1245: - ret = 1244; - break; - case 1247: - ret = 1246; - break; - case 1249: - ret = 1248; - break; - case 1251: - ret = 1250; - break; - case 1253: - ret = 1252; - break; - case 1255: - ret = 1254; - break; - case 1257: - ret = 1256; - break; - case 1259: - ret = 1258; - break; - case 1263: - ret = 1262; - break; - case 1265: - ret = 1264; - break; - case 1267: - ret = 1266; - break; - case 1269: - ret = 1268; - break; - case 1273: - ret = 1272; - break; - case 1377: - ret = 1329; - break; - case 1378: - ret = 1330; - break; - case 1379: - ret = 1331; - break; - case 1380: - ret = 1332; - break; - case 1381: - ret = 1333; - break; - case 1382: - ret = 1334; - break; - case 1383: - ret = 1335; - break; - case 1384: - ret = 1336; - break; - case 1385: - ret = 1337; - break; - case 1386: - ret = 1338; - break; - case 1387: - ret = 1339; - break; - case 1388: - ret = 1340; - break; - case 1389: - ret = 1341; - break; - case 1390: - ret = 1342; - break; - case 1391: - ret = 1343; - break; - case 1392: - ret = 1344; - break; - case 1393: - ret = 1345; - break; - case 1394: - ret = 1346; - break; - case 1395: - ret = 1347; - break; - case 1396: - ret = 1348; - break; - case 1397: - ret = 1349; - break; - case 1398: - ret = 1350; - break; - case 1399: - ret = 1351; - break; - case 1400: - ret = 1352; - break; - case 1401: - ret = 1353; - break; - case 1402: - ret = 1354; - break; - case 1403: - ret = 1355; - break; - case 1404: - ret = 1356; - break; - case 1405: - ret = 1357; - break; - case 1406: - ret = 1358; - break; - case 1407: - ret = 1359; - break; - case 1408: - ret = 1360; - break; - case 1409: - ret = 1361; - break; - case 1410: - ret = 1362; - break; - case 1411: - ret = 1363; - break; - case 1412: - ret = 1364; - break; - case 1413: - ret = 1365; - break; - case 1414: - ret = 1366; - break; - case 7681: - ret = 7680; - break; - case 7683: - ret = 7682; - break; - case 7685: - ret = 7684; - break; - case 7687: - ret = 7686; - break; - case 7689: - ret = 7688; - break; - case 7691: - ret = 7690; - break; - case 7693: - ret = 7692; - break; - case 7695: - ret = 7694; - break; - case 7697: - ret = 7696; - break; - case 7699: - ret = 7698; - break; - case 7701: - ret = 7700; - break; - case 7703: - ret = 7702; - break; - case 7705: - ret = 7704; - break; - case 7707: - ret = 7706; - break; - case 7709: - ret = 7708; - break; - case 7711: - ret = 7710; - break; - case 7713: - ret = 7712; - break; - case 7715: - ret = 7714; - break; - case 7717: - ret = 7716; - break; - case 7719: - ret = 7718; - break; - case 7721: - ret = 7720; - break; - case 7723: - ret = 7722; - break; - case 7725: - ret = 7724; - break; - case 7727: - ret = 7726; - break; - case 7729: - ret = 7728; - break; - case 7731: - ret = 7730; - break; - case 7733: - ret = 7732; - break; - case 7735: - ret = 7734; - break; - case 7737: - ret = 7736; - break; - case 7739: - ret = 7738; - break; - case 7741: - ret = 7740; - break; - case 7743: - ret = 7742; - break; - case 7745: - ret = 7744; - break; - case 7747: - ret = 7746; - break; - case 7749: - ret = 7748; - break; - case 7751: - ret = 7750; - break; - case 7753: - ret = 7752; - break; - case 7755: - ret = 7754; - break; - case 7757: - ret = 7756; - break; - case 7759: - ret = 7758; - break; - case 7761: - ret = 7760; - break; - case 7763: - ret = 7762; - break; - case 7765: - ret = 7764; - break; - case 7767: - ret = 7766; - break; - case 7769: - ret = 7768; - break; - case 7771: - ret = 7770; - break; - case 7773: - ret = 7772; - break; - case 7775: - ret = 7774; - break; - case 7777: - ret = 7776; - break; - case 7779: - ret = 7778; - break; - case 7781: - ret = 7780; - break; - case 7783: - ret = 7782; - break; - case 7785: - ret = 7784; - break; - case 7787: - ret = 7786; - break; - case 7789: - ret = 7788; - break; - case 7791: - ret = 7790; - break; - case 7793: - ret = 7792; - break; - case 7795: - ret = 7794; - break; - case 7797: - ret = 7796; - break; - case 7799: - ret = 7798; - break; - case 7801: - ret = 7800; - break; - case 7803: - ret = 7802; - break; - case 7805: - ret = 7804; - break; - case 7807: - ret = 7806; - break; - case 7809: - ret = 7808; - break; - case 7811: - ret = 7810; - break; - case 7813: - ret = 7812; - break; - case 7815: - ret = 7814; - break; - case 7817: - ret = 7816; - break; - case 7819: - ret = 7818; - break; - case 7821: - ret = 7820; - break; - case 7823: - ret = 7822; - break; - case 7825: - ret = 7824; - break; - case 7827: - ret = 7826; - break; - case 7829: - ret = 7828; - break; - case 7841: - ret = 7840; - break; - case 7843: - ret = 7842; - break; - case 7845: - ret = 7844; - break; - case 7847: - ret = 7846; - break; - case 7849: - ret = 7848; - break; - case 7851: - ret = 7850; - break; - case 7853: - ret = 7852; - break; - case 7855: - ret = 7854; - break; - case 7857: - ret = 7856; - break; - case 7859: - ret = 7858; - break; - case 7861: - ret = 7860; - break; - case 7863: - ret = 7862; - break; - case 7865: - ret = 7864; - break; - case 7867: - ret = 7866; - break; - case 7869: - ret = 7868; - break; - case 7871: - ret = 7870; - break; - case 7873: - ret = 7872; - break; - case 7875: - ret = 7874; - break; - case 7877: - ret = 7876; - break; - case 7879: - ret = 7878; - break; - case 7881: - ret = 7880; - break; - case 7883: - ret = 7882; - break; - case 7885: - ret = 7884; - break; - case 7887: - ret = 7886; - break; - case 7889: - ret = 7888; - break; - case 7891: - ret = 7890; - break; - case 7893: - ret = 7892; - break; - case 7895: - ret = 7894; - break; - case 7897: - ret = 7896; - break; - case 7899: - ret = 7898; - break; - case 7901: - ret = 7900; - break; - case 7903: - ret = 7902; - break; - case 7905: - ret = 7904; - break; - case 7907: - ret = 7906; - break; - case 7909: - ret = 7908; - break; - case 7911: - ret = 7910; - break; - case 7913: - ret = 7912; - break; - case 7915: - ret = 7914; - break; - case 7917: - ret = 7916; - break; - case 7919: - ret = 7918; - break; - case 7921: - ret = 7920; - break; - case 7923: - ret = 7922; - break; - case 7925: - ret = 7924; - break; - case 7927: - ret = 7926; - break; - case 7929: - ret = 7928; - break; - case 7936: - ret = 7944; - break; - case 7937: - ret = 7945; - break; - case 7938: - ret = 7946; - break; - case 7939: - ret = 7947; - break; - case 7940: - ret = 7948; - break; - case 7941: - ret = 7949; - break; - case 7942: - ret = 7950; - break; - case 7943: - ret = 7951; - break; - case 7952: - ret = 7960; - break; - case 7953: - ret = 7961; - break; - case 7954: - ret = 7962; - break; - case 7955: - ret = 7963; - break; - case 7956: - ret = 7964; - break; - case 7957: - ret = 7965; - break; - case 7968: - ret = 7976; - break; - case 7969: - ret = 7977; - break; - case 7970: - ret = 7978; - break; - case 7971: - ret = 7979; - break; - case 7972: - ret = 7980; - break; - case 7973: - ret = 7981; - break; - case 7974: - ret = 7982; - break; - case 7975: - ret = 7983; - break; - case 7984: - ret = 7992; - break; - case 7985: - ret = 7993; - break; - case 7986: - ret = 7994; - break; - case 7987: - ret = 7995; - break; - case 7988: - ret = 7996; - break; - case 7989: - ret = 7997; - break; - case 7990: - ret = 7998; - break; - case 7991: - ret = 7999; - break; - case 8000: - ret = 8008; - break; - case 8001: - ret = 8009; - break; - case 8002: - ret = 8010; - break; - case 8003: - ret = 8011; - break; - case 8004: - ret = 8012; - break; - case 8005: - ret = 8013; - break; - case 8017: - ret = 8025; - break; - case 8019: - ret = 8027; - break; - case 8021: - ret = 8029; - break; - case 8023: - ret = 8031; - break; - case 8032: - ret = 8040; - break; - case 8033: - ret = 8041; - break; - case 8034: - ret = 8042; - break; - case 8035: - ret = 8043; - break; - case 8036: - ret = 8044; - break; - case 8037: - ret = 8045; - break; - case 8038: - ret = 8046; - break; - case 8039: - ret = 8047; - break; - case 8048: - ret = 8122; - break; - case 8049: - ret = 8123; - break; - case 8050: - ret = 8136; - break; - case 8051: - ret = 8137; - break; - case 8052: - ret = 8138; - break; - case 8053: - ret = 8139; - break; - case 8054: - ret = 8154; - break; - case 8055: - ret = 8155; - break; - case 8056: - ret = 8184; - break; - case 8057: - ret = 8185; - break; - case 8058: - ret = 8170; - break; - case 8059: - ret = 8171; - break; - case 8060: - ret = 8186; - break; - case 8061: - ret = 8187; - break; - case 8064: - ret = 8072; - break; - case 8065: - ret = 8073; - break; - case 8066: - ret = 8074; - break; - case 8067: - ret = 8075; - break; - case 8068: - ret = 8076; - break; - case 8069: - ret = 8077; - break; - case 8070: - ret = 8078; - break; - case 8071: - ret = 8079; - break; - case 8080: - ret = 8088; - break; - case 8081: - ret = 8089; - break; - case 8082: - ret = 8090; - break; - case 8083: - ret = 8091; - break; - case 8084: - ret = 8092; - break; - case 8085: - ret = 8093; - break; - case 8086: - ret = 8094; - break; - case 8087: - ret = 8095; - break; - case 8096: - ret = 8104; - break; - case 8097: - ret = 8105; - break; - case 8098: - ret = 8106; - break; - case 8099: - ret = 8107; - break; - case 8100: - ret = 8108; - break; - case 8101: - ret = 8109; - break; - case 8102: - ret = 8110; - break; - case 8103: - ret = 8111; - break; - case 8112: - ret = 8120; - break; - case 8113: - ret = 8121; - break; - case 8115: - ret = 8124; - break; - case 8131: - ret = 8140; - break; - case 8144: - ret = 8152; - break; - case 8145: - ret = 8153; - break; - case 8160: - ret = 8168; - break; - case 8161: - ret = 8169; - break; - case 8165: - ret = 8172; - break; - case 8179: - ret = 8188; - break; - case 8560: - ret = 8544; - break; - case 8561: - ret = 8545; - break; - case 8562: - ret = 8546; - break; - case 8563: - ret = 8547; - break; - case 8564: - ret = 8548; - break; - case 8565: - ret = 8549; - break; - case 8566: - ret = 8550; - break; - case 8567: - ret = 8551; - break; - case 8568: - ret = 8552; - break; - case 8569: - ret = 8553; - break; - case 8570: - ret = 8554; - break; - case 8571: - ret = 8555; - break; - case 8572: - ret = 8556; - break; - case 8573: - ret = 8557; - break; - case 8574: - ret = 8558; - break; - case 8575: - ret = 8559; - break; - case 9424: - ret = 9398; - break; - case 9425: - ret = 9399; - break; - case 9426: - ret = 9400; - break; - case 9427: - ret = 9401; - break; - case 9428: - ret = 9402; - break; - case 9429: - ret = 9403; - break; - case 9430: - ret = 9404; - break; - case 9431: - ret = 9405; - break; - case 9432: - ret = 9406; - break; - case 9433: - ret = 9407; - break; - case 9434: - ret = 9408; - break; - case 9435: - ret = 9409; - break; - case 9436: - ret = 9410; - break; - case 9437: - ret = 9411; - break; - case 9438: - ret = 9412; - break; - case 9439: - ret = 9413; - break; - case 9440: - ret = 9414; - break; - case 9441: - ret = 9415; - break; - case 9442: - ret = 9416; - break; - case 9443: - ret = 9417; - break; - case 9444: - ret = 9418; - break; - case 9445: - ret = 9419; - break; - case 9446: - ret = 9420; - break; - case 9447: - ret = 9421; - break; - case 9448: - ret = 9422; - break; - case 9449: - ret = 9423; - break; - case 65345: - ret = 65313; - break; - case 65346: - ret = 65314; - break; - case 65347: - ret = 65315; - break; - case 65348: - ret = 65316; - break; - case 65349: - ret = 65317; - break; - case 65350: - ret = 65318; - break; - case 65351: - ret = 65319; - break; - case 65352: - ret = 65320; - break; - case 65353: - ret = 65321; - break; - case 65354: - ret = 65322; - break; - case 65355: - ret = 65323; - break; - case 65356: - ret = 65324; - break; - case 65357: - ret = 65325; - break; - case 65358: - ret = 65326; - break; - case 65359: - ret = 65327; - break; - case 65360: - ret = 65328; - break; - case 65361: - ret = 65329; - break; - case 65362: - ret = 65330; - break; - case 65363: - ret = 65331; - break; - case 65364: - ret = 65332; - break; - case 65365: - ret = 65333; - break; - case 65366: - ret = 65334; - break; - case 65367: - ret = 65335; - break; - case 65368: - ret = 65336; - break; - case 65369: - ret = 65337; - break; - case 65370: - ret = 65338; - break; - } - return (char) ret; - } - return Character.toUpperCase(c); - } - - /** Convert a character to lower case. */ - public static char toLowerCase(char c) - { - if (java_1_0) - { - int ret = (int) c; - switch (c) - { - case 65: - ret = 97; - break; - case 66: - ret = 98; - break; - case 67: - ret = 99; - break; - case 68: - ret = 100; - break; - case 69: - ret = 101; - break; - case 70: - ret = 102; - break; - case 71: - ret = 103; - break; - case 72: - ret = 104; - break; - case 73: - ret = 105; - break; - case 74: - ret = 106; - break; - case 75: - ret = 107; - break; - case 76: - ret = 108; - break; - case 77: - ret = 109; - break; - case 78: - ret = 110; - break; - case 79: - ret = 111; - break; - case 80: - ret = 112; - break; - case 81: - ret = 113; - break; - case 82: - ret = 114; - break; - case 83: - ret = 115; - break; - case 84: - ret = 116; - break; - case 85: - ret = 117; - break; - case 86: - ret = 118; - break; - case 87: - ret = 119; - break; - case 88: - ret = 120; - break; - case 89: - ret = 121; - break; - case 90: - ret = 122; - break; - case 192: - ret = 224; - break; - case 193: - ret = 225; - break; - case 194: - ret = 226; - break; - case 195: - ret = 227; - break; - case 196: - ret = 228; - break; - case 197: - ret = 229; - break; - case 198: - ret = 230; - break; - case 199: - ret = 231; - break; - case 200: - ret = 232; - break; - case 201: - ret = 233; - break; - case 202: - ret = 234; - break; - case 203: - ret = 235; - break; - case 204: - ret = 236; - break; - case 205: - ret = 237; - break; - case 206: - ret = 238; - break; - case 207: - ret = 239; - break; - case 208: - ret = 240; - break; - case 209: - ret = 241; - break; - case 210: - ret = 242; - break; - case 211: - ret = 243; - break; - case 212: - ret = 244; - break; - case 213: - ret = 245; - break; - case 214: - ret = 246; - break; - case 216: - ret = 248; - break; - case 217: - ret = 249; - break; - case 218: - ret = 250; - break; - case 219: - ret = 251; - break; - case 220: - ret = 252; - break; - case 221: - ret = 253; - break; - case 222: - ret = 254; - break; - case 256: - ret = 257; - break; - case 258: - ret = 259; - break; - case 260: - ret = 261; - break; - case 262: - ret = 263; - break; - case 264: - ret = 265; - break; - case 266: - ret = 267; - break; - case 268: - ret = 269; - break; - case 270: - ret = 271; - break; - case 272: - ret = 273; - break; - case 274: - ret = 275; - break; - case 276: - ret = 277; - break; - case 278: - ret = 279; - break; - case 280: - ret = 281; - break; - case 282: - ret = 283; - break; - case 284: - ret = 285; - break; - case 286: - ret = 287; - break; - case 288: - ret = 289; - break; - case 290: - ret = 291; - break; - case 292: - ret = 293; - break; - case 294: - ret = 295; - break; - case 296: - ret = 297; - break; - case 298: - ret = 299; - break; - case 300: - ret = 301; - break; - case 302: - ret = 303; - break; - case 304: - ret = 105; - break; - case 306: - ret = 307; - break; - case 308: - ret = 309; - break; - case 310: - ret = 311; - break; - case 313: - ret = 314; - break; - case 315: - ret = 316; - break; - case 317: - ret = 318; - break; - case 319: - ret = 320; - break; - case 321: - ret = 322; - break; - case 323: - ret = 324; - break; - case 325: - ret = 326; - break; - case 327: - ret = 328; - break; - case 330: - ret = 331; - break; - case 332: - ret = 333; - break; - case 334: - ret = 335; - break; - case 336: - ret = 337; - break; - case 338: - ret = 339; - break; - case 340: - ret = 341; - break; - case 342: - ret = 343; - break; - case 344: - ret = 345; - break; - case 346: - ret = 347; - break; - case 348: - ret = 349; - break; - case 350: - ret = 351; - break; - case 352: - ret = 353; - break; - case 354: - ret = 355; - break; - case 356: - ret = 357; - break; - case 358: - ret = 359; - break; - case 360: - ret = 361; - break; - case 362: - ret = 363; - break; - case 364: - ret = 365; - break; - case 366: - ret = 367; - break; - case 368: - ret = 369; - break; - case 370: - ret = 371; - break; - case 372: - ret = 373; - break; - case 374: - ret = 375; - break; - case 376: - ret = 255; - break; - case 377: - ret = 378; - break; - case 379: - ret = 380; - break; - case 381: - ret = 382; - break; - case 385: - ret = 595; - break; - case 386: - ret = 387; - break; - case 388: - ret = 389; - break; - case 390: - ret = 596; - break; - case 391: - ret = 392; - break; - case 393: - ret = 598; - break; - case 394: - ret = 599; - break; - case 395: - ret = 396; - break; - case 398: - ret = 600; - break; - case 399: - ret = 601; - break; - case 400: - ret = 603; - break; - case 401: - ret = 402; - break; - case 403: - ret = 608; - break; - case 404: - ret = 611; - break; - case 406: - ret = 617; - break; - case 407: - ret = 616; - break; - case 408: - ret = 409; - break; - case 412: - ret = 623; - break; - case 413: - ret = 626; - break; - case 416: - ret = 417; - break; - case 418: - ret = 419; - break; - case 420: - ret = 421; - break; - case 423: - ret = 424; - break; - case 425: - ret = 643; - break; - case 428: - ret = 429; - break; - case 430: - ret = 648; - break; - case 431: - ret = 432; - break; - case 433: - ret = 650; - break; - case 434: - ret = 651; - break; - case 435: - ret = 436; - break; - case 437: - ret = 438; - break; - case 439: - ret = 658; - break; - case 440: - ret = 441; - break; - case 444: - ret = 445; - break; - case 452: - ret = 454; - break; - case 453: - ret = 454; - break; - case 455: - ret = 457; - break; - case 456: - ret = 457; - break; - case 458: - ret = 460; - break; - case 459: - ret = 460; - break; - case 461: - ret = 462; - break; - case 463: - ret = 464; - break; - case 465: - ret = 466; - break; - case 467: - ret = 468; - break; - case 469: - ret = 470; - break; - case 471: - ret = 472; - break; - case 473: - ret = 474; - break; - case 475: - ret = 476; - break; - case 478: - ret = 479; - break; - case 480: - ret = 481; - break; - case 482: - ret = 483; - break; - case 484: - ret = 485; - break; - case 486: - ret = 487; - break; - case 488: - ret = 489; - break; - case 490: - ret = 491; - break; - case 492: - ret = 493; - break; - case 494: - ret = 495; - break; - case 497: - ret = 499; - break; - case 498: - ret = 499; - break; - case 500: - ret = 501; - break; - case 506: - ret = 507; - break; - case 508: - ret = 509; - break; - case 510: - ret = 511; - break; - case 512: - ret = 513; - break; - case 514: - ret = 515; - break; - case 516: - ret = 517; - break; - case 518: - ret = 519; - break; - case 520: - ret = 521; - break; - case 522: - ret = 523; - break; - case 524: - ret = 525; - break; - case 526: - ret = 527; - break; - case 528: - ret = 529; - break; - case 530: - ret = 531; - break; - case 532: - ret = 533; - break; - case 534: - ret = 535; - break; - case 902: - ret = 940; - break; - case 904: - ret = 941; - break; - case 905: - ret = 942; - break; - case 906: - ret = 943; - break; - case 908: - ret = 972; - break; - case 910: - ret = 973; - break; - case 911: - ret = 974; - break; - case 913: - ret = 945; - break; - case 914: - ret = 946; - break; - case 915: - ret = 947; - break; - case 916: - ret = 948; - break; - case 917: - ret = 949; - break; - case 918: - ret = 950; - break; - case 919: - ret = 951; - break; - case 920: - ret = 952; - break; - case 921: - ret = 953; - break; - case 922: - ret = 954; - break; - case 923: - ret = 955; - break; - case 924: - ret = 956; - break; - case 925: - ret = 957; - break; - case 926: - ret = 958; - break; - case 927: - ret = 959; - break; - case 928: - ret = 960; - break; - case 929: - ret = 961; - break; - case 931: - ret = 963; - break; - case 932: - ret = 964; - break; - case 933: - ret = 965; - break; - case 934: - ret = 966; - break; - case 935: - ret = 967; - break; - case 936: - ret = 968; - break; - case 937: - ret = 969; - break; - case 938: - ret = 970; - break; - case 939: - ret = 971; - break; - case 994: - ret = 995; - break; - case 996: - ret = 997; - break; - case 998: - ret = 999; - break; - case 1000: - ret = 1001; - break; - case 1002: - ret = 1003; - break; - case 1004: - ret = 1005; - break; - case 1006: - ret = 1007; - break; - case 1025: - ret = 1105; - break; - case 1026: - ret = 1106; - break; - case 1027: - ret = 1107; - break; - case 1028: - ret = 1108; - break; - case 1029: - ret = 1109; - break; - case 1030: - ret = 1110; - break; - case 1031: - ret = 1111; - break; - case 1032: - ret = 1112; - break; - case 1033: - ret = 1113; - break; - case 1034: - ret = 1114; - break; - case 1035: - ret = 1115; - break; - case 1036: - ret = 1116; - break; - case 1038: - ret = 1118; - break; - case 1039: - ret = 1119; - break; - case 1040: - ret = 1072; - break; - case 1041: - ret = 1073; - break; - case 1042: - ret = 1074; - break; - case 1043: - ret = 1075; - break; - case 1044: - ret = 1076; - break; - case 1045: - ret = 1077; - break; - case 1046: - ret = 1078; - break; - case 1047: - ret = 1079; - break; - case 1048: - ret = 1080; - break; - case 1049: - ret = 1081; - break; - case 1050: - ret = 1082; - break; - case 1051: - ret = 1083; - break; - case 1052: - ret = 1084; - break; - case 1053: - ret = 1085; - break; - case 1054: - ret = 1086; - break; - case 1055: - ret = 1087; - break; - case 1056: - ret = 1088; - break; - case 1057: - ret = 1089; - break; - case 1058: - ret = 1090; - break; - case 1059: - ret = 1091; - break; - case 1060: - ret = 1092; - break; - case 1061: - ret = 1093; - break; - case 1062: - ret = 1094; - break; - case 1063: - ret = 1095; - break; - case 1064: - ret = 1096; - break; - case 1065: - ret = 1097; - break; - case 1066: - ret = 1098; - break; - case 1067: - ret = 1099; - break; - case 1068: - ret = 1100; - break; - case 1069: - ret = 1101; - break; - case 1070: - ret = 1102; - break; - case 1071: - ret = 1103; - break; - case 1120: - ret = 1121; - break; - case 1122: - ret = 1123; - break; - case 1124: - ret = 1125; - break; - case 1126: - ret = 1127; - break; - case 1128: - ret = 1129; - break; - case 1130: - ret = 1131; - break; - case 1132: - ret = 1133; - break; - case 1134: - ret = 1135; - break; - case 1136: - ret = 1137; - break; - case 1138: - ret = 1139; - break; - case 1140: - ret = 1141; - break; - case 1142: - ret = 1143; - break; - case 1144: - ret = 1145; - break; - case 1146: - ret = 1147; - break; - case 1148: - ret = 1149; - break; - case 1150: - ret = 1151; - break; - case 1152: - ret = 1153; - break; - case 1168: - ret = 1169; - break; - case 1170: - ret = 1171; - break; - case 1172: - ret = 1173; - break; - case 1174: - ret = 1175; - break; - case 1176: - ret = 1177; - break; - case 1178: - ret = 1179; - break; - case 1180: - ret = 1181; - break; - case 1182: - ret = 1183; - break; - case 1184: - ret = 1185; - break; - case 1186: - ret = 1187; - break; - case 1188: - ret = 1189; - break; - case 1190: - ret = 1191; - break; - case 1192: - ret = 1193; - break; - case 1194: - ret = 1195; - break; - case 1196: - ret = 1197; - break; - case 1198: - ret = 1199; - break; - case 1200: - ret = 1201; - break; - case 1202: - ret = 1203; - break; - case 1204: - ret = 1205; - break; - case 1206: - ret = 1207; - break; - case 1208: - ret = 1209; - break; - case 1210: - ret = 1211; - break; - case 1212: - ret = 1213; - break; - case 1214: - ret = 1215; - break; - case 1217: - ret = 1218; - break; - case 1219: - ret = 1220; - break; - case 1223: - ret = 1224; - break; - case 1227: - ret = 1228; - break; - case 1232: - ret = 1233; - break; - case 1234: - ret = 1235; - break; - case 1236: - ret = 1237; - break; - case 1238: - ret = 1239; - break; - case 1240: - ret = 1241; - break; - case 1242: - ret = 1243; - break; - case 1244: - ret = 1245; - break; - case 1246: - ret = 1247; - break; - case 1248: - ret = 1249; - break; - case 1250: - ret = 1251; - break; - case 1252: - ret = 1253; - break; - case 1254: - ret = 1255; - break; - case 1256: - ret = 1257; - break; - case 1258: - ret = 1259; - break; - case 1262: - ret = 1263; - break; - case 1264: - ret = 1265; - break; - case 1266: - ret = 1267; - break; - case 1268: - ret = 1269; - break; - case 1272: - ret = 1273; - break; - case 1329: - ret = 1377; - break; - case 1330: - ret = 1378; - break; - case 1331: - ret = 1379; - break; - case 1332: - ret = 1380; - break; - case 1333: - ret = 1381; - break; - case 1334: - ret = 1382; - break; - case 1335: - ret = 1383; - break; - case 1336: - ret = 1384; - break; - case 1337: - ret = 1385; - break; - case 1338: - ret = 1386; - break; - case 1339: - ret = 1387; - break; - case 1340: - ret = 1388; - break; - case 1341: - ret = 1389; - break; - case 1342: - ret = 1390; - break; - case 1343: - ret = 1391; - break; - case 1344: - ret = 1392; - break; - case 1345: - ret = 1393; - break; - case 1346: - ret = 1394; - break; - case 1347: - ret = 1395; - break; - case 1348: - ret = 1396; - break; - case 1349: - ret = 1397; - break; - case 1350: - ret = 1398; - break; - case 1351: - ret = 1399; - break; - case 1352: - ret = 1400; - break; - case 1353: - ret = 1401; - break; - case 1354: - ret = 1402; - break; - case 1355: - ret = 1403; - break; - case 1356: - ret = 1404; - break; - case 1357: - ret = 1405; - break; - case 1358: - ret = 1406; - break; - case 1359: - ret = 1407; - break; - case 1360: - ret = 1408; - break; - case 1361: - ret = 1409; - break; - case 1362: - ret = 1410; - break; - case 1363: - ret = 1411; - break; - case 1364: - ret = 1412; - break; - case 1365: - ret = 1413; - break; - case 1366: - ret = 1414; - break; - case 4256: - ret = 4304; - break; - case 4257: - ret = 4305; - break; - case 4258: - ret = 4306; - break; - case 4259: - ret = 4307; - break; - case 4260: - ret = 4308; - break; - case 4261: - ret = 4309; - break; - case 4262: - ret = 4310; - break; - case 4263: - ret = 4311; - break; - case 4264: - ret = 4312; - break; - case 4265: - ret = 4313; - break; - case 4266: - ret = 4314; - break; - case 4267: - ret = 4315; - break; - case 4268: - ret = 4316; - break; - case 4269: - ret = 4317; - break; - case 4270: - ret = 4318; - break; - case 4271: - ret = 4319; - break; - case 4272: - ret = 4320; - break; - case 4273: - ret = 4321; - break; - case 4274: - ret = 4322; - break; - case 4275: - ret = 4323; - break; - case 4276: - ret = 4324; - break; - case 4277: - ret = 4325; - break; - case 4278: - ret = 4326; - break; - case 4279: - ret = 4327; - break; - case 4280: - ret = 4328; - break; - case 4281: - ret = 4329; - break; - case 4282: - ret = 4330; - break; - case 4283: - ret = 4331; - break; - case 4284: - ret = 4332; - break; - case 4285: - ret = 4333; - break; - case 4286: - ret = 4334; - break; - case 4287: - ret = 4335; - break; - case 4288: - ret = 4336; - break; - case 4289: - ret = 4337; - break; - case 4290: - ret = 4338; - break; - case 4291: - ret = 4339; - break; - case 4292: - ret = 4340; - break; - case 4293: - ret = 4341; - break; - case 7680: - ret = 7681; - break; - case 7682: - ret = 7683; - break; - case 7684: - ret = 7685; - break; - case 7686: - ret = 7687; - break; - case 7688: - ret = 7689; - break; - case 7690: - ret = 7691; - break; - case 7692: - ret = 7693; - break; - case 7694: - ret = 7695; - break; - case 7696: - ret = 7697; - break; - case 7698: - ret = 7699; - break; - case 7700: - ret = 7701; - break; - case 7702: - ret = 7703; - break; - case 7704: - ret = 7705; - break; - case 7706: - ret = 7707; - break; - case 7708: - ret = 7709; - break; - case 7710: - ret = 7711; - break; - case 7712: - ret = 7713; - break; - case 7714: - ret = 7715; - break; - case 7716: - ret = 7717; - break; - case 7718: - ret = 7719; - break; - case 7720: - ret = 7721; - break; - case 7722: - ret = 7723; - break; - case 7724: - ret = 7725; - break; - case 7726: - ret = 7727; - break; - case 7728: - ret = 7729; - break; - case 7730: - ret = 7731; - break; - case 7732: - ret = 7733; - break; - case 7734: - ret = 7735; - break; - case 7736: - ret = 7737; - break; - case 7738: - ret = 7739; - break; - case 7740: - ret = 7741; - break; - case 7742: - ret = 7743; - break; - case 7744: - ret = 7745; - break; - case 7746: - ret = 7747; - break; - case 7748: - ret = 7749; - break; - case 7750: - ret = 7751; - break; - case 7752: - ret = 7753; - break; - case 7754: - ret = 7755; - break; - case 7756: - ret = 7757; - break; - case 7758: - ret = 7759; - break; - case 7760: - ret = 7761; - break; - case 7762: - ret = 7763; - break; - case 7764: - ret = 7765; - break; - case 7766: - ret = 7767; - break; - case 7768: - ret = 7769; - break; - case 7770: - ret = 7771; - break; - case 7772: - ret = 7773; - break; - case 7774: - ret = 7775; - break; - case 7776: - ret = 7777; - break; - case 7778: - ret = 7779; - break; - case 7780: - ret = 7781; - break; - case 7782: - ret = 7783; - break; - case 7784: - ret = 7785; - break; - case 7786: - ret = 7787; - break; - case 7788: - ret = 7789; - break; - case 7790: - ret = 7791; - break; - case 7792: - ret = 7793; - break; - case 7794: - ret = 7795; - break; - case 7796: - ret = 7797; - break; - case 7798: - ret = 7799; - break; - case 7800: - ret = 7801; - break; - case 7802: - ret = 7803; - break; - case 7804: - ret = 7805; - break; - case 7806: - ret = 7807; - break; - case 7808: - ret = 7809; - break; - case 7810: - ret = 7811; - break; - case 7812: - ret = 7813; - break; - case 7814: - ret = 7815; - break; - case 7816: - ret = 7817; - break; - case 7818: - ret = 7819; - break; - case 7820: - ret = 7821; - break; - case 7822: - ret = 7823; - break; - case 7824: - ret = 7825; - break; - case 7826: - ret = 7827; - break; - case 7828: - ret = 7829; - break; - case 7840: - ret = 7841; - break; - case 7842: - ret = 7843; - break; - case 7844: - ret = 7845; - break; - case 7846: - ret = 7847; - break; - case 7848: - ret = 7849; - break; - case 7850: - ret = 7851; - break; - case 7852: - ret = 7853; - break; - case 7854: - ret = 7855; - break; - case 7856: - ret = 7857; - break; - case 7858: - ret = 7859; - break; - case 7860: - ret = 7861; - break; - case 7862: - ret = 7863; - break; - case 7864: - ret = 7865; - break; - case 7866: - ret = 7867; - break; - case 7868: - ret = 7869; - break; - case 7870: - ret = 7871; - break; - case 7872: - ret = 7873; - break; - case 7874: - ret = 7875; - break; - case 7876: - ret = 7877; - break; - case 7878: - ret = 7879; - break; - case 7880: - ret = 7881; - break; - case 7882: - ret = 7883; - break; - case 7884: - ret = 7885; - break; - case 7886: - ret = 7887; - break; - case 7888: - ret = 7889; - break; - case 7890: - ret = 7891; - break; - case 7892: - ret = 7893; - break; - case 7894: - ret = 7895; - break; - case 7896: - ret = 7897; - break; - case 7898: - ret = 7899; - break; - case 7900: - ret = 7901; - break; - case 7902: - ret = 7903; - break; - case 7904: - ret = 7905; - break; - case 7906: - ret = 7907; - break; - case 7908: - ret = 7909; - break; - case 7910: - ret = 7911; - break; - case 7912: - ret = 7913; - break; - case 7914: - ret = 7915; - break; - case 7916: - ret = 7917; - break; - case 7918: - ret = 7919; - break; - case 7920: - ret = 7921; - break; - case 7922: - ret = 7923; - break; - case 7924: - ret = 7925; - break; - case 7926: - ret = 7927; - break; - case 7928: - ret = 7929; - break; - case 7944: - ret = 7936; - break; - case 7945: - ret = 7937; - break; - case 7946: - ret = 7938; - break; - case 7947: - ret = 7939; - break; - case 7948: - ret = 7940; - break; - case 7949: - ret = 7941; - break; - case 7950: - ret = 7942; - break; - case 7951: - ret = 7943; - break; - case 7960: - ret = 7952; - break; - case 7961: - ret = 7953; - break; - case 7962: - ret = 7954; - break; - case 7963: - ret = 7955; - break; - case 7964: - ret = 7956; - break; - case 7965: - ret = 7957; - break; - case 7976: - ret = 7968; - break; - case 7977: - ret = 7969; - break; - case 7978: - ret = 7970; - break; - case 7979: - ret = 7971; - break; - case 7980: - ret = 7972; - break; - case 7981: - ret = 7973; - break; - case 7982: - ret = 7974; - break; - case 7983: - ret = 7975; - break; - case 7992: - ret = 7984; - break; - case 7993: - ret = 7985; - break; - case 7994: - ret = 7986; - break; - case 7995: - ret = 7987; - break; - case 7996: - ret = 7988; - break; - case 7997: - ret = 7989; - break; - case 7998: - ret = 7990; - break; - case 7999: - ret = 7991; - break; - case 8008: - ret = 8000; - break; - case 8009: - ret = 8001; - break; - case 8010: - ret = 8002; - break; - case 8011: - ret = 8003; - break; - case 8012: - ret = 8004; - break; - case 8013: - ret = 8005; - break; - case 8025: - ret = 8017; - break; - case 8027: - ret = 8019; - break; - case 8029: - ret = 8021; - break; - case 8031: - ret = 8023; - break; - case 8040: - ret = 8032; - break; - case 8041: - ret = 8033; - break; - case 8042: - ret = 8034; - break; - case 8043: - ret = 8035; - break; - case 8044: - ret = 8036; - break; - case 8045: - ret = 8037; - break; - case 8046: - ret = 8038; - break; - case 8047: - ret = 8039; - break; - case 8072: - ret = 8064; - break; - case 8073: - ret = 8065; - break; - case 8074: - ret = 8066; - break; - case 8075: - ret = 8067; - break; - case 8076: - ret = 8068; - break; - case 8077: - ret = 8069; - break; - case 8078: - ret = 8070; - break; - case 8079: - ret = 8071; - break; - case 8088: - ret = 8080; - break; - case 8089: - ret = 8081; - break; - case 8090: - ret = 8082; - break; - case 8091: - ret = 8083; - break; - case 8092: - ret = 8084; - break; - case 8093: - ret = 8085; - break; - case 8094: - ret = 8086; - break; - case 8095: - ret = 8087; - break; - case 8104: - ret = 8096; - break; - case 8105: - ret = 8097; - break; - case 8106: - ret = 8098; - break; - case 8107: - ret = 8099; - break; - case 8108: - ret = 8100; - break; - case 8109: - ret = 8101; - break; - case 8110: - ret = 8102; - break; - case 8111: - ret = 8103; - break; - case 8120: - ret = 8112; - break; - case 8121: - ret = 8113; - break; - case 8122: - ret = 8048; - break; - case 8123: - ret = 8049; - break; - case 8124: - ret = 8115; - break; - case 8136: - ret = 8050; - break; - case 8137: - ret = 8051; - break; - case 8138: - ret = 8052; - break; - case 8139: - ret = 8053; - break; - case 8140: - ret = 8131; - break; - case 8152: - ret = 8144; - break; - case 8153: - ret = 8145; - break; - case 8154: - ret = 8054; - break; - case 8155: - ret = 8055; - break; - case 8168: - ret = 8160; - break; - case 8169: - ret = 8161; - break; - case 8170: - ret = 8058; - break; - case 8171: - ret = 8059; - break; - case 8172: - ret = 8165; - break; - case 8184: - ret = 8056; - break; - case 8185: - ret = 8057; - break; - case 8186: - ret = 8060; - break; - case 8187: - ret = 8061; - break; - case 8188: - ret = 8179; - break; - case 8544: - ret = 8560; - break; - case 8545: - ret = 8561; - break; - case 8546: - ret = 8562; - break; - case 8547: - ret = 8563; - break; - case 8548: - ret = 8564; - break; - case 8549: - ret = 8565; - break; - case 8550: - ret = 8566; - break; - case 8551: - ret = 8567; - break; - case 8552: - ret = 8568; - break; - case 8553: - ret = 8569; - break; - case 8554: - ret = 8570; - break; - case 8555: - ret = 8571; - break; - case 8556: - ret = 8572; - break; - case 8557: - ret = 8573; - break; - case 8558: - ret = 8574; - break; - case 8559: - ret = 8575; - break; - case 9398: - ret = 9424; - break; - case 9399: - ret = 9425; - break; - case 9400: - ret = 9426; - break; - case 9401: - ret = 9427; - break; - case 9402: - ret = 9428; - break; - case 9403: - ret = 9429; - break; - case 9404: - ret = 9430; - break; - case 9405: - ret = 9431; - break; - case 9406: - ret = 9432; - break; - case 9407: - ret = 9433; - break; - case 9408: - ret = 9434; - break; - case 9409: - ret = 9435; - break; - case 9410: - ret = 9436; - break; - case 9411: - ret = 9437; - break; - case 9412: - ret = 9438; - break; - case 9413: - ret = 9439; - break; - case 9414: - ret = 9440; - break; - case 9415: - ret = 9441; - break; - case 9416: - ret = 9442; - break; - case 9417: - ret = 9443; - break; - case 9418: - ret = 9444; - break; - case 9419: - ret = 9445; - break; - case 9420: - ret = 9446; - break; - case 9421: - ret = 9447; - break; - case 9422: - ret = 9448; - break; - case 9423: - ret = 9449; - break; - case 65313: - ret = 65345; - break; - case 65314: - ret = 65346; - break; - case 65315: - ret = 65347; - break; - case 65316: - ret = 65348; - break; - case 65317: - ret = 65349; - break; - case 65318: - ret = 65350; - break; - case 65319: - ret = 65351; - break; - case 65320: - ret = 65352; - break; - case 65321: - ret = 65353; - break; - case 65322: - ret = 65354; - break; - case 65323: - ret = 65355; - break; - case 65324: - ret = 65356; - break; - case 65325: - ret = 65357; - break; - case 65326: - ret = 65358; - break; - case 65327: - ret = 65359; - break; - case 65328: - ret = 65360; - break; - case 65329: - ret = 65361; - break; - case 65330: - ret = 65362; - break; - case 65331: - ret = 65363; - break; - case 65332: - ret = 65364; - break; - case 65333: - ret = 65365; - break; - case 65334: - ret = 65366; - break; - case 65335: - ret = 65367; - break; - case 65336: - ret = 65368; - break; - case 65337: - ret = 65369; - break; - case 65338: - ret = 65370; - break; - } - return (char) ret; - } - return Character.toLowerCase(c); - } - - /** Convert a String to title case. */ - public static String toTitleCase(String s) - { - javajs.util.SB sb = new javajs.util.SB(); - for (int i = 0; i < s.length(); i++) - { - sb.appendC(CaseMgr.toTitleCase(s.charAt(i))); - } - return sb.toString(); - } - - /** Convert a String to upper case. */ - public static String toUpperCase(String s) - { - javajs.util.SB sb = new javajs.util.SB(); - for (int i = 0; i < s.length(); i++) - { - sb.appendC(CaseMgr.toUpperCase(s.charAt(i))); - } - return sb.toString(); - } - - /** Convert a String to lower case. */ - public static String toLowerCase(String s) - { - javajs.util.SB sb = new javajs.util.SB(); - for (int i = 0; i < s.length(); i++) - { - sb.appendC(CaseMgr.toLowerCase(s.charAt(i))); - } - return sb.toString(); - } - - /** Convert a character to title case. */ - public static char toTitleCase(char c) - { - if (java_1_0) - { - int ret = (int) toUpperCase(c); - switch (c) - { - case 452: - ret = 453; - break; - case 453: - ret = 453; - break; - case 454: - ret = 453; - break; - case 455: - ret = 456; - break; - case 456: - ret = 456; - break; - case 457: - ret = 456; - break; - case 458: - ret = 459; - break; - case 459: - ret = 459; - break; - case 460: - ret = 459; - break; - case 497: - ret = 498; - break; - case 498: - ret = 498; - break; - case 499: - ret = 498; - break; - } - return (char) ret; - } - return Character.toTitleCase(c); - } - - /** - * Duplicates the regionMatches routine of String -- but makes use of the - * definitions of upper, lower, and title case in this class when ignoreCase - * is set. - */ - public static boolean regionMatches(StringLike s1, boolean ign, int i1, - StringLike s2, int i2, int i3) - { - int itot = i2 + i3; - if (itot > s2.length() || i1 + i3 > s1.length()) - { - return false; - } - if (!ign) - { - for (int i = i2; i < itot; i++) - { - if (s2.charAt(i) != s1.charAt(i1++)) - { - return false; - } - } - } - else - { - for (int i = i2; i < itot; i++) - { - if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) - { - return false; - } - } - } - return true; - } - - /** - * Duplicates the regionMatches routine of String -- but makes use of the - * definitions of upper, lower, and title case in this class when ignoreCase - * is set. - */ - public static boolean regionMatches(String s1, boolean ign, int i1, - StringLike s2, int i2, int i3) - { - int itot = i2 + i3; - if (itot > s2.length() || i1 + i3 > s1.length()) - { - return false; - } - if (!ign) - { - for (int i = i2; i < itot; i++) - { - if (s2.charAt(i) != s1.charAt(i1++)) - { - return false; - } - } - } - else - { - for (int i = i2; i < itot; i++) - { - if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) - { - return false; - } - } - } - return true; - } - - /** - * Duplicates the regionMatches routine of String -- but makes use of the - * definitions of upper, lower, and title case in this class when ignoreCase - * is set. - */ - public static boolean regionMatches(StringLike s1, boolean ign, int i1, - String s2, int i2, int i3) - { - int itot = i2 + i3; - if (itot > s2.length() || i1 + i3 > s1.length()) - { - return false; - } - if (!ign) - { - for (int i = i2; i < itot; i++) - { - if (s2.charAt(i) != s1.charAt(i1++)) - { - return false; - } - } - } - else - { - for (int i = i2; i < itot; i++) - { - if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) - { - return false; - } - } - } - return true; - } - - /** - * Duplicates the regionMatches routine of String -- but makes use of the - * definitions of upper, lower, and title case in this class when ignoreCase - * is set. - */ - public static boolean regionMatches(String s1, boolean ign, int i1, - String s2, int i2, int i3) - { - int itot = i2 + i3; - if (itot > s2.length() || i1 + i3 > s1.length()) - { - return false; - } - if (!ign) - { - for (int i = i2; i < itot; i++) - { - if (s2.charAt(i) != s1.charAt(i1++)) - { - return false; - } - } - } - else - { - for (int i = i2; i < itot; i++) - { - if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) - { - return false; - } - } - } - return true; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * Encapsulates the Unicode definitions of Upper, Lower, and Title case as + * defined by unicode.org. + *

    + * The performance of the methods found in String and Character is better, but + * these methods work both in java 1.0 and 1.1. If it is desirable, either to + * gain a slight performance increase or to accomodate application specific + * modifications to the definitions of upper, lower, and title case then it + * should be a straightforward task to substitute your own methods for these. + */ +final public class CaseMgr +{ + final static boolean java_1_0 = false; + + /** Convert a character to upper case . */ + public static char toUpperCase(char c) + { + if (java_1_0) + { + int ret = (int) c; + switch (c) + { + case 97: + ret = 65; + break; + case 98: + ret = 66; + break; + case 99: + ret = 67; + break; + case 100: + ret = 68; + break; + case 101: + ret = 69; + break; + case 102: + ret = 70; + break; + case 103: + ret = 71; + break; + case 104: + ret = 72; + break; + case 105: + ret = 73; + break; + case 106: + ret = 74; + break; + case 107: + ret = 75; + break; + case 108: + ret = 76; + break; + case 109: + ret = 77; + break; + case 110: + ret = 78; + break; + case 111: + ret = 79; + break; + case 112: + ret = 80; + break; + case 113: + ret = 81; + break; + case 114: + ret = 82; + break; + case 115: + ret = 83; + break; + case 116: + ret = 84; + break; + case 117: + ret = 85; + break; + case 118: + ret = 86; + break; + case 119: + ret = 87; + break; + case 120: + ret = 88; + break; + case 121: + ret = 89; + break; + case 122: + ret = 90; + break; + case 224: + ret = 192; + break; + case 225: + ret = 193; + break; + case 226: + ret = 194; + break; + case 227: + ret = 195; + break; + case 228: + ret = 196; + break; + case 229: + ret = 197; + break; + case 230: + ret = 198; + break; + case 231: + ret = 199; + break; + case 232: + ret = 200; + break; + case 233: + ret = 201; + break; + case 234: + ret = 202; + break; + case 235: + ret = 203; + break; + case 236: + ret = 204; + break; + case 237: + ret = 205; + break; + case 238: + ret = 206; + break; + case 239: + ret = 207; + break; + case 240: + ret = 208; + break; + case 241: + ret = 209; + break; + case 242: + ret = 210; + break; + case 243: + ret = 211; + break; + case 244: + ret = 212; + break; + case 245: + ret = 213; + break; + case 246: + ret = 214; + break; + case 248: + ret = 216; + break; + case 249: + ret = 217; + break; + case 250: + ret = 218; + break; + case 251: + ret = 219; + break; + case 252: + ret = 220; + break; + case 253: + ret = 221; + break; + case 254: + ret = 222; + break; + case 255: + ret = 376; + break; + case 257: + ret = 256; + break; + case 259: + ret = 258; + break; + case 261: + ret = 260; + break; + case 263: + ret = 262; + break; + case 265: + ret = 264; + break; + case 267: + ret = 266; + break; + case 269: + ret = 268; + break; + case 271: + ret = 270; + break; + case 273: + ret = 272; + break; + case 275: + ret = 274; + break; + case 277: + ret = 276; + break; + case 279: + ret = 278; + break; + case 281: + ret = 280; + break; + case 283: + ret = 282; + break; + case 285: + ret = 284; + break; + case 287: + ret = 286; + break; + case 289: + ret = 288; + break; + case 291: + ret = 290; + break; + case 293: + ret = 292; + break; + case 295: + ret = 294; + break; + case 297: + ret = 296; + break; + case 299: + ret = 298; + break; + case 301: + ret = 300; + break; + case 303: + ret = 302; + break; + case 305: + ret = 73; + break; + case 307: + ret = 306; + break; + case 309: + ret = 308; + break; + case 311: + ret = 310; + break; + case 314: + ret = 313; + break; + case 316: + ret = 315; + break; + case 318: + ret = 317; + break; + case 320: + ret = 319; + break; + case 322: + ret = 321; + break; + case 324: + ret = 323; + break; + case 326: + ret = 325; + break; + case 328: + ret = 327; + break; + case 331: + ret = 330; + break; + case 333: + ret = 332; + break; + case 335: + ret = 334; + break; + case 337: + ret = 336; + break; + case 339: + ret = 338; + break; + case 341: + ret = 340; + break; + case 343: + ret = 342; + break; + case 345: + ret = 344; + break; + case 347: + ret = 346; + break; + case 349: + ret = 348; + break; + case 351: + ret = 350; + break; + case 353: + ret = 352; + break; + case 355: + ret = 354; + break; + case 357: + ret = 356; + break; + case 359: + ret = 358; + break; + case 361: + ret = 360; + break; + case 363: + ret = 362; + break; + case 365: + ret = 364; + break; + case 367: + ret = 366; + break; + case 369: + ret = 368; + break; + case 371: + ret = 370; + break; + case 373: + ret = 372; + break; + case 375: + ret = 374; + break; + case 378: + ret = 377; + break; + case 380: + ret = 379; + break; + case 382: + ret = 381; + break; + case 383: + ret = 83; + break; + case 387: + ret = 386; + break; + case 389: + ret = 388; + break; + case 392: + ret = 391; + break; + case 396: + ret = 395; + break; + case 402: + ret = 401; + break; + case 409: + ret = 408; + break; + case 417: + ret = 416; + break; + case 419: + ret = 418; + break; + case 421: + ret = 420; + break; + case 424: + ret = 423; + break; + case 429: + ret = 428; + break; + case 432: + ret = 431; + break; + case 436: + ret = 435; + break; + case 438: + ret = 437; + break; + case 441: + ret = 440; + break; + case 445: + ret = 444; + break; + case 453: + ret = 452; + break; + case 454: + ret = 452; + break; + case 456: + ret = 455; + break; + case 457: + ret = 455; + break; + case 459: + ret = 458; + break; + case 460: + ret = 458; + break; + case 462: + ret = 461; + break; + case 464: + ret = 463; + break; + case 466: + ret = 465; + break; + case 468: + ret = 467; + break; + case 470: + ret = 469; + break; + case 472: + ret = 471; + break; + case 474: + ret = 473; + break; + case 476: + ret = 475; + break; + case 479: + ret = 478; + break; + case 481: + ret = 480; + break; + case 483: + ret = 482; + break; + case 485: + ret = 484; + break; + case 487: + ret = 486; + break; + case 489: + ret = 488; + break; + case 491: + ret = 490; + break; + case 493: + ret = 492; + break; + case 495: + ret = 494; + break; + case 498: + ret = 497; + break; + case 499: + ret = 497; + break; + case 501: + ret = 500; + break; + case 507: + ret = 506; + break; + case 509: + ret = 508; + break; + case 511: + ret = 510; + break; + case 513: + ret = 512; + break; + case 515: + ret = 514; + break; + case 517: + ret = 516; + break; + case 519: + ret = 518; + break; + case 521: + ret = 520; + break; + case 523: + ret = 522; + break; + case 525: + ret = 524; + break; + case 527: + ret = 526; + break; + case 529: + ret = 528; + break; + case 531: + ret = 530; + break; + case 533: + ret = 532; + break; + case 535: + ret = 534; + break; + case 595: + ret = 385; + break; + case 596: + ret = 390; + break; + case 598: + ret = 393; + break; + case 599: + ret = 394; + break; + case 600: + ret = 398; + break; + case 601: + ret = 399; + break; + case 603: + ret = 400; + break; + case 608: + ret = 403; + break; + case 611: + ret = 404; + break; + case 616: + ret = 407; + break; + case 617: + ret = 406; + break; + case 623: + ret = 412; + break; + case 626: + ret = 413; + break; + case 643: + ret = 425; + break; + case 648: + ret = 430; + break; + case 650: + ret = 433; + break; + case 651: + ret = 434; + break; + case 658: + ret = 439; + break; + case 940: + ret = 902; + break; + case 941: + ret = 904; + break; + case 942: + ret = 905; + break; + case 943: + ret = 906; + break; + case 945: + ret = 913; + break; + case 946: + ret = 914; + break; + case 947: + ret = 915; + break; + case 948: + ret = 916; + break; + case 949: + ret = 917; + break; + case 950: + ret = 918; + break; + case 951: + ret = 919; + break; + case 952: + ret = 920; + break; + case 953: + ret = 921; + break; + case 954: + ret = 922; + break; + case 955: + ret = 923; + break; + case 956: + ret = 924; + break; + case 957: + ret = 925; + break; + case 958: + ret = 926; + break; + case 959: + ret = 927; + break; + case 960: + ret = 928; + break; + case 961: + ret = 929; + break; + case 963: + ret = 931; + break; + case 964: + ret = 932; + break; + case 965: + ret = 933; + break; + case 966: + ret = 934; + break; + case 967: + ret = 935; + break; + case 968: + ret = 936; + break; + case 969: + ret = 937; + break; + case 970: + ret = 938; + break; + case 971: + ret = 939; + break; + case 972: + ret = 908; + break; + case 973: + ret = 910; + break; + case 974: + ret = 911; + break; + case 976: + ret = 914; + break; + case 977: + ret = 920; + break; + case 981: + ret = 934; + break; + case 982: + ret = 928; + break; + case 995: + ret = 994; + break; + case 997: + ret = 996; + break; + case 999: + ret = 998; + break; + case 1001: + ret = 1000; + break; + case 1003: + ret = 1002; + break; + case 1005: + ret = 1004; + break; + case 1007: + ret = 1006; + break; + case 1008: + ret = 922; + break; + case 1009: + ret = 929; + break; + case 1072: + ret = 1040; + break; + case 1073: + ret = 1041; + break; + case 1074: + ret = 1042; + break; + case 1075: + ret = 1043; + break; + case 1076: + ret = 1044; + break; + case 1077: + ret = 1045; + break; + case 1078: + ret = 1046; + break; + case 1079: + ret = 1047; + break; + case 1080: + ret = 1048; + break; + case 1081: + ret = 1049; + break; + case 1082: + ret = 1050; + break; + case 1083: + ret = 1051; + break; + case 1084: + ret = 1052; + break; + case 1085: + ret = 1053; + break; + case 1086: + ret = 1054; + break; + case 1087: + ret = 1055; + break; + case 1088: + ret = 1056; + break; + case 1089: + ret = 1057; + break; + case 1090: + ret = 1058; + break; + case 1091: + ret = 1059; + break; + case 1092: + ret = 1060; + break; + case 1093: + ret = 1061; + break; + case 1094: + ret = 1062; + break; + case 1095: + ret = 1063; + break; + case 1096: + ret = 1064; + break; + case 1097: + ret = 1065; + break; + case 1098: + ret = 1066; + break; + case 1099: + ret = 1067; + break; + case 1100: + ret = 1068; + break; + case 1101: + ret = 1069; + break; + case 1102: + ret = 1070; + break; + case 1103: + ret = 1071; + break; + case 1105: + ret = 1025; + break; + case 1106: + ret = 1026; + break; + case 1107: + ret = 1027; + break; + case 1108: + ret = 1028; + break; + case 1109: + ret = 1029; + break; + case 1110: + ret = 1030; + break; + case 1111: + ret = 1031; + break; + case 1112: + ret = 1032; + break; + case 1113: + ret = 1033; + break; + case 1114: + ret = 1034; + break; + case 1115: + ret = 1035; + break; + case 1116: + ret = 1036; + break; + case 1118: + ret = 1038; + break; + case 1119: + ret = 1039; + break; + case 1121: + ret = 1120; + break; + case 1123: + ret = 1122; + break; + case 1125: + ret = 1124; + break; + case 1127: + ret = 1126; + break; + case 1129: + ret = 1128; + break; + case 1131: + ret = 1130; + break; + case 1133: + ret = 1132; + break; + case 1135: + ret = 1134; + break; + case 1137: + ret = 1136; + break; + case 1139: + ret = 1138; + break; + case 1141: + ret = 1140; + break; + case 1143: + ret = 1142; + break; + case 1145: + ret = 1144; + break; + case 1147: + ret = 1146; + break; + case 1149: + ret = 1148; + break; + case 1151: + ret = 1150; + break; + case 1153: + ret = 1152; + break; + case 1169: + ret = 1168; + break; + case 1171: + ret = 1170; + break; + case 1173: + ret = 1172; + break; + case 1175: + ret = 1174; + break; + case 1177: + ret = 1176; + break; + case 1179: + ret = 1178; + break; + case 1181: + ret = 1180; + break; + case 1183: + ret = 1182; + break; + case 1185: + ret = 1184; + break; + case 1187: + ret = 1186; + break; + case 1189: + ret = 1188; + break; + case 1191: + ret = 1190; + break; + case 1193: + ret = 1192; + break; + case 1195: + ret = 1194; + break; + case 1197: + ret = 1196; + break; + case 1199: + ret = 1198; + break; + case 1201: + ret = 1200; + break; + case 1203: + ret = 1202; + break; + case 1205: + ret = 1204; + break; + case 1207: + ret = 1206; + break; + case 1209: + ret = 1208; + break; + case 1211: + ret = 1210; + break; + case 1213: + ret = 1212; + break; + case 1215: + ret = 1214; + break; + case 1218: + ret = 1217; + break; + case 1220: + ret = 1219; + break; + case 1224: + ret = 1223; + break; + case 1228: + ret = 1227; + break; + case 1233: + ret = 1232; + break; + case 1235: + ret = 1234; + break; + case 1237: + ret = 1236; + break; + case 1239: + ret = 1238; + break; + case 1241: + ret = 1240; + break; + case 1243: + ret = 1242; + break; + case 1245: + ret = 1244; + break; + case 1247: + ret = 1246; + break; + case 1249: + ret = 1248; + break; + case 1251: + ret = 1250; + break; + case 1253: + ret = 1252; + break; + case 1255: + ret = 1254; + break; + case 1257: + ret = 1256; + break; + case 1259: + ret = 1258; + break; + case 1263: + ret = 1262; + break; + case 1265: + ret = 1264; + break; + case 1267: + ret = 1266; + break; + case 1269: + ret = 1268; + break; + case 1273: + ret = 1272; + break; + case 1377: + ret = 1329; + break; + case 1378: + ret = 1330; + break; + case 1379: + ret = 1331; + break; + case 1380: + ret = 1332; + break; + case 1381: + ret = 1333; + break; + case 1382: + ret = 1334; + break; + case 1383: + ret = 1335; + break; + case 1384: + ret = 1336; + break; + case 1385: + ret = 1337; + break; + case 1386: + ret = 1338; + break; + case 1387: + ret = 1339; + break; + case 1388: + ret = 1340; + break; + case 1389: + ret = 1341; + break; + case 1390: + ret = 1342; + break; + case 1391: + ret = 1343; + break; + case 1392: + ret = 1344; + break; + case 1393: + ret = 1345; + break; + case 1394: + ret = 1346; + break; + case 1395: + ret = 1347; + break; + case 1396: + ret = 1348; + break; + case 1397: + ret = 1349; + break; + case 1398: + ret = 1350; + break; + case 1399: + ret = 1351; + break; + case 1400: + ret = 1352; + break; + case 1401: + ret = 1353; + break; + case 1402: + ret = 1354; + break; + case 1403: + ret = 1355; + break; + case 1404: + ret = 1356; + break; + case 1405: + ret = 1357; + break; + case 1406: + ret = 1358; + break; + case 1407: + ret = 1359; + break; + case 1408: + ret = 1360; + break; + case 1409: + ret = 1361; + break; + case 1410: + ret = 1362; + break; + case 1411: + ret = 1363; + break; + case 1412: + ret = 1364; + break; + case 1413: + ret = 1365; + break; + case 1414: + ret = 1366; + break; + case 7681: + ret = 7680; + break; + case 7683: + ret = 7682; + break; + case 7685: + ret = 7684; + break; + case 7687: + ret = 7686; + break; + case 7689: + ret = 7688; + break; + case 7691: + ret = 7690; + break; + case 7693: + ret = 7692; + break; + case 7695: + ret = 7694; + break; + case 7697: + ret = 7696; + break; + case 7699: + ret = 7698; + break; + case 7701: + ret = 7700; + break; + case 7703: + ret = 7702; + break; + case 7705: + ret = 7704; + break; + case 7707: + ret = 7706; + break; + case 7709: + ret = 7708; + break; + case 7711: + ret = 7710; + break; + case 7713: + ret = 7712; + break; + case 7715: + ret = 7714; + break; + case 7717: + ret = 7716; + break; + case 7719: + ret = 7718; + break; + case 7721: + ret = 7720; + break; + case 7723: + ret = 7722; + break; + case 7725: + ret = 7724; + break; + case 7727: + ret = 7726; + break; + case 7729: + ret = 7728; + break; + case 7731: + ret = 7730; + break; + case 7733: + ret = 7732; + break; + case 7735: + ret = 7734; + break; + case 7737: + ret = 7736; + break; + case 7739: + ret = 7738; + break; + case 7741: + ret = 7740; + break; + case 7743: + ret = 7742; + break; + case 7745: + ret = 7744; + break; + case 7747: + ret = 7746; + break; + case 7749: + ret = 7748; + break; + case 7751: + ret = 7750; + break; + case 7753: + ret = 7752; + break; + case 7755: + ret = 7754; + break; + case 7757: + ret = 7756; + break; + case 7759: + ret = 7758; + break; + case 7761: + ret = 7760; + break; + case 7763: + ret = 7762; + break; + case 7765: + ret = 7764; + break; + case 7767: + ret = 7766; + break; + case 7769: + ret = 7768; + break; + case 7771: + ret = 7770; + break; + case 7773: + ret = 7772; + break; + case 7775: + ret = 7774; + break; + case 7777: + ret = 7776; + break; + case 7779: + ret = 7778; + break; + case 7781: + ret = 7780; + break; + case 7783: + ret = 7782; + break; + case 7785: + ret = 7784; + break; + case 7787: + ret = 7786; + break; + case 7789: + ret = 7788; + break; + case 7791: + ret = 7790; + break; + case 7793: + ret = 7792; + break; + case 7795: + ret = 7794; + break; + case 7797: + ret = 7796; + break; + case 7799: + ret = 7798; + break; + case 7801: + ret = 7800; + break; + case 7803: + ret = 7802; + break; + case 7805: + ret = 7804; + break; + case 7807: + ret = 7806; + break; + case 7809: + ret = 7808; + break; + case 7811: + ret = 7810; + break; + case 7813: + ret = 7812; + break; + case 7815: + ret = 7814; + break; + case 7817: + ret = 7816; + break; + case 7819: + ret = 7818; + break; + case 7821: + ret = 7820; + break; + case 7823: + ret = 7822; + break; + case 7825: + ret = 7824; + break; + case 7827: + ret = 7826; + break; + case 7829: + ret = 7828; + break; + case 7841: + ret = 7840; + break; + case 7843: + ret = 7842; + break; + case 7845: + ret = 7844; + break; + case 7847: + ret = 7846; + break; + case 7849: + ret = 7848; + break; + case 7851: + ret = 7850; + break; + case 7853: + ret = 7852; + break; + case 7855: + ret = 7854; + break; + case 7857: + ret = 7856; + break; + case 7859: + ret = 7858; + break; + case 7861: + ret = 7860; + break; + case 7863: + ret = 7862; + break; + case 7865: + ret = 7864; + break; + case 7867: + ret = 7866; + break; + case 7869: + ret = 7868; + break; + case 7871: + ret = 7870; + break; + case 7873: + ret = 7872; + break; + case 7875: + ret = 7874; + break; + case 7877: + ret = 7876; + break; + case 7879: + ret = 7878; + break; + case 7881: + ret = 7880; + break; + case 7883: + ret = 7882; + break; + case 7885: + ret = 7884; + break; + case 7887: + ret = 7886; + break; + case 7889: + ret = 7888; + break; + case 7891: + ret = 7890; + break; + case 7893: + ret = 7892; + break; + case 7895: + ret = 7894; + break; + case 7897: + ret = 7896; + break; + case 7899: + ret = 7898; + break; + case 7901: + ret = 7900; + break; + case 7903: + ret = 7902; + break; + case 7905: + ret = 7904; + break; + case 7907: + ret = 7906; + break; + case 7909: + ret = 7908; + break; + case 7911: + ret = 7910; + break; + case 7913: + ret = 7912; + break; + case 7915: + ret = 7914; + break; + case 7917: + ret = 7916; + break; + case 7919: + ret = 7918; + break; + case 7921: + ret = 7920; + break; + case 7923: + ret = 7922; + break; + case 7925: + ret = 7924; + break; + case 7927: + ret = 7926; + break; + case 7929: + ret = 7928; + break; + case 7936: + ret = 7944; + break; + case 7937: + ret = 7945; + break; + case 7938: + ret = 7946; + break; + case 7939: + ret = 7947; + break; + case 7940: + ret = 7948; + break; + case 7941: + ret = 7949; + break; + case 7942: + ret = 7950; + break; + case 7943: + ret = 7951; + break; + case 7952: + ret = 7960; + break; + case 7953: + ret = 7961; + break; + case 7954: + ret = 7962; + break; + case 7955: + ret = 7963; + break; + case 7956: + ret = 7964; + break; + case 7957: + ret = 7965; + break; + case 7968: + ret = 7976; + break; + case 7969: + ret = 7977; + break; + case 7970: + ret = 7978; + break; + case 7971: + ret = 7979; + break; + case 7972: + ret = 7980; + break; + case 7973: + ret = 7981; + break; + case 7974: + ret = 7982; + break; + case 7975: + ret = 7983; + break; + case 7984: + ret = 7992; + break; + case 7985: + ret = 7993; + break; + case 7986: + ret = 7994; + break; + case 7987: + ret = 7995; + break; + case 7988: + ret = 7996; + break; + case 7989: + ret = 7997; + break; + case 7990: + ret = 7998; + break; + case 7991: + ret = 7999; + break; + case 8000: + ret = 8008; + break; + case 8001: + ret = 8009; + break; + case 8002: + ret = 8010; + break; + case 8003: + ret = 8011; + break; + case 8004: + ret = 8012; + break; + case 8005: + ret = 8013; + break; + case 8017: + ret = 8025; + break; + case 8019: + ret = 8027; + break; + case 8021: + ret = 8029; + break; + case 8023: + ret = 8031; + break; + case 8032: + ret = 8040; + break; + case 8033: + ret = 8041; + break; + case 8034: + ret = 8042; + break; + case 8035: + ret = 8043; + break; + case 8036: + ret = 8044; + break; + case 8037: + ret = 8045; + break; + case 8038: + ret = 8046; + break; + case 8039: + ret = 8047; + break; + case 8048: + ret = 8122; + break; + case 8049: + ret = 8123; + break; + case 8050: + ret = 8136; + break; + case 8051: + ret = 8137; + break; + case 8052: + ret = 8138; + break; + case 8053: + ret = 8139; + break; + case 8054: + ret = 8154; + break; + case 8055: + ret = 8155; + break; + case 8056: + ret = 8184; + break; + case 8057: + ret = 8185; + break; + case 8058: + ret = 8170; + break; + case 8059: + ret = 8171; + break; + case 8060: + ret = 8186; + break; + case 8061: + ret = 8187; + break; + case 8064: + ret = 8072; + break; + case 8065: + ret = 8073; + break; + case 8066: + ret = 8074; + break; + case 8067: + ret = 8075; + break; + case 8068: + ret = 8076; + break; + case 8069: + ret = 8077; + break; + case 8070: + ret = 8078; + break; + case 8071: + ret = 8079; + break; + case 8080: + ret = 8088; + break; + case 8081: + ret = 8089; + break; + case 8082: + ret = 8090; + break; + case 8083: + ret = 8091; + break; + case 8084: + ret = 8092; + break; + case 8085: + ret = 8093; + break; + case 8086: + ret = 8094; + break; + case 8087: + ret = 8095; + break; + case 8096: + ret = 8104; + break; + case 8097: + ret = 8105; + break; + case 8098: + ret = 8106; + break; + case 8099: + ret = 8107; + break; + case 8100: + ret = 8108; + break; + case 8101: + ret = 8109; + break; + case 8102: + ret = 8110; + break; + case 8103: + ret = 8111; + break; + case 8112: + ret = 8120; + break; + case 8113: + ret = 8121; + break; + case 8115: + ret = 8124; + break; + case 8131: + ret = 8140; + break; + case 8144: + ret = 8152; + break; + case 8145: + ret = 8153; + break; + case 8160: + ret = 8168; + break; + case 8161: + ret = 8169; + break; + case 8165: + ret = 8172; + break; + case 8179: + ret = 8188; + break; + case 8560: + ret = 8544; + break; + case 8561: + ret = 8545; + break; + case 8562: + ret = 8546; + break; + case 8563: + ret = 8547; + break; + case 8564: + ret = 8548; + break; + case 8565: + ret = 8549; + break; + case 8566: + ret = 8550; + break; + case 8567: + ret = 8551; + break; + case 8568: + ret = 8552; + break; + case 8569: + ret = 8553; + break; + case 8570: + ret = 8554; + break; + case 8571: + ret = 8555; + break; + case 8572: + ret = 8556; + break; + case 8573: + ret = 8557; + break; + case 8574: + ret = 8558; + break; + case 8575: + ret = 8559; + break; + case 9424: + ret = 9398; + break; + case 9425: + ret = 9399; + break; + case 9426: + ret = 9400; + break; + case 9427: + ret = 9401; + break; + case 9428: + ret = 9402; + break; + case 9429: + ret = 9403; + break; + case 9430: + ret = 9404; + break; + case 9431: + ret = 9405; + break; + case 9432: + ret = 9406; + break; + case 9433: + ret = 9407; + break; + case 9434: + ret = 9408; + break; + case 9435: + ret = 9409; + break; + case 9436: + ret = 9410; + break; + case 9437: + ret = 9411; + break; + case 9438: + ret = 9412; + break; + case 9439: + ret = 9413; + break; + case 9440: + ret = 9414; + break; + case 9441: + ret = 9415; + break; + case 9442: + ret = 9416; + break; + case 9443: + ret = 9417; + break; + case 9444: + ret = 9418; + break; + case 9445: + ret = 9419; + break; + case 9446: + ret = 9420; + break; + case 9447: + ret = 9421; + break; + case 9448: + ret = 9422; + break; + case 9449: + ret = 9423; + break; + case 65345: + ret = 65313; + break; + case 65346: + ret = 65314; + break; + case 65347: + ret = 65315; + break; + case 65348: + ret = 65316; + break; + case 65349: + ret = 65317; + break; + case 65350: + ret = 65318; + break; + case 65351: + ret = 65319; + break; + case 65352: + ret = 65320; + break; + case 65353: + ret = 65321; + break; + case 65354: + ret = 65322; + break; + case 65355: + ret = 65323; + break; + case 65356: + ret = 65324; + break; + case 65357: + ret = 65325; + break; + case 65358: + ret = 65326; + break; + case 65359: + ret = 65327; + break; + case 65360: + ret = 65328; + break; + case 65361: + ret = 65329; + break; + case 65362: + ret = 65330; + break; + case 65363: + ret = 65331; + break; + case 65364: + ret = 65332; + break; + case 65365: + ret = 65333; + break; + case 65366: + ret = 65334; + break; + case 65367: + ret = 65335; + break; + case 65368: + ret = 65336; + break; + case 65369: + ret = 65337; + break; + case 65370: + ret = 65338; + break; + } + return (char) ret; + } + return Character.toUpperCase(c); + } + + /** Convert a character to lower case. */ + public static char toLowerCase(char c) + { + if (java_1_0) + { + int ret = (int) c; + switch (c) + { + case 65: + ret = 97; + break; + case 66: + ret = 98; + break; + case 67: + ret = 99; + break; + case 68: + ret = 100; + break; + case 69: + ret = 101; + break; + case 70: + ret = 102; + break; + case 71: + ret = 103; + break; + case 72: + ret = 104; + break; + case 73: + ret = 105; + break; + case 74: + ret = 106; + break; + case 75: + ret = 107; + break; + case 76: + ret = 108; + break; + case 77: + ret = 109; + break; + case 78: + ret = 110; + break; + case 79: + ret = 111; + break; + case 80: + ret = 112; + break; + case 81: + ret = 113; + break; + case 82: + ret = 114; + break; + case 83: + ret = 115; + break; + case 84: + ret = 116; + break; + case 85: + ret = 117; + break; + case 86: + ret = 118; + break; + case 87: + ret = 119; + break; + case 88: + ret = 120; + break; + case 89: + ret = 121; + break; + case 90: + ret = 122; + break; + case 192: + ret = 224; + break; + case 193: + ret = 225; + break; + case 194: + ret = 226; + break; + case 195: + ret = 227; + break; + case 196: + ret = 228; + break; + case 197: + ret = 229; + break; + case 198: + ret = 230; + break; + case 199: + ret = 231; + break; + case 200: + ret = 232; + break; + case 201: + ret = 233; + break; + case 202: + ret = 234; + break; + case 203: + ret = 235; + break; + case 204: + ret = 236; + break; + case 205: + ret = 237; + break; + case 206: + ret = 238; + break; + case 207: + ret = 239; + break; + case 208: + ret = 240; + break; + case 209: + ret = 241; + break; + case 210: + ret = 242; + break; + case 211: + ret = 243; + break; + case 212: + ret = 244; + break; + case 213: + ret = 245; + break; + case 214: + ret = 246; + break; + case 216: + ret = 248; + break; + case 217: + ret = 249; + break; + case 218: + ret = 250; + break; + case 219: + ret = 251; + break; + case 220: + ret = 252; + break; + case 221: + ret = 253; + break; + case 222: + ret = 254; + break; + case 256: + ret = 257; + break; + case 258: + ret = 259; + break; + case 260: + ret = 261; + break; + case 262: + ret = 263; + break; + case 264: + ret = 265; + break; + case 266: + ret = 267; + break; + case 268: + ret = 269; + break; + case 270: + ret = 271; + break; + case 272: + ret = 273; + break; + case 274: + ret = 275; + break; + case 276: + ret = 277; + break; + case 278: + ret = 279; + break; + case 280: + ret = 281; + break; + case 282: + ret = 283; + break; + case 284: + ret = 285; + break; + case 286: + ret = 287; + break; + case 288: + ret = 289; + break; + case 290: + ret = 291; + break; + case 292: + ret = 293; + break; + case 294: + ret = 295; + break; + case 296: + ret = 297; + break; + case 298: + ret = 299; + break; + case 300: + ret = 301; + break; + case 302: + ret = 303; + break; + case 304: + ret = 105; + break; + case 306: + ret = 307; + break; + case 308: + ret = 309; + break; + case 310: + ret = 311; + break; + case 313: + ret = 314; + break; + case 315: + ret = 316; + break; + case 317: + ret = 318; + break; + case 319: + ret = 320; + break; + case 321: + ret = 322; + break; + case 323: + ret = 324; + break; + case 325: + ret = 326; + break; + case 327: + ret = 328; + break; + case 330: + ret = 331; + break; + case 332: + ret = 333; + break; + case 334: + ret = 335; + break; + case 336: + ret = 337; + break; + case 338: + ret = 339; + break; + case 340: + ret = 341; + break; + case 342: + ret = 343; + break; + case 344: + ret = 345; + break; + case 346: + ret = 347; + break; + case 348: + ret = 349; + break; + case 350: + ret = 351; + break; + case 352: + ret = 353; + break; + case 354: + ret = 355; + break; + case 356: + ret = 357; + break; + case 358: + ret = 359; + break; + case 360: + ret = 361; + break; + case 362: + ret = 363; + break; + case 364: + ret = 365; + break; + case 366: + ret = 367; + break; + case 368: + ret = 369; + break; + case 370: + ret = 371; + break; + case 372: + ret = 373; + break; + case 374: + ret = 375; + break; + case 376: + ret = 255; + break; + case 377: + ret = 378; + break; + case 379: + ret = 380; + break; + case 381: + ret = 382; + break; + case 385: + ret = 595; + break; + case 386: + ret = 387; + break; + case 388: + ret = 389; + break; + case 390: + ret = 596; + break; + case 391: + ret = 392; + break; + case 393: + ret = 598; + break; + case 394: + ret = 599; + break; + case 395: + ret = 396; + break; + case 398: + ret = 600; + break; + case 399: + ret = 601; + break; + case 400: + ret = 603; + break; + case 401: + ret = 402; + break; + case 403: + ret = 608; + break; + case 404: + ret = 611; + break; + case 406: + ret = 617; + break; + case 407: + ret = 616; + break; + case 408: + ret = 409; + break; + case 412: + ret = 623; + break; + case 413: + ret = 626; + break; + case 416: + ret = 417; + break; + case 418: + ret = 419; + break; + case 420: + ret = 421; + break; + case 423: + ret = 424; + break; + case 425: + ret = 643; + break; + case 428: + ret = 429; + break; + case 430: + ret = 648; + break; + case 431: + ret = 432; + break; + case 433: + ret = 650; + break; + case 434: + ret = 651; + break; + case 435: + ret = 436; + break; + case 437: + ret = 438; + break; + case 439: + ret = 658; + break; + case 440: + ret = 441; + break; + case 444: + ret = 445; + break; + case 452: + ret = 454; + break; + case 453: + ret = 454; + break; + case 455: + ret = 457; + break; + case 456: + ret = 457; + break; + case 458: + ret = 460; + break; + case 459: + ret = 460; + break; + case 461: + ret = 462; + break; + case 463: + ret = 464; + break; + case 465: + ret = 466; + break; + case 467: + ret = 468; + break; + case 469: + ret = 470; + break; + case 471: + ret = 472; + break; + case 473: + ret = 474; + break; + case 475: + ret = 476; + break; + case 478: + ret = 479; + break; + case 480: + ret = 481; + break; + case 482: + ret = 483; + break; + case 484: + ret = 485; + break; + case 486: + ret = 487; + break; + case 488: + ret = 489; + break; + case 490: + ret = 491; + break; + case 492: + ret = 493; + break; + case 494: + ret = 495; + break; + case 497: + ret = 499; + break; + case 498: + ret = 499; + break; + case 500: + ret = 501; + break; + case 506: + ret = 507; + break; + case 508: + ret = 509; + break; + case 510: + ret = 511; + break; + case 512: + ret = 513; + break; + case 514: + ret = 515; + break; + case 516: + ret = 517; + break; + case 518: + ret = 519; + break; + case 520: + ret = 521; + break; + case 522: + ret = 523; + break; + case 524: + ret = 525; + break; + case 526: + ret = 527; + break; + case 528: + ret = 529; + break; + case 530: + ret = 531; + break; + case 532: + ret = 533; + break; + case 534: + ret = 535; + break; + case 902: + ret = 940; + break; + case 904: + ret = 941; + break; + case 905: + ret = 942; + break; + case 906: + ret = 943; + break; + case 908: + ret = 972; + break; + case 910: + ret = 973; + break; + case 911: + ret = 974; + break; + case 913: + ret = 945; + break; + case 914: + ret = 946; + break; + case 915: + ret = 947; + break; + case 916: + ret = 948; + break; + case 917: + ret = 949; + break; + case 918: + ret = 950; + break; + case 919: + ret = 951; + break; + case 920: + ret = 952; + break; + case 921: + ret = 953; + break; + case 922: + ret = 954; + break; + case 923: + ret = 955; + break; + case 924: + ret = 956; + break; + case 925: + ret = 957; + break; + case 926: + ret = 958; + break; + case 927: + ret = 959; + break; + case 928: + ret = 960; + break; + case 929: + ret = 961; + break; + case 931: + ret = 963; + break; + case 932: + ret = 964; + break; + case 933: + ret = 965; + break; + case 934: + ret = 966; + break; + case 935: + ret = 967; + break; + case 936: + ret = 968; + break; + case 937: + ret = 969; + break; + case 938: + ret = 970; + break; + case 939: + ret = 971; + break; + case 994: + ret = 995; + break; + case 996: + ret = 997; + break; + case 998: + ret = 999; + break; + case 1000: + ret = 1001; + break; + case 1002: + ret = 1003; + break; + case 1004: + ret = 1005; + break; + case 1006: + ret = 1007; + break; + case 1025: + ret = 1105; + break; + case 1026: + ret = 1106; + break; + case 1027: + ret = 1107; + break; + case 1028: + ret = 1108; + break; + case 1029: + ret = 1109; + break; + case 1030: + ret = 1110; + break; + case 1031: + ret = 1111; + break; + case 1032: + ret = 1112; + break; + case 1033: + ret = 1113; + break; + case 1034: + ret = 1114; + break; + case 1035: + ret = 1115; + break; + case 1036: + ret = 1116; + break; + case 1038: + ret = 1118; + break; + case 1039: + ret = 1119; + break; + case 1040: + ret = 1072; + break; + case 1041: + ret = 1073; + break; + case 1042: + ret = 1074; + break; + case 1043: + ret = 1075; + break; + case 1044: + ret = 1076; + break; + case 1045: + ret = 1077; + break; + case 1046: + ret = 1078; + break; + case 1047: + ret = 1079; + break; + case 1048: + ret = 1080; + break; + case 1049: + ret = 1081; + break; + case 1050: + ret = 1082; + break; + case 1051: + ret = 1083; + break; + case 1052: + ret = 1084; + break; + case 1053: + ret = 1085; + break; + case 1054: + ret = 1086; + break; + case 1055: + ret = 1087; + break; + case 1056: + ret = 1088; + break; + case 1057: + ret = 1089; + break; + case 1058: + ret = 1090; + break; + case 1059: + ret = 1091; + break; + case 1060: + ret = 1092; + break; + case 1061: + ret = 1093; + break; + case 1062: + ret = 1094; + break; + case 1063: + ret = 1095; + break; + case 1064: + ret = 1096; + break; + case 1065: + ret = 1097; + break; + case 1066: + ret = 1098; + break; + case 1067: + ret = 1099; + break; + case 1068: + ret = 1100; + break; + case 1069: + ret = 1101; + break; + case 1070: + ret = 1102; + break; + case 1071: + ret = 1103; + break; + case 1120: + ret = 1121; + break; + case 1122: + ret = 1123; + break; + case 1124: + ret = 1125; + break; + case 1126: + ret = 1127; + break; + case 1128: + ret = 1129; + break; + case 1130: + ret = 1131; + break; + case 1132: + ret = 1133; + break; + case 1134: + ret = 1135; + break; + case 1136: + ret = 1137; + break; + case 1138: + ret = 1139; + break; + case 1140: + ret = 1141; + break; + case 1142: + ret = 1143; + break; + case 1144: + ret = 1145; + break; + case 1146: + ret = 1147; + break; + case 1148: + ret = 1149; + break; + case 1150: + ret = 1151; + break; + case 1152: + ret = 1153; + break; + case 1168: + ret = 1169; + break; + case 1170: + ret = 1171; + break; + case 1172: + ret = 1173; + break; + case 1174: + ret = 1175; + break; + case 1176: + ret = 1177; + break; + case 1178: + ret = 1179; + break; + case 1180: + ret = 1181; + break; + case 1182: + ret = 1183; + break; + case 1184: + ret = 1185; + break; + case 1186: + ret = 1187; + break; + case 1188: + ret = 1189; + break; + case 1190: + ret = 1191; + break; + case 1192: + ret = 1193; + break; + case 1194: + ret = 1195; + break; + case 1196: + ret = 1197; + break; + case 1198: + ret = 1199; + break; + case 1200: + ret = 1201; + break; + case 1202: + ret = 1203; + break; + case 1204: + ret = 1205; + break; + case 1206: + ret = 1207; + break; + case 1208: + ret = 1209; + break; + case 1210: + ret = 1211; + break; + case 1212: + ret = 1213; + break; + case 1214: + ret = 1215; + break; + case 1217: + ret = 1218; + break; + case 1219: + ret = 1220; + break; + case 1223: + ret = 1224; + break; + case 1227: + ret = 1228; + break; + case 1232: + ret = 1233; + break; + case 1234: + ret = 1235; + break; + case 1236: + ret = 1237; + break; + case 1238: + ret = 1239; + break; + case 1240: + ret = 1241; + break; + case 1242: + ret = 1243; + break; + case 1244: + ret = 1245; + break; + case 1246: + ret = 1247; + break; + case 1248: + ret = 1249; + break; + case 1250: + ret = 1251; + break; + case 1252: + ret = 1253; + break; + case 1254: + ret = 1255; + break; + case 1256: + ret = 1257; + break; + case 1258: + ret = 1259; + break; + case 1262: + ret = 1263; + break; + case 1264: + ret = 1265; + break; + case 1266: + ret = 1267; + break; + case 1268: + ret = 1269; + break; + case 1272: + ret = 1273; + break; + case 1329: + ret = 1377; + break; + case 1330: + ret = 1378; + break; + case 1331: + ret = 1379; + break; + case 1332: + ret = 1380; + break; + case 1333: + ret = 1381; + break; + case 1334: + ret = 1382; + break; + case 1335: + ret = 1383; + break; + case 1336: + ret = 1384; + break; + case 1337: + ret = 1385; + break; + case 1338: + ret = 1386; + break; + case 1339: + ret = 1387; + break; + case 1340: + ret = 1388; + break; + case 1341: + ret = 1389; + break; + case 1342: + ret = 1390; + break; + case 1343: + ret = 1391; + break; + case 1344: + ret = 1392; + break; + case 1345: + ret = 1393; + break; + case 1346: + ret = 1394; + break; + case 1347: + ret = 1395; + break; + case 1348: + ret = 1396; + break; + case 1349: + ret = 1397; + break; + case 1350: + ret = 1398; + break; + case 1351: + ret = 1399; + break; + case 1352: + ret = 1400; + break; + case 1353: + ret = 1401; + break; + case 1354: + ret = 1402; + break; + case 1355: + ret = 1403; + break; + case 1356: + ret = 1404; + break; + case 1357: + ret = 1405; + break; + case 1358: + ret = 1406; + break; + case 1359: + ret = 1407; + break; + case 1360: + ret = 1408; + break; + case 1361: + ret = 1409; + break; + case 1362: + ret = 1410; + break; + case 1363: + ret = 1411; + break; + case 1364: + ret = 1412; + break; + case 1365: + ret = 1413; + break; + case 1366: + ret = 1414; + break; + case 4256: + ret = 4304; + break; + case 4257: + ret = 4305; + break; + case 4258: + ret = 4306; + break; + case 4259: + ret = 4307; + break; + case 4260: + ret = 4308; + break; + case 4261: + ret = 4309; + break; + case 4262: + ret = 4310; + break; + case 4263: + ret = 4311; + break; + case 4264: + ret = 4312; + break; + case 4265: + ret = 4313; + break; + case 4266: + ret = 4314; + break; + case 4267: + ret = 4315; + break; + case 4268: + ret = 4316; + break; + case 4269: + ret = 4317; + break; + case 4270: + ret = 4318; + break; + case 4271: + ret = 4319; + break; + case 4272: + ret = 4320; + break; + case 4273: + ret = 4321; + break; + case 4274: + ret = 4322; + break; + case 4275: + ret = 4323; + break; + case 4276: + ret = 4324; + break; + case 4277: + ret = 4325; + break; + case 4278: + ret = 4326; + break; + case 4279: + ret = 4327; + break; + case 4280: + ret = 4328; + break; + case 4281: + ret = 4329; + break; + case 4282: + ret = 4330; + break; + case 4283: + ret = 4331; + break; + case 4284: + ret = 4332; + break; + case 4285: + ret = 4333; + break; + case 4286: + ret = 4334; + break; + case 4287: + ret = 4335; + break; + case 4288: + ret = 4336; + break; + case 4289: + ret = 4337; + break; + case 4290: + ret = 4338; + break; + case 4291: + ret = 4339; + break; + case 4292: + ret = 4340; + break; + case 4293: + ret = 4341; + break; + case 7680: + ret = 7681; + break; + case 7682: + ret = 7683; + break; + case 7684: + ret = 7685; + break; + case 7686: + ret = 7687; + break; + case 7688: + ret = 7689; + break; + case 7690: + ret = 7691; + break; + case 7692: + ret = 7693; + break; + case 7694: + ret = 7695; + break; + case 7696: + ret = 7697; + break; + case 7698: + ret = 7699; + break; + case 7700: + ret = 7701; + break; + case 7702: + ret = 7703; + break; + case 7704: + ret = 7705; + break; + case 7706: + ret = 7707; + break; + case 7708: + ret = 7709; + break; + case 7710: + ret = 7711; + break; + case 7712: + ret = 7713; + break; + case 7714: + ret = 7715; + break; + case 7716: + ret = 7717; + break; + case 7718: + ret = 7719; + break; + case 7720: + ret = 7721; + break; + case 7722: + ret = 7723; + break; + case 7724: + ret = 7725; + break; + case 7726: + ret = 7727; + break; + case 7728: + ret = 7729; + break; + case 7730: + ret = 7731; + break; + case 7732: + ret = 7733; + break; + case 7734: + ret = 7735; + break; + case 7736: + ret = 7737; + break; + case 7738: + ret = 7739; + break; + case 7740: + ret = 7741; + break; + case 7742: + ret = 7743; + break; + case 7744: + ret = 7745; + break; + case 7746: + ret = 7747; + break; + case 7748: + ret = 7749; + break; + case 7750: + ret = 7751; + break; + case 7752: + ret = 7753; + break; + case 7754: + ret = 7755; + break; + case 7756: + ret = 7757; + break; + case 7758: + ret = 7759; + break; + case 7760: + ret = 7761; + break; + case 7762: + ret = 7763; + break; + case 7764: + ret = 7765; + break; + case 7766: + ret = 7767; + break; + case 7768: + ret = 7769; + break; + case 7770: + ret = 7771; + break; + case 7772: + ret = 7773; + break; + case 7774: + ret = 7775; + break; + case 7776: + ret = 7777; + break; + case 7778: + ret = 7779; + break; + case 7780: + ret = 7781; + break; + case 7782: + ret = 7783; + break; + case 7784: + ret = 7785; + break; + case 7786: + ret = 7787; + break; + case 7788: + ret = 7789; + break; + case 7790: + ret = 7791; + break; + case 7792: + ret = 7793; + break; + case 7794: + ret = 7795; + break; + case 7796: + ret = 7797; + break; + case 7798: + ret = 7799; + break; + case 7800: + ret = 7801; + break; + case 7802: + ret = 7803; + break; + case 7804: + ret = 7805; + break; + case 7806: + ret = 7807; + break; + case 7808: + ret = 7809; + break; + case 7810: + ret = 7811; + break; + case 7812: + ret = 7813; + break; + case 7814: + ret = 7815; + break; + case 7816: + ret = 7817; + break; + case 7818: + ret = 7819; + break; + case 7820: + ret = 7821; + break; + case 7822: + ret = 7823; + break; + case 7824: + ret = 7825; + break; + case 7826: + ret = 7827; + break; + case 7828: + ret = 7829; + break; + case 7840: + ret = 7841; + break; + case 7842: + ret = 7843; + break; + case 7844: + ret = 7845; + break; + case 7846: + ret = 7847; + break; + case 7848: + ret = 7849; + break; + case 7850: + ret = 7851; + break; + case 7852: + ret = 7853; + break; + case 7854: + ret = 7855; + break; + case 7856: + ret = 7857; + break; + case 7858: + ret = 7859; + break; + case 7860: + ret = 7861; + break; + case 7862: + ret = 7863; + break; + case 7864: + ret = 7865; + break; + case 7866: + ret = 7867; + break; + case 7868: + ret = 7869; + break; + case 7870: + ret = 7871; + break; + case 7872: + ret = 7873; + break; + case 7874: + ret = 7875; + break; + case 7876: + ret = 7877; + break; + case 7878: + ret = 7879; + break; + case 7880: + ret = 7881; + break; + case 7882: + ret = 7883; + break; + case 7884: + ret = 7885; + break; + case 7886: + ret = 7887; + break; + case 7888: + ret = 7889; + break; + case 7890: + ret = 7891; + break; + case 7892: + ret = 7893; + break; + case 7894: + ret = 7895; + break; + case 7896: + ret = 7897; + break; + case 7898: + ret = 7899; + break; + case 7900: + ret = 7901; + break; + case 7902: + ret = 7903; + break; + case 7904: + ret = 7905; + break; + case 7906: + ret = 7907; + break; + case 7908: + ret = 7909; + break; + case 7910: + ret = 7911; + break; + case 7912: + ret = 7913; + break; + case 7914: + ret = 7915; + break; + case 7916: + ret = 7917; + break; + case 7918: + ret = 7919; + break; + case 7920: + ret = 7921; + break; + case 7922: + ret = 7923; + break; + case 7924: + ret = 7925; + break; + case 7926: + ret = 7927; + break; + case 7928: + ret = 7929; + break; + case 7944: + ret = 7936; + break; + case 7945: + ret = 7937; + break; + case 7946: + ret = 7938; + break; + case 7947: + ret = 7939; + break; + case 7948: + ret = 7940; + break; + case 7949: + ret = 7941; + break; + case 7950: + ret = 7942; + break; + case 7951: + ret = 7943; + break; + case 7960: + ret = 7952; + break; + case 7961: + ret = 7953; + break; + case 7962: + ret = 7954; + break; + case 7963: + ret = 7955; + break; + case 7964: + ret = 7956; + break; + case 7965: + ret = 7957; + break; + case 7976: + ret = 7968; + break; + case 7977: + ret = 7969; + break; + case 7978: + ret = 7970; + break; + case 7979: + ret = 7971; + break; + case 7980: + ret = 7972; + break; + case 7981: + ret = 7973; + break; + case 7982: + ret = 7974; + break; + case 7983: + ret = 7975; + break; + case 7992: + ret = 7984; + break; + case 7993: + ret = 7985; + break; + case 7994: + ret = 7986; + break; + case 7995: + ret = 7987; + break; + case 7996: + ret = 7988; + break; + case 7997: + ret = 7989; + break; + case 7998: + ret = 7990; + break; + case 7999: + ret = 7991; + break; + case 8008: + ret = 8000; + break; + case 8009: + ret = 8001; + break; + case 8010: + ret = 8002; + break; + case 8011: + ret = 8003; + break; + case 8012: + ret = 8004; + break; + case 8013: + ret = 8005; + break; + case 8025: + ret = 8017; + break; + case 8027: + ret = 8019; + break; + case 8029: + ret = 8021; + break; + case 8031: + ret = 8023; + break; + case 8040: + ret = 8032; + break; + case 8041: + ret = 8033; + break; + case 8042: + ret = 8034; + break; + case 8043: + ret = 8035; + break; + case 8044: + ret = 8036; + break; + case 8045: + ret = 8037; + break; + case 8046: + ret = 8038; + break; + case 8047: + ret = 8039; + break; + case 8072: + ret = 8064; + break; + case 8073: + ret = 8065; + break; + case 8074: + ret = 8066; + break; + case 8075: + ret = 8067; + break; + case 8076: + ret = 8068; + break; + case 8077: + ret = 8069; + break; + case 8078: + ret = 8070; + break; + case 8079: + ret = 8071; + break; + case 8088: + ret = 8080; + break; + case 8089: + ret = 8081; + break; + case 8090: + ret = 8082; + break; + case 8091: + ret = 8083; + break; + case 8092: + ret = 8084; + break; + case 8093: + ret = 8085; + break; + case 8094: + ret = 8086; + break; + case 8095: + ret = 8087; + break; + case 8104: + ret = 8096; + break; + case 8105: + ret = 8097; + break; + case 8106: + ret = 8098; + break; + case 8107: + ret = 8099; + break; + case 8108: + ret = 8100; + break; + case 8109: + ret = 8101; + break; + case 8110: + ret = 8102; + break; + case 8111: + ret = 8103; + break; + case 8120: + ret = 8112; + break; + case 8121: + ret = 8113; + break; + case 8122: + ret = 8048; + break; + case 8123: + ret = 8049; + break; + case 8124: + ret = 8115; + break; + case 8136: + ret = 8050; + break; + case 8137: + ret = 8051; + break; + case 8138: + ret = 8052; + break; + case 8139: + ret = 8053; + break; + case 8140: + ret = 8131; + break; + case 8152: + ret = 8144; + break; + case 8153: + ret = 8145; + break; + case 8154: + ret = 8054; + break; + case 8155: + ret = 8055; + break; + case 8168: + ret = 8160; + break; + case 8169: + ret = 8161; + break; + case 8170: + ret = 8058; + break; + case 8171: + ret = 8059; + break; + case 8172: + ret = 8165; + break; + case 8184: + ret = 8056; + break; + case 8185: + ret = 8057; + break; + case 8186: + ret = 8060; + break; + case 8187: + ret = 8061; + break; + case 8188: + ret = 8179; + break; + case 8544: + ret = 8560; + break; + case 8545: + ret = 8561; + break; + case 8546: + ret = 8562; + break; + case 8547: + ret = 8563; + break; + case 8548: + ret = 8564; + break; + case 8549: + ret = 8565; + break; + case 8550: + ret = 8566; + break; + case 8551: + ret = 8567; + break; + case 8552: + ret = 8568; + break; + case 8553: + ret = 8569; + break; + case 8554: + ret = 8570; + break; + case 8555: + ret = 8571; + break; + case 8556: + ret = 8572; + break; + case 8557: + ret = 8573; + break; + case 8558: + ret = 8574; + break; + case 8559: + ret = 8575; + break; + case 9398: + ret = 9424; + break; + case 9399: + ret = 9425; + break; + case 9400: + ret = 9426; + break; + case 9401: + ret = 9427; + break; + case 9402: + ret = 9428; + break; + case 9403: + ret = 9429; + break; + case 9404: + ret = 9430; + break; + case 9405: + ret = 9431; + break; + case 9406: + ret = 9432; + break; + case 9407: + ret = 9433; + break; + case 9408: + ret = 9434; + break; + case 9409: + ret = 9435; + break; + case 9410: + ret = 9436; + break; + case 9411: + ret = 9437; + break; + case 9412: + ret = 9438; + break; + case 9413: + ret = 9439; + break; + case 9414: + ret = 9440; + break; + case 9415: + ret = 9441; + break; + case 9416: + ret = 9442; + break; + case 9417: + ret = 9443; + break; + case 9418: + ret = 9444; + break; + case 9419: + ret = 9445; + break; + case 9420: + ret = 9446; + break; + case 9421: + ret = 9447; + break; + case 9422: + ret = 9448; + break; + case 9423: + ret = 9449; + break; + case 65313: + ret = 65345; + break; + case 65314: + ret = 65346; + break; + case 65315: + ret = 65347; + break; + case 65316: + ret = 65348; + break; + case 65317: + ret = 65349; + break; + case 65318: + ret = 65350; + break; + case 65319: + ret = 65351; + break; + case 65320: + ret = 65352; + break; + case 65321: + ret = 65353; + break; + case 65322: + ret = 65354; + break; + case 65323: + ret = 65355; + break; + case 65324: + ret = 65356; + break; + case 65325: + ret = 65357; + break; + case 65326: + ret = 65358; + break; + case 65327: + ret = 65359; + break; + case 65328: + ret = 65360; + break; + case 65329: + ret = 65361; + break; + case 65330: + ret = 65362; + break; + case 65331: + ret = 65363; + break; + case 65332: + ret = 65364; + break; + case 65333: + ret = 65365; + break; + case 65334: + ret = 65366; + break; + case 65335: + ret = 65367; + break; + case 65336: + ret = 65368; + break; + case 65337: + ret = 65369; + break; + case 65338: + ret = 65370; + break; + } + return (char) ret; + } + return Character.toLowerCase(c); + } + + /** Convert a String to title case. */ + public static String toTitleCase(String s) + { + javajs.util.SB sb = new javajs.util.SB(); + for (int i = 0; i < s.length(); i++) + { + sb.appendC(CaseMgr.toTitleCase(s.charAt(i))); + } + return sb.toString(); + } + + /** Convert a String to upper case. */ + public static String toUpperCase(String s) + { + javajs.util.SB sb = new javajs.util.SB(); + for (int i = 0; i < s.length(); i++) + { + sb.appendC(CaseMgr.toUpperCase(s.charAt(i))); + } + return sb.toString(); + } + + /** Convert a String to lower case. */ + public static String toLowerCase(String s) + { + javajs.util.SB sb = new javajs.util.SB(); + for (int i = 0; i < s.length(); i++) + { + sb.appendC(CaseMgr.toLowerCase(s.charAt(i))); + } + return sb.toString(); + } + + /** Convert a character to title case. */ + public static char toTitleCase(char c) + { + if (java_1_0) + { + int ret = (int) toUpperCase(c); + switch (c) + { + case 452: + ret = 453; + break; + case 453: + ret = 453; + break; + case 454: + ret = 453; + break; + case 455: + ret = 456; + break; + case 456: + ret = 456; + break; + case 457: + ret = 456; + break; + case 458: + ret = 459; + break; + case 459: + ret = 459; + break; + case 460: + ret = 459; + break; + case 497: + ret = 498; + break; + case 498: + ret = 498; + break; + case 499: + ret = 498; + break; + } + return (char) ret; + } + return Character.toTitleCase(c); + } + + /** + * Duplicates the regionMatches routine of String -- but makes use of the + * definitions of upper, lower, and title case in this class when ignoreCase + * is set. + */ + public static boolean regionMatches(StringLike s1, boolean ign, int i1, + StringLike s2, int i2, int i3) + { + int itot = i2 + i3; + if (itot > s2.length() || i1 + i3 > s1.length()) + { + return false; + } + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; + } + } + } + else + { + for (int i = i2; i < itot; i++) + { + if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) + { + return false; + } + } + } + return true; + } + + /** + * Duplicates the regionMatches routine of String -- but makes use of the + * definitions of upper, lower, and title case in this class when ignoreCase + * is set. + */ + public static boolean regionMatches(String s1, boolean ign, int i1, + StringLike s2, int i2, int i3) + { + int itot = i2 + i3; + if (itot > s2.length() || i1 + i3 > s1.length()) + { + return false; + } + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; + } + } + } + else + { + for (int i = i2; i < itot; i++) + { + if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) + { + return false; + } + } + } + return true; + } + + /** + * Duplicates the regionMatches routine of String -- but makes use of the + * definitions of upper, lower, and title case in this class when ignoreCase + * is set. + */ + public static boolean regionMatches(StringLike s1, boolean ign, int i1, + String s2, int i2, int i3) + { + int itot = i2 + i3; + if (itot > s2.length() || i1 + i3 > s1.length()) + { + return false; + } + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; + } + } + } + else + { + for (int i = i2; i < itot; i++) + { + if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) + { + return false; + } + } + } + return true; + } + + /** + * Duplicates the regionMatches routine of String -- but makes use of the + * definitions of upper, lower, and title case in this class when ignoreCase + * is set. + */ + public static boolean regionMatches(String s1, boolean ign, int i1, + String s2, int i2, int i3) + { + int itot = i2 + i3; + if (itot > s2.length() || i1 + i3 > s1.length()) + { + return false; + } + if (!ign) + { + for (int i = i2; i < itot; i++) + { + if (s2.charAt(i) != s1.charAt(i1++)) + { + return false; + } + } + } + else + { + for (int i = i2; i < itot; i++) + { + if (toLowerCase(s2.charAt(i)) != toLowerCase(s1.charAt(i1++))) + { + return false; + } + } + } + return true; + } +} diff --git a/unused/com/stevesoft/pat/ChangeRule.java b/unused/com/stevesoft/pat/ChangeRule.java index e8ef5df..b2b6c0e 100644 --- a/unused/com/stevesoft/pat/ChangeRule.java +++ b/unused/com/stevesoft/pat/ChangeRule.java @@ -1,50 +1,50 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class implements user defined special replacement rules of the form - * ${=name}. See trans2.java and trans2a.java. - */ -public class ChangeRule extends SpecialRule -{ - Regex NewRule; - - public ChangeRule(ChangeRule c) - { - NewRule = c.NewRule; - } - - public ChangeRule(String nm, Regex rr) - { - name = nm; - NewRule = rr; - } - - public ChangeRule(String nm, Transformer tr) - { - name = nm; - NewRule = tr.rp; - } - - public Object clone1() - { - return new ChangeRule(this); - } - - public String toString1() - { - return "${=" + name + "}"; - } - - public void apply(StringBufferLike sb, RegRes rr) - { - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class implements user defined special replacement rules of the form + * ${=name}. See trans2.java and trans2a.java. + */ +public class ChangeRule extends SpecialRule +{ + Regex NewRule; + + public ChangeRule(ChangeRule c) + { + NewRule = c.NewRule; + } + + public ChangeRule(String nm, Regex rr) + { + name = nm; + NewRule = rr; + } + + public ChangeRule(String nm, Transformer tr) + { + name = nm; + NewRule = tr.rp; + } + + public Object clone1() + { + return new ChangeRule(this); + } + + public String toString1() + { + return "${=" + name + "}"; + } + + public void apply(StringBufferLike sb, RegRes rr) + { + } +} diff --git a/unused/com/stevesoft/pat/CodeRule.java b/unused/com/stevesoft/pat/CodeRule.java index aa9c4dc..b4739ca 100644 --- a/unused/com/stevesoft/pat/CodeRule.java +++ b/unused/com/stevesoft/pat/CodeRule.java @@ -1,33 +1,33 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** Implements the rules for \U, \L, \E, \Q in substitutions. */ -public final class CodeRule extends SpecialRule -{ - char c = 'E'; - - public CodeRule() - { - } - - public CodeRule(char c) - { - this.c = c; - } - - public void apply(StringBufferLike sb, RegRes res) - { - sb.setMode(c); - } - - public String toString1() - { - return "\\" + c; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** Implements the rules for \U, \L, \E, \Q in substitutions. */ +public final class CodeRule extends SpecialRule +{ + char c = 'E'; + + public CodeRule() + { + } + + public CodeRule(char c) + { + this.c = c; + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.setMode(c); + } + + public String toString1() + { + return "\\" + c; + } +} diff --git a/unused/com/stevesoft/pat/Ctrl.java b/unused/com/stevesoft/pat/Ctrl.java index 5d40098..72da16d 100644 --- a/unused/com/stevesoft/pat/Ctrl.java +++ b/unused/com/stevesoft/pat/Ctrl.java @@ -1,61 +1,61 @@ -package // -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -com.stevesoft.pat; - -public class Ctrl -{ - public final static char[] cmap = - { (char) 64, (char) 65, (char) 66, (char) 67, (char) 68, (char) 69, - (char) 70, (char) 71, (char) 72, (char) 73, (char) 74, (char) 75, - (char) 76, (char) 77, (char) 78, (char) 79, (char) 80, (char) 81, - (char) 82, (char) 83, (char) 84, (char) 85, (char) 86, (char) 87, - (char) 88, (char) 89, (char) 90, (char) 91, (char) 92, (char) 93, - (char) 94, (char) 95, (char) 96, (char) 97, (char) 97, (char) 99, - (char) 100, (char) 101, (char) 102, (char) 103, (char) 104, - (char) 105, (char) 106, (char) 107, (char) 108, (char) 109, - (char) 110, (char) 111, (char) 112, (char) 113, (char) 114, - (char) 115, (char) 116, (char) 117, (char) 118, (char) 119, - (char) 120, (char) 121, (char) 122, (char) 123, (char) 124, - (char) 125, (char) 126, (char) 127, (char) 0, (char) 1, (char) 2, - (char) 3, (char) 4, (char) 5, (char) 6, (char) 7, (char) 8, (char) 9, - (char) 10, (char) 11, (char) 12, (char) 13, (char) 14, (char) 15, - (char) 16, (char) 17, (char) 18, (char) 19, (char) 20, (char) 21, - (char) 22, (char) 23, (char) 24, (char) 25, (char) 26, (char) 27, - (char) 27, (char) 29, (char) 30, (char) 31, (char) 32, (char) 1, - (char) 2, (char) 3, (char) 4, (char) 5, (char) 6, (char) 7, (char) 8, - (char) 9, (char) 10, (char) 11, (char) 12, (char) 13, (char) 14, - (char) 15, (char) 16, (char) 17, (char) 18, (char) 19, (char) 20, - (char) 21, (char) 22, (char) 23, (char) 24, (char) 25, (char) 26, - (char) 59, (char) 60, (char) 61, (char) 62, (char) 63, (char) 192, - (char) 193, (char) 194, (char) 195, (char) 196, (char) 197, - (char) 198, (char) 199, (char) 200, (char) 201, (char) 202, - (char) 203, (char) 204, (char) 205, (char) 206, (char) 207, - (char) 208, (char) 209, (char) 210, (char) 211, (char) 212, - (char) 213, (char) 214, (char) 215, (char) 216, (char) 217, - (char) 218, (char) 219, (char) 220, (char) 221, (char) 222, - (char) 223, (char) 224, (char) 225, (char) 226, (char) 227, - (char) 228, (char) 229, (char) 230, (char) 231, (char) 232, - (char) 233, (char) 234, (char) 235, (char) 236, (char) 237, - (char) 238, (char) 239, (char) 240, (char) 241, (char) 242, - (char) 243, (char) 244, (char) 245, (char) 246, (char) 247, - (char) 248, (char) 249, (char) 250, (char) 251, (char) 252, - (char) 253, (char) 254, (char) 255, (char) 128, (char) 129, - (char) 130, (char) 131, (char) 132, (char) 133, (char) 134, - (char) 135, (char) 136, (char) 137, (char) 138, (char) 139, - (char) 140, (char) 141, (char) 142, (char) 143, (char) 144, - (char) 145, (char) 146, (char) 147, (char) 148, (char) 149, - (char) 150, (char) 151, (char) 152, (char) 153, (char) 154, - (char) 155, (char) 156, (char) 157, (char) 158, (char) 159, - (char) 160, (char) 161, (char) 162, (char) 163, (char) 164, - (char) 165, (char) 166, (char) 167, (char) 168, (char) 169, - (char) 170, (char) 171, (char) 172, (char) 173, (char) 174, - (char) 175, (char) 176, (char) 177, (char) 178, (char) 179, - (char) 180, (char) 181, (char) 182, (char) 183, (char) 184, - (char) 185, (char) 186, (char) 187, (char) 188, (char) 189, - (char) 190, (char) 191 }; -} +package // +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +com.stevesoft.pat; + +public class Ctrl +{ + public final static char[] cmap = + { (char) 64, (char) 65, (char) 66, (char) 67, (char) 68, (char) 69, + (char) 70, (char) 71, (char) 72, (char) 73, (char) 74, (char) 75, + (char) 76, (char) 77, (char) 78, (char) 79, (char) 80, (char) 81, + (char) 82, (char) 83, (char) 84, (char) 85, (char) 86, (char) 87, + (char) 88, (char) 89, (char) 90, (char) 91, (char) 92, (char) 93, + (char) 94, (char) 95, (char) 96, (char) 97, (char) 97, (char) 99, + (char) 100, (char) 101, (char) 102, (char) 103, (char) 104, + (char) 105, (char) 106, (char) 107, (char) 108, (char) 109, + (char) 110, (char) 111, (char) 112, (char) 113, (char) 114, + (char) 115, (char) 116, (char) 117, (char) 118, (char) 119, + (char) 120, (char) 121, (char) 122, (char) 123, (char) 124, + (char) 125, (char) 126, (char) 127, (char) 0, (char) 1, (char) 2, + (char) 3, (char) 4, (char) 5, (char) 6, (char) 7, (char) 8, (char) 9, + (char) 10, (char) 11, (char) 12, (char) 13, (char) 14, (char) 15, + (char) 16, (char) 17, (char) 18, (char) 19, (char) 20, (char) 21, + (char) 22, (char) 23, (char) 24, (char) 25, (char) 26, (char) 27, + (char) 27, (char) 29, (char) 30, (char) 31, (char) 32, (char) 1, + (char) 2, (char) 3, (char) 4, (char) 5, (char) 6, (char) 7, (char) 8, + (char) 9, (char) 10, (char) 11, (char) 12, (char) 13, (char) 14, + (char) 15, (char) 16, (char) 17, (char) 18, (char) 19, (char) 20, + (char) 21, (char) 22, (char) 23, (char) 24, (char) 25, (char) 26, + (char) 59, (char) 60, (char) 61, (char) 62, (char) 63, (char) 192, + (char) 193, (char) 194, (char) 195, (char) 196, (char) 197, + (char) 198, (char) 199, (char) 200, (char) 201, (char) 202, + (char) 203, (char) 204, (char) 205, (char) 206, (char) 207, + (char) 208, (char) 209, (char) 210, (char) 211, (char) 212, + (char) 213, (char) 214, (char) 215, (char) 216, (char) 217, + (char) 218, (char) 219, (char) 220, (char) 221, (char) 222, + (char) 223, (char) 224, (char) 225, (char) 226, (char) 227, + (char) 228, (char) 229, (char) 230, (char) 231, (char) 232, + (char) 233, (char) 234, (char) 235, (char) 236, (char) 237, + (char) 238, (char) 239, (char) 240, (char) 241, (char) 242, + (char) 243, (char) 244, (char) 245, (char) 246, (char) 247, + (char) 248, (char) 249, (char) 250, (char) 251, (char) 252, + (char) 253, (char) 254, (char) 255, (char) 128, (char) 129, + (char) 130, (char) 131, (char) 132, (char) 133, (char) 134, + (char) 135, (char) 136, (char) 137, (char) 138, (char) 139, + (char) 140, (char) 141, (char) 142, (char) 143, (char) 144, + (char) 145, (char) 146, (char) 147, (char) 148, (char) 149, + (char) 150, (char) 151, (char) 152, (char) 153, (char) 154, + (char) 155, (char) 156, (char) 157, (char) 158, (char) 159, + (char) 160, (char) 161, (char) 162, (char) 163, (char) 164, + (char) 165, (char) 166, (char) 167, (char) 168, (char) 169, + (char) 170, (char) 171, (char) 172, (char) 173, (char) 174, + (char) 175, (char) 176, (char) 177, (char) 178, (char) 179, + (char) 180, (char) 181, (char) 182, (char) 183, (char) 184, + (char) 185, (char) 186, (char) 187, (char) 188, (char) 189, + (char) 190, (char) 191 }; +} diff --git a/unused/com/stevesoft/pat/Custom.java b/unused/com/stevesoft/pat/Custom.java index 61879ac..18cba7d 100644 --- a/unused/com/stevesoft/pat/Custom.java +++ b/unused/com/stevesoft/pat/Custom.java @@ -1,64 +1,64 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * Simple custom patterns. See deriv2.java and deriv3.java in the - * test directory. - * - * @see com.stevesoft.pat.CustomEndpoint - */ -class Custom extends PatternSub -{ - String select; - - Validator v; - - int start; - - Custom(String s) - { - select = s; - v = (Validator) Regex.validators.get(s); - } - - public int matchInternal(int pos, Pthings pt) - { - start = pos; - return sub.matchInternal(pos, pt); - } - - public String toString() - { - String a = v.argsave == null ? "" : ":" + v.argsave; - return "(??" + select + a + ")" + nextString(); - } - - public patInt minChars() - { - return v.minChars(); - } - - public patInt maxChars() - { - return v.maxChars(); - } - - Pattern clone1(Hashtable h) - { - Custom c = new Custom(select); - h.put(c, c); - h.put(this, c); - c.sub = sub.clone(h); - return c; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Simple custom patterns. See deriv2.java and deriv3.java in the + * test directory. + * + * @see com.stevesoft.pat.CustomEndpoint + */ +class Custom extends PatternSub +{ + String select; + + Validator v; + + int start; + + Custom(String s) + { + select = s; + v = (Validator) Regex.validators.get(s); + } + + public int matchInternal(int pos, Pthings pt) + { + start = pos; + return sub.matchInternal(pos, pt); + } + + public String toString() + { + String a = v.argsave == null ? "" : ":" + v.argsave; + return "(??" + select + a + ")" + nextString(); + } + + public patInt minChars() + { + return v.minChars(); + } + + public patInt maxChars() + { + return v.maxChars(); + } + + Pattern clone1(Hashtable h) + { + Custom c = new Custom(select); + h.put(c, c); + h.put(this, c); + c.sub = sub.clone(h); + return c; + } +} diff --git a/unused/com/stevesoft/pat/CustomEndpoint.java b/unused/com/stevesoft/pat/CustomEndpoint.java index 9608f7e..3c57b29 100644 --- a/unused/com/stevesoft/pat/CustomEndpoint.java +++ b/unused/com/stevesoft/pat/CustomEndpoint.java @@ -1,44 +1,44 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * This class is needed internally to make backtracking work correctly in - * user-defined patterns. - */ -class CustomEndpoint extends Pattern -{ - Custom c; - - CustomEndpoint(Custom cm) - { - c = cm; - } - - public int matchInternal(int pos, Pthings pt) - { - int npos = c.v.validate(pt.src, c.start, pos); - if (npos >= 0) - { - return nextMatch(npos, pt); - } - return -1; - } - - public String toString() - { - return ""; - } - - Pattern clone1(Hashtable h) - { - return new CustomEndpoint((Custom) c.clone(h)); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * This class is needed internally to make backtracking work correctly in + * user-defined patterns. + */ +class CustomEndpoint extends Pattern +{ + Custom c; + + CustomEndpoint(Custom cm) + { + c = cm; + } + + public int matchInternal(int pos, Pthings pt) + { + int npos = c.v.validate(pt.src, c.start, pos); + if (npos >= 0) + { + return nextMatch(npos, pt); + } + return -1; + } + + public String toString() + { + return ""; + } + + Pattern clone1(Hashtable h) + { + return new CustomEndpoint((Custom) c.clone(h)); + } +} diff --git a/unused/com/stevesoft/pat/DotMulti.java b/unused/com/stevesoft/pat/DotMulti.java index cc5f094..2cf6a47 100644 --- a/unused/com/stevesoft/pat/DotMulti.java +++ b/unused/com/stevesoft/pat/DotMulti.java @@ -1,209 +1,209 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * A special optimization of multi that is used when the common subpattern ".*" - * is encountered. - */ -class DotMulti extends PatternSub -{ - patInt fewestMatches, mostMatches; - - public patInt minChars() - { - return fewestMatches; - } - - public patInt maxChars() - { - return mostMatches; - } - - public boolean matchFewest = false; - - StringLike src = null; - - int srclength = 0; - - boolean dotDoesntMatchCR = true; - - DotMulti(patInt a, patInt b) - { - fewestMatches = a; - mostMatches = b; - } - - public String toString() - { - return ".{" + fewestMatches + "," + mostMatches + "}" - + (matchFewest ? "?" : "") + "(?# <= dot multi)" + nextString(); - } - - final int submatchInternal(int pos, Pthings pt) - { - if (pos < srclength) - { - if (dotDoesntMatchCR) - { - if (src.charAt(pos) != '\n') - { - return 1 + pos; - } - } - else - { - return 1 + pos; - } - } - return -1; - } - - final static int step = 1; - - static int idcount = 1; - - public int matchInternal(int pos, Pthings pt) - { - int m = -1; - int i = pos; - src = pt.src; - srclength = src.length(); - dotDoesntMatchCR = pt.dotDoesntMatchCR; - if (matchFewest) - { - int nMatches = 0; - while (fewestMatches.intValue() > nMatches) - { - i = submatchInternal(i, pt); - if (i < 0) - { - return -1; - } - nMatches++; - } - if (i < 0) - { - return -1; - } - int ii = nextMatch(i, pt); - if (ii >= 0) - { - return ii; - } - if (!mostMatches.finite()) - { - while (i >= 0) - { - i = submatchInternal(i, pt); - if (i < 0) - { - return -1; - } - ii = nextMatch(i, pt); - if (ii >= 0) - { - return ii; - } - } - } - else - { - while (i > 0) - { - i = submatchInternal(i, pt); - if (i < 0) - { - return -1; - } - nMatches++; - if (nMatches > mostMatches.intValue()) - { - return -1; - } - ii = nextMatch(i, pt); - if (ii >= 0) - { - return ii; - } - } - } - return -1; - } - int nMatches = 0; - while (fewestMatches.intValue() > nMatches) - { - i = submatchInternal(i, pt); - if (i >= 0) - { - nMatches++; - } - else - { - return -1; - } - } - m = i; - if (mostMatches.finite()) - { - while (nMatches < mostMatches.intValue()) - { - i = submatchInternal(i, pt); - if (i >= 0) - { - m = i; - nMatches++; - } - else - { - break; - } - } - } - else - { - while (true) - { - i = submatchInternal(i, pt); - if (i >= 0) - { - m = i; - nMatches++; - } - else - { - break; - } - } - } - while (m >= pos) - { - int r = nextMatch(m, pt); - if (r >= 0) - { - return r; - } - m -= step; - nMatches--; - if (nMatches < fewestMatches.intValue()) - { - return -1; - } - } - return -1; - } - - Pattern clone1(Hashtable h) - { - DotMulti dm = new DotMulti(fewestMatches, mostMatches); - dm.matchFewest = matchFewest; - return dm; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * A special optimization of multi that is used when the common subpattern ".*" + * is encountered. + */ +class DotMulti extends PatternSub +{ + patInt fewestMatches, mostMatches; + + public patInt minChars() + { + return fewestMatches; + } + + public patInt maxChars() + { + return mostMatches; + } + + public boolean matchFewest = false; + + StringLike src = null; + + int srclength = 0; + + boolean dotDoesntMatchCR = true; + + DotMulti(patInt a, patInt b) + { + fewestMatches = a; + mostMatches = b; + } + + public String toString() + { + return ".{" + fewestMatches + "," + mostMatches + "}" + + (matchFewest ? "?" : "") + "(?# <= dot multi)" + nextString(); + } + + final int submatchInternal(int pos, Pthings pt) + { + if (pos < srclength) + { + if (dotDoesntMatchCR) + { + if (src.charAt(pos) != '\n') + { + return 1 + pos; + } + } + else + { + return 1 + pos; + } + } + return -1; + } + + final static int step = 1; + + static int idcount = 1; + + public int matchInternal(int pos, Pthings pt) + { + int m = -1; + int i = pos; + src = pt.src; + srclength = src.length(); + dotDoesntMatchCR = pt.dotDoesntMatchCR; + if (matchFewest) + { + int nMatches = 0; + while (fewestMatches.intValue() > nMatches) + { + i = submatchInternal(i, pt); + if (i < 0) + { + return -1; + } + nMatches++; + } + if (i < 0) + { + return -1; + } + int ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + if (!mostMatches.finite()) + { + while (i >= 0) + { + i = submatchInternal(i, pt); + if (i < 0) + { + return -1; + } + ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + } + } + else + { + while (i > 0) + { + i = submatchInternal(i, pt); + if (i < 0) + { + return -1; + } + nMatches++; + if (nMatches > mostMatches.intValue()) + { + return -1; + } + ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + } + } + return -1; + } + int nMatches = 0; + while (fewestMatches.intValue() > nMatches) + { + i = submatchInternal(i, pt); + if (i >= 0) + { + nMatches++; + } + else + { + return -1; + } + } + m = i; + if (mostMatches.finite()) + { + while (nMatches < mostMatches.intValue()) + { + i = submatchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; + } + else + { + break; + } + } + } + else + { + while (true) + { + i = submatchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; + } + else + { + break; + } + } + } + while (m >= pos) + { + int r = nextMatch(m, pt); + if (r >= 0) + { + return r; + } + m -= step; + nMatches--; + if (nMatches < fewestMatches.intValue()) + { + return -1; + } + } + return -1; + } + + Pattern clone1(Hashtable h) + { + DotMulti dm = new DotMulti(fewestMatches, mostMatches); + dm.matchFewest = matchFewest; + return dm; + } +} diff --git a/unused/com/stevesoft/pat/End.java b/unused/com/stevesoft/pat/End.java index 547f3d6..2d6a04d 100644 --- a/unused/com/stevesoft/pat/End.java +++ b/unused/com/stevesoft/pat/End.java @@ -1,71 +1,71 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -//class AddToEnd extends RegSyntax {}; - -/** - * Compiles the '$' or the '\Z' Pattern. It is an error to have further Pattern - * elements after '\Z'. It is the end of the String. - */ -class End extends Pattern -{ - boolean retIsEnd; - - End(boolean b) - { - retIsEnd = b; - } - - public int matchInternal(int pos, Pthings pt) - { - if (retIsEnd && pt.mFlag && pos < pt.src.length()) - { - if (pt.src.charAt(pos) == '\n') - { - return nextMatch(pos, pt); - } - } - if (pt.src.length() == pos) - { - return nextMatch(pos, pt); - } - else if (pos < pt.src.length()) - { - // Access the next character... - // this is crucial to making - // RegexReader work. - pt.src.charAt(pos); - } - return -1; - } - - public String toString() - { - if (retIsEnd) - { - return "$"; - } - else - { - return "\\Z"; - } - } - - public patInt maxChars() - { - return new patInt(1); - } - - public Pattern clone1(Hashtable h) - { - return new End(retIsEnd); - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +//class AddToEnd extends RegSyntax {}; + +/** + * Compiles the '$' or the '\Z' Pattern. It is an error to have further Pattern + * elements after '\Z'. It is the end of the String. + */ +class End extends Pattern +{ + boolean retIsEnd; + + End(boolean b) + { + retIsEnd = b; + } + + public int matchInternal(int pos, Pthings pt) + { + if (retIsEnd && pt.mFlag && pos < pt.src.length()) + { + if (pt.src.charAt(pos) == '\n') + { + return nextMatch(pos, pt); + } + } + if (pt.src.length() == pos) + { + return nextMatch(pos, pt); + } + else if (pos < pt.src.length()) + { + // Access the next character... + // this is crucial to making + // RegexReader work. + pt.src.charAt(pos); + } + return -1; + } + + public String toString() + { + if (retIsEnd) + { + return "$"; + } + else + { + return "\\Z"; + } + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Pattern clone1(Hashtable h) + { + return new End(retIsEnd); + } +}; diff --git a/unused/com/stevesoft/pat/FastBracket.java b/unused/com/stevesoft/pat/FastBracket.java index a10ec2b..74fae2d 100644 --- a/unused/com/stevesoft/pat/FastBracket.java +++ b/unused/com/stevesoft/pat/FastBracket.java @@ -1,256 +1,256 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * Uses table lookup to match [] type constructs, but only if it can use a - * lookup table 256 bits in size. It is impractical to make a table if it is too - * large. - */ -public class FastBracket extends Bracket -{ - int min, max; - - BitSet bs; - - FastBracket(boolean n) - { - super(n); - } - - // This routine can optimize a bracket, possibly - // it will replace it with a FastBracket. - static Bracket process(Bracket b, boolean ignc) - { - Vector v = b.v; - b.pv = null; - try - { - - // Expand out the vector to make separate - // entries for other cases if ignoreCase is - // turned on. - Vector nv = v; - if (ignc) - { - nv = new Vector(); - for (int i = 0; i < v.size(); i++) - { - Pattern p = (Pattern) v.elementAt(i); - nv.addElement(p); - if (p instanceof oneChar) - { - oneChar oc = (oneChar) p; - nv.addElement(new oneChar(oc.altc)); - } - else if (p instanceof Range) - { - Range ra = (Range) p; - nv.addElement(new Range(ra.altlo, ra.althi)); - } - } - } - v = nv; - - // Bubble sort, make sure elements - // are in order. This will allow us - // to merge them. - for (int i = 0; i < v.size() - 1; i++) - { - for (int j = 0; j < v.size() - 1; j++) - { - char c1 = getl(v.elementAt(j)); - char c2 = getl(v.elementAt(j + 1)); - if (c2 < c1) - { - Object o = v.elementAt(j); - v.setElementAt(v.elementAt(j + 1), j); - v.setElementAt(o, j + 1); - } - } - } - - nv = new Vector(); - // merge -- remove overlaps - Pattern p = (Pattern) v.elementAt(0); - nv.addElement(p); - for (int i = 1; i < v.size(); i++) - { - if (geth(p) + 1 >= getl(v.elementAt(i))) - { - Pattern p2 = (Pattern) v.elementAt(i); - char lo = min(getl(p), getl(p2)); - char hi = max(geth(p), geth(p2)); - nv.setElementAt(p = mkelem(lo, hi), nv.size() - 1); - } - else - { - p = (Pattern) v.elementAt(i); - nv.addElement(p); - } - } - - b.v = v = nv; - } catch (RegSyntax e) - { - e.printStackTrace(); - } - - // We don't want these things to be empty. - Vector negv = neg(v); - if (v.size() == 1) - { - return b; - } - if (negv.size() == 1) - { - b.v = negv; - b.neg = !b.neg; - return b; - } - - // Now consider if we can make a FastBracket. - // Uses a BitSet to do a lookup. - FastBracket fb = newbrack(v, b.neg); - if (fb == null) - { - fb = newbrack(negv, !b.neg); - } - if (fb != null) - { - fb.parent = b.parent; - fb.next = b.next; - return fb; - } - - // return the normal Bracket. - return b; - } - - // Build a FastBracket and set bits. If this can't - // be done, return null. - final static FastBracket newbrack(Vector v, boolean neg) - { - FastBracket fb = new FastBracket(neg); - fb.v = v; - if (v.size() == 0) - { - return null; - } - fb.min = getl(v.elementAt(0)); - fb.max = geth(v.elementAt(v.size() - 1)); - if (fb.max - fb.min <= 256) - { - fb.bs = new BitSet(fb.max - fb.min + 1); - for (int i = 0; i < v.size(); i++) - { - Object o = v.elementAt(i); - int min0 = getl(o) - fb.min; - int max0 = geth(o) - fb.min; - for (int j = min0; j <= max0; j++) - { - fb.bs.set(j); - } - } - return fb; - } - return null; - } - - // Negate a sorted Vector. Applying this - // operation twice should yield the same Vector - // back. - final static Vector neg(Vector v) - { - try - { - Vector nv = new Vector(); - if (v.size() == 0) - { - nv.addElement(new Range((char) 0, (char) 65535)); - return nv; - } - int p0 = getl(v.elementAt(0)); - if (p0 != 0) - { - nv.addElement(mkelem((char) 0, (char) (p0 - 1))); - } - for (int i = 0; i < v.size() - 1; i++) - { - int hi = getl(v.elementAt(i + 1)) - 1; - int lo = geth(v.elementAt(i)) + 1; - nv.addElement(mkelem((char) lo, (char) hi)); - } - int pN = geth(v.lastElement()); - if (pN != 65535) - { - nv.addElement(mkelem((char) (pN + 1), (char) 65535)); - } - return nv; - } catch (RegSyntax rs) - { - return null; - } - } - - // Make either a Range or oneChar Object, depending on which - // is appropriate. - final static Pattern mkelem(char lo, char hi) throws RegSyntax - { - return lo == hi ? (Pattern) (new oneChar(lo)) : (Pattern) (new Range( - lo, hi)); - } - - static final char min(char a, char b) - { - return a < b ? a : b; - } - - static final char max(char a, char b) - { - return a > b ? a : b; - } - - // getl -- get lower value of Range object, - // or get value of oneChar object. - final static char getl(Object o) - { - Pattern p = (Pattern) o; - if (p instanceof Range) - { - return ((Range) p).lo; - } - return ((oneChar) p).c; - } - - // geth -- get higher value of Range object, - // or get value of oneChar object. - final static char geth(Object o) - { - Pattern p = (Pattern) o; - if (p instanceof Range) - { - return ((Range) p).hi; - } - return ((oneChar) p).c; - } - - // This is the easy part! - public int matchInternal(int pos, Pthings pt) - { - if (pos >= pt.src.length() || Masked(pos, pt)) - { - return -1; - } - char c = pt.src.charAt(pos); - return (neg ^ (c >= min && c <= max && bs.get(c - min))) ? nextMatch( - pos + 1, pt) : -1; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Uses table lookup to match [] type constructs, but only if it can use a + * lookup table 256 bits in size. It is impractical to make a table if it is too + * large. + */ +public class FastBracket extends Bracket +{ + int min, max; + + BitSet bs; + + FastBracket(boolean n) + { + super(n); + } + + // This routine can optimize a bracket, possibly + // it will replace it with a FastBracket. + static Bracket process(Bracket b, boolean ignc) + { + Vector v = b.v; + b.pv = null; + try + { + + // Expand out the vector to make separate + // entries for other cases if ignoreCase is + // turned on. + Vector nv = v; + if (ignc) + { + nv = new Vector(); + for (int i = 0; i < v.size(); i++) + { + Pattern p = (Pattern) v.elementAt(i); + nv.addElement(p); + if (p instanceof oneChar) + { + oneChar oc = (oneChar) p; + nv.addElement(new oneChar(oc.altc)); + } + else if (p instanceof Range) + { + Range ra = (Range) p; + nv.addElement(new Range(ra.altlo, ra.althi)); + } + } + } + v = nv; + + // Bubble sort, make sure elements + // are in order. This will allow us + // to merge them. + for (int i = 0; i < v.size() - 1; i++) + { + for (int j = 0; j < v.size() - 1; j++) + { + char c1 = getl(v.elementAt(j)); + char c2 = getl(v.elementAt(j + 1)); + if (c2 < c1) + { + Object o = v.elementAt(j); + v.setElementAt(v.elementAt(j + 1), j); + v.setElementAt(o, j + 1); + } + } + } + + nv = new Vector(); + // merge -- remove overlaps + Pattern p = (Pattern) v.elementAt(0); + nv.addElement(p); + for (int i = 1; i < v.size(); i++) + { + if (geth(p) + 1 >= getl(v.elementAt(i))) + { + Pattern p2 = (Pattern) v.elementAt(i); + char lo = min(getl(p), getl(p2)); + char hi = max(geth(p), geth(p2)); + nv.setElementAt(p = mkelem(lo, hi), nv.size() - 1); + } + else + { + p = (Pattern) v.elementAt(i); + nv.addElement(p); + } + } + + b.v = v = nv; + } catch (RegSyntax e) + { + e.printStackTrace(); + } + + // We don't want these things to be empty. + Vector negv = neg(v); + if (v.size() == 1) + { + return b; + } + if (negv.size() == 1) + { + b.v = negv; + b.neg = !b.neg; + return b; + } + + // Now consider if we can make a FastBracket. + // Uses a BitSet to do a lookup. + FastBracket fb = newbrack(v, b.neg); + if (fb == null) + { + fb = newbrack(negv, !b.neg); + } + if (fb != null) + { + fb.parent = b.parent; + fb.next = b.next; + return fb; + } + + // return the normal Bracket. + return b; + } + + // Build a FastBracket and set bits. If this can't + // be done, return null. + final static FastBracket newbrack(Vector v, boolean neg) + { + FastBracket fb = new FastBracket(neg); + fb.v = v; + if (v.size() == 0) + { + return null; + } + fb.min = getl(v.elementAt(0)); + fb.max = geth(v.elementAt(v.size() - 1)); + if (fb.max - fb.min <= 256) + { + fb.bs = new BitSet(fb.max - fb.min + 1); + for (int i = 0; i < v.size(); i++) + { + Object o = v.elementAt(i); + int min0 = getl(o) - fb.min; + int max0 = geth(o) - fb.min; + for (int j = min0; j <= max0; j++) + { + fb.bs.set(j); + } + } + return fb; + } + return null; + } + + // Negate a sorted Vector. Applying this + // operation twice should yield the same Vector + // back. + final static Vector neg(Vector v) + { + try + { + Vector nv = new Vector(); + if (v.size() == 0) + { + nv.addElement(new Range((char) 0, (char) 65535)); + return nv; + } + int p0 = getl(v.elementAt(0)); + if (p0 != 0) + { + nv.addElement(mkelem((char) 0, (char) (p0 - 1))); + } + for (int i = 0; i < v.size() - 1; i++) + { + int hi = getl(v.elementAt(i + 1)) - 1; + int lo = geth(v.elementAt(i)) + 1; + nv.addElement(mkelem((char) lo, (char) hi)); + } + int pN = geth(v.lastElement()); + if (pN != 65535) + { + nv.addElement(mkelem((char) (pN + 1), (char) 65535)); + } + return nv; + } catch (RegSyntax rs) + { + return null; + } + } + + // Make either a Range or oneChar Object, depending on which + // is appropriate. + final static Pattern mkelem(char lo, char hi) throws RegSyntax + { + return lo == hi ? (Pattern) (new oneChar(lo)) : (Pattern) (new Range( + lo, hi)); + } + + static final char min(char a, char b) + { + return a < b ? a : b; + } + + static final char max(char a, char b) + { + return a > b ? a : b; + } + + // getl -- get lower value of Range object, + // or get value of oneChar object. + final static char getl(Object o) + { + Pattern p = (Pattern) o; + if (p instanceof Range) + { + return ((Range) p).lo; + } + return ((oneChar) p).c; + } + + // geth -- get higher value of Range object, + // or get value of oneChar object. + final static char geth(Object o) + { + Pattern p = (Pattern) o; + if (p instanceof Range) + { + return ((Range) p).hi; + } + return ((oneChar) p).c; + } + + // This is the easy part! + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length() || Masked(pos, pt)) + { + return -1; + } + char c = pt.src.charAt(pos); + return (neg ^ (c >= min && c <= max && bs.get(c - min))) ? nextMatch( + pos + 1, pt) : -1; + } +} diff --git a/unused/com/stevesoft/pat/FastMulti.java b/unused/com/stevesoft/pat/FastMulti.java index a8387b4..6e6d578 100644 --- a/unused/com/stevesoft/pat/FastMulti.java +++ b/unused/com/stevesoft/pat/FastMulti.java @@ -1,169 +1,169 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * A special case of Multi, implemented when minChars().equals(maxChars()), and - * some other conditions spelled out in RegOpt.safe4fm "Safe for FastMulti." It - * avoids stack growth problems as well as being slightly faster. - */ -class FastMulti extends PatternSub -{ - patInt fewestMatches, mostMatches; - - public patInt minChars() - { - return sub.countMinChars().mul(fewestMatches); - } - - public patInt maxChars() - { - return sub.countMaxChars().mul(mostMatches); - } - - public boolean matchFewest = false; - - FastMulti(patInt a, patInt b, Pattern p) throws RegSyntax - { - if (p == null) - { - RegSyntaxError.endItAll("Null length pattern " - + "followed by *, +, or other Multi."); - } - fewestMatches = a; - mostMatches = b; - sub = p; - step = p.countMinChars().intValue(); - sub.setParent(null); - } - - public String toString() - { - return sub.toString() + "{" + fewestMatches + "," + mostMatches + "}" - + (matchFewest ? "?" : "") + "(?# <= fast multi)" - + nextString(); - } - - int step = -1; - - public int matchInternal(int pos, Pthings pt) - { - int m = -1; - int i = pos; - int endstr = pt.src.length() - step; - patInt matches = new patInt(0); - if (matchFewest) - { - if (fewestMatches.lessEq(matches)) - { - int ii = nextMatch(i, pt); - if (ii >= 0) - { - return ii; - } - } - while (i >= 0 && i <= endstr) - { - i = sub.matchInternal(i, pt); - if (i >= 0) - { - matches.inc(); - if (fewestMatches.lessEq(matches)) - { - int ii = nextMatch(i, pt); - if (ii >= 0) - { - return ii; - } - } - if (matches.equals(mostMatches)) - { - return -1; - } - } - } - return -1; - } - int nMatches = 0; - while (fewestMatches.intValue() > nMatches) - { - i = sub.matchInternal(i, pt); - if (i >= 0) - { - nMatches++; - } - else - { - return -1; - } - } - m = i; - if (mostMatches.finite()) - { - while (nMatches < mostMatches.intValue()) - { - i = sub.matchInternal(i, pt); - if (i >= 0) - { - m = i; - nMatches++; - } - else - { - break; - } - } - } - else - { - while (true) - { - i = sub.matchInternal(i, pt); - if (i >= 0) - { - m = i; - nMatches++; - } - else - { - break; - } - } - } - while (m >= pos) - { - int r = nextMatch(m, pt); - if (r >= 0) - { - return r; - } - m -= step; - nMatches--; - if (nMatches < fewestMatches.intValue()) - { - return -1; - } - } - return -1; - } - - public Pattern clone1(Hashtable h) - { - try - { - FastMulti fm = new FastMulti(fewestMatches, mostMatches, sub.clone(h)); - fm.matchFewest = matchFewest; - return fm; - } catch (RegSyntax rs) - { - return null; - } - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * A special case of Multi, implemented when minChars().equals(maxChars()), and + * some other conditions spelled out in RegOpt.safe4fm "Safe for FastMulti." It + * avoids stack growth problems as well as being slightly faster. + */ +class FastMulti extends PatternSub +{ + patInt fewestMatches, mostMatches; + + public patInt minChars() + { + return sub.countMinChars().mul(fewestMatches); + } + + public patInt maxChars() + { + return sub.countMaxChars().mul(mostMatches); + } + + public boolean matchFewest = false; + + FastMulti(patInt a, patInt b, Pattern p) throws RegSyntax + { + if (p == null) + { + RegSyntaxError.endItAll("Null length pattern " + + "followed by *, +, or other Multi."); + } + fewestMatches = a; + mostMatches = b; + sub = p; + step = p.countMinChars().intValue(); + sub.setParent(null); + } + + public String toString() + { + return sub.toString() + "{" + fewestMatches + "," + mostMatches + "}" + + (matchFewest ? "?" : "") + "(?# <= fast multi)" + + nextString(); + } + + int step = -1; + + public int matchInternal(int pos, Pthings pt) + { + int m = -1; + int i = pos; + int endstr = pt.src.length() - step; + patInt matches = new patInt(0); + if (matchFewest) + { + if (fewestMatches.lessEq(matches)) + { + int ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + } + while (i >= 0 && i <= endstr) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + matches.inc(); + if (fewestMatches.lessEq(matches)) + { + int ii = nextMatch(i, pt); + if (ii >= 0) + { + return ii; + } + } + if (matches.equals(mostMatches)) + { + return -1; + } + } + } + return -1; + } + int nMatches = 0; + while (fewestMatches.intValue() > nMatches) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + nMatches++; + } + else + { + return -1; + } + } + m = i; + if (mostMatches.finite()) + { + while (nMatches < mostMatches.intValue()) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; + } + else + { + break; + } + } + } + else + { + while (true) + { + i = sub.matchInternal(i, pt); + if (i >= 0) + { + m = i; + nMatches++; + } + else + { + break; + } + } + } + while (m >= pos) + { + int r = nextMatch(m, pt); + if (r >= 0) + { + return r; + } + m -= step; + nMatches--; + if (nMatches < fewestMatches.intValue()) + { + return -1; + } + } + return -1; + } + + public Pattern clone1(Hashtable h) + { + try + { + FastMulti fm = new FastMulti(fewestMatches, mostMatches, sub.clone(h)); + fm.matchFewest = matchFewest; + return fm; + } catch (RegSyntax rs) + { + return null; + } + } +} diff --git a/unused/com/stevesoft/pat/Group.java b/unused/com/stevesoft/pat/Group.java index e6f734c..b467dbc 100644 --- a/unused/com/stevesoft/pat/Group.java +++ b/unused/com/stevesoft/pat/Group.java @@ -1,77 +1,77 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * This class implements the (?@<>) syntax that matches a balanced parenthesis. - * Not in perl 5. - */ -class Group extends Pattern -{ - char op, cl; - - Group(char opi, char cli) - { - op = opi; - cl = cli; - } - - public int matchInternal(int pos, Pthings pt) - { - int i, count = 1; - if (pos < pt.src.length()) - { - if (!Masked(pos, pt) && pt.src.charAt(pos) != op) - { - return -1; - } - } - for (i = pos + 1; i < pt.src.length(); i++) - { - char c = pt.src.charAt(i); - boolean b = !Masked(i, pt); - if (b && c == ESC) - { - i++; - } - else - { - if (b && c == cl) - { - count--; - } - if (count == 0) - { - return nextMatch(i + 1, pt); - } - if (b && c == op) - { - count++; - } - } - } - return -1; - } - - public String toString() - { - return "(?@" + op + cl + ")" + nextString(); - } - - public patInt minChars() - { - return new patInt(2); - } - - Pattern clone1(Hashtable h) - { - return new Group(op, cl); - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * This class implements the (?@<>) syntax that matches a balanced parenthesis. + * Not in perl 5. + */ +class Group extends Pattern +{ + char op, cl; + + Group(char opi, char cli) + { + op = opi; + cl = cli; + } + + public int matchInternal(int pos, Pthings pt) + { + int i, count = 1; + if (pos < pt.src.length()) + { + if (!Masked(pos, pt) && pt.src.charAt(pos) != op) + { + return -1; + } + } + for (i = pos + 1; i < pt.src.length(); i++) + { + char c = pt.src.charAt(i); + boolean b = !Masked(i, pt); + if (b && c == ESC) + { + i++; + } + else + { + if (b && c == cl) + { + count--; + } + if (count == 0) + { + return nextMatch(i + 1, pt); + } + if (b && c == op) + { + count++; + } + } + } + return -1; + } + + public String toString() + { + return "(?@" + op + cl + ")" + nextString(); + } + + public patInt minChars() + { + return new patInt(2); + } + + Pattern clone1(Hashtable h) + { + return new Group(op, cl); + } +}; diff --git a/unused/com/stevesoft/pat/LeftRule.java b/unused/com/stevesoft/pat/LeftRule.java index 1a427f9..856c7e0 100644 --- a/unused/com/stevesoft/pat/LeftRule.java +++ b/unused/com/stevesoft/pat/LeftRule.java @@ -1,31 +1,31 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * The apply(StringBufferLike sb,RegRes res) method of this derivation of - * ReplaceRule appends the contents of res.left() to the javajs.util.SB sb. - * - * @see com.stevesoft.pat.ReplaceRule - */ -public class LeftRule extends ReplaceRule -{ - public LeftRule() - { - } - - public void apply(StringBufferLike sb, RegRes res) - { - sb.appendStr(res.left()); - } - - public String toString1() - { - return "$`"; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * The apply(StringBufferLike sb,RegRes res) method of this derivation of + * ReplaceRule appends the contents of res.left() to the javajs.util.SB sb. + * + * @see com.stevesoft.pat.ReplaceRule + */ +public class LeftRule extends ReplaceRule +{ + public LeftRule() + { + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.appendStr(res.left()); + } + + public String toString1() + { + return "$`"; + } +} diff --git a/unused/com/stevesoft/pat/Multi.java b/unused/com/stevesoft/pat/Multi.java index 1fe197d..e1489b9 100644 --- a/unused/com/stevesoft/pat/Multi.java +++ b/unused/com/stevesoft/pat/Multi.java @@ -1,90 +1,90 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * Matches any number of instances of sub Pattern this was the hardest method to - * write. It implements '+', '*', '?', "{0,10}", "{5,}", "{5}", etc. - * - * @see pat.Multi_stage2 - * @see pat.MultiMin - */ -class Multi extends PatternSub -{ - patInt a, b; - - public patInt minChars() - { - return a.mul(p.countMinChars()); - } - - public patInt maxChars() - { - return b.mul(p.countMaxChars()); - } - - Pattern p; - - Multi_stage2 st2; - - public boolean matchFewest = false; - - /** - * @param a - * The fewest number of times the sub pattern can match. - * @param b - * The maximum number of times the sub pattern can match. - * @param p - * The sub pattern. - * @see Multi_stage2 - * @see MultiMin - */ - public Multi(patInt a, patInt b, Pattern p) throws RegSyntax - { - this.a = a; - this.b = b; - this.p = p; - st2 = new Multi_stage2(a, b, p); - st2.parent = this; - sub = st2.sub; - } - - public String toString() - { - st2.matchFewest = matchFewest; - return st2.toString(); - } - - public int matchInternal(int pos, Pthings pt) - { - try - { - st2 = new Multi_stage2(a, b, p); - } catch (RegSyntax r__) - { - } - st2.matchFewest = matchFewest; - st2.parent = this; - return st2.matchInternal(pos, pt); - } - - public Pattern clone1(Hashtable h) - { - try - { - Multi m = new Multi(a, b, ((Pattern) p).clone(h)); - m.matchFewest = matchFewest; - return m; - } catch (RegSyntax rs) - { - return null; - } - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Matches any number of instances of sub Pattern this was the hardest method to + * write. It implements '+', '*', '?', "{0,10}", "{5,}", "{5}", etc. + * + * @see pat.Multi_stage2 + * @see pat.MultiMin + */ +class Multi extends PatternSub +{ + patInt a, b; + + public patInt minChars() + { + return a.mul(p.countMinChars()); + } + + public patInt maxChars() + { + return b.mul(p.countMaxChars()); + } + + Pattern p; + + Multi_stage2 st2; + + public boolean matchFewest = false; + + /** + * @param a + * The fewest number of times the sub pattern can match. + * @param b + * The maximum number of times the sub pattern can match. + * @param p + * The sub pattern. + * @see Multi_stage2 + * @see MultiMin + */ + public Multi(patInt a, patInt b, Pattern p) throws RegSyntax + { + this.a = a; + this.b = b; + this.p = p; + st2 = new Multi_stage2(a, b, p); + st2.parent = this; + sub = st2.sub; + } + + public String toString() + { + st2.matchFewest = matchFewest; + return st2.toString(); + } + + public int matchInternal(int pos, Pthings pt) + { + try + { + st2 = new Multi_stage2(a, b, p); + } catch (RegSyntax r__) + { + } + st2.matchFewest = matchFewest; + st2.parent = this; + return st2.matchInternal(pos, pt); + } + + public Pattern clone1(Hashtable h) + { + try + { + Multi m = new Multi(a, b, ((Pattern) p).clone(h)); + m.matchFewest = matchFewest; + return m; + } catch (RegSyntax rs) + { + return null; + } + } +}; diff --git a/unused/com/stevesoft/pat/MultiMin.java b/unused/com/stevesoft/pat/MultiMin.java index 6054e06..fad2558 100644 --- a/unused/com/stevesoft/pat/MultiMin.java +++ b/unused/com/stevesoft/pat/MultiMin.java @@ -1,21 +1,21 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This extension of multi is the version of multi which wants to match the - * fewest number of characters. It implements the *? type of syntax. - */ -class MultiMin extends Multi -{ - MultiMin(patInt i1, patInt i2, Pattern p) throws RegSyntax - { - super(i1, i2, p); - matchFewest = true; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This extension of multi is the version of multi which wants to match the + * fewest number of characters. It implements the *? type of syntax. + */ +class MultiMin extends Multi +{ + MultiMin(patInt i1, patInt i2, Pattern p) throws RegSyntax + { + super(i1, i2, p); + matchFewest = true; + } +}; diff --git a/unused/com/stevesoft/pat/Multi_stage2.java b/unused/com/stevesoft/pat/Multi_stage2.java index b18ad1c..1ca9cbe 100644 --- a/unused/com/stevesoft/pat/Multi_stage2.java +++ b/unused/com/stevesoft/pat/Multi_stage2.java @@ -1,157 +1,157 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * If Multi were not split into a second stage, then a nested Multi would try to - * re-use the same count variable and the whole thing would break. - */ -class Multi_stage2 extends PatternSub -{ - Pattern nextRet; - - patInt count; - - patInt matchMin, matchMax; - - public boolean matchFewest = false; - - public String toString() - { - String ret = ""; - ret += sub.toString(); - ret += "{" + matchMin + "," + matchMax + "}"; - if (matchFewest) - { - ret += "?"; - } - ret += parent.nextString(); - return ret; - } - - Multi_stage2(patInt a, patInt b, Pattern p) throws RegSyntax - { - if (p == null) - { - RegSyntaxError.endItAll("Multiple match of Null pattern requested."); - } - sub = p; - nextRet = this; - sub.setParent(this); - matchMin = a; - matchMax = b; - count = new patInt(0); - // we must have b > a > -1 for this - // to make sense. - if (!a.lessEq(b)) - { - // throw new BadMultiArgs(); - RegSyntaxError.endItAll("Bad Multi Args: " + a + ">" + b); - } - patInt i = new patInt(-1); - if (a.lessEq(i)) - { - // throw new BadMultiArgs(); - RegSyntaxError.endItAll("Bad Multi Args: " + a + "< 0"); - } - } - - public Pattern getNext() - { - return nextRet; - } - - int pos_old = -1; - - public int matchInternal(int pos, Pthings pt) - { - sub.setParent(this); - - int canUse = -1; - - // check for some forms of infinite recursion... - if (pos_old >= 0 && pos == pos_old) - { - return -1; - } - pos_old = pos; - - if (matchMin.lessEq(count)) - { - canUse = pos; - } - if (!count.lessEq(matchMax) || pos > pt.src.length()) - { - return -1; - } - - if ((matchFewest || count.equals(matchMax)) && canUse >= 0) - { - Pattern n = super.getNext(); - if (n == null) - { - return canUse; - } - int ret = testMatch(n, pos, pt); - if (ret >= 0) - { - return ret; - } - else - { - canUse = -1; - } - } - - count.inc(); - try - { - if (count.lessEq(matchMax)) - { - int r = testMatch(sub, pos, pt); - if (r >= 0) - { - return r; - } - } - } finally - { - count.dec(); - } - - if (!matchFewest && canUse >= 0) - { - Pattern n = super.getNext(); - if (n == null) - { - return canUse; - } - int ret = testMatch(n, pos, pt); - return ret; - } - else - { - return canUse; - } - } - - public Pattern clone1(Hashtable h) - { - try - { - Multi_stage2 m = new Multi_stage2(matchMin, matchMax, sub.clone(h)); - m.matchFewest = matchFewest; - return m; - } catch (RegSyntax rs) - { - return null; - } - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * If Multi were not split into a second stage, then a nested Multi would try to + * re-use the same count variable and the whole thing would break. + */ +class Multi_stage2 extends PatternSub +{ + Pattern nextRet; + + patInt count; + + patInt matchMin, matchMax; + + public boolean matchFewest = false; + + public String toString() + { + String ret = ""; + ret += sub.toString(); + ret += "{" + matchMin + "," + matchMax + "}"; + if (matchFewest) + { + ret += "?"; + } + ret += parent.nextString(); + return ret; + } + + Multi_stage2(patInt a, patInt b, Pattern p) throws RegSyntax + { + if (p == null) + { + RegSyntaxError.endItAll("Multiple match of Null pattern requested."); + } + sub = p; + nextRet = this; + sub.setParent(this); + matchMin = a; + matchMax = b; + count = new patInt(0); + // we must have b > a > -1 for this + // to make sense. + if (!a.lessEq(b)) + { + // throw new BadMultiArgs(); + RegSyntaxError.endItAll("Bad Multi Args: " + a + ">" + b); + } + patInt i = new patInt(-1); + if (a.lessEq(i)) + { + // throw new BadMultiArgs(); + RegSyntaxError.endItAll("Bad Multi Args: " + a + "< 0"); + } + } + + public Pattern getNext() + { + return nextRet; + } + + int pos_old = -1; + + public int matchInternal(int pos, Pthings pt) + { + sub.setParent(this); + + int canUse = -1; + + // check for some forms of infinite recursion... + if (pos_old >= 0 && pos == pos_old) + { + return -1; + } + pos_old = pos; + + if (matchMin.lessEq(count)) + { + canUse = pos; + } + if (!count.lessEq(matchMax) || pos > pt.src.length()) + { + return -1; + } + + if ((matchFewest || count.equals(matchMax)) && canUse >= 0) + { + Pattern n = super.getNext(); + if (n == null) + { + return canUse; + } + int ret = testMatch(n, pos, pt); + if (ret >= 0) + { + return ret; + } + else + { + canUse = -1; + } + } + + count.inc(); + try + { + if (count.lessEq(matchMax)) + { + int r = testMatch(sub, pos, pt); + if (r >= 0) + { + return r; + } + } + } finally + { + count.dec(); + } + + if (!matchFewest && canUse >= 0) + { + Pattern n = super.getNext(); + if (n == null) + { + return canUse; + } + int ret = testMatch(n, pos, pt); + return ret; + } + else + { + return canUse; + } + } + + public Pattern clone1(Hashtable h) + { + try + { + Multi_stage2 m = new Multi_stage2(matchMin, matchMax, sub.clone(h)); + m.matchFewest = matchFewest; + return m; + } catch (RegSyntax rs) + { + return null; + } + } +}; diff --git a/unused/com/stevesoft/pat/NoPattern.java b/unused/com/stevesoft/pat/NoPattern.java index 444d094..fb2a9aa 100644 --- a/unused/com/stevesoft/pat/NoPattern.java +++ b/unused/com/stevesoft/pat/NoPattern.java @@ -1,33 +1,33 @@ -package // -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -com.stevesoft.pat; - -import java.util.*; - -/** - * The idea behind this class is simply to eliminate the need for testing to see - * if Regex.thePattern is null. Every instruction we can eliminate from _search - * will help. - */ -public class NoPattern extends Pattern -{ - public String toString() - { - return "(?e=#)[^#d#D]"; - } - - public int matchInternal(int i, Pthings p) - { - return -1; - } - - Pattern clone1(Hashtable h) - { - return new NoPattern(); - } -} +package // +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +com.stevesoft.pat; + +import java.util.*; + +/** + * The idea behind this class is simply to eliminate the need for testing to see + * if Regex.thePattern is null. Every instruction we can eliminate from _search + * will help. + */ +public class NoPattern extends Pattern +{ + public String toString() + { + return "(?e=#)[^#d#D]"; + } + + public int matchInternal(int i, Pthings p) + { + return -1; + } + + Pattern clone1(Hashtable h) + { + return new NoPattern(); + } +} diff --git a/unused/com/stevesoft/pat/NotImplementedError.java b/unused/com/stevesoft/pat/NotImplementedError.java index 11ce9eb..030e3ac 100644 --- a/unused/com/stevesoft/pat/NotImplementedError.java +++ b/unused/com/stevesoft/pat/NotImplementedError.java @@ -1,16 +1,16 @@ -package // -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -com.stevesoft.pat; - -public class NotImplementedError extends Error -{ - public NotImplementedError(String s) - { - super(s); - } -} +package // +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +com.stevesoft.pat; + +public class NotImplementedError extends Error +{ + public NotImplementedError(String s) + { + super(s); + } +} diff --git a/unused/com/stevesoft/pat/NullPattern.java b/unused/com/stevesoft/pat/NullPattern.java index 09460de..f9bf68b 100644 --- a/unused/com/stevesoft/pat/NullPattern.java +++ b/unused/com/stevesoft/pat/NullPattern.java @@ -1,37 +1,37 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * This pattern matches nothing -- it is found in patterns like (hello|world|) - * where a zero-length subelement occurs. - */ -class NullPattern extends Pattern -{ - public String toString() - { - return nextString(); - } - - public int matchInternal(int p, Pthings pt) - { - return nextMatch(p, pt); - } - - public patInt maxChars() - { - return new patInt(0); - } - - Pattern clone1(Hashtable h) - { - return new NullPattern(); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * This pattern matches nothing -- it is found in patterns like (hello|world|) + * where a zero-length subelement occurs. + */ +class NullPattern extends Pattern +{ + public String toString() + { + return nextString(); + } + + public int matchInternal(int p, Pthings pt) + { + return nextMatch(p, pt); + } + + public patInt maxChars() + { + return new patInt(0); + } + + Pattern clone1(Hashtable h) + { + return new NullPattern(); + } +} diff --git a/unused/com/stevesoft/pat/NullRule.java b/unused/com/stevesoft/pat/NullRule.java index e0442ea..0d82ecc 100644 --- a/unused/com/stevesoft/pat/NullRule.java +++ b/unused/com/stevesoft/pat/NullRule.java @@ -1,30 +1,30 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * The apply(StringBufferLike sb,RegRes res) method of this derivation of - * ReplaceRule appends nothing to the contents of the javajs.util.SB sb. - * - * @see com.stevesoft.pat.ReplaceRule - */ -public class NullRule extends ReplaceRule -{ - public NullRule() - { - } - - public void apply(StringBufferLike sb, RegRes res) - { - } - - public String toString1() - { - return ""; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * The apply(StringBufferLike sb,RegRes res) method of this derivation of + * ReplaceRule appends nothing to the contents of the javajs.util.SB sb. + * + * @see com.stevesoft.pat.ReplaceRule + */ +public class NullRule extends ReplaceRule +{ + public NullRule() + { + } + + public void apply(StringBufferLike sb, RegRes res) + { + } + + public String toString1() + { + return ""; + } +} diff --git a/unused/com/stevesoft/pat/Or.java b/unused/com/stevesoft/pat/Or.java index 9b619f6..e251b46 100644 --- a/unused/com/stevesoft/pat/Or.java +++ b/unused/com/stevesoft/pat/Or.java @@ -1,130 +1,130 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * This class implements the (?: ... ) extended Pattern. It provides a base - * class from which we derive the [ ... ], ( ... ), (?! ... ), and (?= ... ) - * patterns. - */ -class Or extends Pattern -{ - Vector v; - - Pattern[] pv = null; - - Or() - { - v = new Vector(); - } - - String leftForm() - { - return "(?:"; - } - - String rightForm() - { - return ")"; - } - - String sepForm() - { - return "|"; - } - - public Or addOr(Pattern p) - { - pv = null; - v.addElement(p); - p.setParent(this); - return this; - } - - public String toString() - { - int i; - javajs.util.SB sb = new javajs.util.SB(); - sb.append(leftForm()); - if (v.size() > 0) - { - sb.append(((Pattern) v.elementAt(0)).toString()); - } - for (i = 1; i < v.size(); i++) - { - sb.append(sepForm()); - sb.append(((Pattern) v.elementAt(i)).toString()); - } - sb.append(rightForm()); - sb.append(nextString()); - return sb.toString(); - } - - public int matchInternal(int pos, Pthings pt) - { - if (pv == null) - { - pv = new Pattern[v.size()]; - v.copyInto(pv); - } - for (int i = 0; i < v.size(); i++) - { - Pattern p = pv[i]; // (Pattern)v.elementAt(i); - int r = p.matchInternal(pos, pt); - if (r >= 0) - { - return r; - } - } - return -1; - } - - public patInt minChars() - { - if (v.size() == 0) - { - return new patInt(0); - } - patInt m = ((Pattern) v.elementAt(0)).countMinChars(); - for (int i = 1; i < v.size(); i++) - { - Pattern p = (Pattern) v.elementAt(i); - m.mineq(p.countMinChars()); - } - return m; - } - - public patInt maxChars() - { - if (v.size() == 0) - { - return new patInt(0); - } - patInt m = ((Pattern) v.elementAt(0)).countMaxChars(); - for (int i = 1; i < v.size(); i++) - { - Pattern p = (Pattern) v.elementAt(i); - m.maxeq(p.countMaxChars()); - } - return m; - } - - Pattern clone1(Hashtable h) - { - Or o = new Or(); - h.put(this, o); - h.put(o, o); - for (int i = 0; i < v.size(); i++) - { - o.v.addElement(((Pattern) v.elementAt(i)).clone(h)); - } - return o; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * This class implements the (?: ... ) extended Pattern. It provides a base + * class from which we derive the [ ... ], ( ... ), (?! ... ), and (?= ... ) + * patterns. + */ +class Or extends Pattern +{ + Vector v; + + Pattern[] pv = null; + + Or() + { + v = new Vector(); + } + + String leftForm() + { + return "(?:"; + } + + String rightForm() + { + return ")"; + } + + String sepForm() + { + return "|"; + } + + public Or addOr(Pattern p) + { + pv = null; + v.addElement(p); + p.setParent(this); + return this; + } + + public String toString() + { + int i; + javajs.util.SB sb = new javajs.util.SB(); + sb.append(leftForm()); + if (v.size() > 0) + { + sb.append(((Pattern) v.elementAt(0)).toString()); + } + for (i = 1; i < v.size(); i++) + { + sb.append(sepForm()); + sb.append(((Pattern) v.elementAt(i)).toString()); + } + sb.append(rightForm()); + sb.append(nextString()); + return sb.toString(); + } + + public int matchInternal(int pos, Pthings pt) + { + if (pv == null) + { + pv = new Pattern[v.size()]; + v.copyInto(pv); + } + for (int i = 0; i < v.size(); i++) + { + Pattern p = pv[i]; // (Pattern)v.elementAt(i); + int r = p.matchInternal(pos, pt); + if (r >= 0) + { + return r; + } + } + return -1; + } + + public patInt minChars() + { + if (v.size() == 0) + { + return new patInt(0); + } + patInt m = ((Pattern) v.elementAt(0)).countMinChars(); + for (int i = 1; i < v.size(); i++) + { + Pattern p = (Pattern) v.elementAt(i); + m.mineq(p.countMinChars()); + } + return m; + } + + public patInt maxChars() + { + if (v.size() == 0) + { + return new patInt(0); + } + patInt m = ((Pattern) v.elementAt(0)).countMaxChars(); + for (int i = 1; i < v.size(); i++) + { + Pattern p = (Pattern) v.elementAt(i); + m.maxeq(p.countMaxChars()); + } + return m; + } + + Pattern clone1(Hashtable h) + { + Or o = new Or(); + h.put(this, o); + h.put(o, o); + for (int i = 0; i < v.size(); i++) + { + o.v.addElement(((Pattern) v.elementAt(i)).clone(h)); + } + return o; + } +}; diff --git a/unused/com/stevesoft/pat/OrMark.java b/unused/com/stevesoft/pat/OrMark.java index 89b8869..f73aad5 100644 --- a/unused/com/stevesoft/pat/OrMark.java +++ b/unused/com/stevesoft/pat/OrMark.java @@ -1,73 +1,73 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** Implements the parenthesis pattern subelement. */ -class OrMark extends Or -{ - SubMark sm = new SubMark(); - - int id; - - OrMark(int i) - { - sm.om = this; - id = i; - } - - String leftForm() - { - return "("; - } - - public Pattern getNext() - { - return sm; - } - - public int matchInternal(int pos, Pthings pt) - { - sm.next = super.getNext(); - if (pt.marks == null) - { - int n2 = 2 * pt.nMarks + 2; - pt.marks = new int[n2]; - for (int i = 0; i < n2; i++) - { - pt.marks[i] = -1; - } - } - pt.marks[id] = pos; - int ret = super.matchInternal(pos, pt); - if (ret < 0) - { - pt.marks[id] = -1; - } - else if (pt.marks[id] > pt.marks[id + pt.nMarks]) - { - int swap = pt.marks[id]; - pt.marks[id] = pt.marks[id + pt.nMarks] + 1; - pt.marks[id + pt.nMarks] = swap + 1; - } - return ret; - } - - public Pattern clone1(Hashtable h) - { - OrMark om = new OrMark(id); - h.put(om, om); - h.put(this, om); - for (int i = 0; i < v.size(); i++) - { - om.v.addElement(((Pattern) v.elementAt(i)).clone(h)); - } - return om; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** Implements the parenthesis pattern subelement. */ +class OrMark extends Or +{ + SubMark sm = new SubMark(); + + int id; + + OrMark(int i) + { + sm.om = this; + id = i; + } + + String leftForm() + { + return "("; + } + + public Pattern getNext() + { + return sm; + } + + public int matchInternal(int pos, Pthings pt) + { + sm.next = super.getNext(); + if (pt.marks == null) + { + int n2 = 2 * pt.nMarks + 2; + pt.marks = new int[n2]; + for (int i = 0; i < n2; i++) + { + pt.marks[i] = -1; + } + } + pt.marks[id] = pos; + int ret = super.matchInternal(pos, pt); + if (ret < 0) + { + pt.marks[id] = -1; + } + else if (pt.marks[id] > pt.marks[id + pt.nMarks]) + { + int swap = pt.marks[id]; + pt.marks[id] = pt.marks[id + pt.nMarks] + 1; + pt.marks[id + pt.nMarks] = swap + 1; + } + return ret; + } + + public Pattern clone1(Hashtable h) + { + OrMark om = new OrMark(id); + h.put(om, om); + h.put(this, om); + for (int i = 0; i < v.size(); i++) + { + om.v.addElement(((Pattern) v.elementAt(i)).clone(h)); + } + return om; + } +}; diff --git a/unused/com/stevesoft/pat/PartialBuffer.java b/unused/com/stevesoft/pat/PartialBuffer.java index e64a122..a465b0b 100644 --- a/unused/com/stevesoft/pat/PartialBuffer.java +++ b/unused/com/stevesoft/pat/PartialBuffer.java @@ -1,109 +1,109 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class allows you to match on a partial string. If the allowOverRun flag - * is true, then the length() method returns a number 1 larger than is actually - * contained by the class. - *

    - * If one attempts to access the last character as follows: - * - *

    - *  javajs.util.SB sb = ...;
    - *  ...
    - *  PartialBuffer pb = new PartialBuffer(sb);
    - *  char c = pb.charAt(pb.length()-1);
    - * 
    - * - * then two things happen. First, a zero is returned into the variable c. - * Second, the overRun flag is set to "true." Accessing data beyond the end of - * the buffer is considered an "overRun" of the data. - *

    - * This can be helpful in determining whether more characters are required for a - * match to occur, as the pseudo-code below illustrates. - * - *

    - *  int i = ...;
    - *  Regex r = new Regex("some pattern");
    - *  pb.allowOverRun = true;
    - *  pb.overRun = true;
    - *  boolean result = r.matchAt(pb,i);
    - *  if(pb.overRun) {
    - *  // The result of the match is not relevant, regardless
    - *  // of whether result is true or false.  We need to
    - *  // append more data to the buffer and try again.
    - *  ....
    - *  sb.append(more data);
    - *  }
    - * 
    - */ -class PartialBuffer implements StringLike -{ - int off; - - public boolean allowOverRun = true; - - public boolean overRun = false; - - javajs.util.SB sb; - - PartialBuffer(javajs.util.SB sb) - { - this.sb = sb; - } - - public char charAt(int n) - { - n += off; - if (n == sb.length()) - { - overRun = true; - return 0; - } - return sb.charAt(n); - } - - public int length() - { - return allowOverRun ? sb.length() + 1 : sb.length(); - } - - public int indexOf(char c) - { - for (int i = 0; i < sb.length(); i++) - { - if (sb.charAt(i) == c) - { - return i; - } - } - return -1; - } - - public Object unwrap() - { - return sb; - } - - public String substring(int i1, int i2) - { - javajs.util.SB sb = new javajs.util.SB();//(i2 - i1); - for (int i = i1; i < i2; i++) - { - sb.appendC(charAt(i)); - } - return sb.toString(); - } - - /** Just returns null. */ - public BasicStringBufferLike newStringBufferLike() - { - return null; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class allows you to match on a partial string. If the allowOverRun flag + * is true, then the length() method returns a number 1 larger than is actually + * contained by the class. + *

    + * If one attempts to access the last character as follows: + * + *

    + *  javajs.util.SB sb = ...;
    + *  ...
    + *  PartialBuffer pb = new PartialBuffer(sb);
    + *  char c = pb.charAt(pb.length()-1);
    + * 
    + * + * then two things happen. First, a zero is returned into the variable c. + * Second, the overRun flag is set to "true." Accessing data beyond the end of + * the buffer is considered an "overRun" of the data. + *

    + * This can be helpful in determining whether more characters are required for a + * match to occur, as the pseudo-code below illustrates. + * + *

    + *  int i = ...;
    + *  Regex r = new Regex("some pattern");
    + *  pb.allowOverRun = true;
    + *  pb.overRun = true;
    + *  boolean result = r.matchAt(pb,i);
    + *  if(pb.overRun) {
    + *  // The result of the match is not relevant, regardless
    + *  // of whether result is true or false.  We need to
    + *  // append more data to the buffer and try again.
    + *  ....
    + *  sb.append(more data);
    + *  }
    + * 
    + */ +class PartialBuffer implements StringLike +{ + int off; + + public boolean allowOverRun = true; + + public boolean overRun = false; + + javajs.util.SB sb; + + PartialBuffer(javajs.util.SB sb) + { + this.sb = sb; + } + + public char charAt(int n) + { + n += off; + if (n == sb.length()) + { + overRun = true; + return 0; + } + return sb.charAt(n); + } + + public int length() + { + return allowOverRun ? sb.length() + 1 : sb.length(); + } + + public int indexOf(char c) + { + for (int i = 0; i < sb.length(); i++) + { + if (sb.charAt(i) == c) + { + return i; + } + } + return -1; + } + + public Object unwrap() + { + return sb; + } + + public String substring(int i1, int i2) + { + javajs.util.SB sb = new javajs.util.SB();//(i2 - i1); + for (int i = i1; i < i2; i++) + { + sb.appendC(charAt(i)); + } + return sb.toString(); + } + + /** Just returns null. */ + public BasicStringBufferLike newStringBufferLike() + { + return null; + } +} diff --git a/unused/com/stevesoft/pat/Pattern.java b/unused/com/stevesoft/pat/Pattern.java index 142ea73..10d914c 100644 --- a/unused/com/stevesoft/pat/Pattern.java +++ b/unused/com/stevesoft/pat/Pattern.java @@ -1,296 +1,296 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import jalview.util.MessageManager; - -import java.util.*; - -/** - Shareware: package pat - Copyright 2001, Steven R. Brandt - */ -/** - * Class Pattern is the base class on which all the other pattern elements are - * built. - */ - -public abstract class Pattern -{ - /** - * The ESC character, the user can provide his own value for the escape - * character through regex.esc - */ - public final static char ESC = '\\'; - - final static String PROTECT_THESE = "[]{}(),$,-\"^."; - - /** - * The interal match function, it must be provided by any class which wishes - * to extend Pattern. - */ - public abstract int matchInternal(int i, Pthings p); - - public abstract String toString(); - - // Class Pattern is a singly linked list - // chained together by member next. The member - // parent is used so that sub patterns can access - // the chain they are branching from. - Pattern next = null, parent = null; - - /** - * This gets the next element of a Pattern that we wish to match. If we are at - * the end of a subchain of patterns, it will return us to the parent chain. - */ - public Pattern getNext() - { - return next != null ? next : (parent == null ? null : parent.getNext()); - } - - /** - * Call this method if you have a pattern element that takes a sub pattern - * (such as Or), and after you have added a sub pattern to the current pattern - * element. - */ - public void setParent(Pattern p) - { - if (next != null) - { - next.setParent(p); - } - else - { - parent = p; - } - } - - /** - * This determines if the remainder of a Pattern matches. Type "return - * nextMatch" from within matchInternal if the current Pattern matches. - * Otherwise, return a -1. - */ - public int nextMatch(int i, Pthings pt) - { - Pattern p = getNext(); - /* - * if(p == null) return i; return p.matchInternal(i,pt); - */ - return p == null ? i : p.matchInternal(i, pt); - } - - /** - * This is a toString() for the remainder of the Pattern elements after this - * one. use this when overriding toString(). Called from within toString(). - */ - public String nextString() - { - if (next == null) - { - return ""; - } - return next.toString(); - } - - /** a method to detect whether char c is in String s */ - final static boolean inString(char c, String s) - { - int i; - for (i = 0; i < s.length(); i++) - { - if (s.charAt(i) == c) - { - return true; - } - } - return false; - } - - /** - * A method to create a string that protects the characters listed in - * PROTECT_THESE by prepending the esc character. The esc character itself is - * automatically protected. - */ - final static String protect(String s, String PROTECT_THESE, char esc) - { - int i; - javajs.util.SB sb = new javajs.util.SB(); - String p = PROTECT_THESE + esc; - for (i = 0; i < s.length(); i++) - { - char c = s.charAt(i); - if (inString(c, p)) - { - sb.appendC(esc); - } - sb.appendC(c); - } - return sb.toString(); - } - - /** - * This can be used to perform a match test from within class Pattern. - */ - public int match(StringLike s, Pthings pt) - { - return matchAt(s, 0, pt); - } - - /** - * This can be used to perform a match test from within class Pattern. - */ - public int matchAt(StringLike s, int i, Pthings pt) - { - pt.src = s; - int r = matchInternal(i, pt); - if (r < 0) - { - return -1; - } - mfrom = r < i ? r + 1 : i; - return r < i ? i - r - 1 : r - i; - } - - int mfrom = 0; - - // Detect masked characters - final boolean Masked(int i, Pthings pt) - { - return pt.cbits == null ? false : pt.cbits.get(i); - } - - /** add a Pattern to the singly-linked Pattern chain. */ - public Pattern add(Pattern p) - { - if (next == null) - { - if (p == null) - { - return this; - } - next = p; - p.parent = parent; - parent = null; - } - else - { - next.add(p); - } - return this; - } - - /** - * The minimum number of characters which this pattern element can match. - */ - public patInt minChars() - { - return new patInt(0); - } - - /** - * The maximum number of characters which this pattern element can match. - */ - public patInt maxChars() - { - return new patInf(); - } - - /** return minimum number of characters in pattern */ - public final patInt countMinChars() - { - Pattern p = this; - patInt sum = new patInt(0); - while (p != null) - { - sum.pluseq(p.minChars()); - p = p.next; - } - return sum; - } - - /** return maximum number of characters in pattern */ - public final patInt countMaxChars() - { - Pattern p = this; - patInt sum = new patInt(0); - while (p != null) - { - sum.pluseq(p.maxChars()); - p = p.next; - } - return sum; - } - - // This method is only needed by Multi_stage2 so far... - // the reason is that it may try something else after a - // match succeeds. OrMark will only record the last thing - // tried in marks, so we need to backup the result of the - // last successful match and restore it if the next one - // does not succeed. - final int testMatch(Pattern p, int pos, Pthings pt) - { - int[] tab = null; - if (pt.marks != null) - { - try - { - tab = new int[pt.marks.length]; - for (int i = 0; i < tab.length; i++) - { - tab[i] = pt.marks[i]; - } - } catch (Throwable t) - { - } - } - int ret = p.matchInternal(pos, pt); - if (ret < 0) - { - pt.marks = tab; - } - return ret; - } - - /** - * Clones this pattern elements without cloning others in the linked list. - */ - Pattern clone1(Hashtable h) - { - throw new Error(MessageManager.formatMessage("error.no_such_method_as_clone1_for", new String[]{getClass().getName()})); - } - - Pattern clone(Hashtable h) - { - Pattern p = (Pattern) h.get(this); - if (p != null) - { - return p; - } - p = clone1(h); - if (p == null) - { - throw new Error(MessageManager.getString("error.null_from_clone1")); - } - h.put(this, p); - h.put(p, p); - if (next != null) - { - p.next = next.clone(h); - } - if (parent != null) - { - p.parent = parent.clone(h); - } - return p; - } - - public boolean equals(Object o) - { - return o == this; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import jalview.util.MessageManager; + +import java.util.*; + +/** + Shareware: package pat + Copyright 2001, Steven R. Brandt + */ +/** + * Class Pattern is the base class on which all the other pattern elements are + * built. + */ + +public abstract class Pattern +{ + /** + * The ESC character, the user can provide his own value for the escape + * character through regex.esc + */ + public final static char ESC = '\\'; + + final static String PROTECT_THESE = "[]{}(),$,-\"^."; + + /** + * The interal match function, it must be provided by any class which wishes + * to extend Pattern. + */ + public abstract int matchInternal(int i, Pthings p); + + public abstract String toString(); + + // Class Pattern is a singly linked list + // chained together by member next. The member + // parent is used so that sub patterns can access + // the chain they are branching from. + Pattern next = null, parent = null; + + /** + * This gets the next element of a Pattern that we wish to match. If we are at + * the end of a subchain of patterns, it will return us to the parent chain. + */ + public Pattern getNext() + { + return next != null ? next : (parent == null ? null : parent.getNext()); + } + + /** + * Call this method if you have a pattern element that takes a sub pattern + * (such as Or), and after you have added a sub pattern to the current pattern + * element. + */ + public void setParent(Pattern p) + { + if (next != null) + { + next.setParent(p); + } + else + { + parent = p; + } + } + + /** + * This determines if the remainder of a Pattern matches. Type "return + * nextMatch" from within matchInternal if the current Pattern matches. + * Otherwise, return a -1. + */ + public int nextMatch(int i, Pthings pt) + { + Pattern p = getNext(); + /* + * if(p == null) return i; return p.matchInternal(i,pt); + */ + return p == null ? i : p.matchInternal(i, pt); + } + + /** + * This is a toString() for the remainder of the Pattern elements after this + * one. use this when overriding toString(). Called from within toString(). + */ + public String nextString() + { + if (next == null) + { + return ""; + } + return next.toString(); + } + + /** a method to detect whether char c is in String s */ + final static boolean inString(char c, String s) + { + int i; + for (i = 0; i < s.length(); i++) + { + if (s.charAt(i) == c) + { + return true; + } + } + return false; + } + + /** + * A method to create a string that protects the characters listed in + * PROTECT_THESE by prepending the esc character. The esc character itself is + * automatically protected. + */ + final static String protect(String s, String PROTECT_THESE, char esc) + { + int i; + javajs.util.SB sb = new javajs.util.SB(); + String p = PROTECT_THESE + esc; + for (i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + if (inString(c, p)) + { + sb.appendC(esc); + } + sb.appendC(c); + } + return sb.toString(); + } + + /** + * This can be used to perform a match test from within class Pattern. + */ + public int match(StringLike s, Pthings pt) + { + return matchAt(s, 0, pt); + } + + /** + * This can be used to perform a match test from within class Pattern. + */ + public int matchAt(StringLike s, int i, Pthings pt) + { + pt.src = s; + int r = matchInternal(i, pt); + if (r < 0) + { + return -1; + } + mfrom = r < i ? r + 1 : i; + return r < i ? i - r - 1 : r - i; + } + + int mfrom = 0; + + // Detect masked characters + final boolean Masked(int i, Pthings pt) + { + return pt.cbits == null ? false : pt.cbits.get(i); + } + + /** add a Pattern to the singly-linked Pattern chain. */ + public Pattern add(Pattern p) + { + if (next == null) + { + if (p == null) + { + return this; + } + next = p; + p.parent = parent; + parent = null; + } + else + { + next.add(p); + } + return this; + } + + /** + * The minimum number of characters which this pattern element can match. + */ + public patInt minChars() + { + return new patInt(0); + } + + /** + * The maximum number of characters which this pattern element can match. + */ + public patInt maxChars() + { + return new patInf(); + } + + /** return minimum number of characters in pattern */ + public final patInt countMinChars() + { + Pattern p = this; + patInt sum = new patInt(0); + while (p != null) + { + sum.pluseq(p.minChars()); + p = p.next; + } + return sum; + } + + /** return maximum number of characters in pattern */ + public final patInt countMaxChars() + { + Pattern p = this; + patInt sum = new patInt(0); + while (p != null) + { + sum.pluseq(p.maxChars()); + p = p.next; + } + return sum; + } + + // This method is only needed by Multi_stage2 so far... + // the reason is that it may try something else after a + // match succeeds. OrMark will only record the last thing + // tried in marks, so we need to backup the result of the + // last successful match and restore it if the next one + // does not succeed. + final int testMatch(Pattern p, int pos, Pthings pt) + { + int[] tab = null; + if (pt.marks != null) + { + try + { + tab = new int[pt.marks.length]; + for (int i = 0; i < tab.length; i++) + { + tab[i] = pt.marks[i]; + } + } catch (Throwable t) + { + } + } + int ret = p.matchInternal(pos, pt); + if (ret < 0) + { + pt.marks = tab; + } + return ret; + } + + /** + * Clones this pattern elements without cloning others in the linked list. + */ + Pattern clone1(Hashtable h) + { + throw new Error(MessageManager.formatMessage("error.no_such_method_as_clone1_for", new String[]{getClass().getName()})); + } + + Pattern clone(Hashtable h) + { + Pattern p = (Pattern) h.get(this); + if (p != null) + { + return p; + } + p = clone1(h); + if (p == null) + { + throw new Error(MessageManager.getString("error.null_from_clone1")); + } + h.put(this, p); + h.put(p, p); + if (next != null) + { + p.next = next.clone(h); + } + if (parent != null) + { + p.parent = parent.clone(h); + } + return p; + } + + public boolean equals(Object o) + { + return o == this; + } +}; diff --git a/unused/com/stevesoft/pat/PatternSub.java b/unused/com/stevesoft/pat/PatternSub.java index d790f4b..315a4dd 100644 --- a/unused/com/stevesoft/pat/PatternSub.java +++ b/unused/com/stevesoft/pat/PatternSub.java @@ -1,16 +1,16 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This is simply a subclass of pattern that contains a sub pattern. - */ -abstract class PatternSub extends Pattern -{ - Pattern sub; -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This is simply a subclass of pattern that contains a sub pattern. + */ +abstract class PatternSub extends Pattern +{ + Pattern sub; +} diff --git a/unused/com/stevesoft/pat/PopRule.java b/unused/com/stevesoft/pat/PopRule.java index 4a17ab8..8ce0610 100644 --- a/unused/com/stevesoft/pat/PopRule.java +++ b/unused/com/stevesoft/pat/PopRule.java @@ -1,24 +1,24 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * Implements substitution rule $POP. See the example file trans3.html. - */ -public class PopRule extends SpecialRule -{ - public PopRule() - { - } - - public String toString1() - { - return "${POP}"; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * Implements substitution rule $POP. See the example file trans3.html. + */ +public class PopRule extends SpecialRule +{ + public PopRule() + { + } + + public String toString1() + { + return "${POP}"; + } +} diff --git a/unused/com/stevesoft/pat/Prop.java b/unused/com/stevesoft/pat/Prop.java index 127e44a..a78c7f6 100644 --- a/unused/com/stevesoft/pat/Prop.java +++ b/unused/com/stevesoft/pat/Prop.java @@ -1,75 +1,75 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * Get Unicode properties for a character. See http://unicode.org. - */ -public class Prop -{ - /** Is this a "Decimal Digit" according to Unicode? */ - public final static boolean isDecimalDigit(char c) - { - if (Bits.decimal_digit == null) - { - Bits.decimal_digit_f(); - } - return Bits.decimal_digit.get(c); - } - - /** Is this a "Alphabetic" according to Unicode? */ - public final static boolean isAlphabetic(char c) - { - if (Bits.letter == null) - { - Bits.letter_f(); - } - return Bits.letter.get(c); - } - - /** Is this a "Math" according to Unicode? */ - public final static boolean isMath(char c) - { - if (Bits.math == null) - { - Bits.math_f(); - } - return Bits.math.get(c); - } - - /** Is this a "Currency" according to Unicode? */ - public final static boolean isCurrency(char c) - { - if (Bits.currency == null) - { - Bits.currency_f(); - } - return Bits.currency.get(c); - } - - /** Is c a white space character according to Unicode? */ - public final static boolean isWhite(char c) - { - if (Bits.white == null) - { - Bits.white_f(); - } - return Bits.white.get(c); - } - - /** Is c a punctuation character according to Unicode? */ - public final static boolean isPunct(char c) - { - if (Bits.punct == null) - { - Bits.punct_f(); - } - return Bits.punct.get(c); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * Get Unicode properties for a character. See http://unicode.org. + */ +public class Prop +{ + /** Is this a "Decimal Digit" according to Unicode? */ + public final static boolean isDecimalDigit(char c) + { + if (Bits.decimal_digit == null) + { + Bits.decimal_digit_f(); + } + return Bits.decimal_digit.get(c); + } + + /** Is this a "Alphabetic" according to Unicode? */ + public final static boolean isAlphabetic(char c) + { + if (Bits.letter == null) + { + Bits.letter_f(); + } + return Bits.letter.get(c); + } + + /** Is this a "Math" according to Unicode? */ + public final static boolean isMath(char c) + { + if (Bits.math == null) + { + Bits.math_f(); + } + return Bits.math.get(c); + } + + /** Is this a "Currency" according to Unicode? */ + public final static boolean isCurrency(char c) + { + if (Bits.currency == null) + { + Bits.currency_f(); + } + return Bits.currency.get(c); + } + + /** Is c a white space character according to Unicode? */ + public final static boolean isWhite(char c) + { + if (Bits.white == null) + { + Bits.white_f(); + } + return Bits.white.get(c); + } + + /** Is c a punctuation character according to Unicode? */ + public final static boolean isPunct(char c) + { + if (Bits.punct == null) + { + Bits.punct_f(); + } + return Bits.punct.get(c); + } +} diff --git a/unused/com/stevesoft/pat/Pthings.java b/unused/com/stevesoft/pat/Pthings.java index 69e8fed..d427983 100644 --- a/unused/com/stevesoft/pat/Pthings.java +++ b/unused/com/stevesoft/pat/Pthings.java @@ -1,47 +1,47 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * Things that need to be kept track of during a match. Passed along with - * Pattern.matchInternal. - */ -public class Pthings -{ - /** The current text we are attempting to match. */ - public StringLike src; - - /** - * Whether we should ignore the case of letters in this match. - */ - public boolean ignoreCase; - - public boolean mFlag; - - /** The mask to use when dontMatchInQuotes is set. */ - public BitSet cbits; - - /** Used to keep track of backreferences. */ - // public Hashtable marks; - public int[] marks; - - public int nMarks; - - /** - * Used to set the behavior of "." By default, it now fails to match the '\n' - * character. - */ - public boolean dotDoesntMatchCR; - - /** Determine if Skipped strings need to be checked. */ - public boolean no_check; - - int lastPos; -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Things that need to be kept track of during a match. Passed along with + * Pattern.matchInternal. + */ +public class Pthings +{ + /** The current text we are attempting to match. */ + public StringLike src; + + /** + * Whether we should ignore the case of letters in this match. + */ + public boolean ignoreCase; + + public boolean mFlag; + + /** The mask to use when dontMatchInQuotes is set. */ + public BitSet cbits; + + /** Used to keep track of backreferences. */ + // public Hashtable marks; + public int[] marks; + + public int nMarks; + + /** + * Used to set the behavior of "." By default, it now fails to match the '\n' + * character. + */ + public boolean dotDoesntMatchCR; + + /** Determine if Skipped strings need to be checked. */ + public boolean no_check; + + int lastPos; +} diff --git a/unused/com/stevesoft/pat/PushRule.java b/unused/com/stevesoft/pat/PushRule.java index c9aee2b..5d4dc35 100644 --- a/unused/com/stevesoft/pat/PushRule.java +++ b/unused/com/stevesoft/pat/PushRule.java @@ -1,50 +1,50 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * See the example file trans3.java for - * further examples of how this is used. You will probably not want to call it - * directly. - */ -public class PushRule extends SpecialRule -{ - Regex NewRule; - - public PushRule(PushRule p) - { - NewRule = p.NewRule; - } - - public PushRule(String nm, Regex rr) - { - name = nm; - NewRule = rr; - } - - public PushRule(String nm, Transformer tr) - { - name = nm; - NewRule = tr.rp; - } - - public Object clone1() - { - return new PushRule(this); - } - - public String String1() - { - return "${+" + name + "}"; - } - - public void apply(StringBufferLike sbl, RegRes rr) - { - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * See the example file trans3.java for + * further examples of how this is used. You will probably not want to call it + * directly. + */ +public class PushRule extends SpecialRule +{ + Regex NewRule; + + public PushRule(PushRule p) + { + NewRule = p.NewRule; + } + + public PushRule(String nm, Regex rr) + { + name = nm; + NewRule = rr; + } + + public PushRule(String nm, Transformer tr) + { + name = nm; + NewRule = tr.rp; + } + + public Object clone1() + { + return new PushRule(this); + } + + public String String1() + { + return "${+" + name + "}"; + } + + public void apply(StringBufferLike sbl, RegRes rr) + { + } +} diff --git a/unused/com/stevesoft/pat/RBuffer.java b/unused/com/stevesoft/pat/RBuffer.java index 094fb80..2e496c6 100644 --- a/unused/com/stevesoft/pat/RBuffer.java +++ b/unused/com/stevesoft/pat/RBuffer.java @@ -1,52 +1,52 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class is used internally by RegexReader to store blocks of data. - */ -class RBuffer -{ - boolean done = false; - - javajs.util.SB sb; - - int pos, epos; - - RBuffer next; - - RBuffer() - { - } - - RBuffer(javajs.util.SB sb) - { - this.sb = sb; - } - - public String toString() - { - return "sb=" + sb.toString().replace('\n', ' ') + " pos=" + pos - + " epos=" + epos + " sb.length()=" + sb.length() + "\n" - + sp(pos + 3) + "^" + sp(epos - pos - 1) + "^"; - } - - String sp(int n) - { - if (n <= 0) - { - return ""; - } - javajs.util.SB sb = new javajs.util.SB(); // n - for (int i = 0; i < n; i++) - { - sb.appendC(' '); - } - return sb.toString(); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class is used internally by RegexReader to store blocks of data. + */ +class RBuffer +{ + boolean done = false; + + javajs.util.SB sb; + + int pos, epos; + + RBuffer next; + + RBuffer() + { + } + + RBuffer(javajs.util.SB sb) + { + this.sb = sb; + } + + public String toString() + { + return "sb=" + sb.toString().replace('\n', ' ') + " pos=" + pos + + " epos=" + epos + " sb.length()=" + sb.length() + "\n" + + sp(pos + 3) + "^" + sp(epos - pos - 1) + "^"; + } + + String sp(int n) + { + if (n <= 0) + { + return ""; + } + javajs.util.SB sb = new javajs.util.SB(); // n + for (int i = 0; i < n; i++) + { + sb.appendC(' '); + } + return sb.toString(); + } +} diff --git a/unused/com/stevesoft/pat/Range.java b/unused/com/stevesoft/pat/Range.java index 610a4d5..e3ed0c9 100644 --- a/unused/com/stevesoft/pat/Range.java +++ b/unused/com/stevesoft/pat/Range.java @@ -1,97 +1,97 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** Thrown when one encounters things like [z-a] */ -class BadRangeArgs extends RegSyntax -{ -}; - -/** - * Implments a subelement (ranges) of the [] pattern element. For example, - * [a-z023] is implemented using a range and tree oneChar classes. - * - * @see Bracket - * @see oneChar - */ -class Range extends Pattern -{ - char lo, hi, altlo, althi; - - boolean printBrackets = false; - - public String toString() - { - String s = protect("" + lo, PROTECT_THESE, ESC) + "-" - + protect("" + hi, PROTECT_THESE, ESC); - if (!printBrackets) - { - return s; - } - return "[" + s + "]"; - } - - Range(char loi, char hii) throws RegSyntax - { - lo = loi; - hi = hii; - oneChar o = null; - if (lo >= hi) - { - // throw new BadRangeArgs(); - RegSyntaxError.endItAll("Badly formed []'s : " + lo + " >= " + hi); - } - o = new oneChar(lo); - altlo = o.altc; - o = new oneChar(hi); - althi = o.altc; - } - - public int matchInternal(int pos, Pthings pt) - { - if (pos >= pt.src.length()) - { - return -1; - } - if (Masked(pos, pt)) - { - return -1; - } - char c = pt.src.charAt(pos); - if (lo <= c && c <= hi || (pt.ignoreCase && (altlo <= c && c <= althi))) - { - return nextMatch(pos + 1, pt); - } - return -1; - } - - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } - - public Pattern clone1(Hashtable h) - { - try - { - Range r = new Range(lo, hi); - r.printBrackets = printBrackets; - return r; - } catch (RegSyntax rs) - { - return null; - } - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** Thrown when one encounters things like [z-a] */ +class BadRangeArgs extends RegSyntax +{ +}; + +/** + * Implments a subelement (ranges) of the [] pattern element. For example, + * [a-z023] is implemented using a range and tree oneChar classes. + * + * @see Bracket + * @see oneChar + */ +class Range extends Pattern +{ + char lo, hi, altlo, althi; + + boolean printBrackets = false; + + public String toString() + { + String s = protect("" + lo, PROTECT_THESE, ESC) + "-" + + protect("" + hi, PROTECT_THESE, ESC); + if (!printBrackets) + { + return s; + } + return "[" + s + "]"; + } + + Range(char loi, char hii) throws RegSyntax + { + lo = loi; + hi = hii; + oneChar o = null; + if (lo >= hi) + { + // throw new BadRangeArgs(); + RegSyntaxError.endItAll("Badly formed []'s : " + lo + " >= " + hi); + } + o = new oneChar(lo); + altlo = o.altc; + o = new oneChar(hi); + althi = o.altc; + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; + } + if (Masked(pos, pt)) + { + return -1; + } + char c = pt.src.charAt(pos); + if (lo <= c && c <= hi || (pt.ignoreCase && (altlo <= c && c <= althi))) + { + return nextMatch(pos + 1, pt); + } + return -1; + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Pattern clone1(Hashtable h) + { + try + { + Range r = new Range(lo, hi); + r.printBrackets = printBrackets; + return r; + } catch (RegSyntax rs) + { + return null; + } + } +}; diff --git a/unused/com/stevesoft/pat/RegOpt.java b/unused/com/stevesoft/pat/RegOpt.java index 97f05ba..c7ed628 100644 --- a/unused/com/stevesoft/pat/RegOpt.java +++ b/unused/com/stevesoft/pat/RegOpt.java @@ -1,448 +1,448 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** This class is just like oneChar, but doesn't worry about case. */ -class FastChar extends oneChar -{ - FastChar(char c) - { - super(c); - } - - public int matchInternal(int p, Pthings pt) - { - return (p < pt.src.length() && pt.src.charAt(p) == c) ? nextMatch( - p + 1, pt) : -1; - } - - Pattern clone1(Hashtable h) - { - return new FastChar(c); - } -} - -/** - * This class is a hashtable keyed by Character Objects. It is used to match - * things of the form (?:a..|b..|c..|..) match with greater efficiency -- by - * using a Hashtable that indexes into the group of patterns. - */ -class Branch extends Pattern -{ - Hashtable h = new Hashtable(); - - // We need to keep track of the order - // of the keys -- if we don't then - // recompiling the output of toString - // may produce errors by re-ordering - // ()'s and changing the id number of - // the backreference associated with - // a subpattern. - Vector keys = new Vector(); - - Branch() - { - } - - Pattern clone1(Hashtable x) - { - Branch b = new Branch(); - b.keys = (Vector) keys.clone(); - x.put(this, b); - x.put(b, b); - - for (int i = 0; i < keys.size(); i++) - { - Pattern p = (Pattern) h.get(keys.elementAt(i)); - b.h.put(keys.elementAt(i), p.clone(x)); - } - return b; - } - - // this function eliminates Branches with 0 or 1 elements. - final Pattern reduce(boolean ignoreCase, boolean dontMinQ) - { - if (h.size() == 1) - { - Enumeration e = h.keys(); - Character c = (Character) e.nextElement(); - Pattern oc; - if (ignoreCase || dontMinQ) - { - oc = new oneChar(c.charValue()); - } - else - { - oc = new FastChar(c.charValue()); - } - oc.next = (Pattern) h.get(c); - oc.add(next); - return oc; - } - else if (h.size() == 0) - { - return null; - } - return this; - } - - public patInt maxChars() - { - Enumeration e = h.keys(); - patInt count = new patInt(0); - while (e.hasMoreElements()) - { - Object key = e.nextElement(); - Pattern pa = (Pattern) h.get(key); - patInt pi = pa.maxChars(); - pi.inc(); - count.maxeq(pi); - } - return count; - } - - public patInt minChars() - { - Enumeration e = h.keys(); - patInt count = new patInt(0); - while (e.hasMoreElements()) - { - Object key = e.nextElement(); - Pattern pa = (Pattern) h.get(key); - patInt pi = pa.minChars(); - pi.inc(); - count.mineq(pi); - } - return count; - } - - // adds a oneChar object to this Branch - void addc(oneChar o, boolean ignoreCase, boolean dontMinQ) - { - Pattern n = o.next; - if (n == null) - { - n = new NullPattern(); - } - else - { - n = RegOpt.opt(n, ignoreCase, dontMinQ); - } - n.setParent(this); - set(new Character(o.c), n, ignoreCase, dontMinQ); - if (ignoreCase) - { - if (o.c != o.altc) - { - set(new Character(o.altc), n, ignoreCase, dontMinQ); - } - if (o.c != o.altc2 && o.altc != o.altc2) - { - set(new Character(o.altc2), n, ignoreCase, dontMinQ); - } - } - } - - void set(Character c, Pattern n, boolean igc, boolean dontMinQ) - { - Pattern p = (Pattern) h.get(c); - next = null; - // This letter is not yet used in the Branch object. - // We need to add it. - if (p == null) - { - if (n instanceof Or) - { - // A NullPattern is prepended to an Or - // to prevent confusing this object. - // For example: (boo|bug) => (b(?:oo|ug)) - // during this process. However, we - // want (b(?:oo|ell)|bug) - NullPattern np = new NullPattern(); - np.add(n); - h.put(c, np); - } - else - { - h.put(c, n); - } - // Make sure we remember the order things were - // added into the Branch object so that we can - // properly convert it to a String. - keys.addElement(c); - } - else if (p instanceof Or) - { - ((Or) p).addOr(n); - } - else if (p instanceof oneChar && n instanceof oneChar - && ((oneChar) p).c != ((oneChar) n).c) - { - Branch b = new Branch(); - b.addc((oneChar) p, igc, dontMinQ); - b.addc((oneChar) n, igc, dontMinQ); - h.put(c, b); - b.setParent(this); - } - else if (p instanceof Branch && n instanceof oneChar) - { - ((Branch) p).addc((oneChar) n, igc, dontMinQ); - n.setParent(p); - } - else - { - // Create an Or object to receive the variety - // of branches in the pattern if the current letter - // is matched. We do not attempt to make these - // sub-branches into a Branch object yet. - Or o = new Or(); - o.setParent(this); - - // Remove NullPattern from p -- it's no longer needed. - if (p instanceof NullPattern && p.parent == null && p.next != null) - { - o.addOr(p.next); - } - else - { - o.addOr(p); - } - o.addOr(n); - - Pattern optpat = RegOpt.opt(o, igc, dontMinQ); - h.put(c, optpat); - optpat.setParent(this); - } - } - - public String toString() - { - javajs.util.SB sb = new javajs.util.SB(); - // should protect this... - sb.append("(?:(?#branch)"); // Hashtable)"); - for (int i = 0; i < keys.size(); i++) - { - Character c = (Character) keys.elementAt(i); - sb.appendC(c); - sb.append((String) h.get(c)); - if (i + 1 < keys.size()) - { - sb.append("|"); - } - } - sb.append(")"); - sb.append(nextString()); - return sb.toString(); - } - - public int matchInternal(int pos, Pthings pt) - { - if (pos >= pt.src.length()) - { - return -1; - } - Pattern n = (Pattern) h.get(new Character(pt.src.charAt(pos))); - if (n == null) - { - return -1; - } - if (pt.cbits != null && pt.cbits.get(pos)) - { - return -1; - } - return n.matchInternal(pos + 1, pt); - } -} - -/** - * This is just a place to put the optimizing function. It is never instantiated - * as an Object. It just sorts through the RegOpt looking for things it can - * change and make faster. - */ -public class RegOpt -{ - static Pattern opt(Pattern p, boolean ignoreCase, boolean dontMinQ) - { - if (p == null) - { - return p; - } - if (p instanceof Bracket) - { - Bracket b = (Bracket) p; - // FastBracket is the only special - // optimized class to have its own - // source file. - p = FastBracket.process(b, ignoreCase); - // if(!(p instanceof FastBracket) - // p = Switch.process(b,ignoreCase); - p.next = b.next; - p.parent = b.parent; - } - else if (p instanceof oneChar && !ignoreCase && !dontMinQ) - { - oneChar o = (oneChar) p; - p = new FastChar(o.c); - p.next = o.next; - p.parent = o.parent; - } - else if (p instanceof Or && ((Or) p).leftForm().equals("(?:") - && ((Or) p).v.size() == 1) - { // Eliminate this Or Object. - Or o = (Or) p; - p = (Pattern) o.v.elementAt(0); - p.setParent(null); - p = RegOpt.opt(p, ignoreCase, dontMinQ); - p.add(o.next); - } - else if (p instanceof Or) - { - Or o = (Or) p; - o.pv = null; - Vector v = o.v; - o.v = new Vector(); - Branch b = new Branch(); - b.parent = o.parent; - for (int i = 0; i < v.size(); i++) - { - Pattern pp = (Pattern) v.elementAt(i); - // We want to have at least two oneChar's in - // the Or Object to consider making a Branch. - if (pp instanceof oneChar - && (b.h.size() >= 1 || (i + 1 < v.size() && v - .elementAt(i + 1) instanceof oneChar))) - { - b.addc((oneChar) pp, ignoreCase, dontMinQ); - } - else - { - if (b.keys.size() > 0) - { - Pattern p2 = (Pattern) b.reduce(ignoreCase, dontMinQ); - if (p2 != null) - { - o.addOr(p2); - b = new Branch(); - b.parent = o.parent; - } - } - o.addOr(opt(pp, ignoreCase, dontMinQ)); - } - } - if (b.keys.size() > 0) - { - Pattern p2 = (Pattern) b.reduce(ignoreCase, dontMinQ); - if (p2 != null) - { - o.addOr(p2); - } - } - if (o.v.size() == 1 && o.leftForm().equals("(?:")) - { // Eliminate Or Object - p = (Pattern) o.v.elementAt(0); - p.setParent(null); - p = RegOpt.opt(p, ignoreCase, dontMinQ); - p.add(o.next); - } - } - else if (p instanceof FastMulti) - { - PatternSub ps = (PatternSub) p; - ps.sub = RegOpt.opt(ps.sub, ignoreCase, dontMinQ); - } - else if (p instanceof Multi && safe4fm(((PatternSub) p).sub)) - { - Multi m = (Multi) p; - FastMulti fm = null; - try - { - fm = new FastMulti(m.a, m.b, opt(m.sub, ignoreCase, dontMinQ)); - } catch (RegSyntax rs) - { - } - fm.parent = m.parent; - fm.matchFewest = m.matchFewest; - fm.next = m.next; - p = fm; - } - if (p.next != null) - { - p.next = opt(p.next, ignoreCase, dontMinQ); - } - return p; - } - - final static boolean safe4fm(Pattern x) - { - while (x != null) - { - if (x instanceof Bracket) - { - ; - } - else if (x instanceof Range) - { - ; - } - else if (x instanceof oneChar) - { - ; - } - else if (x instanceof Any) - { - ; - } - else if (x instanceof Custom - && ((Custom) x).v instanceof UniValidator) - { - ; - } - else if (x instanceof Or) - { - Or o = (Or) x; - if (!o.leftForm().equals("(?:")) - { - return false; - } - patInt lo = o.countMinChars(); - patInt hi = o.countMaxChars(); - if (!lo.equals(hi)) - { - return false; - } - for (int i = 0; i < o.v.size(); i++) - { - if (!safe4fm((Pattern) o.v.elementAt(i))) - { - return false; - } - } - } - else - { - return false; - } - x = x.next; - } - return true; - } - /* - * public static void setParents(Regex r) { setParents(r.thePattern,null); } - * static void setParents(Pattern p,Pattern x) { if(p instanceof PatternSub && - * !(p instanceof FastMulti) && !(p instanceof DotMulti)) RegOpt.setParents( - * ((PatternSub)p).sub, p); else if(p instanceof Or && !(p instanceof - * Bracket)) { Or o = (Or)p; for(int i=0;i (b(?:oo|ug)) + // during this process. However, we + // want (b(?:oo|ell)|bug) + NullPattern np = new NullPattern(); + np.add(n); + h.put(c, np); + } + else + { + h.put(c, n); + } + // Make sure we remember the order things were + // added into the Branch object so that we can + // properly convert it to a String. + keys.addElement(c); + } + else if (p instanceof Or) + { + ((Or) p).addOr(n); + } + else if (p instanceof oneChar && n instanceof oneChar + && ((oneChar) p).c != ((oneChar) n).c) + { + Branch b = new Branch(); + b.addc((oneChar) p, igc, dontMinQ); + b.addc((oneChar) n, igc, dontMinQ); + h.put(c, b); + b.setParent(this); + } + else if (p instanceof Branch && n instanceof oneChar) + { + ((Branch) p).addc((oneChar) n, igc, dontMinQ); + n.setParent(p); + } + else + { + // Create an Or object to receive the variety + // of branches in the pattern if the current letter + // is matched. We do not attempt to make these + // sub-branches into a Branch object yet. + Or o = new Or(); + o.setParent(this); + + // Remove NullPattern from p -- it's no longer needed. + if (p instanceof NullPattern && p.parent == null && p.next != null) + { + o.addOr(p.next); + } + else + { + o.addOr(p); + } + o.addOr(n); + + Pattern optpat = RegOpt.opt(o, igc, dontMinQ); + h.put(c, optpat); + optpat.setParent(this); + } + } + + public String toString() + { + javajs.util.SB sb = new javajs.util.SB(); + // should protect this... + sb.append("(?:(?#branch)"); // Hashtable)"); + for (int i = 0; i < keys.size(); i++) + { + Character c = (Character) keys.elementAt(i); + sb.appendC(c); + sb.append((String) h.get(c)); + if (i + 1 < keys.size()) + { + sb.append("|"); + } + } + sb.append(")"); + sb.append(nextString()); + return sb.toString(); + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; + } + Pattern n = (Pattern) h.get(new Character(pt.src.charAt(pos))); + if (n == null) + { + return -1; + } + if (pt.cbits != null && pt.cbits.get(pos)) + { + return -1; + } + return n.matchInternal(pos + 1, pt); + } +} + +/** + * This is just a place to put the optimizing function. It is never instantiated + * as an Object. It just sorts through the RegOpt looking for things it can + * change and make faster. + */ +public class RegOpt +{ + static Pattern opt(Pattern p, boolean ignoreCase, boolean dontMinQ) + { + if (p == null) + { + return p; + } + if (p instanceof Bracket) + { + Bracket b = (Bracket) p; + // FastBracket is the only special + // optimized class to have its own + // source file. + p = FastBracket.process(b, ignoreCase); + // if(!(p instanceof FastBracket) + // p = Switch.process(b,ignoreCase); + p.next = b.next; + p.parent = b.parent; + } + else if (p instanceof oneChar && !ignoreCase && !dontMinQ) + { + oneChar o = (oneChar) p; + p = new FastChar(o.c); + p.next = o.next; + p.parent = o.parent; + } + else if (p instanceof Or && ((Or) p).leftForm().equals("(?:") + && ((Or) p).v.size() == 1) + { // Eliminate this Or Object. + Or o = (Or) p; + p = (Pattern) o.v.elementAt(0); + p.setParent(null); + p = RegOpt.opt(p, ignoreCase, dontMinQ); + p.add(o.next); + } + else if (p instanceof Or) + { + Or o = (Or) p; + o.pv = null; + Vector v = o.v; + o.v = new Vector(); + Branch b = new Branch(); + b.parent = o.parent; + for (int i = 0; i < v.size(); i++) + { + Pattern pp = (Pattern) v.elementAt(i); + // We want to have at least two oneChar's in + // the Or Object to consider making a Branch. + if (pp instanceof oneChar + && (b.h.size() >= 1 || (i + 1 < v.size() && v + .elementAt(i + 1) instanceof oneChar))) + { + b.addc((oneChar) pp, ignoreCase, dontMinQ); + } + else + { + if (b.keys.size() > 0) + { + Pattern p2 = (Pattern) b.reduce(ignoreCase, dontMinQ); + if (p2 != null) + { + o.addOr(p2); + b = new Branch(); + b.parent = o.parent; + } + } + o.addOr(opt(pp, ignoreCase, dontMinQ)); + } + } + if (b.keys.size() > 0) + { + Pattern p2 = (Pattern) b.reduce(ignoreCase, dontMinQ); + if (p2 != null) + { + o.addOr(p2); + } + } + if (o.v.size() == 1 && o.leftForm().equals("(?:")) + { // Eliminate Or Object + p = (Pattern) o.v.elementAt(0); + p.setParent(null); + p = RegOpt.opt(p, ignoreCase, dontMinQ); + p.add(o.next); + } + } + else if (p instanceof FastMulti) + { + PatternSub ps = (PatternSub) p; + ps.sub = RegOpt.opt(ps.sub, ignoreCase, dontMinQ); + } + else if (p instanceof Multi && safe4fm(((PatternSub) p).sub)) + { + Multi m = (Multi) p; + FastMulti fm = null; + try + { + fm = new FastMulti(m.a, m.b, opt(m.sub, ignoreCase, dontMinQ)); + } catch (RegSyntax rs) + { + } + fm.parent = m.parent; + fm.matchFewest = m.matchFewest; + fm.next = m.next; + p = fm; + } + if (p.next != null) + { + p.next = opt(p.next, ignoreCase, dontMinQ); + } + return p; + } + + final static boolean safe4fm(Pattern x) + { + while (x != null) + { + if (x instanceof Bracket) + { + ; + } + else if (x instanceof Range) + { + ; + } + else if (x instanceof oneChar) + { + ; + } + else if (x instanceof Any) + { + ; + } + else if (x instanceof Custom + && ((Custom) x).v instanceof UniValidator) + { + ; + } + else if (x instanceof Or) + { + Or o = (Or) x; + if (!o.leftForm().equals("(?:")) + { + return false; + } + patInt lo = o.countMinChars(); + patInt hi = o.countMaxChars(); + if (!lo.equals(hi)) + { + return false; + } + for (int i = 0; i < o.v.size(); i++) + { + if (!safe4fm((Pattern) o.v.elementAt(i))) + { + return false; + } + } + } + else + { + return false; + } + x = x.next; + } + return true; + } + /* + * public static void setParents(Regex r) { setParents(r.thePattern,null); } + * static void setParents(Pattern p,Pattern x) { if(p instanceof PatternSub && + * !(p instanceof FastMulti) && !(p instanceof DotMulti)) RegOpt.setParents( + * ((PatternSub)p).sub, p); else if(p instanceof Or && !(p instanceof + * Bracket)) { Or o = (Or)p; for(int i=0;iCopyright 2001, Steven R. Brandt - */ -/** - * This class is used to store a result from Regex - */ -public class RegRes implements Cloneable -{ - protected int[] marks = null; - - protected boolean didMatch_ = false; - - protected StringLike src = null; - - /** Obtain the text String that was matched against. */ - public String getString() - { - return src.toString(); - } - - /** Obtain the source StringLike object. */ - public StringLike getStringLike() - { - return src; - } - - protected int charsMatched_ = 0, matchFrom_ = 0, numSubs_ = 0; - - public String toString() - { - javajs.util.SB sb = new javajs.util.SB(); - sb.append("match=" + matchedFrom() + ":" + charsMatched()); - if (!didMatch()) - { - return sb.toString(); - } - for (int i = 0; i < numSubs(); i++) - { - int n = i + 1; - sb - .append(" sub(" + n + ")=" + matchedFrom(n) + ":" - + charsMatched(n)); - } - return sb.toString(); - } - - public RegRes() - { - } - - public RegRes(RegRes r) - { - copyOutOf(r); - } - - public void copyOutOf(RegRes r) - { - if (r.marks == null) - { - marks = null; - } - else - { - try - { - // marks = (Hashtable)r.marks.clone(); - marks = new int[r.marks.length]; - for (int i = 0; i < marks.length; i++) - { - marks[i] = r.marks[i]; - } - // marks = (int[])r.marks.clone(); - } catch (Throwable t) - { - } - } - didMatch_ = r.didMatch_; - src = r.src; - charsMatched_ = r.charsMatched_; - matchFrom_ = r.matchFrom_; - numSubs_ = r.numSubs_; - } - - public Object clone() - { - return new RegRes(this); - } - - public boolean equals(RegRes r) - { - if (charsMatched_ != r.charsMatched_ || matchFrom_ != r.matchFrom_ - || didMatch_ != r.didMatch_ || numSubs_ != r.numSubs_ - || !src.unwrap().equals(r.src.unwrap())) - { - return false; - } - if (marks == null && r.marks != null) - { - return false; - } - if (marks != null && r.marks == null) - { - return false; - } - for (int i = 1; i <= numSubs_; i++) - { - if (matchedFrom(i) != r.matchedFrom(i)) - { - return false; - } - else if (charsMatched(i) != r.charsMatched(i)) - { - return false; - } - } - return true; - } - - /** Obtains the match if successful, null otherwise. */ - public String stringMatched() - { - int mf = matchedFrom(), cm = charsMatched(); - return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf, mf - + cm); - } - - /** - * Obtains the position backreference number i begins to match, or -1 if - * backreference i was not matched. - */ - public int matchedFrom(int i) - { - if (marks == null || i > numSubs_) - { - return -1; - } - // Integer in=(Integer)marks.get("left"+i); - // return in == null ? -1 : in.intValue(); - return marks[i]; - } - - /** - * Obtains the number of characters matched by backreference i, or -1 if - * backreference i was not matched. - */ - public int charsMatched(int i) - { - if (marks == null || i > numSubs_ || !didMatch_) - { - return -1; - } - // Integer in = (Integer)marks.get("right"+i); - // int i2 = in==null ? -1 : in.intValue(); - int mf = matchedFrom(i); - return mf < 0 ? -1 : marks[i + numSubs_] - matchedFrom(i); - } - - /** - * This is either equal to matchedFrom(i)+charsMatched(i) if the match was - * successful, or -1 if it was not. - */ - public int matchedTo(int i) - { - if (marks == null || i > numSubs_ || !didMatch_) - { - return -1; - } - return marks[i + numSubs_]; - } - - /** - * Obtains a substring matching the nth set of parenthesis from the pattern. - * See numSubs(void), or null if the nth backrefence did not match. - */ - public String stringMatched(int i) - { - int mf = matchedFrom(i), cm = charsMatched(i); - return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf, mf - + cm); - } - - /** - * This returns the part of the string that preceeds the match, or null if the - * match failed. - */ - public String left() - { - int mf = matchedFrom(); - return !didMatch_ || (mf < 0) ? null : src.substring(0, mf); - } - - /** - * This returns the part of the string that follows the ith backreference, or - * null if the backreference did not match. - */ - public String left(int i) - { - int mf = matchedFrom(i); - return !didMatch_ || (mf < 0) ? null : src.substring(0, mf); - } - - /** - * This returns the part of the string that follows the match, or null if the - * backreference did not match. - */ - public String right() - { - int mf = matchedFrom(), cm = charsMatched(); - return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + cm, - src.length()); - } - - /** - * This returns the string to the right of the ith backreference, or null if - * the backreference did not match. - */ - public String right(int i) - { - int mf = matchedFrom(i), cm = charsMatched(i); - return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + cm, - src.length()); - } - - /** - * After a successful match, this returns the location of the first matching - * character, or -1 if the match failed. - */ - public int matchedFrom() - { - return !didMatch_ ? -1 : matchFrom_; - } - - /** - * After a successful match, this returns the number of characters in the - * match, or -1 if the match failed. - */ - public int charsMatched() - { - return !didMatch_ || matchFrom_ < 0 ? -1 : charsMatched_; - } - - /** - * This is matchedFrom()+charsMatched() after a successful match, or -1 - * otherwise. - */ - public int matchedTo() - { - return !didMatch_ ? -1 : matchFrom_ + charsMatched_; - } - - /** - * This returns the number of backreferences (parenthesis) in the pattern, - * i.e. the pattern "(ab)" has one, the pattern "(a)(b)" has two, etc. - */ - public int numSubs() - { - return numSubs_; - } - - /** Contains true if the last match was successful. */ - public boolean didMatch() - { - return didMatch_; - } - - /** An older name for matchedFrom. */ - public int matchFrom() - { - return matchedFrom(); - } - - /** An older name for stringMatched(). */ - public String substring() - { - return stringMatched(); - } - - /** An older name for matchedFrom. */ - public int matchFrom(int i) - { - return matchedFrom(i); - } - - /** An older name for stringMatched. */ - public String substring(int i) - { - return stringMatched(i); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + Shareware: package pat + Copyright 2001, Steven R. Brandt + */ +/** + * This class is used to store a result from Regex + */ +public class RegRes implements Cloneable +{ + protected int[] marks = null; + + protected boolean didMatch_ = false; + + protected StringLike src = null; + + /** Obtain the text String that was matched against. */ + public String getString() + { + return src.toString(); + } + + /** Obtain the source StringLike object. */ + public StringLike getStringLike() + { + return src; + } + + protected int charsMatched_ = 0, matchFrom_ = 0, numSubs_ = 0; + + public String toString() + { + javajs.util.SB sb = new javajs.util.SB(); + sb.append("match=" + matchedFrom() + ":" + charsMatched()); + if (!didMatch()) + { + return sb.toString(); + } + for (int i = 0; i < numSubs(); i++) + { + int n = i + 1; + sb + .append(" sub(" + n + ")=" + matchedFrom(n) + ":" + + charsMatched(n)); + } + return sb.toString(); + } + + public RegRes() + { + } + + public RegRes(RegRes r) + { + copyOutOf(r); + } + + public void copyOutOf(RegRes r) + { + if (r.marks == null) + { + marks = null; + } + else + { + try + { + // marks = (Hashtable)r.marks.clone(); + marks = new int[r.marks.length]; + for (int i = 0; i < marks.length; i++) + { + marks[i] = r.marks[i]; + } + // marks = (int[])r.marks.clone(); + } catch (Throwable t) + { + } + } + didMatch_ = r.didMatch_; + src = r.src; + charsMatched_ = r.charsMatched_; + matchFrom_ = r.matchFrom_; + numSubs_ = r.numSubs_; + } + + public Object clone() + { + return new RegRes(this); + } + + public boolean equals(RegRes r) + { + if (charsMatched_ != r.charsMatched_ || matchFrom_ != r.matchFrom_ + || didMatch_ != r.didMatch_ || numSubs_ != r.numSubs_ + || !src.unwrap().equals(r.src.unwrap())) + { + return false; + } + if (marks == null && r.marks != null) + { + return false; + } + if (marks != null && r.marks == null) + { + return false; + } + for (int i = 1; i <= numSubs_; i++) + { + if (matchedFrom(i) != r.matchedFrom(i)) + { + return false; + } + else if (charsMatched(i) != r.charsMatched(i)) + { + return false; + } + } + return true; + } + + /** Obtains the match if successful, null otherwise. */ + public String stringMatched() + { + int mf = matchedFrom(), cm = charsMatched(); + return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf, mf + + cm); + } + + /** + * Obtains the position backreference number i begins to match, or -1 if + * backreference i was not matched. + */ + public int matchedFrom(int i) + { + if (marks == null || i > numSubs_) + { + return -1; + } + // Integer in=(Integer)marks.get("left"+i); + // return in == null ? -1 : in.intValue(); + return marks[i]; + } + + /** + * Obtains the number of characters matched by backreference i, or -1 if + * backreference i was not matched. + */ + public int charsMatched(int i) + { + if (marks == null || i > numSubs_ || !didMatch_) + { + return -1; + } + // Integer in = (Integer)marks.get("right"+i); + // int i2 = in==null ? -1 : in.intValue(); + int mf = matchedFrom(i); + return mf < 0 ? -1 : marks[i + numSubs_] - matchedFrom(i); + } + + /** + * This is either equal to matchedFrom(i)+charsMatched(i) if the match was + * successful, or -1 if it was not. + */ + public int matchedTo(int i) + { + if (marks == null || i > numSubs_ || !didMatch_) + { + return -1; + } + return marks[i + numSubs_]; + } + + /** + * Obtains a substring matching the nth set of parenthesis from the pattern. + * See numSubs(void), or null if the nth backrefence did not match. + */ + public String stringMatched(int i) + { + int mf = matchedFrom(i), cm = charsMatched(i); + return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf, mf + + cm); + } + + /** + * This returns the part of the string that preceeds the match, or null if the + * match failed. + */ + public String left() + { + int mf = matchedFrom(); + return !didMatch_ || (mf < 0) ? null : src.substring(0, mf); + } + + /** + * This returns the part of the string that follows the ith backreference, or + * null if the backreference did not match. + */ + public String left(int i) + { + int mf = matchedFrom(i); + return !didMatch_ || (mf < 0) ? null : src.substring(0, mf); + } + + /** + * This returns the part of the string that follows the match, or null if the + * backreference did not match. + */ + public String right() + { + int mf = matchedFrom(), cm = charsMatched(); + return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + cm, + src.length()); + } + + /** + * This returns the string to the right of the ith backreference, or null if + * the backreference did not match. + */ + public String right(int i) + { + int mf = matchedFrom(i), cm = charsMatched(i); + return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + cm, + src.length()); + } + + /** + * After a successful match, this returns the location of the first matching + * character, or -1 if the match failed. + */ + public int matchedFrom() + { + return !didMatch_ ? -1 : matchFrom_; + } + + /** + * After a successful match, this returns the number of characters in the + * match, or -1 if the match failed. + */ + public int charsMatched() + { + return !didMatch_ || matchFrom_ < 0 ? -1 : charsMatched_; + } + + /** + * This is matchedFrom()+charsMatched() after a successful match, or -1 + * otherwise. + */ + public int matchedTo() + { + return !didMatch_ ? -1 : matchFrom_ + charsMatched_; + } + + /** + * This returns the number of backreferences (parenthesis) in the pattern, + * i.e. the pattern "(ab)" has one, the pattern "(a)(b)" has two, etc. + */ + public int numSubs() + { + return numSubs_; + } + + /** Contains true if the last match was successful. */ + public boolean didMatch() + { + return didMatch_; + } + + /** An older name for matchedFrom. */ + public int matchFrom() + { + return matchedFrom(); + } + + /** An older name for stringMatched(). */ + public String substring() + { + return stringMatched(); + } + + /** An older name for matchedFrom. */ + public int matchFrom(int i) + { + return matchedFrom(i); + } + + /** An older name for stringMatched. */ + public String substring(int i) + { + return stringMatched(i); + } +} diff --git a/unused/com/stevesoft/pat/RegSyntax.java b/unused/com/stevesoft/pat/RegSyntax.java index 635dc4c..0a4324c 100644 --- a/unused/com/stevesoft/pat/RegSyntax.java +++ b/unused/com/stevesoft/pat/RegSyntax.java @@ -1,30 +1,30 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/* - Shareware: package pat - Copyright 2001, Steven R. Brandt - */ -/** - * This type of syntax error is thrown whenever a syntax error is encountered in - * the pattern. It may not be caught directly, as it is not in the throws clause - * of any method. To detect it, catch Throwable, and use instanceof to see if it - * is a RegSyntax. - */ -public class RegSyntax extends Exception -{ - RegSyntax() - { - } - - RegSyntax(String msg) - { - super(msg); - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/* + Shareware: package pat + Copyright 2001, Steven R. Brandt + */ +/** + * This type of syntax error is thrown whenever a syntax error is encountered in + * the pattern. It may not be caught directly, as it is not in the throws clause + * of any method. To detect it, catch Throwable, and use instanceof to see if it + * is a RegSyntax. + */ +public class RegSyntax extends Exception +{ + RegSyntax() + { + } + + RegSyntax(String msg) + { + super(msg); + } +}; diff --git a/unused/com/stevesoft/pat/RegSyntaxError.java b/unused/com/stevesoft/pat/RegSyntaxError.java index 1e56122..681135c 100644 --- a/unused/com/stevesoft/pat/RegSyntaxError.java +++ b/unused/com/stevesoft/pat/RegSyntaxError.java @@ -1,40 +1,40 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * When enabled, this class is thrown instead of the normal RegSyntax. Thus, - * enabling of this class will make your debugging easier -- but if you leave it - * on and forget to catch RegSyntaxError a user-supplied pattern could generate - * a RegSyntaxError that will kill your application. - * - * I strongly recommend turning this flag on, however, as I think it is more - * likely to help than to hurt your programming efforts. - */ -public class RegSyntaxError extends Error -{ - public static boolean RegSyntaxErrorEnabled = false; - - public RegSyntaxError() - { - } - - public RegSyntaxError(String s) - { - super(s); - } - - final static void endItAll(String s) throws RegSyntax - { - if (RegSyntaxErrorEnabled) - { - throw new RegSyntaxError(s); - } - throw new RegSyntax(s); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * When enabled, this class is thrown instead of the normal RegSyntax. Thus, + * enabling of this class will make your debugging easier -- but if you leave it + * on and forget to catch RegSyntaxError a user-supplied pattern could generate + * a RegSyntaxError that will kill your application. + * + * I strongly recommend turning this flag on, however, as I think it is more + * likely to help than to hurt your programming efforts. + */ +public class RegSyntaxError extends Error +{ + public static boolean RegSyntaxErrorEnabled = false; + + public RegSyntaxError() + { + } + + public RegSyntaxError(String s) + { + super(s); + } + + final static void endItAll(String s) throws RegSyntax + { + if (RegSyntaxErrorEnabled) + { + throw new RegSyntaxError(s); + } + throw new RegSyntax(s); + } +} diff --git a/unused/com/stevesoft/pat/Regex.java b/unused/com/stevesoft/pat/Regex.java index 4f49f0c..594c7c9 100644 --- a/unused/com/stevesoft/pat/Regex.java +++ b/unused/com/stevesoft/pat/Regex.java @@ -1,2081 +1,2081 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import jalview.util.MessageManager; - -import java.util.BitSet; -import java.util.Hashtable; - -import com.stevesoft.pat.wrap.StringWrap; - -/** Matches a Unicode punctuation character. */ -class UnicodePunct extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && Prop.isPunct(s.charAt(from)) ? to : -1; - } -} - -/** Matches a Unicode white space character. */ -class UnicodeWhite extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && Prop.isWhite(s.charAt(from)) ? to : -1; - } -} - -/** - * Matches a character that is not a Unicode punctuation character. - */ -class NUnicodePunct extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && !Prop.isPunct(s.charAt(from)) ? to : -1; - } -} - -/** - * Matches a character that is not a Unicode white space character. - */ -class NUnicodeWhite extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && !Prop.isWhite(s.charAt(from)) ? to : -1; - } -} - -/** Matches a Unicode word character: an alphanumeric or underscore. */ -class UnicodeW extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - if (from >= s.length()) - { - return -1; - } - char c = s.charAt(from); - return (Prop.isAlphabetic(c) || Prop.isDecimalDigit(c) || c == '_') ? to - : -1; - } -} - -/** Matches a character that is not a Unicode alphanumeric or underscore. */ -class NUnicodeW extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - if (from >= s.length()) - { - return -1; - } - char c = s.charAt(from); - return !(Prop.isAlphabetic(c) || Prop.isDecimalDigit(c) || c == '_') ? to - : -1; - } -} - -/** Matches a Unicode decimal digit. */ -class UnicodeDigit extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && Prop.isDecimalDigit(s.charAt(from)) ? to - : -1; - } -} - -/** Matches a character that is not a Unicode digit. */ -class NUnicodeDigit extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && !Prop.isDecimalDigit(s.charAt(from)) ? to - : -1; - } -} - -/** Matches a Unicode math character. */ -class UnicodeMath extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && Prop.isMath(s.charAt(from)) ? to : -1; - } -} - -/** Matches a non-math Unicode character. */ -class NUnicodeMath extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && !Prop.isMath(s.charAt(from)) ? to : -1; - } -} - -/** Matches a Unicode currency symbol. */ -class UnicodeCurrency extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && Prop.isCurrency(s.charAt(from)) ? to : -1; - } -} - -/** Matches a non-currency symbol Unicode character. */ -class NUnicodeCurrency extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && !Prop.isCurrency(s.charAt(from)) ? to : -1; - } -} - -/** Matches a Unicode alphabetic character. */ -class UnicodeAlpha extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && Prop.isAlphabetic(s.charAt(from)) ? to : -1; - } -} - -/** Matches a non-alphabetic Unicode character. */ -class NUnicodeAlpha extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && !Prop.isAlphabetic(s.charAt(from)) ? to - : -1; - } -} - -/** Matches an upper case Unicode character. */ -class UnicodeUpper extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && isUpper(s.charAt(from)) ? to : -1; - } - - final boolean isUpper(char c) - { - return c == CaseMgr.toUpperCase(c) && c != CaseMgr.toLowerCase(c); - } -} - -/** Matches an upper case Unicode character. */ -class UnicodeLower extends UniValidator -{ - public int validate(StringLike s, int from, int to) - { - return from < s.length() && isLower(s.charAt(from)) ? to : -1; - } - - final boolean isLower(char c) - { - return c != CaseMgr.toUpperCase(c) && c == CaseMgr.toLowerCase(c); - } -} - -/** - * Regex provides the parser which constructs the linked list of Pattern classes - * from a String. - *

    - * For the purpose of this documentation, the fact that java interprets the - * backslash will be ignored. In practice, however, you will need a double - * backslash to obtain a string that contains a single backslash character. - * Thus, the example pattern "\b" should really be typed as "\\b" inside java - * code. - *

    - * Note that Regex is part of package "com.stevesoft.pat". To use it, simply - * import com.stevesoft.pat.Regex at the top of your file. - *

    - * Regex is made with a constructor that takes a String that defines the regular - * expression. Thus, for example - * - *

    - * Regex r = new Regex("[a-c]*");
    - * 
    - * - * matches any number of characters so long as the are 'a', 'b', or 'c'). - *

    - * To attempt to match the Pattern to a given string, you can use either the - * search(String) member function, or the matchAt(String,int position) member - * function. These functions return a boolean which tells you whether or not the - * thing worked, and sets the methods "charsMatched()" and "matchedFrom()" in - * the Regex object appropriately. - *

    - * The portion of the string before the match can be obtained by the left() - * member, and the portion after the match can be obtained by the right() - * member. - *

    - * Essentially, this package implements a syntax that is very much like the perl - * 5 regular expression syntax. - * - * Longer example: - * - *

    - * Regex r = new Regex("x(a|b)y");
    - * r.matchAt("xay", 0);
    - * System.out.println("sub = " + r.stringMatched(1));
    - * 
    - * - * The above would print "sub = a". - * - *
    - *  r.left() // would return "x"
    - *  r.right() // would return "y"
    - * 
    - * - *

    - * Differences between this package and perl5:
    - * The extended Pattern for setting flags, is now supported, but the flags are - * different. "(?i)" tells the pattern to ignore case, "(?Q)" sets the - * "dontMatchInQuotes" flag, and "(?iQ)" sets them both. You can change the - * escape character. The pattern - * - *

    - * (?e=#)#d+
    - * 
    - * - * is the same as - * - *
    - * \d+
    - * 
    , but note that the sequence - * - *
    - * (?e=#)
    - * 
    - * - * must occur at the very beginning of the pattern. There may be other - * small differences as well. I will either make my package conform or note them - * as I become aware of them. - *

    - * This package supports additional patterns not in perl5:

    - * - * - * - * - * - * - * - * - *
    (?@())GroupThis matches all characters between the '(' character and the balancing - * ')' character. Thus, it will match "()" as well as "(())". The balancing - * characters are arbitrary, thus (?@{}) matches on "{}" and "{{}}".
    (?<1)BackupMoves the pointer backwards within the text. This allows you to make a - * "look behind." It fails if it attempts to move to a position before the - * beginning of the string. "x(?<1)" is equivalent to "(?=x)". The number, 1 - * in this example, is the number of characters to move backwards.
    - * - * - * @author Steven R. Brandt - * @version package com.stevesoft.pat, release 1.5.3 - * @see Pattern - */ -public class Regex extends RegRes// implements FilenameFilter -{ - /** - * BackRefOffset gives the identity number of the first pattern. Version 1.0 - * used zero, version 1.1 uses 1 to be more compatible with perl. - */ - static int BackRefOffset = 1; - - private static Pattern none = new NoPattern(); - - Pattern thePattern = none; - - patInt minMatch = new patInt(0); - - static Hashtable validators = new Hashtable(); - static - { - define("p", "(?>1)", new UnicodePunct()); - define("P", "(?>1)", new NUnicodePunct()); - define("s", "(?>1)", new UnicodeWhite()); - define("S", "(?>1)", new NUnicodeWhite()); - define("w", "(?>1)", new UnicodeW()); - define("W", "(?>1)", new NUnicodeW()); - define("d", "(?>1)", new UnicodeDigit()); - define("D", "(?>1)", new NUnicodeDigit()); - define("m", "(?>1)", new UnicodeMath()); - define("M", "(?>1)", new NUnicodeMath()); - define("c", "(?>1)", new UnicodeCurrency()); - define("C", "(?>1)", new NUnicodeCurrency()); - define("a", "(?>1)", new UnicodeAlpha()); - define("A", "(?>1)", new NUnicodeAlpha()); - define("uc", "(?>1)", new UnicodeUpper()); - define("lc", "(?>1)", new UnicodeLower()); - } - - /** Set the dontMatch in quotes flag. */ - public void setDontMatchInQuotes(boolean b) - { - dontMatchInQuotes = b; - } - - /** Find out if the dontMatchInQuotes flag is enabled. */ - public boolean getDontMatchInQuotes() - { - return dontMatchInQuotes; - } - - boolean dontMatchInQuotes = false; - - /** - * Set the state of the ignoreCase flag. If set to true, then the pattern - * matcher will ignore case when searching for a match. - */ - public void setIgnoreCase(boolean b) - { - ignoreCase = b; - } - - /** - * Get the state of the ignoreCase flag. Returns true if we are ignoring the - * case of the pattern, false otherwise. - */ - public boolean getIgnoreCase() - { - return ignoreCase; - } - - boolean ignoreCase = false; - - static boolean defaultMFlag = false; - - /** - * Set the default value of the m flag. If it is set to true, then the MFlag - * will be on for any regex search executed. - */ - public static void setDefaultMFlag(boolean mFlag) - { - defaultMFlag = mFlag; - } - - /** - * Get the default value of the m flag. If it is set to true, then the MFlag - * will be on for any regex search executed. - */ - public static boolean getDefaultMFlag() - { - return defaultMFlag; - } - - /** - * Initializes the object without a Pattern. To supply a Pattern use - * compile(String s). - * - * @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex() - { - } - - /** - * Create and compile a Regex, but do not throw any exceptions. If you wish to - * have exceptions thrown for syntax errors, you must use the Regex(void) - * constructor to create the Regex object, and then call the compile method. - * Therefore, you should only call this method when you know your pattern is - * right. I will probably become more like - * - * @see com.stevesoft.pat.Regex#search(java.lang.String) - * @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex(String s) - { - try - { - compile(s); - } catch (RegSyntax rs) - { - } - } - - ReplaceRule rep = null; - - /** - * Create and compile both a Regex and a ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex(String s, String rp) - { - this(s); - rep = parsePerl.perlCode(rp); - } - - /** - * Create and compile a Regex, but give it the ReplaceRule specified. This - * allows the user finer control of the Replacement process, if that is - * desired. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#compile(java.lang.String) - */ - public Regex(String s, ReplaceRule rp) - { - this(s); - rep = rp; - } - - /** - * Change the ReplaceRule of this Regex by compiling a new one using String - * rp. - */ - public void setReplaceRule(String rp) - { - rep = parsePerl.perlCode(rp); - repr = null; // Clear Replacer history - } - - /** Change the ReplaceRule of this Regex to rp. */ - public void setReplaceRule(ReplaceRule rp) - { - rep = rp; - } - - /** - * Test to see if a custom defined rule exists. - * - * @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) - */ - public static boolean isDefined(String nm) - { - return validators.get(nm) != null; - } - - /** - * Removes a custom defined rule. - * - * @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) - */ - public static void undefine(String nm) - { - validators.remove(nm); - } - - /** - * Defines a method to create a new rule. See test/deriv2.java and - * test/deriv3.java for examples of how to use it. - */ - public static void define(String nm, String pat, Validator v) - { - v.pattern = pat; - validators.put(nm, v); - } - - /** - * Defines a shorthand for a pattern. The pattern will be invoked by a string - * that has the form "(??"+nm+")". - */ - public static void define(String nm, String pat) - { - validators.put(nm, pat); - } - - /** Get the current ReplaceRule. */ - public ReplaceRule getReplaceRule() - { - return rep; - } - - Replacer repr = null; - - final Replacer _getReplacer() - { - return repr == null ? repr = new Replacer() : repr; - } - - public Replacer getReplacer() - { - if (repr == null) - { - repr = new Replacer(); - } - repr.rh.me = this; - repr.rh.prev = null; - return repr; - } - - /** - * Replace the first occurence of this pattern in String s according to the - * ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceFirst(String s) - { - return _getReplacer().replaceFirstRegion(s, this, 0, s.length()) - .toString(); - } - - /** - * Replace the first occurence of this pattern in String s beginning with - * position pos according to the ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceFirstFrom(String s, int pos) - { - return _getReplacer().replaceFirstRegion(s, this, pos, s.length()) - .toString(); - } - - /** - * Replace the first occurence of this pattern in String s beginning with - * position start and ending with end according to the ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceFirstRegion(String s, int start, int end) - { - return _getReplacer().replaceFirstRegion(s, this, start, end) - .toString(); - } - - /** - * Replace all occurences of this pattern in String s according to the - * ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceAll(String s) - { - return _getReplacer().replaceAllRegion(s, this, 0, s.length()) - .toString(); - } - - public StringLike replaceAll(StringLike s) - { - return _getReplacer().replaceAllRegion(s, this, 0, s.length()); - } - - /** - * Replace all occurences of this pattern in String s beginning with position - * pos according to the ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceAllFrom(String s, int pos) - { - return _getReplacer().replaceAllRegion(s, this, pos, s.length()) - .toString(); - } - - /** - * Replace all occurences of this pattern in String s beginning with position - * start and ending with end according to the ReplaceRule. - * - * @see com.stevesoft.pat.ReplaceRule - * @see com.stevesoft.pat.Regex#getReplaceRule() - */ - public String replaceAllRegion(String s, int start, int end) - { - return _getReplacer().replaceAllRegion(s, this, start, end).toString(); - } - - /** Essentially clones the Regex object */ - public Regex(Regex r) - { - super((RegRes) r); - dontMatchInQuotes = r.dontMatchInQuotes; - esc = r.esc; - ignoreCase = r.ignoreCase; - gFlag = r.gFlag; - if (r.rep == null) - { - rep = null; - } - else - { - rep = (ReplaceRule) r.rep.clone(); - } - /* - * try { compile(r.toString()); } catch(RegSyntax r_) {} - */ - thePattern = r.thePattern.clone(new Hashtable()); - minMatch = r.minMatch; - skipper = r.skipper; - } - - /** - * By default, the escape character is the backslash, but you can make it - * anything you want by setting this variable. - */ - public char esc = Pattern.ESC; - - /** - * This method compiles a regular expression, making it possible to call the - * search or matchAt methods. - * - * @exception com.stevesoft.pat.RegSyntax - * is thrown if a syntax error is encountered in the - * pattern. For example, "x{3,1}" or "*a" are not valid - * patterns. - * @see com.stevesoft.pat.Regex#search - * @see com.stevesoft.pat.Regex#matchAt - */ - public void compile(String prepat) throws RegSyntax - { - String postpat = parsePerl.codify(prepat, true); - String pat = postpat == null ? prepat : postpat; - minMatch = null; - ignoreCase = false; - dontMatchInQuotes = false; - Rthings mk = new Rthings(this); - int offset = mk.val; - String newpat = pat; - thePattern = none; - p = null; - or = null; - minMatch = new patInt(0); - StrPos sp = new StrPos(pat, 0); - if (sp.incMatch("(?e=")) - { - char newEsc = sp.c; - sp.inc(); - if (sp.match(')')) - { - newpat = reEscape(pat.substring(6), newEsc, Pattern.ESC); - } - } - else if (esc != Pattern.ESC) - { - newpat = reEscape(pat, esc, Pattern.ESC); - } - thePattern = _compile2(newpat, mk); - numSubs_ = mk.val - offset; - mk.set(this); - } - - /* - * If a Regex is compared against a Regex, a check is done to see that the - * patterns are equal as well as the most recent match. If a Regex is compare - * with a RegRes, only the result of the most recent match is compared. - */ - public boolean equals(Object o) - { - if (o instanceof Regex) - { - if (toString().equals(o.toString())) - { - return super.equals(o); - } - else - { - return false; - } - } - else - { - return super.equals(o); - } - } - - /** A clone by any other name would smell as sweet. */ - public Object clone() - { - return new Regex(this); - } - - /** Return a clone of the underlying RegRes object. */ - public RegRes result() - { - return (RegRes) super.clone(); - } - - // prep sets global variables of class - // Pattern so that it can access them - // during an attempt at a match - Pthings pt = new Pthings(); - - final Pthings prep(StringLike s) - { - // if(gFlag) - pt.lastPos = matchedTo(); - if (pt.lastPos < 0) - { - pt.lastPos = 0; - } - if ((s == null ? null : s.unwrap()) != (src == null ? null : s.unwrap())) - { - pt.lastPos = 0; - } - src = s; - pt.dotDoesntMatchCR = dotDoesntMatchCR && (!sFlag); - pt.mFlag = (mFlag | defaultMFlag); - pt.ignoreCase = ignoreCase; - pt.no_check = false; - if (pt.marks != null) - { - for (int i = 0; i < pt.marks.length; i++) - { - pt.marks[i] = -1; - } - } - pt.marks = null; - pt.nMarks = numSubs_; - pt.src = s; - if (dontMatchInQuotes) - { - setCbits(s, pt); - } - else - { - pt.cbits = null; - } - return pt; - } - - /** - * Attempt to match a Pattern beginning at a specified location within the - * string. - * - * @see com.stevesoft.pat.Regex#search - */ - public boolean matchAt(String s, int start_pos) - { - return _search(s, start_pos, start_pos); - } - - /** - * Attempt to match a Pattern beginning at a specified location within the - * StringLike. - * - * @see com.stevesoft.pat.Regex#search - */ - public boolean matchAt(StringLike s, int start_pos) - { - return _search(s, start_pos, start_pos); - } - - /** - * Search through a String for the first occurrence of a match. - * - * @see com.stevesoft.pat.Regex#searchFrom - * @see com.stevesoft.pat.Regex#matchAt - */ - public boolean search(String s) - { - if (s == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_given_to_regex_search")); - } - return _search(s, 0, s.length()); - } - - public boolean search(StringLike sl) - { - if (sl == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search")); - } - return _search(sl, 0, sl.length()); - } - - public boolean reverseSearch(String s) - { - if (s == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_given_to_regex_reverse_search")); - } - return _reverseSearch(s, 0, s.length()); - } - - public boolean reverseSearch(StringLike sl) - { - if (sl == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_reverse_search")); - } - return _reverseSearch(sl, 0, sl.length()); - } - - /** - * Search through a String for the first occurence of a match, but start at - * position - * - *
    -   * start
    -   * 
    - */ - public boolean searchFrom(String s, int start) - { - if (s == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search_from")); - } - return _search(s, start, s.length()); - } - - public boolean searchFrom(StringLike s, int start) - { - if (s == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search_from")); - } - return _search(s, start, s.length()); - } - - /** - * Search through a region of a String for the first occurence of a match. - */ - public boolean searchRegion(String s, int start, int end) - { - if (s == null) - { - throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search_region")); - } - return _search(s, start, end); - } - - /** - * Set this to change the default behavior of the "." pattern. By default it - * now matches perl's behavior and fails to match the '\n' character. - */ - public static boolean dotDoesntMatchCR = true; - - StringLike gFlags; - - int gFlagto = 0; - - boolean gFlag = false; - - /** Set the 'g' flag */ - public void setGFlag(boolean b) - { - gFlag = b; - } - - /** Get the state of the 'g' flag. */ - public boolean getGFlag() - { - return gFlag; - } - - boolean sFlag = false; - - /** Get the state of the sFlag */ - public boolean getSFlag() - { - return sFlag; - } - - boolean mFlag = false; - - /** Get the state of the sFlag */ - public boolean getMFlag() - { - return mFlag; - } - - final boolean _search(String s, int start, int end) - { - return _search(new StringWrap(s), start, end); - } - - final boolean _search(StringLike s, int start, int end) - { - if (gFlag && gFlagto > 0 && gFlags != null - && s.unwrap() == gFlags.unwrap()) - { - start = gFlagto; - } - gFlags = null; - - Pthings pt = prep(s); - - int up = (minMatch == null ? end : end - minMatch.i); - - if (up < start && end >= start) - { - up = start; - } - - if (skipper == null) - { - for (int i = start; i <= up; i++) - { - charsMatched_ = thePattern.matchAt(s, i, pt); - if (charsMatched_ >= 0) - { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_ + charsMatched_; - gFlags = s; - return didMatch_ = true; - } - } - } - else - { - pt.no_check = true; - for (int i = start; i <= up; i++) - { - i = skipper.find(src, i, up); - if (i < 0) - { - charsMatched_ = matchFrom_ = -1; - return didMatch_ = false; - } - charsMatched_ = thePattern.matchAt(s, i, pt); - if (charsMatched_ >= 0) - { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_ + charsMatched_; - gFlags = s; - return didMatch_ = true; - } - } - } - return didMatch_ = false; - } - - /* - * final boolean _search(LongStringLike s,long start,long end) { if(gFlag && - * gFlagto > 0 && s==gFlags) start = gFlagto; gFlags = null; - * - * Pthings pt=prep(s); - * - * int up = end;//(minMatch == null ? end : end-minMatch.i); - * - * if(up < start && end >= start) up = start; - * - * if(skipper == null) { for(long i=start;i<=up;i++) { charsMatched_ = - * thePattern.matchAt(s,i,pt); if(charsMatched_ >= 0) { matchFrom_ = - * thePattern.mfrom; marks = pt.marks; gFlagto = matchFrom_+charsMatched_; - * return didMatch_=true; } } } else { pt.no_check = true; for(long i=start;i<=up;i++) { - * i = skipper.find(src,i,up); if(i<0) { charsMatched_ = matchFrom_ = -1; - * return didMatch_ = false; } charsMatched_ = thePattern.matchAt(s,i,pt); - * if(charsMatched_ >= 0) { matchFrom_ = thePattern.mfrom; marks = pt.marks; - * gFlagto = matchFrom_+charsMatched_; gFlags = s; return didMatch_=true; } - * else { i = s.adjustIndex(i); up = s.adjustEnd(i); } } } return - * didMatch_=false; } - */ - - boolean _reverseSearch(String s, int start, int end) - { - return _reverseSearch(new StringWrap(s), start, end); - } - - boolean _reverseSearch(StringLike s, int start, int end) - { - if (gFlag && gFlagto > 0 && s.unwrap() == gFlags.unwrap()) - { - end = gFlagto; - } - gFlags = null; - Pthings pt = prep(s); - for (int i = end; i >= start; i--) - { - charsMatched_ = thePattern.matchAt(s, i, pt); - if (charsMatched_ >= 0) - { - matchFrom_ = thePattern.mfrom; - marks = pt.marks; - gFlagto = matchFrom_ - 1; - gFlags = s; - return didMatch_ = true; - } - } - return didMatch_ = false; - } - - // This routine sets the cbits variable - // of class Pattern. Cbits is true for - // the bit corresponding to a character inside - // a set of quotes. - static StringLike lasts = null; - - static BitSet lastbs = null; - - static void setCbits(StringLike s, Pthings pt) - { - if (s == lasts) - { - pt.cbits = lastbs; - return; - } - BitSet bs = new BitSet(s.length()); - char qc = ' '; - boolean setBit = false; - for (int i = 0; i < s.length(); i++) - { - if (setBit) - { - bs.set(i); - } - char c = s.charAt(i); - if (!setBit && c == '"') - { - qc = c; - setBit = true; - bs.set(i); - } - else if (!setBit && c == '\'') - { - qc = c; - setBit = true; - bs.set(i); - } - else if (setBit && c == qc) - { - setBit = false; - } - else if (setBit && c == '\\' && i + 1 < s.length()) - { - i++; - if (setBit) - { - bs.set(i); - } - } - } - pt.cbits = lastbs = bs; - lasts = s; - } - - // Wanted user to over-ride this in alpha version, - // but it wasn't really necessary because of this trick: - Regex newRegex() - { - try - { - return (Regex) getClass().newInstance(); - } catch (InstantiationException ie) - { - return null; - } catch (IllegalAccessException iae) - { - return null; - } - } - - /** - * Only needed for creating your own extensions of Regex. This method adds the - * next Pattern in the chain of patterns or sets the Pattern if it is the - * first call. - */ - protected void add(Pattern p2) - { - if (p == null) - { - p = p2; - } - else - { - p.add(p2); - p2 = p; - } - } - - /** - * You only need to use this method if you are creating your own extentions to - * Regex. compile1 compiles one Pattern element, it can be over-ridden to - * allow the Regex compiler to understand new syntax. See deriv.java for an - * example. This routine is the heart of class Regex. Rthings has one integer - * member called intValue, it is used to keep track of the number of ()'s in - * the Pattern. - * - * @exception com.stevesoft.pat.RegSyntax - * is thrown when a nonsensensical pattern is supplied. For - * example, a pattern beginning with *. - */ - protected void compile1(StrPos sp, Rthings mk) throws RegSyntax - { - if (sp.match('[')) - { - sp.inc(); - add(matchBracket(sp)); - } - else if (sp.match('|')) - { - if (or == null) - { - or = new Or(); - } - if (p == null) - { - p = new NullPattern(); - } - or.addOr(p); - p = null; - } - else if (sp.incMatch("(?<")) - { - patInt i = sp.getPatInt(); - if (i == null) - { - RegSyntaxError.endItAll("No int after (?<"); - } - add(new Backup(i.intValue())); - if (!sp.match(')')) - { - RegSyntaxError.endItAll("No ) after (?<"); - } - } - else if (sp.incMatch("(?>")) - { - patInt i = sp.getPatInt(); - if (i == null) - { - RegSyntaxError.endItAll("No int after (?>"); - } - add(new Backup(-i.intValue())); - if (!sp.match(')')) - { - RegSyntaxError.endItAll("No ) after (?<"); - } - } - else if (sp.incMatch("(?@")) - { - char op = sp.c; - sp.inc(); - char cl = sp.c; - sp.inc(); - if (!sp.match(')')) - { - RegSyntaxError.endItAll("(?@ does not have closing paren"); - } - add(new Group(op, cl)); - } - else if (sp.incMatch("(?#")) - { - while (!sp.match(')')) - { - sp.inc(); - } - } - else if (sp.dontMatch && sp.c == 'w') - { - // Regex r = new Regex(); - // r._compile("[a-zA-Z0-9_]",mk); - // add(new Goop("\\w",r.thePattern)); - Bracket b = new Bracket(false); - b.addOr(new Range('a', 'z')); - b.addOr(new Range('A', 'Z')); - b.addOr(new Range('0', '9')); - b.addOr(new oneChar('_')); - add(b); - } - else if (sp.dontMatch && sp.c == 'G') - { - add(new BackG()); - } - else if (sp.dontMatch && sp.c == 's') - { - // Regex r = new Regex(); - // r._compile("[ \t\n\r\b]",mk); - // add(new Goop("\\s",r.thePattern)); - Bracket b = new Bracket(false); - b.addOr(new oneChar((char) 32)); - b.addOr(new Range((char) 8, (char) 10)); - b.addOr(new oneChar((char) 13)); - add(b); - } - else if (sp.dontMatch && sp.c == 'd') - { - // Regex r = new Regex(); - // r._compile("[0-9]",mk); - // add(new Goop("\\d",r.thePattern)); - Range digit = new Range('0', '9'); - digit.printBrackets = true; - add(digit); - } - else if (sp.dontMatch && sp.c == 'W') - { - // Regex r = new Regex(); - // r._compile("[^a-zA-Z0-9_]",mk); - // add(new Goop("\\W",r.thePattern)); - Bracket b = new Bracket(true); - b.addOr(new Range('a', 'z')); - b.addOr(new Range('A', 'Z')); - b.addOr(new Range('0', '9')); - b.addOr(new oneChar('_')); - add(b); - } - else if (sp.dontMatch && sp.c == 'S') - { - // Regex r = new Regex(); - // r._compile("[^ \t\n\r\b]",mk); - // add(new Goop("\\S",r.thePattern)); - Bracket b = new Bracket(true); - b.addOr(new oneChar((char) 32)); - b.addOr(new Range((char) 8, (char) 10)); - b.addOr(new oneChar((char) 13)); - add(b); - } - else if (sp.dontMatch && sp.c == 'D') - { - // Regex r = new Regex(); - // r._compile("[^0-9]",mk); - // add(new Goop("\\D",r.thePattern)); - Bracket b = new Bracket(true); - b.addOr(new Range('0', '9')); - add(b); - } - else if (sp.dontMatch && sp.c == 'B') - { - Regex r = new Regex(); - r._compile2("(?!" + back_slash + "b)", mk); - add(r.thePattern); - } - else if (isOctalString(sp)) - { - int d = sp.c - '0'; - sp.inc(); - d = 8 * d + sp.c - '0'; - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if (isOctalDigit(sp2, false)) - { - sp.inc(); - d = 8 * d + sp.c - '0'; - } - add(new oneChar((char) d)); - } - else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') - { - int iv = sp.c - '0'; - StrPos s2 = new StrPos(sp); - s2.inc(); - if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') - { - iv = 10 * iv + (s2.c - '0'); - sp.inc(); - } - add(new BackMatch(iv)); - } - else if (sp.dontMatch && sp.c == 'b') - { - add(new Boundary()); - } - else if (sp.match('\b')) - { - add(new Boundary()); - } - else if (sp.match('$')) - { - add(new End(true)); - } - else if (sp.dontMatch && sp.c == 'Z') - { - add(new End(false)); - } - else if (sp.match('.')) - { - add(new Any()); - } - else if (sp.incMatch("(??")) - { - javajs.util.SB sb = new javajs.util.SB(); - javajs.util.SB sb2 = new javajs.util.SB(); - while (!sp.match(')') && !sp.match(':')) - { - sb.appendC(sp.c); - sp.inc(); - } - if (sp.incMatch(":")) - { - while (!sp.match(')')) - { - sb2.appendC(sp.c); - sp.inc(); - } - } - String sbs = sb.toString(); - if (validators.get(sbs) instanceof String) - { - String pat = (String) validators.get(sbs); - Regex r = newRegex(); - Rthings rth = new Rthings(this); - rth.noBackRefs = true; - r._compile2(pat, rth); - add(r.thePattern); - } - else - { - Custom cm = new Custom(sb.toString()); - if (cm.v != null) - { - Validator v2 = cm.v.arg(sb2.toString()); - if (v2 != null) - { - v2.argsave = sb2.toString(); - String p = cm.v.pattern; - cm.v = v2; - v2.pattern = p; - } - Regex r = newRegex(); - Rthings rth = new Rthings(this); - rth.noBackRefs = true; - r._compile2(cm.v.pattern, rth); - cm.sub = r.thePattern; - cm.sub.add(new CustomEndpoint(cm)); - cm.sub.setParent(cm); - add(cm); - } - } - } - else if (sp.match('(')) - { - mk.parenLevel++; - Regex r = newRegex(); - // r.or = new Or(); - sp.inc(); - if (sp.incMatch("?:")) - { - r.or = new Or(); - } - else if (sp.incMatch("?=")) - { - r.or = new lookAhead(false); - } - else if (sp.incMatch("?!")) - { - r.or = new lookAhead(true); - } - else if (sp.match('?')) - { - sp.inc(); - do - { - if (sp.c == 'i') - { - mk.ignoreCase = true; - } - if (sp.c == 'Q') - { - mk.dontMatchInQuotes = true; - } - if (sp.c == 'o') - { - mk.optimizeMe = true; - } - if (sp.c == 'g') - { - mk.gFlag = true; - } - if (sp.c == 's') - { - mk.sFlag = true; - } - if (sp.c == 'm') - { - mk.mFlag = true; - } - sp.inc(); - } while (!sp.match(')') && !sp.eos); - r = null; - mk.parenLevel--; - if (sp.eos) // throw new RegSyntax - { - RegSyntaxError.endItAll("Unclosed ()"); - } - } - else - { // just ordinary parenthesis - r.or = mk.noBackRefs ? new Or() : new OrMark(mk.val++); - } - if (r != null) - { - add(r._compile1(sp, mk)); - } - } - else if (sp.match('^')) - { - add(new Start(true)); - } - else if (sp.dontMatch && sp.c == 'A') - { - add(new Start(false)); - } - else if (sp.match('*')) - { - addMulti(new patInt(0), new patInf()); - } - else if (sp.match('+')) - { - addMulti(new patInt(1), new patInf()); - } - else if (sp.match('?')) - { - addMulti(new patInt(0), new patInt(1)); - } - else if (sp.match('{')) - { - boolean bad = false; - StrPos sp2 = new StrPos(sp); - // javajs.util.SB sb = new javajs.util.SB(); - sp.inc(); - patInt i1 = sp.getPatInt(); - patInt i2 = null; - if (sp.match('}')) - { - i2 = i1; - } - else - { - if (!sp.match(',')) - { - /* - * RegSyntaxError.endItAll( "String \"{"+i2+ "\" should be followed - * with , or }"); - */ - bad = true; - } - sp.inc(); - if (sp.match('}')) - { - i2 = new patInf(); - } - else - { - i2 = sp.getPatInt(); - } - } - if (i1 == null || i2 == null) - { - /* - * throw new RegSyntax("Badly formatted Multi: " +"{"+i1+","+i2+"}"); - */ - bad = true; - } - if (bad) - { - sp.dup(sp2); - add(new oneChar(sp.c)); - } - else - { - addMulti(i1, i2); - } - } - else if (sp.escMatch('x') && next2Hex(sp)) - { - sp.inc(); - int d = getHexDigit(sp); - sp.inc(); - d = 16 * d + getHexDigit(sp); - add(new oneChar((char) d)); - } - else if (sp.escMatch('c')) - { - sp.inc(); - if (sp.c < Ctrl.cmap.length) - { - add(new oneChar(Ctrl.cmap[sp.c])); - } - else - { - add(new oneChar(sp.c)); - } - } - else if (sp.escMatch('f')) - { - add(new oneChar((char) 12)); - } - else if (sp.escMatch('a')) - { - add(new oneChar((char) 7)); - } - else if (sp.escMatch('t')) - { - add(new oneChar('\t')); - } - else if (sp.escMatch('n')) - { - add(new oneChar('\n')); - } - else if (sp.escMatch('r')) - { - add(new oneChar('\r')); - } - else if (sp.escMatch('b')) - { - add(new oneChar('\b')); - } - else if (sp.escMatch('e')) - { - add(new oneChar((char) 27)); - } - else - { - add(new oneChar(sp.c)); - if (sp.match(')')) - { - RegSyntaxError.endItAll("Unmatched right paren in pattern"); - } - } - } - - // compiles all Pattern elements, internal method - private Pattern _compile2(String pat, Rthings mk) throws RegSyntax - { - minMatch = null; - sFlag = mFlag = ignoreCase = gFlag = false; - StrPos sp = new StrPos(pat, 0); - thePattern = _compile1(sp, mk); - pt.marks = null; - return thePattern; - } - - Pattern p = null; - - Or or = null; - - Pattern _compile1(StrPos sp, Rthings mk) throws RegSyntax - { - while (!(sp.eos || (or != null && sp.match(')')))) - { - compile1(sp, mk); - sp.inc(); - } - if (sp.match(')')) - { - mk.parenLevel--; - } - else if (sp.eos && mk.parenLevel != 0) - { - RegSyntaxError.endItAll("Unclosed Parenthesis! lvl=" + mk.parenLevel); - } - if (or != null) - { - if (p == null) - { - p = new NullPattern(); - } - or.addOr(p); - return or; - } - return p == null ? new NullPattern() : p; - } - - // add a multi object to the end of the chain - // which applies to the last object - void addMulti(patInt i1, patInt i2) throws RegSyntax - { - Pattern last, last2; - for (last = p; last != null && last.next != null; last = last.next) - { - ; - } - if (last == null || last == p) - { - last2 = null; - } - else - { - for (last2 = p; last2.next != last; last2 = last2.next) - { - ; - } - } - if (last instanceof Multi && i1.intValue() == 0 && i2.intValue() == 1) - { - ((Multi) last).matchFewest = true; - } - else if (last instanceof FastMulti && i1.intValue() == 0 - && i2.intValue() == 1) - { - ((FastMulti) last).matchFewest = true; - } - else if (last instanceof DotMulti && i1.intValue() == 0 - && i2.intValue() == 1) - { - ((DotMulti) last).matchFewest = true; - } - else if (last instanceof Multi || last instanceof DotMulti - || last instanceof FastMulti) - { - throw new RegSyntax("Syntax error."); - } - else if (last2 == null) - { - p = mkMulti(i1, i2, p); - } - else - { - last2.next = mkMulti(i1, i2, last); - } - } - - final static Pattern mkMulti(patInt lo, patInt hi, Pattern p) - throws RegSyntax - { - if (p instanceof Any && p.next == null) - { - return (Pattern) new DotMulti(lo, hi); - } - return RegOpt.safe4fm(p) ? (Pattern) new FastMulti(lo, hi, p) - : (Pattern) new Multi(lo, hi, p); - } - - // process the bracket operator - Pattern matchBracket(StrPos sp) throws RegSyntax - { - Bracket ret; - if (sp.match('^')) - { - ret = new Bracket(true); - sp.inc(); - } - else - { - ret = new Bracket(false); - } - if (sp.match(']')) - { - // throw new RegSyntax - RegSyntaxError.endItAll("Unmatched []"); - } - - while (!sp.eos && !sp.match(']')) - { - StrPos s1 = new StrPos(sp); - s1.inc(); - StrPos s1_ = new StrPos(s1); - s1_.inc(); - if (s1.match('-') && !s1_.match(']')) - { - StrPos s2 = new StrPos(s1); - s2.inc(); - if (!s2.eos) - { - ret.addOr(new Range(sp.c, s2.c)); - } - sp.inc(); - sp.inc(); - } - else if (sp.escMatch('Q')) - { - sp.inc(); - while (!sp.escMatch('E')) - { - ret.addOr(new oneChar(sp.c)); - sp.inc(); - } - } - else if (sp.escMatch('d')) - { - ret.addOr(new Range('0', '9')); - } - else if (sp.escMatch('s')) - { - ret.addOr(new oneChar((char) 32)); - ret.addOr(new Range((char) 8, (char) 10)); - ret.addOr(new oneChar((char) 13)); - } - else if (sp.escMatch('w')) - { - ret.addOr(new Range('a', 'z')); - ret.addOr(new Range('A', 'Z')); - ret.addOr(new Range('0', '9')); - ret.addOr(new oneChar('_')); - } - else if (sp.escMatch('D')) - { - ret.addOr(new Range((char) 0, (char) 47)); - ret.addOr(new Range((char) 58, (char) 65535)); - } - else if (sp.escMatch('S')) - { - ret.addOr(new Range((char) 0, (char) 7)); - ret.addOr(new Range((char) 11, (char) 12)); - ret.addOr(new Range((char) 14, (char) 31)); - ret.addOr(new Range((char) 33, (char) 65535)); - } - else if (sp.escMatch('W')) - { - ret.addOr(new Range((char) 0, (char) 64)); - ret.addOr(new Range((char) 91, (char) 94)); - ret.addOr(new oneChar((char) 96)); - ret.addOr(new Range((char) 123, (char) 65535)); - } - else if (sp.escMatch('x') && next2Hex(sp)) - { - sp.inc(); - int d = getHexDigit(sp); - sp.inc(); - d = 16 * d + getHexDigit(sp); - ret.addOr(new oneChar((char) d)); - } - else if (sp.escMatch('a')) - { - ret.addOr(new oneChar((char) 7)); - } - else if (sp.escMatch('f')) - { - ret.addOr(new oneChar((char) 12)); - } - else if (sp.escMatch('e')) - { - ret.addOr(new oneChar((char) 27)); - } - else if (sp.escMatch('n')) - { - ret.addOr(new oneChar('\n')); - } - else if (sp.escMatch('t')) - { - ret.addOr(new oneChar('\t')); - } - else if (sp.escMatch('r')) - { - ret.addOr(new oneChar('\r')); - } - else if (sp.escMatch('c')) - { - sp.inc(); - if (sp.c < Ctrl.cmap.length) - { - ret.addOr(new oneChar(Ctrl.cmap[sp.c])); - } - else - { - ret.addOr(new oneChar(sp.c)); - } - } - else if (isOctalString(sp)) - { - int d = sp.c - '0'; - sp.inc(); - d = 8 * d + sp.c - '0'; - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if (isOctalDigit(sp2, false)) - { - sp.inc(); - d = 8 * d + sp.c - '0'; - } - ret.addOr(new oneChar((char) d)); - } - else - { - ret.addOr(new oneChar(sp.c)); - } - sp.inc(); - } - return ret; - } - - /** - * Converts the stored Pattern to a String -- this is a decompile. Note that - * \t and \n will really print out here, Not just the two character - * representations. Also be prepared to see some strange output if your - * characters are not printable. - */ - public String toString() - { - if (false && thePattern == null) - { - return ""; - } - else - { - javajs.util.SB sb = new javajs.util.SB(); - if (esc != Pattern.ESC) - { - sb.append("(?e="); - sb.appendC(esc); - sb.append(")"); - } - if (gFlag || mFlag || !dotDoesntMatchCR || sFlag || ignoreCase - || dontMatchInQuotes || optimized()) - { - sb.append("(?"); - if (ignoreCase) - { - sb.append("i"); - } - if (mFlag) - { - sb.append("m"); - } - if (sFlag || !dotDoesntMatchCR) - { - sb.append("s"); - } - if (dontMatchInQuotes) - { - sb.append("Q"); - } - if (optimized()) - { - sb.append("o"); - } - if (gFlag) - { - sb.append("g"); - } - sb.append(")"); - } - String patstr = thePattern.toString(); - if (esc != Pattern.ESC) - { - patstr = reEscape(patstr, Pattern.ESC, esc); - } - sb.append(patstr); - return sb.toString(); - } - } - - // Re-escape Pattern, allows us to use a different escape - // character. - static String reEscape(String s, char oldEsc, char newEsc) - { - if (oldEsc == newEsc) - { - return s; - } - int i; - javajs.util.SB sb = new javajs.util.SB(); - for (i = 0; i < s.length(); i++) - { - if (s.charAt(i) == oldEsc && i + 1 < s.length()) - { - if (s.charAt(i + 1) == oldEsc) - { - sb.appendC(oldEsc); - } - else - { - sb.appendC(newEsc); - sb.appendC(s.charAt(i + 1)); - } - i++; - } - else if (s.charAt(i) == newEsc) - { - sb.appendC(newEsc); - sb.appendC(newEsc); - } - else - { - sb.appendC(s.charAt(i)); - } - } - return sb.toString(); - } - -// /** -// * This method implements FilenameFilter, allowing one to use a Regex to -// * search through a directory using File.list. There is a FileRegex now that -// * does this better. -// * -// * @see com.stevesoft.pat.FileRegex -// */ -// public boolean accept(File dir, String s) -// { -// return search(s); -// } - - /** The version of this package */ - final static public String version() - { - return "lgpl release 1.5.3"; - } - - /** - * Once this method is called, the state of variables ignoreCase and - * dontMatchInQuotes should not be changed as the results will be - * unpredictable. However, search and matchAt will run more quickly. Note that - * you can check to see if the pattern has been optimized by calling the - * optimized() method. - *

    - * This method will attempt to rewrite your pattern in a way that makes it - * faster (not all patterns execute at the same speed). In general, "(?: ... )" - * will be faster than "( ... )" so if you don't need the backreference, you - * should group using the former pattern. - *

    - * It will also introduce new pattern elements that you can't get to - * otherwise, for example if you have a large table of strings, i.e. the - * months of the year "(January|February|...)" optimize() will make a - * Hashtable that takes it to the next appropriate pattern element -- - * eliminating the need for a linear search. - * - * @see com.stevesoft.pat.Regex#optimized - * @see com.stevesoft.pat.Regex#ignoreCase - * @see com.stevesoft.pat.Regex#dontMatchInQuotes - * @see com.stevesoft.pat.Regex#matchAt - * @see com.stevesoft.pat.Regex#search - */ - public void optimize() - { - if (optimized() || thePattern == null) - { - return; - } - minMatch = new patInt(0); // thePattern.countMinChars(); - thePattern = RegOpt.opt(thePattern, ignoreCase, dontMatchInQuotes); - skipper = Skip.findSkip(this); - // RegOpt.setParents(this); - return; - } - - Skip skipper; - - /** - * This function returns true if the optimize method has been called. - */ - public boolean optimized() - { - return minMatch != null; - } - - /** - * A bit of syntactic surgar for those who want to make their code look more - * perl-like. To use this initialize your Regex object by saying: - * - *

    -   *       Regex r1 = Regex.perlCode("s/hello/goodbye/");
    -   *       Regex r2 = Regex.perlCode("s'fish'frog'i");
    -   *       Regex r3 = Regex.perlCode("m'hello');
    -   * 
    - * - * The i for ignoreCase is supported in this syntax, as well as m, s, and x. - * The g flat is a bit of a special case. - *

    - * If you wish to replace all occurences of a pattern, you do not put a 'g' in - * the perlCode, but call Regex's replaceAll method. - *

    - * If you wish to simply and only do a search for r2's pattern, you can do - * this by calling the searchFrom method method repeatedly, or by calling - * search repeatedly if the g flag is set. - *

    - * Note: Currently perlCode does not support the (?e=#) syntax for - * changing the escape character. - */ - - public static Regex perlCode(String s) - { - // this file is big enough, see parsePerl.java - // for this function. - return parsePerl.parse(s); - } - - static final char back_slash = '\\'; - - /** - * Checks to see if there are only literal and no special pattern elements in - * this Regex. - */ - public boolean isLiteral() - { - Pattern x = thePattern; - while (x != null) - { - if (x instanceof oneChar) - { - ; - } - else if (x instanceof Skipped) - { - ; - } - else - { - return false; - } - x = x.next; - } - return true; - } - - /** - * You only need to know about this if you are inventing your own pattern - * elements. - */ - public patInt countMinChars() - { - return thePattern.countMinChars(); - } - - /** - * You only need to know about this if you are inventing your own pattern - * elements. - */ - public patInt countMaxChars() - { - return thePattern.countMaxChars(); - } - - boolean isHexDigit(StrPos sp) - { - boolean r = !sp.eos - && !sp.dontMatch - && ((sp.c >= '0' && sp.c <= '9') - || (sp.c >= 'a' && sp.c <= 'f') || (sp.c >= 'A' && sp.c <= 'F')); - return r; - } - - boolean isOctalDigit(StrPos sp, boolean first) - { - boolean r = !sp.eos && !(first ^ sp.dontMatch) && sp.c >= '0' - && sp.c <= '7'; - return r; - } - - int getHexDigit(StrPos sp) - { - if (sp.c >= '0' && sp.c <= '9') - { - return sp.c - '0'; - } - if (sp.c >= 'a' && sp.c <= 'f') - { - return sp.c - 'a' + 10; - } - return sp.c - 'A' + 10; - } - - boolean next2Hex(StrPos sp) - { - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if (!isHexDigit(sp2)) - { - return false; - } - sp2.inc(); - if (!isHexDigit(sp2)) - { - return false; - } - return true; - } - - boolean isOctalString(StrPos sp) - { - if (!isOctalDigit(sp, true)) - { - return false; - } - StrPos sp2 = new StrPos(sp); - sp2.inc(); - if (!isOctalDigit(sp2, false)) - { - return false; - } - return true; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import jalview.util.MessageManager; + +import java.util.BitSet; +import java.util.Hashtable; + +import com.stevesoft.pat.wrap.StringWrap; + +/** Matches a Unicode punctuation character. */ +class UnicodePunct extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && Prop.isPunct(s.charAt(from)) ? to : -1; + } +} + +/** Matches a Unicode white space character. */ +class UnicodeWhite extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && Prop.isWhite(s.charAt(from)) ? to : -1; + } +} + +/** + * Matches a character that is not a Unicode punctuation character. + */ +class NUnicodePunct extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && !Prop.isPunct(s.charAt(from)) ? to : -1; + } +} + +/** + * Matches a character that is not a Unicode white space character. + */ +class NUnicodeWhite extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && !Prop.isWhite(s.charAt(from)) ? to : -1; + } +} + +/** Matches a Unicode word character: an alphanumeric or underscore. */ +class UnicodeW extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + if (from >= s.length()) + { + return -1; + } + char c = s.charAt(from); + return (Prop.isAlphabetic(c) || Prop.isDecimalDigit(c) || c == '_') ? to + : -1; + } +} + +/** Matches a character that is not a Unicode alphanumeric or underscore. */ +class NUnicodeW extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + if (from >= s.length()) + { + return -1; + } + char c = s.charAt(from); + return !(Prop.isAlphabetic(c) || Prop.isDecimalDigit(c) || c == '_') ? to + : -1; + } +} + +/** Matches a Unicode decimal digit. */ +class UnicodeDigit extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && Prop.isDecimalDigit(s.charAt(from)) ? to + : -1; + } +} + +/** Matches a character that is not a Unicode digit. */ +class NUnicodeDigit extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && !Prop.isDecimalDigit(s.charAt(from)) ? to + : -1; + } +} + +/** Matches a Unicode math character. */ +class UnicodeMath extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && Prop.isMath(s.charAt(from)) ? to : -1; + } +} + +/** Matches a non-math Unicode character. */ +class NUnicodeMath extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && !Prop.isMath(s.charAt(from)) ? to : -1; + } +} + +/** Matches a Unicode currency symbol. */ +class UnicodeCurrency extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && Prop.isCurrency(s.charAt(from)) ? to : -1; + } +} + +/** Matches a non-currency symbol Unicode character. */ +class NUnicodeCurrency extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && !Prop.isCurrency(s.charAt(from)) ? to : -1; + } +} + +/** Matches a Unicode alphabetic character. */ +class UnicodeAlpha extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && Prop.isAlphabetic(s.charAt(from)) ? to : -1; + } +} + +/** Matches a non-alphabetic Unicode character. */ +class NUnicodeAlpha extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && !Prop.isAlphabetic(s.charAt(from)) ? to + : -1; + } +} + +/** Matches an upper case Unicode character. */ +class UnicodeUpper extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && isUpper(s.charAt(from)) ? to : -1; + } + + final boolean isUpper(char c) + { + return c == CaseMgr.toUpperCase(c) && c != CaseMgr.toLowerCase(c); + } +} + +/** Matches an upper case Unicode character. */ +class UnicodeLower extends UniValidator +{ + public int validate(StringLike s, int from, int to) + { + return from < s.length() && isLower(s.charAt(from)) ? to : -1; + } + + final boolean isLower(char c) + { + return c != CaseMgr.toUpperCase(c) && c == CaseMgr.toLowerCase(c); + } +} + +/** + * Regex provides the parser which constructs the linked list of Pattern classes + * from a String. + *

    + * For the purpose of this documentation, the fact that java interprets the + * backslash will be ignored. In practice, however, you will need a double + * backslash to obtain a string that contains a single backslash character. + * Thus, the example pattern "\b" should really be typed as "\\b" inside java + * code. + *

    + * Note that Regex is part of package "com.stevesoft.pat". To use it, simply + * import com.stevesoft.pat.Regex at the top of your file. + *

    + * Regex is made with a constructor that takes a String that defines the regular + * expression. Thus, for example + * + *

    + * Regex r = new Regex("[a-c]*");
    + * 
    + * + * matches any number of characters so long as the are 'a', 'b', or 'c'). + *

    + * To attempt to match the Pattern to a given string, you can use either the + * search(String) member function, or the matchAt(String,int position) member + * function. These functions return a boolean which tells you whether or not the + * thing worked, and sets the methods "charsMatched()" and "matchedFrom()" in + * the Regex object appropriately. + *

    + * The portion of the string before the match can be obtained by the left() + * member, and the portion after the match can be obtained by the right() + * member. + *

    + * Essentially, this package implements a syntax that is very much like the perl + * 5 regular expression syntax. + * + * Longer example: + * + *

    + * Regex r = new Regex("x(a|b)y");
    + * r.matchAt("xay", 0);
    + * System.out.println("sub = " + r.stringMatched(1));
    + * 
    + * + * The above would print "sub = a". + * + *
    + *  r.left() // would return "x"
    + *  r.right() // would return "y"
    + * 
    + * + *

    + * Differences between this package and perl5:
    + * The extended Pattern for setting flags, is now supported, but the flags are + * different. "(?i)" tells the pattern to ignore case, "(?Q)" sets the + * "dontMatchInQuotes" flag, and "(?iQ)" sets them both. You can change the + * escape character. The pattern + * + *

    + * (?e=#)#d+
    + * 
    + * + * is the same as + * + *
    + * \d+
    + * 
    , but note that the sequence + * + *
    + * (?e=#)
    + * 
    + * + * must occur at the very beginning of the pattern. There may be other + * small differences as well. I will either make my package conform or note them + * as I become aware of them. + *

    + * This package supports additional patterns not in perl5:

    + * + * + * + * + * + * + * + * + *
    (?@())GroupThis matches all characters between the '(' character and the balancing + * ')' character. Thus, it will match "()" as well as "(())". The balancing + * characters are arbitrary, thus (?@{}) matches on "{}" and "{{}}".
    (?<1)BackupMoves the pointer backwards within the text. This allows you to make a + * "look behind." It fails if it attempts to move to a position before the + * beginning of the string. "x(?<1)" is equivalent to "(?=x)". The number, 1 + * in this example, is the number of characters to move backwards.
    + * + * + * @author Steven R. Brandt + * @version package com.stevesoft.pat, release 1.5.3 + * @see Pattern + */ +public class Regex extends RegRes// implements FilenameFilter +{ + /** + * BackRefOffset gives the identity number of the first pattern. Version 1.0 + * used zero, version 1.1 uses 1 to be more compatible with perl. + */ + static int BackRefOffset = 1; + + private static Pattern none = new NoPattern(); + + Pattern thePattern = none; + + patInt minMatch = new patInt(0); + + static Hashtable validators = new Hashtable(); + static + { + define("p", "(?>1)", new UnicodePunct()); + define("P", "(?>1)", new NUnicodePunct()); + define("s", "(?>1)", new UnicodeWhite()); + define("S", "(?>1)", new NUnicodeWhite()); + define("w", "(?>1)", new UnicodeW()); + define("W", "(?>1)", new NUnicodeW()); + define("d", "(?>1)", new UnicodeDigit()); + define("D", "(?>1)", new NUnicodeDigit()); + define("m", "(?>1)", new UnicodeMath()); + define("M", "(?>1)", new NUnicodeMath()); + define("c", "(?>1)", new UnicodeCurrency()); + define("C", "(?>1)", new NUnicodeCurrency()); + define("a", "(?>1)", new UnicodeAlpha()); + define("A", "(?>1)", new NUnicodeAlpha()); + define("uc", "(?>1)", new UnicodeUpper()); + define("lc", "(?>1)", new UnicodeLower()); + } + + /** Set the dontMatch in quotes flag. */ + public void setDontMatchInQuotes(boolean b) + { + dontMatchInQuotes = b; + } + + /** Find out if the dontMatchInQuotes flag is enabled. */ + public boolean getDontMatchInQuotes() + { + return dontMatchInQuotes; + } + + boolean dontMatchInQuotes = false; + + /** + * Set the state of the ignoreCase flag. If set to true, then the pattern + * matcher will ignore case when searching for a match. + */ + public void setIgnoreCase(boolean b) + { + ignoreCase = b; + } + + /** + * Get the state of the ignoreCase flag. Returns true if we are ignoring the + * case of the pattern, false otherwise. + */ + public boolean getIgnoreCase() + { + return ignoreCase; + } + + boolean ignoreCase = false; + + static boolean defaultMFlag = false; + + /** + * Set the default value of the m flag. If it is set to true, then the MFlag + * will be on for any regex search executed. + */ + public static void setDefaultMFlag(boolean mFlag) + { + defaultMFlag = mFlag; + } + + /** + * Get the default value of the m flag. If it is set to true, then the MFlag + * will be on for any regex search executed. + */ + public static boolean getDefaultMFlag() + { + return defaultMFlag; + } + + /** + * Initializes the object without a Pattern. To supply a Pattern use + * compile(String s). + * + * @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex() + { + } + + /** + * Create and compile a Regex, but do not throw any exceptions. If you wish to + * have exceptions thrown for syntax errors, you must use the Regex(void) + * constructor to create the Regex object, and then call the compile method. + * Therefore, you should only call this method when you know your pattern is + * right. I will probably become more like + * + * @see com.stevesoft.pat.Regex#search(java.lang.String) + * @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex(String s) + { + try + { + compile(s); + } catch (RegSyntax rs) + { + } + } + + ReplaceRule rep = null; + + /** + * Create and compile both a Regex and a ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex(String s, String rp) + { + this(s); + rep = parsePerl.perlCode(rp); + } + + /** + * Create and compile a Regex, but give it the ReplaceRule specified. This + * allows the user finer control of the Replacement process, if that is + * desired. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#compile(java.lang.String) + */ + public Regex(String s, ReplaceRule rp) + { + this(s); + rep = rp; + } + + /** + * Change the ReplaceRule of this Regex by compiling a new one using String + * rp. + */ + public void setReplaceRule(String rp) + { + rep = parsePerl.perlCode(rp); + repr = null; // Clear Replacer history + } + + /** Change the ReplaceRule of this Regex to rp. */ + public void setReplaceRule(ReplaceRule rp) + { + rep = rp; + } + + /** + * Test to see if a custom defined rule exists. + * + * @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) + */ + public static boolean isDefined(String nm) + { + return validators.get(nm) != null; + } + + /** + * Removes a custom defined rule. + * + * @see com.stevesoft.pat#define(java.lang.String,java.lang.String,Validator) + */ + public static void undefine(String nm) + { + validators.remove(nm); + } + + /** + * Defines a method to create a new rule. See test/deriv2.java and + * test/deriv3.java for examples of how to use it. + */ + public static void define(String nm, String pat, Validator v) + { + v.pattern = pat; + validators.put(nm, v); + } + + /** + * Defines a shorthand for a pattern. The pattern will be invoked by a string + * that has the form "(??"+nm+")". + */ + public static void define(String nm, String pat) + { + validators.put(nm, pat); + } + + /** Get the current ReplaceRule. */ + public ReplaceRule getReplaceRule() + { + return rep; + } + + Replacer repr = null; + + final Replacer _getReplacer() + { + return repr == null ? repr = new Replacer() : repr; + } + + public Replacer getReplacer() + { + if (repr == null) + { + repr = new Replacer(); + } + repr.rh.me = this; + repr.rh.prev = null; + return repr; + } + + /** + * Replace the first occurence of this pattern in String s according to the + * ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceFirst(String s) + { + return _getReplacer().replaceFirstRegion(s, this, 0, s.length()) + .toString(); + } + + /** + * Replace the first occurence of this pattern in String s beginning with + * position pos according to the ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceFirstFrom(String s, int pos) + { + return _getReplacer().replaceFirstRegion(s, this, pos, s.length()) + .toString(); + } + + /** + * Replace the first occurence of this pattern in String s beginning with + * position start and ending with end according to the ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceFirstRegion(String s, int start, int end) + { + return _getReplacer().replaceFirstRegion(s, this, start, end) + .toString(); + } + + /** + * Replace all occurences of this pattern in String s according to the + * ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceAll(String s) + { + return _getReplacer().replaceAllRegion(s, this, 0, s.length()) + .toString(); + } + + public StringLike replaceAll(StringLike s) + { + return _getReplacer().replaceAllRegion(s, this, 0, s.length()); + } + + /** + * Replace all occurences of this pattern in String s beginning with position + * pos according to the ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceAllFrom(String s, int pos) + { + return _getReplacer().replaceAllRegion(s, this, pos, s.length()) + .toString(); + } + + /** + * Replace all occurences of this pattern in String s beginning with position + * start and ending with end according to the ReplaceRule. + * + * @see com.stevesoft.pat.ReplaceRule + * @see com.stevesoft.pat.Regex#getReplaceRule() + */ + public String replaceAllRegion(String s, int start, int end) + { + return _getReplacer().replaceAllRegion(s, this, start, end).toString(); + } + + /** Essentially clones the Regex object */ + public Regex(Regex r) + { + super((RegRes) r); + dontMatchInQuotes = r.dontMatchInQuotes; + esc = r.esc; + ignoreCase = r.ignoreCase; + gFlag = r.gFlag; + if (r.rep == null) + { + rep = null; + } + else + { + rep = (ReplaceRule) r.rep.clone(); + } + /* + * try { compile(r.toString()); } catch(RegSyntax r_) {} + */ + thePattern = r.thePattern.clone(new Hashtable()); + minMatch = r.minMatch; + skipper = r.skipper; + } + + /** + * By default, the escape character is the backslash, but you can make it + * anything you want by setting this variable. + */ + public char esc = Pattern.ESC; + + /** + * This method compiles a regular expression, making it possible to call the + * search or matchAt methods. + * + * @exception com.stevesoft.pat.RegSyntax + * is thrown if a syntax error is encountered in the + * pattern. For example, "x{3,1}" or "*a" are not valid + * patterns. + * @see com.stevesoft.pat.Regex#search + * @see com.stevesoft.pat.Regex#matchAt + */ + public void compile(String prepat) throws RegSyntax + { + String postpat = parsePerl.codify(prepat, true); + String pat = postpat == null ? prepat : postpat; + minMatch = null; + ignoreCase = false; + dontMatchInQuotes = false; + Rthings mk = new Rthings(this); + int offset = mk.val; + String newpat = pat; + thePattern = none; + p = null; + or = null; + minMatch = new patInt(0); + StrPos sp = new StrPos(pat, 0); + if (sp.incMatch("(?e=")) + { + char newEsc = sp.c; + sp.inc(); + if (sp.match(')')) + { + newpat = reEscape(pat.substring(6), newEsc, Pattern.ESC); + } + } + else if (esc != Pattern.ESC) + { + newpat = reEscape(pat, esc, Pattern.ESC); + } + thePattern = _compile2(newpat, mk); + numSubs_ = mk.val - offset; + mk.set(this); + } + + /* + * If a Regex is compared against a Regex, a check is done to see that the + * patterns are equal as well as the most recent match. If a Regex is compare + * with a RegRes, only the result of the most recent match is compared. + */ + public boolean equals(Object o) + { + if (o instanceof Regex) + { + if (toString().equals(o.toString())) + { + return super.equals(o); + } + else + { + return false; + } + } + else + { + return super.equals(o); + } + } + + /** A clone by any other name would smell as sweet. */ + public Object clone() + { + return new Regex(this); + } + + /** Return a clone of the underlying RegRes object. */ + public RegRes result() + { + return (RegRes) super.clone(); + } + + // prep sets global variables of class + // Pattern so that it can access them + // during an attempt at a match + Pthings pt = new Pthings(); + + final Pthings prep(StringLike s) + { + // if(gFlag) + pt.lastPos = matchedTo(); + if (pt.lastPos < 0) + { + pt.lastPos = 0; + } + if ((s == null ? null : s.unwrap()) != (src == null ? null : s.unwrap())) + { + pt.lastPos = 0; + } + src = s; + pt.dotDoesntMatchCR = dotDoesntMatchCR && (!sFlag); + pt.mFlag = (mFlag | defaultMFlag); + pt.ignoreCase = ignoreCase; + pt.no_check = false; + if (pt.marks != null) + { + for (int i = 0; i < pt.marks.length; i++) + { + pt.marks[i] = -1; + } + } + pt.marks = null; + pt.nMarks = numSubs_; + pt.src = s; + if (dontMatchInQuotes) + { + setCbits(s, pt); + } + else + { + pt.cbits = null; + } + return pt; + } + + /** + * Attempt to match a Pattern beginning at a specified location within the + * string. + * + * @see com.stevesoft.pat.Regex#search + */ + public boolean matchAt(String s, int start_pos) + { + return _search(s, start_pos, start_pos); + } + + /** + * Attempt to match a Pattern beginning at a specified location within the + * StringLike. + * + * @see com.stevesoft.pat.Regex#search + */ + public boolean matchAt(StringLike s, int start_pos) + { + return _search(s, start_pos, start_pos); + } + + /** + * Search through a String for the first occurrence of a match. + * + * @see com.stevesoft.pat.Regex#searchFrom + * @see com.stevesoft.pat.Regex#matchAt + */ + public boolean search(String s) + { + if (s == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_given_to_regex_search")); + } + return _search(s, 0, s.length()); + } + + public boolean search(StringLike sl) + { + if (sl == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search")); + } + return _search(sl, 0, sl.length()); + } + + public boolean reverseSearch(String s) + { + if (s == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_given_to_regex_reverse_search")); + } + return _reverseSearch(s, 0, s.length()); + } + + public boolean reverseSearch(StringLike sl) + { + if (sl == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_reverse_search")); + } + return _reverseSearch(sl, 0, sl.length()); + } + + /** + * Search through a String for the first occurence of a match, but start at + * position + * + *
    +   * start
    +   * 
    + */ + public boolean searchFrom(String s, int start) + { + if (s == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search_from")); + } + return _search(s, start, s.length()); + } + + public boolean searchFrom(StringLike s, int start) + { + if (s == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search_from")); + } + return _search(s, start, s.length()); + } + + /** + * Search through a region of a String for the first occurence of a match. + */ + public boolean searchRegion(String s, int start, int end) + { + if (s == null) + { + throw new NullPointerException(MessageManager.getString("exception.null_string_like_given_to_regex_search_region")); + } + return _search(s, start, end); + } + + /** + * Set this to change the default behavior of the "." pattern. By default it + * now matches perl's behavior and fails to match the '\n' character. + */ + public static boolean dotDoesntMatchCR = true; + + StringLike gFlags; + + int gFlagto = 0; + + boolean gFlag = false; + + /** Set the 'g' flag */ + public void setGFlag(boolean b) + { + gFlag = b; + } + + /** Get the state of the 'g' flag. */ + public boolean getGFlag() + { + return gFlag; + } + + boolean sFlag = false; + + /** Get the state of the sFlag */ + public boolean getSFlag() + { + return sFlag; + } + + boolean mFlag = false; + + /** Get the state of the sFlag */ + public boolean getMFlag() + { + return mFlag; + } + + final boolean _search(String s, int start, int end) + { + return _search(new StringWrap(s), start, end); + } + + final boolean _search(StringLike s, int start, int end) + { + if (gFlag && gFlagto > 0 && gFlags != null + && s.unwrap() == gFlags.unwrap()) + { + start = gFlagto; + } + gFlags = null; + + Pthings pt = prep(s); + + int up = (minMatch == null ? end : end - minMatch.i); + + if (up < start && end >= start) + { + up = start; + } + + if (skipper == null) + { + for (int i = start; i <= up; i++) + { + charsMatched_ = thePattern.matchAt(s, i, pt); + if (charsMatched_ >= 0) + { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_ + charsMatched_; + gFlags = s; + return didMatch_ = true; + } + } + } + else + { + pt.no_check = true; + for (int i = start; i <= up; i++) + { + i = skipper.find(src, i, up); + if (i < 0) + { + charsMatched_ = matchFrom_ = -1; + return didMatch_ = false; + } + charsMatched_ = thePattern.matchAt(s, i, pt); + if (charsMatched_ >= 0) + { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_ + charsMatched_; + gFlags = s; + return didMatch_ = true; + } + } + } + return didMatch_ = false; + } + + /* + * final boolean _search(LongStringLike s,long start,long end) { if(gFlag && + * gFlagto > 0 && s==gFlags) start = gFlagto; gFlags = null; + * + * Pthings pt=prep(s); + * + * int up = end;//(minMatch == null ? end : end-minMatch.i); + * + * if(up < start && end >= start) up = start; + * + * if(skipper == null) { for(long i=start;i<=up;i++) { charsMatched_ = + * thePattern.matchAt(s,i,pt); if(charsMatched_ >= 0) { matchFrom_ = + * thePattern.mfrom; marks = pt.marks; gFlagto = matchFrom_+charsMatched_; + * return didMatch_=true; } } } else { pt.no_check = true; for(long i=start;i<=up;i++) { + * i = skipper.find(src,i,up); if(i<0) { charsMatched_ = matchFrom_ = -1; + * return didMatch_ = false; } charsMatched_ = thePattern.matchAt(s,i,pt); + * if(charsMatched_ >= 0) { matchFrom_ = thePattern.mfrom; marks = pt.marks; + * gFlagto = matchFrom_+charsMatched_; gFlags = s; return didMatch_=true; } + * else { i = s.adjustIndex(i); up = s.adjustEnd(i); } } } return + * didMatch_=false; } + */ + + boolean _reverseSearch(String s, int start, int end) + { + return _reverseSearch(new StringWrap(s), start, end); + } + + boolean _reverseSearch(StringLike s, int start, int end) + { + if (gFlag && gFlagto > 0 && s.unwrap() == gFlags.unwrap()) + { + end = gFlagto; + } + gFlags = null; + Pthings pt = prep(s); + for (int i = end; i >= start; i--) + { + charsMatched_ = thePattern.matchAt(s, i, pt); + if (charsMatched_ >= 0) + { + matchFrom_ = thePattern.mfrom; + marks = pt.marks; + gFlagto = matchFrom_ - 1; + gFlags = s; + return didMatch_ = true; + } + } + return didMatch_ = false; + } + + // This routine sets the cbits variable + // of class Pattern. Cbits is true for + // the bit corresponding to a character inside + // a set of quotes. + static StringLike lasts = null; + + static BitSet lastbs = null; + + static void setCbits(StringLike s, Pthings pt) + { + if (s == lasts) + { + pt.cbits = lastbs; + return; + } + BitSet bs = new BitSet(s.length()); + char qc = ' '; + boolean setBit = false; + for (int i = 0; i < s.length(); i++) + { + if (setBit) + { + bs.set(i); + } + char c = s.charAt(i); + if (!setBit && c == '"') + { + qc = c; + setBit = true; + bs.set(i); + } + else if (!setBit && c == '\'') + { + qc = c; + setBit = true; + bs.set(i); + } + else if (setBit && c == qc) + { + setBit = false; + } + else if (setBit && c == '\\' && i + 1 < s.length()) + { + i++; + if (setBit) + { + bs.set(i); + } + } + } + pt.cbits = lastbs = bs; + lasts = s; + } + + // Wanted user to over-ride this in alpha version, + // but it wasn't really necessary because of this trick: + Regex newRegex() + { + try + { + return (Regex) getClass().newInstance(); + } catch (InstantiationException ie) + { + return null; + } catch (IllegalAccessException iae) + { + return null; + } + } + + /** + * Only needed for creating your own extensions of Regex. This method adds the + * next Pattern in the chain of patterns or sets the Pattern if it is the + * first call. + */ + protected void add(Pattern p2) + { + if (p == null) + { + p = p2; + } + else + { + p.add(p2); + p2 = p; + } + } + + /** + * You only need to use this method if you are creating your own extentions to + * Regex. compile1 compiles one Pattern element, it can be over-ridden to + * allow the Regex compiler to understand new syntax. See deriv.java for an + * example. This routine is the heart of class Regex. Rthings has one integer + * member called intValue, it is used to keep track of the number of ()'s in + * the Pattern. + * + * @exception com.stevesoft.pat.RegSyntax + * is thrown when a nonsensensical pattern is supplied. For + * example, a pattern beginning with *. + */ + protected void compile1(StrPos sp, Rthings mk) throws RegSyntax + { + if (sp.match('[')) + { + sp.inc(); + add(matchBracket(sp)); + } + else if (sp.match('|')) + { + if (or == null) + { + or = new Or(); + } + if (p == null) + { + p = new NullPattern(); + } + or.addOr(p); + p = null; + } + else if (sp.incMatch("(?<")) + { + patInt i = sp.getPatInt(); + if (i == null) + { + RegSyntaxError.endItAll("No int after (?<"); + } + add(new Backup(i.intValue())); + if (!sp.match(')')) + { + RegSyntaxError.endItAll("No ) after (?<"); + } + } + else if (sp.incMatch("(?>")) + { + patInt i = sp.getPatInt(); + if (i == null) + { + RegSyntaxError.endItAll("No int after (?>"); + } + add(new Backup(-i.intValue())); + if (!sp.match(')')) + { + RegSyntaxError.endItAll("No ) after (?<"); + } + } + else if (sp.incMatch("(?@")) + { + char op = sp.c; + sp.inc(); + char cl = sp.c; + sp.inc(); + if (!sp.match(')')) + { + RegSyntaxError.endItAll("(?@ does not have closing paren"); + } + add(new Group(op, cl)); + } + else if (sp.incMatch("(?#")) + { + while (!sp.match(')')) + { + sp.inc(); + } + } + else if (sp.dontMatch && sp.c == 'w') + { + // Regex r = new Regex(); + // r._compile("[a-zA-Z0-9_]",mk); + // add(new Goop("\\w",r.thePattern)); + Bracket b = new Bracket(false); + b.addOr(new Range('a', 'z')); + b.addOr(new Range('A', 'Z')); + b.addOr(new Range('0', '9')); + b.addOr(new oneChar('_')); + add(b); + } + else if (sp.dontMatch && sp.c == 'G') + { + add(new BackG()); + } + else if (sp.dontMatch && sp.c == 's') + { + // Regex r = new Regex(); + // r._compile("[ \t\n\r\b]",mk); + // add(new Goop("\\s",r.thePattern)); + Bracket b = new Bracket(false); + b.addOr(new oneChar((char) 32)); + b.addOr(new Range((char) 8, (char) 10)); + b.addOr(new oneChar((char) 13)); + add(b); + } + else if (sp.dontMatch && sp.c == 'd') + { + // Regex r = new Regex(); + // r._compile("[0-9]",mk); + // add(new Goop("\\d",r.thePattern)); + Range digit = new Range('0', '9'); + digit.printBrackets = true; + add(digit); + } + else if (sp.dontMatch && sp.c == 'W') + { + // Regex r = new Regex(); + // r._compile("[^a-zA-Z0-9_]",mk); + // add(new Goop("\\W",r.thePattern)); + Bracket b = new Bracket(true); + b.addOr(new Range('a', 'z')); + b.addOr(new Range('A', 'Z')); + b.addOr(new Range('0', '9')); + b.addOr(new oneChar('_')); + add(b); + } + else if (sp.dontMatch && sp.c == 'S') + { + // Regex r = new Regex(); + // r._compile("[^ \t\n\r\b]",mk); + // add(new Goop("\\S",r.thePattern)); + Bracket b = new Bracket(true); + b.addOr(new oneChar((char) 32)); + b.addOr(new Range((char) 8, (char) 10)); + b.addOr(new oneChar((char) 13)); + add(b); + } + else if (sp.dontMatch && sp.c == 'D') + { + // Regex r = new Regex(); + // r._compile("[^0-9]",mk); + // add(new Goop("\\D",r.thePattern)); + Bracket b = new Bracket(true); + b.addOr(new Range('0', '9')); + add(b); + } + else if (sp.dontMatch && sp.c == 'B') + { + Regex r = new Regex(); + r._compile2("(?!" + back_slash + "b)", mk); + add(r.thePattern); + } + else if (isOctalString(sp)) + { + int d = sp.c - '0'; + sp.inc(); + d = 8 * d + sp.c - '0'; + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (isOctalDigit(sp2, false)) + { + sp.inc(); + d = 8 * d + sp.c - '0'; + } + add(new oneChar((char) d)); + } + else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') + { + int iv = sp.c - '0'; + StrPos s2 = new StrPos(sp); + s2.inc(); + if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') + { + iv = 10 * iv + (s2.c - '0'); + sp.inc(); + } + add(new BackMatch(iv)); + } + else if (sp.dontMatch && sp.c == 'b') + { + add(new Boundary()); + } + else if (sp.match('\b')) + { + add(new Boundary()); + } + else if (sp.match('$')) + { + add(new End(true)); + } + else if (sp.dontMatch && sp.c == 'Z') + { + add(new End(false)); + } + else if (sp.match('.')) + { + add(new Any()); + } + else if (sp.incMatch("(??")) + { + javajs.util.SB sb = new javajs.util.SB(); + javajs.util.SB sb2 = new javajs.util.SB(); + while (!sp.match(')') && !sp.match(':')) + { + sb.appendC(sp.c); + sp.inc(); + } + if (sp.incMatch(":")) + { + while (!sp.match(')')) + { + sb2.appendC(sp.c); + sp.inc(); + } + } + String sbs = sb.toString(); + if (validators.get(sbs) instanceof String) + { + String pat = (String) validators.get(sbs); + Regex r = newRegex(); + Rthings rth = new Rthings(this); + rth.noBackRefs = true; + r._compile2(pat, rth); + add(r.thePattern); + } + else + { + Custom cm = new Custom(sb.toString()); + if (cm.v != null) + { + Validator v2 = cm.v.arg(sb2.toString()); + if (v2 != null) + { + v2.argsave = sb2.toString(); + String p = cm.v.pattern; + cm.v = v2; + v2.pattern = p; + } + Regex r = newRegex(); + Rthings rth = new Rthings(this); + rth.noBackRefs = true; + r._compile2(cm.v.pattern, rth); + cm.sub = r.thePattern; + cm.sub.add(new CustomEndpoint(cm)); + cm.sub.setParent(cm); + add(cm); + } + } + } + else if (sp.match('(')) + { + mk.parenLevel++; + Regex r = newRegex(); + // r.or = new Or(); + sp.inc(); + if (sp.incMatch("?:")) + { + r.or = new Or(); + } + else if (sp.incMatch("?=")) + { + r.or = new lookAhead(false); + } + else if (sp.incMatch("?!")) + { + r.or = new lookAhead(true); + } + else if (sp.match('?')) + { + sp.inc(); + do + { + if (sp.c == 'i') + { + mk.ignoreCase = true; + } + if (sp.c == 'Q') + { + mk.dontMatchInQuotes = true; + } + if (sp.c == 'o') + { + mk.optimizeMe = true; + } + if (sp.c == 'g') + { + mk.gFlag = true; + } + if (sp.c == 's') + { + mk.sFlag = true; + } + if (sp.c == 'm') + { + mk.mFlag = true; + } + sp.inc(); + } while (!sp.match(')') && !sp.eos); + r = null; + mk.parenLevel--; + if (sp.eos) // throw new RegSyntax + { + RegSyntaxError.endItAll("Unclosed ()"); + } + } + else + { // just ordinary parenthesis + r.or = mk.noBackRefs ? new Or() : new OrMark(mk.val++); + } + if (r != null) + { + add(r._compile1(sp, mk)); + } + } + else if (sp.match('^')) + { + add(new Start(true)); + } + else if (sp.dontMatch && sp.c == 'A') + { + add(new Start(false)); + } + else if (sp.match('*')) + { + addMulti(new patInt(0), new patInf()); + } + else if (sp.match('+')) + { + addMulti(new patInt(1), new patInf()); + } + else if (sp.match('?')) + { + addMulti(new patInt(0), new patInt(1)); + } + else if (sp.match('{')) + { + boolean bad = false; + StrPos sp2 = new StrPos(sp); + // javajs.util.SB sb = new javajs.util.SB(); + sp.inc(); + patInt i1 = sp.getPatInt(); + patInt i2 = null; + if (sp.match('}')) + { + i2 = i1; + } + else + { + if (!sp.match(',')) + { + /* + * RegSyntaxError.endItAll( "String \"{"+i2+ "\" should be followed + * with , or }"); + */ + bad = true; + } + sp.inc(); + if (sp.match('}')) + { + i2 = new patInf(); + } + else + { + i2 = sp.getPatInt(); + } + } + if (i1 == null || i2 == null) + { + /* + * throw new RegSyntax("Badly formatted Multi: " +"{"+i1+","+i2+"}"); + */ + bad = true; + } + if (bad) + { + sp.dup(sp2); + add(new oneChar(sp.c)); + } + else + { + addMulti(i1, i2); + } + } + else if (sp.escMatch('x') && next2Hex(sp)) + { + sp.inc(); + int d = getHexDigit(sp); + sp.inc(); + d = 16 * d + getHexDigit(sp); + add(new oneChar((char) d)); + } + else if (sp.escMatch('c')) + { + sp.inc(); + if (sp.c < Ctrl.cmap.length) + { + add(new oneChar(Ctrl.cmap[sp.c])); + } + else + { + add(new oneChar(sp.c)); + } + } + else if (sp.escMatch('f')) + { + add(new oneChar((char) 12)); + } + else if (sp.escMatch('a')) + { + add(new oneChar((char) 7)); + } + else if (sp.escMatch('t')) + { + add(new oneChar('\t')); + } + else if (sp.escMatch('n')) + { + add(new oneChar('\n')); + } + else if (sp.escMatch('r')) + { + add(new oneChar('\r')); + } + else if (sp.escMatch('b')) + { + add(new oneChar('\b')); + } + else if (sp.escMatch('e')) + { + add(new oneChar((char) 27)); + } + else + { + add(new oneChar(sp.c)); + if (sp.match(')')) + { + RegSyntaxError.endItAll("Unmatched right paren in pattern"); + } + } + } + + // compiles all Pattern elements, internal method + private Pattern _compile2(String pat, Rthings mk) throws RegSyntax + { + minMatch = null; + sFlag = mFlag = ignoreCase = gFlag = false; + StrPos sp = new StrPos(pat, 0); + thePattern = _compile1(sp, mk); + pt.marks = null; + return thePattern; + } + + Pattern p = null; + + Or or = null; + + Pattern _compile1(StrPos sp, Rthings mk) throws RegSyntax + { + while (!(sp.eos || (or != null && sp.match(')')))) + { + compile1(sp, mk); + sp.inc(); + } + if (sp.match(')')) + { + mk.parenLevel--; + } + else if (sp.eos && mk.parenLevel != 0) + { + RegSyntaxError.endItAll("Unclosed Parenthesis! lvl=" + mk.parenLevel); + } + if (or != null) + { + if (p == null) + { + p = new NullPattern(); + } + or.addOr(p); + return or; + } + return p == null ? new NullPattern() : p; + } + + // add a multi object to the end of the chain + // which applies to the last object + void addMulti(patInt i1, patInt i2) throws RegSyntax + { + Pattern last, last2; + for (last = p; last != null && last.next != null; last = last.next) + { + ; + } + if (last == null || last == p) + { + last2 = null; + } + else + { + for (last2 = p; last2.next != last; last2 = last2.next) + { + ; + } + } + if (last instanceof Multi && i1.intValue() == 0 && i2.intValue() == 1) + { + ((Multi) last).matchFewest = true; + } + else if (last instanceof FastMulti && i1.intValue() == 0 + && i2.intValue() == 1) + { + ((FastMulti) last).matchFewest = true; + } + else if (last instanceof DotMulti && i1.intValue() == 0 + && i2.intValue() == 1) + { + ((DotMulti) last).matchFewest = true; + } + else if (last instanceof Multi || last instanceof DotMulti + || last instanceof FastMulti) + { + throw new RegSyntax("Syntax error."); + } + else if (last2 == null) + { + p = mkMulti(i1, i2, p); + } + else + { + last2.next = mkMulti(i1, i2, last); + } + } + + final static Pattern mkMulti(patInt lo, patInt hi, Pattern p) + throws RegSyntax + { + if (p instanceof Any && p.next == null) + { + return (Pattern) new DotMulti(lo, hi); + } + return RegOpt.safe4fm(p) ? (Pattern) new FastMulti(lo, hi, p) + : (Pattern) new Multi(lo, hi, p); + } + + // process the bracket operator + Pattern matchBracket(StrPos sp) throws RegSyntax + { + Bracket ret; + if (sp.match('^')) + { + ret = new Bracket(true); + sp.inc(); + } + else + { + ret = new Bracket(false); + } + if (sp.match(']')) + { + // throw new RegSyntax + RegSyntaxError.endItAll("Unmatched []"); + } + + while (!sp.eos && !sp.match(']')) + { + StrPos s1 = new StrPos(sp); + s1.inc(); + StrPos s1_ = new StrPos(s1); + s1_.inc(); + if (s1.match('-') && !s1_.match(']')) + { + StrPos s2 = new StrPos(s1); + s2.inc(); + if (!s2.eos) + { + ret.addOr(new Range(sp.c, s2.c)); + } + sp.inc(); + sp.inc(); + } + else if (sp.escMatch('Q')) + { + sp.inc(); + while (!sp.escMatch('E')) + { + ret.addOr(new oneChar(sp.c)); + sp.inc(); + } + } + else if (sp.escMatch('d')) + { + ret.addOr(new Range('0', '9')); + } + else if (sp.escMatch('s')) + { + ret.addOr(new oneChar((char) 32)); + ret.addOr(new Range((char) 8, (char) 10)); + ret.addOr(new oneChar((char) 13)); + } + else if (sp.escMatch('w')) + { + ret.addOr(new Range('a', 'z')); + ret.addOr(new Range('A', 'Z')); + ret.addOr(new Range('0', '9')); + ret.addOr(new oneChar('_')); + } + else if (sp.escMatch('D')) + { + ret.addOr(new Range((char) 0, (char) 47)); + ret.addOr(new Range((char) 58, (char) 65535)); + } + else if (sp.escMatch('S')) + { + ret.addOr(new Range((char) 0, (char) 7)); + ret.addOr(new Range((char) 11, (char) 12)); + ret.addOr(new Range((char) 14, (char) 31)); + ret.addOr(new Range((char) 33, (char) 65535)); + } + else if (sp.escMatch('W')) + { + ret.addOr(new Range((char) 0, (char) 64)); + ret.addOr(new Range((char) 91, (char) 94)); + ret.addOr(new oneChar((char) 96)); + ret.addOr(new Range((char) 123, (char) 65535)); + } + else if (sp.escMatch('x') && next2Hex(sp)) + { + sp.inc(); + int d = getHexDigit(sp); + sp.inc(); + d = 16 * d + getHexDigit(sp); + ret.addOr(new oneChar((char) d)); + } + else if (sp.escMatch('a')) + { + ret.addOr(new oneChar((char) 7)); + } + else if (sp.escMatch('f')) + { + ret.addOr(new oneChar((char) 12)); + } + else if (sp.escMatch('e')) + { + ret.addOr(new oneChar((char) 27)); + } + else if (sp.escMatch('n')) + { + ret.addOr(new oneChar('\n')); + } + else if (sp.escMatch('t')) + { + ret.addOr(new oneChar('\t')); + } + else if (sp.escMatch('r')) + { + ret.addOr(new oneChar('\r')); + } + else if (sp.escMatch('c')) + { + sp.inc(); + if (sp.c < Ctrl.cmap.length) + { + ret.addOr(new oneChar(Ctrl.cmap[sp.c])); + } + else + { + ret.addOr(new oneChar(sp.c)); + } + } + else if (isOctalString(sp)) + { + int d = sp.c - '0'; + sp.inc(); + d = 8 * d + sp.c - '0'; + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (isOctalDigit(sp2, false)) + { + sp.inc(); + d = 8 * d + sp.c - '0'; + } + ret.addOr(new oneChar((char) d)); + } + else + { + ret.addOr(new oneChar(sp.c)); + } + sp.inc(); + } + return ret; + } + + /** + * Converts the stored Pattern to a String -- this is a decompile. Note that + * \t and \n will really print out here, Not just the two character + * representations. Also be prepared to see some strange output if your + * characters are not printable. + */ + public String toString() + { + if (false && thePattern == null) + { + return ""; + } + else + { + javajs.util.SB sb = new javajs.util.SB(); + if (esc != Pattern.ESC) + { + sb.append("(?e="); + sb.appendC(esc); + sb.append(")"); + } + if (gFlag || mFlag || !dotDoesntMatchCR || sFlag || ignoreCase + || dontMatchInQuotes || optimized()) + { + sb.append("(?"); + if (ignoreCase) + { + sb.append("i"); + } + if (mFlag) + { + sb.append("m"); + } + if (sFlag || !dotDoesntMatchCR) + { + sb.append("s"); + } + if (dontMatchInQuotes) + { + sb.append("Q"); + } + if (optimized()) + { + sb.append("o"); + } + if (gFlag) + { + sb.append("g"); + } + sb.append(")"); + } + String patstr = thePattern.toString(); + if (esc != Pattern.ESC) + { + patstr = reEscape(patstr, Pattern.ESC, esc); + } + sb.append(patstr); + return sb.toString(); + } + } + + // Re-escape Pattern, allows us to use a different escape + // character. + static String reEscape(String s, char oldEsc, char newEsc) + { + if (oldEsc == newEsc) + { + return s; + } + int i; + javajs.util.SB sb = new javajs.util.SB(); + for (i = 0; i < s.length(); i++) + { + if (s.charAt(i) == oldEsc && i + 1 < s.length()) + { + if (s.charAt(i + 1) == oldEsc) + { + sb.appendC(oldEsc); + } + else + { + sb.appendC(newEsc); + sb.appendC(s.charAt(i + 1)); + } + i++; + } + else if (s.charAt(i) == newEsc) + { + sb.appendC(newEsc); + sb.appendC(newEsc); + } + else + { + sb.appendC(s.charAt(i)); + } + } + return sb.toString(); + } + +// /** +// * This method implements FilenameFilter, allowing one to use a Regex to +// * search through a directory using File.list. There is a FileRegex now that +// * does this better. +// * +// * @see com.stevesoft.pat.FileRegex +// */ +// public boolean accept(File dir, String s) +// { +// return search(s); +// } + + /** The version of this package */ + final static public String version() + { + return "lgpl release 1.5.3"; + } + + /** + * Once this method is called, the state of variables ignoreCase and + * dontMatchInQuotes should not be changed as the results will be + * unpredictable. However, search and matchAt will run more quickly. Note that + * you can check to see if the pattern has been optimized by calling the + * optimized() method. + *

    + * This method will attempt to rewrite your pattern in a way that makes it + * faster (not all patterns execute at the same speed). In general, "(?: ... )" + * will be faster than "( ... )" so if you don't need the backreference, you + * should group using the former pattern. + *

    + * It will also introduce new pattern elements that you can't get to + * otherwise, for example if you have a large table of strings, i.e. the + * months of the year "(January|February|...)" optimize() will make a + * Hashtable that takes it to the next appropriate pattern element -- + * eliminating the need for a linear search. + * + * @see com.stevesoft.pat.Regex#optimized + * @see com.stevesoft.pat.Regex#ignoreCase + * @see com.stevesoft.pat.Regex#dontMatchInQuotes + * @see com.stevesoft.pat.Regex#matchAt + * @see com.stevesoft.pat.Regex#search + */ + public void optimize() + { + if (optimized() || thePattern == null) + { + return; + } + minMatch = new patInt(0); // thePattern.countMinChars(); + thePattern = RegOpt.opt(thePattern, ignoreCase, dontMatchInQuotes); + skipper = Skip.findSkip(this); + // RegOpt.setParents(this); + return; + } + + Skip skipper; + + /** + * This function returns true if the optimize method has been called. + */ + public boolean optimized() + { + return minMatch != null; + } + + /** + * A bit of syntactic surgar for those who want to make their code look more + * perl-like. To use this initialize your Regex object by saying: + * + *

    +   *       Regex r1 = Regex.perlCode("s/hello/goodbye/");
    +   *       Regex r2 = Regex.perlCode("s'fish'frog'i");
    +   *       Regex r3 = Regex.perlCode("m'hello');
    +   * 
    + * + * The i for ignoreCase is supported in this syntax, as well as m, s, and x. + * The g flat is a bit of a special case. + *

    + * If you wish to replace all occurences of a pattern, you do not put a 'g' in + * the perlCode, but call Regex's replaceAll method. + *

    + * If you wish to simply and only do a search for r2's pattern, you can do + * this by calling the searchFrom method method repeatedly, or by calling + * search repeatedly if the g flag is set. + *

    + * Note: Currently perlCode does not support the (?e=#) syntax for + * changing the escape character. + */ + + public static Regex perlCode(String s) + { + // this file is big enough, see parsePerl.java + // for this function. + return parsePerl.parse(s); + } + + static final char back_slash = '\\'; + + /** + * Checks to see if there are only literal and no special pattern elements in + * this Regex. + */ + public boolean isLiteral() + { + Pattern x = thePattern; + while (x != null) + { + if (x instanceof oneChar) + { + ; + } + else if (x instanceof Skipped) + { + ; + } + else + { + return false; + } + x = x.next; + } + return true; + } + + /** + * You only need to know about this if you are inventing your own pattern + * elements. + */ + public patInt countMinChars() + { + return thePattern.countMinChars(); + } + + /** + * You only need to know about this if you are inventing your own pattern + * elements. + */ + public patInt countMaxChars() + { + return thePattern.countMaxChars(); + } + + boolean isHexDigit(StrPos sp) + { + boolean r = !sp.eos + && !sp.dontMatch + && ((sp.c >= '0' && sp.c <= '9') + || (sp.c >= 'a' && sp.c <= 'f') || (sp.c >= 'A' && sp.c <= 'F')); + return r; + } + + boolean isOctalDigit(StrPos sp, boolean first) + { + boolean r = !sp.eos && !(first ^ sp.dontMatch) && sp.c >= '0' + && sp.c <= '7'; + return r; + } + + int getHexDigit(StrPos sp) + { + if (sp.c >= '0' && sp.c <= '9') + { + return sp.c - '0'; + } + if (sp.c >= 'a' && sp.c <= 'f') + { + return sp.c - 'a' + 10; + } + return sp.c - 'A' + 10; + } + + boolean next2Hex(StrPos sp) + { + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (!isHexDigit(sp2)) + { + return false; + } + sp2.inc(); + if (!isHexDigit(sp2)) + { + return false; + } + return true; + } + + boolean isOctalString(StrPos sp) + { + if (!isOctalDigit(sp, true)) + { + return false; + } + StrPos sp2 = new StrPos(sp); + sp2.inc(); + if (!isOctalDigit(sp2, false)) + { + return false; + } + return true; + } +} diff --git a/unused/com/stevesoft/pat/RegexReader.java b/unused/com/stevesoft/pat/RegexReader.java index 8092064..7cb6ad3 100644 --- a/unused/com/stevesoft/pat/RegexReader.java +++ b/unused/com/stevesoft/pat/RegexReader.java @@ -1,309 +1,309 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.io.*; - -import com.stevesoft.pat.wrap.*; - -/** - * This class allows you to replace the text in strings as you read them in. Be - * careful what you do with this freedom... using Regex.perlCode("s{.*}{x}s") as - * your pattern will result in loading the entire contents of the Reader into - * memory. - */ -public class RegexReader extends Reader -{ - RBuffer rb = new RBuffer(new javajs.util.SB()); - - PartialBuffer wrap = new PartialBuffer(rb.sb); - - boolean moreToRead = true; - - Reader r; - - Replacer rp; - - // the buffer size - int nmax = 2 * 1024; - - public RegexReader(Regex rex, Reader r) - { - this.r = r; - rp = rex.getReplacer(); - } - - public RegexReader(Transformer tex, Reader r) - { - this.r = r; - rp = tex.getReplacer(); - } - - public void reset() throws IOException - { - r.reset(); - rb = new RBuffer(new javajs.util.SB()); - wrap = new PartialBuffer(rb.sb); - moreToRead = true; - } - - void readData() throws IOException - { - int c; - int n = 0; - while ((c = r.read()) != -1) - { - rb.sb.appendC((char) c); - if (n++ > nmax) - { - break; - } - } - if (c == -1 && n == 0) - { - moreToRead = false; - wrap.allowOverRun = false; - } - } - - void getMoreData() throws IOException - { - while (rb.pos >= rb.epos) - { - wrap.overRun = false; - if (rb.next != null) - { - rb = rb.next; - } - else if (rb.done) - { - break; - } - else if (rb.epos >= rb.sb.length() && rb.epos > nmax) - { - rb.pos = 1; - rb.epos = 1; - rb.sb.setLength(1); - readData(); - } - else if (rb.epos >= rb.sb.length() && moreToRead) - { - readData(); - } - else if (rp.getRegex().matchAt(wrap, rb.epos)) - { - if (wrap.overRun) - { - readData(); - } - else - { - StringBufferWrap sbw = new StringBufferWrap(); - StringBufferLike sbl = new StringBufferLike(sbw); - /* - * ReplaceRule rr = rex.getReplaceRule(); while(rr != null) { - * rr.apply(sbl,rex); rr = rr.next; } - */ - Regex rex = rp.getRegex(); - int npos = rex.matchedTo(); - rp.setBuffer(sbl); - rp.setSource(wrap); - rp.setPos(npos); - rp.apply(rex, rex.getReplaceRule()); - int opos = rb.epos; - RBuffer rb2 = new RBuffer((javajs.util.SB) sbw.unwrap()); - rb2.epos = rb2.sb.length(); - RBuffer rb3 = new RBuffer(rb.sb); - - rb.next = rb2; - rb2.next = rb3; - - if (npos == opos) - { - rb3.epos = npos + 1; - if (rb3.epos > rb3.sb.length()) - { - if (rb.pos >= rb.epos) - { - rb = rb.next; - } - rb3.pos = rb3.epos = 0; - rb3.done = true; - // break; - } - rb3.pos = npos; - } - else - { - rb3.pos = rb3.epos = npos; - } - - } - } - else - { - if (wrap.overRun) - { - readData(); - } - else if (rb.epos < rb.sb.length()) - { - rb.epos++; - } - else - { - break; - } - } - } - } - - public int read() throws IOException - { - if (rb.pos >= rb.epos) - { - getMoreData(); - if (rb.pos >= rb.epos) - { - return -1; - } - } - // System.out.println(rb); - return rb.sb.charAt(rb.pos++); - } - - public int read(char[] buf, int off, int len) throws IOException - { - int c = -1; - int end = off + len; - for (int i = off; i < end; i++) - { - c = read(); - if (c < 0) - { - if (i == off) - { - return -1; - } - return i - off; - } - buf[i] = (char) c; - } - return len; - } - - public void close() throws IOException - { - r.close(); - } - - public boolean markSupported() - { - return false; - } - - /** - * Get the size of the working buffer. The current buffer may be larger if the - * pattern demands it. - */ - public int getBufferSize() - { - return nmax; - } - - /** - * Set the size of the working buffer. The current buffer may be larger if the - * pattern demands it. - */ - public void setBufferSize(int n) - { - nmax = n; - } - - int max_lines = 2; - - /** - * This function no longer serves any purpose. - * - * @deprecated - */ - public int getMaxLines() - { - return max_lines; - } - - /** - * This function no longer serves any purpose. - * - * @deprecated - */ - public void setMaxLines(int ml) - { - max_lines = ml; - } - - char EOLchar = '\n'; - - /** - * This function no longer serves any purpose. - * - * @deprecated - */ - public char getEOLchar() - { - return EOLchar; - } - - /** - * This function no longer serves any purpose. - * - * @deprecated - */ - public void setEOLchar(char c) - { - EOLchar = c; - } - - public long skip(long d) throws IOException - { - // This is probably inefficient, I just did it - // this way to avoid possible bugs. - long n = 0; - while (n < d && read() != -1) - { - n++; - } - return n; - } - - /* - * static void test(String re,String inp,int n) throws Exception { Reader r = - * new StringReader(inp); r = new BufferedReader(r); Regex rex = - * Regex.perlCode(re); String res1 = rex.replaceAll(inp); int c = -1; - * javajs.util.SB sb = new javajs.util.SB(); RegexReader rr = new - * RegexReader(rex,r); rr.setBufferSize(n); while( (c = rr.read()) != -1) - * sb.append((char)c); String res2 = sb.toString(); if(!res1.equals(res2)) { - * System.out.println("nmax="+n); System.out.println("re="+re); - * System.out.println("inp="+inp); System.out.println("res1="+res1); - * System.out.println("res2="+res2); System.exit(255); } } public static void - * main(String[] args) throws Exception { for(int n=6;n<15;n++) { - * test("s/x/y/","-----x123456789",n); test("s/x/y/","x123456789",n); - * test("s/x/y/","-----x",n); - * test("s/x.*?x/y/",".xx..x..x...x...x....x....x",n); - * test("s/x.*x/[$&]/","--x........x--xx",n); - * test("s/x.*x/[$&]/","--x........x------",n); - * test("s/.$/a/m","bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbbbbbbbbbbbb",n); - * test("s/.$/a/","123",n); - * test("s/.$/a/","bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb",n); - * test("s/^./a/","bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb",n); - * test("s/$/a/","bbb",n); test("s/^/a/","bbb",n); test("s/^/a/","",n); - * test("s{.*}{N}","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",n); - * test("s/.{0,7}/y/","AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",n); - * test("s/x/$&/","xxx",n); } System.out.println("Success!!!"); } - */ -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.io.*; + +import com.stevesoft.pat.wrap.*; + +/** + * This class allows you to replace the text in strings as you read them in. Be + * careful what you do with this freedom... using Regex.perlCode("s{.*}{x}s") as + * your pattern will result in loading the entire contents of the Reader into + * memory. + */ +public class RegexReader extends Reader +{ + RBuffer rb = new RBuffer(new javajs.util.SB()); + + PartialBuffer wrap = new PartialBuffer(rb.sb); + + boolean moreToRead = true; + + Reader r; + + Replacer rp; + + // the buffer size + int nmax = 2 * 1024; + + public RegexReader(Regex rex, Reader r) + { + this.r = r; + rp = rex.getReplacer(); + } + + public RegexReader(Transformer tex, Reader r) + { + this.r = r; + rp = tex.getReplacer(); + } + + public void reset() throws IOException + { + r.reset(); + rb = new RBuffer(new javajs.util.SB()); + wrap = new PartialBuffer(rb.sb); + moreToRead = true; + } + + void readData() throws IOException + { + int c; + int n = 0; + while ((c = r.read()) != -1) + { + rb.sb.appendC((char) c); + if (n++ > nmax) + { + break; + } + } + if (c == -1 && n == 0) + { + moreToRead = false; + wrap.allowOverRun = false; + } + } + + void getMoreData() throws IOException + { + while (rb.pos >= rb.epos) + { + wrap.overRun = false; + if (rb.next != null) + { + rb = rb.next; + } + else if (rb.done) + { + break; + } + else if (rb.epos >= rb.sb.length() && rb.epos > nmax) + { + rb.pos = 1; + rb.epos = 1; + rb.sb.setLength(1); + readData(); + } + else if (rb.epos >= rb.sb.length() && moreToRead) + { + readData(); + } + else if (rp.getRegex().matchAt(wrap, rb.epos)) + { + if (wrap.overRun) + { + readData(); + } + else + { + StringBufferWrap sbw = new StringBufferWrap(); + StringBufferLike sbl = new StringBufferLike(sbw); + /* + * ReplaceRule rr = rex.getReplaceRule(); while(rr != null) { + * rr.apply(sbl,rex); rr = rr.next; } + */ + Regex rex = rp.getRegex(); + int npos = rex.matchedTo(); + rp.setBuffer(sbl); + rp.setSource(wrap); + rp.setPos(npos); + rp.apply(rex, rex.getReplaceRule()); + int opos = rb.epos; + RBuffer rb2 = new RBuffer((javajs.util.SB) sbw.unwrap()); + rb2.epos = rb2.sb.length(); + RBuffer rb3 = new RBuffer(rb.sb); + + rb.next = rb2; + rb2.next = rb3; + + if (npos == opos) + { + rb3.epos = npos + 1; + if (rb3.epos > rb3.sb.length()) + { + if (rb.pos >= rb.epos) + { + rb = rb.next; + } + rb3.pos = rb3.epos = 0; + rb3.done = true; + // break; + } + rb3.pos = npos; + } + else + { + rb3.pos = rb3.epos = npos; + } + + } + } + else + { + if (wrap.overRun) + { + readData(); + } + else if (rb.epos < rb.sb.length()) + { + rb.epos++; + } + else + { + break; + } + } + } + } + + public int read() throws IOException + { + if (rb.pos >= rb.epos) + { + getMoreData(); + if (rb.pos >= rb.epos) + { + return -1; + } + } + // System.out.println(rb); + return rb.sb.charAt(rb.pos++); + } + + public int read(char[] buf, int off, int len) throws IOException + { + int c = -1; + int end = off + len; + for (int i = off; i < end; i++) + { + c = read(); + if (c < 0) + { + if (i == off) + { + return -1; + } + return i - off; + } + buf[i] = (char) c; + } + return len; + } + + public void close() throws IOException + { + r.close(); + } + + public boolean markSupported() + { + return false; + } + + /** + * Get the size of the working buffer. The current buffer may be larger if the + * pattern demands it. + */ + public int getBufferSize() + { + return nmax; + } + + /** + * Set the size of the working buffer. The current buffer may be larger if the + * pattern demands it. + */ + public void setBufferSize(int n) + { + nmax = n; + } + + int max_lines = 2; + + /** + * This function no longer serves any purpose. + * + * @deprecated + */ + public int getMaxLines() + { + return max_lines; + } + + /** + * This function no longer serves any purpose. + * + * @deprecated + */ + public void setMaxLines(int ml) + { + max_lines = ml; + } + + char EOLchar = '\n'; + + /** + * This function no longer serves any purpose. + * + * @deprecated + */ + public char getEOLchar() + { + return EOLchar; + } + + /** + * This function no longer serves any purpose. + * + * @deprecated + */ + public void setEOLchar(char c) + { + EOLchar = c; + } + + public long skip(long d) throws IOException + { + // This is probably inefficient, I just did it + // this way to avoid possible bugs. + long n = 0; + while (n < d && read() != -1) + { + n++; + } + return n; + } + + /* + * static void test(String re,String inp,int n) throws Exception { Reader r = + * new StringReader(inp); r = new BufferedReader(r); Regex rex = + * Regex.perlCode(re); String res1 = rex.replaceAll(inp); int c = -1; + * javajs.util.SB sb = new javajs.util.SB(); RegexReader rr = new + * RegexReader(rex,r); rr.setBufferSize(n); while( (c = rr.read()) != -1) + * sb.append((char)c); String res2 = sb.toString(); if(!res1.equals(res2)) { + * System.out.println("nmax="+n); System.out.println("re="+re); + * System.out.println("inp="+inp); System.out.println("res1="+res1); + * System.out.println("res2="+res2); System.exit(255); } } public static void + * main(String[] args) throws Exception { for(int n=6;n<15;n++) { + * test("s/x/y/","-----x123456789",n); test("s/x/y/","x123456789",n); + * test("s/x/y/","-----x",n); + * test("s/x.*?x/y/",".xx..x..x...x...x....x....x",n); + * test("s/x.*x/[$&]/","--x........x--xx",n); + * test("s/x.*x/[$&]/","--x........x------",n); + * test("s/.$/a/m","bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbbbbbbbbbbbb",n); + * test("s/.$/a/","123",n); + * test("s/.$/a/","bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb",n); + * test("s/^./a/","bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb",n); + * test("s/$/a/","bbb",n); test("s/^/a/","bbb",n); test("s/^/a/","",n); + * test("s{.*}{N}","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",n); + * test("s/.{0,7}/y/","AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",n); + * test("s/x/$&/","xxx",n); } System.out.println("Success!!!"); } + */ +} diff --git a/unused/com/stevesoft/pat/RegexTokenizer.java b/unused/com/stevesoft/pat/RegexTokenizer.java index 0378f3a..0e53857 100644 --- a/unused/com/stevesoft/pat/RegexTokenizer.java +++ b/unused/com/stevesoft/pat/RegexTokenizer.java @@ -1,171 +1,171 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - Shareware: package pat - Copyright 2001, Steven R. Brandt - */ -/** - * The RegexTokenizer is similar to the StringTokenizer class provided with - * java, but allows one to tokenize using regular expressions, rather than a - * simple list of characters. Tokens are any strings between the supplied - * regular expression, as well as any backreferences (things in parenthesis) - * contained within the regular expression. - */ -public class RegexTokenizer implements Enumeration -{ - String toParse; - - Regex r; - - int count = 0; - - Vector v = new Vector(); - - Vector vi = new Vector(); - - int pos = 0; - - int offset = 1; - - void getMore() - { - String s = r.right(); - if (r.searchFrom(toParse, pos)) - { - v.addElement(r.left().substring(pos)); - vi.addElement(new Integer(r.matchFrom() + r.charsMatched())); - for (int i = 0; i < r.numSubs(); i++) - { - if (r.substring() != null) - { - v.addElement(r.substring(i + offset)); - vi.addElement(new Integer(r.matchFrom(i + offset) - + r.charsMatched(i + offset))); - } - } - pos = r.matchFrom() + r.charsMatched(); - } - else if (s != null) - { - v.addElement(s); - } - } - - /** Initialize the tokenizer with a string of text and a pattern */ - public RegexTokenizer(String txt, String ptrn) - { - toParse = txt; - r = new Regex(ptrn); - offset = Regex.BackRefOffset; - getMore(); - } - - /** Initialize the tokenizer with a Regex object. */ - public RegexTokenizer(String txt, Regex r) - { - toParse = txt; - this.r = r; - offset = Regex.BackRefOffset; - getMore(); - } - - /** - * This should always be cast to a String, as in StringTokenizer, and as in - * StringTokenizer one can do this by calling nextString(). - */ - public Object nextElement() - { - if (count >= v.size()) - { - getMore(); - } - return v.elementAt(count++); - } - - /** This is the equivalent (String)nextElement(). */ - public String nextToken() - { - return (String) nextElement(); - } - - /** - * This asks for the next token, and changes the pattern being used at the - * same time. - */ - public String nextToken(String newpat) - { - try - { - r.compile(newpat); - } catch (RegSyntax r_) - { - } - return nextToken(r); - } - - /** - * This asks for the next token, and changes the pattern being used at the - * same time. - */ - public String nextToken(Regex nr) - { - r = nr; - if (vi.size() > count) - { - pos = ((Integer) vi.elementAt(count)).intValue(); - v.setSize(count); - vi.setSize(count); - } - getMore(); - return nextToken(); - } - - /** Tells whether there are more tokens in the pattern. */ - public boolean hasMoreElements() - { - if (count >= v.size()) - { - getMore(); - } - return count < v.size(); - } - - /** - * Tells whether there are more tokens in the pattern, but in the fashion of - * StringTokenizer. - */ - public boolean hasMoreTokens() - { - return hasMoreElements(); - } - - /** Determines the # of remaining tokens */ - public int countTokens() - { - int _count = count; - while (hasMoreTokens()) - { - nextToken(); - } - count = _count; - return v.size() - count; - } - - /** Returns all tokens in the String */ - public String[] allTokens() - { - countTokens(); - String[] ret = new String[v.size()]; - v.copyInto(ret); - return ret; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + Shareware: package pat + Copyright 2001, Steven R. Brandt + */ +/** + * The RegexTokenizer is similar to the StringTokenizer class provided with + * java, but allows one to tokenize using regular expressions, rather than a + * simple list of characters. Tokens are any strings between the supplied + * regular expression, as well as any backreferences (things in parenthesis) + * contained within the regular expression. + */ +public class RegexTokenizer implements Enumeration +{ + String toParse; + + Regex r; + + int count = 0; + + Vector v = new Vector(); + + Vector vi = new Vector(); + + int pos = 0; + + int offset = 1; + + void getMore() + { + String s = r.right(); + if (r.searchFrom(toParse, pos)) + { + v.addElement(r.left().substring(pos)); + vi.addElement(new Integer(r.matchFrom() + r.charsMatched())); + for (int i = 0; i < r.numSubs(); i++) + { + if (r.substring() != null) + { + v.addElement(r.substring(i + offset)); + vi.addElement(new Integer(r.matchFrom(i + offset) + + r.charsMatched(i + offset))); + } + } + pos = r.matchFrom() + r.charsMatched(); + } + else if (s != null) + { + v.addElement(s); + } + } + + /** Initialize the tokenizer with a string of text and a pattern */ + public RegexTokenizer(String txt, String ptrn) + { + toParse = txt; + r = new Regex(ptrn); + offset = Regex.BackRefOffset; + getMore(); + } + + /** Initialize the tokenizer with a Regex object. */ + public RegexTokenizer(String txt, Regex r) + { + toParse = txt; + this.r = r; + offset = Regex.BackRefOffset; + getMore(); + } + + /** + * This should always be cast to a String, as in StringTokenizer, and as in + * StringTokenizer one can do this by calling nextString(). + */ + public Object nextElement() + { + if (count >= v.size()) + { + getMore(); + } + return v.elementAt(count++); + } + + /** This is the equivalent (String)nextElement(). */ + public String nextToken() + { + return (String) nextElement(); + } + + /** + * This asks for the next token, and changes the pattern being used at the + * same time. + */ + public String nextToken(String newpat) + { + try + { + r.compile(newpat); + } catch (RegSyntax r_) + { + } + return nextToken(r); + } + + /** + * This asks for the next token, and changes the pattern being used at the + * same time. + */ + public String nextToken(Regex nr) + { + r = nr; + if (vi.size() > count) + { + pos = ((Integer) vi.elementAt(count)).intValue(); + v.setSize(count); + vi.setSize(count); + } + getMore(); + return nextToken(); + } + + /** Tells whether there are more tokens in the pattern. */ + public boolean hasMoreElements() + { + if (count >= v.size()) + { + getMore(); + } + return count < v.size(); + } + + /** + * Tells whether there are more tokens in the pattern, but in the fashion of + * StringTokenizer. + */ + public boolean hasMoreTokens() + { + return hasMoreElements(); + } + + /** Determines the # of remaining tokens */ + public int countTokens() + { + int _count = count; + while (hasMoreTokens()) + { + nextToken(); + } + count = _count; + return v.size() - count; + } + + /** Returns all tokens in the String */ + public String[] allTokens() + { + countTokens(); + String[] ret = new String[v.size()]; + v.copyInto(ret); + return ret; + } +}; diff --git a/unused/com/stevesoft/pat/RegexWriter.java b/unused/com/stevesoft/pat/RegexWriter.java index 7024d61..a111bd7 100644 --- a/unused/com/stevesoft/pat/RegexWriter.java +++ b/unused/com/stevesoft/pat/RegexWriter.java @@ -1,238 +1,238 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.io.IOException; -import java.io.Writer; - -import com.stevesoft.pat.wrap.WriterWrap; - -/** - * A basic extension of FilterWriter that uses Transformer to make replacements - * in data as it is written out. It attempts to transform a string whenever the - * End-of-Line (EOL) character is written (which is, by default, the carriage - * return '\n'). Only the transformed portion of the line is written out, - * allowing the RegexWriter to wait until a complete pattern is present before - * attempting to write out info. Until a pattern completes, data is stored in a - * javajs.util.SB -- which can be accessed through the length() and charAt() - * methods of this class. - *

    - * Note a subtlety here -- while a Transformer normally matches at higher - * priority against the pattern added to it first, this will not necessarily be - * true when a multi-line match is in progress because one of the complete - * multi-line patterns may not be completely loaded in RegexWriter's buffer. For - * this reason, the Transformer class is equipped with a way to add a pattern - * and replacement rule in three pieces -- a beginning (once this matches, - * nothing else in the Transformer can match until the whole pattern matches), - * an ending (the whole pattern is a String formed by adding the beginning and - * ending), and a ReplaceRule. - *

    - * An illustration of this is given in the this example. - */ -public class RegexWriter extends Writer -{ - Replacer repr; - - Writer w; - - WriterWrap ww; - - javajs.util.SB sb = new javajs.util.SB(); - - PartialBuffer wrap = new PartialBuffer(sb); - - int pos, epos; - - int interval = 128; - - int bufferSize = 2 * 1024; - - public RegexWriter(Transformer t, Writer w) - { - this.w = w; - ww = new WriterWrap(w); - repr = t.getReplacer(); - repr.setBuffer(new StringBufferLike(ww)); - repr.setSource(wrap); - } - - public RegexWriter(Regex r, Writer w) - { - this.w = w; - ww = new WriterWrap(w); - repr = r.getReplacer(); - repr.setBuffer(new StringBufferLike(ww)); - repr.setSource(wrap); - } - - char EOLchar = '\n'; - - /** - * This method no longer serves any purpose. - * - * @deprecated - */ - @Deprecated - public char getEOLchar() - { - return EOLchar; - } - - /** - * This method no longer serves any purpose. - * - * @deprecated - */ - @Deprecated - public void setEOLchar(char c) - { - EOLchar = c; - } - - int max_lines = 2; - - /** - * This method no longer serves any purpose. - * - * @deprecated - */ - @Deprecated - public int getMaxLines() - { - return max_lines; - } - - /** - * This method no longer serves any purpose. - * - * @deprecated - */ - @Deprecated - public void setMaxLines(int ml) - { - max_lines = ml; - } - - void write() throws IOException - { - Regex rex = repr.getRegex(); - int eposOld = epos; - if (rex.matchAt(wrap, epos) && !wrap.overRun) - { - while (pos < epos) - { - w.write(sb.charAt(pos++)); - } - int to = rex.matchedTo(); - repr.setPos(to); - repr.apply(rex, rex.getReplaceRule()); - epos = pos = to; - if (epos == eposOld && epos < sb.length()) - { - epos++; - } - } - else if (!wrap.overRun && epos < sb.length()) - { - epos++; - } - while (pos < epos) - { - w.write(sb.charAt(pos++)); - } - if (epos == sb.length()) - { - sb.setLength(1); - pos = epos = 1; - } - else if (pos > bufferSize) - { - - String s = sb.substring(bufferSize); - sb.setLength(0); - sb.append(s); -// for (int i = bufferSize; i < sb.length(); i++) -// { -// sb.setCharAt(i - bufferSize, sb.charAt(i)); -// } - pos -= bufferSize; - epos -= bufferSize; - sb.setLength(sb.length() - bufferSize); - } - } - - public void write(char[] ca, int b, int n) throws IOException - { - int m = b + n; - for (int i = b; i < m; i++) - { - sb.appendC(ca[i]); - if (sb.length() % interval == interval - 1) - { - wrap.overRun = false; - while (epos + interval < sb.length() && !wrap.overRun) - { - write(); - } - } - } - } - - public void flush() throws IOException - { - } - - public void close() throws IOException - { - wrap.allowOverRun = false; - wrap.overRun = false; - while (epos < sb.length()) - { - write(); - } - write(); - w.close(); - } - - /** The current size of the javajs.util.SB in use by RegexWriter. */ - public int length() - { - return sb.length(); - } - - /** The character at location i in the StringBuffer. */ - public char charAt(int i) - { - return sb.charAt(i); - } - - /** Set the interval at which regex patterns are checked. */ - public void setInterval(int i) - { - interval = i; - } - - /** Get the interval at which regex matches are checked. */ - public int getInterval() - { - return interval; - } - - /** Get the buffer size. */ - public int getBufferSize() - { - return bufferSize; - } - - /** Set the buffer size. */ - public void setBufferSize(int i) - { - bufferSize = i; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.io.IOException; +import java.io.Writer; + +import com.stevesoft.pat.wrap.WriterWrap; + +/** + * A basic extension of FilterWriter that uses Transformer to make replacements + * in data as it is written out. It attempts to transform a string whenever the + * End-of-Line (EOL) character is written (which is, by default, the carriage + * return '\n'). Only the transformed portion of the line is written out, + * allowing the RegexWriter to wait until a complete pattern is present before + * attempting to write out info. Until a pattern completes, data is stored in a + * javajs.util.SB -- which can be accessed through the length() and charAt() + * methods of this class. + *

    + * Note a subtlety here -- while a Transformer normally matches at higher + * priority against the pattern added to it first, this will not necessarily be + * true when a multi-line match is in progress because one of the complete + * multi-line patterns may not be completely loaded in RegexWriter's buffer. For + * this reason, the Transformer class is equipped with a way to add a pattern + * and replacement rule in three pieces -- a beginning (once this matches, + * nothing else in the Transformer can match until the whole pattern matches), + * an ending (the whole pattern is a String formed by adding the beginning and + * ending), and a ReplaceRule. + *

    + * An illustration of this is given in the this example. + */ +public class RegexWriter extends Writer +{ + Replacer repr; + + Writer w; + + WriterWrap ww; + + javajs.util.SB sb = new javajs.util.SB(); + + PartialBuffer wrap = new PartialBuffer(sb); + + int pos, epos; + + int interval = 128; + + int bufferSize = 2 * 1024; + + public RegexWriter(Transformer t, Writer w) + { + this.w = w; + ww = new WriterWrap(w); + repr = t.getReplacer(); + repr.setBuffer(new StringBufferLike(ww)); + repr.setSource(wrap); + } + + public RegexWriter(Regex r, Writer w) + { + this.w = w; + ww = new WriterWrap(w); + repr = r.getReplacer(); + repr.setBuffer(new StringBufferLike(ww)); + repr.setSource(wrap); + } + + char EOLchar = '\n'; + + /** + * This method no longer serves any purpose. + * + * @deprecated + */ + @Deprecated + public char getEOLchar() + { + return EOLchar; + } + + /** + * This method no longer serves any purpose. + * + * @deprecated + */ + @Deprecated + public void setEOLchar(char c) + { + EOLchar = c; + } + + int max_lines = 2; + + /** + * This method no longer serves any purpose. + * + * @deprecated + */ + @Deprecated + public int getMaxLines() + { + return max_lines; + } + + /** + * This method no longer serves any purpose. + * + * @deprecated + */ + @Deprecated + public void setMaxLines(int ml) + { + max_lines = ml; + } + + void write() throws IOException + { + Regex rex = repr.getRegex(); + int eposOld = epos; + if (rex.matchAt(wrap, epos) && !wrap.overRun) + { + while (pos < epos) + { + w.write(sb.charAt(pos++)); + } + int to = rex.matchedTo(); + repr.setPos(to); + repr.apply(rex, rex.getReplaceRule()); + epos = pos = to; + if (epos == eposOld && epos < sb.length()) + { + epos++; + } + } + else if (!wrap.overRun && epos < sb.length()) + { + epos++; + } + while (pos < epos) + { + w.write(sb.charAt(pos++)); + } + if (epos == sb.length()) + { + sb.setLength(1); + pos = epos = 1; + } + else if (pos > bufferSize) + { + + String s = sb.substring(bufferSize); + sb.setLength(0); + sb.append(s); +// for (int i = bufferSize; i < sb.length(); i++) +// { +// sb.setCharAt(i - bufferSize, sb.charAt(i)); +// } + pos -= bufferSize; + epos -= bufferSize; + sb.setLength(sb.length() - bufferSize); + } + } + + public void write(char[] ca, int b, int n) throws IOException + { + int m = b + n; + for (int i = b; i < m; i++) + { + sb.appendC(ca[i]); + if (sb.length() % interval == interval - 1) + { + wrap.overRun = false; + while (epos + interval < sb.length() && !wrap.overRun) + { + write(); + } + } + } + } + + public void flush() throws IOException + { + } + + public void close() throws IOException + { + wrap.allowOverRun = false; + wrap.overRun = false; + while (epos < sb.length()) + { + write(); + } + write(); + w.close(); + } + + /** The current size of the javajs.util.SB in use by RegexWriter. */ + public int length() + { + return sb.length(); + } + + /** The character at location i in the StringBuffer. */ + public char charAt(int i) + { + return sb.charAt(i); + } + + /** Set the interval at which regex patterns are checked. */ + public void setInterval(int i) + { + interval = i; + } + + /** Get the interval at which regex matches are checked. */ + public int getInterval() + { + return interval; + } + + /** Get the buffer size. */ + public int getBufferSize() + { + return bufferSize; + } + + /** Set the buffer size. */ + public void setBufferSize(int i) + { + bufferSize = i; + } +} diff --git a/unused/com/stevesoft/pat/ReplaceRule.java b/unused/com/stevesoft/pat/ReplaceRule.java index 8e969a3..6758e2f 100644 --- a/unused/com/stevesoft/pat/ReplaceRule.java +++ b/unused/com/stevesoft/pat/ReplaceRule.java @@ -1,202 +1,202 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.Hashtable; - -/** - * ReplaceRule is a singly linked list of Objects which describe how to replace - * the matched portion of a String. The only member method that you absolutely - * need to define to use this class is apply(StringBuffer,RegRes) -- although - * you may want define toString1() and clone1() (if you are unhappy with the - * default methods) that are needed by the clone() or toString() methods on this - * class. During the replacement process, each ReplaceRule tells the replacer - * what to add to javajs.util.SB and uses the contents of the Regular expression - * result to get the information it needs to do this. Here is an example - * - * @see com.stevesoft.pat.NullRule - * @see com.stevesoft.pat.AmpersandRule - * @see com.stevesoft.pat.BackRefRule - * @see com.stevesoft.pat.LeftRule - * @see com.stevesoft.pat.RightRule - * @see com.stevesoft.pat.StringRule - */ -public abstract class ReplaceRule -{ - /** points to the next ReplaceRule in the linked list. */ - protected ReplaceRule next = null; - - /** - * This function appends to the StringBufferLike the text you want to replaced - * the portion of the String last matched. - */ - public abstract void apply(StringBufferLike sb, RegRes r); - - /** - * A rule describing how to clone only the current ReplaceRule, and none of - * the others in this linked list. It is called by clone() for each item in - * the list. - */ - public Object clone1() - { - return new RuleHolder(this); - } - - public final Object clone() - { - ReplaceRule x = (ReplaceRule) clone1(); - ReplaceRule xsav = x; - ReplaceRule y = this; - while (y.next != null) - { - x.next = (ReplaceRule) y.next.clone1(); - x.name = y.name; - x = x.next; - y = y.next; - } - return xsav; - } - - static ReplaceRule add(ReplaceRule head, ReplaceRule adding) - { - if (head == null) - { - return head = adding; - } - head.addRule(adding); - return head; - } - - public ReplaceRule add(ReplaceRule adding) - { - return add(this, adding); - } - - /** Add another ReplaceRule to the linked list. */ - public void addRule(ReplaceRule r) - { - if (next == null) - { - next = r; - } - else - { - next.addRule(r); - } - } - - static Regex getvar = null; - - final static Regex getv() - { - // Thanks to Michael Jimenez for pointing out the need - // to clone getvar rather than simply returning it. - // Previously this was not thread safe. - // if(getvar != null) return getvar; - if (getvar != null) - { - return (Regex) getvar.clone(); - } - getvar = new Regex("(?:\\\\(\\d+)|" + // ref 1 - "\\$(?:" + "(\\d+)|" + // ref 2 - "(\\w+)|" + // ref 3 - "([&'`])|" + // ref 4 - "\\{(?:(\\d+)|" + // ref 5 - "([^\n}\\\\]+))}" + // ref 6 - ")|" + "\\\\([nrbtaef])|" + // ref 7 - "\\\\c([\u0000-\uFFFF])|" + // ref 8 - "\\\\x([A-Fa-f0-9]{2})|" + // ref 9 - "\\\\([\u0000-\uFFFF])" + // ref 10 - ")"); - getvar.optimize(); - return getvar; - } - - static Hashtable defs = new Hashtable(); - - public static boolean isDefined(String s) - { - return defs.get(s) != null; - } - - public static void define(String s, Regex r) - { - defs.put(s, r); - } - - public static void define(String s, ReplaceRule r) - { - defs.put(s, r); - r.name = s; - } - - String name = getClass().getName(); - - public static void define(String s, Transformer t) - { - defs.put(s, t); - } - - public static void undefine(String s) - { - defs.remove(s); - } - - /** - * This tells how to convert just the current element (and none of the other - * items in the linked list) to a String. This method is called by toString() - * for each item in the linked list. - */ - public String toString1() - { - return "${" + name + "}"; - } - - /** Convert to a String. */ - public final String toString() - { - javajs.util.SB sb = new javajs.util.SB(); - sb.append(toString1()); - ReplaceRule rr = this.next; - while (rr != null) - { - sb.append(rr.toString1()); - rr = rr.next; - } - return sb.toString(); - } - - /** - * Modified the behavior of a ReplaceRule by supplying an argument. If a - * ReplaceRule named "foo" is defined and the pattern "s/x/${foo:5}/" is given - * to Regex.perlCode, then the "foo" the definition of "foo" will be retrieved - * and arg("5") will be called. If the result is non-null, that is the - * ReplaceRule that will be used. If the result is null, then the pattern - * works just as if it were "s/x/${foo}/". - * - * @see com.stevesoft.pat.Validator#arg(java.lang.String) - */ - public ReplaceRule arg(String s) - { - return null; - } - - static int getHexDigit(char c) - { - if (c >= '0' && c <= '9') - { - return c - '0'; - } - if (c >= 'a' && c <= 'f') - { - return c - 'a' + 10; - } - return c - 'A' + 10; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.Hashtable; + +/** + * ReplaceRule is a singly linked list of Objects which describe how to replace + * the matched portion of a String. The only member method that you absolutely + * need to define to use this class is apply(StringBuffer,RegRes) -- although + * you may want define toString1() and clone1() (if you are unhappy with the + * default methods) that are needed by the clone() or toString() methods on this + * class. During the replacement process, each ReplaceRule tells the replacer + * what to add to javajs.util.SB and uses the contents of the Regular expression + * result to get the information it needs to do this. Here is an example + * + * @see com.stevesoft.pat.NullRule + * @see com.stevesoft.pat.AmpersandRule + * @see com.stevesoft.pat.BackRefRule + * @see com.stevesoft.pat.LeftRule + * @see com.stevesoft.pat.RightRule + * @see com.stevesoft.pat.StringRule + */ +public abstract class ReplaceRule +{ + /** points to the next ReplaceRule in the linked list. */ + protected ReplaceRule next = null; + + /** + * This function appends to the StringBufferLike the text you want to replaced + * the portion of the String last matched. + */ + public abstract void apply(StringBufferLike sb, RegRes r); + + /** + * A rule describing how to clone only the current ReplaceRule, and none of + * the others in this linked list. It is called by clone() for each item in + * the list. + */ + public Object clone1() + { + return new RuleHolder(this); + } + + public final Object clone() + { + ReplaceRule x = (ReplaceRule) clone1(); + ReplaceRule xsav = x; + ReplaceRule y = this; + while (y.next != null) + { + x.next = (ReplaceRule) y.next.clone1(); + x.name = y.name; + x = x.next; + y = y.next; + } + return xsav; + } + + static ReplaceRule add(ReplaceRule head, ReplaceRule adding) + { + if (head == null) + { + return head = adding; + } + head.addRule(adding); + return head; + } + + public ReplaceRule add(ReplaceRule adding) + { + return add(this, adding); + } + + /** Add another ReplaceRule to the linked list. */ + public void addRule(ReplaceRule r) + { + if (next == null) + { + next = r; + } + else + { + next.addRule(r); + } + } + + static Regex getvar = null; + + final static Regex getv() + { + // Thanks to Michael Jimenez for pointing out the need + // to clone getvar rather than simply returning it. + // Previously this was not thread safe. + // if(getvar != null) return getvar; + if (getvar != null) + { + return (Regex) getvar.clone(); + } + getvar = new Regex("(?:\\\\(\\d+)|" + // ref 1 + "\\$(?:" + "(\\d+)|" + // ref 2 + "(\\w+)|" + // ref 3 + "([&'`])|" + // ref 4 + "\\{(?:(\\d+)|" + // ref 5 + "([^\n}\\\\]+))}" + // ref 6 + ")|" + "\\\\([nrbtaef])|" + // ref 7 + "\\\\c([\u0000-\uFFFF])|" + // ref 8 + "\\\\x([A-Fa-f0-9]{2})|" + // ref 9 + "\\\\([\u0000-\uFFFF])" + // ref 10 + ")"); + getvar.optimize(); + return getvar; + } + + static Hashtable defs = new Hashtable(); + + public static boolean isDefined(String s) + { + return defs.get(s) != null; + } + + public static void define(String s, Regex r) + { + defs.put(s, r); + } + + public static void define(String s, ReplaceRule r) + { + defs.put(s, r); + r.name = s; + } + + String name = getClass().getName(); + + public static void define(String s, Transformer t) + { + defs.put(s, t); + } + + public static void undefine(String s) + { + defs.remove(s); + } + + /** + * This tells how to convert just the current element (and none of the other + * items in the linked list) to a String. This method is called by toString() + * for each item in the linked list. + */ + public String toString1() + { + return "${" + name + "}"; + } + + /** Convert to a String. */ + public final String toString() + { + javajs.util.SB sb = new javajs.util.SB(); + sb.append(toString1()); + ReplaceRule rr = this.next; + while (rr != null) + { + sb.append(rr.toString1()); + rr = rr.next; + } + return sb.toString(); + } + + /** + * Modified the behavior of a ReplaceRule by supplying an argument. If a + * ReplaceRule named "foo" is defined and the pattern "s/x/${foo:5}/" is given + * to Regex.perlCode, then the "foo" the definition of "foo" will be retrieved + * and arg("5") will be called. If the result is non-null, that is the + * ReplaceRule that will be used. If the result is null, then the pattern + * works just as if it were "s/x/${foo}/". + * + * @see com.stevesoft.pat.Validator#arg(java.lang.String) + */ + public ReplaceRule arg(String s) + { + return null; + } + + static int getHexDigit(char c) + { + if (c >= '0' && c <= '9') + { + return c - '0'; + } + if (c >= 'a' && c <= 'f') + { + return c - 'a' + 10; + } + return c - 'A' + 10; + } +} diff --git a/unused/com/stevesoft/pat/Replacer.java b/unused/com/stevesoft/pat/Replacer.java index ce9d311..8de8021 100644 --- a/unused/com/stevesoft/pat/Replacer.java +++ b/unused/com/stevesoft/pat/Replacer.java @@ -1,369 +1,369 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import jalview.util.MessageManager; - -import com.stevesoft.pat.wrap.*; - -/** Internally used class. */ -class RegHolder -{ - Regex me = null; - - RegHolder prev = null; -} - -/** - * Internally used class. - * - * @see CodeRule - */ -class CodeVal -{ - int pos; - - char code; - - CodeVal(int p, char c) - { - pos = p; - code = c; - } - - public String toString() - { - return "(" + pos + "," + code + ")"; - } -} - -/** - * To use this class, first use either the getReplacer() method from Transformer - * or Regex. You can then use replaceAll, replaceFirst, etc. methods on the - * Replacer in the same way that you can from either of those two classes. - *

    - * The only potential difference between using the methods of Replacer to do the - * replacing is that Replacer remembers changes to the replacing object between - * calls to replaceAll, replaceFirst etc. For details, see the example file trans3.java. - * - * @see com.stevesoft.pat.Transformer - * @see com.stevesoft.pat.Regex - */ -public class Replacer -{ - boolean first; - - /** Instantiate a new Replacer. */ - public Replacer() - { - } - - public StringLike replaceFirstRegion(String s, Regex r, int start, int end) - { - return replaceFirstRegion(new StringWrap(s), r, start, end); - } - - /** - * This method replaces the first occurence of the Regex in the String - * starting with position pos according to the Replacer rule of this object. - */ - public StringLike replaceFirstRegion(StringLike s, Regex r, int start, - int end) - { - first = true; - rh.me = r; - rh.prev = null; - return dorep(s, start, end); - } - - public StringLike replaceFirst(StringLike s) - { - return replaceFirstRegion(s, 0, s.length()); - } - - public StringLike replaceFirstFrom(StringLike s, int start) - { - return replaceFirstRegion(s, start, s.length()); - } - - public StringLike replaceFirstRegion(StringLike s, int start, int end) - { - first = true; - return dorep(s, start, end); - } - - RegHolder rh = new RegHolder(); - - public StringLike replaceAllRegion(String s, Regex r, int start, int end) - { - return replaceAllRegion(new StringWrap(s), r, start, end); - } - - /** - * This method replaces all occurences of the Regex in the String starting - * with postition pos according to the Replacer rule of this object. - */ - public StringLike replaceAllRegion(StringLike s, Regex r, int start, - int end) - { - first = false; - // reset - rh.me = r; - rh.prev = null; - return dorep(s, start, end); - } - - public StringLike replaceAll(StringLike s) - { - return replaceAllRegion(s, 0, s.length()); - } - - public StringLike replaceAllFrom(StringLike s, int start) - { - return replaceAllRegion(s, start, s.length()); - } - - public StringLike replaceAllRegion(StringLike s, int start, int end) - { - first = false; - return dorep(s, start, end); - } - - public String replaceAll(String s) - { - return replaceAllRegion(new StringWrap(s), 0, s.length()).toString(); - } - - public String replaceAllFrom(String s, int start) - { - return replaceAllRegion(new StringWrap(s), start, s.length()) - .toString(); - } - - public String replaceAllRegion(String s, int start, int end) - { - first = false; - return dorep(new StringWrap(s), start, end).toString(); - } - - final public boolean isSpecial(ReplaceRule x) - { - while (x != null) - { - if (x instanceof SpecialRule - || (x instanceof RuleHolder && ((RuleHolder) x).held instanceof SpecialRule)) - { - return true; - } - x = x.next; - } - return false; - } - - final public void apply1(RegRes rr) - { - rr.charsMatched_++; - apply(rr, null); - rr.charsMatched_--; - } - - final StringLike dorep(StringLike s, int start, int end) - { - StringLike ret = s; - want_more_text = false; - lastMatchedTo = 0; - if (rh.me == null) - { - throw new NullPointerException(MessageManager.getString("exception.replace_null_regex_pointer")); - } - if (rh.me._search(s, start, end)) - { - int rmn = rh.me.matchedTo(); - if (rh.me.charsMatched() == 0 && !isSpecial(rh.me.getReplaceRule())) - { - apply1(rh.me); - rmn++; - } - apply(rh.me); - if (!first) - { - for (int i = rmn; !want_more_text && rh.me._search(s, i, end); i = rmn) - { - rmn = rh.me.matchedTo(); - if (rh.me.charsMatched() == 0) - { - if (!isSpecial(rh.me.getReplaceRule())) - { - apply1(rh.me); - } - rmn++; - } - apply(rh.me); - } - } - ret = finish(); - ret = ret == null ? s : ret; - } - return ret; - } - - StringBufferLike sb = null; - - StringLike src = null; - - int pos = 0; - - /** - * This method allows you to apply the results of several matches in a - * sequence to modify a String of text. Each call in the sequence must operate - * on the same piece of text and the matchedFrom() of each RegRes given to - * this method must be greater in value than the preceeding RegRes's - * matchedTo() value. - */ - public void apply(RegRes r, ReplaceRule rp) - { - if (rp == null || (rp.next == null && rp instanceof AmpersandRule)) - { - return; - } - if (r.didMatch()) - { - if (src == null) - { - src = r.getStringLike(); - } - if (sb == null) - { - sb = new StringBufferLike(src.newStringBufferLike()); - } - int rmf = r.matchedFrom(); - for (int ii = pos; ii < rmf; ii++) - { - sb.appendChar(src.charAt(ii)); - } - - for (ReplaceRule x = rp; x != null; x = x.next) - { - x.apply(sb, r); - if (x instanceof SpecialRule) - { - if (x instanceof WantMoreTextReplaceRule && want_more_text_enable) - { - want_more_text = true; - } - else if (x instanceof PushRule) - { - RegHolder rh2 = new RegHolder(); - rh2.me = ((PushRule) x).NewRule; - rh2.prev = rh; - rh = rh2; - } - else if (x instanceof PopRule) - { - if (rh.prev != null) - { - rh = rh.prev; - } - } - else if (x instanceof ChangeRule) - { - rh.me = ((ChangeRule) x).NewRule; - } - } - } - if (!want_more_text) - { - pos = r.matchedTo(); - } - } - } - - boolean want_more_text = false, want_more_text_enable = false; - - public boolean WantMoreText() - { - return want_more_text; - } - - /** - * Another form of apply, it is the same as apply(r,r.getReplaceRule()). - */ - public void apply(Regex r) - { - apply(r, r.getReplaceRule()); - } - - /** - * This finishes the replacement, appending the right() part of the last - * RegRes given to substitute(RegRes). After this method is called, the - * Replace object is reset to perform another substitution. If no RegRes - * objects with a true didMatch are applied, this returns null. - */ - public StringLike finish() - { - if (src == null) - { - return null; - } - // sb.append(src.substring(pos,src.length())); - int s_end = src.length(); - for (int ii = pos; ii < s_end; ii++) - { - sb.appendChar(src.charAt(ii)); - } - src = null; - lastMatchedTo = pos; - pos = 0; - StringLike retstr = sb.toStringLike(); - sb = null; - return retstr; - } - - int lastMatchedTo = 0; - - public Object clone() - { - Replacer r = new Replacer(); - r.first = first; - r.src = src; - r.sb = sb; - r.pos = pos; - r.lastMatchedTo = lastMatchedTo; - r.want_more_text = want_more_text; - r.want_more_text_enable = want_more_text_enable; - r.rh.me = rh.me; - r.rh.prev = rh.prev; - return r; - } - - public int lastMatchedTo() - { - return lastMatchedTo; - } - - public Regex getRegex() - { - return rh.me; - } - - public void setSource(StringLike sl) - { - src = sl; - } - - public void setBuffer(StringBufferLike sbl) - { - sb = sbl; - } - - public void setPos(int pos) - { - this.pos = pos; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import jalview.util.MessageManager; + +import com.stevesoft.pat.wrap.*; + +/** Internally used class. */ +class RegHolder +{ + Regex me = null; + + RegHolder prev = null; +} + +/** + * Internally used class. + * + * @see CodeRule + */ +class CodeVal +{ + int pos; + + char code; + + CodeVal(int p, char c) + { + pos = p; + code = c; + } + + public String toString() + { + return "(" + pos + "," + code + ")"; + } +} + +/** + * To use this class, first use either the getReplacer() method from Transformer + * or Regex. You can then use replaceAll, replaceFirst, etc. methods on the + * Replacer in the same way that you can from either of those two classes. + *

    + * The only potential difference between using the methods of Replacer to do the + * replacing is that Replacer remembers changes to the replacing object between + * calls to replaceAll, replaceFirst etc. For details, see the example file trans3.java. + * + * @see com.stevesoft.pat.Transformer + * @see com.stevesoft.pat.Regex + */ +public class Replacer +{ + boolean first; + + /** Instantiate a new Replacer. */ + public Replacer() + { + } + + public StringLike replaceFirstRegion(String s, Regex r, int start, int end) + { + return replaceFirstRegion(new StringWrap(s), r, start, end); + } + + /** + * This method replaces the first occurence of the Regex in the String + * starting with position pos according to the Replacer rule of this object. + */ + public StringLike replaceFirstRegion(StringLike s, Regex r, int start, + int end) + { + first = true; + rh.me = r; + rh.prev = null; + return dorep(s, start, end); + } + + public StringLike replaceFirst(StringLike s) + { + return replaceFirstRegion(s, 0, s.length()); + } + + public StringLike replaceFirstFrom(StringLike s, int start) + { + return replaceFirstRegion(s, start, s.length()); + } + + public StringLike replaceFirstRegion(StringLike s, int start, int end) + { + first = true; + return dorep(s, start, end); + } + + RegHolder rh = new RegHolder(); + + public StringLike replaceAllRegion(String s, Regex r, int start, int end) + { + return replaceAllRegion(new StringWrap(s), r, start, end); + } + + /** + * This method replaces all occurences of the Regex in the String starting + * with postition pos according to the Replacer rule of this object. + */ + public StringLike replaceAllRegion(StringLike s, Regex r, int start, + int end) + { + first = false; + // reset + rh.me = r; + rh.prev = null; + return dorep(s, start, end); + } + + public StringLike replaceAll(StringLike s) + { + return replaceAllRegion(s, 0, s.length()); + } + + public StringLike replaceAllFrom(StringLike s, int start) + { + return replaceAllRegion(s, start, s.length()); + } + + public StringLike replaceAllRegion(StringLike s, int start, int end) + { + first = false; + return dorep(s, start, end); + } + + public String replaceAll(String s) + { + return replaceAllRegion(new StringWrap(s), 0, s.length()).toString(); + } + + public String replaceAllFrom(String s, int start) + { + return replaceAllRegion(new StringWrap(s), start, s.length()) + .toString(); + } + + public String replaceAllRegion(String s, int start, int end) + { + first = false; + return dorep(new StringWrap(s), start, end).toString(); + } + + final public boolean isSpecial(ReplaceRule x) + { + while (x != null) + { + if (x instanceof SpecialRule + || (x instanceof RuleHolder && ((RuleHolder) x).held instanceof SpecialRule)) + { + return true; + } + x = x.next; + } + return false; + } + + final public void apply1(RegRes rr) + { + rr.charsMatched_++; + apply(rr, null); + rr.charsMatched_--; + } + + final StringLike dorep(StringLike s, int start, int end) + { + StringLike ret = s; + want_more_text = false; + lastMatchedTo = 0; + if (rh.me == null) + { + throw new NullPointerException(MessageManager.getString("exception.replace_null_regex_pointer")); + } + if (rh.me._search(s, start, end)) + { + int rmn = rh.me.matchedTo(); + if (rh.me.charsMatched() == 0 && !isSpecial(rh.me.getReplaceRule())) + { + apply1(rh.me); + rmn++; + } + apply(rh.me); + if (!first) + { + for (int i = rmn; !want_more_text && rh.me._search(s, i, end); i = rmn) + { + rmn = rh.me.matchedTo(); + if (rh.me.charsMatched() == 0) + { + if (!isSpecial(rh.me.getReplaceRule())) + { + apply1(rh.me); + } + rmn++; + } + apply(rh.me); + } + } + ret = finish(); + ret = ret == null ? s : ret; + } + return ret; + } + + StringBufferLike sb = null; + + StringLike src = null; + + int pos = 0; + + /** + * This method allows you to apply the results of several matches in a + * sequence to modify a String of text. Each call in the sequence must operate + * on the same piece of text and the matchedFrom() of each RegRes given to + * this method must be greater in value than the preceeding RegRes's + * matchedTo() value. + */ + public void apply(RegRes r, ReplaceRule rp) + { + if (rp == null || (rp.next == null && rp instanceof AmpersandRule)) + { + return; + } + if (r.didMatch()) + { + if (src == null) + { + src = r.getStringLike(); + } + if (sb == null) + { + sb = new StringBufferLike(src.newStringBufferLike()); + } + int rmf = r.matchedFrom(); + for (int ii = pos; ii < rmf; ii++) + { + sb.appendChar(src.charAt(ii)); + } + + for (ReplaceRule x = rp; x != null; x = x.next) + { + x.apply(sb, r); + if (x instanceof SpecialRule) + { + if (x instanceof WantMoreTextReplaceRule && want_more_text_enable) + { + want_more_text = true; + } + else if (x instanceof PushRule) + { + RegHolder rh2 = new RegHolder(); + rh2.me = ((PushRule) x).NewRule; + rh2.prev = rh; + rh = rh2; + } + else if (x instanceof PopRule) + { + if (rh.prev != null) + { + rh = rh.prev; + } + } + else if (x instanceof ChangeRule) + { + rh.me = ((ChangeRule) x).NewRule; + } + } + } + if (!want_more_text) + { + pos = r.matchedTo(); + } + } + } + + boolean want_more_text = false, want_more_text_enable = false; + + public boolean WantMoreText() + { + return want_more_text; + } + + /** + * Another form of apply, it is the same as apply(r,r.getReplaceRule()). + */ + public void apply(Regex r) + { + apply(r, r.getReplaceRule()); + } + + /** + * This finishes the replacement, appending the right() part of the last + * RegRes given to substitute(RegRes). After this method is called, the + * Replace object is reset to perform another substitution. If no RegRes + * objects with a true didMatch are applied, this returns null. + */ + public StringLike finish() + { + if (src == null) + { + return null; + } + // sb.append(src.substring(pos,src.length())); + int s_end = src.length(); + for (int ii = pos; ii < s_end; ii++) + { + sb.appendChar(src.charAt(ii)); + } + src = null; + lastMatchedTo = pos; + pos = 0; + StringLike retstr = sb.toStringLike(); + sb = null; + return retstr; + } + + int lastMatchedTo = 0; + + public Object clone() + { + Replacer r = new Replacer(); + r.first = first; + r.src = src; + r.sb = sb; + r.pos = pos; + r.lastMatchedTo = lastMatchedTo; + r.want_more_text = want_more_text; + r.want_more_text_enable = want_more_text_enable; + r.rh.me = rh.me; + r.rh.prev = rh.prev; + return r; + } + + public int lastMatchedTo() + { + return lastMatchedTo; + } + + public Regex getRegex() + { + return rh.me; + } + + public void setSource(StringLike sl) + { + src = sl; + } + + public void setBuffer(StringBufferLike sbl) + { + sb = sbl; + } + + public void setPos(int pos) + { + this.pos = pos; + } +} diff --git a/unused/com/stevesoft/pat/RightRule.java b/unused/com/stevesoft/pat/RightRule.java index 6cef168..cf0e67f 100644 --- a/unused/com/stevesoft/pat/RightRule.java +++ b/unused/com/stevesoft/pat/RightRule.java @@ -1,31 +1,31 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * The apply(StringBufferLike sb,RegRes res) method of this derivation of - * ReplaceRule appends the contents of res.right() to the StringBufferLike sb. - * - * @see com.stevesoft.pat.ReplaceRule - */ -public class RightRule extends ReplaceRule -{ - public RightRule() - { - } - - public void apply(StringBufferLike sb, RegRes res) - { - sb.appendStr(res.right()); - } - - public String toString1() - { - return "$'"; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * The apply(StringBufferLike sb,RegRes res) method of this derivation of + * ReplaceRule appends the contents of res.right() to the StringBufferLike sb. + * + * @see com.stevesoft.pat.ReplaceRule + */ +public class RightRule extends ReplaceRule +{ + public RightRule() + { + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.appendStr(res.right()); + } + + public String toString1() + { + return "$'"; + } +} diff --git a/unused/com/stevesoft/pat/Rthings.java b/unused/com/stevesoft/pat/Rthings.java index 58afe8e..23497e1 100644 --- a/unused/com/stevesoft/pat/Rthings.java +++ b/unused/com/stevesoft/pat/Rthings.java @@ -1,68 +1,68 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - Shareware: package pat - Copyright 2001, Steven R. Brandt - */ -/** - * This class only exists to store data needed during the compilation of a - * regular expression. - */ -public class Rthings -{ - /** - * The numeric identity of the next () to be encountered while compiling the - * pattern. - */ - public int val = Regex.BackRefOffset; - - /** - * Needed in case (?i) is encountered, to pass back the message that - * ignoreCase should be set. - */ - public boolean ignoreCase; - - /** - * Needed in case (?Q) is encountered, to pass back the message that - * dontMatchInQuotes should be set. - */ - public boolean dontMatchInQuotes; - - public boolean optimizeMe = false; - - public boolean noBackRefs = false; - - public int parenLevel = 0; - - boolean gFlag = false, mFlag = false, sFlag = false; - - Pattern p; - - Or o; - - Rthings(Regex r) - { - ignoreCase = r.ignoreCase; - dontMatchInQuotes = r.dontMatchInQuotes; - } - - void set(Regex r) - { - r.gFlag = gFlag; - r.mFlag = mFlag; - r.sFlag = sFlag; - r.ignoreCase = ignoreCase; - r.dontMatchInQuotes = dontMatchInQuotes; - if (optimizeMe) - { - r.optimize(); - } - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + Shareware: package pat + Copyright 2001, Steven R. Brandt + */ +/** + * This class only exists to store data needed during the compilation of a + * regular expression. + */ +public class Rthings +{ + /** + * The numeric identity of the next () to be encountered while compiling the + * pattern. + */ + public int val = Regex.BackRefOffset; + + /** + * Needed in case (?i) is encountered, to pass back the message that + * ignoreCase should be set. + */ + public boolean ignoreCase; + + /** + * Needed in case (?Q) is encountered, to pass back the message that + * dontMatchInQuotes should be set. + */ + public boolean dontMatchInQuotes; + + public boolean optimizeMe = false; + + public boolean noBackRefs = false; + + public int parenLevel = 0; + + boolean gFlag = false, mFlag = false, sFlag = false; + + Pattern p; + + Or o; + + Rthings(Regex r) + { + ignoreCase = r.ignoreCase; + dontMatchInQuotes = r.dontMatchInQuotes; + } + + void set(Regex r) + { + r.gFlag = gFlag; + r.mFlag = mFlag; + r.sFlag = sFlag; + r.ignoreCase = ignoreCase; + r.dontMatchInQuotes = dontMatchInQuotes; + if (optimizeMe) + { + r.optimize(); + } + } +}; diff --git a/unused/com/stevesoft/pat/RuleHolder.java b/unused/com/stevesoft/pat/RuleHolder.java index 8b50149..688c78a 100644 --- a/unused/com/stevesoft/pat/RuleHolder.java +++ b/unused/com/stevesoft/pat/RuleHolder.java @@ -1,43 +1,43 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** This class is used internally. */ -class RuleHolder extends ReplaceRule -{ - ReplaceRule held = null; - - RuleHolder() - { - } - - RuleHolder(ReplaceRule h) - { - held = h; - } - - public Object clone1() - { - return new RuleHolder(held); - } - - public String toString1() - { - return held.toString1(); - } - - public void apply(StringBufferLike sb, RegRes rr) - { - held.apply(sb, rr); - } - - public ReplaceRule arg(String s) - { - return new RuleHolder(held.arg(s)); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** This class is used internally. */ +class RuleHolder extends ReplaceRule +{ + ReplaceRule held = null; + + RuleHolder() + { + } + + RuleHolder(ReplaceRule h) + { + held = h; + } + + public Object clone1() + { + return new RuleHolder(held); + } + + public String toString1() + { + return held.toString1(); + } + + public void apply(StringBufferLike sb, RegRes rr) + { + held.apply(sb, rr); + } + + public ReplaceRule arg(String s) + { + return new RuleHolder(held.arg(s)); + } +} diff --git a/unused/com/stevesoft/pat/Skip.java b/unused/com/stevesoft/pat/Skip.java index af56714..ef5f3f0 100644 --- a/unused/com/stevesoft/pat/Skip.java +++ b/unused/com/stevesoft/pat/Skip.java @@ -1,196 +1,196 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class is used internally to search ahead for some optimized Regex - * objects. It searches within a String for occrences of a given String -- like - * a more flexible version of String.indexOf. - * - * @see com.stevesoft.pat.Skip2 - * @see com.stevesoft.pat.SkipBMH - */ -public class Skip -{ - static int mkmask(int c) - { - char x = (char) c; - return ~(CaseMgr.toUpperCase(x) | CaseMgr.toLowerCase(x) | CaseMgr - .toTitleCase(x)); - } - - String src; - - int c, mask; - - int offset; - - boolean ign, m1; - - /** - * Examine a Regex to determine what String it will attempt to skip to when - * searching for patterns. Return -1 if we aren't doing this. - */ - public static String string(Regex r) - { - return r.skipper == null ? null : r.skipper.src; - } - - /** - * Determine the offset of the String within the pattern that we are skipping - * to. Return -1 if we aren't doing this. - */ - public static int offset(Regex r) - { - return r.skipper == null ? -1 : r.skipper.offset; - } - - /** - * Initialize, give it a String to search for, tell it whether or not to - * ignoreCase, and what the offset is of the String within the String to be - * searched. - */ - public Skip(String s, boolean ign, int o) - { - src = s; - c = s.charAt(0); - if (ign) - { - mask = mkmask(c); - } - else - { - mask = 0; - } - offset = o; - this.ign = ign; - m1 = (s.length() == 1); - } - - /** The same as find(s,0,s.length()) */ - public final int find(StringLike s) - { - return find(s, 0, s.length()); - } - - static final int min(int a, int b) - { - return a < b ? a : b; - } - - /** - * Searches a given region of text beginning at position start and ending at - * position end for the skip object. - */ - public int find(StringLike s, int start, int end) - { - if (start > end) - { - return -1; - } - start += offset; - int vend = min(s.length() - 1, end + offset); - if (mask != c) - { - for (int i = start; i <= vend; i++) - { - if (0 == (s.charAt(i) & mask)) - { - // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) - if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) - { - return i - offset; - } - } - } - } - else - { - for (int i = start; i <= vend; i++) - { - if (c == s.charAt(i)) - { - // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) - if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) - { - return i - offset; - } - } - } - } - return -1; - } - - static Skip findSkip(Regex r) - { - return findSkip(r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); - } - - // look for things that can be skipped - static Skip findSkip(Pattern p, boolean ignoreCase, boolean trnc) - { - javajs.util.SB sb = new javajs.util.SB(); - Skip subsk = null; - int offset = 0; - int skipc = -1, skipoff = 0; - for (; p != null; p = p.next) - { - if (p instanceof oneChar) - { - skipc = ((oneChar) p).c; - skipoff = offset; - } - if (p instanceof oneChar && p.next instanceof oneChar) - { - Pattern psav = p; - sb.appendC(((oneChar) p).c); - while (p.next instanceof oneChar) - { - sb.appendC(((oneChar) p.next).c); - p = p.next; - } - String st = sb.toString(); - Skip sk = null; - if (st.length() > 2) - { - sk = new SkipBMH(st, ignoreCase, offset); - } - else - { - sk = new Skip2(st, ignoreCase, offset); - } - if (trnc && st.length() > 2) - { // chop out a whole string... - psav.next = new Skipped(st.substring(1)); - psav.next.next = p.next; - psav.next.parent = p.parent; - } - return sk; - } - else if (p instanceof Or - && ((Or) p).v.size() == 1 - && !((Or) p).leftForm().equals("(?!") - && null != (subsk = findSkip((Pattern) ((Or) p).v - .elementAt(0), ignoreCase, trnc))) - { - subsk.offset += offset; - return subsk; - } - else if (p.minChars().equals(p.maxChars())) - { - offset += p.minChars().intValue(); - } - else - { - return skipc < 0 ? null : new Skip("" + (char) skipc, ignoreCase, - skipoff); - } - } - return null; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class is used internally to search ahead for some optimized Regex + * objects. It searches within a String for occrences of a given String -- like + * a more flexible version of String.indexOf. + * + * @see com.stevesoft.pat.Skip2 + * @see com.stevesoft.pat.SkipBMH + */ +public class Skip +{ + static int mkmask(int c) + { + char x = (char) c; + return ~(CaseMgr.toUpperCase(x) | CaseMgr.toLowerCase(x) | CaseMgr + .toTitleCase(x)); + } + + String src; + + int c, mask; + + int offset; + + boolean ign, m1; + + /** + * Examine a Regex to determine what String it will attempt to skip to when + * searching for patterns. Return -1 if we aren't doing this. + */ + public static String string(Regex r) + { + return r.skipper == null ? null : r.skipper.src; + } + + /** + * Determine the offset of the String within the pattern that we are skipping + * to. Return -1 if we aren't doing this. + */ + public static int offset(Regex r) + { + return r.skipper == null ? -1 : r.skipper.offset; + } + + /** + * Initialize, give it a String to search for, tell it whether or not to + * ignoreCase, and what the offset is of the String within the String to be + * searched. + */ + public Skip(String s, boolean ign, int o) + { + src = s; + c = s.charAt(0); + if (ign) + { + mask = mkmask(c); + } + else + { + mask = 0; + } + offset = o; + this.ign = ign; + m1 = (s.length() == 1); + } + + /** The same as find(s,0,s.length()) */ + public final int find(StringLike s) + { + return find(s, 0, s.length()); + } + + static final int min(int a, int b) + { + return a < b ? a : b; + } + + /** + * Searches a given region of text beginning at position start and ending at + * position end for the skip object. + */ + public int find(StringLike s, int start, int end) + { + if (start > end) + { + return -1; + } + start += offset; + int vend = min(s.length() - 1, end + offset); + if (mask != c) + { + for (int i = start; i <= vend; i++) + { + if (0 == (s.charAt(i) & mask)) + { + // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) + { + return i - offset; + } + } + } + } + else + { + for (int i = start; i <= vend; i++) + { + if (c == s.charAt(i)) + { + // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) + { + return i - offset; + } + } + } + } + return -1; + } + + static Skip findSkip(Regex r) + { + return findSkip(r.thePattern, r.ignoreCase, !r.dontMatchInQuotes); + } + + // look for things that can be skipped + static Skip findSkip(Pattern p, boolean ignoreCase, boolean trnc) + { + javajs.util.SB sb = new javajs.util.SB(); + Skip subsk = null; + int offset = 0; + int skipc = -1, skipoff = 0; + for (; p != null; p = p.next) + { + if (p instanceof oneChar) + { + skipc = ((oneChar) p).c; + skipoff = offset; + } + if (p instanceof oneChar && p.next instanceof oneChar) + { + Pattern psav = p; + sb.appendC(((oneChar) p).c); + while (p.next instanceof oneChar) + { + sb.appendC(((oneChar) p.next).c); + p = p.next; + } + String st = sb.toString(); + Skip sk = null; + if (st.length() > 2) + { + sk = new SkipBMH(st, ignoreCase, offset); + } + else + { + sk = new Skip2(st, ignoreCase, offset); + } + if (trnc && st.length() > 2) + { // chop out a whole string... + psav.next = new Skipped(st.substring(1)); + psav.next.next = p.next; + psav.next.parent = p.parent; + } + return sk; + } + else if (p instanceof Or + && ((Or) p).v.size() == 1 + && !((Or) p).leftForm().equals("(?!") + && null != (subsk = findSkip((Pattern) ((Or) p).v + .elementAt(0), ignoreCase, trnc))) + { + subsk.offset += offset; + return subsk; + } + else if (p.minChars().equals(p.maxChars())) + { + offset += p.minChars().intValue(); + } + else + { + return skipc < 0 ? null : new Skip("" + (char) skipc, ignoreCase, + skipoff); + } + } + return null; + } +} diff --git a/unused/com/stevesoft/pat/Skip2.java b/unused/com/stevesoft/pat/Skip2.java index 5f6bb5a..f861336 100644 --- a/unused/com/stevesoft/pat/Skip2.java +++ b/unused/com/stevesoft/pat/Skip2.java @@ -1,57 +1,57 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This is the same as Skip, except it needs a minimum of two characters in the - * initializing String. - * - * @see com.stevesoft.pat.Skip - * @see com.stevesoft.pat.SkipBMH - */ -public class Skip2 extends Skip -{ - int c1, mask1; - - public Skip2(String s, boolean ign, int offset) - { - super(s, ign, offset); - c1 = s.charAt(1); - m1 = 2 == s.length(); - if (ign) - { - mask1 = mkmask(c1); - } - else - { - mask1 = 0; - } - } - - public int find(StringLike s, int start, int end) - { - if (start > end) - { - return -1; - } - start += offset; - int vend = min(s.length() - 2, end + offset); - for (int i = start; i <= vend; i++) - { - if (0 == (s.charAt(i) & mask) && 0 == (s.charAt(i + 1) & mask1)) - { - // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) - if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) - { - return i - offset; - } - } - } - return -1; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This is the same as Skip, except it needs a minimum of two characters in the + * initializing String. + * + * @see com.stevesoft.pat.Skip + * @see com.stevesoft.pat.SkipBMH + */ +public class Skip2 extends Skip +{ + int c1, mask1; + + public Skip2(String s, boolean ign, int offset) + { + super(s, ign, offset); + c1 = s.charAt(1); + m1 = 2 == s.length(); + if (ign) + { + mask1 = mkmask(c1); + } + else + { + mask1 = 0; + } + } + + public int find(StringLike s, int start, int end) + { + if (start > end) + { + return -1; + } + start += offset; + int vend = min(s.length() - 2, end + offset); + for (int i = start; i <= vend; i++) + { + if (0 == (s.charAt(i) & mask) && 0 == (s.charAt(i + 1) & mask1)) + { + // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) + if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) + { + return i - offset; + } + } + } + return -1; + } +} diff --git a/unused/com/stevesoft/pat/SkipBMH.java b/unused/com/stevesoft/pat/SkipBMH.java index 1397b90..afb3fd0 100644 --- a/unused/com/stevesoft/pat/SkipBMH.java +++ b/unused/com/stevesoft/pat/SkipBMH.java @@ -1,279 +1,279 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import com.stevesoft.pat.wrap.*; - -/** - * Like Skip, but implements a - * Boyer-Moore-Horspool type search method that has been modified to be - * more like a "T-search" (see the Michael Tamm''s article in C'T, magazin - * fuer computer und technic, August 97 p 292). Yet another important - * source of information for me was the Deep Magic - * article on string searching. As of this writing, I can beat String's indexOf - * method in many cases. - * - * @see com.stevesoft.pat.Skip - * @see com.stevesoft.pat.Skip2 - */ -public class SkipBMH extends Skip -{ - // This number could be 256, but I think it's - // big enough. Note, it must be a power of 2. - final int MAX_CHAR = 64; - - final char[] skip = new char[MAX_CHAR]; - - int sm1; - - int jump_ahead = 0; - - char uc, lc, tc, x; - - final boolean exact(char c) - { - return (ign && anyc(c)) || c == x; - } - - final boolean anyc(char c) - { - return c == uc || c == lc || c == tc; - } - - public SkipBMH(String pt, boolean ign) - { - this(pt, ign, 0); - } - - public SkipBMH(String pt) - { - this(pt, false, 0); - } - - public SkipBMH(String pt, boolean ign, int offset) - { - super(pt, ign, offset); - for (int k = 0; k < MAX_CHAR; k++) - { - skip[k] = (char) src.length(); - } - - sm1 = src.length() - 1; - x = src.charAt(sm1); - uc = CaseMgr.toUpperCase(x); - lc = CaseMgr.toLowerCase(x); - tc = CaseMgr.toTitleCase(x); - - // We don't really want 65536 long arrays in skip[], - // so we mask of the higher bits. This can be combined - // with ignore case, so accounting for upper - // case costs us nothing extra. - for (int k = 0; k < src.length() - 1; k++) - { - char x_ = src.charAt(k); - if (ign) - { - char uc_ = CaseMgr.toUpperCase(x_); - char lc_ = CaseMgr.toLowerCase(x_); - char tc_ = CaseMgr.toTitleCase(x_); - skip[uc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); - skip[lc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); - skip[tc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); - } - else - { - skip[x_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); - } - } - - // This trick can be found in the July issue of - // C-T magazine. This makes the method a type of - // "T-search." - jump_ahead = src.length() - 1; - for (int k = 0; k < src.length() - 1; k++) - { - char y = src.charAt(sm1 - k - 1); - if (exact(y)) - { - jump_ahead = k; - break; - } - } - } - - /** - * Set to true if you only want to compare two of the characters in the - * String. - */ - final public int searchRegion(String s, int start, int end) - { - return find(s, start, end); - } - - final public int searchFrom(String s, int start) - { - return find(s, start, s.length()); - } - - final public int search(String s) - { - return find(s, 0, s.length()); - } - - public int find(String s, int start, int end) - { - start += offset + sm1; - int vend = min(s.length() - 1, end + sm1 + offset), k; - int vend1 = vend - jump_ahead; - if (ign) - { - for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (anyc(s.charAt(k))) - { - if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - } - } - for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (anyc(s.charAt(k))) - { - if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - if (k > vend) - { - return -1; - } - } - } - } - else - { - for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (x == s.charAt(k)) - { - // if(src.regionMatches(0,s,k-sm1,sm1)) - if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - } - } - for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (x == s.charAt(k)) - { - // if(src.regionMatches(0,s,k-sm1,sm1)) - if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - if (k > vend) - { - return -1; - } - } - } - } - - return -1; - } - - public int find(StringLike s, int start, int end) - { - if (s instanceof StringWrap) - { - return find(s.toString(), start, end); - } - start += offset + sm1; - int vend = min(s.length() - 1, end + sm1 + offset), k; - int vend1 = vend - jump_ahead; - if (ign) - { - for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (anyc(s.charAt(k))) - { - if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - } - } - for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (anyc(s.charAt(k))) - { - if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - if (k > vend) - { - return -1; - } - } - } - } - else - { - for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (x == s.charAt(k)) - { - // if(src.regionMatches(0,s,k-sm1,sm1)) - if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - } - } - for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) - { - // table look-up is expensive, avoid it if possible - if (x == s.charAt(k)) - { - // if(src.regionMatches(0,s,k-sm1,sm1)) - if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) - { - return k - sm1 - offset; - } - k += jump_ahead; - if (k > vend) - { - return -1; - } - } - } - } - - return -1; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import com.stevesoft.pat.wrap.*; + +/** + * Like Skip, but implements a + * Boyer-Moore-Horspool type search method that has been modified to be + * more like a "T-search" (see the Michael Tamm''s article in C'T, magazin + * fuer computer und technic, August 97 p 292). Yet another important + * source of information for me was the Deep Magic + * article on string searching. As of this writing, I can beat String's indexOf + * method in many cases. + * + * @see com.stevesoft.pat.Skip + * @see com.stevesoft.pat.Skip2 + */ +public class SkipBMH extends Skip +{ + // This number could be 256, but I think it's + // big enough. Note, it must be a power of 2. + final int MAX_CHAR = 64; + + final char[] skip = new char[MAX_CHAR]; + + int sm1; + + int jump_ahead = 0; + + char uc, lc, tc, x; + + final boolean exact(char c) + { + return (ign && anyc(c)) || c == x; + } + + final boolean anyc(char c) + { + return c == uc || c == lc || c == tc; + } + + public SkipBMH(String pt, boolean ign) + { + this(pt, ign, 0); + } + + public SkipBMH(String pt) + { + this(pt, false, 0); + } + + public SkipBMH(String pt, boolean ign, int offset) + { + super(pt, ign, offset); + for (int k = 0; k < MAX_CHAR; k++) + { + skip[k] = (char) src.length(); + } + + sm1 = src.length() - 1; + x = src.charAt(sm1); + uc = CaseMgr.toUpperCase(x); + lc = CaseMgr.toLowerCase(x); + tc = CaseMgr.toTitleCase(x); + + // We don't really want 65536 long arrays in skip[], + // so we mask of the higher bits. This can be combined + // with ignore case, so accounting for upper + // case costs us nothing extra. + for (int k = 0; k < src.length() - 1; k++) + { + char x_ = src.charAt(k); + if (ign) + { + char uc_ = CaseMgr.toUpperCase(x_); + char lc_ = CaseMgr.toLowerCase(x_); + char tc_ = CaseMgr.toTitleCase(x_); + skip[uc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + skip[lc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + skip[tc_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + } + else + { + skip[x_ & (MAX_CHAR - 1)] = (char) (src.length() - k - 1); + } + } + + // This trick can be found in the July issue of + // C-T magazine. This makes the method a type of + // "T-search." + jump_ahead = src.length() - 1; + for (int k = 0; k < src.length() - 1; k++) + { + char y = src.charAt(sm1 - k - 1); + if (exact(y)) + { + jump_ahead = k; + break; + } + } + } + + /** + * Set to true if you only want to compare two of the characters in the + * String. + */ + final public int searchRegion(String s, int start, int end) + { + return find(s, start, end); + } + + final public int searchFrom(String s, int start) + { + return find(s, start, s.length()); + } + + final public int search(String s) + { + return find(s, 0, s.length()); + } + + public int find(String s, int start, int end) + { + start += offset + sm1; + int vend = min(s.length() - 1, end + sm1 + offset), k; + int vend1 = vend - jump_ahead; + if (ign) + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (anyc(s.charAt(k))) + { + if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + } + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (anyc(s.charAt(k))) + { + if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } + } + else + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + // if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + } + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + // if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } + } + + return -1; + } + + public int find(StringLike s, int start, int end) + { + if (s instanceof StringWrap) + { + return find(s.toString(), start, end); + } + start += offset + sm1; + int vend = min(s.length() - 1, end + sm1 + offset), k; + int vend1 = vend - jump_ahead; + if (ign) + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (anyc(s.charAt(k))) + { + if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + } + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (anyc(s.charAt(k))) + { + if (CaseMgr.regionMatches(src, ign, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } + } + else + { + for (k = start; k <= vend1; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + // if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + } + } + for (; k <= vend; k += skip[s.charAt(k) & (MAX_CHAR - 1)]) + { + // table look-up is expensive, avoid it if possible + if (x == s.charAt(k)) + { + // if(src.regionMatches(0,s,k-sm1,sm1)) + if (CaseMgr.regionMatches(src, false, 0, s, k - sm1, sm1)) + { + return k - sm1 - offset; + } + k += jump_ahead; + if (k > vend) + { + return -1; + } + } + } + } + + return -1; + } +} diff --git a/unused/com/stevesoft/pat/Skipped.java b/unused/com/stevesoft/pat/Skipped.java index 551166b..9d5ff86 100644 --- a/unused/com/stevesoft/pat/Skipped.java +++ b/unused/com/stevesoft/pat/Skipped.java @@ -1,56 +1,56 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** - * Implements the (?<number) Pattern, where number is an integer telling us - * how far to back up in the Pattern. Not in perl 5. - */ -class Skipped extends Pattern -{ - String s; - - Skipped(String s) - { - this.s = s; - } - - public String toString() - { - return s + nextString(); - } - - public int matchInternal(int pos, Pthings pt) - { - // if(pt.no_check || s.regionMatches(pt.ignoreCase,0,pt.src,pos,s.length())) - if (pt.no_check - || CaseMgr.regionMatches(s, pt.ignoreCase, 0, pt.src, pos, s - .length())) - { - return nextMatch(pos + s.length(), pt); - } - return -1; - } - - public patInt minChars() - { - return new patInt(s.length()); - } - - public patInt maxChars() - { - return new patInt(s.length()); - } - - Pattern clone1(Hashtable h) - { - return new Skipped(s); - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** + * Implements the (?<number) Pattern, where number is an integer telling us + * how far to back up in the Pattern. Not in perl 5. + */ +class Skipped extends Pattern +{ + String s; + + Skipped(String s) + { + this.s = s; + } + + public String toString() + { + return s + nextString(); + } + + public int matchInternal(int pos, Pthings pt) + { + // if(pt.no_check || s.regionMatches(pt.ignoreCase,0,pt.src,pos,s.length())) + if (pt.no_check + || CaseMgr.regionMatches(s, pt.ignoreCase, 0, pt.src, pos, s + .length())) + { + return nextMatch(pos + s.length(), pt); + } + return -1; + } + + public patInt minChars() + { + return new patInt(s.length()); + } + + public patInt maxChars() + { + return new patInt(s.length()); + } + + Pattern clone1(Hashtable h) + { + return new Skipped(s); + } +}; diff --git a/unused/com/stevesoft/pat/SpecialRule.java b/unused/com/stevesoft/pat/SpecialRule.java index 2a249a2..09517c2 100644 --- a/unused/com/stevesoft/pat/SpecialRule.java +++ b/unused/com/stevesoft/pat/SpecialRule.java @@ -1,19 +1,19 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -public class SpecialRule extends ReplaceRule -{ - public SpecialRule() - { - } - - public void apply(StringBufferLike sb, RegRes rr) - { - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +public class SpecialRule extends ReplaceRule +{ + public SpecialRule() + { + } + + public void apply(StringBufferLike sb, RegRes rr) + { + } +} diff --git a/unused/com/stevesoft/pat/Start.java b/unused/com/stevesoft/pat/Start.java index 650e7a7..fe84b8a 100644 --- a/unused/com/stevesoft/pat/Start.java +++ b/unused/com/stevesoft/pat/Start.java @@ -1,56 +1,56 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** The '^' or the '\A' Pattern, matches the start of a string. */ -class Start extends Pattern -{ - boolean retIsStart; - - Start(boolean b) - { - retIsStart = b; - } - - public int matchInternal(int pos, Pthings pt) - { - if (retIsStart && pt.mFlag && pos > 0 && pt.src.charAt(pos - 1) == '\n') - { - return nextMatch(pos, pt); - } - if (pos == 0) - { - return nextMatch(pos, pt); - } - return -1; - } - - public String toString() - { - if (retIsStart) - { - return "^" + nextString(); - } - else - { - return "\\A" + nextString(); - } - } - - public patInt maxChars() - { - return new patInt(0); - } - - Pattern clone1(Hashtable h) - { - return new Start(retIsStart); - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** The '^' or the '\A' Pattern, matches the start of a string. */ +class Start extends Pattern +{ + boolean retIsStart; + + Start(boolean b) + { + retIsStart = b; + } + + public int matchInternal(int pos, Pthings pt) + { + if (retIsStart && pt.mFlag && pos > 0 && pt.src.charAt(pos - 1) == '\n') + { + return nextMatch(pos, pt); + } + if (pos == 0) + { + return nextMatch(pos, pt); + } + return -1; + } + + public String toString() + { + if (retIsStart) + { + return "^" + nextString(); + } + else + { + return "\\A" + nextString(); + } + } + + public patInt maxChars() + { + return new patInt(0); + } + + Pattern clone1(Hashtable h) + { + return new Start(retIsStart); + } +}; diff --git a/unused/com/stevesoft/pat/StrPos.java b/unused/com/stevesoft/pat/StrPos.java index 1f08e31..ea3c6ce 100644 --- a/unused/com/stevesoft/pat/StrPos.java +++ b/unused/com/stevesoft/pat/StrPos.java @@ -1,192 +1,192 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - Shareware: package pat - Copyright 2001, Steven R. Brandt - */ -/** - * StrPos is used internally by regex to parse the regular expression. - */ -public class StrPos -{ - String s; - - int pos; - - /** Return the position in the string pointed to */ - public int pos() - { - return pos; - } - - /** This contains the escape character, which is \ by default. */ - public char esc = Pattern.ESC; - - char c; - - /** Returns the current, possibly escaped, character. */ - public char thisChar() - { - return c; - } - - boolean dontMatch, eos; - - /** tell whether we are at end of string */ - public boolean eos() - { - return eos; - } - - /** initialize a StrPos from another StrPos. */ - public StrPos(StrPos sp) - { - dup(sp); - } - - /** copy a StrPos from sp to this. */ - public void dup(StrPos sp) - { - s = sp.s; - pos = sp.pos; - c = sp.c; - dontMatch = sp.dontMatch; - eos = sp.eos; - } - - /** - * Initialize a StrPos by giving it a String, and a position within the - * String. - */ - public StrPos(String s, int pos) - { - this.s = s; - this.pos = pos - 1; - inc(); - } - - /** - * Advance the place where StrPos points within the String. Counts a backslash - * as part of the next character. - */ - public StrPos inc() - { - pos++; - if (pos >= s.length()) - { - eos = true; - return this; - } - eos = false; - c = s.charAt(pos); - if (c == esc && pos + 1 < s.length()) - { - pos++; - c = s.charAt(pos); - if (c != esc) - { - dontMatch = true; - } - else - { - dontMatch = false; - } - } - else - { - dontMatch = false; - } - return this; - } - - /** - * Compare the (possibly escaped) character pointed to by StrPos. Return true - * if they are the same, but lways return if character pointed to is escaped. - */ - public boolean match(char ch) - { - if (dontMatch || eos) - { - return false; - } - return c == ch; - } - - /** As match, but only matches if the character is escaped. */ - public boolean escMatch(char ch) - { - if (!dontMatch || eos) - { - return false; - } - return c == ch; - } - - /** - * Returns true if the current character is escaped (preceeded by "\"). - */ - public boolean escaped() - { - return dontMatch; - } - - /** - * Increment the string pointer by each character in - * - *

    -   * st
    -   * 
    - * - * that matches a non-escaped character. - */ - public boolean incMatch(String st) - { - StrPos sp = new StrPos(this); - int i; - for (i = 0; i < st.length(); i++) - { - if (!sp.match(st.charAt(i))) - { - return false; - } - sp.inc(); - } - dup(sp); - return true; - } - - /** Read in an integer. */ - public patInt getPatInt() - { - if (incMatch("inf")) - { - return new patInf(); - } - int i, cnt = 0; - StrPos sp = new StrPos(this); - for (i = 0; !sp.eos && sp.c >= '0' && sp.c <= '9'; i++) - { - cnt = 10 * cnt + sp.c - '0'; - sp.inc(); - } - if (i == 0) - { - return null; - } - dup(sp); - return new patInt(cnt); - } - - /** get the string that we are processing. */ - public String getString() - { - return s; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + Shareware: package pat + Copyright 2001, Steven R. Brandt + */ +/** + * StrPos is used internally by regex to parse the regular expression. + */ +public class StrPos +{ + String s; + + int pos; + + /** Return the position in the string pointed to */ + public int pos() + { + return pos; + } + + /** This contains the escape character, which is \ by default. */ + public char esc = Pattern.ESC; + + char c; + + /** Returns the current, possibly escaped, character. */ + public char thisChar() + { + return c; + } + + boolean dontMatch, eos; + + /** tell whether we are at end of string */ + public boolean eos() + { + return eos; + } + + /** initialize a StrPos from another StrPos. */ + public StrPos(StrPos sp) + { + dup(sp); + } + + /** copy a StrPos from sp to this. */ + public void dup(StrPos sp) + { + s = sp.s; + pos = sp.pos; + c = sp.c; + dontMatch = sp.dontMatch; + eos = sp.eos; + } + + /** + * Initialize a StrPos by giving it a String, and a position within the + * String. + */ + public StrPos(String s, int pos) + { + this.s = s; + this.pos = pos - 1; + inc(); + } + + /** + * Advance the place where StrPos points within the String. Counts a backslash + * as part of the next character. + */ + public StrPos inc() + { + pos++; + if (pos >= s.length()) + { + eos = true; + return this; + } + eos = false; + c = s.charAt(pos); + if (c == esc && pos + 1 < s.length()) + { + pos++; + c = s.charAt(pos); + if (c != esc) + { + dontMatch = true; + } + else + { + dontMatch = false; + } + } + else + { + dontMatch = false; + } + return this; + } + + /** + * Compare the (possibly escaped) character pointed to by StrPos. Return true + * if they are the same, but lways return if character pointed to is escaped. + */ + public boolean match(char ch) + { + if (dontMatch || eos) + { + return false; + } + return c == ch; + } + + /** As match, but only matches if the character is escaped. */ + public boolean escMatch(char ch) + { + if (!dontMatch || eos) + { + return false; + } + return c == ch; + } + + /** + * Returns true if the current character is escaped (preceeded by "\"). + */ + public boolean escaped() + { + return dontMatch; + } + + /** + * Increment the string pointer by each character in + * + *
    +   * st
    +   * 
    + * + * that matches a non-escaped character. + */ + public boolean incMatch(String st) + { + StrPos sp = new StrPos(this); + int i; + for (i = 0; i < st.length(); i++) + { + if (!sp.match(st.charAt(i))) + { + return false; + } + sp.inc(); + } + dup(sp); + return true; + } + + /** Read in an integer. */ + public patInt getPatInt() + { + if (incMatch("inf")) + { + return new patInf(); + } + int i, cnt = 0; + StrPos sp = new StrPos(this); + for (i = 0; !sp.eos && sp.c >= '0' && sp.c <= '9'; i++) + { + cnt = 10 * cnt + sp.c - '0'; + sp.inc(); + } + if (i == 0) + { + return null; + } + dup(sp); + return new patInt(cnt); + } + + /** get the string that we are processing. */ + public String getString() + { + return s; + } +}; diff --git a/unused/com/stevesoft/pat/StringBufferLike.java b/unused/com/stevesoft/pat/StringBufferLike.java index 1b45fd2..d35502f 100644 --- a/unused/com/stevesoft/pat/StringBufferLike.java +++ b/unused/com/stevesoft/pat/StringBufferLike.java @@ -1,92 +1,92 @@ -package // -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -com.stevesoft.pat; - -/** - * A tool that is used to make the \E, \U, \L, and \Q elements of a - * substitution. - */ -public class StringBufferLike implements BasicStringBufferLike -{ - BasicStringBufferLike sbl; - - public StringBufferLike(BasicStringBufferLike sbl) - { - this.sbl = sbl; - } - - char mode = 'E', altMode = ' '; - - public StringLike toStringLike() - { - return sbl.toStringLike(); - } - - public String toString() - { - return sbl.toString(); - } - - public void appendChar(char c) - { - - switch (mode) - { - case 'u': - mode = altMode; - altMode = ' '; - case 'U': - sbl.appendChar(CaseMgr.toUpperCase(c)); - break; - case 'l': - mode = altMode; - altMode = ' '; - case 'L': - sbl.appendChar(CaseMgr.toLowerCase(c)); - break; - case 'Q': - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9')) - { - ; - } - else - { - sbl.appendChar('\\'); - } - default: - sbl.appendChar(c); - break; - } - } - - public void appendStr(String s) - { - for (int i = 0; i < s.length(); i++) - { - appendChar(s.charAt(i)); - } - } - - public void setMode(char c) - { - if (c == 'u' || c == 'l') - { - if (altMode == ' ') - { - altMode = mode; - } - } - mode = c; - } - - public Object unwrap() - { - return sbl.unwrap(); - } -} +package // +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +com.stevesoft.pat; + +/** + * A tool that is used to make the \E, \U, \L, and \Q elements of a + * substitution. + */ +public class StringBufferLike implements BasicStringBufferLike +{ + BasicStringBufferLike sbl; + + public StringBufferLike(BasicStringBufferLike sbl) + { + this.sbl = sbl; + } + + char mode = 'E', altMode = ' '; + + public StringLike toStringLike() + { + return sbl.toStringLike(); + } + + public String toString() + { + return sbl.toString(); + } + + public void appendChar(char c) + { + + switch (mode) + { + case 'u': + mode = altMode; + altMode = ' '; + case 'U': + sbl.appendChar(CaseMgr.toUpperCase(c)); + break; + case 'l': + mode = altMode; + altMode = ' '; + case 'L': + sbl.appendChar(CaseMgr.toLowerCase(c)); + break; + case 'Q': + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9')) + { + ; + } + else + { + sbl.appendChar('\\'); + } + default: + sbl.appendChar(c); + break; + } + } + + public void appendStr(String s) + { + for (int i = 0; i < s.length(); i++) + { + appendChar(s.charAt(i)); + } + } + + public void setMode(char c) + { + if (c == 'u' || c == 'l') + { + if (altMode == ' ') + { + altMode = mode; + } + } + mode = c; + } + + public Object unwrap() + { + return sbl.unwrap(); + } +} diff --git a/unused/com/stevesoft/pat/StringLike.java b/unused/com/stevesoft/pat/StringLike.java index be98ff3..ea01b85 100644 --- a/unused/com/stevesoft/pat/StringLike.java +++ b/unused/com/stevesoft/pat/StringLike.java @@ -1,47 +1,47 @@ -package // -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -com.stevesoft.pat; - -/** - * Package pat can search anything that implements this interface. Package pat - * assumes the following: - *
      - *
    • The StringLike object will not change. Calls to charAt(int) will not - * vary with time. - *
    • The length of the object being searched is known before the search - * begins and does not vary with time. - *
    - * Note that searching String is probably faster than searching other objects, - * so searching String is still preferred if possible. - */ -public interface StringLike -{ - public char charAt(int i); - - public String toString(); - - public int length(); - - public String substring(int i1, int i2); - - /** - * Obtain the underlying object, be it a String, char[], RandomAccessFile, - * whatever. - */ - public Object unwrap(); - - /** - * By default, the result is put in a String or char[] when a replace is done. - * If you wish to save the result in some other StringBufferLike then you can - * do this by implementing this method, or over-riding it's behavior from an - * existing class. - */ - public BasicStringBufferLike newStringBufferLike(); - - public int indexOf(char c); -} +package // +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +com.stevesoft.pat; + +/** + * Package pat can search anything that implements this interface. Package pat + * assumes the following: + *
      + *
    • The StringLike object will not change. Calls to charAt(int) will not + * vary with time. + *
    • The length of the object being searched is known before the search + * begins and does not vary with time. + *
    + * Note that searching String is probably faster than searching other objects, + * so searching String is still preferred if possible. + */ +public interface StringLike +{ + public char charAt(int i); + + public String toString(); + + public int length(); + + public String substring(int i1, int i2); + + /** + * Obtain the underlying object, be it a String, char[], RandomAccessFile, + * whatever. + */ + public Object unwrap(); + + /** + * By default, the result is put in a String or char[] when a replace is done. + * If you wish to save the result in some other StringBufferLike then you can + * do this by implementing this method, or over-riding it's behavior from an + * existing class. + */ + public BasicStringBufferLike newStringBufferLike(); + + public int indexOf(char c); +} diff --git a/unused/com/stevesoft/pat/StringRule.java b/unused/com/stevesoft/pat/StringRule.java index d9abe58..e0aedae 100644 --- a/unused/com/stevesoft/pat/StringRule.java +++ b/unused/com/stevesoft/pat/StringRule.java @@ -1,39 +1,39 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * The apply method of this ReplaceRule simply appends the text it was - * initialized with to the StringBufferLike. - * - * @see com.stevesoft.pat.ReplaceRule - */ -public class StringRule extends ReplaceRule -{ - String s; - - public StringRule(String s) - { - this.s = s; - } - - public void apply(StringBufferLike sb, RegRes res) - { - sb.appendStr(s); - } - - public String toString1() - { - return s; - } - - public Object clone1() - { - return new StringRule(s); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * The apply method of this ReplaceRule simply appends the text it was + * initialized with to the StringBufferLike. + * + * @see com.stevesoft.pat.ReplaceRule + */ +public class StringRule extends ReplaceRule +{ + String s; + + public StringRule(String s) + { + this.s = s; + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.appendStr(s); + } + + public String toString1() + { + return s; + } + + public Object clone1() + { + return new StringRule(s); + } +} diff --git a/unused/com/stevesoft/pat/SubMark.java b/unused/com/stevesoft/pat/SubMark.java index 245fa6c..d709c7a 100644 --- a/unused/com/stevesoft/pat/SubMark.java +++ b/unused/com/stevesoft/pat/SubMark.java @@ -1,32 +1,32 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** OrMark and SubMark together implement ( ... ) */ -class SubMark extends Pattern -{ - int end_pos, start_pos; - - OrMark om; - - public String toString() - { - return ""; - } - - public int matchInternal(int i, Pthings pt) - { - pt.marks[om.id + pt.nMarks] = i; - int ret = nextMatch(i, pt); - if (ret < 0) - { - pt.marks[om.id + pt.nMarks] = -1; - } - return ret; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** OrMark and SubMark together implement ( ... ) */ +class SubMark extends Pattern +{ + int end_pos, start_pos; + + OrMark om; + + public String toString() + { + return ""; + } + + public int matchInternal(int i, Pthings pt) + { + pt.marks[om.id + pt.nMarks] = i; + int ret = nextMatch(i, pt); + if (ret < 0) + { + pt.marks[om.id + pt.nMarks] = -1; + } + return ret; + } +} diff --git a/unused/com/stevesoft/pat/TransPat.java b/unused/com/stevesoft/pat/TransPat.java index fd188e1..07ea0ac 100644 --- a/unused/com/stevesoft/pat/TransPat.java +++ b/unused/com/stevesoft/pat/TransPat.java @@ -1,52 +1,52 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class is used to implement the Transformer - * - * @see com.stevesoft.pat.Transform - */ -class TransPat extends Pattern -{ - Regex[] ra = new Regex[10]; - - int ra_len = 0; - - int pn = -1; - - public String toString() - { - return "(?#TransPat)"; - } - - TransPat() - { - - } - - int lastMatchedTo = -1; - - public int matchInternal(int pos, Pthings pt) - { - for (int i = 0; i < ra_len; i++) - { - pt.ignoreCase = ra[i].ignoreCase; - pt.mFlag = ra[i].mFlag; - pt.dotDoesntMatchCR = Regex.dotDoesntMatchCR; - int r = ra[i].thePattern.matchInternal(pos, pt); - if (r >= 0) - { - pn = i; - return r; - } - } - pn = -1; - return -1; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class is used to implement the Transformer + * + * @see com.stevesoft.pat.Transform + */ +class TransPat extends Pattern +{ + Regex[] ra = new Regex[10]; + + int ra_len = 0; + + int pn = -1; + + public String toString() + { + return "(?#TransPat)"; + } + + TransPat() + { + + } + + int lastMatchedTo = -1; + + public int matchInternal(int pos, Pthings pt) + { + for (int i = 0; i < ra_len; i++) + { + pt.ignoreCase = ra[i].ignoreCase; + pt.mFlag = ra[i].mFlag; + pt.dotDoesntMatchCR = Regex.dotDoesntMatchCR; + int r = ra[i].thePattern.matchInternal(pos, pt); + if (r >= 0) + { + pn = i; + return r; + } + } + pn = -1; + return -1; + } +} diff --git a/unused/com/stevesoft/pat/Transformer.java b/unused/com/stevesoft/pat/Transformer.java index 84a3a46..7ed1e23 100644 --- a/unused/com/stevesoft/pat/Transformer.java +++ b/unused/com/stevesoft/pat/Transformer.java @@ -1,235 +1,235 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import jalview.util.MessageManager; - -import com.stevesoft.pat.wrap.*; - -/** - * Replacement rule used by the Transformer. - * - * @see com.stevesoft.pat.Transformer - */ -class TransRepRule extends ReplaceRule -{ - Transformer t; - - TransRepRule(Transformer t) - { - this.t = t; - } - - public String toString1() - { - return ""; - } - - public Object clone1() - { - return new TransRepRule(t); - } - - public void apply(StringBufferLike sb, RegRes rr) - { - // get the ReplaceRule of the Regex that matched. - next = t.tp.ra[t.tp.pn].getReplaceRule(); - } -} - -/** - * Sometimes you want to replace a whole bunch of things that might occur within - * a single line of text. One efficient way to do this, both in terms of - * performance and programming ease, is with Transformer. The Transformer - * contains an array of Regex's and uses the Regex that matches earliest within - * the text to do the replacing, if two Regex's match at the same time it uses - * the one put in the Transformer first. - *

    - * This feature can be used to prevent transformations from occurring in certain - * regions. For example, if I add the rule s'//.*'$&' and then add the rule - * s/hello/goodbye/ the Transformer will replace "hello" with "goodbye" except - * when it occurs inside a double-slash style of comment. The transformation on - * the comment goes first, does nothing, and precludes transformation on the - * same region of text as the s/hello/goodbye/ rule. - *

    - * So far, at least, this class does not have the capability of turning into a - * giant robot :-) - */ -public class Transformer -{ - TransPat tp; - - Regex rp = new Regex(); - - boolean auto_optimize; - - /** - * Get a replacer to that works with the current Regex. - * - * @see com.stevesoft.pat.Replacer - */ - public Replacer getReplacer() - { - return rp.getReplacer(); - } - - /** Instantiate a new Transformer object. */ - public Transformer(boolean auto) - { - auto_optimize = auto; - tp = new TransPat(); - rp.setReplaceRule(new TransRepRule(this)); - rp.thePattern = tp; - } - - /** Add a new Regex to the set of Regex's. */ - public void add(Regex r) - { - if (auto_optimize) - { - r.optimize(); - } - tp.ra[tp.ra_len++] = r; - if (tp.ra.length == tp.ra_len) - { - Regex[] ra2 = new Regex[tp.ra_len + 10]; - for (int i = 0; i < tp.ra_len; i++) - { - ra2[i] = tp.ra[i]; - } - tp.ra = ra2; - } - rp.numSubs_ = r.numSubs_ > rp.numSubs_ ? r.numSubs_ : rp.numSubs_; - } - - /** Returns the number of Regex's in this Transformer. */ - public int patterns() - { - return tp.ra_len; - } - - /** Get the Regex at position i in this Transformer. */ - public Regex getRegexAt(int i) - { - if (i >= tp.ra_len) - { - throw new ArrayIndexOutOfBoundsException("i=" + i + ">=" + patterns()); - } - if (i < 0) - { - throw new ArrayIndexOutOfBoundsException("i=" + i + "< 0"); - } - return tp.ra[i]; - } - - /** Set the Regex at position i in this Transformer. */ - public void setRegexAt(Regex rx, int i) - { - if (i >= tp.ra_len) - { - throw new ArrayIndexOutOfBoundsException("i=" + i + ">=" + patterns()); - } - if (i < 0) - { - throw new ArrayIndexOutOfBoundsException("i=" + i + "< 0"); - } - tp.ra[i] = rx; - } - - /** - * Add a new Regex by calling Regex.perlCode - * - * @see com.stevesoft.pat.Regex#perlCode(java.lang.String) - */ - public void add(String rs) - { - Regex r = Regex.perlCode(rs); - if (r == null) - { - throw new NullPointerException(MessageManager.formatMessage("exception.bad_pattern_to_regex_perl_code", new String[]{rs})); - } - add(r); - } - - /** - * Add an array of Strings (which will be converted to Regex's via the - * Regex.perlCode method. - * - * @see com.stevesoft.pat.Regex#perlCode(java.lang.String) - */ - public void add(String[] array) - { - for (int i = 0; i < array.length; i++) - { - add(array[i]); - } - } - - /** Replace all matches in the current String. */ - public String replaceAll(String s) - { - return dorep(s, 0, s.length()); - } - - public StringLike replaceAll(StringLike s) - { - return dorep(s, 0, s.length()); - } - - /** Replace all matching patterns beginning at position start. */ - public String replaceAllFrom(String s, int start) - { - return dorep(s, start, s.length()); - } - - /** - * Replace all matching patterns beginning between the positions start and end - * inclusive. - */ - public String replaceAllRegion(String s, int start, int end) - { - return dorep(s, start, end); - } - - Replacer repr = new Replacer(); - - final StringLike dorep(StringLike s, int start, int end) - { - StringLike tfmd = repr.replaceAllRegion(s, rp, start, end); - tp.lastMatchedTo = repr.lastMatchedTo; - return tfmd; - } - - final String dorep(String s, int start, int end) - { - return dorep(new StringWrap(s), start, end).toString(); - } - - /** Replace the first matching pattern in String s. */ - public String replaceFirst(String s) - { - return dorep(s, 0, s.length()); - } - - /** - * Replace the first matching pattern after position start in String s. - */ - public String replaceFirstFrom(String s, int start) - { - return dorep(s, start, s.length()); - } - - /** - * Replace the first matching pattern that begins between start and end - * inclusive. - */ - public String replaceFirstRegion(String s, int start, int end) - { - return dorep(s, start, end); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import jalview.util.MessageManager; + +import com.stevesoft.pat.wrap.*; + +/** + * Replacement rule used by the Transformer. + * + * @see com.stevesoft.pat.Transformer + */ +class TransRepRule extends ReplaceRule +{ + Transformer t; + + TransRepRule(Transformer t) + { + this.t = t; + } + + public String toString1() + { + return ""; + } + + public Object clone1() + { + return new TransRepRule(t); + } + + public void apply(StringBufferLike sb, RegRes rr) + { + // get the ReplaceRule of the Regex that matched. + next = t.tp.ra[t.tp.pn].getReplaceRule(); + } +} + +/** + * Sometimes you want to replace a whole bunch of things that might occur within + * a single line of text. One efficient way to do this, both in terms of + * performance and programming ease, is with Transformer. The Transformer + * contains an array of Regex's and uses the Regex that matches earliest within + * the text to do the replacing, if two Regex's match at the same time it uses + * the one put in the Transformer first. + *

    + * This feature can be used to prevent transformations from occurring in certain + * regions. For example, if I add the rule s'//.*'$&' and then add the rule + * s/hello/goodbye/ the Transformer will replace "hello" with "goodbye" except + * when it occurs inside a double-slash style of comment. The transformation on + * the comment goes first, does nothing, and precludes transformation on the + * same region of text as the s/hello/goodbye/ rule. + *

    + * So far, at least, this class does not have the capability of turning into a + * giant robot :-) + */ +public class Transformer +{ + TransPat tp; + + Regex rp = new Regex(); + + boolean auto_optimize; + + /** + * Get a replacer to that works with the current Regex. + * + * @see com.stevesoft.pat.Replacer + */ + public Replacer getReplacer() + { + return rp.getReplacer(); + } + + /** Instantiate a new Transformer object. */ + public Transformer(boolean auto) + { + auto_optimize = auto; + tp = new TransPat(); + rp.setReplaceRule(new TransRepRule(this)); + rp.thePattern = tp; + } + + /** Add a new Regex to the set of Regex's. */ + public void add(Regex r) + { + if (auto_optimize) + { + r.optimize(); + } + tp.ra[tp.ra_len++] = r; + if (tp.ra.length == tp.ra_len) + { + Regex[] ra2 = new Regex[tp.ra_len + 10]; + for (int i = 0; i < tp.ra_len; i++) + { + ra2[i] = tp.ra[i]; + } + tp.ra = ra2; + } + rp.numSubs_ = r.numSubs_ > rp.numSubs_ ? r.numSubs_ : rp.numSubs_; + } + + /** Returns the number of Regex's in this Transformer. */ + public int patterns() + { + return tp.ra_len; + } + + /** Get the Regex at position i in this Transformer. */ + public Regex getRegexAt(int i) + { + if (i >= tp.ra_len) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + ">=" + patterns()); + } + if (i < 0) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + "< 0"); + } + return tp.ra[i]; + } + + /** Set the Regex at position i in this Transformer. */ + public void setRegexAt(Regex rx, int i) + { + if (i >= tp.ra_len) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + ">=" + patterns()); + } + if (i < 0) + { + throw new ArrayIndexOutOfBoundsException("i=" + i + "< 0"); + } + tp.ra[i] = rx; + } + + /** + * Add a new Regex by calling Regex.perlCode + * + * @see com.stevesoft.pat.Regex#perlCode(java.lang.String) + */ + public void add(String rs) + { + Regex r = Regex.perlCode(rs); + if (r == null) + { + throw new NullPointerException(MessageManager.formatMessage("exception.bad_pattern_to_regex_perl_code", new String[]{rs})); + } + add(r); + } + + /** + * Add an array of Strings (which will be converted to Regex's via the + * Regex.perlCode method. + * + * @see com.stevesoft.pat.Regex#perlCode(java.lang.String) + */ + public void add(String[] array) + { + for (int i = 0; i < array.length; i++) + { + add(array[i]); + } + } + + /** Replace all matches in the current String. */ + public String replaceAll(String s) + { + return dorep(s, 0, s.length()); + } + + public StringLike replaceAll(StringLike s) + { + return dorep(s, 0, s.length()); + } + + /** Replace all matching patterns beginning at position start. */ + public String replaceAllFrom(String s, int start) + { + return dorep(s, start, s.length()); + } + + /** + * Replace all matching patterns beginning between the positions start and end + * inclusive. + */ + public String replaceAllRegion(String s, int start, int end) + { + return dorep(s, start, end); + } + + Replacer repr = new Replacer(); + + final StringLike dorep(StringLike s, int start, int end) + { + StringLike tfmd = repr.replaceAllRegion(s, rp, start, end); + tp.lastMatchedTo = repr.lastMatchedTo; + return tfmd; + } + + final String dorep(String s, int start, int end) + { + return dorep(new StringWrap(s), start, end).toString(); + } + + /** Replace the first matching pattern in String s. */ + public String replaceFirst(String s) + { + return dorep(s, 0, s.length()); + } + + /** + * Replace the first matching pattern after position start in String s. + */ + public String replaceFirstFrom(String s, int start) + { + return dorep(s, start, s.length()); + } + + /** + * Replace the first matching pattern that begins between start and end + * inclusive. + */ + public String replaceFirstRegion(String s, int start, int end) + { + return dorep(s, start, end); + } +} diff --git a/unused/com/stevesoft/pat/UniValidator.java b/unused/com/stevesoft/pat/UniValidator.java index 31ae272..f7a022a 100644 --- a/unused/com/stevesoft/pat/UniValidator.java +++ b/unused/com/stevesoft/pat/UniValidator.java @@ -1,24 +1,24 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This provides a base class for all the Unicode character matching rules. - */ -class UniValidator extends Validator -{ - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This provides a base class for all the Unicode character matching rules. + */ +class UniValidator extends Validator +{ + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } +} diff --git a/unused/com/stevesoft/pat/Util.java b/unused/com/stevesoft/pat/Util.java index 88b01eb..d442192 100644 --- a/unused/com/stevesoft/pat/Util.java +++ b/unused/com/stevesoft/pat/Util.java @@ -1,13 +1,13 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - - -public abstract class Util -{ -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + + +public abstract class Util +{ +} diff --git a/unused/com/stevesoft/pat/Validator.java b/unused/com/stevesoft/pat/Validator.java index dbedca5..0de35e8 100644 --- a/unused/com/stevesoft/pat/Validator.java +++ b/unused/com/stevesoft/pat/Validator.java @@ -1,75 +1,75 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class makes it easy to create your own patterns and integrate them into - * Regex. For more detail, see the example file deriv2.java or deriv3.java. - */ - -public class Validator -{ - String argsave = null; - - String pattern = "."; - - /** - * This method does extra checking on a matched section of a String beginning - * at position start and ending at end. The idea is that you can do extra - * checking with this that you don't know how to do with a standard Regex. - * - * If this method is successful, it returns the location of the end of this - * pattern element -- that may be the value end provided or some other value. - * A negative value signifies that a match failure. - * - * By default, this method just returns end and thus does nothing. - * - * @see com.stevesoft.pat.Regex#define(java.lang.String,java.lang.String,com.stevesoft.pat.Validator) - */ - public int validate(StringLike src, int start, int end) - { - return end; - } - - /* - * This method allows you to modify the behavior of this validator by making a - * new Validator object. If a Validator named "foo" is defined, then the - * pattern "{??foo:bar}" will cause Regex to first get the Validator given to - * Regex.define and then to call its arg method with the string "bar". If this - * method returns a null (the default) you get the same behavior as the - * pattern "{??foo}" would supply. - */ - public Validator arg(String s) - { - return null; - } - - /** - * For optimization it is helpful, but not necessary, that you define the - * minimum number of characters this validator will allow to match. To do this - * return new patInt(number) where number is the smallest number of characters - * that can match. - */ - public patInt minChars() - { - return new patInt(0); - } - - /** - * For optimization it is helpful, but not necessary, that you define the - * maximum number of characters this validator will allow to match. To do this - * either return new patInt(number), or new patInf() if an infinite number of - * characters may match. - */ - public patInt maxChars() - { - return new patInf(); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class makes it easy to create your own patterns and integrate them into + * Regex. For more detail, see the example file deriv2.java or deriv3.java. + */ + +public class Validator +{ + String argsave = null; + + String pattern = "."; + + /** + * This method does extra checking on a matched section of a String beginning + * at position start and ending at end. The idea is that you can do extra + * checking with this that you don't know how to do with a standard Regex. + * + * If this method is successful, it returns the location of the end of this + * pattern element -- that may be the value end provided or some other value. + * A negative value signifies that a match failure. + * + * By default, this method just returns end and thus does nothing. + * + * @see com.stevesoft.pat.Regex#define(java.lang.String,java.lang.String,com.stevesoft.pat.Validator) + */ + public int validate(StringLike src, int start, int end) + { + return end; + } + + /* + * This method allows you to modify the behavior of this validator by making a + * new Validator object. If a Validator named "foo" is defined, then the + * pattern "{??foo:bar}" will cause Regex to first get the Validator given to + * Regex.define and then to call its arg method with the string "bar". If this + * method returns a null (the default) you get the same behavior as the + * pattern "{??foo}" would supply. + */ + public Validator arg(String s) + { + return null; + } + + /** + * For optimization it is helpful, but not necessary, that you define the + * minimum number of characters this validator will allow to match. To do this + * return new patInt(number) where number is the smallest number of characters + * that can match. + */ + public patInt minChars() + { + return new patInt(0); + } + + /** + * For optimization it is helpful, but not necessary, that you define the + * maximum number of characters this validator will allow to match. To do this + * either return new patInt(number), or new patInf() if an infinite number of + * characters may match. + */ + public patInt maxChars() + { + return new patInf(); + } +} diff --git a/unused/com/stevesoft/pat/WantMoreTextReplaceRule.java b/unused/com/stevesoft/pat/WantMoreTextReplaceRule.java index 6c0ddeb..fbb3636 100644 --- a/unused/com/stevesoft/pat/WantMoreTextReplaceRule.java +++ b/unused/com/stevesoft/pat/WantMoreTextReplaceRule.java @@ -1,29 +1,29 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * Triggers the reading of another line of text, allowing a longer pattern to - * match -- for details see WantMore.java. - */ -public class WantMoreTextReplaceRule extends SpecialRule -{ - public WantMoreTextReplaceRule() - { - } - - public void apply(StringBufferLike sb, RegRes res) - { - } - - public String toString1() - { - return "${WANT_MORE_TEXT}"; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * Triggers the reading of another line of text, allowing a longer pattern to + * match -- for details see WantMore.java. + */ +public class WantMoreTextReplaceRule extends SpecialRule +{ + public WantMoreTextReplaceRule() + { + } + + public void apply(StringBufferLike sb, RegRes res) + { + } + + public String toString1() + { + return "${WANT_MORE_TEXT}"; + } +} diff --git a/unused/com/stevesoft/pat/lookAhead.java b/unused/com/stevesoft/pat/lookAhead.java index d7d71c3..a8fd75f 100644 --- a/unused/com/stevesoft/pat/lookAhead.java +++ b/unused/com/stevesoft/pat/lookAhead.java @@ -1,99 +1,99 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** Implements "(?= )" and "(?! )" */ -class lookAhead extends Or -{ - boolean reverse; - - lookAhead(boolean b) - { - reverse = b; - } - - public Pattern getNext() - { - return null; - } - - public int nextMatch(int pos, Pthings pt) - { - Pattern p = super.getNext(); - if (p != null) - { - return p.matchInternal(pos, pt); - } - else - { - return pos; - } - } - - public int matchInternal(int pos, Pthings pt) - { - if (super.matchInternal(pos, pt) >= 0) - { - if (reverse) - { - return -1; - } - else - { - return nextMatch(pos, pt); - } - } - else - { - if (reverse) - { - return nextMatch(pos, pt); - } - else - { - return -1; - } - } - } - - String leftForm() - { - if (reverse) - { - return "(?!"; - } - else - { - return "(?="; - } - } - - public patInt minChars() - { - return new patInt(0); - } - - public patInt maxChars() - { - return new patInt(0); - } - - Pattern clone1(Hashtable h) - { - lookAhead la = new lookAhead(reverse); - h.put(this, la); - h.put(la, la); - for (int i = 0; i < v.size(); i++) - { - la.v.addElement(((Pattern) v.elementAt(i)).clone(h)); - } - return la; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** Implements "(?= )" and "(?! )" */ +class lookAhead extends Or +{ + boolean reverse; + + lookAhead(boolean b) + { + reverse = b; + } + + public Pattern getNext() + { + return null; + } + + public int nextMatch(int pos, Pthings pt) + { + Pattern p = super.getNext(); + if (p != null) + { + return p.matchInternal(pos, pt); + } + else + { + return pos; + } + } + + public int matchInternal(int pos, Pthings pt) + { + if (super.matchInternal(pos, pt) >= 0) + { + if (reverse) + { + return -1; + } + else + { + return nextMatch(pos, pt); + } + } + else + { + if (reverse) + { + return nextMatch(pos, pt); + } + else + { + return -1; + } + } + } + + String leftForm() + { + if (reverse) + { + return "(?!"; + } + else + { + return "(?="; + } + } + + public patInt minChars() + { + return new patInt(0); + } + + public patInt maxChars() + { + return new patInt(0); + } + + Pattern clone1(Hashtable h) + { + lookAhead la = new lookAhead(reverse); + h.put(this, la); + h.put(la, la); + for (int i = 0; i < v.size(); i++) + { + la.v.addElement(((Pattern) v.elementAt(i)).clone(h)); + } + return la; + } +} diff --git a/unused/com/stevesoft/pat/oneChar.java b/unused/com/stevesoft/pat/oneChar.java index ebbe991..009fc99 100644 --- a/unused/com/stevesoft/pat/oneChar.java +++ b/unused/com/stevesoft/pat/oneChar.java @@ -1,76 +1,76 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -import java.util.*; - -/** This class matches a single character. */ -class oneChar extends Pattern -{ - char c, altc, altc2; - - int mask; - - public oneChar(char ci) - { - c = ci; - char cu, cl, ct; - cu = CaseMgr.toUpperCase(c); - cl = CaseMgr.toLowerCase(c); - ct = CaseMgr.toTitleCase(c); - if (c == cu) - { - altc = cl; - altc2 = ct; - } - else if (c == cl) - { - altc = cu; - altc2 = ct; - } - else - { - altc = cl; - altc2 = cu; - } - mask = c & altc & altc2; - } - - public int matchInternal(int pos, Pthings pt) - { - char p; - int ret = -1; - if (pos < pt.src.length() - && !Masked(pos, pt) - && ((p = pt.src.charAt(pos)) == c || (pt.ignoreCase && (p == altc || p == altc2)))) - { - ret = nextMatch(pos + 1, pt); - } - return ret; - } - - public String toString() - { - return protect("" + c, PROTECT_THESE, ESC) + nextString(); - } - - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } - - Pattern clone1(Hashtable h) - { - return new oneChar(c); - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +import java.util.*; + +/** This class matches a single character. */ +class oneChar extends Pattern +{ + char c, altc, altc2; + + int mask; + + public oneChar(char ci) + { + c = ci; + char cu, cl, ct; + cu = CaseMgr.toUpperCase(c); + cl = CaseMgr.toLowerCase(c); + ct = CaseMgr.toTitleCase(c); + if (c == cu) + { + altc = cl; + altc2 = ct; + } + else if (c == cl) + { + altc = cu; + altc2 = ct; + } + else + { + altc = cl; + altc2 = cu; + } + mask = c & altc & altc2; + } + + public int matchInternal(int pos, Pthings pt) + { + char p; + int ret = -1; + if (pos < pt.src.length() + && !Masked(pos, pt) + && ((p = pt.src.charAt(pos)) == c || (pt.ignoreCase && (p == altc || p == altc2)))) + { + ret = nextMatch(pos + 1, pt); + } + return ret; + } + + public String toString() + { + return protect("" + c, PROTECT_THESE, ESC) + nextString(); + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + Pattern clone1(Hashtable h) + { + return new oneChar(c); + } +}; diff --git a/unused/com/stevesoft/pat/parsePerl.java b/unused/com/stevesoft/pat/parsePerl.java index 4b8a93f..ab43a94 100644 --- a/unused/com/stevesoft/pat/parsePerl.java +++ b/unused/com/stevesoft/pat/parsePerl.java @@ -1,571 +1,571 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This class provides a method for parsing the "s/.../.../" constructs of - * Regex.perlCode. - * - * @see Regex#perlCode - */ -class parsePerl -{ - final static char close(char c) - { - // This switch statement does not behave - // properly when compiled with jdk1.1.5 - // and the -O flag. - /* - * switch(c) { case '[': return ']'; case '(': return ')'; case '{': return - * '}'; } return c; - */ - if (c == '<') - { - return '>'; - } - if (c == '[') - { - return ']'; - } - if (c == '(') - { - return ')'; - } - if (c == '{') - { - return '}'; - } - return c; - } - - final public static String codify(String s, boolean keepbs) - { - return codify(s, 0, s.length(), keepbs); - } - - final public static String codify(String s, int i0, int iN, boolean keepbs) - { - javajs.util.SB sb = new javajs.util.SB(); - boolean ucmode = false, lcmode = false, litmode = false; - boolean uc1 = false, lc1 = false; - boolean modified = false; - for (int i = i0; i < iN; i++) - { - char c = s.charAt(i); - boolean mf = true, app = true; - if (c == '\\') - { - app = false; - i++; - if (i < s.length()) - { - char c2 = s.charAt(i); - switch (c2) - { - case 'Q': - litmode = true; - break; - case 'U': - ucmode = true; - break; - case 'L': - lcmode = true; - break; - case 'u': - uc1 = true; - break; - case 'l': - lc1 = true; - break; - case 'E': - uc1 = lc1 = ucmode = lcmode = litmode = false; - break; - default: - if (keepbs) - { - sb.appendC('\\'); - } - c = c2; - if (keepbs) - { - mf = false; - } - app = true; - break; - } - modified |= mf; - } - } - if (app) - { - if (lc1) - { - c = lc(c); - lc1 = false; - } - else if (uc1) - { - c = uc(c); - uc1 = false; - } - else if (ucmode) - { - c = uc(c); - } - else if (lcmode) - { - c = lc(c); - } - if (litmode && needbs(c)) - { - sb.appendC('\\'); - } - sb.appendC(c); - } - } - return modified ? sb.toString() : s; - } - - final static char uc(char c) - { - return CaseMgr.toUpperCase(c); - } - - final static char lc(char c) - { - return CaseMgr.toLowerCase(c); - } - - final static boolean needbs(char c) - { - if (c >= 'a' && c <= 'z') - { - return false; - } - if (c >= 'A' && c <= 'Z') - { - return false; - } - if (c >= '0' && c <= '9') - { - return false; - } - if (c == '_') - { - return false; - } - return true; - } - - final static Regex parse(String s) - { - boolean igncase = false, optim = false, gFlag = false; - boolean sFlag = false, mFlag = false, xFlag = false; - - javajs.util.SB s1 = new javajs.util.SB(); - javajs.util.SB s2 = new javajs.util.SB(); - int i = 0, count = 0; - char mode, delim = '/', cdelim = '/'; - if (s.length() >= 3 && s.charAt(0) == 's') - { - mode = 's'; - delim = s.charAt(1); - cdelim = close(delim); - i = 2; - } - else if (s.length() >= 2 && s.charAt(0) == 'm') - { - mode = 'm'; - delim = s.charAt(1); - cdelim = close(delim); - i = 2; - } - else if (s.length() >= 1 && s.charAt(0) == '/') - { - mode = 'm'; - i = 1; - } - else - { - try - { - RegSyntaxError.endItAll("Regex.perlCode should be of the " - + "form s/// or m// or //"); - } catch (RegSyntax rs) - { - } - return null; - } - for (; i < s.length(); i++) - { - if (s.charAt(i) == '\\') - { - s1.appendC('\\'); - i++; - } - else if (s.charAt(i) == cdelim && count == 0) - { - i++; - break; - } - else if (s.charAt(i) == delim && cdelim != delim) - { - count++; - } - else if (s.charAt(i) == cdelim && cdelim != delim) - { - count--; - } - s1.appendC(s.charAt(i)); - } - if (mode == 's' && cdelim != delim) - { - while (i < s.length() && Prop.isWhite(s.charAt(i))) - { - i++; - } - if (i >= s.length()) - { - try - { - RegSyntaxError.endItAll("" + mode + delim + " needs " + cdelim); - } catch (RegSyntax rs) - { - } - return null; - } - cdelim = close(delim = s.charAt(i)); - i++; - } - count = 0; - if (mode == 's') - { - for (; i < s.length(); i++) - { - if (s.charAt(i) == '\\') - { - s2.appendC('\\'); - i++; - } - else if (s.charAt(i) == cdelim && count == 0) - { - i++; - break; - } - else if (s.charAt(i) == delim && cdelim != delim) - { - count++; - } - else if (s.charAt(i) == cdelim && cdelim != delim) - { - count--; - } - s2.appendC(s.charAt(i)); - } - } - for (; i < s.length(); i++) - { - char c = s.charAt(i); - switch (c) - { - case 'x': - xFlag = true; - break; - case 'i': - igncase = true; - break; - case 'o': - optim = true; - break; - case 's': - sFlag = true; - break; - case 'm': - mFlag = true; - break; - case 'g': - gFlag = true; - break; - default: - - // syntax error! - try - { - RegSyntaxError.endItAll("Illegal flag to pattern: " + c); - } catch (RegSyntax rs) - { - } - return null; - } - } - Regex r = new Regex(); - try - { - String pat = s1.toString(), reprul = s2.toString(); - if (xFlag) - { - pat = strip(pat); - reprul = strip(reprul); - } - r.compile(pat); - r.ignoreCase |= igncase; - r.gFlag |= gFlag; - r.sFlag |= sFlag; - r.mFlag |= mFlag; - if (optim) - { - r.optimize(); - } - if (delim == '\'') - { - r.setReplaceRule(new StringRule(reprul)); - } - else - { - r.setReplaceRule(parsePerl.perlCode(reprul)); - } - } catch (RegSyntax rs) - { - r = null; - } - return r; - } - - static String strip(String s) - { - javajs.util.SB sb = new javajs.util.SB(); - for (int i = 0; i < s.length(); i++) - { - char c = s.charAt(i); - if (Prop.isWhite(c)) - { - ; - } - else if (c == '#') - { - i++; - while (i < s.length()) - { - if (s.charAt(i) == '\n') - { - break; - } - i++; - } - } - else if (c == '\\') - { - sb.appendC(c); - sb.appendC(s.charAt(++i)); - } - else - { - sb.appendC(c); - } - } - return sb.toString(); - } - - /** - * Compile a ReplaceRule using the text that would go between the second and - * third /'s in a typical substitution pattern in Perl: s/ ... / The - * argument to ReplaceRule.perlCode /. - */ - public static ReplaceRule perlCode(String s) - { - // String sav_backGs = Regex.backGs; - // int sav_backGto = Regex.backGto; - try - { - int mf = 0, mt = 0; - Regex gv = ReplaceRule.getv(); - ReplaceRule head = null; - Object tmp = null; - while (gv.searchFrom(s, mt)) - { - int off = Regex.BackRefOffset - 1; - mf = gv.matchedFrom(); - if (mf > mt) - { - head = ReplaceRule.add(head, new StringRule(s.substring(mt, mf))); - } - String var = null; - if ((var = gv.stringMatched(1 + off)) != null - || (var = gv.stringMatched(2 + off)) != null - || (var = gv.stringMatched(5 + off)) != null) - { - int d = 0; - for (int i = 0; i < var.length(); i++) - { - d = 8 * d + (var.charAt(i) - '0'); - } - if (var.length() == 1) - { - head = ReplaceRule.add(head, new BackRefRule(d)); - } - else - { - head = new StringRule("" + (char) d); - } - } - else if ((var = gv.stringMatched(10 + off)) != null) - { - if ("QELlUu".indexOf(var) >= 0) - { - head = ReplaceRule.add(head, new CodeRule(var.charAt(0))); - } - else - { - head = ReplaceRule.add(head, new StringRule(var)); - } - } - else if ((var = gv.stringMatched(3 + off)) != null - || (var = gv.stringMatched(4 + off)) != null - || (var = gv.stringMatched(6 + off)) != null) - { - String arg = ""; - int pc; - if ((pc = var.indexOf(':')) > 0) - { - arg = var.substring(pc + 1); - var = var.substring(0, pc); - } - if (var.equals("&") || var.equals("MATCH")) - { - head = ReplaceRule.add(head, new AmpersandRule()); - } - else if (var.equals("`") || var.equals("PREMATCH")) - { - head = ReplaceRule.add(head, new LeftRule()); - } - else if (var.equals("'") || var.equals("POSTMATCH")) - { - head = ReplaceRule.add(head, new RightRule()); - } - else if (var.equals("WANT_MORE_TEXT")) - { - head = ReplaceRule.add(head, new WantMoreTextReplaceRule()); - } - else if (var.equals("POP")) - { - head = ReplaceRule.add(head, new PopRule()); - } - else if (var.startsWith("+") - && (tmp = ReplaceRule.defs.get(var.substring(1))) != null) - { - if (tmp instanceof Regex) - { - head = ReplaceRule.add(head, new PushRule(var.substring(1), (Regex) tmp)); - } - else if (tmp instanceof Transformer) - { - head = ReplaceRule.add(head, new PushRule(var.substring(1), - (Transformer) tmp)); - } - else - { - head = ReplaceRule.add(head, new StringRule("${" + var + "}")); - } - } - else if (var.startsWith("=") - && (tmp = ReplaceRule.defs.get(var.substring(1))) != null) - { - if (tmp instanceof Regex) - { - head = ReplaceRule.add(head, - new ChangeRule(var.substring(1), (Regex) tmp)); - } - else if (tmp instanceof Transformer) - { - head = ReplaceRule.add(head, new ChangeRule(var.substring(1), - (Transformer) tmp)); - } - else - { - head = ReplaceRule.add(head, new StringRule("${" + var + "}")); - } - } - else if ((tmp = ReplaceRule.defs.get(var)) != null) - { - if (tmp instanceof ReplaceRule) - { - ReplaceRule alt = ((ReplaceRule) tmp).arg(arg); - if (alt == null) - { - alt = ((ReplaceRule) tmp); - } - head = ReplaceRule.add(head, (ReplaceRule) (alt.clone())); - } - } - else - // can't figure out how to transform this thing... - { - head = ReplaceRule.add(head, new StringRule("${" + var + "}")); - } - } - else if ((var = gv.stringMatched(7 + off)) != null) - { - char c = var.charAt(0); - if (c == 'n') - { - head = ReplaceRule.add(head, new StringRule("\n")); - } - else if (c == 't') - { - head = ReplaceRule.add(head, new StringRule("\t")); - } - else if (c == 'r') - { - head = ReplaceRule.add(head, new StringRule("\r")); - } - else if (c == 'b') - { - head = ReplaceRule.add(head, new StringRule("\r")); - } - else if (c == 'a') - { - head = ReplaceRule.add(head, new StringRule("" + (char) 7)); - } - else if (c == 'e') - { - head = ReplaceRule.add(head, new StringRule("" + (char) 27)); - } - else if (c == 'f') - { - head = ReplaceRule.add(head, new StringRule("" + (char) 12)); - } - } - else if ((var = gv.stringMatched(8 + off)) != null) - { - char c = var.charAt(0); - if (c < Ctrl.cmap.length) - { - c = Ctrl.cmap[c]; - } - head = ReplaceRule.add(head, new StringRule("" + c)); - } - else if ((var = gv.stringMatched(9 + off)) != null) - { - int d = 16 * ReplaceRule.getHexDigit(var.charAt(0)) - + ReplaceRule.getHexDigit(var.charAt(1)); - head = ReplaceRule.add(head, new StringRule("" + (char) d)); - } - mt = gv.matchedTo(); - } - if (mt <= s.length()) - { - head = ReplaceRule.add(head, new StringRule(s.substring(mt))); - } - return head; - } finally - { - // Regex.backGs = sav_backGs; - // Regex.backGto = sav_backGto; - } - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This class provides a method for parsing the "s/.../.../" constructs of + * Regex.perlCode. + * + * @see Regex#perlCode + */ +class parsePerl +{ + final static char close(char c) + { + // This switch statement does not behave + // properly when compiled with jdk1.1.5 + // and the -O flag. + /* + * switch(c) { case '[': return ']'; case '(': return ')'; case '{': return + * '}'; } return c; + */ + if (c == '<') + { + return '>'; + } + if (c == '[') + { + return ']'; + } + if (c == '(') + { + return ')'; + } + if (c == '{') + { + return '}'; + } + return c; + } + + final public static String codify(String s, boolean keepbs) + { + return codify(s, 0, s.length(), keepbs); + } + + final public static String codify(String s, int i0, int iN, boolean keepbs) + { + javajs.util.SB sb = new javajs.util.SB(); + boolean ucmode = false, lcmode = false, litmode = false; + boolean uc1 = false, lc1 = false; + boolean modified = false; + for (int i = i0; i < iN; i++) + { + char c = s.charAt(i); + boolean mf = true, app = true; + if (c == '\\') + { + app = false; + i++; + if (i < s.length()) + { + char c2 = s.charAt(i); + switch (c2) + { + case 'Q': + litmode = true; + break; + case 'U': + ucmode = true; + break; + case 'L': + lcmode = true; + break; + case 'u': + uc1 = true; + break; + case 'l': + lc1 = true; + break; + case 'E': + uc1 = lc1 = ucmode = lcmode = litmode = false; + break; + default: + if (keepbs) + { + sb.appendC('\\'); + } + c = c2; + if (keepbs) + { + mf = false; + } + app = true; + break; + } + modified |= mf; + } + } + if (app) + { + if (lc1) + { + c = lc(c); + lc1 = false; + } + else if (uc1) + { + c = uc(c); + uc1 = false; + } + else if (ucmode) + { + c = uc(c); + } + else if (lcmode) + { + c = lc(c); + } + if (litmode && needbs(c)) + { + sb.appendC('\\'); + } + sb.appendC(c); + } + } + return modified ? sb.toString() : s; + } + + final static char uc(char c) + { + return CaseMgr.toUpperCase(c); + } + + final static char lc(char c) + { + return CaseMgr.toLowerCase(c); + } + + final static boolean needbs(char c) + { + if (c >= 'a' && c <= 'z') + { + return false; + } + if (c >= 'A' && c <= 'Z') + { + return false; + } + if (c >= '0' && c <= '9') + { + return false; + } + if (c == '_') + { + return false; + } + return true; + } + + final static Regex parse(String s) + { + boolean igncase = false, optim = false, gFlag = false; + boolean sFlag = false, mFlag = false, xFlag = false; + + javajs.util.SB s1 = new javajs.util.SB(); + javajs.util.SB s2 = new javajs.util.SB(); + int i = 0, count = 0; + char mode, delim = '/', cdelim = '/'; + if (s.length() >= 3 && s.charAt(0) == 's') + { + mode = 's'; + delim = s.charAt(1); + cdelim = close(delim); + i = 2; + } + else if (s.length() >= 2 && s.charAt(0) == 'm') + { + mode = 'm'; + delim = s.charAt(1); + cdelim = close(delim); + i = 2; + } + else if (s.length() >= 1 && s.charAt(0) == '/') + { + mode = 'm'; + i = 1; + } + else + { + try + { + RegSyntaxError.endItAll("Regex.perlCode should be of the " + + "form s/// or m// or //"); + } catch (RegSyntax rs) + { + } + return null; + } + for (; i < s.length(); i++) + { + if (s.charAt(i) == '\\') + { + s1.appendC('\\'); + i++; + } + else if (s.charAt(i) == cdelim && count == 0) + { + i++; + break; + } + else if (s.charAt(i) == delim && cdelim != delim) + { + count++; + } + else if (s.charAt(i) == cdelim && cdelim != delim) + { + count--; + } + s1.appendC(s.charAt(i)); + } + if (mode == 's' && cdelim != delim) + { + while (i < s.length() && Prop.isWhite(s.charAt(i))) + { + i++; + } + if (i >= s.length()) + { + try + { + RegSyntaxError.endItAll("" + mode + delim + " needs " + cdelim); + } catch (RegSyntax rs) + { + } + return null; + } + cdelim = close(delim = s.charAt(i)); + i++; + } + count = 0; + if (mode == 's') + { + for (; i < s.length(); i++) + { + if (s.charAt(i) == '\\') + { + s2.appendC('\\'); + i++; + } + else if (s.charAt(i) == cdelim && count == 0) + { + i++; + break; + } + else if (s.charAt(i) == delim && cdelim != delim) + { + count++; + } + else if (s.charAt(i) == cdelim && cdelim != delim) + { + count--; + } + s2.appendC(s.charAt(i)); + } + } + for (; i < s.length(); i++) + { + char c = s.charAt(i); + switch (c) + { + case 'x': + xFlag = true; + break; + case 'i': + igncase = true; + break; + case 'o': + optim = true; + break; + case 's': + sFlag = true; + break; + case 'm': + mFlag = true; + break; + case 'g': + gFlag = true; + break; + default: + + // syntax error! + try + { + RegSyntaxError.endItAll("Illegal flag to pattern: " + c); + } catch (RegSyntax rs) + { + } + return null; + } + } + Regex r = new Regex(); + try + { + String pat = s1.toString(), reprul = s2.toString(); + if (xFlag) + { + pat = strip(pat); + reprul = strip(reprul); + } + r.compile(pat); + r.ignoreCase |= igncase; + r.gFlag |= gFlag; + r.sFlag |= sFlag; + r.mFlag |= mFlag; + if (optim) + { + r.optimize(); + } + if (delim == '\'') + { + r.setReplaceRule(new StringRule(reprul)); + } + else + { + r.setReplaceRule(parsePerl.perlCode(reprul)); + } + } catch (RegSyntax rs) + { + r = null; + } + return r; + } + + static String strip(String s) + { + javajs.util.SB sb = new javajs.util.SB(); + for (int i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + if (Prop.isWhite(c)) + { + ; + } + else if (c == '#') + { + i++; + while (i < s.length()) + { + if (s.charAt(i) == '\n') + { + break; + } + i++; + } + } + else if (c == '\\') + { + sb.appendC(c); + sb.appendC(s.charAt(++i)); + } + else + { + sb.appendC(c); + } + } + return sb.toString(); + } + + /** + * Compile a ReplaceRule using the text that would go between the second and + * third /'s in a typical substitution pattern in Perl: s/ ... / The + * argument to ReplaceRule.perlCode /. + */ + public static ReplaceRule perlCode(String s) + { + // String sav_backGs = Regex.backGs; + // int sav_backGto = Regex.backGto; + try + { + int mf = 0, mt = 0; + Regex gv = ReplaceRule.getv(); + ReplaceRule head = null; + Object tmp = null; + while (gv.searchFrom(s, mt)) + { + int off = Regex.BackRefOffset - 1; + mf = gv.matchedFrom(); + if (mf > mt) + { + head = ReplaceRule.add(head, new StringRule(s.substring(mt, mf))); + } + String var = null; + if ((var = gv.stringMatched(1 + off)) != null + || (var = gv.stringMatched(2 + off)) != null + || (var = gv.stringMatched(5 + off)) != null) + { + int d = 0; + for (int i = 0; i < var.length(); i++) + { + d = 8 * d + (var.charAt(i) - '0'); + } + if (var.length() == 1) + { + head = ReplaceRule.add(head, new BackRefRule(d)); + } + else + { + head = new StringRule("" + (char) d); + } + } + else if ((var = gv.stringMatched(10 + off)) != null) + { + if ("QELlUu".indexOf(var) >= 0) + { + head = ReplaceRule.add(head, new CodeRule(var.charAt(0))); + } + else + { + head = ReplaceRule.add(head, new StringRule(var)); + } + } + else if ((var = gv.stringMatched(3 + off)) != null + || (var = gv.stringMatched(4 + off)) != null + || (var = gv.stringMatched(6 + off)) != null) + { + String arg = ""; + int pc; + if ((pc = var.indexOf(':')) > 0) + { + arg = var.substring(pc + 1); + var = var.substring(0, pc); + } + if (var.equals("&") || var.equals("MATCH")) + { + head = ReplaceRule.add(head, new AmpersandRule()); + } + else if (var.equals("`") || var.equals("PREMATCH")) + { + head = ReplaceRule.add(head, new LeftRule()); + } + else if (var.equals("'") || var.equals("POSTMATCH")) + { + head = ReplaceRule.add(head, new RightRule()); + } + else if (var.equals("WANT_MORE_TEXT")) + { + head = ReplaceRule.add(head, new WantMoreTextReplaceRule()); + } + else if (var.equals("POP")) + { + head = ReplaceRule.add(head, new PopRule()); + } + else if (var.startsWith("+") + && (tmp = ReplaceRule.defs.get(var.substring(1))) != null) + { + if (tmp instanceof Regex) + { + head = ReplaceRule.add(head, new PushRule(var.substring(1), (Regex) tmp)); + } + else if (tmp instanceof Transformer) + { + head = ReplaceRule.add(head, new PushRule(var.substring(1), + (Transformer) tmp)); + } + else + { + head = ReplaceRule.add(head, new StringRule("${" + var + "}")); + } + } + else if (var.startsWith("=") + && (tmp = ReplaceRule.defs.get(var.substring(1))) != null) + { + if (tmp instanceof Regex) + { + head = ReplaceRule.add(head, + new ChangeRule(var.substring(1), (Regex) tmp)); + } + else if (tmp instanceof Transformer) + { + head = ReplaceRule.add(head, new ChangeRule(var.substring(1), + (Transformer) tmp)); + } + else + { + head = ReplaceRule.add(head, new StringRule("${" + var + "}")); + } + } + else if ((tmp = ReplaceRule.defs.get(var)) != null) + { + if (tmp instanceof ReplaceRule) + { + ReplaceRule alt = ((ReplaceRule) tmp).arg(arg); + if (alt == null) + { + alt = ((ReplaceRule) tmp); + } + head = ReplaceRule.add(head, (ReplaceRule) (alt.clone())); + } + } + else + // can't figure out how to transform this thing... + { + head = ReplaceRule.add(head, new StringRule("${" + var + "}")); + } + } + else if ((var = gv.stringMatched(7 + off)) != null) + { + char c = var.charAt(0); + if (c == 'n') + { + head = ReplaceRule.add(head, new StringRule("\n")); + } + else if (c == 't') + { + head = ReplaceRule.add(head, new StringRule("\t")); + } + else if (c == 'r') + { + head = ReplaceRule.add(head, new StringRule("\r")); + } + else if (c == 'b') + { + head = ReplaceRule.add(head, new StringRule("\r")); + } + else if (c == 'a') + { + head = ReplaceRule.add(head, new StringRule("" + (char) 7)); + } + else if (c == 'e') + { + head = ReplaceRule.add(head, new StringRule("" + (char) 27)); + } + else if (c == 'f') + { + head = ReplaceRule.add(head, new StringRule("" + (char) 12)); + } + } + else if ((var = gv.stringMatched(8 + off)) != null) + { + char c = var.charAt(0); + if (c < Ctrl.cmap.length) + { + c = Ctrl.cmap[c]; + } + head = ReplaceRule.add(head, new StringRule("" + c)); + } + else if ((var = gv.stringMatched(9 + off)) != null) + { + int d = 16 * ReplaceRule.getHexDigit(var.charAt(0)) + + ReplaceRule.getHexDigit(var.charAt(1)); + head = ReplaceRule.add(head, new StringRule("" + (char) d)); + } + mt = gv.matchedTo(); + } + if (mt <= s.length()) + { + head = ReplaceRule.add(head, new StringRule(s.substring(mt))); + } + return head; + } finally + { + // Regex.backGs = sav_backGs; + // Regex.backGto = sav_backGto; + } + } +} diff --git a/unused/com/stevesoft/pat/patInf.java b/unused/com/stevesoft/pat/patInf.java index cbdbf9e..3445919 100644 --- a/unused/com/stevesoft/pat/patInf.java +++ b/unused/com/stevesoft/pat/patInf.java @@ -1,16 +1,16 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -final class patInf extends patInt -{ - patInf() - { - inf = true; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +final class patInf extends patInt +{ + patInf() + { + inf = true; + } +}; diff --git a/unused/com/stevesoft/pat/patInt.java b/unused/com/stevesoft/pat/patInt.java index df0d028..72e0d2c 100644 --- a/unused/com/stevesoft/pat/patInt.java +++ b/unused/com/stevesoft/pat/patInt.java @@ -1,180 +1,180 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat; - -/** - * This is just an integer that can have infinite value. It is used internally - * to implement the *, and + parts of regular expressions. - */ -public class patInt -{ - int i; - - boolean inf; - - /** Initialize to zero. */ - public patInt() - { - i = 0; - inf = false; - } - - /** Initialize to the value of init. */ - public patInt(int init) - { - i = init; - inf = false; - } - - /** Initialize to the value of p. */ - public patInt(patInt p) - { - i = p.i; - inf = p.inf; - } - - /** set this int to infinity. */ - public void setInf(boolean b) - { - inf = b; - if (b) - { - i = Integer.MAX_VALUE; - } - } - - /** Increment the value of this by 1. */ - public final void inc() - { - if (!inf) - { - i++; - } - } - - /** Decrement the value of this by 1. */ - public final void dec() - { - if (!inf) - { - i--; - } - } - - /** Test to see if this is less than or equal to j. */ - public final boolean lessEq(patInt j) - { /* - * if(inf) return false; if(j.inf) return true; return i <= j.i; - */ - return !inf && (j.inf || i <= j.i); - } - - /** Test to see if two patterns are equal. */ - public final boolean equals(patInt j) - { - return !j.inf && !inf && i == j.i; - } - - /** - * Formats the pattern as a String. Contrary to what you might expect, - * infinity is formatted as "" - */ - final public String toString() - { - if (inf) - { - return ""; - } - else - { - return "" + i; - } - } - - /** - * This would be operator+=(patInt) if I were programming in C++. - */ - public final patInt pluseq(patInt p) - { - if (inf || p.inf) - { - setInf(true); - } - else - { - i += p.i; - } - return this; - } - - /** - * Returns a patInt with value equal to the product of the value of p and - * this. - */ - public final patInt mul(patInt p) - { - if (inf || p.inf) - { - return new patInf(); - } - return new patInt(i * p.i); - } - - /** - * If the argument p has a smaller value than this, then set this Object equal - * to p. - */ - public final patInt mineq(patInt p) - { - if (p.inf) - { - return this; - } - if (inf) - { - i = p.i; - } - else if (p.i < i) - { - i = p.i; - } - setInf(false); - return this; - } - - /** - * If the argument p has a greater than this, then set this object equal to p. - */ - public final patInt maxeq(patInt p) - { - if (inf || p.inf) - { - setInf(true); - return this; - } - if (p.i > i) - { - i = p.i; - } - return this; - } - - /** Tests to see if this represents an infinite quantity. */ - public boolean finite() - { - return !inf; - } - - /** - * Converts to a patInt to an int. Infinity is mapped Integer.MAX_VALUE; - */ - public int intValue() - { - return inf ? Integer.MAX_VALUE : i; - } -}; +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat; + +/** + * This is just an integer that can have infinite value. It is used internally + * to implement the *, and + parts of regular expressions. + */ +public class patInt +{ + int i; + + boolean inf; + + /** Initialize to zero. */ + public patInt() + { + i = 0; + inf = false; + } + + /** Initialize to the value of init. */ + public patInt(int init) + { + i = init; + inf = false; + } + + /** Initialize to the value of p. */ + public patInt(patInt p) + { + i = p.i; + inf = p.inf; + } + + /** set this int to infinity. */ + public void setInf(boolean b) + { + inf = b; + if (b) + { + i = Integer.MAX_VALUE; + } + } + + /** Increment the value of this by 1. */ + public final void inc() + { + if (!inf) + { + i++; + } + } + + /** Decrement the value of this by 1. */ + public final void dec() + { + if (!inf) + { + i--; + } + } + + /** Test to see if this is less than or equal to j. */ + public final boolean lessEq(patInt j) + { /* + * if(inf) return false; if(j.inf) return true; return i <= j.i; + */ + return !inf && (j.inf || i <= j.i); + } + + /** Test to see if two patterns are equal. */ + public final boolean equals(patInt j) + { + return !j.inf && !inf && i == j.i; + } + + /** + * Formats the pattern as a String. Contrary to what you might expect, + * infinity is formatted as "" + */ + final public String toString() + { + if (inf) + { + return ""; + } + else + { + return "" + i; + } + } + + /** + * This would be operator+=(patInt) if I were programming in C++. + */ + public final patInt pluseq(patInt p) + { + if (inf || p.inf) + { + setInf(true); + } + else + { + i += p.i; + } + return this; + } + + /** + * Returns a patInt with value equal to the product of the value of p and + * this. + */ + public final patInt mul(patInt p) + { + if (inf || p.inf) + { + return new patInf(); + } + return new patInt(i * p.i); + } + + /** + * If the argument p has a smaller value than this, then set this Object equal + * to p. + */ + public final patInt mineq(patInt p) + { + if (p.inf) + { + return this; + } + if (inf) + { + i = p.i; + } + else if (p.i < i) + { + i = p.i; + } + setInf(false); + return this; + } + + /** + * If the argument p has a greater than this, then set this object equal to p. + */ + public final patInt maxeq(patInt p) + { + if (inf || p.inf) + { + setInf(true); + return this; + } + if (p.i > i) + { + i = p.i; + } + return this; + } + + /** Tests to see if this represents an infinite quantity. */ + public boolean finite() + { + return !inf; + } + + /** + * Converts to a patInt to an int. Infinity is mapped Integer.MAX_VALUE; + */ + public int intValue() + { + return inf ? Integer.MAX_VALUE : i; + } +}; diff --git a/unused/com/stevesoft/pat/wrap/CharArrayBufferWrap.java b/unused/com/stevesoft/pat/wrap/CharArrayBufferWrap.java index 97bfcf4..f353732 100644 --- a/unused/com/stevesoft/pat/wrap/CharArrayBufferWrap.java +++ b/unused/com/stevesoft/pat/wrap/CharArrayBufferWrap.java @@ -1,59 +1,59 @@ -package // -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -com.stevesoft.pat.wrap; - -import com.stevesoft.pat.BasicStringBufferLike; -import com.stevesoft.pat.StringLike; - -/** - * Allows the outcome of a replaceAll() or replaceFirst() to be an array of - * characters rather than a String. - */ -public class CharArrayBufferWrap implements BasicStringBufferLike -{ - javajs.util.SB sb = new javajs.util.SB(); - - public void appendChar(char c) - { - sb.appendC(c); - } - - public void appendStr(String s) - { - sb.append(s); - } - - public StringLike toStringLike() - { - char[] ca = new char[sb.length()]; - for (int i = 0; i < ca.length; i++) - { - ca[i] = sb.charAt(i); - } - try { - return (StringLike) Class.forName("com.stevesoft.pat.wrap.CharArrayWrap").getConstructor(char[].class).newInstance(ca); - } catch (Exception e) { - return null; - } - } - - public int length() - { - return sb.length(); - } - - public String toString() - { - return sb.toString(); - } - - public Object unwrap() - { - return sb; - } -} +package // +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +com.stevesoft.pat.wrap; + +import com.stevesoft.pat.BasicStringBufferLike; +import com.stevesoft.pat.StringLike; + +/** + * Allows the outcome of a replaceAll() or replaceFirst() to be an array of + * characters rather than a String. + */ +public class CharArrayBufferWrap implements BasicStringBufferLike +{ + javajs.util.SB sb = new javajs.util.SB(); + + public void appendChar(char c) + { + sb.appendC(c); + } + + public void appendStr(String s) + { + sb.append(s); + } + + public StringLike toStringLike() + { + char[] ca = new char[sb.length()]; + for (int i = 0; i < ca.length; i++) + { + ca[i] = sb.charAt(i); + } + try { + return (StringLike) Class.forName("com.stevesoft.pat.wrap.CharArrayWrap").getConstructor(char[].class).newInstance(ca); + } catch (Exception e) { + return null; + } + } + + public int length() + { + return sb.length(); + } + + public String toString() + { + return sb.toString(); + } + + public Object unwrap() + { + return sb; + } +} diff --git a/unused/com/stevesoft/pat/wrap/CharArrayWrap.java b/unused/com/stevesoft/pat/wrap/CharArrayWrap.java index a1cbbad..6710056 100644 --- a/unused/com/stevesoft/pat/wrap/CharArrayWrap.java +++ b/unused/com/stevesoft/pat/wrap/CharArrayWrap.java @@ -1,80 +1,80 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat.wrap; - -import com.stevesoft.pat.BasicStringBufferLike; -import com.stevesoft.pat.StringLike; - -/** - * This provides a wrapper for a char array so that it can be searched by Regex. - */ -public class CharArrayWrap implements StringLike -{ - char[] ca; - - public char[] getCharArray() - { - return ca; - } - - public CharArrayWrap(char[] ca) - { - this.ca = ca; - } - - public String toString() - { - return new String(ca); - } - - public char charAt(int i) - { - return ca[i]; - } - - public int length() - { - return ca.length; - } - - public String substring(int i1, int i2) - { - javajs.util.SB sb = new javajs.util.SB(); - for (int i = i1; i < i2; i++) - { - sb.appendC(ca[i]); - } - return sb.toString(); - } - - public Object unwrap() - { - return ca; - } - - public BasicStringBufferLike newStringBufferLike() - { - try { - return (BasicStringBufferLike) Class.forName("com.stevesoft.pat.wrap.CharArrayBufferWrap").newInstance(); - } catch (Exception e) { - return null; - } - } - - public int indexOf(char c) - { - for (int i = 0; i < ca.length; i++) - { - if (ca[i] == c) - { - return i; - } - } - return -1; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat.wrap; + +import com.stevesoft.pat.BasicStringBufferLike; +import com.stevesoft.pat.StringLike; + +/** + * This provides a wrapper for a char array so that it can be searched by Regex. + */ +public class CharArrayWrap implements StringLike +{ + char[] ca; + + public char[] getCharArray() + { + return ca; + } + + public CharArrayWrap(char[] ca) + { + this.ca = ca; + } + + public String toString() + { + return new String(ca); + } + + public char charAt(int i) + { + return ca[i]; + } + + public int length() + { + return ca.length; + } + + public String substring(int i1, int i2) + { + javajs.util.SB sb = new javajs.util.SB(); + for (int i = i1; i < i2; i++) + { + sb.appendC(ca[i]); + } + return sb.toString(); + } + + public Object unwrap() + { + return ca; + } + + public BasicStringBufferLike newStringBufferLike() + { + try { + return (BasicStringBufferLike) Class.forName("com.stevesoft.pat.wrap.CharArrayBufferWrap").newInstance(); + } catch (Exception e) { + return null; + } + } + + public int indexOf(char c) + { + for (int i = 0; i < ca.length; i++) + { + if (ca[i] == c) + { + return i; + } + } + return -1; + } +} diff --git a/unused/com/stevesoft/pat/wrap/StringBufferWrap.java b/unused/com/stevesoft/pat/wrap/StringBufferWrap.java index b3def1e..7114468 100644 --- a/unused/com/stevesoft/pat/wrap/StringBufferWrap.java +++ b/unused/com/stevesoft/pat/wrap/StringBufferWrap.java @@ -1,53 +1,53 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat.wrap; - -import com.stevesoft.pat.*; - -/** - * This provides a wrapper for javajs.util.SB to capture the output of a - * replacement. - */ -public class StringBufferWrap implements BasicStringBufferLike -{ - javajs.util.SB sb = new javajs.util.SB(); - - public void appendChar(char c) - { - sb.appendC(c); - } - - public void appendStr(String s) - { - sb.append(s); - } - - public int length() - { - return sb.length(); - } - - public String toString() - { - return sb.toString(); - } - - public StringLike toStringLike() - { - try { - return (StringLike) Class.forName("com.stevesoft.pat.wrap.StringWrap").getConstructor(String.class).newInstance(sb.toString()); - } catch (Exception e) { - return null; - } - } - - public Object unwrap() - { - return sb; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat.wrap; + +import com.stevesoft.pat.*; + +/** + * This provides a wrapper for javajs.util.SB to capture the output of a + * replacement. + */ +public class StringBufferWrap implements BasicStringBufferLike +{ + javajs.util.SB sb = new javajs.util.SB(); + + public void appendChar(char c) + { + sb.appendC(c); + } + + public void appendStr(String s) + { + sb.append(s); + } + + public int length() + { + return sb.length(); + } + + public String toString() + { + return sb.toString(); + } + + public StringLike toStringLike() + { + try { + return (StringLike) Class.forName("com.stevesoft.pat.wrap.StringWrap").getConstructor(String.class).newInstance(sb.toString()); + } catch (Exception e) { + return null; + } + } + + public Object unwrap() + { + return sb; + } +} diff --git a/unused/com/stevesoft/pat/wrap/StringWrap.java b/unused/com/stevesoft/pat/wrap/StringWrap.java index 536a53a..7333c33 100644 --- a/unused/com/stevesoft/pat/wrap/StringWrap.java +++ b/unused/com/stevesoft/pat/wrap/StringWrap.java @@ -1,64 +1,64 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat.wrap; - -import com.stevesoft.pat.BasicStringBufferLike; -import com.stevesoft.pat.StringLike; - -/** - * A basic wrapper for the String object. Regex does not search String directly - * any longer, it searches StringLike. - */ -public class StringWrap implements StringLike -{ - String s; - - public StringWrap(String s) - { - this.s = s; - } - - public String toString() - { - return s; - } - - public char charAt(int i) - { - return s.charAt(i); - } - - public int length() - { - return s.length(); - } - - public String substring(int i1, int i2) - { - return s.substring(i1, i2); - } - - public Object unwrap() - { - return s; - } - - public BasicStringBufferLike newStringBufferLike() - { - try { - return (BasicStringBufferLike) Class.forName("com.stevesoft.pat.wrap.StringBufferWrap").newInstance(); - } catch (Exception e) { - return null; - } - } - - public int indexOf(char c) - { - return s.indexOf(c); - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat.wrap; + +import com.stevesoft.pat.BasicStringBufferLike; +import com.stevesoft.pat.StringLike; + +/** + * A basic wrapper for the String object. Regex does not search String directly + * any longer, it searches StringLike. + */ +public class StringWrap implements StringLike +{ + String s; + + public StringWrap(String s) + { + this.s = s; + } + + public String toString() + { + return s; + } + + public char charAt(int i) + { + return s.charAt(i); + } + + public int length() + { + return s.length(); + } + + public String substring(int i1, int i2) + { + return s.substring(i1, i2); + } + + public Object unwrap() + { + return s; + } + + public BasicStringBufferLike newStringBufferLike() + { + try { + return (BasicStringBufferLike) Class.forName("com.stevesoft.pat.wrap.StringBufferWrap").newInstance(); + } catch (Exception e) { + return null; + } + } + + public int indexOf(char c) + { + return s.indexOf(c); + } +} diff --git a/unused/com/stevesoft/pat/wrap/WriterWrap.java b/unused/com/stevesoft/pat/wrap/WriterWrap.java index 48db5e6..e5c6a84 100644 --- a/unused/com/stevesoft/pat/wrap/WriterWrap.java +++ b/unused/com/stevesoft/pat/wrap/WriterWrap.java @@ -1,61 +1,61 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat.wrap; - -import java.io.*; - -import com.stevesoft.pat.*; - -/** - * Allows the outcome of a replaceAll() or replaceFirst() to be directed to a - * Writer rather than a String. - *

    - * The method toStringLike() cannot work, however. This means that the return - * value of replaceAll() will be null if this Object is used as the - * StringBufferLike. - */ -public class WriterWrap implements BasicStringBufferLike -{ - Writer w; - - public WriterWrap(Writer w) - { - this.w = w; - } - - public void appendChar(char c) - { - try - { - w.write((int) c); - } catch (IOException ioe) - { - } - } - - public void appendStr(String s) - { - try - { - w.write(s); - } catch (IOException ioe) - { - } - } - - /** This operation can't really be done. */ - public StringLike toStringLike() - { - return null; - } - - public Object unwrap() - { - return w; - } -} +// +// This software is now distributed according to +// the Lesser Gnu Public License. Please see +// http://www.gnu.org/copyleft/lesser.txt for +// the details. +// -- Happy Computing! +// +package com.stevesoft.pat.wrap; + +import java.io.*; + +import com.stevesoft.pat.*; + +/** + * Allows the outcome of a replaceAll() or replaceFirst() to be directed to a + * Writer rather than a String. + *

    + * The method toStringLike() cannot work, however. This means that the return + * value of replaceAll() will be null if this Object is used as the + * StringBufferLike. + */ +public class WriterWrap implements BasicStringBufferLike +{ + Writer w; + + public WriterWrap(Writer w) + { + this.w = w; + } + + public void appendChar(char c) + { + try + { + w.write((int) c); + } catch (IOException ioe) + { + } + } + + public void appendStr(String s) + { + try + { + w.write(s); + } catch (IOException ioe) + { + } + } + + /** This operation can't really be done. */ + public StringLike toStringLike() + { + return null; + } + + public Object unwrap() + { + return w; + } +} -- 1.7.10.2