From: gmungoc Date: Fri, 24 May 2019 10:31:34 +0000 (+0100) Subject: Merge branch 'develop' into trialMerge X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8946f41687f4c822ac8d15ee8551f23f156735c4;p=jalview.git Merge branch 'develop' into trialMerge Conflicts: .classpath .project .settings/org.eclipse.jdt.core.prefs .settings/org.eclipse.jdt.groovy.core.prefs .settings/org.eclipse.jdt.ui.prefs build.xml src/MCview/AppletPDBCanvas.java src/MCview/Atom.java src/MCview/PDBCanvas.java src/jalview/appletgui/EmbmenuFrame.java src/jalview/appletgui/OverviewPanel.java src/jalview/appletgui/SeqPanel.java src/jalview/bin/Jalview.java src/jalview/ext/paradise/Annotate3D.java src/jalview/gui/AlignFrame.java src/jalview/gui/Desktop.java src/jalview/gui/FeatureRenderer.java src/jalview/gui/FeatureTypeSettings.java src/jalview/io/FileLoader.java src/jalview/jbgui/GDesktop.java src/jalview/util/ImageMaker.java src/jalview/util/Platform.java --- 8946f41687f4c822ac8d15ee8551f23f156735c4 diff --cc .classpath index 004d432,0000000..430d9e6 mode 100644,000000..100644 --- a/.classpath +++ b/.classpath @@@ -1,74 -1,0 +1,183 @@@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + - - ++ + diff --cc .project index 6c40472,0000000..d4d0c20 mode 100644,000000..100644 --- a/.project +++ b/.project @@@ -1,37 -1,0 +1,23 @@@ + + - Jalview Release 2.7-old ++ Jalview with gradle build + - - ++ ++ ++ org.eclipse.jdt.core.javanature ++ org.eclipse.jdt.groovy.core.groovyNature ++ org.eclipse.buildship.core.gradleprojectnature ++ + + + org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - ++ + + - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Jalview Release indices [Builder].launch - - ++ org.eclipse.buildship.core.gradleprojectbuilder ++ + + - - org.eclipse.jdt.groovy.core.groovyNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - de.tud.st.ispace.builder.ISpaceNature - org.eclipse.jem.beaninfo.BeanInfoNature - ++ ++ + diff --cc .settings/org.eclipse.jdt.core.prefs index 32ad05c,0000000..604d902 mode 100644,000000..100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@@ -1,421 -1,0 +1,298 @@@ +eclipse.preferences.version=1 - org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled - org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore - org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull - org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= - org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault - org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= - org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable - org.eclipse.jdt.core.compiler.annotation.nullable.secondary= - org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate - org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error - org.eclipse.jdt.core.compiler.problem.autoboxing=ignore - org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning - org.eclipse.jdt.core.compiler.problem.deadCode=warning - org.eclipse.jdt.core.compiler.problem.deprecation=warning - org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled - org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning - org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error - org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore - org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore - org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled - org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore - org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning - org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning - org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning - org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning - org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled - org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning - org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning - org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore - org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore - org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning - org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore - org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore - org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled - org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore - org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore - org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled - org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning - org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore - org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning - org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning - org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore - org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning - org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning - org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error - org.eclipse.jdt.core.compiler.problem.nullReference=warning - org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error - org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning - org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning - org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore - org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning - org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore - org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore - org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore - org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning - org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning - org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore - org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore - org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore - org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore - org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore - org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled - org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning - org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled - org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled - org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled - org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning - org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning - org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled - org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning - org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning - org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore - org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning - org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore - org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore - org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore - org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore - org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled - org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled - org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled - org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore - org.eclipse.jdt.core.compiler.problem.unusedImport=warning - org.eclipse.jdt.core.compiler.problem.unusedLabel=warning - org.eclipse.jdt.core.compiler.problem.unusedLocal=warning - org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore - org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore - org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled - org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled - org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled - org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning - org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore - org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning - org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 - org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false - org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false - org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false - org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=52 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 - org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 - org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 - org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 - org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 - org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 - org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=next_line_on_wrap +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line - org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false - org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false - org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=4 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false - org.eclipse.jdt.core.formatter.indentation.size=2 - org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert ++org.eclipse.jdt.core.formatter.indentation.size=8 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false - org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false - org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false - org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=76 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 - org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines - org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false - org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true - org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true - org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --cc src/MCview/AppletPDBCanvas.java index 0000000,c6553f8..bc36d9e mode 000000,100644..100644 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@@ -1,0 -1,1264 +1,6 @@@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ + package MCview; + -import jalview.analysis.AlignSeq; -import jalview.appletgui.AlignmentPanel; -import jalview.appletgui.FeatureRenderer; -import jalview.appletgui.SequenceRenderer; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.io.DataSourceType; -import jalview.io.StructureFile; -import jalview.renderer.seqfeatures.FeatureColourFinder; -import jalview.structure.AtomSpec; -import jalview.structure.StructureListener; -import jalview.structure.StructureMapping; -import jalview.structure.StructureSelectionManager; -import jalview.util.MessageManager; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.event.InputEvent;import java.awt.Font; -import java.awt.Graphics; -import java.awt.Image; -// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug -import java.awt.Panel; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.io.PrintStream; -import java.util.List; -import java.util.Vector; - -public class AppletPDBCanvas extends Panel - implements MouseListener, MouseMotionListener, StructureListener ++public class AppletPDBCanvas + { + - 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 StructureFile 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; - - 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, DataSourceType protocol) - - { - this.ap = ap; - this.pdbentry = pdbentry; - this.sequence = seq; - - ssm = StructureSelectionManager - .getStructureSelectionManager(ap.av.applet); - - try - { - pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol, null); - - if (protocol == DataSourceType.PASTE) - { - pdbentry.setFile("INLINE" + pdb.getId()); - } - - } catch (Exception ex) - { - ex.printStackTrace(); - return; - } - - pdbentry.setId(pdb.getId()); - - ssm.addStructureViewerListener(this); - - colourBySequence(); - - float max = -10; - int maxchain = -1; - int pdbstart = 0; - int pdbend = 0; - int seqstart = 0; - int seqend = 0; - - // JUST DEAL WITH ONE SEQUENCE FOR NOW - SequenceI sequence = seq[0]; - - for (int i = 0; i < pdb.getChains().size(); i++) - { - - mappingDetails.append("\n\nPDB Sequence is :\nSequence = " - + pdb.getChains().elementAt(i).sequence - .getSequenceAsString()); - mappingDetails.append("\nNo of residues = " - + pdb.getChains().elementAt(i).residues.size() + "\n\n"); - - // Now lets compare the sequences to get - // the start and end points. - // Align the sequence to the pdb - // TODO: DNa/Pep switch - AlignSeq as = new AlignSeq(sequence, - pdb.getChains().elementAt(i).sequence, - pdb.getChains().elementAt(i).isNa ? AlignSeq.DNA - : AlignSeq.PEP); - as.calcScoreMatrix(); - as.traceAlignment(); - PrintStream ps = new PrintStream(System.out) - { - @Override - public void print(String x) - { - mappingDetails.append(x); - } - - @Override - public void println() - { - mappingDetails.append("\n"); - } - }; - - as.printAlignment(ps); - - if (as.maxscore > max) - { - max = as.maxscore; - maxchain = i; - - pdbstart = as.seq2start; - 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); - } - - mainchain = pdb.getChains().elementAt(maxchain); - - mainchain.pdbstart = pdbstart; - mainchain.pdbend = pdbend; - mainchain.seqstart = seqstart; - mainchain.seqend = seqend; - mainchain.isVisible = true; - // mainchain.makeExactMapping(maxAlignseq, sequence); - // mainchain.transferRESNUMFeatures(sequence, null); - this.pdb = pdb; - this.prefsize = new Dimension(getSize().width, getSize().height); - - // 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); - } - else - { - idmat.addElement(i, j, 1); - objmat.addElement(i, j, 1); - } - } - } - - addMouseMotionListener(this); - addMouseListener(this); - - addKeyListener(new KeyAdapter() - { - @Override - public void keyPressed(KeyEvent evt) - { - doKeyPressed(evt); - } - }); - - findCentre(); - findWidth(); - - setupBonds(); - - scale = findScale(); - } - - Vector visiblebonds; - - void setupBonds() - { - seqColoursReady = false; - // Sort the bonds by z coord - visiblebonds = new Vector(); - - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - if (pdb.getChains().elementAt(ii).isVisible) - { - Vector tmp = pdb.getChains().elementAt(ii).bonds; - - for (int i = 0; i < tmp.size(); i++) - { - visiblebonds.addElement(tmp.elementAt(i)); - } - } - } - seqColoursReady = true; - colourBySequence(); - redrawneeded = true; - repaint(); - } - - public void findWidth() - { - float[] max = new float[3]; - float[] 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 ii = 0; ii < pdb.getChains().size(); ii++) - { - if (pdb.getChains().elementAt(ii).isVisible) - { - Vector bonds = pdb.getChains().elementAt(ii).bonds; - - for (Bond tmp : bonds) - { - if (tmp.start[0] >= max[0]) - { - max[0] = tmp.start[0]; - } - - if (tmp.start[1] >= max[1]) - { - max[1] = tmp.start[1]; - } - - if (tmp.start[2] >= max[2]) - { - max[2] = tmp.start[2]; - } - - if (tmp.start[0] <= min[0]) - { - min[0] = tmp.start[0]; - } - - if (tmp.start[1] <= min[1]) - { - min[1] = tmp.start[1]; - } - - if (tmp.start[2] <= min[2]) - { - min[2] = tmp.start[2]; - } - - if (tmp.end[0] >= max[0]) - { - max[0] = tmp.end[0]; - } - - if (tmp.end[1] >= max[1]) - { - max[1] = tmp.end[1]; - } - - if (tmp.end[2] >= max[2]) - { - max[2] = tmp.end[2]; - } - - if (tmp.end[0] <= min[0]) - { - min[0] = tmp.end[0]; - } - - if (tmp.end[1] <= min[1]) - { - min[1] = tmp.end[1]; - } - - if (tmp.end[2] <= min[2]) - { - min[2] = tmp.end[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; - int width; - int 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 / (1.5d * maxwidth)); - } - - public void findCentre() - { - float xtot = 0; - float ytot = 0; - float ztot = 0; - - int bsize = 0; - - // Find centre coordinate - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - if (pdb.getChains().elementAt(ii).isVisible) - { - Vector bonds = pdb.getChains().elementAt(ii).bonds; - - bsize += bonds.size(); - - for (Bond b : bonds) - { - xtot = xtot + b.start[0] + b.end[0]; - ytot = ytot + b.start[1] + b.end[1]; - ztot = ztot + b.start[2] + b.end[2]; - } - } - } - - centre[0] = xtot / (2 * (float) bsize); - centre[1] = ytot / (2 * (float) bsize); - centre[2] = ztot / (2 * (float) bsize); - } - - @Override - public void paint(Graphics g) - { - - if (errorLoading) - { - g.setColor(Color.white); - g.fillRect(0, 0, getSize().width, getSize().height); - g.setColor(Color.black); - g.setFont(new Font("Verdana", Font.BOLD, 14)); - g.drawString(MessageManager.getString("label.error_loading_pdb_data"), - 50, getSize().height / 2); - return; - } - - if (!seqColoursReady) - { - g.setColor(Color.black); - g.setFont(new Font("Verdana", Font.BOLD, 14)); - g.drawString(MessageManager.getString("label.fetching_pdb_data"), 50, - getSize().height / 2); - return; - } - - // Only create the image at the beginning - - // this saves much memory usage - if ((img == null) || (prefsize.width != getSize().width) - || (prefsize.height != getSize().height)) - { - - try - { - prefsize.width = getSize().width; - prefsize.height = getSize().height; - - scale = findScale(); - img = createImage(prefsize.width, prefsize.height); - ig = img.getGraphics(); - - redrawneeded = true; - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - - if (redrawneeded) - { - drawAll(ig, prefsize.width, prefsize.height); - redrawneeded = false; - } - if (appletToolTip != null) - { - ig.setColor(Color.red); - ig.drawString(appletToolTip, toolx, tooly); - } - - g.drawImage(img, 0, 0, this); - - pdbAction = false; - } - - public void drawAll(Graphics g, int width, int height) - { - ig.setColor(Color.black); - ig.fillRect(0, 0, width, height); - drawScene(ig); - drawLabels(ig); - } - - public void setColours(jalview.schemes.ColourSchemeI cs) - { - bysequence = false; - pdb.setColours(cs); - redrawneeded = true; - repaint(); - } - - // This method has been taken out of PDBChain to allow - // Applet and Application specific sequence renderers to be used - void colourBySequence() - { - SequenceRenderer sr = new SequenceRenderer(ap.av); - - StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile()); - - boolean showFeatures = false; - if (ap.av.isShowSequenceFeatures()) - { - if (fr == null) - { - fr = new jalview.appletgui.FeatureRenderer(ap.av); - } - - fr.transferSettings(ap.getFeatureRenderer()); - - showFeatures = true; - } - - FeatureColourFinder finder = new FeatureColourFinder(fr); - - PDBChain chain; - if (bysequence && pdb != null) - { - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - chain = pdb.getChains().elementAt(ii); - - for (int i = 0; i < chain.bonds.size(); i++) - { - Bond tmp = chain.bonds.elementAt(i); - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; - if (chain != mainchain) - { - continue; - } - - for (int s = 0; s < sequence.length; s++) - { - for (int m = 0; m < mapping.length; m++) - { - if (mapping[m].getSequence() == sequence[s]) - { - int pos = mapping[m].getSeqPos(tmp.at1.resNumber) - 1; - if (pos > 0) - { - pos = sequence[s].findIndex(pos); - tmp.startCol = sr.getResidueColour(sequence[s], pos, - finder); - } - pos = mapping[m].getSeqPos(tmp.at2.resNumber) - 1; - if (pos > 0) - { - pos = sequence[s].findIndex(pos); - tmp.endCol = sr.getResidueColour(sequence[s], pos, - finder); - } - } - } - } - } - } - } - } - - Zsort zsort; - - public void drawScene(Graphics g) - { - if (zbuffer) - { - if (zsort == null) - { - zsort = new Zsort(); - } - - zsort.sort(visiblebonds); - } - - Bond tmpBond = null; - for (int i = 0; i < visiblebonds.size(); i++) - { - tmpBond = 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)); - - 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; - - if (depthcue && !bymolecule) - { - if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) - { - g.setColor(tmpBond.startCol.darker().darker()); - drawLine(g, xstart, ystart, xmid, ymid); - - g.setColor(tmpBond.endCol.darker().darker()); - drawLine(g, xmid, ymid, xend, yend); - } - else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) - { - g.setColor(tmpBond.startCol.darker()); - drawLine(g, xstart, ystart, xmid, ymid); - - g.setColor(tmpBond.endCol.darker()); - drawLine(g, xmid, ymid, xend, yend); - } - else - { - g.setColor(tmpBond.startCol); - drawLine(g, xstart, ystart, xmid, ymid); - - g.setColor(tmpBond.endCol); - drawLine(g, xmid, ymid, xend, yend); - } - - } - else if (depthcue && bymolecule) - { - if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) - { - g.setColor(Color.green.darker().darker()); - drawLine(g, xstart, ystart, xend, yend); - } - else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) - { - g.setColor(Color.green.darker()); - drawLine(g, xstart, ystart, xend, yend); - } - else - { - g.setColor(Color.green); - drawLine(g, xstart, ystart, xend, yend); - } - } - else if (!depthcue && !bymolecule) - { - g.setColor(tmpBond.startCol); - drawLine(g, xstart, ystart, xmid, ymid); - g.setColor(tmpBond.endCol); - drawLine(g, xmid, ymid, xend, yend); - } - else - { - drawLine(g, xstart, ystart, xend, yend); - } - - if (highlightBond1 != null && highlightBond1 == tmpBond) - { - g.setColor(Color.white); - drawLine(g, xmid, ymid, xend, yend); - } - - if (highlightBond2 != null && highlightBond2 == tmpBond) - { - g.setColor(Color.white); - drawLine(g, xstart, ystart, xmid, ymid); - } - - } - } - - public void drawLine(Graphics g, int x1, int y1, int x2, int y2) - { - if (!wire) - { - 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); - g.drawLine(x1, y1 - 1, x2, y2 - 1); - } - else - { - g.setColor(g.getColor().brighter()); - g.drawLine(x1, y1, x2, y2); - g.drawLine(x1 + 1, y1, x2 + 1, y2); - g.drawLine(x1 - 1, y1, x2 - 1, y2); - } - } - else - { - g.drawLine(x1, y1, x2, y2); - } - } - - public Dimension minimumsize() - { - return prefsize; - } - - public Dimension preferredsize() - { - return prefsize; - } - - public void doKeyPressed(KeyEvent evt) - { - if (evt.getKeyCode() == KeyEvent.VK_UP) - { - scale = (float) (scale * 1.1); - redrawneeded = true; - repaint(); - } - else if (evt.getKeyCode() == KeyEvent.VK_DOWN) - { - scale = (float) (scale * 0.9); - redrawneeded = true; - repaint(); - } - } - - @Override - public void mousePressed(MouseEvent e) - { - pdbAction = true; - Atom fatom = findAtom(e.getX(), e.getY()); - if (fatom != null) - { - fatom.isSelected = !fatom.isSelected; - - redrawneeded = true; - repaint(); - if (foundchain != -1) - { - PDBChain chain = pdb.getChains().elementAt(foundchain); - if (chain == mainchain) - { - if (fatom.alignmentMapping != -1) - { - if (highlightRes == null) - { - highlightRes = new Vector(); - } - - final String atomString = Integer - .toString(fatom.alignmentMapping); - if (highlightRes.contains(atomString)) - { - highlightRes.removeElement(atomString); - } - else - { - highlightRes.addElement(atomString); - } - } - } - } - - } - mx = e.getX(); - my = e.getY(); - omx = mx; - omy = my; - dragging = false; - } - - @Override - public void mouseMoved(MouseEvent e) - { - pdbAction = true; - if (highlightBond1 != null) - { - highlightBond1.at2.isSelected = false; - highlightBond2.at1.isSelected = false; - highlightBond1 = null; - highlightBond2 = null; - } - - Atom fatom = findAtom(e.getX(), e.getY()); - - PDBChain chain = null; - if (foundchain != -1) - { - chain = pdb.getChains().elementAt(foundchain); - if (chain == mainchain) - { - mouseOverStructure(fatom.resNumber, chain.id); - } - } - - if (fatom != null) - { - toolx = e.getX(); - tooly = e.getY(); - - appletToolTip = chain.id + ":" + fatom.resNumber + " " - + fatom.resName; - redrawneeded = true; - repaint(); - } - else - { - mouseOverStructure(-1, chain != null ? chain.id : null); - appletToolTip = null; - redrawneeded = true; - repaint(); - } - } - - @Override - public void mouseClicked(MouseEvent e) - { - } - - @Override - public void mouseEntered(MouseEvent e) - { - } - - @Override - public void mouseExited(MouseEvent e) - { - } - - @Override - public void mouseDragged(MouseEvent evt) - { - int x = evt.getX(); - int y = evt.getY(); - mx = x; - my = y; - - MCMatrix objmat = new MCMatrix(3, 3); - objmat.setIdentity(); - - if ((evt.getModifiersEx() & InputEvent.META_DOWN_MASK) != 0) - { - objmat.rotatez(((mx - omx))); - } - else - { - objmat.rotatex(((omy - my))); - objmat.rotatey(((omx - mx))); - } - - // Alter the bonds - for (PDBChain chain : pdb.getChains()) - { - for (Bond tmpBond : chain.bonds) - { - // Translate the bond so the centre is 0,0,0 - tmpBond.translate(-centre[0], -centre[1], -centre[2]); - - // Now apply the rotation matrix - tmpBond.start = objmat.vectorMultiply(tmpBond.start); - tmpBond.end = objmat.vectorMultiply(tmpBond.end); - - // Now translate back again - tmpBond.translate(centre[0], centre[1], centre[2]); - } - } - - objmat = null; - - omx = mx; - omy = my; - - dragging = true; - - redrawneeded = true; - - repaint(); - } - - @Override - public void mouseReleased(MouseEvent evt) - { - dragging = false; - return; - } - - void drawLabels(Graphics g) - { - - for (PDBChain chain : pdb.getChains()) - { - if (chain.isVisible) - { - for (Bond tmpBond : chain.bonds) - { - if (tmpBond.at1.isSelected) - { - labelAtom(g, tmpBond, 1); - } - - if (tmpBond.at2.isSelected) - { - labelAtom(g, tmpBond, 2); - } - } - } - } - } - - public void labelAtom(Graphics g, Bond b, int n) - { - g.setFont(font); - - 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)); - - g.setColor(Color.red); - g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart); - } - - 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)); - - g.setColor(Color.red); - g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart); - } - } - - int foundchain = -1; - - public Atom findAtom(int x, int y) - { - Atom fatom = null; - - foundchain = -1; - - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - PDBChain chain = pdb.getChains().elementAt(ii); - int truex; - Bond tmpBond = null; - - if (chain.isVisible) - { - Vector bonds = pdb.getChains().elementAt(ii).bonds; - - for (int i = 0; i < bonds.size(); i++) - { - tmpBond = bonds.elementAt(i); - - 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)); - - if (Math.abs(truey - y) <= 2) - { - fatom = tmpBond.at1; - foundchain = ii; - break; - } - } - } - - // Still here? Maybe its the last bond - - 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)); - - if (Math.abs(truey - y) <= 2) - { - fatom = tmpBond.at2; - foundchain = ii; - break; - } - } - - } - - if (fatom != null) // )&& chain.ds != null) - { - chain = pdb.getChains().elementAt(foundchain); - } - } - - return fatom; - } - - @Override - public void update(Graphics g) - { - paint(g); - } - - public void highlightRes(int ii) - { - if (!seqColoursReady) - { - return; - } - - if (highlightRes != null && highlightRes.contains((ii - 1) + "")) - { - return; - } - - int index = -1; - Bond tmpBond; - for (index = 0; index < mainchain.bonds.size(); index++) - { - tmpBond = mainchain.bonds.elementAt(index); - if (tmpBond.at1.alignmentMapping == ii - 1) - { - if (highlightBond1 != null) - { - highlightBond1.at2.isSelected = false; - } - - if (highlightBond2 != null) - { - highlightBond2.at1.isSelected = false; - } - - highlightBond1 = null; - highlightBond2 = null; - - if (index > 0) - { - highlightBond1 = mainchain.bonds.elementAt(index - 1); - highlightBond1.at2.isSelected = true; - } - - if (index != mainchain.bonds.size()) - { - highlightBond2 = mainchain.bonds.elementAt(index); - highlightBond2.at1.isSelected = true; - } - - break; - } - } - - redrawneeded = true; - repaint(); - } - - public void setAllchainsVisible(boolean b) - { - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - PDBChain chain = pdb.getChains().elementAt(ii); - chain.isVisible = b; - } - mainchain.isVisible = true; - findCentre(); - setupBonds(); - } - - // //////////////////////////////// - // /StructureListener - @Override - public String[] getStructureFiles() - { - return new String[] { pdbentry.getFile() }; - } - - String lastMessage; - - public void mouseOverStructure(int pdbResNum, String chain) - { - if (lastMessage == null || !lastMessage.equals(pdbResNum + chain)) - { - ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile()); - } - - lastMessage = pdbResNum + chain; - } - - StringBuffer resetLastRes = new StringBuffer(); - - StringBuffer eval = new StringBuffer(); - - /** - * Highlight the specified atoms in the structure. - * - * @param atoms - */ - @Override - public void highlightAtoms(List atoms) - { - if (!seqColoursReady) - { - return; - } - for (AtomSpec atom : atoms) - { - int atomIndex = atom.getAtomIndex(); - - if (highlightRes != null - && highlightRes.contains((atomIndex - 1) + "")) - { - continue; - } - - highlightAtom(atomIndex); - } - - redrawneeded = true; - repaint(); - } - - /** - * @param atomIndex - */ - protected void highlightAtom(int atomIndex) - { - int index = -1; - Bond tmpBond; - for (index = 0; index < mainchain.bonds.size(); index++) - { - tmpBond = mainchain.bonds.elementAt(index); - if (tmpBond.at1.atomIndex == atomIndex) - { - if (highlightBond1 != null) - { - highlightBond1.at2.isSelected = false; - } - - if (highlightBond2 != null) - { - highlightBond2.at1.isSelected = false; - } - - highlightBond1 = null; - highlightBond2 = null; - - if (index > 0) - { - highlightBond1 = mainchain.bonds.elementAt(index - 1); - highlightBond1.at2.isSelected = true; - } - - if (index != mainchain.bonds.size()) - { - highlightBond2 = mainchain.bonds.elementAt(index); - highlightBond2.at1.isSelected = true; - } - - break; - } - } - } - - public Color getColour(int atomIndex, int pdbResNum, String chain, - String pdbfile) - { - return Color.white; - // if (!pdbfile.equals(pdbentry.getFile())) - // return null; - - // return new Color(viewer.getAtomArgb(atomIndex)); - } - - @Override - public void updateColours(Object source) - { - colourBySequence(); - redrawneeded = true; - repaint(); - } - - @Override - public void releaseReferences(Object svl) - { - // TODO Auto-generated method stub - - } - - @Override - public boolean isListeningFor(SequenceI seq) - { - if (sequence != null) - { - for (SequenceI s : sequence) - { - if (s == seq) - { - return true; - } - } - } - return false; - } + } diff --cc src/MCview/Atom.java index 0000000,a2ce2ae..eb91e4e mode 000000,100755..100644 --- a/src/MCview/Atom.java +++ b/src/MCview/Atom.java @@@ -1,0 -1,136 +1,6 @@@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ + package MCview; + -import jalview.schemes.ResidueProperties; - -import java.awt.Color; - + 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; - - /** - * this is a temporary value - designed to store the position in sequence that - * this atom corresponds to after aligning the chain to a SequenceI object. Do - * not rely on its value being correct when visualizing sequence colourings on - * the structure - use the StructureSelectionManager's mapping instead. - */ - public int alignmentMapping = -1; - - public int atomIndex; - - public float occupancy = 0; - - public float tfactor = 0; - - // need these if we ever want to export Atom data - // public boolean tfacset=true,occset=true; - public boolean isSelected = false; - - public Atom(String str) - { - atomIndex = Integer.parseInt(str.substring(6, 11).trim()); - - name = str.substring(12, 15).trim(); - - resName = str.substring(17, 20); - // JAL-1828 treat MSE Selenomethionine as MET (etc) - resName = ResidueProperties.getCanonicalAminoAcid(resName); - - chain = str.substring(21, 22); - - resNumber = Integer.parseInt(str.substring(22, 26).trim()); - resNumIns = str.substring(22, 27).trim(); - insCode = str.substring(26, 27).charAt(0); - this.x = (Float.valueOf(str.substring(30, 38).trim()).floatValue()); - this.y = (Float.valueOf(str.substring(38, 46).trim()).floatValue()); - this.z = (Float.valueOf(str.substring(47, 55).trim()).floatValue()); - // optional entries - see JAL-730 - String tm = str.substring(54, 60).trim(); - if (tm.length() > 0) - { - occupancy = (Float.valueOf(tm)).floatValue(); - } - else - { - occupancy = 1f; // default occupancy - // see note above: occset=false; - } - tm = str.substring(60, 66).trim(); - if (tm.length() > 0) - { - tfactor = (Float.valueOf(tm).floatValue()); - } - else - { - tfactor = 1f; - // see note above: tfacset=false; - } - } - - @Override - public boolean equals(Object that) - { - if (this == that || that == null) - { - return true; - } - if (that instanceof Atom) - { - Atom other = (Atom) that; - return other.resName.equals(this.resName) - && other.resNumber == this.resNumber - && other.resNumIns.equals(this.resNumIns) - && other.chain.equals(this.chain); - } - return false; - } + - public Atom(float x, float y, float z) - { - this.x = x; - this.y = y; - this.z = z; - } + } diff --cc src/MCview/PDBCanvas.java index 0000000,a34e574..c49ab09 mode 000000,100644..100644 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@@ -1,0 -1,1223 +1,6 @@@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ + package MCview; + -import jalview.analysis.AlignSeq; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.gui.AlignmentPanel; -import jalview.gui.FeatureRenderer; -import jalview.gui.SequenceRenderer; -import jalview.io.DataSourceType; -import jalview.io.StructureFile; -import jalview.renderer.seqfeatures.FeatureColourFinder; -import jalview.structure.AtomSpec; -import jalview.structure.StructureListener; -import jalview.structure.StructureMapping; -import jalview.structure.StructureSelectionManager; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.event.InputEvent;import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug -import java.awt.Image; -import java.awt.RenderingHints; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.io.PrintStream; -import java.util.List; -import java.util.Vector; - -import javax.swing.JPanel; -import javax.swing.ToolTipManager; - -public class PDBCanvas extends JPanel - implements MouseListener, MouseMotionListener, StructureListener ++public class PDBCanvas + { - boolean redrawneeded = true; - - int omx = 0; - - int mx = 0; - - int omy = 0; - - int my = 0; - - public StructureFile 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; - - final StringBuffer mappingDetails = new StringBuffer(); - - PDBChain mainchain; - - Vector highlightRes; - - boolean pdbAction = false; - - boolean seqColoursReady = false; - - jalview.renderer.seqfeatures.FeatureRenderer fr; - - Color backgroundColour = Color.black; - - AlignmentPanel ap; - - StructureSelectionManager ssm; - - String errorMessage; - - void init(PDBEntry pdbentry, SequenceI[] seq, String[] chains, - AlignmentPanel ap, DataSourceType protocol) - { - this.ap = ap; - this.pdbentry = pdbentry; - this.sequence = seq; - - ssm = ap.av.getStructureSelectionManager(); - - try - { - pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol, - ap.alignFrame); - - if (protocol.equals(jalview.io.DataSourceType.PASTE)) - { - pdbentry.setFile("INLINE" + pdb.getId()); - } - - } catch (Exception ex) - { - ex.printStackTrace(); - return; - } - - if (pdb == null) - { - errorMessage = "Error loading file: " + pdbentry.getId(); - return; - } - pdbentry.setId(pdb.getId()); - - ssm.addStructureViewerListener(this); - - colourBySequence(); - - float max = -10; - int maxchain = -1; - int pdbstart = 0; - int pdbend = 0; - int seqstart = 0; - int seqend = 0; - - // JUST DEAL WITH ONE SEQUENCE FOR NOW - SequenceI sequence = seq[0]; - - for (int i = 0; i < pdb.getChains().size(); i++) - { - - mappingDetails.append("\n\nPDB Sequence is :\nSequence = " - + pdb.getChains().elementAt(i).sequence - .getSequenceAsString()); - mappingDetails.append("\nNo of residues = " - + pdb.getChains().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, - pdb.getChains().elementAt(i).sequence, "pep"); - as.calcScoreMatrix(); - as.traceAlignment(); - PrintStream ps = new PrintStream(System.out) - { - @Override - public void print(String x) - { - mappingDetails.append(x); - } - - @Override - public void println() - { - mappingDetails.append("\n"); - } - }; - - as.printAlignment(ps); - - if (as.maxscore > max) - { - max = as.maxscore; - maxchain = i; - - pdbstart = as.seq2start; - 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); - } - - mainchain = pdb.getChains().elementAt(maxchain); - - mainchain.pdbstart = pdbstart; - mainchain.pdbend = pdbend; - mainchain.seqstart = seqstart; - mainchain.seqend = seqend; - mainchain.isVisible = true; - - this.pdb = pdb; - this.prefsize = new Dimension(getSize().width, getSize().height); - - addMouseMotionListener(this); - addMouseListener(this); - - addKeyListener(new KeyAdapter() - { - @Override - public void keyPressed(KeyEvent evt) - { - keyPressed(evt); - } - }); - - findCentre(); - findWidth(); - - setupBonds(); - - scale = findScale(); - - ToolTipManager.sharedInstance().registerComponent(this); - ToolTipManager.sharedInstance().setInitialDelay(0); - ToolTipManager.sharedInstance().setDismissDelay(10000); - } - - Vector visiblebonds; - - void setupBonds() - { - seqColoursReady = false; - // Sort the bonds by z coord - visiblebonds = new Vector(); - - for (PDBChain chain : pdb.getChains()) - { - if (chain.isVisible) - { - for (Bond bond : chain.bonds) - { - visiblebonds.addElement(bond); - } - } - } - - updateSeqColours(); - seqColoursReady = true; - redrawneeded = true; - repaint(); - } - - public void findWidth() - { - float[] max = new float[3]; - float[] 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 (PDBChain chain : pdb.getChains()) - { - if (chain.isVisible) - { - for (Bond tmp : chain.bonds) - { - if (tmp.start[0] >= max[0]) - { - max[0] = tmp.start[0]; - } - - if (tmp.start[1] >= max[1]) - { - max[1] = tmp.start[1]; - } - - if (tmp.start[2] >= max[2]) - { - max[2] = tmp.start[2]; - } - - if (tmp.start[0] <= min[0]) - { - min[0] = tmp.start[0]; - } - - if (tmp.start[1] <= min[1]) - { - min[1] = tmp.start[1]; - } - - if (tmp.start[2] <= min[2]) - { - min[2] = tmp.start[2]; - } - - if (tmp.end[0] >= max[0]) - { - max[0] = tmp.end[0]; - } - - if (tmp.end[1] >= max[1]) - { - max[1] = tmp.end[1]; - } - - if (tmp.end[2] >= max[2]) - { - max[2] = tmp.end[2]; - } - - if (tmp.end[0] <= min[0]) - { - min[0] = tmp.end[0]; - } - - if (tmp.end[1] <= min[1]) - { - min[1] = tmp.end[1]; - } - - if (tmp.end[2] <= min[2]) - { - min[2] = tmp.end[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] = 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; - int width; - int height; - - if (getWidth() != 0) - { - width = getWidth(); - height = getHeight(); - } - else - { - width = prefsize.width; - height = prefsize.height; - } - - if (width < height) - { - dim = width; - } - else - { - dim = height; - } - - return (float) (dim / (1.5d * maxwidth)); - } - - public void findCentre() - { - float xtot = 0; - float ytot = 0; - float ztot = 0; - - int bsize = 0; - - // Find centre coordinate - for (PDBChain chain : pdb.getChains()) - { - if (chain.isVisible) - { - bsize += chain.bonds.size(); - - for (Bond bond : chain.bonds) - { - xtot = xtot + bond.start[0] + bond.end[0]; - ytot = ytot + bond.start[1] + bond.end[1]; - ztot = ztot + bond.start[2] + bond.end[2]; - } - } - } - - centre[0] = xtot / (2 * (float) bsize); - centre[1] = ytot / (2 * (float) bsize); - centre[2] = ztot / (2 * (float) bsize); - } - - @Override - public void paintComponent(Graphics g) - { - super.paintComponent(g); - - 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); - return; - } - - // Only create the image at the beginning - - // this saves much memory usage - if ((img == null) || (prefsize.width != getWidth()) - || (prefsize.height != getHeight())) - - { - prefsize.width = getWidth(); - prefsize.height = getHeight(); - - scale = findScale(); - img = createImage(prefsize.width, prefsize.height); - ig = img.getGraphics(); - Graphics2D ig2 = (Graphics2D) ig; - - ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - redrawneeded = true; - } - - if (redrawneeded) - { - drawAll(ig, prefsize.width, prefsize.height); - redrawneeded = false; - } - - g.drawImage(img, 0, 0, this); - - pdbAction = false; - } - - public void drawAll(Graphics g, int width, int height) - { - g.setColor(backgroundColour); - g.fillRect(0, 0, width, height); - drawScene(g); - drawLabels(g); - } - - public void updateSeqColours() - { - if (pdbAction) - { - return; - } - - colourBySequence(); - - redrawneeded = true; - repaint(); - } - - // This method has been taken out of PDBChain to allow - // Applet and Application specific sequence renderers to be used - void colourBySequence() - { - SequenceRenderer sr = new SequenceRenderer(ap.av); - - StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile()); - - boolean showFeatures = false; - if (ap.av.isShowSequenceFeatures()) - { - if (fr == null) - { - fr = new FeatureRenderer(ap); - } - - fr.transferSettings(ap.alignFrame.getFeatureRenderer()); - - showFeatures = true; - } - - FeatureColourFinder finder = new FeatureColourFinder(fr); - PDBChain chain; - if (bysequence && pdb != null) - { - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - chain = pdb.getChains().elementAt(ii); - - for (int i = 0; i < chain.bonds.size(); i++) - { - Bond tmp = chain.bonds.elementAt(i); - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; - if (chain != mainchain) - { - continue; - } - - for (int s = 0; s < sequence.length; s++) - { - for (int m = 0; m < mapping.length; m++) - { - if (mapping[m].getSequence() == sequence[s]) - { - int pos = mapping[m].getSeqPos(tmp.at1.resNumber) - 1; - if (pos > 0) - { - pos = sequence[s].findIndex(pos); - tmp.startCol = sr.getResidueColour(sequence[s], pos, - finder); - } - pos = mapping[m].getSeqPos(tmp.at2.resNumber) - 1; - if (pos > 0) - { - pos = sequence[s].findIndex(pos); - tmp.endCol = sr.getResidueColour(sequence[s], pos, - finder); - } - - } - } - } - } - } - } - } - - Zsort zsort; - - public void drawScene(Graphics g) - { - if (zbuffer) - { - if (zsort == null) - { - zsort = new Zsort(); - } - - zsort.sort(visiblebonds); - } - - Bond tmpBond = null; - for (int i = 0; i < visiblebonds.size(); i++) - { - tmpBond = visiblebonds.elementAt(i); - - 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)); - - xmid = (xend + xstart) / 2; - ymid = (yend + ystart) / 2; - if (depthcue && !bymolecule) - { - if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) - { - - g.setColor(tmpBond.startCol.darker().darker()); - drawLine(g, xstart, ystart, xmid, ymid); - g.setColor(tmpBond.endCol.darker().darker()); - drawLine(g, xmid, ymid, xend, yend); - - } - else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) - { - g.setColor(tmpBond.startCol.darker()); - drawLine(g, xstart, ystart, xmid, ymid); - - g.setColor(tmpBond.endCol.darker()); - drawLine(g, xmid, ymid, xend, yend); - } - else - { - g.setColor(tmpBond.startCol); - drawLine(g, xstart, ystart, xmid, ymid); - - g.setColor(tmpBond.endCol); - drawLine(g, xmid, ymid, xend, yend); - } - } - else if (depthcue && bymolecule) - { - if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) - { - g.setColor(Color.green.darker().darker()); - drawLine(g, xstart, ystart, xend, yend); - } - else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) - { - g.setColor(Color.green.darker()); - drawLine(g, xstart, ystart, xend, yend); - } - else - { - g.setColor(Color.green); - drawLine(g, xstart, ystart, xend, yend); - } - } - else if (!depthcue && !bymolecule) - { - g.setColor(tmpBond.startCol); - drawLine(g, xstart, ystart, xmid, ymid); - g.setColor(tmpBond.endCol); - drawLine(g, xmid, ymid, xend, yend); - } - else - { - drawLine(g, xstart, ystart, xend, yend); - } - - if (highlightBond1 != null && highlightBond1 == tmpBond) - { - 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()); - drawLine(g, xstart, ystart, xmid, ymid); - } - - } - - } - - public void drawLine(Graphics g, int x1, int y1, int x2, int y2) - { - if (!wire) - { - 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); - g.drawLine(x1, y1 - 1, x2, y2 - 1); - } - else - { - g.setColor(g.getColor().brighter()); - g.drawLine(x1, y1, x2, y2); - g.drawLine(x1 + 1, y1, x2 + 1, y2); - g.drawLine(x1 - 1, y1, x2 - 1, y2); - } - } - else - { - g.drawLine(x1, y1, x2, y2); - } - } - - public Dimension minimumsize() - { - return prefsize; - } - - public Dimension preferredsize() - { - return prefsize; - } - - public void keyPressed(KeyEvent evt) - { - if (evt.getKeyCode() == KeyEvent.VK_UP) - { - scale = (float) (scale * 1.1); - redrawneeded = true; - repaint(); - } - else if (evt.getKeyCode() == KeyEvent.VK_DOWN) - { - scale = (float) (scale * 0.9); - redrawneeded = true; - repaint(); - } - } - - @Override - public void mousePressed(MouseEvent e) - { - pdbAction = true; - Atom fatom = findAtom(e.getX(), e.getY()); - if (fatom != null) - { - fatom.isSelected = !fatom.isSelected; - - redrawneeded = true; - repaint(); - if (foundchain != -1) - { - PDBChain chain = pdb.getChains().elementAt(foundchain); - if (chain == mainchain) - { - if (fatom.alignmentMapping != -1) - { - if (highlightRes == null) - { - highlightRes = new Vector(); - } - - final String atomString = Integer - .toString(fatom.alignmentMapping); - if (highlightRes.contains(atomString)) - { - highlightRes.remove(atomString); - } - else - { - highlightRes.add(atomString); - } - } - } - } - - } - mx = e.getX(); - my = e.getY(); - omx = mx; - omy = my; - dragging = false; - } - - @Override - public void mouseMoved(MouseEvent e) - { - pdbAction = true; - if (highlightBond1 != null) - { - highlightBond1.at2.isSelected = false; - highlightBond2.at1.isSelected = false; - highlightBond1 = null; - highlightBond2 = null; - } - - Atom fatom = findAtom(e.getX(), e.getY()); - - PDBChain chain = null; - if (foundchain != -1) - { - chain = pdb.getChains().elementAt(foundchain); - if (chain == mainchain) - { - mouseOverStructure(fatom.resNumber, chain.id); - } - } - - if (fatom != null) - { - this.setToolTipText( - chain.id + ":" + fatom.resNumber + " " + fatom.resName); - } - else - { - mouseOverStructure(-1, chain != null ? chain.id : null); - this.setToolTipText(null); - } - } - - @Override - public void mouseClicked(MouseEvent e) - { - } - - @Override - public void mouseEntered(MouseEvent e) - { - } - - @Override - public void mouseExited(MouseEvent e) - { - } - - @Override - public void mouseDragged(MouseEvent evt) - { - int x = evt.getX(); - int y = evt.getY(); - mx = x; - my = y; - - MCMatrix objmat = new MCMatrix(3, 3); - objmat.setIdentity(); - - if ((evt.getModifiersEx() & InputEvent.META_DOWN_MASK) != 0) - { - objmat.rotatez(((mx - omx))); - } - else - { - objmat.rotatex(((my - omy))); - objmat.rotatey(((omx - mx))); - } - - // Alter the bonds - for (PDBChain chain : pdb.getChains()) - { - for (Bond tmpBond : chain.bonds) - { - // Translate the bond so the centre is 0,0,0 - tmpBond.translate(-centre[0], -centre[1], -centre[2]); - - // Now apply the rotation matrix - tmpBond.start = objmat.vectorMultiply(tmpBond.start); - tmpBond.end = objmat.vectorMultiply(tmpBond.end); - - // Now translate back again - tmpBond.translate(centre[0], centre[1], centre[2]); - } - } - - objmat = null; - - omx = mx; - omy = my; - - dragging = true; - - redrawneeded = true; - - repaint(); - } - - @Override - public void mouseReleased(MouseEvent evt) - { - dragging = false; - return; - } - - void drawLabels(Graphics g) - { - - for (PDBChain chain : pdb.getChains()) - { - if (chain.isVisible) - { - for (Bond tmpBond : chain.bonds) - { - if (tmpBond.at1.isSelected) - { - labelAtom(g, tmpBond, 1); - } - - if (tmpBond.at2.isSelected) - { - labelAtom(g, tmpBond, 2); - } - } - } - } - } - - public void labelAtom(Graphics g, Bond b, int n) - { - g.setFont(font); - 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)); - - 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)); - - g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart); - } - } - - int foundchain = -1; - - public Atom findAtom(int x, int y) - { - Atom fatom = null; - - foundchain = -1; - - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - PDBChain chain = pdb.getChains().elementAt(ii); - int truex; - Bond tmpBond = null; - - if (chain.isVisible) - { - for (Bond bond : chain.bonds) - { - tmpBond = bond; - - 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)); - - if (Math.abs(truey - y) <= 2) - { - fatom = tmpBond.at1; - foundchain = ii; - break; - } - } - } - - // Still here? Maybe its the last bond - - 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)); - - if (Math.abs(truey - y) <= 2) - { - fatom = tmpBond.at2; - foundchain = ii; - break; - } - } - - } - - if (fatom != null) // )&& chain.ds != null) - { // dead code? value of chain is either overwritten or discarded - chain = pdb.getChains().elementAt(foundchain); - } - } - - return fatom; - } - - Bond highlightBond1, highlightBond2; - - public void highlightRes(int ii) - { - if (!seqColoursReady) - { - return; - } - - if (highlightRes != null && highlightRes.contains((ii - 1) + "")) - { - return; - } - - int index = -1; - Bond tmpBond; - for (index = 0; index < mainchain.bonds.size(); index++) - { - tmpBond = mainchain.bonds.elementAt(index); - if (tmpBond.at1.alignmentMapping == ii - 1) - { - if (highlightBond1 != null) - { - highlightBond1.at2.isSelected = false; - } - - if (highlightBond2 != null) - { - highlightBond2.at1.isSelected = false; - } - - highlightBond1 = null; - highlightBond2 = null; - - if (index > 0) - { - highlightBond1 = mainchain.bonds.elementAt(index - 1); - highlightBond1.at2.isSelected = true; - } - - if (index != mainchain.bonds.size()) - { - highlightBond2 = mainchain.bonds.elementAt(index); - highlightBond2.at1.isSelected = true; - } - - break; - } - } - - redrawneeded = true; - repaint(); - } - - public void setAllchainsVisible(boolean b) - { - for (int ii = 0; ii < pdb.getChains().size(); ii++) - { - PDBChain chain = pdb.getChains().elementAt(ii); - chain.isVisible = b; - } - mainchain.isVisible = true; - findCentre(); - setupBonds(); - } - - // //////////////////////////////// - // /StructureListener - @Override - public String[] getStructureFiles() - { - return new String[] { pdbentry.getFile() }; - } - - String lastMessage; - - public void mouseOverStructure(int pdbResNum, String chain) - { - if (lastMessage == null || !lastMessage.equals(pdbResNum + chain)) - { - ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile()); - } - - lastMessage = pdbResNum + chain; - } - - StringBuffer resetLastRes = new StringBuffer(); - - StringBuffer eval = new StringBuffer(); - - /** - * Highlight the specified atoms in the structure. - * - * @param atoms - */ - @Override - public void highlightAtoms(List atoms) - { - if (!seqColoursReady) - { - return; - } - - for (AtomSpec atom : atoms) - { - int atomIndex = atom.getAtomIndex(); - if (highlightRes != null - && highlightRes.contains((atomIndex - 1) + "")) - { - continue; - } - - highlightAtom(atomIndex); - } - - redrawneeded = true; - repaint(); - } - - /** - * Highlight the atom at the specified index. - * - * @param atomIndex - */ - protected void highlightAtom(int atomIndex) - { - int index = -1; - Bond tmpBond; - for (index = 0; index < mainchain.bonds.size(); index++) - { - tmpBond = mainchain.bonds.elementAt(index); - if (tmpBond.at1.atomIndex == atomIndex) - { - if (highlightBond1 != null) - { - highlightBond1.at2.isSelected = false; - } - - if (highlightBond2 != null) - { - highlightBond2.at1.isSelected = false; - } - - highlightBond1 = null; - highlightBond2 = null; - - if (index > 0) - { - highlightBond1 = mainchain.bonds.elementAt(index - 1); - highlightBond1.at2.isSelected = true; - } - - if (index != mainchain.bonds.size()) - { - highlightBond2 = mainchain.bonds.elementAt(index); - highlightBond2.at1.isSelected = true; - } - - break; - } - } - } - - public Color getColour(int atomIndex, int pdbResNum, String chain, - String pdbfile) - { - return Color.white; - // if (!pdbfile.equals(pdbentry.getFile())) - // return null; - - // return new Color(viewer.getAtomArgb(atomIndex)); - } - - @Override - public void updateColours(Object source) - { - colourBySequence(); - redrawneeded = true; - repaint(); - } - - @Override - public void releaseReferences(Object svl) - { - // TODO Auto-generated method stub - - } + - @Override - public boolean isListeningFor(SequenceI seq) - { - if (sequence != null) - { - for (SequenceI s : sequence) - { - if (s == seq) - { - return true; - } - } - } - return false; - } + } diff --cc src/jalview/appletgui/EmbmenuFrame.java index b6b81fa,7b489ea..0edb8c0 --- a/src/jalview/appletgui/EmbmenuFrame.java +++ b/src/jalview/appletgui/EmbmenuFrame.java @@@ -51,8 -49,8 +51,9 @@@ import java.util.Map * @author Jim Procter and Andrew Waterhouse * */ +@SuppressWarnings("serial") - public class EmbmenuFrame extends Frame implements MouseListener + public class EmbmenuFrame extends Frame + implements MouseListener, AutoCloseable { protected static final Font FONT_ARIAL_PLAIN_11 = new Font("Arial", Font.PLAIN, 11); diff --cc src/jalview/appletgui/OverviewPanel.java index 4e69399,8f72260..ddb49f1 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@@ -142,10 -140,10 +142,10 @@@ public class OverviewPanel extends Pane @Override public void mousePressed(MouseEvent evt) { - if ((evt.getModifiers() - & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if ((evt.getModifiersEx() + & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { - if (!Platform.isAMac()) + if (!Platform.isMac()) // BH was excluding JavaScript { showPopupMenu(evt); } @@@ -187,32 -185,32 +187,36 @@@ @Override public void mouseDragged(MouseEvent evt) { - if (Platform.isWinRightButton(evt)) - if ((evt.getModifiersEx() - & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) ++ if (Platform.isWinRightButton(evt)) { - showPopupMenu(evt); - return; - if (!Platform.isAMac()) ++ if ((evt.getModifiersEx() ++ & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) + { - showPopupMenu(evt); ++ showPopupMenu(evt); ++ return; + } } - else - { - if (draggingBox) - { - // set the mouse position as a fixed point in the box - // and drag relative to that position - od.adjustViewportFromMouse(evt.getX(), evt.getY(), - av.getAlignment().getHiddenSequences(), - av.getAlignment().getHiddenColumns()); - } - else - { - od.updateViewportFromMouse(evt.getX(), evt.getY(), - av.getAlignment().getHiddenSequences(), - av.getAlignment().getHiddenColumns()); - } - ap.paintAlignment(false, false); + + if (SwingUtilities.isRightMouseButton(evt)) + { + return; } + + if (draggingBox) + { + // set the mouse position as a fixed point in the box + // and drag relative to that position + od.adjustViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + else + { + od.updateViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + ap.paintAlignment(false, false); } /** diff --cc src/jalview/appletgui/SeqPanel.java index 32f0abb,fee68c8..5becbc1 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@@ -500,8 -499,9 +500,7 @@@ public class SeqPanel extends Panel imp // For now, ignore the mouseWheel font resizing on Macs // As the Button2_mask always seems to be true - - if ((evt.getModifiersEx() - & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK - && !av.MAC) + if (Platform.isWinMiddleButton(evt)) { mouseWheelPressed = true; return; diff --cc src/jalview/bin/Jalview.java index 694fe00,c66e63e..b245cf4 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@@ -406,30 -352,42 +425,42 @@@ public class Jalvie if (!headless) { - desktop = new Desktop(); + desktop = new Desktop() +// { +// // BH testing +// @Override +// protected void processEvent(AWTEvent e) { +// System.out.println("Jalview.java " + e); +// super.processEvent(e); +// } +// } + ; desktop.setInBatchMode(true); // indicate we are starting up + + try + { + JalviewTaskbar.setTaskbar(this); + } catch (Exception e) + { + e.printStackTrace(); + } catch (Throwable t) + { + t.printStackTrace(); + } + desktop.setVisible(true); - desktop.startServiceDiscovery(); - if (!aparser.contains("nousagestats")) - { - startUsageStats(desktop); - } - else - { - System.err.println("CMD [-nousagestats] executed successfully!"); - } - if (!aparser.contains("noquestionnaire")) + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + */ { - String url = aparser.getValue("questionnaire"); - if (url != null) + desktop.startServiceDiscovery(); + if (!aparser.contains("nousagestats")) { - // Start the desktop questionnaire prompter with the specified - // questionnaire - Cache.log.debug("Starting questionnaire url at " + url); - desktop.checkForQuestionnaire(url); - System.out.println( - "CMD questionnaire[-" + url + "] executed successfully!"); + startUsageStats(desktop); } else { diff --cc src/jalview/ext/ensembl/EnsemblMap.java index add71b3,b1c9d86..e9f1af1 --- a/src/jalview/ext/ensembl/EnsemblMap.java +++ b/src/jalview/ext/ensembl/EnsemblMap.java @@@ -14,10 -13,24 +14,22 @@@ import java.util.ArrayList import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Map; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; + /** + * A client for the Ensembl REST service /map endpoint, to convert from + * coordinates of one genome assembly to another. + *

+ * Note that species and assembly identifiers passed to this class must be valid + * in Ensembl. They are not case sensitive. + * + * @author gmcarstairs + * @see https://rest.ensembl.org/documentation/info/assembly_map + * @see https://rest.ensembl.org/info/assembly/human?content-type=text/xml + * @see https://rest.ensembl.org/info/species?content-type=text/xml + */ public class EnsemblMap extends EnsemblRestClient { private static final String MAPPED = "mapped"; diff --cc src/jalview/ext/paradise/Annotate3D.java index 3b7044b,b8ba847..3c443de --- a/src/jalview/ext/paradise/Annotate3D.java +++ b/src/jalview/ext/paradise/Annotate3D.java @@@ -159,84 -154,19 +159,17 @@@ public class Annotate3 public static Iterator processJsonResponseFor(Reader respons) throws Exception { - // BH 2019 never called? - org.json.simple.parser.JSONParser jp = new org.json.simple.parser.JSONParser(); try { - final JSONArray responses = (JSONArray) jp.parse(respons); - final RvalsIterator rvals = new RvalsIterator(responses); - return rvals; + @SuppressWarnings("unchecked") - final Iterator rvals = ((List) JSONUtils.parse(respons)).iterator(); - return new Iterator() - { - @Override - public boolean hasNext() - { - return rvals.hasNext(); - } - - @SuppressWarnings("unchecked") - @Override - public Reader next() - { - Map val = (Map) rvals.next(); - - Object sval = null; - try - { - sval = val.get("2D"); - } catch (Exception x) - { - x.printStackTrace(); - } - ; - if (sval == null) - { - System.err.println( - "DEVELOPER WARNING: Annotate3d didn't return a '2D' tag in its response. Consider checking output of server. Response was :" - + val.toString()); - - sval = ""; - } - return new StringReader(sval.toString()); - - } - - @Override - public void remove() - { - throw new Error( - MessageManager.getString("error.not_implemented_remove")); - - } - - @Override - protected Object clone() throws CloneNotSupportedException - { - throw new CloneNotSupportedException( - MessageManager.getString("error.not_implemented_clone")); - } - - @Override - public boolean equals(Object obj) - { - return super.equals(obj); - } - - @Override - protected void finalize() throws Throwable - { - while (rvals.hasNext()) - { - rvals.next(); - } - super.finalize(); - } - }; ++ List responses = (List) JSONUtils.parse(respons); ++ return new RvalsIterator(responses); } catch (Exception foo) { throw new Exception(MessageManager.getString( "exception.couldnt_parse_responde_from_annotated3d_server"), foo); } -- } public static Iterator getRNAMLForPDBId(String pdbid) @@@ -256,3 -186,77 +189,64 @@@ } } + -class RvalsIterator implements Iterator, AutoCloseable ++class RvalsIterator implements Iterator, AutoCloseable + { - private Iterator rvals; ++ private Iterator rvals; + - protected RvalsIterator(JSONArray responses) ++ protected RvalsIterator(List responses) + { + this.rvals = responses.iterator(); + } + + @Override + public boolean hasNext() + { + return rvals.hasNext(); + } + + @Override + public Reader next() + { - JSONObject val = (JSONObject) rvals.next(); ++ Map val = (Map) rvals.next(); + + Object sval = null; + try + { + sval = val.get("2D"); + } catch (Exception x) + { + x.printStackTrace(); + } - ; + if (sval == null) + { + System.err.println( + "DEVELOPER WARNING: Annotate3d didn't return a '2D' tag in its response. Consider checking output of server. Response was :" + + val.toString()); + + sval = ""; + } - return new StringReader( - (sval instanceof JSONObject) ? ((JSONObject) sval).toString() - : sval.toString()); - ++ return new StringReader(sval.toString()); + } + + @Override + public void remove() + { - throw new Error( - MessageManager.getString("error.not_implemented_remove")); - ++ throw new UnsupportedOperationException(); + } + + @Override + protected Object clone() throws CloneNotSupportedException + { - throw new CloneNotSupportedException( - MessageManager.getString("error.not_implemented_clone")); - } - - @Override - public boolean equals(Object obj) - { - return super.equals(obj); ++ throw new UnsupportedOperationException(); + } + + @Override + public void close() + { + while (rvals.hasNext()) + { + rvals.next(); + } + } + } diff --cc src/jalview/gui/APQHandlers.java index 0000000,31f7a6d..3706cba mode 000000,100644..100644 --- a/src/jalview/gui/APQHandlers.java +++ b/src/jalview/gui/APQHandlers.java @@@ -1,0 -1,150 +1,150 @@@ + package jalview.gui; + + import jalview.util.MessageManager; + import jalview.util.Platform; + + import java.awt.Desktop; + import java.awt.desktop.AboutEvent; + import java.awt.desktop.AboutHandler; + import java.awt.desktop.PreferencesEvent; + import java.awt.desktop.PreferencesHandler; + import java.awt.desktop.QuitEvent; + import java.awt.desktop.QuitHandler; + import java.awt.desktop.QuitResponse; + import java.awt.desktop.QuitStrategy; + + import javax.swing.JOptionPane; + + public class APQHandlers + { + private static boolean setAPQHandlers = false; + + public APQHandlers() { + } + + protected static boolean setAPQHandlers(jalview.gui.Desktop jalviewDesktop) + { + // flagging this test to avoid unnecessary reflection + if (!setAPQHandlers) + { + // see if the Quit, About and Preferences handlers are available + Class desktopClass = Desktop.class; + Desktop hdesktop = Desktop.getDesktop(); + + try + { + Float specversion = Float.parseFloat( + System.getProperty("java.specification.version")); + + if (specversion >= 9) + { - if (Platform.isAMac()) ++ if (Platform.isMac()) + { + if (desktopClass.getDeclaredMethod("setAboutHandler", + new Class[] + { AboutHandler.class }) != null) + { + + hdesktop.setAboutHandler(new AboutHandler() + { + @Override + public void handleAbout(AboutEvent e) + { + jalviewDesktop.aboutMenuItem_actionPerformed(null); + } + }); + + } + + if (desktopClass.getDeclaredMethod("setPreferencesHandler", + new Class[] + { PreferencesHandler.class }) != null) + { + + hdesktop.setPreferencesHandler( + new PreferencesHandler() + { + @Override + public void handlePreferences( + PreferencesEvent e) + { + jalviewDesktop.preferences_actionPerformed(null); + } + }); + + } + + if (desktopClass.getDeclaredMethod("setQuitHandler", + new Class[] + { QuitHandler.class }) != null) + { + + hdesktop.setQuitHandler(new QuitHandler() + { + @Override + public void handleQuitRequestWith( + QuitEvent e, QuitResponse r) + { + boolean confirmQuit = jalview.bin.Cache + .getDefault(jalviewDesktop.CONFIRM_KEYBOARD_QUIT, + true); + int n; + if (confirmQuit) + { + n = JOptionPane.showConfirmDialog(null, + MessageManager.getString("label.quit_jalview"), + MessageManager.getString("action.quit"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.PLAIN_MESSAGE, null); + } + else + { + n = JOptionPane.OK_OPTION; + } + if (n == JOptionPane.OK_OPTION) + { + System.out.println("Shortcut Quit confirmed by user"); + jalviewDesktop.quit(); + r.performQuit(); // probably won't reach this line, but just + // in + // case + } + else + { + r.cancelQuit(); + System.out.println("Shortcut Quit cancelled by user"); + } + } + }); + hdesktop.setQuitStrategy( + QuitStrategy.CLOSE_ALL_WINDOWS); + + } + } + setAPQHandlers = true; + } + else + { + System.out.println( + "Not going to try setting APQ Handlers as java.spec.version is " + + specversion); + } + + } catch (Exception e) + { + System.out.println( + "Exception when looking for About, Preferences, Quit Handlers"); + e.printStackTrace(); + } catch (Throwable t) + { + System.out.println( + "Throwable when looking for About, Preferences, Quit Handlers"); + t.printStackTrace(); + } + + } + + return setAPQHandlers; + } + + } diff --cc src/jalview/gui/AlignFrame.java index 27a0f76,0ab7515..1b09868 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@@ -1249,80 -1168,94 +1249,79 @@@ public class AlignFrame extends GAlignF statusBar.setText(MessageManager.formatMessage( "label.successfully_saved_to_file_in_format", new Object[] { fileName, format })); - + + return; } - else + + AlignExportSettingsI options = new AlignExportSettingsAdapter(false); + Runnable cancelAction = new Runnable() { - AlignmentExportData exportData = getAlignmentForExport(format, - viewport, null); - if (exportData.getSettings().isCancelled()) - { - return false; - } - FormatAdapter f = new FormatAdapter(alignPanel, - exportData.getSettings()); - String output = f.formatSequences(format, exportData.getAlignment(), // class - // cast - // exceptions - // will - // occur in the distant future - exportData.getOmitHidden(), exportData.getStartEndPostions(), - f.getCacheSuffixDefault(format), - viewport.getAlignment().getHiddenColumns()); - - if (output == null) + @Override + public void run() { - success = false; + lastSaveSuccessful = false; } - else + }; + Runnable outputAction = new Runnable() + { + @Override + public void run() { - // create backupfiles object and get new temp filename destination - BackupFiles backupfiles = new BackupFiles(file); - - try + // todo defer this to inside formatSequences (or later) + AlignmentExportData exportData = viewport + .getAlignExportData(options); + String output = new FormatAdapter(alignPanel, options) + .formatSequences(format, exportData.getAlignment(), + exportData.getOmitHidden(), + exportData.getStartEndPostions(), + viewport.getAlignment().getHiddenColumns()); + if (output == null) { - PrintWriter out = new PrintWriter( - new FileWriter(backupfiles.getTempFilePath())); - - // TESTING code here - boolean TESTING = true; - if (TESTING) + lastSaveSuccessful = false; + } + else + { + // create backupfiles object and get new temp filename destination + boolean doBackup = BackupFiles.getEnabled(); + BackupFiles backupfiles = doBackup ? new BackupFiles(file) : null; + try { - out.print("; TESTSTART\n"); - int count = 20; - for (int i = 0; i < count; i++) - { - // Thread.sleep(1000); - out.println("; TEST: " + (count - 1 - i)); - } + String tempFilePath = doBackup ? backupfiles.getTempFilePath() : file; + PrintWriter out = new PrintWriter( + new FileWriter(tempFilePath)); - + out.print(output); + out.close(); + AlignFrame.this.setTitle(file); + statusBar.setText(MessageManager.formatMessage( + "label.successfully_saved_to_file_in_format", new Object[] + { fileName, format.getName() })); + lastSaveSuccessful = true; + } catch (Exception ex) + { + lastSaveSuccessful = false; + ex.printStackTrace(); } - out.print(output); - if (TESTING) + + if (doBackup) { - out.print("; TESTEND\n"); + backupfiles.setWriteSuccess(lastSaveSuccessful); + // do the backup file roll and rename the temp file to actual file + lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile(); } - out.close(); - this.setTitle(file); - statusBar.setText(MessageManager.formatMessage( - "label.successfully_saved_to_file_in_format", new Object[] - { fileName, format.getName() })); - } catch (Exception ex) - { - success = false; - ex.printStackTrace(); } - - backupfiles.setWriteSuccess(success); - // do the backup file roll and rename the temp file to actual file - success = backupfiles.rollBackupsAndRenameTempFile(); - } - } - - if (!success) - { - JvOptionPane.showInternalMessageDialog(this, MessageManager - .formatMessage("label.couldnt_save_file", new Object[] - { fileName }), - MessageManager.getString("label.error_saving_file"), - JvOptionPane.WARNING_MESSAGE); - } + }; - return success; - } - - private void warningMessage(String warning, String title) - { - if (new jalview.util.Platform().isHeadless()) + /* + * show dialog with export options if applicable; else just do it + */ + if (AlignExportOptions.isNeeded(viewport, format)) { - System.err.println("Warning: " + title + "\nWarning: " + warning); - + AlignExportOptions choices = new AlignExportOptions( + alignPanel.getAlignViewport(), format, options); + choices.setResponseAction(0, outputAction); + choices.setResponseAction(1, cancelAction); + choices.showDialog(); } else { diff --cc src/jalview/gui/Desktop.java index cd8330a,41cbad8..e6d7a15 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@@ -366,9 -391,9 +404,10 @@@ public class Desktop extends jalview.jb boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE", false); desktop = new MyDesktopPane(selmemusage); + showMemusage.setSelected(selmemusage); desktop.setBackground(Color.white); + getContentPane().setLayout(new BorderLayout()); // alternate config - have scrollbars - see notes in JAL-153 // JScrollPane sp = new JScrollPane(); @@@ -401,86 -419,41 +440,92 @@@ else { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - setBounds((screenSize.width - 900) / 2, (screenSize.height - 650) / 2, - 900, 650); - } - jconsole = new Console(this, showjconsole); - // add essential build information - jconsole.setHeader( - "Jalview Version: " + jalview.bin.Cache.getProperty("VERSION") - + "\n" + "Jalview Installation: " - + jalview.bin.Cache.getDefault("INSTALLATION", - "unknown") - + "\n" + "Build Date: " - + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") - + "\n" + "Java version: " - + System.getProperty("java.version") + "\n" - + System.getProperty("os.arch") + " " - + System.getProperty("os.name") + " " - + System.getProperty("os.version") - + (jalview.bin.Cache.getProperty("VERSION").equals("DEVELOPMENT") - ? "\nJava path:" - + System.getProperty( - "java.home") - + File.separator + "bin" - + File.separator + "java" - : "") - ); - - showConsole(showjconsole); - - showNews.setVisible(false); - - experimentalFeatures.setSelected(showExperimental()); - - getIdentifiersOrgData(); - - checkURLLinks(); + int xPos = Math.max(5, (screenSize.width - 900) / 2); + int yPos = Math.max(5, (screenSize.height - 650) / 2); + setBounds(xPos, yPos, 900, 650); + } + + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + */ + { + + jconsole = new Console(this, showjconsole); + // add essential build information + jconsole.setHeader("Jalview Version: " + + jalview.bin.Cache.getProperty("VERSION") + "\n" + + "Jalview Installation: " + + jalview.bin.Cache.getDefault("INSTALLATION", "unknown") + + "\n" + "Build Date: " + + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n" + + "Java version: " + System.getProperty("java.version") + "\n" + + System.getProperty("os.arch") + " " + + System.getProperty("os.name") + " " - + System.getProperty("os.version")); ++ + System.getProperty("os.version") ++ + (jalview.bin.Cache.getProperty("VERSION").equals("DEVELOPMENT") ++ ? "\nJava path:" ++ + System.getProperty( ++ "java.home") ++ + File.separator + "bin" ++ + File.separator + "java" ++ : "")); + + showConsole(showjconsole); + + showNews.setVisible(false); + + experimentalFeatures.setSelected(showExperimental()); + + getIdentifiersOrgData(); + + checkURLLinks(); + + // Spawn a thread that shows the splashscreen + + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + new SplashScreen(); + } + }); + + // Thread off a new instance of the file chooser - this reduces the time - // it - // takes to open it later on. ++ // it takes to open it later on. + new Thread(new Runnable() + { + @Override + public void run() + { + Cache.log.debug("Filechooser init thread started."); + String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); + JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"), + fileFormat); + Cache.log.debug("Filechooser init thread finished."); + } + }).start(); + // Add the service change listener + changeSupport.addJalviewPropertyChangeListener("services", + new PropertyChangeListener() + { + + @Override + public void propertyChange(PropertyChangeEvent evt) + { + Cache.log.debug("Firing service changed event for " + + evt.getNewValue()); + JalviewServicesChanged(evt); + } + + }); + + } + + this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); this.addWindowListener(new WindowAdapter() { @@@ -589,7 -602,7 +634,7 @@@ } } }).start(); -- ; ++ } @Override @@@ -940,7 -956,7 +985,7 @@@ menuItem.removeActionListener(menuItem.getActionListeners()[0]); } windowMenu.remove(menuItem); -- }; ++ } }); menuItem.addActionListener(new ActionListener() @@@ -2342,7 -2317,7 +2389,7 @@@ }); rthr.start(); } -- }; ++ } }); VamsasStMenu.add(sessit); } @@@ -3239,7 -3212,7 +3286,6 @@@ } catch (InterruptedException x) { } -- ; } if (instance == null) { @@@ -3527,7 -3469,7 +3573,6 @@@ System.err.println( "Please ignore plist error - occurs due to problem with java 8 on OSX"); } -- ; } } catch (Throwable ex) { diff --cc src/jalview/gui/FeatureTypeSettings.java index 735e514,a2194f4..80861ac --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@@ -1443,11 -1419,9 +1443,12 @@@ public class FeatureTypeSettings extend || (pattern != null && pattern.trim().length() > 0)) { JButton removeCondition = new JButton("\u2717"); // Dingbats cursive x + removeCondition.setBorder(new EmptyBorder(0, 0, 0, 0)); + removeCondition.setBackground(Color.WHITE); + removeCondition.setPreferredSize(new Dimension(23, 17)); - removeCondition - .setToolTipText(MessageManager.getString("label.delete_row")); + removeCondition.setToolTipText( + MessageManager.getString("label.delete_condition")); + removeCondition.setBorder(new EmptyBorder(0, 0, 0, 0)); removeCondition.addActionListener(new ActionListener() { @Override diff --cc src/jalview/jbgui/GDesktop.java index 2ea3774,fe85043..4e01b25 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@@ -452,18 -448,15 +453,18 @@@ public class GDesktop extends JFram VamsasMenu.add(vamsasImport); VamsasMenu.add(vamsasSave); VamsasMenu.add(vamsasStop); - toolsMenu.add(preferences); - if (!Platform.isJS()) - if (!Platform.isAMac() || specversion < 11) ++ if (!Platform.isMac() || specversion < 11) { - toolsMenu.add(showMemusage); - toolsMenu.add(showConsole); + toolsMenu.add(preferences); } - toolsMenu.add(showMemusage); - toolsMenu.add(showConsole); - toolsMenu.add(showNews); - toolsMenu.add(garbageCollect); - toolsMenu.add(groovyShell); + if (!Platform.isJS()) + { ++ toolsMenu.add(showMemusage); ++ toolsMenu.add(showConsole); + toolsMenu.add(showNews); + toolsMenu.add(garbageCollect); + toolsMenu.add(groovyShell); + } toolsMenu.add(experimentalFeatures); // toolsMenu.add(snapShotWindow); inputMenu.add(inputLocalFileMenuItem); diff --cc src/jalview/project/Jalview2XML.java index 4d772a1,0d2ec68..5618529 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@@ -1672,7 -1659,6 +1672,7 @@@ public class Jalview2XM // using save and then load try { - fileName = fileName.replace('\\', '/'); ++ fileName = fileName.replace('\\', '/'); System.out.println("Writing jar entry " + fileName); JarEntry entry = new JarEntry(fileName); jout.putNextEntry(entry); @@@ -2771,52 -2755,44 +2771,52 @@@ return af; } - @SuppressWarnings("unused") - private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException { - private jarInputStreamProvider createjarInputStreamProvider( - final String file) throws MalformedURLException - { - URL url = null; - errorMessage = null; - uniqueSetSuffix = null; - seqRefIds = null; - viewportsAdded.clear(); - frefedSequence = null; - - if (file.startsWith("http://")) - { - url = new URL(file); - } - final URL _url = url; - return new jarInputStreamProvider() - { - - @Override - public JarInputStream getJarInputStream() throws IOException - { - if (_url != null) - { - return new JarInputStream(_url.openStream()); - } - else - { - return new JarInputStream(new FileInputStream(file)); ++ @SuppressWarnings("unused") ++ private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException { + - // BH 2018 allow for bytes already attached to File object - try { - String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); ++ // BH 2018 allow for bytes already attached to File object ++ try { ++ String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); + byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile) + : null; - URL url = null; - errorMessage = null; - uniqueSetSuffix = null; - seqRefIds = null; - viewportsAdded.clear(); - frefedSequence = null; - - if (file.startsWith("http://")) { - url = new URL(file); - } - final URL _url = url; - return new jarInputStreamProvider() { - - @Override - public JarInputStream getJarInputStream() throws IOException { - if (bytes != null) { - // System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length); - return new JarInputStream(new ByteArrayInputStream(bytes)); - } - if (_url != null) { - // System.out.println("Jalview2XML: opening url jarInputStream for " + _url); - return new JarInputStream(_url.openStream()); - } else { - // System.out.println("Jalview2XML: opening file jarInputStream for " + file); - return new JarInputStream(new FileInputStream(file)); - } - } - - @Override - public String getFilename() { - return file; - } - }; - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } ++ URL url = null; ++ errorMessage = null; ++ uniqueSetSuffix = null; ++ seqRefIds = null; ++ viewportsAdded.clear(); ++ frefedSequence = null; ++ ++ if (file.startsWith("http://")) { ++ url = new URL(file); ++ } ++ final URL _url = url; ++ return new jarInputStreamProvider() { ++ ++ @Override ++ public JarInputStream getJarInputStream() throws IOException { ++ if (bytes != null) { ++// System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length); ++ return new JarInputStream(new ByteArrayInputStream(bytes)); ++ } ++ if (_url != null) { ++// System.out.println("Jalview2XML: opening url jarInputStream for " + _url); ++ return new JarInputStream(_url.openStream()); ++ } else { ++// System.out.println("Jalview2XML: opening file jarInputStream for " + file); ++ return new JarInputStream(new FileInputStream(file)); ++ } ++ } ++ ++ @Override ++ public String getFilename() { ++ return file; ++ } ++ }; ++ } catch (IOException e) { ++ e.printStackTrace(); ++ return null; ++ } + } - } - - @Override - public String getFilename() - { - return file; - } - }; - } /** * Recover jalview session from a jalview project archive. Caller may @@@ -4855,18 -4839,7 +4855,18 @@@ { AlignFrame af = null; af = new AlignFrame(al, safeInt(view.getWidth()), - safeInt(view.getHeight()), uniqueSeqSetId, viewId); + safeInt(view.getHeight()), uniqueSeqSetId, viewId) +// { - // - // @Override - // protected void processKeyEvent(java.awt.event.KeyEvent e) { - // System.out.println("Jalview2XML AF " + e); - // super.processKeyEvent(e); - // - // } - // ++// ++// @Override ++// protected void processKeyEvent(java.awt.event.KeyEvent e) { ++// System.out.println("Jalview2XML AF " + e); ++// super.processKeyEvent(e); ++// ++// } ++// +// } + ; af.setFileName(file, FileFormat.Jalview); diff --cc src/jalview/util/Platform.java index f9eb2a6,c1d8228..bf0dfcd --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@@ -177,438 -122,41 +169,463 @@@ public class Platfor */ protected static boolean isControlDown(MouseEvent e, boolean aMac) { - if (!aMac) - { - return e.isControlDown(); - } - // answer false for right mouse button - // shortcut key will be META for a Mac - return !e.isPopupTrigger() - && (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() - & e.getModifiers()) != 0; - // could we use e.isMetaDown() here? - } - if (aMac) ++ if (aMac) ++ { ++ /* ++ * answer false for right mouse button ++ */ ++ if (e.isPopupTrigger()) ++ { ++ return false; ++ } ++ return (jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx() // .getMenuShortcutKeyMaskEx() ++ & e.getModifiersEx()) != 0; // getModifiers()) != 0; ++ } ++ return e.isControlDown(); ++ } + + // BH: I don't know about that previous method. Here is what SwingJS uses. + // Notice the distinction in mouse events. (BUTTON3_MASK == META) + // + // private static boolean isPopupTrigger(int id, int mods, boolean isWin) { + // boolean rt = ((mods & InputEvent.BUTTON3_MASK) != 0); + // if (isWin) { + // if (id != MouseEvent.MOUSE_RELEASED) + // return false; + //// + //// // Oddly, Windows returns InputEvent.META_DOWN_MASK on release, though + //// // BUTTON3_DOWN_MASK for pressed. So here we just accept both. + //// + //// actually, we can use XXX_MASK, not XXX_DOWN_MASK and avoid this issue, + // because + //// J2S adds the appropriate extended (0x3FC0) and simple (0x3F) modifiers. + //// + // return rt; + // } else { + // // mac, linux, unix + // if (id != MouseEvent.MOUSE_PRESSED) + // return false; + // boolean lt = ((mods & InputEvent.BUTTON1_MASK) != 0); + // boolean ctrl = ((mods & InputEvent.CTRL_MASK) != 0); + // return rt || (ctrl && lt); + // } + // } + // + + /** + * Windows (not Mac, Linux, or Unix) and right button to test for the + * right-mouse pressed event in Windows that would have opened a menu or a + * Mac. + * + * @param e + * @return + */ + public static boolean isWinRightButton(MouseEvent e) + { + // was !isAMac(), but that is true also for Linux and Unix and JS, + + return isWin() && SwingUtilities.isRightMouseButton(e); + } + + /** + * Windows (not Mac, Linux, or Unix) and middle button -- for mouse wheeling + * without pressing the button. + * + * @param e + * @return + */ + public static boolean isWinMiddleButton(MouseEvent e) + { + // was !isAMac(), but that is true also for Linux and Unix and JS + return isWin() && SwingUtilities.isMiddleMouseButton(e); + } + + public static boolean allowMnemonics() + { + return !isMac(); + } + + public final static int TIME_RESET = 0; + + public final static int TIME_MARK = 1; + + public static final int TIME_SET = 2; + + public static final int TIME_GET = 3; + + public static long time, mark, set, duration; + + public static void timeCheck(String msg, int mode) + { + long t = System.currentTimeMillis(); + switch (mode) { - /* - * answer false for right mouse button - */ - if (e.isPopupTrigger()) + case TIME_RESET: + time = mark = t; + if (msg != null) + { + System.err.println("Platform: timer reset\t\t\t" + msg); + } + break; + case TIME_MARK: + if (set > 0) + { + duration += (t - set); + } + else { - return false; + if (time == 0) + { + time = mark = t; + } + if (msg != null) + { + System.err.println("Platform: timer mark\t" + ((t - time) / 1000f) + + "\t" + ((t - mark) / 1000f) + "\t" + msg); + } + mark = t; } - return (jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx() // .getMenuShortcutKeyMaskEx() - & e.getModifiersEx()) != 0; // getModifiers()) != 0; + break; + case TIME_SET: + set = t; + break; + case TIME_GET: + if (msg != null) + { + System.err.println("Platform: timer dur\t" + ((t - time) / 1000f) + + "\t" + ((duration) / 1000f) + "\t" + msg); + } + set = 0; + break; } - return e.isControlDown(); + } + + public static void cacheFileData(String path, Object data) + { + if (!isJS() || data == null) + { + return; + } + /** + * @j2sNative + * + * swingjs.JSUtil.cacheFileData$S$O(path, data); + * + */ + } + + public static void cacheFileData(File file) + { + byte[] data; + if (!isJS() || (data = Platform.getFileBytes(file)) == null) + { + return; + } + cacheFileData(file.toString(), data); + } + + public static byte[] getFileBytes(File f) + { + return /** @j2sNative f && f._bytes || */ + null; + } + + public static byte[] getFileAsBytes(String fileStr) + { + byte[] bytes = null; + // BH 2018 hack for no support for access-origin + /** + * @j2sNative bytes = swingjs.JSUtil.getFileAsBytes$O(fileStr) + */ + cacheFileData(fileStr, bytes); + return bytes; + } + + @SuppressWarnings("unused") + public static String getFileAsString(String url) + { + String ret = null; + /** + * @j2sNative + * + * ret = swingjs.JSUtil.getFileAsString$S(url); + * + * + */ + cacheFileData(url, ret); + return ret; + } + + public static boolean setFileBytes(File f, String urlstring) + { + if (!isJS()) + { + return false; + } + @SuppressWarnings("unused") + byte[] bytes = getFileAsBytes(urlstring); + /** + * @j2sNative f._bytes = bytes; + */ + return true; + } + + public static void addJ2SBinaryType(String ext) + { + /** + * @j2sNative + * + * J2S._binaryTypes.push("." + ext + "?"); + * + */ + } + + /** + * Encode the URI using JavaScript encodeURIComponent + * + * @param value + * @return encoded value + */ + public static String encodeURI(String value) + { + /** + * @j2sNative value = encodeURIComponent(value); + */ + return value; + } + + /** + * Open the URL using a simple window call if this is JavaScript + * + * @param url + * @return true if window has been opened + */ + public static boolean openURL(String url) + { + if (!isJS()) + { + return false; + } + /** + * @j2sNative + * + * + * window.open(url); + */ + return true; + } + + public static String getUniqueAppletID() + { + @SuppressWarnings("unused") + ThreadGroup g = Thread.currentThread().getThreadGroup(); + /** + * @j2sNative return g.html5Applet._uniqueId; + * + */ + return null; + + } + + /** + * Read the Info block for this applet. + * + * @param prefix + * "jalview_" + * @param p + * @return unique id for this applet + */ + public static void readInfoProperties(String prefix, Properties p) + { + if (!isJS()) + { + return; + } + @SuppressWarnings("unused") + ThreadGroup g = Thread.currentThread().getThreadGroup(); + String id = getUniqueAppletID(); + String key = "", value = ""; + /** + * @j2sNative var info = g.html5Applet.__Info || {}; for (var key in info) { + * if (key.indexOf(prefix) == 0) { value = "" + info[key]; + */ + + System.out.println( + "Platform id=" + id + " reading Info." + key + " = " + value); + p.put(id + "_" + key, value); + + /** + * @j2sNative + * + * + * } } + */ + } + + public static void setAjaxJSON(URL url) + { + if (isJS()) + { + JSON.setAjax(url); + } + } + + public static Object parseJSON(InputStream response) + throws IOException, ParseException + { + if (isJS()) + { + return JSON.parse(response); + } + + BufferedReader br = null; + try + { + br = new BufferedReader(new InputStreamReader(response, "UTF-8")); + return new JSONParser().parse(br); + } finally + { + if (br != null) + { + try + { + br.close(); + } catch (IOException e) + { + // ignore + } + } + } + } + + public static Object parseJSON(String json) throws ParseException + { + return (isJS() ? JSON.parse(json) + : new JSONParser().parse(json)); + } + + public static Object parseJSON(Reader r) + throws IOException, ParseException + { + if (r == null) + { + return null; + } + + if (!isJS()) + { + return new JSONParser().parse(r); + } + // Using a file reader is not currently supported in SwingJS JavaScript + + if (r instanceof FileReader) + { + throw new IOException( + "StringJS does not support FileReader parsing for JSON -- but it could..."); + } + return JSON.parse(r); + + } + + /** + * Dump the input stream to an output file. + * + * @param is + * @param outFile + * @throws IOException + * if the file cannot be created or there is a problem reading the + * input stream. + */ + public static void streamToFile(InputStream is, File outFile) + throws IOException + { + FileOutputStream fio = new FileOutputStream(outFile); + try + { + if (isJS() + && /** + * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) && + */ + true) + { + return; + } + byte[] bb = new byte[32 * 1024]; + int l; + while ((l = is.read(bb)) > 0) + { + fio.write(bb, 0, l); + } + } finally + { + fio.close(); + } + } + + /** + * Add a known domain that implements access-control-allow-origin:* + * + * These should be reviewed periodically. + * + * @param domain + * for a service that is not allowing ajax + * + * @author hansonr@stolaf.edu + * + */ + public static void addJ2SDirectDatabaseCall(String domain) + { + + if (isJS()) + { + System.out.println( + "Platform adding known access-control-allow-origin * for domain " + + domain); + /** + * @j2sNative + * + * J2S.addDirectDatabaseCall(domain); + */ + } + + } + + public static void getURLCommandArguments() + { + + /** + * Retrieve the first query field as command arguments to Jalview. Include + * only if prior to "?j2s" or "&j2s" or "#". Assign the applet's __Info.args + * element to this value. + * + * @j2sNative var a = + * decodeURI((document.location.href.replace("&","?").split("?j2s")[0] + * + "?").split("?")[1].split("#")[0]); a && + * (J2S.thisApplet.__Info.args = a.split(" ")); + */ + } + /** + * A (case sensitive) file path comparator that ignores the difference between / + * and \ + * + * @param path1 + * @param path2 + * @return + */ + public static boolean pathEquals(String path1, String path2) + { + if (path1 == null) + { + return path2 == null; + } + if (path2 == null) + { + return false; + } + String p1 = path1.replace('\\', '/'); + String p2 = path2.replace('\\', '/'); + return p1.equals(p2); + } } diff --cc src/org/jibble/epsgraphics/EpsGraphics2D.java index 313ec1c,fe6d962..fe6d962 mode 100644,100755..100644 --- a/src/org/jibble/epsgraphics/EpsGraphics2D.java +++ b/src/org/jibble/epsgraphics/EpsGraphics2D.java