From 506d60f0e188723ddc91c26824b41ac7034df3fe Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 4 Sep 2008 13:34:15 +0000 Subject: [PATCH] merge from 2_4_Release branch --- help/html/jalviewjnlp.html | 38 +- src/MCview/AppletPDBCanvas.java | 264 +- src/MCview/AppletPDBViewer.java | 72 +- src/MCview/Atom.java | 41 +- src/MCview/Bond.java | 160 +- src/MCview/MCMatrix.java | 346 +- src/MCview/PDBCanvas.java | 287 +- src/MCview/PDBChain.java | 214 +- src/MCview/PDBViewer.java | 158 +- src/MCview/PDBfile.java | 65 +- src/MCview/Residue.java | 101 +- src/MCview/Zsort.java | 148 +- src/com/stevesoft/pat/AmpersandRule.java | 59 +- src/com/stevesoft/pat/Any.java | 110 +- src/com/stevesoft/pat/BackG.java | 93 +- src/com/stevesoft/pat/BackMatch.java | 114 +- src/com/stevesoft/pat/BackRefRule.java | 78 +- src/com/stevesoft/pat/Backup.java | 106 +- src/com/stevesoft/pat/BasicStringBufferLike.java | 45 +- src/com/stevesoft/pat/Bits.java | 6136 +++++++------- src/com/stevesoft/pat/Boundary.java | 181 +- src/com/stevesoft/pat/Bracket.java | 175 +- src/com/stevesoft/pat/CaseMgr.java | 8816 ++++++++++---------- src/com/stevesoft/pat/ChangeRule.java | 97 +- src/com/stevesoft/pat/CodeRule.java | 65 +- src/com/stevesoft/pat/Ctrl.java | 332 +- src/com/stevesoft/pat/Custom.java | 124 +- src/com/stevesoft/pat/CustomEndpoint.java | 87 +- src/com/stevesoft/pat/DirFileRegex.java | 61 +- src/com/stevesoft/pat/DotMulti.java | 414 +- src/com/stevesoft/pat/End.java | 141 +- src/com/stevesoft/pat/FastBracket.java | 512 +- src/com/stevesoft/pat/FastMulti.java | 340 +- src/com/stevesoft/pat/FileRegex.java | 616 +- src/com/stevesoft/pat/Group.java | 152 +- src/com/stevesoft/pat/LeftRule.java | 61 +- src/com/stevesoft/pat/Multi.java | 175 +- src/com/stevesoft/pat/MultiMin.java | 43 +- src/com/stevesoft/pat/Multi_stage2.java | 313 +- src/com/stevesoft/pat/NoPattern.java | 66 +- src/com/stevesoft/pat/NonDirFileRegex.java | 61 +- src/com/stevesoft/pat/NotImplementedError.java | 33 +- src/com/stevesoft/pat/NullPattern.java | 74 +- src/com/stevesoft/pat/NullRule.java | 58 +- src/com/stevesoft/pat/Or.java | 257 +- src/com/stevesoft/pat/OrMark.java | 145 +- src/com/stevesoft/pat/PartialBuffer.java | 215 +- src/com/stevesoft/pat/Pattern.java | 574 +- src/com/stevesoft/pat/PatternSub.java | 33 +- src/com/stevesoft/pat/PopRule.java | 47 +- src/com/stevesoft/pat/Prop.java | 148 +- src/com/stevesoft/pat/Pthings.java | 82 +- src/com/stevesoft/pat/PushRule.java | 97 +- src/com/stevesoft/pat/RBuffer.java | 99 +- src/com/stevesoft/pat/Range.java | 195 +- src/com/stevesoft/pat/RegOpt.java | 917 +- src/com/stevesoft/pat/RegRes.java | 575 +- src/com/stevesoft/pat/RegSyntax.java | 59 +- src/com/stevesoft/pat/RegSyntaxError.java | 82 +- src/com/stevesoft/pat/Regex.java | 4114 ++++----- src/com/stevesoft/pat/RegexReader.java | 634 +- src/com/stevesoft/pat/RegexTokenizer.java | 332 +- src/com/stevesoft/pat/RegexWriter.java | 543 +- src/com/stevesoft/pat/ReplaceRule.java | 798 +- src/com/stevesoft/pat/Replacer.java | 724 +- src/com/stevesoft/pat/RightRule.java | 60 +- src/com/stevesoft/pat/Rthings.java | 120 +- src/com/stevesoft/pat/RuleHolder.java | 85 +- src/com/stevesoft/pat/Skip.java | 382 +- src/com/stevesoft/pat/Skip2.java | 112 +- src/com/stevesoft/pat/SkipBMH.java | 550 +- src/com/stevesoft/pat/Skipped.java | 110 +- src/com/stevesoft/pat/SpecialRule.java | 37 +- src/com/stevesoft/pat/Start.java | 114 +- src/com/stevesoft/pat/StrPos.java | 367 +- src/com/stevesoft/pat/StringBufferLike.java | 182 +- src/com/stevesoft/pat/StringLike.java | 91 +- src/com/stevesoft/pat/StringRule.java | 76 +- src/com/stevesoft/pat/SubMark.java | 63 +- src/com/stevesoft/pat/TransPat.java | 96 +- src/com/stevesoft/pat/Transformer.java | 452 +- src/com/stevesoft/pat/UniValidator.java | 49 +- src/com/stevesoft/pat/Validator.java | 145 +- src/com/stevesoft/pat/WantMoreTextReplaceRule.java | 57 +- src/com/stevesoft/pat/lookAhead.java | 198 +- src/com/stevesoft/pat/oneChar.java | 151 +- src/com/stevesoft/pat/parsePerl.java | 752 +- src/com/stevesoft/pat/patInf.java | 33 +- src/com/stevesoft/pat/patInt.java | 351 +- .../stevesoft/pat/wrap/CharArrayBufferWrap.java | 107 +- src/com/stevesoft/pat/wrap/CharArrayWrap.java | 149 +- .../stevesoft/pat/wrap/RandomAccessFileWrap.java | 343 +- src/com/stevesoft/pat/wrap/StringBufferWrap.java | 96 +- src/com/stevesoft/pat/wrap/StringWrap.java | 116 +- src/com/stevesoft/pat/wrap/WriterWrap.java | 120 +- src/ext/vamsas/IRegistry.java | 28 +- src/ext/vamsas/IRegistryService.java | 30 +- src/ext/vamsas/IRegistryServiceLocator.java | 85 +- src/ext/vamsas/Jpred.java | 39 +- src/ext/vamsas/JpredService.java | 31 +- src/ext/vamsas/JpredServiceLocator.java | 84 +- src/ext/vamsas/JpredSoapBindingStub.java | 224 +- src/ext/vamsas/MuscleWS.java | 96 +- src/ext/vamsas/MuscleWSService.java | 86 +- src/ext/vamsas/MuscleWSServiceLocator.java | 417 +- src/ext/vamsas/MuscleWSSoapBindingStub.java | 960 +-- src/ext/vamsas/RegistryServiceSoapBindingStub.java | 121 +- src/ext/vamsas/SeqSearchI.java | 46 +- src/ext/vamsas/SeqSearchServiceLocator.java | 286 +- src/ext/vamsas/SeqSearchServiceService.java | 34 +- .../vamsas/SeqSearchServiceSoapBindingStub.java | 835 +- src/ext/vamsas/ServiceHandle.java | 118 +- src/ext/vamsas/ServiceHandles.java | 86 +- src/jalview/analysis/AAFrequency.java | 315 +- src/jalview/analysis/AlignSeq.java | 360 +- src/jalview/analysis/AlignmentSorter.java | 265 +- src/jalview/analysis/Conservation.java | 31 +- src/jalview/analysis/CrossRef.java | 76 +- src/jalview/analysis/Dna.java | 270 +- src/jalview/analysis/Finder.java | 91 +- src/jalview/analysis/NJTree.java | 517 +- src/jalview/analysis/PCA.java | 491 +- src/jalview/analysis/ParseProperties.java | 159 +- src/jalview/analysis/SeqsetUtils.java | 174 +- src/jalview/analysis/SequenceIdMatcher.java | 504 +- src/jalview/appletgui/APopupMenu.java | 353 +- src/jalview/appletgui/AlignFrame.java | 1492 ++-- src/jalview/appletgui/AlignViewport.java | 280 +- src/jalview/appletgui/AlignmentPanel.java | 120 +- src/jalview/appletgui/AnnotationColourChooser.java | 161 +- src/jalview/appletgui/AnnotationLabels.java | 107 +- src/jalview/appletgui/AnnotationPanel.java | 556 +- src/jalview/appletgui/AppletJmol.java | 470 +- src/jalview/appletgui/CutAndPasteTransfer.java | 557 +- src/jalview/appletgui/EditNameDialog.java | 161 +- src/jalview/appletgui/EmbmenuFrame.java | 186 +- src/jalview/appletgui/FeatureRenderer.java | 487 +- src/jalview/appletgui/FeatureSettings.java | 154 +- src/jalview/appletgui/Finder.java | 59 +- src/jalview/appletgui/FontChooser.java | 550 +- src/jalview/appletgui/IdCanvas.java | 134 +- src/jalview/appletgui/IdPanel.java | 77 +- src/jalview/appletgui/IdwidthAdjuster.java | 212 +- src/jalview/appletgui/JVDialog.java | 157 +- src/jalview/appletgui/OverviewPanel.java | 904 +- src/jalview/appletgui/PCAPanel.java | 78 +- src/jalview/appletgui/PaintRefresher.java | 457 +- src/jalview/appletgui/PairwiseAlignPanel.java | 68 +- src/jalview/appletgui/RedundancyPanel.java | 86 +- src/jalview/appletgui/RotatableCanvas.java | 1263 +-- src/jalview/appletgui/ScalePanel.java | 910 +- src/jalview/appletgui/SeqCanvas.java | 1643 ++-- src/jalview/appletgui/SeqPanel.java | 433 +- src/jalview/appletgui/SequenceRenderer.java | 673 +- src/jalview/appletgui/SliderPanel.java | 740 +- src/jalview/appletgui/Tooltip.java | 57 +- src/jalview/appletgui/TreeCanvas.java | 203 +- src/jalview/appletgui/TreePanel.java | 140 +- src/jalview/appletgui/UserDefinedColours.java | 1195 +-- src/jalview/bin/Cache.java | 330 +- src/jalview/bin/Jalview.java | 226 +- src/jalview/bin/JalviewLite.java | 50 +- src/jalview/binding/Alignment.java | 332 +- src/jalview/binding/Annotation.java | 864 +- src/jalview/binding/AnnotationElement.java | 579 +- src/jalview/binding/Colour.java | 331 +- src/jalview/binding/Feature.java | 577 +- src/jalview/binding/FeatureSettings.java | 493 +- src/jalview/binding/Features.java | 205 +- src/jalview/binding/JGroup.java | 1484 ++-- src/jalview/binding/JSeq.java | 1253 +-- src/jalview/binding/JalviewModel.java | 436 +- src/jalview/binding/JalviewModelSequence.java | 1862 +++-- src/jalview/binding/JalviewUserColours.java | 584 +- src/jalview/binding/Pdbentry.java | 643 +- src/jalview/binding/PdbentryItem.java | 367 +- src/jalview/binding/Pdbids.java | 205 +- src/jalview/binding/Property.java | 332 +- src/jalview/binding/Sequence.java | 205 +- src/jalview/binding/SequenceSet.java | 1037 +-- src/jalview/binding/SequenceType.java | 383 +- src/jalview/binding/Setting.java | 495 +- src/jalview/binding/Tree.java | 1648 ++-- src/jalview/binding/UserColourScheme.java | 206 +- src/jalview/binding/UserColours.java | 333 +- src/jalview/binding/VAMSAS.java | 1168 +-- src/jalview/binding/VamsasModel.java | 204 +- src/jalview/binding/Viewport.java | 2880 +++---- src/jalview/commands/ChangeCaseCommand.java | 37 +- src/jalview/commands/CommandI.java | 10 +- src/jalview/commands/EditCommand.java | 505 +- src/jalview/commands/OrderCommand.java | 20 +- src/jalview/commands/RemoveGapColCommand.java | 65 +- src/jalview/commands/RemoveGapsCommand.java | 60 +- src/jalview/commands/SlideSequencesCommand.java | 55 +- src/jalview/commands/TrimRegionCommand.java | 48 +- src/jalview/datamodel/AlignedCodonFrame.java | 204 +- src/jalview/datamodel/Alignment.java | 261 +- src/jalview/datamodel/AlignmentAnnotation.java | 315 +- src/jalview/datamodel/AlignmentI.java | 195 +- src/jalview/datamodel/AlignmentOrder.java | 665 +- src/jalview/datamodel/AlignmentView.java | 1053 +-- src/jalview/datamodel/Annotation.java | 67 +- src/jalview/datamodel/BinaryNode.java | 585 +- src/jalview/datamodel/BinarySequence.java | 46 +- src/jalview/datamodel/CigarArray.java | 89 +- src/jalview/datamodel/CigarBase.java | 571 +- src/jalview/datamodel/CigarCigar.java | 121 +- src/jalview/datamodel/CigarSimple.java | 96 +- src/jalview/datamodel/ColumnSelection.java | 323 +- src/jalview/datamodel/DBRefEntry.java | 188 +- src/jalview/datamodel/DBRefSource.java | 231 +- src/jalview/datamodel/FeatureProperties.java | 33 +- src/jalview/datamodel/GraphLine.java | 20 +- src/jalview/datamodel/HiddenSequences.java | 30 +- src/jalview/datamodel/Mapping.java | 90 +- src/jalview/datamodel/PDBEntry.java | 47 +- src/jalview/datamodel/Provenance.java | 95 +- src/jalview/datamodel/ProvenanceEntry.java | 106 +- src/jalview/datamodel/SearchResults.java | 54 +- src/jalview/datamodel/SeqCigar.java | 370 +- src/jalview/datamodel/Sequence.java | 19 +- src/jalview/datamodel/SequenceFeature.java | 87 +- src/jalview/datamodel/SequenceGroup.java | 228 +- src/jalview/datamodel/SequenceI.java | 201 +- src/jalview/datamodel/SequenceNode.java | 93 +- src/jalview/datamodel/SequencePoint.java | 15 +- src/jalview/datamodel/UniprotEntry.java | 191 +- src/jalview/datamodel/UniprotFile.java | 72 +- src/jalview/datamodel/UniprotProteinName.java | 10 +- src/jalview/datamodel/UniprotSequence.java | 92 +- src/jalview/datamodel/xdb/embl/BasePosition.java | 84 +- src/jalview/datamodel/xdb/embl/EmblEntry.java | 151 +- src/jalview/datamodel/xdb/embl/EmblError.java | 50 +- src/jalview/datamodel/xdb/embl/EmblFeature.java | 151 +- .../datamodel/xdb/embl/EmblFeatureLocElement.java | 183 +- .../datamodel/xdb/embl/EmblFeatureLocations.java | 241 +- src/jalview/datamodel/xdb/embl/EmblFile.java | 211 +- src/jalview/datamodel/xdb/embl/EmblSequence.java | 116 +- src/jalview/datamodel/xdb/embl/Qualifier.java | 160 +- src/jalview/gui/AlignFrame.java | 3067 +++---- src/jalview/gui/AlignViewport.java | 2999 +++---- src/jalview/gui/AlignmentPanel.java | 506 +- src/jalview/gui/AnnotationColourChooser.java | 1041 +-- src/jalview/gui/AnnotationExporter.java | 117 +- src/jalview/gui/AnnotationLabels.java | 234 +- src/jalview/gui/AnnotationPanel.java | 640 +- src/jalview/gui/AppJmol.java | 438 +- src/jalview/gui/CutAndPasteTransfer.java | 525 +- src/jalview/gui/DasSourceBrowser.java | 280 +- src/jalview/gui/Desktop.java | 794 +- src/jalview/gui/EPSOptions.java | 292 +- src/jalview/gui/EditNameDialog.java | 164 +- src/jalview/gui/FeatureRenderer.java | 544 +- src/jalview/gui/FeatureSettings.java | 586 +- src/jalview/gui/Finder.java | 93 +- src/jalview/gui/FontChooser.java | 530 +- src/jalview/gui/IProgressIndicator.java | 35 +- src/jalview/gui/IdCanvas.java | 966 +-- src/jalview/gui/IdPanel.java | 170 +- src/jalview/gui/IdwidthAdjuster.java | 333 +- src/jalview/gui/Jalview2XML.java | 462 +- src/jalview/gui/Jalview2XML_V1.java | 230 +- src/jalview/gui/OOMWarning.java | 79 + src/jalview/gui/OverviewPanel.java | 905 +- src/jalview/gui/PCAPanel.java | 190 +- src/jalview/gui/PaintRefresher.java | 487 +- src/jalview/gui/PairwiseAlignPanel.java | 68 +- src/jalview/gui/PopupMenu.java | 622 +- src/jalview/gui/Preferences.java | 295 +- src/jalview/gui/RedundancyPanel.java | 85 +- src/jalview/gui/RotatableCanvas.java | 1587 ++-- src/jalview/gui/ScalePanel.java | 137 +- src/jalview/gui/ScriptWindow.java | 1346 +-- src/jalview/gui/SeqCanvas.java | 378 +- src/jalview/gui/SeqPanel.java | 495 +- src/jalview/gui/SequenceFetcher.java | 96 +- src/jalview/gui/SequenceRenderer.java | 906 +- src/jalview/gui/SliderPanel.java | 732 +- src/jalview/gui/SplashScreen.java | 123 +- src/jalview/gui/TextColourChooser.java | 422 +- src/jalview/gui/TreeCanvas.java | 414 +- src/jalview/gui/TreePanel.java | 272 +- src/jalview/gui/UserDefinedColours.java | 270 +- src/jalview/gui/UserQuestionnaireCheck.java | 89 +- src/jalview/gui/VamsasApplication.java | 104 +- src/jalview/gui/WebserviceInfo.java | 10 +- src/jalview/io/AMSAFile.java | 199 +- src/jalview/io/AlignFile.java | 108 +- src/jalview/io/AnnotationFile.java | 336 +- src/jalview/io/AppletFormatAdapter.java | 268 +- src/jalview/io/BLCFile.java | 139 +- src/jalview/io/ClansFile.java | 20 +- src/jalview/io/ClustalFile.java | 56 +- src/jalview/io/DBRefFile.java | 24 +- src/jalview/io/FastaFile.java | 94 +- src/jalview/io/FeaturesFile.java | 49 +- src/jalview/io/FileLoader.java | 77 +- src/jalview/io/FileParse.java | 282 +- src/jalview/io/FormatAdapter.java | 162 +- src/jalview/io/HTMLOutput.java | 773 +- src/jalview/io/IdentifyFile.java | 168 +- src/jalview/io/JPredFile.java | 220 +- src/jalview/io/JalviewFileChooser.java | 95 +- src/jalview/io/JalviewFileFilter.java | 345 +- src/jalview/io/JalviewFileView.java | 222 +- src/jalview/io/JnetAnnotationMaker.java | 143 +- src/jalview/io/MSFfile.java | 128 +- src/jalview/io/MatrixFile.java | 39 +- src/jalview/io/ModellerDescription.java | 799 +- src/jalview/io/NewickFile.java | 56 +- src/jalview/io/PIRFile.java | 43 +- src/jalview/io/PfamFile.java | 42 +- src/jalview/io/PileUpfile.java | 78 +- src/jalview/io/StockholmFile.java | 63 +- src/jalview/io/VamsasAppDatastore.java | 75 +- src/jalview/io/WSWUBlastClient.java | 609 +- src/jalview/io/vamsas/DatastoreItem.java | 111 +- src/jalview/io/vamsas/Dbref.java | 99 +- src/jalview/io/vamsas/LocalDocSyncObject.java | 68 +- src/jalview/io/vamsas/Rangetype.java | 131 +- src/jalview/io/vamsas/Sequencemapping.java | 315 +- src/jalview/io/vamsas/Tree.java | 42 +- src/jalview/jbgui/GAlignFrame.java | 786 +- src/jalview/jbgui/GAlignmentPanel.java | 234 +- src/jalview/jbgui/GCutAndPasteTransfer.java | 444 +- src/jalview/jbgui/GDasSourceBrowser.java | 109 +- src/jalview/jbgui/GDesktop.java | 175 +- src/jalview/jbgui/GFinder.java | 42 +- src/jalview/jbgui/GFontChooser.java | 526 +- src/jalview/jbgui/GPCAPanel.java | 527 +- src/jalview/jbgui/GPairwiseAlignPanel.java | 184 +- src/jalview/jbgui/GPreferences.java | 1207 +-- src/jalview/jbgui/GSequenceLink.java | 57 +- src/jalview/jbgui/GSliderPanel.java | 402 +- src/jalview/jbgui/GStructureViewer.java | 666 +- src/jalview/jbgui/GTreePanel.java | 511 +- src/jalview/jbgui/GUserDefinedColours.java | 536 +- src/jalview/jbgui/GWebserviceInfo.java | 240 +- src/jalview/math/Matrix.java | 1708 ++-- src/jalview/math/RotatableMatrix.java | 675 +- src/jalview/schemabinding/version2/AlcodMap.java | 359 +- src/jalview/schemabinding/version2/Alcodon.java | 521 +- .../schemabinding/version2/AlcodonFrame.java | 861 +- src/jalview/schemabinding/version2/Annotation.java | 1561 ++-- .../schemabinding/version2/AnnotationColours.java | 723 +- .../schemabinding/version2/AnnotationElement.java | 679 +- src/jalview/schemabinding/version2/Colour.java | 332 +- src/jalview/schemabinding/version2/DBRef.java | 435 +- src/jalview/schemabinding/version2/Feature.java | 1052 +-- .../schemabinding/version2/FeatureSettings.java | 857 +- src/jalview/schemabinding/version2/Features.java | 205 +- src/jalview/schemabinding/version2/Group.java | 398 +- .../schemabinding/version2/HiddenColumns.java | 426 +- src/jalview/schemabinding/version2/JGroup.java | 1772 ++-- src/jalview/schemabinding/version2/JSeq.java | 1664 ++-- .../schemabinding/version2/JalviewModel.java | 439 +- .../version2/JalviewModelSequence.java | 1896 +++-- .../schemabinding/version2/JalviewUserColours.java | 587 +- .../schemabinding/version2/MapListFrom.java | 426 +- src/jalview/schemabinding/version2/MapListTo.java | 426 +- .../schemabinding/version2/MapListType.java | 1162 +-- src/jalview/schemabinding/version2/Mapping.java | 317 +- .../schemabinding/version2/MappingChoice.java | 335 +- src/jalview/schemabinding/version2/OtherData.java | 334 +- src/jalview/schemabinding/version2/Pdbentry.java | 700 +- .../schemabinding/version2/PdbentryItem.java | 375 +- src/jalview/schemabinding/version2/Pdbids.java | 510 +- src/jalview/schemabinding/version2/Property.java | 334 +- src/jalview/schemabinding/version2/Sequence.java | 608 +- .../schemabinding/version2/SequenceSet.java | 1664 ++-- .../version2/SequenceSetProperties.java | 336 +- .../schemabinding/version2/SequenceType.java | 436 +- src/jalview/schemabinding/version2/Setting.java | 592 +- .../schemabinding/version2/StructureState.java | 794 +- .../schemabinding/version2/ThresholdLine.java | 477 +- src/jalview/schemabinding/version2/Tree.java | 1649 ++-- .../schemabinding/version2/UserColourScheme.java | 209 +- .../schemabinding/version2/UserColours.java | 335 +- src/jalview/schemabinding/version2/VAMSAS.java | 846 +- .../schemabinding/version2/VamsasModel.java | 205 +- src/jalview/schemabinding/version2/Viewport.java | 3538 ++++---- .../version2/descriptors/AlcodMapDescriptor.java | 438 +- .../version2/descriptors/AlcodonDescriptor.java | 528 +- .../descriptors/AlcodonFrameDescriptor.java | 467 +- .../descriptors/AnnotationColoursDescriptor.java | 812 +- .../version2/descriptors/AnnotationDescriptor.java | 1432 ++-- .../descriptors/AnnotationElementDescriptor.java | 812 +- .../version2/descriptors/ColourDescriptor.java | 434 +- .../version2/descriptors/DBRefDescriptor.java | 590 +- .../version2/descriptors/FeatureDescriptor.java | 987 ++- .../descriptors/FeatureSettingsDescriptor.java | 466 +- .../version2/descriptors/FeaturesDescriptor.java | 282 +- .../version2/descriptors/GroupDescriptor.java | 449 +- .../descriptors/HiddenColumnsDescriptor.java | 462 +- .../version2/descriptors/JGroupDescriptor.java | 1584 ++-- .../version2/descriptors/JSeqDescriptor.java | 1046 +-- .../descriptors/JalviewModelDescriptor.java | 611 +- .../JalviewModelSequenceDescriptor.java | 826 +- .../descriptors/JalviewUserColoursDescriptor.java | 453 +- .../descriptors/MapListFromDescriptor.java | 464 +- .../version2/descriptors/MapListToDescriptor.java | 464 +- .../descriptors/MapListTypeDescriptor.java | 660 +- .../descriptors/MappingChoiceDescriptor.java | 447 +- .../version2/descriptors/MappingDescriptor.java | 379 +- .../version2/descriptors/OtherDataDescriptor.java | 440 +- .../version2/descriptors/PdbentryDescriptor.java | 613 +- .../descriptors/PdbentryItemDescriptor.java | 394 +- .../version2/descriptors/PdbidsDescriptor.java | 397 +- .../version2/descriptors/PropertyDescriptor.java | 440 +- .../version2/descriptors/SequenceDescriptor.java | 455 +- .../descriptors/SequenceSetDescriptor.java | 825 +- .../SequenceSetPropertiesDescriptor.java | 446 +- .../descriptors/SequenceTypeDescriptor.java | 600 +- .../version2/descriptors/SettingDescriptor.java | 641 +- .../descriptors/StructureStateDescriptor.java | 823 +- .../descriptors/ThresholdLineDescriptor.java | 524 +- .../version2/descriptors/TreeDescriptor.java | 1649 ++-- .../descriptors/UserColourSchemeDescriptor.java | 283 +- .../descriptors/UserColoursDescriptor.java | 436 +- .../version2/descriptors/VAMSASDescriptor.java | 478 +- .../descriptors/VamsasModelDescriptor.java | 282 +- .../version2/descriptors/ViewportDescriptor.java | 3206 +++---- src/jalview/schemes/AnnotationColourGradient.java | 457 +- src/jalview/schemes/Blosum62ColourScheme.java | 183 +- src/jalview/schemes/BuriedColourScheme.java | 104 +- src/jalview/schemes/ClustalxColourScheme.java | 178 +- src/jalview/schemes/ColourSchemeI.java | 86 +- src/jalview/schemes/ColourSchemeProperty.java | 12 +- src/jalview/schemes/Consensus.java | 32 +- src/jalview/schemes/HelixColourScheme.java | 71 +- src/jalview/schemes/HydrophobicColourScheme.java | 104 +- src/jalview/schemes/NucleotideColourScheme.java | 175 +- src/jalview/schemes/PIDColourScheme.java | 187 +- src/jalview/schemes/ResidueColourScheme.java | 552 +- src/jalview/schemes/ResidueProperties.java | 577 +- src/jalview/schemes/ScoreColourScheme.java | 247 +- src/jalview/schemes/ScoreMatrix.java | 36 +- src/jalview/schemes/StrandColourScheme.java | 104 +- src/jalview/schemes/TaylorColourScheme.java | 55 +- src/jalview/schemes/TurnColourScheme.java | 104 +- src/jalview/schemes/UserColourScheme.java | 37 +- src/jalview/schemes/ZappoColourScheme.java | 15 +- src/jalview/structure/SequenceListener.java | 10 +- src/jalview/structure/StructureListener.java | 66 +- src/jalview/structure/StructureMapping.java | 199 +- .../structure/StructureSelectionManager.java | 14 +- src/jalview/structure/VamsasListener.java | 18 + src/jalview/util/BrowserLauncher.java | 1821 ++-- src/jalview/util/Comparison.java | 462 +- src/jalview/util/DBRefUtils.java | 526 +- src/jalview/util/Format.java | 1809 ++-- src/jalview/util/ImageMaker.java | 376 +- src/jalview/util/MapList.java | 51 +- src/jalview/util/Platform.java | 24 +- src/jalview/util/QuickSort.java | 31 +- src/jalview/util/ShiftList.java | 47 +- src/jalview/util/TableSorter.java | 184 +- src/jalview/util/UrlLink.java | 20 +- src/jalview/ws/DBRefFetcher.java | 65 +- src/jalview/ws/DasSequenceFeatureFetcher.java | 181 +- src/jalview/ws/Discoverer.java | 314 +- src/jalview/ws/JPredClient.java | 241 +- src/jalview/ws/JPredThread.java | 375 +- src/jalview/ws/MsaWSClient.java | 141 +- src/jalview/ws/MsaWSThread.java | 1435 ++-- src/jalview/ws/SeqSearchWSClient.java | 610 +- src/jalview/ws/SeqSearchWSThread.java | 1346 +-- src/jalview/ws/SequenceFetcher.java | 153 +- src/jalview/ws/WSClient.java | 93 +- src/jalview/ws/WSClientI.java | 23 +- src/jalview/ws/WSThread.java | 929 ++- src/jalview/ws/dbsources/DasSequenceSource.java | 100 +- .../ws/dbsources/EbiFileRetrievedProxy.java | 31 +- src/jalview/ws/dbsources/EmblCdsSouce.java | 36 +- src/jalview/ws/dbsources/EmblSource.java | 54 +- src/jalview/ws/dbsources/EmblXmlSource.java | 149 +- src/jalview/ws/dbsources/GeneDbSource.java | 20 +- src/jalview/ws/dbsources/Pdb.java | 86 +- src/jalview/ws/dbsources/Pfam.java | 121 +- src/jalview/ws/dbsources/PfamFull.java | 31 +- src/jalview/ws/dbsources/PfamSeed.java | 32 +- src/jalview/ws/dbsources/Uniprot.java | 75 +- src/jalview/ws/dbsources/UnprotName.java | 33 +- .../dbsources/das/DasSequenceSourceListener.java | 94 +- src/jalview/ws/ebi/EBIFetchClient.java | 475 +- src/jalview/ws/seqfetcher/ASequenceFetcher.java | 70 +- src/jalview/ws/seqfetcher/DbSourceProxy.java | 80 +- src/jalview/ws/seqfetcher/DbSourceProxyImpl.java | 58 +- .../biojava/dasobert/das/DAS_FeatureRetrieve.java | 171 +- .../biojava/dasobert/das/DAS_Feature_Handler.java | 262 +- .../biojava/dasobert/das/DAS_Sequence_Handler.java | 240 +- src/org/biojava/dasobert/das/FeatureThread.java | 43 +- src/org/biojava/dasobert/das/SequenceThread.java | 447 +- src/org/biojava/dasobert/das2/Das2Capability.java | 5 +- .../biojava/dasobert/das2/Das2CapabilityImpl.java | 9 +- src/org/biojava/dasobert/das2/Das2Source.java | 12 +- src/org/biojava/dasobert/das2/Das2SourceImpl.java | 18 +- .../biojava/dasobert/das2/DasSourceConverter.java | 23 +- .../dasobert/das2/io/DAS2SourceHandler.java | 60 +- .../dasobert/das2/io/DasSourceReaderImpl.java | 51 +- .../biojava/dasobert/dasregistry/Das1Source.java | 124 +- .../dasregistry/DasCoordSysComparator.java | 22 +- .../dasobert/dasregistry/DasCoordinateSystem.java | 38 +- .../biojava/dasobert/dasregistry/DasSource.java | 65 +- .../dasobert/dasregistry/DasSourceComparator.java | 69 +- .../dasobert/eventmodel/AbstractDasEvent.java | 23 +- .../biojava/dasobert/eventmodel/FeatureEvent.java | 52 +- .../dasobert/eventmodel/FeatureListener.java | 17 +- .../dasobert/eventmodel/ObjectListener.java | 18 +- .../biojava/dasobert/eventmodel/SequenceEvent.java | 19 +- .../dasobert/eventmodel/SequenceListener.java | 40 +- .../dasobert/feature/AbstractFeatureTrack.java | 410 +- .../biojava/dasobert/feature/AbstractSegment.java | 363 +- .../dasobert/feature/FeatureComparator.java | 76 +- .../dasobert/feature/FeatureMapComparator.java | 59 +- src/org/biojava/dasobert/feature/FeatureTrack.java | 176 +- .../dasobert/feature/FeatureTrackConverter.java | 924 +- .../biojava/dasobert/feature/FeatureTrackImpl.java | 67 +- .../biojava/dasobert/feature/HistogramFeature.java | 135 +- .../biojava/dasobert/feature/HistogramSegment.java | 70 +- src/org/biojava/dasobert/feature/Segment.java | 72 +- .../dasobert/feature/SegmentComparator.java | 30 +- src/org/biojava/dasobert/feature/SegmentImpl.java | 97 +- src/org/jibble/epsgraphics/EpsDocument.java | 533 +- src/org/jibble/epsgraphics/EpsException.java | 53 +- src/org/jibble/epsgraphics/EpsGraphics2D.java | 2887 ++++--- src/uk/ac/ebi/picr/model/CrossReference.java | 580 +- .../ac/ebi/picr/model/CrossReference_Helper.java | 180 +- src/uk/ac/ebi/picr/model/UPEntry.java | 493 +- src/uk/ac/ebi/picr/model/UPEntry_Helper.java | 148 +- src/uk/ac/ebi/www/Data.java | 51 +- src/uk/ac/ebi/www/InputParams.java | 145 +- src/uk/ac/ebi/www/WSFile.java | 51 +- src/uk/ac/ebi/www/WSWUBlast.java | 18 +- src/uk/ac/ebi/www/WSWUBlastService.java | 7 +- src/uk/ac/ebi/www/WSWUBlastServiceLocator.java | 59 +- src/uk/ac/ebi/www/WSWUBlastSoapBindingStub.java | 267 +- .../AccessionMapperBindingStub.java | 588 +- .../AccessionMapperInterface.java | 18 +- .../AccessionMapperService.java | 11 +- .../AccessionMapperServiceLocator.java | 275 +- src/vamsas/IMsaWS.java | 23 +- src/vamsas/objects/simple/Alignment.java | 281 +- src/vamsas/objects/simple/Alignment_Helper.java | 128 +- src/vamsas/objects/simple/JpredResult.java | 56 +- src/vamsas/objects/simple/JpredResult_Helper.java | 56 +- src/vamsas/objects/simple/MsaResult.java | 251 +- src/vamsas/objects/simple/MsaResult_Helper.java | 165 +- src/vamsas/objects/simple/Msfalignment.java | 55 +- src/vamsas/objects/simple/Msfalignment_Helper.java | 56 +- src/vamsas/objects/simple/Object.java | 86 +- src/vamsas/objects/simple/Object_Helper.java | 95 +- src/vamsas/objects/simple/Result.java | 658 +- src/vamsas/objects/simple/Result_Helper.java | 216 +- src/vamsas/objects/simple/Secstructpred.java | 43 +- .../objects/simple/Secstructpred_Helper.java | 54 +- src/vamsas/objects/simple/SeqSearchResult.java | 325 +- .../objects/simple/SeqSearchResult_Helper.java | 139 +- src/vamsas/objects/simple/Sequence.java | 190 +- src/vamsas/objects/simple/SequenceSet.java | 152 +- src/vamsas/objects/simple/SequenceSet_Helper.java | 106 +- src/vamsas/objects/simple/Sequence_Helper.java | 117 +- src/vamsas/objects/simple/WsJobId.java | 184 +- src/vamsas/objects/simple/WsJobId_Helper.java | 117 +- utils/.cvsignore | 1 + utils/help2Website.java | 208 +- 567 files changed, 115183 insertions(+), 104310 deletions(-) create mode 100644 src/jalview/gui/OOMWarning.java create mode 100644 utils/.cvsignore diff --git a/help/html/jalviewjnlp.html b/help/html/jalviewjnlp.html index 9be4e4b..b966dcd 100755 --- a/help/html/jalviewjnlp.html +++ b/help/html/jalviewjnlp.html @@ -29,31 +29,31 @@ <resources> <!-- the additional memory parameters are here --> <j2se version="1.4+" initial-heap-size="500M" max-heap-size="1000M"/> - <jar href="http://www.jalview.org/webstart/jalview.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/activation.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/axis.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/castor-0.9.6-xml.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/commons-discovery.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/commons-logging.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/jaxrpc.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/jhall.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/log4j-1.2.8.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/mail.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/regex.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/saaj.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/wsdl4j.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/xercesImpl.jar" download="eager" main="false"/> - <jar href="http://www.jalview.org/webstart/xml-apis.jar" download="eager" main="false"/> - <property name="jalview.version" value="2.07"/> + <jar href="jalview.jar"/> + <jar href="Jmol-11.0.2.jar"/> + <jar href="activation.jar"/> + <jar href="axis.jar"/> + <jar href="castor-1.1-cycle-xml.jar"/> + <jar href="commons-discovery.jar"/> + <jar href="commons-logging.jar"/> + <jar href="jaxrpc.jar"/> + <jar href="jhall.jar"/> + <jar href="log4j-1.2.8.jar"/> + <jar href="mail.jar"/> + <jar href="regex.jar"/> + <jar href="saaj.jar"/> + <jar href="vamsas-client.jar"/> + <jar href="wsdl4j.jar"/> + <jar href="xercesImpl.jar"/> + <jar href="xml-apis.jar"/> + <property name="jalview.version" value="2.4"/> </resources> <application-desc main-class="jalview.bin.Jalview"/> </jnlp>
jalview -help +href="http://www.jalview.org/mailman/listinfo/jalview-discuss">If you have problems, send an email to jalview-discuss
- diff --git a/src/MCview/AppletPDBCanvas.java b/src/MCview/AppletPDBCanvas.java index 73ed7a7..390e20f 100755 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -31,61 +31,102 @@ import jalview.datamodel.*; import jalview.appletgui.*; import jalview.structure.*; -public class AppletPDBCanvas - extends Panel implements MouseListener, MouseMotionListener, StructureListener +public class AppletPDBCanvas extends Panel implements MouseListener, + MouseMotionListener, StructureListener { MCMatrix idmat = new MCMatrix(3, 3); + MCMatrix objmat = new MCMatrix(3, 3); + boolean redrawneeded = true; + int omx = 0; + int mx = 0; + int omy = 0; + int my = 0; + public PDBfile pdb; + PDBEntry pdbentry; + int bsize; + Image img; + Graphics ig; + Dimension prefsize; + float[] centre = new float[3]; + float[] width = new float[3]; + float maxwidth; + float scale; + String inStr; + String inType; + boolean bysequence = true; + boolean depthcue = true; + boolean wire = false; + boolean bymolecule = false; + boolean zbuffer = true; + boolean dragging; + int xstart; + int xend; + int ystart; + int yend; + int xmid; + int ymid; + Font font = new Font("Helvetica", Font.PLAIN, 10); - public SequenceI [] sequence; + + public SequenceI[] sequence; + final StringBuffer mappingDetails = new StringBuffer(); + String appletToolTip = null; + int toolx, tooly; + PDBChain mainchain; + Vector highlightRes; + boolean pdbAction = false; + Bond highlightBond1, highlightBond2; + boolean errorLoading = false; + boolean seqColoursReady = false; + FeatureRenderer fr; + AlignmentPanel ap; + StructureSelectionManager ssm; - public AppletPDBCanvas(PDBEntry pdbentry, - SequenceI[] seq, - String [] chains, - AlignmentPanel ap, - String protocol) + public AppletPDBCanvas(PDBEntry pdbentry, SequenceI[] seq, + String[] chains, AlignmentPanel ap, String protocol) { this.ap = ap; @@ -94,13 +135,14 @@ public class AppletPDBCanvas ssm = StructureSelectionManager.getStructureSelectionManager(); - try{ + try + { pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol); - if(protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) - pdbentry.setFile("INLINE"+pdb.id); + if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) + pdbentry.setFile("INLINE" + pdb.id); - }catch(Exception ex) + } catch (Exception ex) { ex.printStackTrace(); return; @@ -119,25 +161,24 @@ public class AppletPDBCanvas int seqstart = 0; int seqend = 0; - //JUST DEAL WITH ONE SEQUENCE FOR NOW + // JUST DEAL WITH ONE SEQUENCE FOR NOW SequenceI sequence = seq[0]; for (int i = 0; i < pdb.chains.size(); i++) { - mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + - ( (PDBChain) pdb.chains.elementAt(i)).sequence. - getSequenceAsString()); - mappingDetails.append("\nNo of residues = " + - ( (PDBChain) pdb.chains.elementAt(i)).residues.size() + - "\n\n"); + mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + + ((PDBChain) pdb.chains.elementAt(i)).sequence + .getSequenceAsString()); + mappingDetails.append("\nNo of residues = " + + ((PDBChain) pdb.chains.elementAt(i)).residues.size() + + "\n\n"); // Now lets compare the sequences to get // the start and end points. // Align the sequence to the pdb - AlignSeq as = new AlignSeq(sequence, - ( (PDBChain) pdb.chains.elementAt(i)).sequence, - "pep"); + AlignSeq as = new AlignSeq(sequence, ((PDBChain) pdb.chains + .elementAt(i)).sequence, "pep"); as.calcScoreMatrix(); as.traceAlignment(); PrintStream ps = new PrintStream(System.out) @@ -164,7 +205,7 @@ public class AppletPDBCanvas pdbend = as.seq2end; seqstart = as.seq1start + sequence.getStart() - 1; seqend = as.seq1end + sequence.getEnd() - 1; - } + } mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend); mappingDetails.append("\nSEQ start/end " + seqstart + " " + seqend); @@ -177,12 +218,12 @@ public class AppletPDBCanvas mainchain.seqstart = seqstart; mainchain.seqend = seqend; mainchain.isVisible = true; - // mainchain.makeExactMapping(maxAlignseq, sequence); - // mainchain.transferRESNUMFeatures(sequence, null); + // mainchain.makeExactMapping(maxAlignseq, sequence); + // mainchain.transferRESNUMFeatures(sequence, null); this.pdb = pdb; this.prefsize = new Dimension(getSize().width, getSize().height); - //Initialize the matrices to identity + // Initialize the matrices to identity for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) @@ -220,6 +261,7 @@ public class AppletPDBCanvas } Vector visiblebonds; + void setupBonds() { seqColoursReady = false; @@ -228,9 +270,9 @@ public class AppletPDBCanvas for (int ii = 0; ii < pdb.chains.size(); ii++) { - if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible) + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { - Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector tmp = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < tmp.size(); i++) { @@ -249,9 +291,9 @@ public class AppletPDBCanvas float[] max = new float[3]; float[] min = new float[3]; - max[0] = (float) - 1e30; - max[1] = (float) - 1e30; - max[2] = (float) - 1e30; + max[0] = (float) -1e30; + max[1] = (float) -1e30; + max[2] = (float) -1e30; min[0] = (float) 1e30; min[1] = (float) 1e30; @@ -259,9 +301,9 @@ public class AppletPDBCanvas for (int ii = 0; ii < pdb.chains.size(); ii++) { - if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible) + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { @@ -386,25 +428,25 @@ public class AppletPDBCanvas int bsize = 0; - //Find centre coordinate + // Find centre coordinate for (int ii = 0; ii < pdb.chains.size(); ii++) { - if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible) + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; bsize += bonds.size(); for (int i = 0; i < bonds.size(); i++) { - xtot = xtot + ( (Bond) bonds.elementAt(i)).start[0] + - ( (Bond) bonds.elementAt(i)).end[0]; + xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] + + ((Bond) bonds.elementAt(i)).end[0]; - ytot = ytot + ( (Bond) bonds.elementAt(i)).start[1] + - ( (Bond) bonds.elementAt(i)).end[1]; + ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] + + ((Bond) bonds.elementAt(i)).end[1]; - ztot = ztot + ( (Bond) bonds.elementAt(i)).start[2] + - ( (Bond) bonds.elementAt(i)).end[2]; + ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] + + ((Bond) bonds.elementAt(i)).end[2]; } } } @@ -435,10 +477,10 @@ public class AppletPDBCanvas return; } - //Only create the image at the beginning - - //this saves much memory usage - if ( (img == null) || (prefsize.width != getSize().width) || - (prefsize.height != getSize().height)) + // Only create the image at the beginning - + // this saves much memory usage + if ((img == null) || (prefsize.width != getSize().width) + || (prefsize.height != getSize().height)) { try @@ -451,8 +493,7 @@ public class AppletPDBCanvas ig = img.getGraphics(); redrawneeded = true; - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -490,8 +531,6 @@ public class AppletPDBCanvas repaint(); } - - // This method has been taken out of PDBChain to allow // Applet and Application specific sequence renderers to be used void colourBySequence() @@ -536,7 +575,7 @@ public class AppletPDBCanvas { if (mapping[m].getSequence() == sequence[s]) { - int pos = mapping[m].getSeqPos(tmp.at1.resNumber)-1; + int pos = mapping[m].getSeqPos(tmp.at1.resNumber) - 1; if (pos > 0) { pos = sequence[s].findIndex(pos); @@ -544,11 +583,10 @@ public class AppletPDBCanvas if (showFeatures) { tmp.startCol = fr.findFeatureColour(tmp.startCol, - sequence[s], - pos); + sequence[s], pos); } } - pos = mapping[m].getSeqPos(tmp.at2.resNumber)-1; + pos = mapping[m].getSeqPos(tmp.at2.resNumber) - 1; if (pos > 0) { pos = sequence[s].findIndex(pos); @@ -556,8 +594,7 @@ public class AppletPDBCanvas if (showFeatures) { tmp.endCol = fr.findFeatureColour(tmp.endCol, - sequence[s], - pos); + sequence[s], pos); } } @@ -570,6 +607,7 @@ public class AppletPDBCanvas } Zsort zsort; + public void drawScene(Graphics g) { if (zbuffer) @@ -587,15 +625,11 @@ public class AppletPDBCanvas { tmpBond = (Bond) visiblebonds.elementAt(i); - xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) + - (getSize().width / 2)); - ystart = (int) ( ( (centre[1] - tmpBond.start[1] ) * scale) + - (getSize().height / 2)); + xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getSize().width / 2)); + ystart = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getSize().height / 2)); - xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) + - (getSize().width / 2)); - yend = (int) ( ( (centre[1] - tmpBond.end[1] ) * scale) + - (getSize().height / 2)); + xend = (int) (((tmpBond.end[0] - centre[0]) * scale) + (getSize().width / 2)); + yend = (int) (((centre[1] - tmpBond.end[1]) * scale) + (getSize().height / 2)); xmid = (xend + xstart) / 2; ymid = (yend + ystart) / 2; @@ -677,7 +711,7 @@ public class AppletPDBCanvas { if (!wire) { - if ( ( (float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) + if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) { g.drawLine(x1, y1, x2, y2); g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1); @@ -793,13 +827,14 @@ public class AppletPDBCanvas toolx = e.getX(); tooly = e.getY(); - appletToolTip = chain.id + ":" + fatom.resNumber + " " + fatom.resName; + appletToolTip = chain.id + ":" + fatom.resNumber + " " + + fatom.resName; redrawneeded = true; repaint(); } else { - mouseOverStructure(-1, chain!=null?chain.id:null); + mouseOverStructure(-1, chain != null ? chain.id : null); appletToolTip = null; redrawneeded = true; repaint(); @@ -828,33 +863,33 @@ public class AppletPDBCanvas MCMatrix objmat = new MCMatrix(3, 3); objmat.setIdentity(); - if ( (evt.getModifiers() & Event.META_MASK) != 0) + if ((evt.getModifiers() & Event.META_MASK) != 0) { - objmat.rotatez( (float) ( (mx - omx))); + objmat.rotatez((float) ((mx - omx))); } else { - objmat.rotatex( (float) ( (omy - my))); - objmat.rotatey( (float) ( (omx - mx))); + objmat.rotatex((float) ((omy - my))); + objmat.rotatey((float) ((omx - mx))); } - //Alter the bonds + // Alter the bonds for (int ii = 0; ii < pdb.chains.size(); ii++) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { Bond tmpBond = (Bond) bonds.elementAt(i); - //Translate the bond so the centre is 0,0,0 - tmpBond.translate( -centre[0], -centre[1], -centre[2]); + // Translate the bond so the centre is 0,0,0 + tmpBond.translate(-centre[0], -centre[1], -centre[2]); - //Now apply the rotation matrix + // Now apply the rotation matrix tmpBond.start = objmat.vectorMultiply(tmpBond.start); tmpBond.end = objmat.vectorMultiply(tmpBond.end); - //Now translate back again + // Now translate back again tmpBond.translate(centre[0], centre[1], centre[2]); } } @@ -886,7 +921,7 @@ public class AppletPDBCanvas if (chain.isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { @@ -913,10 +948,8 @@ public class AppletPDBCanvas if (n == 1) { - int xstart = (int) ( ( (b.start[0] - centre[0]) * scale) + - (getSize().width / 2)); - int ystart = (int) ( ( (centre[1] - b.start[1]) * scale) + - (getSize().height / 2)); + int xstart = (int) (((b.start[0] - centre[0]) * scale) + (getSize().width / 2)); + int ystart = (int) (((centre[1] - b.start[1]) * scale) + (getSize().height / 2)); g.setColor(Color.red); g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart); @@ -924,10 +957,8 @@ public class AppletPDBCanvas if (n == 2) { - int xstart = (int) ( ( (b.end[0] - centre[0]) * scale) + - (getSize().width / 2)); - int ystart = (int) ( ( (centre[1] - b.end[1]) * scale) + - (getSize().height / 2)); + int xstart = (int) (((b.end[0] - centre[0]) * scale) + (getSize().width / 2)); + int ystart = (int) (((centre[1] - b.end[1]) * scale) + (getSize().height / 2)); g.setColor(Color.red); g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart); @@ -935,6 +966,7 @@ public class AppletPDBCanvas } int foundchain = -1; + public Atom findAtom(int x, int y) { Atom fatom = null; @@ -949,19 +981,17 @@ public class AppletPDBCanvas if (chain.isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { tmpBond = (Bond) bonds.elementAt(i); - truex = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) + - (getSize().width / 2)); + truex = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getSize().width / 2)); if (Math.abs(truex - x) <= 2) { - int truey = (int) ( ( (centre[1] - tmpBond.start[1] ) * scale) + - (getSize().height / 2)); + int truey = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getSize().height / 2)); if (Math.abs(truey - y) <= 2) { @@ -974,13 +1004,11 @@ public class AppletPDBCanvas // Still here? Maybe its the last bond - truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) + - (getSize().width / 2)); + truex = (int) (((tmpBond.end[0] - centre[0]) * scale) + (getSize().width / 2)); if (Math.abs(truex - x) <= 2) { - int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) + - (getSize().height / 2)); + int truey = (int) (((tmpBond.end[1] - centre[1]) * scale) + (getSize().height / 2)); if (Math.abs(truey - y) <= 2) { @@ -992,7 +1020,7 @@ public class AppletPDBCanvas } - if (fatom != null) //)&& chain.ds != null) + if (fatom != null) // )&& chain.ds != null) { chain = (PDBChain) pdb.chains.elementAt(foundchain); } @@ -1013,8 +1041,7 @@ public class AppletPDBCanvas return; } - if (highlightRes != null - && highlightRes.contains( (ii - 1) + "")) + if (highlightRes != null && highlightRes.contains((ii - 1) + "")) { return; } @@ -1071,36 +1098,36 @@ public class AppletPDBCanvas setupBonds(); } - - ////////////////////////////////// - ///StructureListener + // //////////////////////////////// + // /StructureListener public String getPdbFile() { return pdbentry.getFile(); } - String lastMessage; + public void mouseOverStructure(int pdbResNum, String chain) { - if (lastMessage == null || !lastMessage.equals(pdbResNum+chain)) - ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile()); + if (lastMessage == null || !lastMessage.equals(pdbResNum + chain)) + ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile()); - lastMessage = pdbResNum+chain; + lastMessage = pdbResNum + chain; } StringBuffer resetLastRes = new StringBuffer(); + StringBuffer eval = new StringBuffer(); - public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile) + public void highlightAtom(int atomIndex, int pdbResNum, String chain, + String pdbfile) { if (!seqColoursReady) { return; } - if (highlightRes != null - && highlightRes.contains( (atomIndex - 1) + "")) + if (highlightRes != null && highlightRes.contains((atomIndex - 1) + "")) { return; } @@ -1145,14 +1172,14 @@ public class AppletPDBCanvas repaint(); } - - public Color getColour(int atomIndex, int pdbResNum, String chain, String pdbfile) + public Color getColour(int atomIndex, int pdbResNum, String chain, + String pdbfile) { return Color.white; - // if (!pdbfile.equals(pdbentry.getFile())) - // return null; + // if (!pdbfile.equals(pdbentry.getFile())) + // return null; - //return new Color(viewer.getAtomArgb(atomIndex)); + // return new Color(viewer.getAtomArgb(atomIndex)); } public void updateColours(Object source) @@ -1162,5 +1189,4 @@ public class AppletPDBCanvas repaint(); } - } diff --git a/src/MCview/AppletPDBViewer.java b/src/MCview/AppletPDBViewer.java index fc8478d..8299abc 100755 --- a/src/MCview/AppletPDBViewer.java +++ b/src/MCview/AppletPDBViewer.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -25,23 +25,18 @@ import jalview.appletgui.*; import jalview.datamodel.*; import jalview.schemes.*; - -public class AppletPDBViewer - extends EmbmenuFrame implements ActionListener, ItemListener +public class AppletPDBViewer extends EmbmenuFrame implements + ActionListener, ItemListener { AppletPDBCanvas pdbcanvas; - public AppletPDBViewer(PDBEntry pdbentry, - SequenceI[] seq, - String [] chains, - AlignmentPanel ap, - String protocol) + public AppletPDBViewer(PDBEntry pdbentry, SequenceI[] seq, + String[] chains, AlignmentPanel ap, String protocol) { try { jbInit(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -51,26 +46,23 @@ public class AppletPDBViewer embedMenuIfNeeded(pdbcanvas); add(pdbcanvas, BorderLayout.CENTER); - StringBuffer title = new StringBuffer(seq[0].getName() - + ":" - + pdbcanvas.pdbentry.getFile()); + StringBuffer title = new StringBuffer(seq[0].getName() + ":" + + pdbcanvas.pdbentry.getFile()); jalview.bin.JalviewLite.addFrame(this, title.toString(), 400, 400); } - - public void actionPerformed(ActionEvent evt) { if (evt.getSource() == mapping) { - jalview.appletgui.CutAndPasteTransfer cap - = new jalview.appletgui.CutAndPasteTransfer(false, null); + jalview.appletgui.CutAndPasteTransfer cap = new jalview.appletgui.CutAndPasteTransfer( + false, null); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 500, - 600); + jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", + 500, 600); cap.setText(pdbcanvas.mappingDetails.toString()); } @@ -138,7 +130,7 @@ public class AppletPDBViewer } else if (evt.getSource() == wire) { - pdbcanvas.wire = !pdbcanvas.wire; + pdbcanvas.wire = !pdbcanvas.wire; } else if (evt.getSource() == depth) { @@ -152,8 +144,7 @@ public class AppletPDBViewer pdbcanvas.repaint(); } - private void jbInit() - throws Exception + private void jbInit() throws Exception { setMenuBar(jMenuBar1); fileMenu.setLabel("File"); @@ -196,7 +187,8 @@ public class AppletPDBViewer jMenuBar1.add(fileMenu); jMenuBar1.add(coloursMenu); jMenuBar1.add(viewMenu); - fileMenu.add(mapping); ; + fileMenu.add(mapping); + ; coloursMenu.add(seqButton); coloursMenu.add(chain); @@ -217,32 +209,48 @@ public class AppletPDBViewer } MenuBar jMenuBar1 = new MenuBar(); + Menu fileMenu = new Menu(); + Menu coloursMenu = new Menu(); + MenuItem mapping = new MenuItem(); + CheckboxGroup bg = new CheckboxGroup(); + CheckboxMenuItem wire = new CheckboxMenuItem(); + CheckboxMenuItem depth = new CheckboxMenuItem(); + CheckboxMenuItem zbuffer = new CheckboxMenuItem(); MenuItem charge = new MenuItem(); + MenuItem hydro = new MenuItem(); + MenuItem chain = new MenuItem(); + MenuItem seqButton = new MenuItem(); CheckboxMenuItem allchains = new CheckboxMenuItem(); + Menu viewMenu = new Menu(); + MenuItem turn = new MenuItem(); + MenuItem strand = new MenuItem(); + MenuItem helix = new MenuItem(); + MenuItem taylor = new MenuItem(); + MenuItem zappo = new MenuItem(); - MenuItem buried = new MenuItem(); - MenuItem user = new MenuItem(); + MenuItem buried = new MenuItem(); -//End StructureListener -//////////////////////////// + MenuItem user = new MenuItem(); + // End StructureListener + // ////////////////////////// } diff --git a/src/MCview/Atom.java b/src/MCview/Atom.java index e22b94e..e69e1ce 100755 --- a/src/MCview/Atom.java +++ b/src/MCview/Atom.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -23,21 +23,37 @@ import java.awt.*; public class Atom { public float x; + public float y; + public float z; + public int number; + public String name; + public String resName; + public int resNumber; + public char insCode = ' '; + public String resNumIns = null; + public int type; + Color color = Color.lightGray; + public String chain; + public int alignmentMapping = -1; + public int atomIndex; - public float occupancy=0; - public float tfactor=0; + + public float occupancy = 0; + + public float tfactor = 0; + public boolean isSelected = false; public Atom(String str) @@ -56,8 +72,9 @@ public class Atom this.x = (float) (new Float(str.substring(30, 38).trim()).floatValue()); this.y = (float) (new Float(str.substring(38, 46).trim()).floatValue()); this.z = (float) (new Float(str.substring(47, 55).trim()).floatValue()); - occupancy = (float) (new Float(str.substring(54,60).trim()).floatValue()); - tfactor = (float) (new Float(str.substring(60,66).trim()).floatValue()); + occupancy = (float) (new Float(str.substring(54, 60).trim()) + .floatValue()); + tfactor = (float) (new Float(str.substring(60, 66).trim()).floatValue()); } public Atom(float x, float y, float z) @@ -66,7 +83,7 @@ public class Atom this.y = y; this.z = z; } - // public void setColor(Color col) { - // this.color = col; - // } + // public void setColor(Color col) { + // this.color = col; + // } } diff --git a/src/MCview/Bond.java b/src/MCview/Bond.java index 8e95c1b..cc5e67c 100755 --- a/src/MCview/Bond.java +++ b/src/MCview/Bond.java @@ -1,80 +1,80 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package MCview; - -import java.awt.*; - -public class Bond -{ - float[] start; - float[] end; - Color startCol = Color.lightGray; - Color endCol = Color.lightGray; - public Atom at1; - public Atom at2; - - public Bond(float[] start, float[] end, Atom at1, Atom at2) - { - this.start = start; - this.end = end; - this.startCol = at1.color; - this.endCol = at2.color; - this.at1 = at1; - this.at2 = at2; - } - - /* public Bond(Bond bond) { - this.start = new float[3]; - - this.start[0] = bond.start[0]; - this.start[1] = bond.start[1]; - this.start[2] = bond.start[2]; - - this.end = new float[3]; - - this.end[0] = bond.end[0]; - this.end[1] = bond.end[1]; - this.end[2] = bond.end[2]; - - this.startCol = bond.startCol; - this.endCol = bond.endCol; - } - - public float length() { - float len = ((end[0] - start[0]) * (end[0] - start[0])) + - ((end[1] - start[1]) * (end[1] - start[1])) + - ((end[2] - start[2]) * (end[2] - start[2])); - - len = (float) (Math.sqrt(len)); - - return len; - }*/ - - public void translate(float x, float y, float z) - { - start[0] = (start[0] + x); - end[0] = (end[0] + x); - - start[1] = (start[1] + y); - end[1] = (end[1] + y); - - start[2] = (start[2] + z); - end[2] = (end[2] + z); - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package MCview; + +import java.awt.*; + +public class Bond +{ + float[] start; + + float[] end; + + Color startCol = Color.lightGray; + + Color endCol = Color.lightGray; + + public Atom at1; + + public Atom at2; + + public Bond(float[] start, float[] end, Atom at1, Atom at2) + { + this.start = start; + this.end = end; + this.startCol = at1.color; + this.endCol = at2.color; + this.at1 = at1; + this.at2 = at2; + } + + /* + * public Bond(Bond bond) { this.start = new float[3]; + * + * this.start[0] = bond.start[0]; this.start[1] = bond.start[1]; this.start[2] = + * bond.start[2]; + * + * this.end = new float[3]; + * + * this.end[0] = bond.end[0]; this.end[1] = bond.end[1]; this.end[2] = + * bond.end[2]; + * + * this.startCol = bond.startCol; this.endCol = bond.endCol; } + * + * public float length() { float len = ((end[0] - start[0]) * (end[0] - + * start[0])) + ((end[1] - start[1]) * (end[1] - start[1])) + ((end[2] - + * start[2]) * (end[2] - start[2])); + * + * len = (float) (Math.sqrt(len)); + * + * return len; } + */ + + public void translate(float x, float y, float z) + { + start[0] = (start[0] + x); + end[0] = (end[0] + x); + + start[1] = (start[1] + y); + end[1] = (end[1] + y); + + start[2] = (start[2] + z); + end[2] = (end[2] + z); + } +} diff --git a/src/MCview/MCMatrix.java b/src/MCview/MCMatrix.java index 9eba886..1b9a2d8 100755 --- a/src/MCview/MCMatrix.java +++ b/src/MCview/MCMatrix.java @@ -1,171 +1,175 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package MCview; - -public class MCMatrix -{ - float[][] matrix; - float[][] tmp; - float mycos; - float mysin; - float myconst = (float) (Math.PI / 180); - - public MCMatrix(int rows, int cols) - { - matrix = new float[rows][cols]; - tmp = new float[rows][cols]; - } - - public void addElement(int i, int j, float value) - { - matrix[i][j] = value; - } - - public void rotatex(float degrees) - { - mycos = (float) (Math.cos(degrees * myconst)); - mysin = (float) (Math.sin(degrees * myconst)); - - tmp[0][0] = 1; - tmp[0][1] = 0; - tmp[0][2] = 0; - tmp[1][0] = 0; - tmp[1][1] = mycos; - tmp[1][2] = mysin; - tmp[2][0] = 0; - tmp[2][1] = -mysin; - tmp[2][2] = mycos; - preMultiply(tmp); - } - - public void rotatez(float degrees) - { - mycos = (float) (Math.cos(degrees * myconst)); - mysin = (float) (Math.sin(degrees * myconst)); - - tmp[0][0] = mycos; - tmp[0][1] = -mysin; - tmp[0][2] = 0; - tmp[1][0] = mysin; - tmp[1][1] = mycos; - tmp[1][2] = 0; - tmp[2][0] = 0; - tmp[2][1] = 0; - tmp[2][2] = 1; - - preMultiply(tmp); - } - - public void rotatey(float degrees) - { - mycos = (float) (Math.cos(degrees * myconst)); - mysin = (float) (Math.sin(degrees * myconst)); - - tmp[0][0] = mycos; - tmp[0][1] = 0; - tmp[0][2] = -mysin; - tmp[1][0] = 0; - tmp[1][1] = 1; - tmp[1][2] = 0; - tmp[2][0] = mysin; - tmp[2][1] = 0; - tmp[2][2] = mycos; - - preMultiply(tmp); - } - - public float[] vectorMultiply(float[] vect) - { - float[] temp = new float[3]; - - temp[0] = vect[0]; - temp[1] = vect[1]; - temp[2] = vect[2]; - - for (int i = 0; i < 3; i++) - { - temp[i] = ( (float) matrix[i][0] * vect[0]) + - ( (float) matrix[i][1] * vect[1]) + - ( (float) matrix[i][2] * vect[2]); - } - - vect[0] = temp[0]; - vect[1] = temp[1]; - vect[2] = temp[2]; - - return vect; - } - - public void preMultiply(float[][] mat) - { - float[][] tmp = new float[3][3]; - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - tmp[i][j] = (mat[i][0] * matrix[0][j]) + - (mat[i][1] * matrix[1][j]) + (mat[i][2] * matrix[2][j]); - } - } - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - matrix[i][j] = tmp[i][j]; - } - } - } - - public void postMultiply(float[][] mat) - { - float[][] tmp = new float[3][3]; - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - tmp[i][j] = (matrix[i][0] * mat[0][j]) + - (matrix[i][1] * mat[1][j]) + (matrix[i][2] * mat[2][j]); - } - } - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - matrix[i][j] = tmp[i][j]; - } - } - } - - public void setIdentity() - { - matrix[0][0] = 1; - matrix[1][1] = 1; - matrix[2][2] = 1; - matrix[0][1] = 0; - matrix[0][2] = 0; - matrix[1][0] = 0; - matrix[1][2] = 0; - matrix[2][0] = 0; - matrix[2][1] = 0; - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package MCview; + +public class MCMatrix +{ + float[][] matrix; + + float[][] tmp; + + float mycos; + + float mysin; + + float myconst = (float) (Math.PI / 180); + + public MCMatrix(int rows, int cols) + { + matrix = new float[rows][cols]; + tmp = new float[rows][cols]; + } + + public void addElement(int i, int j, float value) + { + matrix[i][j] = value; + } + + public void rotatex(float degrees) + { + mycos = (float) (Math.cos(degrees * myconst)); + mysin = (float) (Math.sin(degrees * myconst)); + + tmp[0][0] = 1; + tmp[0][1] = 0; + tmp[0][2] = 0; + tmp[1][0] = 0; + tmp[1][1] = mycos; + tmp[1][2] = mysin; + tmp[2][0] = 0; + tmp[2][1] = -mysin; + tmp[2][2] = mycos; + preMultiply(tmp); + } + + public void rotatez(float degrees) + { + mycos = (float) (Math.cos(degrees * myconst)); + mysin = (float) (Math.sin(degrees * myconst)); + + tmp[0][0] = mycos; + tmp[0][1] = -mysin; + tmp[0][2] = 0; + tmp[1][0] = mysin; + tmp[1][1] = mycos; + tmp[1][2] = 0; + tmp[2][0] = 0; + tmp[2][1] = 0; + tmp[2][2] = 1; + + preMultiply(tmp); + } + + public void rotatey(float degrees) + { + mycos = (float) (Math.cos(degrees * myconst)); + mysin = (float) (Math.sin(degrees * myconst)); + + tmp[0][0] = mycos; + tmp[0][1] = 0; + tmp[0][2] = -mysin; + tmp[1][0] = 0; + tmp[1][1] = 1; + tmp[1][2] = 0; + tmp[2][0] = mysin; + tmp[2][1] = 0; + tmp[2][2] = mycos; + + preMultiply(tmp); + } + + public float[] vectorMultiply(float[] vect) + { + float[] temp = new float[3]; + + temp[0] = vect[0]; + temp[1] = vect[1]; + temp[2] = vect[2]; + + for (int i = 0; i < 3; i++) + { + temp[i] = ((float) matrix[i][0] * vect[0]) + + ((float) matrix[i][1] * vect[1]) + + ((float) matrix[i][2] * vect[2]); + } + + vect[0] = temp[0]; + vect[1] = temp[1]; + vect[2] = temp[2]; + + return vect; + } + + public void preMultiply(float[][] mat) + { + float[][] tmp = new float[3][3]; + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + tmp[i][j] = (mat[i][0] * matrix[0][j]) + (mat[i][1] * matrix[1][j]) + + (mat[i][2] * matrix[2][j]); + } + } + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + matrix[i][j] = tmp[i][j]; + } + } + } + + public void postMultiply(float[][] mat) + { + float[][] tmp = new float[3][3]; + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + tmp[i][j] = (matrix[i][0] * mat[0][j]) + (matrix[i][1] * mat[1][j]) + + (matrix[i][2] * mat[2][j]); + } + } + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + matrix[i][j] = tmp[i][j]; + } + } + } + + public void setIdentity() + { + matrix[0][0] = 1; + matrix[1][1] = 1; + matrix[2][2] = 1; + matrix[0][1] = 0; + matrix[0][2] = 0; + matrix[1][0] = 0; + matrix[1][2] = 0; + matrix[2][0] = 0; + matrix[2][1] = 0; + } +} diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index 79871e8..ccc359b 100755 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -31,58 +31,95 @@ import jalview.datamodel.*; import jalview.gui.*; import jalview.structure.*; -public class PDBCanvas - extends JPanel implements MouseListener, MouseMotionListener, StructureListener +public class PDBCanvas extends JPanel implements MouseListener, + MouseMotionListener, StructureListener { boolean redrawneeded = true; + int omx = 0; + int mx = 0; + int omy = 0; + int my = 0; + public PDBfile pdb; + PDBEntry pdbentry; + int bsize; + Image img; + Graphics ig; + Dimension prefsize; + float[] centre = new float[3]; + float[] width = new float[3]; + float maxwidth; + float scale; + String inStr; + String inType; + boolean bysequence = true; + boolean depthcue = true; + boolean wire = false; + boolean bymolecule = false; + boolean zbuffer = true; + boolean dragging; + int xstart; + int xend; + int ystart; + int yend; + int xmid; + int ymid; + Font font = new Font("Helvetica", Font.PLAIN, 10); + jalview.gui.SeqCanvas seqcanvas; - public SequenceI [] sequence; + + public SequenceI[] sequence; + final StringBuffer mappingDetails = new StringBuffer(); + PDBChain mainchain; + Vector highlightRes; + boolean pdbAction = false; + boolean seqColoursReady = false; + jalview.gui.FeatureRenderer fr; + Color backgroundColour = Color.black; + AlignmentPanel ap; + StructureSelectionManager ssm; - String errorMessage; + String errorMessage; - void init(PDBEntry pdbentry, - SequenceI[] seq, - String [] chains, - AlignmentPanel ap, - String protocol) + void init(PDBEntry pdbentry, SequenceI[] seq, String[] chains, + AlignmentPanel ap, String protocol) { this.ap = ap; this.pdbentry = pdbentry; @@ -90,21 +127,22 @@ public class PDBCanvas ssm = StructureSelectionManager.getStructureSelectionManager(); - try{ + try + { pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol); - if(protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) - pdbentry.setFile("INLINE"+pdb.id); + if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) + pdbentry.setFile("INLINE" + pdb.id); - }catch(Exception ex) + } catch (Exception ex) { ex.printStackTrace(); return; } - if(pdb==null) + if (pdb == null) { - errorMessage = "Error loading file: "+pdbentry.getId(); + errorMessage = "Error loading file: " + pdbentry.getId(); return; } pdbentry.setId(pdb.id); @@ -120,25 +158,24 @@ public class PDBCanvas int seqstart = 0; int seqend = 0; - //JUST DEAL WITH ONE SEQUENCE FOR NOW + // JUST DEAL WITH ONE SEQUENCE FOR NOW SequenceI sequence = seq[0]; for (int i = 0; i < pdb.chains.size(); i++) { - mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + - ( (PDBChain) pdb.chains.elementAt(i)).sequence. - getSequenceAsString()); - mappingDetails.append("\nNo of residues = " + - ( (PDBChain) pdb.chains.elementAt(i)).residues.size() + - "\n\n"); + mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + + ((PDBChain) pdb.chains.elementAt(i)).sequence + .getSequenceAsString()); + mappingDetails.append("\nNo of residues = " + + ((PDBChain) pdb.chains.elementAt(i)).residues.size() + + "\n\n"); // Now lets compare the sequences to get // the start and end points. // Align the sequence to the pdb - AlignSeq as = new AlignSeq(sequence, - ( (PDBChain) pdb.chains.elementAt(i)).sequence, - "pep"); + AlignSeq as = new AlignSeq(sequence, ((PDBChain) pdb.chains + .elementAt(i)).sequence, "pep"); as.calcScoreMatrix(); as.traceAlignment(); PrintStream ps = new PrintStream(System.out) @@ -182,7 +219,6 @@ public class PDBCanvas this.pdb = pdb; this.prefsize = new Dimension(getSize().width, getSize().height); - addMouseMotionListener(this); addMouseListener(this); @@ -207,6 +243,7 @@ public class PDBCanvas } Vector visiblebonds; + void setupBonds() { seqColoursReady = false; @@ -215,9 +252,9 @@ public class PDBCanvas for (int ii = 0; ii < pdb.chains.size(); ii++) { - if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible) + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { - Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector tmp = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < tmp.size(); i++) { @@ -237,9 +274,9 @@ public class PDBCanvas float[] max = new float[3]; float[] min = new float[3]; - max[0] = (float) - 1e30; - max[1] = (float) - 1e30; - max[2] = (float) - 1e30; + max[0] = (float) -1e30; + max[1] = (float) -1e30; + max[2] = (float) -1e30; min[0] = (float) 1e30; min[1] = (float) 1e30; @@ -247,9 +284,9 @@ public class PDBCanvas for (int ii = 0; ii < pdb.chains.size(); ii++) { - if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible) + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { @@ -318,9 +355,10 @@ public class PDBCanvas } } /* - System.out.println("xmax " + max[0] + " min " + min[0]); - System.out.println("ymax " + max[1] + " min " + min[1]); - System.out.println("zmax " + max[2] + " min " + min[2]);*/ + * System.out.println("xmax " + max[0] + " min " + min[0]); + * System.out.println("ymax " + max[1] + " min " + min[1]); + * System.out.println("zmax " + max[2] + " min " + min[2]); + */ width[0] = (float) Math.abs(max[0] - min[0]); width[1] = (float) Math.abs(max[1] - min[1]); @@ -378,25 +416,25 @@ public class PDBCanvas int bsize = 0; - //Find centre coordinate + // Find centre coordinate for (int ii = 0; ii < pdb.chains.size(); ii++) { - if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible) + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; bsize += bonds.size(); for (int i = 0; i < bonds.size(); i++) { - xtot = xtot + ( (Bond) bonds.elementAt(i)).start[0] + - ( (Bond) bonds.elementAt(i)).end[0]; + xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] + + ((Bond) bonds.elementAt(i)).end[0]; - ytot = ytot + ( (Bond) bonds.elementAt(i)).start[1] + - ( (Bond) bonds.elementAt(i)).end[1]; + ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] + + ((Bond) bonds.elementAt(i)).end[1]; - ztot = ztot + ( (Bond) bonds.elementAt(i)).start[2] + - ( (Bond) bonds.elementAt(i)).end[2]; + ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] + + ((Bond) bonds.elementAt(i)).end[2]; } } } @@ -410,21 +448,19 @@ public class PDBCanvas { super.paintComponent(g); - if (!seqColoursReady || errorMessage!=null) + if (!seqColoursReady || errorMessage != null) { g.setColor(Color.black); g.setFont(new Font("Verdana", Font.BOLD, 14)); - g.drawString(errorMessage==null? - "Retrieving PDB data....":errorMessage, - 20, getHeight() / 2); + g.drawString(errorMessage == null ? "Retrieving PDB data...." + : errorMessage, 20, getHeight() / 2); return; } - //Only create the image at the beginning - - //this saves much memory usage - if ( (img == null) - || (prefsize.width != getWidth()) - || (prefsize.height != getHeight())) + // Only create the image at the beginning - + // this saves much memory usage + if ((img == null) || (prefsize.width != getWidth()) + || (prefsize.height != getHeight())) { prefsize.width = getWidth(); @@ -436,7 +472,7 @@ public class PDBCanvas Graphics2D ig2 = (Graphics2D) ig; ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + RenderingHints.VALUE_ANTIALIAS_ON); redrawneeded = true; } @@ -473,7 +509,6 @@ public class PDBCanvas repaint(); } - // This method has been taken out of PDBChain to allow // Applet and Application specific sequence renderers to be used void colourBySequence() @@ -518,7 +553,7 @@ public class PDBCanvas { if (mapping[m].getSequence() == sequence[s]) { - int pos = mapping[m].getSeqPos(tmp.at1.resNumber)-1; + int pos = mapping[m].getSeqPos(tmp.at1.resNumber) - 1; if (pos > 0) { pos = sequence[s].findIndex(pos); @@ -526,11 +561,10 @@ public class PDBCanvas if (showFeatures) { tmp.startCol = fr.findFeatureColour(tmp.startCol, - sequence[s], - pos); + sequence[s], pos); } } - pos = mapping[m].getSeqPos(tmp.at2.resNumber)-1; + pos = mapping[m].getSeqPos(tmp.at2.resNumber) - 1; if (pos > 0) { pos = sequence[s].findIndex(pos); @@ -538,8 +572,7 @@ public class PDBCanvas if (showFeatures) { tmp.endCol = fr.findFeatureColour(tmp.endCol, - sequence[s], - pos); + sequence[s], pos); } } @@ -552,6 +585,7 @@ public class PDBCanvas } Zsort zsort; + public void drawScene(Graphics g) { if (zbuffer) @@ -569,15 +603,11 @@ public class PDBCanvas { tmpBond = (Bond) visiblebonds.elementAt(i); - xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) + - (getWidth() / 2)); - ystart = (int) ( ( (centre[1] - tmpBond.start[1] ) * scale) + - (getHeight() / 2)); + xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getWidth() / 2)); + ystart = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getHeight() / 2)); - xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) + - (getWidth() / 2)); - yend = (int) ( ( (centre[1] - tmpBond.end[1] ) * scale) + - (getHeight() / 2)); + xend = (int) (((tmpBond.end[0] - centre[0]) * scale) + (getWidth() / 2)); + yend = (int) (((centre[1] - tmpBond.end[1]) * scale) + (getHeight() / 2)); xmid = (xend + xstart) / 2; ymid = (yend + ystart) / 2; @@ -641,13 +671,15 @@ public class PDBCanvas if (highlightBond1 != null && highlightBond1 == tmpBond) { - g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter()); + g.setColor(tmpBond.endCol.brighter().brighter().brighter() + .brighter()); drawLine(g, xmid, ymid, xend, yend); } if (highlightBond2 != null && highlightBond2 == tmpBond) { - g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter()); + g.setColor(tmpBond.startCol.brighter().brighter().brighter() + .brighter()); drawLine(g, xstart, ystart, xmid, ymid); } @@ -659,7 +691,7 @@ public class PDBCanvas { if (!wire) { - if ( ( (float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) + if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) { g.drawLine(x1, y1, x2, y2); g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1); @@ -772,24 +804,27 @@ public class PDBCanvas if (fatom != null) { - this.setToolTipText(chain.id + ":" + fatom.resNumber + " " + - fatom.resName); + this.setToolTipText(chain.id + ":" + fatom.resNumber + " " + + fatom.resName); } else { - mouseOverStructure(-1, chain!=null?chain.id:null); + mouseOverStructure(-1, chain != null ? chain.id : null); this.setToolTipText(null); } } public void mouseClicked(MouseEvent e) - {} + { + } public void mouseEntered(MouseEvent e) - {} + { + } public void mouseExited(MouseEvent e) - {} + { + } public void mouseDragged(MouseEvent evt) { @@ -801,33 +836,33 @@ public class PDBCanvas MCMatrix objmat = new MCMatrix(3, 3); objmat.setIdentity(); - if ( (evt.getModifiers() & Event.META_MASK) != 0) + if ((evt.getModifiers() & Event.META_MASK) != 0) { - objmat.rotatez( (float) ( (mx - omx))); + objmat.rotatez((float) ((mx - omx))); } else { - objmat.rotatex( (float) ( (my - omy))); - objmat.rotatey( (float) ( (omx - mx))); + objmat.rotatex((float) ((my - omy))); + objmat.rotatey((float) ((omx - mx))); } - //Alter the bonds + // Alter the bonds for (int ii = 0; ii < pdb.chains.size(); ii++) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { Bond tmpBond = (Bond) bonds.elementAt(i); - //Translate the bond so the centre is 0,0,0 - tmpBond.translate( -centre[0], -centre[1], -centre[2]); + // Translate the bond so the centre is 0,0,0 + tmpBond.translate(-centre[0], -centre[1], -centre[2]); - //Now apply the rotation matrix + // Now apply the rotation matrix tmpBond.start = objmat.vectorMultiply(tmpBond.start); tmpBond.end = objmat.vectorMultiply(tmpBond.end); - //Now translate back again + // Now translate back again tmpBond.translate(centre[0], centre[1], centre[2]); } } @@ -859,7 +894,7 @@ public class PDBCanvas if (chain.isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { @@ -886,26 +921,23 @@ public class PDBCanvas g.setColor(Color.red); if (n == 1) { - int xstart = (int) ( ( (b.start[0] - centre[0]) * scale) + - (getWidth() / 2)); - int ystart = (int) ( ( (centre[1] - b.start[1] ) * scale) + - (getHeight() / 2)); + int xstart = (int) (((b.start[0] - centre[0]) * scale) + (getWidth() / 2)); + int ystart = (int) (((centre[1] - b.start[1]) * scale) + (getHeight() / 2)); g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart); } if (n == 2) { - int xstart = (int) ( ( (b.end[0] - centre[0]) * scale) + - (getWidth() / 2)); - int ystart = (int) ( ( (centre[1] - b.end[1] ) * scale) + - (getHeight() / 2)); + int xstart = (int) (((b.end[0] - centre[0]) * scale) + (getWidth() / 2)); + int ystart = (int) (((centre[1] - b.end[1]) * scale) + (getHeight() / 2)); g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart); } } int foundchain = -1; + public Atom findAtom(int x, int y) { Atom fatom = null; @@ -920,19 +952,17 @@ public class PDBCanvas if (chain.isVisible) { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; for (int i = 0; i < bonds.size(); i++) { tmpBond = (Bond) bonds.elementAt(i); - truex = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) + - (getWidth() / 2)); + truex = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getWidth() / 2)); if (Math.abs(truex - x) <= 2) { - int truey = (int) ( ( (centre[1] - tmpBond.start[1] ) * scale) + - (getHeight() / 2)); + int truey = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getHeight() / 2)); if (Math.abs(truey - y) <= 2) { @@ -945,13 +975,11 @@ public class PDBCanvas // Still here? Maybe its the last bond - truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) + - (getWidth() / 2)); + truex = (int) (((tmpBond.end[0] - centre[0]) * scale) + (getWidth() / 2)); if (Math.abs(truex - x) <= 2) { - int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) + - (getHeight() / 2)); + int truey = (int) (((tmpBond.end[1] - centre[1]) * scale) + (getHeight() / 2)); if (Math.abs(truey - y) <= 2) { @@ -963,7 +991,7 @@ public class PDBCanvas } - if (fatom != null) //)&& chain.ds != null) + if (fatom != null) // )&& chain.ds != null) { chain = (PDBChain) pdb.chains.elementAt(foundchain); } @@ -973,6 +1001,7 @@ public class PDBCanvas } Bond highlightBond1, highlightBond2; + public void highlightRes(int ii) { if (!seqColoursReady) @@ -980,8 +1009,7 @@ public class PDBCanvas return; } - if (highlightRes != null - && highlightRes.contains( (ii - 1) + "")) + if (highlightRes != null && highlightRes.contains((ii - 1) + "")) { return; } @@ -1038,35 +1066,36 @@ public class PDBCanvas setupBonds(); } - ////////////////////////////////// - ///StructureListener + // //////////////////////////////// + // /StructureListener public String getPdbFile() { return pdbentry.getFile(); } - String lastMessage; + public void mouseOverStructure(int pdbResNum, String chain) { - if (lastMessage == null || !lastMessage.equals(pdbResNum+chain)) - ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile()); + if (lastMessage == null || !lastMessage.equals(pdbResNum + chain)) + ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile()); - lastMessage = pdbResNum+chain; + lastMessage = pdbResNum + chain; } StringBuffer resetLastRes = new StringBuffer(); + StringBuffer eval = new StringBuffer(); - public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile) + public void highlightAtom(int atomIndex, int pdbResNum, String chain, + String pdbfile) { if (!seqColoursReady) { return; } - if (highlightRes != null - && highlightRes.contains( (atomIndex - 1) + "")) + if (highlightRes != null && highlightRes.contains((atomIndex - 1) + "")) { return; } @@ -1111,14 +1140,14 @@ public class PDBCanvas repaint(); } - - public Color getColour(int atomIndex, int pdbResNum, String chain, String pdbfile) + public Color getColour(int atomIndex, int pdbResNum, String chain, + String pdbfile) { return Color.white; - // if (!pdbfile.equals(pdbentry.getFile())) - // return null; + // if (!pdbfile.equals(pdbentry.getFile())) + // return null; - //return new Color(viewer.getAtomArgb(atomIndex)); + // return new Color(viewer.getAtomArgb(atomIndex)); } public void updateColours(Object source) diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 30712f2..c1c586a 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -33,19 +33,33 @@ public class PDBChain * SequenceFeature group for PDB File features added to sequences */ private static final String PDBFILEFEATURE = "PDBFile"; + private static final String IEASTATUS = "IEA:jalview"; + public String id; + public Vector bonds = new Vector(); + public Vector atoms = new Vector(); + public Vector residues = new Vector(); + public int offset; + public Sequence sequence; + public boolean isVisible = true; + public int pdbstart = 0; + public int pdbend = 0; + public int seqstart = 0; + public int seqend = 0; + public String pdbid = ""; + public PDBChain(String pdbid, String id) { this.pdbid = pdbid.toLowerCase(); @@ -58,9 +72,9 @@ public class PDBChain for (int i = 0; i < bonds.size(); i++) { - tmp = tmp + ( (Bond) bonds.elementAt(i)).at1.resName + " " + - ( (Bond) bonds.elementAt(i)).at1.resNumber + " " + offset + - "\n"; + tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " " + + ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset + + "\n"; } return tmp; @@ -95,16 +109,21 @@ public class PDBChain } } } + /** - * copy over the RESNUM seqfeatures from the internal chain sequence to the mapped sequence + * copy over the RESNUM seqfeatures from the internal chain sequence to the + * mapped sequence + * * @param seq - * @param status The Status of the transferred annotation + * @param status + * The Status of the transferred annotation * @return the features added to sq (or its dataset) */ - public SequenceFeature[] transferRESNUMFeatures(SequenceI seq, String status) + public SequenceFeature[] transferRESNUMFeatures(SequenceI seq, + String status) { SequenceI sq = seq; - while (sq!=null && sq.getDatasetSequence()!=null) + while (sq != null && sq.getDatasetSequence() != null) { sq = sq.getDatasetSequence(); if (sq == sequence) @@ -114,11 +133,10 @@ public class PDBChain } /** * Remove any existing features for this chain if they exist ? - * SequenceFeature[] seqsfeatures=seq.getSequenceFeatures(); - int totfeat=seqsfeatures.length; - // Remove any features for this exact chain ? - for (int i=0; ik) + min = k; + max = k; + } + else + { + if (min > k) + { + min = k; + } + else if (max < k) { - min=k; - } else - if (max") > -1 || data.indexOf("") > -1) - ) + if (!(data.indexOf("
") > -1 || data.indexOf("
") > -1)) { out.println(data); } } out.close(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index e5ad565..5fd3d10 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -26,18 +26,18 @@ import java.awt.*; import jalview.datamodel.*; import jalview.io.FileParse; -public class PDBfile - extends jalview.io.AlignFile +public class PDBfile extends jalview.io.AlignFile { public Vector chains; + public String id; /** * set to true to add chain alignment annotation as visible annotation. */ - boolean VisibleChainAnnotation=false; - public PDBfile(String inFile, String inType) - throws IOException + boolean VisibleChainAnnotation = false; + + public PDBfile(String inFile, String inType) throws IOException { super(inFile, inType); } @@ -52,11 +52,10 @@ public class PDBfile return null; } - public void parse() - throws IOException + public void parse() throws IOException { - // TODO set the filename sensibly - id = (inFile==null) ? "PDBFILE" : inFile.getName(); + // TODO set the filename sensibly + id = (inFile == null) ? "PDBFILE" : inFile.getName(); try { chains = new Vector(); @@ -67,7 +66,7 @@ public class PDBfile boolean terFlag = false; int index = 0; - while ( (line = nextLine()) != null) + while ((line = nextLine()) != null) { if (line.indexOf("HEADER") == 0) { @@ -94,12 +93,11 @@ public class PDBfile break; } if (line.indexOf("ATOM") == 0 - || (line.indexOf("HETATM") == 0 && !terFlag) - ) + || (line.indexOf("HETATM") == 0 && !terFlag)) { terFlag = false; - //Jalview is only interested in CA bonds???? + // Jalview is only interested in CA bonds???? if (!line.substring(12, 15).trim().equals("CA")) { continue; @@ -130,8 +128,7 @@ public class PDBfile } for (int i = 0; i < chains.size(); i++) { - SequenceI dataset = ( (PDBChain) chains.elementAt(i)). - sequence; + SequenceI dataset = ((PDBChain) chains.elementAt(i)).sequence; dataset.setName(id + "|" + dataset.getName()); PDBEntry entry = new PDBEntry(); entry.setId(id); @@ -140,20 +137,21 @@ public class PDBfile entry.setFile(inFile.getAbsolutePath()); } dataset.addPDBId(entry); - SequenceI chainseq = dataset.deriveSequence(); // PDBChain objects maintain reference to dataset + SequenceI chainseq = dataset.deriveSequence(); // PDBChain objects + // maintain reference to + // dataset seqs.addElement(chainseq); AlignmentAnnotation[] chainannot = chainseq.getAnnotation(); - if (chainannot!=null) + if (chainannot != null) { - for (int ai=0; ai= 0) && ( ( (Bond) bonds.elementAt(j)).start[2] > x)); - - do - { - i++; - } - while ( (i < bonds.size()) && - ( ( (Bond) bonds.elementAt(i)).start[2] < x)); - - if (i < j) - { - tmp = (Bond) bonds.elementAt(i); - bonds.setElementAt(bonds.elementAt(j), i); - bonds.setElementAt(tmp, j); - } - else - { - return j; - } - } - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package MCview; + +import java.util.*; + +public class Zsort +{ + public void Zsort(Vector bonds) + { + sort(bonds, 0, bonds.size() - 1); + } + + public void sort(Vector bonds, int p, int r) + { + int q; + + if (p < r) + { + q = partition(bonds, p, r); + sort(bonds, p, q); + sort(bonds, q + 1, r); + } + } + + private int partition(Vector bonds, int p, int r) + { + float x = ((Bond) bonds.elementAt(p)).start[2]; + int i = p - 1; + int j = r + 1; + Bond tmp; + while (true) + { + do + { + j--; + } while ((j >= 0) && (((Bond) bonds.elementAt(j)).start[2] > x)); + + do + { + i++; + } while ((i < bonds.size()) + && (((Bond) bonds.elementAt(i)).start[2] < x)); + + if (i < j) + { + tmp = (Bond) bonds.elementAt(i); + bonds.setElementAt(bonds.elementAt(j), i); + bonds.setElementAt(tmp, j); + } + else + { + return j; + } + } + } +} diff --git a/src/com/stevesoft/pat/AmpersandRule.java b/src/com/stevesoft/pat/AmpersandRule.java index f838ab2..0496a19 100755 --- a/src/com/stevesoft/pat/AmpersandRule.java +++ b/src/com/stevesoft/pat/AmpersandRule.java @@ -1,29 +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; - -/** This implements the $& element of the second argument to - * Regex. - * @see com.stevesoft.pat.ReplaceRule - */ -public final class AmpersandRule - extends ReplaceRule -{ - public AmpersandRule() - {} - - public void apply(StringBufferLike sb, RegRes res) - { - sb.append(res.stringMatched()); - } - - 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; + +/** + * This implements the $& element of the second argument to Regex. + * + * @see com.stevesoft.pat.ReplaceRule + */ +public final class AmpersandRule extends ReplaceRule +{ + public AmpersandRule() + { + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.append(res.stringMatched()); + } + + public String toString1() + { + return "$&"; + } +} diff --git a/src/com/stevesoft/pat/Any.java b/src/com/stevesoft/pat/Any.java index e833662..c97599c 100755 --- a/src/com/stevesoft/pat/Any.java +++ b/src/com/stevesoft/pat/Any.java @@ -1,55 +1,55 @@ -// -// 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 is the '.' character in a Pattern. It - matches any character. */ -class Any - extends Pattern -{ - public int matchInternal(int pos, Pthings pt) - { - if (pos < pt.src.length()) - { - if (pt.dotDoesntMatchCR) - { - if (pt.src.charAt(pos) != '\n') - { - return nextMatch(pos + 1, pt); - } - } - else - { - return nextMatch(pos + 1, pt); - } - } - return -1; - } - - public String toString() - { - return "." + nextString(); - } - - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } - - public Pattern clone1(Hashtable h) - { - return new Any(); - } -}; +// +// 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 is the '.' character in a Pattern. It matches any character. + */ +class Any extends Pattern +{ + public int matchInternal(int pos, Pthings pt) + { + if (pos < pt.src.length()) + { + if (pt.dotDoesntMatchCR) + { + if (pt.src.charAt(pos) != '\n') + { + return nextMatch(pos + 1, pt); + } + } + else + { + return nextMatch(pos + 1, pt); + } + } + return -1; + } + + public String toString() + { + return "." + nextString(); + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Pattern clone1(Hashtable h) + { + return new Any(); + } +}; diff --git a/src/com/stevesoft/pat/BackG.java b/src/com/stevesoft/pat/BackG.java index 72c4c9a..69f7f61 100755 --- a/src/com/stevesoft/pat/BackG.java +++ b/src/com/stevesoft/pat/BackG.java @@ -1,46 +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.*; - -/** This class represents the \G pattern element. */ -class BackG - extends Pattern -{ - char c, altc, altc2; - int mask; - public BackG() - { - } - - public int matchInternal(int pos, Pthings pt) - { - return pos == pt.lastPos ? nextMatch(pos, pt) : -1; - } - - public String toString() - { - return "\\G" + nextString(); - } - - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } - - Pattern clone1(Hashtable h) - { - return new BackG(); - } -} +// +// 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 represents the \G pattern element. */ +class BackG extends Pattern +{ + char c, altc, altc2; + + int mask; + + public BackG() + { + } + + public int matchInternal(int pos, Pthings pt) + { + return pos == pt.lastPos ? nextMatch(pos, pt) : -1; + } + + public String toString() + { + return "\\G" + nextString(); + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + Pattern clone1(Hashtable h) + { + return new BackG(); + } +} diff --git a/src/com/stevesoft/pat/BackMatch.java b/src/com/stevesoft/pat/BackMatch.java index 2eed23b..1b166e9 100755 --- a/src/com/stevesoft/pat/BackMatch.java +++ b/src/com/stevesoft/pat/BackMatch.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; - -import java.util.*; - -/** Provides the ability to match a backreference from within - * a Pattern. - */ -class BackMatch - extends Pattern -{ - int id; - BackMatch(int id) - { - this.id = id; - } - - public String toString() - { - return "\\" + (id) + nextString(); - } - - public int matchInternal(int pos, Pthings p) - { - int i1 = p.marks[id]; - int i2 = p.marks[id + p.nMarks]; - int imax = i2 - i1; - if (i1 < 0 || imax < 0 || pos + imax > p.src.length()) - { - return -1; - } - int ns = p.src.length() - pos; - if (imax < ns) - { - ns = imax; - } - for (int i = 0; i < ns; i++) - { - if (p.src.charAt(i + i1) != p.src.charAt(pos + i)) - { - return -1; - } - } - return nextMatch(pos + imax, p); - } - - Pattern clone1(Hashtable h) - { - return new BackMatch(id); - } -} +// +// 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.*; + +/** + * Provides the ability to match a backreference from within a Pattern. + */ +class BackMatch extends Pattern +{ + int id; + + BackMatch(int id) + { + this.id = id; + } + + public String toString() + { + return "\\" + (id) + nextString(); + } + + public int matchInternal(int pos, Pthings p) + { + int i1 = p.marks[id]; + int i2 = p.marks[id + p.nMarks]; + int imax = i2 - i1; + if (i1 < 0 || imax < 0 || pos + imax > p.src.length()) + { + return -1; + } + int ns = p.src.length() - pos; + if (imax < ns) + { + ns = imax; + } + for (int i = 0; i < ns; i++) + { + if (p.src.charAt(i + i1) != p.src.charAt(pos + i)) + { + return -1; + } + } + return nextMatch(pos + imax, p); + } + + Pattern clone1(Hashtable h) + { + return new BackMatch(id); + } +} diff --git a/src/com/stevesoft/pat/BackRefRule.java b/src/com/stevesoft/pat/BackRefRule.java index 8488ba3..daacbc1 100755 --- a/src/com/stevesoft/pat/BackRefRule.java +++ b/src/com/stevesoft/pat/BackRefRule.java @@ -1,38 +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; - -/** This method implements the pattern elements $1, $2, etc in - a substitution rule. The apply(StringBufferLike sb,RegRes rr) method of this ReplaceRule - simply appends the contents of rr.stringMatched(n), where n is - the integer supplied to the constructor. */ -public class BackRefRule - extends ReplaceRule -{ - int n; - public BackRefRule(int n) - { - this.n = n; - } - - public void apply(StringBufferLike sb, RegRes res) - { - String x = res.stringMatched(n); - sb.append(x == null ? "" : x); - } - - public String toString1() - { - return "$" + n; - } - - public Object clone1() - { - return new BackRefRule(n); - } -} +// +// 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 method implements the pattern elements $1, $2, etc in a substitution + * rule. The apply(StringBufferLike sb,RegRes rr) method of this ReplaceRule + * simply appends the contents of rr.stringMatched(n), where n is the integer + * supplied to the constructor. + */ +public class BackRefRule extends ReplaceRule +{ + int n; + + public BackRefRule(int n) + { + this.n = n; + } + + public void apply(StringBufferLike sb, RegRes res) + { + String x = res.stringMatched(n); + sb.append(x == null ? "" : x); + } + + public String toString1() + { + return "$" + n; + } + + public Object clone1() + { + return new BackRefRule(n); + } +} diff --git a/src/com/stevesoft/pat/Backup.java b/src/com/stevesoft/pat/Backup.java index 31c41c4..1986460 100755 --- a/src/com/stevesoft/pat/Backup.java +++ b/src/com/stevesoft/pat/Backup.java @@ -1,52 +1,54 @@ -// -// 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. It also allows (?>number). */ -class Backup - extends Pattern -{ - int bk; - Backup(int ii) - { - bk = ii; - } - - public String toString() - { - return "(?" + (bk < 0 ? ">" + ( -bk) : "<" + bk) + ")" + nextString(); - } - - public int matchInternal(int pos, Pthings pt) - { - if (pos < bk) - { - return -1; - } - return nextMatch(pos - bk, pt); - } - - public patInt minChars() - { - return new patInt( -bk); - } - - public patInt maxChars() - { - return new patInt( -bk); - } - - public Pattern clone1(Hashtable h) - { - return new Backup(bk); - } -}; +// +// 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. It also allows + * (?>number). + */ +class Backup extends Pattern +{ + int bk; + + Backup(int ii) + { + bk = ii; + } + + public String toString() + { + return "(?" + (bk < 0 ? ">" + (-bk) : "<" + bk) + ")" + nextString(); + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos < bk) + { + return -1; + } + return nextMatch(pos - bk, pt); + } + + public patInt minChars() + { + return new patInt(-bk); + } + + public patInt maxChars() + { + return new patInt(-bk); + } + + public Pattern clone1(Hashtable h) + { + return new Backup(bk); + } +}; diff --git a/src/com/stevesoft/pat/BasicStringBufferLike.java b/src/com/stevesoft/pat/BasicStringBufferLike.java index 7563703..adb10f1 100755 --- a/src/com/stevesoft/pat/BasicStringBufferLike.java +++ b/src/com/stevesoft/pat/BasicStringBufferLike.java @@ -1,22 +1,23 @@ -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; - -/** An abstraction of the StringBuffer which only - implements a subset of StringBuffer's methods. - */ -public interface BasicStringBufferLike -{ - public void append(char c); - - public void append(String s); - - public StringLike toStringLike(); - - public Object 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; + +/** + * An abstraction of the StringBuffer which only implements a subset of + * StringBuffer's methods. + */ +public interface BasicStringBufferLike +{ + public void append(char c); + + public void append(String s); + + public StringLike toStringLike(); + + public Object unwrap(); +} diff --git a/src/com/stevesoft/pat/Bits.java b/src/com/stevesoft/pat/Bits.java index f26d1fb..05b3d34 100755 --- a/src/com/stevesoft/pat/Bits.java +++ b/src/com/stevesoft/pat/Bits.java @@ -1,3096 +1,3040 @@ -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 Bits -{ - char[] carray; - Bits(char[] carray) - { - this.carray = carray; - } - - public boolean get(int i) - { - return ( (carray[i >> 4]) & (1 << (i & 15))) != 0; - } - - public void set(int i, boolean b) - { - if (b) - { - carray[i >> 4] |= (char) 1 << (i & 15); - } - else - { - carray[i >> 4] &= (char)~ (1 << (i & 15)); - } - } - - /* - public static String n4(char c) { - String s = Integer.toHexString(c); - while(s.length()<4) - s = "0"+s; - return s; - } - static abstract class Tester { - abstract boolean test(char c); - } - public static void main(String[] args) throws Exception { - //pw_s.println(" static {"); - FileWriter fw = new FileWriter("x.out"); - fw.close(); - test("upper",new Tester() { - boolean test(char c) { - return Character.isUpperCase(c); - } - }); - test("lower",new Tester() { - boolean test(char c) { - return Character.isLowerCase(c); - } - }); - test("title",new Tester() { - boolean test(char c) { - return Character.isLowerCase(c); - } - }); - test("currency",new Tester() { - boolean test(char c) { - return Character.getType(c)==Character.CURRENCY_SYMBOL; - } - }); - test("decimal_digit",new Tester() { - boolean test(char c) { - return Character.getType(c)==Character.DECIMAL_DIGIT_NUMBER; - } - }); - test("math",new Tester() { - boolean test(char c) { - return Character.getType(c)==Character.MATH_SYMBOL; - } - }); - test("letter",new Tester() { - boolean test(char c) { - return Character.isLetter(c); - } - }); - test("white",new Tester() { - boolean test(char c) { - return Character.isWhitespace(c); - } - }); - test("punct",new Tester() { - boolean test(char c) { - boolean r = false; - switch(Character.getType(c)) { - case Character.DASH_PUNCTUATION: - case Character.START_PUNCTUATION: - case Character.END_PUNCTUATION: - case Character.CONNECTOR_PUNCTUATION: - case Character.OTHER_PUNCTUATION: - r = true; - break; - default: - r = false; - break; - } - return r; - } - }); - //pw_s.println(" }"); - fw = new FileWriter("x.out",true); - fw.write(sw.toString()); - fw.close(); - } - static StringWriter sw = new StringWriter(); - static PrintWriter pw_s = new PrintWriter(sw,true); - public static void test(String var,Tester t) throws Exception { - - char[] ca = new char[(66536 >> 4)+1]; - Bits b = new Bits(ca); - FileWriter fw = new FileWriter("x.out",true); - PrintWriter pw = new PrintWriter(fw); - - //pw_s.println(" "+var+"_f();"); - pw.println(" public static Bits "+var+";"); - pw.println(" static void "+var+"_f() {"); - pw.println(" char[] data = new char["+ca.length+"];"); - pw.println(" "+var+" = new Bits(data);"); - for(int i=0;i<66536;i++) { - char c = (char)i; - //b.set(i,Character.getType(c)==Character.CURRENCY_SYMBOL); - b.set(i,t.test(c)); - } - for(int i=0;i> 4]) & (1 << (i & 15))) != 0; + } + + public void set(int i, boolean b) + { + if (b) + { + carray[i >> 4] |= (char) 1 << (i & 15); + } + else + { + carray[i >> 4] &= (char) ~(1 << (i & 15)); + } + } + + /* + * public static String n4(char c) { String s = Integer.toHexString(c); + * while(s.length()<4) s = "0"+s; return s; } static abstract class Tester { + * abstract boolean test(char c); } public static void main(String[] args) + * throws Exception { //pw_s.println(" static {"); FileWriter fw = new + * FileWriter("x.out"); fw.close(); test("upper",new Tester() { boolean + * test(char c) { return Character.isUpperCase(c); } }); test("lower",new + * Tester() { boolean test(char c) { return Character.isLowerCase(c); } }); + * test("title",new Tester() { boolean test(char c) { return + * Character.isLowerCase(c); } }); test("currency",new Tester() { boolean + * test(char c) { return Character.getType(c)==Character.CURRENCY_SYMBOL; } + * }); test("decimal_digit",new Tester() { boolean test(char c) { return + * Character.getType(c)==Character.DECIMAL_DIGIT_NUMBER; } }); test("math",new + * Tester() { boolean test(char c) { return + * Character.getType(c)==Character.MATH_SYMBOL; } }); test("letter",new + * Tester() { boolean test(char c) { return Character.isLetter(c); } }); + * test("white",new Tester() { boolean test(char c) { return + * Character.isWhitespace(c); } }); test("punct",new Tester() { boolean + * test(char c) { boolean r = false; switch(Character.getType(c)) { case + * Character.DASH_PUNCTUATION: case Character.START_PUNCTUATION: case + * Character.END_PUNCTUATION: case Character.CONNECTOR_PUNCTUATION: case + * Character.OTHER_PUNCTUATION: r = true; break; default: r = false; break; } + * return r; } }); //pw_s.println(" }"); fw = new FileWriter("x.out",true); + * fw.write(sw.toString()); fw.close(); } static StringWriter sw = new + * StringWriter(); static PrintWriter pw_s = new PrintWriter(sw,true); public + * static void test(String var,Tester t) throws Exception { + * + * char[] ca = new char[(66536 >> 4)+1]; Bits b = new Bits(ca); FileWriter fw = + * new FileWriter("x.out",true); PrintWriter pw = new PrintWriter(fw); + * + * //pw_s.println(" "+var+"_f();"); pw.println(" public static Bits + * "+var+";"); pw.println(" static void "+var+"_f() {"); pw.println(" char[] + * data = new char["+ca.length+"];"); pw.println(" "+var+" = new + * Bits(data);"); for(int i=0;i<66536;i++) { char c = (char)i; + * //b.set(i,Character.getType(c)==Character.CURRENCY_SYMBOL); + * b.set(i,t.test(c)); } for(int i=0;i= '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; - } - - boolean matchLeft(int pos, Pthings pt) - { - if (pos <= 0) - { - return true; - } - if (isAChar(pt.src.charAt(pos)) - && isAChar(pt.src.charAt(pos - 1))) - { - return false; - } - return true; - } - - boolean matchRight(int pos, Pthings pt) - { - if (pos < 0) - { - return false; - } - if (pos + 1 >= pt.src.length()) - { - return true; - } - if (isAChar(pt.src.charAt(pos)) - && isAChar(pt.src.charAt(pos + 1))) - { - return false; - } - return true; - } - - public int matchInternal(int pos, Pthings pt) - { - if (matchRight(pos - 1, pt) || matchLeft(pos, pt)) - { - return nextMatch(pos, pt); - } - return -1; - } - - public patInt maxChars() - { - return new patInt(0); - } - - public Pattern clone1(Hashtable h) - { - return new Boundary(); - } -}; +// +// 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 word boundary pattern element: \b. */ +class Boundary extends Pattern +{ + public String toString() + { + return "\\b" + nextString(); + } + + boolean isAChar(char 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; + } + + boolean matchLeft(int pos, Pthings pt) + { + if (pos <= 0) + { + return true; + } + if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos - 1))) + { + return false; + } + return true; + } + + boolean matchRight(int pos, Pthings pt) + { + if (pos < 0) + { + return false; + } + if (pos + 1 >= pt.src.length()) + { + return true; + } + if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos + 1))) + { + return false; + } + return true; + } + + public int matchInternal(int pos, Pthings pt) + { + if (matchRight(pos - 1, pt) || matchLeft(pos, pt)) + { + return nextMatch(pos, pt); + } + return -1; + } + + public patInt maxChars() + { + return new patInt(0); + } + + public Pattern clone1(Hashtable h) + { + return new Boundary(); + } +}; diff --git a/src/com/stevesoft/pat/Bracket.java b/src/com/stevesoft/pat/Bracket.java index 175731b..cec8af4 100755 --- a/src/com/stevesoft/pat/Bracket.java +++ b/src/com/stevesoft/pat/Bracket.java @@ -1,87 +1,88 @@ -// -// 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 Bracket is a form of the Or class, - implements the pattern element [ ]. */ -class Bracket - extends Or -{ - boolean neg; - Bracket(boolean n) - { - neg = n; - } - - String leftForm() - { - if (neg) - { - return "[^"; - } - else - { - return "["; - } - } - - String rightForm() - { - return "]"; - } - - String sepForm() - { - return ""; - } - - public int matchInternal(int pos, Pthings pt) - { - if (pos >= pt.src.length()) - { - return -1; - } - int r = super.matchInternal(pos, pt); - if ( (neg && r < 0) || (!neg && r >= 0)) - { - return nextMatch(pos + 1, pt); - } - return -1; - } - - public patInt minChars() - { - return new patInt(1); - } - - public patInt maxChars() - { - return new patInt(1); - } - - public Or addOr(Pattern p) - { - pv = null; - v.addElement(p); - p.setParent(null); - return this; - } - - public Pattern clone1(Hashtable h) - { - Bracket b = new Bracket(neg); - b.v = new Vector(); - for (int i = 0; i < v.size(); i++) - { - b.v.addElement( ( (Pattern) v.elementAt(i)).clone1(h)); - } - return b; - } -}; +// +// 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 Bracket is a form of the Or class, implements the pattern element [ ]. + */ +class Bracket extends Or +{ + boolean neg; + + Bracket(boolean n) + { + neg = n; + } + + String leftForm() + { + if (neg) + { + return "[^"; + } + else + { + return "["; + } + } + + String rightForm() + { + return "]"; + } + + String sepForm() + { + return ""; + } + + public int matchInternal(int pos, Pthings pt) + { + if (pos >= pt.src.length()) + { + return -1; + } + int r = super.matchInternal(pos, pt); + if ((neg && r < 0) || (!neg && r >= 0)) + { + return nextMatch(pos + 1, pt); + } + return -1; + } + + public patInt minChars() + { + return new patInt(1); + } + + public patInt maxChars() + { + return new patInt(1); + } + + public Or addOr(Pattern p) + { + pv = null; + v.addElement(p); + p.setParent(null); + return this; + } + + public Pattern clone1(Hashtable h) + { + Bracket b = new Bracket(neg); + b.v = new Vector(); + for (int i = 0; i < v.size(); i++) + { + b.v.addElement(((Pattern) v.elementAt(i)).clone1(h)); + } + return b; + } +}; diff --git a/src/com/stevesoft/pat/CaseMgr.java b/src/com/stevesoft/pat/CaseMgr.java index ff93f25..393dac9 100755 --- a/src/com/stevesoft/pat/CaseMgr.java +++ b/src/com/stevesoft/pat/CaseMgr.java @@ -1,4407 +1,4409 @@ -// -// 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) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < s.length(); i++) - { - sb.append(CaseMgr.toTitleCase(s.charAt(i))); - } - return sb.toString(); - } - - /** Convert a String to upper case. */ - public static String toUpperCase(String s) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < s.length(); i++) - { - sb.append(CaseMgr.toUpperCase(s.charAt(i))); - } - return sb.toString(); - } - - /** Convert a String to lower case. */ - public static String toLowerCase(String s) - { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < s.length(); i++) - { - sb.append(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) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < s.length(); i++) + { + sb.append(CaseMgr.toTitleCase(s.charAt(i))); + } + return sb.toString(); + } + + /** Convert a String to upper case. */ + public static String toUpperCase(String s) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < s.length(); i++) + { + sb.append(CaseMgr.toUpperCase(s.charAt(i))); + } + return sb.toString(); + } + + /** Convert a String to lower case. */ + public static String toLowerCase(String s) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < s.length(); i++) + { + sb.append(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/src/com/stevesoft/pat/ChangeRule.java b/src/com/stevesoft/pat/ChangeRule.java index 31046ee..e8ef5df 100755 --- a/src/com/stevesoft/pat/ChangeRule.java +++ b/src/com/stevesoft/pat/ChangeRule.java @@ -1,47 +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/src/com/stevesoft/pat/CodeRule.java b/src/com/stevesoft/pat/CodeRule.java index 763bf3e..aa9c4dc 100755 --- a/src/com/stevesoft/pat/CodeRule.java +++ b/src/com/stevesoft/pat/CodeRule.java @@ -1,32 +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/src/com/stevesoft/pat/Ctrl.java b/src/com/stevesoft/pat/Ctrl.java index 6fee70f..5d40098 100755 --- a/src/com/stevesoft/pat/Ctrl.java +++ b/src/com/stevesoft/pat/Ctrl.java @@ -1,271 +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/src/com/stevesoft/pat/Custom.java b/src/com/stevesoft/pat/Custom.java index 72aebc7..61879ac 100755 --- a/src/com/stevesoft/pat/Custom.java +++ b/src/com/stevesoft/pat/Custom.java @@ -1,60 +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/src/com/stevesoft/pat/CustomEndpoint.java b/src/com/stevesoft/pat/CustomEndpoint.java index ac6c4ba..9608f7e 100755 --- a/src/com/stevesoft/pat/CustomEndpoint.java +++ b/src/com/stevesoft/pat/CustomEndpoint.java @@ -1,43 +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/src/com/stevesoft/pat/DirFileRegex.java b/src/com/stevesoft/pat/DirFileRegex.java index 24c0cf6..bc62910 100755 --- a/src/com/stevesoft/pat/DirFileRegex.java +++ b/src/com/stevesoft/pat/DirFileRegex.java @@ -1,30 +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; - -/** This class is just like FileRegex, except that its accept method - only returns true if the file matching the pattern is a directory.*/ -public class DirFileRegex - extends FileRegex -{ - public DirFileRegex() - { - dirflag = DIR; - } - - public DirFileRegex(String fp) - { - super(fp); - dirflag = DIR; - } - - public static String[] list(String f) - { - return list(f, DIR); - } -} +// +// 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 just like FileRegex, except that its accept method only returns + * true if the file matching the pattern is a directory. + */ +public class DirFileRegex extends FileRegex +{ + public DirFileRegex() + { + dirflag = DIR; + } + + public DirFileRegex(String fp) + { + super(fp); + dirflag = DIR; + } + + public static String[] list(String f) + { + return list(f, DIR); + } +} diff --git a/src/com/stevesoft/pat/DotMulti.java b/src/com/stevesoft/pat/DotMulti.java index 4691728..cc5f094 100755 --- a/src/com/stevesoft/pat/DotMulti.java +++ b/src/com/stevesoft/pat/DotMulti.java @@ -1,205 +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/src/com/stevesoft/pat/End.java b/src/com/stevesoft/pat/End.java index 42894b3..547f3d6 100755 --- a/src/com/stevesoft/pat/End.java +++ b/src/com/stevesoft/pat/End.java @@ -1,70 +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/src/com/stevesoft/pat/FastBracket.java b/src/com/stevesoft/pat/FastBracket.java index 5f5fff0..a10ec2b 100755 --- a/src/com/stevesoft/pat/FastBracket.java +++ b/src/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/src/com/stevesoft/pat/FastMulti.java b/src/com/stevesoft/pat/FastMulti.java index 53130fa..a8387b4 100755 --- a/src/com/stevesoft/pat/FastMulti.java +++ b/src/com/stevesoft/pat/FastMulti.java @@ -1,171 +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/src/com/stevesoft/pat/FileRegex.java b/src/com/stevesoft/pat/FileRegex.java index 37729eb..342d41c 100755 --- a/src/com/stevesoft/pat/FileRegex.java +++ b/src/com/stevesoft/pat/FileRegex.java @@ -1,293 +1,323 @@ -// -// 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 java.util.*; - -/** This class is a different form of Regex designed to work more - like the file matching utility of a Unix shell. It is implemented - by some simple string transformations: -

- - - - - - - - - - - -
FileRegex Regex
* .*
. \.
{ (?:
{?! (?!
{?= (?=
{?? (??
} )
? .
{,} (|)
-
- Note that a FileRegex pattern always ends with the Regex - pattern element "$". If you like to experiment, try making - FileRegex's and then printing them out. The toString() method - does a decompile of the pattern to a standard Regex. Here are - some more complete examples: -
- - - - - -
FileRegex Regex
*.java .*\.java$
*.{java,html} .*\.(java|html)$
foo.[chC] foo.[chC]$
-
- */ -public class FileRegex - extends Regex -{ - /** Build an unitialized FileRegex. */ - public FileRegex() - { - dirflag = EITHER; - } - - /** Build a FileRegex form String s. */ - public FileRegex(String s) - { - super(s); - dirflag = EITHER; - } - - /** Compile a new pattern. - Throws @exception com.stevesoft.pat.RegSyntax for - nonsensical patterns like "[9-0]+" just as Regex does. - @see com.stevesoft.pat#compile(java.lang.String) - */ - public void compile(String s) - throws RegSyntax - { - String npat = toFileRegex(s); - super.compile(npat); - if (File.separatorChar == '\\') // MS-DOS - { - ignoreCase = true; - } - } - - /** This is the method required by FileNameFilter. - To get a listing of files in the current directory - ending in .java, do this: -
-      File dot = new File(".");
-      FileRegex java_files = new FileRegex("*.java");
-      String[] file_list = dot.list(java_files);
-      
- */ - public boolean accept(File dir, String s) - { - if (dirflag != EITHER) - { - File f = new File(s); - if (f.isDirectory() && dirflag == NONDIR) - { - return false; - } - if (!f.isDirectory() && dirflag == DIR) - { - return false; - } - } - return matchAt(s, 0); - } - - int dirflag = 0; - final static int EITHER = 0, DIR = 1, NONDIR = 2; - - /** Provides an alternative to File.list -- this - separates its argument according to File.pathSeparator. - To each path, it splits off a directory -- all characters - up to and including the first instance of File.separator -- - and a file pattern -- the part that comes after the directory. - It then produces a list of all the pattern matches on all - the paths. Thus "*.java:../*.java" would produce a list of - all the java files in this directory and in the ".." directory - on a Unix machine. "*.java;..\\*.java" would do the same thing - on a Dos machine. */ - public static String[] list(String f) - { - return list(f, EITHER); - } - - static String[] list(String f, int df) - { - //return list_(f,new FileRegex()); - StringTokenizer st = new StringTokenizer(f, File.pathSeparator); - Vector v = new Vector(); - while (st.hasMoreTokens()) - { - String path = st.nextToken(); - list1(path, v, df, true); - } - String[] sa = new String[v.size()]; - v.copyInto(sa); - return sa; - } - - final static Regex root = new Regex(File.separatorChar == '/' ? - "/$" : "(?:.:|)\\\\$"); - static void list1(String path, Vector v, int df, boolean rec) - { - // if path looks like a/b/c/ or d:\ then add . - if (root.matchAt(path, 0)) - { - v.addElement(path + "."); - return; - } - File f = new File(path); - if (f.getParent() != null && rec) - { - Vector v2 = new Vector(); - list1(f.getParent(), v2, DIR, true); - for (int i = 0; i < v2.size(); i++) - { - String path2 = ( (String) v2.elementAt(i)) + - File.separator + f.getName(); - list1(path2, v, df, false); - } - } - else - { - File base = new File(path); - - String dir_s = base.getParent(); - if (dir_s == null) - { - dir_s = "."; - } - File dir = new File(dir_s); - - FileRegex fr = new FileRegex(base.getName()); - if (fr.isLiteral()) - { - v.addElement(dir_s + File.separator + base.getName()); - return; - } - fr.dirflag = df; - String[] sa = dir.list(fr); - if (sa == null) - { - return; - } - for (int i = 0; i < sa.length; i++) - { - v.addElement(dir_s + File.separator + sa[i]); - } - } - } - - /** This method takes a file regular expression, and translates it - into the type of pattern used by a normal Regex. */ - public static String toFileRegex(String s) - { - StrPos sp = new StrPos(s, 0); - StringBuffer sb = new StringBuffer(); - if (sp.incMatch("{?e=")) - { - char e = sp.thisChar(); - sp.inc(); - if (sp.incMatch("}")) - { - sb.append("(?e=" + e + ")^"); - } - else - { - sb.append("^(?e="); - } - sp.esc = e; - } - int ParenLvl = 0; - while (!sp.eos()) - { - if (File.separatorChar == '\\') - { - if (sp.escaped()) - { - sb.append("\\\\"); - } - sp.dontMatch = false; - } - if (sp.incMatch("?")) - { - sb.append("."); - } - else if (sp.incMatch(".")) - { - sb.append(sp.esc); - sb.append('.'); - } - else if (sp.incMatch("{??")) - { - sb.append("(??"); - ParenLvl++; - // allow negative lookahead to work - } - else if (sp.incMatch("{?!")) - { - sb.append("(?!"); - ParenLvl++; - // allow positive lookahead to work - } - else if (sp.incMatch("{?=")) - { - sb.append("(?="); - ParenLvl++; - } - else if (sp.incMatch("{")) - { - sb.append("(?:"); - ParenLvl++; - } - else if (sp.incMatch("}")) - { - sb.append(')'); - ParenLvl--; - } - else if (ParenLvl != 0 && sp.incMatch(",")) - { - sb.append('|'); - } - else if (sp.incMatch("*")) - { - sb.append(".*"); - } - else - { - sb.append(sp.thisChar()); - sp.inc(); - } - } - sb.append("$"); - return sb.toString(); - } - - public boolean isLiteral() - { - Pattern x = thePattern; - while (x != null && ! (x instanceof End)) - { - if (x instanceof oneChar) - { - ; - } - else if (x instanceof Skipped) - { - ; - } - else - { - return false; - } - x = x.next; - } - 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 java.io.*; +import java.util.*; + +/** + * This class is a different form of Regex designed to work more like the file + * matching utility of a Unix shell. It is implemented by some simple string + * transformations:
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
FileRegex Regex
* .*
. \.
{ (?:
{?! (?!
{?= (?=
{?? (??
} )
? .
{,} (|)
Note that a FileRegex pattern always ends with the Regex + * pattern element "$". If you like to experiment, try making FileRegex's and + * then printing them out. The toString() method does a decompile of the pattern + * to a standard Regex. Here are some more complete examples:
+ * + * + * + * + * + * + * + * + * + * + * + * + *
FileRegex Regex
*.java .*\.java$
*.{java,html} .*\.(java|html)$
foo.[chC] foo.[chC]$
+ */ +public class FileRegex extends Regex +{ + /** Build an unitialized FileRegex. */ + public FileRegex() + { + dirflag = EITHER; + } + + /** Build a FileRegex form String s. */ + public FileRegex(String s) + { + super(s); + dirflag = EITHER; + } + + /** + * Compile a new pattern. Throws + * + * @exception com.stevesoft.pat.RegSyntax + * for nonsensical patterns like "[9-0]+" just as Regex + * does. + * @see com.stevesoft.pat#compile(java.lang.String) + */ + public void compile(String s) throws RegSyntax + { + String npat = toFileRegex(s); + super.compile(npat); + if (File.separatorChar == '\\') // MS-DOS + { + ignoreCase = true; + } + } + + /** + * This is the method required by FileNameFilter. To get a listing of files in + * the current directory ending in .java, do this: + * + *
+   * File dot = new File(".");
+   * 
+   * FileRegex java_files = new FileRegex("*.java");
+   * 
+   * String[] file_list = dot.list(java_files);
+   * 
+ */ + public boolean accept(File dir, String s) + { + if (dirflag != EITHER) + { + File f = new File(s); + if (f.isDirectory() && dirflag == NONDIR) + { + return false; + } + if (!f.isDirectory() && dirflag == DIR) + { + return false; + } + } + return matchAt(s, 0); + } + + int dirflag = 0; + + final static int EITHER = 0, DIR = 1, NONDIR = 2; + + /** + * Provides an alternative to File.list -- this separates its argument + * according to File.pathSeparator. To each path, it splits off a directory -- + * all characters up to and including the first instance of File.separator -- + * and a file pattern -- the part that comes after the directory. It then + * produces a list of all the pattern matches on all the paths. Thus + * "*.java:../*.java" would produce a list of all the java files in this + * directory and in the ".." directory on a Unix machine. "*.java;..\\*.java" + * would do the same thing on a Dos machine. + */ + public static String[] list(String f) + { + return list(f, EITHER); + } + + static String[] list(String f, int df) + { + // return list_(f,new FileRegex()); + StringTokenizer st = new StringTokenizer(f, File.pathSeparator); + Vector v = new Vector(); + while (st.hasMoreTokens()) + { + String path = st.nextToken(); + list1(path, v, df, true); + } + String[] sa = new String[v.size()]; + v.copyInto(sa); + return sa; + } + + final static Regex root = new Regex(File.separatorChar == '/' ? "/$" + : "(?:.:|)\\\\$"); + + static void list1(String path, Vector v, int df, boolean rec) + { + // if path looks like a/b/c/ or d:\ then add . + if (root.matchAt(path, 0)) + { + v.addElement(path + "."); + return; + } + File f = new File(path); + if (f.getParent() != null && rec) + { + Vector v2 = new Vector(); + list1(f.getParent(), v2, DIR, true); + for (int i = 0; i < v2.size(); i++) + { + String path2 = ((String) v2.elementAt(i)) + File.separator + + f.getName(); + list1(path2, v, df, false); + } + } + else + { + File base = new File(path); + + String dir_s = base.getParent(); + if (dir_s == null) + { + dir_s = "."; + } + File dir = new File(dir_s); + + FileRegex fr = new FileRegex(base.getName()); + if (fr.isLiteral()) + { + v.addElement(dir_s + File.separator + base.getName()); + return; + } + fr.dirflag = df; + String[] sa = dir.list(fr); + if (sa == null) + { + return; + } + for (int i = 0; i < sa.length; i++) + { + v.addElement(dir_s + File.separator + sa[i]); + } + } + } + + /** + * This method takes a file regular expression, and translates it into the + * type of pattern used by a normal Regex. + */ + public static String toFileRegex(String s) + { + StrPos sp = new StrPos(s, 0); + StringBuffer sb = new StringBuffer(); + if (sp.incMatch("{?e=")) + { + char e = sp.thisChar(); + sp.inc(); + if (sp.incMatch("}")) + { + sb.append("(?e=" + e + ")^"); + } + else + { + sb.append("^(?e="); + } + sp.esc = e; + } + int ParenLvl = 0; + while (!sp.eos()) + { + if (File.separatorChar == '\\') + { + if (sp.escaped()) + { + sb.append("\\\\"); + } + sp.dontMatch = false; + } + if (sp.incMatch("?")) + { + sb.append("."); + } + else if (sp.incMatch(".")) + { + sb.append(sp.esc); + sb.append('.'); + } + else if (sp.incMatch("{??")) + { + sb.append("(??"); + ParenLvl++; + // allow negative lookahead to work + } + else if (sp.incMatch("{?!")) + { + sb.append("(?!"); + ParenLvl++; + // allow positive lookahead to work + } + else if (sp.incMatch("{?=")) + { + sb.append("(?="); + ParenLvl++; + } + else if (sp.incMatch("{")) + { + sb.append("(?:"); + ParenLvl++; + } + else if (sp.incMatch("}")) + { + sb.append(')'); + ParenLvl--; + } + else if (ParenLvl != 0 && sp.incMatch(",")) + { + sb.append('|'); + } + else if (sp.incMatch("*")) + { + sb.append(".*"); + } + else + { + sb.append(sp.thisChar()); + sp.inc(); + } + } + sb.append("$"); + return sb.toString(); + } + + public boolean isLiteral() + { + Pattern x = thePattern; + while (x != null && !(x instanceof End)) + { + if (x instanceof oneChar) + { + ; + } + else if (x instanceof Skipped) + { + ; + } + else + { + return false; + } + x = x.next; + } + return true; + } +} diff --git a/src/com/stevesoft/pat/Group.java b/src/com/stevesoft/pat/Group.java index 4f538b5..e6f734c 100755 --- a/src/com/stevesoft/pat/Group.java +++ b/src/com/stevesoft/pat/Group.java @@ -1,75 +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/src/com/stevesoft/pat/LeftRule.java b/src/com/stevesoft/pat/LeftRule.java index 0b9bae3..c75a0a5 100755 --- a/src/com/stevesoft/pat/LeftRule.java +++ b/src/com/stevesoft/pat/LeftRule.java @@ -1,30 +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 StringBuffer - sb. - @see com.stevesoft.pat.ReplaceRule - */ -public class LeftRule - extends ReplaceRule -{ - public LeftRule() - {} - - public void apply(StringBufferLike sb, RegRes res) - { - sb.append(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 StringBuffer sb. + * + * @see com.stevesoft.pat.ReplaceRule + */ +public class LeftRule extends ReplaceRule +{ + public LeftRule() + { + } + + public void apply(StringBufferLike sb, RegRes res) + { + sb.append(res.left()); + } + + public String toString1() + { + return "$`"; + } +} diff --git a/src/com/stevesoft/pat/Multi.java b/src/com/stevesoft/pat/Multi.java index 14b3a06..1fe197d 100755 --- a/src/com/stevesoft/pat/Multi.java +++ b/src/com/stevesoft/pat/Multi.java @@ -1,85 +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/src/com/stevesoft/pat/MultiMin.java b/src/com/stevesoft/pat/MultiMin.java index f741e99..6054e06 100755 --- a/src/com/stevesoft/pat/MultiMin.java +++ b/src/com/stevesoft/pat/MultiMin.java @@ -1,22 +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/src/com/stevesoft/pat/Multi_stage2.java b/src/com/stevesoft/pat/Multi_stage2.java index 990b0e6..b18ad1c 100755 --- a/src/com/stevesoft/pat/Multi_stage2.java +++ b/src/com/stevesoft/pat/Multi_stage2.java @@ -1,156 +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/src/com/stevesoft/pat/NoPattern.java b/src/com/stevesoft/pat/NoPattern.java index c5eba3c..444d094 100755 --- a/src/com/stevesoft/pat/NoPattern.java +++ b/src/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/src/com/stevesoft/pat/NonDirFileRegex.java b/src/com/stevesoft/pat/NonDirFileRegex.java index cb7b69d..864243c 100755 --- a/src/com/stevesoft/pat/NonDirFileRegex.java +++ b/src/com/stevesoft/pat/NonDirFileRegex.java @@ -1,30 +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; - -/** This class is just like FileRegex, except that its accept method - only returns true if the file matching the pattern is not a directory.*/ -public class NonDirFileRegex - extends FileRegex -{ - public NonDirFileRegex() - { - dirflag = NONDIR; - } - - public NonDirFileRegex(String fp) - { - super(fp); - dirflag = NONDIR; - } - - public static String[] list(String f) - { - return list(f, NONDIR); - } -} +// +// 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 just like FileRegex, except that its accept method only returns + * true if the file matching the pattern is not a directory. + */ +public class NonDirFileRegex extends FileRegex +{ + public NonDirFileRegex() + { + dirflag = NONDIR; + } + + public NonDirFileRegex(String fp) + { + super(fp); + dirflag = NONDIR; + } + + public static String[] list(String f) + { + return list(f, NONDIR); + } +} diff --git a/src/com/stevesoft/pat/NotImplementedError.java b/src/com/stevesoft/pat/NotImplementedError.java index 246ecad..11ce9eb 100755 --- a/src/com/stevesoft/pat/NotImplementedError.java +++ b/src/com/stevesoft/pat/NotImplementedError.java @@ -1,17 +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/src/com/stevesoft/pat/NullPattern.java b/src/com/stevesoft/pat/NullPattern.java index abdc5fa..09460de 100755 --- a/src/com/stevesoft/pat/NullPattern.java +++ b/src/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/src/com/stevesoft/pat/NullRule.java b/src/com/stevesoft/pat/NullRule.java index fe4e837..7c780e1 100755 --- a/src/com/stevesoft/pat/NullRule.java +++ b/src/com/stevesoft/pat/NullRule.java @@ -1,28 +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 StringBuffer 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 StringBuffer 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/src/com/stevesoft/pat/Or.java b/src/com/stevesoft/pat/Or.java index 05981aa..8d405e5 100755 --- a/src/com/stevesoft/pat/Or.java +++ b/src/com/stevesoft/pat/Or.java @@ -1,127 +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; - StringBuffer sb = new StringBuffer(); - 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; + StringBuffer sb = new StringBuffer(); + 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/src/com/stevesoft/pat/OrMark.java b/src/com/stevesoft/pat/OrMark.java index 77aac0f..89b8869 100755 --- a/src/com/stevesoft/pat/OrMark.java +++ b/src/com/stevesoft/pat/OrMark.java @@ -1,72 +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/src/com/stevesoft/pat/PartialBuffer.java b/src/com/stevesoft/pat/PartialBuffer.java index 121dd32..c53d6df 100755 --- a/src/com/stevesoft/pat/PartialBuffer.java +++ b/src/com/stevesoft/pat/PartialBuffer.java @@ -1,106 +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: -

-    StringBuffer 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; - StringBuffer sb; - PartialBuffer(StringBuffer 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) - { - StringBuffer sb = new StringBuffer(i2 - i1); - for (int i = i1; i < i2; i++) - { - sb.append(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: + * + *

+ *  StringBuffer 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; + + StringBuffer sb; + + PartialBuffer(StringBuffer 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) + { + StringBuffer sb = new StringBuffer(i2 - i1); + for (int i = i1; i < i2; i++) + { + sb.append(charAt(i)); + } + return sb.toString(); + } + + /** Just returns null. */ + public BasicStringBufferLike newStringBufferLike() + { + return null; + } +} diff --git a/src/com/stevesoft/pat/Pattern.java b/src/com/stevesoft/pat/Pattern.java index a441b37..543391e 100755 --- a/src/com/stevesoft/pat/Pattern.java +++ b/src/com/stevesoft/pat/Pattern.java @@ -1,280 +1,294 @@ -// -// 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 - */ -/** - 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; - StringBuffer sb = new StringBuffer(); - String p = PROTECT_THESE + esc; - for (i = 0; i < s.length(); i++) - { - char c = s.charAt(i); - if (inString(c, p)) - { - sb.append(esc); - } - sb.append(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("No such method as clone1 for " + 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("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 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; + StringBuffer sb = new StringBuffer(); + String p = PROTECT_THESE + esc; + for (i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + if (inString(c, p)) + { + sb.append(esc); + } + sb.append(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("No such method as clone1 for " + 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("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/src/com/stevesoft/pat/PatternSub.java b/src/com/stevesoft/pat/PatternSub.java index 57576e3..d790f4b 100755 --- a/src/com/stevesoft/pat/PatternSub.java +++ b/src/com/stevesoft/pat/PatternSub.java @@ -1,17 +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/src/com/stevesoft/pat/PopRule.java b/src/com/stevesoft/pat/PopRule.java index c8622f3..4a17ab8 100755 --- a/src/com/stevesoft/pat/PopRule.java +++ b/src/com/stevesoft/pat/PopRule.java @@ -1,23 +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/src/com/stevesoft/pat/Prop.java b/src/com/stevesoft/pat/Prop.java index b6490a6..127e44a 100755 --- a/src/com/stevesoft/pat/Prop.java +++ b/src/com/stevesoft/pat/Prop.java @@ -1,73 +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/src/com/stevesoft/pat/Pthings.java b/src/com/stevesoft/pat/Pthings.java index 84e327b..69e8fed 100755 --- a/src/com/stevesoft/pat/Pthings.java +++ b/src/com/stevesoft/pat/Pthings.java @@ -1,35 +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/src/com/stevesoft/pat/PushRule.java b/src/com/stevesoft/pat/PushRule.java index 3fbfe14..c9aee2b 100755 --- a/src/com/stevesoft/pat/PushRule.java +++ b/src/com/stevesoft/pat/PushRule.java @@ -1,47 +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/src/com/stevesoft/pat/RBuffer.java b/src/com/stevesoft/pat/RBuffer.java index 44657af..7970a1a 100755 --- a/src/com/stevesoft/pat/RBuffer.java +++ b/src/com/stevesoft/pat/RBuffer.java @@ -1,47 +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; - StringBuffer sb; - int pos, epos; - RBuffer next; - RBuffer() - {} - - RBuffer(StringBuffer 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 ""; - } - StringBuffer sb = new StringBuffer(n); - for (int i = 0; i < n; i++) - { - sb.append(' '); - } - 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; + + StringBuffer sb; + + int pos, epos; + + RBuffer next; + + RBuffer() + { + } + + RBuffer(StringBuffer 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 ""; + } + StringBuffer sb = new StringBuffer(n); + for (int i = 0; i < n; i++) + { + sb.append(' '); + } + return sb.toString(); + } +} diff --git a/src/com/stevesoft/pat/Range.java b/src/com/stevesoft/pat/Range.java index 5b740cd..610a4d5 100755 --- a/src/com/stevesoft/pat/Range.java +++ b/src/com/stevesoft/pat/Range.java @@ -1,98 +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/src/com/stevesoft/pat/RegOpt.java b/src/com/stevesoft/pat/RegOpt.java index f70df39..0d65139 100755 --- a/src/com/stevesoft/pat/RegOpt.java +++ b/src/com/stevesoft/pat/RegOpt.java @@ -1,469 +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() - { - StringBuffer sb = new StringBuffer(); - // should protect this... - sb.append("(?:(?#branch)"); // Hashtable)"); - for (int i = 0; i < keys.size(); i++) - { - Character c = (Character) keys.elementAt(i); - sb.append(c); - sb.append(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() + { + StringBuffer sb = new StringBuffer(); + // should protect this... + sb.append("(?:(?#branch)"); // Hashtable)"); + for (int i = 0; i < keys.size(); i++) + { + Character c = (Character) keys.elementAt(i); + sb.append(c); + sb.append(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() - { - StringBuffer sb = new StringBuffer(); - 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() + { + StringBuffer sb = new StringBuffer(); + 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/src/com/stevesoft/pat/RegSyntax.java b/src/com/stevesoft/pat/RegSyntax.java index ac47c1a..635dc4c 100755 --- a/src/com/stevesoft/pat/RegSyntax.java +++ b/src/com/stevesoft/pat/RegSyntax.java @@ -1,29 +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/src/com/stevesoft/pat/RegSyntaxError.java b/src/com/stevesoft/pat/RegSyntaxError.java index 688c906..1e56122 100755 --- a/src/com/stevesoft/pat/RegSyntaxError.java +++ b/src/com/stevesoft/pat/RegSyntaxError.java @@ -1,42 +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/src/com/stevesoft/pat/Regex.java b/src/com/stevesoft/pat/Regex.java index 2b38ee7..04bb0da 100755 --- a/src/com/stevesoft/pat/Regex.java +++ b/src/com/stevesoft/pat/Regex.java @@ -1,2029 +1,2085 @@ -// -// 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 java.util.*; - -import com.stevesoft.pat.wrap.*; - -/** 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 = ReplaceRule.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 = ReplaceRule.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 = _compile(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("Null String Given to Regex.search"); - } - return _search(s, 0, s.length()); - } - - public boolean search(StringLike sl) - { - if (sl == null) - { - throw new NullPointerException("Null StringLike Given to Regex.search"); - } - return _search(sl, 0, sl.length()); - } - - public boolean reverseSearch(String s) - { - if (s == null) - { - throw new NullPointerException("Null String Given to Regex.reverseSearch"); - } - return _reverseSearch(s, 0, s.length()); - } - - public boolean reverseSearch(StringLike sl) - { - if (sl == null) - { - throw new NullPointerException( - "Null StringLike Given to Regex.reverseSearch"); - } - 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("Null String Given to Regex.searchFrom"); - } - return _search(s, start, s.length()); - } - - public boolean searchFrom(StringLike s, int start) - { - if (s == null) - { - throw new NullPointerException("Null String Given to Regex.searchFrom"); - } - 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("Null String Given to Regex.searchRegion"); - } - 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._compile("(?!" + 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("(??")) - { - StringBuffer sb = new StringBuffer(); - StringBuffer 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(); - } - } - 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._compile(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._compile(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._compile(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); - //StringBuffer sb = new StringBuffer(); - 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 _compile(String pat, Rthings mk) - throws RegSyntax - { - minMatch = null; - sFlag = mFlag = ignoreCase = gFlag = false; - StrPos sp = new StrPos(pat, 0); - thePattern = _compile(sp, mk); - pt.marks = null; - return thePattern; - } - - Pattern p = null; - Or or = null; - Pattern _compile(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 - { - StringBuffer sb = new StringBuffer(); - if (esc != Pattern.ESC) - { - sb.append("(?e="); - sb.append(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; - StringBuffer 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(); - } - - /** 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 java.io.*; +import java.util.*; + +import com.stevesoft.pat.wrap.*; + +/** 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 = ReplaceRule.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 = ReplaceRule.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 = _compile(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("Null String Given to Regex.search"); + } + return _search(s, 0, s.length()); + } + + public boolean search(StringLike sl) + { + if (sl == null) + { + throw new NullPointerException( + "Null StringLike Given to Regex.search"); + } + return _search(sl, 0, sl.length()); + } + + public boolean reverseSearch(String s) + { + if (s == null) + { + throw new NullPointerException( + "Null String Given to Regex.reverseSearch"); + } + return _reverseSearch(s, 0, s.length()); + } + + public boolean reverseSearch(StringLike sl) + { + if (sl == null) + { + throw new NullPointerException( + "Null StringLike Given to Regex.reverseSearch"); + } + 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( + "Null String Given to Regex.searchFrom"); + } + return _search(s, start, s.length()); + } + + public boolean searchFrom(StringLike s, int start) + { + if (s == null) + { + throw new NullPointerException( + "Null String Given to Regex.searchFrom"); + } + 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( + "Null String Given to Regex.searchRegion"); + } + 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._compile("(?!" + 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("(??")) + { + StringBuffer sb = new StringBuffer(); + StringBuffer 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(); + } + } + 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._compile(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._compile(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._compile(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); + // StringBuffer sb = new StringBuffer(); + 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 _compile(String pat, Rthings mk) throws RegSyntax + { + minMatch = null; + sFlag = mFlag = ignoreCase = gFlag = false; + StrPos sp = new StrPos(pat, 0); + thePattern = _compile(sp, mk); + pt.marks = null; + return thePattern; + } + + Pattern p = null; + + Or or = null; + + Pattern _compile(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 + { + StringBuffer sb = new StringBuffer(); + if (esc != Pattern.ESC) + { + sb.append("(?e="); + sb.append(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; + StringBuffer 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(); + } + + /** + * 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/src/com/stevesoft/pat/RegexReader.java b/src/com/stevesoft/pat/RegexReader.java index 6475dfe..2e10f16 100755 --- a/src/com/stevesoft/pat/RegexReader.java +++ b/src/com/stevesoft/pat/RegexReader.java @@ -1,325 +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 StringBuffer()); - 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 StringBuffer()); - wrap = new PartialBuffer(rb.sb); - moreToRead = true; - } - - void readData() - throws IOException - { - int c; - int n = 0; - while ( (c = r.read()) != -1) - { - rb.sb.append( (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( (StringBuffer) 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; - StringBuffer sb = new StringBuffer(); - 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 StringBuffer()); + + 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 StringBuffer()); + wrap = new PartialBuffer(rb.sb); + moreToRead = true; + } + + void readData() throws IOException + { + int c; + int n = 0; + while ((c = r.read()) != -1) + { + rb.sb.append((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((StringBuffer) 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; + * StringBuffer sb = new StringBuffer(); 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/src/com/stevesoft/pat/RegexTokenizer.java b/src/com/stevesoft/pat/RegexTokenizer.java index 76fa005..0378f3a 100755 --- a/src/com/stevesoft/pat/RegexTokenizer.java +++ b/src/com/stevesoft/pat/RegexTokenizer.java @@ -1,161 +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/src/com/stevesoft/pat/RegexWriter.java b/src/com/stevesoft/pat/RegexWriter.java index bcfbd5b..a8c3e50 100755 --- a/src/com/stevesoft/pat/RegexWriter.java +++ b/src/com/stevesoft/pat/RegexWriter.java @@ -1,267 +1,276 @@ -// -// 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.*; - -/** 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 StringBuffer -- 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; - StringBuffer sb = new StringBuffer(); - 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 - */ - public char getEOLchar() - { - return EOLchar; - } - - /** This method no longer serves any purpose. - @deprecated - */ - public void setEOLchar(char c) - { - EOLchar = c; - } - - int max_lines = 2; - /** This method no longer serves any purpose. - @deprecated - */ - public int getMaxLines() - { - return max_lines; - } - - /** This method no longer serves any purpose. - @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) - { - 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.append(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 StringBuffer 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; - } - - static void test(String re, String inp, int n) - throws Exception - { - StringWriter sw = new StringWriter(); - Regex rex = Regex.perlCode(re); - String res1 = rex.replaceAll(inp); - RegexWriter rw = new RegexWriter(rex, sw); - for (int i = 0; i < inp.length(); i++) - { - rw.write(inp.charAt(i)); - } - rw.close(); - String res2 = sw.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 = 1; n <= 1; 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.*; + +/** + * 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 + * StringBuffer -- 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; + + StringBuffer sb = new StringBuffer(); + + 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 + */ + public char getEOLchar() + { + return EOLchar; + } + + /** + * This method no longer serves any purpose. + * + * @deprecated + */ + public void setEOLchar(char c) + { + EOLchar = c; + } + + int max_lines = 2; + + /** + * This method no longer serves any purpose. + * + * @deprecated + */ + public int getMaxLines() + { + return max_lines; + } + + /** + * This method no longer serves any purpose. + * + * @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) + { + 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.append(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 StringBuffer 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; + } + + static void test(String re, String inp, int n) throws Exception + { + StringWriter sw = new StringWriter(); + Regex rex = Regex.perlCode(re); + String res1 = rex.replaceAll(inp); + RegexWriter rw = new RegexWriter(rex, sw); + for (int i = 0; i < inp.length(); i++) + { + rw.write(inp.charAt(i)); + } + rw.close(); + String res2 = sw.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 = 1; n <= 1; 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/src/com/stevesoft/pat/ReplaceRule.java b/src/com/stevesoft/pat/ReplaceRule.java index d4f09bb..bf56143 100755 --- a/src/com/stevesoft/pat/ReplaceRule.java +++ b/src/com/stevesoft/pat/ReplaceRule.java @@ -1,398 +1,400 @@ -// -// 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.*; - -/** 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 StringBuffer 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; - } - - /** 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 = getv(); - ReplaceRule head = null; - Object tmp = null; - while (gv.searchFrom(s, mt)) - { - int off = Regex.BackRefOffset - 1; - mf = gv.matchedFrom(); - if (mf > mt) - { - head = 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 = 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 = add(head, new CodeRule(var.charAt(0))); - } - else - { - head = 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 = add(head, new AmpersandRule()); - } - else if (var.equals("`") || var.equals("PREMATCH")) - { - head = add(head, new LeftRule()); - } - else if (var.equals("'") || var.equals("POSTMATCH")) - { - head = add(head, new RightRule()); - } - else if (var.equals("WANT_MORE_TEXT")) - { - head = add(head, new WantMoreTextReplaceRule()); - } - else if (var.equals("POP")) - { - head = add(head, new PopRule()); - } - else if (var.startsWith("+") && (tmp = defs.get(var.substring(1))) != null) - { - if (tmp instanceof Regex) - { - head = add(head, new PushRule(var.substring(1), (Regex) tmp)); - } - else if (tmp instanceof Transformer) - { - head = add(head, new PushRule(var.substring(1), (Transformer) tmp)); - } - else - { - head = add(head, new StringRule("${" + var + "}")); - } - } - else if (var.startsWith("=") && (tmp = defs.get(var.substring(1))) != null) - { - if (tmp instanceof Regex) - { - head = add(head, new ChangeRule(var.substring(1), (Regex) tmp)); - } - else if (tmp instanceof Transformer) - { - head = add(head, - new ChangeRule(var.substring(1), (Transformer) tmp)); - } - else - { - head = add(head, new StringRule("${" + var + "}")); - } - } - else if ( (tmp = defs.get(var)) != null) - { - if (tmp instanceof ReplaceRule) - { - ReplaceRule alt = ( (ReplaceRule) tmp).arg(arg); - if (alt == null) - { - alt = ( (ReplaceRule) tmp); - } - head = add(head, (ReplaceRule) (alt.clone())); - } - } - else // can't figure out how to transform this thing... - { - head = add(head, new StringRule("${" + var + "}")); - } - } - else if ( - (var = gv.stringMatched(7 + off)) != null) - { - char c = var.charAt(0); - if (c == 'n') - { - head = add(head, new StringRule("\n")); - } - else if (c == 't') - { - head = add(head, new StringRule("\t")); - } - else if (c == 'r') - { - head = add(head, new StringRule("\r")); - } - else if (c == 'b') - { - head = add(head, new StringRule("\r")); - } - else if (c == 'a') - { - head = add(head, new StringRule("" + (char) 7)); - } - else if (c == 'e') - { - head = add(head, new StringRule("" + (char) 27)); - } - else if (c == 'f') - { - head = 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 = add(head, new StringRule("" + c)); - } - else if ( - (var = gv.stringMatched(9 + off)) != null) - { - int d = - 16 * getHexDigit(var.charAt(0)) + - getHexDigit(var.charAt(1)); - head = add(head, new StringRule("" + (char) d)); - } - mt = gv.matchedTo(); - } - if (mt <= s.length()) - { - head = add(head, new StringRule(s.substring(mt))); - } - return head; - } - finally - { - //Regex.backGs = sav_backGs; - //Regex.backGto = sav_backGto; - } - } - - 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() - { - StringBuffer sb = new StringBuffer(); - 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.*; + +/** + * 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 StringBuffer 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; + } + + /** + * 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 = getv(); + ReplaceRule head = null; + Object tmp = null; + while (gv.searchFrom(s, mt)) + { + int off = Regex.BackRefOffset - 1; + mf = gv.matchedFrom(); + if (mf > mt) + { + head = 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 = 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 = add(head, new CodeRule(var.charAt(0))); + } + else + { + head = 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 = add(head, new AmpersandRule()); + } + else if (var.equals("`") || var.equals("PREMATCH")) + { + head = add(head, new LeftRule()); + } + else if (var.equals("'") || var.equals("POSTMATCH")) + { + head = add(head, new RightRule()); + } + else if (var.equals("WANT_MORE_TEXT")) + { + head = add(head, new WantMoreTextReplaceRule()); + } + else if (var.equals("POP")) + { + head = add(head, new PopRule()); + } + else if (var.startsWith("+") + && (tmp = defs.get(var.substring(1))) != null) + { + if (tmp instanceof Regex) + { + head = add(head, new PushRule(var.substring(1), (Regex) tmp)); + } + else if (tmp instanceof Transformer) + { + head = add(head, new PushRule(var.substring(1), + (Transformer) tmp)); + } + else + { + head = add(head, new StringRule("${" + var + "}")); + } + } + else if (var.startsWith("=") + && (tmp = defs.get(var.substring(1))) != null) + { + if (tmp instanceof Regex) + { + head = add(head, + new ChangeRule(var.substring(1), (Regex) tmp)); + } + else if (tmp instanceof Transformer) + { + head = add(head, new ChangeRule(var.substring(1), + (Transformer) tmp)); + } + else + { + head = add(head, new StringRule("${" + var + "}")); + } + } + else if ((tmp = defs.get(var)) != null) + { + if (tmp instanceof ReplaceRule) + { + ReplaceRule alt = ((ReplaceRule) tmp).arg(arg); + if (alt == null) + { + alt = ((ReplaceRule) tmp); + } + head = add(head, (ReplaceRule) (alt.clone())); + } + } + else + // can't figure out how to transform this thing... + { + head = add(head, new StringRule("${" + var + "}")); + } + } + else if ((var = gv.stringMatched(7 + off)) != null) + { + char c = var.charAt(0); + if (c == 'n') + { + head = add(head, new StringRule("\n")); + } + else if (c == 't') + { + head = add(head, new StringRule("\t")); + } + else if (c == 'r') + { + head = add(head, new StringRule("\r")); + } + else if (c == 'b') + { + head = add(head, new StringRule("\r")); + } + else if (c == 'a') + { + head = add(head, new StringRule("" + (char) 7)); + } + else if (c == 'e') + { + head = add(head, new StringRule("" + (char) 27)); + } + else if (c == 'f') + { + head = 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 = add(head, new StringRule("" + c)); + } + else if ((var = gv.stringMatched(9 + off)) != null) + { + int d = 16 * getHexDigit(var.charAt(0)) + + getHexDigit(var.charAt(1)); + head = add(head, new StringRule("" + (char) d)); + } + mt = gv.matchedTo(); + } + if (mt <= s.length()) + { + head = add(head, new StringRule(s.substring(mt))); + } + return head; + } finally + { + // Regex.backGs = sav_backGs; + // Regex.backGto = sav_backGto; + } + } + + 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() + { + StringBuffer sb = new StringBuffer(); + 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/src/com/stevesoft/pat/Replacer.java b/src/com/stevesoft/pat/Replacer.java index 77570f9..062a548 100755 --- a/src/com/stevesoft/pat/Replacer.java +++ b/src/com/stevesoft/pat/Replacer.java @@ -1,357 +1,367 @@ -// -// 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.*; - -/** 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("Replacer has 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.append(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.append(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 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("Replacer has 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.append(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.append(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/src/com/stevesoft/pat/RightRule.java b/src/com/stevesoft/pat/RightRule.java index c27d2e4..cddcb4a 100755 --- a/src/com/stevesoft/pat/RightRule.java +++ b/src/com/stevesoft/pat/RightRule.java @@ -1,29 +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.append(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.append(res.right()); + } + + public String toString1() + { + return "$'"; + } +} diff --git a/src/com/stevesoft/pat/Rthings.java b/src/com/stevesoft/pat/Rthings.java index 4c4db39..58afe8e 100755 --- a/src/com/stevesoft/pat/Rthings.java +++ b/src/com/stevesoft/pat/Rthings.java @@ -1,52 +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/src/com/stevesoft/pat/RuleHolder.java b/src/com/stevesoft/pat/RuleHolder.java index 9b8017d..8b50149 100755 --- a/src/com/stevesoft/pat/RuleHolder.java +++ b/src/com/stevesoft/pat/RuleHolder.java @@ -1,42 +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/src/com/stevesoft/pat/Skip.java b/src/com/stevesoft/pat/Skip.java index 16aada1..d3f3822 100755 --- a/src/com/stevesoft/pat/Skip.java +++ b/src/com/stevesoft/pat/Skip.java @@ -1,186 +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) - { - StringBuffer sb = new StringBuffer(); - 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.append( ( (oneChar) p).c); - while (p.next instanceof oneChar) - { - sb.append( ( (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) + { + StringBuffer sb = new StringBuffer(); + 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.append(((oneChar) p).c); + while (p.next instanceof oneChar) + { + sb.append(((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/src/com/stevesoft/pat/Skip2.java b/src/com/stevesoft/pat/Skip2.java index ca1c5a8..5f6bb5a 100755 --- a/src/com/stevesoft/pat/Skip2.java +++ b/src/com/stevesoft/pat/Skip2.java @@ -1,55 +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/src/com/stevesoft/pat/SkipBMH.java b/src/com/stevesoft/pat/SkipBMH.java index 632418e..1397b90 100755 --- a/src/com/stevesoft/pat/SkipBMH.java +++ b/src/com/stevesoft/pat/SkipBMH.java @@ -1,271 +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/src/com/stevesoft/pat/Skipped.java b/src/com/stevesoft/pat/Skipped.java index 9bf2837..551166b 100755 --- a/src/com/stevesoft/pat/Skipped.java +++ b/src/com/stevesoft/pat/Skipped.java @@ -1,54 +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/src/com/stevesoft/pat/SpecialRule.java b/src/com/stevesoft/pat/SpecialRule.java index fbae452..2a249a2 100755 --- a/src/com/stevesoft/pat/SpecialRule.java +++ b/src/com/stevesoft/pat/SpecialRule.java @@ -1,18 +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/src/com/stevesoft/pat/Start.java b/src/com/stevesoft/pat/Start.java index c47ee53..650e7a7 100755 --- a/src/com/stevesoft/pat/Start.java +++ b/src/com/stevesoft/pat/Start.java @@ -1,58 +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/src/com/stevesoft/pat/StrPos.java b/src/com/stevesoft/pat/StrPos.java index d9383dd..1f08e31 100755 --- a/src/com/stevesoft/pat/StrPos.java +++ b/src/com/stevesoft/pat/StrPos.java @@ -1,175 +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/src/com/stevesoft/pat/StringBufferLike.java b/src/com/stevesoft/pat/StringBufferLike.java index 96d2178..d125758 100755 --- a/src/com/stevesoft/pat/StringBufferLike.java +++ b/src/com/stevesoft/pat/StringBufferLike.java @@ -1,90 +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 append(char c) - { - - switch (mode) - { - case 'u': - mode = altMode; - altMode = ' '; - case 'U': - sbl.append(CaseMgr.toUpperCase(c)); - break; - case 'l': - mode = altMode; - altMode = ' '; - case 'L': - sbl.append(CaseMgr.toLowerCase(c)); - break; - case 'Q': - if ( (c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9')) - { - ; - } - else - { - sbl.append('\\'); - } - default: - sbl.append(c); - break; - } - } - - public void append(String s) - { - for (int i = 0; i < s.length(); i++) - { - append(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 append(char c) + { + + switch (mode) + { + case 'u': + mode = altMode; + altMode = ' '; + case 'U': + sbl.append(CaseMgr.toUpperCase(c)); + break; + case 'l': + mode = altMode; + altMode = ' '; + case 'L': + sbl.append(CaseMgr.toLowerCase(c)); + break; + case 'Q': + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9')) + { + ; + } + else + { + sbl.append('\\'); + } + default: + sbl.append(c); + break; + } + } + + public void append(String s) + { + for (int i = 0; i < s.length(); i++) + { + append(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/src/com/stevesoft/pat/StringLike.java b/src/com/stevesoft/pat/StringLike.java index 07bc441..be98ff3 100755 --- a/src/com/stevesoft/pat/StringLike.java +++ b/src/com/stevesoft/pat/StringLike.java @@ -1,44 +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/src/com/stevesoft/pat/StringRule.java b/src/com/stevesoft/pat/StringRule.java index e831a14..10557d8 100755 --- a/src/com/stevesoft/pat/StringRule.java +++ b/src/com/stevesoft/pat/StringRule.java @@ -1,37 +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.append(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.append(s); + } + + public String toString1() + { + return s; + } + + public Object clone1() + { + return new StringRule(s); + } +} diff --git a/src/com/stevesoft/pat/SubMark.java b/src/com/stevesoft/pat/SubMark.java index 16c3306..245fa6c 100755 --- a/src/com/stevesoft/pat/SubMark.java +++ b/src/com/stevesoft/pat/SubMark.java @@ -1,31 +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/src/com/stevesoft/pat/TransPat.java b/src/com/stevesoft/pat/TransPat.java index 4c71c1f..b9a0989 100755 --- a/src/com/stevesoft/pat/TransPat.java +++ b/src/com/stevesoft/pat/TransPat.java @@ -1,45 +1,51 @@ -// -// 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/src/com/stevesoft/pat/Transformer.java b/src/com/stevesoft/pat/Transformer.java index 843fbfa..d770f08 100755 --- a/src/com/stevesoft/pat/Transformer.java +++ b/src/com/stevesoft/pat/Transformer.java @@ -1,219 +1,233 @@ -// -// 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.*; - -/** 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("bad pattern to Regex.perlCode: " + 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 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("bad pattern to Regex.perlCode: " + 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/src/com/stevesoft/pat/UniValidator.java b/src/com/stevesoft/pat/UniValidator.java index 4d86074..31ae272 100755 --- a/src/com/stevesoft/pat/UniValidator.java +++ b/src/com/stevesoft/pat/UniValidator.java @@ -1,25 +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/src/com/stevesoft/pat/Validator.java b/src/com/stevesoft/pat/Validator.java index 34b07da..dbedca5 100755 --- a/src/com/stevesoft/pat/Validator.java +++ b/src/com/stevesoft/pat/Validator.java @@ -1,70 +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/src/com/stevesoft/pat/WantMoreTextReplaceRule.java b/src/com/stevesoft/pat/WantMoreTextReplaceRule.java index 34b73e5..6c0ddeb 100755 --- a/src/com/stevesoft/pat/WantMoreTextReplaceRule.java +++ b/src/com/stevesoft/pat/WantMoreTextReplaceRule.java @@ -1,28 +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/src/com/stevesoft/pat/lookAhead.java b/src/com/stevesoft/pat/lookAhead.java index 73be36a..d7d71c3 100755 --- a/src/com/stevesoft/pat/lookAhead.java +++ b/src/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/src/com/stevesoft/pat/oneChar.java b/src/com/stevesoft/pat/oneChar.java index da7c6d0..ebbe991 100755 --- a/src/com/stevesoft/pat/oneChar.java +++ b/src/com/stevesoft/pat/oneChar.java @@ -1,75 +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/src/com/stevesoft/pat/parsePerl.java b/src/com/stevesoft/pat/parsePerl.java index 5de9f07..0d1f14e 100755 --- a/src/com/stevesoft/pat/parsePerl.java +++ b/src/com/stevesoft/pat/parsePerl.java @@ -1,379 +1,373 @@ -// -// 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) - { - StringBuffer sb = new StringBuffer(); - 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.append('\\'); - } - 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.append('\\'); - } - sb.append(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; - - StringBuffer s1 = new StringBuffer(); - StringBuffer s2 = new StringBuffer(); - 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.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() && 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.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++) - { - 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(ReplaceRule.perlCode(reprul)); - } - } - catch (RegSyntax rs) - { - r = null; - } - return r; - } - - static String strip(String s) - { - StringBuffer sb = new StringBuffer(); - 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.append(c); - sb.append(s.charAt(++i)); - } - else - { - sb.append(c); - } - } - 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 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) + { + StringBuffer sb = new StringBuffer(); + 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.append('\\'); + } + 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.append('\\'); + } + sb.append(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; + + StringBuffer s1 = new StringBuffer(); + StringBuffer s2 = new StringBuffer(); + 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.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() && 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.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++) + { + 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(ReplaceRule.perlCode(reprul)); + } + } catch (RegSyntax rs) + { + r = null; + } + return r; + } + + static String strip(String s) + { + StringBuffer sb = new StringBuffer(); + 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.append(c); + sb.append(s.charAt(++i)); + } + else + { + sb.append(c); + } + } + return sb.toString(); + } +} diff --git a/src/com/stevesoft/pat/patInf.java b/src/com/stevesoft/pat/patInf.java index 28580e2..cbdbf9e 100755 --- a/src/com/stevesoft/pat/patInf.java +++ b/src/com/stevesoft/pat/patInf.java @@ -1,17 +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/src/com/stevesoft/pat/patInt.java b/src/com/stevesoft/pat/patInt.java index f997a52..df0d028 100755 --- a/src/com/stevesoft/pat/patInt.java +++ b/src/com/stevesoft/pat/patInt.java @@ -1,171 +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/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java b/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java index 19f268e..c014a57 100755 --- a/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java +++ b/src/com/stevesoft/pat/wrap/CharArrayBufferWrap.java @@ -1,53 +1,54 @@ -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.*; - -/** Allows the outcome of a replaceAll() or replaceFirst() - to be an array of characters rather than a String. - */ -public class CharArrayBufferWrap - implements BasicStringBufferLike -{ - StringBuffer sb = new StringBuffer(); - public void append(char c) - { - sb.append(c); - } - - public void append(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); - } - return new CharArrayWrap(ca); - } - - 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.*; + +/** + * Allows the outcome of a replaceAll() or replaceFirst() to be an array of + * characters rather than a String. + */ +public class CharArrayBufferWrap implements BasicStringBufferLike +{ + StringBuffer sb = new StringBuffer(); + + public void append(char c) + { + sb.append(c); + } + + public void append(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); + } + return new CharArrayWrap(ca); + } + + public int length() + { + return sb.length(); + } + + public String toString() + { + return sb.toString(); + } + + public Object unwrap() + { + return sb; + } +} diff --git a/src/com/stevesoft/pat/wrap/CharArrayWrap.java b/src/com/stevesoft/pat/wrap/CharArrayWrap.java index 6de78cf..bde9bd1 100755 --- a/src/com/stevesoft/pat/wrap/CharArrayWrap.java +++ b/src/com/stevesoft/pat/wrap/CharArrayWrap.java @@ -1,74 +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.wrap; - -import com.stevesoft.pat.*; - -/** 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) - { - StringBuffer sb = new StringBuffer(); - for (int i = i1; i < i2; i++) - { - sb.append(ca[i]); - } - return sb.toString(); - } - - public Object unwrap() - { - return ca; - } - - public BasicStringBufferLike newStringBufferLike() - { - return new CharArrayBufferWrap(); - } - - 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.*; + +/** + * 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) + { + StringBuffer sb = new StringBuffer(); + for (int i = i1; i < i2; i++) + { + sb.append(ca[i]); + } + return sb.toString(); + } + + public Object unwrap() + { + return ca; + } + + public BasicStringBufferLike newStringBufferLike() + { + return new CharArrayBufferWrap(); + } + + public int indexOf(char c) + { + for (int i = 0; i < ca.length; i++) + { + if (ca[i] == c) + { + return i; + } + } + return -1; + } +} diff --git a/src/com/stevesoft/pat/wrap/RandomAccessFileWrap.java b/src/com/stevesoft/pat/wrap/RandomAccessFileWrap.java index 90e7691..b4d38dc 100755 --- a/src/com/stevesoft/pat/wrap/RandomAccessFileWrap.java +++ b/src/com/stevesoft/pat/wrap/RandomAccessFileWrap.java @@ -1,173 +1,170 @@ -// -// 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.*; - -/** Provides a wrapper for a RandomAccessFile so that it - can be searched by Regex. */ -public class RandomAccessFileWrap - implements StringLike -{ - - long offset = 0; - public void setOffset(long o) - { - offset = o; - i0 = iend = 0; - } - - public long getOffset() - { - return offset; - } - - RandomAccessFile raf; - int i0 = 0, iend = 0; - byte[] buf = new byte[1024]; - - public int getBufferSize() - { - return buf.length; - } - - public void setBufferSize(int bs) - { - buf = new byte[bs]; - i0 = iend = 0; - } - - public RandomAccessFileWrap(String file) - throws IOException - { - this.raf = new RandomAccessFile(file, "r"); - } - - public RandomAccessFileWrap(RandomAccessFile raf) - { - this.raf = raf; - } - - public char charAt(int i) - { - if (i >= i0 && i < iend) - { - return (char) buf[i - i0]; - } - - try - { - i0 = i - 5; - //if(i0+offset<0) i0=(int)(-offset); - if (i0 < 0) - { - i0 = 0; - } - raf.seek(i0 + offset); - iend = i0 + raf.read(buf, 0, buf.length); - - if (i >= i0 && i < iend) - { - return (char) buf[i - i0]; - } - } - catch (Throwable t) - {} - - throw new ArrayIndexOutOfBoundsException("Out of bounds for file:" + - " i=" + i + - ", Final Buffer: i0=" + i0 + - " iend=" + iend); - } - - public String toString() - { - throw new Error("Not implemented"); - } - - public int length() - { - try - { - long len = raf.length() - offset; - if (len > Integer.MAX_VALUE) - { - return Integer.MAX_VALUE; - } - return (int) len; - } - catch (IOException ioe) - { - return 0; - } - } - - public String substring(int i1, int i2) - { - StringBuffer sb = new StringBuffer(); - for (int i = i1; i < i2; i++) - { - sb.append(charAt(i)); - } - return sb.toString(); - } - - public Object unwrap() - { - return raf; - } - - public static void main(String[] files) - throws IOException - { - for (int i = 0; i < files.length; i++) - { - RandomAccessFileWrap fw = - new RandomAccessFileWrap(new RandomAccessFile(files[i], "r")); - Regex r = new Regex("toString\\(\\) *(?@{})"); - r.setGFlag(true); - r.optimize(); - System.out.print(files[i] + " "); - int j = 0; - do - { - if (r.searchFrom(fw, j)) - { - System.out.println("Matched at index: " + - r.matchedFrom()); - j = r.matchedTo(); - } - else - { - System.out.println("not found"); - } - System.out.println(r.stringMatched()); - } - while (r.didMatch()); - } - } - - public BasicStringBufferLike newStringBufferLike() - { - return new StringBufferWrap(); - } - - public int indexOf(char c) - { - for (int i = 0; i < length(); i++) - { - if (charAt(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 java.io.*; + +import com.stevesoft.pat.*; + +/** + * Provides a wrapper for a RandomAccessFile so that it can be searched by + * Regex. + */ +public class RandomAccessFileWrap implements StringLike +{ + + long offset = 0; + + public void setOffset(long o) + { + offset = o; + i0 = iend = 0; + } + + public long getOffset() + { + return offset; + } + + RandomAccessFile raf; + + int i0 = 0, iend = 0; + + byte[] buf = new byte[1024]; + + public int getBufferSize() + { + return buf.length; + } + + public void setBufferSize(int bs) + { + buf = new byte[bs]; + i0 = iend = 0; + } + + public RandomAccessFileWrap(String file) throws IOException + { + this.raf = new RandomAccessFile(file, "r"); + } + + public RandomAccessFileWrap(RandomAccessFile raf) + { + this.raf = raf; + } + + public char charAt(int i) + { + if (i >= i0 && i < iend) + { + return (char) buf[i - i0]; + } + + try + { + i0 = i - 5; + // if(i0+offset<0) i0=(int)(-offset); + if (i0 < 0) + { + i0 = 0; + } + raf.seek(i0 + offset); + iend = i0 + raf.read(buf, 0, buf.length); + + if (i >= i0 && i < iend) + { + return (char) buf[i - i0]; + } + } catch (Throwable t) + { + } + + throw new ArrayIndexOutOfBoundsException("Out of bounds for file:" + + " i=" + i + ", Final Buffer: i0=" + i0 + " iend=" + iend); + } + + public String toString() + { + throw new Error("Not implemented"); + } + + public int length() + { + try + { + long len = raf.length() - offset; + if (len > Integer.MAX_VALUE) + { + return Integer.MAX_VALUE; + } + return (int) len; + } catch (IOException ioe) + { + return 0; + } + } + + public String substring(int i1, int i2) + { + StringBuffer sb = new StringBuffer(); + for (int i = i1; i < i2; i++) + { + sb.append(charAt(i)); + } + return sb.toString(); + } + + public Object unwrap() + { + return raf; + } + + public static void main(String[] files) throws IOException + { + for (int i = 0; i < files.length; i++) + { + RandomAccessFileWrap fw = new RandomAccessFileWrap( + new RandomAccessFile(files[i], "r")); + Regex r = new Regex("toString\\(\\) *(?@{})"); + r.setGFlag(true); + r.optimize(); + System.out.print(files[i] + " "); + int j = 0; + do + { + if (r.searchFrom(fw, j)) + { + System.out.println("Matched at index: " + r.matchedFrom()); + j = r.matchedTo(); + } + else + { + System.out.println("not found"); + } + System.out.println(r.stringMatched()); + } while (r.didMatch()); + } + } + + public BasicStringBufferLike newStringBufferLike() + { + return new StringBufferWrap(); + } + + public int indexOf(char c) + { + for (int i = 0; i < length(); i++) + { + if (charAt(i) == c) + { + return i; + } + } + return -1; + } +} diff --git a/src/com/stevesoft/pat/wrap/StringBufferWrap.java b/src/com/stevesoft/pat/wrap/StringBufferWrap.java index 40ddd65..d522461 100755 --- a/src/com/stevesoft/pat/wrap/StringBufferWrap.java +++ b/src/com/stevesoft/pat/wrap/StringBufferWrap.java @@ -1,47 +1,49 @@ -// -// 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 StringBuffer to - capture the output of a replacement. */ -public class StringBufferWrap - implements BasicStringBufferLike -{ - StringBuffer sb = new StringBuffer(); - public void append(char c) - { - sb.append(c); - } - - public void append(String s) - { - sb.append(s); - } - - public int length() - { - return sb.length(); - } - - public String toString() - { - return sb.toString(); - } - - public StringLike toStringLike() - { - return new StringWrap(sb.toString()); - } - - 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 StringBuffer to capture the output of a + * replacement. + */ +public class StringBufferWrap implements BasicStringBufferLike +{ + StringBuffer sb = new StringBuffer(); + + public void append(char c) + { + sb.append(c); + } + + public void append(String s) + { + sb.append(s); + } + + public int length() + { + return sb.length(); + } + + public String toString() + { + return sb.toString(); + } + + public StringLike toStringLike() + { + return new StringWrap(sb.toString()); + } + + public Object unwrap() + { + return sb; + } +} diff --git a/src/com/stevesoft/pat/wrap/StringWrap.java b/src/com/stevesoft/pat/wrap/StringWrap.java index a53d18e..3ddf7c5 100755 --- a/src/com/stevesoft/pat/wrap/StringWrap.java +++ b/src/com/stevesoft/pat/wrap/StringWrap.java @@ -1,57 +1,59 @@ -// -// 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.*; - -/** 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() - { - return new StringBufferWrap(); - } - - 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.*; + +/** + * 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() + { + return new StringBufferWrap(); + } + + public int indexOf(char c) + { + return s.indexOf(c); + } +} diff --git a/src/com/stevesoft/pat/wrap/WriterWrap.java b/src/com/stevesoft/pat/wrap/WriterWrap.java index 1b7f6c2..e72b5fa 100755 --- a/src/com/stevesoft/pat/wrap/WriterWrap.java +++ b/src/com/stevesoft/pat/wrap/WriterWrap.java @@ -1,59 +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 append(char c) - { - try - { - w.write( (int) c); - } - catch (IOException ioe) - {} - } - - public void append(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 append(char c) + { + try + { + w.write((int) c); + } catch (IOException ioe) + { + } + } + + public void append(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; + } +} diff --git a/src/ext/vamsas/IRegistry.java b/src/ext/vamsas/IRegistry.java index 9300f59..9b91b5d 100755 --- a/src/ext/vamsas/IRegistry.java +++ b/src/ext/vamsas/IRegistry.java @@ -1,15 +1,25 @@ -/** - * IRegistry.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public interface IRegistry - extends java.rmi.Remote +public interface IRegistry extends java.rmi.Remote { public ext.vamsas.ServiceHandles getServices() - throws java.rmi.RemoteException; + throws java.rmi.RemoteException; } diff --git a/src/ext/vamsas/IRegistryService.java b/src/ext/vamsas/IRegistryService.java index 2590314..c99414d 100755 --- a/src/ext/vamsas/IRegistryService.java +++ b/src/ext/vamsas/IRegistryService.java @@ -1,20 +1,30 @@ -/** - * IRegistryService.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public interface IRegistryService - extends javax.xml.rpc.Service +public interface IRegistryService extends javax.xml.rpc.Service { public java.lang.String getRegistryServiceAddress(); public ext.vamsas.IRegistry getRegistryService() - throws javax.xml.rpc.ServiceException; + throws javax.xml.rpc.ServiceException; public ext.vamsas.IRegistry getRegistryService(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException; + throws javax.xml.rpc.ServiceException; } diff --git a/src/ext/vamsas/IRegistryServiceLocator.java b/src/ext/vamsas/IRegistryServiceLocator.java index 0d7c0da..b83a9ee 100755 --- a/src/ext/vamsas/IRegistryServiceLocator.java +++ b/src/ext/vamsas/IRegistryServiceLocator.java @@ -1,15 +1,25 @@ -/** - * IRegistryServiceLocator.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class IRegistryServiceLocator - extends org.apache.axis.client.Service implements ext.vamsas. - IRegistryService +public class IRegistryServiceLocator extends org.apache.axis.client.Service + implements ext.vamsas.IRegistryService { public IRegistryServiceLocator() @@ -43,14 +53,13 @@ public class IRegistryServiceLocator } public ext.vamsas.IRegistry getRegistryService() - throws javax.xml.rpc.ServiceException + throws javax.xml.rpc.ServiceException { java.net.URL endpoint; try { endpoint = new java.net.URL(RegistryService_address); - } - catch (java.net.MalformedURLException e) + } catch (java.net.MalformedURLException e) { throw new javax.xml.rpc.ServiceException(e); } @@ -58,16 +67,15 @@ public class IRegistryServiceLocator } public ext.vamsas.IRegistry getRegistryService(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException + throws javax.xml.rpc.ServiceException { try { - ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas. - RegistryServiceSoapBindingStub(portAddress, this); + ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas.RegistryServiceSoapBindingStub( + portAddress, this); _stub.setPortName(getRegistryServiceWSDDServiceName()); return _stub; - } - catch (org.apache.axis.AxisFault e) + } catch (org.apache.axis.AxisFault e) { return null; } @@ -79,42 +87,39 @@ public class IRegistryServiceLocator } /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. */ public java.rmi.Remote getPort(Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException + throws javax.xml.rpc.ServiceException { try { - if (ext.vamsas.IRegistry.class.isAssignableFrom(serviceEndpointInterface)) + if (ext.vamsas.IRegistry.class + .isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas. - RegistryServiceSoapBindingStub(new java.net.URL( - RegistryService_address), this); + ext.vamsas.RegistryServiceSoapBindingStub _stub = new ext.vamsas.RegistryServiceSoapBindingStub( + new java.net.URL(RegistryService_address), this); _stub.setPortName(getRegistryServiceWSDDServiceName()); return _stub; } - } - catch (java.lang.Throwable t) + } catch (java.lang.Throwable t) { throw new javax.xml.rpc.ServiceException(t); } throw new javax.xml.rpc.ServiceException( - "There is no stub implementation for the interface: " + - (serviceEndpointInterface == null ? "null" : - serviceEndpointInterface.getName())); + "There is no stub implementation for the interface: " + + (serviceEndpointInterface == null ? "null" + : serviceEndpointInterface.getName())); } /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. */ public java.rmi.Remote getPort(javax.xml.namespace.QName portName, - Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException { if (portName == null) { @@ -128,7 +133,7 @@ public class IRegistryServiceLocator else { java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ( (org.apache.axis.client.Stub) _stub).setPortName(portName); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); return _stub; } } @@ -154,8 +159,7 @@ public class IRegistryServiceLocator * Set the endpoint address for the specified port name. */ public void setEndpointAddress(java.lang.String portName, - java.lang.String address) - throws javax.xml.rpc.ServiceException + java.lang.String address) throws javax.xml.rpc.ServiceException { if ("RegistryService".equals(portName)) { @@ -164,7 +168,7 @@ public class IRegistryServiceLocator else { // Unknown Port Name throw new javax.xml.rpc.ServiceException( - " Cannot set Endpoint Address for Unknown Port" + portName); + " Cannot set Endpoint Address for Unknown Port" + portName); } } @@ -172,8 +176,7 @@ public class IRegistryServiceLocator * Set the endpoint address for the specified port name. */ public void setEndpointAddress(javax.xml.namespace.QName portName, - java.lang.String address) - throws javax.xml.rpc.ServiceException + java.lang.String address) throws javax.xml.rpc.ServiceException { setEndpointAddress(portName.getLocalPart(), address); } diff --git a/src/ext/vamsas/Jpred.java b/src/ext/vamsas/Jpred.java index c3ab28b..2805a1d 100755 --- a/src/ext/vamsas/Jpred.java +++ b/src/ext/vamsas/Jpred.java @@ -1,24 +1,35 @@ -/** - * Jpred.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public interface Jpred - extends java.rmi.Remote +public interface Jpred extends java.rmi.Remote { public java.lang.String predict(vamsas.objects.simple.Sequence seq) - throws java.rmi.RemoteException; + throws java.rmi.RemoteException; - public java.lang.String predictOnMsa(vamsas.objects.simple.Msfalignment msf) - throws java.rmi.RemoteException; + public java.lang.String predictOnMsa( + vamsas.objects.simple.Msfalignment msf) + throws java.rmi.RemoteException; - public vamsas.objects.simple.Secstructpred getpredict(java.lang.String job_id) - throws java.rmi.RemoteException; + public vamsas.objects.simple.Secstructpred getpredict( + java.lang.String job_id) throws java.rmi.RemoteException; public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id) - throws java.rmi.RemoteException; + throws java.rmi.RemoteException; } diff --git a/src/ext/vamsas/JpredService.java b/src/ext/vamsas/JpredService.java index 8917d77..61ef50b 100755 --- a/src/ext/vamsas/JpredService.java +++ b/src/ext/vamsas/JpredService.java @@ -1,20 +1,29 @@ -/** - * JpredService.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public interface JpredService - extends javax.xml.rpc.Service +public interface JpredService extends javax.xml.rpc.Service { public java.lang.String getjpredAddress(); - public ext.vamsas.Jpred getjpred() - throws javax.xml.rpc.ServiceException; + public ext.vamsas.Jpred getjpred() throws javax.xml.rpc.ServiceException; public ext.vamsas.Jpred getjpred(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException; + throws javax.xml.rpc.ServiceException; } diff --git a/src/ext/vamsas/JpredServiceLocator.java b/src/ext/vamsas/JpredServiceLocator.java index 433fa70..ec70fe6 100755 --- a/src/ext/vamsas/JpredServiceLocator.java +++ b/src/ext/vamsas/JpredServiceLocator.java @@ -1,14 +1,25 @@ -/** - * JpredServiceLocator.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class JpredServiceLocator - extends org.apache.axis.client.Service implements ext.vamsas.JpredService +public class JpredServiceLocator extends org.apache.axis.client.Service + implements ext.vamsas.JpredService { public JpredServiceLocator() @@ -21,8 +32,7 @@ public class JpredServiceLocator } // Use to get a proxy class for jpred - private java.lang.String jpred_address = - "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; + private java.lang.String jpred_address = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; public java.lang.String getjpredAddress() { @@ -42,15 +52,13 @@ public class JpredServiceLocator jpredWSDDServiceName = name; } - public ext.vamsas.Jpred getjpred() - throws javax.xml.rpc.ServiceException + public ext.vamsas.Jpred getjpred() throws javax.xml.rpc.ServiceException { java.net.URL endpoint; try { endpoint = new java.net.URL(jpred_address); - } - catch (java.net.MalformedURLException e) + } catch (java.net.MalformedURLException e) { throw new javax.xml.rpc.ServiceException(e); } @@ -58,16 +66,15 @@ public class JpredServiceLocator } public ext.vamsas.Jpred getjpred(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException + throws javax.xml.rpc.ServiceException { try { - ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas. - JpredSoapBindingStub(portAddress, this); + ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub( + portAddress, this); _stub.setPortName(getjpredWSDDServiceName()); return _stub; - } - catch (org.apache.axis.AxisFault e) + } catch (org.apache.axis.AxisFault e) { return null; } @@ -79,41 +86,38 @@ public class JpredServiceLocator } /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. */ public java.rmi.Remote getPort(Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException + throws javax.xml.rpc.ServiceException { try { if (ext.vamsas.Jpred.class.isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas. - JpredSoapBindingStub(new java.net.URL(jpred_address), this); + ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub( + new java.net.URL(jpred_address), this); _stub.setPortName(getjpredWSDDServiceName()); return _stub; } - } - catch (java.lang.Throwable t) + } catch (java.lang.Throwable t) { throw new javax.xml.rpc.ServiceException(t); } throw new javax.xml.rpc.ServiceException( - "There is no stub implementation for the interface: " + - (serviceEndpointInterface == null ? "null" : - serviceEndpointInterface.getName())); + "There is no stub implementation for the interface: " + + (serviceEndpointInterface == null ? "null" + : serviceEndpointInterface.getName())); } /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. */ public java.rmi.Remote getPort(javax.xml.namespace.QName portName, - Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException { if (portName == null) { @@ -127,7 +131,7 @@ public class JpredServiceLocator else { java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ( (org.apache.axis.client.Stub) _stub).setPortName(portName); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); return _stub; } } @@ -153,8 +157,7 @@ public class JpredServiceLocator * Set the endpoint address for the specified port name. */ public void setEndpointAddress(java.lang.String portName, - java.lang.String address) - throws javax.xml.rpc.ServiceException + java.lang.String address) throws javax.xml.rpc.ServiceException { if ("jpred".equals(portName)) { @@ -163,7 +166,7 @@ public class JpredServiceLocator else { // Unknown Port Name throw new javax.xml.rpc.ServiceException( - " Cannot set Endpoint Address for Unknown Port" + portName); + " Cannot set Endpoint Address for Unknown Port" + portName); } } @@ -171,8 +174,7 @@ public class JpredServiceLocator * Set the endpoint address for the specified port name. */ public void setEndpointAddress(javax.xml.namespace.QName portName, - java.lang.String address) - throws javax.xml.rpc.ServiceException + java.lang.String address) throws javax.xml.rpc.ServiceException { setEndpointAddress(portName.getLocalPart(), address); } diff --git a/src/ext/vamsas/JpredSoapBindingStub.java b/src/ext/vamsas/JpredSoapBindingStub.java index 4c8fc7f..5915dca 100755 --- a/src/ext/vamsas/JpredSoapBindingStub.java +++ b/src/ext/vamsas/JpredSoapBindingStub.java @@ -1,18 +1,32 @@ -/** - * JpredSoapBindingStub.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class JpredSoapBindingStub - extends org.apache.axis.client.Stub implements ext.vamsas.Jpred +public class JpredSoapBindingStub extends org.apache.axis.client.Stub + implements ext.vamsas.Jpred { private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); static org.apache.axis.description.OperationDesc[] _operations; @@ -29,12 +43,11 @@ public class JpredSoapBindingStub oper = new org.apache.axis.description.OperationDesc(); oper.setName("predict"); oper.addParameter(new javax.xml.namespace.QName("", "seq"), - new javax.xml. - namespace.QName("simple.objects.vamsas", "Sequence"), - vamsas.objects.simple.Sequence.class, - org.apache.axis.description.ParameterDesc.IN, false, false); + new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"), vamsas.objects.simple.Sequence.class, + org.apache.axis.description.ParameterDesc.IN, false, false); oper.setReturnType(new javax.xml.namespace.QName( - "http://www.w3.org/2001/XMLSchema", "string")); + "http://www.w3.org/2001/XMLSchema", "string")); oper.setReturnClass(java.lang.String.class); oper.setReturnQName(new javax.xml.namespace.QName("", "predictReturn")); oper.setStyle(org.apache.axis.constants.Style.RPC); @@ -44,15 +57,15 @@ public class JpredSoapBindingStub oper = new org.apache.axis.description.OperationDesc(); oper.setName("predictOnMsa"); oper.addParameter(new javax.xml.namespace.QName("", "msf"), - new javax.xml. - namespace.QName("http://simple.objects.vamsas", - "Msfalignment"), - vamsas.objects.simple.Msfalignment.class, - org.apache.axis.description.ParameterDesc.IN, false, false); + new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Msfalignment"), + vamsas.objects.simple.Msfalignment.class, + org.apache.axis.description.ParameterDesc.IN, false, false); oper.setReturnType(new javax.xml.namespace.QName( - "http://www.w3.org/2001/XMLSchema", "string")); + "http://www.w3.org/2001/XMLSchema", "string")); oper.setReturnClass(java.lang.String.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "predictOnMsaReturn")); + oper.setReturnQName(new javax.xml.namespace.QName("", + "predictOnMsaReturn")); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.apache.axis.constants.Use.ENCODED); _operations[1] = oper; @@ -60,14 +73,15 @@ public class JpredSoapBindingStub oper = new org.apache.axis.description.OperationDesc(); oper.setName("getpredict"); oper.addParameter(new javax.xml.namespace.QName("", "job_id"), - new javax. - xml.namespace.QName("http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); oper.setReturnType(new javax.xml.namespace.QName( - "http://simple.objects.vamsas", "Secstructpred")); + "http://simple.objects.vamsas", "Secstructpred")); oper.setReturnClass(vamsas.objects.simple.Secstructpred.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getpredictReturn")); + oper.setReturnQName(new javax.xml.namespace.QName("", + "getpredictReturn")); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.apache.axis.constants.Use.ENCODED); _operations[2] = oper; @@ -75,36 +89,36 @@ public class JpredSoapBindingStub oper = new org.apache.axis.description.OperationDesc(); oper.setName("getresult"); oper.addParameter(new javax.xml.namespace.QName("", "job_id"), - new javax. - xml.namespace.QName("http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); oper.setReturnType(new javax.xml.namespace.QName( - "http://simple.objects.vamsas", "JpredResult")); + "http://simple.objects.vamsas", "JpredResult")); oper.setReturnClass(vamsas.objects.simple.JpredResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getresultReturn")); + oper + .setReturnQName(new javax.xml.namespace.QName("", + "getresultReturn")); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.apache.axis.constants.Use.ENCODED); _operations[3] = oper; } - public JpredSoapBindingStub() - throws org.apache.axis.AxisFault + public JpredSoapBindingStub() throws org.apache.axis.AxisFault { this(null); } public JpredSoapBindingStub(java.net.URL endpointURL, - javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault + javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { this(service); super.cachedEndpoint = endpointURL; } public JpredSoapBindingStub(javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault + throws org.apache.axis.AxisFault { if (service == null) { @@ -117,18 +131,26 @@ public class JpredSoapBindingStub java.lang.Class cls; javax.xml.namespace.QName qName; java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser. - BeanDeserializerFactory.class; - /*java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class;*/ + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + /* + * java.lang.Class enumsf = + * org.apache.axis.encoding.ser.EnumSerializerFactory.class; java.lang.Class + * enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + * java.lang.Class arraysf = + * org.apache.axis.encoding.ser.ArraySerializerFactory.class; + * java.lang.Class arraydf = + * org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + * java.lang.Class simplesf = + * org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + * java.lang.Class simpledf = + * org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + * java.lang.Class simplelistsf = + * org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + * java.lang.Class simplelistdf = + * org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + */ qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", - "JpredResult"); + "JpredResult"); cachedSerQNames.add(qName); cls = vamsas.objects.simple.JpredResult.class; cachedSerClasses.add(cls); @@ -143,7 +165,7 @@ public class JpredSoapBindingStub cachedDeserFactories.add(beandf); qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", - "Secstructpred"); + "Secstructpred"); cachedSerQNames.add(qName); cls = vamsas.objects.simple.Secstructpred.class; cachedSerClasses.add(cls); @@ -151,14 +173,15 @@ public class JpredSoapBindingStub cachedDeserFactories.add(beandf); qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", - "Msfalignment"); + "Msfalignment"); cachedSerQNames.add(qName); cls = vamsas.objects.simple.Msfalignment.class; cachedSerClasses.add(cls); cachedSerFactories.add(beansf); cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"); + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"); cachedSerQNames.add(qName); cls = vamsas.objects.simple.Sequence.class; cachedSerClasses.add(cls); @@ -168,12 +191,12 @@ public class JpredSoapBindingStub } protected org.apache.axis.client.Call createCall() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call)super.service.createCall(); + org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service + .createCall(); if (super.maintainSessionSet) { _call.setMaintainSession(super.maintainSession); @@ -214,33 +237,32 @@ public class JpredSoapBindingStub if (firstCall()) { // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants. - SOAP11_CONSTANTS); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); for (int i = 0; i < cachedSerFactories.size(); ++i) { java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames + .get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories + .get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories + .get(i); _call.registerTypeMapping(cls, qName, sf, df, false); } } } return _call; - } - catch (java.lang.Throwable _t) + } catch (java.lang.Throwable _t) { throw new org.apache.axis.AxisFault( - "Failure trying to get the Call object", _t); + "Failure trying to get the Call object", _t); } } public java.lang.String predict(vamsas.objects.simple.Sequence seq) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { @@ -250,13 +272,15 @@ public class JpredSoapBindingStub _call.setOperation(_operations[0]); _call.setUseSOAPAction(true); _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predict")); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "predict")); setRequestHeaders(_call); setAttachments(_call); java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {seq}); + { seq }); if (_resp instanceof java.rmi.RemoteException) { @@ -268,17 +292,17 @@ public class JpredSoapBindingStub try { return (java.lang.String) _resp; - } - catch (java.lang.Exception _exception) + } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, - java.lang.String.class); + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert( + _resp, java.lang.String.class); } } } - public java.lang.String predictOnMsa(vamsas.objects.simple.Msfalignment msf) - throws java.rmi.RemoteException + public java.lang.String predictOnMsa( + vamsas.objects.simple.Msfalignment msf) + throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { @@ -288,14 +312,15 @@ public class JpredSoapBindingStub _call.setOperation(_operations[1]); _call.setUseSOAPAction(true); _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); _call.setOperationName(new javax.xml.namespace.QName("vamsas", - "predictOnMsa")); + "predictOnMsa")); setRequestHeaders(_call); setAttachments(_call); java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {msf}); + { msf }); if (_resp instanceof java.rmi.RemoteException) { @@ -307,17 +332,16 @@ public class JpredSoapBindingStub try { return (java.lang.String) _resp; - } - catch (java.lang.Exception _exception) + } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, - java.lang.String.class); + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert( + _resp, java.lang.String.class); } } } - public vamsas.objects.simple.Secstructpred getpredict(java.lang.String job_id) - throws java.rmi.RemoteException + public vamsas.objects.simple.Secstructpred getpredict( + java.lang.String job_id) throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { @@ -327,13 +351,15 @@ public class JpredSoapBindingStub _call.setOperation(_operations[2]); _call.setUseSOAPAction(true); _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getpredict")); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getpredict")); setRequestHeaders(_call); setAttachments(_call); java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {job_id}); + { job_id }); if (_resp instanceof java.rmi.RemoteException) { @@ -345,17 +371,16 @@ public class JpredSoapBindingStub try { return (vamsas.objects.simple.Secstructpred) _resp; - } - catch (java.lang.Exception _exception) + } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.Secstructpred) org.apache.axis.utils. - JavaUtils.convert(_resp, vamsas.objects.simple.Secstructpred.class); + return (vamsas.objects.simple.Secstructpred) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.Secstructpred.class); } } } public vamsas.objects.simple.JpredResult getresult(java.lang.String job_id) - throws java.rmi.RemoteException + throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { @@ -365,13 +390,15 @@ public class JpredSoapBindingStub _call.setOperation(_operations[3]); _call.setUseSOAPAction(true); _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getresult")); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getresult")); setRequestHeaders(_call); setAttachments(_call); java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {job_id}); + { job_id }); if (_resp instanceof java.rmi.RemoteException) { @@ -383,11 +410,10 @@ public class JpredSoapBindingStub try { return (vamsas.objects.simple.JpredResult) _resp; - } - catch (java.lang.Exception _exception) + } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.JpredResult) org.apache.axis.utils. - JavaUtils.convert(_resp, vamsas.objects.simple.JpredResult.class); + return (vamsas.objects.simple.JpredResult) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.JpredResult.class); } } } diff --git a/src/ext/vamsas/MuscleWS.java b/src/ext/vamsas/MuscleWS.java index db1416e..c4e1f77 100755 --- a/src/ext/vamsas/MuscleWS.java +++ b/src/ext/vamsas/MuscleWS.java @@ -1,43 +1,53 @@ -/** - * MuscleWS.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package ext.vamsas; - -public interface MuscleWS - extends java.rmi.Remote -{ - public vamsas.objects.simple.WsJobId align( - vamsas.objects.simple.SequenceSet seqSet) - throws java.rmi.RemoteException; - - public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) - throws java.rmi.RemoteException; - - public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) - throws java.rmi.RemoteException; - - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) - throws java.rmi.RemoteException; -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package ext.vamsas; + +public interface MuscleWS extends java.rmi.Remote +{ + public vamsas.objects.simple.WsJobId align( + vamsas.objects.simple.SequenceSet seqSet) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException; +} diff --git a/src/ext/vamsas/MuscleWSService.java b/src/ext/vamsas/MuscleWSService.java index a4dc674..76a5995 100755 --- a/src/ext/vamsas/MuscleWSService.java +++ b/src/ext/vamsas/MuscleWSService.java @@ -1,38 +1,48 @@ -/** - * MuscleWSService.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package ext.vamsas; - -public interface MuscleWSService - extends javax.xml.rpc.Service -{ - public java.lang.String getMuscleWSAddress(); - - public ext.vamsas.MuscleWS getMuscleWS() - throws javax.xml.rpc.ServiceException; - - public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException; -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package ext.vamsas; + +public interface MuscleWSService extends javax.xml.rpc.Service +{ + public java.lang.String getMuscleWSAddress(); + + public ext.vamsas.MuscleWS getMuscleWS() + throws javax.xml.rpc.ServiceException; + + public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; +} diff --git a/src/ext/vamsas/MuscleWSServiceLocator.java b/src/ext/vamsas/MuscleWSServiceLocator.java index a269029..0f08435 100755 --- a/src/ext/vamsas/MuscleWSServiceLocator.java +++ b/src/ext/vamsas/MuscleWSServiceLocator.java @@ -1,208 +1,209 @@ -/** - * MuscleWSServiceLocator.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package ext.vamsas; - -public class MuscleWSServiceLocator - extends org.apache.axis.client.Service implements ext.vamsas. - MuscleWSService -{ - // Use to get a proxy class for MuscleWS - private java.lang.String MuscleWS_address = - "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/MuscleWS"; - - // The WSDD service name defaults to the port name. - private java.lang.String MuscleWSWSDDServiceName = "MuscleWS"; - private java.util.HashSet ports = null; - - public MuscleWSServiceLocator() - { - } - - public MuscleWSServiceLocator(org.apache.axis.EngineConfiguration config) - { - super(config); - } - - public java.lang.String getMuscleWSAddress() - { - return MuscleWS_address; - } - - public java.lang.String getMuscleWSWSDDServiceName() - { - return MuscleWSWSDDServiceName; - } - - public void setMuscleWSWSDDServiceName(java.lang.String name) - { - MuscleWSWSDDServiceName = name; - } - - public ext.vamsas.MuscleWS getMuscleWS() - throws javax.xml.rpc.ServiceException - { - java.net.URL endpoint; - - try - { - endpoint = new java.net.URL(MuscleWS_address); - } - catch (java.net.MalformedURLException e) - { - throw new javax.xml.rpc.ServiceException(e); - } - - return getMuscleWS(endpoint); - } - - public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) - throws javax.xml.rpc.ServiceException - { - try - { - ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas. - MuscleWSSoapBindingStub(portAddress, - this); - _stub.setPortName(getMuscleWSWSDDServiceName()); - - return _stub; - } - catch (org.apache.axis.AxisFault e) - { - return null; - } - } - - public void setMuscleWSEndpointAddress(java.lang.String address) - { - MuscleWS_address = address; - } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException - { - try - { - if (ext.vamsas.MuscleWS.class.isAssignableFrom( - serviceEndpointInterface)) - { - ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas. - MuscleWSSoapBindingStub(new java.net.URL( - MuscleWS_address), this); - _stub.setPortName(getMuscleWSWSDDServiceName()); - - return _stub; - } - } - catch (java.lang.Throwable t) - { - throw new javax.xml.rpc.ServiceException(t); - } - - throw new javax.xml.rpc.ServiceException( - "There is no stub implementation for the interface: " + - ( (serviceEndpointInterface == null) ? "null" - : serviceEndpointInterface.getName())); - } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, - Class serviceEndpointInterface) - throws javax.xml.rpc.ServiceException - { - if (portName == null) - { - return getPort(serviceEndpointInterface); - } - - java.lang.String inputPortName = portName.getLocalPart(); - - if ("MuscleWS".equals(inputPortName)) - { - return getMuscleWS(); - } - else - { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ( (org.apache.axis.client.Stub) _stub).setPortName(portName); - - return _stub; - } - } - - public javax.xml.namespace.QName getServiceName() - { - return new javax.xml.namespace.QName("vamsas", "MuscleWSService"); - } - - public java.util.Iterator getPorts() - { - if (ports == null) - { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "MuscleWS")); - } - - return ports.iterator(); - } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(java.lang.String portName, - java.lang.String address) - throws javax.xml.rpc.ServiceException - { - if ("MuscleWS".equals(portName)) - { - setMuscleWSEndpointAddress(address); - } - else - { // Unknown Port Name - throw new javax.xml.rpc.ServiceException( - " Cannot set Endpoint Address for Unknown Port" + portName); - } - } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(javax.xml.namespace.QName portName, - java.lang.String address) - throws javax.xml.rpc.ServiceException - { - setEndpointAddress(portName.getLocalPart(), address); - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package ext.vamsas; + +public class MuscleWSServiceLocator extends org.apache.axis.client.Service + implements ext.vamsas.MuscleWSService +{ + // Use to get a proxy class for MuscleWS + private java.lang.String MuscleWS_address = "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/MuscleWS"; + + // The WSDD service name defaults to the port name. + private java.lang.String MuscleWSWSDDServiceName = "MuscleWS"; + + private java.util.HashSet ports = null; + + public MuscleWSServiceLocator() + { + } + + public MuscleWSServiceLocator(org.apache.axis.EngineConfiguration config) + { + super(config); + } + + public java.lang.String getMuscleWSAddress() + { + return MuscleWS_address; + } + + public java.lang.String getMuscleWSWSDDServiceName() + { + return MuscleWSWSDDServiceName; + } + + public void setMuscleWSWSDDServiceName(java.lang.String name) + { + MuscleWSWSDDServiceName = name; + } + + public ext.vamsas.MuscleWS getMuscleWS() + throws javax.xml.rpc.ServiceException + { + java.net.URL endpoint; + + try + { + endpoint = new java.net.URL(MuscleWS_address); + } catch (java.net.MalformedURLException e) + { + throw new javax.xml.rpc.ServiceException(e); + } + + return getMuscleWS(endpoint); + } + + public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException + { + try + { + ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub( + portAddress, this); + _stub.setPortName(getMuscleWSWSDDServiceName()); + + return _stub; + } catch (org.apache.axis.AxisFault e) + { + return null; + } + } + + public void setMuscleWSEndpointAddress(java.lang.String address) + { + MuscleWS_address = address; + } + + /** + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + try + { + if (ext.vamsas.MuscleWS.class + .isAssignableFrom(serviceEndpointInterface)) + { + ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub( + new java.net.URL(MuscleWS_address), this); + _stub.setPortName(getMuscleWSWSDDServiceName()); + + return _stub; + } + } catch (java.lang.Throwable t) + { + throw new javax.xml.rpc.ServiceException(t); + } + + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + ((serviceEndpointInterface == null) ? "null" + : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + if (portName == null) + { + return getPort(serviceEndpointInterface); + } + + java.lang.String inputPortName = portName.getLocalPart(); + + if ("MuscleWS".equals(inputPortName)) + { + return getMuscleWS(); + } + else + { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() + { + return new javax.xml.namespace.QName("vamsas", "MuscleWSService"); + } + + public java.util.Iterator getPorts() + { + if (ports == null) + { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "MuscleWS")); + } + + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) throws javax.xml.rpc.ServiceException + { + if ("MuscleWS".equals(portName)) + { + setMuscleWSEndpointAddress(address); + } + else + { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); + } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) throws javax.xml.rpc.ServiceException + { + setEndpointAddress(portName.getLocalPart(), address); + } +} diff --git a/src/ext/vamsas/MuscleWSSoapBindingStub.java b/src/ext/vamsas/MuscleWSSoapBindingStub.java index de80f9e..958a4c2 100755 --- a/src/ext/vamsas/MuscleWSSoapBindingStub.java +++ b/src/ext/vamsas/MuscleWSSoapBindingStub.java @@ -1,470 +1,490 @@ -/** - * MuscleWSSoapBindingStub.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package ext.vamsas; - -public class MuscleWSSoapBindingStub - extends org.apache.axis.client.Stub implements ext.vamsas.MuscleWS -{ - static org.apache.axis.description.OperationDesc[] _operations; - - static - { - _operations = new org.apache.axis.description.OperationDesc[4]; - _initOperationDesc1(); - } - - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); - - public MuscleWSSoapBindingStub() - throws org.apache.axis.AxisFault - { - this(null); - } - - public MuscleWSSoapBindingStub(java.net.URL endpointURL, - javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault - { - this(service); - super.cachedEndpoint = endpointURL; - } - - public MuscleWSSoapBindingStub(javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault - { - if (service == null) - { - super.service = new org.apache.axis.client.Service(); - } - else - { - super.service = service; - } - - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser. - BeanDeserializerFactory.class; - //java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - //java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser. - ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser. - ArrayDeserializerFactory.class; - //java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - // java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - //java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - //java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "MsaResult"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.MsaResult.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "SequenceSet"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.SequenceSet.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", - "Object"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Object.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", - "Alignment"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Alignment.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.WsJobId.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); - cachedSerQNames.add(qName); - cls = java.lang.String[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Result.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - } - - private static void _initOperationDesc1() - { - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("align"); - oper.addParameter(new javax.xml.namespace.QName("", "seqSet"), - new javax.xml.namespace.QName("simple.objects.vamsas", - "SequenceSet"), - vamsas.objects.simple.SequenceSet.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "alignReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[0] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getalign"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), - new javax.xml.namespace.QName( - "http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "Alignment")); - oper.setReturnClass(vamsas.objects.simple.Alignment.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getalignReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[1] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getResult"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), - new javax.xml.namespace.QName( - "http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "MsaResult")); - oper.setReturnClass(vamsas.objects.simple.MsaResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getResultReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[2] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("cancel"); - oper.addParameter(new javax.xml.namespace.QName("", "jobId"), - new javax.xml.namespace.QName( - "http://www.w3.org/2001/XMLSchema", - "string"), java.lang.String.class, - org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName( - "simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[3] = oper; - } - - protected org.apache.axis.client.Call createCall() - throws java.rmi.RemoteException - { - try - { - org.apache.axis.client.Call _call = (org.apache.axis.client.Call)super. - service.createCall(); - - if (super.maintainSessionSet) - { - _call.setMaintainSession(super.maintainSession); - } - - if (super.cachedUsername != null) - { - _call.setUsername(super.cachedUsername); - } - - if (super.cachedPassword != null) - { - _call.setPassword(super.cachedPassword); - } - - if (super.cachedEndpoint != null) - { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - - if (super.cachedTimeout != null) - { - _call.setTimeout(super.cachedTimeout); - } - - if (super.cachedPortName != null) - { - _call.setPortName(super.cachedPortName); - } - - java.util.Enumeration keys = super.cachedProperties.keys(); - - while (keys.hasMoreElements()) - { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) - { - if (firstCall()) - { - // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants. - SOAP11_CONSTANTS); - _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); - - for (int i = 0; i < cachedSerFactories.size(); ++i) - { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = (javax.xml.namespace.QName) - cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - - return _call; - } - catch (java.lang.Throwable _t) - { - throw new org.apache.axis.AxisFault( - "Failure trying to get the Call object", - _t); - } - } - - public vamsas.objects.simple.WsJobId align( - vamsas.objects.simple.SequenceSet seqSet) - throws java.rmi.RemoteException - { - if (super.cachedEndpoint == null) - { - throw new org.apache.axis.NoEndPointException(); - } - - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "align")); - - setRequestHeaders(_call); - setAttachments(_call); - - java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {seqSet}); - - if (_resp instanceof java.rmi.RemoteException) - { - throw (java.rmi.RemoteException) _resp; - } - else - { - extractAttachments(_call); - - try - { - return (vamsas.objects.simple.WsJobId) _resp; - } - catch (java.lang.Exception _exception) - { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils. - convert(_resp, - vamsas.objects.simple.WsJobId.class); - } - } - } - - public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) - throws java.rmi.RemoteException - { - if (super.cachedEndpoint == null) - { - throw new org.apache.axis.NoEndPointException(); - } - - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[1]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", - "getalign")); - - setRequestHeaders(_call); - setAttachments(_call); - - java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {job_id}); - - if (_resp instanceof java.rmi.RemoteException) - { - throw (java.rmi.RemoteException) _resp; - } - else - { - extractAttachments(_call); - - try - { - return (vamsas.objects.simple.Alignment) _resp; - } - catch (java.lang.Exception _exception) - { - return (vamsas.objects.simple.Alignment) org.apache.axis.utils. - JavaUtils.convert(_resp, - vamsas.objects.simple.Alignment.class); - } - } - } - - public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) - throws java.rmi.RemoteException - { - if (super.cachedEndpoint == null) - { - throw new org.apache.axis.NoEndPointException(); - } - - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[2]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", - "getResult")); - - setRequestHeaders(_call); - setAttachments(_call); - - java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {job_id}); - - if (_resp instanceof java.rmi.RemoteException) - { - throw (java.rmi.RemoteException) _resp; - } - else - { - extractAttachments(_call); - - try - { - return (vamsas.objects.simple.MsaResult) _resp; - } - catch (java.lang.Exception _exception) - { - return (vamsas.objects.simple.MsaResult) org.apache.axis.utils. - JavaUtils.convert(_resp, - vamsas.objects.simple.MsaResult.class); - } - } - } - - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) - throws java.rmi.RemoteException - { - if (super.cachedEndpoint == null) - { - throw new org.apache.axis.NoEndPointException(); - } - - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[3]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "cancel")); - - setRequestHeaders(_call); - setAttachments(_call); - - java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {jobId}); - - if (_resp instanceof java.rmi.RemoteException) - { - throw (java.rmi.RemoteException) _resp; - } - else - { - extractAttachments(_call); - - try - { - return (vamsas.objects.simple.WsJobId) _resp; - } - catch (java.lang.Exception _exception) - { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils. - convert(_resp, - vamsas.objects.simple.WsJobId.class); - } - } - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package ext.vamsas; + +public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub + implements ext.vamsas.MuscleWS +{ + static org.apache.axis.description.OperationDesc[] _operations; + + static + { + _operations = new org.apache.axis.description.OperationDesc[4]; + _initOperationDesc1(); + } + + private java.util.Vector cachedSerClasses = new java.util.Vector(); + + private java.util.Vector cachedSerQNames = new java.util.Vector(); + + private java.util.Vector cachedSerFactories = new java.util.Vector(); + + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + public MuscleWSSoapBindingStub() throws org.apache.axis.AxisFault + { + this(null); + } + + public MuscleWSSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) throws org.apache.axis.AxisFault + { + this(service); + super.cachedEndpoint = endpointURL; + } + + public MuscleWSSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + if (service == null) + { + super.service = new org.apache.axis.client.Service(); + } + else + { + super.service = service; + } + + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + // java.lang.Class enumsf = + // org.apache.axis.encoding.ser.EnumSerializerFactory.class; + // java.lang.Class enumdf = + // org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + // java.lang.Class simplesf = + // org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + // java.lang.Class simpledf = + // org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + // java.lang.Class simplelistsf = + // org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + // java.lang.Class simplelistdf = + // org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "MsaResult"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.MsaResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "SequenceSet"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.SequenceSet.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Object"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Object.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Alignment"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Alignment.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "WsJobId"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.WsJobId.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); + cachedSerQNames.add(qName); + cls = java.lang.String[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Result.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + } + + private static void _initOperationDesc1() + { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("align"); + oper.addParameter(new javax.xml.namespace.QName("", "seqSet"), + new javax.xml.namespace.QName("simple.objects.vamsas", + "SequenceSet"), + vamsas.objects.simple.SequenceSet.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "alignReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getalign"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "Alignment")); + oper.setReturnClass(vamsas.objects.simple.Alignment.class); + oper + .setReturnQName(new javax.xml.namespace.QName("", + "getalignReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getResult"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "MsaResult")); + oper.setReturnClass(vamsas.objects.simple.MsaResult.class); + oper + .setReturnQName(new javax.xml.namespace.QName("", + "getResultReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("cancel"); + oper.addParameter(new javax.xml.namespace.QName("", "jobId"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[3] = oper; + } + + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException + { + try + { + org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service + .createCall(); + + if (super.maintainSessionSet) + { + _call.setMaintainSession(super.maintainSession); + } + + if (super.cachedUsername != null) + { + _call.setUsername(super.cachedUsername); + } + + if (super.cachedPassword != null) + { + _call.setPassword(super.cachedPassword); + } + + if (super.cachedEndpoint != null) + { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + + if (super.cachedTimeout != null) + { + _call.setTimeout(super.cachedTimeout); + } + + if (super.cachedPortName != null) + { + _call.setPortName(super.cachedPortName); + } + + java.util.Enumeration keys = super.cachedProperties.keys(); + + while (keys.hasMoreElements()) + { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) + { + if (firstCall()) + { + // must set encoding style before registering serializers + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + + for (int i = 0; i < cachedSerFactories.size(); ++i) + { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames + .get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories + .get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories + .get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + + return _call; + } catch (java.lang.Throwable _t) + { + throw new org.apache.axis.AxisFault( + "Failure trying to get the Call object", _t); + } + } + + public vamsas.objects.simple.WsJobId align( + vamsas.objects.simple.SequenceSet seqSet) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call + .setOperationName(new javax.xml.namespace.QName("vamsas", + "align")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { seqSet }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.WsJobId.class); + } + } + } + + public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getalign")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { job_id }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.Alignment) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.Alignment) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.Alignment.class); + } + } + } + + public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getResult")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { job_id }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.MsaResult) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.MsaResult) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.MsaResult.class); + } + } + } + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call + .setOperationName(new javax.xml.namespace.QName("vamsas", + "cancel")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { jobId }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.WsJobId.class); + } + } + } +} diff --git a/src/ext/vamsas/RegistryServiceSoapBindingStub.java b/src/ext/vamsas/RegistryServiceSoapBindingStub.java index 22bd8ed..c361e8d 100755 --- a/src/ext/vamsas/RegistryServiceSoapBindingStub.java +++ b/src/ext/vamsas/RegistryServiceSoapBindingStub.java @@ -1,18 +1,32 @@ -/** - * RegistryServiceSoapBindingStub.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class RegistryServiceSoapBindingStub - extends org.apache.axis.client.Stub implements ext.vamsas.IRegistry +public class RegistryServiceSoapBindingStub extends + org.apache.axis.client.Stub implements ext.vamsas.IRegistry { private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); static org.apache.axis.description.OperationDesc[] _operations; @@ -28,32 +42,31 @@ public class RegistryServiceSoapBindingStub org.apache.axis.description.OperationDesc oper; oper = new org.apache.axis.description.OperationDesc(); oper.setName("getServices"); - oper.setReturnType(new javax.xml.namespace.QName("registry.objects.vamsas", - "ServiceHandles")); + oper.setReturnType(new javax.xml.namespace.QName( + "registry.objects.vamsas", "ServiceHandles")); oper.setReturnClass(ext.vamsas.ServiceHandles.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getServicesReturn")); + oper.setReturnQName(new javax.xml.namespace.QName("", + "getServicesReturn")); oper.setStyle(org.apache.axis.constants.Style.RPC); oper.setUse(org.apache.axis.constants.Use.ENCODED); _operations[0] = oper; } - public RegistryServiceSoapBindingStub() - throws org.apache.axis.AxisFault + public RegistryServiceSoapBindingStub() throws org.apache.axis.AxisFault { this(null); } public RegistryServiceSoapBindingStub(java.net.URL endpointURL, - javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault + javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { this(service); super.cachedEndpoint = endpointURL; } public RegistryServiceSoapBindingStub(javax.xml.rpc.Service service) - throws org.apache.axis.AxisFault + throws org.apache.axis.AxisFault { if (service == null) { @@ -66,20 +79,23 @@ public class RegistryServiceSoapBindingStub java.lang.Class cls; javax.xml.namespace.QName qName; java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser. - BeanDeserializerFactory.class; - //java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - //java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser. - ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser. - ArrayDeserializerFactory.class; - //java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - //java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - //java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - //java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + // java.lang.Class enumsf = + // org.apache.axis.encoding.ser.EnumSerializerFactory.class; + // java.lang.Class enumdf = + // org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + // java.lang.Class simplesf = + // org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + // java.lang.Class simpledf = + // org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + // java.lang.Class simplelistsf = + // org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + // java.lang.Class simplelistdf = + // org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; qName = new javax.xml.namespace.QName("vamsas", - "ArrayOf_tns1_ServiceHandle"); + "ArrayOf_tns1_ServiceHandle"); cachedSerQNames.add(qName); cls = ext.vamsas.ServiceHandle[].class; cachedSerClasses.add(cls); @@ -87,7 +103,7 @@ public class RegistryServiceSoapBindingStub cachedDeserFactories.add(arraydf); qName = new javax.xml.namespace.QName("registry.objects.vamsas", - "ServiceHandles"); + "ServiceHandles"); cachedSerQNames.add(qName); cls = ext.vamsas.ServiceHandles.class; cachedSerClasses.add(cls); @@ -95,7 +111,7 @@ public class RegistryServiceSoapBindingStub cachedDeserFactories.add(beandf); qName = new javax.xml.namespace.QName("registry.objects.vamsas", - "ServiceHandle"); + "ServiceHandle"); cachedSerQNames.add(qName); cls = ext.vamsas.ServiceHandle.class; cachedSerClasses.add(cls); @@ -105,12 +121,12 @@ public class RegistryServiceSoapBindingStub } protected org.apache.axis.client.Call createCall() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call)super.service.createCall(); + org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service + .createCall(); if (super.maintainSessionSet) { _call.setMaintainSession(super.maintainSession); @@ -151,33 +167,32 @@ public class RegistryServiceSoapBindingStub if (firstCall()) { // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants. - SOAP11_CONSTANTS); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); for (int i = 0; i < cachedSerFactories.size(); ++i) { java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames + .get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories + .get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories + .get(i); _call.registerTypeMapping(cls, qName, sf, df, false); } } } return _call; - } - catch (java.lang.Throwable _t) + } catch (java.lang.Throwable _t) { throw new org.apache.axis.AxisFault( - "Failure trying to get the Call object", _t); + "Failure trying to get the Call object", _t); } } public ext.vamsas.ServiceHandles getServices() - throws java.rmi.RemoteException + throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { @@ -187,14 +202,15 @@ public class RegistryServiceSoapBindingStub _call.setOperation(_operations[0]); _call.setUseSOAPAction(true); _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); _call.setOperationName(new javax.xml.namespace.QName("vamsas", - "getServices")); + "getServices")); setRequestHeaders(_call); setAttachments(_call); java.lang.Object _resp = _call.invoke(new java.lang.Object[] - {}); + {}); if (_resp instanceof java.rmi.RemoteException) { @@ -206,11 +222,10 @@ public class RegistryServiceSoapBindingStub try { return (ext.vamsas.ServiceHandles) _resp; - } - catch (java.lang.Exception _exception) + } catch (java.lang.Exception _exception) { - return (ext.vamsas.ServiceHandles) org.apache.axis.utils.JavaUtils. - convert(_resp, ext.vamsas.ServiceHandles.class); + return (ext.vamsas.ServiceHandles) org.apache.axis.utils.JavaUtils + .convert(_resp, ext.vamsas.ServiceHandles.class); } } } diff --git a/src/ext/vamsas/SeqSearchI.java b/src/ext/vamsas/SeqSearchI.java index 3c89161..f8b0fb7 100644 --- a/src/ext/vamsas/SeqSearchI.java +++ b/src/ext/vamsas/SeqSearchI.java @@ -1,16 +1,38 @@ -/** - * ScanPSService.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public interface SeqSearchI extends java.rmi.Remote { - public java.lang.String getDatabase() throws java.rmi.RemoteException; - public vamsas.objects.simple.SeqSearchResult getResult(java.lang.String job_id) throws java.rmi.RemoteException; - public vamsas.objects.simple.WsJobId psearch(vamsas.objects.simple.Alignment al, java.lang.String database) throws java.rmi.RemoteException; - public vamsas.objects.simple.WsJobId search(vamsas.objects.simple.Sequence s, java.lang.String database) throws java.rmi.RemoteException; - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) throws java.rmi.RemoteException; +public interface SeqSearchI extends java.rmi.Remote +{ + public java.lang.String getDatabase() throws java.rmi.RemoteException; + + public vamsas.objects.simple.SeqSearchResult getResult( + java.lang.String job_id) throws java.rmi.RemoteException; + + public vamsas.objects.simple.WsJobId psearch( + vamsas.objects.simple.Alignment al, java.lang.String database) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.WsJobId search( + vamsas.objects.simple.Sequence s, java.lang.String database) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException; } diff --git a/src/ext/vamsas/SeqSearchServiceLocator.java b/src/ext/vamsas/SeqSearchServiceLocator.java index 46b435b..598e1ad 100644 --- a/src/ext/vamsas/SeqSearchServiceLocator.java +++ b/src/ext/vamsas/SeqSearchServiceLocator.java @@ -1,136 +1,184 @@ -/** - * ScanPSServiceServiceLocator.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class SeqSearchServiceLocator extends org.apache.axis.client.Service implements ext.vamsas.SeqSearchServiceService { - - public SeqSearchServiceLocator() { +public class SeqSearchServiceLocator extends org.apache.axis.client.Service + implements ext.vamsas.SeqSearchServiceService +{ + + public SeqSearchServiceLocator() + { + } + + public SeqSearchServiceLocator(org.apache.axis.EngineConfiguration config) + { + super(config); + } + + // Use to get a proxy class for ScanPSService + private java.lang.String ScanPSService_address = "http://localhost:8080/TestJWS/services/ScanPSService"; + + public java.lang.String getSeqSeachServiceAddress() + { + return ScanPSService_address; + } + + // The WSDD service name defaults to the port name. + private java.lang.String ScanPSServiceWSDDServiceName = "ScanPSService"; + + public java.lang.String getScanPSServiceWSDDServiceName() + { + return ScanPSServiceWSDDServiceName; + } + + public void setScanPSServiceWSDDServiceName(java.lang.String name) + { + ScanPSServiceWSDDServiceName = name; + } + + public ext.vamsas.SeqSearchI getSeqSearchService() + throws javax.xml.rpc.ServiceException + { + java.net.URL endpoint; + try + { + endpoint = new java.net.URL(ScanPSService_address); + } catch (java.net.MalformedURLException e) + { + throw new javax.xml.rpc.ServiceException(e); } - - - public SeqSearchServiceLocator(org.apache.axis.EngineConfiguration config) { - super(config); + return getSeqSearchService(endpoint); + } + + public ext.vamsas.SeqSearchI getSeqSearchService(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException + { + try + { + ext.vamsas.SeqSearchServiceSoapBindingStub _stub = new ext.vamsas.SeqSearchServiceSoapBindingStub( + portAddress, this); + _stub.setPortName(getScanPSServiceWSDDServiceName()); + return _stub; + } catch (org.apache.axis.AxisFault e) + { + return null; } - - // Use to get a proxy class for ScanPSService - private java.lang.String ScanPSService_address = "http://localhost:8080/TestJWS/services/ScanPSService"; - - public java.lang.String getSeqSeachServiceAddress() { - return ScanPSService_address; + } + + public void setScanPSServiceEndpointAddress(java.lang.String address) + { + ScanPSService_address = address; + } + + /** + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + try + { + if (ext.vamsas.SeqSearchI.class + .isAssignableFrom(serviceEndpointInterface)) + { + ext.vamsas.SeqSearchServiceSoapBindingStub _stub = new ext.vamsas.SeqSearchServiceSoapBindingStub( + new java.net.URL(ScanPSService_address), this); + _stub.setPortName(getScanPSServiceWSDDServiceName()); + return _stub; + } + } catch (java.lang.Throwable t) + { + throw new javax.xml.rpc.ServiceException(t); } - - // The WSDD service name defaults to the port name. - private java.lang.String ScanPSServiceWSDDServiceName = "ScanPSService"; - - public java.lang.String getScanPSServiceWSDDServiceName() { - return ScanPSServiceWSDDServiceName; + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + (serviceEndpointInterface == null ? "null" + : serviceEndpointInterface.getName())); + } + + /** + * For the given interface, get the stub implementation. If this service has + * no port for the given interface, then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException + { + if (portName == null) + { + return getPort(serviceEndpointInterface); } - - public void setScanPSServiceWSDDServiceName(java.lang.String name) { - ScanPSServiceWSDDServiceName = name; + java.lang.String inputPortName = portName.getLocalPart(); + if ("ScanPSService".equals(inputPortName)) + { + return getSeqSearchService(); } - - public ext.vamsas.SeqSearchI getSeqSearchService() throws javax.xml.rpc.ServiceException { - java.net.URL endpoint; - try { - endpoint = new java.net.URL(ScanPSService_address); - } - catch (java.net.MalformedURLException e) { - throw new javax.xml.rpc.ServiceException(e); - } - return getSeqSearchService(endpoint); + else + { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + return _stub; } + } - public ext.vamsas.SeqSearchI getSeqSearchService(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { - try { - ext.vamsas.SeqSearchServiceSoapBindingStub _stub = new ext.vamsas.SeqSearchServiceSoapBindingStub(portAddress, this); - _stub.setPortName(getScanPSServiceWSDDServiceName()); - return _stub; - } - catch (org.apache.axis.AxisFault e) { - return null; - } - } + public javax.xml.namespace.QName getServiceName() + { + return new javax.xml.namespace.QName("vamsas", "ScanPSServiceService"); + } - public void setScanPSServiceEndpointAddress(java.lang.String address) { - ScanPSService_address = address; - } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - try { - if (ext.vamsas.SeqSearchI.class.isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.SeqSearchServiceSoapBindingStub _stub = new ext.vamsas.SeqSearchServiceSoapBindingStub(new java.net.URL(ScanPSService_address), this); - _stub.setPortName(getScanPSServiceWSDDServiceName()); - return _stub; - } - } - catch (java.lang.Throwable t) { - throw new javax.xml.rpc.ServiceException(t); - } - throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); - } - - /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - if (portName == null) { - return getPort(serviceEndpointInterface); - } - java.lang.String inputPortName = portName.getLocalPart(); - if ("ScanPSService".equals(inputPortName)) { - return getSeqSearchService(); - } - else { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ((org.apache.axis.client.Stub) _stub).setPortName(portName); - return _stub; - } - } + private java.util.HashSet ports = null; - public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("vamsas", "ScanPSServiceService"); + public java.util.Iterator getPorts() + { + if (ports == null) + { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "ScanPSService")); } - - private java.util.HashSet ports = null; - - public java.util.Iterator getPorts() { - if (ports == null) { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "ScanPSService")); - } - return ports.iterator(); + return ports.iterator(); + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) throws javax.xml.rpc.ServiceException + { + if ("ScanPSService".equals(portName)) + { + setScanPSServiceEndpointAddress(address); } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - if ("ScanPSService".equals(portName)) { - setScanPSServiceEndpointAddress(address); - } - else { // Unknown Port Name - throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); - } - } - - /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - setEndpointAddress(portName.getLocalPart(), address); + else + { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); } + } + + /** + * Set the endpoint address for the specified port name. + */ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) throws javax.xml.rpc.ServiceException + { + setEndpointAddress(portName.getLocalPart(), address); + } } diff --git a/src/ext/vamsas/SeqSearchServiceService.java b/src/ext/vamsas/SeqSearchServiceService.java index 0dd4c14..1775b9d 100644 --- a/src/ext/vamsas/SeqSearchServiceService.java +++ b/src/ext/vamsas/SeqSearchServiceService.java @@ -1,16 +1,30 @@ -/** - * ScanPSServiceService.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public interface SeqSearchServiceService extends javax.xml.rpc.Service { - public java.lang.String getSeqSeachServiceAddress(); +public interface SeqSearchServiceService extends javax.xml.rpc.Service +{ + public java.lang.String getSeqSeachServiceAddress(); - public ext.vamsas.SeqSearchI getSeqSearchService() throws javax.xml.rpc.ServiceException; + public ext.vamsas.SeqSearchI getSeqSearchService() + throws javax.xml.rpc.ServiceException; - public ext.vamsas.SeqSearchI getSeqSearchService(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; + public ext.vamsas.SeqSearchI getSeqSearchService(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; } diff --git a/src/ext/vamsas/SeqSearchServiceSoapBindingStub.java b/src/ext/vamsas/SeqSearchServiceSoapBindingStub.java index 614a85f..11e307b 100644 --- a/src/ext/vamsas/SeqSearchServiceSoapBindingStub.java +++ b/src/ext/vamsas/SeqSearchServiceSoapBindingStub.java @@ -1,366 +1,501 @@ -/** - * ScanPSServiceSoapBindingStub.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class SeqSearchServiceSoapBindingStub extends org.apache.axis.client.Stub implements ext.vamsas.SeqSearchI { - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); - - static org.apache.axis.description.OperationDesc [] _operations; - - static { - _operations = new org.apache.axis.description.OperationDesc[5]; - _initOperationDesc1(); - } - - private static void _initOperationDesc1(){ - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getDatabase"); - oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - oper.setReturnClass(java.lang.String.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getDatabaseReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[0] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getResult"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "SeqSearchResult")); - oper.setReturnClass(vamsas.objects.simple.SeqSearchResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getResultReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[1] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("psearch"); - oper.addParameter(new javax.xml.namespace.QName("", "al"), new javax.xml.namespace.QName("simple.objects.vamsas", "Alignment"), vamsas.objects.simple.Alignment.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.addParameter(new javax.xml.namespace.QName("", "database"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "psearchReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[2] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("search"); - oper.addParameter(new javax.xml.namespace.QName("", "s"), new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"), vamsas.objects.simple.Sequence.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.addParameter(new javax.xml.namespace.QName("", "database"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "searchReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[3] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("cancel"); - oper.addParameter(new javax.xml.namespace.QName("", "jobId"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[4] = oper; - +public class SeqSearchServiceSoapBindingStub extends + org.apache.axis.client.Stub implements ext.vamsas.SeqSearchI +{ + private java.util.Vector cachedSerClasses = new java.util.Vector(); + + private java.util.Vector cachedSerQNames = new java.util.Vector(); + + private java.util.Vector cachedSerFactories = new java.util.Vector(); + + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + static org.apache.axis.description.OperationDesc[] _operations; + + static + { + _operations = new org.apache.axis.description.OperationDesc[5]; + _initOperationDesc1(); + } + + private static void _initOperationDesc1() + { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getDatabase"); + oper.setReturnType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("", + "getDatabaseReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getResult"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "SeqSearchResult")); + oper.setReturnClass(vamsas.objects.simple.SeqSearchResult.class); + oper + .setReturnQName(new javax.xml.namespace.QName("", + "getResultReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("psearch"); + oper.addParameter(new javax.xml.namespace.QName("", "al"), + new javax.xml.namespace.QName("simple.objects.vamsas", + "Alignment"), vamsas.objects.simple.Alignment.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.addParameter(new javax.xml.namespace.QName("", "database"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "psearchReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("search"); + oper.addParameter(new javax.xml.namespace.QName("", "s"), + new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"), vamsas.objects.simple.Sequence.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.addParameter(new javax.xml.namespace.QName("", "database"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "searchReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[3] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("cancel"); + oper.addParameter(new javax.xml.namespace.QName("", "jobId"), + new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string"), + java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[4] = oper; + + } + + public SeqSearchServiceSoapBindingStub() throws org.apache.axis.AxisFault + { + this(null); + } + + public SeqSearchServiceSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) throws org.apache.axis.AxisFault + { + this(service); + super.cachedEndpoint = endpointURL; + } + + public SeqSearchServiceSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault + { + if (service == null) + { + super.service = new org.apache.axis.client.Service(); } - - public SeqSearchServiceSoapBindingStub() throws org.apache.axis.AxisFault { - this(null); - } - - public SeqSearchServiceSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - this(service); - super.cachedEndpoint = endpointURL; + else + { + super.service = service; } - - public SeqSearchServiceSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - if (service == null) { - super.service = new org.apache.axis.client.Service(); - } else { - super.service = service; + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Result.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "WsJobId"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.WsJobId.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Object"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Object.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); + cachedSerQNames.add(qName); + cls = java.lang.String[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Alignment"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Alignment.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "SeqSearchResult"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.SeqSearchResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "SequenceSet"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.SequenceSet.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + } + + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException + { + try + { + org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service + .createCall(); + if (super.maintainSessionSet) + { + _call.setMaintainSession(super.maintainSession); + } + if (super.cachedUsername != null) + { + _call.setUsername(super.cachedUsername); + } + if (super.cachedPassword != null) + { + _call.setPassword(super.cachedPassword); + } + if (super.cachedEndpoint != null) + { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + if (super.cachedTimeout != null) + { + _call.setTimeout(super.cachedTimeout); + } + if (super.cachedPortName != null) + { + _call.setPortName(super.cachedPortName); + } + java.util.Enumeration keys = super.cachedProperties.keys(); + while (keys.hasMoreElements()) + { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) + { + if (firstCall()) + { + // must set encoding style before registering serializers + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + for (int i = 0; i < cachedSerFactories.size(); ++i) + { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames + .get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories + .get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories + .get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } } - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; - java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Result.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.WsJobId.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", "Object"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Object.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); - cachedSerQNames.add(qName); - cls = java.lang.String[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Alignment"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Alignment.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "SeqSearchResult"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.SeqSearchResult.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "SequenceSet"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.SequenceSet.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - + } + return _call; + } catch (java.lang.Throwable _t) + { + throw new org.apache.axis.AxisFault( + "Failure trying to get the Call object", _t); } + } - protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { - try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call) super.service.createCall(); - if (super.maintainSessionSet) { - _call.setMaintainSession(super.maintainSession); - } - if (super.cachedUsername != null) { - _call.setUsername(super.cachedUsername); - } - if (super.cachedPassword != null) { - _call.setPassword(super.cachedPassword); - } - if (super.cachedEndpoint != null) { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - if (super.cachedTimeout != null) { - _call.setTimeout(super.cachedTimeout); - } - if (super.cachedPortName != null) { - _call.setPortName(super.cachedPortName); - } - java.util.Enumeration keys = super.cachedProperties.keys(); - while (keys.hasMoreElements()) { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) { - if (firstCall()) { - // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); - for (int i = 0; i < cachedSerFactories.size(); ++i) { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - return _call; - } - catch (java.lang.Throwable _t) { - throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); - } + public java.lang.String getDatabase() throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); } - - public java.lang.String getDatabase() throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getDatabase")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (java.lang.String) _resp; - } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); - } - } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getDatabase")); + + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + {}); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; } - - public vamsas.objects.simple.SeqSearchResult getResult(java.lang.String job_id) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[1]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getResult")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {job_id}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.SeqSearchResult) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.SeqSearchResult) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.SeqSearchResult.class); - } - } + else + { + extractAttachments(_call); + try + { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) + { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert( + _resp, java.lang.String.class); + } } - - public vamsas.objects.simple.WsJobId psearch(vamsas.objects.simple.Alignment al, java.lang.String database) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[2]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "psearch")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {al, database}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } + } + + public vamsas.objects.simple.SeqSearchResult getResult( + java.lang.String job_id) throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); } - - public vamsas.objects.simple.WsJobId search(vamsas.objects.simple.Sequence s, java.lang.String database) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[3]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "search")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {s, database}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getResult")); + + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { job_id }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; } - - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[4]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "cancel")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {jobId}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } + else + { + extractAttachments(_call); + try + { + return (vamsas.objects.simple.SeqSearchResult) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.SeqSearchResult) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.SeqSearchResult.class); + } + } + } + + public vamsas.objects.simple.WsJobId psearch( + vamsas.objects.simple.Alignment al, java.lang.String database) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "psearch")); + + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { al, database }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.WsJobId.class); + } + } + } + + public vamsas.objects.simple.WsJobId search( + vamsas.objects.simple.Sequence s, java.lang.String database) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call + .setOperationName(new javax.xml.namespace.QName("vamsas", + "search")); + + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { s, database }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.WsJobId.class); + } + } + } + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException + { + if (super.cachedEndpoint == null) + { + throw new org.apache.axis.NoEndPointException(); + } + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[4]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call + .setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call + .setOperationName(new javax.xml.namespace.QName("vamsas", + "cancel")); + + setRequestHeaders(_call); + setAttachments(_call); + java.lang.Object _resp = _call.invoke(new java.lang.Object[] + { jobId }); + + if (_resp instanceof java.rmi.RemoteException) + { + throw (java.rmi.RemoteException) _resp; + } + else + { + extractAttachments(_call); + try + { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) + { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils + .convert(_resp, vamsas.objects.simple.WsJobId.class); + } } + } } diff --git a/src/ext/vamsas/ServiceHandle.java b/src/ext/vamsas/ServiceHandle.java index 994ea5c..8b15688 100755 --- a/src/ext/vamsas/ServiceHandle.java +++ b/src/ext/vamsas/ServiceHandle.java @@ -1,29 +1,40 @@ -/** - * ServiceHandle.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class ServiceHandle - implements java.io.Serializable +public class ServiceHandle implements java.io.Serializable { private java.lang.String abstractName; + private java.lang.String description; + private java.lang.String endpointURL; + private java.lang.String name; public ServiceHandle() { } - public ServiceHandle( - java.lang.String abstractName, - java.lang.String description, - java.lang.String endpointURL, - java.lang.String name) + public ServiceHandle(java.lang.String abstractName, + java.lang.String description, java.lang.String endpointURL, + java.lang.String name) { this.abstractName = abstractName; this.description = description; @@ -33,7 +44,7 @@ public class ServiceHandle /** * Gets the abstractName value for this ServiceHandle. - * + * * @return abstractName */ public java.lang.String getAbstractName() @@ -43,7 +54,7 @@ public class ServiceHandle /** * Sets the abstractName value for this ServiceHandle. - * + * * @param abstractName */ public void setAbstractName(java.lang.String abstractName) @@ -53,7 +64,7 @@ public class ServiceHandle /** * Gets the description value for this ServiceHandle. - * + * * @return description */ public java.lang.String getDescription() @@ -63,7 +74,7 @@ public class ServiceHandle /** * Sets the description value for this ServiceHandle. - * + * * @param description */ public void setDescription(java.lang.String description) @@ -73,7 +84,7 @@ public class ServiceHandle /** * Gets the endpointURL value for this ServiceHandle. - * + * * @return endpointURL */ public java.lang.String getEndpointURL() @@ -83,7 +94,7 @@ public class ServiceHandle /** * Sets the endpointURL value for this ServiceHandle. - * + * * @param endpointURL */ public void setEndpointURL(java.lang.String endpointURL) @@ -93,7 +104,7 @@ public class ServiceHandle /** * Gets the name value for this ServiceHandle. - * + * * @return name */ public java.lang.String getName() @@ -103,7 +114,7 @@ public class ServiceHandle /** * Sets the name value for this ServiceHandle. - * + * * @param name */ public void setName(java.lang.String name) @@ -112,9 +123,10 @@ public class ServiceHandle } private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { - if (! (obj instanceof ServiceHandle)) + if (!(obj instanceof ServiceHandle)) { return false; } @@ -133,24 +145,21 @@ public class ServiceHandle } __equalsCalc = obj; boolean _equals; - _equals = true && - ( (this.abstractName == null && other.getAbstractName() == null) || - (this.abstractName != null && - this.abstractName.equals(other.getAbstractName()))) && - ( (this.description == null && other.getDescription() == null) || - (this.description != null && - this.description.equals(other.getDescription()))) && - ( (this.endpointURL == null && other.getEndpointURL() == null) || - (this.endpointURL != null && - this.endpointURL.equals(other.getEndpointURL()))) && - ( (this.name == null && other.getName() == null) || - (this.name != null && - this.name.equals(other.getName()))); + _equals = true + && ((this.abstractName == null && other.getAbstractName() == null) || (this.abstractName != null && this.abstractName + .equals(other.getAbstractName()))) + && ((this.description == null && other.getDescription() == null) || (this.description != null && this.description + .equals(other.getDescription()))) + && ((this.endpointURL == null && other.getEndpointURL() == null) || (this.endpointURL != null && this.endpointURL + .equals(other.getEndpointURL()))) + && ((this.name == null && other.getName() == null) || (this.name != null && this.name + .equals(other.getName()))); __equalsCalc = null; return _equals; } private boolean __hashCodeCalc = false; + public synchronized int hashCode() { if (__hashCodeCalc) @@ -180,37 +189,36 @@ public class ServiceHandle } // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(ServiceHandle.class, true); + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc( + ServiceHandle.class, true); static { - typeDesc.setXmlType(new javax.xml.namespace.QName("registry.objects.vamsas", - "ServiceHandle")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis. - description.ElementDesc(); + typeDesc.setXmlType(new javax.xml.namespace.QName( + "registry.objects.vamsas", "ServiceHandle")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("abstractName"); elemField.setXmlName(new javax.xml.namespace.QName("", "abstractName")); elemField.setXmlType(new javax.xml.namespace.QName( - "http://schemas.xmlsoap.org/soap/encoding/", "string")); + "http://schemas.xmlsoap.org/soap/encoding/", "string")); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("description"); elemField.setXmlName(new javax.xml.namespace.QName("", "description")); elemField.setXmlType(new javax.xml.namespace.QName( - "http://schemas.xmlsoap.org/soap/encoding/", "string")); + "http://schemas.xmlsoap.org/soap/encoding/", "string")); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("endpointURL"); elemField.setXmlName(new javax.xml.namespace.QName("", "endpointURL")); elemField.setXmlType(new javax.xml.namespace.QName( - "http://schemas.xmlsoap.org/soap/encoding/", "string")); + "http://schemas.xmlsoap.org/soap/encoding/", "string")); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("name"); elemField.setXmlName(new javax.xml.namespace.QName("", "name")); elemField.setXmlType(new javax.xml.namespace.QName( - "http://schemas.xmlsoap.org/soap/encoding/", "string")); + "http://schemas.xmlsoap.org/soap/encoding/", "string")); typeDesc.addFieldDesc(elemField); } @@ -226,26 +234,22 @@ public class ServiceHandle * Get Custom Serializer */ public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); } /** * Get Custom Deserializer */ public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); } } diff --git a/src/ext/vamsas/ServiceHandles.java b/src/ext/vamsas/ServiceHandles.java index 1de1345..60e4ffd 100755 --- a/src/ext/vamsas/ServiceHandles.java +++ b/src/ext/vamsas/ServiceHandles.java @@ -1,14 +1,24 @@ -/** - * ServiceHandles.java - * - * This file was auto-generated from WSDL - * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package ext.vamsas; -public class ServiceHandles - implements java.io.Serializable +public class ServiceHandles implements java.io.Serializable { private ext.vamsas.ServiceHandle[] services; @@ -16,15 +26,14 @@ public class ServiceHandles { } - public ServiceHandles( - ext.vamsas.ServiceHandle[] services) + public ServiceHandles(ext.vamsas.ServiceHandle[] services) { this.services = services; } /** * Gets the services value for this ServiceHandles. - * + * * @return services */ public ext.vamsas.ServiceHandle[] getServices() @@ -34,7 +43,7 @@ public class ServiceHandles /** * Sets the services value for this ServiceHandles. - * + * * @param services */ public void setServices(ext.vamsas.ServiceHandle[] services) @@ -43,9 +52,10 @@ public class ServiceHandles } private java.lang.Object __equalsCalc = null; + public synchronized boolean equals(java.lang.Object obj) { - if (! (obj instanceof ServiceHandles)) + if (!(obj instanceof ServiceHandles)) { return false; } @@ -64,15 +74,14 @@ public class ServiceHandles } __equalsCalc = obj; boolean _equals; - _equals = true && - ( (this.services == null && other.getServices() == null) || - (this.services != null && - java.util.Arrays.equals(this.services, other.getServices()))); + _equals = true && ((this.services == null && other.getServices() == null) || (this.services != null && java.util.Arrays + .equals(this.services, other.getServices()))); __equalsCalc = null; return _equals; } private boolean __hashCodeCalc = false; + public synchronized int hashCode() { if (__hashCodeCalc) @@ -83,13 +92,11 @@ public class ServiceHandles int _hashCode = 1; if (getServices() != null) { - for (int i = 0; - i < java.lang.reflect.Array.getLength(getServices()); - i++) + for (int i = 0; i < java.lang.reflect.Array.getLength(getServices()); i++) { - java.lang.Object obj = java.lang.reflect.Array.get(getServices(), i); - if (obj != null && - !obj.getClass().isArray()) + java.lang.Object obj = java.lang.reflect.Array + .get(getServices(), i); + if (obj != null && !obj.getClass().isArray()) { _hashCode += obj.hashCode(); } @@ -100,19 +107,18 @@ public class ServiceHandles } // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(ServiceHandles.class, true); + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc( + ServiceHandles.class, true); static { - typeDesc.setXmlType(new javax.xml.namespace.QName("registry.objects.vamsas", - "ServiceHandles")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis. - description.ElementDesc(); + typeDesc.setXmlType(new javax.xml.namespace.QName( + "registry.objects.vamsas", "ServiceHandles")); + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("services"); elemField.setXmlName(new javax.xml.namespace.QName("", "services")); elemField.setXmlType(new javax.xml.namespace.QName( - "registry.objects.vamsas", "ServiceHandle")); + "registry.objects.vamsas", "ServiceHandle")); typeDesc.addFieldDesc(elemField); } @@ -128,26 +134,22 @@ public class ServiceHandles * Get Custom Serializer */ public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); } /** * Get Custom Deserializer */ public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); } } diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index 03cdc15..36534a3 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -1,156 +1,159 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package jalview.analysis; - -import java.util.*; - -import jalview.datamodel.*; - -/** - * Takes in a vector or array of sequences and column start and column end - * and returns a new Hashtable[] of size maxSeqLength, if Hashtable not supplied. - * This class is used extensively in calculating alignment colourschemes - * that depend on the amount of conservation in each alignment column. - * @author $author$ - * @version $Revision$ - */ -public class AAFrequency -{ - //No need to store 1000s of strings which are not - //visible to the user. - public static final String MAXCOUNT = "C"; - public static final String MAXRESIDUE = "R"; - public static final String PID_GAPS = "G"; - public static final String PID_NOGAPS = "N"; - - public static final Hashtable[] calculate(Vector sequences, int start, - int end) - { - SequenceI[] seqs = new SequenceI[sequences.size()]; - int width = 0; - for (int i = 0; i < sequences.size(); i++) - { - seqs[i] = (SequenceI) sequences.elementAt(i); - if (seqs[i].getLength() > width) - { - width = seqs[i].getLength(); - } - } - - Hashtable[] reply = new Hashtable[width]; - - if (end >= width) - { - end = width; - } - - calculate(seqs, start, end, reply); - - return reply; - } - - public static final void calculate(SequenceI[] sequences, - int start, int end, - Hashtable[] result) - { - Hashtable residueHash; - int maxCount, nongap, i, j, v, jSize = sequences.length; - String maxResidue; - char c; - float percentage; - - int[] values = new int[255]; - - char[] seq; - - for (i = start; i < end; i++) - { - residueHash = new Hashtable(); - maxCount = 0; - maxResidue = ""; - nongap = 0; - values = new int[255]; - - for (j = 0; j < jSize; j++) - { - seq = sequences[j].getSequence(); - if (seq.length > i) - { - c = seq[i]; - - if (c == '.' || c == ' ') - { - c = '-'; - } - - if (c == '-') - { - values['-']++; - continue; - } - else if ('a' <= c && c <= 'z') - { - c -= 32; //('a' - 'A'); - } - - nongap++; - values[c]++; - - } - else - { - values['-']++; - } - } - - for (v = 'A'; v < 'Z'; v++) - { - if (values[v] < 2 || values[v] < maxCount) - { - continue; - } - - if (values[v] > maxCount) - { - maxResidue = String.valueOf( (char) v); - } - else if (values[v] == maxCount) - { - maxResidue += String.valueOf( (char) v); - } - maxCount = values[v]; - } - - if (maxResidue.length() == 0) - { - maxResidue = "-"; - } - - residueHash.put(MAXCOUNT, new Integer(maxCount)); - residueHash.put(MAXRESIDUE, maxResidue); - - percentage = ( (float) maxCount * 100) / (float) jSize; - residueHash.put(PID_GAPS, new Float(percentage)); - - percentage = ( (float) maxCount * 100) / (float) nongap; - residueHash.put(PID_NOGAPS, new Float(percentage)); - result[i] = residueHash; - } - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.analysis; + +import java.util.*; + +import jalview.datamodel.*; + +/** + * Takes in a vector or array of sequences and column start and column end and + * returns a new Hashtable[] of size maxSeqLength, if Hashtable not supplied. + * This class is used extensively in calculating alignment colourschemes that + * depend on the amount of conservation in each alignment column. + * + * @author $author$ + * @version $Revision$ + */ +public class AAFrequency +{ + // No need to store 1000s of strings which are not + // visible to the user. + public static final String MAXCOUNT = "C"; + + public static final String MAXRESIDUE = "R"; + + public static final String PID_GAPS = "G"; + + public static final String PID_NOGAPS = "N"; + + public static final Hashtable[] calculate(Vector sequences, int start, + int end) + { + SequenceI[] seqs = new SequenceI[sequences.size()]; + int width = 0; + for (int i = 0; i < sequences.size(); i++) + { + seqs[i] = (SequenceI) sequences.elementAt(i); + if (seqs[i].getLength() > width) + { + width = seqs[i].getLength(); + } + } + + Hashtable[] reply = new Hashtable[width]; + + if (end >= width) + { + end = width; + } + + calculate(seqs, start, end, reply); + + return reply; + } + + public static final void calculate(SequenceI[] sequences, int start, + int end, Hashtable[] result) + { + Hashtable residueHash; + int maxCount, nongap, i, j, v, jSize = sequences.length; + String maxResidue; + char c; + float percentage; + + int[] values = new int[255]; + + char[] seq; + + for (i = start; i < end; i++) + { + residueHash = new Hashtable(); + maxCount = 0; + maxResidue = ""; + nongap = 0; + values = new int[255]; + + for (j = 0; j < jSize; j++) + { + seq = sequences[j].getSequence(); + if (seq.length > i) + { + c = seq[i]; + + if (c == '.' || c == ' ') + { + c = '-'; + } + + if (c == '-') + { + values['-']++; + continue; + } + else if ('a' <= c && c <= 'z') + { + c -= 32; // ('a' - 'A'); + } + + nongap++; + values[c]++; + + } + else + { + values['-']++; + } + } + + for (v = 'A'; v < 'Z'; v++) + { + if (values[v] < 2 || values[v] < maxCount) + { + continue; + } + + if (values[v] > maxCount) + { + maxResidue = String.valueOf((char) v); + } + else if (values[v] == maxCount) + { + maxResidue += String.valueOf((char) v); + } + maxCount = values[v]; + } + + if (maxResidue.length() == 0) + { + maxResidue = "-"; + } + + residueHash.put(MAXCOUNT, new Integer(maxCount)); + residueHash.put(MAXRESIDUE, maxResidue); + + percentage = ((float) maxCount * 100) / (float) jSize; + residueHash.put(PID_GAPS, new Float(percentage)); + + percentage = ((float) maxCount * 100) / (float) nongap; + residueHash.put(PID_NOGAPS, new Float(percentage)); + result[i] = residueHash; + } + } +} diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 0de8167..c9a8077 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -27,40 +27,55 @@ import jalview.schemes.*; import jalview.util.*; /** - * - * + * + * * @author $author$ * @version $Revision$ */ public class AlignSeq { public static final String PEP = "pep"; + public static final String DNA = "dna"; - + static String[] dna = - { - "A", "C", "G", "T", "-"}; - //"C", "T", "A", "G", "-"}; + { "A", "C", "G", "T", "-" }; + + // "C", "T", "A", "G", "-"}; static String[] pep = - { - "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", - "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" - }; + { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", + "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" }; + int[][] score; + int[][] E; + int[][] F; + int[][] traceback; + int[] seq1; + int[] seq2; + SequenceI s1; + SequenceI s2; + public String s1str; + public String s2str; + int maxi; + int maxj; + int[] aseq1; + int[] aseq2; + public String astr1 = ""; + public String astr2 = ""; /** DOCUMENT ME!! */ @@ -74,51 +89,65 @@ public class AlignSeq /** DOCUMENT ME!! */ public int seq2end; + int count; /** DOCUMENT ME!! */ public int maxscore; + float pid; + int prev = 0; + int gapOpen = 120; + int gapExtend = 20; + int[][] lookup = ResidueProperties.getBLOSUM62(); + String[] intToStr = pep; + int defInt = 23; + StringBuffer output = new StringBuffer(); + String type; /** * Creates a new AlignSeq object. - * - * @param s1 DOCUMENT ME! - * @param s2 DOCUMENT ME! - * @param type DOCUMENT ME! + * + * @param s1 + * DOCUMENT ME! + * @param s2 + * DOCUMENT ME! + * @param type + * DOCUMENT ME! */ public AlignSeq(SequenceI s1, SequenceI s2, String type) { - SeqInit(s1, s1.getSequenceAsString(), s2, s2.getSequenceAsString(), type); + SeqInit(s1, s1.getSequenceAsString(), s2, s2.getSequenceAsString(), + type); } /** * Creates a new AlignSeq object. - * - * @param s1 DOCUMENT ME! - * @param s2 DOCUMENT ME! - * @param type DOCUMENT ME! + * + * @param s1 + * DOCUMENT ME! + * @param s2 + * DOCUMENT ME! + * @param type + * DOCUMENT ME! */ - public AlignSeq(SequenceI s1, - String string1, - SequenceI s2, - String string2, - String type) + public AlignSeq(SequenceI s1, String string1, SequenceI s2, + String string2, String type) { SeqInit(s1, string1, s2, string2, type); } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int getMaxScore() @@ -128,7 +157,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int getSeq2Start() @@ -138,7 +167,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int getSeq2End() @@ -148,7 +177,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int getSeq1Start() @@ -158,7 +187,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int getSeq1End() @@ -168,7 +197,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public String getOutput() @@ -178,7 +207,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public String getAStr1() @@ -188,7 +217,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public String getAStr2() @@ -198,7 +227,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int[] getASeq1() @@ -208,7 +237,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public int[] getASeq2() @@ -218,7 +247,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public SequenceI getS1() @@ -228,7 +257,7 @@ public class AlignSeq /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ public SequenceI getS2() @@ -238,18 +267,20 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param s1 DOCUMENT ME! - * @param string1 - string to align for sequence1 - * @param s2 sequence 2 - * @param string2 - string to align for sequence2 - * @param type DNA or PEPTIDE + * + * @param s1 + * DOCUMENT ME! + * @param string1 - + * string to align for sequence1 + * @param s2 + * sequence 2 + * @param string2 - + * string to align for sequence2 + * @param type + * DNA or PEPTIDE */ - public void SeqInit(SequenceI s1, - String string1, - SequenceI s2, - String string2, - String type) + public void SeqInit(SequenceI s1, String string1, SequenceI s2, + String string2, String type) { this.s1 = s1; this.s2 = s2; @@ -257,11 +288,8 @@ public class AlignSeq SeqInit(string1, string2); } - public void SeqInit(SequenceI s1, - String string1, - SequenceI s2, - String string2, - ScoreMatrix scoreMatrix) + public void SeqInit(SequenceI s1, String string1, SequenceI s2, + String string2, ScoreMatrix scoreMatrix) { this.s1 = s1; this.s2 = s2; @@ -270,7 +298,9 @@ public class AlignSeq } /** - * construct score matrix for string1 and string2 (after removing any existing gaps + * construct score matrix for string1 and string2 (after removing any existing + * gaps + * * @param string1 * @param string2 */ @@ -281,51 +311,53 @@ public class AlignSeq if (s1str.length() == 0 || s2str.length() == 0) { - output.append("ALL GAPS: " + - (s1str.length() == 0 ? s1.getName() : " ") - + (s2str.length() == 0 ? s2.getName() : "")); + output.append("ALL GAPS: " + + (s1str.length() == 0 ? s1.getName() : " ") + + (s2str.length() == 0 ? s2.getName() : "")); return; } - //System.out.println("lookuip " + rt.freeMemory() + " "+ rt.totalMemory()); + // System.out.println("lookuip " + rt.freeMemory() + " "+ rt.totalMemory()); seq1 = new int[s1str.length()]; - //System.out.println("seq1 " + rt.freeMemory() +" " + rt.totalMemory()); + // System.out.println("seq1 " + rt.freeMemory() +" " + rt.totalMemory()); seq2 = new int[s2str.length()]; - //System.out.println("seq2 " + rt.freeMemory() + " " + rt.totalMemory()); + // System.out.println("seq2 " + rt.freeMemory() + " " + rt.totalMemory()); score = new int[s1str.length()][s2str.length()]; - //System.out.println("score " + rt.freeMemory() + " " + rt.totalMemory()); + // System.out.println("score " + rt.freeMemory() + " " + rt.totalMemory()); E = new int[s1str.length()][s2str.length()]; - //System.out.println("E " + rt.freeMemory() + " " + rt.totalMemory()); + // System.out.println("E " + rt.freeMemory() + " " + rt.totalMemory()); F = new int[s1str.length()][s2str.length()]; traceback = new int[s1str.length()][s2str.length()]; - //System.out.println("F " + rt.freeMemory() + " " + rt.totalMemory()); + // System.out.println("F " + rt.freeMemory() + " " + rt.totalMemory()); seq1 = stringToInt(s1str, type); - //System.out.println("seq1 " + rt.freeMemory() + " " + rt.totalMemory()); + // System.out.println("seq1 " + rt.freeMemory() + " " + rt.totalMemory()); seq2 = stringToInt(s2str, type); - //System.out.println("Seq2 " + rt.freeMemory() + " " + rt.totalMemory()); - // long tstart = System.currentTimeMillis(); - // calcScoreMatrix(); - //long tend = System.currentTimeMillis(); - //System.out.println("Time take to calculate score matrix = " + (tend-tstart) + " ms"); - // printScoreMatrix(score); - //System.out.println(); - //printScoreMatrix(traceback); - //System.out.println(); - // printScoreMatrix(E); - //System.out.println(); - ///printScoreMatrix(F); - //System.out.println(); + // System.out.println("Seq2 " + rt.freeMemory() + " " + rt.totalMemory()); + // long tstart = System.currentTimeMillis(); + // calcScoreMatrix(); + // long tend = System.currentTimeMillis(); + // System.out.println("Time take to calculate score matrix = " + + // (tend-tstart) + " ms"); + // printScoreMatrix(score); + // System.out.println(); + // printScoreMatrix(traceback); + // System.out.println(); + // printScoreMatrix(E); + // System.out.println(); + // /printScoreMatrix(F); + // System.out.println(); // tstart = System.currentTimeMillis(); - //traceAlignment(); - //tend = System.currentTimeMillis(); - //System.out.println("Time take to traceback alignment = " + (tend-tstart) + " ms"); + // traceAlignment(); + // tend = System.currentTimeMillis(); + // System.out.println("Time take to traceback alignment = " + (tend-tstart) + // + " ms"); } private void setDefaultParams(String type) @@ -358,8 +390,8 @@ public class AlignSeq else { output.append("Wrong type = dna or pep only"); - throw new Error("Unknown Type " + type2 + - " - dna or pep are the only allowed values."); + throw new Error("Unknown Type " + type2 + + " - dna or pep are the only allowed values."); } } @@ -391,7 +423,7 @@ public class AlignSeq } } - // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]); + // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]); int i = maxi; int j = maxj; int trace; @@ -405,15 +437,15 @@ public class AlignSeq count = (seq1.length + seq2.length) - 1; - while ( (i > 0) && (j > 0)) + while ((i > 0) && (j > 0)) { - if ( (aseq1[count] != defInt) && (i >= 0)) + if ((aseq1[count] != defInt) && (i >= 0)) { aseq1[count] = seq1[i]; astr1 = s1str.charAt(i) + astr1; } - if ( (aseq2[count] != defInt) && (j > 0)) + if ((aseq2[count] != defInt) && (j > 0)) { aseq2[count] = seq2[j]; astr2 = s2str.charAt(j) + astr2; @@ -463,7 +495,8 @@ public class AlignSeq */ public void printAlignment(java.io.PrintStream os) { - // TODO: Use original sequence characters rather than re-translated characters in output + // TODO: Use original sequence characters rather than re-translated + // characters in output // Find the biggest id length for formatting purposes int maxid = s1.getName().length(); if (s2.getName().length() > maxid) @@ -472,33 +505,31 @@ public class AlignSeq } int len = 72 - maxid - 1; - int nochunks = ( (aseq1.length - count) / len) + 1; + int nochunks = ((aseq1.length - count) / len) + 1; pid = 0; output.append("Score = " + score[maxi][maxj] + "\n"); output.append("Length of alignment = " + (aseq1.length - count) + "\n"); output.append("Sequence "); output.append(new Format("%" + maxid + "s").form(s1.getName())); - output.append(" : " + s1.getStart() + " - " + s1.getEnd() + - " (Sequence length = " + - s1str.length() + ")\n"); + output.append(" : " + s1.getStart() + " - " + s1.getEnd() + + " (Sequence length = " + s1str.length() + ")\n"); output.append("Sequence "); output.append(new Format("%" + maxid + "s").form(s2.getName())); - output.append(" : " + s2.getStart() + " - " + s2.getEnd() + - " (Sequence length = " + - s2str.length() + ")\n\n"); - + output.append(" : " + s2.getStart() + " - " + s2.getEnd() + + " (Sequence length = " + s2str.length() + ")\n\n"); + for (int j = 0; j < nochunks; j++) { // Print the first aligned sequence - output.append(new Format("%" + (maxid) + "s").form(s1.getName()) + " "); + output.append(new Format("%" + (maxid) + "s").form(s1.getName()) + + " "); for (int i = 0; i < len; i++) { - if ( (i + (j * len)) < astr1.length()) + if ((i + (j * len)) < astr1.length()) { - output.append(astr1.charAt(i + - (j * len))); + output.append(astr1.charAt(i + (j * len))); } } @@ -508,19 +539,19 @@ public class AlignSeq // Print out the matching chars for (int i = 0; i < len; i++) { - if ( (i + (j * len)) < astr1.length()) + if ((i + (j * len)) < astr1.length()) { - if (astr1.charAt(i + (j * len))==astr2.charAt(i + (j * len)) && - !jalview.util.Comparison.isGap(astr1.charAt(i + (j * len)))) + if (astr1.charAt(i + (j * len)) == astr2.charAt(i + (j * len)) + && !jalview.util.Comparison.isGap(astr1.charAt(i + + (j * len)))) { pid++; output.append("|"); } else if (type.equals("pep")) { - if (ResidueProperties.getPAM250( - astr1.charAt(i + (j * len)), - astr2.charAt(i + (j * len)))>0) + if (ResidueProperties.getPAM250(astr1.charAt(i + (j * len)), + astr2.charAt(i + (j * len))) > 0) { output.append("."); } @@ -538,12 +569,13 @@ public class AlignSeq // Now print the second aligned sequence output = output.append("\n"); - output = output.append(new Format("%" + (maxid) + "s").form(s2.getName()) + - " "); + output = output.append(new Format("%" + (maxid) + "s").form(s2 + .getName()) + + " "); for (int i = 0; i < len; i++) { - if ( (i + (j * len)) < astr2.length()) + if ((i + (j * len)) < astr2.length()) { output.append(astr2.charAt(i + (j * len))); } @@ -553,20 +585,22 @@ public class AlignSeq } pid = pid / (float) (aseq1.length - count) * 100; - output = output.append(new Format("Percentage ID = %2.2f\n\n").form(pid)); + output = output.append(new Format("Percentage ID = %2.2f\n\n") + .form(pid)); try { os.print(output.toString()); + } catch (Exception ex) + { } - catch (Exception ex) - {} } /** * DOCUMENT ME! - * - * @param mat DOCUMENT ME! + * + * @param mat + * DOCUMENT ME! */ public void printScoreMatrix(int[][] mat) { @@ -604,10 +638,12 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param i DOCUMENT ME! - * @param j DOCUMENT ME! - * + * + * @param i + * DOCUMENT ME! + * @param j + * DOCUMENT ME! + * * @return DOCUMENT ME! */ public int findTrace(int i, int j) @@ -668,8 +704,7 @@ public class AlignSeq E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend); F[0][j] = -gapExtend; - score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, - -gapExtend); + score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, -gapExtend); traceback[0][j] = 1; } @@ -689,13 +724,11 @@ public class AlignSeq { for (int j = 1; j < m; j++) { - E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - - gapExtend); - F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - - gapExtend); + E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - gapExtend); + F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - gapExtend); - score[i][j] = max(score[i - 1][j - 1] + - (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]); + score[i][j] = max(score[i - 1][j - 1] + + (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]); traceback[i][j] = findTrace(i, j); } } @@ -703,10 +736,12 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param gapChar DOCUMENT ME! - * @param seq DOCUMENT ME! - * + * + * @param gapChar + * DOCUMENT ME! + * @param seq + * DOCUMENT ME! + * * @return DOCUMENT ME! */ public static String extractGaps(String gapChar, String seq) @@ -724,11 +759,14 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param i1 DOCUMENT ME! - * @param i2 DOCUMENT ME! - * @param i3 DOCUMENT ME! - * + * + * @param i1 + * DOCUMENT ME! + * @param i2 + * DOCUMENT ME! + * @param i3 + * DOCUMENT ME! + * * @return DOCUMENT ME! */ public int max(int i1, int i2, int i3) @@ -750,10 +788,12 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param i1 DOCUMENT ME! - * @param i2 DOCUMENT ME! - * + * + * @param i1 + * DOCUMENT ME! + * @param i2 + * DOCUMENT ME! + * * @return DOCUMENT ME! */ public int max(int i1, int i2) @@ -770,10 +810,12 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param s DOCUMENT ME! - * @param type DOCUMENT ME! - * + * + * @param s + * DOCUMENT ME! + * @param type + * DOCUMENT ME! + * * @return DOCUMENT ME! */ public int[] stringToInt(String s, String type) @@ -809,8 +851,7 @@ public class AlignSeq } } - } - catch (Exception e) + } catch (Exception e) { if (type.equals("dna")) { @@ -828,15 +869,20 @@ public class AlignSeq /** * DOCUMENT ME! - * - * @param g DOCUMENT ME! - * @param mat DOCUMENT ME! - * @param n DOCUMENT ME! - * @param m DOCUMENT ME! - * @param psize DOCUMENT ME! + * + * @param g + * DOCUMENT ME! + * @param mat + * DOCUMENT ME! + * @param n + * DOCUMENT ME! + * @param m + * DOCUMENT ME! + * @param psize + * DOCUMENT ME! */ public static void displayMatrix(Graphics g, int[][] mat, int n, int m, - int psize) + int psize) { int max = -1000; int min = 1000; @@ -866,12 +912,12 @@ public class AlignSeq int x = psize * i; int y = psize * j; - // System.out.println(mat[i][j]); + // System.out.println(mat[i][j]); float score = (float) (mat[i][j] - min) / (float) (max - min); g.setColor(new Color(score, 0, 0)); g.fillRect(x, y, psize, psize); - // System.out.println(x + " " + y + " " + score); + // System.out.println(x + " " + y + " " + score); } } } diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index a3493f7..fe2cfc7 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -23,34 +23,51 @@ import java.util.*; import jalview.datamodel.*; import jalview.util.*; -/** - * Routines for manipulating the order of a multiple sequence alignment - * TODO: this class retains some global states concerning sort-order which should be made attributes for the caller's alignment visualization. - * TODO: refactor to allow a subset of selected sequences to be sorted within the context of a whole alignment. - * Sort method template is: SequenceI[] tobesorted, [ input data mapping to each tobesorted element to use ], Alignment context of tobesorted that are to be re-ordered, boolean sortinplace, [special data - ie seuqence to be sorted w.r.t.]) - * sortinplace implies that the sorted vector resulting from applying the operation to tobesorted should be mapped back to the original positions in alignment. - * Otherwise, normal behaviour is to re order alignment so that tobesorted is sorted and grouped together starting from the first tobesorted position in the alignment. - * e.g. (a,tb2,b,tb1,c,tb3 becomes a,tb1,tb2,tb3,b,c) +/** + * Routines for manipulating the order of a multiple sequence alignment TODO: + * this class retains some global states concerning sort-order which should be + * made attributes for the caller's alignment visualization. TODO: refactor to + * allow a subset of selected sequences to be sorted within the context of a + * whole alignment. Sort method template is: SequenceI[] tobesorted, [ input + * data mapping to each tobesorted element to use ], Alignment context of + * tobesorted that are to be re-ordered, boolean sortinplace, [special data - ie + * seuqence to be sorted w.r.t.]) sortinplace implies that the sorted vector + * resulting from applying the operation to tobesorted should be mapped back to + * the original positions in alignment. Otherwise, normal behaviour is to re + * order alignment so that tobesorted is sorted and grouped together starting + * from the first tobesorted position in the alignment. e.g. (a,tb2,b,tb1,c,tb3 + * becomes a,tb1,tb2,tb3,b,c) */ public class AlignmentSorter { static boolean sortIdAscending = true; + static int lastGroupHash = 0; + static boolean sortGroupAscending = true; + static AlignmentOrder lastOrder = null; + static boolean sortOrderAscending = true; + static NJTree lastTree = null; + static boolean sortTreeAscending = true; + private static String lastSortByScore; /** * Sort by Percentage Identity w.r.t. s - * - * @param align AlignmentI - * @param s SequenceI - * @param tosort sequences from align that are to be sorted. + * + * @param align + * AlignmentI + * @param s + * SequenceI + * @param tosort + * sequences from align that are to be sorted. */ - public static void sortByPID(AlignmentI align, SequenceI s, SequenceI[] tosort) + public static void sortByPID(AlignmentI align, SequenceI s, + SequenceI[] tosort) { int nSeq = align.getHeight(); @@ -59,8 +76,8 @@ public class AlignmentSorter for (int i = 0; i < nSeq; i++) { - scores[i] = Comparison.PID(align.getSequenceAt(i).getSequenceAsString(), - s.getSequenceAsString()); + scores[i] = Comparison.PID(align.getSequenceAt(i) + .getSequenceAsString(), s.getSequenceAsString()); seqs[i] = align.getSequenceAt(i); } @@ -71,9 +88,11 @@ public class AlignmentSorter /** * Reverse the order of the sort - * - * @param align DOCUMENT ME! - * @param seqs DOCUMENT ME! + * + * @param align + * DOCUMENT ME! + * @param seqs + * DOCUMENT ME! */ private static void setReverseOrder(AlignmentI align, SequenceI[] seqs) { @@ -81,7 +100,7 @@ public class AlignmentSorter int len = 0; - if ( (nSeq % 2) == 0) + if ((nSeq % 2) == 0) { len = nSeq / 2; } @@ -93,7 +112,7 @@ public class AlignmentSorter // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work for (int i = 0; i < len; i++) { - //SequenceI tmp = seqs[i]; + // SequenceI tmp = seqs[i]; align.getSequences().setElementAt(seqs[nSeq - i - 1], i); align.getSequences().setElementAt(seqs[i], nSeq - i - 1); } @@ -101,9 +120,11 @@ public class AlignmentSorter /** * Sets the Alignment object with the given sequences - * - * @param align Alignment object to be updated - * @param tmp sequences as a vector + * + * @param align + * Alignment object to be updated + * @param tmp + * sequences as a vector */ private static void setOrder(AlignmentI align, Vector tmp) { @@ -112,9 +133,11 @@ public class AlignmentSorter /** * Sets the Alignment object with the given sequences - * - * @param align DOCUMENT ME! - * @param seqs sequences as an array + * + * @param align + * DOCUMENT ME! + * @param seqs + * sequences as an array */ public static void setOrder(AlignmentI align, SequenceI[] seqs) { @@ -131,7 +154,7 @@ public class AlignmentSorter } algn.removeAllElements(); - //User may have hidden seqs, then clicked undo or redo + // User may have hidden seqs, then clicked undo or redo for (int i = 0; i < tmp.size(); i++) { algn.addElement(tmp.elementAt(i)); @@ -141,8 +164,9 @@ public class AlignmentSorter /** * Sorts by ID. Numbers are sorted before letters. - * - * @param align The alignment object to sort + * + * @param align + * The alignment object to sort */ public static void sortByID(AlignmentI align) { @@ -172,16 +196,17 @@ public class AlignmentSorter } /** - * Sorts the alignment by size of group. - *
Maintains the order of sequences in each group - * by order in given alignment object. - * - * @param align sorts the given alignment object by group + * Sorts the alignment by size of group.
+ * Maintains the order of sequences in each group by order in given alignment + * object. + * + * @param align + * sorts the given alignment object by group */ public static void sortByGroup(AlignmentI align) { - //MAINTAINS ORIGNAL SEQUENCE ORDER, - //ORDERS BY GROUP SIZE + // MAINTAINS ORIGNAL SEQUENCE ORDER, + // ORDERS BY GROUP SIZE Vector groups = new Vector(); if (groups.hashCode() != lastGroupHash) @@ -194,8 +219,8 @@ public class AlignmentSorter sortGroupAscending = !sortGroupAscending; } - //SORTS GROUPS BY SIZE - ////////////////////// + // SORTS GROUPS BY SIZE + // //////////////////// for (int i = 0; i < align.getGroups().size(); i++) { SequenceGroup sg = (SequenceGroup) align.getGroups().elementAt(i); @@ -218,8 +243,8 @@ public class AlignmentSorter } } - //NOW ADD SEQUENCES MAINTAINING ALIGNMENT ORDER - /////////////////////////////////////////////// + // NOW ADD SEQUENCES MAINTAINING ALIGNMENT ORDER + // ///////////////////////////////////////////// Vector seqs = new Vector(); for (int i = 0; i < groups.size(); i++) @@ -240,16 +265,16 @@ public class AlignmentSorter else { setReverseOrder(align, - vectorSubsetToArray(seqs, align.getSequences())); + vectorSubsetToArray(seqs, align.getSequences())); } } /** - * Converts Vector to array. - * java 1.18 does not have Vector.toArray() - * - * @param tmp Vector of SequenceI objects - * + * Converts Vector to array. java 1.18 does not have Vector.toArray() + * + * @param tmp + * Vector of SequenceI objects + * * @return array of Sequence[] */ private static SequenceI[] vectorToArray(Vector tmp) @@ -266,10 +291,12 @@ public class AlignmentSorter /** * DOCUMENT ME! - * - * @param tmp DOCUMENT ME! - * @param mask DOCUMENT ME! - * + * + * @param tmp + * DOCUMENT ME! + * @param mask + * DOCUMENT ME! + * * @return DOCUMENT ME! */ private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask) @@ -307,9 +334,11 @@ public class AlignmentSorter /** * Sorts by a given AlignmentOrder object - * - * @param align Alignment to order - * @param order specified order for alignment + * + * @param align + * Alignment to order + * @param order + * specified order for alignment */ public static void sortBy(AlignmentI align, AlignmentOrder order) { @@ -331,17 +360,18 @@ public class AlignmentSorter } else { - setReverseOrder(align, - vectorSubsetToArray(tmp, align.getSequences())); + setReverseOrder(align, vectorSubsetToArray(tmp, align.getSequences())); } } /** * DOCUMENT ME! - * - * @param align alignment to order - * @param tree tree which has - * + * + * @param align + * alignment to order + * @param tree + * tree which has + * * @return DOCUMENT ME! */ private static Vector getOrderByTree(AlignmentI align, NJTree tree) @@ -356,7 +386,7 @@ public class AlignmentSorter { // TODO: JBPNote - decide if this is always an error // (eg. not when a tree is associated to another alignment which has more - // sequences) + // sequences) if (tmp.size() < nSeq) { addStrays(align, tmp); @@ -364,8 +394,8 @@ public class AlignmentSorter if (tmp.size() != nSeq) { - System.err.println("ERROR: tmp.size()=" + tmp.size() + - " != nseq=" + nSeq + " in getOrderByTree"); + System.err.println("ERROR: tmp.size()=" + tmp.size() + " != nseq=" + + nSeq + " in getOrderByTree"); } } @@ -374,9 +404,11 @@ public class AlignmentSorter /** * Sorts the alignment by a given tree - * - * @param align alignment to order - * @param tree tree which has + * + * @param align + * alignment to order + * @param tree + * tree which has */ public static void sortByTree(AlignmentI align, NJTree tree) { @@ -399,16 +431,17 @@ public class AlignmentSorter } else { - setReverseOrder(align, - vectorSubsetToArray(tmp, align.getSequences())); + setReverseOrder(align, vectorSubsetToArray(tmp, align.getSequences())); } } /** * DOCUMENT ME! - * - * @param align DOCUMENT ME! - * @param seqs DOCUMENT ME! + * + * @param align + * DOCUMENT ME! + * @param seqs + * DOCUMENT ME! */ private static void addStrays(AlignmentI align, Vector seqs) { @@ -424,22 +457,25 @@ public class AlignmentSorter if (nSeq != seqs.size()) { - System.err.println( - "ERROR: Size still not right even after addStrays"); + System.err + .println("ERROR: Size still not right even after addStrays"); } } /** * DOCUMENT ME! - * - * @param node DOCUMENT ME! - * @param tmp DOCUMENT ME! - * @param seqset DOCUMENT ME! - * + * + * @param node + * DOCUMENT ME! + * @param tmp + * DOCUMENT ME! + * @param seqset + * DOCUMENT ME! + * * @return DOCUMENT ME! */ private static Vector _sortByTree(SequenceNode node, Vector tmp, - Vector seqset) + Vector seqset) { if (node == null) { @@ -449,7 +485,7 @@ public class AlignmentSorter SequenceNode left = (SequenceNode) node.left(); SequenceNode right = (SequenceNode) node.right(); - if ( (left == null) && (right == null)) + if ((left == null) && (right == null)) { if (!node.isPlaceholder() && (node.element() != null)) { @@ -457,7 +493,7 @@ public class AlignmentSorter { if (!tmp.contains(node.element())) { - tmp.addElement( (SequenceI) node.element()); + tmp.addElement((SequenceI) node.element()); } } } @@ -474,7 +510,8 @@ public class AlignmentSorter } // Ordering Objects - // Alignment.sortBy(OrderObj) - sequence of sequence pointer refs in appropriate order + // Alignment.sortBy(OrderObj) - sequence of sequence pointer refs in + // appropriate order // /** @@ -487,42 +524,52 @@ public class AlignmentSorter for (int i = 0; i < alignment.length; i++) { - ids[i] = (new Float(alignment[i].getName().substring(8))).floatValue(); + ids[i] = (new Float(alignment[i].getName().substring(8))) + .floatValue(); } jalview.util.QuickSort.sort(ids, alignment); } + /** - * Sort sequence in order of increasing score attribute for annotation with a particular - * scoreLabel. Or reverse if same label was used previously - * @param scoreLabel exact label for sequence associated AlignmentAnnotation scores to use for sorting. - * @param alignment sequences to be sorted + * Sort sequence in order of increasing score attribute for annotation with a + * particular scoreLabel. Or reverse if same label was used previously + * + * @param scoreLabel + * exact label for sequence associated AlignmentAnnotation + * scores to use for sorting. + * @param alignment + * sequences to be sorted */ - public static void sortByAnnotationScore(String scoreLabel, AlignmentI alignment) + public static void sortByAnnotationScore(String scoreLabel, + AlignmentI alignment) { SequenceI[] seqs = alignment.getSequencesArray(); - boolean[] hasScore = new boolean[seqs.length]; // per sequence score presence - int hasScores=0; // number of scores present on set + boolean[] hasScore = new boolean[seqs.length]; // per sequence score + // presence + int hasScores = 0; // number of scores present on set double[] scores = new double[seqs.length]; - double min=0,max=0; + double min = 0, max = 0; for (int i = 0; i < seqs.length; i++) { AlignmentAnnotation[] scoreAnn = seqs[i].getAnnotation(scoreLabel); - if (scoreAnn!=null) + if (scoreAnn != null) { hasScores++; hasScore[i] = true; - scores[i] = scoreAnn[0].getScore(); // take the first instance of this score. - if (hasScores==1) + scores[i] = scoreAnn[0].getScore(); // take the first instance of this + // score. + if (hasScores == 1) { max = min = scores[i]; - } else + } + else { - if (maxscores[i]) + if (min > scores[i]) { min = scores[i]; } @@ -533,27 +580,29 @@ public class AlignmentSorter hasScore[i] = false; } } - if (hasScores==0) + if (hasScores == 0) { return; // do nothing - no scores present to sort by. } - if (hasScores max) { max = cons2[i][j]; - * maxi = i; maxj = j; } - * } } + * maxi = i; maxj = j; } } } */ } } diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 159d96a..8bc844b 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.analysis; import java.util.Enumeration; @@ -158,7 +176,8 @@ public class CrossRef { if (cdna[c].getSource().equals(DBRefSource.EMBLCDS)) { - System.err.println("TODO: unimplemented sequence retrieval for coding region sequence."); + System.err + .println("TODO: unimplemented sequence retrieval for coding region sequence."); // TODO: retrieve CDS dataset sequences // need global dataset sequence retriever/resolver to reuse refs // and construct Mapping entry. @@ -306,7 +325,10 @@ public class CrossRef xrfs = t; try { - retrieved = sftch.getSequences(xrfs); // problem here is we don't know which of xrfs resulted in which retrieved element + retrieved = sftch.getSequences(xrfs); // problem here is we don't + // know which of xrfs + // resulted in which + // retrieved element } catch (Exception e) { System.err @@ -319,32 +341,39 @@ public class CrossRef for (int rs = 0; rs < retrieved.length; rs++) { // TODO: examine each sequence for 'redundancy' - jalview.datamodel.DBRefEntry[] dbr = retrieved[rs].getDBRef(); + jalview.datamodel.DBRefEntry[] dbr = retrieved[rs] + .getDBRef(); if (dbr != null && dbr.length > 0) { for (int di = 0; di < dbr.length; di++) { - // find any entry where we should put in the sequence being cross-referenced into the map + // find any entry where we should put in the sequence being + // cross-referenced into the map jalview.datamodel.Mapping map = dbr[di].getMap(); if (map != null) { if (map.getTo() != null && map.getMap() != null) { - // should search the local dataset to find any existing candidates for To ! + // should search the local dataset to find any existing + // candidates for To ! try { - // compare ms with dss and replace with dss in mapping if map is congruent + // compare ms with dss and replace with dss in mapping + // if map is congruent SequenceI ms = map.getTo(); int sf = map.getMap().getToLowest(); int st = map.getMap().getToHighest(); SequenceI mappedrg = ms.getSubSequence(sf, st); SequenceI loc = dss.getSubSequence(sf, st); - if (mappedrg.getLength()>0 && mappedrg.getSequenceAsString().equals( - loc.getSequenceAsString())) + if (mappedrg.getLength() > 0 + && mappedrg.getSequenceAsString().equals( + loc.getSequenceAsString())) { System.err .println("Mapping updated for retrieved crossreference"); - // method to update all refs of existing To on retrieved sequence with dss and merge any props on To onto dss. + // method to update all refs of existing To on + // retrieved sequence with dss and merge any props + // on To onto dss. map.setTo(dss); } } catch (Exception e) @@ -445,7 +474,7 @@ public class CrossRef boolean direct, boolean dna) { boolean found = false; - SequenceI[] typer=new SequenceI[1]; + SequenceI[] typer = new SequenceI[1]; if (dataset == null) return false; if (dataset.getSequences() == null) @@ -470,7 +499,7 @@ public class CrossRef { typer[0] = nxt; boolean isDna = jalview.util.Comparison.isNucleotide(typer); - if ((direct && isDna == dna) || (!direct && isDna!=dna)) + if ((direct && isDna == dna) || (!direct && isDna != dna)) { // skip this sequence because it is same molecule type continue; @@ -550,16 +579,17 @@ public class CrossRef * System.out.println("Found " + ((prod == null) ? "no" : "" + * prod.length) + " products"); if (prod!=null) { for (int p=0; palwidth) + + if (sqstr.length() > alwidth) alwidth = sqstr.length(); cdnasqs.addElement(sqstr.toString()); cdnasqi.addElement(dna); @@ -237,7 +272,8 @@ public class Dna cdnasqs.copyInto(xons); cdnaprod.copyInto(prods); cdnasqi.copyInto(cdna); - return CdnaTranslate(cdna, xons, prods, viscontigs, gapCharacter, null, alwidth, dataset); + return CdnaTranslate(cdna, xons, prods, viscontigs, gapCharacter, + null, alwidth, dataset); } return null; } @@ -282,7 +318,8 @@ public class Dna if (codons.codons[a] != null && codons.codons[a][0] == (codons.codons[a][2] - 2)) { - anots[a] = getCodonAnnotation(codons.codons[a], annotations[i].annotations); + anots[a] = getCodonAnnotation(codons.codons[a], + annotations[i].annotations); } } } @@ -292,9 +329,10 @@ public class Dna aa.graph = annotations[i].graph; aa.graphGroup = annotations[i].graphGroup; aa.graphHeight = annotations[i].graphHeight; - if (annotations[i].getThreshold()!=null) + if (annotations[i].getThreshold() != null) { - aa.setThreshold(new jalview.datamodel.GraphLine(annotations[i].getThreshold())); + aa.setThreshold(new jalview.datamodel.GraphLine(annotations[i] + .getThreshold())); } if (annotations[i].hasScore) { @@ -321,13 +359,14 @@ public class Dna } } - private static Annotation getCodonAnnotation(int[] is, Annotation[] annotations) - { + private static Annotation getCodonAnnotation(int[] is, + Annotation[] annotations) + { // Have a look at all the codon positions for annotation and put the first // one found into the translated annotation pos. - for (int p=0; p<3; p++) + for (int p = 0; p < 3; p++) { - if (annotations[is[p]]!=null) + if (annotations[is[p]] != null) { return new Annotation(annotations[is[p]]); } @@ -338,10 +377,15 @@ public class Dna /** * Translate a na sequence * - * @param selection sequence displayed under viscontigs visible columns - * @param seqstring ORF read in some global alignment reference frame - * @param viscontigs mapping from global reference frame to visible seqstring ORF read - * @param codons Definition of global ORF alignment reference frame + * @param selection + * sequence displayed under viscontigs visible columns + * @param seqstring + * ORF read in some global alignment reference frame + * @param viscontigs + * mapping from global reference frame to visible seqstring ORF + * read + * @param codons + * Definition of global ORF alignment reference frame * @param gapCharacter * @param newSeq * @return sequence ready to be added to alignment. @@ -350,22 +394,25 @@ public class Dna String seqstring, int[] viscontigs, AlignedCodonFrame codons, char gapCharacter, DBRefEntry product) { - Vector skip=new Vector(); - int skipint[]=null; + Vector skip = new Vector(); + int skipint[] = null; ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring // intervals int vc, scontigs[] = new int[viscontigs.length]; int npos = 0; for (vc = 0; vc < viscontigs.length; vc += 2) { - if (vc==0) { - vismapping.addShift(npos, viscontigs[vc]); - } else { + if (vc == 0) + { + vismapping.addShift(npos, viscontigs[vc]); + } + else + { // hidden region - vismapping.addShift(npos, viscontigs[vc]-viscontigs[vc-1]+1); + vismapping.addShift(npos, viscontigs[vc] - viscontigs[vc - 1] + 1); } scontigs[vc] = viscontigs[vc]; - scontigs[vc + 1] = viscontigs[vc+1]; + scontigs[vc + 1] = viscontigs[vc + 1]; } StringBuffer protein = new StringBuffer(); @@ -389,37 +436,42 @@ public class Dna if (aa == null) { aa = String.valueOf(gapCharacter); - if (skipint==null) + if (skipint == null) { - skipint = new int[] { cdp[0],cdp[2] }; + skipint = new int[] + { cdp[0], cdp[2] }; } skipint[1] = cdp[2]; - } else { - if (skipint!=null) + } + else + { + if (skipint != null) { // edit scontigs skipint[0] = vismapping.shift(skipint[0]); skipint[1] = vismapping.shift(skipint[1]); - for (vc=0; vc= codons.aaWidth) - // codons.aaWidth = aspos + 1; + // if (aspos >= codons.aaWidth) + // codons.aaWidth = aspos + 1; break; // check the next position for alignment case 0: // codon aligns at aspos position. @@ -515,8 +567,7 @@ public class Dna for (vc = 0; vc < scontigs.length; vc += 2) { scontigs[vc] = selection.findPosition(scontigs[vc]); // not from 1! - scontigs[vc + 1] = selection - .findPosition(scontigs[vc + 1]); // exclusive + scontigs[vc + 1] = selection.findPosition(scontigs[vc + 1]); // exclusive if (scontigs[vc + 1] == selection.getEnd()) break; } @@ -528,62 +579,35 @@ public class Dna scontigs = t; } /* - * delete intervals in scontigs which are not translated. - * 1. map skip into sequence position intervals - * 2. truncate existing ranges and add new ranges to exclude untranslated regions. - if (skip.size()>0) - { - Vector narange = new Vector(); - for (vc=0; vc=skipint[0] && iv[0]<=skipint[1]) - { - if (iv[0]==skipint[0]) - { - // delete beginning of range - } else { - // truncate range and create new one if necessary - iv = (int[]) narange.elementAt(vc+1); - if (iv[0]<=skipint[1]) - { - // truncate range - iv[0] = skipint[1]; - } else { - - } - } - } else - if (iv[0]0) { + * Vector narange = new Vector(); for (vc=0; vc=skipint[0] && iv[0]<=skipint[1]) { if (iv[0]==skipint[0]) { // + * delete beginning of range } else { // truncate range and create new + * one if necessary iv = (int[]) narange.elementAt(vc+1); if (iv[0]<=skipint[1]) { // + * truncate range iv[0] = skipint[1]; } else { + * } } } else if (iv[0]

Title:

- * - *

Description:

- * - *

Copyright: Copyright (c) 2004

- * - *

Company: Dundee University

- * + *

+ * Title: + *

+ * + *

+ * Description: + *

+ * + *

+ * Copyright: Copyright (c) 2004 + *

+ * + *

+ * Company: Dundee University + *

+ * * @author not attributable * @version 1.0 */ @@ -39,8 +47,10 @@ public class SeqsetUtils /** * Store essential properties of a sequence in a hashtable for later recovery - * Keys are Name, Start, End, SeqFeatures, PdbId - * @param seq SequenceI + * Keys are Name, Start, End, SeqFeatures, PdbId + * + * @param seq + * SequenceI * @return Hashtable */ public static Hashtable SeqCharacterHash(SequenceI seq) @@ -63,19 +73,21 @@ public class SeqsetUtils } } sqinfo.put("SeqFeatures", sfeat); - sqinfo.put("PdbId", - (seq.getPDBId() != null) ? seq.getPDBId() : new Vector()); - sqinfo.put("datasetSequence", - (seq.getDatasetSequence() != null) ? seq.getDatasetSequence() : - new Sequence("THISISAPLACEHOLDER", "")); + sqinfo.put("PdbId", (seq.getPDBId() != null) ? seq.getPDBId() + : new Vector()); + sqinfo.put("datasetSequence", (seq.getDatasetSequence() != null) ? seq + .getDatasetSequence() : new Sequence("THISISAPLACEHOLDER", "")); return sqinfo; } /** - * Recover essential properties of a sequence from a hashtable - * TODO: replace these methods with something more elegant. - * @param sq SequenceI - * @param sqinfo Hashtable + * Recover essential properties of a sequence from a hashtable TODO: replace + * these methods with something more elegant. + * + * @param sq + * SequenceI + * @param sqinfo + * Hashtable * @return boolean true if name was not updated from sqinfo Name entry */ public static boolean SeqCharacterUnhash(SequenceI sq, Hashtable sqinfo) @@ -88,8 +100,7 @@ public class SeqsetUtils String oldname = (String) sqinfo.get("Name"); Integer start = (Integer) sqinfo.get("Start"); Integer end = (Integer) sqinfo.get("End"); - Vector sfeatures = (Vector) sqinfo.get( - "SeqFeatures"); + Vector sfeatures = (Vector) sqinfo.get("SeqFeatures"); Vector pdbid = (Vector) sqinfo.get("PdbId"); String description = (String) sqinfo.get("Description"); Sequence seqds = (Sequence) sqinfo.get("datasetSequence"); @@ -106,17 +117,17 @@ public class SeqsetUtils sq.setPDBId(pdbid); } - if ( (start != null) && (end != null)) + if ((start != null) && (end != null)) { sq.setStart(start.intValue()); sq.setEnd(end.intValue()); } - if ( (sfeatures != null) && (sfeatures.size() > 0)) + if ((sfeatures != null) && (sfeatures.size() > 0)) { SequenceFeature[] sfarray = new SequenceFeature[sfeatures.size()]; - for (int is=0,isize=sfeatures.size();is 0 && !quiet) { System.err.println("Did not find matches for :"); - for (Enumeration i = unmatched.elements(); i.hasMoreElements(); - System.out.println( ( (SequenceI) i.nextElement()).getName())) + for (Enumeration i = unmatched.elements(); i.hasMoreElements(); System.out + .println(((SequenceI) i.nextElement()).getName())) { ; } @@ -239,9 +273,11 @@ public class SeqsetUtils } /** - * returns a subset of the sequenceI seuqences, - * including only those that contain at least one residue. - * @param sequences SequenceI[] + * returns a subset of the sequenceI seuqences, including only those that + * contain at least one residue. + * + * @param sequences + * SequenceI[] * @return SequenceI[] */ public static SequenceI[] getNonEmptySequenceSet(SequenceI[] sequences) @@ -252,8 +288,8 @@ public class SeqsetUtils for (int i = 0, j = sequences.length; i < j; i++) { String tempseq = jalview.analysis.AlignSeq.extractGaps( - jalview.util.Comparison.GapChars, - sequences[i].getSequenceAsString()); + jalview.util.Comparison.GapChars, sequences[i] + .getSequenceAsString()); if (tempseq.length() == 0) { diff --git a/src/jalview/analysis/SequenceIdMatcher.java b/src/jalview/analysis/SequenceIdMatcher.java index 0744937..240f9cf 100755 --- a/src/jalview/analysis/SequenceIdMatcher.java +++ b/src/jalview/analysis/SequenceIdMatcher.java @@ -1,246 +1,258 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package jalview.analysis; - -import java.util.*; - -import jalview.datamodel.*; - -/** - *

Title:

- * SequenceIdMatcher - *

Description:

- * Routine which does approximate Sequence Id resolution by name using - * string containment (on word boundaries) rather than equivalence. It also - * attempts to resolve ties where no exact match is available by picking the - * the id closest to the query. - *

Copyright: Copyright (c) 2004

- * - *

Company: Dundee University

- * - * @author not attributable - * @version 1.0 - */ -public class SequenceIdMatcher -{ - private Hashtable names; - - public SequenceIdMatcher(SequenceI[] seqs) - { - names = new Hashtable(); - for (int i = 0; i < seqs.length; i++) - { - names.put(new SeqIdName(seqs[i].getName()), seqs[i]); - } - } - - /** - * returns the closest SequenceI in matches to SeqIdName and returns all the matches - * to the names hash. - * @param candName SeqIdName - * @param matches Vector of SequenceI objects - * @return SequenceI closest SequenceI to SeqIdName - */ - private SequenceI pickbestMatch(SeqIdName candName, Vector matches) - { - SequenceI match = null; - if (candName == null || matches == null || matches.size() == 0) - { - return null; - } - match = (SequenceI) matches.elementAt(0); - matches.removeElementAt(0); - names.put(new SeqIdName(match.getName()), match); - int matchlen = match.getName().length(); - int namlen = candName.id.length(); - while (matches.size() > 0) - { - // look through for a better one. - SequenceI cand = (SequenceI) matches.elementAt(0); - names.put(new SeqIdName(cand.getName()), cand); - int candlen = cand.getName().length(); - // keep the one with an id 'closer' to the given seqnam string - if (Math.abs(matchlen - namlen) > Math.abs(candlen - namlen) && - candlen > matchlen) - { - match = cand; - matchlen = candlen; - } - } - return match; - } - - /** - * get SequenceI with closest SequenceI.getName() to seq.getName() - * @param seq SequenceI - * @return SequenceI - */ - SequenceI findIdMatch(SequenceI seq) - { - SeqIdName nam = new SeqIdName(seq.getName()); - return findIdMatch(nam); - } - - SequenceI findIdMatch(String seqnam) - { - SeqIdName nam = new SeqIdName(seqnam); - return findIdMatch(nam); - } - - /** - * findIdMatch - * - * Return pointers to sequences (or sequence object containers) - * which have same Id as a given set of different sequence objects - * - * @param seqs SequenceI[] - * @return SequenceI[] - */ - SequenceI[] findIdMatch(SequenceI[] seqs) - { - SequenceI[] namedseqs = null; - int i = 0; - SeqIdName nam; - - if (seqs.length > 0) - { - namedseqs = new SequenceI[seqs.length]; - do - { - nam = new SeqIdName(seqs[i].getName()); - - if (names.containsKey(nam)) - { - namedseqs[i] = findIdMatch(nam); - } - else - { - namedseqs[i] = null; - } - } - while (++i < seqs.length); - } - - return namedseqs; - } - - /** - * core findIdMatch search method - * @param nam SeqIdName - * @return SequenceI - */ - private SequenceI findIdMatch(jalview.analysis.SequenceIdMatcher.SeqIdName - nam) - { - Vector matches = new Vector(); - while (names.containsKey(nam)) - { - matches.addElement(names.remove(nam)); - } - return pickbestMatch(nam, matches); - } - - private class SeqIdName - { - String id; - - SeqIdName(String s) - { - if (s != null) - { - id = new String(s); - } - else - { - id = ""; - } - } - - public int hashCode() - { - return ( (id.length() >= 4) ? id.substring(0, 4).hashCode() : id.hashCode()); - } - - public boolean equals(Object s) - { - if (s instanceof SeqIdName) - { - return this.equals( (SeqIdName) s); - } - else - { - if (s instanceof String) - { - return this.equals( (String) s); - } - } - - return false; - } - - /** - * Characters that define the end of a unique sequence ID at - * the beginning of an arbitrary ID string - * JBPNote: This is a heuristic that will fail for arbritrarily extended sequence id's - * (like portions of an aligned set of repeats from one sequence) - */ - private String WORD_SEP = "~. |#\\/<>!\"£$%^*)}[@',?_"; - - /** - * matches if one ID properly contains another at a whitespace boundary. - * TODO: (JBPNote) These are not efficient. should use char[] for speed - * todo: (JBPNote) Set separator characters appropriately - * @param s SeqIdName - * @return boolean - */ - public boolean equals(SeqIdName s) - { - if (id.length() > s.id.length()) - { - return id.startsWith(s.id) ? - (WORD_SEP.indexOf(id.charAt(s.id.length())) > -1) - : false; - } - else - { - return s.id.startsWith(id) ? - (s.id.equals(id) ? true : - (WORD_SEP.indexOf(s.id.charAt(id.length())) > -1)) - : false; - } - } - - public boolean equals(String s) - { - if (id.length() > s.length()) - { - return id.startsWith(s) ? - (WORD_SEP.indexOf(id.charAt(s.length())) > -1) - : false; - } - else - { - return s.startsWith(id) ? - (s.equals(id) ? true : - (WORD_SEP.indexOf(s.charAt(id.length())) > -1)) - : false; - } - } - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.analysis; + +import java.util.*; + +import jalview.datamodel.*; + +/** + *

+ * Title: + *

+ * SequenceIdMatcher + *

+ * Description: + *

+ * Routine which does approximate Sequence Id resolution by name using string + * containment (on word boundaries) rather than equivalence. It also attempts to + * resolve ties where no exact match is available by picking the the id closest + * to the query. + *

+ * Copyright: Copyright (c) 2004 + *

+ * + *

+ * Company: Dundee University + *

+ * + * @author not attributable + * @version 1.0 + */ +public class SequenceIdMatcher +{ + private Hashtable names; + + public SequenceIdMatcher(SequenceI[] seqs) + { + names = new Hashtable(); + for (int i = 0; i < seqs.length; i++) + { + names.put(new SeqIdName(seqs[i].getName()), seqs[i]); + } + } + + /** + * returns the closest SequenceI in matches to SeqIdName and returns all the + * matches to the names hash. + * + * @param candName + * SeqIdName + * @param matches + * Vector of SequenceI objects + * @return SequenceI closest SequenceI to SeqIdName + */ + private SequenceI pickbestMatch(SeqIdName candName, Vector matches) + { + SequenceI match = null; + if (candName == null || matches == null || matches.size() == 0) + { + return null; + } + match = (SequenceI) matches.elementAt(0); + matches.removeElementAt(0); + names.put(new SeqIdName(match.getName()), match); + int matchlen = match.getName().length(); + int namlen = candName.id.length(); + while (matches.size() > 0) + { + // look through for a better one. + SequenceI cand = (SequenceI) matches.elementAt(0); + names.put(new SeqIdName(cand.getName()), cand); + int candlen = cand.getName().length(); + // keep the one with an id 'closer' to the given seqnam string + if (Math.abs(matchlen - namlen) > Math.abs(candlen - namlen) + && candlen > matchlen) + { + match = cand; + matchlen = candlen; + } + } + return match; + } + + /** + * get SequenceI with closest SequenceI.getName() to seq.getName() + * + * @param seq + * SequenceI + * @return SequenceI + */ + SequenceI findIdMatch(SequenceI seq) + { + SeqIdName nam = new SeqIdName(seq.getName()); + return findIdMatch(nam); + } + + SequenceI findIdMatch(String seqnam) + { + SeqIdName nam = new SeqIdName(seqnam); + return findIdMatch(nam); + } + + /** + * findIdMatch + * + * Return pointers to sequences (or sequence object containers) which have + * same Id as a given set of different sequence objects + * + * @param seqs + * SequenceI[] + * @return SequenceI[] + */ + SequenceI[] findIdMatch(SequenceI[] seqs) + { + SequenceI[] namedseqs = null; + int i = 0; + SeqIdName nam; + + if (seqs.length > 0) + { + namedseqs = new SequenceI[seqs.length]; + do + { + nam = new SeqIdName(seqs[i].getName()); + + if (names.containsKey(nam)) + { + namedseqs[i] = findIdMatch(nam); + } + else + { + namedseqs[i] = null; + } + } while (++i < seqs.length); + } + + return namedseqs; + } + + /** + * core findIdMatch search method + * + * @param nam + * SeqIdName + * @return SequenceI + */ + private SequenceI findIdMatch( + jalview.analysis.SequenceIdMatcher.SeqIdName nam) + { + Vector matches = new Vector(); + while (names.containsKey(nam)) + { + matches.addElement(names.remove(nam)); + } + return pickbestMatch(nam, matches); + } + + private class SeqIdName + { + String id; + + SeqIdName(String s) + { + if (s != null) + { + id = new String(s); + } + else + { + id = ""; + } + } + + public int hashCode() + { + return ((id.length() >= 4) ? id.substring(0, 4).hashCode() : id + .hashCode()); + } + + public boolean equals(Object s) + { + if (s instanceof SeqIdName) + { + return this.equals((SeqIdName) s); + } + else + { + if (s instanceof String) + { + return this.equals((String) s); + } + } + + return false; + } + + /** + * Characters that define the end of a unique sequence ID at the beginning + * of an arbitrary ID string JBPNote: This is a heuristic that will fail for + * arbritrarily extended sequence id's (like portions of an aligned set of + * repeats from one sequence) + */ + private String WORD_SEP = "~. |#\\/<>!\"£$%^*)}[@',?_"; + + /** + * matches if one ID properly contains another at a whitespace boundary. + * TODO: (JBPNote) These are not efficient. should use char[] for speed + * todo: (JBPNote) Set separator characters appropriately + * + * @param s + * SeqIdName + * @return boolean + */ + public boolean equals(SeqIdName s) + { + if (id.length() > s.id.length()) + { + return id.startsWith(s.id) ? (WORD_SEP.indexOf(id.charAt(s.id + .length())) > -1) : false; + } + else + { + return s.id.startsWith(id) ? (s.id.equals(id) ? true : (WORD_SEP + .indexOf(s.id.charAt(id.length())) > -1)) : false; + } + } + + public boolean equals(String s) + { + if (id.length() > s.length()) + { + return id.startsWith(s) ? (WORD_SEP.indexOf(id.charAt(s.length())) > -1) + : false; + } + else + { + return s.startsWith(id) ? (s.equals(id) ? true : (WORD_SEP + .indexOf(s.charAt(id.length())) > -1)) : false; + } + } + } +} diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 7c1ea3f..f7ecfda 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -31,60 +30,97 @@ import jalview.schemes.*; import jalview.util.UrlLink; import jalview.io.AppletFormatAdapter; -public class APopupMenu - extends java.awt.PopupMenu implements ActionListener, ItemListener +public class APopupMenu extends java.awt.PopupMenu implements + ActionListener, ItemListener { Menu groupMenu = new Menu(); + MenuItem editGroupName = new MenuItem(); + protected MenuItem clustalColour = new MenuItem(); + protected MenuItem zappoColour = new MenuItem(); + protected MenuItem taylorColour = new MenuItem(); + protected MenuItem hydrophobicityColour = new MenuItem(); + protected MenuItem helixColour = new MenuItem(); + protected MenuItem strandColour = new MenuItem(); + protected MenuItem turnColour = new MenuItem(); + protected MenuItem buriedColour = new MenuItem(); + protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem(); + protected MenuItem userDefinedColour = new MenuItem(); + protected MenuItem PIDColour = new MenuItem(); + protected MenuItem BLOSUM62Colour = new MenuItem(); + MenuItem noColourmenuItem = new MenuItem(); + protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); final AlignmentPanel ap; + MenuItem unGroupMenuItem = new MenuItem(); + MenuItem nucleotideMenuItem = new MenuItem(); + Menu colourMenu = new Menu(); + CheckboxMenuItem showBoxes = new CheckboxMenuItem(); + CheckboxMenuItem showText = new CheckboxMenuItem(); + CheckboxMenuItem showColourText = new CheckboxMenuItem(); + Menu editMenu = new Menu("Edit"); + MenuItem copy = new MenuItem("Copy (Jalview Only)"); + MenuItem cut = new MenuItem("Cut (Jalview Only)"); + MenuItem toUpper = new MenuItem("To Upper Case"); + MenuItem toLower = new MenuItem("To Lower Case"); + MenuItem toggleCase = new MenuItem("Toggle Case"); + Menu outputmenu = new Menu(); + Menu seqMenu = new Menu(); + MenuItem pdb = new MenuItem(); + MenuItem hideSeqs = new MenuItem(); + MenuItem repGroup = new MenuItem(); + MenuItem sequenceName = new MenuItem("Edit Name/Description"); + MenuItem sequenceFeature = new MenuItem("Create Sequence Feature"); + MenuItem editSequence = new MenuItem("Edit Sequence"); Sequence seq; + MenuItem revealAll = new MenuItem(); + Menu menu1 = new Menu(); public APopupMenu(AlignmentPanel apanel, final Sequence 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; @@ -92,17 +128,15 @@ public class APopupMenu try { jbInit(); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } - for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; - i++) + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { - MenuItem item = new MenuItem(jalview.io.AppletFormatAdapter. - WRITEABLE_FORMATS[i]); + MenuItem item = new MenuItem( + jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); item.addActionListener(this); outputmenu.add(item); @@ -128,7 +162,7 @@ public class APopupMenu remove(groupMenu); } - if (links != null && links.size()>0) + if (links != null && links.size() > 0) { Menu linkMenu = new Menu("Link"); String link; @@ -141,92 +175,82 @@ public class APopupMenu System.err.println(urlLink.getInvalidMessage()); continue; } - final String target = urlLink.getTarget(); // link.substring(0, link.indexOf("|")); + final String target = urlLink.getTarget(); // link.substring(0, + // link.indexOf("|")); final String label = urlLink.getLabel(); if (urlLink.isDynamic()) { // collect matching db-refs - DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new String[]{target}); + DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq + .getDBRef(), new String[] + { target }); // collect id string too String id = seq.getName(); - if (dbr!=null) + if (dbr != null) { - for (int r=0;r -1) + else { - // 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 = jalview.util.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 -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 = + * jalview.util.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) { - alignPanel.seqPanel.seqCanvas - .getFeatureRenderer().featureLinks = featureLinks; + alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks; } viewport.showSequenceFeatures = true; sequenceFeatures.setState(true); @@ -186,307 +182,298 @@ public class AlignFrame 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()); - + 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(); - 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 27: // escape key + deselectAllSequenceMenuItem_actionPerformed(); + 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_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_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_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_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_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_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_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_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("Keyboard editing mode is " + + (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(); + boolean hide = false; + SequenceGroup sg = viewport.getSelectionGroup(); - case KeyEvent.VK_F2: - viewport.cursorMode = !viewport.cursorMode; - statusBar.setText("Keyboard editing mode is " + - (viewport.cursorMode ? "on" : "off")); - if (viewport.cursorMode) + if (toggleSeqs) + { + if (sg != null && sg.getSize() != viewport.alignment.getHeight()) { - alignPanel.seqPanel.seqCanvas.cursorX = viewport.startRes; - alignPanel.seqPanel.seqCanvas.cursorY = viewport.startSeq; + hide = true; + viewport.hideAllSelectedSeqs(); } - break; - - case KeyEvent.VK_F: - if (evt.isControlDown()) + else if (!(toggleCols && viewport.colSel.getSelected().size() > 0)) { - findMenuItem_actionPerformed(); + viewport.showAllHiddenSeqs(); } - break; + } - case KeyEvent.VK_H: + if (toggleCols) { - boolean toggleSeqs = !evt.isControlDown(); - boolean toggleCols = !evt.isShiftDown(); - boolean hide = false; - SequenceGroup sg = viewport.getSelectionGroup(); - - if (toggleSeqs) + if (viewport.colSel.getSelected().size() > 0) { - if (sg != null && sg.getSize() != viewport.alignment.getHeight()) - { - hide = true; - viewport.hideAllSelectedSeqs(); - } - else if (! (toggleCols && viewport.colSel.getSelected().size() > 0)) + viewport.hideSelectedColumns(); + if (!toggleSeqs) { - viewport.showAllHiddenSeqs(); + viewport.selectionGroup = sg; } } - - if (toggleCols) + else if (!hide) { - if (viewport.colSel.getSelected().size() > 0) - { - viewport.hideSelectedColumns(); - if (!toggleSeqs) - { - viewport.selectionGroup = sg; - } - } - else if (!hide) - { - viewport.showAllHiddenColumns(); - } + viewport.showAllHiddenColumns(); } - break; } + break; + } - case KeyEvent.VK_PAGE_UP: - if (viewport.wrapAlignment) - { - alignPanel.scrollUp(true); - } - else - { - alignPanel.setScrollValues(viewport.startRes, - viewport.startSeq - - viewport.endSeq + viewport.startSeq); - } - break; + case KeyEvent.VK_PAGE_UP: + if (viewport.wrapAlignment) + { + alignPanel.scrollUp(true); + } + else + { + alignPanel.setScrollValues(viewport.startRes, viewport.startSeq + - viewport.endSeq + viewport.startSeq); + } + break; - case KeyEvent.VK_PAGE_DOWN: - if (viewport.wrapAlignment) - { - alignPanel.scrollUp(false); - } - else - { - alignPanel.setScrollValues(viewport.startRes, - viewport.startSeq - + viewport.endSeq - viewport.startSeq); - } - break; + case KeyEvent.VK_PAGE_DOWN: + if (viewport.wrapAlignment) + { + 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_Z: + if (evt.isControlDown()) + { + undoMenuItem_actionPerformed(); + } + break; - case KeyEvent.VK_Y: - if (evt.isControlDown()) - { - redoMenuItem_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_L: + if (evt.isControlDown()) + { + trimAlignment(true); + } + break; - case KeyEvent.VK_R: - if (evt.isControlDown()) - { - trimAlignment(false); - } - break; + case KeyEvent.VK_R: + if (evt.isControlDown()) + { + trimAlignment(false); + } + break; - case KeyEvent.VK_E: - if (evt.isControlDown()) + case KeyEvent.VK_E: + if (evt.isControlDown()) + { + if (evt.isShiftDown()) { - if (evt.isShiftDown()) - { - this.removeAllGapsMenuItem_actionPerformed(); - } - else - { - removeGappedColumnMenuItem_actionPerformed(); - } + this.removeAllGapsMenuItem_actionPerformed(); } - break; - case KeyEvent.VK_I: - if (evt.isControlDown()) + else { - if (evt.isAltDown()) - { - viewport.invertColumnSelection(); - } - else - { - this.invertSequenceMenuItem_actionPerformed(); - } + removeGappedColumnMenuItem_actionPerformed(); } - break; - - case KeyEvent.VK_U: - if (evt.isControlDown()) + } + break; + case KeyEvent.VK_I: + if (evt.isControlDown()) + { + if (evt.isAltDown()) { - this.deleteGroups_actionPerformed(); + viewport.invertColumnSelection(); } - break; - - case KeyEvent.VK_T: - if (evt.isControlDown()) + else { - newView(null); + this.invertSequenceMenuItem_actionPerformed(); } - break; + } + 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); } public void keyReleased(KeyEvent evt) - {} + { + } public void keyTyped(KeyEvent evt) - {} + { + } public void itemStateChanged(ItemEvent evt) { @@ -551,11 +538,12 @@ public class AlignFrame else if (evt.getSource() == autoCalculate) { viewport.autocalculateConsensus = autoCalculate.getState(); - } else if (evt.getSource() == this.centreColumnLabelFlag) + } + else if (evt.getSource() == this.centreColumnLabelFlag) { centreColumnLabelFlag_stateChanged(); } - + alignPanel.paintAlignment(true); } @@ -708,7 +696,8 @@ public class AlignFrame viewport.hideSelectedColumns(); alignPanel.paintAlignment(true); } - else if (source == hideSequences && viewport.getSelectionGroup() != null) + else if (source == hideSequences + && viewport.getSelectionGroup() != null) { viewport.hideAllSelectedSeqs(); } @@ -716,47 +705,46 @@ public class AlignFrame { new FeatureSettings(alignPanel); } - else if(source== alProperties) + else if (source == alProperties) { - StringBuffer contents = new StringBuffer(); + StringBuffer contents = new StringBuffer(); - float avg = 0; - int min=Integer.MAX_VALUE, max=0; - for(int i=0; imax) - max = size; - if(size max) + max = size; + if (size < min) + min = size; + } + avg = avg / (float) viewport.alignment.getHeight(); - contents.append("\nSequences: "+ viewport.alignment.getHeight()); - contents.append("\nMinimum Sequence Length: "+min); - contents.append("\nMaximum Sequence Length: "+max); - contents.append("\nAverage Length: "+(int)avg); + contents.append("\nSequences: " + viewport.alignment.getHeight()); + contents.append("\nMinimum Sequence Length: " + min); + contents.append("\nMaximum Sequence Length: " + max); + contents.append("\nAverage Length: " + (int) avg); - if (((Alignment)viewport.alignment).alignmentProperties != null) + if (((Alignment) viewport.alignment).alignmentProperties != null) + { + Hashtable props = ((Alignment) viewport.alignment).alignmentProperties; + Enumeration en = props.keys(); + while (en.hasMoreElements()) { - Hashtable props = ((Alignment)viewport.alignment).alignmentProperties; - Enumeration en = props.keys(); - while(en.hasMoreElements()) - { - String key = en.nextElement().toString(); - contents.append("\n"+key+"\t"+props.get(key)); - } + String key = en.nextElement().toString(); + contents.append("\n" + key + "\t" + props.get(key)); } + } - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); - cap.setText(contents.toString()); - Frame frame = new Frame(); - frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - "Alignment Properties: "+getTitle() - , 400, 250); + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); + cap.setText(contents.toString()); + Frame frame = new Frame(); + frame.add(cap); + jalview.bin.JalviewLite.addFrame(frame, "Alignment Properties: " + + getTitle(), 400, 250); } else if (source == overviewMenuItem) { @@ -769,8 +757,8 @@ public class AlignFrame else if (source == clustalColour) { abovePIDThreshold.setState(false); - changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(), - viewport.alignment.getWidth())); + changeColour(new ClustalxColourScheme(viewport.alignment + .getSequences(), viewport.alignment.getWidth())); } else if (source == zappoColour) { @@ -892,12 +880,11 @@ public class AlignFrame CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - "Alignment output - " + e.getActionCommand(), - 600, 500); - cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(), - viewport.getAlignment(), - viewport.showJVSuffix)); + jalview.bin.JalviewLite.addFrame(frame, "Alignment output - " + + e.getActionCommand(), 600, 500); + cap.setText(new AppletFormatAdapter().formatSequences(e + .getActionCommand(), viewport.getAlignment(), + viewport.showJVSuffix)); } public void loadAnnotations() @@ -914,18 +901,17 @@ public class AlignFrame public String outputAnnotations(boolean displayTextbox) { String annotation = new AnnotationFile().printAnnotations( - viewport.showAnnotation ? viewport.alignment.getAlignmentAnnotation() : null, - viewport.alignment.getGroups(), - ((Alignment) viewport.alignment).alignmentProperties); + viewport.showAnnotation ? viewport.alignment + .getAlignmentAnnotation() : null, viewport.alignment + .getGroups(), + ((Alignment) viewport.alignment).alignmentProperties); if (displayTextbox) { CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - "Annotations", - 600, 500); + jalview.bin.JalviewLite.addFrame(frame, "Annotations", 600, 500); cap.setText(annotation); } @@ -937,15 +923,13 @@ public class AlignFrame String features; if (format.equalsIgnoreCase("Jalview")) { - features = new FeaturesFile().printJalviewFormat( - viewport.alignment.getSequencesArray(), - viewport.featuresDisplayed); + features = new FeaturesFile().printJalviewFormat(viewport.alignment + .getSequencesArray(), viewport.featuresDisplayed); } else { - features = new FeaturesFile().printGFFFormat( - viewport.alignment.getSequencesArray(), - viewport.featuresDisplayed); + features = new FeaturesFile().printGFFFormat(viewport.alignment + .getSequencesArray(), viewport.featuresDisplayed); } if (displayTextbox) @@ -953,9 +937,7 @@ public class AlignFrame CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - "Features", - 600, 500); + jalview.bin.JalviewLite.addFrame(frame, "Features", 600, 500); cap.setText(features); } @@ -967,8 +949,8 @@ public class AlignFrame { StringBuffer url = new StringBuffer(jalviewServletURL); - url.append("?open=" + - appendProtocol(viewport.applet.getParameter("file"))); + url.append("?open=" + + appendProtocol(viewport.applet.getParameter("file"))); if (viewport.applet.getParameter("features") != null) { @@ -979,7 +961,9 @@ public class AlignFrame if (viewport.applet.getParameter("annotations") != null) { url.append("&annotations="); - url.append(appendProtocol(viewport.applet.getParameter("annotations"))); + url + .append(appendProtocol(viewport.applet + .getParameter("annotations"))); } if (viewport.applet.getParameter("jnetfile") != null) @@ -990,25 +974,26 @@ public class AlignFrame if (viewport.applet.getParameter("defaultColour") != null) { - url.append("&colour=" + - removeWhiteSpace(viewport.applet.getParameter("defaultColour")) - ); + url.append("&colour=" + + removeWhiteSpace(viewport.applet + .getParameter("defaultColour"))); } if (viewport.applet.getParameter("userDefinedColour") != null) { - url.append("&colour=" + - removeWhiteSpace(viewport.applet.getParameter( - "userDefinedColour")) - ); + url.append("&colour=" + + removeWhiteSpace(viewport.applet + .getParameter("userDefinedColour"))); } - if (viewport.applet.getParameter("tree")!=null) + if (viewport.applet.getParameter("tree") != null) { - url.append("&tree="+appendProtocol(viewport.applet.getParameter("tree"))); + url.append("&tree=" + + appendProtocol(viewport.applet.getParameter("tree"))); } - if (viewport.applet.getParameter("treeFile")!=null) + if (viewport.applet.getParameter("treeFile") != null) { - url.append("&tree="+appendProtocol(viewport.applet.getParameter("treeFile"))); + url.append("&tree=" + + appendProtocol(viewport.applet.getParameter("treeFile"))); } showURL(url.toString(), "FULL_APP"); @@ -1039,14 +1024,13 @@ public class AlignFrame 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(); - } */ + /* + * 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; @@ -1110,10 +1094,12 @@ public class AlignFrame viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null; } } + /** * DOCUMENT ME! - * - * @param e DOCUMENT ME! + * + * @param e + * DOCUMENT ME! */ protected void undoMenuItem_actionPerformed() { @@ -1131,13 +1117,14 @@ public class AlignFrame originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null; updateEditMenuBar(); originalSource.firePropertyChange("alignment", null, - originalSource.alignment.getSequences()); + originalSource.alignment.getSequences()); } /** * DOCUMENT ME! - * - * @param e DOCUMENT ME! + * + * @param e + * DOCUMENT ME! */ protected void redoMenuItem_actionPerformed() { @@ -1155,29 +1142,29 @@ public class AlignFrame updateEditMenuBar(); originalSource.firePropertyChange("alignment", null, - originalSource.alignment.getSequences()); + originalSource.alignment.getSequences()); } AlignViewport getOriginatingSource(CommandI command) { AlignViewport originalSource = null; - //For sequence removal and addition, we need to fire - //the property change event FROM the viewport where the - //original alignment was altered + // 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()); + 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.alignment) + if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment) { - originalSource = ( (AlignmentPanel) comps.elementAt(i)).av; + originalSource = ((AlignmentPanel) comps.elementAt(i)).av; break; } } @@ -1186,8 +1173,8 @@ public class AlignFrame if (originalSource == null) { - //The original view is closed, we must validate - //the current view against the closed view first + // The original view is closed, we must validate + // the current view against the closed view first if (al != null) { PaintRefresher.validateSequences(al, viewport.alignment); @@ -1254,19 +1241,20 @@ public class AlignFrame synchronized void slideSequences(boolean right, int size) { Vector sg = new Vector(); - if(viewport.cursorMode) + if (viewport.cursorMode) + { + sg.addElement(viewport.alignment + .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY)); + } + else if (viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() != viewport.alignment + .getHeight()) { - sg.addElement(viewport.alignment.getSequenceAt( - alignPanel.seqPanel.seqCanvas.cursorY)); + sg = viewport.getSelectionGroup().getSequences( + viewport.hiddenRepSequences); } - else if(viewport.getSelectionGroup()!=null - && viewport.getSelectionGroup().getSize()!=viewport.alignment.getHeight()) - { - sg = viewport.getSelectionGroup().getSequences( - viewport.hiddenRepSequences); - } - if(sg.size()<1) + if (sg.size() < 1) { return; } @@ -1275,8 +1263,8 @@ public class AlignFrame for (int i = 0; i < viewport.alignment.getHeight(); i++) { - if(!sg.contains(viewport.alignment.getSequenceAt(i))) - invertGroup.addElement(viewport.alignment.getSequenceAt(i)); + if (!sg.contains(viewport.alignment.getSequenceAt(i))) + invertGroup.addElement(viewport.alignment.getSequenceAt(i)); } SequenceI[] seqs1 = new SequenceI[sg.size()]; @@ -1289,15 +1277,11 @@ public class AlignFrame SlideSequencesCommand ssc; if (right) - ssc = new SlideSequencesCommand("Slide Sequences", - seqs2, seqs1, size, - viewport.getGapCharacter() - ); + ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1, + size, viewport.getGapCharacter()); else - ssc = new SlideSequencesCommand("Slide Sequences", - seqs1, seqs2, size, - viewport.getGapCharacter() - ); + ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2, + size, viewport.getGapCharacter()); int groupAdjustment = 0; if (ssc.getGapsInsertedBegin() && right) @@ -1310,7 +1294,7 @@ public class AlignFrame else if (!ssc.getGapsInsertedBegin() && !right) { if (viewport.cursorMode) - alignPanel.seqPanel.moveCursor( -size, 0); + alignPanel.seqPanel.moveCursor(-size, 0); else groupAdjustment = -size; } @@ -1318,30 +1302,30 @@ public class AlignFrame if (groupAdjustment != 0) { viewport.getSelectionGroup().setStartRes( - viewport.getSelectionGroup().getStartRes() + groupAdjustment); + viewport.getSelectionGroup().getStartRes() + groupAdjustment); viewport.getSelectionGroup().setEndRes( - viewport.getSelectionGroup().getEndRes() + groupAdjustment); + viewport.getSelectionGroup().getEndRes() + groupAdjustment); } - boolean appendHistoryItem = false; - if(viewport.historyList!=null - && viewport.historyList.size()>0 - && viewport.historyList.peek() instanceof SlideSequencesCommand) + if (viewport.historyList != null && viewport.historyList.size() > 0 + && viewport.historyList.peek() instanceof SlideSequencesCommand) { - appendHistoryItem = ssc.appendSlideCommand( - (SlideSequencesCommand)viewport.historyList.peek()) - ; + appendHistoryItem = ssc + .appendSlideCommand((SlideSequencesCommand) viewport.historyList + .peek()); } - if(!appendHistoryItem) + if (!appendHistoryItem) addHistoryItem(ssc); repaint(); } static StringBuffer copiedSequences; + static Vector copiedHiddenColumns; + protected void copy_actionPerformed() { if (viewport.getSelectionGroup() == null) @@ -1366,15 +1350,14 @@ public class AlignFrame { copiedHiddenColumns = new Vector(); int hiddenOffset = viewport.getSelectionGroup().getStartRes(); - for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns().size(); - i++) + for (int i = 0; i < viewport.getColumnSelection().getHiddenColumns() + .size(); i++) { - int[] region = (int[]) - viewport.getColumnSelection().getHiddenColumns().elementAt(i); + int[] region = (int[]) viewport.getColumnSelection() + .getHiddenColumns().elementAt(i); copiedHiddenColumns.addElement(new int[] - {region[0] - hiddenOffset, - region[1] - hiddenOffset}); + { region[0] - hiddenOffset, region[1] - hiddenOffset }); } } else @@ -1401,18 +1384,18 @@ public class AlignFrame } } - //FIND START RES - //Returns residue following index if gap + // 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 + // 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 (!jalview.util.Comparison.isGap( (ch))) + if (!jalview.util.Comparison.isGap((ch))) { endRes++; } @@ -1423,11 +1406,14 @@ public class AlignFrame endRes += seq.getStart() - 1; } - copiedSequences.append(seq.getName() + "\t" + - startRes + "\t" + - endRes + "\t" + - seq.getSequenceAsString(sg.getStartRes(), - sg.getEndRes() + 1) + "\n"); + copiedSequences.append(seq.getName() + + "\t" + + startRes + + "\t" + + endRes + + "\t" + + seq.getSequenceAsString(sg.getStartRes(), + sg.getEndRes() + 1) + "\n"); } } @@ -1479,9 +1465,7 @@ public class AlignFrame newtitle = newtitle.concat("- from " + getTitle()); } AlignFrame af = new AlignFrame(new Alignment(newSeqs), - viewport.applet, - newtitle, - false); + viewport.applet, newtitle, false); if (copiedHiddenColumns != null) { for (int i = 0; i < copiedHiddenColumns.size(); i++) @@ -1492,16 +1476,16 @@ public class AlignFrame } jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH, - DEFAULT_HEIGHT); + DEFAULT_HEIGHT); } else { addSequences(newSeqs); } - } - catch (Exception ex) - {} // could be anything being pasted in here + } catch (Exception ex) + { + } // could be anything being pasted in here } @@ -1512,20 +1496,14 @@ public class AlignFrame viewport.alignment.addSequence(seqs[i]); } - //!newAlignment - addHistoryItem(new EditCommand( - "Add sequences", - EditCommand.PASTE, - seqs, - 0, - viewport.alignment.getWidth(), - viewport.alignment) - ); + // !newAlignment + addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE, + seqs, 0, viewport.alignment.getWidth(), viewport.alignment)); viewport.setEndSeq(viewport.alignment.getHeight()); viewport.alignment.getWidth(); - viewport.firePropertyChange("alignment", null, - viewport.alignment.getSequences()); + viewport.firePropertyChange("alignment", null, viewport.alignment + .getSequences()); } @@ -1556,7 +1534,7 @@ public class AlignFrame if (sg.getSize() == viewport.alignment.getHeight()) { viewport.getColumnSelection().removeElements(sg.getStartRes(), - sg.getEndRes() + 1); + sg.getEndRes() + 1); } SequenceI[] cut = new SequenceI[seqs.size()]; @@ -1566,20 +1544,17 @@ public class AlignFrame } /* - //ADD HISTORY ITEM + * //ADD HISTORY ITEM */ - addHistoryItem(new EditCommand("Cut Sequences", - EditCommand.CUT, - cut, - sg.getStartRes(), - sg.getEndRes() - sg.getStartRes() + 1, - viewport.alignment)); + addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut, + sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1, + viewport.alignment)); viewport.setSelectionGroup(null); viewport.alignment.deleteGroup(sg); - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); if (viewport.getAlignment().getHeight() < 1) { @@ -1655,8 +1630,8 @@ public class AlignFrame SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport. - hiddenRepSequences); + seqs = viewport.getSelectionGroup().getSequencesAsArray( + viewport.hiddenRepSequences); } else { @@ -1667,23 +1642,17 @@ public class AlignFrame if (trimLeft) { trimRegion = new TrimRegionCommand("Remove Left", - TrimRegionCommand.TRIM_LEFT, - seqs, - column, - viewport.alignment, - viewport.colSel, - viewport.selectionGroup); + TrimRegionCommand.TRIM_LEFT, seqs, column, + viewport.alignment, viewport.colSel, + viewport.selectionGroup); viewport.setStartRes(0); } else { trimRegion = new TrimRegionCommand("Remove Right", - TrimRegionCommand.TRIM_RIGHT, - seqs, - column, - viewport.alignment, - viewport.colSel, - viewport.selectionGroup); + TrimRegionCommand.TRIM_RIGHT, seqs, column, + viewport.alignment, viewport.colSel, + viewport.selectionGroup); } statusBar.setText("Removed " + trimRegion.getSize() + " columns."); @@ -1696,15 +1665,15 @@ public class AlignFrame { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if ( (trimLeft && !sg.adjustForRemoveLeft(column)) - || (!trimLeft && !sg.adjustForRemoveRight(column))) + if ((trimLeft && !sg.adjustForRemoveLeft(column)) + || (!trimLeft && !sg.adjustForRemoveRight(column))) { viewport.alignment.deleteGroup(sg); } } - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, viewport + .getAlignment().getSequences()); } } @@ -1715,8 +1684,8 @@ public class AlignFrame SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport. - hiddenRepSequences); + seqs = viewport.getSelectionGroup().getSequencesAsArray( + viewport.hiddenRepSequences); start = viewport.getSelectionGroup().getStartRes(); end = viewport.getSelectionGroup().getEndRes(); } @@ -1725,28 +1694,26 @@ public class AlignFrame seqs = viewport.alignment.getSequencesArray(); } - RemoveGapColCommand removeGapCols = - new RemoveGapColCommand("Remove Gapped Columns", - seqs, - start, end, - viewport.alignment); + RemoveGapColCommand removeGapCols = new RemoveGapColCommand( + "Remove Gapped Columns", seqs, start, end, viewport.alignment); addHistoryItem(removeGapCols); - statusBar.setText("Removed " + removeGapCols.getSize() + " empty columns."); + statusBar.setText("Removed " + removeGapCols.getSize() + + " empty columns."); - //This is to maintain viewport position on first residue - //of first sequence + // This is to maintain viewport position on first residue + // of first sequence SequenceI seq = viewport.alignment.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.getColumnSelection().compensateForEdits(shifts); viewport.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); } @@ -1757,8 +1724,8 @@ public class AlignFrame SequenceI[] seqs; if (viewport.getSelectionGroup() != null) { - seqs = viewport.getSelectionGroup().getSequencesAsArray(viewport. - hiddenRepSequences); + seqs = viewport.getSelectionGroup().getSequencesAsArray( + viewport.hiddenRepSequences); start = viewport.getSelectionGroup().getStartRes(); end = viewport.getSelectionGroup().getEndRes(); } @@ -1767,20 +1734,18 @@ public class AlignFrame seqs = viewport.alignment.getSequencesArray(); } - //This is to maintain viewport position on first residue - //of first sequence + // This is to maintain viewport position on first residue + // of first sequence SequenceI seq = viewport.alignment.getSequenceAt(0); int startRes = seq.findPosition(viewport.startRes); - addHistoryItem(new RemoveGapsCommand("Remove Gaps", - seqs, - start, end, - viewport.alignment)); + addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end, + viewport.alignment)); viewport.setStartRes(seq.findIndex(startRes) - 1); - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); + viewport.firePropertyChange("alignment", null, viewport.getAlignment() + .getSequences()); } @@ -1788,8 +1753,10 @@ public class AlignFrame { new Finder(alignPanel); } + /** * create a new view derived from the current view + * * @param viewtitle * @return frame for the new view */ @@ -1798,10 +1765,8 @@ public class AlignFrame AlignmentI newal; if (viewport.hasHiddenRows) { - newal = new Alignment(viewport.getAlignment(). - getHiddenSequences() - .getFullAlignment(). - getSequencesArray()); + newal = new Alignment(viewport.getAlignment().getHiddenSequences() + .getFullAlignment().getSequencesArray()); } else { @@ -1814,28 +1779,27 @@ public class AlignFrame { if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated) { - newal.addAnnotation(viewport.alignment.getAlignmentAnnotation()[i]); + newal + .addAnnotation(viewport.alignment + .getAlignmentAnnotation()[i]); } } } - AlignFrame newaf = new AlignFrame(newal, - viewport.applet, - "", - false); + AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false); newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId(); PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId()); - PaintRefresher.Register(newaf.alignPanel, - newaf.alignPanel.av.getSequenceSetId()); + PaintRefresher.Register(newaf.alignPanel, newaf.alignPanel.av + .getSequenceSetId()); PaintRefresher.Register(newaf.alignPanel.idPanel.idCanvas, - newaf.alignPanel.av.getSequenceSetId()); + newaf.alignPanel.av.getSequenceSetId()); PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas, - newaf.alignPanel.av.getSequenceSetId()); + newaf.alignPanel.av.getSequenceSetId()); - Vector comps = (Vector) PaintRefresher.components.get(viewport. - getSequenceSetId()); + Vector comps = (Vector) PaintRefresher.components.get(viewport + .getSequenceSetId()); int viewSize = -1; for (int i = 0; i < comps.size(); i++) { @@ -1846,10 +1810,12 @@ public class AlignFrame } String title = new String(this.getTitle()); - if (viewtitle!=null) + if (viewtitle != null) + { + title = viewtitle + " ( " + title + ")"; + } + else { - title = viewtitle+" ( "+title+")"; - } else { if (title.indexOf("(View") > -1) { title = title.substring(0, title.indexOf("(View")); @@ -1863,6 +1829,7 @@ public class AlignFrame newaf.viewport.redoList = viewport.redoList; return newaf; } + /** * * @return list of feature groups on the view @@ -1870,36 +1837,47 @@ public class AlignFrame public String[] getFeatureGroups() { FeatureRenderer fr = null; - if (alignPanel!=null && (fr=alignPanel.getFeatureRenderer())!=null) + if (alignPanel != null + && (fr = alignPanel.getFeatureRenderer()) != null) { return fr.getGroups(); } return null; } + /** * get sequence feature groups that are hidden or shown - * @param visible true is visible + * + * @param visible + * true is visible * @return list */ public String[] getFeatureGroupsOfState(boolean visible) { FeatureRenderer fr = null; - if (alignPanel!=null && (fr=alignPanel.getFeatureRenderer())!=null) + if (alignPanel != null + && (fr = alignPanel.getFeatureRenderer()) != null) { return fr.getGroups(visible); } return null; } + /** * Change the display state for the given feature groups - * @param groups list of group strings - * @param state visible or invisible + * + * @param groups + * list of group strings + * @param state + * visible or invisible */ - public void setFeatureGroupState(String[] groups, boolean state) { + public void setFeatureGroupState(String[] groups, boolean state) + { FeatureRenderer fr = null; this.sequenceFeatures.setState(true); viewport.showSequenceFeatures(true); - if (alignPanel!=null && (fr=alignPanel.getFeatureRenderer())!=null) + if (alignPanel != null + && (fr = alignPanel.getFeatureRenderer()) != null) { fr.setGroupState(groups, state); alignPanel.seqPanel.seqCanvas.repaint(); @@ -1909,6 +1887,7 @@ public class AlignFrame } } } + public void seqLimits_itemStateChanged() { viewport.setShowJVSuffix(seqLimits.getState()); @@ -1944,8 +1923,8 @@ public class AlignFrame frame.add(overview); // +50 must allow for applet frame window jalview.bin.JalviewLite.addFrame(frame, "Overview " + this.getTitle(), - overview.getPreferredSize().width, - overview.getPreferredSize().height + 50); + overview.getPreferredSize().width, + overview.getPreferredSize().height + 50); frame.pack(); frame.addWindowListener(new WindowAdapter() @@ -1968,7 +1947,8 @@ public class AlignFrame { if (viewport.getAbovePIDThreshold()) { - threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background"); + threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, + "Background"); cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus()); @@ -1984,17 +1964,16 @@ public class AlignFrame Alignment al = (Alignment) viewport.alignment; Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, - al.getSequences(), 0, - al.getWidth() - 1); + ResidueProperties.propHash, 3, al.getSequences(), 0, al + .getWidth() - 1); c.calculate(); c.verdict(false, viewport.ConsPercGaps); cs.setConservation(c); - cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, cs, - "Background")); + cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel, + cs, "Background")); } else @@ -2021,17 +2000,15 @@ public class AlignFrame } if (cs instanceof ClustalxColourScheme) { - sg.cs = new ClustalxColourScheme( - sg.getSequences(viewport.hiddenRepSequences), - sg.getWidth()); + sg.cs = new ClustalxColourScheme(sg + .getSequences(viewport.hiddenRepSequences), sg.getWidth()); } else { try { sg.cs = (ColourSchemeI) cs.getClass().newInstance(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); sg.cs = cs; @@ -2039,12 +2016,13 @@ public class AlignFrame } if (viewport.getAbovePIDThreshold() - || cs instanceof PIDColourScheme - || cs instanceof Blosum62ColourScheme) + || cs instanceof PIDColourScheme + || cs instanceof Blosum62ColourScheme) { sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus()); - sg.cs.setConsensus(AAFrequency.calculate( - sg.getSequences(viewport.hiddenRepSequences), 0, sg.getWidth())); + sg.cs.setConsensus(AAFrequency.calculate(sg + .getSequences(viewport.hiddenRepSequences), 0, sg + .getWidth())); } else { @@ -2054,10 +2032,9 @@ public class AlignFrame if (viewport.getConservationSelected()) { Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.getSequences(viewport. - hiddenRepSequences), 0, - viewport.alignment.getWidth() - 1); + ResidueProperties.propHash, 3, sg + .getSequences(viewport.hiddenRepSequences), 0, + viewport.alignment.getWidth() - 1); c.calculate(); c.verdict(false, viewport.ConsPercGaps); sg.cs.setConservation(c); @@ -2076,28 +2053,31 @@ public class AlignFrame alignPanel.getOverviewPanel().updateOverviewImage(); } - jalview.structure.StructureSelectionManager.getStructureSelectionManager() - .sequenceColoursChanged(alignPanel); + jalview.structure.StructureSelectionManager + .getStructureSelectionManager().sequenceColoursChanged( + alignPanel); alignPanel.paintAlignment(true); } protected void modifyPID_actionPerformed() { - if (viewport.getAbovePIDThreshold() && viewport.globalColourScheme != null) + if (viewport.getAbovePIDThreshold() + && viewport.globalColourScheme != null) { - SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(), - "Background"); + SliderPanel.setPIDSliderSource(alignPanel, viewport + .getGlobalColourScheme(), "Background"); SliderPanel.showPIDSlider(); } } protected void modifyConservation_actionPerformed() { - if (viewport.getConservationSelected() && viewport.globalColourScheme != null) + if (viewport.getConservationSelected() + && viewport.globalColourScheme != null) { - SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme, - "Background"); + SliderPanel.setConservationSlider(alignPanel, + viewport.globalColourScheme, "Background"); SliderPanel.showConservationSlider(); } } @@ -2129,25 +2109,25 @@ public class AlignFrame public void sortPairwiseMenuItem_actionPerformed() { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByPID(viewport.getAlignment(), - viewport.getAlignment().getSequenceAt(0), null); + AlignmentSorter.sortByPID(viewport.getAlignment(), viewport + .getAlignment().getSequenceAt(0), null); addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, - viewport.alignment)); + viewport.alignment)); alignPanel.paintAlignment(true); } public void sortIDMenuItem_actionPerformed() { - // addHistoryItem(new HistoryItem("ID Sort", viewport.alignment, - // HistoryItem.SORT)); + // addHistoryItem(new HistoryItem("ID Sort", viewport.alignment, + // HistoryItem.SORT)); AlignmentSorter.sortByID(viewport.getAlignment()); alignPanel.paintAlignment(true); } public void sortGroupMenuItem_actionPerformed() { - // addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, - // HistoryItem.SORT)); + // addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, + // HistoryItem.SORT)); AlignmentSorter.sortByGroup(viewport.getAlignment()); alignPanel.paintAlignment(true); @@ -2161,24 +2141,24 @@ public class AlignFrame public void pairwiseAlignmentMenuItem_actionPerformed() { if (viewport.getSelectionGroup() != null - && viewport.getSelectionGroup().getSize() > 1) + && viewport.getSelectionGroup().getSize() > 1) { Frame frame = new Frame(); frame.add(new PairwiseAlignPanel(alignPanel)); - jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, 500); + jalview.bin.JalviewLite.addFrame(frame, "Pairwise Alignment", 600, + 500); } } public void PCAMenuItem_actionPerformed() { - //are the sequences aligned? + // are the sequences aligned? if (!viewport.alignment.isAligned()) { SequenceI current; int Width = viewport.getAlignment().getWidth(); - for (int i = 0; i < viewport.getAlignment().getSequences().size(); - i++) + for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) { current = viewport.getAlignment().getSequenceAt(i); @@ -2190,10 +2170,10 @@ public class AlignFrame alignPanel.paintAlignment(true); } - if ( (viewport.getSelectionGroup() != null && - viewport.getSelectionGroup().getSize() < 4 && - viewport.getSelectionGroup().getSize() > 0) - || viewport.getAlignment().getHeight() < 4) + if ((viewport.getSelectionGroup() != null + && viewport.getSelectionGroup().getSize() < 4 && viewport + .getSelectionGroup().getSize() > 0) + || viewport.getAlignment().getHeight() < 4) { return; } @@ -2201,8 +2181,7 @@ public class AlignFrame try { new PCAPanel(viewport); - } - catch (java.lang.OutOfMemoryError ex) + } catch (java.lang.OutOfMemoryError ex) { } @@ -2230,14 +2209,13 @@ public class AlignFrame void NewTreePanel(String type, String pwType, String title) { - //are the sequences aligned? + // are the sequences aligned? if (!viewport.alignment.isAligned()) { SequenceI current; int Width = viewport.getAlignment().getWidth(); - for (int i = 0; i < viewport.getAlignment().getSequences().size(); - i++) + for (int i = 0; i < viewport.getAlignment().getSequences().size(); i++) { current = viewport.getAlignment().getSequenceAt(i); @@ -2250,14 +2228,12 @@ public class AlignFrame } - if ( (viewport.getSelectionGroup() != null && - viewport.getSelectionGroup().getSize() > 1) - || (viewport.getSelectionGroup() == null - && viewport.alignment.getHeight() > 1)) + if ((viewport.getSelectionGroup() != null && viewport + .getSelectionGroup().getSize() > 1) + || (viewport.getSelectionGroup() == null && viewport.alignment + .getHeight() > 1)) { - final TreePanel tp = new TreePanel(viewport, - type, - pwType); + final TreePanel tp = new TreePanel(viewport, type, pwType); addTreeMenuItem(tp, title); @@ -2277,10 +2253,7 @@ public class AlignFrame public void loadTree(jalview.io.NewickFile tree, String treeFile) { - TreePanel tp = new TreePanel(viewport, - treeFile, - "From File - ", - tree); + TreePanel tp = new TreePanel(viewport, treeFile, "From File - ", tree); jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500); addTreeMenuItem(tp, treeFile); } @@ -2293,9 +2266,10 @@ public class AlignFrame { public void actionPerformed(ActionEvent evt) { - // addHistoryItem(new HistoryItem("Sort", viewport.alignment, - // HistoryItem.SORT)); - AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree()); + // addHistoryItem(new HistoryItem("Sort", viewport.alignment, + // HistoryItem.SORT)); + AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel + .getTree()); alignPanel.paintAlignment(true); } }); @@ -2317,10 +2291,10 @@ public class AlignFrame protected void about_actionPerformed() { - class AboutPanel - extends Canvas + class AboutPanel extends Canvas { String version; + public AboutPanel(String version) { this.version = version; @@ -2335,19 +2309,29 @@ public class AlignFrame 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("Jalview - Release " + version, 200, y += fh); + g.drawString("JalviewLite - Release " + version, x, y += fh); g.setFont(new Font("Helvetica", Font.PLAIN, 12)); - g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.", - x, y += fh * 2); - g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.", - x, y += fh); - g.drawString( - "For any issues relating to Jalview, email help@jalview.org", x, - y += fh); - g.drawString("If you use JalView, please cite:", x, y += fh + 8); - g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", - x, y += fh); + g + .drawString( + "Authors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,", + x, y += fh * 1.5); + g.drawString("David Martin & Geoff Barton.", x + 50, y += fh); + g + .drawString( + "Development managed by The Barton Group, University of Dundee, Scotland, UK.", + x, y += fh); + g + .drawString( + "For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list", + x, y += fh); + g.drawString("If you use Jalview, please cite:", x, y += fh + 8); + g + .drawString( + "\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", + x, y += fh); g.drawString("Bioinformatics, 2004 20;426-7.", x, y += fh); } } @@ -2359,17 +2343,16 @@ public class AlignFrame try { BufferedReader reader = new BufferedReader(new InputStreamReader( - url.openStream())); + url.openStream())); String line; - while ( (line = reader.readLine()) != null) + while ((line = reader.readLine()) != null) { if (line.indexOf("VERSION") > -1) { version = line.substring(line.indexOf("=") + 1); } } - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -2377,7 +2360,7 @@ public class AlignFrame Frame frame = new Frame(); frame.add(new AboutPanel(version)); - jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200); + jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 220); } @@ -2391,108 +2374,198 @@ public class AlignFrame { try { - System.out.println("Show url: " + url); - viewport.applet.getAppletContext().showDocument(new java.net.URL(url), - target); - } - catch (Exception ex) + if (url.indexOf(":")==-1) + { + // TODO: verify (Bas Vroling bug) prepend codebase or server URL to form valid URL + if (url.indexOf("/")==0) + { + String codebase = viewport.applet.getCodeBase().toString(); + url = codebase.substring(0,codebase.length()-viewport.applet.getCodeBase().getFile().length())+url; + } else { + url = viewport.applet.getCodeBase()+url; + } + System.out.println("Show url (prepended codebase): " + url); + } else { + System.out.println("Show url: " + url); + } + viewport.applet.getAppletContext().showDocument( + new java.net.URL(url), target); + } catch (Exception ex) { ex.printStackTrace(); } } } - ////////////////////////////////////////////////////////////////////////////////// - //JBuilder Graphics here - - MenuBar alignFrameMenuBar = new MenuBar(); - Menu fileMenu = new Menu("File"); - MenuItem loadApplication = new MenuItem("View in Full Application"); - MenuItem loadTree = new MenuItem("Load Associated Tree ..."); - MenuItem loadAnnotations = new MenuItem( - "Load Features/Annotations ..."); - MenuItem outputFeatures = new MenuItem("Export Features ..."); - MenuItem outputAnnotations = new MenuItem("Export Annotations ..."); - - MenuItem closeMenuItem = new MenuItem("Close"); - Menu editMenu = new Menu("Edit"); - Menu viewMenu = new Menu("View"); - Menu colourMenu = new Menu("Colour"); - Menu calculateMenu = new Menu("Calculate"); - MenuItem selectAllSequenceMenuItem = new MenuItem("Select all"); - MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All"); - MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection"); - MenuItem remove2LeftMenuItem = new MenuItem(); - MenuItem remove2RightMenuItem = new MenuItem(); - MenuItem removeGappedColumnMenuItem = new MenuItem(); - MenuItem removeAllGapsMenuItem = new MenuItem(); - CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); - CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); - MenuItem sortPairwiseMenuItem = new MenuItem(); - MenuItem sortIDMenuItem = new MenuItem(); - MenuItem sortGroupMenuItem = new MenuItem(); - MenuItem removeRedundancyMenuItem = new MenuItem(); - MenuItem pairwiseAlignmentMenuItem = new MenuItem(); - MenuItem PCAMenuItem = new MenuItem(); - MenuItem averageDistanceTreeMenuItem = new MenuItem(); - MenuItem neighbourTreeMenuItem = new MenuItem(); + // //////////////////////////////////////////////////////////////////////////////// + // JBuilder Graphics here + + MenuBar alignFrameMenuBar = new MenuBar(); + + Menu fileMenu = new Menu("File"); + + MenuItem loadApplication = new MenuItem("View in Full Application"); + + MenuItem loadTree = new MenuItem("Load Associated Tree ..."); + + MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ..."); + + MenuItem outputFeatures = new MenuItem("Export Features ..."); + + MenuItem outputAnnotations = new MenuItem("Export Annotations ..."); + + MenuItem closeMenuItem = new MenuItem("Close"); + + Menu editMenu = new Menu("Edit"); + + Menu viewMenu = new Menu("View"); + + Menu colourMenu = new Menu("Colour"); + + Menu calculateMenu = new Menu("Calculate"); + + MenuItem selectAllSequenceMenuItem = new MenuItem("Select all"); + + MenuItem deselectAllSequenceMenuItem = new MenuItem("Deselect All"); + + MenuItem invertSequenceMenuItem = new MenuItem("Invert Selection"); + + MenuItem remove2LeftMenuItem = new MenuItem(); + + MenuItem remove2RightMenuItem = new MenuItem(); + + MenuItem removeGappedColumnMenuItem = new MenuItem(); + + MenuItem removeAllGapsMenuItem = new MenuItem(); + + CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); + + CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); + + MenuItem sortPairwiseMenuItem = new MenuItem(); + + MenuItem sortIDMenuItem = new MenuItem(); + + MenuItem sortGroupMenuItem = new MenuItem(); + + MenuItem removeRedundancyMenuItem = new MenuItem(); + + MenuItem pairwiseAlignmentMenuItem = new MenuItem(); + + MenuItem PCAMenuItem = new MenuItem(); + + MenuItem averageDistanceTreeMenuItem = new MenuItem(); + + MenuItem neighbourTreeMenuItem = new MenuItem(); + BorderLayout borderLayout1 = new BorderLayout(); + public Label statusBar = new Label(); - Menu outputTextboxMenu = new Menu(); - MenuItem clustalColour = new MenuItem(); - MenuItem zappoColour = new MenuItem(); - MenuItem taylorColour = new MenuItem(); - MenuItem hydrophobicityColour = new MenuItem(); - MenuItem helixColour = new MenuItem(); - MenuItem strandColour = new MenuItem(); - MenuItem turnColour = new MenuItem(); - MenuItem buriedColour = new MenuItem(); - MenuItem userDefinedColour = new MenuItem(); - MenuItem PIDColour = new MenuItem(); - MenuItem BLOSUM62Colour = new MenuItem(); + + Menu outputTextboxMenu = new Menu(); + + MenuItem clustalColour = new MenuItem(); + + MenuItem zappoColour = new MenuItem(); + + MenuItem taylorColour = new MenuItem(); + + MenuItem hydrophobicityColour = new MenuItem(); + + MenuItem helixColour = new MenuItem(); + + MenuItem strandColour = new MenuItem(); + + MenuItem turnColour = new MenuItem(); + + MenuItem buriedColour = new MenuItem(); + + MenuItem userDefinedColour = new MenuItem(); + + MenuItem PIDColour = new MenuItem(); + + MenuItem BLOSUM62Colour = new MenuItem(); + MenuItem njTreeBlosumMenuItem = new MenuItem(); + MenuItem avDistanceTreeBlosumMenuItem = new MenuItem(); - CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); - CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); - MenuItem alProperties = new MenuItem("Alignment Properties..."); + + CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); + + CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); + + MenuItem alProperties = new MenuItem("Alignment Properties..."); + MenuItem overviewMenuItem = new MenuItem(); - MenuItem undoMenuItem = new MenuItem(); - MenuItem redoMenuItem = new MenuItem(); - CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); + + MenuItem undoMenuItem = new MenuItem(); + + MenuItem redoMenuItem = new MenuItem(); + + CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); + MenuItem noColourmenuItem = new MenuItem(); - CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); - CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); + + CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); + + CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); + MenuItem findMenuItem = new MenuItem(); - CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem(); - MenuItem nucleotideColour = new MenuItem(); + + CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem(); + + MenuItem nucleotideColour = new MenuItem(); + MenuItem deleteGroups = new MenuItem(); + MenuItem delete = new MenuItem(); + MenuItem copy = new MenuItem(); + MenuItem cut = new MenuItem(); + Menu pasteMenu = new Menu(); + MenuItem pasteNew = new MenuItem(); + MenuItem pasteThis = new MenuItem(); - CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); - MenuItem font = new MenuItem(); - CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); - CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); - CheckboxMenuItem scaleRight = new CheckboxMenuItem(); + + CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); + + MenuItem font = new MenuItem(); + + CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); + + CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); + + CheckboxMenuItem scaleRight = new CheckboxMenuItem(); + MenuItem modifyPID = new MenuItem(); + MenuItem modifyConservation = new MenuItem(); - CheckboxMenuItem autoCalculate - = new CheckboxMenuItem("Autocalculate Consensus", true); - Menu sortByTreeMenu = new Menu(); + + CheckboxMenuItem autoCalculate = new CheckboxMenuItem( + "Autocalculate Consensus", true); + + Menu sortByTreeMenu = new Menu(); + Menu sort = new Menu(); + Menu calculate = new Menu(); + MenuItem inputText = new MenuItem(); + Menu helpMenu = new Menu(); + MenuItem documentation = new MenuItem(); + MenuItem about = new MenuItem(); - CheckboxMenuItem seqLimits = new CheckboxMenuItem(); - CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem(); - private void jbInit() - throws Exception + CheckboxMenuItem seqLimits = new CheckboxMenuItem(); + + CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem(); + + private void jbInit() throws Exception { setMenuBar(alignFrameMenuBar); @@ -2500,11 +2573,11 @@ public class AlignFrame MenuItem item; // dynamically fill save as menu with available formats - for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; - i++) + for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++) { - item = new MenuItem(jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); + item = new MenuItem( + jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]); item.addActionListener(new java.awt.event.ActionListener() { @@ -2552,8 +2625,8 @@ public class AlignFrame pairwiseAlignmentMenuItem.addActionListener(this); PCAMenuItem.setLabel("Principal Component Analysis"); PCAMenuItem.addActionListener(this); - averageDistanceTreeMenuItem.setLabel( - "Average Distance Using % Identity"); + averageDistanceTreeMenuItem + .setLabel("Average Distance Using % Identity"); averageDistanceTreeMenuItem.addActionListener(this); neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity"); neighbourTreeMenuItem.addActionListener(this); @@ -2584,8 +2657,8 @@ public class AlignFrame PIDColour.addActionListener(this); BLOSUM62Colour.setLabel("BLOSUM62 Score"); BLOSUM62Colour.addActionListener(this); - avDistanceTreeBlosumMenuItem.setLabel( - "Average Distance Using BLOSUM62"); + avDistanceTreeBlosumMenuItem + .setLabel("Average Distance Using BLOSUM62"); avDistanceTreeBlosumMenuItem.addActionListener(this); njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62"); njTreeBlosumMenuItem.addActionListener(this); @@ -2659,7 +2732,7 @@ public class AlignFrame inputText.addActionListener(this); centreColumnLabelFlag.setLabel("Centre column labels"); centreColumnLabelFlag.addItemListener(this); - + helpMenu.setLabel("Help"); documentation.setLabel("Documentation"); documentation.addActionListener(this); @@ -2807,63 +2880,80 @@ public class AlignFrame selectMenu.add(invertColSel); selectMenu.add(deleteGroups); } + MenuItem featureSettings = new MenuItem(); + CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem(); + MenuItem annotationColour = new MenuItem(); + MenuItem invertColSel = new MenuItem(); + Menu menu1 = new Menu(); + MenuItem showColumns = new MenuItem(); + MenuItem showSeqs = new MenuItem(); + Menu menu2 = new Menu(); + MenuItem hideColumns = new MenuItem(); + MenuItem hideSequences = new MenuItem(); + Menu formatMenu = new Menu(); + Menu selectMenu = new Menu(); + MenuItem newView = new MenuItem(); /** - * 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 + * 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, String title) { if (reallyEmbedded) { - ////// + // //// // Explicly 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 Seperator - embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, "Arial", Font.PLAIN, 10, false); // use our own fonts. + embeddedMenu = makeEmbeddedPopupMenu(alignFrameMenuBar, "Arial", + Font.PLAIN, 10, false); // use our own fonts. // and actually add the components to the applet area viewport.applet.setLayout(new BorderLayout()); viewport.applet.add(embeddedMenu, BorderLayout.NORTH); viewport.applet.add(statusBar, BorderLayout.SOUTH); - alignPanel.setSize(viewport.applet.getSize().width, - viewport.applet.getSize().height + alignPanel.setSize(viewport.applet.getSize().width, viewport.applet + .getSize().height - embeddedMenu.HEIGHT - statusBar.HEIGHT); viewport.applet.add(alignPanel, BorderLayout.CENTER); viewport.applet.validate(); - } else { - //////// + } + else + { + // ////// // test and embed menu bar if necessary. // - if (embedMenuIfNeeded(alignPanel)) { + if (embedMenuIfNeeded(alignPanel)) + { // adjust for status bar height too - alignPanel.setSize(getSize().width, - getSize().height + alignPanel.setSize(getSize().width, getSize().height - statusBar.HEIGHT); } add(statusBar, BorderLayout.SOUTH); add(alignPanel, BorderLayout.CENTER); // and register with the applet so it can pass external API calls to us jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH, - DEFAULT_HEIGHT); + DEFAULT_HEIGHT); } } } diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 33a73d3..b39aaeb 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -31,50 +30,73 @@ import jalview.schemes.*; public class AlignViewport { int startRes; + int endRes; int startSeq; + int endSeq; boolean cursorMode = false; boolean showJVSuffix = true; + boolean showText = true; + boolean showColourText = false; + boolean showBoxes = true; + boolean wrapAlignment = false; + boolean renderGaps = true; + boolean showSequenceFeatures = false; + boolean showAnnotation = true; + boolean showConservation = true; + boolean showQuality = true; + boolean showConsensus = true; + boolean upperCasebold = false; boolean colourAppliesToAllGroups = true; + ColourSchemeI globalColourScheme = null; + boolean conservationColourSelected = false; + boolean abovePIDThreshold = false; SequenceGroup selectionGroup; int charHeight; + int charWidth; + int wrappedWidth; Font font = new Font("SansSerif", Font.PLAIN, 10); + boolean validCharWidth = true; + AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); int threshold; + int increment; NJTree currentTree = null; boolean scaleAboveWrapped = true; + boolean scaleLeftWrapped = true; + boolean scaleRightWrapped = true; // The following vector holds the features which are @@ -82,20 +104,25 @@ public class AlignViewport public Hashtable featuresDisplayed; boolean hasHiddenColumns = false; + boolean hasHiddenRows = false; + boolean showHiddenMarkers = true; public Hashtable[] hconsensus; + AlignmentAnnotation consensus; + AlignmentAnnotation conservation; + AlignmentAnnotation quality; boolean autocalculateConsensus = true; public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! - private java.beans.PropertyChangeSupport changeSupport = new java.beans. - PropertyChangeSupport(this); + private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport( + this); boolean ignoreGapsInConsensusCalculation = false; @@ -106,6 +133,7 @@ public class AlignViewport boolean MAC = false; Stack historyList = new Stack(); + Stack redoList = new Stack(); String sequenceSetID; @@ -123,7 +151,7 @@ public class AlignViewport setFont(font); MAC = new jalview.util.Platform().isAMac(); - + if (applet != null) { String param = applet.getParameter("showFullId"); @@ -164,7 +192,6 @@ public class AlignViewport upperCasebold = true; } } - } @@ -183,7 +210,8 @@ public class AlignViewport if (colour != null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, colour); + globalColourScheme = ColourSchemeProperty.getColour(alignment, + colour); if (globalColourScheme != null) { globalColourScheme.setConsensus(hconsensus); @@ -192,8 +220,8 @@ public class AlignViewport if (applet.getParameter("userDefinedColour") != null) { - ( (UserColourScheme) globalColourScheme).parseAppletParameter( - applet.getParameter("userDefinedColour")); + ((UserColourScheme) globalColourScheme).parseAppletParameter(applet + .getParameter("userDefinedColour")); } } if (hconsensus == null) @@ -201,10 +229,8 @@ public class AlignViewport if (!alignment.isNucleotide()) { conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment less than " + - ConsPercGaps + "% gaps", - new Annotation[1], 0f, - 11f, + "Conservation of total alignment less than " + ConsPercGaps + + "% gaps", new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH); conservation.hasText = true; conservation.autoCalculated = true; @@ -218,10 +244,7 @@ public class AlignViewport { quality = new AlignmentAnnotation("Quality", "Alignment Quality based on Blosum62 scores", - new Annotation[1], - 0f, - 11f, - AlignmentAnnotation.BAR_GRAPH); + new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH); quality.hasText = true; quality.autoCalculated = true; @@ -230,8 +253,7 @@ public class AlignViewport } consensus = new AlignmentAnnotation("Consensus", "PID", - new Annotation[1], 0f, 100f, - AlignmentAnnotation.BAR_GRAPH); + new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); consensus.hasText = true; consensus.autoCalculated = true; @@ -253,10 +275,10 @@ public class AlignViewport return showSequenceFeatures; } - class ConservationThread - extends Thread + class ConservationThread extends Thread { AlignmentPanel ap; + public ConservationThread(AlignmentPanel ap) { this.ap = ap; @@ -277,8 +299,7 @@ public class AlignViewport ap.paintAlignment(false); } Thread.sleep(200); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -293,8 +314,8 @@ public class AlignViewport } Conservation cons = new jalview.analysis.Conservation("All", - jalview.schemes.ResidueProperties.propHash, 3, - alignment.getSequences(), 0, alWidth - 1); + jalview.schemes.ResidueProperties.propHash, 3, alignment + .getSequences(), 0, alWidth - 1); cons.calculate(); cons.verdict(false, ConsPercGaps); @@ -316,7 +337,8 @@ public class AlignViewport minB = 0f; maxR = 1.0f - minR; maxG = 0.9f - minG; - maxB = 0f - minB; // scalable range for colouring both Conservation and Quality + maxB = 0f - minB; // scalable range for colouring both Conservation and + // Quality float min = 0f; float max = 11f; @@ -356,29 +378,24 @@ public class AlignViewport float vprop = value - min; vprop /= max; - conservation.annotations[i] = - new Annotation(String.valueOf(c), - String.valueOf(value), ' ', value, - new Color(minR + (maxR * vprop), - minG + (maxG * vprop), - minB + (maxB * vprop))); + conservation.annotations[i] = new Annotation(String.valueOf(c), + String.valueOf(value), ' ', value, new Color(minR + + (maxR * vprop), minG + (maxG * vprop), minB + + (maxB * vprop))); // Quality calc if (quality != null) { - value = ( (Double) cons.quality.elementAt(i)).floatValue(); + value = ((Double) cons.quality.elementAt(i)).floatValue(); vprop = value - qmin; vprop /= qmax; - quality.annotations[i] = new Annotation(" ", String.valueOf(value), - ' ', - value, - new Color(minR + (maxR * vprop), - minG + (maxG * vprop), - minB + (maxB * vprop))); + quality.annotations[i] = new Annotation(" ", String + .valueOf(value), ' ', value, new Color(minR + + (maxR * vprop), minG + (maxG * vprop), minB + + (maxB * vprop))); } } - } - catch (OutOfMemoryError error) + } catch (OutOfMemoryError error) { System.out.println("Out of memory calculating conservation!!"); conservation = null; @@ -434,10 +451,10 @@ public class AlignViewport consensusThread.start(); } - class ConsensusThread - extends Thread + class ConsensusThread extends Thread { AlignmentPanel ap; + public ConsensusThread(AlignmentPanel ap) { this.ap = ap; @@ -456,8 +473,7 @@ public class AlignViewport } Thread.sleep(200); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -477,27 +493,27 @@ public class AlignViewport consensus.annotations = new Annotation[aWidth]; hconsensus = new Hashtable[aWidth]; - AAFrequency.calculate(alignment.getSequencesArray(), - 0, - alignment.getWidth(), - hconsensus); + AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment + .getWidth(), hconsensus); for (int i = 0; i < aWidth; i++) { float value = 0; if (ignoreGapsInConsensusCalculation) { - value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)). - floatValue(); + value = ((Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)) + .floatValue(); } else { - value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)). - floatValue(); + value = ((Float) hconsensus[i].get(AAFrequency.PID_GAPS)) + .floatValue(); } - String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString(); - String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " "; + String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE) + .toString(); + String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + + " "; if (maxRes.length() > 1) { @@ -505,9 +521,9 @@ public class AlignViewport maxRes = "+"; } - mouseOver += ( (int) value + "%"); + mouseOver += ((int) value + "%"); consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', - value); + value); } if (globalColourScheme != null) @@ -515,8 +531,7 @@ public class AlignViewport globalColourScheme.setConsensus(hconsensus); } - } - catch (OutOfMemoryError error) + } catch (OutOfMemoryError error) { alignment.deleteAnnotation(consensus); @@ -536,11 +551,15 @@ public class AlignViewport } /** - * get the consensus sequence as displayed under the PID consensus annotation row. + * get the consensus sequence as displayed under the PID consensus annotation + * row. + * * @return consensus sequence as a new sequence object */ /** - * get the consensus sequence as displayed under the PID consensus annotation row. + * get the consensus sequence as displayed under the PID consensus annotation + * row. + * * @return consensus sequence as a new sequence object */ public SequenceI getConsensusSeq() @@ -565,9 +584,8 @@ public class AlignViewport } } SequenceI sq = new Sequence("Consensus", seqs.toString()); - sq.setDescription("Percentage Identity Consensus " + - ( (ignoreGapsInConsensusCalculation) ? " without gaps" : - "")); + sq.setDescription("Percentage Identity Consensus " + + ((ignoreGapsInConsensusCalculation) ? " without gaps" : "")); return sq; } @@ -640,7 +658,8 @@ public class AlignViewport { if (res > alignment.getWidth() - 1) { - // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1)); + // log.System.out.println(" Corrected res from " + res + " to maximum " + + // (alignment.getWidth()-1)); res = alignment.getWidth() - 1; } if (res < 0) @@ -669,7 +688,9 @@ public class AlignViewport } java.awt.Frame nullFrame; - protected FeatureSettings featureSettings=null; + + protected FeatureSettings featureSettings = null; + public void setFont(Font f) { font = f; @@ -905,41 +926,47 @@ public class AlignViewport if (globalColourScheme != null) { globalColourScheme.setThreshold(globalColourScheme.getThreshold(), - ignoreGapsInConsensusCalculation); + ignoreGapsInConsensusCalculation); } } /** * Property change listener for changes in alignment - * - * @param listener DOCUMENT ME! + * + * @param listener + * DOCUMENT ME! */ public void addPropertyChangeListener( - java.beans.PropertyChangeListener listener) + java.beans.PropertyChangeListener listener) { changeSupport.addPropertyChangeListener(listener); } /** * DOCUMENT ME! - * - * @param listener DOCUMENT ME! + * + * @param listener + * DOCUMENT ME! */ public void removePropertyChangeListener( - java.beans.PropertyChangeListener listener) + java.beans.PropertyChangeListener listener) { changeSupport.removePropertyChangeListener(listener); } /** * Property change listener for changes in alignment - * - * @param prop DOCUMENT ME! - * @param oldvalue DOCUMENT ME! - * @param newvalue DOCUMENT ME! + * + * @param prop + * DOCUMENT ME! + * @param oldvalue + * DOCUMENT ME! + * @param newvalue + * DOCUMENT ME! */ - public void firePropertyChange(String prop, Object oldvalue, Object newvalue) + public void firePropertyChange(String prop, Object oldvalue, + Object newvalue) { changeSupport.firePropertyChange(prop, oldvalue, newvalue); } @@ -1009,7 +1036,7 @@ public class AlignViewport hiddenRepSequences.put(repSequence, sg); - //Hide all sequences except the repSequence + // Hide all sequences except the repSequence SequenceI[] seqs = new SequenceI[sSize - 1]; int index = 0; for (int i = 0; i < sSize; i++) @@ -1031,7 +1058,7 @@ public class AlignViewport public void hideAllSelectedSeqs() { - if (selectionGroup == null || selectionGroup.getSize()<1) + if (selectionGroup == null || selectionGroup.getSize() < 1) { return; } @@ -1081,12 +1108,11 @@ public class AlignViewport selectionGroup = new SequenceGroup(); selectionGroup.setEndRes(alignment.getWidth() - 1); } - Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences); + Vector tmp = alignment.getHiddenSequences().showAll( + hiddenRepSequences); for (int t = 0; t < tmp.size(); t++) { - selectionGroup.addSequence( - (SequenceI) tmp.elementAt(t), false - ); + selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false); } firePropertyChange("alignment", null, alignment.getSequences()); hasHiddenRows = false; @@ -1096,12 +1122,14 @@ public class AlignViewport public int adjustForHiddenSeqs(int alignmentIndex) { - return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex); + return alignment.getHiddenSequences().adjustForHiddenSeqs( + alignmentIndex); } /** - * This method returns the a new SequenceI [] with - * the selection sequence and start and end points adjusted + * This method returns the a new SequenceI [] with the selection sequence and + * start and end points adjusted + * * @return String[] */ public SequenceI[] getSelectionAsNewSequence() @@ -1121,15 +1149,15 @@ public class AlignViewport } /** - * This method returns the visible alignment as text, as - * seen on the GUI, ie if columns are hidden they will not - * be returned in the result. - * Use this for calculating trees, PCA, redundancy etc on views - * which contain hidden columns. + * This method returns the visible alignment as text, as seen on the GUI, ie + * if columns are hidden they will not be returned in the result. Use this for + * calculating trees, PCA, redundancy etc on views which contain hidden + * columns. + * * @return String[] */ - public jalview.datamodel.CigarArray getViewAsCigars(boolean - selectedRegionOnly) + public jalview.datamodel.CigarArray getViewAsCigars( + boolean selectedRegionOnly) { CigarArray selection = null; SequenceI[] seqs = null; @@ -1140,7 +1168,8 @@ public class AlignViewport iSize = selectionGroup.getSize(); seqs = selectionGroup.getSequencesInOrder(alignment); start = selectionGroup.getStartRes(); - end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor + end = selectionGroup.getEndRes(); // inclusive for start and end in + // SeqCigar constructor } else { @@ -1217,33 +1246,36 @@ public class AlignViewport } /** - * return a compact representation of the current alignment selection to - * pass to an analysis function - * @param selectedOnly boolean true to just return the selected view + * return a compact representation of the current alignment selection to pass + * to an analysis function + * + * @param selectedOnly + * boolean true to just return the selected view * @return AlignmentView */ jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly) { // JBPNote: - // this is here because the AlignmentView constructor modifies the CigarArray + // this is here because the AlignmentView constructor modifies the + // CigarArray // object. Refactoring of Cigar and alignment view representation should // be done to remove redundancy. CigarArray aligview = getViewAsCigars(selectedOnly); if (aligview != null) { return new AlignmentView(aligview, - (selectedOnly && selectionGroup != null) ? - selectionGroup.getStartRes() : 0); + (selectedOnly && selectionGroup != null) ? selectionGroup + .getStartRes() : 0); } return null; } /** - * This method returns the visible alignment as text, as - * seen on the GUI, ie if columns are hidden they will not - * be returned in the result. - * Use this for calculating trees, PCA, redundancy etc on views - * which contain hidden columns. + * This method returns the visible alignment as text, as seen on the GUI, ie + * if columns are hidden they will not be returned in the result. Use this for + * calculating trees, PCA, redundancy etc on views which contain hidden + * columns. + * * @return String[] */ public String[] getViewAsString(boolean selectedRegionOnly) @@ -1379,7 +1411,7 @@ public class AlignViewport updateConservation(ap); } - //Reset endRes of groups if beyond alignment width + // Reset endRes of groups if beyond alignment width int alWidth = alignment.getWidth(); Vector groups = alignment.getGroups(); if (groups != null) @@ -1401,7 +1433,7 @@ public class AlignViewport resetAllColourSchemes(); - //AW alignment.adjustSequenceAnnotations(); + // AW alignment.adjustSequenceAnnotations(); } void resetAllColourSchemes() @@ -1411,9 +1443,8 @@ public class AlignViewport { if (cs instanceof ClustalxColourScheme) { - ( (ClustalxColourScheme) cs). - resetClustalX(alignment.getSequences(), - alignment.getWidth()); + ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(), + alignment.getWidth()); } cs.setConsensus(hconsensus); @@ -1421,9 +1452,8 @@ public class AlignViewport { Alignment al = (Alignment) alignment; Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, - al.getSequences(), 0, - al.getWidth() - 1); + ResidueProperties.propHash, 3, al.getSequences(), 0, al + .getWidth() - 1); c.calculate(); c.verdict(false, ConsPercGaps); @@ -1437,13 +1467,15 @@ public class AlignViewport SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s); if (sg.cs != null && sg.cs instanceof ClustalxColourScheme) { - ( (ClustalxColourScheme) sg.cs).resetClustalX( - sg.getSequences(hiddenRepSequences), sg.getWidth()); + ((ClustalxColourScheme) sg.cs).resetClustalX(sg + .getSequences(hiddenRepSequences), sg.getWidth()); } sg.recalcConservation(); } } + boolean centreColumnLabels; + public boolean getCentreColumnLabels() { return centreColumnLabels; @@ -1452,16 +1484,16 @@ public class AlignViewport public void updateSequenceIdColours() { Vector groups = alignment.getGroups(); - for (int ig=0,igSize=groups.size(); ig end) || (av.getEndRes() < start) || - ( (av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex))) + if ((av.getStartRes() > end) + || (av.getEndRes() < start) + || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex))) { if (start > av.alignment.getWidth() - hextent) { @@ -269,8 +273,8 @@ public class AlignmentPanel void scrollToWrappedVisible(int res) { - int cwidth = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas. - getSize().width); + int cwidth = seqPanel.seqCanvas + .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth)) { vscroll.setValue(res / cwidth); @@ -321,7 +325,7 @@ public class AlignmentPanel idSpaceFillerPanel1.setVisible(!wrap); - fontChanged(); //This is so that the scalePanel is resized correctly + fontChanged(); // This is so that the scalePanel is resized correctly validate(); repaint(); @@ -329,6 +333,7 @@ public class AlignmentPanel } int hextent = 0; + int vextent = 0; // return value is true if the scroll is valid @@ -389,7 +394,8 @@ public class AlignmentPanel } av.setStartRes(x); - av.setEndRes( (x + (seqPanel.seqCanvas.getSize().width / av.charWidth)) - 1); + av + .setEndRes((x + (seqPanel.seqCanvas.getSize().width / av.charWidth)) - 1); hextent = seqPanel.seqCanvas.getSize().width / av.charWidth; vextent = seqPanel.seqCanvas.getSize().height / av.charHeight; @@ -404,12 +410,12 @@ public class AlignmentPanel vextent = height; } - if ( (hextent + x) > width) + if ((hextent + x) > width) { x = width - hextent; } - if ( (vextent + y) > height) + if ((vextent + y) > height) { y = height - vextent; } @@ -452,8 +458,8 @@ public class AlignmentPanel { int x = hscroll.getValue(); av.setStartRes(x); - av.setEndRes(x + seqPanel.seqCanvas.getSize().width / av.getCharWidth() - - 1); + av.setEndRes(x + seqPanel.seqCanvas.getSize().width + / av.getCharWidth() - 1); } if (evt == null || evt.getSource() == vscroll) @@ -461,16 +467,16 @@ public class AlignmentPanel int offy = vscroll.getValue(); if (av.getWrapAlignment()) { - int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel. - seqCanvas.getSize().width); + int rowSize = seqPanel.seqCanvas + .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); av.setStartRes(vscroll.getValue() * rowSize); - av.setEndRes( (vscroll.getValue() + 1) * rowSize); + av.setEndRes((vscroll.getValue() + 1) * rowSize); } else { av.setStartSeq(offy); - av.setEndSeq(offy + - seqPanel.seqCanvas.getSize().height / av.getCharHeight()); + av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height + / av.getCharHeight()); } } @@ -500,8 +506,7 @@ public class AlignmentPanel } idPanel.idCanvas.fastPaint(scrollY); - seqPanel.seqCanvas.fastPaint(scrollX, - scrollY); + seqPanel.seqCanvas.fastPaint(scrollX, scrollY); scalePanel.repaint(); if (av.getShowAnnotation()) @@ -516,10 +521,10 @@ public class AlignmentPanel { repaint(); - if(updateOverview) + if (updateOverview) { - jalview.structure.StructureSelectionManager.getStructureSelectionManager() - .sequenceColoursChanged(this); + jalview.structure.StructureSelectionManager + .getStructureSelectionManager().sequenceColoursChanged(this); if (overviewPanel != null) { @@ -539,7 +544,7 @@ public class AlignmentPanel Dimension d = idPanel.idCanvas.getSize(); idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); annotationSpaceFillerHolder.setSize(d.width, - annotationPanel.getSize().height); + annotationPanel.getSize().height); alabels.setSize(d.width, annotationPanel.getSize().height); @@ -552,8 +557,8 @@ public class AlignmentPanel maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; } - int canvasWidth = seqPanel.seqCanvas.getWrappedCanvasWidth - (seqPanel.seqCanvas.getSize().width); + int canvasWidth = seqPanel.seqCanvas + .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); if (canvasWidth > 0) { @@ -577,32 +582,49 @@ public class AlignmentPanel } protected Panel sequenceHolderPanel = new Panel(); + protected Scrollbar vscroll = new Scrollbar(); + protected Scrollbar hscroll = new Scrollbar(); + protected Panel seqPanelHolder = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + protected Panel scalePanelHolder = new Panel(); + protected Panel idPanelHolder = new Panel(); + BorderLayout borderLayout5 = new BorderLayout(); + protected Panel idSpaceFillerPanel1 = new Panel(); + public Panel annotationSpaceFillerHolder = new Panel(); + BorderLayout borderLayout6 = new BorderLayout(); + BorderLayout borderLayout7 = new BorderLayout(); + Panel hscrollHolder = new Panel(); + BorderLayout borderLayout10 = new BorderLayout(); + protected Panel hscrollFillerPanel = new Panel(); + BorderLayout borderLayout11 = new BorderLayout(); + BorderLayout borderLayout4 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); - private void jbInit() - throws Exception + private void jbInit() throws Exception { - // idPanelHolder.setPreferredSize(new Dimension(70, 10)); + // idPanelHolder.setPreferredSize(new Dimension(70, 10)); this.setLayout(borderLayout7); - // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); + // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); sequenceHolderPanel.setLayout(borderLayout3); seqPanelHolder.setLayout(borderLayout1); scalePanelHolder.setBackground(Color.white); @@ -612,28 +634,28 @@ public class AlignmentPanel idPanelHolder.setLayout(borderLayout5); idSpaceFillerPanel1.setBackground(Color.white); - // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); + // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); idSpaceFillerPanel1.setLayout(borderLayout11); annotationSpaceFillerHolder.setBackground(Color.white); - // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); + // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); annotationSpaceFillerHolder.setLayout(borderLayout4); hscroll.setOrientation(Scrollbar.HORIZONTAL); hscrollHolder.setLayout(borderLayout10); hscrollFillerPanel.setBackground(Color.white); - // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); + // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); hscrollHolder.setBackground(Color.white); - // annotationScroller.setPreferredSize(new Dimension(10, 80)); - // this.setPreferredSize(new Dimension(220, 166)); + // 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); + // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH); this.add(idPanelHolder, BorderLayout.WEST); idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH); idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH); diff --git a/src/jalview/appletgui/AnnotationColourChooser.java b/src/jalview/appletgui/AnnotationColourChooser.java index c932962..4416ec3 100755 --- a/src/jalview/appletgui/AnnotationColourChooser.java +++ b/src/jalview/appletgui/AnnotationColourChooser.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -27,16 +27,21 @@ import jalview.datamodel.*; import jalview.schemes.*; import java.awt.Rectangle; -public class AnnotationColourChooser - extends Panel implements ActionListener, - AdjustmentListener, ItemListener, MouseListener +public class AnnotationColourChooser extends Panel implements + ActionListener, AdjustmentListener, ItemListener, MouseListener { Frame frame; + AlignViewport av; + AlignmentPanel ap; + ColourSchemeI oldcs; + Hashtable oldgroupColours; + jalview.datamodel.AlignmentAnnotation currentAnnotation; + boolean adjusting = false; public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap) @@ -44,9 +49,9 @@ public class AnnotationColourChooser try { jbInit(); + } catch (Exception ex) + { } - catch (Exception ex) - {} oldcs = av.getGlobalColourScheme(); if (av.alignment.getGroups() != null) @@ -57,10 +62,12 @@ public class AnnotationColourChooser for (int g = 0; g < allGroups.size(); g++) { sg = (SequenceGroup) allGroups.elementAt(g); - if (sg.cs!=null) + if (sg.cs != null) + { + oldgroupColours.put(sg, sg.cs); + } + else { - oldgroupColours.put(sg, sg.cs); - } else { oldgroupColours.put(sg, "null"); } } @@ -98,12 +105,12 @@ public class AnnotationColourChooser if (!list.contains(label)) list.addElement(label); else - list.addElement(label+"_"+(index++)); + list.addElement(label + "_" + (index++)); } for (int i = 0; i < list.size(); i++) { - annotations.addItem(list.elementAt(i).toString()); + annotations.addItem(list.elementAt(i).toString()); } threshold.addItem("No Threshold"); @@ -116,7 +123,8 @@ public class AnnotationColourChooser frame = new Frame(); frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "Colour by Annotation", 480, 145); + jalview.bin.JalviewLite.addFrame(frame, "Colour by Annotation", 480, + 145); validate(); } @@ -125,15 +133,13 @@ public class AnnotationColourChooser try { jbInit(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } } - private void jbInit() - throws Exception + private void jbInit() throws Exception { minColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); minColour.setLabel("Min Colour"); @@ -191,19 +197,33 @@ public class AnnotationColourChooser } Choice annotations = new Choice(); + Button minColour = new Button(); + Button maxColour = new Button(); + Button ok = new Button(); + Button cancel = new Button(); + Panel jPanel1 = new Panel(); + Panel jPanel2 = new Panel(); + Choice threshold = new Choice(); + FlowLayout flowLayout1 = new FlowLayout(); + Panel jPanel3 = new Panel(); + Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL); + TextField thresholdValue = new TextField(20); + Checkbox currentColours = new Checkbox(); + BorderLayout borderLayout1 = new BorderLayout(); + Checkbox thresholdIsMin = new Checkbox(); public void actionPerformed(ActionEvent evt) @@ -213,11 +233,11 @@ public class AnnotationColourChooser try { float f = new Float(thresholdValue.getText()).floatValue(); - slider.setValue( (int) (f * 1000)); + slider.setValue((int) (f * 1000)); adjustmentValueChanged(null); + } catch (NumberFormatException ex) + { } - catch (NumberFormatException ex) - {} } else if (evt.getSource() == minColour) { @@ -267,9 +287,9 @@ public class AnnotationColourChooser { if (!adjusting) { - thresholdValue.setText( ( (float) slider.getValue() / 1000f) + ""); + thresholdValue.setText(((float) slider.getValue() / 1000f) + ""); if (currentColours.getState() - && ! (av.getGlobalColourScheme() instanceof AnnotationColourGradient)) + && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient)) { changeColour(); } @@ -289,8 +309,7 @@ public class AnnotationColourChooser } else { - new UserDefinedColours(this, "Min Colour", - minColour.getBackground()); + new UserDefinedColours(this, "Min Colour", minColour.getBackground()); } } @@ -305,8 +324,7 @@ public class AnnotationColourChooser } else { - new UserDefinedColours(this, "Max Colour", - maxColour.getBackground()); + new UserDefinedColours(this, "Max Colour", maxColour.getBackground()); } } @@ -318,9 +336,8 @@ public class AnnotationColourChooser return; } - - currentAnnotation = av.alignment.getAlignmentAnnotation() - [annotations.getSelectedIndex()]; + currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations + .getSelectedIndex()]; int aboveThreshold = -1; if (threshold.getSelectedItem().equals("Above Threshold")) @@ -341,23 +358,22 @@ public class AnnotationColourChooser thresholdValue.setEnabled(false); thresholdValue.setText(""); } - else if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD && - currentAnnotation.threshold == null) - { - currentAnnotation.setThreshold(new jalview.datamodel.GraphLine - ( (currentAnnotation.graphMax - - currentAnnotation.graphMin) / 2f, - "Threshold", - Color.black)); + else if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD + && currentAnnotation.threshold == null) + { + currentAnnotation + .setThreshold(new jalview.datamodel.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)); + 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); @@ -367,21 +383,17 @@ public class AnnotationColourChooser AnnotationColourGradient acg = null; if (currentColours.getState()) { - acg = new AnnotationColourGradient( - currentAnnotation, - av.getGlobalColourScheme(), aboveThreshold); + acg = new AnnotationColourGradient(currentAnnotation, av + .getGlobalColourScheme(), aboveThreshold); } else { - acg = - new AnnotationColourGradient( - currentAnnotation, - minColour.getBackground(), - maxColour.getBackground(), - aboveThreshold); + acg = new AnnotationColourGradient(currentAnnotation, minColour + .getBackground(), maxColour.getBackground(), aboveThreshold); } - if (currentAnnotation.graphMin == 0f && currentAnnotation.graphMax == 0f) + if (currentAnnotation.graphMin == 0f + && currentAnnotation.graphMax == 0f) { acg.predefinedColours = true; } @@ -405,17 +417,14 @@ public class AnnotationColourChooser if (currentColours.getState()) { - sg.cs = new AnnotationColourGradient( - currentAnnotation, - sg.cs, aboveThreshold); + sg.cs = new AnnotationColourGradient(currentAnnotation, sg.cs, + aboveThreshold); } else { - sg.cs = new AnnotationColourGradient( - currentAnnotation, - minColour.getBackground(), - maxColour.getBackground(), - aboveThreshold); + sg.cs = new AnnotationColourGradient(currentAnnotation, minColour + .getBackground(), maxColour.getBackground(), + aboveThreshold); } } @@ -437,8 +446,10 @@ public class AnnotationColourChooser Object cs = oldgroupColours.get(sg); if (cs instanceof ColourSchemeI) { - sg.cs = (ColourSchemeI) cs; - } else { + sg.cs = (ColourSchemeI) cs; + } + else + { // probably the "null" string we set it to if it was null originally. sg.cs = null; } @@ -448,11 +459,25 @@ public class AnnotationColourChooser } - 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){} + 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/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 2d2d748..28270c9 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -26,24 +25,35 @@ import java.awt.event.*; import jalview.datamodel.*; -public class AnnotationLabels - extends Panel implements ActionListener, MouseListener, MouseMotionListener +public class AnnotationLabels extends Panel 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; @@ -103,9 +113,8 @@ public class AnnotationLabels if (evt.getActionCommand().equals(ADDNEW)) { - AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", - null, - new Annotation[ap.av.alignment.getWidth()]); + AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", null, + new Annotation[ap.av.alignment.getWidth()]); if (!editLabelDescription(newAnnotation)) { @@ -127,17 +136,17 @@ public class AnnotationLabels { for (int i = 0; i < aa.length; i++) { - aa[i].visible = (aa[i].annotations==null) ? false : true; + aa[i].visible = (aa[i].annotations == null) ? false : true; } } else if (evt.getActionCommand().equals(OUTPUT_TEXT)) { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame); + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, + ap.alignFrame); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - ap.alignFrame.getTitle() + " - " + - aa[selectedRow].label, 500, 100); + jalview.bin.JalviewLite.addFrame(frame, ap.alignFrame.getTitle() + + " - " + aa[selectedRow].label, 500, 100); cap.setText(aa[selectedRow].toString()); } else if (evt.getActionCommand().equals(COPYCONS_SEQ)) @@ -158,17 +167,12 @@ public class AnnotationLabels boolean editLabelDescription(AlignmentAnnotation annotation) { Checkbox padGaps = new Checkbox("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); + + 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); Panel empty = new Panel(new FlowLayout()); empty.add(padGaps); @@ -198,14 +202,13 @@ public class AnnotationLabels { if (tooltip == null) { - tooltip = new Tooltip(ap.av.alignment. - getAlignmentAnnotation()[row].getDescription(true), - this); + tooltip = new Tooltip(ap.av.alignment.getAlignmentAnnotation()[row] + .getDescription(true), this); } else { - tooltip.setTip(ap.av.alignment. - getAlignmentAnnotation()[row].getDescription(true)); + tooltip.setTip(ap.av.alignment.getAlignmentAnnotation()[row] + .getDescription(true)); } } else if (tooltip != null) @@ -216,19 +219,24 @@ public class AnnotationLabels } public void mouseDragged(MouseEvent evt) - {} + { + } public void mouseClicked(MouseEvent evt) - {} + { + } public void mouseReleased(MouseEvent evt) - {} + { + } public void mouseEntered(MouseEvent evt) - {} + { + } public void mouseExited(MouseEvent evt) - {} + { + } public void mousePressed(MouseEvent evt) { @@ -259,8 +267,7 @@ public class AnnotationLabels { popup.addSeparator(); final CheckboxMenuItem cbmi = new CheckboxMenuItem( - "Ignore Gaps In Consensus", - ap.av.getIgnoreGapsConsensus()); + "Ignore Gaps In Consensus", ap.av.getIgnoreGapsConsensus()); cbmi.addItemListener(new ItemListener() { @@ -282,8 +289,9 @@ public class AnnotationLabels /** * DOCUMENT ME! - * - * @param e DOCUMENT ME! + * + * @param e + * DOCUMENT ME! */ protected void copy_annotseqtoclipboard(SequenceI sq) { @@ -292,21 +300,20 @@ public class AnnotationLabels return; } jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer(); - jalview.appletgui.AlignFrame.copiedSequences.append(sq.getName() + "\t" + - sq.getStart() + "\t" + - sq.getEnd() + "\t" + - sq.getSequenceAsString() + "\n"); + jalview.appletgui.AlignFrame.copiedSequences.append(sq.getName() + "\t" + + sq.getStart() + "\t" + sq.getEnd() + "\t" + + sq.getSequenceAsString() + "\n"); if (av.hasHiddenColumns) { jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector(); for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) { - int[] region = (int[]) - av.getColumnSelection().getHiddenColumns().elementAt(i); + int[] region = (int[]) av.getColumnSelection().getHiddenColumns() + .elementAt(i); - jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement(new int[] - {region[0], - region[1]}); + jalview.appletgui.AlignFrame.copiedHiddenColumns + .addElement(new int[] + { region[0], region[1] }); } } } diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 909ce78..13db915 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -26,29 +25,41 @@ import java.awt.event.*; import jalview.datamodel.*; -public class AnnotationPanel - extends Panel - implements AdjustmentListener, ActionListener, MouseListener, MouseMotionListener +public class AnnotationPanel extends Panel implements AdjustmentListener, + ActionListener, MouseListener, MouseMotionListener { AlignViewport av; + AlignmentPanel ap; + int activeRow = -1; Vector activeRes; + static String HELIX = "Helix"; + static String SHEET = "Sheet"; + static String LABEL = "Label"; + static String REMOVE = "Remove Annotation"; + static String COLOUR = "Colour"; + static Color HELIX_COLOUR = Color.red.darker(); + static Color SHEET_COLOUR = Color.green.darker().darker(); - + Image image; + Graphics gg; + FontMetrics fm; + int imgWidth = 0; boolean fastPaint = false; + public static int GRAPH_HEIGHT = 40; boolean MAC = false; @@ -65,7 +76,6 @@ public class AnnotationPanel addMouseListener(this); - // ap.annotationScroller.getVAdjustable().addAdjustmentListener( this ); } @@ -76,13 +86,14 @@ public class AnnotationPanel public void adjustmentValueChanged(AdjustmentEvent evt) { - ap.alabels.setScrollOffset( -evt.getValue()); + ap.alabels.setScrollOffset(-evt.getValue()); } /** * DOCUMENT ME! - * - * @param evt DOCUMENT ME! + * + * @param evt + * DOCUMENT ME! */ public void actionPerformed(ActionEvent evt) { @@ -99,10 +110,9 @@ public class AnnotationPanel String label = ""; if (av.colSel != null && av.colSel.size() > 0 - && anot[av.colSel.getMin()] != null) + && anot[av.colSel.getMin()] != null) label = anot[av.getColumnSelection().getMin()].displayCharacter; - if (evt.getActionCommand().equals(REMOVE)) { for (int i = 0; i < av.getColumnSelection().size(); i++) @@ -119,7 +129,7 @@ public class AnnotationPanel return; } - if ( (label.length() > 0) && !aa[activeRow].hasText) + if ((label.length() > 0) && !aa[activeRow].hasText) { aa[activeRow].hasText = true; } @@ -128,7 +138,7 @@ public class AnnotationPanel { int index = av.getColumnSelection().columnAt(i); - if(!av.colSel.isVisible(index)) + if (!av.colSel.isVisible(index)) continue; if (anot[index] == null) @@ -141,9 +151,8 @@ public class AnnotationPanel } else if (evt.getActionCommand().equals(COLOUR)) { - UserDefinedColours udc = new UserDefinedColours( - this, - Color.black, ap.alignFrame); + UserDefinedColours udc = new UserDefinedColours(this, Color.black, + ap.alignFrame); Color col = udc.getColor(); @@ -151,7 +160,7 @@ public class AnnotationPanel { int index = av.getColumnSelection().columnAt(i); - if(!av.colSel.isVisible(index)) + if (!av.colSel.isVisible(index)) continue; if (anot[index] == null) @@ -162,7 +171,8 @@ public class AnnotationPanel anot[index].colour = col; } } - else // HELIX OR SHEET + else + // HELIX OR SHEET { char type = 0; String symbol = "\u03B1"; @@ -189,7 +199,7 @@ public class AnnotationPanel return; } - if ( (label.length() > 0) && !aa[activeRow].hasText) + if ((label.length() > 0) && !aa[activeRow].hasText) { aa[activeRow].hasText = true; } @@ -198,7 +208,7 @@ public class AnnotationPanel { int index = av.getColumnSelection().columnAt(i); - if(!av.colSel.isVisible(index)) + if (!av.colSel.isVisible(index)) continue; if (anot[index] == null) @@ -219,10 +229,10 @@ public class AnnotationPanel String enterLabel(String text, String label) { - EditNameDialog dialog = new EditNameDialog(text,null,label,null, - ap.alignFrame,"Enter Label", 400,200, true); + EditNameDialog dialog = new EditNameDialog(text, null, label, null, + ap.alignFrame, "Enter Label", 400, 200, true); - if(dialog.accept) + if (dialog.accept) return dialog.getName(); else return null; @@ -230,70 +240,69 @@ public class AnnotationPanel public void mousePressed(MouseEvent evt) { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - if (aa == null) - { - return; - } - - int height = 0; - activeRow = -1; + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if (aa == null) + { + return; + } + int height = 0; + activeRow = -1; - for (int i = 0; i < aa.length; i++) + for (int i = 0; i < aa.length; i++) + { + if (aa[i].visible) { - if (aa[i].visible) - { - height += aa[i].height; - } - - if (evt.getY() < height) - { - if (aa[i].editable) - { - activeRow = i; - } - - break; - } + height += aa[i].height; } - if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == - InputEvent.BUTTON3_MASK && activeRow != -1) + if (evt.getY() < height) { - if (av.getColumnSelection() == null) + if (aa[i].editable) { - return; + activeRow = i; } - PopupMenu pop = new PopupMenu("Structure type"); - MenuItem item = new MenuItem(HELIX); - item.addActionListener(this); - pop.add(item); - item = new MenuItem(SHEET); - item.addActionListener(this); - pop.add(item); - item = new MenuItem(LABEL); - item.addActionListener(this); - pop.add(item); - item = new MenuItem(COLOUR); - item.addActionListener(this); - pop.add(item); - item = new MenuItem(REMOVE); - item.addActionListener(this); - pop.add(item); - ap.alignFrame.add(pop); - pop.show(this, evt.getX(), evt.getY()); - - return; + break; } + } - if (aa == null) + if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK + && activeRow != -1) + { + if (av.getColumnSelection() == null) { return; } - ap.scalePanel.mousePressed(evt); + PopupMenu pop = new PopupMenu("Structure type"); + MenuItem item = new MenuItem(HELIX); + item.addActionListener(this); + pop.add(item); + item = new MenuItem(SHEET); + item.addActionListener(this); + pop.add(item); + item = new MenuItem(LABEL); + item.addActionListener(this); + pop.add(item); + item = new MenuItem(COLOUR); + item.addActionListener(this); + pop.add(item); + item = new MenuItem(REMOVE); + item.addActionListener(this); + pop.add(item); + ap.alignFrame.add(pop); + pop.show(this, evt.getX(), evt.getY()); + + return; + } + + if (aa == null) + { + return; + } + + ap.scalePanel.mousePressed(evt); } public void mouseReleased(MouseEvent evt) @@ -302,7 +311,8 @@ public class AnnotationPanel } public void mouseClicked(MouseEvent evt) - {} + { + } public void mouseDragged(MouseEvent evt) { @@ -341,7 +351,8 @@ public class AnnotationPanel res = av.getColumnSelection().adjustForHiddenColumns(res); } - if (row > -1 && res < aa[row].annotations.length && aa[row].annotations[res] != null) + if (row > -1 && res < aa[row].annotations.length + && aa[row].annotations[res] != null) { StringBuffer text = new StringBuffer("Sequence position " + (res + 1)); if (aa[row].annotations[res].description != null) @@ -351,16 +362,17 @@ public class AnnotationPanel ap.alignFrame.statusBar.setText(text.toString()); } } + public void mouseEntered(MouseEvent evt) { ap.scalePanel.mouseEntered(evt); } + public void mouseExited(MouseEvent evt) { ap.scalePanel.mouseExited(evt); } - public int adjustPanelHeight() { // setHeight of panels @@ -444,7 +456,6 @@ public class AnnotationPanel activeRes.addElement(String.valueOf(i)); } - public void update(Graphics g) { paint(g); @@ -454,7 +465,7 @@ public class AnnotationPanel { imgWidth = getSize().width; - //(av.endRes - av.startRes + 1) * av.charWidth; + // (av.endRes - av.startRes + 1) * av.charWidth; if (image == null || imgWidth != image.getWidth(this)) { @@ -481,16 +492,15 @@ public class AnnotationPanel public void fastPaint(int horizontal) { - if (horizontal == 0 - || av.alignment.getAlignmentAnnotation() == null - || av.alignment.getAlignmentAnnotation().length < 1 - ) + if (horizontal == 0 || av.alignment.getAlignmentAnnotation() == null + || av.alignment.getAlignmentAnnotation().length < 1) { repaint(); return; } - gg.copyArea(0, 0, imgWidth, getSize().height, -horizontal * av.charWidth, 0); + gg.copyArea(0, 0, imgWidth, getSize().height, -horizontal + * av.charWidth, 0); int sr = av.startRes, er = av.endRes + 1, transX = 0; if (horizontal > 0) // scrollbar pulled right, image to the left @@ -507,7 +517,7 @@ public class AnnotationPanel drawComponent(gg, sr, er); - gg.translate( -transX, 0); + gg.translate(-transX, 0); fastPaint = true; repaint(); @@ -515,10 +525,13 @@ public class AnnotationPanel /** * DOCUMENT ME! - * - * @param g DOCUMENT ME! - * @param startRes DOCUMENT ME! - * @param endRes DOCUMENT ME! + * + * @param g + * DOCUMENT ME! + * @param startRes + * DOCUMENT ME! + * @param endRes + * DOCUMENT ME! */ public void drawComponent(Graphics g, int startRes, int endRes) { @@ -532,8 +545,8 @@ public class AnnotationPanel fm = g.getFontMetrics(); } - if ( (av.alignment.getAlignmentAnnotation() == null) || - (av.alignment.getAlignmentAnnotation().length < 1)) + if ((av.alignment.getAlignmentAnnotation() == null) + || (av.alignment.getAlignmentAnnotation().length < 1)) { g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); @@ -558,7 +571,7 @@ public class AnnotationPanel boolean validEnd = false; boolean[] graphGroupDrawn = new boolean[aa.length]; - //\u03B2 \u03B1 + // \u03B2 \u03B1 for (int i = 0; i < aa.length; i++) { AlignmentAnnotation row = aa[i]; @@ -601,7 +614,8 @@ public class AnnotationPanel { if (av.hasHiddenColumns) { - column = av.getColumnSelection().adjustForHiddenColumns(startRes + x); + column = av.getColumnSelection().adjustForHiddenColumns( + startRes + x); if (column > row.annotations.length - 1) { break; @@ -612,8 +626,8 @@ public class AnnotationPanel column = startRes + x; } - if ( (row.annotations.length <= column) || - (row.annotations[column] == null)) + if ((row.annotations.length <= column) + || (row.annotations[column] == null)) { validRes = false; } @@ -634,25 +648,26 @@ public class AnnotationPanel if (v == column) { - g.fillRect(x * av.charWidth, y, - av.charWidth, av.charHeight); + g + .fillRect(x * av.charWidth, y, av.charWidth, + av.charHeight); } } } } - - - if (av.validCharWidth && validRes && - (row.annotations[column].displayCharacter!=null && row.annotations[column].displayCharacter.length() > 0)) + if (av.validCharWidth + && validRes + && (row.annotations[column].displayCharacter != null && row.annotations[column].displayCharacter + .length() > 0)) { - int charOffset = (av.getCentreColumnLabels()) ? ((av.charWidth - - fm.charsWidth(row.annotations[column]. - displayCharacter.toCharArray(),0, - row.annotations[column]. - displayCharacter.length())) / 2) - : (av.charWidth - fm.charWidth(row.annotations[column]. - displayCharacter.charAt(0))) / 2; + int charOffset = (av.getCentreColumnLabels()) ? ((av.charWidth - fm + .charsWidth(row.annotations[column].displayCharacter + .toCharArray(), 0, + row.annotations[column].displayCharacter.length())) / 2) + : (av.charWidth - fm + .charWidth(row.annotations[column].displayCharacter + .charAt(0))) / 2; if (row.annotations[column].colour == null) g.setColor(Color.black); @@ -662,87 +677,78 @@ public class AnnotationPanel if (column == 0 || row.graph > 0) { g.drawString(row.annotations[column].displayCharacter, - (x * av.charWidth) + charOffset, - y + iconOffset + 3); + (x * av.charWidth) + charOffset, y + iconOffset + 3); } - else if ( - row.annotations[column - 1] == null - || (!row.annotations[column].displayCharacter.equals( - row.annotations[column - 1].displayCharacter) - || - (row.annotations[column].displayCharacter.length() < 2 && - row.annotations[column].secondaryStructure == ' '))) + else if (row.annotations[column - 1] == null + || (!row.annotations[column].displayCharacter + .equals(row.annotations[column - 1].displayCharacter) || (row.annotations[column].displayCharacter + .length() < 2 && row.annotations[column].secondaryStructure == ' '))) { g.drawString(row.annotations[column].displayCharacter, - (x * av.charWidth) + charOffset, - y + iconOffset + 3); + (x * av.charWidth) + charOffset, y + iconOffset + 3); } } if (row.hasIcons) { - if (!validRes || - (row.annotations[column].secondaryStructure != lastSS)) + if (!validRes + || (row.annotations[column].secondaryStructure != lastSS)) { switch (lastSS) { - case 'H': - g.setColor(HELIX_COLOUR); - if (MAC) - { - //Off by 1 offset when drawing rects and ovals - //to offscreen image on the MAC - g.fillRoundRect(lastSSX, y + 4 + iconOffset, - (x * av.charWidth) - lastSSX, 7, 8, 8); - break; - } - - int sCol = (lastSSX / av.charWidth) + startRes; - int x1 = lastSSX; - int x2 = (x * av.charWidth); - - if (sCol == 0 || - row.annotations[sCol - 1] == null || - row.annotations[sCol - 1].secondaryStructure != 'H') - { - g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, - 180); - x1 += av.charWidth / 2; - } - - if (row.annotations[column] == null || - row.annotations[column].secondaryStructure != 'H') - { - g.fillArc( (x * av.charWidth) - av.charWidth, - y + 4 + iconOffset, av.charWidth, 8, 270, 180); - x2 -= av.charWidth / 2; - } - - g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8); + case 'H': + g.setColor(HELIX_COLOUR); + if (MAC) + { + // Off by 1 offset when drawing rects and ovals + // to offscreen image on the MAC + g.fillRoundRect(lastSSX, y + 4 + iconOffset, + (x * av.charWidth) - lastSSX, 7, 8, 8); break; + } - case 'E': - g.setColor(SHEET_COLOUR); - g.fillRect(lastSSX, y + 4 + iconOffset, - (x * av.charWidth) - lastSSX - 4, 7); - g.fillPolygon(new int[] - { (x * av.charWidth) - 4, - (x * av.charWidth) - 4, - (x * av.charWidth)}, - new int[] - { - y + iconOffset, y + 14 + iconOffset, - y + 8 + iconOffset - }, 3); + int sCol = (lastSSX / av.charWidth) + startRes; + int x1 = lastSSX; + int x2 = (x * av.charWidth); - break; + if (sCol == 0 + || row.annotations[sCol - 1] == null + || row.annotations[sCol - 1].secondaryStructure != 'H') + { + g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, + 180); + x1 += av.charWidth / 2; + } + + if (row.annotations[column] == null + || row.annotations[column].secondaryStructure != 'H') + { + g.fillArc((x * av.charWidth) - av.charWidth, y + 4 + + iconOffset, av.charWidth, 8, 270, 180); + x2 -= av.charWidth / 2; + } - default: - g.setColor(Color.gray); - g.fillRect(lastSSX, y + 6 + iconOffset, - (x * av.charWidth) - lastSSX, 2); + g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8); + break; - break; + case 'E': + g.setColor(SHEET_COLOUR); + g.fillRect(lastSSX, y + 4 + iconOffset, (x * av.charWidth) + - lastSSX - 4, 7); + g.fillPolygon(new int[] + { (x * av.charWidth) - 4, (x * av.charWidth) - 4, + (x * av.charWidth) }, new int[] + { y + iconOffset, y + 14 + iconOffset, y + 8 + iconOffset }, + 3); + + break; + + default: + g.setColor(Color.gray); + g.fillRect(lastSSX, y + 6 + iconOffset, (x * av.charWidth) + - lastSSX, 2); + + break; } if (validRes) @@ -766,86 +772,83 @@ public class AnnotationPanel { column = row.annotations.length - 1; validEnd = false; - } else { + } + else + { validEnd = true; } - // x ++; + // x ++; if (row.hasIcons) { switch (lastSS) { - case 'H': - g.setColor(HELIX_COLOUR); - if (MAC) - { - //Off by 1 offset when drawing rects and ovals - //to offscreen image on the MAC - g.fillRoundRect(lastSSX, y + 4 + iconOffset, - (x * av.charWidth) - lastSSX, 7, 8, 8); - break; - } + case 'H': + g.setColor(HELIX_COLOUR); + if (MAC) + { + // Off by 1 offset when drawing rects and ovals + // to offscreen image on the MAC + g.fillRoundRect(lastSSX, y + 4 + iconOffset, (x * av.charWidth) + - lastSSX, 7, 8, 8); + break; + } - int sCol = (lastSSX / av.charWidth) + startRes; - int x1 = lastSSX; - int x2 = (x * av.charWidth); + int sCol = (lastSSX / av.charWidth) + startRes; + int x1 = lastSSX; + int x2 = (x * av.charWidth); - if (sCol == 0 || - row.annotations[sCol - 1] == null || - row.annotations[sCol - 1].secondaryStructure != 'H') - { - g.fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, 90, 180); - x1 += av.charWidth / 2; - } + if (sCol == 0 || row.annotations[sCol - 1] == null + || row.annotations[sCol - 1].secondaryStructure != 'H') + { + g + .fillArc(lastSSX, y + 4 + iconOffset, av.charWidth, 8, + 90, 180); + x1 += av.charWidth / 2; + } - if (row.annotations[column] == null || - row.annotations[column].secondaryStructure != 'H') - { - g.fillArc( (x * av.charWidth) - av.charWidth, - y + 4 + iconOffset, av.charWidth, 8, 270, - 180); - x2 -= av.charWidth / 2; - } + if (row.annotations[column] == null + || row.annotations[column].secondaryStructure != 'H') + { + g.fillArc((x * av.charWidth) - av.charWidth, + y + 4 + iconOffset, av.charWidth, 8, 270, 180); + x2 -= av.charWidth / 2; + } - g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8); + g.fillRect(x1, y + 4 + iconOffset, x2 - x1, 8); - break; + break; - case 'E': - g.setColor(SHEET_COLOUR); + case 'E': + g.setColor(SHEET_COLOUR); - if (!validEnd || row.annotations[endRes] == null - || row.annotations[endRes].secondaryStructure != 'E') - { - g.fillRect(lastSSX, y + 4 + iconOffset, - (x * av.charWidth) - lastSSX - 4, 7); - g.fillPolygon(new int[] - { (x * av.charWidth) - 4, - (x * av.charWidth) - 4, - (x * av.charWidth)}, - new int[] - { - y + iconOffset, y + 14 + iconOffset, - y + 7 + iconOffset - }, 3); - } - else - { - g.fillRect(lastSSX, y + 4 + iconOffset, - x * av.charWidth - lastSSX, 7); - } - break; + if (!validEnd || row.annotations[endRes] == null + || row.annotations[endRes].secondaryStructure != 'E') + { + g.fillRect(lastSSX, y + 4 + iconOffset, (x * av.charWidth) + - lastSSX - 4, 7); + g.fillPolygon(new int[] + { (x * av.charWidth) - 4, (x * av.charWidth) - 4, + (x * av.charWidth) }, new int[] + { y + iconOffset, y + 14 + iconOffset, y + 7 + iconOffset }, 3); + } + else + { + g.fillRect(lastSSX, y + 4 + iconOffset, x * av.charWidth + - lastSSX, 7); + } + break; - default: - g.setColor(Color.gray); - if (!av.wrapAlignment || endRes == av.endRes) - { - g.fillRect(lastSSX, y + 6 + iconOffset, - (x * av.charWidth) - lastSSX, 2); - } + default: + g.setColor(Color.gray); + if (!av.wrapAlignment || endRes == av.endRes) + { + g.fillRect(lastSSX, y + 6 + iconOffset, (x * av.charWidth) + - lastSSX, 2); + } - break; + break; } } @@ -882,9 +885,8 @@ public class AnnotationPanel { if (aa[gg].graphGroup == row.graphGroup) { - drawLineGraph(g, aa[gg], startRes, endRes, y, - groupmin, groupmax, - row.graphHeight); + drawLineGraph(g, aa[gg], startRes, endRes, y, groupmin, + groupmax, row.graphHeight); } } @@ -892,14 +894,14 @@ public class AnnotationPanel } else { - drawLineGraph(g, row, startRes, endRes, - y, row.graphMin, row.graphMax, row.graphHeight); + drawLineGraph(g, row, startRes, endRes, y, row.graphMin, + row.graphMax, row.graphHeight); } } else if (row.graph == AlignmentAnnotation.BAR_GRAPH) { - drawBarGraph(g, row, startRes, endRes, - row.graphMin, row.graphMax, y); + drawBarGraph(g, row, startRes, endRes, row.graphMin, + row.graphMax, y); } } @@ -915,11 +917,8 @@ public class AnnotationPanel } } - public void drawLineGraph(Graphics g, AlignmentAnnotation aa, - int sRes, int eRes, - int y, - float min, float max, - int graphHeight) + public void drawLineGraph(Graphics g, AlignmentAnnotation aa, int sRes, + int eRes, int y, float min, float max, int graphHeight) { if (sRes > aa.annotations.length) { @@ -928,7 +927,7 @@ public class AnnotationPanel int x = 0; - //Adjustment for fastpaint to left + // Adjustment for fastpaint to left if (eRes < av.endRes) { eRes++; @@ -939,10 +938,10 @@ public class AnnotationPanel int y1 = y, y2 = y; float range = max - min; - ////Draw origin + // //Draw origin if (min < 0) { - y2 = y - (int) ( (0 - min / range) * graphHeight); + y2 = y - (int) ((0 - min / range) * graphHeight); } g.setColor(Color.gray); @@ -965,8 +964,9 @@ public class AnnotationPanel { break; } - - if (aa.annotations[column] == null) // || coaa.annotations[column - 1] == null) + + if (aa.annotations[column] == null) // || coaa.annotations[column - 1] == + // null) { x++; continue; @@ -976,19 +976,21 @@ public class AnnotationPanel g.setColor(Color.black); else g.setColor(aa.annotations[column].colour); - if (column==0 || aa.annotations[column-1]==null) + if (column == 0 || aa.annotations[column - 1] == null) + { + y1 = y + - (int) (((aa.annotations[column].value - min) / range) * graphHeight); + } + else { - y1 = y - - (int) ( ( (aa.annotations[column].value - min) / range) * graphHeight); - } else { - y1 = y - - (int) ( ( (aa.annotations[column-1].value - min) / range) * graphHeight); + y1 = y + - (int) (((aa.annotations[column - 1].value - min) / range) * graphHeight); } - y2 = y - - (int) ( ( (aa.annotations[column].value - min) / range) * graphHeight); + y2 = y + - (int) (((aa.annotations[column].value - min) / range) * graphHeight); - g.drawLine(x * av.charWidth - av.charWidth / 2, y1, - x * av.charWidth + av.charWidth / 2, y2); + g.drawLine(x * av.charWidth - av.charWidth / 2, y1, x * av.charWidth + + av.charWidth / 2, y2); x++; } @@ -996,15 +998,13 @@ public class AnnotationPanel { g.setColor(aa.threshold.colour); - y2 = (int) (y - ( (aa.threshold.value - min) / range) * graphHeight); + y2 = (int) (y - ((aa.threshold.value - min) / range) * graphHeight); g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2); } } - public void drawBarGraph(Graphics g, AlignmentAnnotation aa, - int sRes, int eRes, - float min, float max, - int y) + public void drawBarGraph(Graphics g, AlignmentAnnotation aa, int sRes, + int eRes, float min, float max, int y) { if (sRes > aa.annotations.length) { @@ -1019,7 +1019,7 @@ public class AnnotationPanel if (min < 0) { - y2 = y - (int) ( (0 - min / (range)) * aa.graphHeight); + y2 = y - (int) ((0 - min / (range)) * aa.graphHeight); } g.setColor(Color.gray); @@ -1053,8 +1053,8 @@ public class AnnotationPanel else g.setColor(aa.annotations[column].colour); - y1 = y - - (int) ( ( (aa.annotations[column].value - min) / (range)) * aa.graphHeight); + y1 = y + - (int) (((aa.annotations[column].value - min) / (range)) * aa.graphHeight); if (y1 - y2 > 0) { @@ -1071,14 +1071,14 @@ public class AnnotationPanel if (aa.threshold != null) { g.setColor(aa.threshold.colour); - y2 = (int) (y - ( (aa.threshold.value - min) / range) * aa.graphHeight); + y2 = (int) (y - ((aa.threshold.value - min) / range) * aa.graphHeight); g.drawLine(0, y2, (eRes - sRes) * av.charWidth, y2); } } // used by overview window - public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, - int sRes, int eRes) + public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, + int y, int sRes, int eRes) { eRes = Math.min(eRes, aa.annotations.length); g.setColor(Color.white); @@ -1094,7 +1094,7 @@ public class AnnotationPanel else g.setColor(aa.annotations[j].colour); - height = (int) ( (aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); if (height > y) { height = y; diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index 82a5911..7939d9b 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -33,71 +32,121 @@ import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.popup.*; import jalview.schemes.*; - -public class AppletJmol extends EmbmenuFrame - implements StructureListener, JmolStatusListener, - KeyListener, ActionListener, ItemListener +public class AppletJmol extends EmbmenuFrame implements StructureListener, + JmolStatusListener, KeyListener, ActionListener, ItemListener { Menu fileMenu = new Menu("File"); + Menu viewMenu = new Menu("View"); + Menu coloursMenu = new Menu("Colours"); + Menu chainMenu = new Menu("Show Chain"); + Menu helpMenu = new Menu("Help"); + MenuItem mappingMenuItem = new MenuItem("View Mapping"); CheckboxMenuItem seqColour = new CheckboxMenuItem("By Sequence", true); + MenuItem chain = new MenuItem("By Chain"); + MenuItem charge = new MenuItem("Charge & Cysteine"); + MenuItem zappo = new MenuItem("Zappo"); + MenuItem taylor = new MenuItem("Taylor"); + MenuItem hydro = new MenuItem("Hydrophobicity"); + MenuItem helix = new MenuItem("Helix Propensity"); + MenuItem strand = new MenuItem("Strand Propensity"); + MenuItem turn = new MenuItem("Turn Propensity"); + MenuItem buried = new MenuItem("Buried Index"); + MenuItem user = new MenuItem("User Defined Colours"); MenuItem jmolHelp = new MenuItem("Jmol Help"); JmolViewer viewer; + JmolPopup jmolpopup; Panel scriptWindow; + TextField inputLine; + TextArea history; + SequenceI[] sequence; - String [] chains; + + String[] chains; + StructureSelectionManager ssm; + RenderPanel renderPanel; + AlignmentPanel ap; + String fileLoadingError; + boolean loadedInline; + PDBEntry pdbentry; + boolean colourBySequence = true; + Vector atomsPicked = new Vector(); - public AppletJmol(PDBEntry pdbentry, - SequenceI[] seq, - String[] chains, - AlignmentPanel ap, - String protocol) + /** + * datasource protocol for access to PDBEntry + */ + String protocol = null; + + public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains, + AlignmentPanel ap, String protocol) { this.ap = ap; this.sequence = seq; this.chains = chains; this.pdbentry = pdbentry; + this.protocol = protocol; + if (pdbentry.getId() == null || pdbentry.getId().length() < 1) + { + if (jalview.bin.JalviewLite.debug) + { + System.err.println("Setting PDB id for file " + pdbentry.getFile()); + if (protocol.equals(AppletFormatAdapter.PASTE)) + { + pdbentry.setId("PASTED PDB" + + (chains == null ? "_" : chains.toString())); + } + else + { + pdbentry.setId(pdbentry.getFile()); + } + } + } + if (jalview.bin.JalviewLite.debug) + { + System.err + .println("AppletJmol: PDB ID is '" + pdbentry.getId() + "'"); + } - String alreadyMapped = StructureSelectionManager - .getStructureSelectionManager() - .alreadyMappedToFile(pdbentry.getId()); - + String alreadyMapped = StructureSelectionManager + .getStructureSelectionManager().alreadyMappedToFile( + pdbentry.getId()); + MCview.PDBfile reader = null; if (alreadyMapped != null) { - StructureSelectionManager.getStructureSelectionManager() - .setMapping(seq, chains, pdbentry.getFile(), protocol); - //PROMPT USER HERE TO ADD TO NEW OR EXISTING VIEW? - //FOR NOW, LETS JUST OPEN A NEW WINDOW + reader = StructureSelectionManager.getStructureSelectionManager() + .setMapping(seq, chains, pdbentry.getFile(), protocol); + // PROMPT USER HERE TO ADD TO NEW OR EXISTING VIEW? + // FOR NOW, LETS JUST OPEN A NEW WINDOW } MenuBar menuBar = new MenuBar(); menuBar.add(fileMenu); @@ -141,57 +190,90 @@ public class AppletJmol extends EmbmenuFrame renderPanel = new RenderPanel(); embedMenuIfNeeded(renderPanel); this.add(renderPanel, BorderLayout.CENTER); - viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter()); + viewer = JmolViewer.allocateViewer(renderPanel, + new SmarterJmolAdapter()); - viewer.setAppletContext("jalview", - ap.av.applet.getDocumentBase(), - ap.av.applet.getCodeBase(), - null); + viewer.setAppletContext("jalview", ap.av.applet.getDocumentBase(), + ap.av.applet.getCodeBase(), null); viewer.setJmolStatusListener(this); jmolpopup = JmolPopup.newJmolPopup(viewer); this.addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - closeViewer(); - } - }); - + { + public void windowClosing(WindowEvent evt) + { + closeViewer(); + } + }); - if(pdbentry.getFile()!=null) + if (pdbentry.getFile() != null) { // import structure data from pdbentry.getFile based on given protocol if (protocol.equals(AppletFormatAdapter.PASTE)) - { + { loadInline(pdbentry.getFile()); - } else - if (protocol.equals(AppletFormatAdapter.FILE) || protocol.equals(AppletFormatAdapter.URL)){ - viewer.openFile(pdbentry.getFile()); + } + else if (protocol.equals(AppletFormatAdapter.FILE) + || protocol.equals(AppletFormatAdapter.URL)) + { + viewer.openFile(pdbentry.getFile()); } else - { + { // probably CLASSLOADER based datasource.. // Try and get a reader on the datasource, and pass that to Jmol - try { - FileParse fparser = new jalview.io.FileParse(protocol, pdbentry.getFile()); - if (!fparser.isValid()) + try + { + java.io.Reader freader = null; + if (reader != null) + { + if (jalview.bin.JalviewLite.debug) + { + System.err + .println("AppletJmol:Trying to reuse existing PDBfile IO parser."); + } + // re-use the one we opened earlier + freader = reader.getReader(); + } + if (freader == null) + { + if (jalview.bin.JalviewLite.debug) + { + System.err + .println("AppletJmol:Creating new PDBfile IO parser."); + } + FileParse fp = new FileParse(pdbentry.getFile(), protocol); + fp.mark(); + // reader = new MCview.PDBfile(fp); + // could set ID, etc. + // if (!reader.isValid()) + // { + // throw new Exception("Invalid datasource. + // "+reader.getWarningMessage()); + // } + // fp.reset(); + freader = fp.getReader(); + } + if (freader == null) { - throw new Exception("Invalid datasource. "+fparser.getWarningMessage()); + throw new Exception( + "Invalid datasource. Could not obtain Reader."); } - viewer.openReader(pdbentry.getFile(), pdbentry.getId(), fparser.getReader()); + viewer.openReader(pdbentry.getFile(), pdbentry.getId(), freader); } catch (Exception e) { // give up! - System.err.println("Couldn't access pdbentry id="+pdbentry.getId()+" and file="+pdbentry.getFile()+" using protocol="+protocol); + System.err.println("Couldn't access pdbentry id=" + + pdbentry.getId() + " and file=" + pdbentry.getFile() + + " using protocol=" + protocol); e.printStackTrace(); } - } + } } - - jalview.bin.JalviewLite.addFrame(this, "Jmol", 400,400); + + jalview.bin.JalviewLite.addFrame(this, "Jmol", 400, 400); } public void loadInline(String string) @@ -200,7 +282,6 @@ public class AppletJmol extends EmbmenuFrame viewer.openStringInline(string); } - void setChainMenuItems(Vector chains) { chainMenu.removeAll(); @@ -213,13 +294,15 @@ public class AppletJmol extends EmbmenuFrame CheckboxMenuItem menuItemCB; for (int c = 0; c < chains.size(); c++) { - menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(), true); + menuItemCB = new CheckboxMenuItem(chains.elementAt(c).toString(), + true); menuItemCB.addItemListener(this); chainMenu.add(menuItemCB); } } boolean allChainsSelected = false; + void centerViewer() { StringBuffer cmd = new StringBuffer(); @@ -236,11 +319,11 @@ public class AppletJmol extends EmbmenuFrame if (cmd.length() > 0) cmd.setLength(cmd.length() - 4); - viewer.evalString("select *;restrict " - + cmd + ";cartoon;center " + cmd); + viewer + .evalString("select *;restrict " + cmd + ";cartoon;center " + + cmd); } - void closeViewer() { viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE); @@ -248,37 +331,35 @@ public class AppletJmol extends EmbmenuFrame viewer.setJmolStatusListener(null); viewer = null; - //We'll need to find out what other + // We'll need to find out what other // listeners need to be shut down in Jmol - StructureSelectionManager - .getStructureSelectionManager() - .removeStructureViewerListener(this, pdbentry.getId()); + StructureSelectionManager.getStructureSelectionManager() + .removeStructureViewerListener(this, pdbentry.getId()); this.setVisible(false); } public void actionPerformed(ActionEvent evt) { - if(evt.getSource()==mappingMenuItem) + if (evt.getSource() == mappingMenuItem) { - jalview.appletgui.CutAndPasteTransfer cap - = new jalview.appletgui.CutAndPasteTransfer(false, null); + jalview.appletgui.CutAndPasteTransfer cap = new jalview.appletgui.CutAndPasteTransfer( + false, null); Frame frame = new Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", 550, - 600); - cap.setText( - StructureSelectionManager.getStructureSelectionManager().printMapping( - pdbentry.getFile()) - ); + jalview.bin.JalviewLite.addFrame(frame, "PDB - Sequence Mapping", + 550, 600); + cap.setText(StructureSelectionManager.getStructureSelectionManager() + .printMapping(pdbentry.getFile())); } else if (evt.getSource() == charge) { colourBySequence = false; seqColour.setState(false); - viewer.evalStringQuiet("select *;color white;select ASP,GLU;color red;" - +"select LYS,ARG;color blue;select CYS;color yellow"); + viewer + .evalStringQuiet("select *;color white;select ASP,GLU;color red;" + + "select LYS,ARG;color blue;select CYS;color yellow"); } else if (evt.getSource() == chain) @@ -293,7 +374,7 @@ public class AppletJmol extends EmbmenuFrame } else if (evt.getSource() == taylor) { - setJalviewColourScheme(new TaylorColourScheme()); + setJalviewColourScheme(new TaylorColourScheme()); } else if (evt.getSource() == hydro) { @@ -319,13 +400,17 @@ public class AppletJmol extends EmbmenuFrame { new UserDefinedColours(this); } - else if(evt.getSource() == jmolHelp) + else if (evt.getSource() == jmolHelp) { - try{ + try + { ap.av.applet.getAppletContext().showDocument( - new java.net.URL("http://jmol.sourceforge.net/docs/JmolUserGuide/"), - "jmolHelp"); - }catch(java.net.MalformedURLException ex){} + new java.net.URL( + "http://jmol.sourceforge.net/docs/JmolUserGuide/"), + "jmolHelp"); + } catch (java.net.MalformedURLException ex) + { + } } else { @@ -333,7 +418,7 @@ public class AppletJmol extends EmbmenuFrame for (int i = 0; i < chainMenu.getItemCount(); i++) { if (chainMenu.getItem(i) instanceof CheckboxMenuItem) - ( (CheckboxMenuItem) chainMenu.getItem(i)).setState(true); + ((CheckboxMenuItem) chainMenu.getItem(i)).setState(true); } centerViewer(); allChainsSelected = false; @@ -345,7 +430,7 @@ public class AppletJmol extends EmbmenuFrame colourBySequence = false; seqColour.setState(false); - if(cs==null) + if (cs == null) return; String res; @@ -354,19 +439,17 @@ public class AppletJmol extends EmbmenuFrame Enumeration en = ResidueProperties.aa3Hash.keys(); StringBuffer command = new StringBuffer("select *;color white;"); - while(en.hasMoreElements()) + while (en.hasMoreElements()) { res = en.nextElement().toString(); index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue(); - if(index>20) + if (index > 20) continue; col = cs.findColour(ResidueProperties.aa[index].charAt(0)); - command.append("select "+res+";color[" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "];"); + command.append("select " + res + ";color[" + col.getRed() + "," + + col.getGreen() + "," + col.getBlue() + "];"); } viewer.evalStringQuiet(command.toString()); @@ -386,63 +469,66 @@ public class AppletJmol extends EmbmenuFrame public void keyPressed(KeyEvent evt) { - if (evt.getKeyCode() == KeyEvent.VK_ENTER - && scriptWindow.isVisible()) + if (evt.getKeyCode() == KeyEvent.VK_ENTER && scriptWindow.isVisible()) { viewer.evalString(inputLine.getText()); - history.append("\n$ "+inputLine.getText()); + history.append("\n$ " + inputLine.getText()); inputLine.setText(""); } } public void keyTyped(KeyEvent evt) - { } + { + } - public void keyReleased(KeyEvent evt){} + public void keyReleased(KeyEvent evt) + { + } - ////////////////////////////////// - ///StructureListener + // //////////////////////////////// + // /StructureListener public String getPdbFile() { return "???"; } - - String lastMessage; + public void mouseOverStructure(int atomIndex, String strInfo) { - int pdbResNum; + int pdbResNum; - int chainSeparator = strInfo.indexOf(":"); + int chainSeparator = strInfo.indexOf(":"); - if(chainSeparator==-1) - chainSeparator = strInfo.indexOf("."); + if (chainSeparator == -1) + chainSeparator = strInfo.indexOf("."); - pdbResNum = Integer.parseInt( - strInfo.substring(strInfo.indexOf("]")+ 1, chainSeparator)); + pdbResNum = Integer.parseInt(strInfo.substring( + strInfo.indexOf("]") + 1, chainSeparator)); - String chainId; + String chainId; - if (strInfo.indexOf(":") > -1) - chainId = strInfo.substring - (strInfo.indexOf(":")+1, strInfo.indexOf(".")); - else - { - chainId = " "; - } + if (strInfo.indexOf(":") > -1) + chainId = strInfo.substring(strInfo.indexOf(":") + 1, strInfo + .indexOf(".")); + else + { + chainId = " "; + } - if (lastMessage == null || !lastMessage.equals(strInfo)) - ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile()); + if (lastMessage == null || !lastMessage.equals(strInfo)) + ssm.mouseOverStructure(pdbResNum, chainId, pdbentry.getFile()); - lastMessage = strInfo; + lastMessage = strInfo; } StringBuffer resetLastRes = new StringBuffer(); + StringBuffer eval = new StringBuffer(); - public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile) + public void highlightAtom(int atomIndex, int pdbResNum, String chain, + String pdbfile) { if (!pdbfile.equals(pdbentry.getFile())) return; @@ -464,9 +550,10 @@ public class AppletJmol extends EmbmenuFrame resetLastRes.append(":" + chain); } - eval.append(";wireframe 100;"+eval.toString()+".CA;"); + eval.append(";wireframe 100;" + eval.toString() + ".CA;"); - resetLastRes.append(";wireframe 0;"+resetLastRes.toString()+".CA;spacefill 0;"); + resetLastRes.append(";wireframe 0;" + resetLastRes.toString() + + ".CA;spacefill 0;"); eval.append("spacefill 200;select none"); @@ -476,13 +563,14 @@ public class AppletJmol extends EmbmenuFrame public void updateColours(Object source) { - colourBySequence( (AlignmentPanel) source); + colourBySequence((AlignmentPanel) source); } -//End StructureListener -//////////////////////////// + // End StructureListener + // ////////////////////////// - public Color getColour(int atomIndex, int pdbResNum, String chain, String pdbfile) + public Color getColour(int atomIndex, int pdbResNum, String chain, + String pdbfile) { if (!pdbfile.equals(pdbentry.getFile())) return null; @@ -491,7 +579,9 @@ public class AppletJmol extends EmbmenuFrame } String lastCommand; - FeatureRenderer fr=null; + + FeatureRenderer fr = null; + public void colourBySequence(AlignmentPanel sourceap) { this.ap = sourceap; @@ -524,10 +614,10 @@ public class AppletJmol extends EmbmenuFrame int lastPos = -1; for (int s = 0; s < sequence.length; s++) { - for (int sp,m = 0; m < mapping.length; m++) + for (int sp, m = 0; m < mapping.length; m++) { if (mapping[m].getSequence() == sequence[s] - && (sp=ap.av.alignment.findIndex(sequence[s])) > -1) + && (sp = ap.av.alignment.findIndex(sequence[s])) > -1) { SequenceI asp = ap.av.alignment.getSequenceAt(sp); for (int r = 0; r < asp.getLength(); r++) @@ -537,9 +627,7 @@ public class AppletJmol extends EmbmenuFrame { continue; } - int pos = mapping[m].getPDBResNum( - asp.findPosition(r)); - + int pos = mapping[m].getPDBResNum(asp.findPosition(r)); if (pos < 1 || pos == lastPos) continue; @@ -551,11 +639,10 @@ public class AppletJmol extends EmbmenuFrame if (showFeatures) col = fr.findFeatureColour(col, sequence[s], r); - if (command.toString().endsWith(":" + mapping[m].getChain() + - ";color[" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "]")) + if (command.toString().endsWith( + ":" + mapping[m].getChain() + ";color[" + col.getRed() + + "," + col.getGreen() + "," + col.getBlue() + + "]")) { command = condenseCommand(command.toString(), pos); continue; @@ -568,10 +655,8 @@ public class AppletJmol extends EmbmenuFrame command.append(":" + mapping[m].getChain()); } - command.append(";color[" - + col.getRed() + "," - + col.getGreen() + "," - + col.getBlue() + "]"); + command.append(";color[" + col.getRed() + "," + col.getGreen() + + "," + col.getBlue() + "]"); } break; } @@ -585,11 +670,11 @@ public class AppletJmol extends EmbmenuFrame lastCommand = command.toString(); } - StringBuffer condenseCommand(String command, int pos) { - StringBuffer sb = new StringBuffer(command.substring(0, command.lastIndexOf("select")+7)); + StringBuffer sb = new StringBuffer(command.substring(0, command + .lastIndexOf("select") + 7)); command = command.substring(sb.length()); @@ -597,40 +682,41 @@ public class AppletJmol extends EmbmenuFrame if (command.indexOf("-") > -1) { - start = command.substring(0,command.indexOf("-")); + start = command.substring(0, command.indexOf("-")); } else { start = command.substring(0, command.indexOf(":")); } - sb.append(start+"-"+pos+command.substring(command.indexOf(":"))); + sb.append(start + "-" + pos + command.substring(command.indexOf(":"))); return sb; } - ///////////////////////////////// - //JmolStatusListener + // /////////////////////////////// + // JmolStatusListener public String eval(String strEval) { - // System.out.println(strEval); - //"# 'eval' is implemented only for the applet."; + // System.out.println(strEval); + // "# 'eval' is implemented only for the applet."; return null; } public void createImage(String file, String type, int quality) - {} + { + } public void setCallbackFunction(String callbackType, - String callbackFunction) - {} + String callbackFunction) + { + } public void notifyFileLoaded(String fullPathName, String fileName, - String modelName, Object clientFile, - String errorMsg) + String modelName, Object clientFile, String errorMsg) { - if(errorMsg!=null) + if (errorMsg != null) { fileLoadingError = errorMsg; repaint(); @@ -641,26 +727,28 @@ public class AppletJmol extends EmbmenuFrame if (fileName != null) { - //FILE LOADED OK + // FILE LOADED OK jmolpopup.updateComputedMenus(); - viewer.evalStringQuiet( - "select backbone;restrict;cartoon;wireframe off;spacefill off"); + viewer + .evalStringQuiet("select backbone;restrict;cartoon;wireframe off;spacefill off"); ssm = StructureSelectionManager.getStructureSelectionManager(); - MCview.PDBfile pdb; if (loadedInline) { - pdb = ssm.setMapping(sequence,chains, - pdbentry.getFile(), - AppletFormatAdapter.PASTE); - pdbentry.setFile("INLINE"+pdb.id); + pdb = ssm.setMapping(sequence, chains, pdbentry.getFile(), + AppletFormatAdapter.PASTE); + pdbentry.setFile("INLINE" + pdb.id); } else { - pdb = ssm.setMapping(sequence,chains, - pdbentry.getFile(), - AppletFormatAdapter.URL); + // TODO: Jmol can in principle retrieve from CLASSLOADER but this needs + // to be tested. See mantis bug + // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605 + + pdb = ssm.setMapping(sequence, chains, pdbentry.getFile(), + AppletFormatAdapter.URL); + } pdbentry.setId(pdb.id); @@ -670,14 +758,14 @@ public class AppletJmol extends EmbmenuFrame Vector chains = new Vector(); for (int i = 0; i < pdb.chains.size(); i++) { - chains.addElement( ( (MCview.PDBChain) pdb.chains.elementAt(i)).id); + chains.addElement(((MCview.PDBChain) pdb.chains.elementAt(i)).id); } setChainMenuItems(chains); colourBySequence(ap); - StringBuffer title = new StringBuffer(sequence[0].getName() + ":" + - pdbentry.getId()); + StringBuffer title = new StringBuffer(sequence[0].getName() + ":" + + pdbentry.getId()); if (pdbentry.getProperty() != null) { @@ -706,27 +794,29 @@ public class AppletJmol extends EmbmenuFrame } public void notifyScriptStart(String statusMessage, String additionalInfo) - {} + { + } public void sendConsoleEcho(String strEcho) { if (scriptWindow == null) showConsole(true); - history.append("\n"+strEcho); + history.append("\n" + strEcho); } public void sendConsoleMessage(String strStatus) { - if(history!=null && strStatus!=null - && !strStatus.equals("Script completed")) + if (history != null && strStatus != null + && !strStatus.equals("Script completed")) { - history.append("\n"+strStatus); + history.append("\n" + strStatus); } } public void notifyScriptTermination(String strStatus, int msWalltime) - { } + { + } public void handlePopupMenu(int x, int y) { @@ -739,34 +829,34 @@ public class AppletJmol extends EmbmenuFrame } public void notifyNewDefaultModeMeasurement(int count, String strInfo) - {} + { + } public void notifyAtomPicked(int atomIndex, String strInfo) { int chainSeparator = strInfo.indexOf(":"); - if(chainSeparator==-1) + if (chainSeparator == -1) chainSeparator = strInfo.indexOf("."); - String picked = - strInfo.substring(strInfo.indexOf("]")+ 1, chainSeparator); - + String picked = strInfo.substring(strInfo.indexOf("]") + 1, + chainSeparator); if (strInfo.indexOf(":") > -1) - picked+=strInfo.substring(strInfo.indexOf(":")+1, - strInfo.indexOf(".")); + picked += strInfo.substring(strInfo.indexOf(":") + 1, strInfo + .indexOf(".")); - picked+=".CA"; + picked += ".CA"; if (!atomsPicked.contains(picked)) { - viewer.evalString("select "+picked+";label %n %r:%c"); + viewer.evalString("select " + picked + ";label %n %r:%c"); atomsPicked.addElement(picked); } else { - viewer.evalString("select "+picked+";label off"); + viewer.evalString("select " + picked + ";label off"); atomsPicked.removeElement(picked); } } @@ -777,15 +867,18 @@ public class AppletJmol extends EmbmenuFrame } public void sendSyncScript(String script, String appletName) - {} + { + } public void showUrl(String url) { - try{ + try + { ap.av.applet.getAppletContext().showDocument(new java.net.URL(url), - "jmolOutput"); - }catch(java.net.MalformedURLException ex) - {} + "jmolOutput"); + } catch (java.net.MalformedURLException ex) + { + } } public void showConsole(boolean showConsole) @@ -812,19 +905,20 @@ public class AppletJmol extends EmbmenuFrame return 0; } - ///End JmolStatusListener - /////////////////////////////// - + // /End JmolStatusListener + // ///////////////////////////// - class RenderPanel - extends Panel + class RenderPanel extends Panel { Dimension currentSize = new Dimension(); + Rectangle rectClip = new Rectangle(); - public void update(Graphics g) { + public void update(Graphics g) + { paint(g); } + public void paint(Graphics g) { currentSize = this.getSize(); diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index 78d7ba7..6f5498d 100755 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -1,279 +1,278 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; -import jalview.io.*; - -public class CutAndPasteTransfer - extends Panel implements ActionListener, MouseListener -{ - boolean pdbImport = false; - boolean treeImport = false; - boolean annotationImport = false; - Sequence seq; - AlignFrame alignFrame; - - public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame) - { - try - { - jbInit(); - } - catch (Exception e) - { - e.printStackTrace(); - } - - this.alignFrame = alignFrame; - - if (!forImport) - { - buttonPanel.setVisible(false); - } - } - - public String getText() - { - return textarea.getText(); - } - - public void setText(String text) - { - textarea.setText(text); - } - - public void setPDBImport(Sequence seq) - { - this.seq = seq; - accept.setLabel("Accept"); - addSequences.setVisible(false); - pdbImport = true; - } - - public void setTreeImport() - { - treeImport = true; - accept.setLabel("Accept"); - addSequences.setVisible(false); - } - - public void setAnnotationImport() - { - annotationImport = true; - accept.setLabel("Accept"); - addSequences.setVisible(false); - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == accept) - { - ok(true); - } - else if (evt.getSource() == addSequences) - { - ok(false); - } - else if (evt.getSource() == cancel) - { - cancel(); - } - } - - protected void ok(boolean newWindow) - { - String text = getText(); - int length = text.length(); - textarea.append("\n"); - if (textarea.getText().length() == length) - { - String warning = - "\n\n#################################################\n" - + "WARNING!! 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"; - textarea.setText(text.substring(0, text.length() - warning.length()) - + warning); - - textarea.setCaretPosition(text.length()); - } - - if (pdbImport) - { - PDBEntry pdb = new PDBEntry(); - pdb.setFile(text); - - if ( alignFrame.alignPanel.av.applet.jmolAvailable ) - new jalview.appletgui.AppletJmol(pdb, - new Sequence[]{seq}, - null, - alignFrame.alignPanel, - AppletFormatAdapter.PASTE); - else - - new MCview.AppletPDBViewer(pdb, - new Sequence[]{seq}, - null, - alignFrame.alignPanel, - AppletFormatAdapter.PASTE); - - } - else if (treeImport) - { - try - { - jalview.io.NewickFile fin = new jalview.io.NewickFile(textarea.getText(), - "Paste"); - - fin.parse(); - if (fin.getTree() != null) - { - alignFrame.loadTree(fin, "Pasted tree file"); - } - - } - catch (Exception ex) - { - textarea.setText("Could not parse Newick file!\n" + ex); - return; - } - } - else if (annotationImport) - { - if (new AnnotationFile().readAnnotationFile( - alignFrame.viewport.alignment, textarea.getText(), - jalview.io.AppletFormatAdapter.PASTE)) - { - alignFrame.alignPanel.fontChanged(); - alignFrame.alignPanel.setScrollValues(0, 0); - - } - else - { - alignFrame.parseFeaturesFile(textarea.getText(), - jalview.io.AppletFormatAdapter.PASTE); - } - } - else if (alignFrame != null) - { - Alignment al = null; - - String format = new IdentifyFile().Identify(text, - AppletFormatAdapter.PASTE); - try - { - al = new AppletFormatAdapter().readFile(text, AppletFormatAdapter.PASTE, - format); - } - catch (java.io.IOException ex) - { - ex.printStackTrace(); - } - - if (al != null) - { - if (newWindow) - { - AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet, - "Cut & Paste input - " + format, - false); - af.statusBar.setText("Successfully pasted alignment file"); - } - else - { - alignFrame.addSequences(al.getSequencesArray()); - } - } - } - - if (this.getParent() instanceof Frame) - { - ( (Frame)this.getParent()).setVisible(false); - } - else - { - ( (Dialog)this.getParent()).setVisible(false); - } - } - - protected void cancel() - { - textarea.setText(""); - if (this.getParent() instanceof Frame) - { - ( (Frame)this.getParent()).setVisible(false); - } - else - { - ( (Dialog)this.getParent()).setVisible(false); - } - } - - protected TextArea textarea = new TextArea(); - Button accept = new Button("New Window"); - Button addSequences = new Button("Add to Current Alignment"); - Button cancel = new Button("Close"); - - protected Panel buttonPanel = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); - - private void jbInit() - throws Exception - { - textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 10)); - textarea.setText("Paste your alignment file here"); - textarea.addMouseListener(this); - this.setLayout(borderLayout1); - accept.addActionListener(this); - addSequences.addActionListener(this); - cancel.addActionListener(this); - this.add(buttonPanel, BorderLayout.SOUTH); - buttonPanel.add(accept, null); - buttonPanel.add(addSequences); - buttonPanel.add(cancel, null); - this.add(textarea, java.awt.BorderLayout.CENTER); - } - - public void mousePressed(MouseEvent evt) - { - if (textarea.getText().startsWith("Paste your")) - { - textarea.setText(""); - } - } - - public void mouseReleased(MouseEvent evt) - {} - - public void mouseClicked(MouseEvent evt) - {} - - public void mouseEntered(MouseEvent evt) - {} - - public void mouseExited(MouseEvent evt) - {} -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; +import java.awt.event.*; + +import jalview.datamodel.*; +import jalview.io.*; + +public class CutAndPasteTransfer extends Panel implements ActionListener, + MouseListener +{ + boolean pdbImport = false; + + boolean treeImport = false; + + boolean annotationImport = false; + + Sequence seq; + + AlignFrame alignFrame; + + public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame) + { + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + + this.alignFrame = alignFrame; + + if (!forImport) + { + buttonPanel.setVisible(false); + } + } + + public String getText() + { + return textarea.getText(); + } + + public void setText(String text) + { + textarea.setText(text); + } + + public void setPDBImport(Sequence seq) + { + this.seq = seq; + accept.setLabel("Accept"); + addSequences.setVisible(false); + pdbImport = true; + } + + public void setTreeImport() + { + treeImport = true; + accept.setLabel("Accept"); + addSequences.setVisible(false); + } + + public void setAnnotationImport() + { + annotationImport = true; + accept.setLabel("Accept"); + addSequences.setVisible(false); + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == accept) + { + ok(true); + } + else if (evt.getSource() == addSequences) + { + ok(false); + } + else if (evt.getSource() == cancel) + { + cancel(); + } + } + + protected void ok(boolean newWindow) + { + String text = getText(); + int length = text.length(); + textarea.append("\n"); + if (textarea.getText().length() == length) + { + String warning = "\n\n#################################################\n" + + "WARNING!! 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"; + textarea.setText(text.substring(0, text.length() - warning.length()) + + warning); + + textarea.setCaretPosition(text.length()); + } + + if (pdbImport) + { + PDBEntry pdb = new PDBEntry(); + pdb.setFile(text); + + if (alignFrame.alignPanel.av.applet.jmolAvailable) + new jalview.appletgui.AppletJmol(pdb, new Sequence[] + { seq }, null, alignFrame.alignPanel, AppletFormatAdapter.PASTE); + else + + new MCview.AppletPDBViewer(pdb, new Sequence[] + { seq }, null, alignFrame.alignPanel, AppletFormatAdapter.PASTE); + + } + else if (treeImport) + { + try + { + jalview.io.NewickFile fin = new jalview.io.NewickFile(textarea + .getText(), "Paste"); + + fin.parse(); + if (fin.getTree() != null) + { + alignFrame.loadTree(fin, "Pasted tree file"); + } + + } catch (Exception ex) + { + textarea.setText("Could not parse Newick file!\n" + ex); + return; + } + } + else if (annotationImport) + { + if (new AnnotationFile().readAnnotationFile( + alignFrame.viewport.alignment, textarea.getText(), + jalview.io.AppletFormatAdapter.PASTE)) + { + alignFrame.alignPanel.fontChanged(); + alignFrame.alignPanel.setScrollValues(0, 0); + + } + else + { + alignFrame.parseFeaturesFile(textarea.getText(), + jalview.io.AppletFormatAdapter.PASTE); + } + } + else if (alignFrame != null) + { + Alignment al = null; + + String format = new IdentifyFile().Identify(text, + AppletFormatAdapter.PASTE); + try + { + al = new AppletFormatAdapter().readFile(text, + AppletFormatAdapter.PASTE, format); + } catch (java.io.IOException ex) + { + ex.printStackTrace(); + } + + if (al != null) + { + if (newWindow) + { + AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet, + "Cut & Paste input - " + format, false); + af.statusBar.setText("Successfully pasted alignment file"); + } + else + { + alignFrame.addSequences(al.getSequencesArray()); + } + } + } + + if (this.getParent() instanceof Frame) + { + ((Frame) this.getParent()).setVisible(false); + } + else + { + ((Dialog) this.getParent()).setVisible(false); + } + } + + protected void cancel() + { + textarea.setText(""); + if (this.getParent() instanceof Frame) + { + ((Frame) this.getParent()).setVisible(false); + } + else + { + ((Dialog) this.getParent()).setVisible(false); + } + } + + protected TextArea textarea = new TextArea(); + + Button accept = new Button("New Window"); + + Button addSequences = new Button("Add to Current Alignment"); + + Button cancel = new Button("Close"); + + protected Panel buttonPanel = new Panel(); + + BorderLayout borderLayout1 = new BorderLayout(); + + private void jbInit() throws Exception + { + textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 10)); + textarea.setText("Paste your alignment file here"); + textarea.addMouseListener(this); + this.setLayout(borderLayout1); + accept.addActionListener(this); + addSequences.addActionListener(this); + cancel.addActionListener(this); + this.add(buttonPanel, BorderLayout.SOUTH); + buttonPanel.add(accept, null); + buttonPanel.add(addSequences); + buttonPanel.add(cancel, null); + this.add(textarea, java.awt.BorderLayout.CENTER); + } + + public void mousePressed(MouseEvent evt) + { + if (textarea.getText().startsWith("Paste your")) + { + textarea.setText(""); + } + } + + public void mouseReleased(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } +} diff --git a/src/jalview/appletgui/EditNameDialog.java b/src/jalview/appletgui/EditNameDialog.java index 46325d9..b1cd40e 100644 --- a/src/jalview/appletgui/EditNameDialog.java +++ b/src/jalview/appletgui/EditNameDialog.java @@ -1,84 +1,77 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; - - -public class EditNameDialog extends JVDialog -{ - TextField id, description; - - public String getName() - { - return id.getText(); - } - - public String getDescription() - { - if (description.getText().length() < 1) - { - return null; - } - else - { - return description.getText(); - } - } - - public EditNameDialog(String name, - String desc, - String label1, - String label2, - Frame owner, - String title, - int width, int height, boolean display) - { - super(owner, title, true, width, height); - - Font mono = new Font("Monospaced", Font.PLAIN, 12); - Panel panel = new Panel(new BorderLayout()); - Panel panel2 = new Panel(new BorderLayout()); - - id = new TextField(name, 40); - id.setFont(mono); - Label label = new Label(label1); - label.setFont(mono); - - panel2.add(label, BorderLayout.WEST); - panel2.add(id, BorderLayout.CENTER); - panel.add(panel2, BorderLayout.NORTH); - - - if(label2!=null) - { - panel2 = new Panel(new BorderLayout()); - description = new TextField(desc, 40); - description.setFont(mono); - label = new Label(label2); - label.setFont(mono); - panel2.add(label, BorderLayout.WEST); - panel2.add(description, BorderLayout.CENTER); - panel.add(panel2, BorderLayout.CENTER); - } - setMainPanel(panel); - setVisible(display); - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; + +public class EditNameDialog extends JVDialog +{ + TextField id, description; + + public String getName() + { + return id.getText(); + } + + public String getDescription() + { + if (description.getText().length() < 1) + { + return null; + } + else + { + return description.getText(); + } + } + + public EditNameDialog(String name, String desc, String label1, + String label2, Frame owner, String title, int width, int height, + boolean display) + { + super(owner, title, true, width, height); + + Font mono = new Font("Monospaced", Font.PLAIN, 12); + Panel panel = new Panel(new BorderLayout()); + Panel panel2 = new Panel(new BorderLayout()); + + id = new TextField(name, 40); + id.setFont(mono); + Label label = new Label(label1); + label.setFont(mono); + + panel2.add(label, BorderLayout.WEST); + panel2.add(id, BorderLayout.CENTER); + panel.add(panel2, BorderLayout.NORTH); + + if (label2 != null) + { + panel2 = new Panel(new BorderLayout()); + description = new TextField(desc, 40); + description.setFont(mono); + label = new Label(label2); + label.setFont(mono); + panel2.add(label, BorderLayout.WEST); + panel2.add(description, BorderLayout.CENTER); + panel.add(panel2, BorderLayout.CENTER); + } + setMainPanel(panel); + setVisible(display); + } +} diff --git a/src/jalview/appletgui/EmbmenuFrame.java b/src/jalview/appletgui/EmbmenuFrame.java index 23f6aa2..df59ef4 100644 --- a/src/jalview/appletgui/EmbmenuFrame.java +++ b/src/jalview/appletgui/EmbmenuFrame.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.appletgui; import java.awt.BorderLayout; @@ -19,18 +37,19 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Enumeration; import java.util.Hashtable; + /** - * This class implements a pattern form embedding toolbars as a panel with popups - * for situations where the system menu bar is either invisible or inappropriate. - * It was derived from the code for embedding the jalview applet alignFrame as - * a component on the web-page, which requires the local alignFrame menu to be - * attached to that panel rather than placed on the parent (which isn't allowed - * anyhow). - * TODO: try to modify the embeddedMenu display so it looks like a real toolbar menu - * TODO: modify click/mouse handler for embeddedMenu so it behaves more like a real pulldown menu toolbar + * This class implements a pattern form embedding toolbars as a panel with + * popups for situations where the system menu bar is either invisible or + * inappropriate. It was derived from the code for embedding the jalview applet + * alignFrame as a component on the web-page, which requires the local + * alignFrame menu to be attached to that panel rather than placed on the parent + * (which isn't allowed anyhow). TODO: try to modify the embeddedMenu display so + * it looks like a real toolbar menu TODO: modify click/mouse handler for + * embeddedMenu so it behaves more like a real pulldown menu toolbar * * @author Jim Procter and Andrew Waterhouse - * + * */ public class EmbmenuFrame extends Frame implements MouseListener { @@ -38,9 +57,10 @@ public class EmbmenuFrame extends Frame implements MouseListener * map from labels to popup menus for the embedded menubar */ protected Hashtable embeddedPopup; + /** - * the embedded menu is built on this and should be - * added to the frame at the appropriate position. + * the embedded menu is built on this and should be added to the frame at the + * appropriate position. * */ protected Panel embeddedMenu; @@ -49,20 +69,25 @@ public class EmbmenuFrame extends Frame implements MouseListener { super(); } + public EmbmenuFrame(String title) throws HeadlessException { super(title); } + /** - * Check if the applet is running on a platform that requires the Frame menuBar to be embedded, - * and if so, embeds it. - * @param tobeAdjusted the panel that is to be reduced to make space for the embedded menu bar + * Check if the applet is running on a platform that requires the Frame + * menuBar to be embedded, and if so, embeds it. + * + * @param tobeAdjusted + * the panel that is to be reduced to make space for the + * embedded menu bar * @return true if menuBar was embedded and tobeAdjusted's height modified */ protected boolean embedMenuIfNeeded(Panel tobeAdjusted) { MenuBar topMenuBar = getMenuBar(); - if (topMenuBar==null) + if (topMenuBar == null) { return false; } @@ -70,43 +95,53 @@ public class EmbmenuFrame extends Frame implements MouseListener if (new jalview.util.Platform().isAMac()) { // Build the embedded menu panel - embeddedMenu = makeEmbeddedPopupMenu(topMenuBar, "Arial", Font.PLAIN, 10, true); // try to pickup system font. + embeddedMenu = makeEmbeddedPopupMenu(topMenuBar, "Arial", Font.PLAIN, + 10, true); // try to pickup system font. setMenuBar(null); // add the components to the TreePanel area. add(embeddedMenu, BorderLayout.NORTH); - tobeAdjusted.setSize(getSize().width, - getSize().height - - embeddedMenu.HEIGHT); + tobeAdjusted.setSize(getSize().width, getSize().height + - embeddedMenu.HEIGHT); return true; } return false; } + /** - * move all menus on menuBar onto embeddedMenu. - * embeddedPopup is used to store the popups for each menu removed from the menuBar and added - * to the panel. - * NOTE: it is up to the caller to remove menuBar from the Frame if it is already attached. + * move all menus on menuBar onto embeddedMenu. embeddedPopup is used to store + * the popups for each menu removed from the menuBar and added to the panel. + * NOTE: it is up to the caller to remove menuBar from the Frame if it is + * already attached. + * * @param menuBar * @param fn * @param fstyle * @param fsz - * @param overrideFonts true if we take the menuBar fonts in preference to the supplied defaults + * @param overrideFonts + * true if we take the menuBar fonts in preference to the + * supplied defaults * @return the embedded menu instance to be added to the frame. */ protected Panel makeEmbeddedPopupMenu(MenuBar menuBar, String fn, int fstyle, int fsz, boolean overrideFonts) { - return makeEmbeddedPopupMenu(menuBar, fn, fstyle, fsz, overrideFonts, false); + return makeEmbeddedPopupMenu(menuBar, fn, fstyle, fsz, overrideFonts, + false); } + /** - * Create or add elements to the embedded menu from menuBar. This removes all menu from - * menuBar and it is up to the caller to remove the now useless menuBar from the Frame if it is already attached. + * Create or add elements to the embedded menu from menuBar. This removes all + * menu from menuBar and it is up to the caller to remove the now useless + * menuBar from the Frame if it is already attached. + * * @param menuBar * @param fn * @param fstyle * @param fsz - * @param overrideFonts - * @param append true means existing menu will be emptied before adding new elements + * @param overrideFonts + * @param append + * true means existing menu will be emptied before adding new + * elements * @return */ protected Panel makeEmbeddedPopupMenu(MenuBar menuBar, String fn, @@ -117,59 +152,71 @@ public class EmbmenuFrame extends Frame implements MouseListener if (embeddedPopup != null) { embeddedPopup.clear(); // TODO: check if j1.1 - } - if (embeddedMenu!=null) + } + if (embeddedMenu != null) { - embeddedMenu.removeAll(); + embeddedMenu.removeAll(); } } - if (embeddedPopup==null) + if (embeddedPopup == null) { embeddedPopup = new Hashtable(); } - - embeddedMenu = makeEmbeddedPopupMenu(menuBar, fn, fstyle, fsz, overrideFonts, embeddedPopup, new Panel(), this); + + embeddedMenu = makeEmbeddedPopupMenu(menuBar, fn, fstyle, fsz, + overrideFonts, embeddedPopup, new Panel(), this); return embeddedMenu; } + /** - * Generic method to move elements from menubar onto embeddedMenu using the existing or the supplied font, - * and adds binding from panel to attached menus in embeddedPopup - * This removes all menu from - * menuBar and it is up to the caller to remove the now useless menuBar from the Frame if it is already attached. - * @param menuBar must be non-null + * Generic method to move elements from menubar onto embeddedMenu using the + * existing or the supplied font, and adds binding from panel to attached + * menus in embeddedPopup This removes all menu from menuBar and it is up to + * the caller to remove the now useless menuBar from the Frame if it is + * already attached. + * + * @param menuBar + * must be non-null * @param fn * @param fstyle * @param fsz * @param overrideFonts - * @param embeddedPopup must be non-null - * @param embeddedMenu if null, a new panel will be created and returned - * @param clickHandler - usually the instance of EmbmenuFrame that holds references to embeddedPopup and embeddedMenu + * @param embeddedPopup + * must be non-null + * @param embeddedMenu + * if null, a new panel will be created and returned + * @param clickHandler - + * usually the instance of EmbmenuFrame that holds references + * to embeddedPopup and embeddedMenu * @return the panel instance for convenience. */ protected Panel makeEmbeddedPopupMenu(MenuBar menuBar, String fn, - int fstyle, int fsz, boolean overrideFonts, Hashtable embeddedPopup, Panel embeddedMenu, MouseListener clickHandler) + int fstyle, int fsz, boolean overrideFonts, + Hashtable embeddedPopup, Panel embeddedMenu, + MouseListener clickHandler) { - if (embeddedPopup==null) + if (embeddedPopup == null) { - throw new Error("Implementation error - embeddedPopup must be non-null"); + throw new Error( + "Implementation error - embeddedPopup must be non-null"); } if (overrideFonts) { Font mbf = menuBar.getFont(); - if (mbf!=null) + if (mbf != null) { fn = mbf.getName(); fstyle = mbf.getStyle(); fsz = mbf.getSize(); } } - if (embeddedMenu==null) + if (embeddedMenu == null) embeddedMenu = new Panel(); FlowLayout flowLayout1 = new FlowLayout(); embeddedMenu.setBackground(Color.lightGray); embeddedMenu.setLayout(flowLayout1); // loop thru - for (int mbi = 0,nMbi=menuBar.getMenuCount(); mbi1) + // ///////////////////////////////////// + // /MULTIPLE FEATURES AT SELECTED RESIDUE + if (!newFeatures && features.length > 1) { - panel = new Panel(new GridLayout(4, 1)); - tmp = new Panel(); - tmp.add(new Label("Select Feature: ")); - overlaps = new Choice(); - for(int i=0; i0) + if (dialog.accept && name.getText().length() > 0) { for (int i = 0; i < sequences.length; i++) { @@ -366,17 +359,17 @@ public class FeatureRenderer col = colourPanel.getBackground(); setColour(lastFeatureAdded, col); - if(lastFeatureGroupAdded!=null) + if (lastFeatureGroupAdded != null) { featureGroups.put(lastFeatureGroupAdded, new Boolean(true)); - av.featuresDisplayed.put(lastFeatureGroupAdded, - new Integer(col.getRGB())); + av.featuresDisplayed.put(lastFeatureGroupAdded, new Integer(col + .getRGB())); } findAllFeatures(); - String [] tro = new String[renderOrder.length]; - tro[0] = renderOrder[renderOrder.length-1]; - System.arraycopy(renderOrder,0,tro,1,renderOrder.length-1); + String[] tro = new String[renderOrder.length]; + tro[0] = renderOrder[renderOrder.length - 1]; + System.arraycopy(renderOrder, 0, tro, 1, renderOrder.length - 1); renderOrder = tro; ap.paintAlignment(true); @@ -396,7 +389,6 @@ public class FeatureRenderer return true; } - public Color findFeatureColour(Color initialCol, SequenceI seq, int i) { overview = true; @@ -428,41 +420,50 @@ public class FeatureRenderer return initialCol; } - return new Color( ( (Integer) currentColour).intValue()); + return new Color(((Integer) currentColour).intValue()); } /** - * This is used by the Molecule Viewer to get the accurate colour - * of the rendered sequence + * This is used by the Molecule Viewer to get the accurate colour of the + * rendered sequence */ boolean overview = false; - /** * DOCUMENT ME! - * - * @param g DOCUMENT ME! - * @param seq DOCUMENT ME! - * @param sg DOCUMENT ME! - * @param start DOCUMENT ME! - * @param end DOCUMENT ME! - * @param x1 DOCUMENT ME! - * @param y1 DOCUMENT ME! - * @param width DOCUMENT ME! - * @param height DOCUMENT ME! + * + * @param g + * DOCUMENT ME! + * @param seq + * DOCUMENT ME! + * @param sg + * DOCUMENT ME! + * @param start + * DOCUMENT ME! + * @param end + * DOCUMENT ME! + * @param x1 + * DOCUMENT ME! + * @param y1 + * DOCUMENT ME! + * @param width + * DOCUMENT ME! + * @param height + * DOCUMENT ME! */ // String type; // SequenceFeature sf; - SequenceI lastSeq; + SequenceFeature[] sequenceFeatures; + int sfSize, sfindex, spos, epos; synchronized public void drawSequence(Graphics g, SequenceI seq, - int start, int end, int y1) + int start, int end, int y1) { if (seq.getSequenceFeatures() == null - || seq.getSequenceFeatures().length == 0) + || seq.getSequenceFeatures().length == 0) { return; } @@ -472,7 +473,8 @@ public class FeatureRenderer transparencySetter.setTransparency(g, transparency); } - if (lastSeq == null || seq != lastSeq || sequenceFeatures!=seq.getSequenceFeatures()) + if (lastSeq == null || seq != lastSeq + || sequenceFeatures != seq.getSequenceFeatures()) { lastSeq = seq; sequenceFeatures = seq.getSequenceFeatures(); @@ -518,57 +520,60 @@ public class FeatureRenderer } if (featureGroups != null - && sequenceFeatures[sfindex].featureGroup != null - && - featureGroups.containsKey(sequenceFeatures[sfindex].featureGroup) - && - ! ( (Boolean) featureGroups.get(sequenceFeatures[sfindex]. - featureGroup)). - booleanValue()) + && sequenceFeatures[sfindex].featureGroup != null + && featureGroups + .containsKey(sequenceFeatures[sfindex].featureGroup) + && !((Boolean) featureGroups + .get(sequenceFeatures[sfindex].featureGroup)) + .booleanValue()) { continue; } - if (!overview && (sequenceFeatures[sfindex].getBegin() > epos - || sequenceFeatures[sfindex].getEnd() < spos)) + if (!overview + && (sequenceFeatures[sfindex].getBegin() > epos || sequenceFeatures[sfindex] + .getEnd() < spos)) { continue; } if (overview) { - if (sequenceFeatures[sfindex].begin <= start && - sequenceFeatures[sfindex].end >= start) + if (sequenceFeatures[sfindex].begin <= start + && sequenceFeatures[sfindex].end >= start) { - currentColour = av.featuresDisplayed.get(sequenceFeatures[sfindex]. - type); + currentColour = av.featuresDisplayed + .get(sequenceFeatures[sfindex].type); } } else if (sequenceFeatures[sfindex].type.equals("disulfide bond")) { - renderFeature(g, seq, - seq.findIndex(sequenceFeatures[sfindex].begin) - 1, - seq.findIndex(sequenceFeatures[sfindex].begin) - 1, - new Color( ( (Integer) av.featuresDisplayed.get( - sequenceFeatures[sfindex].type)).intValue()), - start, end, y1); - renderFeature(g, seq, - seq.findIndex(sequenceFeatures[sfindex].end) - 1, - seq.findIndex(sequenceFeatures[sfindex].end) - 1, - new Color( ( (Integer) av.featuresDisplayed.get( - sequenceFeatures[sfindex].type)).intValue()), - start, end, y1); + renderFeature( + g, + seq, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, + seq.findIndex(sequenceFeatures[sfindex].begin) - 1, + new Color(((Integer) av.featuresDisplayed + .get(sequenceFeatures[sfindex].type)).intValue()), + start, end, y1); + renderFeature( + g, + seq, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, + seq.findIndex(sequenceFeatures[sfindex].end) - 1, + new Color(((Integer) av.featuresDisplayed + .get(sequenceFeatures[sfindex].type)).intValue()), + start, end, y1); } else { - renderFeature(g, seq, - seq.findIndex(sequenceFeatures[sfindex].begin) - 1, - seq.findIndex(sequenceFeatures[sfindex].end) - 1, - getColour(sequenceFeatures[sfindex].type), - start, end, y1); + renderFeature(g, seq, seq + .findIndex(sequenceFeatures[sfindex].begin) - 1, seq + .findIndex(sequenceFeatures[sfindex].end) - 1, + getColour(sequenceFeatures[sfindex].type), start, end, y1); } } @@ -581,13 +586,14 @@ public class FeatureRenderer } char s; + int i; - void renderFeature(Graphics g, SequenceI seq, - int fstart, int fend, Color featureColour, int start, - int end, int y1) + + void renderFeature(Graphics g, SequenceI seq, int fstart, int fend, + Color featureColour, int start, int end, int y1) { - if ( ( (fstart <= end) && (fend >= start))) + if (((fstart <= end) && (fend >= start))) { if (fstart < start) { // fix for if the feature we have starts before the sequence start, @@ -610,7 +616,8 @@ public class FeatureRenderer g.setColor(featureColour); - g.fillRect( (i - start) * av.charWidth, y1, av.charWidth, av.charHeight); + g.fillRect((i - start) * av.charWidth, y1, av.charWidth, + av.charHeight); if (!av.validCharWidth) { @@ -619,9 +626,9 @@ public class FeatureRenderer g.setColor(Color.white); charOffset = (av.charWidth - fm.charWidth(s)) / 2; - g.drawString(String.valueOf(s), - charOffset + (av.charWidth * (i - start)), - (y1 + av.charHeight) - av.charHeight / 5); //pady = height / 5; + g.drawString(String.valueOf(s), charOffset + + (av.charWidth * (i - start)), (y1 + av.charHeight) + - av.charHeight / 5); // pady = height / 5; } } @@ -629,15 +636,14 @@ public class FeatureRenderer void findAllFeatures() { - jalview.schemes.UserColourScheme ucs = new - jalview.schemes.UserColourScheme(); + jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(); av.featuresDisplayed = new Hashtable(); Vector allfeatures = new Vector(); for (int i = 0; i < av.alignment.getHeight(); i++) { - SequenceFeature[] features = av.alignment.getSequenceAt(i). - getSequenceFeatures(); + SequenceFeature[] features = av.alignment.getSequenceAt(i) + .getSequenceFeatures(); if (features == null) { @@ -651,14 +657,12 @@ public class FeatureRenderer { if (getColour(features[index].getType()) == null) { - featureColours.put(features[index].getType(), - ucs.createColourFromName(features[index]. - getType())); + featureColours.put(features[index].getType(), ucs + .createColourFromName(features[index].getType())); } - av.featuresDisplayed.put(features[index].getType(), - new Integer(getColour(features[index]. - getType()).getRGB())); + av.featuresDisplayed.put(features[index].getType(), new Integer( + getColour(features[index].getType()).getRGB())); allfeatures.addElement(features[index].getType()); } index++; @@ -679,8 +683,7 @@ public class FeatureRenderer { if (!featureColours.containsKey(featureType)) { - jalview.schemes.UserColourScheme ucs = new - jalview.schemes.UserColourScheme(); + jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(); Color col = ucs.createColourFromName(featureType); featureColours.put(featureType, col); return col; @@ -689,7 +692,6 @@ public class FeatureRenderer return (Color) featureColours.get(featureType); } - public void setColour(String featureType, Color col) { featureColours.put(featureType, col); @@ -705,22 +707,11 @@ public class FeatureRenderer av.featuresDisplayed.clear(); } - /* if (visibleNew) - { - if (av.featuresDisplayed != null) - { - av.featuresDisplayed.clear(); - } - else - { - av.featuresDisplayed = new Hashtable(); - } - } - if (data == null) - { - return; - }*/ - + /* + * if (visibleNew) { if (av.featuresDisplayed != null) { + * av.featuresDisplayed.clear(); } else { av.featuresDisplayed = new + * Hashtable(); } } if (data == null) { return; } + */ renderOrder = new String[data.length]; @@ -730,113 +721,126 @@ public class FeatureRenderer { String type = data[i][0].toString(); setColour(type, (Color) data[i][1]); - if ( ( (Boolean) data[i][2]).booleanValue()) + if (((Boolean) data[i][2]).booleanValue()) { - av.featuresDisplayed.put(type, new Integer(getColour(type).getRGB())); + av.featuresDisplayed.put(type, new Integer(getColour(type) + .getRGB())); } renderOrder[data.length - i - 1] = type; } } } + /** - * @return a simple list of feature group names or null + * @return a simple list of feature group names or null */ public String[] getGroups() { buildGroupHash(); - if (featureGroups!=null) + if (featureGroups != null) { String[] gps = new String[featureGroups.size()]; Enumeration gn = featureGroups.keys(); - int i=0; + int i = 0; while (gn.hasMoreElements()) { - gps[i++] = (String) gn.nextElement(); + gps[i++] = (String) gn.nextElement(); } return gps; } return null; } + /** * get visible or invisible groups - * @param visible true to return visible groups, false to return hidden ones. + * + * @param visible + * true to return visible groups, false to return hidden ones. * @return list of groups */ - public String[] getGroups(boolean visible) + public String[] getGroups(boolean visible) { buildGroupHash(); - if (featureGroups!=null) + if (featureGroups != null) { Vector gp = new Vector(); - + Enumeration gn = featureGroups.keys(); while (gn.hasMoreElements()) { String nm = (String) gn.nextElement(); Boolean state = (Boolean) featureGroups.get(nm); - if (state.booleanValue()==visible) + if (state.booleanValue() == visible) { gp.addElement(nm); } } String[] gps = new String[gp.size()]; gp.copyInto(gps); - - int i=0; + + int i = 0; while (gn.hasMoreElements()) { - gps[i++] = (String) gn.nextElement(); + gps[i++] = (String) gn.nextElement(); } return gps; } return null; } + /** * set all feature groups in toset to be visible or invisible - * @param toset group names - * @param visible the state of the named groups to set + * + * @param toset + * group names + * @param visible + * the state of the named groups to set */ public void setGroupState(String[] toset, boolean visible) { buildGroupHash(); - if (toset!=null && toset.length>0 && featureGroups!=null) + if (toset != null && toset.length > 0 && featureGroups != null) { boolean rdrw = false; - for (int i=0;i0) + if (allFeatures.size() > 0) { String[] neworder = new String[allFeatures.size()]; - int p=neworder.length-1; - for (int i=renderOrder.length-1; i>=0; i--) + int p = neworder.length - 1; + for (int i = renderOrder.length - 1; i >= 0; i--) { if (allFeatures.contains(renderOrder[i])) { neworder[p--] = renderOrder[i]; allFeatures.removeElement(renderOrder[i]); - } else { + } + else + { av.featuresDisplayed.remove(renderOrder[i]); } } - for (int i=allFeatures.size()-1; i>0; i++) + for (int i = allFeatures.size() - 1; i > 0; i++) { Object e = allFeatures.elementAt(i); - if (e!=null) + if (e != null) { neworder[p--] = (String) e; - av.featuresDisplayed.put(e, getColour((String)e)); + av.featuresDisplayed.put(e, getColour((String) e)); } } renderOrder = neworder; return true; } - + return alignmentHasFeatures; } } @@ -967,9 +979,8 @@ class TransparencySetter { void setTransparency(Graphics g, float value) { - Graphics2D g2 = (Graphics2D) g; - g2.setComposite( - AlphaComposite.getInstance( - AlphaComposite.SRC_OVER, value)); + Graphics2D g2 = (Graphics2D) g; + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + value)); } } diff --git a/src/jalview/appletgui/FeatureSettings.java b/src/jalview/appletgui/FeatureSettings.java index 6670d2f..4649786 100755 --- a/src/jalview/appletgui/FeatureSettings.java +++ b/src/jalview/appletgui/FeatureSettings.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -25,19 +25,28 @@ import java.awt.event.*; import jalview.datamodel.*; -public class FeatureSettings - extends Panel implements ItemListener, - MouseListener, MouseMotionListener, ActionListener, AdjustmentListener +public class FeatureSettings extends Panel implements ItemListener, + MouseListener, MouseMotionListener, ActionListener, + AdjustmentListener { FeatureRenderer fr; + AlignmentPanel ap; + AlignViewport av; + Frame frame; + Panel groupPanel; + Panel featurePanel = new Panel(); + ScrollPane scrollPane; + boolean alignmentHasFeatures = false; + Image linkImage; + Scrollbar transparency; public FeatureSettings(final AlignmentPanel ap) @@ -48,7 +57,7 @@ public class FeatureSettings fr = ap.seqPanel.seqCanvas.getFeatureRenderer(); transparency = new Scrollbar(Scrollbar.HORIZONTAL, - 100 - (int) (fr.transparency * 100), 1, 1, 100); + 100 - (int) (fr.transparency * 100), 1, 1, 100); if (fr.transparencySetter != null) { @@ -95,8 +104,9 @@ public class FeatureSettings } else { - tPanel.add(new Label("Transparency not available in this web browser"), - BorderLayout.CENTER); + tPanel.add( + new Label("Transparency not available in this web browser"), + BorderLayout.CENTER); } lowerPanel.add(tPanel, BorderLayout.SOUTH); @@ -105,8 +115,8 @@ public class FeatureSettings if (groupPanel != null) { - groupPanel.setLayout( - new GridLayout(fr.featureGroups.size() / 4 + 1, 4)); + groupPanel.setLayout(new GridLayout(fr.featureGroups.size() / 4 + 1, + 4)); groupPanel.validate(); add(groupPanel, BorderLayout.NORTH); @@ -118,22 +128,21 @@ public class FeatureSettings { public void windowClosing(WindowEvent e) { - if (me.av.featureSettings==me) + if (me.av.featureSettings == me) { me.av.featureSettings = null; me.ap = null; me.av = null; } } - } - ); + }); int height = featurePanel.getComponentCount() * 50 + 60; height = Math.max(200, height); height = Math.min(400, height); int width = 300; jalview.bin.JalviewLite.addFrame(frame, "Feature Settings", width, - height); + height); } public void paint(Graphics g) @@ -150,10 +159,11 @@ public class FeatureSettings if (alignmentHasFeatures) { rebuildGroups(); - + } resetTable(false); } + /** * rebuilds the group panel */ @@ -163,21 +173,21 @@ public class FeatureSettings if (groupPanel == null) { groupPanel = new Panel(); - } else { + } + else + { rdrw = true; groupPanel.removeAll(); } - + Enumeration gps = fr.featureGroups.keys(); while (gps.hasMoreElements()) { String group = (String) gps.nextElement(); Boolean vis = (Boolean) fr.featureGroups.get(group); - Checkbox check = new MyCheckbox( - group, - vis.booleanValue(), - (fr.featureLinks != null && fr.featureLinks.containsKey(group)) - ); + Checkbox check = new MyCheckbox(group, vis.booleanValue(), + (fr.featureLinks != null && fr.featureLinks + .containsKey(group))); check.addMouseListener(this); check.setFont(new Font("Serif", Font.BOLD, 12)); check.addItemListener(this); @@ -189,8 +199,8 @@ public class FeatureSettings } } - //This routine adds and removes checkboxes depending on - //Group selection states + // This routine adds and removes checkboxes depending on + // Group selection states void resetTable(boolean groupsChanged) { SequenceFeature[] tmpfeatures; @@ -210,8 +220,8 @@ public class FeatureSettings { group = tmpfeatures[index].featureGroup; - if (group == null || fr.featureGroups.get(group) == null || - ( (Boolean) fr.featureGroups.get(group)).booleanValue()) + if (group == null || fr.featureGroups.get(group) == null + || ((Boolean) fr.featureGroups.get(group)).booleanValue()) { type = tmpfeatures[index].getType(); if (!visibleChecks.contains(type)) @@ -226,8 +236,8 @@ public class FeatureSettings Component[] comps; int cSize = featurePanel.getComponentCount(); Checkbox check; - //This will remove any checkboxes which shouldn't be - //visible + // This will remove any checkboxes which shouldn't be + // visible for (int i = 0; i < cSize; i++) { comps = featurePanel.getComponents(); @@ -242,8 +252,8 @@ public class FeatureSettings if (fr.renderOrder != null) { - //First add the checks in the previous render order, - //in case the window has been closed and reopened + // First add the checks in the previous render order, + // in case the window has been closed and reopened for (int ro = fr.renderOrder.length - 1; ro > -1; ro--) { String item = fr.renderOrder[ro]; @@ -268,8 +278,8 @@ public class FeatureSettings addCheck(groupsChanged, en.nextElement().toString()); } - featurePanel.setLayout(new GridLayout(featurePanel.getComponentCount(), 1, - 10, 5)); + featurePanel.setLayout(new GridLayout(featurePanel.getComponentCount(), + 1, 10, 5)); featurePanel.validate(); if (scrollPane != null) @@ -279,10 +289,15 @@ public class FeatureSettings itemStateChanged(null); } + /** * update the checklist of feature types with the given type - * @param groupsChanged true means if the type is not in the display list then it will be added and displayed - * @param type feature type to be checked for in the list. + * + * @param groupsChanged + * true means if the type is not in the display list then it + * will be added and displayed + * @param type + * feature type to be checked for in the list. */ void addCheck(boolean groupsChanged, String type) { @@ -308,11 +323,10 @@ public class FeatureSettings selected = true; } - check = new MyCheckbox(type, - selected, - (fr.featureLinks != null && - fr.featureLinks.containsKey(type)) - ); + check = new MyCheckbox( + type, + selected, + (fr.featureLinks != null && fr.featureLinks.containsKey(type))); check.addMouseListener(this); check.addMouseMotionListener(this); @@ -345,11 +359,12 @@ public class FeatureSettings { if (evt != null) { - //Is the source a top level featureGroup? + // Is the source a top level featureGroup? Checkbox source = (Checkbox) evt.getSource(); if (fr.featureGroups.containsKey(source.getLabel())) { - fr.featureGroups.put(source.getLabel(), new Boolean(source.getState())); + fr.featureGroups.put(source.getLabel(), new Boolean(source + .getState())); ap.seqPanel.seqCanvas.repaint(); if (ap.overviewPanel != null) { @@ -388,6 +403,7 @@ public class FeatureSettings } MyCheckbox selectedCheck; + boolean dragging = false; public void mousePressed(MouseEvent evt) @@ -396,8 +412,7 @@ public class FeatureSettings selectedCheck = (MyCheckbox) evt.getSource(); if (fr.featureLinks != null - && fr.featureLinks.containsKey(selectedCheck.getLabel()) - ) + && fr.featureLinks.containsKey(selectedCheck.getLabel())) { if (evt.getX() > selectedCheck.stringWidth + 20) { @@ -409,7 +424,7 @@ public class FeatureSettings public void mouseDragged(MouseEvent evt) { - if ( ( (Component) evt.getSource()).getParent() != featurePanel) + if (((Component) evt.getSource()).getParent() != featurePanel) { return; } @@ -418,7 +433,7 @@ public class FeatureSettings public void mouseReleased(MouseEvent evt) { - if ( ( (Component) evt.getSource()).getParent() != featurePanel) + if (((Component) evt.getSource()).getParent() != featurePanel) { return; } @@ -431,7 +446,8 @@ public class FeatureSettings if (height > featurePanel.getSize().height) { - comp = featurePanel.getComponent(featurePanel.getComponentCount() - 1); + comp = featurePanel + .getComponent(featurePanel.getComponentCount() - 1); } else if (height < 0) { @@ -439,9 +455,8 @@ public class FeatureSettings } else { - comp = featurePanel.getComponentAt(evt.getX(), - evt.getY() + - evt.getComponent().getLocation().y); + comp = featurePanel.getComponentAt(evt.getX(), evt.getY() + + evt.getComponent().getLocation().y); } if (comp != null && comp instanceof Checkbox) @@ -449,9 +464,7 @@ public class FeatureSettings target = (Checkbox) comp; } - if (selectedCheck != null - && target != null - && selectedCheck != target) + if (selectedCheck != null && target != null && selectedCheck != target) { int targetIndex = -1; for (int i = 0; i < featurePanel.getComponentCount(); i++) @@ -479,24 +492,26 @@ public class FeatureSettings } public void mouseEntered(MouseEvent evt) - {} + { + } public void mouseExited(MouseEvent evt) - {} + { + } public void mouseClicked(MouseEvent evt) { MyCheckbox check = (MyCheckbox) evt.getSource(); if (fr.featureLinks != null - && fr.featureLinks.containsKey(check.getLabel())) + && fr.featureLinks.containsKey(check.getLabel())) { if (evt.getX() > check.stringWidth + 20) { evt.consume(); String link = fr.featureLinks.get(check.getLabel()).toString(); - ap.alignFrame.showURL(link.substring(link.indexOf("|") + 1), - link.substring(0, link.indexOf("|"))); + ap.alignFrame.showURL(link.substring(link.indexOf("|") + 1), link + .substring(0, link.indexOf("|"))); } } @@ -507,26 +522,28 @@ public class FeatureSettings if (evt.getClickCount() > 1) { - new UserDefinedColours(this, check.getLabel(), - fr.getColour(check.getLabel())); + new UserDefinedColours(this, check.getLabel(), fr.getColour(check + .getLabel())); } } public void mouseMoved(MouseEvent evt) - {} + { + } public void adjustmentValueChanged(AdjustmentEvent evt) { - fr.transparency = ( (float) (100 - transparency.getValue()) / 100f); + fr.transparency = ((float) (100 - transparency.getValue()) / 100f); ap.seqPanel.seqCanvas.repaint(); } - class MyCheckbox - extends Checkbox + class MyCheckbox extends Checkbox { public int stringWidth; + boolean hasLink; + public MyCheckbox(String label, boolean checked, boolean haslink) { super(label, checked); @@ -540,9 +557,8 @@ public class FeatureSettings { if (hasLink) { - g.drawImage(linkImage, stringWidth + 25, ( - getSize().height - linkImage.getHeight(this)) / 2, - this); + g.drawImage(linkImage, stringWidth + 25, + (getSize().height - linkImage.getHeight(this)) / 2, this); } } } diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index 9e974e9..6d205b6 100755 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -26,25 +25,27 @@ import java.awt.event.*; import jalview.datamodel.*; -public class Finder - extends Panel implements ActionListener +public class Finder extends Panel implements ActionListener { AlignViewport av; + AlignmentPanel ap; + Frame frame; SearchResults searchResults; int seqIndex = 0; + int resIndex = 0; + public Finder(final AlignmentPanel ap) { try { jbInit(); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } @@ -92,21 +93,20 @@ public class Finder public void createNewGroup_actionPerformed() { SequenceI[] seqs = new SequenceI[searchResults.getSize()]; - SequenceFeature[] features = new SequenceFeature[searchResults.getSize()]; + SequenceFeature[] features = new SequenceFeature[searchResults + .getSize()]; for (int i = 0; i < searchResults.getSize(); i++) { seqs[i] = searchResults.getResultSequence(i); features[i] = new SequenceFeature(textfield.getText().trim(), - "Search Results", null, - searchResults.getResultStart(i), - searchResults.getResultEnd(i), - "Search Results"); + "Search Results", null, searchResults.getResultStart(i), + searchResults.getResultEnd(i), "Search Results"); } - if (ap.seqPanel.seqCanvas.getFeatureRenderer() - .amendFeatures(seqs, features, true, ap)) + if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs, + features, true, ap)) { ap.alignFrame.sequenceFeatures.setState(true); av.showSequenceFeatures(true); @@ -122,8 +122,8 @@ public class Finder av = ap.av; } createNewGroup.setEnabled(false); - jalview.analysis.Finder finder = new jalview.analysis.Finder(av. - getAlignment(), av.getSelectionGroup(), seqIndex, resIndex); + jalview.analysis.Finder finder = new jalview.analysis.Finder(av + .getAlignment(), av.getSelectionGroup(), seqIndex, resIndex); finder.setCaseSensitive(caseSensitive.getState()); finder.setFindAll(findAll); @@ -152,30 +152,37 @@ public class Finder seqIndex = 0; } - // if allResults is null, this effectively switches displaySearch flag in seqCanvas + // if allResults is null, this effectively switches displaySearch flag in + // seqCanvas ap.highlightSearchResults(searchResults); if (findAll) { - String message = (searchResults == null ? 0 : searchResults.getSize()) + - " matches found."; - ap.alignFrame.statusBar.setText("Search results: " + searchString + " : " + - message); + String message = (searchResults == null ? 0 : searchResults.getSize()) + + " matches found."; + ap.alignFrame.statusBar.setText("Search results: " + searchString + + " : " + message); } } Label jLabel1 = new Label(); + protected TextField textfield = new TextField(); + protected Button findAll = new Button(); + protected Button findNext = new Button(); + Panel jPanel1 = new Panel(); + GridLayout gridLayout1 = new GridLayout(); + protected Button createNewGroup = new Button(); + Checkbox caseSensitive = new Checkbox(); - private void jbInit() - throws Exception + private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); jLabel1.setText("Find"); diff --git a/src/jalview/appletgui/FontChooser.java b/src/jalview/appletgui/FontChooser.java index 87fa50f..514b059 100755 --- a/src/jalview/appletgui/FontChooser.java +++ b/src/jalview/appletgui/FontChooser.java @@ -1,268 +1,282 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; -import java.awt.event.*; - -public class FontChooser - extends Panel implements ActionListener, ItemListener -{ - AlignmentPanel ap; - TreePanel tp; - Font oldFont; - boolean init = true; - Frame frame; - - public FontChooser(TreePanel tp) - { - try - { - jbInit(); - } - catch (Exception e) - { - e.printStackTrace(); - } - - this.tp = tp; - oldFont = tp.getTreeFont(); - init(); - } - - public FontChooser(AlignmentPanel ap) - { - try - { - jbInit(); - } - catch (Exception e) - { - e.printStackTrace(); - } - - this.ap = ap; - oldFont = ap.av.getFont(); - init(); - } - - void init() - { - String fonts[] = Toolkit.getDefaultToolkit().getFontList(); - for (int i = 0; i < fonts.length; i++) - { - fontName.addItem(fonts[i]); - } - - for (int i = 1; i < 31; i++) - { - fontSize.addItem(i + ""); - } - - fontStyle.addItem("plain"); - fontStyle.addItem("bold"); - fontStyle.addItem("italic"); - - fontName.select(oldFont.getName()); - fontSize.select(oldFont.getSize() + ""); - fontStyle.select(oldFont.getStyle()); - - Frame frame = new Frame(); - this.frame = frame; - frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "Change Font", 440, 115); - - init = false; - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == ok) - { - ok_actionPerformed(); - } - else if (evt.getSource() == cancel) - { - cancel_actionPerformed(); - } - } - - public void itemStateChanged(ItemEvent evt) - { - if (evt.getSource() == fontName) - { - fontName_actionPerformed(); - } - else if (evt.getSource() == fontSize) - { - fontSize_actionPerformed(); - } - else if (evt.getSource() == fontStyle) - { - fontStyle_actionPerformed(); - } - } - - protected void ok_actionPerformed() - { - frame.setVisible(false); - if (ap != null) - { - if (ap.getOverviewPanel() != null) - { - ap.getOverviewPanel().updateOverviewImage(); - } - } - - } - - protected void cancel_actionPerformed() - { - if (ap != null) - { - ap.av.setFont(oldFont); - ap.paintAlignment(true); - } - else if (tp != null) - { - tp.setTreeFont(oldFont); - tp.treeCanvas.repaint(); - } - - fontName.select(oldFont.getName()); - fontSize.select(oldFont.getSize() + ""); - fontStyle.select(oldFont.getStyle()); - - frame.setVisible(false); - } - - void changeFont() - { - Font newFont = new Font(fontName.getSelectedItem().toString(), - fontStyle.getSelectedIndex(), - Integer.parseInt(fontSize.getSelectedItem(). - toString()) - ); - if (ap != null) - { - ap.av.setFont(newFont); - ap.fontChanged(); - } - else if (tp != null) - { - tp.setTreeFont(newFont); - } - } - - protected void fontName_actionPerformed() - { - if (init) - { - return; - } - changeFont(); - } - - protected void fontSize_actionPerformed() - { - if (init) - { - return; - } - changeFont(); - } - - protected void fontStyle_actionPerformed() - { - if (init) - { - return; - } - changeFont(); - } - - Label label1 = new Label(); - protected Choice fontSize = new Choice(); - protected Choice fontStyle = new Choice(); - Label label2 = new Label(); - Label label3 = new Label(); - protected Choice fontName = new Choice(); - Button ok = new Button(); - Button cancel = new Button(); - Panel panel1 = new Panel(); - Panel panel2 = new Panel(); - Panel panel3 = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - BorderLayout borderLayout3 = new BorderLayout(); - Panel panel4 = new Panel(); - Panel panel5 = new Panel(); - BorderLayout borderLayout4 = new BorderLayout(); - - private void jbInit() - throws Exception - { - label1.setFont(new java.awt.Font("Verdana", 0, 11)); - label1.setAlignment(Label.RIGHT); - label1.setText("Font: "); - this.setLayout(borderLayout4); - fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); - fontSize.addItemListener(this); - fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); - fontStyle.addItemListener(this); - label2.setAlignment(Label.RIGHT); - label2.setFont(new java.awt.Font("Verdana", 0, 11)); - label2.setText("Size: "); - label3.setAlignment(Label.RIGHT); - label3.setFont(new java.awt.Font("Verdana", 0, 11)); - label3.setText("Style: "); - fontName.setFont(new java.awt.Font("Verdana", 0, 11)); - fontName.addItemListener(this); - ok.setFont(new java.awt.Font("Verdana", 0, 11)); - ok.setLabel("OK"); - ok.addActionListener(this); - cancel.setFont(new java.awt.Font("Verdana", 0, 11)); - cancel.setLabel("Cancel"); - cancel.addActionListener(this); - this.setBackground(Color.white); - panel1.setLayout(borderLayout1); - panel2.setLayout(borderLayout3); - panel3.setLayout(borderLayout2); - panel5.setBackground(Color.white); - panel4.setBackground(Color.white); - panel1.setBackground(Color.white); - panel2.setBackground(Color.white); - panel3.setBackground(Color.white); - panel1.add(label1, BorderLayout.WEST); - panel1.add(fontName, BorderLayout.CENTER); - panel5.add(panel1, null); - panel5.add(panel3, null); - panel5.add(panel2, null); - panel2.add(label3, BorderLayout.WEST); - panel2.add(fontStyle, BorderLayout.CENTER); - panel3.add(label2, BorderLayout.WEST); - panel3.add(fontSize, BorderLayout.CENTER); - this.add(panel4, BorderLayout.SOUTH); - panel4.add(ok, null); - panel4.add(cancel, null); - this.add(panel5, BorderLayout.CENTER); - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; +import java.awt.event.*; + +public class FontChooser extends Panel implements ActionListener, + ItemListener +{ + AlignmentPanel ap; + + TreePanel tp; + + Font oldFont; + + boolean init = true; + + Frame frame; + + public FontChooser(TreePanel tp) + { + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + + this.tp = tp; + oldFont = tp.getTreeFont(); + init(); + } + + public FontChooser(AlignmentPanel ap) + { + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + + this.ap = ap; + oldFont = ap.av.getFont(); + init(); + } + + void init() + { + String fonts[] = Toolkit.getDefaultToolkit().getFontList(); + for (int i = 0; i < fonts.length; i++) + { + fontName.addItem(fonts[i]); + } + + for (int i = 1; i < 31; i++) + { + fontSize.addItem(i + ""); + } + + fontStyle.addItem("plain"); + fontStyle.addItem("bold"); + fontStyle.addItem("italic"); + + fontName.select(oldFont.getName()); + fontSize.select(oldFont.getSize() + ""); + fontStyle.select(oldFont.getStyle()); + + Frame frame = new Frame(); + this.frame = frame; + frame.add(this); + jalview.bin.JalviewLite.addFrame(frame, "Change Font", 440, 115); + + init = false; + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == ok) + { + ok_actionPerformed(); + } + else if (evt.getSource() == cancel) + { + cancel_actionPerformed(); + } + } + + public void itemStateChanged(ItemEvent evt) + { + if (evt.getSource() == fontName) + { + fontName_actionPerformed(); + } + else if (evt.getSource() == fontSize) + { + fontSize_actionPerformed(); + } + else if (evt.getSource() == fontStyle) + { + fontStyle_actionPerformed(); + } + } + + protected void ok_actionPerformed() + { + frame.setVisible(false); + if (ap != null) + { + if (ap.getOverviewPanel() != null) + { + ap.getOverviewPanel().updateOverviewImage(); + } + } + + } + + protected void cancel_actionPerformed() + { + if (ap != null) + { + ap.av.setFont(oldFont); + ap.paintAlignment(true); + } + else if (tp != null) + { + tp.setTreeFont(oldFont); + tp.treeCanvas.repaint(); + } + + fontName.select(oldFont.getName()); + fontSize.select(oldFont.getSize() + ""); + fontStyle.select(oldFont.getStyle()); + + frame.setVisible(false); + } + + void changeFont() + { + Font newFont = new Font(fontName.getSelectedItem().toString(), + fontStyle.getSelectedIndex(), Integer.parseInt(fontSize + .getSelectedItem().toString())); + if (ap != null) + { + ap.av.setFont(newFont); + ap.fontChanged(); + } + else if (tp != null) + { + tp.setTreeFont(newFont); + } + } + + protected void fontName_actionPerformed() + { + if (init) + { + return; + } + changeFont(); + } + + protected void fontSize_actionPerformed() + { + if (init) + { + return; + } + changeFont(); + } + + protected void fontStyle_actionPerformed() + { + if (init) + { + return; + } + changeFont(); + } + + Label label1 = new Label(); + + protected Choice fontSize = new Choice(); + + protected Choice fontStyle = new Choice(); + + Label label2 = new Label(); + + Label label3 = new Label(); + + protected Choice fontName = new Choice(); + + Button ok = new Button(); + + Button cancel = new Button(); + + Panel panel1 = new Panel(); + + Panel panel2 = new Panel(); + + Panel panel3 = new Panel(); + + BorderLayout borderLayout1 = new BorderLayout(); + + BorderLayout borderLayout2 = new BorderLayout(); + + BorderLayout borderLayout3 = new BorderLayout(); + + Panel panel4 = new Panel(); + + Panel panel5 = new Panel(); + + BorderLayout borderLayout4 = new BorderLayout(); + + private void jbInit() throws Exception + { + label1.setFont(new java.awt.Font("Verdana", 0, 11)); + label1.setAlignment(Label.RIGHT); + label1.setText("Font: "); + this.setLayout(borderLayout4); + fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); + fontSize.addItemListener(this); + fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); + fontStyle.addItemListener(this); + label2.setAlignment(Label.RIGHT); + label2.setFont(new java.awt.Font("Verdana", 0, 11)); + label2.setText("Size: "); + label3.setAlignment(Label.RIGHT); + label3.setFont(new java.awt.Font("Verdana", 0, 11)); + label3.setText("Style: "); + fontName.setFont(new java.awt.Font("Verdana", 0, 11)); + fontName.addItemListener(this); + ok.setFont(new java.awt.Font("Verdana", 0, 11)); + ok.setLabel("OK"); + ok.addActionListener(this); + cancel.setFont(new java.awt.Font("Verdana", 0, 11)); + cancel.setLabel("Cancel"); + cancel.addActionListener(this); + this.setBackground(Color.white); + panel1.setLayout(borderLayout1); + panel2.setLayout(borderLayout3); + panel3.setLayout(borderLayout2); + panel5.setBackground(Color.white); + panel4.setBackground(Color.white); + panel1.setBackground(Color.white); + panel2.setBackground(Color.white); + panel3.setBackground(Color.white); + panel1.add(label1, BorderLayout.WEST); + panel1.add(fontName, BorderLayout.CENTER); + panel5.add(panel1, null); + panel5.add(panel3, null); + panel5.add(panel2, null); + panel2.add(label3, BorderLayout.WEST); + panel2.add(fontStyle, BorderLayout.CENTER); + panel3.add(label2, BorderLayout.WEST); + panel3.add(fontSize, BorderLayout.CENTER); + this.add(panel4, BorderLayout.SOUTH); + panel4.add(ok, null); + panel4.add(cancel, null); + this.add(panel5, BorderLayout.CENTER); + } + +} diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index bec3c63..d530fd8 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -1,40 +1,43 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.awt.*; import jalview.datamodel.*; -public class IdCanvas - extends Panel +public class IdCanvas extends Panel { protected AlignViewport av; protected boolean showScores = true; protected int maxIdLength = -1; + protected String maxIdStr = null; + Image image; + Graphics gg; + int imgHeight = 0; + boolean fastPaint = false; java.util.Vector searchResults; @@ -47,36 +50,36 @@ public class IdCanvas } public void drawIdString(Graphics gg, SequenceI s, int i, int starty, - int ypos) + int ypos) { int charHeight = av.getCharHeight(); if (searchResults != null && searchResults.contains(s)) { gg.setColor(Color.black); - gg.fillRect(0, ( (i - starty) * charHeight) + ypos, - getSize().width, charHeight); + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getSize().width, + charHeight); gg.setColor(Color.white); } - else if (av.getSelectionGroup() != null && - av.getSelectionGroup().getSequences(null).contains(s)) + else if (av.getSelectionGroup() != null + && av.getSelectionGroup().getSequences(null).contains(s)) { gg.setColor(Color.lightGray); - gg.fillRect(0, ( (i - starty) * charHeight) + ypos, - getSize().width, charHeight); + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getSize().width, + charHeight); gg.setColor(Color.white); } else { gg.setColor(av.getSequenceColour(s)); - gg.fillRect(0, ( (i - starty) * charHeight) + ypos, - getSize().width, charHeight); + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getSize().width, + charHeight); gg.setColor(Color.black); } gg.drawString(s.getDisplayId(av.getShowJVSuffix()), 0, - ( (i - starty) * charHeight) + ypos + - charHeight - (charHeight / 5)); + ((i - starty) * charHeight) + ypos + charHeight + - (charHeight / 5)); if (av.hasHiddenRows && av.showHiddenMarkers) { @@ -93,7 +96,8 @@ public class IdCanvas return; } - gg.copyArea(0, 0, getSize().width, imgHeight, 0, -vertical * av.charHeight); + gg.copyArea(0, 0, getSize().width, imgHeight, 0, -vertical + * av.charHeight); int ss = av.startSeq, es = av.endSeq, transY = 0; if (vertical > 0) // scroll down @@ -160,21 +164,21 @@ public class IdCanvas gg.setFont(av.getFont()); } - //Fill in the background + // Fill in the background gg.setColor(Color.white); - Font italic = new Font(av.getFont().getName(), Font.ITALIC, - av.getFont().getSize()); + Font italic = new Font(av.getFont().getName(), Font.ITALIC, av + .getFont().getSize()); gg.setFont(italic); gg.fillRect(0, 0, getSize().width, getSize().height); drawIds(av.startSeq, av.endSeq); g.drawImage(image, 0, 0, this); } - + void drawIds(int starty, int endy) { - Font italic = new Font(av.getFont().getName(), Font.ITALIC, - av.getFont().getSize()); + Font italic = new Font(av.getFont().getName(), Font.ITALIC, av + .getFont().getSize()); gg.setFont(italic); @@ -207,16 +211,13 @@ public class IdCanvas hgap += av.charHeight; } - int cHeight = alheight * av.charHeight - + hgap - + annotationHeight; + int cHeight = alheight * av.charHeight + hgap + annotationHeight; int rowSize = av.getEndRes() - av.getStartRes(); // Draw the rest of the panels - for (int ypos = hgap, row = av.startRes; - (ypos <= getSize().height) && (row < maxwidth); - ypos += cHeight, row += rowSize) + for (int ypos = hgap, row = av.startRes; (ypos <= getSize().height) + && (row < maxwidth); ypos += cHeight, row += rowSize) { for (int i = starty; i < alheight; i++) { @@ -241,7 +242,7 @@ public class IdCanvas } else { - //Now draw the id strings + // Now draw the id strings SequenceI seq; for (int i = starty; i < endy; i++) { @@ -252,22 +253,21 @@ public class IdCanvas continue; } gg.setFont(italic); - //boolean isrep=false; + // boolean isrep=false; if (av.hasHiddenRows) { - //isrep = + // isrep = setHiddenFont(seq); } // Selected sequence colours - if ( (searchResults != null) && - searchResults.contains(seq)) + if ((searchResults != null) && searchResults.contains(seq)) { currentColor = Color.black; currentTextColor = Color.white; } - else if ( (av.getSelectionGroup() != null) && - av.getSelectionGroup().getSequences(null).contains(seq)) + else if ((av.getSelectionGroup() != null) + && av.getSelectionGroup().getSequences(null).contains(seq)) { currentColor = Color.lightGray; currentTextColor = Color.black; @@ -279,15 +279,15 @@ public class IdCanvas } gg.setColor(currentColor); - // TODO: isrep could be used to highlight the representative in a different way + // TODO: isrep could be used to highlight the representative in a + // different way gg.fillRect(0, (i - starty) * av.charHeight, getSize().width, - av.charHeight); + av.charHeight); gg.setColor(currentTextColor); - gg.drawString(seq.getDisplayId(av.getShowJVSuffix()), - 0, - ( ( (i - starty) * av.charHeight) + av.charHeight) - - (av.charHeight / 5)); + gg.drawString(seq.getDisplayId(av.getShowJVSuffix()), 0, + (((i - starty) * av.charHeight) + av.charHeight) + - (av.charHeight / 5)); if (av.hasHiddenRows && av.showHiddenMarkers) { @@ -306,15 +306,14 @@ public class IdCanvas void drawMarker(int i, int starty, int yoffset) { SequenceI[] hseqs = av.alignment.getHiddenSequences().hiddenSequences; - //Use this method here instead of calling hiddenSeq adjust - //3 times. + // Use this method here instead of calling hiddenSeq adjust + // 3 times. int hSize = hseqs.length; int hiddenIndex = i; int lastIndex = i - 1; int nextIndex = i + 1; - for (int j = 0; j < hSize; j++) { if (hseqs[j] != null) @@ -341,40 +340,31 @@ public class IdCanvas if (below) { gg.fillPolygon(new int[] - {getSize().width - av.charHeight, - getSize().width - av.charHeight, - getSize().width}, - new int[] - { - (i - starty) * av.charHeight + yoffset, - (i - starty) * av.charHeight + yoffset + av.charHeight / 4, - (i - starty) * av.charHeight + yoffset - }, 3); + { getSize().width - av.charHeight, getSize().width - av.charHeight, + getSize().width }, new int[] + { (i - starty) * av.charHeight + yoffset, + (i - starty) * av.charHeight + yoffset + av.charHeight / 4, + (i - starty) * av.charHeight + yoffset }, 3); } if (above) { gg.fillPolygon(new int[] - {getSize().width - av.charHeight, - getSize().width - av.charHeight, - getSize().width}, - new int[] - { - (i - starty + 1) * av.charHeight + yoffset, - (i - starty + 1) * av.charHeight + yoffset - - av.charHeight / 4, - (i - starty + 1) * av.charHeight + yoffset - }, 3); + { getSize().width - av.charHeight, getSize().width - av.charHeight, + getSize().width }, new int[] + { (i - starty + 1) * av.charHeight + yoffset, + (i - starty + 1) * av.charHeight + yoffset - av.charHeight / 4, + (i - starty + 1) * av.charHeight + yoffset }, 3); } } + boolean setHiddenFont(SequenceI seq) { - Font bold = new Font(av.getFont().getName(), Font.BOLD - , - av.getFont().getSize()); + Font bold = new Font(av.getFont().getName(), Font.BOLD, av.getFont() + .getSize()); - if (av.hiddenRepSequences != null && - av.hiddenRepSequences.containsKey(seq)) + if (av.hiddenRepSequences != null + && av.hiddenRepSequences.containsKey(seq)) { gg.setFont(bold); return true; diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index 44a03ec..9bf2374 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.awt.*; @@ -25,19 +24,26 @@ import java.awt.event.*; import jalview.datamodel.*; import jalview.util.UrlLink; -public class IdPanel - extends Panel implements MouseListener, MouseMotionListener +public class IdPanel extends Panel implements MouseListener, + MouseMotionListener { protected IdCanvas idCanvas; + protected AlignViewport av; + protected AlignmentPanel alignPanel; + ScrollThread scrollThread = null; int offy; + int width; + int lastid = -1; + boolean mouseDragging = false; + java.util.Vector links = new java.util.Vector(); public IdPanel(AlignViewport av, AlignmentPanel parent) @@ -68,11 +74,13 @@ public class IdPanel if (links.size() < 1) { links = new java.util.Vector(); - links.addElement("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry"); + links + .addElement("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry"); } } Tooltip tooltip; + public void mouseMoved(MouseEvent e) { int seq = alignPanel.seqPanel.findSeq(e); @@ -91,14 +99,13 @@ public class IdPanel if (tooltip == null) { - tooltip = new Tooltip( - sequence.getDisplayId(true) - + "\n" + sequence.getDescription(), idCanvas); + tooltip = new Tooltip(sequence.getDisplayId(true) + "\n" + + sequence.getDescription(), idCanvas); } else { - tooltip.setTip(sequence.getDisplayId(true) - + "\n" + sequence.getDescription()); + tooltip.setTip(sequence.getDisplayId(true) + "\n" + + sequence.getDescription()); } } @@ -128,13 +135,13 @@ public class IdPanel return; } - //DEFAULT LINK IS FIRST IN THE LINK LIST + // DEFAULT LINK IS FIRST IN THE LINK LIST int seq = alignPanel.seqPanel.findSeq(e); String id = av.getAlignment().getSequenceAt(seq).getName(); - + String target = null; String url = null; - int i=0; + int i = 0; while (url == null && i < links.size()) { // DEFAULT LINK IS FIRST IN THE LINK LIST @@ -161,7 +168,7 @@ public class IdPanel } String urls[] = urlLink.makeUrls(id, true); - if (urls == null || urls[0]==null || urls[0].length()<1) + if (urls == null || urls[0] == null || urls[0].length() < 1) { url = null; continue; @@ -173,8 +180,7 @@ public class IdPanel { alignPanel.alignFrame.showURL(url, target); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -200,8 +206,8 @@ public class IdPanel scrollThread = new ScrollThread(true); } - if (mouseDragging && e.getY() >= getSize().height && - av.alignment.getHeight() > av.getEndSeq()) + if (mouseDragging && e.getY() >= getSize().height + && av.alignment.getHeight() > av.getEndSeq()) { scrollThread = new ScrollThread(false); } @@ -222,19 +228,18 @@ public class IdPanel int seq = alignPanel.seqPanel.findSeq(e); - if ( (e.getModifiers() & InputEvent.BUTTON3_MASK) == - InputEvent.BUTTON3_MASK) + if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - APopupMenu popup = new APopupMenu(alignPanel, - (Sequence) av.getAlignment(). - getSequenceAt(seq), links); + APopupMenu popup = new APopupMenu(alignPanel, (Sequence) av + .getAlignment().getSequenceAt(seq), links); this.add(popup); popup.show(this, e.getX(), e.getY()); return; } - if ( (av.getSelectionGroup() == null) || - ( (!e.isControlDown() && !e.isShiftDown()) && av.getSelectionGroup() != null)) + if ((av.getSelectionGroup() == null) + || ((!e.isControlDown() && !e.isShiftDown()) && av + .getSelectionGroup() != null)) { av.setSelectionGroup(new SequenceGroup()); av.getSelectionGroup().setStartRes(0); @@ -280,7 +285,8 @@ public class IdPanel for (int i = start; i <= end; i++) { - av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i), false); + av.getSelectionGroup().addSequence( + av.getAlignment().getSequenceAt(i), false); } } @@ -310,7 +316,7 @@ public class IdPanel return; } - int index = av.alignment.findIndex( (SequenceI) found.elementAt(0)); + int index = av.alignment.findIndex((SequenceI) found.elementAt(0)); // do we need to scroll the panel? if (av.getStartSeq() > index || av.getEndSeq() < index) @@ -320,11 +326,12 @@ public class IdPanel } // this class allows scrolling off the bottom of the visible alignment - class ScrollThread - extends Thread + class ScrollThread extends Thread { boolean running = false; + boolean up = true; + public ScrollThread(boolean up) { this.up = up; @@ -370,9 +377,9 @@ public class IdPanel try { Thread.sleep(100); + } catch (Exception ex) + { } - catch (Exception ex) - {} } } } diff --git a/src/jalview/appletgui/IdwidthAdjuster.java b/src/jalview/appletgui/IdwidthAdjuster.java index 052a95e..4a9f9ef 100755 --- a/src/jalview/appletgui/IdwidthAdjuster.java +++ b/src/jalview/appletgui/IdwidthAdjuster.java @@ -1,104 +1,108 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; -import java.awt.event.*; - -public class IdwidthAdjuster - extends Panel implements MouseListener, MouseMotionListener -{ - boolean active = false; - int oldX = 0; - Image image; - AlignmentPanel ap; - - public IdwidthAdjuster(AlignmentPanel ap) - { - setLayout(null); - this.ap = ap; - java.net.URL url = getClass().getResource("/images/idwidth.gif"); - if (url != null) - { - image = java.awt.Toolkit.getDefaultToolkit().getImage(url); - } - - addMouseListener(this); - addMouseMotionListener(this); - } - - public void mousePressed(MouseEvent evt) - { - oldX = evt.getX(); - } - - public void mouseReleased(MouseEvent evt) - { - active = false; - repaint(); - } - - public void mouseEntered(MouseEvent evt) - { - active = true; - repaint(); - } - - public void mouseExited(MouseEvent evt) - { - active = false; - repaint(); - } - - public void mouseDragged(MouseEvent evt) - { - active = true; - Dimension d = ap.idPanel.idCanvas.getSize(); - int dif = evt.getX() - oldX; - - if (d.width + dif > 20 || dif > 0) - { - ap.setIdWidth(d.width + dif, d.height); - this.setSize(d.width + dif, getSize().height); - } - - oldX = evt.getX(); - } - - public void mouseMoved(MouseEvent evt) - {} - - public void mouseClicked(MouseEvent evt) - {} - - public void paint(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getSize().width, getSize().height); - if (active) - { - if (image != null) - { - g.drawImage(image, getSize().width - 20, 2, this); - } - } - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; +import java.awt.event.*; + +public class IdwidthAdjuster extends Panel implements MouseListener, + MouseMotionListener +{ + boolean active = false; + + int oldX = 0; + + Image image; + + AlignmentPanel ap; + + public IdwidthAdjuster(AlignmentPanel ap) + { + setLayout(null); + this.ap = ap; + java.net.URL url = getClass().getResource("/images/idwidth.gif"); + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().getImage(url); + } + + addMouseListener(this); + addMouseMotionListener(this); + } + + public void mousePressed(MouseEvent evt) + { + oldX = evt.getX(); + } + + public void mouseReleased(MouseEvent evt) + { + active = false; + repaint(); + } + + public void mouseEntered(MouseEvent evt) + { + active = true; + repaint(); + } + + public void mouseExited(MouseEvent evt) + { + active = false; + repaint(); + } + + public void mouseDragged(MouseEvent evt) + { + active = true; + Dimension d = ap.idPanel.idCanvas.getSize(); + int dif = evt.getX() - oldX; + + if (d.width + dif > 20 || dif > 0) + { + ap.setIdWidth(d.width + dif, d.height); + this.setSize(d.width + dif, getSize().height); + } + + oldX = evt.getX(); + } + + public void mouseMoved(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void paint(Graphics g) + { + g.setColor(Color.white); + g.fillRect(0, 0, getSize().width, getSize().height); + if (active) + { + if (image != null) + { + g.drawImage(image, getSize().width - 20, 2, this); + } + } + } + +} diff --git a/src/jalview/appletgui/JVDialog.java b/src/jalview/appletgui/JVDialog.java index b8e0abc..b85424c 100644 --- a/src/jalview/appletgui/JVDialog.java +++ b/src/jalview/appletgui/JVDialog.java @@ -1,79 +1,78 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; -import java.awt.event.*; - -public class JVDialog extends Dialog implements ActionListener -{ - AlignmentPanel ap; - Panel buttonPanel; - Button ok = new Button("Accept"); - Button cancel = new Button("Cancel"); - boolean accept = false; - Frame owner; - - public JVDialog(Frame owner, - String title, - boolean modal, - int width, int height) - { - super(owner, title, modal); - this.owner = owner; - - height += owner.getInsets().top + getInsets().bottom; - - setBounds(owner.getBounds().x - + (owner.getSize().width - width) / 2, - owner.getBounds().y - + (owner.getSize().height - height) / 2, - width, height); - } - - void setMainPanel(Panel panel) - { - add(panel, BorderLayout.NORTH); - - buttonPanel = new Panel(new FlowLayout()); - - buttonPanel.add(ok); - buttonPanel.add(cancel); - ok.addActionListener(this); - cancel.addActionListener(this); - - add(buttonPanel, BorderLayout.SOUTH); - - pack(); - - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == ok) - { - accept = true; - } - - setVisible(false); - } - - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; +import java.awt.event.*; + +public class JVDialog extends Dialog implements ActionListener +{ + AlignmentPanel ap; + + Panel buttonPanel; + + Button ok = new Button("Accept"); + + Button cancel = new Button("Cancel"); + + boolean accept = false; + + Frame owner; + + public JVDialog(Frame owner, String title, boolean modal, int width, + int height) + { + super(owner, title, modal); + this.owner = owner; + + height += owner.getInsets().top + getInsets().bottom; + + setBounds(owner.getBounds().x + (owner.getSize().width - width) / 2, + owner.getBounds().y + (owner.getSize().height - height) / 2, + width, height); + } + + void setMainPanel(Panel panel) + { + add(panel, BorderLayout.NORTH); + + buttonPanel = new Panel(new FlowLayout()); + + buttonPanel.add(ok); + buttonPanel.add(cancel); + ok.addActionListener(this); + cancel.addActionListener(this); + + add(buttonPanel, BorderLayout.SOUTH); + + pack(); + + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == ok) + { + accept = true; + } + + setVisible(false); + } + +} diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 7265489..ef7c16d 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -1,449 +1,455 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; -import java.awt.event.*; - -public class OverviewPanel - extends Panel implements Runnable, MouseMotionListener, MouseListener -{ - Image miniMe; - Image offscreen; - AlignViewport av; - AlignmentPanel ap; - float scalew = 1f; - float scaleh = 1f; - - public int width, sequencesHeight; - int graphHeight = 20; - int boxX = -1, boxY = -1, boxWidth = -1, boxHeight = -1; - - boolean resizing = false; - - // Can set different properties in this seqCanvas than - // main visible SeqCanvas - SequenceRenderer sr; - FeatureRenderer fr; - - Frame nullFrame; - - public OverviewPanel(AlignmentPanel ap) - { - this.av = ap.av; - this.ap = ap; - setLayout(null); - nullFrame = new Frame(); - nullFrame.addNotify(); - - sr = new SequenceRenderer(av); - sr.graphics = nullFrame.getGraphics(); - sr.renderGaps = false; - sr.forOverview = true; - fr = new FeatureRenderer(av); - fr.overview = true; - - // scale the initial size of overviewpanel to shape of alignment - float initialScale = (float) av.alignment.getWidth() / - (float) av.alignment.getHeight(); - - if (av.hconsensus == null) - { - graphHeight = 0; - } - - if (av.alignment.getWidth() > av.alignment.getHeight()) - { - // wider - width = 400; - sequencesHeight = (int) (400f / initialScale); - if (sequencesHeight < 40) - { - sequencesHeight = 40; - } - } - else - { - // taller - width = (int) (400f * initialScale); - sequencesHeight = 300; - if (width < 120) - { - width = 120; - } - } - - setSize(new Dimension(width, sequencesHeight + graphHeight)); - addComponentListener(new ComponentAdapter() - { - - public void componentResized(ComponentEvent evt) - { - if (getSize().width != width || - getSize().height != sequencesHeight + graphHeight) - { - updateOverviewImage(); - } - } - }); - - addMouseMotionListener(this); - - addMouseListener(this); - - updateOverviewImage(); - - } - - public void mouseEntered(MouseEvent evt) - {} - - public void mouseExited(MouseEvent evt) - {} - - public void mouseClicked(MouseEvent evt) - {} - - public void mouseMoved(MouseEvent evt) - {} - - public void mousePressed(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - } - - public void mouseReleased(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - } - - public void mouseDragged(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - } - - void checkValid() - { - if (boxY < 0) - { - boxY = 0; - } - - if (boxY > (sequencesHeight - boxHeight)) - { - boxY = sequencesHeight - boxHeight + 1; - } - - if (boxX < 0) - { - boxX = 0; - } - - if (boxX > (width - boxWidth)) - { - if (av.hasHiddenColumns) - { - //Try smallest possible box - boxWidth = (int) ( (av.endRes - av.startRes + 1) * - av.getCharWidth() * scalew); - } - boxX = width - boxWidth; - } - - int col = (int) (boxX / scalew / av.getCharWidth()); - int row = (int) (boxY / scaleh / av.getCharHeight()); - - if (av.hasHiddenColumns) - { - if (!av.getColumnSelection().isVisible(col)) - { - return; - } - - col = av.getColumnSelection().findColumnPosition(col); - } - - if (av.hasHiddenRows) - { - row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(row); - } - - ap.setScrollValues(col, row); - ap.paintAlignment(false); - } - - /** - * DOCUMENT ME! - */ - public void updateOverviewImage() - { - if (resizing) - { - resizeAgain = true; - return; - } - - if (av.showSequenceFeatures) - { - fr.featureGroups = ap.seqPanel.seqCanvas.getFeatureRenderer(). - featureGroups; - fr.featureColours = ap.seqPanel.seqCanvas.getFeatureRenderer(). - featureColours; - } - - resizing = true; - - if ( (getSize().width > 0) && (getSize().height > 0)) - { - width = getSize().width; - sequencesHeight = getSize().height - graphHeight; - } - setSize(new Dimension(width, sequencesHeight + graphHeight)); - - Thread thread = new Thread(this); - thread.start(); - repaint(); - } - - // This is set true if the user resizes whilst - // the overview is being calculated - boolean resizeAgain = false; - - public void run() - { - miniMe = null; - int alwidth = av.alignment.getWidth(); - int alheight = av.alignment.getHeight(); - - if (av.showSequenceFeatures) - { - fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer()); - } - - if (getSize().width > 0 && getSize().height > 0) - { - width = getSize().width; - sequencesHeight = getSize().height - graphHeight; - } - - setSize(new Dimension(width, sequencesHeight + graphHeight)); - - int fullsizeWidth = alwidth * av.getCharWidth(); - int fullsizeHeight = alheight * av.getCharHeight(); - - scalew = (float) width / (float) fullsizeWidth; - scaleh = (float) sequencesHeight / (float) fullsizeHeight; - - miniMe = nullFrame.createImage(width, sequencesHeight + graphHeight); - offscreen = nullFrame.createImage(width, sequencesHeight + graphHeight); - - Graphics mg = miniMe.getGraphics(); - float sampleCol = (float) alwidth / (float) width; - float sampleRow = (float) alheight / (float) sequencesHeight; - - int lastcol = 0, lastrow = 0; - int xstart = 0, ystart = 0; - Color color = Color.yellow; - int row, col, sameRow = 0, sameCol = 0; - jalview.datamodel.SequenceI seq; - boolean hiddenRow = false; - for (row = 0; row <= sequencesHeight; row++) - { - if ( (int) (row * sampleRow) == lastrow) - { - sameRow++; - continue; - } - - hiddenRow = false; - if (av.hasHiddenRows) - { - seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow); - if (seq == null) - { - int index = - av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs( - lastrow); - - seq = av.alignment.getSequenceAt(index); - } - else - { - hiddenRow = true; - } - } - else - { - seq = av.alignment.getSequenceAt(lastrow); - } - - for (col = 0; col < width; col++) - { - if ( (int) (col * sampleCol) == lastcol && - (int) (row * sampleRow) == lastrow) - { - sameCol++; - continue; - } - - lastcol = (int) (col * sampleCol); - - if (seq.getLength() > lastcol) - { - color = sr.getResidueBoxColour( - seq, lastcol); - - if (av.showSequenceFeatures) - { - color = fr.findFeatureColour(color, seq, lastcol); - } - } - else - { - color = Color.white; //White - } - - if (hiddenRow || - (av.hasHiddenColumns && !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 = (int) (row * sampleRow); - ystart = row; - sameRow = 1; - } - - if (av.conservation != null) - { - for (col = 0; col < width; col++) - { - lastcol = (int) (col * sampleCol); - { - mg.translate(col, sequencesHeight); - ap.annotationPanel.drawGraph(mg, av.conservation, - (int) (sampleCol) + 1, - graphHeight, - (int) (col * sampleCol), - (int) (col * sampleCol) + 1); - mg.translate( -col, -sequencesHeight); - } - } - } - System.gc(); - - resizing = false; - - setBoxPosition(); - - if (resizeAgain) - { - resizeAgain = false; - updateOverviewImage(); - } - } - - public void setBoxPosition() - { - int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth(); - int fullsizeHeight = (av.alignment.getHeight() - + av.alignment.getHiddenSequences().getSize()) * - av.getCharHeight(); - - int startRes = av.getStartRes(); - int endRes = av.getEndRes(); - - if (av.hasHiddenColumns) - { - startRes = av.getColumnSelection().adjustForHiddenColumns(startRes); - endRes = av.getColumnSelection().adjustForHiddenColumns(endRes); - } - - int startSeq = av.startSeq; - int endSeq = av.endSeq; - - if (av.hasHiddenRows) - { - startSeq = - av.alignment.getHiddenSequences().adjustForHiddenSeqs(startSeq); - - endSeq = - av.alignment.getHiddenSequences().adjustForHiddenSeqs(endSeq); - - } - - scalew = (float) width / (float) fullsizeWidth; - scaleh = (float) sequencesHeight / (float) fullsizeHeight; - - boxX = (int) (startRes * av.getCharWidth() * scalew); - boxY = (int) (startSeq * av.getCharHeight() * scaleh); - - if (av.hasHiddenColumns) - { - boxWidth = (int) ( (endRes - startRes + 1) * av.getCharWidth() * scalew); - } - else - { - boxWidth = (int) ( (endRes - startRes + 1) * av.getCharWidth() * scalew); - } - - boxHeight = (int) ( (endSeq - startSeq) * av.getCharHeight() * scaleh); - - repaint(); - } - - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - Graphics og = offscreen.getGraphics(); - if (miniMe != null) - { - og.drawImage(miniMe, 0, 0, this); - og.setColor(Color.red); - og.drawRect(boxX, boxY, boxWidth, boxHeight); - og.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); - g.drawImage(offscreen, 0, 0, this); - } - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; +import java.awt.event.*; + +public class OverviewPanel extends Panel implements Runnable, + MouseMotionListener, MouseListener +{ + Image miniMe; + + Image offscreen; + + AlignViewport av; + + AlignmentPanel ap; + + float scalew = 1f; + + float scaleh = 1f; + + public int width, sequencesHeight; + + int graphHeight = 20; + + int boxX = -1, boxY = -1, boxWidth = -1, boxHeight = -1; + + boolean resizing = false; + + // Can set different properties in this seqCanvas than + // main visible SeqCanvas + SequenceRenderer sr; + + FeatureRenderer fr; + + Frame nullFrame; + + public OverviewPanel(AlignmentPanel ap) + { + this.av = ap.av; + this.ap = ap; + setLayout(null); + nullFrame = new Frame(); + nullFrame.addNotify(); + + sr = new SequenceRenderer(av); + sr.graphics = nullFrame.getGraphics(); + sr.renderGaps = false; + sr.forOverview = true; + fr = new FeatureRenderer(av); + fr.overview = true; + + // scale the initial size of overviewpanel to shape of alignment + float initialScale = (float) av.alignment.getWidth() + / (float) av.alignment.getHeight(); + + if (av.hconsensus == null) + { + graphHeight = 0; + } + + if (av.alignment.getWidth() > av.alignment.getHeight()) + { + // wider + width = 400; + sequencesHeight = (int) (400f / initialScale); + if (sequencesHeight < 40) + { + sequencesHeight = 40; + } + } + else + { + // taller + width = (int) (400f * initialScale); + sequencesHeight = 300; + if (width < 120) + { + width = 120; + } + } + + setSize(new Dimension(width, sequencesHeight + graphHeight)); + addComponentListener(new ComponentAdapter() + { + + public void componentResized(ComponentEvent evt) + { + if (getSize().width != width + || getSize().height != sequencesHeight + graphHeight) + { + updateOverviewImage(); + } + } + }); + + addMouseMotionListener(this); + + addMouseListener(this); + + updateOverviewImage(); + + } + + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void mouseMoved(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); + } + + public void mouseReleased(MouseEvent evt) + { + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); + } + + public void mouseDragged(MouseEvent evt) + { + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); + } + + void checkValid() + { + if (boxY < 0) + { + boxY = 0; + } + + if (boxY > (sequencesHeight - boxHeight)) + { + boxY = sequencesHeight - boxHeight + 1; + } + + if (boxX < 0) + { + boxX = 0; + } + + if (boxX > (width - boxWidth)) + { + if (av.hasHiddenColumns) + { + // Try smallest possible box + boxWidth = (int) ((av.endRes - av.startRes + 1) * av.getCharWidth() * scalew); + } + boxX = width - boxWidth; + } + + int col = (int) (boxX / scalew / av.getCharWidth()); + int row = (int) (boxY / scaleh / av.getCharHeight()); + + if (av.hasHiddenColumns) + { + if (!av.getColumnSelection().isVisible(col)) + { + return; + } + + col = av.getColumnSelection().findColumnPosition(col); + } + + if (av.hasHiddenRows) + { + row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs( + row); + } + + ap.setScrollValues(col, row); + ap.paintAlignment(false); + } + + /** + * DOCUMENT ME! + */ + public void updateOverviewImage() + { + if (resizing) + { + resizeAgain = true; + return; + } + + if (av.showSequenceFeatures) + { + fr.featureGroups = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups; + fr.featureColours = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours; + } + + resizing = true; + + if ((getSize().width > 0) && (getSize().height > 0)) + { + width = getSize().width; + sequencesHeight = getSize().height - graphHeight; + } + setSize(new Dimension(width, sequencesHeight + graphHeight)); + + Thread thread = new Thread(this); + thread.start(); + repaint(); + } + + // This is set true if the user resizes whilst + // the overview is being calculated + boolean resizeAgain = false; + + public void run() + { + miniMe = null; + int alwidth = av.alignment.getWidth(); + int alheight = av.alignment.getHeight(); + + if (av.showSequenceFeatures) + { + fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer()); + } + + if (getSize().width > 0 && getSize().height > 0) + { + width = getSize().width; + sequencesHeight = getSize().height - graphHeight; + } + + setSize(new Dimension(width, sequencesHeight + graphHeight)); + + int fullsizeWidth = alwidth * av.getCharWidth(); + int fullsizeHeight = alheight * av.getCharHeight(); + + scalew = (float) width / (float) fullsizeWidth; + scaleh = (float) sequencesHeight / (float) fullsizeHeight; + + miniMe = nullFrame.createImage(width, sequencesHeight + graphHeight); + offscreen = nullFrame.createImage(width, sequencesHeight + graphHeight); + + Graphics mg = miniMe.getGraphics(); + float sampleCol = (float) alwidth / (float) width; + float sampleRow = (float) alheight / (float) sequencesHeight; + + int lastcol = 0, lastrow = 0; + int xstart = 0, ystart = 0; + Color color = Color.yellow; + int row, col, sameRow = 0, sameCol = 0; + jalview.datamodel.SequenceI seq; + boolean hiddenRow = false; + for (row = 0; row <= sequencesHeight; row++) + { + if ((int) (row * sampleRow) == lastrow) + { + sameRow++; + continue; + } + + hiddenRow = false; + if (av.hasHiddenRows) + { + seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow); + if (seq == null) + { + int index = av.alignment.getHiddenSequences() + .findIndexWithoutHiddenSeqs(lastrow); + + seq = av.alignment.getSequenceAt(index); + } + else + { + hiddenRow = true; + } + } + else + { + seq = av.alignment.getSequenceAt(lastrow); + } + + for (col = 0; col < width; col++) + { + if ((int) (col * sampleCol) == lastcol + && (int) (row * sampleRow) == lastrow) + { + sameCol++; + continue; + } + + lastcol = (int) (col * sampleCol); + + if (seq.getLength() > lastcol) + { + color = sr.getResidueBoxColour(seq, lastcol); + + if (av.showSequenceFeatures) + { + color = fr.findFeatureColour(color, seq, lastcol); + } + } + else + { + color = Color.white; // White + } + + if (hiddenRow + || (av.hasHiddenColumns && !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 = (int) (row * sampleRow); + ystart = row; + sameRow = 1; + } + + if (av.conservation != null) + { + for (col = 0; col < width; col++) + { + lastcol = (int) (col * sampleCol); + { + mg.translate(col, sequencesHeight); + ap.annotationPanel.drawGraph(mg, av.conservation, + (int) (sampleCol) + 1, graphHeight, + (int) (col * sampleCol), (int) (col * sampleCol) + 1); + mg.translate(-col, -sequencesHeight); + } + } + } + System.gc(); + + resizing = false; + + setBoxPosition(); + + if (resizeAgain) + { + resizeAgain = false; + updateOverviewImage(); + } + } + + public void setBoxPosition() + { + int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth(); + int fullsizeHeight = (av.alignment.getHeight() + av.alignment + .getHiddenSequences().getSize()) + * av.getCharHeight(); + + int startRes = av.getStartRes(); + int endRes = av.getEndRes(); + + if (av.hasHiddenColumns) + { + startRes = av.getColumnSelection().adjustForHiddenColumns(startRes); + endRes = av.getColumnSelection().adjustForHiddenColumns(endRes); + } + + int startSeq = av.startSeq; + int endSeq = av.endSeq; + + if (av.hasHiddenRows) + { + startSeq = av.alignment.getHiddenSequences().adjustForHiddenSeqs( + startSeq); + + endSeq = av.alignment.getHiddenSequences() + .adjustForHiddenSeqs(endSeq); + + } + + scalew = (float) width / (float) fullsizeWidth; + scaleh = (float) sequencesHeight / (float) fullsizeHeight; + + boxX = (int) (startRes * av.getCharWidth() * scalew); + boxY = (int) (startSeq * av.getCharHeight() * scaleh); + + if (av.hasHiddenColumns) + { + boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); + } + else + { + boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); + } + + boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh); + + repaint(); + } + + public void update(Graphics g) + { + paint(g); + } + + public void paint(Graphics g) + { + Graphics og = offscreen.getGraphics(); + if (miniMe != null) + { + og.drawImage(miniMe, 0, 0, this); + og.setColor(Color.red); + og.drawRect(boxX, boxY, boxWidth, boxHeight); + og.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); + g.drawImage(offscreen, 0, 0, this); + } + } + +} diff --git a/src/jalview/appletgui/PCAPanel.java b/src/jalview/appletgui/PCAPanel.java index ee54478..922941b 100755 --- a/src/jalview/appletgui/PCAPanel.java +++ b/src/jalview/appletgui/PCAPanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -27,14 +26,19 @@ import java.awt.event.*; import jalview.analysis.*; import jalview.datamodel.*; -public class PCAPanel - extends EmbmenuFrame implements Runnable, ActionListener, ItemListener +public class PCAPanel extends EmbmenuFrame implements Runnable, + ActionListener, ItemListener { PCA pca; + int top; + RotatableCanvas rc; + AlignViewport av; + SequenceI[] seqs; + AlignmentView seqstrings; public PCAPanel(AlignViewport av) @@ -42,8 +46,7 @@ public class PCAPanel try { jbInit(); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } @@ -72,7 +75,8 @@ public class PCAPanel { if (sq[i].getWidth() != length) { - System.out.println("Sequences must be equal length for PCA analysis"); + System.out + .println("Sequences must be equal length for PCA analysis"); return; } } @@ -82,7 +86,7 @@ public class PCAPanel add(rc, BorderLayout.CENTER); jalview.bin.JalviewLite.addFrame(this, "Principal component analysis", - 400, 400); + 400, 400); Thread worker = new Thread(this); worker.start(); @@ -99,7 +103,7 @@ public class PCAPanel // Now find the component coordinates int ii = 0; - while ( (ii < seqs.length) && (seqs[ii] != null)) + while ((ii < seqs.length) && (seqs[ii] != null)) { ii++; } @@ -114,7 +118,7 @@ public class PCAPanel } } - ////////////////// + // //////////////// xCombobox.select(0); yCombobox.select(1); zCombobox.select(2); @@ -150,7 +154,7 @@ public class PCAPanel float[][] scores = pca.getComponents(dim1, dim2, dim3, 100); for (int i = 0; i < pca.getM().rows; i++) { - ( (SequencePoint) rc.points.elementAt(i)).coord = scores[i]; + ((SequencePoint) rc.points.elementAt(i)).coord = scores[i]; } rc.img = null; @@ -215,28 +219,31 @@ public class PCAPanel void showOriginalData() { - // decide if av alignment is sufficiently different to original data to warrant a new window to be created - // create new alignmnt window with hidden regions (unhiding hidden regions yields unaligned seqs) + // decide if av alignment is sufficiently different to original data to + // warrant a new window to be created + // create new alignmnt window with hidden regions (unhiding hidden regions + // yields unaligned seqs) // or create a selection box around columns in alignment view // test Alignment(SeqCigar[]) char gc = '-'; - try { + try + { // we try to get the associated view's gap character // but this may fail if the view was closed... - gc = av. - getGapCharacter(); - } catch (Exception ex) {}; + gc = av.getGapCharacter(); + } catch (Exception ex) + { + } + ; Object[] alAndColsel = seqstrings.getAlignmentAndColumnSelection(gc); if (alAndColsel != null && alAndColsel[0] != null) { - Alignment al = new Alignment( (SequenceI[]) alAndColsel[0]); - AlignFrame af = new AlignFrame(al, - av.applet, - "Original Data for PCA", - false); + Alignment al = new Alignment((SequenceI[]) alAndColsel[0]); + AlignFrame af = new AlignFrame(al, av.applet, + "Original Data for PCA", false); - af.viewport.setHiddenColumns( (ColumnSelection) alAndColsel[1]); + af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]); } } @@ -246,23 +253,36 @@ public class PCAPanel } Panel jPanel2 = new Panel(); + Label jLabel1 = new Label(); + Label jLabel2 = new Label(); + Label jLabel3 = new Label(); + protected Choice xCombobox = new Choice(); + protected Choice yCombobox = new Choice(); + protected Choice zCombobox = new Choice(); + FlowLayout flowLayout1 = new FlowLayout(); + BorderLayout borderLayout1 = new BorderLayout(); + MenuBar menuBar1 = new MenuBar(); + Menu menu1 = new Menu(); + Menu menu2 = new Menu(); + protected CheckboxMenuItem labels = new CheckboxMenuItem(); + MenuItem values = new MenuItem(); + MenuItem inputData = new MenuItem(); - private void jbInit() - throws Exception + private void jbInit() throws Exception { this.setLayout(borderLayout1); jPanel2.setLayout(flowLayout1); diff --git a/src/jalview/appletgui/PaintRefresher.java b/src/jalview/appletgui/PaintRefresher.java index 7e0edf7..20edeeb 100755 --- a/src/jalview/appletgui/PaintRefresher.java +++ b/src/jalview/appletgui/PaintRefresher.java @@ -1,228 +1,229 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package jalview.appletgui; - -import java.util.*; - -import java.awt.*; - -import jalview.datamodel.*; - -/** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision$ - */ -public class PaintRefresher -{ - static Hashtable components; - - /** - * DOCUMENT ME! - * - * @param comp DOCUMENT ME! - * @param al DOCUMENT ME! - */ - public static void Register(Component comp, String seqSetId) - { - if (components == null) - { - components = new Hashtable(); - } - - if (components.containsKey(seqSetId)) - { - Vector comps = (Vector) components.get(seqSetId); - if (!comps.contains(comp)) - { - comps.addElement(comp); - } - } - else - { - Vector vcoms = new Vector(); - vcoms.addElement(comp); - components.put(seqSetId, vcoms); - } - } - - public static void RemoveComponent(Component comp) - { - if (components == null) - { - return; - } - - Enumeration en = components.keys(); - while (en.hasMoreElements()) - { - String id = en.nextElement().toString(); - Vector comps = (Vector) components.get(id); - comps.removeElement(comp); - if (comps.size() == 0) - { - components.remove(id); - } - } - } - - public static void Refresh(Component source, String id) - { - Refresh(source, id, false, false); - } - - public static void Refresh(Component source, - String id, - boolean alignmentChanged, - boolean validateSequences) - { - if (components == null) - { - return; - } - - Component comp; - Vector comps = (Vector) components.get(id); - - if (comps == null) - { - return; - } - - Enumeration e = comps.elements(); - while (e.hasMoreElements()) - { - comp = (Component) e.nextElement(); - - if (comp == source) - { - continue; - } - - if (!comp.isValid()) - { - comps.removeElement(comp); - } - else if (validateSequences - && comp instanceof AlignmentPanel - && source instanceof AlignmentPanel) - { - validateSequences( ( (AlignmentPanel) source).av.alignment, - ( (AlignmentPanel) comp).av.alignment); - } - - if (comp instanceof AlignmentPanel && alignmentChanged) - { - ( (AlignmentPanel) comp).alignmentChanged(); - } - - comp.repaint(); - } - } - - static void validateSequences(AlignmentI source, AlignmentI comp) - { - SequenceI[] a1; - if (source.getHiddenSequences().getSize() > 0) - { - a1 = source.getHiddenSequences().getFullAlignment().getSequencesArray(); - } - else - { - a1 = source.getSequencesArray(); - } - - SequenceI[] a2; - if (comp.getHiddenSequences().getSize() > 0) - { - a2 = comp.getHiddenSequences().getFullAlignment().getSequencesArray(); - } - else - { - a2 = comp.getSequencesArray(); - } - - int i, iSize = a1.length, j, jSize = a2.length; - - if (iSize == jSize) - { - return; - } - - boolean 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()) - { - comp.getSequences().insertElementAt(a1[i], 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 - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.util.*; + +import java.awt.*; + +import jalview.datamodel.*; + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class PaintRefresher +{ + static Hashtable components; + + /** + * DOCUMENT ME! + * + * @param comp + * DOCUMENT ME! + * @param al + * DOCUMENT ME! + */ + public static void Register(Component comp, String seqSetId) + { + if (components == null) + { + components = new Hashtable(); + } + + if (components.containsKey(seqSetId)) + { + Vector comps = (Vector) components.get(seqSetId); + if (!comps.contains(comp)) + { + comps.addElement(comp); + } + } + else + { + Vector vcoms = new Vector(); + vcoms.addElement(comp); + components.put(seqSetId, vcoms); + } + } + + public static void RemoveComponent(Component comp) + { + if (components == null) + { + return; + } + + Enumeration en = components.keys(); + while (en.hasMoreElements()) + { + String id = en.nextElement().toString(); + Vector comps = (Vector) components.get(id); + comps.removeElement(comp); + if (comps.size() == 0) + { + components.remove(id); + } + } + } + + public static void Refresh(Component source, String id) + { + Refresh(source, id, false, false); + } + + public static void Refresh(Component source, String id, + boolean alignmentChanged, boolean validateSequences) + { + if (components == null) + { + return; + } + + Component comp; + Vector comps = (Vector) components.get(id); + + if (comps == null) + { + return; + } + + Enumeration e = comps.elements(); + while (e.hasMoreElements()) + { + comp = (Component) e.nextElement(); + + if (comp == source) + { + continue; + } + + if (!comp.isValid()) + { + comps.removeElement(comp); + } + else if (validateSequences && comp instanceof AlignmentPanel + && source instanceof AlignmentPanel) + { + validateSequences(((AlignmentPanel) source).av.alignment, + ((AlignmentPanel) comp).av.alignment); + } + + if (comp instanceof AlignmentPanel && alignmentChanged) + { + ((AlignmentPanel) comp).alignmentChanged(); + } + + comp.repaint(); + } + } + + static void validateSequences(AlignmentI source, AlignmentI comp) + { + SequenceI[] a1; + if (source.getHiddenSequences().getSize() > 0) + { + a1 = source.getHiddenSequences().getFullAlignment() + .getSequencesArray(); + } + else + { + a1 = source.getSequencesArray(); + } + + SequenceI[] a2; + if (comp.getHiddenSequences().getSize() > 0) + { + a2 = comp.getHiddenSequences().getFullAlignment().getSequencesArray(); + } + else + { + a2 = comp.getSequencesArray(); + } + + int i, iSize = a1.length, j, jSize = a2.length; + + if (iSize == jSize) + { + return; + } + + boolean 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()) + { + comp.getSequences().insertElementAt(a1[i], 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]); + } + } + } +} diff --git a/src/jalview/appletgui/PairwiseAlignPanel.java b/src/jalview/appletgui/PairwiseAlignPanel.java index 05372a4..c122b3f 100755 --- a/src/jalview/appletgui/PairwiseAlignPanel.java +++ b/src/jalview/appletgui/PairwiseAlignPanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -27,10 +26,10 @@ import java.awt.event.*; import jalview.analysis.*; import jalview.datamodel.*; -public class PairwiseAlignPanel - extends Panel implements ActionListener +public class PairwiseAlignPanel extends Panel implements ActionListener { Vector sequences = new Vector(); + AlignmentPanel ap; public PairwiseAlignPanel(AlignmentPanel ap) @@ -38,8 +37,7 @@ public class PairwiseAlignPanel try { jbInit(); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } @@ -61,8 +59,8 @@ public class PairwiseAlignPanel float scores[][] = new float[seqs.length][seqs.length]; double totscore = 0; int count = ap.av.getSelectionGroup().getSize(); - String type = (ap.av.alignment.isNucleotide()) ? AlignSeq.DNA : - AlignSeq.PEP; + String type = (ap.av.alignment.isNucleotide()) ? AlignSeq.DNA + : AlignSeq.PEP; Sequence seq; for (int i = 1; i < count; i++) @@ -70,8 +68,8 @@ public class PairwiseAlignPanel for (int j = 0; j < i; j++) { - AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], - seqs[j], seqStrings[j], type); + AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j], + seqStrings[j], type); if (as.s1str.length() == 0 || as.s2str.length() == 0) { @@ -82,35 +80,30 @@ public class PairwiseAlignPanel as.traceAlignment(); as.printAlignment(System.out); - scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length; + scores[i][j] = (float) as.getMaxScore() + / (float) as.getASeq1().length; totscore = totscore + scores[i][j]; textarea.append(as.getOutput()); - seq = new Sequence(as.getS1().getName(), - as.getAStr1(), - as.getS1().getStart(), - as.getS1().getEnd() - ); + seq = new Sequence(as.getS1().getName(), as.getAStr1(), as.getS1() + .getStart(), as.getS1().getEnd()); sequences.addElement(seq); - seq = new Sequence(as.getS2().getName(), - as.getAStr2(), - as.getS2().getStart(), - as.getS2().getEnd()); + seq = new Sequence(as.getS2().getName(), as.getAStr2(), as.getS2() + .getStart(), as.getS2().getEnd()); sequences.addElement(seq); } } if (count > 2) { - System.out.println( - "Pairwise alignment scaled similarity score matrix\n"); + System.out + .println("Pairwise alignment scaled similarity score matrix\n"); for (int i = 0; i < count; i++) { - jalview.util.Format.print(System.out, "%s \n", - ("" + i) + " " + - seqs[i].getName()); + jalview.util.Format.print(System.out, "%s \n", ("" + i) + " " + + seqs[i].getName()); } System.out.println("\n"); @@ -119,8 +112,8 @@ public class PairwiseAlignPanel { for (int j = 0; j < i; j++) { - jalview.util.Format.print(System.out, "%7.3f", - scores[i][j] / totscore); + jalview.util.Format.print(System.out, "%7.3f", scores[i][j] + / totscore); } } @@ -146,21 +139,22 @@ public class PairwiseAlignPanel seq[i] = (Sequence) sequences.elementAt(i); } - new AlignFrame(new Alignment(seq), - ap.av.applet, - "Pairwise Aligned Sequences", - false); + new AlignFrame(new Alignment(seq), ap.av.applet, + "Pairwise Aligned Sequences", false); } protected ScrollPane scrollPane = new ScrollPane(); + protected TextArea textarea = new TextArea(); + protected Button viewInEditorButton = new Button(); + Panel jPanel1 = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); - private void jbInit() - throws Exception + private void jbInit() throws Exception { this.setLayout(borderLayout1); textarea.setFont(new java.awt.Font("Monospaced", 0, 12)); diff --git a/src/jalview/appletgui/RedundancyPanel.java b/src/jalview/appletgui/RedundancyPanel.java index 9881b64..9682000 100755 --- a/src/jalview/appletgui/RedundancyPanel.java +++ b/src/jalview/appletgui/RedundancyPanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -27,15 +26,19 @@ import java.awt.event.*; import jalview.commands.*; import jalview.datamodel.*; -public class RedundancyPanel - extends SliderPanel implements Runnable, WindowListener +public class RedundancyPanel extends SliderPanel implements Runnable, + WindowListener { AlignmentPanel ap; Stack historyList = new Stack(); // simpler than synching with alignFrame. + float[] redundancy; + SequenceI[] originalSequences; + Frame frame; + Vector redundantSeqs; public RedundancyPanel(AlignmentPanel ap) @@ -67,8 +70,8 @@ public class RedundancyPanel frame = new Frame(); frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "Redundancy threshold selection", - 400, 100); + jalview.bin.JalviewLite.addFrame(frame, + "Redundancy threshold selection", 400, 100); frame.addWindowListener(this); @@ -77,13 +80,15 @@ public class RedundancyPanel } /** - * This is a copy of remove redundancy in jalivew.datamodel.Alignment - * except we dont want to remove redundancy, just calculate once - * so we can use the slider to dynamically hide redundant sequences - * - * @param threshold DOCUMENT ME! - * @param sel DOCUMENT ME! - * + * This is a copy of remove redundancy in jalivew.datamodel.Alignment except + * we dont want to remove redundancy, just calculate once so we can use the + * slider to dynamically hide redundant sequences + * + * @param threshold + * DOCUMENT ME! + * @param sel + * DOCUMENT ME! + * * @return DOCUMENT ME! */ public void run() @@ -103,7 +108,7 @@ public class RedundancyPanel int start, end; - if ( (sg != null) && (sg.getSize() >= 1)) + if ((sg != null) && (sg.getSize() >= 1)) { originalSequences = sg.getSequencesInOrder(ap.av.alignment); start = sg.getStartRes(); @@ -124,9 +129,9 @@ public class RedundancyPanel redundancy[i] = 0f; } - // if (ap.av.hasHiddenColumns) + // if (ap.av.hasHiddenColumns) { - // omitHidden = ap.av.getSelectionAsString(); + // omitHidden = ap.av.getSelectionAsString(); } // long start = System.currentTimeMillis(); @@ -198,10 +203,7 @@ public class RedundancyPanel } ap.idPanel.idCanvas.setHighlighted(redundantSeqs); - PaintRefresher.Refresh(this, - ap.av.getSequenceSetId(), - true, - true); + PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true); } @@ -222,7 +224,8 @@ public class RedundancyPanel } } - // This has to be done before the restoreHistoryItem method of alignFrame will + // This has to be done before the restoreHistoryItem method of alignFrame + // will // actually restore these sequences. if (del.size() > 0) { @@ -239,16 +242,12 @@ public class RedundancyPanel } EditCommand cut = new EditCommand("Remove Redundancy", - EditCommand.CUT, deleted, 0, width, - ap.av.alignment); + EditCommand.CUT, deleted, 0, width, ap.av.alignment); for (int i = 0; i < del.size(); i++) { ap.av.alignment.deleteSequence(deleted[i]); - PaintRefresher.Refresh(this, - ap.av.getSequenceSetId(), - true, - true); + PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true); if (sg != null) { sg.deleteSequence(deleted[i], false); @@ -259,8 +258,8 @@ public class RedundancyPanel ap.alignFrame.addHistoryItem(cut); - ap.av.firePropertyChange("alignment", null, - ap.av.getAlignment().getSequences()); + ap.av.firePropertyChange("alignment", null, ap.av.getAlignment() + .getSequences()); } } @@ -290,15 +289,15 @@ public class RedundancyPanel { int i = Integer.parseInt(valueField.getText()); slider.setValue(i); - } - catch (Exception ex) + } catch (Exception ex) { valueField.setText(slider.getValue() + ""); } } public void windowOpened(WindowEvent evt) - {} + { + } public void windowClosing(WindowEvent evt) { @@ -306,17 +305,22 @@ public class RedundancyPanel } public void windowClosed(WindowEvent evt) - {} + { + } public void windowActivated(WindowEvent evt) - {} + { + } public void windowDeactivated(WindowEvent evt) - {} + { + } public void windowIconified(WindowEvent evt) - {} + { + } public void windowDeiconified(WindowEvent evt) - {} + { + } } diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index a2463e8..4f54670 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -1,622 +1,641 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; -import jalview.math.*; -import jalview.util.*; - -public class RotatableCanvas - extends Panel implements MouseListener, - MouseMotionListener, - KeyListener -{ - RotatableMatrix idmat = new RotatableMatrix(3, 3); - RotatableMatrix objmat = new RotatableMatrix(3, 3); - RotatableMatrix rotmat = new RotatableMatrix(3, 3); - String tooltip; - int toolx, tooly; - - //RubberbandRectangle rubberband; - - boolean drawAxes = true; - - int omx = 0; - int mx = 0; - int omy = 0; - int my = 0; - - Image img; - Graphics ig; - - Dimension prefsize; - - float centre[] = new float[3]; - float width[] = new float[3]; - - float max[] = new float[3]; - float min[] = new float[3]; - - float maxwidth; - float scale; - - int npoint; - - Vector points; - float[][] orig; - float[][] axes; - - int startx; - int starty; - - int lastx; - int lasty; - - int rectx1; - int recty1; - int rectx2; - int recty2; - - float scalefactor = 1; - - AlignViewport av; - boolean showLabels = false; - - public RotatableCanvas(AlignViewport av) - { - this.av = av; - } - - public void showLabels(boolean b) - { - showLabels = b; - repaint(); - } - - public void setPoints(Vector points, int npoint) - { - this.points = points; - this.npoint = npoint; - PaintRefresher.Register(this, av.getSequenceSetId()); - - prefsize = getPreferredSize(); - orig = new float[npoint][3]; - - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - for (int j = 0; j < 3; j++) - { - orig[i][j] = sp.coord[j]; - } - } - //Initialize the matrices to identity - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - if (i != j) - { - idmat.addElement(i, j, 0); - objmat.addElement(i, j, 0); - rotmat.addElement(i, j, 0); - } - else - { - idmat.addElement(i, j, 0); - objmat.addElement(i, j, 0); - rotmat.addElement(i, j, 0); - } - } - } - - axes = new float[3][3]; - initAxes(); - - findCentre(); - findWidth(); - - scale = findScale(); - - // System.out.println("Scale factor = " + scale); - - addMouseListener(this); - addKeyListener(this); - // if (getParent() != null) { - // getParent().addKeyListener(this); - //} - addMouseMotionListener(this); - - // Add rubberband - // rubberband = new RubberbandRectangle(this); - // rubberband.setActive(true); - // rubberband.addListener(this); - } - - /* public boolean handleSequenceSelectionEvent(SequenceSelectionEvent evt) { - redrawneeded = true; - repaint(); - return true; - } - - public void removeNotify() { - controller.removeListener(this); - super.removeNotify(); - }*/ - - public void initAxes() - { - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - if (i != j) - { - axes[i][j] = 0; - } - else - { - axes[i][j] = 1; - } - } - } - } - - public void findWidth() - { - max = new float[3]; - min = new float[3]; - - max[0] = (float) - 1e30; - max[1] = (float) - 1e30; - max[2] = (float) - 1e30; - - min[0] = (float) 1e30; - min[1] = (float) 1e30; - min[2] = (float) 1e30; - - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < npoint; j++) - { - SequencePoint sp = (SequencePoint) points.elementAt(j); - if (sp.coord[i] >= max[i]) - { - max[i] = sp.coord[i]; - } - if (sp.coord[i] <= min[i]) - { - min[i] = sp.coord[i]; - } - } - } - - // System.out.println("xmax " + max[0] + " min " + min[0]); - //System.out.println("ymax " + max[1] + " min " + min[1]); - //System.out.println("zmax " + max[2] + " min " + min[2]); - - width[0] = Math.abs(max[0] - min[0]); - width[1] = Math.abs(max[1] - min[1]); - width[2] = Math.abs(max[2] - min[2]); - - maxwidth = width[0]; - - if (width[1] > width[0]) - { - maxwidth = width[1]; - } - if (width[2] > width[1]) - { - maxwidth = width[2]; - } - - //System.out.println("Maxwidth = " + maxwidth); - } - - public float findScale() - { - int dim, width, height; - if (getSize().width != 0) - { - width = getSize().width; - height = getSize().height; - } - else - { - width = prefsize.width; - height = prefsize.height; - } - - if (width < height) - { - dim = width; - } - else - { - dim = height; - } - - return (float) (dim * scalefactor / (2 * maxwidth)); - } - - public void findCentre() - { - //Find centre coordinate - findWidth(); - - centre[0] = (max[0] + min[0]) / 2; - centre[1] = (max[1] + min[1]) / 2; - centre[2] = (max[2] + min[2]) / 2; - - // System.out.println("Centre x " + centre[0]); - //System.out.println("Centre y " + centre[1]); - //System.out.println("Centre z " + centre[2]); - } - - public Dimension getPreferredSize() - { - if (prefsize != null) - { - return prefsize; - } - else - { - return new Dimension(400, 400); - } - } - - public Dimension getMinimumSize() - { - return getPreferredSize(); - } - - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - if (points == null) - { - g.setFont(new Font("Verdana", Font.PLAIN, 18)); - g.drawString("Calculating PCA....", 20, getSize().height / 2); - } - else - { - - //Only create the image at the beginning - - if ( (img == null) || (prefsize.width != getSize().width) || - (prefsize.height != getSize().height)) - { - prefsize.width = getSize().width; - prefsize.height = getSize().height; - - scale = findScale(); - - // System.out.println("New scale = " + scale); - img = createImage(getSize().width, getSize().height); - ig = img.getGraphics(); - - } - - drawBackground(ig, Color.black); - drawScene(ig); - if (drawAxes == true) - { - drawAxes(ig); - } - - if (tooltip != null) - { - ig.setColor(Color.red); - ig.drawString(tooltip, toolx, tooly); - } - - g.drawImage(img, 0, 0, this); - } - } - - public void drawAxes(Graphics g) - { - - g.setColor(Color.yellow); - for (int i = 0; i < 3; i++) - { - g.drawLine(getSize().width / 2, getSize().height / 2, - (int) (axes[i][0] * scale * max[0] + getSize().width / 2), - (int) (axes[i][1] * scale * max[1] + getSize().height / 2)); - } - } - - public void drawBackground(Graphics g, Color col) - { - g.setColor(col); - g.fillRect(0, 0, prefsize.width, prefsize.height); - } - - public void drawScene(Graphics g) - { - //boolean darker = false; - - int halfwidth = getSize().width / 2; - int halfheight = getSize().height / 2; - - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - int x = (int) ( (float) (sp.coord[0] - centre[0]) * scale) + halfwidth; - int y = (int) ( (float) (sp.coord[1] - centre[1]) * scale) + halfheight; - float z = sp.coord[1] - centre[2]; - - if (av.getSequenceColour(sp.sequence) == Color.black) - { - g.setColor(Color.white); - } - else - { - g.setColor(av.getSequenceColour(sp.sequence)); - } - - if (av.getSelectionGroup() != null) - { - if (av.getSelectionGroup().getSequences(null).contains( ( ( - SequencePoint) points. - elementAt(i)).sequence)) - { - g.setColor(Color.gray); - } - } - if (z < 0) - { - g.setColor(g.getColor().darker()); - } - - g.fillRect(x - 3, y - 3, 6, 6); - if (showLabels) - { - g.setColor(Color.red); - g.drawString( ( (SequencePoint) points.elementAt(i)).sequence. - getName(), - x - 3, y - 4); - } - } - } - - public Dimension minimumsize() - { - return prefsize; - } - - public Dimension preferredsize() - { - return prefsize; - } - - public void keyTyped(KeyEvent evt) - {} - - public void keyReleased(KeyEvent evt) - {} - - public void keyPressed(KeyEvent evt) - { - if (evt.getKeyCode() == KeyEvent.VK_UP) - { - scalefactor = (float) (scalefactor * 1.1); - scale = findScale(); - } - else if (evt.getKeyCode() == KeyEvent.VK_DOWN) - { - scalefactor = (float) (scalefactor * 0.9); - scale = findScale(); - } - else if (evt.getKeyChar() == 's') - { - System.err.println("DEBUG: Rectangle selection"); // log.debug - if (rectx2 != -1 && recty2 != -1) - { - rectSelect(rectx1, recty1, rectx2, recty2); - - } - } - repaint(); - } - - public void printPoints() - { - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - Format.print(System.out, "%5d ", i); - for (int j = 0; j < 3; j++) - { - Format.print(System.out, "%13.3f ", sp.coord[j]); - } - System.out.println(); - } - } - - public void mouseClicked(MouseEvent evt) - {} - - public void mouseEntered(MouseEvent evt) - {} - - public void mouseExited(MouseEvent evt) - {} - - public void mouseReleased(MouseEvent evt) - {} - - public void mousePressed(MouseEvent evt) - { - int x = evt.getX(); - int y = evt.getY(); - - mx = x; - my = y; - - omx = mx; - omy = my; - - startx = x; - starty = y; - - rectx1 = x; - recty1 = y; - - rectx2 = -1; - recty2 = -1; - - SequenceI found = findPoint(x, y); - - if (found != null) - { - if (av.getSelectionGroup() != null) - { - av.getSelectionGroup().addOrRemove(found, true); - av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); - PaintRefresher.Refresh(this, av.getSequenceSetId()); - } - else - { - av.setSelectionGroup(new SequenceGroup()); - av.getSelectionGroup().addOrRemove(found, true); - av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); - - } - } - repaint(); - } - - public void mouseMoved(MouseEvent evt) - { - SequenceI found = findPoint(evt.getX(), evt.getY()); - if (found == null) - { - tooltip = null; - } - else - { - tooltip = found.getName(); - toolx = evt.getX(); - tooly = evt.getY(); - } - repaint(); - } - - public void mouseDragged(MouseEvent evt) - { - mx = evt.getX(); - my = evt.getY(); - - rotmat.setIdentity(); - - rotmat.rotate( (float) (my - omy), 'x'); - rotmat.rotate( (float) (mx - omx), 'y'); - - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - sp.coord[0] -= centre[0]; - sp.coord[1] -= centre[1]; - sp.coord[2] -= centre[2]; - - //Now apply the rotation matrix - sp.coord = rotmat.vectorMultiply(sp.coord); - - //Now translate back again - sp.coord[0] += centre[0]; - sp.coord[1] += centre[1]; - sp.coord[2] += centre[2]; - } - - for (int i = 0; i < 3; i++) - { - axes[i] = rotmat.vectorMultiply(axes[i]); - } - omx = mx; - omy = my; - - paint(this.getGraphics()); - } - - public void rectSelect(int x1, int y1, int x2, int y2) - { - //boolean changedSel = false; - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - int tmp1 = (int) ( (sp.coord[0] - centre[0]) * scale + - (float) getSize().width / 2.0); - int tmp2 = (int) ( (sp.coord[1] - centre[1]) * scale + - (float) getSize().height / 2.0); - - if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) - { - if (av != null) - { - if (!av.getSelectionGroup().getSequences(null).contains(sp.sequence)) - { - av.getSelectionGroup().addSequence(sp.sequence, true); - } - } - } - } - } - - public SequenceI findPoint(int x, int y) - { - - int halfwidth = getSize().width / 2; - int halfheight = getSize().height / 2; - - int found = -1; - - for (int i = 0; i < npoint; i++) - { - - SequencePoint sp = (SequencePoint) points.elementAt(i); - int px = (int) ( (float) (sp.coord[0] - centre[0]) * scale) + halfwidth; - int py = (int) ( (float) (sp.coord[1] - centre[1]) * scale) + halfheight; - - if (Math.abs(px - x) < 3 && Math.abs(py - y) < 3) - { - found = i; - } - } - if (found != -1) - { - return ( (SequencePoint) points.elementAt(found)).sequence; - } - else - { - return null; - } - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.util.*; + +import java.awt.*; +import java.awt.event.*; + +import jalview.datamodel.*; +import jalview.math.*; +import jalview.util.*; + +public class RotatableCanvas extends Panel implements MouseListener, + MouseMotionListener, KeyListener +{ + RotatableMatrix idmat = new RotatableMatrix(3, 3); + + RotatableMatrix objmat = new RotatableMatrix(3, 3); + + RotatableMatrix rotmat = new RotatableMatrix(3, 3); + + String tooltip; + + int toolx, tooly; + + // RubberbandRectangle rubberband; + + boolean drawAxes = true; + + int omx = 0; + + int mx = 0; + + int omy = 0; + + int my = 0; + + Image img; + + Graphics ig; + + Dimension prefsize; + + float centre[] = new float[3]; + + float width[] = new float[3]; + + float max[] = new float[3]; + + float min[] = new float[3]; + + float maxwidth; + + float scale; + + int npoint; + + Vector points; + + float[][] orig; + + float[][] axes; + + int startx; + + int starty; + + int lastx; + + int lasty; + + int rectx1; + + int recty1; + + int rectx2; + + int recty2; + + float scalefactor = 1; + + AlignViewport av; + + boolean showLabels = false; + + public RotatableCanvas(AlignViewport av) + { + this.av = av; + } + + public void showLabels(boolean b) + { + showLabels = b; + repaint(); + } + + public void setPoints(Vector points, int npoint) + { + this.points = points; + this.npoint = npoint; + PaintRefresher.Register(this, av.getSequenceSetId()); + + prefsize = getPreferredSize(); + orig = new float[npoint][3]; + + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + for (int j = 0; j < 3; j++) + { + orig[i][j] = sp.coord[j]; + } + } + // Initialize the matrices to identity + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + if (i != j) + { + idmat.addElement(i, j, 0); + objmat.addElement(i, j, 0); + rotmat.addElement(i, j, 0); + } + else + { + idmat.addElement(i, j, 0); + objmat.addElement(i, j, 0); + rotmat.addElement(i, j, 0); + } + } + } + + axes = new float[3][3]; + initAxes(); + + findCentre(); + findWidth(); + + scale = findScale(); + + // System.out.println("Scale factor = " + scale); + + addMouseListener(this); + addKeyListener(this); + // if (getParent() != null) { + // getParent().addKeyListener(this); + // } + addMouseMotionListener(this); + + // Add rubberband + // rubberband = new RubberbandRectangle(this); + // rubberband.setActive(true); + // rubberband.addListener(this); + } + + /* + * public boolean handleSequenceSelectionEvent(SequenceSelectionEvent evt) { + * redrawneeded = true; repaint(); return true; } + * + * public void removeNotify() { controller.removeListener(this); + * super.removeNotify(); } + */ + + public void initAxes() + { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + if (i != j) + { + axes[i][j] = 0; + } + else + { + axes[i][j] = 1; + } + } + } + } + + public void findWidth() + { + max = new float[3]; + min = new float[3]; + + max[0] = (float) -1e30; + max[1] = (float) -1e30; + max[2] = (float) -1e30; + + min[0] = (float) 1e30; + min[1] = (float) 1e30; + min[2] = (float) 1e30; + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < npoint; j++) + { + SequencePoint sp = (SequencePoint) points.elementAt(j); + if (sp.coord[i] >= max[i]) + { + max[i] = sp.coord[i]; + } + if (sp.coord[i] <= min[i]) + { + min[i] = sp.coord[i]; + } + } + } + + // System.out.println("xmax " + max[0] + " min " + min[0]); + // System.out.println("ymax " + max[1] + " min " + min[1]); + // System.out.println("zmax " + max[2] + " min " + min[2]); + + width[0] = Math.abs(max[0] - min[0]); + width[1] = Math.abs(max[1] - min[1]); + width[2] = Math.abs(max[2] - min[2]); + + maxwidth = width[0]; + + if (width[1] > width[0]) + { + maxwidth = width[1]; + } + if (width[2] > width[1]) + { + maxwidth = width[2]; + } + + // System.out.println("Maxwidth = " + maxwidth); + } + + public float findScale() + { + int dim, width, height; + if (getSize().width != 0) + { + width = getSize().width; + height = getSize().height; + } + else + { + width = prefsize.width; + height = prefsize.height; + } + + if (width < height) + { + dim = width; + } + else + { + dim = height; + } + + return (float) (dim * scalefactor / (2 * maxwidth)); + } + + public void findCentre() + { + // Find centre coordinate + findWidth(); + + centre[0] = (max[0] + min[0]) / 2; + centre[1] = (max[1] + min[1]) / 2; + centre[2] = (max[2] + min[2]) / 2; + + // System.out.println("Centre x " + centre[0]); + // System.out.println("Centre y " + centre[1]); + // System.out.println("Centre z " + centre[2]); + } + + public Dimension getPreferredSize() + { + if (prefsize != null) + { + return prefsize; + } + else + { + return new Dimension(400, 400); + } + } + + public Dimension getMinimumSize() + { + return getPreferredSize(); + } + + public void update(Graphics g) + { + paint(g); + } + + public void paint(Graphics g) + { + if (points == null) + { + g.setFont(new Font("Verdana", Font.PLAIN, 18)); + g.drawString("Calculating PCA....", 20, getSize().height / 2); + } + else + { + + // Only create the image at the beginning - + if ((img == null) || (prefsize.width != getSize().width) + || (prefsize.height != getSize().height)) + { + prefsize.width = getSize().width; + prefsize.height = getSize().height; + + scale = findScale(); + + // System.out.println("New scale = " + scale); + img = createImage(getSize().width, getSize().height); + ig = img.getGraphics(); + + } + + drawBackground(ig, Color.black); + drawScene(ig); + if (drawAxes == true) + { + drawAxes(ig); + } + + if (tooltip != null) + { + ig.setColor(Color.red); + ig.drawString(tooltip, toolx, tooly); + } + + g.drawImage(img, 0, 0, this); + } + } + + public void drawAxes(Graphics g) + { + + g.setColor(Color.yellow); + for (int i = 0; i < 3; i++) + { + g.drawLine(getSize().width / 2, getSize().height / 2, + (int) (axes[i][0] * scale * max[0] + getSize().width / 2), + (int) (axes[i][1] * scale * max[1] + getSize().height / 2)); + } + } + + public void drawBackground(Graphics g, Color col) + { + g.setColor(col); + g.fillRect(0, 0, prefsize.width, prefsize.height); + } + + public void drawScene(Graphics g) + { + // boolean darker = false; + + int halfwidth = getSize().width / 2; + int halfheight = getSize().height / 2; + + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + int x = (int) ((float) (sp.coord[0] - centre[0]) * scale) + halfwidth; + int y = (int) ((float) (sp.coord[1] - centre[1]) * scale) + + halfheight; + float z = sp.coord[1] - centre[2]; + + if (av.getSequenceColour(sp.sequence) == Color.black) + { + g.setColor(Color.white); + } + else + { + g.setColor(av.getSequenceColour(sp.sequence)); + } + + if (av.getSelectionGroup() != null) + { + if (av.getSelectionGroup().getSequences(null).contains( + ((SequencePoint) points.elementAt(i)).sequence)) + { + g.setColor(Color.gray); + } + } + if (z < 0) + { + g.setColor(g.getColor().darker()); + } + + g.fillRect(x - 3, y - 3, 6, 6); + if (showLabels) + { + g.setColor(Color.red); + g.drawString(((SequencePoint) points.elementAt(i)).sequence + .getName(), x - 3, y - 4); + } + } + } + + public Dimension minimumsize() + { + return prefsize; + } + + public Dimension preferredsize() + { + return prefsize; + } + + public void keyTyped(KeyEvent evt) + { + } + + public void keyReleased(KeyEvent evt) + { + } + + public void keyPressed(KeyEvent evt) + { + if (evt.getKeyCode() == KeyEvent.VK_UP) + { + scalefactor = (float) (scalefactor * 1.1); + scale = findScale(); + } + else if (evt.getKeyCode() == KeyEvent.VK_DOWN) + { + scalefactor = (float) (scalefactor * 0.9); + scale = findScale(); + } + else if (evt.getKeyChar() == 's') + { + System.err.println("DEBUG: Rectangle selection"); // log.debug + if (rectx2 != -1 && recty2 != -1) + { + rectSelect(rectx1, recty1, rectx2, recty2); + + } + } + repaint(); + } + + public void printPoints() + { + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + Format.print(System.out, "%5d ", i); + for (int j = 0; j < 3; j++) + { + Format.print(System.out, "%13.3f ", sp.coord[j]); + } + System.out.println(); + } + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mouseReleased(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + int x = evt.getX(); + int y = evt.getY(); + + mx = x; + my = y; + + omx = mx; + omy = my; + + startx = x; + starty = y; + + rectx1 = x; + recty1 = y; + + rectx2 = -1; + recty2 = -1; + + SequenceI found = findPoint(x, y); + + if (found != null) + { + if (av.getSelectionGroup() != null) + { + av.getSelectionGroup().addOrRemove(found, true); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); + PaintRefresher.Refresh(this, av.getSequenceSetId()); + } + else + { + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().addOrRemove(found, true); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); + + } + } + repaint(); + } + + public void mouseMoved(MouseEvent evt) + { + SequenceI found = findPoint(evt.getX(), evt.getY()); + if (found == null) + { + tooltip = null; + } + else + { + tooltip = found.getName(); + toolx = evt.getX(); + tooly = evt.getY(); + } + repaint(); + } + + public void mouseDragged(MouseEvent evt) + { + mx = evt.getX(); + my = evt.getY(); + + rotmat.setIdentity(); + + rotmat.rotate((float) (my - omy), 'x'); + rotmat.rotate((float) (mx - omx), 'y'); + + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + sp.coord[0] -= centre[0]; + sp.coord[1] -= centre[1]; + sp.coord[2] -= centre[2]; + + // Now apply the rotation matrix + sp.coord = rotmat.vectorMultiply(sp.coord); + + // Now translate back again + sp.coord[0] += centre[0]; + sp.coord[1] += centre[1]; + sp.coord[2] += centre[2]; + } + + for (int i = 0; i < 3; i++) + { + axes[i] = rotmat.vectorMultiply(axes[i]); + } + omx = mx; + omy = my; + + paint(this.getGraphics()); + } + + public void rectSelect(int x1, int y1, int x2, int y2) + { + // boolean changedSel = false; + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + int tmp1 = (int) ((sp.coord[0] - centre[0]) * scale + (float) getSize().width / 2.0); + int tmp2 = (int) ((sp.coord[1] - centre[1]) * scale + (float) getSize().height / 2.0); + + if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) + { + if (av != null) + { + if (!av.getSelectionGroup().getSequences(null).contains( + sp.sequence)) + { + av.getSelectionGroup().addSequence(sp.sequence, true); + } + } + } + } + } + + public SequenceI findPoint(int x, int y) + { + + int halfwidth = getSize().width / 2; + int halfheight = getSize().height / 2; + + int found = -1; + + for (int i = 0; i < npoint; i++) + { + + SequencePoint sp = (SequencePoint) points.elementAt(i); + int px = (int) ((float) (sp.coord[0] - centre[0]) * scale) + + halfwidth; + int py = (int) ((float) (sp.coord[1] - centre[1]) * scale) + + halfheight; + + if (Math.abs(px - x) < 3 && Math.abs(py - y) < 3) + { + found = i; + } + } + if (found != -1) + { + return ((SequencePoint) points.elementAt(found)).sequence; + } + else + { + return null; + } + } + +} diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index a1d0bf7..431bc66 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -1,453 +1,457 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; - -public class ScalePanel - extends Panel implements MouseMotionListener, MouseListener -{ - - protected int offy = 4; - public int width; - - protected AlignViewport av; - AlignmentPanel ap; - - boolean stretchingGroup = false; - int min; //used by mouseDragged to see if user - int max; //used by mouseDragged to see if user - boolean mouseDragging = false; - int[] reveal; - - public ScalePanel(AlignViewport av, AlignmentPanel ap) - { - setLayout(null); - this.av = av; - this.ap = ap; - - addMouseListener(this); - addMouseMotionListener(this); - - } - - public void mousePressed(MouseEvent evt) - { - int x = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - final int res; - - if (av.hasHiddenColumns) - { - res = av.getColumnSelection().adjustForHiddenColumns(x); - } - else - { - res = x; - } - - min = res; - max = res; - if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) - == InputEvent.BUTTON3_MASK) - { - PopupMenu pop = new PopupMenu(); - if (reveal != null) - { - MenuItem item = new MenuItem("Reveal"); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - av.showColumn(reveal[0]); - reveal = null; - ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } - } - }); - pop.add(item); - - if (av.getColumnSelection().getHiddenColumns().size() > 1) - { - item = new MenuItem("Reveal All"); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - av.showAllHiddenColumns(); - reveal = null; - ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } - } - }); - pop.add(item); - } - this.add(pop); - pop.show(this, evt.getX(), evt.getY()); - } - else if (av.getColumnSelection().contains(res)) - { - MenuItem item = new MenuItem("Hide Columns"); - item.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - av.hideColumns(res, res); - if (av.getSelectionGroup() != null - && - av.getSelectionGroup().getSize() == av.alignment.getHeight()) - { - av.setSelectionGroup(null); - } - - ap.paintAlignment(true); - if (ap.overviewPanel != null) - { - ap.overviewPanel.updateOverviewImage(); - } - } - }); - pop.add(item); - this.add(pop); - pop.show(this, evt.getX(), evt.getY()); - } - } - else // LEFT MOUSE TO SELECT - { - if (!evt.isControlDown() && !evt.isShiftDown()) - { - av.getColumnSelection().clear(); - } - - av.getColumnSelection().addElement(res); - SequenceGroup sg = new SequenceGroup(); - for (int i = 0; i < av.alignment.getSequences().size(); i++) - { - sg.addSequence(av.alignment.getSequenceAt(i), false); - } - - sg.setStartRes(res); - sg.setEndRes(res); - av.setSelectionGroup(sg); - - if (evt.isShiftDown()) - { - int min = Math.min(av.getColumnSelection().getMin(), res); - int max = Math.max(av.getColumnSelection().getMax(), res); - for (int i = min; i < max; i++) - { - av.getColumnSelection().addElement(i); - } - sg.setStartRes(min); - sg.setEndRes(max); - } - } - - ap.paintAlignment(true); - } - - public void mouseReleased(MouseEvent evt) - { - mouseDragging = false; - - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - - if (res > av.alignment.getWidth()) - { - res = av.alignment.getWidth() - 1; - } - - if (av.hasHiddenColumns) - { - res = av.getColumnSelection().adjustForHiddenColumns(res); - } - - if (!stretchingGroup) - { - ap.paintAlignment(false); - - return; - } - - SequenceGroup sg = av.getSelectionGroup(); - - if (res > sg.getStartRes()) - { - sg.setEndRes(res); - } - else if (res < sg.getStartRes()) - { - sg.setStartRes(res); - } - - stretchingGroup = false; - ap.paintAlignment(false); - } - - public void mouseDragged(MouseEvent evt) - { - mouseDragging = true; - - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - if (res < 0) - { - res = 0; - } - - if (av.hasHiddenColumns) - { - res = av.getColumnSelection().adjustForHiddenColumns(res); - } - - if (res > av.alignment.getWidth()) - { - res = av.alignment.getWidth() - 1; - } - - if (res < min) - { - min = res; - } - - if (res > max) - { - max = res; - } - - SequenceGroup sg = av.getSelectionGroup(); - - if (sg != null) - { - stretchingGroup = true; - - if (!av.getColumnSelection().contains(res)) - { - av.getColumnSelection().addElement(res); - } - - if (res > sg.getStartRes()) - { - sg.setEndRes(res); - } - if (res < sg.getStartRes()) - { - sg.setStartRes(res); - } - - int col; - for (int i = min; i <= max; i++) - { - col = av.getColumnSelection().adjustForHiddenColumns(i); - - if ( (col < sg.getStartRes()) || (col > sg.getEndRes())) - { - av.getColumnSelection().removeElement(col); - } - else - { - av.getColumnSelection().addElement(col); - } - } - - ap.paintAlignment(false); - } - } - - public void mouseEntered(MouseEvent evt) - { - if (mouseDragging) - { - ap.seqPanel.scrollCanvas(null); - } - } - - public void mouseExited(MouseEvent evt) - { - if (mouseDragging) - { - ap.seqPanel.scrollCanvas(evt); - } - } - - public void mouseClicked(MouseEvent evt) - { - - } - - public void mouseMoved(MouseEvent evt) - { - if (!av.hasHiddenColumns) - { - return; - } - - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - - res = av.getColumnSelection().adjustForHiddenColumns(res); - - reveal = null; - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) - { - int[] region = (int[]) av.getColumnSelection().getHiddenColumns(). - elementAt(i); - if (res + 1 == region[0] || res - 1 == region[1]) - { - reveal = region; - break; - } - } - - repaint(); - } - - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - drawScale(g, av.getStartRes(), av.getEndRes(), getSize().width, - getSize().height); - } - -// scalewidth will normally be screenwidth, - public void drawScale(Graphics gg, int startx, int endx, int width, - int height) - { - gg.setFont(av.getFont()); - - //Fill in the background - gg.setColor(Color.white); - gg.fillRect(0, 0, width, height); - gg.setColor(Color.black); - - //Fill the selected columns - ColumnSelection cs = av.getColumnSelection(); - gg.setColor(new Color(220, 0, 0)); - - for (int i = 0; i < cs.size(); i++) - { - int sel = cs.columnAt(i); - if (av.hasHiddenColumns) - { - sel = av.getColumnSelection().findColumnPosition(sel); - } - - if ( (sel >= startx) && (sel <= endx)) - { - gg.fillRect( (sel - startx) * av.charWidth, 0, av.charWidth, - getSize().height); - } - } - - // Draw the scale numbers - gg.setColor(Color.black); - - int scalestartx = (startx / 10) * 10; - - FontMetrics fm = gg.getFontMetrics(av.getFont()); - int y = av.charHeight - fm.getDescent(); - - if ( (scalestartx % 10) == 0) - { - scalestartx += 5; - } - - String string; - int maxX = 0; - - for (int i = scalestartx; i < endx; i += 5) - { - if ( (i % 10) == 0) - { - string = String.valueOf(av.getColumnSelection().adjustForHiddenColumns( - i)); - if ( (i - startx - 1) * av.charWidth > maxX) - { - gg.drawString(string, - (i - startx - 1) * av.charWidth, y); - maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); - } - - gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + 2, - (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), - y + (fm.getDescent() * 2)); - - } - else - { - gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + fm.getDescent(), - (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + (fm.getDescent() * 2)); - } - } - - if (av.hasHiddenColumns) - { - gg.setColor(Color.blue); - int res; - if (av.getShowHiddenMarkers()) - { - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); - i++) - { - - res = av.getColumnSelection().findHiddenRegionPosition(i) - - startx; - - if (res < 0 || res > endx - scalestartx) - { - continue; - } - - gg.fillPolygon(new int[] - {res * av.charWidth - av.charHeight / 4, - res * av.charWidth + av.charHeight / 4, - res * av.charWidth}, - new int[] - { - y - av.charHeight / 2, y - av.charHeight / 2, - y + 8 - }, 3); - - } - } - - if (reveal != null && reveal[0] > startx && reveal[0] < endx) - { - gg.drawString("Reveal Columns", reveal[0] * av.charWidth, 0); - } - } - - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; +import java.awt.event.*; + +import jalview.datamodel.*; + +public class ScalePanel extends Panel implements MouseMotionListener, + MouseListener +{ + + protected int offy = 4; + + public int width; + + protected AlignViewport av; + + AlignmentPanel ap; + + boolean stretchingGroup = false; + + int min; // used by mouseDragged to see if user + + int max; // used by mouseDragged to see if user + + boolean mouseDragging = false; + + int[] reveal; + + public ScalePanel(AlignViewport av, AlignmentPanel ap) + { + setLayout(null); + this.av = av; + this.ap = ap; + + addMouseListener(this); + addMouseMotionListener(this); + + } + + public void mousePressed(MouseEvent evt) + { + int x = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + final int res; + + if (av.hasHiddenColumns) + { + res = av.getColumnSelection().adjustForHiddenColumns(x); + } + else + { + res = x; + } + + min = res; + max = res; + if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + { + PopupMenu pop = new PopupMenu(); + if (reveal != null) + { + MenuItem item = new MenuItem("Reveal"); + item.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + av.showColumn(reveal[0]); + reveal = null; + ap.paintAlignment(true); + if (ap.overviewPanel != null) + { + ap.overviewPanel.updateOverviewImage(); + } + } + }); + pop.add(item); + + if (av.getColumnSelection().getHiddenColumns().size() > 1) + { + item = new MenuItem("Reveal All"); + item.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + av.showAllHiddenColumns(); + reveal = null; + ap.paintAlignment(true); + if (ap.overviewPanel != null) + { + ap.overviewPanel.updateOverviewImage(); + } + } + }); + pop.add(item); + } + this.add(pop); + pop.show(this, evt.getX(), evt.getY()); + } + else if (av.getColumnSelection().contains(res)) + { + MenuItem item = new MenuItem("Hide Columns"); + item.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + av.hideColumns(res, res); + if (av.getSelectionGroup() != null + && av.getSelectionGroup().getSize() == av.alignment + .getHeight()) + { + av.setSelectionGroup(null); + } + + ap.paintAlignment(true); + if (ap.overviewPanel != null) + { + ap.overviewPanel.updateOverviewImage(); + } + } + }); + pop.add(item); + this.add(pop); + pop.show(this, evt.getX(), evt.getY()); + } + } + else + // LEFT MOUSE TO SELECT + { + if (!evt.isControlDown() && !evt.isShiftDown()) + { + av.getColumnSelection().clear(); + } + + av.getColumnSelection().addElement(res); + SequenceGroup sg = new SequenceGroup(); + for (int i = 0; i < av.alignment.getSequences().size(); i++) + { + sg.addSequence(av.alignment.getSequenceAt(i), false); + } + + sg.setStartRes(res); + sg.setEndRes(res); + av.setSelectionGroup(sg); + + if (evt.isShiftDown()) + { + int min = Math.min(av.getColumnSelection().getMin(), res); + int max = Math.max(av.getColumnSelection().getMax(), res); + for (int i = min; i < max; i++) + { + av.getColumnSelection().addElement(i); + } + sg.setStartRes(min); + sg.setEndRes(max); + } + } + + ap.paintAlignment(true); + } + + public void mouseReleased(MouseEvent evt) + { + mouseDragging = false; + + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + + if (res > av.alignment.getWidth()) + { + res = av.alignment.getWidth() - 1; + } + + if (av.hasHiddenColumns) + { + res = av.getColumnSelection().adjustForHiddenColumns(res); + } + + if (!stretchingGroup) + { + ap.paintAlignment(false); + + return; + } + + SequenceGroup sg = av.getSelectionGroup(); + + if (res > sg.getStartRes()) + { + sg.setEndRes(res); + } + else if (res < sg.getStartRes()) + { + sg.setStartRes(res); + } + + stretchingGroup = false; + ap.paintAlignment(false); + } + + public void mouseDragged(MouseEvent evt) + { + mouseDragging = true; + + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + if (res < 0) + { + res = 0; + } + + if (av.hasHiddenColumns) + { + res = av.getColumnSelection().adjustForHiddenColumns(res); + } + + if (res > av.alignment.getWidth()) + { + res = av.alignment.getWidth() - 1; + } + + if (res < min) + { + min = res; + } + + if (res > max) + { + max = res; + } + + SequenceGroup sg = av.getSelectionGroup(); + + if (sg != null) + { + stretchingGroup = true; + + if (!av.getColumnSelection().contains(res)) + { + av.getColumnSelection().addElement(res); + } + + if (res > sg.getStartRes()) + { + sg.setEndRes(res); + } + if (res < sg.getStartRes()) + { + sg.setStartRes(res); + } + + int col; + for (int i = min; i <= max; i++) + { + col = av.getColumnSelection().adjustForHiddenColumns(i); + + if ((col < sg.getStartRes()) || (col > sg.getEndRes())) + { + av.getColumnSelection().removeElement(col); + } + else + { + av.getColumnSelection().addElement(col); + } + } + + ap.paintAlignment(false); + } + } + + public void mouseEntered(MouseEvent evt) + { + if (mouseDragging) + { + ap.seqPanel.scrollCanvas(null); + } + } + + public void mouseExited(MouseEvent evt) + { + if (mouseDragging) + { + ap.seqPanel.scrollCanvas(evt); + } + } + + public void mouseClicked(MouseEvent evt) + { + + } + + public void mouseMoved(MouseEvent evt) + { + if (!av.hasHiddenColumns) + { + return; + } + + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + + res = av.getColumnSelection().adjustForHiddenColumns(res); + + reveal = null; + for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) + { + int[] region = (int[]) av.getColumnSelection().getHiddenColumns() + .elementAt(i); + if (res + 1 == region[0] || res - 1 == region[1]) + { + reveal = region; + break; + } + } + + repaint(); + } + + public void update(Graphics g) + { + paint(g); + } + + public void paint(Graphics g) + { + drawScale(g, av.getStartRes(), av.getEndRes(), getSize().width, + getSize().height); + } + + // scalewidth will normally be screenwidth, + public void drawScale(Graphics gg, int startx, int endx, int width, + int height) + { + gg.setFont(av.getFont()); + + // Fill in the background + gg.setColor(Color.white); + gg.fillRect(0, 0, width, height); + gg.setColor(Color.black); + + // Fill the selected columns + ColumnSelection cs = av.getColumnSelection(); + gg.setColor(new Color(220, 0, 0)); + + for (int i = 0; i < cs.size(); i++) + { + int sel = cs.columnAt(i); + if (av.hasHiddenColumns) + { + sel = av.getColumnSelection().findColumnPosition(sel); + } + + if ((sel >= startx) && (sel <= endx)) + { + gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, + getSize().height); + } + } + + // Draw the scale numbers + gg.setColor(Color.black); + + int scalestartx = (startx / 10) * 10; + + FontMetrics fm = gg.getFontMetrics(av.getFont()); + int y = av.charHeight - fm.getDescent(); + + if ((scalestartx % 10) == 0) + { + scalestartx += 5; + } + + String string; + int maxX = 0; + + for (int i = scalestartx; i < endx; i += 5) + { + if ((i % 10) == 0) + { + string = String.valueOf(av.getColumnSelection() + .adjustForHiddenColumns(i)); + if ((i - startx - 1) * av.charWidth > maxX) + { + gg.drawString(string, (i - startx - 1) * av.charWidth, y); + maxX = (i - startx + 1) * av.charWidth + fm.stringWidth(string); + } + + gg + .drawLine( + (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + y + 2, + (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + y + (fm.getDescent() * 2)); + + } + else + { + gg + .drawLine( + (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + y + fm.getDescent(), + (int) (((i - startx - 1) * av.charWidth) + (av.charWidth / 2)), + y + (fm.getDescent() * 2)); + } + } + + if (av.hasHiddenColumns) + { + gg.setColor(Color.blue); + int res; + if (av.getShowHiddenMarkers()) + { + for (int i = 0; i < av.getColumnSelection().getHiddenColumns() + .size(); i++) + { + + res = av.getColumnSelection().findHiddenRegionPosition(i) + - startx; + + if (res < 0 || res > endx - scalestartx) + { + continue; + } + + gg.fillPolygon(new int[] + { res * av.charWidth - av.charHeight / 4, + res * av.charWidth + av.charHeight / 4, res * av.charWidth }, + new int[] + { y - av.charHeight / 2, y - av.charHeight / 2, y + 8 }, + 3); + + } + } + + if (reveal != null && reveal[0] > startx && reveal[0] < endx) + { + gg.drawString("Reveal Columns", reveal[0] * av.charWidth, 0); + } + } + + } + +} diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 5fb956c..68b8501 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -1,825 +1,818 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; - -import jalview.datamodel.*; - -public class SeqCanvas - extends Panel -{ - FeatureRenderer fr; - SequenceRenderer sr; - Image img; - Graphics gg; - int imgWidth; - int imgHeight; - - AlignViewport av; - - SearchResults searchResults = null; - - boolean fastPaint = false; - - int cursorX = 0; - int cursorY = 0; - - public SeqCanvas(AlignViewport av) - { - this.av = av; - fr = new FeatureRenderer(av); - sr = new SequenceRenderer(av); - PaintRefresher.Register(this, av.getSequenceSetId()); - } - - public AlignViewport getViewport() - { - return av; - } - - public FeatureRenderer getFeatureRenderer() - { - return fr; - } - - public SequenceRenderer getSequenceRenderer() - { - return sr; - } - - void drawNorthScale(Graphics g, int startx, int endx, int ypos) - { - int scalestartx = startx - startx % 10 + 10; - - g.setColor(Color.black); - - // NORTH SCALE - for (int i = scalestartx; i < endx; i += 10) - { - int value = i; - if (av.hasHiddenColumns) - { - value = av.getColumnSelection().adjustForHiddenColumns(value); - } - - g.drawString(String.valueOf(value), (i - startx - 1) * av.charWidth, - ypos - (av.charHeight / 2)); - - g.drawLine( ( (i - startx - 1) * av.charWidth) + (av.charWidth / 2), - (ypos + 2) - (av.charHeight / 2), - ( (i - startx - 1) * av.charWidth) + (av.charWidth / 2), ypos - - 2); - } - } - - void drawWestScale(Graphics g, int startx, int endx, int ypos) - { - FontMetrics fm = getFontMetrics(av.getFont()); - ypos += av.charHeight; - if (av.hasHiddenColumns) - { - startx = av.getColumnSelection().adjustForHiddenColumns(startx); - endx = av.getColumnSelection().adjustForHiddenColumns(endx); - } - - int maxwidth = av.alignment.getWidth(); - if (av.hasHiddenColumns) - { - maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; - } - - // WEST SCALE - for (int i = 0; i < av.alignment.getHeight(); i++) - { - SequenceI seq = av.alignment.getSequenceAt(i); - int index = startx; - int value = -1; - - while (index < endx) - { - if (jalview.util.Comparison.isGap(seq.getCharAt(index))) - { - index++; - - continue; - } - - value = av.alignment.getSequenceAt(i).findPosition(index); - - break; - } - - if (value != -1) - { - int x = LABEL_WEST - fm.stringWidth(String.valueOf(value)) - - av.charWidth / 2; - g.drawString(value + "", x, - (ypos + (i * av.charHeight)) - (av.charHeight / 5)); - } - } - } - - void drawEastScale(Graphics g, int startx, int endx, int ypos) - { - ypos += av.charHeight; - - if (av.hasHiddenColumns) - { - endx = av.getColumnSelection().adjustForHiddenColumns(endx); - } - - SequenceI seq; - // EAST SCALE - for (int i = 0; i < av.alignment.getHeight(); i++) - { - seq = av.alignment.getSequenceAt(i); - int index = endx; - int 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 * av.charHeight)) - (av.charHeight / 5)); - } - } - } - - int lastsr = 0; - void fastPaint(int horizontal, int vertical) - { - if (fastPaint || gg == null) - { - return; - } - - // Its possible on certain browsers that the call to fastpaint - // is faster than it can paint, so this check here catches - // this possibility - if (lastsr + horizontal != av.startRes) - { - horizontal = av.startRes - lastsr; - } - - lastsr = av.startRes; - - fastPaint = true; - gg.copyArea(horizontal * av.charWidth, - vertical * av.charHeight, - imgWidth - horizontal * av.charWidth, - imgHeight - vertical * av.charHeight, - -horizontal * av.charWidth, - -vertical * av.charHeight); - - int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, - transX = 0, transY = 0; - - if (horizontal > 0) // scrollbar pulled right, image to the left - { - transX = (er - sr - horizontal) * av.charWidth; - sr = er - horizontal; - } - else if (horizontal < 0) - { - er = sr - horizontal; - } - - else if (vertical > 0) // scroll down - { - ss = es - vertical; - if (ss < av.startSeq) // ie scrolling too fast, more than a page at a time - { - ss = av.startSeq; - } - else - { - transY = imgHeight - vertical * av.charHeight; - } - } - else if (vertical < 0) - { - es = ss - vertical; - if (es > av.endSeq) - { - es = av.endSeq; - } - } - - gg.translate(transX, transY); - - drawPanel(gg, sr, er, ss, es, 0); - gg.translate( -transX, -transY); - - repaint(); - - } - - /** - * Definitions of startx and endx (hopefully): - * SMJS This is what I'm working towards! - * startx is the first residue (starting at 0) to display. - * endx is the last residue to display (starting at 0). - * starty is the first sequence to display (starting at 0). - * endy is the last sequence to display (starting at 0). - * NOTE 1: The av limits are set in setFont in this class and - * in the adjustment listener in SeqPanel when the scrollbars move. - */ - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - - if (img != null && (fastPaint - || (getSize().width != g.getClipBounds().width) - || (getSize().height != g.getClipBounds().height))) - { - g.drawImage(img, 0, 0, this); - fastPaint = false; - return; - } - - if (fastPaint) - { - g.drawImage(img, 0, 0, this); - fastPaint = false; - return; - } - - // this draws the whole of the alignment - imgWidth = this.getSize().width; - imgHeight = this.getSize().height; - - imgWidth -= imgWidth % av.charWidth; - imgHeight -= imgHeight % av.charHeight; - - if (imgWidth < 1 || imgHeight < 1) - { - return; - } - - if (img == null || imgWidth != img.getWidth(this) || - imgHeight != img.getHeight(this)) - { - img = createImage(imgWidth, imgHeight); - gg = img.getGraphics(); - gg.setFont(av.getFont()); - } - - gg.setColor(Color.white); - gg.fillRect(0, 0, imgWidth, imgHeight); - - if (av.getWrapAlignment()) - { - drawWrappedPanel(gg, imgWidth, imgHeight, av.startRes); - } - else - { - drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, 0); - } - - g.drawImage(img, 0, 0, this); - - } - - int LABEL_WEST, LABEL_EAST; - public int getWrappedCanvasWidth(int cwidth) - { - cwidth -= cwidth % av.charWidth; - - FontMetrics fm = getFontMetrics(av.getFont()); - - LABEL_EAST = 0; - LABEL_WEST = 0; - - if (av.scaleRightWrapped) - { - LABEL_EAST = fm.stringWidth(getMask()); - } - - if (av.scaleLeftWrapped) - { - LABEL_WEST = fm.stringWidth(getMask()); - } - - return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - } - - /** - * Generates a string of zeroes. - * @return String - */ - String getMask() - { - String mask = "0"; - int maxWidth = 0; - int tmp; - for (int i = 0; i < av.alignment.getHeight(); i++) - { - tmp = av.alignment.getSequenceAt(i).getEnd(); - if (tmp > maxWidth) - { - maxWidth = tmp; - } - } - - for (int i = maxWidth; i > 0; i /= 10) - { - mask += "0"; - } - return mask; - } - - public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, - int startRes) - { - AlignmentI al = av.getAlignment(); - - FontMetrics fm = getFontMetrics(av.getFont()); - - if (av.scaleRightWrapped) - { - LABEL_EAST = fm.stringWidth(getMask()); - } - - if (av.scaleLeftWrapped) - { - LABEL_WEST = fm.stringWidth(getMask()); - } - - int hgap = av.charHeight; - if (av.scaleAboveWrapped) - { - hgap += av.charHeight; - } - - int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - int cHeight = av.getAlignment().getHeight() * av.charHeight; - - av.setWrappedWidth(cWidth); - - av.endRes = av.startRes + cWidth; - - int endx; - int ypos = hgap; - - int maxwidth = av.alignment.getWidth() - 1; - - if (av.hasHiddenColumns) - { - maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; - } - - while ( (ypos <= canvasHeight) && (startRes < maxwidth)) - { - endx = startRes + cWidth - 1; - - if (endx > maxwidth) - { - endx = maxwidth; - } - - g.setColor(Color.black); - - if (av.scaleLeftWrapped) - { - drawWestScale(g, startRes, endx, ypos); - } - - if (av.scaleRightWrapped) - { - g.translate(canvasWidth - LABEL_EAST, 0); - drawEastScale(g, startRes, endx, ypos); - g.translate( - (canvasWidth - LABEL_EAST), 0); - } - - g.translate(LABEL_WEST, 0); - - if (av.scaleAboveWrapped) - { - drawNorthScale(g, startRes, endx, ypos); - } - if (av.hasHiddenColumns && av.showHiddenMarkers) - { - g.setColor(Color.blue); - int res; - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); - i++) - { - res = av.getColumnSelection().findHiddenRegionPosition(i) - - startRes; - - if (res < 0 || res > endx - startRes) - { - continue; - } - - gg.fillPolygon(new int[] - {res * av.charWidth - av.charHeight / 4, - res * av.charWidth + av.charHeight / 4, - res * av.charWidth}, - new int[] - { - ypos - (av.charHeight / 2), - ypos - (av.charHeight / 2), - ypos - (av.charHeight / 2) + 8 - }, 3); - - } - } - - if (g.getClip() == null) - { - g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); - } - - drawPanel(g, startRes, endx, 0, al.getHeight(), ypos); - g.setClip(null); - - if (av.showAnnotation) - { - g.translate(0, cHeight + ypos + 4); - if (annotations == null) - { - annotations = new AnnotationPanel(av); - } - - annotations.drawComponent(g, startRes, endx + 1); - g.translate(0, -cHeight - ypos - 4); - } - g.translate( -LABEL_WEST, 0); - - ypos += cHeight + getAnnotationHeight() + hgap; - - startRes += cWidth; - } - - } - - AnnotationPanel annotations; - int getAnnotationHeight() - { - if (!av.showAnnotation) - { - return 0; - } - - if (annotations == null) - { - annotations = new AnnotationPanel(av); - } - - return annotations.adjustPanelHeight(); - } - - void drawPanel(Graphics g1, int startRes, int endRes, - int startSeq, int endSeq, int offset) - { - if (!av.hasHiddenColumns) - { - draw(g1, startRes, endRes, startSeq, endSeq, offset); - } - else - { - java.util.Vector regions = av.getColumnSelection().getHiddenColumns(); - - int screenY = 0; - int blockStart = startRes; - int blockEnd = endRes; - - for (int i = 0; i < regions.size(); i++) - { - int[] region = (int[]) regions.elementAt(i); - int hideStart = region[0]; - int hideEnd = region[1]; - - if (hideStart <= blockStart) - { - blockStart += (hideEnd - hideStart) + 1; - continue; - } - - blockEnd = hideStart - 1; - - g1.translate(screenY * av.charWidth, 0); - - draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); - - if (av.getShowHiddenMarkers()) - { - g1.setColor(Color.blue); - g1.drawLine( (blockEnd - blockStart + 1) * av.charWidth - 1, - 0 + offset, - (blockEnd - blockStart + 1) * av.charWidth - 1, - (endSeq - startSeq) * av.charHeight + offset); - } - - g1.translate( -screenY * av.charWidth, 0); - screenY += blockEnd - blockStart + 1; - blockStart = hideEnd + 1; - } - - if (screenY <= (endRes - startRes)) - { - blockEnd = blockStart + (endRes - startRes) - screenY; - g1.translate(screenY * av.charWidth, 0); - draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); - - g1.translate( -screenY * av.charWidth, 0); - } - } - - } - - //int startRes, int endRes, int startSeq, int endSeq, int x, int y, - // int x1, int x2, int y1, int y2, int startx, int starty, - void draw(Graphics g, - int startRes, int endRes, - int startSeq, int endSeq, - int offset) - { - g.setFont(av.getFont()); - sr.prepare(g, av.renderGaps); - - SequenceI nextSeq; - - /// First draw the sequences - ///////////////////////////// - for (int i = startSeq; i < endSeq; i++) - { - nextSeq = av.alignment.getSequenceAt(i); - - if (nextSeq == null) - { - continue; - } - - sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq), - startRes, endRes, - offset + ( (i - startSeq) * av.charHeight)); - - if (av.showSequenceFeatures) - { - fr.drawSequence(g, nextSeq, startRes, endRes, - offset + ( (i - startSeq) * av.charHeight)); - } - - /// Highlight search Results once all sequences have been drawn - ////////////////////////////////////////////////////////// - if (searchResults != null) - { - int[] visibleResults = searchResults.getResults(nextSeq, startRes, - endRes); - if (visibleResults != null) - { - for (int r = 0; r < visibleResults.length; r += 2) - { - sr.drawHighlightedText(nextSeq, visibleResults[r], - visibleResults[r + 1], - (visibleResults[r] - startRes) * - av.charWidth, - offset + ( (i - startSeq) * av.charHeight)); - } - } - } - - if (av.cursorMode && cursorY == i - && cursorX >= startRes && cursorX <= endRes) - { - sr.drawCursor(nextSeq, cursorX, (cursorX - startRes) * av.charWidth, - offset + ( (i - startSeq) * av.charHeight)); - } - } - - if (av.getSelectionGroup() != null || av.alignment.getGroups().size() > 0) - { - drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset); - } - - } - - void drawGroupsBoundaries(Graphics g, - int startRes, int endRes, - int startSeq, int endSeq, - int offset) - { - // - ///////////////////////////////////// - // Now outline any areas if necessary - ///////////////////////////////////// - SequenceGroup group = av.getSelectionGroup(); - - int sx = -1; - int sy = -1; - int ex = -1; - int groupIndex = -1; - - if ( (group == null) && (av.alignment.getGroups().size() > 0)) - { - group = (SequenceGroup) av.alignment.getGroups().elementAt(0); - groupIndex = 0; - } - - if (group != null) - { - do - { - int oldY = -1; - int i = 0; - boolean inGroup = false; - int top = -1; - int bottom = -1; - int alHeight = av.alignment.getHeight() - 1; - - for (i = startSeq; i < endSeq; i++) - { - sx = (group.getStartRes() - startRes) * av.charWidth; - sy = offset + ( (i - startSeq) * av.charHeight); - ex = ( ( (group.getEndRes() + 1) - group.getStartRes()) * - av.charWidth) - - 1; - - if (sx + ex < 0 || sx > imgWidth) - { - continue; - } - - if ( (sx <= (endRes - startRes) * av.charWidth) && - group.getSequences(null). - contains(av.alignment.getSequenceAt(i))) - { - if ( (bottom == -1) && - (i >= alHeight || - !group.getSequences(null).contains( - av.alignment.getSequenceAt(i + 1)))) - { - bottom = sy + av.charHeight; - } - - if (!inGroup) - { - if ( ( (top == -1) && (i == 0)) || - !group.getSequences(null).contains( - av.alignment.getSequenceAt(i - 1))) - { - top = sy; - } - - oldY = sy; - inGroup = true; - - if (group == av.getSelectionGroup()) - { - g.setColor(Color.red); - } - else - { - g.setColor(group.getOutlineColour()); - } - } - } - else - { - if (inGroup) - { - if (sx >= 0 && sx < imgWidth) - { - g.drawLine(sx, oldY, sx, sy); - } - - if (sx + ex < imgWidth) - { - g.drawLine(sx + ex, oldY, sx + ex, sy); - } - - if (sx < 0) - { - ex += sx; - sx = 0; - } - - if (sx + ex > imgWidth) - { - ex = imgWidth; - } - - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) - { - ex = (endRes - startRes + 1) * av.charWidth; - } - - 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) * av.charHeight); - if (sx >= 0 && sx < imgWidth) - { - g.drawLine(sx, oldY, sx, sy); - } - - if (sx + ex < imgWidth) - { - g.drawLine(sx + ex, oldY, sx + ex, sy); - } - - if (sx < 0) - { - ex += sx; - sx = 0; - } - - if (sx + ex > imgWidth) - { - ex = imgWidth; - } - else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) - { - ex = (endRes - startRes + 1) * av.charWidth; - } - - 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 >= av.alignment.getGroups().size()) - { - break; - } - - group = (SequenceGroup) av.alignment.getGroups().elementAt(groupIndex); - } - while (groupIndex < av.alignment.getGroups().size()); - - } - } - - public void highlightSearchResults(SearchResults results) - { - searchResults = results; - - repaint(); - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; + +import jalview.datamodel.*; + +public class SeqCanvas extends Panel +{ + FeatureRenderer fr; + + SequenceRenderer sr; + + Image img; + + Graphics gg; + + int imgWidth; + + int imgHeight; + + AlignViewport av; + + SearchResults searchResults = null; + + boolean fastPaint = false; + + int cursorX = 0; + + int cursorY = 0; + + public SeqCanvas(AlignViewport av) + { + this.av = av; + fr = new FeatureRenderer(av); + sr = new SequenceRenderer(av); + PaintRefresher.Register(this, av.getSequenceSetId()); + } + + public AlignViewport getViewport() + { + return av; + } + + public FeatureRenderer getFeatureRenderer() + { + return fr; + } + + public SequenceRenderer getSequenceRenderer() + { + return sr; + } + + void drawNorthScale(Graphics g, int startx, int endx, int ypos) + { + int scalestartx = startx - startx % 10 + 10; + + g.setColor(Color.black); + + // NORTH SCALE + for (int i = scalestartx; i < endx; i += 10) + { + int value = i; + if (av.hasHiddenColumns) + { + value = av.getColumnSelection().adjustForHiddenColumns(value); + } + + g.drawString(String.valueOf(value), (i - startx - 1) * av.charWidth, + ypos - (av.charHeight / 2)); + + g.drawLine(((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + (ypos + 2) - (av.charHeight / 2), + ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + ypos - 2); + } + } + + void drawWestScale(Graphics g, int startx, int endx, int ypos) + { + FontMetrics fm = getFontMetrics(av.getFont()); + ypos += av.charHeight; + if (av.hasHiddenColumns) + { + startx = av.getColumnSelection().adjustForHiddenColumns(startx); + endx = av.getColumnSelection().adjustForHiddenColumns(endx); + } + + int maxwidth = av.alignment.getWidth(); + if (av.hasHiddenColumns) + { + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + } + + // WEST SCALE + for (int i = 0; i < av.alignment.getHeight(); i++) + { + SequenceI seq = av.alignment.getSequenceAt(i); + int index = startx; + int value = -1; + + while (index < endx) + { + if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + { + index++; + + continue; + } + + value = av.alignment.getSequenceAt(i).findPosition(index); + + break; + } + + if (value != -1) + { + int x = LABEL_WEST - fm.stringWidth(String.valueOf(value)) + - av.charWidth / 2; + g.drawString(value + "", x, (ypos + (i * av.charHeight)) + - (av.charHeight / 5)); + } + } + } + + void drawEastScale(Graphics g, int startx, int endx, int ypos) + { + ypos += av.charHeight; + + if (av.hasHiddenColumns) + { + endx = av.getColumnSelection().adjustForHiddenColumns(endx); + } + + SequenceI seq; + // EAST SCALE + for (int i = 0; i < av.alignment.getHeight(); i++) + { + seq = av.alignment.getSequenceAt(i); + int index = endx; + int 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 * av.charHeight)) + - (av.charHeight / 5)); + } + } + } + + int lastsr = 0; + + void fastPaint(int horizontal, int vertical) + { + if (fastPaint || gg == null) + { + return; + } + + // Its possible on certain browsers that the call to fastpaint + // is faster than it can paint, so this check here catches + // this possibility + if (lastsr + horizontal != av.startRes) + { + horizontal = av.startRes - lastsr; + } + + lastsr = av.startRes; + + fastPaint = true; + gg.copyArea(horizontal * av.charWidth, vertical * av.charHeight, + imgWidth - horizontal * av.charWidth, imgHeight - vertical + * av.charHeight, -horizontal * av.charWidth, -vertical + * av.charHeight); + + int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, transX = 0, transY = 0; + + if (horizontal > 0) // scrollbar pulled right, image to the left + { + transX = (er - sr - horizontal) * av.charWidth; + sr = er - horizontal; + } + else if (horizontal < 0) + { + er = sr - horizontal; + } + + else if (vertical > 0) // scroll down + { + ss = es - vertical; + if (ss < av.startSeq) // ie scrolling too fast, more than a page at a time + { + ss = av.startSeq; + } + else + { + transY = imgHeight - vertical * av.charHeight; + } + } + else if (vertical < 0) + { + es = ss - vertical; + if (es > av.endSeq) + { + es = av.endSeq; + } + } + + gg.translate(transX, transY); + + drawPanel(gg, sr, er, ss, es, 0); + gg.translate(-transX, -transY); + + repaint(); + + } + + /** + * Definitions of startx and endx (hopefully): SMJS This is what I'm working + * towards! startx is the first residue (starting at 0) to display. endx is + * the last residue to display (starting at 0). starty is the first sequence + * to display (starting at 0). endy is the last sequence to display (starting + * at 0). NOTE 1: The av limits are set in setFont in this class and in the + * adjustment listener in SeqPanel when the scrollbars move. + */ + public void update(Graphics g) + { + paint(g); + } + + public void paint(Graphics g) + { + + if (img != null + && (fastPaint || (getSize().width != g.getClipBounds().width) || (getSize().height != g + .getClipBounds().height))) + { + g.drawImage(img, 0, 0, this); + fastPaint = false; + return; + } + + if (fastPaint) + { + g.drawImage(img, 0, 0, this); + fastPaint = false; + return; + } + + // this draws the whole of the alignment + imgWidth = this.getSize().width; + imgHeight = this.getSize().height; + + imgWidth -= imgWidth % av.charWidth; + imgHeight -= imgHeight % av.charHeight; + + if (imgWidth < 1 || imgHeight < 1) + { + return; + } + + if (img == null || imgWidth != img.getWidth(this) + || imgHeight != img.getHeight(this)) + { + img = createImage(imgWidth, imgHeight); + gg = img.getGraphics(); + gg.setFont(av.getFont()); + } + + gg.setColor(Color.white); + gg.fillRect(0, 0, imgWidth, imgHeight); + + if (av.getWrapAlignment()) + { + drawWrappedPanel(gg, imgWidth, imgHeight, av.startRes); + } + else + { + drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, 0); + } + + g.drawImage(img, 0, 0, this); + + } + + int LABEL_WEST, LABEL_EAST; + + public int getWrappedCanvasWidth(int cwidth) + { + cwidth -= cwidth % av.charWidth; + + FontMetrics fm = getFontMetrics(av.getFont()); + + LABEL_EAST = 0; + LABEL_WEST = 0; + + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(getMask()); + } + + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(getMask()); + } + + return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + } + + /** + * Generates a string of zeroes. + * + * @return String + */ + String getMask() + { + String mask = "0"; + int maxWidth = 0; + int tmp; + for (int i = 0; i < av.alignment.getHeight(); i++) + { + tmp = av.alignment.getSequenceAt(i).getEnd(); + if (tmp > maxWidth) + { + maxWidth = tmp; + } + } + + for (int i = maxWidth; i > 0; i /= 10) + { + mask += "0"; + } + return mask; + } + + public void drawWrappedPanel(Graphics g, int canvasWidth, + int canvasHeight, int startRes) + { + AlignmentI al = av.getAlignment(); + + FontMetrics fm = getFontMetrics(av.getFont()); + + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(getMask()); + } + + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(getMask()); + } + + int hgap = av.charHeight; + if (av.scaleAboveWrapped) + { + hgap += av.charHeight; + } + + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + int cHeight = av.getAlignment().getHeight() * av.charHeight; + + av.setWrappedWidth(cWidth); + + av.endRes = av.startRes + cWidth; + + int endx; + int ypos = hgap; + + int maxwidth = av.alignment.getWidth() - 1; + + if (av.hasHiddenColumns) + { + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + } + + while ((ypos <= canvasHeight) && (startRes < maxwidth)) + { + endx = startRes + cWidth - 1; + + if (endx > maxwidth) + { + endx = maxwidth; + } + + g.setColor(Color.black); + + if (av.scaleLeftWrapped) + { + drawWestScale(g, startRes, endx, ypos); + } + + if (av.scaleRightWrapped) + { + g.translate(canvasWidth - LABEL_EAST, 0); + drawEastScale(g, startRes, endx, ypos); + g.translate(-(canvasWidth - LABEL_EAST), 0); + } + + g.translate(LABEL_WEST, 0); + + if (av.scaleAboveWrapped) + { + drawNorthScale(g, startRes, endx, ypos); + } + if (av.hasHiddenColumns && av.showHiddenMarkers) + { + g.setColor(Color.blue); + int res; + for (int i = 0; i < av.getColumnSelection().getHiddenColumns() + .size(); i++) + { + res = av.getColumnSelection().findHiddenRegionPosition(i) + - startRes; + + if (res < 0 || res > endx - startRes) + { + continue; + } + + gg.fillPolygon(new int[] + { res * av.charWidth - av.charHeight / 4, + res * av.charWidth + av.charHeight / 4, res * av.charWidth }, + new int[] + { ypos - (av.charHeight / 2), ypos - (av.charHeight / 2), + ypos - (av.charHeight / 2) + 8 }, 3); + + } + } + + if (g.getClip() == null) + { + g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); + } + + drawPanel(g, startRes, endx, 0, al.getHeight(), ypos); + g.setClip(null); + + if (av.showAnnotation) + { + g.translate(0, cHeight + ypos + 4); + if (annotations == null) + { + annotations = new AnnotationPanel(av); + } + + annotations.drawComponent(g, startRes, endx + 1); + g.translate(0, -cHeight - ypos - 4); + } + g.translate(-LABEL_WEST, 0); + + ypos += cHeight + getAnnotationHeight() + hgap; + + startRes += cWidth; + } + + } + + AnnotationPanel annotations; + + int getAnnotationHeight() + { + if (!av.showAnnotation) + { + return 0; + } + + if (annotations == null) + { + annotations = new AnnotationPanel(av); + } + + return annotations.adjustPanelHeight(); + } + + void drawPanel(Graphics g1, int startRes, int endRes, int startSeq, + int endSeq, int offset) + { + if (!av.hasHiddenColumns) + { + draw(g1, startRes, endRes, startSeq, endSeq, offset); + } + else + { + java.util.Vector regions = av.getColumnSelection().getHiddenColumns(); + + int screenY = 0; + int blockStart = startRes; + int blockEnd = endRes; + + for (int i = 0; i < regions.size(); i++) + { + int[] region = (int[]) regions.elementAt(i); + int hideStart = region[0]; + int hideEnd = region[1]; + + if (hideStart <= blockStart) + { + blockStart += (hideEnd - hideStart) + 1; + continue; + } + + blockEnd = hideStart - 1; + + g1.translate(screenY * av.charWidth, 0); + + draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); + + if (av.getShowHiddenMarkers()) + { + g1.setColor(Color.blue); + g1 + .drawLine((blockEnd - blockStart + 1) * av.charWidth - 1, + 0 + offset, (blockEnd - blockStart + 1) + * av.charWidth - 1, (endSeq - startSeq) + * av.charHeight + offset); + } + + g1.translate(-screenY * av.charWidth, 0); + screenY += blockEnd - blockStart + 1; + blockStart = hideEnd + 1; + } + + if (screenY <= (endRes - startRes)) + { + blockEnd = blockStart + (endRes - startRes) - screenY; + g1.translate(screenY * av.charWidth, 0); + draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); + + g1.translate(-screenY * av.charWidth, 0); + } + } + + } + + // int startRes, int endRes, int startSeq, int endSeq, int x, int y, + // int x1, int x2, int y1, int y2, int startx, int starty, + void draw(Graphics g, int startRes, int endRes, int startSeq, int endSeq, + int offset) + { + g.setFont(av.getFont()); + sr.prepare(g, av.renderGaps); + + SequenceI nextSeq; + + // / First draw the sequences + // /////////////////////////// + for (int i = startSeq; i < endSeq; i++) + { + nextSeq = av.alignment.getSequenceAt(i); + + if (nextSeq == null) + { + continue; + } + + sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq), + startRes, endRes, offset + ((i - startSeq) * av.charHeight)); + + if (av.showSequenceFeatures) + { + fr.drawSequence(g, nextSeq, startRes, endRes, offset + + ((i - startSeq) * av.charHeight)); + } + + // / Highlight search Results once all sequences have been drawn + // //////////////////////////////////////////////////////// + if (searchResults != null) + { + int[] visibleResults = searchResults.getResults(nextSeq, startRes, + endRes); + if (visibleResults != null) + { + for (int r = 0; r < visibleResults.length; r += 2) + { + sr.drawHighlightedText(nextSeq, visibleResults[r], + visibleResults[r + 1], (visibleResults[r] - startRes) + * av.charWidth, offset + + ((i - startSeq) * av.charHeight)); + } + } + } + + if (av.cursorMode && cursorY == i && cursorX >= startRes + && cursorX <= endRes) + { + sr.drawCursor(nextSeq, cursorX, + (cursorX - startRes) * av.charWidth, offset + + ((i - startSeq) * av.charHeight)); + } + } + + if (av.getSelectionGroup() != null + || av.alignment.getGroups().size() > 0) + { + drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset); + } + + } + + void drawGroupsBoundaries(Graphics g, int startRes, int endRes, + int startSeq, int endSeq, int offset) + { + // + // /////////////////////////////////// + // Now outline any areas if necessary + // /////////////////////////////////// + SequenceGroup group = av.getSelectionGroup(); + + int sx = -1; + int sy = -1; + int ex = -1; + int groupIndex = -1; + + if ((group == null) && (av.alignment.getGroups().size() > 0)) + { + group = (SequenceGroup) av.alignment.getGroups().elementAt(0); + groupIndex = 0; + } + + if (group != null) + { + do + { + int oldY = -1; + int i = 0; + boolean inGroup = false; + int top = -1; + int bottom = -1; + int alHeight = av.alignment.getHeight() - 1; + + for (i = startSeq; i < endSeq; i++) + { + sx = (group.getStartRes() - startRes) * av.charWidth; + sy = offset + ((i - startSeq) * av.charHeight); + ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - 1; + + if (sx + ex < 0 || sx > imgWidth) + { + continue; + } + + if ((sx <= (endRes - startRes) * av.charWidth) + && group.getSequences(null).contains( + av.alignment.getSequenceAt(i))) + { + if ((bottom == -1) + && (i >= alHeight || !group.getSequences(null) + .contains(av.alignment.getSequenceAt(i + 1)))) + { + bottom = sy + av.charHeight; + } + + if (!inGroup) + { + if (((top == -1) && (i == 0)) + || !group.getSequences(null).contains( + av.alignment.getSequenceAt(i - 1))) + { + top = sy; + } + + oldY = sy; + inGroup = true; + + if (group == av.getSelectionGroup()) + { + g.setColor(Color.red); + } + else + { + g.setColor(group.getOutlineColour()); + } + } + } + else + { + if (inGroup) + { + if (sx >= 0 && sx < imgWidth) + { + g.drawLine(sx, oldY, sx, sy); + } + + if (sx + ex < imgWidth) + { + g.drawLine(sx + ex, oldY, sx + ex, sy); + } + + if (sx < 0) + { + ex += sx; + sx = 0; + } + + if (sx + ex > imgWidth) + { + ex = imgWidth; + } + + else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + { + ex = (endRes - startRes + 1) * av.charWidth; + } + + 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) * av.charHeight); + if (sx >= 0 && sx < imgWidth) + { + g.drawLine(sx, oldY, sx, sy); + } + + if (sx + ex < imgWidth) + { + g.drawLine(sx + ex, oldY, sx + ex, sy); + } + + if (sx < 0) + { + ex += sx; + sx = 0; + } + + if (sx + ex > imgWidth) + { + ex = imgWidth; + } + else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) + { + ex = (endRes - startRes + 1) * av.charWidth; + } + + 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 >= av.alignment.getGroups().size()) + { + break; + } + + group = (SequenceGroup) av.alignment.getGroups().elementAt( + groupIndex); + } while (groupIndex < av.alignment.getGroups().size()); + + } + } + + public void highlightSearchResults(SearchResults results) + { + searchResults = results; + + repaint(); + } + +} diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 158f0ab..bf392e9 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -30,44 +29,56 @@ import jalview.schemes.*; import jalview.structure.SequenceListener; import jalview.structure.StructureSelectionManager; -public class SeqPanel - extends Panel implements MouseMotionListener, MouseListener, SequenceListener +public class SeqPanel extends Panel implements MouseMotionListener, + MouseListener, SequenceListener { public SeqCanvas seqCanvas; + public AlignmentPanel ap; protected int lastres; + protected int startseq; protected AlignViewport av; - // if character is inserted or deleted, we will need to recalculate the conservation + // if character is inserted or deleted, we will need to recalculate the + // conservation boolean seqEditOccurred = false; ScrollThread scrollThread = null; + boolean mouseDragging = false; + boolean editingSeqs = false; + boolean groupEditing = false; int oldSeq = -1; + boolean changeEndSeq = false; + boolean changeStartSeq = false; + boolean changeEndRes = false; + boolean changeStartRes = false; + SequenceGroup stretchGroup = null; StringBuffer keyboardNo1; + StringBuffer keyboardNo2; boolean mouseWheelPressed = false; + Point lastMousePress; EditCommand editCommand; StructureSelectionManager ssm; - public SeqPanel(AlignViewport avp, AlignmentPanel p) { this.av = avp; @@ -91,8 +102,8 @@ public class SeqPanel if (editCommand != null && editCommand.getSize() > 0) { ap.alignFrame.addHistoryItem(editCommand); - av.firePropertyChange("alignment", null, - av.getAlignment().getSequences()); + av.firePropertyChange("alignment", null, av.getAlignment() + .getSequences()); } startseq = -1; @@ -132,12 +143,10 @@ public class SeqPanel void setCursorPosition() { - SequenceI sequence = - (Sequence) av.getAlignment().getSequenceAt(seqCanvas.cursorY); + SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt( + seqCanvas.cursorY); - seqCanvas.cursorX = sequence.findIndex( - getKeyboardNo1() - 1 - ); + seqCanvas.cursorX = sequence.findIndex(getKeyboardNo1() - 1); scrollToVisible(); } @@ -151,14 +160,13 @@ public class SeqPanel int maxWidth = av.alignment.getWidth(); while (!av.colSel.isVisible(seqCanvas.cursorX) - && seqCanvas.cursorX < maxWidth - && seqCanvas.cursorX > 0) + && seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0) { seqCanvas.cursorX += dx; } if (seqCanvas.cursorX >= maxWidth - || !av.colSel.isVisible(seqCanvas.cursorX)) + || !av.colSel.isVisible(seqCanvas.cursorX)) { seqCanvas.cursorX = original; } @@ -201,7 +209,8 @@ public class SeqPanel { ap.scrollUp(false); } - while (seqCanvas.cursorX < av.colSel.adjustForHiddenColumns(av.startRes)) + while (seqCanvas.cursorX < av.colSel + .adjustForHiddenColumns(av.startRes)) { if (!ap.scrollRight(false)) @@ -209,7 +218,8 @@ public class SeqPanel break; } } - while (seqCanvas.cursorX > av.colSel.adjustForHiddenColumns(av.endRes)) + while (seqCanvas.cursorX > av.colSel + .adjustForHiddenColumns(av.endRes)) { if (!ap.scrollRight(true)) { @@ -218,20 +228,20 @@ public class SeqPanel } } setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY), - seqCanvas.cursorX, seqCanvas.cursorY); + seqCanvas.cursorX, seqCanvas.cursorY); seqCanvas.repaint(); } void setSelectionAreaAtCursor(boolean topLeft) { - SequenceI sequence = - (Sequence) av.getAlignment().getSequenceAt(seqCanvas.cursorY); + SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt( + seqCanvas.cursorY); if (av.getSelectionGroup() != null) { SequenceGroup sg = av.selectionGroup; - //Find the top and bottom of this group + // Find the top and bottom of this group int min = av.alignment.getHeight(), max = 0; for (int i = 0; i < sg.getSize(); i++) { @@ -356,17 +366,16 @@ public class SeqPanel } } - void setStatusMessage(SequenceI sequence, int res, int seq) { - StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + - sequence.getName()); + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + + sequence.getName()); Object obj = null; if (av.alignment.isNucleotide()) { - obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) + - ""); + obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) + + ""); if (obj != null) { text.append(" Nucleotide: "); @@ -386,8 +395,7 @@ public class SeqPanel if (obj != "") { - text.append(obj + " (" + sequence.findPosition(res) + - ")"); + text.append(obj + " (" + sequence.findPosition(res) + ")"); } } @@ -399,18 +407,16 @@ public class SeqPanel { lastMousePress = evt.getPoint(); - //For now, ignore the mouseWheel font resizing on Macs - //As the Button2_mask always seems to be true - if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) == - InputEvent.BUTTON2_MASK && !av.MAC) + // For now, ignore the mouseWheel font resizing on Macs + // As the Button2_mask always seems to be true + if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK + && !av.MAC) { mouseWheelPressed = true; return; } - if (evt.isShiftDown() - || evt.isControlDown() - || evt.isAltDown()) + if (evt.isShiftDown() || evt.isControlDown() || evt.isAltDown()) { if (evt.isControlDown() || evt.isAltDown()) { @@ -432,8 +438,8 @@ public class SeqPanel return; } - if ( (seq < av.getAlignment().getHeight()) && - (res < av.getAlignment().getSequenceAt(seq).getLength())) + if ((seq < av.getAlignment().getHeight()) + && (res < av.getAlignment().getSequenceAt(seq).getLength())) { startseq = seq; lastres = res; @@ -453,30 +459,26 @@ public class SeqPanel if (evt.getClickCount() > 1) { if (av.getSelectionGroup().getSize() == 1 - && av.getSelectionGroup().getEndRes() - - av.getSelectionGroup().getStartRes() < 2) + && av.getSelectionGroup().getEndRes() + - av.getSelectionGroup().getStartRes() < 2) { av.setSelectionGroup(null); } - SequenceFeature[] features = findFeaturesAtRes( - sequence, - sequence.findPosition(findRes(evt)) - ); + SequenceFeature[] features = findFeaturesAtRes(sequence, sequence + .findPosition(findRes(evt))); if (features != null && features.length > 0) { SearchResults highlight = new SearchResults(); - highlight.addResult(sequence, - features[0].getBegin(), - features[0].getEnd()); + highlight.addResult(sequence, features[0].getBegin(), features[0] + .getEnd()); seqCanvas.highlightSearchResults(highlight); } if (features != null && features.length > 0) { - seqCanvas.getFeatureRenderer().amendFeatures( - new SequenceI[] - {sequence}, features, false, ap); + seqCanvas.getFeatureRenderer().amendFeatures(new SequenceI[] + { sequence }, features, false, ap); seqCanvas.highlightSearchResults(null); } @@ -500,7 +502,9 @@ public class SeqPanel } int startWrapBlock = -1; + int wrappedBlock = -1; + int findRes(MouseEvent evt) { int res = 0; @@ -515,8 +519,8 @@ public class SeqPanel hgap += av.charHeight; } - int cHeight = av.getAlignment().getHeight() * av.charHeight - + hgap + seqCanvas.getAnnotationHeight(); + int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + + seqCanvas.getAnnotationHeight(); int y = evt.getY(); y -= hgap; @@ -551,8 +555,9 @@ public class SeqPanel int findSeq(MouseEvent evt) { final int sqnum = findAlRow(evt); - return (sqnum<0) ? 0 : sqnum; + return (sqnum < 0) ? 0 : sqnum; } + /** * * @param evt @@ -571,13 +576,13 @@ public class SeqPanel hgap += av.charHeight; } - int cHeight = av.getAlignment().getHeight() * av.charHeight - + hgap + seqCanvas.getAnnotationHeight(); + int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap + + seqCanvas.getAnnotationHeight(); y -= hgap; - seq = Math.min( (y % cHeight) / av.getCharHeight(), - av.alignment.getHeight() - 1); + seq = Math.min((y % cHeight) / av.getCharHeight(), av.alignment + .getHeight() - 1); if (seq < 0) { seq = -1; @@ -585,8 +590,8 @@ public class SeqPanel } else { - seq = Math.min( (y / av.getCharHeight()) + av.getStartSeq(), - av.alignment.getHeight() - 1); + seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(), + av.alignment.getHeight() - 1); if (seq < 0) { seq = -1; @@ -596,18 +601,16 @@ public class SeqPanel return seq; } - - public void doMousePressed(MouseEvent evt) { int seq = findSeq(evt); int res = findRes(evt); - if (seq < av.getAlignment().getHeight() && - res < av.getAlignment().getSequenceAt(seq).getLength()) + if (seq < av.getAlignment().getHeight() + && res < av.getAlignment().getSequenceAt(seq).getLength()) { - //char resstr = align.getSequenceAt(seq).getSequence().charAt(res); + // char resstr = align.getSequenceAt(seq).getSequence().charAt(res); // Find the residue's position in the sequence (res is the position // in the alignment @@ -623,18 +626,17 @@ public class SeqPanel return; } - String lastMessage; + public void mouseOverSequence(SequenceI sequence, int index, int pos) { - String tmp = sequence.hashCode()+index+""; + String tmp = sequence.hashCode() + index + ""; if (lastMessage == null || !lastMessage.equals(tmp)) ssm.mouseOverSequence(sequence, index, pos); lastMessage = tmp; } - public void highlightSequence(SearchResults results) { seqCanvas.highlightSearchResults(results); @@ -643,7 +645,7 @@ public class SeqPanel public void updateColours(SequenceI seq, int index) { System.out.println("update the seqPanel colours"); - //repaint(); + // repaint(); } public void mouseMoved(MouseEvent evt) @@ -674,15 +676,14 @@ public class SeqPanel if (ssm != null) mouseOverSequence(sequence, res, respos); - - StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + - sequence.getName()); + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + + sequence.getName()); Object obj = null; if (av.alignment.isNucleotide()) { - obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) + - ""); + obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res) + + ""); if (obj != null) { text.append(" Nucleotide: "); @@ -715,8 +716,8 @@ public class SeqPanel { if (groups[g].getStartRes() <= res && groups[g].getEndRes() >= res) { - if (!groups[g].getName().startsWith("JTreeGroup") && - !groups[g].getName().startsWith("JGroup")) + if (!groups[g].getName().startsWith("JTreeGroup") + && !groups[g].getName().startsWith("JGroup")) { tooltipText.append(groups[g].getName() + " "); } @@ -730,33 +731,33 @@ public class SeqPanel } // use aa to see if the mouse pointer is on a - SequenceFeature [] allFeatures = findFeaturesAtRes(sequence, - sequence.findPosition(res)); + SequenceFeature[] allFeatures = findFeaturesAtRes(sequence, sequence + .findPosition(res)); - int index = 0; - while (index < allFeatures.length) - { - SequenceFeature sf = allFeatures[index]; + int index = 0; + while (index < allFeatures.length) + { + SequenceFeature sf = allFeatures[index]; - tooltipText.append(sf.getType() + " " + sf.begin + ":" + sf.end); + tooltipText.append(sf.getType() + " " + sf.begin + ":" + sf.end); - if (sf.getDescription() != null) - { - tooltipText.append(" " + sf.getDescription()); - } + if (sf.getDescription() != null) + { + tooltipText.append(" " + sf.getDescription()); + } - if (sf.getValue("status") != null) + if (sf.getValue("status") != null) + { + String status = sf.getValue("status").toString(); + if (status.length() > 0) { - String status = sf.getValue("status").toString(); - if (status.length() > 0) - { - tooltipText.append(" (" + sf.getValue("status") + ")"); - } + tooltipText.append(" (" + sf.getValue("status") + ")"); } - tooltipText.append("\n"); - - index++; } + tooltipText.append("\n"); + + index++; + } if (tooltip == null) { @@ -777,22 +778,21 @@ public class SeqPanel for (int i = 0; i < features.length; i++) { if (av.featuresDisplayed == null - || !av.featuresDisplayed.containsKey(features[i].getType())) + || !av.featuresDisplayed.containsKey(features[i].getType())) { continue; } - - if (features[i].featureGroup != null - && seqCanvas.fr.featureGroups!=null - && seqCanvas.fr.featureGroups.containsKey(features[i].featureGroup) - && !((Boolean)seqCanvas.fr.featureGroups.get(features[i].featureGroup)).booleanValue()) + && seqCanvas.fr.featureGroups != null + && seqCanvas.fr.featureGroups + .containsKey(features[i].featureGroup) + && !((Boolean) seqCanvas.fr.featureGroups + .get(features[i].featureGroup)).booleanValue()) continue; - - if ( (features[i].getBegin() <= res) && - (features[i].getEnd() >= res)) + if ((features[i].getBegin() <= res) + && (features[i].getEnd() >= res)) { tmp.addElement(features[i]); } @@ -805,7 +805,6 @@ public class SeqPanel return features; } - Tooltip tooltip; public void mouseDragged(MouseEvent evt) @@ -814,9 +813,9 @@ public class SeqPanel { int oldWidth = av.charWidth; - //Which is bigger, left-right or up-down? - if (Math.abs(evt.getY() - lastMousePress.y) - > Math.abs(evt.getX() - lastMousePress.x)) + // Which is bigger, left-right or up-down? + if (Math.abs(evt.getY() - lastMousePress.y) > Math.abs(evt.getX() + - lastMousePress.x)) { int fontSize = av.font.getSize(); @@ -834,7 +833,9 @@ public class SeqPanel fontSize = 1; } - av.setFont(new Font(av.font.getName(), av.font.getStyle(), fontSize)); + av + .setFont(new Font(av.font.getName(), av.font.getStyle(), + fontSize)); av.charWidth = oldWidth; } else @@ -879,12 +880,12 @@ public class SeqPanel res = 0; } - if ( (lastres == -1) || (lastres == res)) + if ((lastres == -1) || (lastres == res)) { return; } - if ( (res < av.getAlignment().getWidth()) && (res < lastres)) + if ((res < av.getAlignment().getWidth()) && (res < lastres)) { // dragLeft, delete gap editSequence(false, res); @@ -914,7 +915,7 @@ public class SeqPanel if (!groupEditing && av.hasHiddenRows) { if (av.hiddenRepSequences != null - && av.hiddenRepSequences.containsKey(seq)) + && av.hiddenRepSequences.containsKey(seq)) { sg = (SequenceGroup) av.hiddenRepSequences.get(seq); groupEditing = true; @@ -956,18 +957,19 @@ public class SeqPanel message.append(Math.abs(startres - lastres) + " gaps."); ap.alignFrame.statusBar.setText(message.toString()); - //Are we editing within a selection group? + // Are we editing within a selection group? if (groupEditing - || (sg != null && sg.getSequences(av.hiddenRepSequences).contains(seq))) + || (sg != null && sg.getSequences(av.hiddenRepSequences) + .contains(seq))) { fixedColumns = true; - //sg might be null as the user may only see 1 sequence, - //but the sequence represents a group + // sg might be null as the user may only see 1 sequence, + // but the sequence represents a group if (sg == null) { if (av.hiddenRepSequences == null - || !av.hiddenRepSequences.containsKey(seq)) + || !av.hiddenRepSequences.containsKey(seq)) { endEditing(); return; @@ -979,10 +981,10 @@ public class SeqPanel fixedLeft = sg.getStartRes(); fixedRight = sg.getEndRes(); - if ( (startres < fixedLeft && lastres >= fixedLeft) - || (startres >= fixedLeft && lastres < fixedLeft) - || (startres > fixedRight && lastres <= fixedRight) - || (startres <= fixedRight && lastres > fixedRight)) + if ((startres < fixedLeft && lastres >= fixedLeft) + || (startres >= fixedLeft && lastres < fixedLeft) + || (startres > fixedRight && lastres <= fixedRight) + || (startres <= fixedRight && lastres > fixedRight)) { endEditing(); return; @@ -1006,15 +1008,15 @@ public class SeqPanel int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres); int y2 = av.getColumnSelection().getHiddenBoundaryRight(startres); - if ( (insertGap && startres > y1 && lastres < y1) - || (!insertGap && startres < y2 && lastres > y2)) + if ((insertGap && startres > y1 && lastres < y1) + || (!insertGap && startres < y2 && lastres > y2)) { endEditing(); return; } - //System.out.print(y1+" "+y2+" "+fixedLeft+" "+fixedRight+"~~"); - //Selection spans a hidden region + // System.out.print(y1+" "+y2+" "+fixedLeft+" "+fixedRight+"~~"); + // Selection spans a hidden region if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) { if (startres >= y2) @@ -1041,12 +1043,10 @@ public class SeqPanel // drag to right if (insertGap) { - //If the user has selected the whole sequence, and is dragging to + // If the user has selected the whole sequence, and is dragging to // the right, we can still extend the alignment and selectionGroup - if (sg.getStartRes() == 0 - && sg.getEndRes() == fixedRight - && sg.getEndRes() == av.alignment.getWidth() - 1 - ) + if (sg.getStartRes() == 0 && sg.getEndRes() == fixedRight + && sg.getEndRes() == av.alignment.getWidth() - 1) { sg.setEndRes(av.alignment.getWidth() + startres - lastres); fixedRight = sg.getEndRes(); @@ -1056,9 +1056,7 @@ public class SeqPanel // Find the next gap before the end // of the visible region boundary boolean blank = false; - for (fixedRight = fixedRight; - fixedRight > lastres; - fixedRight--) + for (fixedRight = fixedRight; fixedRight > lastres; fixedRight--) { blank = true; @@ -1066,8 +1064,8 @@ public class SeqPanel { for (int j = 0; j < startres - lastres; j++) { - if (!jalview.util.Comparison.isGap( - groupSeqs[g].getCharAt(fixedRight - j))) + if (!jalview.util.Comparison.isGap(groupSeqs[g] + .getCharAt(fixedRight - j))) { blank = false; break; @@ -1084,9 +1082,8 @@ public class SeqPanel { if (sg.getSize() == av.alignment.getHeight()) { - if ( (av.hasHiddenColumns - && - startres < av.getColumnSelection().getHiddenBoundaryRight(startres))) + if ((av.hasHiddenColumns && startres < av.getColumnSelection() + .getHiddenBoundaryRight(startres))) { endEditing(); return; @@ -1101,8 +1098,8 @@ public class SeqPanel alWidth = hwidth; } } - //We can still insert gaps if the selectionGroup - //contains all the sequences + // We can still insert gaps if the selectionGroup + // contains all the sequences sg.setEndRes(sg.getEndRes() + startres - lastres); fixedRight = alWidth + startres - lastres; } @@ -1117,7 +1114,7 @@ public class SeqPanel // drag to left else if (!insertGap) { - /// Are we able to delete? + // / Are we able to delete? // ie are all columns blank? for (g = 0; g < groupSize; g++) @@ -1129,8 +1126,7 @@ public class SeqPanel continue; } - if (!jalview.util.Comparison.isGap( - groupSeqs[g].getCharAt(j))) + if (!jalview.util.Comparison.isGap(groupSeqs[g].getCharAt(j))) { // Not a gap, block edit not valid endEditing(); @@ -1152,11 +1148,8 @@ public class SeqPanel } else { - editCommand.appendEdit(EditCommand.INSERT_GAP, - groupSeqs, - startres, startres - lastres, - av.alignment, - true); + editCommand.appendEdit(EditCommand.INSERT_GAP, groupSeqs, + startres, startres - lastres, av.alignment, true); } } else @@ -1171,16 +1164,14 @@ public class SeqPanel } else { - editCommand.appendEdit(EditCommand.DELETE_GAP, - groupSeqs, - startres, lastres - startres, - av.alignment, - true); + editCommand.appendEdit(EditCommand.DELETE_GAP, groupSeqs, + startres, lastres - startres, av.alignment, true); } } } - else /////Editing a single sequence/////////// + else + // ///Editing a single sequence/////////// { if (insertGap) { @@ -1190,17 +1181,13 @@ public class SeqPanel for (int j = lastres; j < startres; j++) { insertChar(j, new SequenceI[] - {seq}, fixedRight); + { seq }, fixedRight); } } else { - editCommand.appendEdit(EditCommand.INSERT_GAP, - new SequenceI[] - {seq}, - lastres, startres - lastres, - av.alignment, - true); + editCommand.appendEdit(EditCommand.INSERT_GAP, new SequenceI[] + { seq }, lastres, startres - lastres, av.alignment, true); } } else @@ -1216,12 +1203,12 @@ public class SeqPanel break; } deleteChar(startres, new SequenceI[] - {seq}, fixedRight); + { seq }, fixedRight); } } else { - //could be a keyboard edit trying to delete none gaps + // could be a keyboard edit trying to delete none gaps int max = 0; for (int m = startres; m < lastres; m++) { @@ -1234,12 +1221,8 @@ public class SeqPanel if (max > 0) { - editCommand.appendEdit(EditCommand.DELETE_GAP, - new SequenceI[] - {seq}, - startres, max, - av.alignment, - true); + editCommand.appendEdit(EditCommand.DELETE_GAP, new SequenceI[] + { seq }, startres, max, av.alignment, true); } } } @@ -1254,14 +1237,14 @@ public class SeqPanel int blankColumn = fixedColumn; for (int s = 0; s < seq.length; s++) { - //Find the next gap before the end of the visible region boundary - //If lastCol > j, theres a boundary after the gap insertion + // Find the next gap before the end of the visible region boundary + // If lastCol > j, theres a boundary after the gap insertion for (blankColumn = fixedColumn; blankColumn > j; blankColumn--) { if (jalview.util.Comparison.isGap(seq[s].getCharAt(blankColumn))) { - //Theres a space, so break and insert the gap + // Theres a space, so break and insert the gap break; } } @@ -1274,32 +1257,27 @@ public class SeqPanel } } - editCommand.appendEdit(EditCommand.DELETE_GAP, - seq, - blankColumn, 1, av.alignment, true); + editCommand.appendEdit(EditCommand.DELETE_GAP, seq, blankColumn, 1, + av.alignment, true); - editCommand.appendEdit(EditCommand.INSERT_GAP, - seq, - j, 1, av.alignment, - true); + editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.alignment, + true); } void deleteChar(int j, SequenceI[] seq, int fixedColumn) { - editCommand.appendEdit(EditCommand.DELETE_GAP, - seq, - j, 1, av.alignment, true); + editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.alignment, + true); - editCommand.appendEdit(EditCommand.INSERT_GAP, - seq, - fixedColumn, 1, av.alignment, true); + editCommand.appendEdit(EditCommand.INSERT_GAP, seq, fixedColumn, 1, + av.alignment, true); } -////////////////////////////////////////// -/////Everything below this is for defining the boundary of the rubberband -////////////////////////////////////////// + // //////////////////////////////////////// + // ///Everything below this is for defining the boundary of the rubberband + // //////////////////////////////////////// public void doMousePressedDefineMode(MouseEvent evt) { if (scrollThread != null) @@ -1330,8 +1308,8 @@ public class SeqPanel if (stretchGroup == null) { stretchGroup = av.alignment.findGroup(sequence); - if (stretchGroup != null && res > stretchGroup.getStartRes() && - res < stretchGroup.getEndRes()) + if (stretchGroup != null && res > stretchGroup.getStartRes() + && res < stretchGroup.getEndRes()) { av.setSelectionGroup(stretchGroup); } @@ -1342,8 +1320,8 @@ public class SeqPanel } else if (!stretchGroup.getSequences(null).contains(sequence) - || stretchGroup.getStartRes() > res - || stretchGroup.getEndRes() < res) + || stretchGroup.getStartRes() > res + || stretchGroup.getEndRes() < res) { stretchGroup = null; @@ -1353,8 +1331,8 @@ public class SeqPanel { for (int i = 0; i < allGroups.length; i++) { - if (allGroups[i].getStartRes() <= res && - allGroups[i].getEndRes() >= res) + if (allGroups[i].getStartRes() <= res + && allGroups[i].getEndRes() >= res) { stretchGroup = allGroups[i]; break; @@ -1365,11 +1343,10 @@ public class SeqPanel } // DETECT RIGHT MOUSE BUTTON IN AWT - if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == - InputEvent.BUTTON3_MASK) + if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - SequenceFeature [] allFeatures = findFeaturesAtRes(sequence, - sequence.findPosition(res)); + SequenceFeature[] allFeatures = findFeaturesAtRes(sequence, sequence + .findPosition(res)); Vector links = null; if (allFeatures != null) @@ -1378,10 +1355,13 @@ public class SeqPanel { if (allFeatures[i].links != null) { - links = new Vector(); + if (links==null) + { + links = new Vector(); + } for (int j = 0; j < allFeatures[i].links.size(); j++) { - links.addElement(allFeatures[i].links.elementAt(j)); + links.addElement(allFeatures[i].links.elementAt(j)); } } } @@ -1400,7 +1380,7 @@ public class SeqPanel return; } - //Only if left mouse button do we want to change group sizes + // Only if left mouse button do we want to change group sizes if (stretchGroup == null) { @@ -1415,12 +1395,12 @@ public class SeqPanel if (av.getConservationSelected()) { SliderPanel.setConservationSlider(ap, av.getGlobalColourScheme(), - "Background"); + "Background"); } if (av.getAbovePIDThreshold()) { SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), - "Background"); + "Background"); } } @@ -1437,29 +1417,29 @@ public class SeqPanel { if (stretchGroup.cs instanceof ClustalxColourScheme) { - ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX( - stretchGroup.getSequences(av.hiddenRepSequences), - stretchGroup.getWidth()); + ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup + .getSequences(av.hiddenRepSequences), stretchGroup + .getWidth()); } if (stretchGroup.cs instanceof Blosum62ColourScheme - || stretchGroup.cs instanceof PIDColourScheme - || stretchGroup.cs.conservationApplied() - || stretchGroup.cs.getThreshold() > 0) + || stretchGroup.cs instanceof PIDColourScheme + || stretchGroup.cs.conservationApplied() + || stretchGroup.cs.getThreshold() > 0) { stretchGroup.recalcConservation(); } if (stretchGroup.cs.conservationApplied()) { - SliderPanel.setConservationSlider(ap, stretchGroup.cs, - stretchGroup.getName()); + SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup + .getName()); stretchGroup.recalcConservation(); } else { - SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, - stretchGroup.getName()); + SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup + .getName()); } } changeEndRes = false; @@ -1538,7 +1518,7 @@ public class SeqPanel dragDirection = -1; } - while ( (y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight())) + while ((y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight())) { // This routine ensures we don't skip any sequences, as the // selection is quite slow. @@ -1573,8 +1553,8 @@ public class SeqPanel oldSeq = -1; } - if (res > av.endRes || res < av.startRes - || y < av.startSeq || y > av.endSeq) + if (res > av.endRes || res < av.startRes || y < av.startSeq + || y > av.endSeq) { mouseExited(evt); } @@ -1639,11 +1619,12 @@ public class SeqPanel } // this class allows scrolling off the bottom of the visible alignment - class ScrollThread - extends Thread + class ScrollThread extends Thread { MouseEvent evt; + boolean running = false; + public ScrollThread() { start(); @@ -1673,8 +1654,8 @@ public class SeqPanel running = ap.scrollUp(true); } - if (mouseDragging && evt.getY() >= getSize().height && - av.alignment.getHeight() > av.getEndSeq()) + if (mouseDragging && evt.getY() >= getSize().height + && av.alignment.getHeight() > av.getEndSeq()) { running = ap.scrollUp(false); } @@ -1693,9 +1674,9 @@ public class SeqPanel try { Thread.sleep(75); + } catch (Exception ex) + { } - catch (Exception ex) - {} } } } diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index daf971d..c41c35f 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -1,333 +1,340 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.awt.*; - -import jalview.datamodel.*; -import jalview.schemes.*; - -public class SequenceRenderer -{ - AlignViewport av; - FontMetrics fm; - boolean renderGaps = true; - SequenceGroup currentSequenceGroup = null; - SequenceGroup[] allGroups = null; - Color resBoxColour; - Graphics graphics; - boolean forOverview = false; - - public SequenceRenderer(AlignViewport av) - { - this.av = av; - } - - /** - * DOCUMENT ME! - * - * @param b DOCUMENT ME! - */ - public void prepare(Graphics g, boolean renderGaps) - { - graphics = g; - fm = g.getFontMetrics(); - - this.renderGaps = renderGaps; - } - - public Color getResidueBoxColour(SequenceI seq, int i) - { - allGroups = av.alignment.findAllGroups(seq); - - if (inCurrentSequenceGroup(i)) - { - if (currentSequenceGroup.getDisplayBoxes()) - { - getBoxColour(currentSequenceGroup.cs, seq, i); - } - } - else if (av.getShowBoxes()) - { - getBoxColour(av.globalColourScheme, seq, i); - } - - return resBoxColour; - } - - void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) - { - if (cs != null) - { - resBoxColour = cs.findColour(seq.getCharAt(i), i); - } - else if (forOverview && !jalview.util.Comparison.isGap(seq.getCharAt(i))) - { - resBoxColour = Color.lightGray; - } - else - { - resBoxColour = Color.white; - } - - } - - public Color findSequenceColour(SequenceI seq, int i) - { - allGroups = av.alignment.findAllGroups(seq); - drawBoxes(seq, i, i, 0); - return resBoxColour; - } - - public void drawSequence(SequenceI seq, SequenceGroup[] sg, - int start, int end, int y1) - { - if (seq == null) - { - return; - } - - allGroups = sg; - - drawBoxes(seq, start, end, y1); - - if (av.validCharWidth) - { - drawText(seq, start, end, y1); - } - } - - public void drawBoxes(SequenceI seq, int start, int end, int y1) - { - int i = start; - int length = seq.getLength(); - - int curStart = -1; - int curWidth = av.charWidth; - - Color tempColour = null; - while (i <= end) - { - resBoxColour = Color.white; - if (i < length) - { - if (inCurrentSequenceGroup(i)) - { - if (currentSequenceGroup.getDisplayBoxes()) - { - getBoxColour(currentSequenceGroup.cs, seq, i); - } - } - else if (av.getShowBoxes()) - { - getBoxColour(av.getGlobalColourScheme(), seq, i); - } - } - - if (resBoxColour != tempColour) - { - if (tempColour != null) - { - graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, - av.charHeight); - } - graphics.setColor(resBoxColour); - - curStart = i; - curWidth = av.charWidth; - tempColour = resBoxColour; - - } - else - { - curWidth += av.charWidth; - } - - i++; - } - - graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, - av.charHeight); - } - - public void drawText(SequenceI seq, int start, int end, int y1) - { - Font boldFont = null; - boolean bold = false; - if (av.upperCasebold) - { - boldFont = new Font(av.getFont().getName(), Font.BOLD, av.charHeight); - - graphics.setFont(av.getFont()); - } - - y1 += av.charHeight - av.charHeight / 5; // height/5 replaces pady - - int charOffset = 0; - - // Need to find the sequence position here. - if (end + 1 >= seq.getLength()) - { - end = seq.getLength() - 1; - } - - char s = ' '; - - for (int i = start; i <= end; i++) - { - graphics.setColor(Color.black); - - s = seq.getCharAt(i); - if (!renderGaps && jalview.util.Comparison.isGap(s)) - { - continue; - } - - if (inCurrentSequenceGroup(i)) - { - if (!currentSequenceGroup.getDisplayText()) - { - continue; - } - - if (currentSequenceGroup.getColourText()) - { - getBoxColour(currentSequenceGroup.cs, seq, i); - graphics.setColor(resBoxColour.darker()); - } - } - else - { - if (!av.getShowText()) - { - continue; - } - - if (av.getColourText()) - { - getBoxColour(av.getGlobalColourScheme(), seq, i); - if (av.getShowBoxes()) - { - graphics.setColor(resBoxColour.darker()); - } - else - { - graphics.setColor(resBoxColour); - } - } - } - - if (av.upperCasebold) - { - fm = graphics.getFontMetrics(); - if ('A' <= s && s <= 'Z') - { - if (!bold) - { - - graphics.setFont(boldFont); - } - bold = true; - } - else if (bold) - { - graphics.setFont(av.font); - bold = false; - } - - } - - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), - charOffset + av.charWidth * (i - start), - y1); - } - - } - - boolean inCurrentSequenceGroup(int res) - { - if (allGroups == null) - { - return false; - } - - for (int i = 0; i < allGroups.length; i++) - { - if (allGroups[i].getStartRes() <= res && allGroups[i].getEndRes() >= res) - { - currentSequenceGroup = allGroups[i]; - return true; - } - } - - return false; - } - - public void drawHighlightedText(SequenceI seq, int start, int end, int x1, - int y1) - { - int pady = av.charHeight / 5; - int charOffset = 0; - graphics.setColor(Color.black); - graphics.fillRect(x1, y1, av.charWidth * (end - start + 1), av.charHeight); - graphics.setColor(Color.white); - - char s = '~'; - // Need to find the sequence position here. - if (av.validCharWidth) - { - for (int i = start; i <= end; i++) - { - if (i < seq.getLength()) - { - s = seq.getCharAt(i); - } - - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), - charOffset + x1 + av.charWidth * (i - start), - y1 + av.charHeight - pady); - } - } - } - - public void drawCursor(SequenceI seq, int res, int x1, int y1) - { - int pady = av.charHeight / 5; - int charOffset = 0; - graphics.setColor(Color.black); - graphics.fillRect(x1, y1, av.charWidth, av.charHeight); - graphics.setColor(Color.white); - - graphics.setColor(Color.white); - - char s = seq.getCharAt(res); - if (av.validCharWidth) - { - - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), - charOffset + x1, - (y1 + av.charHeight) - pady); - } - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.awt.*; + +import jalview.datamodel.*; +import jalview.schemes.*; + +public class SequenceRenderer +{ + AlignViewport av; + + FontMetrics fm; + + boolean renderGaps = true; + + SequenceGroup currentSequenceGroup = null; + + SequenceGroup[] allGroups = null; + + Color resBoxColour; + + Graphics graphics; + + boolean forOverview = false; + + public SequenceRenderer(AlignViewport av) + { + this.av = av; + } + + /** + * DOCUMENT ME! + * + * @param b + * DOCUMENT ME! + */ + public void prepare(Graphics g, boolean renderGaps) + { + graphics = g; + fm = g.getFontMetrics(); + + this.renderGaps = renderGaps; + } + + public Color getResidueBoxColour(SequenceI seq, int i) + { + allGroups = av.alignment.findAllGroups(seq); + + if (inCurrentSequenceGroup(i)) + { + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.globalColourScheme, seq, i); + } + + return resBoxColour; + } + + void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) + { + if (cs != null) + { + resBoxColour = cs.findColour(seq.getCharAt(i), i); + } + else if (forOverview + && !jalview.util.Comparison.isGap(seq.getCharAt(i))) + { + resBoxColour = Color.lightGray; + } + else + { + resBoxColour = Color.white; + } + + } + + public Color findSequenceColour(SequenceI seq, int i) + { + allGroups = av.alignment.findAllGroups(seq); + drawBoxes(seq, i, i, 0); + return resBoxColour; + } + + public void drawSequence(SequenceI seq, SequenceGroup[] sg, int start, + int end, int y1) + { + if (seq == null) + { + return; + } + + allGroups = sg; + + drawBoxes(seq, start, end, y1); + + if (av.validCharWidth) + { + drawText(seq, start, end, y1); + } + } + + public void drawBoxes(SequenceI seq, int start, int end, int y1) + { + int i = start; + int length = seq.getLength(); + + int curStart = -1; + int curWidth = av.charWidth; + + Color tempColour = null; + while (i <= end) + { + resBoxColour = Color.white; + if (i < length) + { + if (inCurrentSequenceGroup(i)) + { + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); + } + } + + if (resBoxColour != tempColour) + { + if (tempColour != null) + { + graphics.fillRect(av.charWidth * (curStart - start), y1, + curWidth, av.charHeight); + } + graphics.setColor(resBoxColour); + + curStart = i; + curWidth = av.charWidth; + tempColour = resBoxColour; + + } + else + { + curWidth += av.charWidth; + } + + i++; + } + + graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, + av.charHeight); + } + + public void drawText(SequenceI seq, int start, int end, int y1) + { + Font boldFont = null; + boolean bold = false; + if (av.upperCasebold) + { + boldFont = new Font(av.getFont().getName(), Font.BOLD, av.charHeight); + + graphics.setFont(av.getFont()); + } + + y1 += av.charHeight - av.charHeight / 5; // height/5 replaces pady + + int charOffset = 0; + + // Need to find the sequence position here. + if (end + 1 >= seq.getLength()) + { + end = seq.getLength() - 1; + } + + char s = ' '; + + for (int i = start; i <= end; i++) + { + graphics.setColor(Color.black); + + s = seq.getCharAt(i); + if (!renderGaps && jalview.util.Comparison.isGap(s)) + { + continue; + } + + if (inCurrentSequenceGroup(i)) + { + if (!currentSequenceGroup.getDisplayText()) + { + continue; + } + + if (currentSequenceGroup.getColourText()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + graphics.setColor(resBoxColour.darker()); + } + } + else + { + if (!av.getShowText()) + { + continue; + } + + if (av.getColourText()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); + if (av.getShowBoxes()) + { + graphics.setColor(resBoxColour.darker()); + } + else + { + graphics.setColor(resBoxColour); + } + } + } + + if (av.upperCasebold) + { + fm = graphics.getFontMetrics(); + if ('A' <= s && s <= 'Z') + { + if (!bold) + { + + graphics.setFont(boldFont); + } + bold = true; + } + else if (bold) + { + graphics.setFont(av.font); + bold = false; + } + + } + + charOffset = (av.charWidth - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), charOffset + av.charWidth + * (i - start), y1); + } + + } + + boolean inCurrentSequenceGroup(int res) + { + if (allGroups == null) + { + return false; + } + + for (int i = 0; i < allGroups.length; i++) + { + if (allGroups[i].getStartRes() <= res + && allGroups[i].getEndRes() >= res) + { + currentSequenceGroup = allGroups[i]; + return true; + } + } + + return false; + } + + public void drawHighlightedText(SequenceI seq, int start, int end, + int x1, int y1) + { + int pady = av.charHeight / 5; + int charOffset = 0; + graphics.setColor(Color.black); + graphics.fillRect(x1, y1, av.charWidth * (end - start + 1), + av.charHeight); + graphics.setColor(Color.white); + + char s = '~'; + // Need to find the sequence position here. + if (av.validCharWidth) + { + for (int i = start; i <= end; i++) + { + if (i < seq.getLength()) + { + s = seq.getCharAt(i); + } + + charOffset = (av.charWidth - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), charOffset + x1 + + av.charWidth * (i - start), y1 + av.charHeight - pady); + } + } + } + + public void drawCursor(SequenceI seq, int res, int x1, int y1) + { + int pady = av.charHeight / 5; + int charOffset = 0; + graphics.setColor(Color.black); + graphics.fillRect(x1, y1, av.charWidth, av.charHeight); + graphics.setColor(Color.white); + + graphics.setColor(Color.white); + + char s = seq.getCharAt(res); + if (av.validCharWidth) + { + + charOffset = (av.charWidth - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), charOffset + x1, + (y1 + av.charHeight) - pady); + } + } + +} diff --git a/src/jalview/appletgui/SliderPanel.java b/src/jalview/appletgui/SliderPanel.java index 8507331..a05bbf0 100755 --- a/src/jalview/appletgui/SliderPanel.java +++ b/src/jalview/appletgui/SliderPanel.java @@ -1,363 +1,377 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; -import jalview.schemes.*; - -public class SliderPanel - extends Panel implements ActionListener, - AdjustmentListener, - MouseListener -{ - AlignmentPanel ap; - boolean forConservation = true; - ColourSchemeI cs; - - static Frame conservationSlider; - static Frame PIDSlider; - - public static int setConservationSlider(AlignmentPanel ap, ColourSchemeI cs, - String source) - { - SliderPanel sp = null; - - if (conservationSlider == null) - { - sp = new SliderPanel(ap, cs.getConservationInc(), true, cs); - conservationSlider = new Frame(); - conservationSlider.add(sp); - } - else - { - sp = (SliderPanel) conservationSlider.getComponent(0); - sp.cs = cs; - } - - conservationSlider.setTitle("Conservation Colour Increment (" + source + - ")"); - if (ap.av.alignment.getGroups() != null) - { - sp.setAllGroupsCheckEnabled(true); - } - else - { - sp.setAllGroupsCheckEnabled(false); - } - - return sp.getValue(); - } - - public static void showConservationSlider() - { - try - { - PIDSlider.setVisible(false); - PIDSlider = null; - } - catch (Exception ex) - {} - - if (!conservationSlider.isVisible()) - { - jalview.bin.JalviewLite.addFrame(conservationSlider, - conservationSlider.getTitle(), 420, 100); - conservationSlider.addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent e) - { - conservationSlider = null; - } - }); - - } - - } - - public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, - String source) - { - SliderPanel pid = null; - if (PIDSlider == null) - { - pid = new SliderPanel(ap, 50, false, cs); - PIDSlider = new Frame(); - PIDSlider.add(pid); - } - else - { - pid = (SliderPanel) PIDSlider.getComponent(0); - pid.cs = cs; - } - PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")"); - - if (ap.av.alignment.getGroups() != null) - { - pid.setAllGroupsCheckEnabled(true); - } - else - { - pid.setAllGroupsCheckEnabled(false); - } - - return pid.getValue(); - - } - - public static void showPIDSlider() - { - try - { - conservationSlider.setVisible(false); - conservationSlider = null; - } - catch (Exception ex) - {} - - if (!PIDSlider.isVisible()) - { - jalview.bin.JalviewLite.addFrame(PIDSlider, PIDSlider.getTitle(), 420, - 100); - PIDSlider.addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent e) - { - PIDSlider = null; - } - }); - } - - } - - public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, - ColourSchemeI cs) - { - try - { - jbInit(); - } - catch (Exception e) - { - e.printStackTrace(); - } - this.ap = ap; - this.cs = cs; - forConservation = forConserve; - undoButton.setVisible(false); - applyButton.setVisible(false); - if (forConservation) - { - label.setText("Modify conservation visibility"); - slider.setMinimum(0); - slider.setMaximum(50 + slider.getVisibleAmount()); - slider.setUnitIncrement(1); - } - else - { - label.setText("Colour residues above % occurence"); - slider.setMinimum(0); - slider.setMaximum(100 + slider.getVisibleAmount()); - slider.setBlockIncrement(1); - } - - slider.addAdjustmentListener(this); - slider.addMouseListener(this); - - slider.setValue(value); - valueField.setText(value + ""); - } - - public void valueChanged(int i) - { - if (cs == null) - { - return; - } - - ColourSchemeI toChange = null; - Vector allGroups = null; - int groupIndex = 0; - - if (allGroupsCheck.getState()) - { - allGroups = ap.av.alignment.getGroups(); - groupIndex = allGroups.size() - 1; - } - else - { - toChange = cs; - } - - while (groupIndex > -1) - { - if (allGroups != null) - { - toChange = ( (SequenceGroup) allGroups.elementAt(groupIndex)).cs; - } - - if (forConservation) - { - toChange.setConservationInc(i); - } - else - { - toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus()); - } - - groupIndex--; - } - - ap.seqPanel.seqCanvas.repaint(); - - } - - public void setAllGroupsCheckEnabled(boolean b) - { - allGroupsCheck.setEnabled(b); - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == applyButton) - { - applyButton_actionPerformed(); - } - else if (evt.getSource() == undoButton) - { - undoButton_actionPerformed(); - } - else if (evt.getSource() == valueField) - { - valueField_actionPerformed(); - } - } - - public void adjustmentValueChanged(AdjustmentEvent evt) - { - valueField.setText(slider.getValue() + ""); - valueChanged(slider.getValue()); - } - - public void valueField_actionPerformed() - { - try - { - int i = Integer.parseInt(valueField.getText()); - slider.setValue(i); - } - catch (Exception ex) - { - valueField.setText(slider.getValue() + ""); - } - } - - public void setValue(int value) - { - slider.setValue(value); - } - - public int getValue() - { - return Integer.parseInt(valueField.getText()); - } - - // this is used for conservation colours, PID colours and redundancy threshold - protected Scrollbar slider = new Scrollbar(); - protected TextField valueField = new TextField(); - protected Label label = new Label(); - Panel jPanel1 = new Panel(); - Panel jPanel2 = new Panel(); - protected Button applyButton = new Button(); - protected Button undoButton = new Button(); - FlowLayout flowLayout1 = new FlowLayout(); - protected Checkbox allGroupsCheck = new Checkbox(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - FlowLayout flowLayout2 = new FlowLayout(); - - private void jbInit() - throws Exception - { - this.setLayout(borderLayout2); - - // slider.setMajorTickSpacing(10); - // slider.setMinorTickSpacing(1); - // slider.setPaintTicks(true); - slider.setBackground(Color.white); - slider.setFont(new java.awt.Font("Verdana", 0, 11)); - slider.setOrientation(0); - valueField.setFont(new java.awt.Font("Verdana", 0, 11)); - valueField.setText(" "); - valueField.addActionListener(this); - label.setFont(new java.awt.Font("Verdana", 0, 11)); - label.setText("set this label text"); - jPanel1.setLayout(borderLayout1); - jPanel2.setLayout(flowLayout1); - applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); - applyButton.setLabel("Apply"); - applyButton.addActionListener(this); - undoButton.setEnabled(false); - undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); - undoButton.setLabel("Undo"); - undoButton.addActionListener(this); - allGroupsCheck.setEnabled(false); - allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); - allGroupsCheck.setLabel("Apply threshold to all groups"); - allGroupsCheck.setName("Apply to all Groups"); - this.setBackground(Color.white); - this.setForeground(Color.black); - jPanel2.add(label, null); - jPanel2.add(applyButton, null); - jPanel2.add(undoButton, null); - jPanel2.add(allGroupsCheck); - jPanel1.add(valueField, java.awt.BorderLayout.EAST); - jPanel1.add(slider, java.awt.BorderLayout.CENTER); - this.add(jPanel1, java.awt.BorderLayout.SOUTH); - this.add(jPanel2, java.awt.BorderLayout.CENTER); - } - - protected void applyButton_actionPerformed() - {} - - protected void undoButton_actionPerformed() - {} - - public void mousePressed(MouseEvent evt) - {} - - public void mouseReleased(MouseEvent evt) - { - ap.paintAlignment(true); - } - - public void mouseClicked(MouseEvent evt) - {} - - public void mouseEntered(MouseEvent evt) - {} - - public void mouseExited(MouseEvent evt) - {} -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.util.*; + +import java.awt.*; +import java.awt.event.*; + +import jalview.datamodel.*; +import jalview.schemes.*; + +public class SliderPanel extends Panel implements ActionListener, + AdjustmentListener, MouseListener +{ + AlignmentPanel ap; + + boolean forConservation = true; + + ColourSchemeI cs; + + static Frame conservationSlider; + + static Frame PIDSlider; + + public static int setConservationSlider(AlignmentPanel ap, + ColourSchemeI cs, String source) + { + SliderPanel sp = null; + + if (conservationSlider == null) + { + sp = new SliderPanel(ap, cs.getConservationInc(), true, cs); + conservationSlider = new Frame(); + conservationSlider.add(sp); + } + else + { + sp = (SliderPanel) conservationSlider.getComponent(0); + sp.cs = cs; + } + + conservationSlider.setTitle("Conservation Colour Increment (" + source + + ")"); + if (ap.av.alignment.getGroups() != null) + { + sp.setAllGroupsCheckEnabled(true); + } + else + { + sp.setAllGroupsCheckEnabled(false); + } + + return sp.getValue(); + } + + public static void showConservationSlider() + { + try + { + PIDSlider.setVisible(false); + PIDSlider = null; + } catch (Exception ex) + { + } + + if (!conservationSlider.isVisible()) + { + jalview.bin.JalviewLite.addFrame(conservationSlider, + conservationSlider.getTitle(), 420, 100); + conservationSlider.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + conservationSlider = null; + } + }); + + } + + } + + public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, + String source) + { + SliderPanel pid = null; + if (PIDSlider == null) + { + pid = new SliderPanel(ap, 50, false, cs); + PIDSlider = new Frame(); + PIDSlider.add(pid); + } + else + { + pid = (SliderPanel) PIDSlider.getComponent(0); + pid.cs = cs; + } + PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")"); + + if (ap.av.alignment.getGroups() != null) + { + pid.setAllGroupsCheckEnabled(true); + } + else + { + pid.setAllGroupsCheckEnabled(false); + } + + return pid.getValue(); + + } + + public static void showPIDSlider() + { + try + { + conservationSlider.setVisible(false); + conservationSlider = null; + } catch (Exception ex) + { + } + + if (!PIDSlider.isVisible()) + { + jalview.bin.JalviewLite.addFrame(PIDSlider, PIDSlider.getTitle(), + 420, 100); + PIDSlider.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + PIDSlider = null; + } + }); + } + + } + + public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, + ColourSchemeI cs) + { + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + this.ap = ap; + this.cs = cs; + forConservation = forConserve; + undoButton.setVisible(false); + applyButton.setVisible(false); + if (forConservation) + { + label.setText("Modify conservation visibility"); + slider.setMinimum(0); + slider.setMaximum(50 + slider.getVisibleAmount()); + slider.setUnitIncrement(1); + } + else + { + label.setText("Colour residues above % occurence"); + slider.setMinimum(0); + slider.setMaximum(100 + slider.getVisibleAmount()); + slider.setBlockIncrement(1); + } + + slider.addAdjustmentListener(this); + slider.addMouseListener(this); + + slider.setValue(value); + valueField.setText(value + ""); + } + + public void valueChanged(int i) + { + if (cs == null) + { + return; + } + + ColourSchemeI toChange = null; + Vector allGroups = null; + int groupIndex = 0; + + if (allGroupsCheck.getState()) + { + allGroups = ap.av.alignment.getGroups(); + groupIndex = allGroups.size() - 1; + } + else + { + toChange = cs; + } + + while (groupIndex > -1) + { + if (allGroups != null) + { + toChange = ((SequenceGroup) allGroups.elementAt(groupIndex)).cs; + } + + if (forConservation) + { + toChange.setConservationInc(i); + } + else + { + toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus()); + } + + groupIndex--; + } + + ap.seqPanel.seqCanvas.repaint(); + + } + + public void setAllGroupsCheckEnabled(boolean b) + { + allGroupsCheck.setEnabled(b); + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == applyButton) + { + applyButton_actionPerformed(); + } + else if (evt.getSource() == undoButton) + { + undoButton_actionPerformed(); + } + else if (evt.getSource() == valueField) + { + valueField_actionPerformed(); + } + } + + public void adjustmentValueChanged(AdjustmentEvent evt) + { + valueField.setText(slider.getValue() + ""); + valueChanged(slider.getValue()); + } + + public void valueField_actionPerformed() + { + try + { + int i = Integer.parseInt(valueField.getText()); + slider.setValue(i); + } catch (Exception ex) + { + valueField.setText(slider.getValue() + ""); + } + } + + public void setValue(int value) + { + slider.setValue(value); + } + + public int getValue() + { + return Integer.parseInt(valueField.getText()); + } + + // this is used for conservation colours, PID colours and redundancy threshold + protected Scrollbar slider = new Scrollbar(); + + protected TextField valueField = new TextField(); + + protected Label label = new Label(); + + Panel jPanel1 = new Panel(); + + Panel jPanel2 = new Panel(); + + protected Button applyButton = new Button(); + + protected Button undoButton = new Button(); + + FlowLayout flowLayout1 = new FlowLayout(); + + protected Checkbox allGroupsCheck = new Checkbox(); + + BorderLayout borderLayout1 = new BorderLayout(); + + BorderLayout borderLayout2 = new BorderLayout(); + + FlowLayout flowLayout2 = new FlowLayout(); + + private void jbInit() throws Exception + { + this.setLayout(borderLayout2); + + // slider.setMajorTickSpacing(10); + // slider.setMinorTickSpacing(1); + // slider.setPaintTicks(true); + slider.setBackground(Color.white); + slider.setFont(new java.awt.Font("Verdana", 0, 11)); + slider.setOrientation(0); + valueField.setFont(new java.awt.Font("Verdana", 0, 11)); + valueField.setText(" "); + valueField.addActionListener(this); + label.setFont(new java.awt.Font("Verdana", 0, 11)); + label.setText("set this label text"); + jPanel1.setLayout(borderLayout1); + jPanel2.setLayout(flowLayout1); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(this); + undoButton.setEnabled(false); + undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); + undoButton.setLabel("Undo"); + undoButton.addActionListener(this); + allGroupsCheck.setEnabled(false); + allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); + allGroupsCheck.setLabel("Apply threshold to all groups"); + allGroupsCheck.setName("Apply to all Groups"); + this.setBackground(Color.white); + this.setForeground(Color.black); + jPanel2.add(label, null); + jPanel2.add(applyButton, null); + jPanel2.add(undoButton, null); + jPanel2.add(allGroupsCheck); + jPanel1.add(valueField, java.awt.BorderLayout.EAST); + jPanel1.add(slider, java.awt.BorderLayout.CENTER); + this.add(jPanel1, java.awt.BorderLayout.SOUTH); + this.add(jPanel2, java.awt.BorderLayout.CENTER); + } + + protected void applyButton_actionPerformed() + { + } + + protected void undoButton_actionPerformed() + { + } + + public void mousePressed(MouseEvent evt) + { + } + + public void mouseReleased(MouseEvent evt) + { + ap.paintAlignment(true); + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } +} diff --git a/src/jalview/appletgui/Tooltip.java b/src/jalview/appletgui/Tooltip.java index 7de5193..0bbe98b 100755 --- a/src/jalview/appletgui/Tooltip.java +++ b/src/jalview/appletgui/Tooltip.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.applet.*; @@ -25,21 +24,25 @@ import java.util.*; import java.awt.*; import java.awt.event.*; -public class Tooltip - extends Canvas implements MouseListener, - MouseMotionListener +public class Tooltip extends Canvas implements MouseListener, + MouseMotionListener { private String[] tip; + private String lastTip = ""; + private boolean setPosition = false; + protected Component owner; private Container mainContainer; + private LayoutManager mainLayout; private boolean shown; private final int VERTICAL_OFFSET = 20; + private final int HORIZONTAL_ENLARGE = 10; int fontHeight = 0; @@ -77,15 +80,15 @@ public class Tooltip { if (lindex > 0) { - g.drawString(tip[i].substring(0, lindex), 3, (i + 1) * fontHeight - 3); + g.drawString(tip[i].substring(0, lindex), 3, (i + 1) * fontHeight + - 3); x += fm.stringWidth(tip[i].substring(0, lindex) + 3); } g.drawImage(linkImage, x, i * fontHeight + 1, this); if (lindex + 6 < tip[i].length()) { - g.drawString(tip[i].substring(lindex + 6), - x + linkImage.getWidth(this), - (i + 1) * fontHeight - 3); + g.drawString(tip[i].substring(lindex + 6), x + + linkImage.getWidth(this), (i + 1) * fontHeight - 3); } } else @@ -128,8 +131,7 @@ public class Tooltip index++; } - setSize(longestLine + HORIZONTAL_ENLARGE, - fontHeight * this.tip.length); + setSize(longestLine + HORIZONTAL_ENLARGE, fontHeight * this.tip.length); repaint(); @@ -137,21 +139,21 @@ public class Tooltip void setTipLocation(MouseEvent evt) { - if(mainContainer==null || owner==null) + if (mainContainer == null || owner == null) { return; } - setLocation( (owner.getLocationOnScreen().x - - mainContainer.getLocationOnScreen().x) + evt.getX(), - (owner.getLocationOnScreen().y - - mainContainer.getLocationOnScreen().y - + VERTICAL_OFFSET) + evt.getY()); + setLocation((owner.getLocationOnScreen().x - mainContainer + .getLocationOnScreen().x) + + evt.getX(), (owner.getLocationOnScreen().y + - mainContainer.getLocationOnScreen().y + VERTICAL_OFFSET) + + evt.getY()); // correction, whole tool tip must be visible if (mainContainer.getSize().width < (getLocation().x + getSize().width)) { setLocation(mainContainer.getSize().width - getSize().width, - getLocation().y); + getLocation().y); } } @@ -171,7 +173,7 @@ public class Tooltip Container parent = owner.getParent(); while (true) { - if ( (parent instanceof Applet) || (parent instanceof Frame)) + if ((parent instanceof Applet) || (parent instanceof Frame)) { mainContainer = parent; break; @@ -200,10 +202,12 @@ public class Tooltip } public void mouseReleased(MouseEvent me) - {} + { + } public void mouseClicked(MouseEvent me) - {} + { + } public void mouseMoved(MouseEvent me) { @@ -224,5 +228,6 @@ public class Tooltip } public void mouseDragged(MouseEvent me) - {} + { + } } diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index 425c7a9..8c445f0 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.util.*; @@ -29,28 +28,39 @@ import jalview.datamodel.*; import jalview.schemes.*; import jalview.util.*; -public class TreeCanvas - extends Panel implements MouseListener, MouseMotionListener +public class TreeCanvas extends Panel implements MouseListener, + MouseMotionListener { NJTree tree; + ScrollPane scrollPane; + AlignViewport av; + public static final String PLACEHOLDER = " * "; + Font font; + boolean fitToWindow = true; + boolean showDistances = false; + boolean showBootstrap = false; + boolean markPlaceholders = false; int offx = 20; + int offy; float threshold; String longestName; + int labelLength = -1; Hashtable nameHash = new Hashtable(); + Hashtable nodeHash = new Hashtable(); SequenceNode highlightNode; @@ -99,19 +109,19 @@ public class TreeCanvas has_placeholders = true; } - if (longestName.length() < ( (Sequence) lf.element()).getName() - .length()) + if (longestName.length() < ((Sequence) lf.element()).getName() + .length()) { - longestName = TreeCanvas.PLACEHOLDER + - ( (Sequence) lf.element()).getName(); + longestName = TreeCanvas.PLACEHOLDER + + ((Sequence) lf.element()).getName(); } } setMarkPlaceholders(has_placeholders); } - public void drawNode(Graphics g, SequenceNode node, float chunk, float scale, - int width, int offx, int offy) + public void drawNode(Graphics g, SequenceNode node, float chunk, + float scale, int width, int offx, int offy) { if (node == null) { @@ -125,14 +135,14 @@ public class TreeCanvas float height = node.height; float dist = node.dist; - int xstart = (int) ( (height - dist) * scale) + offx; + int xstart = (int) ((height - dist) * scale) + offx; int xend = (int) (height * scale) + offx; int ypos = (int) (node.ycount * chunk) + offy; if (node.element() instanceof SequenceI) { - SequenceI seq = (SequenceI) ( (SequenceNode) node).element(); + SequenceI seq = (SequenceI) ((SequenceNode) node).element(); if (av.getSequenceColour(seq) == Color.white) { @@ -160,8 +170,8 @@ public class TreeCanvas if (showBootstrap) { int btstrap = node.getBootstrap(); - if (btstrap>-1) - { + if (btstrap > -1) + { if (showDistances) { nodeLabel = nodeLabel + " : "; @@ -174,21 +184,23 @@ public class TreeCanvas g.drawString(nodeLabel, xstart + 2, ypos - 2); } - String name = (markPlaceholders && node.isPlaceholder()) ? - (PLACEHOLDER + node.getName()) : node.getName(); + String name = (markPlaceholders && node.isPlaceholder()) ? (PLACEHOLDER + node + .getName()) + : node.getName(); FontMetrics fm = g.getFontMetrics(font); int charWidth = fm.stringWidth(name) + 3; int charHeight = fm.getHeight(); Rectangle rect = new Rectangle(xend + 10, ypos - charHeight, - charWidth, charHeight); + charWidth, charHeight); - nameHash.put( (SequenceI) node.element(), rect); + nameHash.put((SequenceI) node.element(), rect); // Colour selected leaves differently SequenceGroup selected = av.getSelectionGroup(); - if (selected != null && - selected.getSequences(null).contains( (SequenceI) node.element())) + if (selected != null + && selected.getSequences(null).contains( + (SequenceI) node.element())) { g.setColor(Color.gray); @@ -200,17 +212,19 @@ public class TreeCanvas } else { - drawNode(g, (SequenceNode) node.left(), chunk, scale, width, offx, offy); - drawNode(g, (SequenceNode) node.right(), chunk, scale, width, offx, offy); + drawNode(g, (SequenceNode) node.left(), chunk, scale, width, offx, + offy); + drawNode(g, (SequenceNode) node.right(), chunk, scale, width, offx, + offy); float height = node.height; float dist = node.dist; - int xstart = (int) ( (height - dist) * scale) + offx; + int xstart = (int) ((height - dist) * scale) + offx; int xend = (int) (height * scale) + offx; int ypos = (int) (node.ycount * chunk) + offy; - g.setColor( ( (SequenceNode) node).color.darker()); + g.setColor(((SequenceNode) node).color.darker()); // Draw horizontal line g.drawLine(xstart, ypos, xend, ypos); @@ -223,14 +237,16 @@ public class TreeCanvas g.fillRect(xend - 2, ypos - 2, 4, 4); } - int ystart = (int) ( ( (SequenceNode) node.left()).ycount * chunk) + offy; - int yend = (int) ( ( (SequenceNode) node.right()).ycount * chunk) + offy; + int ystart = (int) (((SequenceNode) node.left()).ycount * chunk) + + offy; + int yend = (int) (((SequenceNode) node.right()).ycount * chunk) + + offy; Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); nodeHash.put(node, pos); - g.drawLine( (int) (height * scale) + offx, ystart, - (int) (height * scale) + offx, yend); + g.drawLine((int) (height * scale) + offx, ystart, + (int) (height * scale) + offx, yend); String nodeLabel = ""; @@ -242,8 +258,8 @@ public class TreeCanvas if (showBootstrap) { int btstrap = node.getBootstrap(); - if (btstrap>-1) - { + if (btstrap > -1) + { if (showDistances) { nodeLabel = nodeLabel + " : "; @@ -269,8 +285,8 @@ public class TreeCanvas Object ob = keys.nextElement(); Rectangle rect = (Rectangle) nameHash.get(ob); - if (x >= rect.x && x <= (rect.x + rect.width) && - y >= rect.y && y <= (rect.y + rect.height)) + if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y + && y <= (rect.y + rect.height)) { return ob; } @@ -282,8 +298,8 @@ public class TreeCanvas Object ob = keys.nextElement(); Rectangle rect = (Rectangle) nodeHash.get(ob); - if (x >= rect.x && x <= (rect.x + rect.width) && - y >= rect.y && y <= (rect.y + rect.height)) + if (x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y + && y <= (rect.y + rect.height)) { return ob; } @@ -299,12 +315,11 @@ public class TreeCanvas SequenceNode top = tree.getTopNode(); - float wscale = (float) (width * .8 - offx * 2) / tree.getMaxHeight() - ; + float wscale = (float) (width * .8 - offx * 2) / tree.getMaxHeight(); if (top.count == 0) { - top.count = ( (SequenceNode) top.left()).count + - ( (SequenceNode) top.right()).count; + top.count = ((SequenceNode) top.left()).count + + ((SequenceNode) top.right()).count; } float chunk = (float) (height - offy) / top.count; @@ -312,7 +327,7 @@ public class TreeCanvas } public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, - float scale, int width, int offx, int offy) + float scale, int width, int offx, int offy) { if (node == null) { @@ -322,9 +337,9 @@ public class TreeCanvas if (node.left() == null && node.right() == null) { float height = node.height; - //float dist = node.dist; + // float dist = node.dist; - //int xstart = (int) ( (height - dist) * scale) + offx; + // int xstart = (int) ( (height - dist) * scale) + offx; int xend = (int) (height * scale) + offx; int ypos = (int) (node.ycount * chunk) + offy; @@ -344,10 +359,10 @@ public class TreeCanvas } else { - pickNode(pickBox, (SequenceNode) node.left(), chunk, scale, width, offx, - offy); - pickNode(pickBox, (SequenceNode) node.right(), chunk, scale, width, offx, - offy); + pickNode(pickBox, (SequenceNode) node.left(), chunk, scale, width, + offx, offy); + pickNode(pickBox, (SequenceNode) node.right(), chunk, scale, width, + offx, offy); } } @@ -364,14 +379,14 @@ public class TreeCanvas if (node.element() instanceof SequenceI) { - av.setSequenceColour( (SequenceI) node.element(), c); + av.setSequenceColour((SequenceI) node.element(), c); } } else { node.color = c; - setColor( (SequenceNode) node.left(), c); - setColor( (SequenceNode) node.right(), c); + setColor((SequenceNode) node.left(), c); + setColor((SequenceNode) node.right(), c); } } @@ -421,16 +436,20 @@ public class TreeCanvas g.setColor(Color.white); g.fillRect(0, 0, width, height); - labelLength = g.getFontMetrics(font).stringWidth(longestName) + 20; //20 allows for scrollbar + labelLength = g.getFontMetrics(font).stringWidth(longestName) + 20; // 20 + // allows + // for + // scrollbar - float wscale = (float) (width - labelLength - offx * 2) / tree.getMaxHeight(); + float wscale = (float) (width - labelLength - offx * 2) + / tree.getMaxHeight(); SequenceNode top = tree.getTopNode(); if (top.count == 0) { - top.count = ( (SequenceNode) top.left()).count + - ( (SequenceNode) top.right()).count; + top.count = ((SequenceNode) top.left()).count + + ((SequenceNode) top.right()).count; } float chunk = (float) (height - offy) / top.count; @@ -447,8 +466,8 @@ public class TreeCanvas g.setColor(Color.gray); } - int x = (int) (threshold * - (float) (getSize().width - labelLength - 2 * offx) + offx); + int x = (int) (threshold + * (float) (getSize().width - labelLength - 2 * offx) + offx); g.drawLine(x, 0, x, getSize().height); } @@ -456,13 +475,16 @@ public class TreeCanvas } public void mouseReleased(MouseEvent e) - {} + { + } public void mouseEntered(MouseEvent e) - {} + { + } public void mouseExited(MouseEvent e) - {} + { + } public void mouseClicked(MouseEvent evt) { @@ -481,8 +503,8 @@ public class TreeCanvas for (int i = 0; i < leaves.size(); i++) { - SequenceI seq = - (SequenceI) ( (SequenceNode) leaves.elementAt(i)).element(); + SequenceI seq = (SequenceI) ((SequenceNode) leaves.elementAt(i)) + .element(); treeSelectionChanged(seq); } } @@ -493,7 +515,8 @@ public class TreeCanvas } public void mouseDragged(MouseEvent ect) - {} + { + } public void mouseMoved(MouseEvent evt) { @@ -527,19 +550,19 @@ public class TreeCanvas if (ob instanceof SequenceI) { - treeSelectionChanged( (Sequence) ob); + treeSelectionChanged((Sequence) ob); PaintRefresher.Refresh(this, av.getSequenceSetId()); repaint(); return; } - else if (! (ob instanceof SequenceNode)) + else if (!(ob instanceof SequenceNode)) { // Find threshold if (tree.getMaxHeight() != 0) { - threshold = (float) (x - offx) / - (float) (getSize().width - labelLength - 2 * offx); + threshold = (float) (x - offx) + / (float) (getSize().width - labelLength - 2 * offx); tree.getGroups().removeAllElements(); tree.groupNodes(tree.getTopNode(), threshold); @@ -564,18 +587,18 @@ public class TreeCanvas for (int i = 0; i < tree.getGroups().size(); i++) { - Color col = new Color( (int) (Math.random() * 255), - (int) (Math.random() * 255), - (int) (Math.random() * 255)); - setColor( (SequenceNode) tree.getGroups().elementAt(i), col.brighter()); + Color col = new Color((int) (Math.random() * 255), (int) (Math + .random() * 255), (int) (Math.random() * 255)); + setColor((SequenceNode) tree.getGroups().elementAt(i), col.brighter()); - Vector l = tree.findLeaves( (SequenceNode) tree.getGroups().elementAt( - i), new Vector()); + Vector l = tree.findLeaves((SequenceNode) tree.getGroups().elementAt( + i), new Vector()); Vector sequences = new Vector(); for (int j = 0; j < l.size(); j++) { - SequenceI s1 = (SequenceI) ( (SequenceNode) l.elementAt(j)).element(); + SequenceI s1 = (SequenceI) ((SequenceNode) l.elementAt(j)) + .element(); if (!sequences.contains(s1)) { sequences.addElement(s1); @@ -588,38 +611,32 @@ public class TreeCanvas { if (av.getGlobalColourScheme() instanceof UserColourScheme) { - cs = new UserColourScheme( - ( (UserColourScheme) av.getGlobalColourScheme()).getColours()); + cs = new UserColourScheme(((UserColourScheme) av + .getGlobalColourScheme()).getColours()); } else { - cs = ColourSchemeProperty.getColour(sequences, - av.alignment.getWidth(), - ColourSchemeProperty. - getColourName( - av.getGlobalColourScheme())); + cs = ColourSchemeProperty.getColour(sequences, av.alignment + .getWidth(), ColourSchemeProperty.getColourName(av + .getGlobalColourScheme())); } - cs.setThreshold(av.getGlobalColourScheme().getThreshold(), - av.getIgnoreGapsConsensus()); + cs.setThreshold(av.getGlobalColourScheme().getThreshold(), av + .getIgnoreGapsConsensus()); } - SequenceGroup sg = new SequenceGroup(sequences, "", - cs, true, true, - false, 0, - av.alignment.getWidth() - 1); + SequenceGroup sg = new SequenceGroup(sequences, "", cs, true, true, + false, 0, av.alignment.getWidth() - 1); sg.setName("JTreeGroup:" + sg.hashCode()); sg.setIdColour(col); if (av.getGlobalColourScheme() != null - && av.getGlobalColourScheme().conservationApplied()) + && av.getGlobalColourScheme().conservationApplied()) { Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.getSequences(null), - sg.getStartRes(), - sg.getEndRes()); + ResidueProperties.propHash, 3, sg.getSequences(null), sg + .getStartRes(), sg.getEndRes()); c.calculate(); c.verdict(false, av.ConsPercGaps); diff --git a/src/jalview/appletgui/TreePanel.java b/src/jalview/appletgui/TreePanel.java index 6ab01aa..d6c0069 100755 --- a/src/jalview/appletgui/TreePanel.java +++ b/src/jalview/appletgui/TreePanel.java @@ -1,22 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.appletgui; import java.awt.*; @@ -27,16 +26,23 @@ import jalview.analysis.*; import jalview.datamodel.*; import jalview.io.*; -public class TreePanel - extends EmbmenuFrame implements ActionListener, ItemListener +public class TreePanel extends EmbmenuFrame implements ActionListener, + ItemListener { SequenceI[] seq; + String type; + String pwtype; + int start; + int end; + TreeCanvas treeCanvas; + NJTree tree; + AlignViewport av; public NJTree getTree() @@ -46,13 +52,19 @@ public class TreePanel /** * Creates a new TreePanel object. - * - * @param av DOCUMENT ME! - * @param seqVector DOCUMENT ME! - * @param type DOCUMENT ME! - * @param pwtype DOCUMENT ME! - * @param s DOCUMENT ME! - * @param e DOCUMENT ME! + * + * @param av + * DOCUMENT ME! + * @param seqVector + * DOCUMENT ME! + * @param type + * DOCUMENT ME! + * @param pwtype + * DOCUMENT ME! + * @param s + * DOCUMENT ME! + * @param e + * DOCUMENT ME! */ public TreePanel(AlignViewport av, String type, String pwtype) { @@ -60,8 +72,7 @@ public class TreePanel { jbInit(); this.setMenuBar(jMenuBar1); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } @@ -71,73 +82,78 @@ public class TreePanel /** * Creates a new TreePanel object. - * - * @param av DOCUMENT ME! - * @param seqVector DOCUMENT ME! - * @param newtree DOCUMENT ME! - * @param type DOCUMENT ME! - * @param pwtype DOCUMENT ME! + * + * @param av + * DOCUMENT ME! + * @param seqVector + * DOCUMENT ME! + * @param newtree + * DOCUMENT ME! + * @param type + * DOCUMENT ME! + * @param pwtype + * DOCUMENT ME! */ - public TreePanel(AlignViewport av, - String type, - String pwtype, - NewickFile newtree) + public TreePanel(AlignViewport av, String type, String pwtype, + NewickFile newtree) { try { jbInit(); this.setMenuBar(jMenuBar1); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } initTreePanel(av, type, pwtype, newtree); } - void initTreePanel(AlignViewport av, - String type, - String pwtype, - NewickFile newTree) + + void initTreePanel(AlignViewport av, String type, String pwtype, + NewickFile newTree) { this.av = av; this.type = type; this.pwtype = pwtype; - treeCanvas = new TreeCanvas(av, scrollPane); TreeLoader tl = new TreeLoader(newTree); tl.start(); embedMenuIfNeeded(treeCanvas); scrollPane.add(treeCanvas, BorderLayout.CENTER); } + void showOriginalData() { - // decide if av alignment is sufficiently different to original data to warrant a new window to be created - // create new alignmnt window with hidden regions (unhiding hidden regions yields unaligned seqs) + // decide if av alignment is sufficiently different to original data to + // warrant a new window to be created + // create new alignmnt window with hidden regions (unhiding hidden regions + // yields unaligned seqs) // or create a selection box around columns in alignment view // test Alignment(SeqCigar[]) if (tree.seqData != null) { char gc = '-'; - try { + try + { // we try to get the associated view's gap character // but this may fail if the view was closed... - gc = av. - getGapCharacter(); - } catch (Exception ex) {}; - Object[] alAndColsel = tree.seqData.getAlignmentAndColumnSelection(gc); + gc = av.getGapCharacter(); + } catch (Exception ex) + { + } + ; + Object[] alAndColsel = tree.seqData + .getAlignmentAndColumnSelection(gc); if (alAndColsel != null && alAndColsel[0] != null) { - Alignment al = new Alignment( (SequenceI[]) alAndColsel[0]); - AlignFrame af = new AlignFrame(al, - av.applet, - "Original Data for Tree", - false); + Alignment al = new Alignment((SequenceI[]) alAndColsel[0]); + AlignFrame af = new AlignFrame(al, av.applet, + "Original Data for Tree", false); - af.viewport.setHiddenColumns( (ColumnSelection) alAndColsel[1]); + af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]); } } else @@ -146,10 +162,10 @@ public class TreePanel } } - class TreeLoader - extends Thread + class TreeLoader extends Thread { NewickFile newtree; + jalview.datamodel.AlignmentView odata = null; public TreeLoader(NewickFile newtree) @@ -163,12 +179,12 @@ public class TreePanel { if (odata == null) { - tree = new NJTree(av.alignment.getSequencesArray(), - newtree); + tree = new NJTree(av.alignment.getSequencesArray(), newtree); } else { - tree = new NJTree(av.alignment.getSequencesArray(), odata, newtree); + tree = new NJTree(av.alignment.getSequencesArray(), odata, + newtree); } } @@ -176,7 +192,8 @@ public class TreePanel { int start, end; SequenceI[] seqs; - AlignmentView seqStrings = av.getAlignmentView(av.getSelectionGroup() != null); + AlignmentView seqStrings = av.getAlignmentView(av + .getSelectionGroup() != null); if (av.getSelectionGroup() == null) { start = 0; @@ -254,7 +271,8 @@ public class TreePanel public void newickOutput_actionPerformed() { - jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); + jalview.io.NewickFile fout = new jalview.io.NewickFile(tree + .getTopNode()); String output = fout.print(false, true); CutAndPasteTransfer cap = new CutAndPasteTransfer(false, null); cap.setText(output); @@ -285,20 +303,30 @@ public class TreePanel } BorderLayout borderLayout1 = new BorderLayout(); + protected ScrollPane scrollPane = new ScrollPane(); + MenuBar jMenuBar1 = new MenuBar(); + Menu jMenu2 = new Menu(); + protected MenuItem fontSize = new MenuItem(); + protected CheckboxMenuItem bootstrapMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem distanceMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem placeholdersMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem fitToWindow = new CheckboxMenuItem(); + Menu fileMenu = new Menu(); + MenuItem newickOutput = new MenuItem(); + MenuItem inputData = new MenuItem(); - private void jbInit() - throws Exception + private void jbInit() throws Exception { setLayout(borderLayout1); this.setBackground(Color.white); diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 6e14146..0f30539 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -1,589 +1,606 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.appletgui; - -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import jalview.datamodel.*; -import jalview.schemes.*; - -public class UserDefinedColours - extends Panel implements ActionListener, AdjustmentListener -{ - - AlignmentPanel ap; - SequenceGroup seqGroup; - Button selectedButton; - Vector oldColours = new Vector(); - ColourSchemeI oldColourScheme; - Frame frame; - MCview.AppletPDBCanvas pdbcanvas; - AppletJmol jmol; - - Dialog dialog; - Object caller; - String originalLabel; - Color originalColour; - - int R = 0, G = 0, B = 0; - - public ColourSchemeI loadDefaultColours() - { - // NOT IMPLEMENTED YET IN APPLET VERSION - return null; - } - - public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) - { - this.ap = ap; - seqGroup = sg; - - if (seqGroup != null) - { - oldColourScheme = seqGroup.cs; - } - else - { - oldColourScheme = ap.av.getGlobalColourScheme(); - } - - init(); - } - - public UserDefinedColours(MCview.AppletPDBCanvas pdb) - { - this.pdbcanvas = pdb; - init(); - } - - public UserDefinedColours(AppletJmol jmol) - { - this.jmol = jmol; - init(); - } - - public UserDefinedColours(FeatureRenderer fr, Frame alignframe) - { - caller = fr; - originalColour = fr.colourPanel.getBackground(); - originalLabel = "Feature Colour"; - setForDialog("Select Feature Colour", alignframe); - setTargetColour(fr.colourPanel.getBackground()); - dialog.setVisible(true); - } - - public UserDefinedColours(Component caller, - Color col1, - Frame alignframe) - { - this.caller = caller; - originalColour = col1; - originalLabel = "Select Colour"; - setForDialog("Select Colour", alignframe); - setTargetColour(col1); - dialog.setVisible(true); - } - - - public UserDefinedColours(Object caller, - String label, - Color colour) - { - this.caller = caller; - originalColour = colour; - originalLabel = label; - init(); - remove(buttonPanel); - - setTargetColour(colour); - - okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35)); - frame.setTitle("User Defined Colours - " + label); - frame.setSize(420, 200); - } - - void setForDialog(String title, Frame alignframe) - { - init(); - frame.setVisible(false); - remove(buttonPanel); - dialog = new Dialog(alignframe, title, true); - - dialog.add(this); - this.setSize(400,123); - okcancelPanel.setBounds(new Rectangle(0, 123, 400, 35)); - int height = 160 + alignframe.getInsets().top + getInsets().bottom; - int width = 400; - - dialog.setBounds(alignframe.getBounds().x - + (alignframe.getSize().width - width) / 2, - alignframe.getBounds().y - + (alignframe.getSize().height - height) / 2, - width, height); - - } - - public void actionPerformed(ActionEvent evt) - { - if (evt.getSource() == okButton) - { - okButton_actionPerformed(); - } - else if (evt.getSource() == applyButton) - { - applyButton_actionPerformed(); - } - else if (evt.getSource() == cancelButton) - { - cancelButton_actionPerformed(); - } - else if (evt.getSource() == rText) - { - rText_actionPerformed(); - } - else if (evt.getSource() == gText) - { - gText_actionPerformed(); - } - else if (evt.getSource() == bText) - { - bText_actionPerformed(); - } - } - - public void adjustmentValueChanged(AdjustmentEvent evt) - { - if (evt.getSource() == rScroller) - { - rScroller_adjustmentValueChanged(); - } - else if (evt.getSource() == gScroller) - { - gScroller_adjustmentValueChanged(); - } - else if (evt.getSource() == bScroller) - { - bScroller_adjustmentValueChanged(); - } - } - - void init() - { - try - { - jbInit(); - } - catch (Exception e) - { - e.printStackTrace(); - } - frame = new Frame(); - frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, 345); - - if (seqGroup != null) - { - frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")"); - } - - for (int i = 0; i < 20; i++) - { - makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + - "", ResidueProperties.aa[i]); - } - - makeButton("B", "B"); - makeButton("Z", "Z"); - makeButton("X", "X"); - makeButton("Gap", "'.','-',' '"); - - validate(); - } - - protected void rText_actionPerformed() - { - try - { - int i = Integer.parseInt(rText.getText()); - rScroller.setValue(i); - rScroller_adjustmentValueChanged(); - } - catch (NumberFormatException ex) - {} - } - - protected void gText_actionPerformed() - { - try - { - int i = Integer.parseInt(gText.getText()); - gScroller.setValue(i); - gScroller_adjustmentValueChanged(); - } - catch (NumberFormatException ex) - {} - - } - - protected void bText_actionPerformed() - { - try - { - int i = Integer.parseInt(bText.getText()); - bScroller.setValue(i); - bScroller_adjustmentValueChanged(); - } - catch (NumberFormatException ex) - {} - - } - - protected void rScroller_adjustmentValueChanged() - { - R = rScroller.getValue(); - rText.setText(R + ""); - colourChanged(); - } - - protected void gScroller_adjustmentValueChanged() - { - G = gScroller.getValue(); - gText.setText(G + ""); - colourChanged(); - } - - protected void bScroller_adjustmentValueChanged() - { - B = bScroller.getValue(); - bText.setText(B + ""); - colourChanged(); - } - - public void colourChanged() - { - Color col = new Color(R, G, B); - target.setBackground(col); - target.repaint(); - - if (selectedButton != null) - { - selectedButton.setBackground(col); - selectedButton.repaint(); - } - } - - void setTargetColour(Color col) - { - R = col.getRed(); - G = col.getGreen(); - B = col.getBlue(); - - rScroller.setValue(R); - gScroller.setValue(G); - bScroller.setValue(B); - rText.setText(R + ""); - gText.setText(G + ""); - bText.setText(B + ""); - colourChanged(); - } - - public void colourButtonPressed(MouseEvent e) - { - selectedButton = (Button) e.getSource(); - setTargetColour(selectedButton.getBackground()); - } - - void makeButton(String label, String aa) - { - final Button button = new Button(); - Color col = Color.white; - - try - { - col = oldColourScheme.findColour(aa.charAt(0), -1); - } - catch (Exception ex) - {} - - button.setBackground(col); - oldColours.addElement(col); - button.setLabel(label); - button.setForeground(col.darker().darker().darker()); - button.setFont(new java.awt.Font("Verdana", 1, 10)); - button.addMouseListener(new java.awt.event.MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - colourButtonPressed(e); - } - }); - - buttonPanel.add(button, null); - } - - protected void okButton_actionPerformed() - { - applyButton_actionPerformed(); - if (dialog != null) - dialog.setVisible(false); - - frame.setVisible(false); - } - - public Color getColor() - { - return new Color(R, G, B); - } - - protected void applyButton_actionPerformed() - { - if (caller != null) - { - if (caller instanceof FeatureSettings) - { - ( (FeatureSettings) caller).setUserColour - (originalLabel, getColor()); - } - else if (caller instanceof AnnotationColourChooser) - { - if (originalLabel.equals("Min Colour")) - { - ( (AnnotationColourChooser) caller).minColour_actionPerformed - (getColor()); - } - else - { - ( (AnnotationColourChooser) caller).maxColour_actionPerformed - (getColor()); - } - } - else if(caller instanceof FeatureRenderer) - { - ((FeatureRenderer)caller).colourPanel.setBackground(getColor()); - } - - return; - } - - Color[] newColours = new Color[24]; - for (int i = 0; i < 24; i++) - { - Button button = (Button) buttonPanel.getComponent(i); - newColours[i] = button.getBackground(); - } - - UserColourScheme ucs = new UserColourScheme(newColours); - if (ap != null) - { - ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); - } - - if (ap != null) - { - if (seqGroup != null) - { - seqGroup.cs = ucs; - } - else - { - ap.av.setGlobalColourScheme(ucs); - } - ap.seqPanel.seqCanvas.img = null; - ap.paintAlignment(true); - } - else if(jmol!=null) - { - jmol.setJalviewColourScheme(ucs); - } - else if (pdbcanvas != null) - { - pdbcanvas.setColours(ucs); - } - } - - protected void cancelButton_actionPerformed() - { - if (caller != null) - { - if (caller instanceof FeatureSettings) - { - ( (FeatureSettings) caller).setUserColour - (originalLabel, originalColour); - } - else if (caller instanceof AnnotationColourChooser) - { - if (originalLabel.equals("Min Colour")) - { - ( (AnnotationColourChooser) caller).minColour_actionPerformed - (originalColour); - } - else - { - ( (AnnotationColourChooser) caller).maxColour_actionPerformed - (originalColour); - } - } - else if (caller instanceof FeatureRenderer) - { - ( (FeatureRenderer) caller).colourPanel.setBackground(originalColour); - - } - - if(dialog!=null) - dialog.setVisible(false); - - frame.setVisible(false); - return; - } - - Color[] newColours = new Color[24]; - for (int i = 0; i < 24; i++) - { - newColours[i] = (Color) oldColours.elementAt(i); - buttonPanel.getComponent(i).setBackground(newColours[i]); - } - - UserColourScheme ucs = new UserColourScheme(newColours); - - if (ap != null) - { - if (seqGroup != null) - { - seqGroup.cs = ucs; - } - else - { - ap.av.setGlobalColourScheme(ucs); - } - ap.paintAlignment(true); - } - else if(jmol !=null) - { - jmol.setJalviewColourScheme(ucs); - } - else if (pdbcanvas != null) - { - pdbcanvas.pdb.setColours(ucs); - } - - frame.setVisible(false); - } - - protected Panel buttonPanel = new Panel(); - protected GridLayout gridLayout = new GridLayout(); - Panel okcancelPanel = new Panel(); - protected Button okButton = new Button(); - protected Button applyButton = new Button(); - protected Button cancelButton = new Button(); - protected Scrollbar rScroller = new Scrollbar(); - Label label1 = new Label(); - protected TextField rText = new TextField(); - Label label4 = new Label(); - protected Scrollbar gScroller = new Scrollbar(); - protected TextField gText = new TextField(); - Label label5 = new Label(); - protected Scrollbar bScroller = new Scrollbar(); - protected TextField bText = new TextField(); - protected Panel target = new Panel(); - - private void jbInit() - throws Exception - { - this.setLayout(null); - buttonPanel.setLayout(gridLayout); - gridLayout.setColumns(6); - gridLayout.setRows(4); - okButton.setFont(new java.awt.Font("Verdana", 0, 11)); - okButton.setLabel("OK"); - okButton.addActionListener(this); - applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); - applyButton.setLabel("Apply"); - applyButton.addActionListener(this); - cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); - cancelButton.setLabel("Cancel"); - cancelButton.addActionListener(this); - this.setBackground(new Color(212, 208, 223)); - okcancelPanel.setBounds(new Rectangle(0, 265, 400, 35)); - buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); - rScroller.setMaximum(256); - rScroller.setMinimum(0); - rScroller.setOrientation(0); - rScroller.setUnitIncrement(1); - rScroller.setVisibleAmount(1); - rScroller.setBounds(new Rectangle(36, 27, 119, 19)); - rScroller.addAdjustmentListener(this); - label1.setAlignment(Label.RIGHT); - label1.setText("R"); - label1.setBounds(new Rectangle(19, 30, 16, 15)); - rText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); - rText.setText("0 "); - rText.setBounds(new Rectangle(156, 27, 53, 19)); - rText.addActionListener(this); - label4.setAlignment(Label.RIGHT); - label4.setText("G"); - label4.setBounds(new Rectangle(15, 56, 20, 15)); - gScroller.setMaximum(256); - gScroller.setMinimum(0); - gScroller.setOrientation(0); - gScroller.setUnitIncrement(1); - gScroller.setVisibleAmount(1); - gScroller.setBounds(new Rectangle(35, 52, 120, 20)); - gScroller.addAdjustmentListener(this); - gText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); - gText.setText("0 "); - gText.setBounds(new Rectangle(156, 52, 53, 20)); - gText.addActionListener(this); - label5.setAlignment(Label.RIGHT); - label5.setText("B"); - label5.setBounds(new Rectangle(14, 82, 20, 15)); - bScroller.setMaximum(256); - bScroller.setMinimum(0); - bScroller.setOrientation(0); - bScroller.setUnitIncrement(1); - bScroller.setVisibleAmount(1); - bScroller.setBounds(new Rectangle(35, 78, 120, 20)); - bScroller.addAdjustmentListener(this); - bText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); - bText.setText("0 "); - bText.setBounds(new Rectangle(157, 78, 52, 20)); - bText.addActionListener(this); - target.setBackground(Color.black); - target.setBounds(new Rectangle(229, 26, 134, 79)); - this.add(okcancelPanel, null); - okcancelPanel.add(okButton, null); - okcancelPanel.add(applyButton, null); - okcancelPanel.add(cancelButton, null); - this.add(buttonPanel, null); - this.add(target, null); - this.add(gScroller); - this.add(rScroller); - this.add(bScroller); - this.add(label5); - this.add(label4); - this.add(label1); - this.add(gText); - this.add(rText); - this.add(bText); - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package jalview.appletgui; + +import java.util.*; + +import java.awt.*; +import java.awt.event.*; + +import jalview.datamodel.*; +import jalview.schemes.*; + +public class UserDefinedColours extends Panel implements ActionListener, + AdjustmentListener +{ + + AlignmentPanel ap; + + SequenceGroup seqGroup; + + Button selectedButton; + + Vector oldColours = new Vector(); + + ColourSchemeI oldColourScheme; + + Frame frame; + + MCview.AppletPDBCanvas pdbcanvas; + + AppletJmol jmol; + + Dialog dialog; + + Object caller; + + String originalLabel; + + Color originalColour; + + int R = 0, G = 0, B = 0; + + public ColourSchemeI loadDefaultColours() + { + // NOT IMPLEMENTED YET IN APPLET VERSION + return null; + } + + public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) + { + this.ap = ap; + seqGroup = sg; + + if (seqGroup != null) + { + oldColourScheme = seqGroup.cs; + } + else + { + oldColourScheme = ap.av.getGlobalColourScheme(); + } + + init(); + } + + public UserDefinedColours(MCview.AppletPDBCanvas pdb) + { + this.pdbcanvas = pdb; + init(); + } + + public UserDefinedColours(AppletJmol jmol) + { + this.jmol = jmol; + init(); + } + + public UserDefinedColours(FeatureRenderer fr, Frame alignframe) + { + caller = fr; + originalColour = fr.colourPanel.getBackground(); + originalLabel = "Feature Colour"; + setForDialog("Select Feature Colour", alignframe); + setTargetColour(fr.colourPanel.getBackground()); + dialog.setVisible(true); + } + + public UserDefinedColours(Component caller, Color col1, Frame alignframe) + { + this.caller = caller; + originalColour = col1; + originalLabel = "Select Colour"; + setForDialog("Select Colour", alignframe); + setTargetColour(col1); + dialog.setVisible(true); + } + + public UserDefinedColours(Object caller, String label, Color colour) + { + this.caller = caller; + originalColour = colour; + originalLabel = label; + init(); + remove(buttonPanel); + + setTargetColour(colour); + + okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35)); + frame.setTitle("User Defined Colours - " + label); + frame.setSize(420, 200); + } + + void setForDialog(String title, Frame alignframe) + { + init(); + frame.setVisible(false); + remove(buttonPanel); + dialog = new Dialog(alignframe, title, true); + + dialog.add(this); + this.setSize(400, 123); + okcancelPanel.setBounds(new Rectangle(0, 123, 400, 35)); + int height = 160 + alignframe.getInsets().top + getInsets().bottom; + int width = 400; + + dialog.setBounds(alignframe.getBounds().x + + (alignframe.getSize().width - width) / 2, alignframe + .getBounds().y + + (alignframe.getSize().height - height) / 2, width, height); + + } + + public void actionPerformed(ActionEvent evt) + { + if (evt.getSource() == okButton) + { + okButton_actionPerformed(); + } + else if (evt.getSource() == applyButton) + { + applyButton_actionPerformed(); + } + else if (evt.getSource() == cancelButton) + { + cancelButton_actionPerformed(); + } + else if (evt.getSource() == rText) + { + rText_actionPerformed(); + } + else if (evt.getSource() == gText) + { + gText_actionPerformed(); + } + else if (evt.getSource() == bText) + { + bText_actionPerformed(); + } + } + + public void adjustmentValueChanged(AdjustmentEvent evt) + { + if (evt.getSource() == rScroller) + { + rScroller_adjustmentValueChanged(); + } + else if (evt.getSource() == gScroller) + { + gScroller_adjustmentValueChanged(); + } + else if (evt.getSource() == bScroller) + { + bScroller_adjustmentValueChanged(); + } + } + + void init() + { + try + { + jbInit(); + } catch (Exception e) + { + e.printStackTrace(); + } + frame = new Frame(); + frame.add(this); + jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, + 345); + + if (seqGroup != null) + { + frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")"); + } + + for (int i = 0; i < 20; i++) + { + makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + + "", ResidueProperties.aa[i]); + } + + makeButton("B", "B"); + makeButton("Z", "Z"); + makeButton("X", "X"); + makeButton("Gap", "'.','-',' '"); + + validate(); + } + + protected void rText_actionPerformed() + { + try + { + int i = Integer.parseInt(rText.getText()); + rScroller.setValue(i); + rScroller_adjustmentValueChanged(); + } catch (NumberFormatException ex) + { + } + } + + protected void gText_actionPerformed() + { + try + { + int i = Integer.parseInt(gText.getText()); + gScroller.setValue(i); + gScroller_adjustmentValueChanged(); + } catch (NumberFormatException ex) + { + } + + } + + protected void bText_actionPerformed() + { + try + { + int i = Integer.parseInt(bText.getText()); + bScroller.setValue(i); + bScroller_adjustmentValueChanged(); + } catch (NumberFormatException ex) + { + } + + } + + protected void rScroller_adjustmentValueChanged() + { + R = rScroller.getValue(); + rText.setText(R + ""); + colourChanged(); + } + + protected void gScroller_adjustmentValueChanged() + { + G = gScroller.getValue(); + gText.setText(G + ""); + colourChanged(); + } + + protected void bScroller_adjustmentValueChanged() + { + B = bScroller.getValue(); + bText.setText(B + ""); + colourChanged(); + } + + public void colourChanged() + { + Color col = new Color(R, G, B); + target.setBackground(col); + target.repaint(); + + if (selectedButton != null) + { + selectedButton.setBackground(col); + selectedButton.repaint(); + } + } + + void setTargetColour(Color col) + { + R = col.getRed(); + G = col.getGreen(); + B = col.getBlue(); + + rScroller.setValue(R); + gScroller.setValue(G); + bScroller.setValue(B); + rText.setText(R + ""); + gText.setText(G + ""); + bText.setText(B + ""); + colourChanged(); + } + + public void colourButtonPressed(MouseEvent e) + { + selectedButton = (Button) e.getSource(); + setTargetColour(selectedButton.getBackground()); + } + + void makeButton(String label, String aa) + { + final Button button = new Button(); + Color col = Color.white; + + try + { + col = oldColourScheme.findColour(aa.charAt(0), -1); + } catch (Exception ex) + { + } + + button.setBackground(col); + oldColours.addElement(col); + button.setLabel(label); + button.setForeground(col.darker().darker().darker()); + button.setFont(new java.awt.Font("Verdana", 1, 10)); + button.addMouseListener(new java.awt.event.MouseAdapter() + { + public void mousePressed(MouseEvent e) + { + colourButtonPressed(e); + } + }); + + buttonPanel.add(button, null); + } + + protected void okButton_actionPerformed() + { + applyButton_actionPerformed(); + if (dialog != null) + dialog.setVisible(false); + + frame.setVisible(false); + } + + public Color getColor() + { + return new Color(R, G, B); + } + + protected void applyButton_actionPerformed() + { + if (caller != null) + { + if (caller instanceof FeatureSettings) + { + ((FeatureSettings) caller).setUserColour(originalLabel, getColor()); + } + else if (caller instanceof AnnotationColourChooser) + { + if (originalLabel.equals("Min Colour")) + { + ((AnnotationColourChooser) caller) + .minColour_actionPerformed(getColor()); + } + else + { + ((AnnotationColourChooser) caller) + .maxColour_actionPerformed(getColor()); + } + } + else if (caller instanceof FeatureRenderer) + { + ((FeatureRenderer) caller).colourPanel.setBackground(getColor()); + } + + return; + } + + Color[] newColours = new Color[24]; + for (int i = 0; i < 24; i++) + { + Button button = (Button) buttonPanel.getComponent(i); + newColours[i] = button.getBackground(); + } + + UserColourScheme ucs = new UserColourScheme(newColours); + if (ap != null) + { + ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + } + + if (ap != null) + { + if (seqGroup != null) + { + seqGroup.cs = ucs; + } + else + { + ap.av.setGlobalColourScheme(ucs); + } + ap.seqPanel.seqCanvas.img = null; + ap.paintAlignment(true); + } + else if (jmol != null) + { + jmol.setJalviewColourScheme(ucs); + } + else if (pdbcanvas != null) + { + pdbcanvas.setColours(ucs); + } + } + + protected void cancelButton_actionPerformed() + { + if (caller != null) + { + if (caller instanceof FeatureSettings) + { + ((FeatureSettings) caller).setUserColour(originalLabel, + originalColour); + } + else if (caller instanceof AnnotationColourChooser) + { + if (originalLabel.equals("Min Colour")) + { + ((AnnotationColourChooser) caller) + .minColour_actionPerformed(originalColour); + } + else + { + ((AnnotationColourChooser) caller) + .maxColour_actionPerformed(originalColour); + } + } + else if (caller instanceof FeatureRenderer) + { + ((FeatureRenderer) caller).colourPanel + .setBackground(originalColour); + + } + + if (dialog != null) + dialog.setVisible(false); + + frame.setVisible(false); + return; + } + + Color[] newColours = new Color[24]; + for (int i = 0; i < 24; i++) + { + newColours[i] = (Color) oldColours.elementAt(i); + buttonPanel.getComponent(i).setBackground(newColours[i]); + } + + UserColourScheme ucs = new UserColourScheme(newColours); + + if (ap != null) + { + if (seqGroup != null) + { + seqGroup.cs = ucs; + } + else + { + ap.av.setGlobalColourScheme(ucs); + } + ap.paintAlignment(true); + } + else if (jmol != null) + { + jmol.setJalviewColourScheme(ucs); + } + else if (pdbcanvas != null) + { + pdbcanvas.pdb.setColours(ucs); + } + + frame.setVisible(false); + } + + protected Panel buttonPanel = new Panel(); + + protected GridLayout gridLayout = new GridLayout(); + + Panel okcancelPanel = new Panel(); + + protected Button okButton = new Button(); + + protected Button applyButton = new Button(); + + protected Button cancelButton = new Button(); + + protected Scrollbar rScroller = new Scrollbar(); + + Label label1 = new Label(); + + protected TextField rText = new TextField(); + + Label label4 = new Label(); + + protected Scrollbar gScroller = new Scrollbar(); + + protected TextField gText = new TextField(); + + Label label5 = new Label(); + + protected Scrollbar bScroller = new Scrollbar(); + + protected TextField bText = new TextField(); + + protected Panel target = new Panel(); + + private void jbInit() throws Exception + { + this.setLayout(null); + buttonPanel.setLayout(gridLayout); + gridLayout.setColumns(6); + gridLayout.setRows(4); + okButton.setFont(new java.awt.Font("Verdana", 0, 11)); + okButton.setLabel("OK"); + okButton.addActionListener(this); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(this); + cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); + cancelButton.setLabel("Cancel"); + cancelButton.addActionListener(this); + this.setBackground(new Color(212, 208, 223)); + okcancelPanel.setBounds(new Rectangle(0, 265, 400, 35)); + buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); + rScroller.setMaximum(256); + rScroller.setMinimum(0); + rScroller.setOrientation(0); + rScroller.setUnitIncrement(1); + rScroller.setVisibleAmount(1); + rScroller.setBounds(new Rectangle(36, 27, 119, 19)); + rScroller.addAdjustmentListener(this); + label1.setAlignment(Label.RIGHT); + label1.setText("R"); + label1.setBounds(new Rectangle(19, 30, 16, 15)); + rText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + rText.setText("0 "); + rText.setBounds(new Rectangle(156, 27, 53, 19)); + rText.addActionListener(this); + label4.setAlignment(Label.RIGHT); + label4.setText("G"); + label4.setBounds(new Rectangle(15, 56, 20, 15)); + gScroller.setMaximum(256); + gScroller.setMinimum(0); + gScroller.setOrientation(0); + gScroller.setUnitIncrement(1); + gScroller.setVisibleAmount(1); + gScroller.setBounds(new Rectangle(35, 52, 120, 20)); + gScroller.addAdjustmentListener(this); + gText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + gText.setText("0 "); + gText.setBounds(new Rectangle(156, 52, 53, 20)); + gText.addActionListener(this); + label5.setAlignment(Label.RIGHT); + label5.setText("B"); + label5.setBounds(new Rectangle(14, 82, 20, 15)); + bScroller.setMaximum(256); + bScroller.setMinimum(0); + bScroller.setOrientation(0); + bScroller.setUnitIncrement(1); + bScroller.setVisibleAmount(1); + bScroller.setBounds(new Rectangle(35, 78, 120, 20)); + bScroller.addAdjustmentListener(this); + bText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + bText.setText("0 "); + bText.setBounds(new Rectangle(157, 78, 52, 20)); + bText.addActionListener(this); + target.setBackground(Color.black); + target.setBounds(new Rectangle(229, 26, 134, 79)); + this.add(okcancelPanel, null); + okcancelPanel.add(okButton, null); + okcancelPanel.add(applyButton, null); + okcancelPanel.add(cancelButton, null); + this.add(buttonPanel, null); + this.add(target, null); + this.add(gScroller); + this.add(rScroller); + this.add(bScroller); + this.add(label5); + this.add(label4); + this.add(label1); + this.add(gText); + this.add(rText); + this.add(bText); + } + +} diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 0744cd9..e5f7f7b 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -24,73 +24,89 @@ import java.util.*; import org.apache.log4j.*; /** - * Stores and retrieves Jalview Application Properties - * Lists and fields within list entries are separated by '|' symbols unless otherwise stated - * (|) clauses are alternative values for a tag. - *

Current properties include: - *
    - *
    logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services) - *
    - *
  • logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization) + * Stores and retrieves Jalview Application Properties Lists and fields within + * list entries are separated by '|' symbols unless otherwise stated (|) clauses + * are alternative values for a tag.
    *
    - *
  • logs.Jalview.Level - Cache.log stringified level. + * Current properties include: + *
      *
      - *
    • DISCOVERY_START - Boolean - controls if discovery services are queried on startup - *
    • DISCOVERY_URLS - comma separated list of Discovery Service endpoints. - *
    • SCREEN_WIDTH - *
    • SCREEN_HEIGHT - *
    • SCREEN_Y=285 - *
    • SCREEN_X=371 - *
    • SHOW_FULLSCREEN boolean - *
    • FONT_NAME java font name for alignment text display - *
    • FONT_SIZE size of displayed alignment text - *
    • FONT_STYLE style of font displayed (sequence labels are always italic) - *
    • GAP_SYMBOL character to treat as gap symbol (usually -,.,' ') - *
    • LAST_DIRECTORY last directory for browsing alignment - *
    • USER_DEFINED_COLOURS list of user defined colour scheme files - *
    • SHOW_FULL_ID show id with '/start-end' numbers appended - *
    • SHOW_IDENTITY show percentage identity annotation - *
    • SHOW_QUALITY show alignment quality annotation - *
    • SHOW_ANNOTATIONS show alignment annotation rows - *
    • SHOW_CONSERVATION show alignment conservation annotation - *
    • CENTRE_COLUMN_LABELS centre the labels at each column in a displayed annotation row - *
    • DEFAULT_COLOUR default colour scheme to apply for a new alignment - *
    • DEFAULT_FILE_FORMAT file format used to save - *
    • STARTUP_FILE file loaded on startup (may be a fully qualified url) - *
    • SHOW_STARTUP_FILE flag to control loading of startup file - *
    • VERSION the version of the jalview build - *
    • BUILD_DATE date of this build - *
    • LATEST_VERSION the latest jalview version advertised on the www.jalview.org - *
    • PIR_MODELLER boolean indicating if PIR files are written with MODELLER descriptions - *
    • (FASTA,MSF,PILEUP,CLUSTAL,BLC,PIR,PFAM)_JVSUFFIX boolean for adding jv suffix to file - *
    • RECENT_URL list of recently retrieved URLs - *
    • RECENT_FILE list of recently opened files - *
    • USE_PROXY flag for whether a http proxy is to be used - *
    • PROXY_SERVER the proxy - *
    • PROXY_PORT - *
    • NOQUESTIONNAIRES true to prevent jalview from checking the questionnaire service - *
    • QUESTIONNAIRE last questionnaire:responder id string from questionnaire service - *
    • DAS_LOCAL_SOURCE list of local das sources - *
    • SHOW_OVERVIEW boolean for overview window display - *
    • ANTI_ALIAS boolean for smooth fonts - *
    • RIGHT_ALIGN_IDS boolean - *
    • AUTO_CALC_CONSENSUS boolean for automatic recalculation of consensus - *
    • PAD_GAPS boolean - *
    • ID_ITALICS boolean - *
    • SHOW_JV_SUFFIX - *
    • WRAP_ALIGNMENT - *
    • EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering style check - *
    • SORT_ALIGNMENT (No sort|Id|Pairwise Identity) - *
    • SEQUENCE_LINKS list of name|URL pairs for opening a url with $SEQUENCE_ID$ - *
    • DAS_REGISTRY_URL the registry to query - *
    • DEFAULT_BROWSER for unix - *
    • DAS_ACTIVE_SOURCE list of active sources - *
    • SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop (false) - *
    • + * logs.Axis.Level - one of the stringified Levels for log4j controlling the + * logging level for axis (used for web services)
      + *
    • + *
    • logs.Castor.Level - one of the stringified Levels for log4j controlling + * the logging level for castor (used for serialization)
      + *
    • + *
    • logs.Jalview.Level - Cache.log stringified level.
      + *
    • + *
    • DISCOVERY_START - Boolean - controls if discovery services are queried + * on startup
    • + *
    • DISCOVERY_URLS - comma separated list of Discovery Service endpoints. *
    • + *
    • SCREEN_WIDTH
    • + *
    • SCREEN_HEIGHT
    • + *
    • SCREEN_Y=285
    • + *
    • SCREEN_X=371
    • + *
    • SHOW_FULLSCREEN boolean
    • + *
    • FONT_NAME java font name for alignment text display
    • + *
    • FONT_SIZE size of displayed alignment text
    • + *
    • FONT_STYLE style of font displayed (sequence labels are always italic) + *
    • + *
    • GAP_SYMBOL character to treat as gap symbol (usually -,.,' ')
    • + *
    • LAST_DIRECTORY last directory for browsing alignment
    • + *
    • USER_DEFINED_COLOURS list of user defined colour scheme files
    • + *
    • SHOW_FULL_ID show id with '/start-end' numbers appended
    • + *
    • SHOW_IDENTITY show percentage identity annotation
    • + *
    • SHOW_QUALITY show alignment quality annotation
    • + *
    • SHOW_ANNOTATIONS show alignment annotation rows
    • + *
    • SHOW_CONSERVATION show alignment conservation annotation
    • + *
    • CENTRE_COLUMN_LABELS centre the labels at each column in a displayed + * annotation row
    • + *
    • DEFAULT_COLOUR default colour scheme to apply for a new alignment
    • + *
    • DEFAULT_FILE_FORMAT file format used to save
    • + *
    • STARTUP_FILE file loaded on startup (may be a fully qualified url)
    • + *
    • SHOW_STARTUP_FILE flag to control loading of startup file
    • + *
    • VERSION the version of the jalview build
    • + *
    • BUILD_DATE date of this build
    • + *
    • LATEST_VERSION the latest jalview version advertised on the + * www.jalview.org
    • + *
    • PIR_MODELLER boolean indicating if PIR files are written with MODELLER + * descriptions
    • + *
    • (FASTA,MSF,PILEUP,CLUSTAL,BLC,PIR,PFAM)_JVSUFFIX boolean for adding jv + * suffix to file
    • + *
    • RECENT_URL list of recently retrieved URLs
    • + *
    • RECENT_FILE list of recently opened files
    • + *
    • USE_PROXY flag for whether a http proxy is to be used
    • + *
    • PROXY_SERVER the proxy
    • + *
    • PROXY_PORT
    • + *
    • NOQUESTIONNAIRES true to prevent jalview from checking the questionnaire + * service
    • + *
    • QUESTIONNAIRE last questionnaire:responder id string from questionnaire + * service
    • + *
    • DAS_LOCAL_SOURCE list of local das sources
    • + *
    • SHOW_OVERVIEW boolean for overview window display
    • + *
    • ANTI_ALIAS boolean for smooth fonts
    • + *
    • RIGHT_ALIGN_IDS boolean
    • + *
    • AUTO_CALC_CONSENSUS boolean for automatic recalculation of consensus + *
    • + *
    • PAD_GAPS boolean
    • + *
    • ID_ITALICS boolean
    • + *
    • SHOW_JV_SUFFIX
    • + *
    • WRAP_ALIGNMENT
    • + *
    • EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering + * style check
    • + *
    • SORT_ALIGNMENT (No sort|Id|Pairwise Identity)
    • + *
    • SEQUENCE_LINKS list of name|URL pairs for opening a url with + * $SEQUENCE_ID$
    • + *
    • DAS_REGISTRY_URL the registry to query
    • + *
    • DEFAULT_BROWSER for unix
    • + *
    • DAS_ACTIVE_SOURCE list of active sources
    • + *
    • SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop + * (false)
    • + *
    • * *
    - + * * @author $author$ * @version $Revision$ */ @@ -100,14 +116,17 @@ public class Cache * property giving log4j level for CASTOR loggers */ public static final String CASTORLOGLEVEL = "logs.Castor.level"; + /** * property giving log4j level for AXIS loggers */ public static final String AXISLOGLEVEL = "logs.Axis.level"; + /** * property giving log4j level for Jalview Log */ public static final String JALVIEWLOGLEVEL = "logs.Jalview.level"; + public static final String DAS_LOCAL_SOURCE = "DAS_LOCAL_SOURCE"; /** @@ -118,7 +137,7 @@ public class Cache /** Jalview Properties */ public static Properties applicationProperties = new Properties(); - /** Default file is ~/.jalview_properties */ + /** Default file is ~/.jalview_properties */ static String propertiesFile; public static void initLogger() @@ -126,33 +145,32 @@ public class Cache try { ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(), - "System.err"); + "System.err"); ap.setName("JalviewLogger"); - org.apache.log4j.Logger.getRootLogger().addAppender(ap); // catch all for log output + org.apache.log4j.Logger.getRootLogger().addAppender(ap); // catch all for + // log output Logger laxis = Logger.getLogger("org.apache.axis"); Logger lcastor = Logger.getLogger("org.exolab.castor"); jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview"); laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level", - Level.INFO.toString()))); + Level.INFO.toString()))); lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", - Level.INFO.toString()))); + Level.INFO.toString()))); lcastor = Logger.getLogger("org.exolab.castor.xml"); lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", Level.INFO.toString()))); - //lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller"); - //lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", - // Level.INFO.toString()))); + // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller"); + // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", + // Level.INFO.toString()))); jalview.bin.Cache.log.setLevel(Level.toLevel(Cache.getDefault( - "logs.Jalview.level", - Level.INFO.toString()))); - //laxis.addAppender(ap); - //lcastor.addAppender(ap); - //jalview.bin.Cache.log.addAppender(ap); + "logs.Jalview.level", Level.INFO.toString()))); + // laxis.addAppender(ap); + // lcastor.addAppender(ap); + // jalview.bin.Cache.log.addAppender(ap); // Tell the user that debug is enabled jalview.bin.Cache.log.debug("Jalview Debugging Output Follows."); - } - catch (Exception ex) + } catch (Exception ex) { System.err.println("Problems initializing the log4j system\n"); ex.printStackTrace(System.err); @@ -165,8 +183,8 @@ public class Cache propertiesFile = propsFile; if (propsFile == null) { - propertiesFile = System.getProperty("user.home") + File.separatorChar + - ".jalview_properties"; + propertiesFile = System.getProperty("user.home") + File.separatorChar + + ".jalview_properties"; } try @@ -176,17 +194,19 @@ public class Cache applicationProperties.remove("LATEST_VERSION"); applicationProperties.remove("VERSION"); fis.close(); - } - catch (Exception ex) + } catch (Exception ex) { System.out.println("Error reading properties file: " + ex); } if (getDefault("USE_PROXY", false)) { - System.out.println("Using proxyServer: " + getDefault("PROXY_SERVER", null) + - " proxyPort: " + getDefault("PROXY_PORT", null)); - System.setProperty("http.proxyHost", getDefault("PROXY_SERVER", null)); + System.out.println("Using proxyServer: " + + getDefault("PROXY_SERVER", null) + " proxyPort: " + + getDefault("PROXY_PORT", null)); + System + .setProperty("http.proxyHost", getDefault("PROXY_SERVER", + null)); System.setProperty("http.proxyPort", getDefault("PROXY_PORT", null)); } @@ -195,20 +215,16 @@ public class Cache // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW try { - String buildDetails = "jar:" - .concat( - Cache.class.getProtectionDomain().getCodeSource().getLocation(). - toString() - .concat("!/.build_properties") - ); + String buildDetails = "jar:".concat(Cache.class.getProtectionDomain() + .getCodeSource().getLocation().toString().concat( + "!/.build_properties")); java.net.URL localJarFileURL = new java.net.URL(buildDetails); InputStream in = localJarFileURL.openStream(); applicationProperties.load(in); in.close(); - } - catch (Exception ex) + } catch (Exception ex) { System.out.println("Error reading build details: " + ex); applicationProperties.remove("VERSION"); @@ -228,32 +244,34 @@ public class Cache // jnlpVersion will be null if we're using InstallAnywhere // Dont do this check if running in headless mode - if (jnlpVersion == null && ( - System.getProperty("java.awt.headless") == null - || System.getProperty("java.awt.headless").equals("false"))) + if (jnlpVersion == null + && (System.getProperty("java.awt.headless") == null || System + .getProperty("java.awt.headless").equals("false"))) { - class VersionChecker - extends Thread + class VersionChecker extends Thread { public void run() { - String orgtimeout = System.getProperty("sun.net.client.defaultConnectTimeout"); - if (orgtimeout==null) + String orgtimeout = System + .getProperty("sun.net.client.defaultConnectTimeout"); + if (orgtimeout == null) { - orgtimeout="30"; - System.out.println("# INFO: Setting default net timeout to "+orgtimeout+" seconds."); + orgtimeout = "30"; + System.out.println("# INFO: Setting default net timeout to " + + orgtimeout + " seconds."); } String jnlpVersion = null; try { - System.setProperty("sun.net.client.defaultConnectTimeout", "5000"); + System.setProperty("sun.net.client.defaultConnectTimeout", + "5000"); java.net.URL url = new java.net.URL( - "http://www.jalview.org/webstart/jalview.jnlp"); - BufferedReader in = new BufferedReader(new InputStreamReader(url. - openStream())); + "http://www.jalview.org/webstart/jalview.jnlp"); + BufferedReader in = new BufferedReader(new InputStreamReader( + url.openStream())); String line = null; - while ( (line = in.readLine()) != null) + while ((line = in.readLine()) != null) { if (line.indexOf("jalview.version") == -1) { @@ -265,14 +283,15 @@ public class Cache jnlpVersion = line; break; } - } - catch (Exception ex) + } catch (Exception ex) { - System.out.println("Non-fatal exceptions when checking version at www.jalview.org :"); + System.out + .println("Non-fatal exceptions when checking version at www.jalview.org :"); System.out.println(ex); jnlpVersion = getProperty("VERSION"); } - System.setProperty("sun.net.client.defaultConnectTimeout", orgtimeout); + System.setProperty("sun.net.client.defaultConnectTimeout", + orgtimeout); setProperty("LATEST_VERSION", jnlpVersion); } @@ -295,18 +314,20 @@ public class Cache setProperty("VERSION", codeVersion); - //LOAD USERDEFINED COLOURS - jalview.gui.UserDefinedColours.initUserColourSchemes(getProperty( - "USER_DEFINED_COLOURS")); - jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER", false); + // LOAD USERDEFINED COLOURS + jalview.gui.UserDefinedColours + .initUserColourSchemes(getProperty("USER_DEFINED_COLOURS")); + jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER", + false); } /** - * Gets Jalview application property of given key. Returns null - * if key not found - * - * @param key Name of property - * + * Gets Jalview application property of given key. Returns null if key not + * found + * + * @param key + * Name of property + * * @return Property value */ public static String getProperty(String key) @@ -314,8 +335,9 @@ public class Cache return applicationProperties.getProperty(key); } - /** These methods are used when checking if the saved preference - * is different to the default setting + /** + * These methods are used when checking if the saved preference is different + * to the default setting */ public static boolean getDefault(String property, boolean def) @@ -329,8 +351,9 @@ public class Cache return def; } - /** These methods are used when checking if the saved preference - * is different to the default setting + /** + * These methods are used when checking if the saved preference is different + * to the default setting */ public static String getDefault(String property, String def) { @@ -345,10 +368,12 @@ public class Cache /** * Stores property in the file "HOME_DIR/.jalview_properties" - * - * @param key Name of object - * @param obj String value of property - * + * + * @param key + * Name of object + * @param obj + * String value of property + * * @return String value of property */ public static String setProperty(String key, String obj) @@ -359,11 +384,10 @@ public class Cache applicationProperties.setProperty(key, obj); applicationProperties.store(out, "---JalviewX Properties File---"); out.close(); - } - catch (Exception ex) + } catch (Exception ex) { - System.out.println("Error setting property: " + key + " " + obj + "\n" + - ex); + System.out.println("Error setting property: " + key + " " + obj + + "\n" + ex); } return obj; } @@ -375,8 +399,7 @@ public class Cache FileOutputStream out = new FileOutputStream(propertiesFile); applicationProperties.store(out, "---JalviewX Properties File---"); out.close(); - } - catch (Exception ex) + } catch (Exception ex) { System.out.println("Error saving properties: " + ex); } @@ -386,8 +409,10 @@ public class Cache * internal vamsas class discovery state */ private static int vamsasJarsArePresent = -1; + /** * Searches for vamsas client classes on class path. + * * @return true if vamsas client is present on classpath */ public static boolean vamsasJarsPresent() @@ -397,21 +422,20 @@ public class Cache try { if (jalview.jbgui.GDesktop.class.getClassLoader().loadClass( - "uk.ac.vamsas.client.VorbaId") != null) + "uk.ac.vamsas.client.VorbaId") != null) { - jalview.bin.Cache.log.debug( - "Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)"); + jalview.bin.Cache.log + .debug("Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)"); vamsasJarsArePresent = 1; Logger lvclient = Logger.getLogger("uk.ac.vamsas"); - lvclient.setLevel(Level.toLevel(Cache.getDefault("logs.Vamsas.Level", - Level.INFO.toString()))); + lvclient.setLevel(Level.toLevel(Cache.getDefault( + "logs.Vamsas.Level", Level.INFO.toString()))); lvclient.addAppender(log.getAppender("JalviewLogger")); // Tell the user that debug is enabled lvclient.debug("Jalview Vamsas Client Debugging Output Follows."); } - } - catch (Exception e) + } catch (Exception e) { vamsasJarsArePresent = 0; jalview.bin.Cache.log.debug("Vamsas Classes are not present"); @@ -419,12 +443,15 @@ public class Cache } return (vamsasJarsArePresent > 0); } + /** * internal vamsas class discovery state */ private static int groovyJarsArePresent = -1; + /** * Searches for vamsas client classes on class path. + * * @return true if vamsas client is present on classpath */ public static boolean groovyJarsPresent() @@ -434,21 +461,20 @@ public class Cache try { if (Cache.class.getClassLoader().loadClass( - "groovy.lang.GroovyObject") != null) + "groovy.lang.GroovyObject") != null) { - jalview.bin.Cache.log.debug( - "Found Groovy (groovy.lang.GroovyObject can be loaded)"); + jalview.bin.Cache.log + .debug("Found Groovy (groovy.lang.GroovyObject can be loaded)"); groovyJarsArePresent = 1; Logger lgclient = Logger.getLogger("groovy"); - lgclient.setLevel(Level.toLevel(Cache.getDefault("logs.Groovy.Level", - Level.INFO.toString()))); + lgclient.setLevel(Level.toLevel(Cache.getDefault( + "logs.Groovy.Level", Level.INFO.toString()))); lgclient.addAppender(log.getAppender("JalviewLogger")); // Tell the user that debug is enabled lgclient.debug("Jalview Groovy Client Debugging Output Follows."); } - } - catch (Exception e) + } catch (Exception e) { groovyJarsArePresent = 0; jalview.bin.Cache.log.debug("Groovy Classes are not present"); diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 4f383a0..36f4ff6 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -166,9 +166,11 @@ public class Jalview String file = null, protocol = null, format = null, data = null; jalview.io.FileLoader fileLoader = new jalview.io.FileLoader(); - Vector getFeatures = null; // vector of das source nicknames to fetch features from + Vector getFeatures = null; // vector of das source nicknames to fetch + // features from // loading is done. - String groovyscript = null; // script to execute after all loading is completed one way or another + String groovyscript = null; // script to execute after all loading is + // completed one way or another // extract groovy argument and execute if necessary groovyscript = aparser.getValue("groovy"); file = aparser.getValue("open"); @@ -268,31 +270,36 @@ public class Jalview } } getFeatures = checkDasArguments(aparser); - if (af != null && getFeatures!=null) + if (af != null && getFeatures != null) { - startFeatureFetching(getFeatures); + startFeatureFetching(getFeatures); // need to block until fetching is complete. while (af.operationInProgress()) { // wait around until fetching is finished. - try { + try + { Thread.sleep(10); } catch (Exception e) { - + } } } - if (groovyscript!=null) + if (groovyscript != null) { - // Execute the groovy script after we've done all the rendering stuff + // Execute the groovy script after we've done all the rendering stuff // and before any images or figures are generated. if (jalview.bin.Cache.groovyJarsPresent()) { - System.out.println("Executing script "+groovyscript); + System.out.println("Executing script " + groovyscript); executeGroovyScript(groovyscript, desktop); - } else { - System.err.println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "+groovyscript); + } + else + { + System.err + .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script " + + groovyscript); } groovyscript = null; } @@ -372,128 +379,156 @@ public class Jalview // extract groovy arguments before anything else. } // Once all loading is done. Retrieve features. - if (getFeatures!=null) + if (getFeatures != null) { - if (startUpAlframe!=null) + if (startUpAlframe != null) { startFeatureFetching(getFeatures); } } - if (groovyscript!=null) + if (groovyscript != null) { if (jalview.bin.Cache.groovyJarsPresent()) { - System.out.println("Executing script "+groovyscript); + System.out.println("Executing script " + groovyscript); executeGroovyScript(groovyscript, desktop); - } else { - System.err.println("Sorry. Groovy Support is not available, so ignoring the provided groovy script "+groovyscript); + } + else + { + System.err + .println("Sorry. Groovy Support is not available, so ignoring the provided groovy script " + + groovyscript); } } // Once all other stuff is done, execute any groovy scripts (in order) } + /** * Locate the given string as a file and pass it to the groovy interpreter. - * @param groovyscript the script to execute - * @param jalviewContext the Jalview Desktop object passed in to the groovy binding as the 'Jalview' object. + * + * @param groovyscript + * the script to execute + * @param jalviewContext + * the Jalview Desktop object passed in to the groovy binding + * as the 'Jalview' object. */ - private static void executeGroovyScript(String groovyscript, Object jalviewContext) + private static void executeGroovyScript(String groovyscript, + Object jalviewContext) { - if (jalviewContext==null) + if (jalviewContext == null) { - System.err.println("Sorry. Groovy support is currently only available when running with the Jalview GUI enabled."); + System.err + .println("Sorry. Groovy support is currently only available when running with the Jalview GUI enabled."); } File sfile = null; if (groovyscript.trim().equals("STDIN")) { // read from stdin into a tempfile and execute it - try { + try + { sfile = File.createTempFile("jalview", "groovy"); - PrintWriter outfile = new PrintWriter(new OutputStreamWriter(new FileOutputStream(sfile))); - BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in)); - String line=null; - while ((line=br.readLine())!=null) + PrintWriter outfile = new PrintWriter(new OutputStreamWriter( + new FileOutputStream(sfile))); + BufferedReader br = new BufferedReader( + new java.io.InputStreamReader(System.in)); + String line = null; + while ((line = br.readLine()) != null) { - outfile.write(line+"\n"); + outfile.write(line + "\n"); } br.close(); outfile.flush(); outfile.close(); - + } catch (Exception ex) { - System.err.println("Failed to read from STDIN into tempfile "+((sfile==null) ? "(tempfile wasn't created)" : sfile.toString())); + System.err.println("Failed to read from STDIN into tempfile " + + ((sfile == null) ? "(tempfile wasn't created)" : sfile + .toString())); ex.printStackTrace(); return; } - } else { + } + else + { sfile = new File(groovyscript); } if (!sfile.exists()) { - System.err.println("File '"+groovyscript+"' does not exist."); + System.err.println("File '" + groovyscript + "' does not exist."); return; } if (!sfile.canRead()) { - System.err.println("File '"+groovyscript+"' cannot be read."); + System.err.println("File '" + groovyscript + "' cannot be read."); return; } - if (sfile.length()<1) + if (sfile.length() < 1) { - System.err.println("File '"+groovyscript+"' is empty."); + System.err.println("File '" + groovyscript + "' is empty."); return; } boolean success = false; - try { - /* The following code performs the GroovyScriptEngine invocation using reflection, - * and is equivalent to this fragment from the embedding groovy documentation on - * the groovy site: - * - import groovy.lang.Binding; - import groovy.util.GroovyScriptEngine; - - String[] roots = new String[] { "/my/groovy/script/path" }; - GroovyScriptEngine gse = new GroovyScriptEngine(roots); - Binding binding = new Binding(); - binding.setVariable("input", "world"); - gse.run("hello.groovy", binding); - * - */ - ClassLoader cl = jalviewContext.getClass().getClassLoader(); - Class gbindingc = cl.loadClass("groovy.lang.Binding"); - Constructor gbcons = gbindingc.getConstructor(null); - Object gbinding = gbcons.newInstance(null); - java.lang.reflect.Method setvar = gbindingc.getMethod("setVariable", new Class[] { String.class, Object.class} ); - setvar.invoke(gbinding, new Object[] { "Jalview", jalviewContext}); - Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine"); - Constructor gseccons = gsec.getConstructor(new Class[] { URL[].class } ); // String[].class }); - Object gse = gseccons.newInstance(new Object[] { new URL[] { sfile.toURL() } }); // .toString() } }); - java.lang.reflect.Method run = gsec.getMethod("run", new Class[]{ String.class, gbindingc }); - run.invoke(gse, new Object[] { sfile.getName(), gbinding }); - success = true; + try + { + /* + * The following code performs the GroovyScriptEngine invocation using + * reflection, and is equivalent to this fragment from the embedding + * groovy documentation on the groovy site: import + * groovy.lang.Binding; import groovy.util.GroovyScriptEngine; + * + * String[] roots = new String[] { "/my/groovy/script/path" }; + * GroovyScriptEngine gse = new GroovyScriptEngine(roots); Binding binding = + * new Binding(); binding.setVariable("input", "world"); + * gse.run("hello.groovy", binding); + */ + ClassLoader cl = jalviewContext.getClass().getClassLoader(); + Class gbindingc = cl.loadClass("groovy.lang.Binding"); + Constructor gbcons = gbindingc.getConstructor(null); + Object gbinding = gbcons.newInstance(null); + java.lang.reflect.Method setvar = gbindingc.getMethod("setVariable", + new Class[] + { String.class, Object.class }); + setvar.invoke(gbinding, new Object[] + { "Jalview", jalviewContext }); + Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine"); + Constructor gseccons = gsec.getConstructor(new Class[] + { URL[].class }); // String[].class }); + Object gse = gseccons.newInstance(new Object[] + { new URL[] + { sfile.toURL() } }); // .toString() } }); + java.lang.reflect.Method run = gsec.getMethod("run", new Class[] + { String.class, gbindingc }); + run.invoke(gse, new Object[] + { sfile.getName(), gbinding }); + success = true; } catch (Exception e) { - System.err.println("Exception Whilst trying to execute file "+sfile+" as a groovy script."); + System.err.println("Exception Whilst trying to execute file " + sfile + + " as a groovy script."); e.printStackTrace(System.err); - + } if (success && groovyscript.equals("STDIN")) { - // delete temp file that we made - but only if it was successfully executed + // delete temp file that we made - but only if it was successfully + // executed sfile.delete(); } } + /** * Check commandline for any das server definitions or any fetchfrom switches + * * @return vector of DAS source nicknames to retrieve from */ private static Vector checkDasArguments(ArgsParser aparser) { - Vector source=null; + Vector source = null; String data; String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE); - while ((data = aparser.getValue("dasserver"))!=null) + while ((data = aparser.getValue("dasserver")) != null) { String nickname = null; String url = null; @@ -509,32 +544,35 @@ public class Jalview { nickname = url; } - if (locsources==null) + if (locsources == null) + { + locsources = ""; + } + else { - locsources=""; - } else { - locsources+="\t"; + locsources += "\t"; } - locsources=locsources+nickname+"|"+url; + locsources = locsources + nickname + "|" + url; System.err .println("NOTE! dasserver parameter not yet really supported (got args of " + nickname + "|" + url); - if (source==null) + if (source == null) { source = new Vector(); } source.addElement(nickname); } } // loop until no more server entries are found. - if (locsources!=null && locsources.indexOf('|')>-1) + if (locsources != null && locsources.indexOf('|') > -1) { - Cache.log.debug("Setting local source list in properties file to:\n"+locsources); + Cache.log.debug("Setting local source list in properties file to:\n" + + locsources); Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources); } - while ((data = aparser.getValue("fetchfrom"))!=null) + while ((data = aparser.getValue("fetchfrom")) != null) { - System.out.println("adding source '"+data+"'"); - if (source==null) + System.out.println("adding source '" + data + "'"); + if (source == null) { source = new Vector(); } @@ -542,24 +580,27 @@ public class Jalview } return source; } + /** * start a feature fetcher for every alignment frame + * * @param dasSources */ private static void startFeatureFetching(final Vector dasSources) { AlignFrame afs[] = Desktop.getAlignframes(); - if (afs==null || afs.length==0) + if (afs == null || afs.length == 0) { return; } - for (int i = 0; iCastor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,151 +30,166 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Alignment implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _annotation. - */ - private jalview.binding.Annotation _annotation; - - /** - * Field _sequenceSet. - */ - private jalview.binding.SequenceSet _sequenceSet; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Alignment() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'annotation'. - * - * @return the value of field 'Annotation'. - */ - public jalview.binding.Annotation getAnnotation( - ) { - return this._annotation; - } - - /** - * Returns the value of field 'sequenceSet'. - * - * @return the value of field 'SequenceSet'. - */ - public jalview.binding.SequenceSet getSequenceSet( - ) { - return this._sequenceSet; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'annotation'. - * - * @param annotation the value of field 'annotation'. - */ - public void setAnnotation( - final jalview.binding.Annotation annotation) { - this._annotation = annotation; - } - - /** - * Sets the value of field 'sequenceSet'. - * - * @param sequenceSet the value of field 'sequenceSet'. - */ - public void setSequenceSet( - final jalview.binding.SequenceSet sequenceSet) { - this._sequenceSet = sequenceSet; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Alignment - */ - public static jalview.binding.Alignment unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Alignment) Unmarshaller.unmarshal(jalview.binding.Alignment.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class Alignment implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _annotation. + */ + private jalview.binding.Annotation _annotation; + + /** + * Field _sequenceSet. + */ + private jalview.binding.SequenceSet _sequenceSet; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Alignment() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Returns the value of field 'annotation'. + * + * @return the value of field 'Annotation'. + */ + public jalview.binding.Annotation getAnnotation() + { + return this._annotation; + } + + /** + * Returns the value of field 'sequenceSet'. + * + * @return the value of field 'SequenceSet'. + */ + public jalview.binding.SequenceSet getSequenceSet() + { + return this._sequenceSet; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'annotation'. + * + * @param annotation + * the value of field 'annotation'. + */ + public void setAnnotation(final jalview.binding.Annotation annotation) + { + this._annotation = annotation; + } + + /** + * Sets the value of field 'sequenceSet'. + * + * @param sequenceSet + * the value of field 'sequenceSet'. + */ + public void setSequenceSet(final jalview.binding.SequenceSet sequenceSet) + { + this._sequenceSet = sequenceSet; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Alignment + */ + public static jalview.binding.Alignment unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Alignment) Unmarshaller.unmarshal( + jalview.binding.Alignment.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Annotation.java b/src/jalview/binding/Annotation.java index 108d3ad..ec3e248 100755 --- a/src/jalview/binding/Annotation.java +++ b/src/jalview/binding/Annotation.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,414 +30,445 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Annotation implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _graph. - */ - private boolean _graph; - - /** - * keeps track of state for field: _graph - */ - private boolean _has_graph; - - /** - * Field _graphType. - */ - private int _graphType; - - /** - * keeps track of state for field: _graphType - */ - private boolean _has_graphType; - - /** - * Field _annotationElementList. - */ - private java.util.Vector _annotationElementList; - - /** - * Field _label. - */ - private java.lang.String _label; - - /** - * Field _description. - */ - private java.lang.String _description; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Annotation() { - super(); - this._annotationElementList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAnnotationElement - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAnnotationElement( - final jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException { - this._annotationElementList.addElement(vAnnotationElement); - } - - /** - * - * - * @param index - * @param vAnnotationElement - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAnnotationElement( - final int index, - final jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException { - this._annotationElementList.add(index, vAnnotationElement); - } - - /** - */ - public void deleteGraph( - ) { - this._has_graph= false; - } - - /** - */ - public void deleteGraphType( - ) { - this._has_graphType= false; - } - - /** - * Method enumerateAnnotationElement. - * - * @return an Enumeration over all - * jalview.binding.AnnotationElement elements - */ - public java.util.Enumeration enumerateAnnotationElement( - ) { - return this._annotationElementList.elements(); - } - - /** - * Method getAnnotationElement. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.AnnotationElement - * at the given index - */ - public jalview.binding.AnnotationElement getAnnotationElement( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._annotationElementList.size()) { - throw new IndexOutOfBoundsException("getAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]"); - } - - return (jalview.binding.AnnotationElement) _annotationElementList.get(index); - } - - /** - * Method getAnnotationElement.Returns the contents of the - * collection in an Array.

    Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.AnnotationElement[] getAnnotationElement( - ) { - jalview.binding.AnnotationElement[] array = new jalview.binding.AnnotationElement[0]; - return (jalview.binding.AnnotationElement[]) this._annotationElementList.toArray(array); - } - - /** - * Method getAnnotationElementCount. - * - * @return the size of this collection - */ - public int getAnnotationElementCount( - ) { - return this._annotationElementList.size(); - } - - /** - * Returns the value of field 'description'. - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; +public class Annotation implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _graph. + */ + private boolean _graph; + + /** + * keeps track of state for field: _graph + */ + private boolean _has_graph; + + /** + * Field _graphType. + */ + private int _graphType; + + /** + * keeps track of state for field: _graphType + */ + private boolean _has_graphType; + + /** + * Field _annotationElementList. + */ + private java.util.Vector _annotationElementList; + + /** + * Field _label. + */ + private java.lang.String _label; + + /** + * Field _description. + */ + private java.lang.String _description; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Annotation() + { + super(); + this._annotationElementList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAnnotationElement + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAnnotationElement( + final jalview.binding.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + this._annotationElementList.addElement(vAnnotationElement); + } + + /** + * + * + * @param index + * @param vAnnotationElement + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAnnotationElement(final int index, + final jalview.binding.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + this._annotationElementList.add(index, vAnnotationElement); + } + + /** + */ + public void deleteGraph() + { + this._has_graph = false; + } + + /** + */ + public void deleteGraphType() + { + this._has_graphType = false; + } + + /** + * Method enumerateAnnotationElement. + * + * @return an Enumeration over all jalview.binding.AnnotationElement elements + */ + public java.util.Enumeration enumerateAnnotationElement() + { + return this._annotationElementList.elements(); + } + + /** + * Method getAnnotationElement. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.AnnotationElement at the given + * index + */ + public jalview.binding.AnnotationElement getAnnotationElement( + final int index) throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._annotationElementList.size()) + { + throw new IndexOutOfBoundsException( + "getAnnotationElement: Index value '" + index + + "' not in range [0.." + + (this._annotationElementList.size() - 1) + "]"); } - /** - * Returns the value of field 'graph'. - * - * @return the value of field 'Graph'. - */ - public boolean getGraph( - ) { - return this._graph; + return (jalview.binding.AnnotationElement) _annotationElementList + .get(index); + } + + /** + * Method getAnnotationElement.Returns the contents of the collection in an + * Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.AnnotationElement[] getAnnotationElement() + { + jalview.binding.AnnotationElement[] array = new jalview.binding.AnnotationElement[0]; + return (jalview.binding.AnnotationElement[]) this._annotationElementList + .toArray(array); + } + + /** + * Method getAnnotationElementCount. + * + * @return the size of this collection + */ + public int getAnnotationElementCount() + { + return this._annotationElementList.size(); + } + + /** + * Returns the value of field 'description'. + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() + { + return this._description; + } + + /** + * Returns the value of field 'graph'. + * + * @return the value of field 'Graph'. + */ + public boolean getGraph() + { + return this._graph; + } + + /** + * Returns the value of field 'graphType'. + * + * @return the value of field 'GraphType'. + */ + public int getGraphType() + { + return this._graphType; + } + + /** + * Returns the value of field 'label'. + * + * @return the value of field 'Label'. + */ + public java.lang.String getLabel() + { + return this._label; + } + + /** + * Method hasGraph. + * + * @return true if at least one Graph has been added + */ + public boolean hasGraph() + { + return this._has_graph; + } + + /** + * Method hasGraphType. + * + * @return true if at least one GraphType has been added + */ + public boolean hasGraphType() + { + return this._has_graphType; + } + + /** + * Returns the value of field 'graph'. + * + * @return the value of field 'Graph'. + */ + public boolean isGraph() + { + return this._graph; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } - - /** - * Returns the value of field 'graphType'. - * - * @return the value of field 'GraphType'. - */ - public int getGraphType( - ) { - return this._graphType; - } - - /** - * Returns the value of field 'label'. - * - * @return the value of field 'Label'. - */ - public java.lang.String getLabel( - ) { - return this._label; - } - - /** - * Method hasGraph. - * - * @return true if at least one Graph has been added - */ - public boolean hasGraph( - ) { - return this._has_graph; - } - - /** - * Method hasGraphType. - * - * @return true if at least one GraphType has been added - */ - public boolean hasGraphType( - ) { - return this._has_graphType; - } - - /** - * Returns the value of field 'graph'. - * - * @return the value of field 'Graph'. - */ - public boolean isGraph( - ) { - return this._graph; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllAnnotationElement( - ) { - this._annotationElementList.clear(); - } - - /** - * Method removeAnnotationElement. - * - * @param vAnnotationElement - * @return true if the object was removed from the collection. - */ - public boolean removeAnnotationElement( - final jalview.binding.AnnotationElement vAnnotationElement) { - boolean removed = _annotationElementList.remove(vAnnotationElement); - return removed; - } - - /** - * Method removeAnnotationElementAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.AnnotationElement removeAnnotationElementAt( - final int index) { - java.lang.Object obj = this._annotationElementList.remove(index); - return (jalview.binding.AnnotationElement) obj; - } - - /** - * - * - * @param index - * @param vAnnotationElement - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAnnotationElement( - final int index, - final jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._annotationElementList.size()) { - throw new IndexOutOfBoundsException("setAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]"); - } - - this._annotationElementList.set(index, vAnnotationElement); - } - - /** - * - * - * @param vAnnotationElementArray - */ - public void setAnnotationElement( - final jalview.binding.AnnotationElement[] vAnnotationElementArray) { - //-- copy array - _annotationElementList.clear(); - - for (int i = 0; i < vAnnotationElementArray.length; i++) { - this._annotationElementList.add(vAnnotationElementArray[i]); - } - } - - /** - * Sets the value of field 'description'. - * - * @param description the value of field 'description'. - */ - public void setDescription( - final java.lang.String description) { - this._description = description; - } - - /** - * Sets the value of field 'graph'. - * - * @param graph the value of field 'graph'. - */ - public void setGraph( - final boolean graph) { - this._graph = graph; - this._has_graph = true; - } - - /** - * Sets the value of field 'graphType'. - * - * @param graphType the value of field 'graphType'. - */ - public void setGraphType( - final int graphType) { - this._graphType = graphType; - this._has_graphType = true; - } - - /** - * Sets the value of field 'label'. - * - * @param label the value of field 'label'. - */ - public void setLabel( - final java.lang.String label) { - this._label = label; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Annotation - */ - public static jalview.binding.Annotation unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Annotation) Unmarshaller.unmarshal(jalview.binding.Annotation.class, reader); + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllAnnotationElement() + { + this._annotationElementList.clear(); + } + + /** + * Method removeAnnotationElement. + * + * @param vAnnotationElement + * @return true if the object was removed from the collection. + */ + public boolean removeAnnotationElement( + final jalview.binding.AnnotationElement vAnnotationElement) + { + boolean removed = _annotationElementList.remove(vAnnotationElement); + return removed; + } + + /** + * Method removeAnnotationElementAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.AnnotationElement removeAnnotationElementAt( + final int index) + { + java.lang.Object obj = this._annotationElementList.remove(index); + return (jalview.binding.AnnotationElement) obj; + } + + /** + * + * + * @param index + * @param vAnnotationElement + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAnnotationElement(final int index, + final jalview.binding.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._annotationElementList.size()) + { + throw new IndexOutOfBoundsException( + "setAnnotationElement: Index value '" + index + + "' not in range [0.." + + (this._annotationElementList.size() - 1) + "]"); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._annotationElementList.set(index, vAnnotationElement); + } + + /** + * + * + * @param vAnnotationElementArray + */ + public void setAnnotationElement( + final jalview.binding.AnnotationElement[] vAnnotationElementArray) + { + // -- copy array + _annotationElementList.clear(); + + for (int i = 0; i < vAnnotationElementArray.length; i++) + { + this._annotationElementList.add(vAnnotationElementArray[i]); } + } + + /** + * Sets the value of field 'description'. + * + * @param description + * the value of field 'description'. + */ + public void setDescription(final java.lang.String description) + { + this._description = description; + } + + /** + * Sets the value of field 'graph'. + * + * @param graph + * the value of field 'graph'. + */ + public void setGraph(final boolean graph) + { + this._graph = graph; + this._has_graph = true; + } + + /** + * Sets the value of field 'graphType'. + * + * @param graphType + * the value of field 'graphType'. + */ + public void setGraphType(final int graphType) + { + this._graphType = graphType; + this._has_graphType = true; + } + + /** + * Sets the value of field 'label'. + * + * @param label + * the value of field 'label'. + */ + public void setLabel(final java.lang.String label) + { + this._label = label; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Annotation + */ + public static jalview.binding.Annotation unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Annotation) Unmarshaller.unmarshal( + jalview.binding.Annotation.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/AnnotationElement.java b/src/jalview/binding/AnnotationElement.java index d133fe0..160141c 100755 --- a/src/jalview/binding/AnnotationElement.java +++ b/src/jalview/binding/AnnotationElement.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,273 +30,291 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class AnnotationElement implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _position. - */ - private int _position; - - /** - * keeps track of state for field: _position - */ - private boolean _has_position; - - /** - * Field _displayCharacter. - */ - private java.lang.String _displayCharacter; - - /** - * Field _description. - */ - private java.lang.String _description; - - /** - * Field _secondaryStructure. - */ - private java.lang.String _secondaryStructure; - - /** - * Field _value. - */ - private float _value; - - /** - * keeps track of state for field: _value - */ - private boolean _has_value; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public AnnotationElement() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deletePosition( - ) { - this._has_position= false; - } - - /** - */ - public void deleteValue( - ) { - this._has_value= false; - } - - /** - * Returns the value of field 'description'. - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; - } - - /** - * Returns the value of field 'displayCharacter'. - * - * @return the value of field 'DisplayCharacter'. - */ - public java.lang.String getDisplayCharacter( - ) { - return this._displayCharacter; - } - - /** - * Returns the value of field 'position'. - * - * @return the value of field 'Position'. - */ - public int getPosition( - ) { - return this._position; - } - - /** - * Returns the value of field 'secondaryStructure'. - * - * @return the value of field 'SecondaryStructure'. - */ - public java.lang.String getSecondaryStructure( - ) { - return this._secondaryStructure; - } - - /** - * Returns the value of field 'value'. - * - * @return the value of field 'Value'. - */ - public float getValue( - ) { - return this._value; - } - - /** - * Method hasPosition. - * - * @return true if at least one Position has been added - */ - public boolean hasPosition( - ) { - return this._has_position; - } - - /** - * Method hasValue. - * - * @return true if at least one Value has been added - */ - public boolean hasValue( - ) { - return this._has_value; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'description'. - * - * @param description the value of field 'description'. - */ - public void setDescription( - final java.lang.String description) { - this._description = description; - } - - /** - * Sets the value of field 'displayCharacter'. - * - * @param displayCharacter the value of field 'displayCharacter' - */ - public void setDisplayCharacter( - final java.lang.String displayCharacter) { - this._displayCharacter = displayCharacter; - } - - /** - * Sets the value of field 'position'. - * - * @param position the value of field 'position'. - */ - public void setPosition( - final int position) { - this._position = position; - this._has_position = true; - } - - /** - * Sets the value of field 'secondaryStructure'. - * - * @param secondaryStructure the value of field - * 'secondaryStructure'. - */ - public void setSecondaryStructure( - final java.lang.String secondaryStructure) { - this._secondaryStructure = secondaryStructure; - } - - /** - * Sets the value of field 'value'. - * - * @param value the value of field 'value'. - */ - public void setValue( - final float value) { - this._value = value; - this._has_value = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.AnnotationElement - */ - public static jalview.binding.AnnotationElement unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.AnnotationElement) Unmarshaller.unmarshal(jalview.binding.AnnotationElement.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class AnnotationElement implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _position. + */ + private int _position; + + /** + * keeps track of state for field: _position + */ + private boolean _has_position; + + /** + * Field _displayCharacter. + */ + private java.lang.String _displayCharacter; + + /** + * Field _description. + */ + private java.lang.String _description; + + /** + * Field _secondaryStructure. + */ + private java.lang.String _secondaryStructure; + + /** + * Field _value. + */ + private float _value; + + /** + * keeps track of state for field: _value + */ + private boolean _has_value; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public AnnotationElement() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + */ + public void deletePosition() + { + this._has_position = false; + } + + /** + */ + public void deleteValue() + { + this._has_value = false; + } + + /** + * Returns the value of field 'description'. + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() + { + return this._description; + } + + /** + * Returns the value of field 'displayCharacter'. + * + * @return the value of field 'DisplayCharacter'. + */ + public java.lang.String getDisplayCharacter() + { + return this._displayCharacter; + } + + /** + * Returns the value of field 'position'. + * + * @return the value of field 'Position'. + */ + public int getPosition() + { + return this._position; + } + + /** + * Returns the value of field 'secondaryStructure'. + * + * @return the value of field 'SecondaryStructure'. + */ + public java.lang.String getSecondaryStructure() + { + return this._secondaryStructure; + } + + /** + * Returns the value of field 'value'. + * + * @return the value of field 'Value'. + */ + public float getValue() + { + return this._value; + } + + /** + * Method hasPosition. + * + * @return true if at least one Position has been added + */ + public boolean hasPosition() + { + return this._has_position; + } + + /** + * Method hasValue. + * + * @return true if at least one Value has been added + */ + public boolean hasValue() + { + return this._has_value; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'description'. + * + * @param description + * the value of field 'description'. + */ + public void setDescription(final java.lang.String description) + { + this._description = description; + } + + /** + * Sets the value of field 'displayCharacter'. + * + * @param displayCharacter + * the value of field 'displayCharacter' + */ + public void setDisplayCharacter(final java.lang.String displayCharacter) + { + this._displayCharacter = displayCharacter; + } + + /** + * Sets the value of field 'position'. + * + * @param position + * the value of field 'position'. + */ + public void setPosition(final int position) + { + this._position = position; + this._has_position = true; + } + + /** + * Sets the value of field 'secondaryStructure'. + * + * @param secondaryStructure + * the value of field 'secondaryStructure'. + */ + public void setSecondaryStructure( + final java.lang.String secondaryStructure) + { + this._secondaryStructure = secondaryStructure; + } + + /** + * Sets the value of field 'value'. + * + * @param value + * the value of field 'value'. + */ + public void setValue(final float value) + { + this._value = value; + this._has_value = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.AnnotationElement + */ + public static jalview.binding.AnnotationElement unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.AnnotationElement) Unmarshaller.unmarshal( + jalview.binding.AnnotationElement.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Colour.java b/src/jalview/binding/Colour.java index 488ff98..60d0291 100755 --- a/src/jalview/binding/Colour.java +++ b/src/jalview/binding/Colour.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,151 +30,165 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Colour implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _name. - */ - private java.lang.String _name; - - /** - * Field _RGB. - */ - private java.lang.String _RGB; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Colour() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Returns the value of field 'RGB'. - * - * @return the value of field 'RGB'. - */ - public java.lang.String getRGB( - ) { - return this._RGB; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * Sets the value of field 'RGB'. - * - * @param RGB the value of field 'RGB'. - */ - public void setRGB( - final java.lang.String RGB) { - this._RGB = RGB; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Colour - */ - public static jalview.binding.Colour unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Colour) Unmarshaller.unmarshal(jalview.binding.Colour.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class Colour implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _name. + */ + private java.lang.String _name; + + /** + * Field _RGB. + */ + private java.lang.String _RGB; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Colour() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() + { + return this._name; + } + + /** + * Returns the value of field 'RGB'. + * + * @return the value of field 'RGB'. + */ + public java.lang.String getRGB() + { + return this._RGB; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) + { + this._name = name; + } + + /** + * Sets the value of field 'RGB'. + * + * @param RGB + * the value of field 'RGB'. + */ + public void setRGB(final java.lang.String RGB) + { + this._RGB = RGB; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Colour + */ + public static jalview.binding.Colour unmarshal(final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Colour) Unmarshaller.unmarshal( + jalview.binding.Colour.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Feature.java b/src/jalview/binding/Feature.java index d429df3..509d0e6 100755 --- a/src/jalview/binding/Feature.java +++ b/src/jalview/binding/Feature.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,272 +30,290 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Feature implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _begin. - */ - private int _begin; - - /** - * keeps track of state for field: _begin - */ - private boolean _has_begin; - - /** - * Field _end. - */ - private int _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - /** - * Field _type. - */ - private java.lang.String _type; - - /** - * Field _description. - */ - private java.lang.String _description; - - /** - * Field _status. - */ - private java.lang.String _status; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Feature() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deleteBegin( - ) { - this._has_begin= false; - } - - /** - */ - public void deleteEnd( - ) { - this._has_end= false; - } - - /** - * Returns the value of field 'begin'. - * - * @return the value of field 'Begin'. - */ - public int getBegin( - ) { - return this._begin; - } - - /** - * Returns the value of field 'description'. - * - * @return the value of field 'Description'. - */ - public java.lang.String getDescription( - ) { - return this._description; - } - - /** - * Returns the value of field 'end'. - * - * @return the value of field 'End'. - */ - public int getEnd( - ) { - return this._end; - } - - /** - * Returns the value of field 'status'. - * - * @return the value of field 'Status'. - */ - public java.lang.String getStatus( - ) { - return this._status; - } - - /** - * Returns the value of field 'type'. - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } - - /** - * Method hasBegin. - * - * @return true if at least one Begin has been added - */ - public boolean hasBegin( - ) { - return this._has_begin; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd( - ) { - return this._has_end; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'begin'. - * - * @param begin the value of field 'begin'. - */ - public void setBegin( - final int begin) { - this._begin = begin; - this._has_begin = true; - } - - /** - * Sets the value of field 'description'. - * - * @param description the value of field 'description'. - */ - public void setDescription( - final java.lang.String description) { - this._description = description; - } - - /** - * Sets the value of field 'end'. - * - * @param end the value of field 'end'. - */ - public void setEnd( - final int end) { - this._end = end; - this._has_end = true; - } - - /** - * Sets the value of field 'status'. - * - * @param status the value of field 'status'. - */ - public void setStatus( - final java.lang.String status) { - this._status = status; - } - - /** - * Sets the value of field 'type'. - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Feature - */ - public static jalview.binding.Feature unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Feature) Unmarshaller.unmarshal(jalview.binding.Feature.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class Feature implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _begin. + */ + private int _begin; + + /** + * keeps track of state for field: _begin + */ + private boolean _has_begin; + + /** + * Field _end. + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _type. + */ + private java.lang.String _type; + + /** + * Field _description. + */ + private java.lang.String _description; + + /** + * Field _status. + */ + private java.lang.String _status; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Feature() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + */ + public void deleteBegin() + { + this._has_begin = false; + } + + /** + */ + public void deleteEnd() + { + this._has_end = false; + } + + /** + * Returns the value of field 'begin'. + * + * @return the value of field 'Begin'. + */ + public int getBegin() + { + return this._begin; + } + + /** + * Returns the value of field 'description'. + * + * @return the value of field 'Description'. + */ + public java.lang.String getDescription() + { + return this._description; + } + + /** + * Returns the value of field 'end'. + * + * @return the value of field 'End'. + */ + public int getEnd() + { + return this._end; + } + + /** + * Returns the value of field 'status'. + * + * @return the value of field 'Status'. + */ + public java.lang.String getStatus() + { + return this._status; + } + + /** + * Returns the value of field 'type'. + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() + { + return this._type; + } + + /** + * Method hasBegin. + * + * @return true if at least one Begin has been added + */ + public boolean hasBegin() + { + return this._has_begin; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd() + { + return this._has_end; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'begin'. + * + * @param begin + * the value of field 'begin'. + */ + public void setBegin(final int begin) + { + this._begin = begin; + this._has_begin = true; + } + + /** + * Sets the value of field 'description'. + * + * @param description + * the value of field 'description'. + */ + public void setDescription(final java.lang.String description) + { + this._description = description; + } + + /** + * Sets the value of field 'end'. + * + * @param end + * the value of field 'end'. + */ + public void setEnd(final int end) + { + this._end = end; + this._has_end = true; + } + + /** + * Sets the value of field 'status'. + * + * @param status + * the value of field 'status'. + */ + public void setStatus(final java.lang.String status) + { + this._status = status; + } + + /** + * Sets the value of field 'type'. + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) + { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Feature + */ + public static jalview.binding.Feature unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Feature) Unmarshaller.unmarshal( + jalview.binding.Feature.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/FeatureSettings.java b/src/jalview/binding/FeatureSettings.java index f3d06be..b6c3640 100755 --- a/src/jalview/binding/FeatureSettings.java +++ b/src/jalview/binding/FeatureSettings.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,257 +30,275 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class FeatureSettings implements java.io.Serializable { +public class FeatureSettings implements java.io.Serializable +{ + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ + /** + * Field _settingList. + */ + private java.util.Vector _settingList; - /** - * Field _settingList. - */ - private java.util.Vector _settingList; + // ----------------/ + // - Constructors -/ + // ----------------/ + public FeatureSettings() + { + super(); + this._settingList = new java.util.Vector(); + } - //----------------/ - //- Constructors -/ - //----------------/ + // -----------/ + // - Methods -/ + // -----------/ - public FeatureSettings() { - super(); - this._settingList = new java.util.Vector(); - } + /** + * + * + * @param vSetting + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSetting(final jalview.binding.Setting vSetting) + throws java.lang.IndexOutOfBoundsException + { + this._settingList.addElement(vSetting); + } + /** + * + * + * @param index + * @param vSetting + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSetting(final int index, + final jalview.binding.Setting vSetting) + throws java.lang.IndexOutOfBoundsException + { + this._settingList.add(index, vSetting); + } - //-----------/ - //- Methods -/ - //-----------/ + /** + * Method enumerateSetting. + * + * @return an Enumeration over all jalview.binding.Setting elements + */ + public java.util.Enumeration enumerateSetting() + { + return this._settingList.elements(); + } - /** - * - * - * @param vSetting - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSetting( - final jalview.binding.Setting vSetting) - throws java.lang.IndexOutOfBoundsException { - this._settingList.addElement(vSetting); + /** + * Method getSetting. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Setting at the given index + */ + public jalview.binding.Setting getSetting(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._settingList.size()) + { + throw new IndexOutOfBoundsException("getSetting: Index value '" + + index + "' not in range [0.." + + (this._settingList.size() - 1) + "]"); } - /** - * - * - * @param index - * @param vSetting - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSetting( - final int index, - final jalview.binding.Setting vSetting) - throws java.lang.IndexOutOfBoundsException { - this._settingList.add(index, vSetting); - } + return (jalview.binding.Setting) _settingList.get(index); + } - /** - * Method enumerateSetting. - * - * @return an Enumeration over all jalview.binding.Setting - * elements - */ - public java.util.Enumeration enumerateSetting( - ) { - return this._settingList.elements(); - } + /** + * Method getSetting.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Setting[] getSetting() + { + jalview.binding.Setting[] array = new jalview.binding.Setting[0]; + return (jalview.binding.Setting[]) this._settingList.toArray(array); + } - /** - * Method getSetting. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Setting at the - * given index - */ - public jalview.binding.Setting getSetting( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._settingList.size()) { - throw new IndexOutOfBoundsException("getSetting: Index value '" + index + "' not in range [0.." + (this._settingList.size() - 1) + "]"); - } - - return (jalview.binding.Setting) _settingList.get(index); - } + /** + * Method getSettingCount. + * + * @return the size of this collection + */ + public int getSettingCount() + { + return this._settingList.size(); + } - /** - * Method getSetting.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Setting[] getSetting( - ) { - jalview.binding.Setting[] array = new jalview.binding.Setting[0]; - return (jalview.binding.Setting[]) this._settingList.toArray(array); + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } - /** - * Method getSettingCount. - * - * @return the size of this collection - */ - public int getSettingCount( - ) { - return this._settingList.size(); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + */ + public void removeAllSetting() + { + this._settingList.clear(); + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + /** + * Method removeSetting. + * + * @param vSetting + * @return true if the object was removed from the collection. + */ + public boolean removeSetting(final jalview.binding.Setting vSetting) + { + boolean removed = _settingList.remove(vSetting); + return removed; + } - /** - */ - public void removeAllSetting( - ) { - this._settingList.clear(); - } + /** + * Method removeSettingAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Setting removeSettingAt(final int index) + { + java.lang.Object obj = this._settingList.remove(index); + return (jalview.binding.Setting) obj; + } - /** - * Method removeSetting. - * - * @param vSetting - * @return true if the object was removed from the collection. - */ - public boolean removeSetting( - final jalview.binding.Setting vSetting) { - boolean removed = _settingList.remove(vSetting); - return removed; + /** + * + * + * @param index + * @param vSetting + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSetting(final int index, + final jalview.binding.Setting vSetting) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._settingList.size()) + { + throw new IndexOutOfBoundsException("setSetting: Index value '" + + index + "' not in range [0.." + + (this._settingList.size() - 1) + "]"); } - /** - * Method removeSettingAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Setting removeSettingAt( - final int index) { - java.lang.Object obj = this._settingList.remove(index); - return (jalview.binding.Setting) obj; - } + this._settingList.set(index, vSetting); + } - /** - * - * - * @param index - * @param vSetting - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSetting( - final int index, - final jalview.binding.Setting vSetting) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._settingList.size()) { - throw new IndexOutOfBoundsException("setSetting: Index value '" + index + "' not in range [0.." + (this._settingList.size() - 1) + "]"); - } - - this._settingList.set(index, vSetting); - } + /** + * + * + * @param vSettingArray + */ + public void setSetting(final jalview.binding.Setting[] vSettingArray) + { + // -- copy array + _settingList.clear(); - /** - * - * - * @param vSettingArray - */ - public void setSetting( - final jalview.binding.Setting[] vSettingArray) { - //-- copy array - _settingList.clear(); - - for (int i = 0; i < vSettingArray.length; i++) { - this._settingList.add(vSettingArray[i]); - } + for (int i = 0; i < vSettingArray.length; i++) + { + this._settingList.add(vSettingArray[i]); } + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.FeatureSettings - */ - public static jalview.binding.FeatureSettings unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(jalview.binding.FeatureSettings.class, reader); - } + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.FeatureSettings + */ + public static jalview.binding.FeatureSettings unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal( + jalview.binding.FeatureSettings.class, reader); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Features.java b/src/jalview/binding/Features.java index e50ae7c..8adfa03 100755 --- a/src/jalview/binding/Features.java +++ b/src/jalview/binding/Features.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,98 +30,110 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Features extends Feature -implements java.io.Serializable +public class Features extends Feature implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ - - public Features() { - super(); - } + public Features() + { + super(); + } + // -----------/ + // - Methods -/ + // -----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Feature - */ - public static jalview.binding.Feature unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Feature) Unmarshaller.unmarshal(jalview.binding.Features.class, reader); - } + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Feature + */ + public static jalview.binding.Feature unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Feature) Unmarshaller.unmarshal( + jalview.binding.Features.class, reader); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/JGroup.java b/src/jalview/binding/JGroup.java index 862eebd..a0117ee 100755 --- a/src/jalview/binding/JGroup.java +++ b/src/jalview/binding/JGroup.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,721 +30,746 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class JGroup implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _start. - */ - private int _start; - - /** - * keeps track of state for field: _start - */ - private boolean _has_start; - - /** - * Field _end. - */ - private int _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - /** - * Field _name. - */ - private java.lang.String _name; - - /** - * Field _colour. - */ - private java.lang.String _colour; - - /** - * Field _consThreshold. - */ - private int _consThreshold; - - /** - * keeps track of state for field: _consThreshold - */ - private boolean _has_consThreshold; - - /** - * Field _pidThreshold. - */ - private int _pidThreshold; - - /** - * keeps track of state for field: _pidThreshold - */ - private boolean _has_pidThreshold; - - /** - * Field _outlineColour. - */ - private int _outlineColour; - - /** - * keeps track of state for field: _outlineColour - */ - private boolean _has_outlineColour; - - /** - * Field _displayBoxes. - */ - private boolean _displayBoxes; - - /** - * keeps track of state for field: _displayBoxes - */ - private boolean _has_displayBoxes; - - /** - * Field _displayText. - */ - private boolean _displayText; - - /** - * keeps track of state for field: _displayText - */ - private boolean _has_displayText; - - /** - * Field _colourText. - */ - private boolean _colourText; - - /** - * keeps track of state for field: _colourText - */ - private boolean _has_colourText; - - /** - * Field _seqList. - */ - private java.util.Vector _seqList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JGroup() { - super(); - this._seqList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vSeq - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeq( - final int vSeq) - throws java.lang.IndexOutOfBoundsException { - this._seqList.addElement(new java.lang.Integer(vSeq)); - } - - /** - * - * - * @param index - * @param vSeq - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSeq( - final int index, - final int vSeq) - throws java.lang.IndexOutOfBoundsException { - this._seqList.add(index, new java.lang.Integer(vSeq)); - } - - /** - */ - public void deleteColourText( - ) { - this._has_colourText= false; - } - - /** - */ - public void deleteConsThreshold( - ) { - this._has_consThreshold= false; - } - - /** - */ - public void deleteDisplayBoxes( - ) { - this._has_displayBoxes= false; - } - - /** - */ - public void deleteDisplayText( - ) { - this._has_displayText= false; - } - - /** - */ - public void deleteEnd( - ) { - this._has_end= false; - } - - /** - */ - public void deleteOutlineColour( - ) { - this._has_outlineColour= false; - } - - /** - */ - public void deletePidThreshold( - ) { - this._has_pidThreshold= false; - } - - /** - */ - public void deleteStart( - ) { - this._has_start= false; - } - - /** - * Method enumerateSeq. - * - * @return an Enumeration over all int elements - */ - public java.util.Enumeration enumerateSeq( - ) { - return this._seqList.elements(); - } - - /** - * Returns the value of field 'colour'. - * - * @return the value of field 'Colour'. - */ - public java.lang.String getColour( - ) { - return this._colour; - } - - /** - * Returns the value of field 'colourText'. - * - * @return the value of field 'ColourText'. - */ - public boolean getColourText( - ) { - return this._colourText; - } - - /** - * Returns the value of field 'consThreshold'. - * - * @return the value of field 'ConsThreshold'. - */ - public int getConsThreshold( - ) { - return this._consThreshold; - } - - /** - * Returns the value of field 'displayBoxes'. - * - * @return the value of field 'DisplayBoxes'. - */ - public boolean getDisplayBoxes( - ) { - return this._displayBoxes; - } - - /** - * Returns the value of field 'displayText'. - * - * @return the value of field 'DisplayText'. - */ - public boolean getDisplayText( - ) { - return this._displayText; - } - - /** - * Returns the value of field 'end'. - * - * @return the value of field 'End'. - */ - public int getEnd( - ) { - return this._end; - } - - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Returns the value of field 'outlineColour'. - * - * @return the value of field 'OutlineColour'. - */ - public int getOutlineColour( - ) { - return this._outlineColour; - } - - /** - * Returns the value of field 'pidThreshold'. - * - * @return the value of field 'PidThreshold'. - */ - public int getPidThreshold( - ) { - return this._pidThreshold; - } - - /** - * Method getSeq. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the int at the given index - */ - public int getSeq( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._seqList.size()) { - throw new IndexOutOfBoundsException("getSeq: Index value '" + index + "' not in range [0.." + (this._seqList.size() - 1) + "]"); - } - - return ((java.lang.Integer) _seqList.get(index)).intValue(); - } - - /** - * Method getSeq.Returns the contents of the collection in an - * Array. - * - * @return this collection as an Array - */ - public int[] getSeq( - ) { - int size = this._seqList.size(); - int[] array = new int[size]; - java.util.Iterator iter = _seqList.iterator(); - for (int index = 0; index < size; index++) { - array[index] = ((java.lang.Integer) iter.next()).intValue(); - } - return array; - } - - /** - * Method getSeqCount. - * - * @return the size of this collection - */ - public int getSeqCount( - ) { - return this._seqList.size(); - } - - /** - * Returns the value of field 'start'. - * - * @return the value of field 'Start'. - */ - public int getStart( - ) { - return this._start; - } - - /** - * Method hasColourText. - * - * @return true if at least one ColourText has been added - */ - public boolean hasColourText( - ) { - return this._has_colourText; - } - - /** - * Method hasConsThreshold. - * - * @return true if at least one ConsThreshold has been added - */ - public boolean hasConsThreshold( - ) { - return this._has_consThreshold; - } - - /** - * Method hasDisplayBoxes. - * - * @return true if at least one DisplayBoxes has been added - */ - public boolean hasDisplayBoxes( - ) { - return this._has_displayBoxes; - } - - /** - * Method hasDisplayText. - * - * @return true if at least one DisplayText has been added - */ - public boolean hasDisplayText( - ) { - return this._has_displayText; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd( - ) { - return this._has_end; - } - - /** - * Method hasOutlineColour. - * - * @return true if at least one OutlineColour has been added - */ - public boolean hasOutlineColour( - ) { - return this._has_outlineColour; - } - - /** - * Method hasPidThreshold. - * - * @return true if at least one PidThreshold has been added - */ - public boolean hasPidThreshold( - ) { - return this._has_pidThreshold; - } - - /** - * Method hasStart. - * - * @return true if at least one Start has been added - */ - public boolean hasStart( - ) { - return this._has_start; - } - - /** - * Returns the value of field 'colourText'. - * - * @return the value of field 'ColourText'. - */ - public boolean isColourText( - ) { - return this._colourText; - } - - /** - * Returns the value of field 'displayBoxes'. - * - * @return the value of field 'DisplayBoxes'. - */ - public boolean isDisplayBoxes( - ) { - return this._displayBoxes; - } - - /** - * Returns the value of field 'displayText'. - * - * @return the value of field 'DisplayText'. - */ - public boolean isDisplayText( - ) { - return this._displayText; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllSeq( - ) { - this._seqList.clear(); - } - - /** - * Method removeSeq. - * - * @param vSeq - * @return true if the object was removed from the collection. - */ - public boolean removeSeq( - final int vSeq) { - boolean removed = _seqList.remove(new java.lang.Integer(vSeq)); - return removed; - } - - /** - * Method removeSeqAt. - * - * @param index - * @return the element removed from the collection - */ - public int removeSeqAt( - final int index) { - java.lang.Object obj = this._seqList.remove(index); - return ((java.lang.Integer) obj).intValue(); - } - - /** - * Sets the value of field 'colour'. - * - * @param colour the value of field 'colour'. - */ - public void setColour( - final java.lang.String colour) { - this._colour = colour; - } - - /** - * Sets the value of field 'colourText'. - * - * @param colourText the value of field 'colourText'. - */ - public void setColourText( - final boolean colourText) { - this._colourText = colourText; - this._has_colourText = true; - } - - /** - * Sets the value of field 'consThreshold'. - * - * @param consThreshold the value of field 'consThreshold'. - */ - public void setConsThreshold( - final int consThreshold) { - this._consThreshold = consThreshold; - this._has_consThreshold = true; - } - - /** - * Sets the value of field 'displayBoxes'. - * - * @param displayBoxes the value of field 'displayBoxes'. - */ - public void setDisplayBoxes( - final boolean displayBoxes) { - this._displayBoxes = displayBoxes; - this._has_displayBoxes = true; - } - - /** - * Sets the value of field 'displayText'. - * - * @param displayText the value of field 'displayText'. - */ - public void setDisplayText( - final boolean displayText) { - this._displayText = displayText; - this._has_displayText = true; - } - - /** - * Sets the value of field 'end'. - * - * @param end the value of field 'end'. - */ - public void setEnd( - final int end) { - this._end = end; - this._has_end = true; - } - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * Sets the value of field 'outlineColour'. - * - * @param outlineColour the value of field 'outlineColour'. - */ - public void setOutlineColour( - final int outlineColour) { - this._outlineColour = outlineColour; - this._has_outlineColour = true; - } - - /** - * Sets the value of field 'pidThreshold'. - * - * @param pidThreshold the value of field 'pidThreshold'. - */ - public void setPidThreshold( - final int pidThreshold) { - this._pidThreshold = pidThreshold; - this._has_pidThreshold = true; - } - - /** - * - * - * @param index - * @param vSeq - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSeq( - final int index, - final int vSeq) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._seqList.size()) { - throw new IndexOutOfBoundsException("setSeq: Index value '" + index + "' not in range [0.." + (this._seqList.size() - 1) + "]"); - } - - this._seqList.set(index, new java.lang.Integer(vSeq)); - } - - /** - * - * - * @param vSeqArray - */ - public void setSeq( - final int[] vSeqArray) { - //-- copy array - _seqList.clear(); - - for (int i = 0; i < vSeqArray.length; i++) { - this._seqList.add(new java.lang.Integer(vSeqArray[i])); - } - } - - /** - * Sets the value of field 'start'. - * - * @param start the value of field 'start'. - */ - public void setStart( - final int start) { - this._start = start; - this._has_start = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.JGroup - */ - public static jalview.binding.JGroup unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.JGroup) Unmarshaller.unmarshal(jalview.binding.JGroup.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class JGroup implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _start. + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end. + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _name. + */ + private java.lang.String _name; + + /** + * Field _colour. + */ + private java.lang.String _colour; + + /** + * Field _consThreshold. + */ + private int _consThreshold; + + /** + * keeps track of state for field: _consThreshold + */ + private boolean _has_consThreshold; + + /** + * Field _pidThreshold. + */ + private int _pidThreshold; + + /** + * keeps track of state for field: _pidThreshold + */ + private boolean _has_pidThreshold; + + /** + * Field _outlineColour. + */ + private int _outlineColour; + + /** + * keeps track of state for field: _outlineColour + */ + private boolean _has_outlineColour; + + /** + * Field _displayBoxes. + */ + private boolean _displayBoxes; + + /** + * keeps track of state for field: _displayBoxes + */ + private boolean _has_displayBoxes; + + /** + * Field _displayText. + */ + private boolean _displayText; + + /** + * keeps track of state for field: _displayText + */ + private boolean _has_displayText; + + /** + * Field _colourText. + */ + private boolean _colourText; + + /** + * keeps track of state for field: _colourText + */ + private boolean _has_colourText; + + /** + * Field _seqList. + */ + private java.util.Vector _seqList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public JGroup() + { + super(); + this._seqList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vSeq + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeq(final int vSeq) + throws java.lang.IndexOutOfBoundsException + { + this._seqList.addElement(new java.lang.Integer(vSeq)); + } + + /** + * + * + * @param index + * @param vSeq + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSeq(final int index, final int vSeq) + throws java.lang.IndexOutOfBoundsException + { + this._seqList.add(index, new java.lang.Integer(vSeq)); + } + + /** + */ + public void deleteColourText() + { + this._has_colourText = false; + } + + /** + */ + public void deleteConsThreshold() + { + this._has_consThreshold = false; + } + + /** + */ + public void deleteDisplayBoxes() + { + this._has_displayBoxes = false; + } + + /** + */ + public void deleteDisplayText() + { + this._has_displayText = false; + } + + /** + */ + public void deleteEnd() + { + this._has_end = false; + } + + /** + */ + public void deleteOutlineColour() + { + this._has_outlineColour = false; + } + + /** + */ + public void deletePidThreshold() + { + this._has_pidThreshold = false; + } + + /** + */ + public void deleteStart() + { + this._has_start = false; + } + + /** + * Method enumerateSeq. + * + * @return an Enumeration over all int elements + */ + public java.util.Enumeration enumerateSeq() + { + return this._seqList.elements(); + } + + /** + * Returns the value of field 'colour'. + * + * @return the value of field 'Colour'. + */ + public java.lang.String getColour() + { + return this._colour; + } + + /** + * Returns the value of field 'colourText'. + * + * @return the value of field 'ColourText'. + */ + public boolean getColourText() + { + return this._colourText; + } + + /** + * Returns the value of field 'consThreshold'. + * + * @return the value of field 'ConsThreshold'. + */ + public int getConsThreshold() + { + return this._consThreshold; + } + + /** + * Returns the value of field 'displayBoxes'. + * + * @return the value of field 'DisplayBoxes'. + */ + public boolean getDisplayBoxes() + { + return this._displayBoxes; + } + + /** + * Returns the value of field 'displayText'. + * + * @return the value of field 'DisplayText'. + */ + public boolean getDisplayText() + { + return this._displayText; + } + + /** + * Returns the value of field 'end'. + * + * @return the value of field 'End'. + */ + public int getEnd() + { + return this._end; + } + + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() + { + return this._name; + } + + /** + * Returns the value of field 'outlineColour'. + * + * @return the value of field 'OutlineColour'. + */ + public int getOutlineColour() + { + return this._outlineColour; + } + + /** + * Returns the value of field 'pidThreshold'. + * + * @return the value of field 'PidThreshold'. + */ + public int getPidThreshold() + { + return this._pidThreshold; + } + + /** + * Method getSeq. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the int at the given index + */ + public int getSeq(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._seqList.size()) + { + throw new IndexOutOfBoundsException("getSeq: Index value '" + index + + "' not in range [0.." + (this._seqList.size() - 1) + "]"); + } + + return ((java.lang.Integer) _seqList.get(index)).intValue(); + } + + /** + * Method getSeq.Returns the contents of the collection in an Array. + * + * @return this collection as an Array + */ + public int[] getSeq() + { + int size = this._seqList.size(); + int[] array = new int[size]; + java.util.Iterator iter = _seqList.iterator(); + for (int index = 0; index < size; index++) + { + array[index] = ((java.lang.Integer) iter.next()).intValue(); + } + return array; + } + + /** + * Method getSeqCount. + * + * @return the size of this collection + */ + public int getSeqCount() + { + return this._seqList.size(); + } + + /** + * Returns the value of field 'start'. + * + * @return the value of field 'Start'. + */ + public int getStart() + { + return this._start; + } + + /** + * Method hasColourText. + * + * @return true if at least one ColourText has been added + */ + public boolean hasColourText() + { + return this._has_colourText; + } + + /** + * Method hasConsThreshold. + * + * @return true if at least one ConsThreshold has been added + */ + public boolean hasConsThreshold() + { + return this._has_consThreshold; + } + + /** + * Method hasDisplayBoxes. + * + * @return true if at least one DisplayBoxes has been added + */ + public boolean hasDisplayBoxes() + { + return this._has_displayBoxes; + } + + /** + * Method hasDisplayText. + * + * @return true if at least one DisplayText has been added + */ + public boolean hasDisplayText() + { + return this._has_displayText; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd() + { + return this._has_end; + } + + /** + * Method hasOutlineColour. + * + * @return true if at least one OutlineColour has been added + */ + public boolean hasOutlineColour() + { + return this._has_outlineColour; + } + + /** + * Method hasPidThreshold. + * + * @return true if at least one PidThreshold has been added + */ + public boolean hasPidThreshold() + { + return this._has_pidThreshold; + } + + /** + * Method hasStart. + * + * @return true if at least one Start has been added + */ + public boolean hasStart() + { + return this._has_start; + } + + /** + * Returns the value of field 'colourText'. + * + * @return the value of field 'ColourText'. + */ + public boolean isColourText() + { + return this._colourText; + } + + /** + * Returns the value of field 'displayBoxes'. + * + * @return the value of field 'DisplayBoxes'. + */ + public boolean isDisplayBoxes() + { + return this._displayBoxes; + } + + /** + * Returns the value of field 'displayText'. + * + * @return the value of field 'DisplayText'. + */ + public boolean isDisplayText() + { + return this._displayText; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllSeq() + { + this._seqList.clear(); + } + + /** + * Method removeSeq. + * + * @param vSeq + * @return true if the object was removed from the collection. + */ + public boolean removeSeq(final int vSeq) + { + boolean removed = _seqList.remove(new java.lang.Integer(vSeq)); + return removed; + } + + /** + * Method removeSeqAt. + * + * @param index + * @return the element removed from the collection + */ + public int removeSeqAt(final int index) + { + java.lang.Object obj = this._seqList.remove(index); + return ((java.lang.Integer) obj).intValue(); + } + + /** + * Sets the value of field 'colour'. + * + * @param colour + * the value of field 'colour'. + */ + public void setColour(final java.lang.String colour) + { + this._colour = colour; + } + + /** + * Sets the value of field 'colourText'. + * + * @param colourText + * the value of field 'colourText'. + */ + public void setColourText(final boolean colourText) + { + this._colourText = colourText; + this._has_colourText = true; + } + + /** + * Sets the value of field 'consThreshold'. + * + * @param consThreshold + * the value of field 'consThreshold'. + */ + public void setConsThreshold(final int consThreshold) + { + this._consThreshold = consThreshold; + this._has_consThreshold = true; + } + + /** + * Sets the value of field 'displayBoxes'. + * + * @param displayBoxes + * the value of field 'displayBoxes'. + */ + public void setDisplayBoxes(final boolean displayBoxes) + { + this._displayBoxes = displayBoxes; + this._has_displayBoxes = true; + } + + /** + * Sets the value of field 'displayText'. + * + * @param displayText + * the value of field 'displayText'. + */ + public void setDisplayText(final boolean displayText) + { + this._displayText = displayText; + this._has_displayText = true; + } + + /** + * Sets the value of field 'end'. + * + * @param end + * the value of field 'end'. + */ + public void setEnd(final int end) + { + this._end = end; + this._has_end = true; + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) + { + this._name = name; + } + + /** + * Sets the value of field 'outlineColour'. + * + * @param outlineColour + * the value of field 'outlineColour'. + */ + public void setOutlineColour(final int outlineColour) + { + this._outlineColour = outlineColour; + this._has_outlineColour = true; + } + + /** + * Sets the value of field 'pidThreshold'. + * + * @param pidThreshold + * the value of field 'pidThreshold'. + */ + public void setPidThreshold(final int pidThreshold) + { + this._pidThreshold = pidThreshold; + this._has_pidThreshold = true; + } + + /** + * + * + * @param index + * @param vSeq + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSeq(final int index, final int vSeq) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._seqList.size()) + { + throw new IndexOutOfBoundsException("setSeq: Index value '" + index + + "' not in range [0.." + (this._seqList.size() - 1) + "]"); + } + + this._seqList.set(index, new java.lang.Integer(vSeq)); + } + + /** + * + * + * @param vSeqArray + */ + public void setSeq(final int[] vSeqArray) + { + // -- copy array + _seqList.clear(); + + for (int i = 0; i < vSeqArray.length; i++) + { + this._seqList.add(new java.lang.Integer(vSeqArray[i])); + } + } + + /** + * Sets the value of field 'start'. + * + * @param start + * the value of field 'start'. + */ + public void setStart(final int start) + { + this._start = start; + this._has_start = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.JGroup + */ + public static jalview.binding.JGroup unmarshal(final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JGroup) Unmarshaller.unmarshal( + jalview.binding.JGroup.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/JSeq.java b/src/jalview/binding/JSeq.java index 14b1f2f..19ef2ae 100755 --- a/src/jalview/binding/JSeq.java +++ b/src/jalview/binding/JSeq.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,605 +30,631 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class JSeq implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _colour. - */ - private int _colour; - - /** - * keeps track of state for field: _colour - */ - private boolean _has_colour; - - /** - * Field _start. - */ - private int _start; - - /** - * keeps track of state for field: _start - */ - private boolean _has_start; - - /** - * Field _end. - */ - private int _end; - - /** - * keeps track of state for field: _end - */ - private boolean _has_end; - - /** - * Field _id. - */ - private int _id; - - /** - * keeps track of state for field: _id - */ - private boolean _has_id; - - /** - * Field _featuresList. - */ - private java.util.Vector _featuresList; - - /** - * Field _pdbidsList. - */ - private java.util.Vector _pdbidsList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JSeq() { - super(); - this._featuresList = new java.util.Vector(); - this._pdbidsList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vFeatures - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addFeatures( - final jalview.binding.Features vFeatures) - throws java.lang.IndexOutOfBoundsException { - this._featuresList.addElement(vFeatures); - } - - /** - * - * - * @param index - * @param vFeatures - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addFeatures( - final int index, - final jalview.binding.Features vFeatures) - throws java.lang.IndexOutOfBoundsException { - this._featuresList.add(index, vFeatures); - } - - /** - * - * - * @param vPdbids - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addPdbids( - final jalview.binding.Pdbids vPdbids) - throws java.lang.IndexOutOfBoundsException { - this._pdbidsList.addElement(vPdbids); - } - - /** - * - * - * @param index - * @param vPdbids - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addPdbids( - final int index, - final jalview.binding.Pdbids vPdbids) - throws java.lang.IndexOutOfBoundsException { - this._pdbidsList.add(index, vPdbids); - } - - /** - */ - public void deleteColour( - ) { - this._has_colour= false; - } - - /** - */ - public void deleteEnd( - ) { - this._has_end= false; - } - - /** - */ - public void deleteId( - ) { - this._has_id= false; - } - - /** - */ - public void deleteStart( - ) { - this._has_start= false; - } - - /** - * Method enumerateFeatures. - * - * @return an Enumeration over all jalview.binding.Features - * elements - */ - public java.util.Enumeration enumerateFeatures( - ) { - return this._featuresList.elements(); - } - - /** - * Method enumeratePdbids. - * - * @return an Enumeration over all jalview.binding.Pdbids - * elements - */ - public java.util.Enumeration enumeratePdbids( - ) { - return this._pdbidsList.elements(); - } - - /** - * Returns the value of field 'colour'. - * - * @return the value of field 'Colour'. - */ - public int getColour( - ) { - return this._colour; - } - - /** - * Returns the value of field 'end'. - * - * @return the value of field 'End'. - */ - public int getEnd( - ) { - return this._end; - } - - /** - * Method getFeatures. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Features at the - * given index - */ - public jalview.binding.Features getFeatures( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._featuresList.size()) { - throw new IndexOutOfBoundsException("getFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]"); - } - - return (jalview.binding.Features) _featuresList.get(index); - } - - /** - * Method getFeatures.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Features[] getFeatures( - ) { - jalview.binding.Features[] array = new jalview.binding.Features[0]; - return (jalview.binding.Features[]) this._featuresList.toArray(array); - } - - /** - * Method getFeaturesCount. - * - * @return the size of this collection - */ - public int getFeaturesCount( - ) { - return this._featuresList.size(); - } - - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public int getId( - ) { - return this._id; - } - - /** - * Method getPdbids. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Pdbids at the given - * index - */ - public jalview.binding.Pdbids getPdbids( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._pdbidsList.size()) { - throw new IndexOutOfBoundsException("getPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]"); - } - - return (jalview.binding.Pdbids) _pdbidsList.get(index); - } - - /** - * Method getPdbids.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Pdbids[] getPdbids( - ) { - jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0]; - return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array); - } - - /** - * Method getPdbidsCount. - * - * @return the size of this collection - */ - public int getPdbidsCount( - ) { - return this._pdbidsList.size(); - } - - /** - * Returns the value of field 'start'. - * - * @return the value of field 'Start'. - */ - public int getStart( - ) { - return this._start; - } - - /** - * Method hasColour. - * - * @return true if at least one Colour has been added - */ - public boolean hasColour( - ) { - return this._has_colour; - } - - /** - * Method hasEnd. - * - * @return true if at least one End has been added - */ - public boolean hasEnd( - ) { - return this._has_end; - } - - /** - * Method hasId. - * - * @return true if at least one Id has been added - */ - public boolean hasId( - ) { - return this._has_id; - } - - /** - * Method hasStart. - * - * @return true if at least one Start has been added - */ - public boolean hasStart( - ) { - return this._has_start; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllFeatures( - ) { - this._featuresList.clear(); - } - - /** - */ - public void removeAllPdbids( - ) { - this._pdbidsList.clear(); - } - - /** - * Method removeFeatures. - * - * @param vFeatures - * @return true if the object was removed from the collection. - */ - public boolean removeFeatures( - final jalview.binding.Features vFeatures) { - boolean removed = _featuresList.remove(vFeatures); - return removed; - } - - /** - * Method removeFeaturesAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Features removeFeaturesAt( - final int index) { - java.lang.Object obj = this._featuresList.remove(index); - return (jalview.binding.Features) obj; - } - - /** - * Method removePdbids. - * - * @param vPdbids - * @return true if the object was removed from the collection. - */ - public boolean removePdbids( - final jalview.binding.Pdbids vPdbids) { - boolean removed = _pdbidsList.remove(vPdbids); - return removed; - } - - /** - * Method removePdbidsAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Pdbids removePdbidsAt( - final int index) { - java.lang.Object obj = this._pdbidsList.remove(index); - return (jalview.binding.Pdbids) obj; - } - - /** - * Sets the value of field 'colour'. - * - * @param colour the value of field 'colour'. - */ - public void setColour( - final int colour) { - this._colour = colour; - this._has_colour = true; - } - - /** - * Sets the value of field 'end'. - * - * @param end the value of field 'end'. - */ - public void setEnd( - final int end) { - this._end = end; - this._has_end = true; - } - - /** - * - * - * @param index - * @param vFeatures - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setFeatures( - final int index, - final jalview.binding.Features vFeatures) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._featuresList.size()) { - throw new IndexOutOfBoundsException("setFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]"); - } - - this._featuresList.set(index, vFeatures); - } - - /** - * - * - * @param vFeaturesArray - */ - public void setFeatures( - final jalview.binding.Features[] vFeaturesArray) { - //-- copy array - _featuresList.clear(); - - for (int i = 0; i < vFeaturesArray.length; i++) { - this._featuresList.add(vFeaturesArray[i]); - } - } - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId( - final int id) { - this._id = id; - this._has_id = true; - } - - /** - * - * - * @param index - * @param vPdbids - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setPdbids( - final int index, - final jalview.binding.Pdbids vPdbids) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._pdbidsList.size()) { - throw new IndexOutOfBoundsException("setPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]"); - } - - this._pdbidsList.set(index, vPdbids); - } - - /** - * - * - * @param vPdbidsArray - */ - public void setPdbids( - final jalview.binding.Pdbids[] vPdbidsArray) { - //-- copy array - _pdbidsList.clear(); - - for (int i = 0; i < vPdbidsArray.length; i++) { - this._pdbidsList.add(vPdbidsArray[i]); - } - } - - /** - * Sets the value of field 'start'. - * - * @param start the value of field 'start'. - */ - public void setStart( - final int start) { - this._start = start; - this._has_start = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.JSeq - */ - public static jalview.binding.JSeq unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.JSeq) Unmarshaller.unmarshal(jalview.binding.JSeq.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class JSeq implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _colour. + */ + private int _colour; + + /** + * keeps track of state for field: _colour + */ + private boolean _has_colour; + + /** + * Field _start. + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end. + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _id. + */ + private int _id; + + /** + * keeps track of state for field: _id + */ + private boolean _has_id; + + /** + * Field _featuresList. + */ + private java.util.Vector _featuresList; + + /** + * Field _pdbidsList. + */ + private java.util.Vector _pdbidsList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public JSeq() + { + super(); + this._featuresList = new java.util.Vector(); + this._pdbidsList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vFeatures + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addFeatures(final jalview.binding.Features vFeatures) + throws java.lang.IndexOutOfBoundsException + { + this._featuresList.addElement(vFeatures); + } + + /** + * + * + * @param index + * @param vFeatures + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addFeatures(final int index, + final jalview.binding.Features vFeatures) + throws java.lang.IndexOutOfBoundsException + { + this._featuresList.add(index, vFeatures); + } + + /** + * + * + * @param vPdbids + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addPdbids(final jalview.binding.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException + { + this._pdbidsList.addElement(vPdbids); + } + + /** + * + * + * @param index + * @param vPdbids + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addPdbids(final int index, + final jalview.binding.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException + { + this._pdbidsList.add(index, vPdbids); + } + + /** + */ + public void deleteColour() + { + this._has_colour = false; + } + + /** + */ + public void deleteEnd() + { + this._has_end = false; + } + + /** + */ + public void deleteId() + { + this._has_id = false; + } + + /** + */ + public void deleteStart() + { + this._has_start = false; + } + + /** + * Method enumerateFeatures. + * + * @return an Enumeration over all jalview.binding.Features elements + */ + public java.util.Enumeration enumerateFeatures() + { + return this._featuresList.elements(); + } + + /** + * Method enumeratePdbids. + * + * @return an Enumeration over all jalview.binding.Pdbids elements + */ + public java.util.Enumeration enumeratePdbids() + { + return this._pdbidsList.elements(); + } + + /** + * Returns the value of field 'colour'. + * + * @return the value of field 'Colour'. + */ + public int getColour() + { + return this._colour; + } + + /** + * Returns the value of field 'end'. + * + * @return the value of field 'End'. + */ + public int getEnd() + { + return this._end; + } + + /** + * Method getFeatures. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Features at the given index + */ + public jalview.binding.Features getFeatures(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._featuresList.size()) + { + throw new IndexOutOfBoundsException("getFeatures: Index value '" + + index + "' not in range [0.." + + (this._featuresList.size() - 1) + "]"); + } + + return (jalview.binding.Features) _featuresList.get(index); + } + + /** + * Method getFeatures.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Features[] getFeatures() + { + jalview.binding.Features[] array = new jalview.binding.Features[0]; + return (jalview.binding.Features[]) this._featuresList.toArray(array); + } + + /** + * Method getFeaturesCount. + * + * @return the size of this collection + */ + public int getFeaturesCount() + { + return this._featuresList.size(); + } + + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public int getId() + { + return this._id; + } + + /** + * Method getPdbids. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Pdbids at the given index + */ + public jalview.binding.Pdbids getPdbids(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._pdbidsList.size()) + { + throw new IndexOutOfBoundsException("getPdbids: Index value '" + + index + "' not in range [0.." + + (this._pdbidsList.size() - 1) + "]"); + } + + return (jalview.binding.Pdbids) _pdbidsList.get(index); + } + + /** + * Method getPdbids.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Pdbids[] getPdbids() + { + jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0]; + return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array); + } + + /** + * Method getPdbidsCount. + * + * @return the size of this collection + */ + public int getPdbidsCount() + { + return this._pdbidsList.size(); + } + + /** + * Returns the value of field 'start'. + * + * @return the value of field 'Start'. + */ + public int getStart() + { + return this._start; + } + + /** + * Method hasColour. + * + * @return true if at least one Colour has been added + */ + public boolean hasColour() + { + return this._has_colour; + } + + /** + * Method hasEnd. + * + * @return true if at least one End has been added + */ + public boolean hasEnd() + { + return this._has_end; + } + + /** + * Method hasId. + * + * @return true if at least one Id has been added + */ + public boolean hasId() + { + return this._has_id; + } + + /** + * Method hasStart. + * + * @return true if at least one Start has been added + */ + public boolean hasStart() + { + return this._has_start; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllFeatures() + { + this._featuresList.clear(); + } + + /** + */ + public void removeAllPdbids() + { + this._pdbidsList.clear(); + } + + /** + * Method removeFeatures. + * + * @param vFeatures + * @return true if the object was removed from the collection. + */ + public boolean removeFeatures(final jalview.binding.Features vFeatures) + { + boolean removed = _featuresList.remove(vFeatures); + return removed; + } + + /** + * Method removeFeaturesAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Features removeFeaturesAt(final int index) + { + java.lang.Object obj = this._featuresList.remove(index); + return (jalview.binding.Features) obj; + } + + /** + * Method removePdbids. + * + * @param vPdbids + * @return true if the object was removed from the collection. + */ + public boolean removePdbids(final jalview.binding.Pdbids vPdbids) + { + boolean removed = _pdbidsList.remove(vPdbids); + return removed; + } + + /** + * Method removePdbidsAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Pdbids removePdbidsAt(final int index) + { + java.lang.Object obj = this._pdbidsList.remove(index); + return (jalview.binding.Pdbids) obj; + } + + /** + * Sets the value of field 'colour'. + * + * @param colour + * the value of field 'colour'. + */ + public void setColour(final int colour) + { + this._colour = colour; + this._has_colour = true; + } + + /** + * Sets the value of field 'end'. + * + * @param end + * the value of field 'end'. + */ + public void setEnd(final int end) + { + this._end = end; + this._has_end = true; + } + + /** + * + * + * @param index + * @param vFeatures + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setFeatures(final int index, + final jalview.binding.Features vFeatures) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._featuresList.size()) + { + throw new IndexOutOfBoundsException("setFeatures: Index value '" + + index + "' not in range [0.." + + (this._featuresList.size() - 1) + "]"); + } + + this._featuresList.set(index, vFeatures); + } + + /** + * + * + * @param vFeaturesArray + */ + public void setFeatures(final jalview.binding.Features[] vFeaturesArray) + { + // -- copy array + _featuresList.clear(); + + for (int i = 0; i < vFeaturesArray.length; i++) + { + this._featuresList.add(vFeaturesArray[i]); + } + } + + /** + * Sets the value of field 'id'. + * + * @param id + * the value of field 'id'. + */ + public void setId(final int id) + { + this._id = id; + this._has_id = true; + } + + /** + * + * + * @param index + * @param vPdbids + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setPdbids(final int index, + final jalview.binding.Pdbids vPdbids) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._pdbidsList.size()) + { + throw new IndexOutOfBoundsException("setPdbids: Index value '" + + index + "' not in range [0.." + + (this._pdbidsList.size() - 1) + "]"); + } + + this._pdbidsList.set(index, vPdbids); + } + + /** + * + * + * @param vPdbidsArray + */ + public void setPdbids(final jalview.binding.Pdbids[] vPdbidsArray) + { + // -- copy array + _pdbidsList.clear(); + + for (int i = 0; i < vPdbidsArray.length; i++) + { + this._pdbidsList.add(vPdbidsArray[i]); + } + } + + /** + * Sets the value of field 'start'. + * + * @param start + * the value of field 'start'. + */ + public void setStart(final int start) + { + this._start = start; + this._has_start = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.JSeq + */ + public static jalview.binding.JSeq unmarshal(final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JSeq) Unmarshaller.unmarshal( + jalview.binding.JSeq.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/JalviewModel.java b/src/jalview/binding/JalviewModel.java index 21f8be9..eae870d 100755 --- a/src/jalview/binding/JalviewModel.java +++ b/src/jalview/binding/JalviewModel.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,202 +30,219 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class JalviewModel implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _creationDate. - */ - private java.util.Date _creationDate; - - /** - * Field _version. - */ - private java.lang.String _version; - - /** - * Field _vamsasModel. - */ - private jalview.binding.VamsasModel _vamsasModel; - - /** - * Field _jalviewModelSequence. - */ - private jalview.binding.JalviewModelSequence _jalviewModelSequence; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JalviewModel() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'creationDate'. - * - * @return the value of field 'CreationDate'. - */ - public java.util.Date getCreationDate( - ) { - return this._creationDate; - } - - /** - * Returns the value of field 'jalviewModelSequence'. - * - * @return the value of field 'JalviewModelSequence'. - */ - public jalview.binding.JalviewModelSequence getJalviewModelSequence( - ) { - return this._jalviewModelSequence; - } - - /** - * Returns the value of field 'vamsasModel'. - * - * @return the value of field 'VamsasModel'. - */ - public jalview.binding.VamsasModel getVamsasModel( - ) { - return this._vamsasModel; - } - - /** - * Returns the value of field 'version'. - * - * @return the value of field 'Version'. - */ - public java.lang.String getVersion( - ) { - return this._version; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'creationDate'. - * - * @param creationDate the value of field 'creationDate'. - */ - public void setCreationDate( - final java.util.Date creationDate) { - this._creationDate = creationDate; - } - - /** - * Sets the value of field 'jalviewModelSequence'. - * - * @param jalviewModelSequence the value of field - * 'jalviewModelSequence'. - */ - public void setJalviewModelSequence( - final jalview.binding.JalviewModelSequence jalviewModelSequence) { - this._jalviewModelSequence = jalviewModelSequence; - } - - /** - * Sets the value of field 'vamsasModel'. - * - * @param vamsasModel the value of field 'vamsasModel'. - */ - public void setVamsasModel( - final jalview.binding.VamsasModel vamsasModel) { - this._vamsasModel = vamsasModel; - } - - /** - * Sets the value of field 'version'. - * - * @param version the value of field 'version'. - */ - public void setVersion( - final java.lang.String version) { - this._version = version; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.JalviewModel - */ - public static jalview.binding.JalviewModel unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewModel) Unmarshaller.unmarshal(jalview.binding.JalviewModel.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class JalviewModel implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _creationDate. + */ + private java.util.Date _creationDate; + + /** + * Field _version. + */ + private java.lang.String _version; + + /** + * Field _vamsasModel. + */ + private jalview.binding.VamsasModel _vamsasModel; + + /** + * Field _jalviewModelSequence. + */ + private jalview.binding.JalviewModelSequence _jalviewModelSequence; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public JalviewModel() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Returns the value of field 'creationDate'. + * + * @return the value of field 'CreationDate'. + */ + public java.util.Date getCreationDate() + { + return this._creationDate; + } + + /** + * Returns the value of field 'jalviewModelSequence'. + * + * @return the value of field 'JalviewModelSequence'. + */ + public jalview.binding.JalviewModelSequence getJalviewModelSequence() + { + return this._jalviewModelSequence; + } + + /** + * Returns the value of field 'vamsasModel'. + * + * @return the value of field 'VamsasModel'. + */ + public jalview.binding.VamsasModel getVamsasModel() + { + return this._vamsasModel; + } + + /** + * Returns the value of field 'version'. + * + * @return the value of field 'Version'. + */ + public java.lang.String getVersion() + { + return this._version; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'creationDate'. + * + * @param creationDate + * the value of field 'creationDate'. + */ + public void setCreationDate(final java.util.Date creationDate) + { + this._creationDate = creationDate; + } + + /** + * Sets the value of field 'jalviewModelSequence'. + * + * @param jalviewModelSequence + * the value of field 'jalviewModelSequence'. + */ + public void setJalviewModelSequence( + final jalview.binding.JalviewModelSequence jalviewModelSequence) + { + this._jalviewModelSequence = jalviewModelSequence; + } + + /** + * Sets the value of field 'vamsasModel'. + * + * @param vamsasModel + * the value of field 'vamsasModel'. + */ + public void setVamsasModel(final jalview.binding.VamsasModel vamsasModel) + { + this._vamsasModel = vamsasModel; + } + + /** + * Sets the value of field 'version'. + * + * @param version + * the value of field 'version'. + */ + public void setVersion(final java.lang.String version) + { + this._version = version; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.JalviewModel + */ + public static jalview.binding.JalviewModel unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JalviewModel) Unmarshaller.unmarshal( + jalview.binding.JalviewModel.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/JalviewModelSequence.java b/src/jalview/binding/JalviewModelSequence.java index 5ebcee6..2a247c0 100755 --- a/src/jalview/binding/JalviewModelSequence.java +++ b/src/jalview/binding/JalviewModelSequence.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,904 +30,941 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class JalviewModelSequence implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _JSeqList. - */ - private java.util.Vector _JSeqList; - - /** - * Field _JGroupList. - */ - private java.util.Vector _JGroupList; - - /** - * Field _viewportList. - */ - private java.util.Vector _viewportList; - - /** - * Field _userColoursList. - */ - private java.util.Vector _userColoursList; - - /** - * Field _treeList. - */ - private java.util.Vector _treeList; - - /** - * Field _featureSettings. - */ - private jalview.binding.FeatureSettings _featureSettings; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JalviewModelSequence() { - super(); - this._JSeqList = new java.util.Vector(); - this._JGroupList = new java.util.Vector(); - this._viewportList = new java.util.Vector(); - this._userColoursList = new java.util.Vector(); - this._treeList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vJGroup - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addJGroup( - final jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException { - this._JGroupList.addElement(vJGroup); - } - - /** - * - * - * @param index - * @param vJGroup - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addJGroup( - final int index, - final jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException { - this._JGroupList.add(index, vJGroup); - } - - /** - * - * - * @param vJSeq - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addJSeq( - final jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException { - this._JSeqList.addElement(vJSeq); - } - - /** - * - * - * @param index - * @param vJSeq - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addJSeq( - final int index, - final jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException { - this._JSeqList.add(index, vJSeq); - } - - /** - * - * - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final jalview.binding.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.addElement(vTree); - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final int index, - final jalview.binding.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.add(index, vTree); - } - - /** - * - * - * @param vUserColours - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addUserColours( - final jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException { - this._userColoursList.addElement(vUserColours); - } - - /** - * - * - * @param index - * @param vUserColours - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addUserColours( - final int index, - final jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException { - this._userColoursList.add(index, vUserColours); - } - - /** - * - * - * @param vViewport - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addViewport( - final jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException { - this._viewportList.addElement(vViewport); - } - - /** - * - * - * @param index - * @param vViewport - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addViewport( - final int index, - final jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException { - this._viewportList.add(index, vViewport); - } - - /** - * Method enumerateJGroup. - * - * @return an Enumeration over all jalview.binding.JGroup - * elements - */ - public java.util.Enumeration enumerateJGroup( - ) { - return this._JGroupList.elements(); - } - - /** - * Method enumerateJSeq. - * - * @return an Enumeration over all jalview.binding.JSeq elements - */ - public java.util.Enumeration enumerateJSeq( - ) { - return this._JSeqList.elements(); - } - - /** - * Method enumerateTree. - * - * @return an Enumeration over all jalview.binding.Tree elements - */ - public java.util.Enumeration enumerateTree( - ) { - return this._treeList.elements(); - } - - /** - * Method enumerateUserColours. - * - * @return an Enumeration over all jalview.binding.UserColours - * elements - */ - public java.util.Enumeration enumerateUserColours( - ) { - return this._userColoursList.elements(); - } - - /** - * Method enumerateViewport. - * - * @return an Enumeration over all jalview.binding.Viewport - * elements - */ - public java.util.Enumeration enumerateViewport( - ) { - return this._viewportList.elements(); - } - - /** - * Returns the value of field 'featureSettings'. - * - * @return the value of field 'FeatureSettings'. - */ - public jalview.binding.FeatureSettings getFeatureSettings( - ) { - return this._featureSettings; - } - - /** - * Method getJGroup. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.JGroup at the given - * index - */ - public jalview.binding.JGroup getJGroup( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._JGroupList.size()) { - throw new IndexOutOfBoundsException("getJGroup: Index value '" + index + "' not in range [0.." + (this._JGroupList.size() - 1) + "]"); - } - - return (jalview.binding.JGroup) _JGroupList.get(index); - } - - /** - * Method getJGroup.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.JGroup[] getJGroup( - ) { - jalview.binding.JGroup[] array = new jalview.binding.JGroup[0]; - return (jalview.binding.JGroup[]) this._JGroupList.toArray(array); - } - - /** - * Method getJGroupCount. - * - * @return the size of this collection - */ - public int getJGroupCount( - ) { - return this._JGroupList.size(); - } - - /** - * Method getJSeq. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.JSeq at the given - * index - */ - public jalview.binding.JSeq getJSeq( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._JSeqList.size()) { - throw new IndexOutOfBoundsException("getJSeq: Index value '" + index + "' not in range [0.." + (this._JSeqList.size() - 1) + "]"); - } - - return (jalview.binding.JSeq) _JSeqList.get(index); - } - - /** - * Method getJSeq.Returns the contents of the collection in an - * Array.

    Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.JSeq[] getJSeq( - ) { - jalview.binding.JSeq[] array = new jalview.binding.JSeq[0]; - return (jalview.binding.JSeq[]) this._JSeqList.toArray(array); - } - - /** - * Method getJSeqCount. - * - * @return the size of this collection - */ - public int getJSeqCount( - ) { - return this._JSeqList.size(); - } - - /** - * Method getTree. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Tree at the given - * index - */ - public jalview.binding.Tree getTree( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - return (jalview.binding.Tree) _treeList.get(index); - } - - /** - * Method getTree.Returns the contents of the collection in an - * Array.

    Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Tree[] getTree( - ) { - jalview.binding.Tree[] array = new jalview.binding.Tree[0]; - return (jalview.binding.Tree[]) this._treeList.toArray(array); - } - - /** - * Method getTreeCount. - * - * @return the size of this collection - */ - public int getTreeCount( - ) { - return this._treeList.size(); - } - - /** - * Method getUserColours. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.UserColours at the - * given index - */ - public jalview.binding.UserColours getUserColours( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._userColoursList.size()) { - throw new IndexOutOfBoundsException("getUserColours: Index value '" + index + "' not in range [0.." + (this._userColoursList.size() - 1) + "]"); - } - - return (jalview.binding.UserColours) _userColoursList.get(index); - } - - /** - * Method getUserColours.Returns the contents of the collection - * in an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.UserColours[] getUserColours( - ) { - jalview.binding.UserColours[] array = new jalview.binding.UserColours[0]; - return (jalview.binding.UserColours[]) this._userColoursList.toArray(array); - } - - /** - * Method getUserColoursCount. - * - * @return the size of this collection - */ - public int getUserColoursCount( - ) { - return this._userColoursList.size(); - } - - /** - * Method getViewport. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Viewport at the - * given index - */ - public jalview.binding.Viewport getViewport( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._viewportList.size()) { - throw new IndexOutOfBoundsException("getViewport: Index value '" + index + "' not in range [0.." + (this._viewportList.size() - 1) + "]"); - } - - return (jalview.binding.Viewport) _viewportList.get(index); - } - - /** - * Method getViewport.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Viewport[] getViewport( - ) { - jalview.binding.Viewport[] array = new jalview.binding.Viewport[0]; - return (jalview.binding.Viewport[]) this._viewportList.toArray(array); - } - - /** - * Method getViewportCount. - * - * @return the size of this collection - */ - public int getViewportCount( - ) { - return this._viewportList.size(); - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllJGroup( - ) { - this._JGroupList.clear(); - } - - /** - */ - public void removeAllJSeq( - ) { - this._JSeqList.clear(); - } - - /** - */ - public void removeAllTree( - ) { - this._treeList.clear(); - } - - /** - */ - public void removeAllUserColours( - ) { - this._userColoursList.clear(); - } - - /** - */ - public void removeAllViewport( - ) { - this._viewportList.clear(); - } - - /** - * Method removeJGroup. - * - * @param vJGroup - * @return true if the object was removed from the collection. - */ - public boolean removeJGroup( - final jalview.binding.JGroup vJGroup) { - boolean removed = _JGroupList.remove(vJGroup); - return removed; - } - - /** - * Method removeJGroupAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.JGroup removeJGroupAt( - final int index) { - java.lang.Object obj = this._JGroupList.remove(index); - return (jalview.binding.JGroup) obj; - } - - /** - * Method removeJSeq. - * - * @param vJSeq - * @return true if the object was removed from the collection. - */ - public boolean removeJSeq( - final jalview.binding.JSeq vJSeq) { - boolean removed = _JSeqList.remove(vJSeq); - return removed; - } - - /** - * Method removeJSeqAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.JSeq removeJSeqAt( - final int index) { - java.lang.Object obj = this._JSeqList.remove(index); - return (jalview.binding.JSeq) obj; - } - - /** - * Method removeTree. - * - * @param vTree - * @return true if the object was removed from the collection. - */ - public boolean removeTree( - final jalview.binding.Tree vTree) { - boolean removed = _treeList.remove(vTree); - return removed; - } - - /** - * Method removeTreeAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Tree removeTreeAt( - final int index) { - java.lang.Object obj = this._treeList.remove(index); - return (jalview.binding.Tree) obj; - } - - /** - * Method removeUserColours. - * - * @param vUserColours - * @return true if the object was removed from the collection. - */ - public boolean removeUserColours( - final jalview.binding.UserColours vUserColours) { - boolean removed = _userColoursList.remove(vUserColours); - return removed; - } - - /** - * Method removeUserColoursAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.UserColours removeUserColoursAt( - final int index) { - java.lang.Object obj = this._userColoursList.remove(index); - return (jalview.binding.UserColours) obj; - } - - /** - * Method removeViewport. - * - * @param vViewport - * @return true if the object was removed from the collection. - */ - public boolean removeViewport( - final jalview.binding.Viewport vViewport) { - boolean removed = _viewportList.remove(vViewport); - return removed; - } - - /** - * Method removeViewportAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Viewport removeViewportAt( - final int index) { - java.lang.Object obj = this._viewportList.remove(index); - return (jalview.binding.Viewport) obj; - } - - /** - * Sets the value of field 'featureSettings'. - * - * @param featureSettings the value of field 'featureSettings'. - */ - public void setFeatureSettings( - final jalview.binding.FeatureSettings featureSettings) { - this._featureSettings = featureSettings; - } - - /** - * - * - * @param index - * @param vJGroup - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setJGroup( - final int index, - final jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._JGroupList.size()) { - throw new IndexOutOfBoundsException("setJGroup: Index value '" + index + "' not in range [0.." + (this._JGroupList.size() - 1) + "]"); - } - - this._JGroupList.set(index, vJGroup); - } - - /** - * - * - * @param vJGroupArray - */ - public void setJGroup( - final jalview.binding.JGroup[] vJGroupArray) { - //-- copy array - _JGroupList.clear(); - - for (int i = 0; i < vJGroupArray.length; i++) { - this._JGroupList.add(vJGroupArray[i]); - } - } - - /** - * - * - * @param index - * @param vJSeq - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setJSeq( - final int index, - final jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._JSeqList.size()) { - throw new IndexOutOfBoundsException("setJSeq: Index value '" + index + "' not in range [0.." + (this._JSeqList.size() - 1) + "]"); - } - - this._JSeqList.set(index, vJSeq); - } - - /** - * - * - * @param vJSeqArray - */ - public void setJSeq( - final jalview.binding.JSeq[] vJSeqArray) { - //-- copy array - _JSeqList.clear(); - - for (int i = 0; i < vJSeqArray.length; i++) { - this._JSeqList.add(vJSeqArray[i]); - } - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTree( - final int index, - final jalview.binding.Tree vTree) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - this._treeList.set(index, vTree); - } - - /** - * - * - * @param vTreeArray - */ - public void setTree( - final jalview.binding.Tree[] vTreeArray) { - //-- copy array - _treeList.clear(); - - for (int i = 0; i < vTreeArray.length; i++) { - this._treeList.add(vTreeArray[i]); - } - } - - /** - * - * - * @param index - * @param vUserColours - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setUserColours( - final int index, - final jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._userColoursList.size()) { - throw new IndexOutOfBoundsException("setUserColours: Index value '" + index + "' not in range [0.." + (this._userColoursList.size() - 1) + "]"); - } - - this._userColoursList.set(index, vUserColours); - } - - /** - * - * - * @param vUserColoursArray - */ - public void setUserColours( - final jalview.binding.UserColours[] vUserColoursArray) { - //-- copy array - _userColoursList.clear(); - - for (int i = 0; i < vUserColoursArray.length; i++) { - this._userColoursList.add(vUserColoursArray[i]); - } - } - - /** - * - * - * @param index - * @param vViewport - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setViewport( - final int index, - final jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._viewportList.size()) { - throw new IndexOutOfBoundsException("setViewport: Index value '" + index + "' not in range [0.." + (this._viewportList.size() - 1) + "]"); - } - - this._viewportList.set(index, vViewport); - } - - /** - * - * - * @param vViewportArray - */ - public void setViewport( - final jalview.binding.Viewport[] vViewportArray) { - //-- copy array - _viewportList.clear(); - - for (int i = 0; i < vViewportArray.length; i++) { - this._viewportList.add(vViewportArray[i]); - } - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.JalviewModelSequence - */ - public static jalview.binding.JalviewModelSequence unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewModelSequence) Unmarshaller.unmarshal(jalview.binding.JalviewModelSequence.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class JalviewModelSequence implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _JSeqList. + */ + private java.util.Vector _JSeqList; + + /** + * Field _JGroupList. + */ + private java.util.Vector _JGroupList; + + /** + * Field _viewportList. + */ + private java.util.Vector _viewportList; + + /** + * Field _userColoursList. + */ + private java.util.Vector _userColoursList; + + /** + * Field _treeList. + */ + private java.util.Vector _treeList; + + /** + * Field _featureSettings. + */ + private jalview.binding.FeatureSettings _featureSettings; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public JalviewModelSequence() + { + super(); + this._JSeqList = new java.util.Vector(); + this._JGroupList = new java.util.Vector(); + this._viewportList = new java.util.Vector(); + this._userColoursList = new java.util.Vector(); + this._treeList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vJGroup + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addJGroup(final jalview.binding.JGroup vJGroup) + throws java.lang.IndexOutOfBoundsException + { + this._JGroupList.addElement(vJGroup); + } + + /** + * + * + * @param index + * @param vJGroup + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addJGroup(final int index, + final jalview.binding.JGroup vJGroup) + throws java.lang.IndexOutOfBoundsException + { + this._JGroupList.add(index, vJGroup); + } + + /** + * + * + * @param vJSeq + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addJSeq(final jalview.binding.JSeq vJSeq) + throws java.lang.IndexOutOfBoundsException + { + this._JSeqList.addElement(vJSeq); + } + + /** + * + * + * @param index + * @param vJSeq + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addJSeq(final int index, final jalview.binding.JSeq vJSeq) + throws java.lang.IndexOutOfBoundsException + { + this._JSeqList.add(index, vJSeq); + } + + /** + * + * + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final jalview.binding.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + this._treeList.addElement(vTree); + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final int index, final jalview.binding.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + this._treeList.add(index, vTree); + } + + /** + * + * + * @param vUserColours + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addUserColours(final jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException + { + this._userColoursList.addElement(vUserColours); + } + + /** + * + * + * @param index + * @param vUserColours + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addUserColours(final int index, + final jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException + { + this._userColoursList.add(index, vUserColours); + } + + /** + * + * + * @param vViewport + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addViewport(final jalview.binding.Viewport vViewport) + throws java.lang.IndexOutOfBoundsException + { + this._viewportList.addElement(vViewport); + } + + /** + * + * + * @param index + * @param vViewport + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addViewport(final int index, + final jalview.binding.Viewport vViewport) + throws java.lang.IndexOutOfBoundsException + { + this._viewportList.add(index, vViewport); + } + + /** + * Method enumerateJGroup. + * + * @return an Enumeration over all jalview.binding.JGroup elements + */ + public java.util.Enumeration enumerateJGroup() + { + return this._JGroupList.elements(); + } + + /** + * Method enumerateJSeq. + * + * @return an Enumeration over all jalview.binding.JSeq elements + */ + public java.util.Enumeration enumerateJSeq() + { + return this._JSeqList.elements(); + } + + /** + * Method enumerateTree. + * + * @return an Enumeration over all jalview.binding.Tree elements + */ + public java.util.Enumeration enumerateTree() + { + return this._treeList.elements(); + } + + /** + * Method enumerateUserColours. + * + * @return an Enumeration over all jalview.binding.UserColours elements + */ + public java.util.Enumeration enumerateUserColours() + { + return this._userColoursList.elements(); + } + + /** + * Method enumerateViewport. + * + * @return an Enumeration over all jalview.binding.Viewport elements + */ + public java.util.Enumeration enumerateViewport() + { + return this._viewportList.elements(); + } + + /** + * Returns the value of field 'featureSettings'. + * + * @return the value of field 'FeatureSettings'. + */ + public jalview.binding.FeatureSettings getFeatureSettings() + { + return this._featureSettings; + } + + /** + * Method getJGroup. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.JGroup at the given index + */ + public jalview.binding.JGroup getJGroup(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._JGroupList.size()) + { + throw new IndexOutOfBoundsException("getJGroup: Index value '" + + index + "' not in range [0.." + + (this._JGroupList.size() - 1) + "]"); + } + + return (jalview.binding.JGroup) _JGroupList.get(index); + } + + /** + * Method getJGroup.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.JGroup[] getJGroup() + { + jalview.binding.JGroup[] array = new jalview.binding.JGroup[0]; + return (jalview.binding.JGroup[]) this._JGroupList.toArray(array); + } + + /** + * Method getJGroupCount. + * + * @return the size of this collection + */ + public int getJGroupCount() + { + return this._JGroupList.size(); + } + + /** + * Method getJSeq. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.JSeq at the given index + */ + public jalview.binding.JSeq getJSeq(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._JSeqList.size()) + { + throw new IndexOutOfBoundsException("getJSeq: Index value '" + index + + "' not in range [0.." + (this._JSeqList.size() - 1) + "]"); + } + + return (jalview.binding.JSeq) _JSeqList.get(index); + } + + /** + * Method getJSeq.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.JSeq[] getJSeq() + { + jalview.binding.JSeq[] array = new jalview.binding.JSeq[0]; + return (jalview.binding.JSeq[]) this._JSeqList.toArray(array); + } + + /** + * Method getJSeqCount. + * + * @return the size of this collection + */ + public int getJSeqCount() + { + return this._JSeqList.size(); + } + + /** + * Method getTree. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Tree at the given index + */ + public jalview.binding.Tree getTree(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) + { + throw new IndexOutOfBoundsException("getTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + return (jalview.binding.Tree) _treeList.get(index); + } + + /** + * Method getTree.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Tree[] getTree() + { + jalview.binding.Tree[] array = new jalview.binding.Tree[0]; + return (jalview.binding.Tree[]) this._treeList.toArray(array); + } + + /** + * Method getTreeCount. + * + * @return the size of this collection + */ + public int getTreeCount() + { + return this._treeList.size(); + } + + /** + * Method getUserColours. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.UserColours at the given index + */ + public jalview.binding.UserColours getUserColours(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._userColoursList.size()) + { + throw new IndexOutOfBoundsException("getUserColours: Index value '" + + index + "' not in range [0.." + + (this._userColoursList.size() - 1) + "]"); + } + + return (jalview.binding.UserColours) _userColoursList.get(index); + } + + /** + * Method getUserColours.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.UserColours[] getUserColours() + { + jalview.binding.UserColours[] array = new jalview.binding.UserColours[0]; + return (jalview.binding.UserColours[]) this._userColoursList + .toArray(array); + } + + /** + * Method getUserColoursCount. + * + * @return the size of this collection + */ + public int getUserColoursCount() + { + return this._userColoursList.size(); + } + + /** + * Method getViewport. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Viewport at the given index + */ + public jalview.binding.Viewport getViewport(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._viewportList.size()) + { + throw new IndexOutOfBoundsException("getViewport: Index value '" + + index + "' not in range [0.." + + (this._viewportList.size() - 1) + "]"); + } + + return (jalview.binding.Viewport) _viewportList.get(index); + } + + /** + * Method getViewport.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Viewport[] getViewport() + { + jalview.binding.Viewport[] array = new jalview.binding.Viewport[0]; + return (jalview.binding.Viewport[]) this._viewportList.toArray(array); + } + + /** + * Method getViewportCount. + * + * @return the size of this collection + */ + public int getViewportCount() + { + return this._viewportList.size(); + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllJGroup() + { + this._JGroupList.clear(); + } + + /** + */ + public void removeAllJSeq() + { + this._JSeqList.clear(); + } + + /** + */ + public void removeAllTree() + { + this._treeList.clear(); + } + + /** + */ + public void removeAllUserColours() + { + this._userColoursList.clear(); + } + + /** + */ + public void removeAllViewport() + { + this._viewportList.clear(); + } + + /** + * Method removeJGroup. + * + * @param vJGroup + * @return true if the object was removed from the collection. + */ + public boolean removeJGroup(final jalview.binding.JGroup vJGroup) + { + boolean removed = _JGroupList.remove(vJGroup); + return removed; + } + + /** + * Method removeJGroupAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.JGroup removeJGroupAt(final int index) + { + java.lang.Object obj = this._JGroupList.remove(index); + return (jalview.binding.JGroup) obj; + } + + /** + * Method removeJSeq. + * + * @param vJSeq + * @return true if the object was removed from the collection. + */ + public boolean removeJSeq(final jalview.binding.JSeq vJSeq) + { + boolean removed = _JSeqList.remove(vJSeq); + return removed; + } + + /** + * Method removeJSeqAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.JSeq removeJSeqAt(final int index) + { + java.lang.Object obj = this._JSeqList.remove(index); + return (jalview.binding.JSeq) obj; + } + + /** + * Method removeTree. + * + * @param vTree + * @return true if the object was removed from the collection. + */ + public boolean removeTree(final jalview.binding.Tree vTree) + { + boolean removed = _treeList.remove(vTree); + return removed; + } + + /** + * Method removeTreeAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Tree removeTreeAt(final int index) + { + java.lang.Object obj = this._treeList.remove(index); + return (jalview.binding.Tree) obj; + } + + /** + * Method removeUserColours. + * + * @param vUserColours + * @return true if the object was removed from the collection. + */ + public boolean removeUserColours( + final jalview.binding.UserColours vUserColours) + { + boolean removed = _userColoursList.remove(vUserColours); + return removed; + } + + /** + * Method removeUserColoursAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.UserColours removeUserColoursAt(final int index) + { + java.lang.Object obj = this._userColoursList.remove(index); + return (jalview.binding.UserColours) obj; + } + + /** + * Method removeViewport. + * + * @param vViewport + * @return true if the object was removed from the collection. + */ + public boolean removeViewport(final jalview.binding.Viewport vViewport) + { + boolean removed = _viewportList.remove(vViewport); + return removed; + } + + /** + * Method removeViewportAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Viewport removeViewportAt(final int index) + { + java.lang.Object obj = this._viewportList.remove(index); + return (jalview.binding.Viewport) obj; + } + + /** + * Sets the value of field 'featureSettings'. + * + * @param featureSettings + * the value of field 'featureSettings'. + */ + public void setFeatureSettings( + final jalview.binding.FeatureSettings featureSettings) + { + this._featureSettings = featureSettings; + } + + /** + * + * + * @param index + * @param vJGroup + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setJGroup(final int index, + final jalview.binding.JGroup vJGroup) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._JGroupList.size()) + { + throw new IndexOutOfBoundsException("setJGroup: Index value '" + + index + "' not in range [0.." + + (this._JGroupList.size() - 1) + "]"); + } + + this._JGroupList.set(index, vJGroup); + } + + /** + * + * + * @param vJGroupArray + */ + public void setJGroup(final jalview.binding.JGroup[] vJGroupArray) + { + // -- copy array + _JGroupList.clear(); + + for (int i = 0; i < vJGroupArray.length; i++) + { + this._JGroupList.add(vJGroupArray[i]); + } + } + + /** + * + * + * @param index + * @param vJSeq + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setJSeq(final int index, final jalview.binding.JSeq vJSeq) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._JSeqList.size()) + { + throw new IndexOutOfBoundsException("setJSeq: Index value '" + index + + "' not in range [0.." + (this._JSeqList.size() - 1) + "]"); + } + + this._JSeqList.set(index, vJSeq); + } + + /** + * + * + * @param vJSeqArray + */ + public void setJSeq(final jalview.binding.JSeq[] vJSeqArray) + { + // -- copy array + _JSeqList.clear(); + + for (int i = 0; i < vJSeqArray.length; i++) + { + this._JSeqList.add(vJSeqArray[i]); + } + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTree(final int index, final jalview.binding.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) + { + throw new IndexOutOfBoundsException("setTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + this._treeList.set(index, vTree); + } + + /** + * + * + * @param vTreeArray + */ + public void setTree(final jalview.binding.Tree[] vTreeArray) + { + // -- copy array + _treeList.clear(); + + for (int i = 0; i < vTreeArray.length; i++) + { + this._treeList.add(vTreeArray[i]); + } + } + + /** + * + * + * @param index + * @param vUserColours + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setUserColours(final int index, + final jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._userColoursList.size()) + { + throw new IndexOutOfBoundsException("setUserColours: Index value '" + + index + "' not in range [0.." + + (this._userColoursList.size() - 1) + "]"); + } + + this._userColoursList.set(index, vUserColours); + } + + /** + * + * + * @param vUserColoursArray + */ + public void setUserColours( + final jalview.binding.UserColours[] vUserColoursArray) + { + // -- copy array + _userColoursList.clear(); + + for (int i = 0; i < vUserColoursArray.length; i++) + { + this._userColoursList.add(vUserColoursArray[i]); + } + } + + /** + * + * + * @param index + * @param vViewport + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setViewport(final int index, + final jalview.binding.Viewport vViewport) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._viewportList.size()) + { + throw new IndexOutOfBoundsException("setViewport: Index value '" + + index + "' not in range [0.." + + (this._viewportList.size() - 1) + "]"); + } + + this._viewportList.set(index, vViewport); + } + + /** + * + * + * @param vViewportArray + */ + public void setViewport(final jalview.binding.Viewport[] vViewportArray) + { + // -- copy array + _viewportList.clear(); + + for (int i = 0; i < vViewportArray.length; i++) + { + this._viewportList.add(vViewportArray[i]); + } + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.JalviewModelSequence + */ + public static jalview.binding.JalviewModelSequence unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JalviewModelSequence) Unmarshaller.unmarshal( + jalview.binding.JalviewModelSequence.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/JalviewUserColours.java b/src/jalview/binding/JalviewUserColours.java index b5d0335..822392e 100755 --- a/src/jalview/binding/JalviewUserColours.java +++ b/src/jalview/binding/JalviewUserColours.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,280 +30,299 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class JalviewUserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _schemeName. - */ - private java.lang.String _schemeName; - - /** - * Field _colourList. - */ - private java.util.Vector _colourList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JalviewUserColours() { - super(); - this._colourList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vColour - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addColour( - final Colour vColour) - throws java.lang.IndexOutOfBoundsException { - this._colourList.addElement(vColour); - } - - /** - * - * - * @param index - * @param vColour - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addColour( - final int index, - final Colour vColour) - throws java.lang.IndexOutOfBoundsException { - this._colourList.add(index, vColour); - } - - /** - * Method enumerateColour. - * - * @return an Enumeration over all Colour elements - */ - public java.util.Enumeration enumerateColour( - ) { - return this._colourList.elements(); - } - - /** - * Method getColour. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the Colour at the given index - */ - public Colour getColour( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._colourList.size()) { - throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]"); - } - - return (Colour) _colourList.get(index); - } - - /** - * Method getColour.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public Colour[] getColour( - ) { - Colour[] array = new Colour[0]; - return (Colour[]) this._colourList.toArray(array); - } - - /** - * Method getColourCount. - * - * @return the size of this collection - */ - public int getColourCount( - ) { - return this._colourList.size(); - } - - /** - * Returns the value of field 'schemeName'. - * - * @return the value of field 'SchemeName'. - */ - public java.lang.String getSchemeName( - ) { - return this._schemeName; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); +public class JalviewUserColours implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _schemeName. + */ + private java.lang.String _schemeName; + + /** + * Field _colourList. + */ + private java.util.Vector _colourList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public JalviewUserColours() + { + super(); + this._colourList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vColour + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addColour(final Colour vColour) + throws java.lang.IndexOutOfBoundsException + { + this._colourList.addElement(vColour); + } + + /** + * + * + * @param index + * @param vColour + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addColour(final int index, final Colour vColour) + throws java.lang.IndexOutOfBoundsException + { + this._colourList.add(index, vColour); + } + + /** + * Method enumerateColour. + * + * @return an Enumeration over all Colour elements + */ + public java.util.Enumeration enumerateColour() + { + return this._colourList.elements(); + } + + /** + * Method getColour. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the Colour at the given index + */ + public Colour getColour(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._colourList.size()) + { + throw new IndexOutOfBoundsException("getColour: Index value '" + + index + "' not in range [0.." + + (this._colourList.size() - 1) + "]"); } - /** - */ - public void removeAllColour( - ) { - this._colourList.clear(); + return (Colour) _colourList.get(index); + } + + /** + * Method getColour.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public Colour[] getColour() + { + Colour[] array = new Colour[0]; + return (Colour[]) this._colourList.toArray(array); + } + + /** + * Method getColourCount. + * + * @return the size of this collection + */ + public int getColourCount() + { + return this._colourList.size(); + } + + /** + * Returns the value of field 'schemeName'. + * + * @return the value of field 'SchemeName'. + */ + public java.lang.String getSchemeName() + { + return this._schemeName; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } - - /** - * Method removeColour. - * - * @param vColour - * @return true if the object was removed from the collection. - */ - public boolean removeColour( - final Colour vColour) { - boolean removed = _colourList.remove(vColour); - return removed; - } - - /** - * Method removeColourAt. - * - * @param index - * @return the element removed from the collection - */ - public Colour removeColourAt( - final int index) { - java.lang.Object obj = this._colourList.remove(index); - return (Colour) obj; - } - - /** - * - * - * @param index - * @param vColour - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setColour( - final int index, - final Colour vColour) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._colourList.size()) { - throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]"); - } - - this._colourList.set(index, vColour); - } - - /** - * - * - * @param vColourArray - */ - public void setColour( - final Colour[] vColourArray) { - //-- copy array - _colourList.clear(); - - for (int i = 0; i < vColourArray.length; i++) { - this._colourList.add(vColourArray[i]); - } - } - - /** - * Sets the value of field 'schemeName'. - * - * @param schemeName the value of field 'schemeName'. - */ - public void setSchemeName( - final java.lang.String schemeName) { - this._schemeName = schemeName; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.JalviewUserColours - */ - public static jalview.binding.JalviewUserColours unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader); + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllColour() + { + this._colourList.clear(); + } + + /** + * Method removeColour. + * + * @param vColour + * @return true if the object was removed from the collection. + */ + public boolean removeColour(final Colour vColour) + { + boolean removed = _colourList.remove(vColour); + return removed; + } + + /** + * Method removeColourAt. + * + * @param index + * @return the element removed from the collection + */ + public Colour removeColourAt(final int index) + { + java.lang.Object obj = this._colourList.remove(index); + return (Colour) obj; + } + + /** + * + * + * @param index + * @param vColour + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setColour(final int index, final Colour vColour) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._colourList.size()) + { + throw new IndexOutOfBoundsException("setColour: Index value '" + + index + "' not in range [0.." + + (this._colourList.size() - 1) + "]"); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._colourList.set(index, vColour); + } + + /** + * + * + * @param vColourArray + */ + public void setColour(final Colour[] vColourArray) + { + // -- copy array + _colourList.clear(); + + for (int i = 0; i < vColourArray.length; i++) + { + this._colourList.add(vColourArray[i]); } + } + + /** + * Sets the value of field 'schemeName'. + * + * @param schemeName + * the value of field 'schemeName'. + */ + public void setSchemeName(final java.lang.String schemeName) + { + this._schemeName = schemeName; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.JalviewUserColours + */ + public static jalview.binding.JalviewUserColours unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal( + jalview.binding.JalviewUserColours.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Pdbentry.java b/src/jalview/binding/Pdbentry.java index cac4cf6..53a2484 100755 --- a/src/jalview/binding/Pdbentry.java +++ b/src/jalview/binding/Pdbentry.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,308 +30,330 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Pdbentry implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id. - */ - private java.lang.String _id; - - /** - * Field _type. - */ - private java.lang.String _type; - - /** - * Field _items. - */ - private java.util.Vector _items; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Pdbentry() { - super(); - this._items = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vPdbentryItem - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addPdbentryItem( - final jalview.binding.PdbentryItem vPdbentryItem) - throws java.lang.IndexOutOfBoundsException { - this._items.addElement(vPdbentryItem); - } - - /** - * - * - * @param index - * @param vPdbentryItem - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addPdbentryItem( - final int index, - final jalview.binding.PdbentryItem vPdbentryItem) - throws java.lang.IndexOutOfBoundsException { - this._items.add(index, vPdbentryItem); - } - - /** - * Method enumeratePdbentryItem. - * - * @return an Enumeration over all jalview.binding.PdbentryItem - * elements - */ - public java.util.Enumeration enumeratePdbentryItem( - ) { - return this._items.elements(); - } - - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Method getPdbentryItem. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.PdbentryItem at the - * given index - */ - public jalview.binding.PdbentryItem getPdbentryItem( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._items.size()) { - throw new IndexOutOfBoundsException("getPdbentryItem: Index value '" + index + "' not in range [0.." + (this._items.size() - 1) + "]"); - } - - return (jalview.binding.PdbentryItem) _items.get(index); - } - - /** - * Method getPdbentryItem.Returns the contents of the - * collection in an Array.

    Note: Just in case the - * collection contents are changing in another thread, we pass - * a 0-length Array of the correct type into the API call. - * This way we know that the Array returned is of - * exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.PdbentryItem[] getPdbentryItem( - ) { - jalview.binding.PdbentryItem[] array = new jalview.binding.PdbentryItem[0]; - return (jalview.binding.PdbentryItem[]) this._items.toArray(array); - } - - /** - * Method getPdbentryItemCount. - * - * @return the size of this collection - */ - public int getPdbentryItemCount( - ) { - return this._items.size(); - } - - /** - * Returns the value of field 'type'. - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllPdbentryItem( - ) { - this._items.clear(); - } - - /** - * Method removePdbentryItem. - * - * @param vPdbentryItem - * @return true if the object was removed from the collection. - */ - public boolean removePdbentryItem( - final jalview.binding.PdbentryItem vPdbentryItem) { - boolean removed = _items.remove(vPdbentryItem); - return removed; - } - - /** - * Method removePdbentryItemAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.PdbentryItem removePdbentryItemAt( - final int index) { - java.lang.Object obj = this._items.remove(index); - return (jalview.binding.PdbentryItem) obj; - } - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId( - final java.lang.String id) { - this._id = id; - } - - /** - * - * - * @param index - * @param vPdbentryItem - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setPdbentryItem( - final int index, - final jalview.binding.PdbentryItem vPdbentryItem) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._items.size()) { - throw new IndexOutOfBoundsException("setPdbentryItem: Index value '" + index + "' not in range [0.." + (this._items.size() - 1) + "]"); - } - - this._items.set(index, vPdbentryItem); +public class Pdbentry implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _id. + */ + private java.lang.String _id; + + /** + * Field _type. + */ + private java.lang.String _type; + + /** + * Field _items. + */ + private java.util.Vector _items; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Pdbentry() + { + super(); + this._items = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vPdbentryItem + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addPdbentryItem( + final jalview.binding.PdbentryItem vPdbentryItem) + throws java.lang.IndexOutOfBoundsException + { + this._items.addElement(vPdbentryItem); + } + + /** + * + * + * @param index + * @param vPdbentryItem + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addPdbentryItem(final int index, + final jalview.binding.PdbentryItem vPdbentryItem) + throws java.lang.IndexOutOfBoundsException + { + this._items.add(index, vPdbentryItem); + } + + /** + * Method enumeratePdbentryItem. + * + * @return an Enumeration over all jalview.binding.PdbentryItem elements + */ + public java.util.Enumeration enumeratePdbentryItem() + { + return this._items.elements(); + } + + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() + { + return this._id; + } + + /** + * Method getPdbentryItem. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.PdbentryItem at the given index + */ + public jalview.binding.PdbentryItem getPdbentryItem(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._items.size()) + { + throw new IndexOutOfBoundsException("getPdbentryItem: Index value '" + + index + "' not in range [0.." + (this._items.size() - 1) + + "]"); } - /** - * - * - * @param vPdbentryItemArray - */ - public void setPdbentryItem( - final jalview.binding.PdbentryItem[] vPdbentryItemArray) { - //-- copy array - _items.clear(); - - for (int i = 0; i < vPdbentryItemArray.length; i++) { - this._items.add(vPdbentryItemArray[i]); - } + return (jalview.binding.PdbentryItem) _items.get(index); + } + + /** + * Method getPdbentryItem.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.PdbentryItem[] getPdbentryItem() + { + jalview.binding.PdbentryItem[] array = new jalview.binding.PdbentryItem[0]; + return (jalview.binding.PdbentryItem[]) this._items.toArray(array); + } + + /** + * Method getPdbentryItemCount. + * + * @return the size of this collection + */ + public int getPdbentryItemCount() + { + return this._items.size(); + } + + /** + * Returns the value of field 'type'. + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() + { + return this._type; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } - - /** - * Sets the value of field 'type'. - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Pdbentry - */ - public static jalview.binding.Pdbentry unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Pdbentry) Unmarshaller.unmarshal(jalview.binding.Pdbentry.class, reader); + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllPdbentryItem() + { + this._items.clear(); + } + + /** + * Method removePdbentryItem. + * + * @param vPdbentryItem + * @return true if the object was removed from the collection. + */ + public boolean removePdbentryItem( + final jalview.binding.PdbentryItem vPdbentryItem) + { + boolean removed = _items.remove(vPdbentryItem); + return removed; + } + + /** + * Method removePdbentryItemAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.PdbentryItem removePdbentryItemAt(final int index) + { + java.lang.Object obj = this._items.remove(index); + return (jalview.binding.PdbentryItem) obj; + } + + /** + * Sets the value of field 'id'. + * + * @param id + * the value of field 'id'. + */ + public void setId(final java.lang.String id) + { + this._id = id; + } + + /** + * + * + * @param index + * @param vPdbentryItem + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setPdbentryItem(final int index, + final jalview.binding.PdbentryItem vPdbentryItem) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._items.size()) + { + throw new IndexOutOfBoundsException("setPdbentryItem: Index value '" + + index + "' not in range [0.." + (this._items.size() - 1) + + "]"); } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); + this._items.set(index, vPdbentryItem); + } + + /** + * + * + * @param vPdbentryItemArray + */ + public void setPdbentryItem( + final jalview.binding.PdbentryItem[] vPdbentryItemArray) + { + // -- copy array + _items.clear(); + + for (int i = 0; i < vPdbentryItemArray.length; i++) + { + this._items.add(vPdbentryItemArray[i]); } + } + + /** + * Sets the value of field 'type'. + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) + { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Pdbentry + */ + public static jalview.binding.Pdbentry unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Pdbentry) Unmarshaller.unmarshal( + jalview.binding.Pdbentry.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/PdbentryItem.java b/src/jalview/binding/PdbentryItem.java index 83bc40a..dc2314b 100755 --- a/src/jalview/binding/PdbentryItem.java +++ b/src/jalview/binding/PdbentryItem.java @@ -1,10 +1,21 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; /** @@ -12,181 +23,185 @@ package jalview.binding; * * @version $Revision$ $Date$ */ -public class PdbentryItem implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _propertyList. - */ - private java.util.Vector _propertyList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public PdbentryItem() { - super(); - this._propertyList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final jalview.binding.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.addElement(vProperty); - } - - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addProperty( - final int index, - final jalview.binding.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - this._propertyList.add(index, vProperty); - } - - /** - * Method enumerateProperty. - * - * @return an Enumeration over all jalview.binding.Property - * elements - */ - public java.util.Enumeration enumerateProperty( - ) { - return this._propertyList.elements(); - } - - /** - * Method getProperty. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Property at the - * given index - */ - public jalview.binding.Property getProperty( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - return (jalview.binding.Property) _propertyList.get(index); - } - - /** - * Method getProperty.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Property[] getProperty( - ) { - jalview.binding.Property[] array = new jalview.binding.Property[0]; - return (jalview.binding.Property[]) this._propertyList.toArray(array); - } - - /** - * Method getPropertyCount. - * - * @return the size of this collection - */ - public int getPropertyCount( - ) { - return this._propertyList.size(); - } - - /** - */ - public void removeAllProperty( - ) { - this._propertyList.clear(); - } - - /** - * Method removeProperty. - * - * @param vProperty - * @return true if the object was removed from the collection. - */ - public boolean removeProperty( - final jalview.binding.Property vProperty) { - boolean removed = _propertyList.remove(vProperty); - return removed; - } - - /** - * Method removePropertyAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Property removePropertyAt( - final int index) { - java.lang.Object obj = this._propertyList.remove(index); - return (jalview.binding.Property) obj; +public class PdbentryItem implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _propertyList. + */ + private java.util.Vector _propertyList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public PdbentryItem() + { + super(); + this._propertyList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final jalview.binding.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + this._propertyList.addElement(vProperty); + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addProperty(final int index, + final jalview.binding.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + this._propertyList.add(index, vProperty); + } + + /** + * Method enumerateProperty. + * + * @return an Enumeration over all jalview.binding.Property elements + */ + public java.util.Enumeration enumerateProperty() + { + return this._propertyList.elements(); + } + + /** + * Method getProperty. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Property at the given index + */ + public jalview.binding.Property getProperty(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) + { + throw new IndexOutOfBoundsException("getProperty: Index value '" + + index + "' not in range [0.." + + (this._propertyList.size() - 1) + "]"); } - /** - * - * - * @param index - * @param vProperty - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setProperty( - final int index, - final jalview.binding.Property vProperty) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._propertyList.size()) { - throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]"); - } - - this._propertyList.set(index, vProperty); + return (jalview.binding.Property) _propertyList.get(index); + } + + /** + * Method getProperty.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Property[] getProperty() + { + jalview.binding.Property[] array = new jalview.binding.Property[0]; + return (jalview.binding.Property[]) this._propertyList.toArray(array); + } + + /** + * Method getPropertyCount. + * + * @return the size of this collection + */ + public int getPropertyCount() + { + return this._propertyList.size(); + } + + /** + */ + public void removeAllProperty() + { + this._propertyList.clear(); + } + + /** + * Method removeProperty. + * + * @param vProperty + * @return true if the object was removed from the collection. + */ + public boolean removeProperty(final jalview.binding.Property vProperty) + { + boolean removed = _propertyList.remove(vProperty); + return removed; + } + + /** + * Method removePropertyAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Property removePropertyAt(final int index) + { + java.lang.Object obj = this._propertyList.remove(index); + return (jalview.binding.Property) obj; + } + + /** + * + * + * @param index + * @param vProperty + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setProperty(final int index, + final jalview.binding.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._propertyList.size()) + { + throw new IndexOutOfBoundsException("setProperty: Index value '" + + index + "' not in range [0.." + + (this._propertyList.size() - 1) + "]"); } - /** - * - * - * @param vPropertyArray - */ - public void setProperty( - final jalview.binding.Property[] vPropertyArray) { - //-- copy array - _propertyList.clear(); - - for (int i = 0; i < vPropertyArray.length; i++) { - this._propertyList.add(vPropertyArray[i]); - } + this._propertyList.set(index, vProperty); + } + + /** + * + * + * @param vPropertyArray + */ + public void setProperty(final jalview.binding.Property[] vPropertyArray) + { + // -- copy array + _propertyList.clear(); + + for (int i = 0; i < vPropertyArray.length; i++) + { + this._propertyList.add(vPropertyArray[i]); } + } } diff --git a/src/jalview/binding/Pdbids.java b/src/jalview/binding/Pdbids.java index b4745a2..9713859 100755 --- a/src/jalview/binding/Pdbids.java +++ b/src/jalview/binding/Pdbids.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,98 +30,110 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Pdbids extends Pdbentry -implements java.io.Serializable +public class Pdbids extends Pdbentry implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ - - public Pdbids() { - super(); - } + public Pdbids() + { + super(); + } + // -----------/ + // - Methods -/ + // -----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Pdbentry - */ - public static jalview.binding.Pdbentry unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Pdbentry) Unmarshaller.unmarshal(jalview.binding.Pdbids.class, reader); - } + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Pdbentry + */ + public static jalview.binding.Pdbentry unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Pdbentry) Unmarshaller.unmarshal( + jalview.binding.Pdbids.class, reader); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Property.java b/src/jalview/binding/Property.java index f1114f7..4ab620a 100755 --- a/src/jalview/binding/Property.java +++ b/src/jalview/binding/Property.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,151 +30,166 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Property implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _name. - */ - private java.lang.String _name; - - /** - * Field _value. - */ - private java.lang.String _value; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Property() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Returns the value of field 'value'. - * - * @return the value of field 'Value'. - */ - public java.lang.String getValue( - ) { - return this._value; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * Sets the value of field 'value'. - * - * @param value the value of field 'value'. - */ - public void setValue( - final java.lang.String value) { - this._value = value; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Property - */ - public static jalview.binding.Property unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Property) Unmarshaller.unmarshal(jalview.binding.Property.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class Property implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _name. + */ + private java.lang.String _name; + + /** + * Field _value. + */ + private java.lang.String _value; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Property() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() + { + return this._name; + } + + /** + * Returns the value of field 'value'. + * + * @return the value of field 'Value'. + */ + public java.lang.String getValue() + { + return this._value; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) + { + this._name = name; + } + + /** + * Sets the value of field 'value'. + * + * @param value + * the value of field 'value'. + */ + public void setValue(final java.lang.String value) + { + this._value = value; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Property + */ + public static jalview.binding.Property unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Property) Unmarshaller.unmarshal( + jalview.binding.Property.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Sequence.java b/src/jalview/binding/Sequence.java index 9c8cbc2..bd895f6 100755 --- a/src/jalview/binding/Sequence.java +++ b/src/jalview/binding/Sequence.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,98 +30,110 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Sequence extends SequenceType -implements java.io.Serializable +public class Sequence extends SequenceType implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ - - public Sequence() { - super(); - } + public Sequence() + { + super(); + } + // -----------/ + // - Methods -/ + // -----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.SequenceType - */ - public static jalview.binding.SequenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.SequenceType) Unmarshaller.unmarshal(jalview.binding.Sequence.class, reader); - } + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.SequenceType + */ + public static jalview.binding.SequenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.SequenceType) Unmarshaller.unmarshal( + jalview.binding.Sequence.class, reader); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/SequenceSet.java b/src/jalview/binding/SequenceSet.java index 13a9020..e348f9a 100755 --- a/src/jalview/binding/SequenceSet.java +++ b/src/jalview/binding/SequenceSet.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,496 +30,524 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class SequenceSet implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _gapChar. - */ - private java.lang.String _gapChar; - - /** - * Field _aligned. - */ - private boolean _aligned; - - /** - * keeps track of state for field: _aligned - */ - private boolean _has_aligned; - - /** - * Field _sequenceList. - */ - private java.util.Vector _sequenceList; - - /** - * Field _annotationList. - */ - private java.util.Vector _annotationList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceSet() { - super(); - this._sequenceList = new java.util.Vector(); - this._annotationList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAnnotation( - final jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException { - this._annotationList.addElement(vAnnotation); - } - - /** - * - * - * @param index - * @param vAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAnnotation( - final int index, - final jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException { - this._annotationList.add(index, vAnnotation); - } - - /** - * - * - * @param vSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequence( - final jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException { - this._sequenceList.addElement(vSequence); - } - - /** - * - * - * @param index - * @param vSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequence( - final int index, - final jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException { - this._sequenceList.add(index, vSequence); - } - - /** - */ - public void deleteAligned( - ) { - this._has_aligned= false; - } - - /** - * Method enumerateAnnotation. - * - * @return an Enumeration over all jalview.binding.Annotation - * elements - */ - public java.util.Enumeration enumerateAnnotation( - ) { - return this._annotationList.elements(); - } - - /** - * Method enumerateSequence. - * - * @return an Enumeration over all jalview.binding.Sequence - * elements - */ - public java.util.Enumeration enumerateSequence( - ) { - return this._sequenceList.elements(); - } - - /** - * Returns the value of field 'aligned'. - * - * @return the value of field 'Aligned'. - */ - public boolean getAligned( - ) { - return this._aligned; - } - - /** - * Method getAnnotation. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Annotation at the - * given index - */ - public jalview.binding.Annotation getAnnotation( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._annotationList.size()) { - throw new IndexOutOfBoundsException("getAnnotation: Index value '" + index + "' not in range [0.." + (this._annotationList.size() - 1) + "]"); - } - - return (jalview.binding.Annotation) _annotationList.get(index); - } - - /** - * Method getAnnotation.Returns the contents of the collection - * in an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Annotation[] getAnnotation( - ) { - jalview.binding.Annotation[] array = new jalview.binding.Annotation[0]; - return (jalview.binding.Annotation[]) this._annotationList.toArray(array); - } - - /** - * Method getAnnotationCount. - * - * @return the size of this collection - */ - public int getAnnotationCount( - ) { - return this._annotationList.size(); - } - - /** - * Returns the value of field 'gapChar'. - * - * @return the value of field 'GapChar'. - */ - public java.lang.String getGapChar( - ) { - return this._gapChar; - } - - /** - * Method getSequence. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the jalview.binding.Sequence at the - * given index - */ - public jalview.binding.Sequence getSequence( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceList.size()) { - throw new IndexOutOfBoundsException("getSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]"); - } - - return (jalview.binding.Sequence) _sequenceList.get(index); - } - - /** - * Method getSequence.Returns the contents of the collection in - * an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public jalview.binding.Sequence[] getSequence( - ) { - jalview.binding.Sequence[] array = new jalview.binding.Sequence[0]; - return (jalview.binding.Sequence[]) this._sequenceList.toArray(array); - } - - /** - * Method getSequenceCount. - * - * @return the size of this collection - */ - public int getSequenceCount( - ) { - return this._sequenceList.size(); - } - - /** - * Method hasAligned. - * - * @return true if at least one Aligned has been added - */ - public boolean hasAligned( - ) { - return this._has_aligned; - } - - /** - * Returns the value of field 'aligned'. - * - * @return the value of field 'Aligned'. - */ - public boolean isAligned( - ) { - return this._aligned; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - */ - public void removeAllAnnotation( - ) { - this._annotationList.clear(); - } - - /** - */ - public void removeAllSequence( - ) { - this._sequenceList.clear(); - } - - /** - * Method removeAnnotation. - * - * @param vAnnotation - * @return true if the object was removed from the collection. - */ - public boolean removeAnnotation( - final jalview.binding.Annotation vAnnotation) { - boolean removed = _annotationList.remove(vAnnotation); - return removed; - } - - /** - * Method removeAnnotationAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Annotation removeAnnotationAt( - final int index) { - java.lang.Object obj = this._annotationList.remove(index); - return (jalview.binding.Annotation) obj; - } - - /** - * Method removeSequence. - * - * @param vSequence - * @return true if the object was removed from the collection. - */ - public boolean removeSequence( - final jalview.binding.Sequence vSequence) { - boolean removed = _sequenceList.remove(vSequence); - return removed; - } - - /** - * Method removeSequenceAt. - * - * @param index - * @return the element removed from the collection - */ - public jalview.binding.Sequence removeSequenceAt( - final int index) { - java.lang.Object obj = this._sequenceList.remove(index); - return (jalview.binding.Sequence) obj; - } - - /** - * Sets the value of field 'aligned'. - * - * @param aligned the value of field 'aligned'. - */ - public void setAligned( - final boolean aligned) { - this._aligned = aligned; - this._has_aligned = true; - } - - /** - * - * - * @param index - * @param vAnnotation - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAnnotation( - final int index, - final jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._annotationList.size()) { - throw new IndexOutOfBoundsException("setAnnotation: Index value '" + index + "' not in range [0.." + (this._annotationList.size() - 1) + "]"); - } - - this._annotationList.set(index, vAnnotation); - } - - /** - * - * - * @param vAnnotationArray - */ - public void setAnnotation( - final jalview.binding.Annotation[] vAnnotationArray) { - //-- copy array - _annotationList.clear(); - - for (int i = 0; i < vAnnotationArray.length; i++) { - this._annotationList.add(vAnnotationArray[i]); - } - } - - /** - * Sets the value of field 'gapChar'. - * - * @param gapChar the value of field 'gapChar'. - */ - public void setGapChar( - final java.lang.String gapChar) { - this._gapChar = gapChar; - } - - /** - * - * - * @param index - * @param vSequence - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSequence( - final int index, - final jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceList.size()) { - throw new IndexOutOfBoundsException("setSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]"); - } - - this._sequenceList.set(index, vSequence); - } - - /** - * - * - * @param vSequenceArray - */ - public void setSequence( - final jalview.binding.Sequence[] vSequenceArray) { - //-- copy array - _sequenceList.clear(); - - for (int i = 0; i < vSequenceArray.length; i++) { - this._sequenceList.add(vSequenceArray[i]); - } - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.SequenceSet - */ - public static jalview.binding.SequenceSet unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class SequenceSet implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _gapChar. + */ + private java.lang.String _gapChar; + + /** + * Field _aligned. + */ + private boolean _aligned; + + /** + * keeps track of state for field: _aligned + */ + private boolean _has_aligned; + + /** + * Field _sequenceList. + */ + private java.util.Vector _sequenceList; + + /** + * Field _annotationList. + */ + private java.util.Vector _annotationList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SequenceSet() + { + super(); + this._sequenceList = new java.util.Vector(); + this._annotationList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAnnotation(final jalview.binding.Annotation vAnnotation) + throws java.lang.IndexOutOfBoundsException + { + this._annotationList.addElement(vAnnotation); + } + + /** + * + * + * @param index + * @param vAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAnnotation(final int index, + final jalview.binding.Annotation vAnnotation) + throws java.lang.IndexOutOfBoundsException + { + this._annotationList.add(index, vAnnotation); + } + + /** + * + * + * @param vSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequence(final jalview.binding.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException + { + this._sequenceList.addElement(vSequence); + } + + /** + * + * + * @param index + * @param vSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequence(final int index, + final jalview.binding.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException + { + this._sequenceList.add(index, vSequence); + } + + /** + */ + public void deleteAligned() + { + this._has_aligned = false; + } + + /** + * Method enumerateAnnotation. + * + * @return an Enumeration over all jalview.binding.Annotation elements + */ + public java.util.Enumeration enumerateAnnotation() + { + return this._annotationList.elements(); + } + + /** + * Method enumerateSequence. + * + * @return an Enumeration over all jalview.binding.Sequence elements + */ + public java.util.Enumeration enumerateSequence() + { + return this._sequenceList.elements(); + } + + /** + * Returns the value of field 'aligned'. + * + * @return the value of field 'Aligned'. + */ + public boolean getAligned() + { + return this._aligned; + } + + /** + * Method getAnnotation. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Annotation at the given index + */ + public jalview.binding.Annotation getAnnotation(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._annotationList.size()) + { + throw new IndexOutOfBoundsException("getAnnotation: Index value '" + + index + "' not in range [0.." + + (this._annotationList.size() - 1) + "]"); + } + + return (jalview.binding.Annotation) _annotationList.get(index); + } + + /** + * Method getAnnotation.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Annotation[] getAnnotation() + { + jalview.binding.Annotation[] array = new jalview.binding.Annotation[0]; + return (jalview.binding.Annotation[]) this._annotationList + .toArray(array); + } + + /** + * Method getAnnotationCount. + * + * @return the size of this collection + */ + public int getAnnotationCount() + { + return this._annotationList.size(); + } + + /** + * Returns the value of field 'gapChar'. + * + * @return the value of field 'GapChar'. + */ + public java.lang.String getGapChar() + { + return this._gapChar; + } + + /** + * Method getSequence. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the jalview.binding.Sequence at the given index + */ + public jalview.binding.Sequence getSequence(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._sequenceList.size()) + { + throw new IndexOutOfBoundsException("getSequence: Index value '" + + index + "' not in range [0.." + + (this._sequenceList.size() - 1) + "]"); + } + + return (jalview.binding.Sequence) _sequenceList.get(index); + } + + /** + * Method getSequence.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public jalview.binding.Sequence[] getSequence() + { + jalview.binding.Sequence[] array = new jalview.binding.Sequence[0]; + return (jalview.binding.Sequence[]) this._sequenceList.toArray(array); + } + + /** + * Method getSequenceCount. + * + * @return the size of this collection + */ + public int getSequenceCount() + { + return this._sequenceList.size(); + } + + /** + * Method hasAligned. + * + * @return true if at least one Aligned has been added + */ + public boolean hasAligned() + { + return this._has_aligned; + } + + /** + * Returns the value of field 'aligned'. + * + * @return the value of field 'Aligned'. + */ + public boolean isAligned() + { + return this._aligned; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + */ + public void removeAllAnnotation() + { + this._annotationList.clear(); + } + + /** + */ + public void removeAllSequence() + { + this._sequenceList.clear(); + } + + /** + * Method removeAnnotation. + * + * @param vAnnotation + * @return true if the object was removed from the collection. + */ + public boolean removeAnnotation( + final jalview.binding.Annotation vAnnotation) + { + boolean removed = _annotationList.remove(vAnnotation); + return removed; + } + + /** + * Method removeAnnotationAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Annotation removeAnnotationAt(final int index) + { + java.lang.Object obj = this._annotationList.remove(index); + return (jalview.binding.Annotation) obj; + } + + /** + * Method removeSequence. + * + * @param vSequence + * @return true if the object was removed from the collection. + */ + public boolean removeSequence(final jalview.binding.Sequence vSequence) + { + boolean removed = _sequenceList.remove(vSequence); + return removed; + } + + /** + * Method removeSequenceAt. + * + * @param index + * @return the element removed from the collection + */ + public jalview.binding.Sequence removeSequenceAt(final int index) + { + java.lang.Object obj = this._sequenceList.remove(index); + return (jalview.binding.Sequence) obj; + } + + /** + * Sets the value of field 'aligned'. + * + * @param aligned + * the value of field 'aligned'. + */ + public void setAligned(final boolean aligned) + { + this._aligned = aligned; + this._has_aligned = true; + } + + /** + * + * + * @param index + * @param vAnnotation + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAnnotation(final int index, + final jalview.binding.Annotation vAnnotation) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._annotationList.size()) + { + throw new IndexOutOfBoundsException("setAnnotation: Index value '" + + index + "' not in range [0.." + + (this._annotationList.size() - 1) + "]"); + } + + this._annotationList.set(index, vAnnotation); + } + + /** + * + * + * @param vAnnotationArray + */ + public void setAnnotation( + final jalview.binding.Annotation[] vAnnotationArray) + { + // -- copy array + _annotationList.clear(); + + for (int i = 0; i < vAnnotationArray.length; i++) + { + this._annotationList.add(vAnnotationArray[i]); + } + } + + /** + * Sets the value of field 'gapChar'. + * + * @param gapChar + * the value of field 'gapChar'. + */ + public void setGapChar(final java.lang.String gapChar) + { + this._gapChar = gapChar; + } + + /** + * + * + * @param index + * @param vSequence + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSequence(final int index, + final jalview.binding.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._sequenceList.size()) + { + throw new IndexOutOfBoundsException("setSequence: Index value '" + + index + "' not in range [0.." + + (this._sequenceList.size() - 1) + "]"); + } + + this._sequenceList.set(index, vSequence); + } + + /** + * + * + * @param vSequenceArray + */ + public void setSequence(final jalview.binding.Sequence[] vSequenceArray) + { + // -- copy array + _sequenceList.clear(); + + for (int i = 0; i < vSequenceArray.length; i++) + { + this._sequenceList.add(vSequenceArray[i]); + } + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.SequenceSet + */ + public static jalview.binding.SequenceSet unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.SequenceSet) Unmarshaller.unmarshal( + jalview.binding.SequenceSet.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/SequenceType.java b/src/jalview/binding/SequenceType.java index 1bb2a62..a6bf64e 100755 --- a/src/jalview/binding/SequenceType.java +++ b/src/jalview/binding/SequenceType.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,176 +30,192 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class SequenceType implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id. - */ - private java.lang.String _id; - - /** - * Field _sequence. - */ - private java.lang.String _sequence; - - /** - * Field _name. - */ - private java.lang.String _name; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceType() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'name'. - * - * @return the value of field 'Name'. - */ - public java.lang.String getName( - ) { - return this._name; - } - - /** - * Returns the value of field 'sequence'. - * - * @return the value of field 'Sequence'. - */ - public java.lang.String getSequence( - ) { - return this._sequence; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName( - final java.lang.String name) { - this._name = name; - } - - /** - * Sets the value of field 'sequence'. - * - * @param sequence the value of field 'sequence'. - */ - public void setSequence( - final java.lang.String sequence) { - this._sequence = sequence; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.SequenceType - */ - public static jalview.binding.SequenceType unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.SequenceType) Unmarshaller.unmarshal(jalview.binding.SequenceType.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class SequenceType implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _id. + */ + private java.lang.String _id; + + /** + * Field _sequence. + */ + private java.lang.String _sequence; + + /** + * Field _name. + */ + private java.lang.String _name; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public SequenceType() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() + { + return this._id; + } + + /** + * Returns the value of field 'name'. + * + * @return the value of field 'Name'. + */ + public java.lang.String getName() + { + return this._name; + } + + /** + * Returns the value of field 'sequence'. + * + * @return the value of field 'Sequence'. + */ + public java.lang.String getSequence() + { + return this._sequence; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'id'. + * + * @param id + * the value of field 'id'. + */ + public void setId(final java.lang.String id) + { + this._id = id; + } + + /** + * Sets the value of field 'name'. + * + * @param name + * the value of field 'name'. + */ + public void setName(final java.lang.String name) + { + this._name = name; + } + + /** + * Sets the value of field 'sequence'. + * + * @param sequence + * the value of field 'sequence'. + */ + public void setSequence(final java.lang.String sequence) + { + this._sequence = sequence; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.SequenceType + */ + public static jalview.binding.SequenceType unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.SequenceType) Unmarshaller.unmarshal( + jalview.binding.SequenceType.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Setting.java b/src/jalview/binding/Setting.java index 9cd84b4..3f05e27 100755 --- a/src/jalview/binding/Setting.java +++ b/src/jalview/binding/Setting.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,232 +30,248 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Setting implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _type. - */ - private java.lang.String _type; - - /** - * Field _colour. - */ - private int _colour; - - /** - * keeps track of state for field: _colour - */ - private boolean _has_colour; - - /** - * Field _display. - */ - private boolean _display; - - /** - * keeps track of state for field: _display - */ - private boolean _has_display; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Setting() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deleteColour( - ) { - this._has_colour= false; - } - - /** - */ - public void deleteDisplay( - ) { - this._has_display= false; - } - - /** - * Returns the value of field 'colour'. - * - * @return the value of field 'Colour'. - */ - public int getColour( - ) { - return this._colour; - } - - /** - * Returns the value of field 'display'. - * - * @return the value of field 'Display'. - */ - public boolean getDisplay( - ) { - return this._display; - } - - /** - * Returns the value of field 'type'. - * - * @return the value of field 'Type'. - */ - public java.lang.String getType( - ) { - return this._type; - } - - /** - * Method hasColour. - * - * @return true if at least one Colour has been added - */ - public boolean hasColour( - ) { - return this._has_colour; - } - - /** - * Method hasDisplay. - * - * @return true if at least one Display has been added - */ - public boolean hasDisplay( - ) { - return this._has_display; - } - - /** - * Returns the value of field 'display'. - * - * @return the value of field 'Display'. - */ - public boolean isDisplay( - ) { - return this._display; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'colour'. - * - * @param colour the value of field 'colour'. - */ - public void setColour( - final int colour) { - this._colour = colour; - this._has_colour = true; - } - - /** - * Sets the value of field 'display'. - * - * @param display the value of field 'display'. - */ - public void setDisplay( - final boolean display) { - this._display = display; - this._has_display = true; - } - - /** - * Sets the value of field 'type'. - * - * @param type the value of field 'type'. - */ - public void setType( - final java.lang.String type) { - this._type = type; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Setting - */ - public static jalview.binding.Setting unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Setting) Unmarshaller.unmarshal(jalview.binding.Setting.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class Setting implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _type. + */ + private java.lang.String _type; + + /** + * Field _colour. + */ + private int _colour; + + /** + * keeps track of state for field: _colour + */ + private boolean _has_colour; + + /** + * Field _display. + */ + private boolean _display; + + /** + * keeps track of state for field: _display + */ + private boolean _has_display; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Setting() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + */ + public void deleteColour() + { + this._has_colour = false; + } + + /** + */ + public void deleteDisplay() + { + this._has_display = false; + } + + /** + * Returns the value of field 'colour'. + * + * @return the value of field 'Colour'. + */ + public int getColour() + { + return this._colour; + } + + /** + * Returns the value of field 'display'. + * + * @return the value of field 'Display'. + */ + public boolean getDisplay() + { + return this._display; + } + + /** + * Returns the value of field 'type'. + * + * @return the value of field 'Type'. + */ + public java.lang.String getType() + { + return this._type; + } + + /** + * Method hasColour. + * + * @return true if at least one Colour has been added + */ + public boolean hasColour() + { + return this._has_colour; + } + + /** + * Method hasDisplay. + * + * @return true if at least one Display has been added + */ + public boolean hasDisplay() + { + return this._has_display; + } + + /** + * Returns the value of field 'display'. + * + * @return the value of field 'Display'. + */ + public boolean isDisplay() + { + return this._display; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'colour'. + * + * @param colour + * the value of field 'colour'. + */ + public void setColour(final int colour) + { + this._colour = colour; + this._has_colour = true; + } + + /** + * Sets the value of field 'display'. + * + * @param display + * the value of field 'display'. + */ + public void setDisplay(final boolean display) + { + this._display = display; + this._has_display = true; + } + + /** + * Sets the value of field 'type'. + * + * @param type + * the value of field 'type'. + */ + public void setType(final java.lang.String type) + { + this._type = type; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Setting + */ + public static jalview.binding.Setting unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Setting) Unmarshaller.unmarshal( + jalview.binding.Setting.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Tree.java b/src/jalview/binding/Tree.java index 5f138d0..f7679f1 100755 --- a/src/jalview/binding/Tree.java +++ b/src/jalview/binding/Tree.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,802 +30,829 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Tree implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _width. - */ - private int _width; - - /** - * keeps track of state for field: _width - */ - private boolean _has_width; - - /** - * Field _height. - */ - private int _height; - - /** - * keeps track of state for field: _height - */ - private boolean _has_height; - - /** - * Field _xpos. - */ - private int _xpos; - - /** - * keeps track of state for field: _xpos - */ - private boolean _has_xpos; - - /** - * Field _ypos. - */ - private int _ypos; - - /** - * keeps track of state for field: _ypos - */ - private boolean _has_ypos; - - /** - * Field _fontName. - */ - private java.lang.String _fontName; - - /** - * Field _fontSize. - */ - private int _fontSize; - - /** - * keeps track of state for field: _fontSize - */ - private boolean _has_fontSize; - - /** - * Field _fontStyle. - */ - private int _fontStyle; - - /** - * keeps track of state for field: _fontStyle - */ - private boolean _has_fontStyle; - - /** - * Field _threshold. - */ - private float _threshold; - - /** - * keeps track of state for field: _threshold - */ - private boolean _has_threshold; - - /** - * Field _showBootstrap. - */ - private boolean _showBootstrap; - - /** - * keeps track of state for field: _showBootstrap - */ - private boolean _has_showBootstrap; - - /** - * Field _showDistances. - */ - private boolean _showDistances; - - /** - * keeps track of state for field: _showDistances - */ - private boolean _has_showDistances; - - /** - * Field _markUnlinked. - */ - private boolean _markUnlinked; - - /** - * keeps track of state for field: _markUnlinked - */ - private boolean _has_markUnlinked; - - /** - * Field _fitToWindow. - */ - private boolean _fitToWindow; - - /** - * keeps track of state for field: _fitToWindow - */ - private boolean _has_fitToWindow; - - /** - * Field _currentTree. - */ - private boolean _currentTree; - - /** - * keeps track of state for field: _currentTree - */ - private boolean _has_currentTree; - - /** - * Field _title. - */ - private java.lang.String _title; - - /** - * Field _newick. - */ - private java.lang.String _newick; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Tree() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deleteCurrentTree( - ) { - this._has_currentTree= false; - } - - /** - */ - public void deleteFitToWindow( - ) { - this._has_fitToWindow= false; - } - - /** - */ - public void deleteFontSize( - ) { - this._has_fontSize= false; - } - - /** - */ - public void deleteFontStyle( - ) { - this._has_fontStyle= false; - } - - /** - */ - public void deleteHeight( - ) { - this._has_height= false; - } - - /** - */ - public void deleteMarkUnlinked( - ) { - this._has_markUnlinked= false; - } - - /** - */ - public void deleteShowBootstrap( - ) { - this._has_showBootstrap= false; - } - - /** - */ - public void deleteShowDistances( - ) { - this._has_showDistances= false; - } - - /** - */ - public void deleteThreshold( - ) { - this._has_threshold= false; - } - - /** - */ - public void deleteWidth( - ) { - this._has_width= false; - } - - /** - */ - public void deleteXpos( - ) { - this._has_xpos= false; - } - - /** - */ - public void deleteYpos( - ) { - this._has_ypos= false; - } - - /** - * Returns the value of field 'currentTree'. - * - * @return the value of field 'CurrentTree'. - */ - public boolean getCurrentTree( - ) { - return this._currentTree; - } - - /** - * Returns the value of field 'fitToWindow'. - * - * @return the value of field 'FitToWindow'. - */ - public boolean getFitToWindow( - ) { - return this._fitToWindow; - } - - /** - * Returns the value of field 'fontName'. - * - * @return the value of field 'FontName'. - */ - public java.lang.String getFontName( - ) { - return this._fontName; - } - - /** - * Returns the value of field 'fontSize'. - * - * @return the value of field 'FontSize'. - */ - public int getFontSize( - ) { - return this._fontSize; - } - - /** - * Returns the value of field 'fontStyle'. - * - * @return the value of field 'FontStyle'. - */ - public int getFontStyle( - ) { - return this._fontStyle; - } - - /** - * Returns the value of field 'height'. - * - * @return the value of field 'Height'. - */ - public int getHeight( - ) { - return this._height; - } - - /** - * Returns the value of field 'markUnlinked'. - * - * @return the value of field 'MarkUnlinked'. - */ - public boolean getMarkUnlinked( - ) { - return this._markUnlinked; - } - - /** - * Returns the value of field 'newick'. - * - * @return the value of field 'Newick'. - */ - public java.lang.String getNewick( - ) { - return this._newick; - } - - /** - * Returns the value of field 'showBootstrap'. - * - * @return the value of field 'ShowBootstrap'. - */ - public boolean getShowBootstrap( - ) { - return this._showBootstrap; - } - - /** - * Returns the value of field 'showDistances'. - * - * @return the value of field 'ShowDistances'. - */ - public boolean getShowDistances( - ) { - return this._showDistances; - } - - /** - * Returns the value of field 'threshold'. - * - * @return the value of field 'Threshold'. - */ - public float getThreshold( - ) { - return this._threshold; - } - - /** - * Returns the value of field 'title'. - * - * @return the value of field 'Title'. - */ - public java.lang.String getTitle( - ) { - return this._title; - } - - /** - * Returns the value of field 'width'. - * - * @return the value of field 'Width'. - */ - public int getWidth( - ) { - return this._width; - } - - /** - * Returns the value of field 'xpos'. - * - * @return the value of field 'Xpos'. - */ - public int getXpos( - ) { - return this._xpos; - } - - /** - * Returns the value of field 'ypos'. - * - * @return the value of field 'Ypos'. - */ - public int getYpos( - ) { - return this._ypos; - } - - /** - * Method hasCurrentTree. - * - * @return true if at least one CurrentTree has been added - */ - public boolean hasCurrentTree( - ) { - return this._has_currentTree; - } - - /** - * Method hasFitToWindow. - * - * @return true if at least one FitToWindow has been added - */ - public boolean hasFitToWindow( - ) { - return this._has_fitToWindow; - } - - /** - * Method hasFontSize. - * - * @return true if at least one FontSize has been added - */ - public boolean hasFontSize( - ) { - return this._has_fontSize; - } - - /** - * Method hasFontStyle. - * - * @return true if at least one FontStyle has been added - */ - public boolean hasFontStyle( - ) { - return this._has_fontStyle; - } - - /** - * Method hasHeight. - * - * @return true if at least one Height has been added - */ - public boolean hasHeight( - ) { - return this._has_height; - } - - /** - * Method hasMarkUnlinked. - * - * @return true if at least one MarkUnlinked has been added - */ - public boolean hasMarkUnlinked( - ) { - return this._has_markUnlinked; - } - - /** - * Method hasShowBootstrap. - * - * @return true if at least one ShowBootstrap has been added - */ - public boolean hasShowBootstrap( - ) { - return this._has_showBootstrap; - } - - /** - * Method hasShowDistances. - * - * @return true if at least one ShowDistances has been added - */ - public boolean hasShowDistances( - ) { - return this._has_showDistances; - } - - /** - * Method hasThreshold. - * - * @return true if at least one Threshold has been added - */ - public boolean hasThreshold( - ) { - return this._has_threshold; - } - - /** - * Method hasWidth. - * - * @return true if at least one Width has been added - */ - public boolean hasWidth( - ) { - return this._has_width; - } - - /** - * Method hasXpos. - * - * @return true if at least one Xpos has been added - */ - public boolean hasXpos( - ) { - return this._has_xpos; - } - - /** - * Method hasYpos. - * - * @return true if at least one Ypos has been added - */ - public boolean hasYpos( - ) { - return this._has_ypos; - } - - /** - * Returns the value of field 'currentTree'. - * - * @return the value of field 'CurrentTree'. - */ - public boolean isCurrentTree( - ) { - return this._currentTree; - } - - /** - * Returns the value of field 'fitToWindow'. - * - * @return the value of field 'FitToWindow'. - */ - public boolean isFitToWindow( - ) { - return this._fitToWindow; - } - - /** - * Returns the value of field 'markUnlinked'. - * - * @return the value of field 'MarkUnlinked'. - */ - public boolean isMarkUnlinked( - ) { - return this._markUnlinked; - } - - /** - * Returns the value of field 'showBootstrap'. - * - * @return the value of field 'ShowBootstrap'. - */ - public boolean isShowBootstrap( - ) { - return this._showBootstrap; - } - - /** - * Returns the value of field 'showDistances'. - * - * @return the value of field 'ShowDistances'. - */ - public boolean isShowDistances( - ) { - return this._showDistances; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'currentTree'. - * - * @param currentTree the value of field 'currentTree'. - */ - public void setCurrentTree( - final boolean currentTree) { - this._currentTree = currentTree; - this._has_currentTree = true; - } - - /** - * Sets the value of field 'fitToWindow'. - * - * @param fitToWindow the value of field 'fitToWindow'. - */ - public void setFitToWindow( - final boolean fitToWindow) { - this._fitToWindow = fitToWindow; - this._has_fitToWindow = true; - } - - /** - * Sets the value of field 'fontName'. - * - * @param fontName the value of field 'fontName'. - */ - public void setFontName( - final java.lang.String fontName) { - this._fontName = fontName; - } - - /** - * Sets the value of field 'fontSize'. - * - * @param fontSize the value of field 'fontSize'. - */ - public void setFontSize( - final int fontSize) { - this._fontSize = fontSize; - this._has_fontSize = true; - } - - /** - * Sets the value of field 'fontStyle'. - * - * @param fontStyle the value of field 'fontStyle'. - */ - public void setFontStyle( - final int fontStyle) { - this._fontStyle = fontStyle; - this._has_fontStyle = true; - } - - /** - * Sets the value of field 'height'. - * - * @param height the value of field 'height'. - */ - public void setHeight( - final int height) { - this._height = height; - this._has_height = true; - } - - /** - * Sets the value of field 'markUnlinked'. - * - * @param markUnlinked the value of field 'markUnlinked'. - */ - public void setMarkUnlinked( - final boolean markUnlinked) { - this._markUnlinked = markUnlinked; - this._has_markUnlinked = true; - } - - /** - * Sets the value of field 'newick'. - * - * @param newick the value of field 'newick'. - */ - public void setNewick( - final java.lang.String newick) { - this._newick = newick; - } - - /** - * Sets the value of field 'showBootstrap'. - * - * @param showBootstrap the value of field 'showBootstrap'. - */ - public void setShowBootstrap( - final boolean showBootstrap) { - this._showBootstrap = showBootstrap; - this._has_showBootstrap = true; - } - - /** - * Sets the value of field 'showDistances'. - * - * @param showDistances the value of field 'showDistances'. - */ - public void setShowDistances( - final boolean showDistances) { - this._showDistances = showDistances; - this._has_showDistances = true; - } - - /** - * Sets the value of field 'threshold'. - * - * @param threshold the value of field 'threshold'. - */ - public void setThreshold( - final float threshold) { - this._threshold = threshold; - this._has_threshold = true; - } - - /** - * Sets the value of field 'title'. - * - * @param title the value of field 'title'. - */ - public void setTitle( - final java.lang.String title) { - this._title = title; - } - - /** - * Sets the value of field 'width'. - * - * @param width the value of field 'width'. - */ - public void setWidth( - final int width) { - this._width = width; - this._has_width = true; - } - - /** - * Sets the value of field 'xpos'. - * - * @param xpos the value of field 'xpos'. - */ - public void setXpos( - final int xpos) { - this._xpos = xpos; - this._has_xpos = true; - } - - /** - * Sets the value of field 'ypos'. - * - * @param ypos the value of field 'ypos'. - */ - public void setYpos( - final int ypos) { - this._ypos = ypos; - this._has_ypos = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Tree - */ - public static jalview.binding.Tree unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Tree) Unmarshaller.unmarshal(jalview.binding.Tree.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class Tree implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _width. + */ + private int _width; + + /** + * keeps track of state for field: _width + */ + private boolean _has_width; + + /** + * Field _height. + */ + private int _height; + + /** + * keeps track of state for field: _height + */ + private boolean _has_height; + + /** + * Field _xpos. + */ + private int _xpos; + + /** + * keeps track of state for field: _xpos + */ + private boolean _has_xpos; + + /** + * Field _ypos. + */ + private int _ypos; + + /** + * keeps track of state for field: _ypos + */ + private boolean _has_ypos; + + /** + * Field _fontName. + */ + private java.lang.String _fontName; + + /** + * Field _fontSize. + */ + private int _fontSize; + + /** + * keeps track of state for field: _fontSize + */ + private boolean _has_fontSize; + + /** + * Field _fontStyle. + */ + private int _fontStyle; + + /** + * keeps track of state for field: _fontStyle + */ + private boolean _has_fontStyle; + + /** + * Field _threshold. + */ + private float _threshold; + + /** + * keeps track of state for field: _threshold + */ + private boolean _has_threshold; + + /** + * Field _showBootstrap. + */ + private boolean _showBootstrap; + + /** + * keeps track of state for field: _showBootstrap + */ + private boolean _has_showBootstrap; + + /** + * Field _showDistances. + */ + private boolean _showDistances; + + /** + * keeps track of state for field: _showDistances + */ + private boolean _has_showDistances; + + /** + * Field _markUnlinked. + */ + private boolean _markUnlinked; + + /** + * keeps track of state for field: _markUnlinked + */ + private boolean _has_markUnlinked; + + /** + * Field _fitToWindow. + */ + private boolean _fitToWindow; + + /** + * keeps track of state for field: _fitToWindow + */ + private boolean _has_fitToWindow; + + /** + * Field _currentTree. + */ + private boolean _currentTree; + + /** + * keeps track of state for field: _currentTree + */ + private boolean _has_currentTree; + + /** + * Field _title. + */ + private java.lang.String _title; + + /** + * Field _newick. + */ + private java.lang.String _newick; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Tree() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + */ + public void deleteCurrentTree() + { + this._has_currentTree = false; + } + + /** + */ + public void deleteFitToWindow() + { + this._has_fitToWindow = false; + } + + /** + */ + public void deleteFontSize() + { + this._has_fontSize = false; + } + + /** + */ + public void deleteFontStyle() + { + this._has_fontStyle = false; + } + + /** + */ + public void deleteHeight() + { + this._has_height = false; + } + + /** + */ + public void deleteMarkUnlinked() + { + this._has_markUnlinked = false; + } + + /** + */ + public void deleteShowBootstrap() + { + this._has_showBootstrap = false; + } + + /** + */ + public void deleteShowDistances() + { + this._has_showDistances = false; + } + + /** + */ + public void deleteThreshold() + { + this._has_threshold = false; + } + + /** + */ + public void deleteWidth() + { + this._has_width = false; + } + + /** + */ + public void deleteXpos() + { + this._has_xpos = false; + } + + /** + */ + public void deleteYpos() + { + this._has_ypos = false; + } + + /** + * Returns the value of field 'currentTree'. + * + * @return the value of field 'CurrentTree'. + */ + public boolean getCurrentTree() + { + return this._currentTree; + } + + /** + * Returns the value of field 'fitToWindow'. + * + * @return the value of field 'FitToWindow'. + */ + public boolean getFitToWindow() + { + return this._fitToWindow; + } + + /** + * Returns the value of field 'fontName'. + * + * @return the value of field 'FontName'. + */ + public java.lang.String getFontName() + { + return this._fontName; + } + + /** + * Returns the value of field 'fontSize'. + * + * @return the value of field 'FontSize'. + */ + public int getFontSize() + { + return this._fontSize; + } + + /** + * Returns the value of field 'fontStyle'. + * + * @return the value of field 'FontStyle'. + */ + public int getFontStyle() + { + return this._fontStyle; + } + + /** + * Returns the value of field 'height'. + * + * @return the value of field 'Height'. + */ + public int getHeight() + { + return this._height; + } + + /** + * Returns the value of field 'markUnlinked'. + * + * @return the value of field 'MarkUnlinked'. + */ + public boolean getMarkUnlinked() + { + return this._markUnlinked; + } + + /** + * Returns the value of field 'newick'. + * + * @return the value of field 'Newick'. + */ + public java.lang.String getNewick() + { + return this._newick; + } + + /** + * Returns the value of field 'showBootstrap'. + * + * @return the value of field 'ShowBootstrap'. + */ + public boolean getShowBootstrap() + { + return this._showBootstrap; + } + + /** + * Returns the value of field 'showDistances'. + * + * @return the value of field 'ShowDistances'. + */ + public boolean getShowDistances() + { + return this._showDistances; + } + + /** + * Returns the value of field 'threshold'. + * + * @return the value of field 'Threshold'. + */ + public float getThreshold() + { + return this._threshold; + } + + /** + * Returns the value of field 'title'. + * + * @return the value of field 'Title'. + */ + public java.lang.String getTitle() + { + return this._title; + } + + /** + * Returns the value of field 'width'. + * + * @return the value of field 'Width'. + */ + public int getWidth() + { + return this._width; + } + + /** + * Returns the value of field 'xpos'. + * + * @return the value of field 'Xpos'. + */ + public int getXpos() + { + return this._xpos; + } + + /** + * Returns the value of field 'ypos'. + * + * @return the value of field 'Ypos'. + */ + public int getYpos() + { + return this._ypos; + } + + /** + * Method hasCurrentTree. + * + * @return true if at least one CurrentTree has been added + */ + public boolean hasCurrentTree() + { + return this._has_currentTree; + } + + /** + * Method hasFitToWindow. + * + * @return true if at least one FitToWindow has been added + */ + public boolean hasFitToWindow() + { + return this._has_fitToWindow; + } + + /** + * Method hasFontSize. + * + * @return true if at least one FontSize has been added + */ + public boolean hasFontSize() + { + return this._has_fontSize; + } + + /** + * Method hasFontStyle. + * + * @return true if at least one FontStyle has been added + */ + public boolean hasFontStyle() + { + return this._has_fontStyle; + } + + /** + * Method hasHeight. + * + * @return true if at least one Height has been added + */ + public boolean hasHeight() + { + return this._has_height; + } + + /** + * Method hasMarkUnlinked. + * + * @return true if at least one MarkUnlinked has been added + */ + public boolean hasMarkUnlinked() + { + return this._has_markUnlinked; + } + + /** + * Method hasShowBootstrap. + * + * @return true if at least one ShowBootstrap has been added + */ + public boolean hasShowBootstrap() + { + return this._has_showBootstrap; + } + + /** + * Method hasShowDistances. + * + * @return true if at least one ShowDistances has been added + */ + public boolean hasShowDistances() + { + return this._has_showDistances; + } + + /** + * Method hasThreshold. + * + * @return true if at least one Threshold has been added + */ + public boolean hasThreshold() + { + return this._has_threshold; + } + + /** + * Method hasWidth. + * + * @return true if at least one Width has been added + */ + public boolean hasWidth() + { + return this._has_width; + } + + /** + * Method hasXpos. + * + * @return true if at least one Xpos has been added + */ + public boolean hasXpos() + { + return this._has_xpos; + } + + /** + * Method hasYpos. + * + * @return true if at least one Ypos has been added + */ + public boolean hasYpos() + { + return this._has_ypos; + } + + /** + * Returns the value of field 'currentTree'. + * + * @return the value of field 'CurrentTree'. + */ + public boolean isCurrentTree() + { + return this._currentTree; + } + + /** + * Returns the value of field 'fitToWindow'. + * + * @return the value of field 'FitToWindow'. + */ + public boolean isFitToWindow() + { + return this._fitToWindow; + } + + /** + * Returns the value of field 'markUnlinked'. + * + * @return the value of field 'MarkUnlinked'. + */ + public boolean isMarkUnlinked() + { + return this._markUnlinked; + } + + /** + * Returns the value of field 'showBootstrap'. + * + * @return the value of field 'ShowBootstrap'. + */ + public boolean isShowBootstrap() + { + return this._showBootstrap; + } + + /** + * Returns the value of field 'showDistances'. + * + * @return the value of field 'ShowDistances'. + */ + public boolean isShowDistances() + { + return this._showDistances; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'currentTree'. + * + * @param currentTree + * the value of field 'currentTree'. + */ + public void setCurrentTree(final boolean currentTree) + { + this._currentTree = currentTree; + this._has_currentTree = true; + } + + /** + * Sets the value of field 'fitToWindow'. + * + * @param fitToWindow + * the value of field 'fitToWindow'. + */ + public void setFitToWindow(final boolean fitToWindow) + { + this._fitToWindow = fitToWindow; + this._has_fitToWindow = true; + } + + /** + * Sets the value of field 'fontName'. + * + * @param fontName + * the value of field 'fontName'. + */ + public void setFontName(final java.lang.String fontName) + { + this._fontName = fontName; + } + + /** + * Sets the value of field 'fontSize'. + * + * @param fontSize + * the value of field 'fontSize'. + */ + public void setFontSize(final int fontSize) + { + this._fontSize = fontSize; + this._has_fontSize = true; + } + + /** + * Sets the value of field 'fontStyle'. + * + * @param fontStyle + * the value of field 'fontStyle'. + */ + public void setFontStyle(final int fontStyle) + { + this._fontStyle = fontStyle; + this._has_fontStyle = true; + } + + /** + * Sets the value of field 'height'. + * + * @param height + * the value of field 'height'. + */ + public void setHeight(final int height) + { + this._height = height; + this._has_height = true; + } + + /** + * Sets the value of field 'markUnlinked'. + * + * @param markUnlinked + * the value of field 'markUnlinked'. + */ + public void setMarkUnlinked(final boolean markUnlinked) + { + this._markUnlinked = markUnlinked; + this._has_markUnlinked = true; + } + + /** + * Sets the value of field 'newick'. + * + * @param newick + * the value of field 'newick'. + */ + public void setNewick(final java.lang.String newick) + { + this._newick = newick; + } + + /** + * Sets the value of field 'showBootstrap'. + * + * @param showBootstrap + * the value of field 'showBootstrap'. + */ + public void setShowBootstrap(final boolean showBootstrap) + { + this._showBootstrap = showBootstrap; + this._has_showBootstrap = true; + } + + /** + * Sets the value of field 'showDistances'. + * + * @param showDistances + * the value of field 'showDistances'. + */ + public void setShowDistances(final boolean showDistances) + { + this._showDistances = showDistances; + this._has_showDistances = true; + } + + /** + * Sets the value of field 'threshold'. + * + * @param threshold + * the value of field 'threshold'. + */ + public void setThreshold(final float threshold) + { + this._threshold = threshold; + this._has_threshold = true; + } + + /** + * Sets the value of field 'title'. + * + * @param title + * the value of field 'title'. + */ + public void setTitle(final java.lang.String title) + { + this._title = title; + } + + /** + * Sets the value of field 'width'. + * + * @param width + * the value of field 'width'. + */ + public void setWidth(final int width) + { + this._width = width; + this._has_width = true; + } + + /** + * Sets the value of field 'xpos'. + * + * @param xpos + * the value of field 'xpos'. + */ + public void setXpos(final int xpos) + { + this._xpos = xpos; + this._has_xpos = true; + } + + /** + * Sets the value of field 'ypos'. + * + * @param ypos + * the value of field 'ypos'. + */ + public void setYpos(final int ypos) + { + this._ypos = ypos; + this._has_ypos = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Tree + */ + public static jalview.binding.Tree unmarshal(final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Tree) Unmarshaller.unmarshal( + jalview.binding.Tree.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/UserColourScheme.java b/src/jalview/binding/UserColourScheme.java index 24c97ff..2002137 100755 --- a/src/jalview/binding/UserColourScheme.java +++ b/src/jalview/binding/UserColourScheme.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,98 +30,111 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class UserColourScheme extends JalviewUserColours -implements java.io.Serializable +public class UserColourScheme extends JalviewUserColours implements + java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ - - public UserColourScheme() { - super(); - } + public UserColourScheme() + { + super(); + } + // -----------/ + // - Methods -/ + // -----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.JalviewUserColours - */ - public static jalview.binding.JalviewUserColours unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.UserColourScheme.class, reader); - } + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.JalviewUserColours + */ + public static jalview.binding.JalviewUserColours unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal( + jalview.binding.UserColourScheme.class, reader); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/UserColours.java b/src/jalview/binding/UserColours.java index bdefe05..467904a 100755 --- a/src/jalview/binding/UserColours.java +++ b/src/jalview/binding/UserColours.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,151 +30,167 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class UserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id. - */ - private java.lang.String _id; - - /** - * Field _userColourScheme. - */ - private jalview.binding.UserColourScheme _userColourScheme; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public UserColours() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'id'. - * - * @return the value of field 'Id'. - */ - public java.lang.String getId( - ) { - return this._id; - } - - /** - * Returns the value of field 'userColourScheme'. - * - * @return the value of field 'UserColourScheme'. - */ - public jalview.binding.UserColourScheme getUserColourScheme( - ) { - return this._userColourScheme; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId( - final java.lang.String id) { - this._id = id; - } - - /** - * Sets the value of field 'userColourScheme'. - * - * @param userColourScheme the value of field 'userColourScheme' - */ - public void setUserColourScheme( - final jalview.binding.UserColourScheme userColourScheme) { - this._userColourScheme = userColourScheme; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.UserColours - */ - public static jalview.binding.UserColours unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.UserColours) Unmarshaller.unmarshal(jalview.binding.UserColours.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); +public class UserColours implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _id. + */ + private java.lang.String _id; + + /** + * Field _userColourScheme. + */ + private jalview.binding.UserColourScheme _userColourScheme; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public UserColours() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * Returns the value of field 'id'. + * + * @return the value of field 'Id'. + */ + public java.lang.String getId() + { + return this._id; + } + + /** + * Returns the value of field 'userColourScheme'. + * + * @return the value of field 'UserColourScheme'. + */ + public jalview.binding.UserColourScheme getUserColourScheme() + { + return this._userColourScheme; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'id'. + * + * @param id + * the value of field 'id'. + */ + public void setId(final java.lang.String id) + { + this._id = id; + } + + /** + * Sets the value of field 'userColourScheme'. + * + * @param userColourScheme + * the value of field 'userColourScheme' + */ + public void setUserColourScheme( + final jalview.binding.UserColourScheme userColourScheme) + { + this._userColourScheme = userColourScheme; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.UserColours + */ + public static jalview.binding.UserColours unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.UserColours) Unmarshaller.unmarshal( + jalview.binding.UserColours.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/VAMSAS.java b/src/jalview/binding/VAMSAS.java index 1c92bd3..b886fb9 100755 --- a/src/jalview/binding/VAMSAS.java +++ b/src/jalview/binding/VAMSAS.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,563 +30,588 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class VAMSAS implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _alignmentList. - */ - private java.util.Vector _alignmentList; - - /** - * Field _treeList. - */ - private java.util.Vector _treeList; - - /** - * Field _sequenceSetList. - */ - private java.util.Vector _sequenceSetList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VAMSAS() { - super(); - this._alignmentList = new java.util.Vector(); - this._treeList = new java.util.Vector(); - this._sequenceSetList = new java.util.Vector(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * - * - * @param vAlignment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignment( - final Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException { - this._alignmentList.addElement(vAlignment); - } - - /** - * - * - * @param index - * @param vAlignment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addAlignment( - final int index, - final Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException { - this._alignmentList.add(index, vAlignment); - } - - /** - * - * - * @param vSequenceSet - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequenceSet( - final SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException { - this._sequenceSetList.addElement(vSequenceSet); - } - - /** - * - * - * @param index - * @param vSequenceSet - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addSequenceSet( - final int index, - final SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException { - this._sequenceSetList.add(index, vSequenceSet); - } - - /** - * - * - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.addElement(vTree); - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void addTree( - final int index, - final java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException { - this._treeList.add(index, vTree); - } - - /** - * Method enumerateAlignment. - * - * @return an Enumeration over all Alignment elements - */ - public java.util.Enumeration enumerateAlignment( - ) { - return this._alignmentList.elements(); - } - - /** - * Method enumerateSequenceSet. - * - * @return an Enumeration over all SequenceSet elements - */ - public java.util.Enumeration enumerateSequenceSet( - ) { - return this._sequenceSetList.elements(); - } - - /** - * Method enumerateTree. - * - * @return an Enumeration over all java.lang.String elements - */ - public java.util.Enumeration enumerateTree( - ) { - return this._treeList.elements(); - } - - /** - * Method getAlignment. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the Alignment at the given index - */ - public Alignment getAlignment( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentList.size()) { - throw new IndexOutOfBoundsException("getAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]"); - } - - return (Alignment) _alignmentList.get(index); - } - - /** - * Method getAlignment.Returns the contents of the collection - * in an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public Alignment[] getAlignment( - ) { - Alignment[] array = new Alignment[0]; - return (Alignment[]) this._alignmentList.toArray(array); - } - - /** - * Method getAlignmentCount. - * - * @return the size of this collection - */ - public int getAlignmentCount( - ) { - return this._alignmentList.size(); - } - - /** - * Method getSequenceSet. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the SequenceSet at the given index - */ - public SequenceSet getSequenceSet( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceSetList.size()) { - throw new IndexOutOfBoundsException("getSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]"); - } - - return (SequenceSet) _sequenceSetList.get(index); - } - - /** - * Method getSequenceSet.Returns the contents of the collection - * in an Array.

    Note: Just in case the collection contents - * are changing in another thread, we pass a 0-length Array of - * the correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public SequenceSet[] getSequenceSet( - ) { - SequenceSet[] array = new SequenceSet[0]; - return (SequenceSet[]) this._sequenceSetList.toArray(array); - } - - /** - * Method getSequenceSetCount. - * - * @return the size of this collection - */ - public int getSequenceSetCount( - ) { - return this._sequenceSetList.size(); - } - - /** - * Method getTree. - * - * @param index - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - * @return the value of the java.lang.String at the given index - */ - public java.lang.String getTree( - final int index) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - return (java.lang.String) _treeList.get(index); - } - - /** - * Method getTree.Returns the contents of the collection in an - * Array.

    Note: Just in case the collection contents are - * changing in another thread, we pass a 0-length Array of the - * correct type into the API call. This way we know - * that the Array returned is of exactly the correct length. - * - * @return this collection as an Array - */ - public java.lang.String[] getTree( - ) { - java.lang.String[] array = new java.lang.String[0]; - return (java.lang.String[]) this._treeList.toArray(array); - } - - /** - * Method getTreeCount. - * - * @return the size of this collection - */ - public int getTreeCount( - ) { - return this._treeList.size(); - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Method removeAlignment. - * - * @param vAlignment - * @return true if the object was removed from the collection. - */ - public boolean removeAlignment( - final Alignment vAlignment) { - boolean removed = _alignmentList.remove(vAlignment); - return removed; - } - - /** - * Method removeAlignmentAt. - * - * @param index - * @return the element removed from the collection - */ - public Alignment removeAlignmentAt( - final int index) { - java.lang.Object obj = this._alignmentList.remove(index); - return (Alignment) obj; - } - - /** - */ - public void removeAllAlignment( - ) { - this._alignmentList.clear(); - } - - /** - */ - public void removeAllSequenceSet( - ) { - this._sequenceSetList.clear(); - } - - /** - */ - public void removeAllTree( - ) { - this._treeList.clear(); - } - - /** - * Method removeSequenceSet. - * - * @param vSequenceSet - * @return true if the object was removed from the collection. - */ - public boolean removeSequenceSet( - final SequenceSet vSequenceSet) { - boolean removed = _sequenceSetList.remove(vSequenceSet); - return removed; - } - - /** - * Method removeSequenceSetAt. - * - * @param index - * @return the element removed from the collection - */ - public SequenceSet removeSequenceSetAt( - final int index) { - java.lang.Object obj = this._sequenceSetList.remove(index); - return (SequenceSet) obj; - } - - /** - * Method removeTree. - * - * @param vTree - * @return true if the object was removed from the collection. - */ - public boolean removeTree( - final java.lang.String vTree) { - boolean removed = _treeList.remove(vTree); - return removed; - } - - /** - * Method removeTreeAt. - * - * @param index - * @return the element removed from the collection - */ - public java.lang.String removeTreeAt( - final int index) { - java.lang.Object obj = this._treeList.remove(index); - return (java.lang.String) obj; - } - - /** - * - * - * @param index - * @param vAlignment - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setAlignment( - final int index, - final Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._alignmentList.size()) { - throw new IndexOutOfBoundsException("setAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]"); - } - - this._alignmentList.set(index, vAlignment); - } - - /** - * - * - * @param vAlignmentArray - */ - public void setAlignment( - final Alignment[] vAlignmentArray) { - //-- copy array - _alignmentList.clear(); - - for (int i = 0; i < vAlignmentArray.length; i++) { - this._alignmentList.add(vAlignmentArray[i]); - } - } - - /** - * - * - * @param index - * @param vSequenceSet - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setSequenceSet( - final int index, - final SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._sequenceSetList.size()) { - throw new IndexOutOfBoundsException("setSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]"); - } - - this._sequenceSetList.set(index, vSequenceSet); - } - - /** - * - * - * @param vSequenceSetArray - */ - public void setSequenceSet( - final SequenceSet[] vSequenceSetArray) { - //-- copy array - _sequenceSetList.clear(); - - for (int i = 0; i < vSequenceSetArray.length; i++) { - this._sequenceSetList.add(vSequenceSetArray[i]); - } - } - - /** - * - * - * @param index - * @param vTree - * @throws java.lang.IndexOutOfBoundsException if the index - * given is outside the bounds of the collection - */ - public void setTree( - final int index, - final java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException { - // check bounds for index - if (index < 0 || index >= this._treeList.size()) { - throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]"); - } - - this._treeList.set(index, vTree); - } - - /** - * - * - * @param vTreeArray - */ - public void setTree( - final java.lang.String[] vTreeArray) { - //-- copy array - _treeList.clear(); - - for (int i = 0; i < vTreeArray.length; i++) { - this._treeList.add(vTreeArray[i]); - } - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.VAMSAS - */ - public static jalview.binding.VAMSAS unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(jalview.binding.VAMSAS.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class VAMSAS implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _alignmentList. + */ + private java.util.Vector _alignmentList; + + /** + * Field _treeList. + */ + private java.util.Vector _treeList; + + /** + * Field _sequenceSetList. + */ + private java.util.Vector _sequenceSetList; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public VAMSAS() + { + super(); + this._alignmentList = new java.util.Vector(); + this._treeList = new java.util.Vector(); + this._sequenceSetList = new java.util.Vector(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + * + * + * @param vAlignment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignment(final Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + this._alignmentList.addElement(vAlignment); + } + + /** + * + * + * @param index + * @param vAlignment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addAlignment(final int index, final Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + this._alignmentList.add(index, vAlignment); + } + + /** + * + * + * @param vSequenceSet + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequenceSet(final SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException + { + this._sequenceSetList.addElement(vSequenceSet); + } + + /** + * + * + * @param index + * @param vSequenceSet + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addSequenceSet(final int index, final SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException + { + this._sequenceSetList.add(index, vSequenceSet); + } + + /** + * + * + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final java.lang.String vTree) + throws java.lang.IndexOutOfBoundsException + { + this._treeList.addElement(vTree); + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void addTree(final int index, final java.lang.String vTree) + throws java.lang.IndexOutOfBoundsException + { + this._treeList.add(index, vTree); + } + + /** + * Method enumerateAlignment. + * + * @return an Enumeration over all Alignment elements + */ + public java.util.Enumeration enumerateAlignment() + { + return this._alignmentList.elements(); + } + + /** + * Method enumerateSequenceSet. + * + * @return an Enumeration over all SequenceSet elements + */ + public java.util.Enumeration enumerateSequenceSet() + { + return this._sequenceSetList.elements(); + } + + /** + * Method enumerateTree. + * + * @return an Enumeration over all java.lang.String elements + */ + public java.util.Enumeration enumerateTree() + { + return this._treeList.elements(); + } + + /** + * Method getAlignment. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the Alignment at the given index + */ + public Alignment getAlignment(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._alignmentList.size()) + { + throw new IndexOutOfBoundsException("getAlignment: Index value '" + + index + "' not in range [0.." + + (this._alignmentList.size() - 1) + "]"); + } + + return (Alignment) _alignmentList.get(index); + } + + /** + * Method getAlignment.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public Alignment[] getAlignment() + { + Alignment[] array = new Alignment[0]; + return (Alignment[]) this._alignmentList.toArray(array); + } + + /** + * Method getAlignmentCount. + * + * @return the size of this collection + */ + public int getAlignmentCount() + { + return this._alignmentList.size(); + } + + /** + * Method getSequenceSet. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the SequenceSet at the given index + */ + public SequenceSet getSequenceSet(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._sequenceSetList.size()) + { + throw new IndexOutOfBoundsException("getSequenceSet: Index value '" + + index + "' not in range [0.." + + (this._sequenceSetList.size() - 1) + "]"); + } + + return (SequenceSet) _sequenceSetList.get(index); + } + + /** + * Method getSequenceSet.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public SequenceSet[] getSequenceSet() + { + SequenceSet[] array = new SequenceSet[0]; + return (SequenceSet[]) this._sequenceSetList.toArray(array); + } + + /** + * Method getSequenceSetCount. + * + * @return the size of this collection + */ + public int getSequenceSetCount() + { + return this._sequenceSetList.size(); + } + + /** + * Method getTree. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + * @return the value of the java.lang.String at the given index + */ + public java.lang.String getTree(final int index) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) + { + throw new IndexOutOfBoundsException("getTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + return (java.lang.String) _treeList.get(index); + } + + /** + * Method getTree.Returns the contents of the collection in an Array. + *

    + * Note: Just in case the collection contents are changing in another thread, + * we pass a 0-length Array of the correct type into the API call. This way we + * know that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public java.lang.String[] getTree() + { + java.lang.String[] array = new java.lang.String[0]; + return (java.lang.String[]) this._treeList.toArray(array); + } + + /** + * Method getTreeCount. + * + * @return the size of this collection + */ + public int getTreeCount() + { + return this._treeList.size(); + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Method removeAlignment. + * + * @param vAlignment + * @return true if the object was removed from the collection. + */ + public boolean removeAlignment(final Alignment vAlignment) + { + boolean removed = _alignmentList.remove(vAlignment); + return removed; + } + + /** + * Method removeAlignmentAt. + * + * @param index + * @return the element removed from the collection + */ + public Alignment removeAlignmentAt(final int index) + { + java.lang.Object obj = this._alignmentList.remove(index); + return (Alignment) obj; + } + + /** + */ + public void removeAllAlignment() + { + this._alignmentList.clear(); + } + + /** + */ + public void removeAllSequenceSet() + { + this._sequenceSetList.clear(); + } + + /** + */ + public void removeAllTree() + { + this._treeList.clear(); + } + + /** + * Method removeSequenceSet. + * + * @param vSequenceSet + * @return true if the object was removed from the collection. + */ + public boolean removeSequenceSet(final SequenceSet vSequenceSet) + { + boolean removed = _sequenceSetList.remove(vSequenceSet); + return removed; + } + + /** + * Method removeSequenceSetAt. + * + * @param index + * @return the element removed from the collection + */ + public SequenceSet removeSequenceSetAt(final int index) + { + java.lang.Object obj = this._sequenceSetList.remove(index); + return (SequenceSet) obj; + } + + /** + * Method removeTree. + * + * @param vTree + * @return true if the object was removed from the collection. + */ + public boolean removeTree(final java.lang.String vTree) + { + boolean removed = _treeList.remove(vTree); + return removed; + } + + /** + * Method removeTreeAt. + * + * @param index + * @return the element removed from the collection + */ + public java.lang.String removeTreeAt(final int index) + { + java.lang.Object obj = this._treeList.remove(index); + return (java.lang.String) obj; + } + + /** + * + * + * @param index + * @param vAlignment + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setAlignment(final int index, final Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._alignmentList.size()) + { + throw new IndexOutOfBoundsException("setAlignment: Index value '" + + index + "' not in range [0.." + + (this._alignmentList.size() - 1) + "]"); + } + + this._alignmentList.set(index, vAlignment); + } + + /** + * + * + * @param vAlignmentArray + */ + public void setAlignment(final Alignment[] vAlignmentArray) + { + // -- copy array + _alignmentList.clear(); + + for (int i = 0; i < vAlignmentArray.length; i++) + { + this._alignmentList.add(vAlignmentArray[i]); + } + } + + /** + * + * + * @param index + * @param vSequenceSet + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setSequenceSet(final int index, final SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._sequenceSetList.size()) + { + throw new IndexOutOfBoundsException("setSequenceSet: Index value '" + + index + "' not in range [0.." + + (this._sequenceSetList.size() - 1) + "]"); + } + + this._sequenceSetList.set(index, vSequenceSet); + } + + /** + * + * + * @param vSequenceSetArray + */ + public void setSequenceSet(final SequenceSet[] vSequenceSetArray) + { + // -- copy array + _sequenceSetList.clear(); + + for (int i = 0; i < vSequenceSetArray.length; i++) + { + this._sequenceSetList.add(vSequenceSetArray[i]); + } + } + + /** + * + * + * @param index + * @param vTree + * @throws java.lang.IndexOutOfBoundsException + * if the index given is outside the bounds of the collection + */ + public void setTree(final int index, final java.lang.String vTree) + throws java.lang.IndexOutOfBoundsException + { + // check bounds for index + if (index < 0 || index >= this._treeList.size()) + { + throw new IndexOutOfBoundsException("setTree: Index value '" + index + + "' not in range [0.." + (this._treeList.size() - 1) + "]"); + } + + this._treeList.set(index, vTree); + } + + /** + * + * + * @param vTreeArray + */ + public void setTree(final java.lang.String[] vTreeArray) + { + // -- copy array + _treeList.clear(); + + for (int i = 0; i < vTreeArray.length; i++) + { + this._treeList.add(vTreeArray[i]); + } + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.VAMSAS + */ + public static jalview.binding.VAMSAS unmarshal(final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.VAMSAS) Unmarshaller.unmarshal( + jalview.binding.VAMSAS.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/VamsasModel.java b/src/jalview/binding/VamsasModel.java index 5fda35e..f44a964 100755 --- a/src/jalview/binding/VamsasModel.java +++ b/src/jalview/binding/VamsasModel.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,98 +30,109 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class VamsasModel extends VAMSAS -implements java.io.Serializable +public class VamsasModel extends VAMSAS implements java.io.Serializable { + // ----------------/ + // - Constructors -/ + // ----------------/ - //----------------/ - //- Constructors -/ - //----------------/ - - public VamsasModel() { - super(); - } + public VamsasModel() + { + super(); + } + // -----------/ + // - Methods -/ + // -----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; } + return true; + } - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.VAMSAS - */ - public static jalview.binding.VAMSAS unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(jalview.binding.VamsasModel.class, reader); - } + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.VAMSAS + */ + public static jalview.binding.VAMSAS unmarshal(final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.VAMSAS) Unmarshaller.unmarshal( + jalview.binding.VamsasModel.class, reader); + } - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/binding/Viewport.java b/src/jalview/binding/Viewport.java index 643c323..95b8adf 100755 --- a/src/jalview/binding/Viewport.java +++ b/src/jalview/binding/Viewport.java @@ -1,15 +1,26 @@ /* - * This class was automatically generated with - * Castor 1.1, using an XML - * Schema. - * $Id$ + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +// ---------------------------------/ +// - Imported classes and packages -/ +// ---------------------------------/ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; @@ -19,1414 +30,1449 @@ import org.exolab.castor.xml.Unmarshaller; * * @version $Revision$ $Date$ */ -public class Viewport implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _conservationSelected. - */ - private boolean _conservationSelected; - - /** - * keeps track of state for field: _conservationSelected - */ - private boolean _has_conservationSelected; - - /** - * Field _pidSelected. - */ - private boolean _pidSelected; - - /** - * keeps track of state for field: _pidSelected - */ - private boolean _has_pidSelected; - - /** - * Field _bgColour. - */ - private java.lang.String _bgColour; - - /** - * Field _consThreshold. - */ - private int _consThreshold; - - /** - * keeps track of state for field: _consThreshold - */ - private boolean _has_consThreshold; - - /** - * Field _pidThreshold. - */ - private int _pidThreshold; - - /** - * keeps track of state for field: _pidThreshold - */ - private boolean _has_pidThreshold; - - /** - * Field _title. - */ - private java.lang.String _title; - - /** - * Field _showFullId. - */ - private boolean _showFullId; - - /** - * keeps track of state for field: _showFullId - */ - private boolean _has_showFullId; - - /** - * Field _showText. - */ - private boolean _showText; - - /** - * keeps track of state for field: _showText - */ - private boolean _has_showText; - - /** - * Field _showColourText. - */ - private boolean _showColourText; - - /** - * keeps track of state for field: _showColourText - */ - private boolean _has_showColourText; - - /** - * Field _showBoxes. - */ - private boolean _showBoxes; - - /** - * keeps track of state for field: _showBoxes - */ - private boolean _has_showBoxes; - - /** - * Field _wrapAlignment. - */ - private boolean _wrapAlignment; - - /** - * keeps track of state for field: _wrapAlignment - */ - private boolean _has_wrapAlignment; - - /** - * Field _renderGaps. - */ - private boolean _renderGaps; - - /** - * keeps track of state for field: _renderGaps - */ - private boolean _has_renderGaps; - - /** - * Field _showSequenceFeatures. - */ - private boolean _showSequenceFeatures; - - /** - * keeps track of state for field: _showSequenceFeatures - */ - private boolean _has_showSequenceFeatures; - - /** - * Field _showAnnotation. - */ - private boolean _showAnnotation; - - /** - * keeps track of state for field: _showAnnotation - */ - private boolean _has_showAnnotation; - - /** - * Field _showConservation. - */ - private boolean _showConservation; - - /** - * keeps track of state for field: _showConservation - */ - private boolean _has_showConservation; - - /** - * Field _showQuality. - */ - private boolean _showQuality; - - /** - * keeps track of state for field: _showQuality - */ - private boolean _has_showQuality; - - /** - * Field _showIdentity. - */ - private boolean _showIdentity; - - /** - * keeps track of state for field: _showIdentity - */ - private boolean _has_showIdentity; - - /** - * Field _xpos. - */ - private int _xpos; - - /** - * keeps track of state for field: _xpos - */ - private boolean _has_xpos; - - /** - * Field _ypos. - */ - private int _ypos; - - /** - * keeps track of state for field: _ypos - */ - private boolean _has_ypos; - - /** - * Field _width. - */ - private int _width; - - /** - * keeps track of state for field: _width - */ - private boolean _has_width; - - /** - * Field _height. - */ - private int _height; - - /** - * keeps track of state for field: _height - */ - private boolean _has_height; - - /** - * Field _startRes. - */ - private int _startRes; - - /** - * keeps track of state for field: _startRes - */ - private boolean _has_startRes; - - /** - * Field _startSeq. - */ - private int _startSeq; - - /** - * keeps track of state for field: _startSeq - */ - private boolean _has_startSeq; - - /** - * Field _fontName. - */ - private java.lang.String _fontName; - - /** - * Field _fontSize. - */ - private int _fontSize; - - /** - * keeps track of state for field: _fontSize - */ - private boolean _has_fontSize; - - /** - * Field _fontStyle. - */ - private int _fontStyle; - - /** - * keeps track of state for field: _fontStyle - */ - private boolean _has_fontStyle; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Viewport() { - super(); - } - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - */ - public void deleteConsThreshold( - ) { - this._has_consThreshold= false; - } - - /** - */ - public void deleteConservationSelected( - ) { - this._has_conservationSelected= false; - } - - /** - */ - public void deleteFontSize( - ) { - this._has_fontSize= false; - } - - /** - */ - public void deleteFontStyle( - ) { - this._has_fontStyle= false; - } - - /** - */ - public void deleteHeight( - ) { - this._has_height= false; - } - - /** - */ - public void deletePidSelected( - ) { - this._has_pidSelected= false; - } - - /** - */ - public void deletePidThreshold( - ) { - this._has_pidThreshold= false; - } - - /** - */ - public void deleteRenderGaps( - ) { - this._has_renderGaps= false; - } - - /** - */ - public void deleteShowAnnotation( - ) { - this._has_showAnnotation= false; - } - - /** - */ - public void deleteShowBoxes( - ) { - this._has_showBoxes= false; - } - - /** - */ - public void deleteShowColourText( - ) { - this._has_showColourText= false; - } - - /** - */ - public void deleteShowConservation( - ) { - this._has_showConservation= false; - } - - /** - */ - public void deleteShowFullId( - ) { - this._has_showFullId= false; - } - - /** - */ - public void deleteShowIdentity( - ) { - this._has_showIdentity= false; - } - - /** - */ - public void deleteShowQuality( - ) { - this._has_showQuality= false; - } - - /** - */ - public void deleteShowSequenceFeatures( - ) { - this._has_showSequenceFeatures= false; - } - - /** - */ - public void deleteShowText( - ) { - this._has_showText= false; - } - - /** - */ - public void deleteStartRes( - ) { - this._has_startRes= false; - } - - /** - */ - public void deleteStartSeq( - ) { - this._has_startSeq= false; - } - - /** - */ - public void deleteWidth( - ) { - this._has_width= false; - } - - /** - */ - public void deleteWrapAlignment( - ) { - this._has_wrapAlignment= false; - } - - /** - */ - public void deleteXpos( - ) { - this._has_xpos= false; - } - - /** - */ - public void deleteYpos( - ) { - this._has_ypos= false; - } - - /** - * Returns the value of field 'bgColour'. - * - * @return the value of field 'BgColour'. - */ - public java.lang.String getBgColour( - ) { - return this._bgColour; - } - - /** - * Returns the value of field 'consThreshold'. - * - * @return the value of field 'ConsThreshold'. - */ - public int getConsThreshold( - ) { - return this._consThreshold; - } - - /** - * Returns the value of field 'conservationSelected'. - * - * @return the value of field 'ConservationSelected'. - */ - public boolean getConservationSelected( - ) { - return this._conservationSelected; - } - - /** - * Returns the value of field 'fontName'. - * - * @return the value of field 'FontName'. - */ - public java.lang.String getFontName( - ) { - return this._fontName; - } - - /** - * Returns the value of field 'fontSize'. - * - * @return the value of field 'FontSize'. - */ - public int getFontSize( - ) { - return this._fontSize; - } - - /** - * Returns the value of field 'fontStyle'. - * - * @return the value of field 'FontStyle'. - */ - public int getFontStyle( - ) { - return this._fontStyle; - } - - /** - * Returns the value of field 'height'. - * - * @return the value of field 'Height'. - */ - public int getHeight( - ) { - return this._height; - } - - /** - * Returns the value of field 'pidSelected'. - * - * @return the value of field 'PidSelected'. - */ - public boolean getPidSelected( - ) { - return this._pidSelected; - } - - /** - * Returns the value of field 'pidThreshold'. - * - * @return the value of field 'PidThreshold'. - */ - public int getPidThreshold( - ) { - return this._pidThreshold; - } - - /** - * Returns the value of field 'renderGaps'. - * - * @return the value of field 'RenderGaps'. - */ - public boolean getRenderGaps( - ) { - return this._renderGaps; - } - - /** - * Returns the value of field 'showAnnotation'. - * - * @return the value of field 'ShowAnnotation'. - */ - public boolean getShowAnnotation( - ) { - return this._showAnnotation; - } - - /** - * Returns the value of field 'showBoxes'. - * - * @return the value of field 'ShowBoxes'. - */ - public boolean getShowBoxes( - ) { - return this._showBoxes; - } - - /** - * Returns the value of field 'showColourText'. - * - * @return the value of field 'ShowColourText'. - */ - public boolean getShowColourText( - ) { - return this._showColourText; - } - - /** - * Returns the value of field 'showConservation'. - * - * @return the value of field 'ShowConservation'. - */ - public boolean getShowConservation( - ) { - return this._showConservation; - } - - /** - * Returns the value of field 'showFullId'. - * - * @return the value of field 'ShowFullId'. - */ - public boolean getShowFullId( - ) { - return this._showFullId; - } - - /** - * Returns the value of field 'showIdentity'. - * - * @return the value of field 'ShowIdentity'. - */ - public boolean getShowIdentity( - ) { - return this._showIdentity; - } - - /** - * Returns the value of field 'showQuality'. - * - * @return the value of field 'ShowQuality'. - */ - public boolean getShowQuality( - ) { - return this._showQuality; - } - - /** - * Returns the value of field 'showSequenceFeatures'. - * - * @return the value of field 'ShowSequenceFeatures'. - */ - public boolean getShowSequenceFeatures( - ) { - return this._showSequenceFeatures; - } - - /** - * Returns the value of field 'showText'. - * - * @return the value of field 'ShowText'. - */ - public boolean getShowText( - ) { - return this._showText; - } - - /** - * Returns the value of field 'startRes'. - * - * @return the value of field 'StartRes'. - */ - public int getStartRes( - ) { - return this._startRes; - } - - /** - * Returns the value of field 'startSeq'. - * - * @return the value of field 'StartSeq'. - */ - public int getStartSeq( - ) { - return this._startSeq; - } - - /** - * Returns the value of field 'title'. - * - * @return the value of field 'Title'. - */ - public java.lang.String getTitle( - ) { - return this._title; - } - - /** - * Returns the value of field 'width'. - * - * @return the value of field 'Width'. - */ - public int getWidth( - ) { - return this._width; - } - - /** - * Returns the value of field 'wrapAlignment'. - * - * @return the value of field 'WrapAlignment'. - */ - public boolean getWrapAlignment( - ) { - return this._wrapAlignment; - } - - /** - * Returns the value of field 'xpos'. - * - * @return the value of field 'Xpos'. - */ - public int getXpos( - ) { - return this._xpos; - } - - /** - * Returns the value of field 'ypos'. - * - * @return the value of field 'Ypos'. - */ - public int getYpos( - ) { - return this._ypos; - } - - /** - * Method hasConsThreshold. - * - * @return true if at least one ConsThreshold has been added - */ - public boolean hasConsThreshold( - ) { - return this._has_consThreshold; - } - - /** - * Method hasConservationSelected. - * - * @return true if at least one ConservationSelected has been - * added - */ - public boolean hasConservationSelected( - ) { - return this._has_conservationSelected; - } - - /** - * Method hasFontSize. - * - * @return true if at least one FontSize has been added - */ - public boolean hasFontSize( - ) { - return this._has_fontSize; - } - - /** - * Method hasFontStyle. - * - * @return true if at least one FontStyle has been added - */ - public boolean hasFontStyle( - ) { - return this._has_fontStyle; - } - - /** - * Method hasHeight. - * - * @return true if at least one Height has been added - */ - public boolean hasHeight( - ) { - return this._has_height; - } - - /** - * Method hasPidSelected. - * - * @return true if at least one PidSelected has been added - */ - public boolean hasPidSelected( - ) { - return this._has_pidSelected; - } - - /** - * Method hasPidThreshold. - * - * @return true if at least one PidThreshold has been added - */ - public boolean hasPidThreshold( - ) { - return this._has_pidThreshold; - } - - /** - * Method hasRenderGaps. - * - * @return true if at least one RenderGaps has been added - */ - public boolean hasRenderGaps( - ) { - return this._has_renderGaps; - } - - /** - * Method hasShowAnnotation. - * - * @return true if at least one ShowAnnotation has been added - */ - public boolean hasShowAnnotation( - ) { - return this._has_showAnnotation; - } - - /** - * Method hasShowBoxes. - * - * @return true if at least one ShowBoxes has been added - */ - public boolean hasShowBoxes( - ) { - return this._has_showBoxes; - } - - /** - * Method hasShowColourText. - * - * @return true if at least one ShowColourText has been added - */ - public boolean hasShowColourText( - ) { - return this._has_showColourText; - } - - /** - * Method hasShowConservation. - * - * @return true if at least one ShowConservation has been added - */ - public boolean hasShowConservation( - ) { - return this._has_showConservation; - } - - /** - * Method hasShowFullId. - * - * @return true if at least one ShowFullId has been added - */ - public boolean hasShowFullId( - ) { - return this._has_showFullId; - } - - /** - * Method hasShowIdentity. - * - * @return true if at least one ShowIdentity has been added - */ - public boolean hasShowIdentity( - ) { - return this._has_showIdentity; - } - - /** - * Method hasShowQuality. - * - * @return true if at least one ShowQuality has been added - */ - public boolean hasShowQuality( - ) { - return this._has_showQuality; - } - - /** - * Method hasShowSequenceFeatures. - * - * @return true if at least one ShowSequenceFeatures has been - * added - */ - public boolean hasShowSequenceFeatures( - ) { - return this._has_showSequenceFeatures; - } - - /** - * Method hasShowText. - * - * @return true if at least one ShowText has been added - */ - public boolean hasShowText( - ) { - return this._has_showText; - } - - /** - * Method hasStartRes. - * - * @return true if at least one StartRes has been added - */ - public boolean hasStartRes( - ) { - return this._has_startRes; - } - - /** - * Method hasStartSeq. - * - * @return true if at least one StartSeq has been added - */ - public boolean hasStartSeq( - ) { - return this._has_startSeq; - } - - /** - * Method hasWidth. - * - * @return true if at least one Width has been added - */ - public boolean hasWidth( - ) { - return this._has_width; - } - - /** - * Method hasWrapAlignment. - * - * @return true if at least one WrapAlignment has been added - */ - public boolean hasWrapAlignment( - ) { - return this._has_wrapAlignment; - } - - /** - * Method hasXpos. - * - * @return true if at least one Xpos has been added - */ - public boolean hasXpos( - ) { - return this._has_xpos; - } - - /** - * Method hasYpos. - * - * @return true if at least one Ypos has been added - */ - public boolean hasYpos( - ) { - return this._has_ypos; - } - - /** - * Returns the value of field 'conservationSelected'. - * - * @return the value of field 'ConservationSelected'. - */ - public boolean isConservationSelected( - ) { - return this._conservationSelected; - } - - /** - * Returns the value of field 'pidSelected'. - * - * @return the value of field 'PidSelected'. - */ - public boolean isPidSelected( - ) { - return this._pidSelected; - } - - /** - * Returns the value of field 'renderGaps'. - * - * @return the value of field 'RenderGaps'. - */ - public boolean isRenderGaps( - ) { - return this._renderGaps; - } - - /** - * Returns the value of field 'showAnnotation'. - * - * @return the value of field 'ShowAnnotation'. - */ - public boolean isShowAnnotation( - ) { - return this._showAnnotation; - } - - /** - * Returns the value of field 'showBoxes'. - * - * @return the value of field 'ShowBoxes'. - */ - public boolean isShowBoxes( - ) { - return this._showBoxes; - } - - /** - * Returns the value of field 'showColourText'. - * - * @return the value of field 'ShowColourText'. - */ - public boolean isShowColourText( - ) { - return this._showColourText; - } - - /** - * Returns the value of field 'showConservation'. - * - * @return the value of field 'ShowConservation'. - */ - public boolean isShowConservation( - ) { - return this._showConservation; - } - - /** - * Returns the value of field 'showFullId'. - * - * @return the value of field 'ShowFullId'. - */ - public boolean isShowFullId( - ) { - return this._showFullId; - } - - /** - * Returns the value of field 'showIdentity'. - * - * @return the value of field 'ShowIdentity'. - */ - public boolean isShowIdentity( - ) { - return this._showIdentity; - } - - /** - * Returns the value of field 'showQuality'. - * - * @return the value of field 'ShowQuality'. - */ - public boolean isShowQuality( - ) { - return this._showQuality; - } - - /** - * Returns the value of field 'showSequenceFeatures'. - * - * @return the value of field 'ShowSequenceFeatures'. - */ - public boolean isShowSequenceFeatures( - ) { - return this._showSequenceFeatures; - } - - /** - * Returns the value of field 'showText'. - * - * @return the value of field 'ShowText'. - */ - public boolean isShowText( - ) { - return this._showText; - } - - /** - * Method isValid. - * - * @return true if this object is valid according to the schema - */ - public boolean isValid( - ) { - try { - validate(); - } catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } - - /** - * Returns the value of field 'wrapAlignment'. - * - * @return the value of field 'WrapAlignment'. - */ - public boolean isWrapAlignment( - ) { - return this._wrapAlignment; - } - - /** - * - * - * @param out - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void marshal( - final java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } - - /** - * - * - * @param handler - * @throws java.io.IOException if an IOException occurs during - * marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - */ - public void marshal( - final org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } - - /** - * Sets the value of field 'bgColour'. - * - * @param bgColour the value of field 'bgColour'. - */ - public void setBgColour( - final java.lang.String bgColour) { - this._bgColour = bgColour; - } - - /** - * Sets the value of field 'consThreshold'. - * - * @param consThreshold the value of field 'consThreshold'. - */ - public void setConsThreshold( - final int consThreshold) { - this._consThreshold = consThreshold; - this._has_consThreshold = true; - } - - /** - * Sets the value of field 'conservationSelected'. - * - * @param conservationSelected the value of field - * 'conservationSelected'. - */ - public void setConservationSelected( - final boolean conservationSelected) { - this._conservationSelected = conservationSelected; - this._has_conservationSelected = true; - } - - /** - * Sets the value of field 'fontName'. - * - * @param fontName the value of field 'fontName'. - */ - public void setFontName( - final java.lang.String fontName) { - this._fontName = fontName; - } - - /** - * Sets the value of field 'fontSize'. - * - * @param fontSize the value of field 'fontSize'. - */ - public void setFontSize( - final int fontSize) { - this._fontSize = fontSize; - this._has_fontSize = true; - } - - /** - * Sets the value of field 'fontStyle'. - * - * @param fontStyle the value of field 'fontStyle'. - */ - public void setFontStyle( - final int fontStyle) { - this._fontStyle = fontStyle; - this._has_fontStyle = true; - } - - /** - * Sets the value of field 'height'. - * - * @param height the value of field 'height'. - */ - public void setHeight( - final int height) { - this._height = height; - this._has_height = true; - } - - /** - * Sets the value of field 'pidSelected'. - * - * @param pidSelected the value of field 'pidSelected'. - */ - public void setPidSelected( - final boolean pidSelected) { - this._pidSelected = pidSelected; - this._has_pidSelected = true; - } - - /** - * Sets the value of field 'pidThreshold'. - * - * @param pidThreshold the value of field 'pidThreshold'. - */ - public void setPidThreshold( - final int pidThreshold) { - this._pidThreshold = pidThreshold; - this._has_pidThreshold = true; - } - - /** - * Sets the value of field 'renderGaps'. - * - * @param renderGaps the value of field 'renderGaps'. - */ - public void setRenderGaps( - final boolean renderGaps) { - this._renderGaps = renderGaps; - this._has_renderGaps = true; - } - - /** - * Sets the value of field 'showAnnotation'. - * - * @param showAnnotation the value of field 'showAnnotation'. - */ - public void setShowAnnotation( - final boolean showAnnotation) { - this._showAnnotation = showAnnotation; - this._has_showAnnotation = true; - } - - /** - * Sets the value of field 'showBoxes'. - * - * @param showBoxes the value of field 'showBoxes'. - */ - public void setShowBoxes( - final boolean showBoxes) { - this._showBoxes = showBoxes; - this._has_showBoxes = true; - } - - /** - * Sets the value of field 'showColourText'. - * - * @param showColourText the value of field 'showColourText'. - */ - public void setShowColourText( - final boolean showColourText) { - this._showColourText = showColourText; - this._has_showColourText = true; - } - - /** - * Sets the value of field 'showConservation'. - * - * @param showConservation the value of field 'showConservation' - */ - public void setShowConservation( - final boolean showConservation) { - this._showConservation = showConservation; - this._has_showConservation = true; - } - - /** - * Sets the value of field 'showFullId'. - * - * @param showFullId the value of field 'showFullId'. - */ - public void setShowFullId( - final boolean showFullId) { - this._showFullId = showFullId; - this._has_showFullId = true; - } - - /** - * Sets the value of field 'showIdentity'. - * - * @param showIdentity the value of field 'showIdentity'. - */ - public void setShowIdentity( - final boolean showIdentity) { - this._showIdentity = showIdentity; - this._has_showIdentity = true; - } - - /** - * Sets the value of field 'showQuality'. - * - * @param showQuality the value of field 'showQuality'. - */ - public void setShowQuality( - final boolean showQuality) { - this._showQuality = showQuality; - this._has_showQuality = true; - } - - /** - * Sets the value of field 'showSequenceFeatures'. - * - * @param showSequenceFeatures the value of field - * 'showSequenceFeatures'. - */ - public void setShowSequenceFeatures( - final boolean showSequenceFeatures) { - this._showSequenceFeatures = showSequenceFeatures; - this._has_showSequenceFeatures = true; - } - - /** - * Sets the value of field 'showText'. - * - * @param showText the value of field 'showText'. - */ - public void setShowText( - final boolean showText) { - this._showText = showText; - this._has_showText = true; - } - - /** - * Sets the value of field 'startRes'. - * - * @param startRes the value of field 'startRes'. - */ - public void setStartRes( - final int startRes) { - this._startRes = startRes; - this._has_startRes = true; - } - - /** - * Sets the value of field 'startSeq'. - * - * @param startSeq the value of field 'startSeq'. - */ - public void setStartSeq( - final int startSeq) { - this._startSeq = startSeq; - this._has_startSeq = true; - } - - /** - * Sets the value of field 'title'. - * - * @param title the value of field 'title'. - */ - public void setTitle( - final java.lang.String title) { - this._title = title; - } - - /** - * Sets the value of field 'width'. - * - * @param width the value of field 'width'. - */ - public void setWidth( - final int width) { - this._width = width; - this._has_width = true; - } - - /** - * Sets the value of field 'wrapAlignment'. - * - * @param wrapAlignment the value of field 'wrapAlignment'. - */ - public void setWrapAlignment( - final boolean wrapAlignment) { - this._wrapAlignment = wrapAlignment; - this._has_wrapAlignment = true; - } - - /** - * Sets the value of field 'xpos'. - * - * @param xpos the value of field 'xpos'. - */ - public void setXpos( - final int xpos) { - this._xpos = xpos; - this._has_xpos = true; - } - - /** - * Sets the value of field 'ypos'. - * - * @param ypos the value of field 'ypos'. - */ - public void setYpos( - final int ypos) { - this._ypos = ypos; - this._has_ypos = true; - } - - /** - * Method unmarshal. - * - * @param reader - * @throws org.exolab.castor.xml.MarshalException if object is - * null or if any SAXException is thrown during marshaling - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - * @return the unmarshaled jalview.binding.Viewport - */ - public static jalview.binding.Viewport unmarshal( - final java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { - return (jalview.binding.Viewport) Unmarshaller.unmarshal(jalview.binding.Viewport.class, reader); - } - - /** - * - * - * @throws org.exolab.castor.xml.ValidationException if this - * object is an invalid instance according to the schema - */ - public void validate( - ) - throws org.exolab.castor.xml.ValidationException { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } +public class Viewport implements java.io.Serializable +{ + + // --------------------------/ + // - Class/Member Variables -/ + // --------------------------/ + + /** + * Field _conservationSelected. + */ + private boolean _conservationSelected; + + /** + * keeps track of state for field: _conservationSelected + */ + private boolean _has_conservationSelected; + + /** + * Field _pidSelected. + */ + private boolean _pidSelected; + + /** + * keeps track of state for field: _pidSelected + */ + private boolean _has_pidSelected; + + /** + * Field _bgColour. + */ + private java.lang.String _bgColour; + + /** + * Field _consThreshold. + */ + private int _consThreshold; + + /** + * keeps track of state for field: _consThreshold + */ + private boolean _has_consThreshold; + + /** + * Field _pidThreshold. + */ + private int _pidThreshold; + + /** + * keeps track of state for field: _pidThreshold + */ + private boolean _has_pidThreshold; + + /** + * Field _title. + */ + private java.lang.String _title; + + /** + * Field _showFullId. + */ + private boolean _showFullId; + + /** + * keeps track of state for field: _showFullId + */ + private boolean _has_showFullId; + + /** + * Field _showText. + */ + private boolean _showText; + + /** + * keeps track of state for field: _showText + */ + private boolean _has_showText; + + /** + * Field _showColourText. + */ + private boolean _showColourText; + + /** + * keeps track of state for field: _showColourText + */ + private boolean _has_showColourText; + + /** + * Field _showBoxes. + */ + private boolean _showBoxes; + + /** + * keeps track of state for field: _showBoxes + */ + private boolean _has_showBoxes; + + /** + * Field _wrapAlignment. + */ + private boolean _wrapAlignment; + + /** + * keeps track of state for field: _wrapAlignment + */ + private boolean _has_wrapAlignment; + + /** + * Field _renderGaps. + */ + private boolean _renderGaps; + + /** + * keeps track of state for field: _renderGaps + */ + private boolean _has_renderGaps; + + /** + * Field _showSequenceFeatures. + */ + private boolean _showSequenceFeatures; + + /** + * keeps track of state for field: _showSequenceFeatures + */ + private boolean _has_showSequenceFeatures; + + /** + * Field _showAnnotation. + */ + private boolean _showAnnotation; + + /** + * keeps track of state for field: _showAnnotation + */ + private boolean _has_showAnnotation; + + /** + * Field _showConservation. + */ + private boolean _showConservation; + + /** + * keeps track of state for field: _showConservation + */ + private boolean _has_showConservation; + + /** + * Field _showQuality. + */ + private boolean _showQuality; + + /** + * keeps track of state for field: _showQuality + */ + private boolean _has_showQuality; + + /** + * Field _showIdentity. + */ + private boolean _showIdentity; + + /** + * keeps track of state for field: _showIdentity + */ + private boolean _has_showIdentity; + + /** + * Field _xpos. + */ + private int _xpos; + + /** + * keeps track of state for field: _xpos + */ + private boolean _has_xpos; + + /** + * Field _ypos. + */ + private int _ypos; + + /** + * keeps track of state for field: _ypos + */ + private boolean _has_ypos; + + /** + * Field _width. + */ + private int _width; + + /** + * keeps track of state for field: _width + */ + private boolean _has_width; + + /** + * Field _height. + */ + private int _height; + + /** + * keeps track of state for field: _height + */ + private boolean _has_height; + + /** + * Field _startRes. + */ + private int _startRes; + + /** + * keeps track of state for field: _startRes + */ + private boolean _has_startRes; + + /** + * Field _startSeq. + */ + private int _startSeq; + + /** + * keeps track of state for field: _startSeq + */ + private boolean _has_startSeq; + + /** + * Field _fontName. + */ + private java.lang.String _fontName; + + /** + * Field _fontSize. + */ + private int _fontSize; + + /** + * keeps track of state for field: _fontSize + */ + private boolean _has_fontSize; + + /** + * Field _fontStyle. + */ + private int _fontStyle; + + /** + * keeps track of state for field: _fontStyle + */ + private boolean _has_fontStyle; + + // ----------------/ + // - Constructors -/ + // ----------------/ + + public Viewport() + { + super(); + } + + // -----------/ + // - Methods -/ + // -----------/ + + /** + */ + public void deleteConsThreshold() + { + this._has_consThreshold = false; + } + + /** + */ + public void deleteConservationSelected() + { + this._has_conservationSelected = false; + } + + /** + */ + public void deleteFontSize() + { + this._has_fontSize = false; + } + + /** + */ + public void deleteFontStyle() + { + this._has_fontStyle = false; + } + + /** + */ + public void deleteHeight() + { + this._has_height = false; + } + + /** + */ + public void deletePidSelected() + { + this._has_pidSelected = false; + } + + /** + */ + public void deletePidThreshold() + { + this._has_pidThreshold = false; + } + + /** + */ + public void deleteRenderGaps() + { + this._has_renderGaps = false; + } + + /** + */ + public void deleteShowAnnotation() + { + this._has_showAnnotation = false; + } + + /** + */ + public void deleteShowBoxes() + { + this._has_showBoxes = false; + } + + /** + */ + public void deleteShowColourText() + { + this._has_showColourText = false; + } + + /** + */ + public void deleteShowConservation() + { + this._has_showConservation = false; + } + + /** + */ + public void deleteShowFullId() + { + this._has_showFullId = false; + } + + /** + */ + public void deleteShowIdentity() + { + this._has_showIdentity = false; + } + + /** + */ + public void deleteShowQuality() + { + this._has_showQuality = false; + } + + /** + */ + public void deleteShowSequenceFeatures() + { + this._has_showSequenceFeatures = false; + } + + /** + */ + public void deleteShowText() + { + this._has_showText = false; + } + + /** + */ + public void deleteStartRes() + { + this._has_startRes = false; + } + + /** + */ + public void deleteStartSeq() + { + this._has_startSeq = false; + } + + /** + */ + public void deleteWidth() + { + this._has_width = false; + } + + /** + */ + public void deleteWrapAlignment() + { + this._has_wrapAlignment = false; + } + + /** + */ + public void deleteXpos() + { + this._has_xpos = false; + } + + /** + */ + public void deleteYpos() + { + this._has_ypos = false; + } + + /** + * Returns the value of field 'bgColour'. + * + * @return the value of field 'BgColour'. + */ + public java.lang.String getBgColour() + { + return this._bgColour; + } + + /** + * Returns the value of field 'consThreshold'. + * + * @return the value of field 'ConsThreshold'. + */ + public int getConsThreshold() + { + return this._consThreshold; + } + + /** + * Returns the value of field 'conservationSelected'. + * + * @return the value of field 'ConservationSelected'. + */ + public boolean getConservationSelected() + { + return this._conservationSelected; + } + + /** + * Returns the value of field 'fontName'. + * + * @return the value of field 'FontName'. + */ + public java.lang.String getFontName() + { + return this._fontName; + } + + /** + * Returns the value of field 'fontSize'. + * + * @return the value of field 'FontSize'. + */ + public int getFontSize() + { + return this._fontSize; + } + + /** + * Returns the value of field 'fontStyle'. + * + * @return the value of field 'FontStyle'. + */ + public int getFontStyle() + { + return this._fontStyle; + } + + /** + * Returns the value of field 'height'. + * + * @return the value of field 'Height'. + */ + public int getHeight() + { + return this._height; + } + + /** + * Returns the value of field 'pidSelected'. + * + * @return the value of field 'PidSelected'. + */ + public boolean getPidSelected() + { + return this._pidSelected; + } + + /** + * Returns the value of field 'pidThreshold'. + * + * @return the value of field 'PidThreshold'. + */ + public int getPidThreshold() + { + return this._pidThreshold; + } + + /** + * Returns the value of field 'renderGaps'. + * + * @return the value of field 'RenderGaps'. + */ + public boolean getRenderGaps() + { + return this._renderGaps; + } + + /** + * Returns the value of field 'showAnnotation'. + * + * @return the value of field 'ShowAnnotation'. + */ + public boolean getShowAnnotation() + { + return this._showAnnotation; + } + + /** + * Returns the value of field 'showBoxes'. + * + * @return the value of field 'ShowBoxes'. + */ + public boolean getShowBoxes() + { + return this._showBoxes; + } + + /** + * Returns the value of field 'showColourText'. + * + * @return the value of field 'ShowColourText'. + */ + public boolean getShowColourText() + { + return this._showColourText; + } + + /** + * Returns the value of field 'showConservation'. + * + * @return the value of field 'ShowConservation'. + */ + public boolean getShowConservation() + { + return this._showConservation; + } + + /** + * Returns the value of field 'showFullId'. + * + * @return the value of field 'ShowFullId'. + */ + public boolean getShowFullId() + { + return this._showFullId; + } + + /** + * Returns the value of field 'showIdentity'. + * + * @return the value of field 'ShowIdentity'. + */ + public boolean getShowIdentity() + { + return this._showIdentity; + } + + /** + * Returns the value of field 'showQuality'. + * + * @return the value of field 'ShowQuality'. + */ + public boolean getShowQuality() + { + return this._showQuality; + } + + /** + * Returns the value of field 'showSequenceFeatures'. + * + * @return the value of field 'ShowSequenceFeatures'. + */ + public boolean getShowSequenceFeatures() + { + return this._showSequenceFeatures; + } + + /** + * Returns the value of field 'showText'. + * + * @return the value of field 'ShowText'. + */ + public boolean getShowText() + { + return this._showText; + } + + /** + * Returns the value of field 'startRes'. + * + * @return the value of field 'StartRes'. + */ + public int getStartRes() + { + return this._startRes; + } + + /** + * Returns the value of field 'startSeq'. + * + * @return the value of field 'StartSeq'. + */ + public int getStartSeq() + { + return this._startSeq; + } + + /** + * Returns the value of field 'title'. + * + * @return the value of field 'Title'. + */ + public java.lang.String getTitle() + { + return this._title; + } + + /** + * Returns the value of field 'width'. + * + * @return the value of field 'Width'. + */ + public int getWidth() + { + return this._width; + } + + /** + * Returns the value of field 'wrapAlignment'. + * + * @return the value of field 'WrapAlignment'. + */ + public boolean getWrapAlignment() + { + return this._wrapAlignment; + } + + /** + * Returns the value of field 'xpos'. + * + * @return the value of field 'Xpos'. + */ + public int getXpos() + { + return this._xpos; + } + + /** + * Returns the value of field 'ypos'. + * + * @return the value of field 'Ypos'. + */ + public int getYpos() + { + return this._ypos; + } + + /** + * Method hasConsThreshold. + * + * @return true if at least one ConsThreshold has been added + */ + public boolean hasConsThreshold() + { + return this._has_consThreshold; + } + + /** + * Method hasConservationSelected. + * + * @return true if at least one ConservationSelected has been added + */ + public boolean hasConservationSelected() + { + return this._has_conservationSelected; + } + + /** + * Method hasFontSize. + * + * @return true if at least one FontSize has been added + */ + public boolean hasFontSize() + { + return this._has_fontSize; + } + + /** + * Method hasFontStyle. + * + * @return true if at least one FontStyle has been added + */ + public boolean hasFontStyle() + { + return this._has_fontStyle; + } + + /** + * Method hasHeight. + * + * @return true if at least one Height has been added + */ + public boolean hasHeight() + { + return this._has_height; + } + + /** + * Method hasPidSelected. + * + * @return true if at least one PidSelected has been added + */ + public boolean hasPidSelected() + { + return this._has_pidSelected; + } + + /** + * Method hasPidThreshold. + * + * @return true if at least one PidThreshold has been added + */ + public boolean hasPidThreshold() + { + return this._has_pidThreshold; + } + + /** + * Method hasRenderGaps. + * + * @return true if at least one RenderGaps has been added + */ + public boolean hasRenderGaps() + { + return this._has_renderGaps; + } + + /** + * Method hasShowAnnotation. + * + * @return true if at least one ShowAnnotation has been added + */ + public boolean hasShowAnnotation() + { + return this._has_showAnnotation; + } + + /** + * Method hasShowBoxes. + * + * @return true if at least one ShowBoxes has been added + */ + public boolean hasShowBoxes() + { + return this._has_showBoxes; + } + + /** + * Method hasShowColourText. + * + * @return true if at least one ShowColourText has been added + */ + public boolean hasShowColourText() + { + return this._has_showColourText; + } + + /** + * Method hasShowConservation. + * + * @return true if at least one ShowConservation has been added + */ + public boolean hasShowConservation() + { + return this._has_showConservation; + } + + /** + * Method hasShowFullId. + * + * @return true if at least one ShowFullId has been added + */ + public boolean hasShowFullId() + { + return this._has_showFullId; + } + + /** + * Method hasShowIdentity. + * + * @return true if at least one ShowIdentity has been added + */ + public boolean hasShowIdentity() + { + return this._has_showIdentity; + } + + /** + * Method hasShowQuality. + * + * @return true if at least one ShowQuality has been added + */ + public boolean hasShowQuality() + { + return this._has_showQuality; + } + + /** + * Method hasShowSequenceFeatures. + * + * @return true if at least one ShowSequenceFeatures has been added + */ + public boolean hasShowSequenceFeatures() + { + return this._has_showSequenceFeatures; + } + + /** + * Method hasShowText. + * + * @return true if at least one ShowText has been added + */ + public boolean hasShowText() + { + return this._has_showText; + } + + /** + * Method hasStartRes. + * + * @return true if at least one StartRes has been added + */ + public boolean hasStartRes() + { + return this._has_startRes; + } + + /** + * Method hasStartSeq. + * + * @return true if at least one StartSeq has been added + */ + public boolean hasStartSeq() + { + return this._has_startSeq; + } + + /** + * Method hasWidth. + * + * @return true if at least one Width has been added + */ + public boolean hasWidth() + { + return this._has_width; + } + + /** + * Method hasWrapAlignment. + * + * @return true if at least one WrapAlignment has been added + */ + public boolean hasWrapAlignment() + { + return this._has_wrapAlignment; + } + + /** + * Method hasXpos. + * + * @return true if at least one Xpos has been added + */ + public boolean hasXpos() + { + return this._has_xpos; + } + + /** + * Method hasYpos. + * + * @return true if at least one Ypos has been added + */ + public boolean hasYpos() + { + return this._has_ypos; + } + + /** + * Returns the value of field 'conservationSelected'. + * + * @return the value of field 'ConservationSelected'. + */ + public boolean isConservationSelected() + { + return this._conservationSelected; + } + + /** + * Returns the value of field 'pidSelected'. + * + * @return the value of field 'PidSelected'. + */ + public boolean isPidSelected() + { + return this._pidSelected; + } + + /** + * Returns the value of field 'renderGaps'. + * + * @return the value of field 'RenderGaps'. + */ + public boolean isRenderGaps() + { + return this._renderGaps; + } + + /** + * Returns the value of field 'showAnnotation'. + * + * @return the value of field 'ShowAnnotation'. + */ + public boolean isShowAnnotation() + { + return this._showAnnotation; + } + + /** + * Returns the value of field 'showBoxes'. + * + * @return the value of field 'ShowBoxes'. + */ + public boolean isShowBoxes() + { + return this._showBoxes; + } + + /** + * Returns the value of field 'showColourText'. + * + * @return the value of field 'ShowColourText'. + */ + public boolean isShowColourText() + { + return this._showColourText; + } + + /** + * Returns the value of field 'showConservation'. + * + * @return the value of field 'ShowConservation'. + */ + public boolean isShowConservation() + { + return this._showConservation; + } + + /** + * Returns the value of field 'showFullId'. + * + * @return the value of field 'ShowFullId'. + */ + public boolean isShowFullId() + { + return this._showFullId; + } + + /** + * Returns the value of field 'showIdentity'. + * + * @return the value of field 'ShowIdentity'. + */ + public boolean isShowIdentity() + { + return this._showIdentity; + } + + /** + * Returns the value of field 'showQuality'. + * + * @return the value of field 'ShowQuality'. + */ + public boolean isShowQuality() + { + return this._showQuality; + } + + /** + * Returns the value of field 'showSequenceFeatures'. + * + * @return the value of field 'ShowSequenceFeatures'. + */ + public boolean isShowSequenceFeatures() + { + return this._showSequenceFeatures; + } + + /** + * Returns the value of field 'showText'. + * + * @return the value of field 'ShowText'. + */ + public boolean isShowText() + { + return this._showText; + } + + /** + * Method isValid. + * + * @return true if this object is valid according to the schema + */ + public boolean isValid() + { + try + { + validate(); + } catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } + + /** + * Returns the value of field 'wrapAlignment'. + * + * @return the value of field 'WrapAlignment'. + */ + public boolean isWrapAlignment() + { + return this._wrapAlignment; + } + + /** + * + * + * @param out + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void marshal(final java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, out); + } + + /** + * + * + * @param handler + * @throws java.io.IOException + * if an IOException occurs during marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + */ + public void marshal(final org.xml.sax.ContentHandler handler) + throws java.io.IOException, + org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + Marshaller.marshal(this, handler); + } + + /** + * Sets the value of field 'bgColour'. + * + * @param bgColour + * the value of field 'bgColour'. + */ + public void setBgColour(final java.lang.String bgColour) + { + this._bgColour = bgColour; + } + + /** + * Sets the value of field 'consThreshold'. + * + * @param consThreshold + * the value of field 'consThreshold'. + */ + public void setConsThreshold(final int consThreshold) + { + this._consThreshold = consThreshold; + this._has_consThreshold = true; + } + + /** + * Sets the value of field 'conservationSelected'. + * + * @param conservationSelected + * the value of field 'conservationSelected'. + */ + public void setConservationSelected(final boolean conservationSelected) + { + this._conservationSelected = conservationSelected; + this._has_conservationSelected = true; + } + + /** + * Sets the value of field 'fontName'. + * + * @param fontName + * the value of field 'fontName'. + */ + public void setFontName(final java.lang.String fontName) + { + this._fontName = fontName; + } + + /** + * Sets the value of field 'fontSize'. + * + * @param fontSize + * the value of field 'fontSize'. + */ + public void setFontSize(final int fontSize) + { + this._fontSize = fontSize; + this._has_fontSize = true; + } + + /** + * Sets the value of field 'fontStyle'. + * + * @param fontStyle + * the value of field 'fontStyle'. + */ + public void setFontStyle(final int fontStyle) + { + this._fontStyle = fontStyle; + this._has_fontStyle = true; + } + + /** + * Sets the value of field 'height'. + * + * @param height + * the value of field 'height'. + */ + public void setHeight(final int height) + { + this._height = height; + this._has_height = true; + } + + /** + * Sets the value of field 'pidSelected'. + * + * @param pidSelected + * the value of field 'pidSelected'. + */ + public void setPidSelected(final boolean pidSelected) + { + this._pidSelected = pidSelected; + this._has_pidSelected = true; + } + + /** + * Sets the value of field 'pidThreshold'. + * + * @param pidThreshold + * the value of field 'pidThreshold'. + */ + public void setPidThreshold(final int pidThreshold) + { + this._pidThreshold = pidThreshold; + this._has_pidThreshold = true; + } + + /** + * Sets the value of field 'renderGaps'. + * + * @param renderGaps + * the value of field 'renderGaps'. + */ + public void setRenderGaps(final boolean renderGaps) + { + this._renderGaps = renderGaps; + this._has_renderGaps = true; + } + + /** + * Sets the value of field 'showAnnotation'. + * + * @param showAnnotation + * the value of field 'showAnnotation'. + */ + public void setShowAnnotation(final boolean showAnnotation) + { + this._showAnnotation = showAnnotation; + this._has_showAnnotation = true; + } + + /** + * Sets the value of field 'showBoxes'. + * + * @param showBoxes + * the value of field 'showBoxes'. + */ + public void setShowBoxes(final boolean showBoxes) + { + this._showBoxes = showBoxes; + this._has_showBoxes = true; + } + + /** + * Sets the value of field 'showColourText'. + * + * @param showColourText + * the value of field 'showColourText'. + */ + public void setShowColourText(final boolean showColourText) + { + this._showColourText = showColourText; + this._has_showColourText = true; + } + + /** + * Sets the value of field 'showConservation'. + * + * @param showConservation + * the value of field 'showConservation' + */ + public void setShowConservation(final boolean showConservation) + { + this._showConservation = showConservation; + this._has_showConservation = true; + } + + /** + * Sets the value of field 'showFullId'. + * + * @param showFullId + * the value of field 'showFullId'. + */ + public void setShowFullId(final boolean showFullId) + { + this._showFullId = showFullId; + this._has_showFullId = true; + } + + /** + * Sets the value of field 'showIdentity'. + * + * @param showIdentity + * the value of field 'showIdentity'. + */ + public void setShowIdentity(final boolean showIdentity) + { + this._showIdentity = showIdentity; + this._has_showIdentity = true; + } + + /** + * Sets the value of field 'showQuality'. + * + * @param showQuality + * the value of field 'showQuality'. + */ + public void setShowQuality(final boolean showQuality) + { + this._showQuality = showQuality; + this._has_showQuality = true; + } + + /** + * Sets the value of field 'showSequenceFeatures'. + * + * @param showSequenceFeatures + * the value of field 'showSequenceFeatures'. + */ + public void setShowSequenceFeatures(final boolean showSequenceFeatures) + { + this._showSequenceFeatures = showSequenceFeatures; + this._has_showSequenceFeatures = true; + } + + /** + * Sets the value of field 'showText'. + * + * @param showText + * the value of field 'showText'. + */ + public void setShowText(final boolean showText) + { + this._showText = showText; + this._has_showText = true; + } + + /** + * Sets the value of field 'startRes'. + * + * @param startRes + * the value of field 'startRes'. + */ + public void setStartRes(final int startRes) + { + this._startRes = startRes; + this._has_startRes = true; + } + + /** + * Sets the value of field 'startSeq'. + * + * @param startSeq + * the value of field 'startSeq'. + */ + public void setStartSeq(final int startSeq) + { + this._startSeq = startSeq; + this._has_startSeq = true; + } + + /** + * Sets the value of field 'title'. + * + * @param title + * the value of field 'title'. + */ + public void setTitle(final java.lang.String title) + { + this._title = title; + } + + /** + * Sets the value of field 'width'. + * + * @param width + * the value of field 'width'. + */ + public void setWidth(final int width) + { + this._width = width; + this._has_width = true; + } + + /** + * Sets the value of field 'wrapAlignment'. + * + * @param wrapAlignment + * the value of field 'wrapAlignment'. + */ + public void setWrapAlignment(final boolean wrapAlignment) + { + this._wrapAlignment = wrapAlignment; + this._has_wrapAlignment = true; + } + + /** + * Sets the value of field 'xpos'. + * + * @param xpos + * the value of field 'xpos'. + */ + public void setXpos(final int xpos) + { + this._xpos = xpos; + this._has_xpos = true; + } + + /** + * Sets the value of field 'ypos'. + * + * @param ypos + * the value of field 'ypos'. + */ + public void setYpos(final int ypos) + { + this._ypos = ypos; + this._has_ypos = true; + } + + /** + * Method unmarshal. + * + * @param reader + * @throws org.exolab.castor.xml.MarshalException + * if object is null or if any SAXException is thrown during + * marshaling + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + * @return the unmarshaled jalview.binding.Viewport + */ + public static jalview.binding.Viewport unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Viewport) Unmarshaller.unmarshal( + jalview.binding.Viewport.class, reader); + } + + /** + * + * + * @throws org.exolab.castor.xml.ValidationException + * if this object is an invalid instance according to the + * schema + */ + public void validate() throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } } diff --git a/src/jalview/commands/ChangeCaseCommand.java b/src/jalview/commands/ChangeCaseCommand.java index 976be92..7a74e08 100644 --- a/src/jalview/commands/ChangeCaseCommand.java +++ b/src/jalview/commands/ChangeCaseCommand.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -20,20 +20,24 @@ package jalview.commands; import jalview.datamodel.*; -public class ChangeCaseCommand - implements CommandI +public class ChangeCaseCommand implements CommandI { String description; + public static int TO_LOWER = 0; + public static int TO_UPPER = 1; + public static int TOGGLE_CASE = 2; + int caseChange = -1; + SequenceI[] seqs; + int[][] regions; - public ChangeCaseCommand(String description, - SequenceI[] seqs, - int[][] regions, - int caseChange) + + public ChangeCaseCommand(String description, SequenceI[] seqs, + int[][] regions, int caseChange) { this.description = description; this.seqs = seqs; @@ -89,19 +93,20 @@ public class ChangeCaseCommand newSeq.append(sequence.substring(0, start)); } - if ( (caseChange == TO_UPPER && doCommand) - || (caseChange == TO_LOWER && !doCommand)) + if ((caseChange == TO_UPPER && doCommand) + || (caseChange == TO_LOWER && !doCommand)) { newSeq.append(sequence.substring(start, end).toUpperCase()); } - else if ( (caseChange == TO_LOWER && doCommand) - || (caseChange == TO_UPPER && !doCommand)) + else if ((caseChange == TO_LOWER && doCommand) + || (caseChange == TO_UPPER && !doCommand)) { newSeq.append(sequence.substring(start, end).toLowerCase()); } - else //TOGGLE CASE + else + // TOGGLE CASE { for (int c = start; c < end; c++) { diff --git a/src/jalview/commands/CommandI.java b/src/jalview/commands/CommandI.java index 97675e7..9fe508b 100644 --- a/src/jalview/commands/CommandI.java +++ b/src/jalview/commands/CommandI.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index e859e3e..85e6ad5 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -23,27 +23,37 @@ import java.util.*; import jalview.datamodel.*; /** - * - *

    Title: EditCommmand

    - * - *

    Description: Essential information for performing - * undo and redo for cut/paste insert/delete gap - * which can be stored in the HistoryList

    - * - *

    Copyright: Copyright (c) 2006

    - * - *

    Company: Dundee University

    - * + * + *

    + * Title: EditCommmand + *

    + * + *

    + * Description: Essential information for performing undo and redo for cut/paste + * insert/delete gap which can be stored in the HistoryList + *

    + * + *

    + * Copyright: Copyright (c) 2006 + *

    + * + *

    + * Company: Dundee University + *

    + * * @author not attributable * @version 1.0 */ -public class EditCommand - implements CommandI +public class EditCommand implements CommandI { public static final int INSERT_GAP = 0; + public static final int DELETE_GAP = 1; + public static final int CUT = 2; + public static final int PASTE = 3; + public static final int REPLACE = 4; Edit[] edits; @@ -51,44 +61,35 @@ public class EditCommand String description; public EditCommand() - {} + { + } public EditCommand(String description) { this.description = description; } - public EditCommand(String description, - int command, - SequenceI[] seqs, - int position, - int number, - AlignmentI al) + public EditCommand(String description, int command, SequenceI[] seqs, + int position, int number, AlignmentI al) { this.description = description; if (command == CUT || command == PASTE) { edits = new Edit[] - { - new Edit(command, seqs, position, number, al)}; + { new Edit(command, seqs, position, number, al) }; } performEdit(0, null); } - public EditCommand(String description, - int command, - String replace, - SequenceI[] seqs, - int position, - int number, - AlignmentI al) + public EditCommand(String description, int command, String replace, + SequenceI[] seqs, int position, int number, AlignmentI al) { this.description = description; if (command == REPLACE) { edits = new Edit[] - { new Edit(command, seqs, position, number, al, replace)}; + { new Edit(command, seqs, position, number, al, replace) }; } performEdit(0, null); @@ -110,9 +111,11 @@ public class EditCommand } /** - * append a new editCommand - * Note. this shouldn't be called if the edit is an operation affects more alignment objects than the one referenced - * in al (for example, cut or pasting whole sequences). Use the form with an additional AlignmentI[] views parameter. + * append a new editCommand Note. this shouldn't be called if the edit is an + * operation affects more alignment objects than the one referenced in al (for + * example, cut or pasting whole sequences). Use the form with an additional + * AlignmentI[] views parameter. + * * @param command * @param seqs * @param position @@ -120,17 +123,16 @@ public class EditCommand * @param al * @param performEdit */ - final public void appendEdit(int command, - SequenceI[] seqs, - int position, - int number, - AlignmentI al, - boolean performEdit) + final public void appendEdit(int command, SequenceI[] seqs, int position, + int number, AlignmentI al, boolean performEdit) { appendEdit(command, seqs, position, number, al, performEdit, null); } + /** - * append a new edit command with a set of alignment views that may be operated on + * append a new edit command with a set of alignment views that may be + * operated on + * * @param command * @param seqs * @param position @@ -139,14 +141,11 @@ public class EditCommand * @param performEdit * @param views */ - final public void appendEdit(int command, - SequenceI[] seqs, - int position, - int number, - AlignmentI al, - boolean performEdit, AlignmentI[] views) + final public void appendEdit(int command, SequenceI[] seqs, int position, + int number, AlignmentI al, boolean performEdit, AlignmentI[] views) { - Edit edit = new Edit(command, seqs, position, number, al.getGapCharacter()); + Edit edit = new Edit(command, seqs, position, number, al + .getGapCharacter()); if (al.getHeight() == seqs.length) { edit.al = al; @@ -163,8 +162,7 @@ public class EditCommand else { edits = new Edit[] - { - edit}; + { edit }; } if (performEdit) @@ -178,30 +176,30 @@ public class EditCommand int eSize = edits.length; for (int e = commandIndex; e < eSize; e++) { - switch(edits[e].command) + switch (edits[e].command) { - case INSERT_GAP: + case INSERT_GAP: insertGap(edits[e]); - break; - case DELETE_GAP: + break; + case DELETE_GAP: deleteGap(edits[e]); - break; - case CUT: + break; + case CUT: cut(edits[e], views); - break; - case PASTE: + break; + case PASTE: paste(edits[e], views); - break; - case REPLACE: - replace(edits[e]); - break; + break; + case REPLACE: + replace(edits[e]); + break; } } } final public void doCommand(AlignmentI[] views) { - performEdit(0,views); + performEdit(0, views); } final public void undoCommand(AlignmentI[] views) @@ -211,21 +209,21 @@ public class EditCommand { switch (edits[e].command) { - case INSERT_GAP: + case INSERT_GAP: deleteGap(edits[e]); - break; - case DELETE_GAP: + break; + case DELETE_GAP: insertGap(edits[e]); - break; - case CUT: + break; + case CUT: paste(edits[e], views); - break; - case PASTE: + break; + case PASTE: cut(edits[e], views); - break; - case REPLACE: - replace(edits[e]); - break; + break; + case REPLACE: + replace(edits[e]); + break; } } } @@ -235,9 +233,8 @@ public class EditCommand for (int s = 0; s < command.seqs.length; s++) { - command.seqs[s].insertCharAt(command.position, - command.number, - command.gapChar); + command.seqs[s].insertCharAt(command.position, command.number, + command.gapChar); } adjustAnnotations(command, true, false, null); @@ -247,8 +244,8 @@ public class EditCommand { for (int s = 0; s < command.seqs.length; s++) { - command.seqs[s].deleteChars(command.position, - command.position + command.number); + command.seqs[s].deleteChars(command.position, command.position + + command.number); } adjustAnnotations(command, false, false, null); @@ -256,7 +253,7 @@ public class EditCommand void cut(Edit command, AlignmentI[] views) { - boolean seqDeleted=false; + boolean seqDeleted = false; command.string = new char[command.seqs.length][]; for (int i = 0; i < command.seqs.length; i++) @@ -264,35 +261,35 @@ public class EditCommand if (command.seqs[i].getLength() > command.position) { command.string[i] = command.seqs[i].getSequence(command.position, - command.position + command.number); + command.position + command.number); SequenceI oldds = command.seqs[i].getDatasetSequence(); - if (command.oldds!=null && command.oldds[i]!=null) + if (command.oldds != null && command.oldds[i] != null) { // we are redoing an undone cut. command.seqs[i].setDatasetSequence(null); } - command.seqs[i].deleteChars(command.position, - command.position + command.number); - if (command.oldds!=null && command.oldds[i]!=null) + command.seqs[i].deleteChars(command.position, command.position + + command.number); + if (command.oldds != null && command.oldds[i] != null) { // oldds entry contains the cut dataset sequence. command.seqs[i].setDatasetSequence(command.oldds[i]); command.oldds[i] = oldds; - } else { + } + else + { // modify the oldds if necessary - if (oldds!=command.seqs[i].getDatasetSequence() - || command.seqs[i].getSequenceFeatures() != null) + if (oldds != command.seqs[i].getDatasetSequence() + || command.seqs[i].getSequenceFeatures() != null) { - if (command.oldds==null) + if (command.oldds == null) { command.oldds = new SequenceI[command.seqs.length]; } command.oldds[i] = oldds; - adjustFeatures(command, i, - command.seqs[i].findPosition(command.position), - command.seqs[i].findPosition(command.position + - command.number), - false); + adjustFeatures(command, i, command.seqs[i] + .findPosition(command.position), command.seqs[i] + .findPosition(command.position + command.number), false); } } } @@ -300,7 +297,7 @@ public class EditCommand if (command.seqs[i].getLength() < 1) { command.al.deleteSequence(command.seqs[i]); - seqDeleted=true; + seqDeleted = true; } } @@ -312,14 +309,14 @@ public class EditCommand StringBuffer tmp; boolean newDSNeeded; boolean newDSWasNeeded; - int newstart,newend; - boolean seqWasDeleted=false; + int newstart, newend; + boolean seqWasDeleted = false; int start = 0, end = 0; for (int i = 0; i < command.seqs.length; i++) { newDSNeeded = false; - newDSWasNeeded = command.oldds!=null && command.oldds[i]!=null; + newDSWasNeeded = command.oldds != null && command.oldds[i] != null; if (command.seqs[i].getLength() < 1) { // ie this sequence was deleted, we need to @@ -327,27 +324,28 @@ public class EditCommand if (command.alIndex[i] < command.al.getHeight()) { command.al.getSequences().insertElementAt(command.seqs[i], - command.alIndex[i]); + command.alIndex[i]); } else { command.al.addSequence(command.seqs[i]); } - seqWasDeleted=true; + seqWasDeleted = true; } newstart = command.seqs[i].getStart(); newend = command.seqs[i].getEnd(); tmp = new StringBuffer(); tmp.append(command.seqs[i].getSequence()); - //Undo of a delete does not replace original dataset sequence on to alignment sequence. - + // Undo of a delete does not replace original dataset sequence on to + // alignment sequence. + if (command.string != null && command.string[i] != null) { if (command.position >= tmp.length()) { - //This occurs if padding is on, and residues - //are removed from end of alignment + // This occurs if padding is on, and residues + // are removed from end of alignment int length = command.position - tmp.length(); while (length > 0) { @@ -358,17 +356,16 @@ public class EditCommand tmp.insert(command.position, command.string[i]); for (int s = 0; s < command.string[i].length; s++) { - if (jalview.schemes.ResidueProperties.aaIndex[command.string[i][s]] != - 23) + if (jalview.schemes.ResidueProperties.aaIndex[command.string[i][s]] != 23) { if (!newDSNeeded) { newDSNeeded = true; start = command.seqs[i].findPosition(command.position); - end = command.seqs[i].findPosition(command.position + - command.number); + end = command.seqs[i].findPosition(command.position + + command.number); } - if (command.seqs[i].getStart()==start) + if (command.seqs[i].getStart() == start) newstart--; else newend++; @@ -383,28 +380,28 @@ public class EditCommand if (newDSNeeded) { if (command.seqs[i].getDatasetSequence() != null) - { + { SequenceI ds; if (newDSWasNeeded) { ds = command.oldds[i]; - } else { + } + else + { // make a new DS sequence // use new ds mechanism here - ds= new 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 = new 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) + if (command.oldds == null) { command.oldds = new SequenceI[command.seqs.length]; } - command.oldds[i]=command.seqs[i].getDatasetSequence(); + command.oldds[i] = command.seqs[i].getDatasetSequence(); command.seqs[i].setDatasetSequence(ds); } adjustFeatures(command, i, start, end, true); @@ -421,30 +418,23 @@ public class EditCommand String oldstring; int start = command.position; int end = command.number; - // TODO TUTORIAL - Fix for replacement with different length of sequence (or whole sequence) - // TODO Jalview 2.4 bugfix change to an aggregate command - original sequence string is cut, new string is pasted in. + // TODO TUTORIAL - Fix for replacement with different length of sequence (or + // whole sequence) + // TODO Jalview 2.4 bugfix change to an aggregate command - original + // sequence string is cut, new string is pasted in. command.number = start + command.string[0].length; for (int i = 0; i < command.seqs.length; i++) { - /** cut - * addHistoryItem(new EditCommand("Cut Sequences", - EditCommand.CUT, - cut, - sg.getStartRes(), - sg.getEndRes()-sg.getStartRes()+1, - viewport.alignment)); - + /** + * cut addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, + * cut, sg.getStartRes(), sg.getEndRes()-sg.getStartRes()+1, + * viewport.alignment)); + * */ - /** then - * addHistoryItem(new EditCommand( - "Add sequences", - EditCommand.PASTE, - sequences, - 0, - alignment.getWidth(), - alignment) - ); - + /** + * then addHistoryItem(new EditCommand( "Add sequences", + * EditCommand.PASTE, sequences, 0, alignment.getWidth(), alignment) ); + * */ oldstring = command.seqs[i].getSequenceAsString(); tmp = new StringBuffer(oldstring.substring(0, start)); @@ -457,7 +447,8 @@ public class EditCommand } } - final void adjustAnnotations(Edit command, boolean insert, boolean modifyVisibility, AlignmentI[] views) + final void adjustAnnotations(Edit command, boolean insert, + boolean modifyVisibility, AlignmentI[] views) { AlignmentAnnotation[] annotations = null; @@ -479,28 +470,31 @@ public class EditCommand if (modifyVisibility) { // Rows are only removed or added to sequence object. - if (!insert) { + if (!insert) + { // remove rows tmp = command.seqs[s].getAnnotation(); - if (tmp!=null) { - int alen=tmp.length; - for (int aa =0; aa0) - System.arraycopy(annotations[a].annotations, - 0, temp, 0, copylen); //command.position); + int copylen = Math.min(command.position, + annotations[a].annotations.length); + if (copylen > 0) + System.arraycopy(annotations[a].annotations, 0, temp, 0, + copylen); // command.position); Annotation[] deleted = new Annotation[command.number]; - if (copylen>=command.position) { - copylen = Math.min(command.number, annotations[a].annotations.length-command.position); - if (copylen>0) + 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.number); @@ -729,12 +728,14 @@ public class EditCommand } 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); // aSize + 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); // aSize } } else @@ -744,17 +745,16 @@ public class EditCommand if (dSize > 0) { Annotation[] deleted = new Annotation[command.number]; - System.arraycopy(annotations[a].annotations, - command.position, deleted, 0, dSize); + System.arraycopy(annotations[a].annotations, command.position, + deleted, 0, dSize); command.deletedAnnotations.put(annotations[a].annotationId, - deleted); + deleted); tSize = Math.min(annotations[a].annotations.length, - command.position); + command.position); temp = new Annotation[tSize]; - System.arraycopy(annotations[a].annotations, - 0, temp, 0, tSize); + System.arraycopy(annotations[a].annotations, 0, temp, 0, tSize); } else { @@ -768,7 +768,7 @@ public class EditCommand } final void adjustFeatures(Edit command, int index, int i, int j, - boolean insert) + boolean insert) { SequenceI seq = command.seqs[index]; SequenceI sequence = seq.getDatasetSequence(); @@ -780,11 +780,11 @@ public class EditCommand if (insert) { if (command.editedFeatures != null - && command.editedFeatures.containsKey(seq)) + && command.editedFeatures.containsKey(seq)) { - sequence.setSequenceFeatures( - (SequenceFeature[]) command.editedFeatures.get(seq) - ); + sequence + .setSequenceFeatures((SequenceFeature[]) command.editedFeatures + .get(seq)); } return; @@ -849,23 +849,31 @@ public class EditCommand class Edit { public SequenceI[] oldds; + boolean fullAlignmentHeight = false; + Hashtable deletedAnnotationRows; + Hashtable deletedAnnotations; + Hashtable editedFeatures; + AlignmentI al; + int command; + char[][] string; + SequenceI[] seqs; + int[] alIndex; + int position, number; + char gapChar; - Edit(int command, - SequenceI[] seqs, - int position, - int number, - char gapChar) + Edit(int command, SequenceI[] seqs, int position, int number, + char gapChar) { this.command = command; this.seqs = seqs; @@ -874,11 +882,8 @@ public class EditCommand this.gapChar = gapChar; } - Edit(int command, - SequenceI[] seqs, - int position, - int number, - AlignmentI al) + Edit(int command, SequenceI[] seqs, int position, int number, + AlignmentI al) { this.gapChar = al.getGapCharacter(); this.command = command; @@ -896,12 +901,8 @@ public class EditCommand fullAlignmentHeight = (al.getHeight() == seqs.length); } - Edit(int command, - SequenceI[] seqs, - int position, - int number, - AlignmentI al, - String replace) + Edit(int command, SequenceI[] seqs, int position, int number, + AlignmentI al, String replace) { this.command = command; this.seqs = seqs; diff --git a/src/jalview/commands/OrderCommand.java b/src/jalview/commands/OrderCommand.java index b331690..6ea28ee 100644 --- a/src/jalview/commands/OrderCommand.java +++ b/src/jalview/commands/OrderCommand.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -21,17 +21,17 @@ package jalview.commands; import jalview.analysis.*; import jalview.datamodel.*; -public class OrderCommand - implements CommandI +public class OrderCommand implements CommandI { String description; + SequenceI[] seqs; + SequenceI[] seqs2; + AlignmentI al; - public OrderCommand(String description, - SequenceI[] seqs, - AlignmentI al) + public OrderCommand(String description, SequenceI[] seqs, AlignmentI al) { this.description = description; this.seqs = seqs; diff --git a/src/jalview/commands/RemoveGapColCommand.java b/src/jalview/commands/RemoveGapColCommand.java index a874f71..c5e12f5 100644 --- a/src/jalview/commands/RemoveGapColCommand.java +++ b/src/jalview/commands/RemoveGapColCommand.java @@ -1,33 +1,50 @@ -package jalview.commands; - /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +package jalview.commands; + +/* + * Jalview - A Sequence Alignment Editor and Viewer Copyright (C) 2007 AM + * Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 of the License, or (at your option) any later + * version. + * + * This program 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 + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ import jalview.datamodel.*; -public class RemoveGapColCommand - extends EditCommand +public class RemoveGapColCommand extends EditCommand { int columnsDeleted; - public RemoveGapColCommand(String description, - SequenceI[] seqs, - int start, int end, AlignmentI al) + + public RemoveGapColCommand(String description, SequenceI[] seqs, + int start, int end, AlignmentI al) { this.description = description; @@ -67,11 +84,8 @@ public class RemoveGapColCommand if (!delete && startCol > -1) { - this.appendEdit(DELETE_GAP, seqs, - startCol - columnsDeleted, - endCol - startCol, - al, - false,null); + this.appendEdit(DELETE_GAP, seqs, startCol - columnsDeleted, endCol + - startCol, al, false, null); columnsDeleted += (endCol - startCol); startCol = -1; @@ -81,25 +95,22 @@ public class RemoveGapColCommand if (delete && startCol > -1) { - //This is for empty columns at the - //end of the alignment + // This is for empty columns at the + // end of the alignment - this.appendEdit(DELETE_GAP, seqs, - startCol - columnsDeleted, - end - startCol + 1, - al, - false,null); + this.appendEdit(DELETE_GAP, seqs, startCol - columnsDeleted, end + - startCol + 1, al, false, null); columnsDeleted += (end - startCol + 1); } - performEdit(0,null); + performEdit(0, null); } public int getSize() { - //We're interested in the number of columns deleted, - //Not the number of sequence edits. + // We're interested in the number of columns deleted, + // Not the number of sequence edits. return columnsDeleted; } diff --git a/src/jalview/commands/RemoveGapsCommand.java b/src/jalview/commands/RemoveGapsCommand.java index 5639fa5..d2bd486 100644 --- a/src/jalview/commands/RemoveGapsCommand.java +++ b/src/jalview/commands/RemoveGapsCommand.java @@ -1,31 +1,48 @@ -package jalview.commands; - /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +package jalview.commands; + +/* + * Jalview - A Sequence Alignment Editor and Viewer Copyright (C) 2007 AM + * Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 of the License, or (at your option) any later + * version. + * + * This program 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 + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ import jalview.datamodel.*; -public class RemoveGapsCommand - extends EditCommand +public class RemoveGapsCommand extends EditCommand { - public RemoveGapsCommand(String description, - SequenceI[] seqs, AlignmentI al) + public RemoveGapsCommand(String description, SequenceI[] seqs, + AlignmentI al) { this.description = description; int width = 0; @@ -40,9 +57,8 @@ public class RemoveGapsCommand findGaps(seqs, 0, width, al); } - public RemoveGapsCommand(String description, - SequenceI[] seqs, - int start, int end, AlignmentI al) + public RemoveGapsCommand(String description, SequenceI[] seqs, int start, + int end, AlignmentI al) { this.description = description; findGaps(seqs, start, end, al); @@ -91,11 +107,8 @@ public class RemoveGapsCommand if (!delete && startCol > -1) { this.appendEdit(DELETE_GAP, new SequenceI[] - {seqs[s]}, - start + startCol - deletedCols, - endCol - startCol, - al, - false,null); + { seqs[s] }, start + startCol - deletedCols, endCol - startCol, + al, false, null); deletedCols += (endCol - startCol); startCol = -1; @@ -105,16 +118,13 @@ public class RemoveGapsCommand if (delete && startCol > -1) { this.appendEdit(DELETE_GAP, new SequenceI[] - {seqs[s]}, - start + startCol - deletedCols, - jSize - startCol, - al, - false,null); + { seqs[s] }, start + startCol - deletedCols, jSize - startCol, al, + false, null); } } - performEdit(0,null); + performEdit(0, null); } } diff --git a/src/jalview/commands/SlideSequencesCommand.java b/src/jalview/commands/SlideSequencesCommand.java index 9b9c99e..c8a5533 100644 --- a/src/jalview/commands/SlideSequencesCommand.java +++ b/src/jalview/commands/SlideSequencesCommand.java @@ -1,23 +1,21 @@ - /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ - + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.commands; import jalview.datamodel.*; @@ -26,11 +24,8 @@ public class SlideSequencesCommand extends EditCommand { boolean gapsInsertedBegin = false; - public SlideSequencesCommand(String description, - SequenceI[] seqsLeft, - SequenceI[] seqsRight, - int slideSize, - char gapChar) + public SlideSequencesCommand(String description, SequenceI[] seqsLeft, + SequenceI[] seqsRight, int slideSize, char gapChar) { this.description = description; @@ -49,12 +44,12 @@ public class SlideSequencesCommand extends EditCommand if (!gapsInsertedBegin) edits = new Edit[] - { new Edit(DELETE_GAP, seqsLeft, 0, slideSize, gapChar)}; + { new Edit(DELETE_GAP, seqsLeft, 0, slideSize, gapChar) }; else edits = new Edit[] - { new Edit(INSERT_GAP, seqsRight, 0, slideSize, gapChar)}; + { new Edit(INSERT_GAP, seqsRight, 0, slideSize, gapChar) }; - performEdit(0,null); + performEdit(0, null); } public boolean getGapsInsertedBegin() @@ -66,7 +61,7 @@ public class SlideSequencesCommand extends EditCommand { boolean same = false; - if(command.edits[0].seqs.length==edits[0].seqs.length) + if (command.edits[0].seqs.length == edits[0].seqs.length) { same = true; for (int i = 0; i < command.edits[0].seqs.length; i++) @@ -78,7 +73,7 @@ public class SlideSequencesCommand extends EditCommand } } - if(same) + if (same) { Edit[] temp = new Edit[command.edits.length + 1]; System.arraycopy(command.edits, 0, temp, 0, command.edits.length); @@ -89,5 +84,3 @@ public class SlideSequencesCommand extends EditCommand return same; } } - - diff --git a/src/jalview/commands/TrimRegionCommand.java b/src/jalview/commands/TrimRegionCommand.java index 4110bd1..30f813f 100644 --- a/src/jalview/commands/TrimRegionCommand.java +++ b/src/jalview/commands/TrimRegionCommand.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program 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 2 * of the License, or (at your option) any later version. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -23,10 +23,10 @@ import java.util.*; import jalview.datamodel.*; import jalview.util.*; -public class TrimRegionCommand - extends EditCommand +public class TrimRegionCommand extends EditCommand { public static String TRIM_LEFT = "TrimLeft"; + public static String TRIM_RIGHT = "TrimRight"; public ColumnSelection colSel = null; @@ -41,13 +41,9 @@ public class TrimRegionCommand int columnsDeleted; - public TrimRegionCommand(String description, - String command, - SequenceI[] seqs, - int column, - AlignmentI al, - ColumnSelection colSel, - SequenceGroup selectedRegion) + public TrimRegionCommand(String description, String command, + SequenceI[] seqs, int column, AlignmentI al, + ColumnSelection colSel, SequenceGroup selectedRegion) { this.description = description; this.selectionGroup = selectedRegion; @@ -62,8 +58,7 @@ public class TrimRegionCommand columnsDeleted = column; edits = new Edit[] - { - new Edit(CUT, seqs, 0, column, al)}; + { new Edit(CUT, seqs, 0, column, al) }; } else if (command.equalsIgnoreCase(TRIM_RIGHT)) { @@ -76,12 +71,11 @@ public class TrimRegionCommand columnsDeleted = width - 1; edits = new Edit[] - { - new Edit(CUT, seqs, column + 1, width, al)}; + { new Edit(CUT, seqs, column + 1, width, al) }; } - //We need to keep a record of the sequence start - //in order to restore the state after a redo + // We need to keep a record of the sequence start + // in order to restore the state after a redo int i, isize = edits[0].seqs.length; start = new int[isize]; for (i = 0; i < isize; i++) @@ -89,7 +83,7 @@ public class TrimRegionCommand start[i] = edits[0].seqs[i].getStart(); } - performEdit(0,null); + performEdit(0, null); } void cut(Edit command) @@ -99,13 +93,13 @@ public class TrimRegionCommand { if (command.position == 0) { - //This is a TRIM_LEFT command + // This is a TRIM_LEFT command column = command.seqs[j].findPosition(command.number); command.seqs[j].setStart(column); } else { - //This is a TRIM_RIGHT command + // This is a TRIM_RIGHT command column = command.seqs[j].findPosition(command.position) - 1; command.seqs[j].setEnd(column); } @@ -124,7 +118,7 @@ public class TrimRegionCommand else { deletedHiddenColumns = colSel.compensateForEdit(command.position, - command.number); + command.number); if (selectionGroup != null) { selectionGroup.adjustForRemoveRight(command.position); @@ -144,8 +138,8 @@ public class TrimRegionCommand } else { - column = command.seqs[j] - .findPosition(command.number + command.position) - 1; + column = command.seqs[j].findPosition(command.number + + command.position) - 1; command.seqs[j].setEnd(column); } } @@ -155,7 +149,7 @@ public class TrimRegionCommand colSel.compensateForEdit(0, -command.number); if (selectionGroup != null) { - selectionGroup.adjustForRemoveLeft( -command.number); + selectionGroup.adjustForRemoveLeft(-command.number); } } diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index 6c6c26e..3b59249 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.datamodel; import java.util.Enumeration; @@ -13,25 +31,29 @@ import jalview.util.MapList; public class AlignedCodonFrame { /** - * array of nucleotide positions for aligned codons at column of aligned proteins. + * array of nucleotide positions for aligned codons at column of aligned + * proteins. */ public int[][] codons = null; + /** - * width of protein sequence alignement - * implicit assertion that codons.length >= aaWidth + * width of protein sequence alignement implicit assertion that codons.length >= + * aaWidth */ - public int aaWidth=0; + public int aaWidth = 0; + /** * initialise codon frame with a nominal alignment width + * * @param aWidth */ public AlignedCodonFrame(int aWidth) { - if (aWidth<=0) - { - codons=null; + if (aWidth <= 0) + { + codons = null; return; - } + } codons = new int[aWidth][]; for (int res = 0; res < aWidth; res++) codons[res] = null; @@ -39,6 +61,7 @@ public class AlignedCodonFrame /** * ensure that codons array is at least as wide as aslen residues + * * @param aslen * @return (possibly newly expanded) codon array */ @@ -57,29 +80,37 @@ public class AlignedCodonFrame } return codons; } + /** - * @return width of aligned translated amino acid residues + * @return width of aligned translated amino acid residues */ public int getaaWidth() { return aaWidth; } + /** - * TODO: not an ideal solution - we reference the aligned amino acid sequences in order to make insertions on them - * Better would be dnaAlignment and aaAlignment reference.... + * TODO: not an ideal solution - we reference the aligned amino acid sequences + * in order to make insertions on them Better would be dnaAlignment and + * aaAlignment reference.... */ - Vector a_aaSeqs=new Vector(); + Vector a_aaSeqs = new Vector(); + /** - * increase aaWidth by one and insert a new aligned codon position space at aspos. + * increase aaWidth by one and insert a new aligned codon position space at + * aspos. + * * @param aspos */ public void insertAAGap(int aspos, char gapCharacter) - { - // this aa appears before the aligned codons at aspos - so shift them in each pair of mapped sequences + { + // this aa appears before the aligned codons at aspos - so shift them in + // each pair of mapped sequences aaWidth++; - if (a_aaSeqs!=null) + if (a_aaSeqs != null) { - // we actually have to modify the aligned sequences here, so use the a_aaSeqs vector + // we actually have to modify the aligned sequences here, so use the + // a_aaSeqs vector Enumeration sq = a_aaSeqs.elements(); while (sq.hasMoreElements()) { @@ -87,11 +118,11 @@ public class AlignedCodonFrame } } checkCodonFrameWidth(aspos); - if (aspos